13d0407baSopenharmony_ci/* 23d0407baSopenharmony_ci * Copyright (c) 2021 Rockchip Electronics Co., Ltd. 33d0407baSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 43d0407baSopenharmony_ci * you may not use this file except in compliance with the License. 53d0407baSopenharmony_ci * You may obtain a copy of the License at 63d0407baSopenharmony_ci * 73d0407baSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 83d0407baSopenharmony_ci * 93d0407baSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 103d0407baSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 113d0407baSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 123d0407baSopenharmony_ci * See the License for the specific language governing permissions and 133d0407baSopenharmony_ci * limitations under the License. 143d0407baSopenharmony_ci */ 153d0407baSopenharmony_ci 163d0407baSopenharmony_ci#ifndef __VPU_API_H__ 173d0407baSopenharmony_ci#define __VPU_API_H__ 183d0407baSopenharmony_ci 193d0407baSopenharmony_ci#include "rk_type.h" 203d0407baSopenharmony_ci 213d0407baSopenharmony_ci/** 223d0407baSopenharmony_ci * @brief rockchip media process interface 233d0407baSopenharmony_ci */ 243d0407baSopenharmony_ci 253d0407baSopenharmony_ci#define VPU_API_NOPTS_VALUE (0x8000000000000000LL) 263d0407baSopenharmony_ci 273d0407baSopenharmony_ci/* 283d0407baSopenharmony_ci * bit definition of ColorType in structure VPU_FRAME 293d0407baSopenharmony_ci */ 303d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_TYPE_MASK (0x0000ffff) 313d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_ARGB8888 (0x00000000) 323d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_ABGR8888 (0x00000001) 333d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_RGB888 (0x00000002) 343d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_RGB565 (0x00000003) 353d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_RGB555 (0x00000004) 363d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_YUV420_SEMIPLANAR (0x00000005) 373d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_YUV420_PLANAR (0x00000006) 383d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_YUV422 (0x00000007) 393d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_YUV444 (0x00000008) 403d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_YCH420 (0x00000009) 413d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_BIT_MASK (0x000f0000) 423d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_BIT_8 (0x00000000) 433d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_BIT_10 (0x00010000) 443d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_BIT_12 (0x00020000) 453d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_BIT_14 (0x00030000) 463d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_BIT_16 (0x00040000) 473d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_COLORSPACE_MASK (0x00f00000) 483d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_COLORSPACE_BT709 (0x00100000) 493d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_COLORSPACE_BT2020 (0x00200000) 503d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_DYNCRANGE_MASK (0x0f000000) 513d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_DYNCRANGE_SDR (0x00000000) 523d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR10 (0x01000000) 533d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR_HLG (0x02000000) 543d0407baSopenharmony_ci#define VPU_OUTPUT_FORMAT_DYNCRANGE_HDR_DOLBY (0x03000000) 553d0407baSopenharmony_ci 563d0407baSopenharmony_ci/** 573d0407baSopenharmony_ci * @brief input picture type 583d0407baSopenharmony_ci */ 593d0407baSopenharmony_citypedef enum { 603d0407baSopenharmony_ci ENC_INPUT_YUV420_PLANAR = 0, /**< YYYY... UUUU... VVVV */ 613d0407baSopenharmony_ci ENC_INPUT_YUV420_SEMIPLANAR = 1, /**< YYYY... UVUVUV... */ 623d0407baSopenharmony_ci ENC_INPUT_YUV422_INTERLEAVED_YUYV = 2, /**< YUYVYUYV... */ 633d0407baSopenharmony_ci ENC_INPUT_YUV422_INTERLEAVED_UYVY = 3, /**< UYVYUYVY... */ 643d0407baSopenharmony_ci ENC_INPUT_RGB565 = 4, /**< 16-bit RGB */ 653d0407baSopenharmony_ci ENC_INPUT_BGR565 = 5, /**< 16-bit RGB */ 663d0407baSopenharmony_ci ENC_INPUT_RGB555 = 6, /**< 15-bit RGB */ 673d0407baSopenharmony_ci ENC_INPUT_BGR555 = 7, /**< 15-bit RGB */ 683d0407baSopenharmony_ci ENC_INPUT_RGB444 = 8, /**< 12-bit RGB */ 693d0407baSopenharmony_ci ENC_INPUT_BGR444 = 9, /**< 12-bit RGB */ 703d0407baSopenharmony_ci ENC_INPUT_RGB888 = 10, /**< 24-bit RGB */ 713d0407baSopenharmony_ci ENC_INPUT_BGR888 = 11, /**< 24-bit RGB */ 723d0407baSopenharmony_ci ENC_INPUT_RGB101010 = 12, /**< 30-bit RGB */ 733d0407baSopenharmony_ci ENC_INPUT_BGR101010 = 13 /**< 30-bit RGB */ 743d0407baSopenharmony_ci} EncInputPictureType; 753d0407baSopenharmony_ci 763d0407baSopenharmony_citypedef enum VPU_API_CMD { 773d0407baSopenharmony_ci VPU_API_ENC_SETCFG, 783d0407baSopenharmony_ci VPU_API_ENC_GETCFG, 793d0407baSopenharmony_ci VPU_API_ENC_SETFORMAT, 803d0407baSopenharmony_ci VPU_API_ENC_SETIDRFRAME, 813d0407baSopenharmony_ci 823d0407baSopenharmony_ci VPU_API_ENABLE_DEINTERLACE, 833d0407baSopenharmony_ci VPU_API_SET_VPUMEM_CONTEXT, 843d0407baSopenharmony_ci VPU_API_USE_PRESENT_TIME_ORDER, 853d0407baSopenharmony_ci VPU_API_SET_DEFAULT_WIDTH_HEIGH, 863d0407baSopenharmony_ci VPU_API_SET_INFO_CHANGE, 873d0407baSopenharmony_ci VPU_API_USE_FAST_MODE, 883d0407baSopenharmony_ci VPU_API_DEC_GET_STREAM_COUNT, 893d0407baSopenharmony_ci VPU_API_GET_VPUMEM_USED_COUNT, 903d0407baSopenharmony_ci VPU_API_GET_FRAME_INFO, 913d0407baSopenharmony_ci VPU_API_SET_OUTPUT_BLOCK, 923d0407baSopenharmony_ci VPU_API_GET_EOS_STATUS, 933d0407baSopenharmony_ci VPU_API_SET_OUTPUT_MODE, 943d0407baSopenharmony_ci 953d0407baSopenharmony_ci VPU_API_DEC_GET_DPB_SIZE = 0X100, // add by zhanghanmeng 963d0407baSopenharmony_ci 973d0407baSopenharmony_ci /* get sps/pps header */ 983d0407baSopenharmony_ci VPU_API_GET_EXTRA_INFO = 0x200, 993d0407baSopenharmony_ci 1003d0407baSopenharmony_ci VPU_API_SET_IMMEDIATE_OUT = 0x1000, 1013d0407baSopenharmony_ci VPU_API_SET_PARSER_SPLIT_MODE, /* NOTE: should control before init */ 1023d0407baSopenharmony_ci 1033d0407baSopenharmony_ci VPU_API_ENC_VEPU22_START = 0x2000, 1043d0407baSopenharmony_ci VPU_API_ENC_SET_VEPU22_CFG, 1053d0407baSopenharmony_ci VPU_API_ENC_GET_VEPU22_CFG, 1063d0407baSopenharmony_ci VPU_API_ENC_SET_VEPU22_CTU_QP, 1073d0407baSopenharmony_ci VPU_API_ENC_SET_VEPU22_ROI, 1083d0407baSopenharmony_ci 1093d0407baSopenharmony_ci /* mlvec dynamic configure */ 1103d0407baSopenharmony_ci VPU_API_ENC_MLVEC_CFG = 0x4000, 1113d0407baSopenharmony_ci VPU_API_ENC_SET_MAX_TID, 1123d0407baSopenharmony_ci VPU_API_ENC_SET_MARK_LTR, 1133d0407baSopenharmony_ci VPU_API_ENC_SET_USE_LTR, 1143d0407baSopenharmony_ci VPU_API_ENC_SET_FRAME_QP, 1153d0407baSopenharmony_ci VPU_API_ENC_SET_BASE_LAYER_PID, 1163d0407baSopenharmony_ci} VPU_API_CMD; 1173d0407baSopenharmony_ci 1183d0407baSopenharmony_citypedef struct { 1193d0407baSopenharmony_ci unsigned int TimeLow; 1203d0407baSopenharmony_ci unsigned int TimeHigh; 1213d0407baSopenharmony_ci} TIME_STAMP; 1223d0407baSopenharmony_ci 1233d0407baSopenharmony_citypedef struct { 1243d0407baSopenharmony_ci unsigned int CodecType; 1253d0407baSopenharmony_ci unsigned int ImgWidth; 1263d0407baSopenharmony_ci unsigned int ImgHeight; 1273d0407baSopenharmony_ci unsigned int ImgHorStride; 1283d0407baSopenharmony_ci unsigned int ImgVerStride; 1293d0407baSopenharmony_ci unsigned int BufSize; 1303d0407baSopenharmony_ci} VPU_GENERIC; 1313d0407baSopenharmony_ci 1323d0407baSopenharmony_citypedef struct VPUMem { 1333d0407baSopenharmony_ci unsigned int phy_addr; 1343d0407baSopenharmony_ci unsigned int *vir_addr; 1353d0407baSopenharmony_ci unsigned int size; 1363d0407baSopenharmony_ci unsigned int *offset; 1373d0407baSopenharmony_ci} VPUMemLinear_t; 1383d0407baSopenharmony_ci 1393d0407baSopenharmony_citypedef struct tVPU_FRAME { 1403d0407baSopenharmony_ci unsigned int FrameBusAddr[2]; // 0: Y address; 1: UV address; 1413d0407baSopenharmony_ci unsigned int FrameWidth; // buffer horizontal stride 1423d0407baSopenharmony_ci unsigned int FrameHeight; // buffer vertical stride 1433d0407baSopenharmony_ci unsigned int OutputWidth; // deprecated 1443d0407baSopenharmony_ci unsigned int OutputHeight; // deprecated 1453d0407baSopenharmony_ci unsigned int DisplayWidth; // valid width for display 1463d0407baSopenharmony_ci unsigned int DisplayHeight; // valid height for display 1473d0407baSopenharmony_ci unsigned int CodingType; 1483d0407baSopenharmony_ci unsigned int FrameType; // frame; top_field_first; bot_field_first 1493d0407baSopenharmony_ci unsigned int ColorType; 1503d0407baSopenharmony_ci unsigned int DecodeFrmNum; 1513d0407baSopenharmony_ci TIME_STAMP ShowTime; 1523d0407baSopenharmony_ci unsigned int ErrorInfo; // error information 1533d0407baSopenharmony_ci unsigned int employ_cnt; 1543d0407baSopenharmony_ci VPUMemLinear_t vpumem; 1553d0407baSopenharmony_ci struct tVPU_FRAME *next_frame; 1563d0407baSopenharmony_ci union { 1573d0407baSopenharmony_ci struct { 1583d0407baSopenharmony_ci unsigned int Res0[2]; 1593d0407baSopenharmony_ci struct { 1603d0407baSopenharmony_ci unsigned int ColorPrimaries : 8; 1613d0407baSopenharmony_ci unsigned int ColorTransfer : 8; 1623d0407baSopenharmony_ci unsigned int ColorCoeffs : 8; 1633d0407baSopenharmony_ci unsigned int ColorRange : 1; 1643d0407baSopenharmony_ci unsigned int Res1 : 7; 1653d0407baSopenharmony_ci }; 1663d0407baSopenharmony_ci 1673d0407baSopenharmony_ci unsigned int Res2; 1683d0407baSopenharmony_ci }; 1693d0407baSopenharmony_ci 1703d0407baSopenharmony_ci unsigned int Res[4]; 1713d0407baSopenharmony_ci }; 1723d0407baSopenharmony_ci} VPU_FRAME; 1733d0407baSopenharmony_ci 1743d0407baSopenharmony_citypedef struct VideoPacket { 1753d0407baSopenharmony_ci RK_S64 pts; /* with unit of us */ 1763d0407baSopenharmony_ci RK_S64 dts; /* with unit of us */ 1773d0407baSopenharmony_ci unsigned char *data; 1783d0407baSopenharmony_ci signed int size; 1793d0407baSopenharmony_ci unsigned int capability; 1803d0407baSopenharmony_ci unsigned int nFlags; 1813d0407baSopenharmony_ci} VideoPacket_t; 1823d0407baSopenharmony_ci 1833d0407baSopenharmony_citypedef struct DecoderOut { 1843d0407baSopenharmony_ci unsigned char *data; 1853d0407baSopenharmony_ci unsigned int size; 1863d0407baSopenharmony_ci RK_S64 timeUs; 1873d0407baSopenharmony_ci signed int nFlags; 1883d0407baSopenharmony_ci} DecoderOut_t; 1893d0407baSopenharmony_ci 1903d0407baSopenharmony_citypedef struct ParserOut { 1913d0407baSopenharmony_ci unsigned char *data; 1923d0407baSopenharmony_ci unsigned int size; 1933d0407baSopenharmony_ci RK_S64 timeUs; 1943d0407baSopenharmony_ci unsigned int nFlags; 1953d0407baSopenharmony_ci unsigned int width; 1963d0407baSopenharmony_ci unsigned int height; 1973d0407baSopenharmony_ci} ParserOut_t; 1983d0407baSopenharmony_ci 1993d0407baSopenharmony_citypedef struct EncInputStream { 2003d0407baSopenharmony_ci unsigned char *buf; 2013d0407baSopenharmony_ci signed int size; 2023d0407baSopenharmony_ci unsigned int bufPhyAddr; 2033d0407baSopenharmony_ci RK_S64 timeUs; 2043d0407baSopenharmony_ci unsigned int nFlags; 2053d0407baSopenharmony_ci} EncInputStream_t; 2063d0407baSopenharmony_ci 2073d0407baSopenharmony_citypedef struct EncoderOut { 2083d0407baSopenharmony_ci unsigned char *data; 2093d0407baSopenharmony_ci signed int size; 2103d0407baSopenharmony_ci RK_S64 timeUs; 2113d0407baSopenharmony_ci signed int keyFrame; 2123d0407baSopenharmony_ci} EncoderOut_t; 2133d0407baSopenharmony_ci 2143d0407baSopenharmony_ci/* 2153d0407baSopenharmony_ci * @brief Enumeration used to define the possible video compression codings. 2163d0407baSopenharmony_ci * @note This essentially refers to file extensions. If the coding is 2173d0407baSopenharmony_ci * being used to specify the ENCODE type, then additional work 2183d0407baSopenharmony_ci * must be done to configure the exact flavor of the compression 2193d0407baSopenharmony_ci * to be used. For decode cases where the user application can 2203d0407baSopenharmony_ci * not differentiate between MPEG-4 and H.264 bit streams, it is 2213d0407baSopenharmony_ci * up to the codec to handle this. 2223d0407baSopenharmony_ci * 2233d0407baSopenharmony_ci * sync with the omx_video.h 2243d0407baSopenharmony_ci */ 2253d0407baSopenharmony_citypedef enum OMX_RK_VIDEO_CODINGTYPE { 2263d0407baSopenharmony_ci OMX_RK_VIDEO_CodingUnused, /**< Value when coding is N/A */ 2273d0407baSopenharmony_ci OMX_RK_VIDEO_CodingAutoDetect, /**< Autodetection of coding type */ 2283d0407baSopenharmony_ci OMX_RK_VIDEO_CodingMPEG2, /**< AKA: H.262 */ 2293d0407baSopenharmony_ci OMX_RK_VIDEO_CodingH263, /**< H.263 */ 2303d0407baSopenharmony_ci OMX_RK_VIDEO_CodingMPEG4, /**< MPEG-4 */ 2313d0407baSopenharmony_ci OMX_RK_VIDEO_CodingWMV, /**< Windows Media Video (WMV1,WMV2,WMV3)*/ 2323d0407baSopenharmony_ci OMX_RK_VIDEO_CodingRV, /**< all versions of Real Video */ 2333d0407baSopenharmony_ci OMX_RK_VIDEO_CodingAVC, /**< H.264/AVC */ 2343d0407baSopenharmony_ci OMX_RK_VIDEO_CodingMJPEG, /**< Motion JPEG */ 2353d0407baSopenharmony_ci OMX_RK_VIDEO_CodingVP8, /**< VP8 */ 2363d0407baSopenharmony_ci OMX_RK_VIDEO_CodingVP9, /**< VP9 */ 2373d0407baSopenharmony_ci OMX_RK_VIDEO_CodingVC1 = 0x01000000, /**< Windows Media Video (WMV1,WMV2,WMV3)*/ 2383d0407baSopenharmony_ci OMX_RK_VIDEO_CodingFLV1, /**< Sorenson H.263 */ 2393d0407baSopenharmony_ci OMX_RK_VIDEO_CodingDIVX3, /**< DIVX3 */ 2403d0407baSopenharmony_ci OMX_RK_VIDEO_CodingVP6, 2413d0407baSopenharmony_ci OMX_RK_VIDEO_CodingHEVC, /**< H.265/HEVC */ 2423d0407baSopenharmony_ci OMX_RK_VIDEO_CodingAVS, /**< AVS+ */ 2433d0407baSopenharmony_ci OMX_RK_VIDEO_CodingKhronosExtensions = 0x6F000000, 2443d0407baSopenharmony_ci OMX_RK_VIDEO_CodingVendorStartUnused = 0x7F000000, 2453d0407baSopenharmony_ci OMX_RK_VIDEO_CodingMax = 0x7FFFFFFF 2463d0407baSopenharmony_ci} OMX_RK_VIDEO_CODINGTYPE; 2473d0407baSopenharmony_ci 2483d0407baSopenharmony_citypedef enum CODEC_TYPE { 2493d0407baSopenharmony_ci CODEC_NONE, 2503d0407baSopenharmony_ci CODEC_DECODER, 2513d0407baSopenharmony_ci CODEC_ENCODER, 2523d0407baSopenharmony_ci CODEC_BUTT, 2533d0407baSopenharmony_ci} CODEC_TYPE; 2543d0407baSopenharmony_ci 2553d0407baSopenharmony_citypedef enum VPU_API_ERR { 2563d0407baSopenharmony_ci VPU_API_OK = 0, 2573d0407baSopenharmony_ci VPU_API_ERR_UNKNOW = -1, 2583d0407baSopenharmony_ci VPU_API_ERR_BASE = -1000, 2593d0407baSopenharmony_ci VPU_API_ERR_LIST_STREAM = VPU_API_ERR_BASE - 1, 2603d0407baSopenharmony_ci VPU_API_ERR_INIT = VPU_API_ERR_BASE - 2, 2613d0407baSopenharmony_ci VPU_API_ERR_VPU_CODEC_INIT = VPU_API_ERR_BASE - 3, 2623d0407baSopenharmony_ci VPU_API_ERR_STREAM = VPU_API_ERR_BASE - 4, 2633d0407baSopenharmony_ci VPU_API_ERR_FATAL_THREAD = VPU_API_ERR_BASE - 5, 2643d0407baSopenharmony_ci VPU_API_EOS_STREAM_REACHED = VPU_API_ERR_BASE - 11, 2653d0407baSopenharmony_ci 2663d0407baSopenharmony_ci VPU_API_ERR_BUTT, 2673d0407baSopenharmony_ci} VPU_API_ERR; 2683d0407baSopenharmony_ci 2693d0407baSopenharmony_citypedef enum VPU_FRAME_ERR { 2703d0407baSopenharmony_ci VPU_FRAME_ERR_UNKNOW = 0x0001, 2713d0407baSopenharmony_ci VPU_FRAME_ERR_UNSUPPORT = 0x0002, 2723d0407baSopenharmony_ci} VPU_FRAME_ERR; 2733d0407baSopenharmony_ci 2743d0407baSopenharmony_citypedef struct EncParameter { 2753d0407baSopenharmony_ci signed int width; 2763d0407baSopenharmony_ci signed int height; 2773d0407baSopenharmony_ci signed int rc_mode; /* 0 - CQP mode; 1 - CBR mode; 2 - FIXQP mode */ 2783d0407baSopenharmony_ci signed int bitRate; /* target bitrate */ 2793d0407baSopenharmony_ci signed int framerate; 2803d0407baSopenharmony_ci signed int qp; 2813d0407baSopenharmony_ci signed int enableCabac; 2823d0407baSopenharmony_ci signed int cabacInitIdc; 2833d0407baSopenharmony_ci signed int format; 2843d0407baSopenharmony_ci signed int intraPicRate; 2853d0407baSopenharmony_ci signed int framerateout; 2863d0407baSopenharmony_ci signed int profileIdc; 2873d0407baSopenharmony_ci signed int levelIdc; 2883d0407baSopenharmony_ci signed int reserved[3]; 2893d0407baSopenharmony_ci} EncParameter_t; 2903d0407baSopenharmony_ci 2913d0407baSopenharmony_citypedef struct EXtraCfg { 2923d0407baSopenharmony_ci signed int vc1extra_size; 2933d0407baSopenharmony_ci signed int vp6codeid; 2943d0407baSopenharmony_ci signed int tsformat; 2953d0407baSopenharmony_ci unsigned int ori_vpu; /* use origin vpu framework */ 2963d0407baSopenharmony_ci /* below used in decode */ 2973d0407baSopenharmony_ci unsigned int mpp_mode; /* use mpp framework */ 2983d0407baSopenharmony_ci unsigned int bit_depth; /* 8 or 10 bit */ 2993d0407baSopenharmony_ci unsigned int yuv_format; /* 0:420 1:422 2:444 */ 3003d0407baSopenharmony_ci unsigned int reserved[16]; 3013d0407baSopenharmony_ci} EXtraCfg_t; 3023d0407baSopenharmony_ci 3033d0407baSopenharmony_ci/** 3043d0407baSopenharmony_ci * @brief vpu function interface 3053d0407baSopenharmony_ci */ 3063d0407baSopenharmony_citypedef struct VpuCodecContext { 3073d0407baSopenharmony_ci void *vpuApiObj; 3083d0407baSopenharmony_ci 3093d0407baSopenharmony_ci CODEC_TYPE codecType; 3103d0407baSopenharmony_ci OMX_RK_VIDEO_CODINGTYPE videoCoding; 3113d0407baSopenharmony_ci 3123d0407baSopenharmony_ci unsigned int width; 3133d0407baSopenharmony_ci unsigned int height; 3143d0407baSopenharmony_ci void *extradata; 3153d0407baSopenharmony_ci signed int extradata_size; 3163d0407baSopenharmony_ci 3173d0407baSopenharmony_ci unsigned char enableparsing; 3183d0407baSopenharmony_ci 3193d0407baSopenharmony_ci signed int no_thread; 3203d0407baSopenharmony_ci EXtraCfg_t extra_cfg; 3213d0407baSopenharmony_ci 3223d0407baSopenharmony_ci void *private_data; 3233d0407baSopenharmony_ci 3243d0407baSopenharmony_ci /* 3253d0407baSopenharmony_ci ** 1: error state(not working) 0: working 3263d0407baSopenharmony_ci */ 3273d0407baSopenharmony_ci signed int decoder_err; 3283d0407baSopenharmony_ci 3293d0407baSopenharmony_ci /** 3303d0407baSopenharmony_ci * Allocate and initialize an VpuCodecContext. 3313d0407baSopenharmony_ci * 3323d0407baSopenharmony_ci * @param ctx The context of vpu api, allocated in this function. 3333d0407baSopenharmony_ci * @param extraData The extra data of codec, some codecs need / can 3343d0407baSopenharmony_ci * use extradata like Huffman tables, also live VC1 codec can 3353d0407baSopenharmony_ci * use extradata to initialize itself. 3363d0407baSopenharmony_ci * @param extra_size The size of extra data. 3373d0407baSopenharmony_ci * 3383d0407baSopenharmony_ci * @return 0 for init success, others for failure. 3393d0407baSopenharmony_ci * @note check whether ctx has been allocated success after you do init. 3403d0407baSopenharmony_ci */ 3413d0407baSopenharmony_ci signed int (*init)(struct VpuCodecContext *ctx, unsigned char *extraData, unsigned int extra_size); 3423d0407baSopenharmony_ci /** 3433d0407baSopenharmony_ci * @brief both send video stream packet to decoder and get video frame from 3443d0407baSopenharmony_ci * decoder at the same time 3453d0407baSopenharmony_ci * @param ctx The context of vpu codec 3463d0407baSopenharmony_ci * @param pkt[in] Stream to be decoded 3473d0407baSopenharmony_ci * @param aDecOut[out] Decoding frame 3483d0407baSopenharmony_ci * @return 0 for decode success, others for failure. 3493d0407baSopenharmony_ci */ 3503d0407baSopenharmony_ci signed int (*decode)(struct VpuCodecContext *ctx, VideoPacket_t *pkt, DecoderOut_t *aDecOut); 3513d0407baSopenharmony_ci /** 3523d0407baSopenharmony_ci * @brief both send video frame to encoder and get encoded video stream from 3533d0407baSopenharmony_ci * encoder at the same time. 3543d0407baSopenharmony_ci * @param ctx The context of vpu codec 3553d0407baSopenharmony_ci * @param aEncInStrm[in] Frame to be encoded 3563d0407baSopenharmony_ci * @param aEncOut[out] Encoding stream 3573d0407baSopenharmony_ci * @return 0 for encode success, others for failure. 3583d0407baSopenharmony_ci */ 3593d0407baSopenharmony_ci signed int (*encode)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm, EncoderOut_t *aEncOut); 3603d0407baSopenharmony_ci /** 3613d0407baSopenharmony_ci * @brief flush codec while do fast forward playing. 3623d0407baSopenharmony_ci * @param ctx The context of vpu codec 3633d0407baSopenharmony_ci * @return 0 for flush success, others for failure. 3643d0407baSopenharmony_ci */ 3653d0407baSopenharmony_ci signed int (*flush)(struct VpuCodecContext *ctx); 3663d0407baSopenharmony_ci signed int (*control)(struct VpuCodecContext *ctx, VPU_API_CMD cmdType, void *param); 3673d0407baSopenharmony_ci /** 3683d0407baSopenharmony_ci * @brief send video stream packet to decoder only, async interface 3693d0407baSopenharmony_ci * @param ctx The context of vpu codec 3703d0407baSopenharmony_ci * @param pkt Stream to be decoded 3713d0407baSopenharmony_ci * @return 0 for success, others for failure. 3723d0407baSopenharmony_ci */ 3733d0407baSopenharmony_ci signed int (*decode_sendstream)(struct VpuCodecContext *ctx, VideoPacket_t *pkt); 3743d0407baSopenharmony_ci /** 3753d0407baSopenharmony_ci * @brief get video frame from decoder only, async interface 3763d0407baSopenharmony_ci * @param ctx The context of vpu codec 3773d0407baSopenharmony_ci * @param aDecOut Decoding frame 3783d0407baSopenharmony_ci * @return 0 for success, others for failure. 3793d0407baSopenharmony_ci */ 3803d0407baSopenharmony_ci signed int (*decode_getframe)(struct VpuCodecContext *ctx, DecoderOut_t *aDecOut); 3813d0407baSopenharmony_ci /** 3823d0407baSopenharmony_ci * @brief send video frame to encoder only, async interface 3833d0407baSopenharmony_ci * @param ctx The context of vpu codec 3843d0407baSopenharmony_ci * @param aEncInStrm Frame to be encoded 3853d0407baSopenharmony_ci * @return 0 for success, others for failure. 3863d0407baSopenharmony_ci */ 3873d0407baSopenharmony_ci signed int (*encoder_sendframe)(struct VpuCodecContext *ctx, EncInputStream_t *aEncInStrm); 3883d0407baSopenharmony_ci /** 3893d0407baSopenharmony_ci * @brief get encoded video packet from encoder only, async interface 3903d0407baSopenharmony_ci * @param ctx The context of vpu codec 3913d0407baSopenharmony_ci * @param aEncOut Encoding stream 3923d0407baSopenharmony_ci * @return 0 for success, others for failure. 3933d0407baSopenharmony_ci */ 3943d0407baSopenharmony_ci signed int (*encoder_getstream)(struct VpuCodecContext *ctx, EncoderOut_t *aEncOut); 3953d0407baSopenharmony_ci} VpuCodecContext_t; 3963d0407baSopenharmony_ci 3973d0407baSopenharmony_ci/* allocated vpu codec context */ 3983d0407baSopenharmony_ci#ifdef __cplusplus 3993d0407baSopenharmony_ciextern "C" { 4003d0407baSopenharmony_ci#endif 4013d0407baSopenharmony_ci 4023d0407baSopenharmony_ci/** 4033d0407baSopenharmony_ci * @brief open context of vpu 4043d0407baSopenharmony_ci * @param ctx pointer of vpu codec context 4053d0407baSopenharmony_ci */ 4063d0407baSopenharmony_cisigned int vpu_open_context(struct VpuCodecContext **ctx); 4073d0407baSopenharmony_ci/** 4083d0407baSopenharmony_ci * @brief close context of vpu 4093d0407baSopenharmony_ci * @param ctx pointer of vpu codec context 4103d0407baSopenharmony_ci */ 4113d0407baSopenharmony_cisigned int vpu_close_context(struct VpuCodecContext **ctx); 4123d0407baSopenharmony_ci 4133d0407baSopenharmony_ci#ifdef __cplusplus 4143d0407baSopenharmony_ci} 4153d0407baSopenharmony_ci#endif 4163d0407baSopenharmony_ci 4173d0407baSopenharmony_ci/* 4183d0407baSopenharmony_ci * vpu_mem api 4193d0407baSopenharmony_ci */ 4203d0407baSopenharmony_ci#define vpu_display_mem_pool_FIELDS \ 4213d0407baSopenharmony_ci signed int (*commit_hdl)(vpu_display_mem_pool * p, signed int hdl, signed int size); \ 4223d0407baSopenharmony_ci void *(*get_free)(vpu_display_mem_pool * p); \ 4233d0407baSopenharmony_ci signed int (*inc_used)(vpu_display_mem_pool * p, void *hdl); \ 4243d0407baSopenharmony_ci signed int (*put_used)(vpu_display_mem_pool * p, void *hdl); \ 4253d0407baSopenharmony_ci signed int (*reset)(vpu_display_mem_pool * p); \ 4263d0407baSopenharmony_ci signed int (*get_unused_num)(vpu_display_mem_pool * p); \ 4273d0407baSopenharmony_ci signed int buff_size; \ 4283d0407baSopenharmony_ci float version; \ 4293d0407baSopenharmony_ci signed int res[18] 4303d0407baSopenharmony_ci 4313d0407baSopenharmony_citypedef struct vpu_display_mem_pool vpu_display_mem_pool; 4323d0407baSopenharmony_ci 4333d0407baSopenharmony_cistruct vpu_display_mem_pool { 4343d0407baSopenharmony_ci vpu_display_mem_pool_FIELDS; 4353d0407baSopenharmony_ci}; 4363d0407baSopenharmony_ci 4373d0407baSopenharmony_ci#ifdef __cplusplus 4383d0407baSopenharmony_ciextern "C" { 4393d0407baSopenharmony_ci#endif 4403d0407baSopenharmony_ci 4413d0407baSopenharmony_ci/* 4423d0407baSopenharmony_ci * vpu memory handle interface 4433d0407baSopenharmony_ci */ 4443d0407baSopenharmony_cisigned int VPUMemJudgeIommu(void); 4453d0407baSopenharmony_cisigned int VPUMallocLinear(VPUMemLinear_t *p, unsigned int size); 4463d0407baSopenharmony_cisigned int VPUFreeLinear(VPUMemLinear_t *p); 4473d0407baSopenharmony_cisigned int VPUMemDuplicate(VPUMemLinear_t *dst, VPUMemLinear_t *src); 4483d0407baSopenharmony_cisigned int VPUMemLink(VPUMemLinear_t *p); 4493d0407baSopenharmony_cisigned int VPUMemFlush(VPUMemLinear_t *p); 4503d0407baSopenharmony_cisigned int VPUMemClean(VPUMemLinear_t *p); 4513d0407baSopenharmony_cisigned int VPUMemInvalidate(VPUMemLinear_t *p); 4523d0407baSopenharmony_cisigned int VPUMemGetFD(VPUMemLinear_t *p); 4533d0407baSopenharmony_cisigned int VPUMallocLinearFromRender(VPUMemLinear_t *p, unsigned int size, void *ctx); 4543d0407baSopenharmony_ci 4553d0407baSopenharmony_ci/* 4563d0407baSopenharmony_ci * vpu memory allocator and manager interface 4573d0407baSopenharmony_ci */ 4583d0407baSopenharmony_civpu_display_mem_pool *open_vpu_memory_pool(void); 4593d0407baSopenharmony_civoid close_vpu_memory_pool(vpu_display_mem_pool *p); 4603d0407baSopenharmony_ciint create_vpu_memory_pool_allocator(vpu_display_mem_pool **ipool, int num, int size); 4613d0407baSopenharmony_civoid release_vpu_memory_pool_allocator(vpu_display_mem_pool *ipool); 4623d0407baSopenharmony_ci 4633d0407baSopenharmony_ci#ifdef __cplusplus 4643d0407baSopenharmony_ci} 4653d0407baSopenharmony_ci#endif 4663d0407baSopenharmony_ci 4673d0407baSopenharmony_ci#endif 468