From e54fafe8cb468fdafbae627f11586f6518d97745 Mon Sep 17 00:00:00 2001 From: "leo.ding" Date: Fri, 29 Sep 2017 10:43:38 +0800 Subject: [PATCH] [vpu_api]: add vpuCodecContext parameters a) mpp_mode: if have rkv, can set it 1 to use rkv decoder b) bit_depth: for calculate stride c) yuv_format: for setting multiplication coefficient when malloc Change-Id: Id7c32c7cac17d3c9007a0674979c2b73769ae44f Signed-off-by: leo.ding --- inc/vpu_api.h | 10 ++++++++-- mpp/legacy/vpu_api.cpp | 7 +++++-- mpp/legacy/vpu_api_legacy.cpp | 30 ++++++++++++++++++++---------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/inc/vpu_api.h b/inc/vpu_api.h index 2a08f555..9462c05f 100644 --- a/inc/vpu_api.h +++ b/inc/vpu_api.h @@ -211,7 +211,7 @@ typedef enum OMX_RK_VIDEO_CODINGTYPE { } OMX_RK_VIDEO_CODINGTYPE; typedef enum VPU_VIDEO_PIXEL_FMT { - VPU_VIDEO_PIXEL_FMT_NV12 + VPU_VIDEO_PIXEL_FMT_NV12, } VPU_VIDEO_PIXEL_FMT; typedef enum CODEC_TYPE { @@ -274,7 +274,13 @@ typedef struct EXtraCfg { RK_S32 vc1extra_size; RK_S32 vp6codeid; RK_S32 tsformat; - RK_U32 reserved[20]; + RK_U32 ori_vpu; /* use origin vpu framework */ + /* below used in decode */ + RK_U32 mpp_mode; /* use mpp framework */ + RK_U32 bit_depth; /* 8 or 10 bit */ + RK_U32 yuv_format; /* 0:420 1:422 2:444 */ + RK_U32 reserved[16]; + } EXtraCfg_t; /** diff --git a/mpp/legacy/vpu_api.cpp b/mpp/legacy/vpu_api.cpp index 5f13a163..e3a56fc4 100644 --- a/mpp/legacy/vpu_api.cpp +++ b/mpp/legacy/vpu_api.cpp @@ -300,6 +300,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx) RK_U32 height = 0; void *extradata = NULL; RK_S32 extradata_size = 0; + EXtraCfg_t extra_cfg; vpu_api_dbg_func("enter\n"); @@ -338,7 +339,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx) } else { if (s->videoCoding == OMX_RK_VIDEO_CodingAVC && s->codecType == CODEC_DECODER && s->width <= 1920 - && s->height <= 1088) { + && s->height <= 1088 && !s->extra_cfg.mpp_mode) { /* H.264 smaller than 1080p use original vpuapi library for better error process */ use_mpp = 0; } else { @@ -368,6 +369,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx) height = s->height; extradata = s->extradata; extradata_size = s->extradata_size; + extra_cfg = s->extra_cfg; free(s); s = NULL; @@ -418,6 +420,7 @@ RK_S32 vpu_open_context(VpuCodecContext **ctx) s->height = height; s->extradata = extradata; s->extradata_size = extradata_size; + s->extra_cfg = extra_cfg; } *ctx = s; @@ -435,7 +438,7 @@ RK_S32 vpu_close_context(VpuCodecContext **ctx) mpp_env_get_u32("force_original", &force_original, 0); if (s) { - if (s->extra_cfg.reserved[0]) { + if (s->extra_cfg.ori_vpu) { ret = close_orign_vpu(ctx); mpp_log("org vpu_close_context ok"); } else { diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index 68a77e67..05c289ef 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -1341,16 +1341,26 @@ RK_S32 VpuApiLegacy::control(VpuCodecContext *ctx, VPU_API_CMD cmd, void *param) MppFrame frame = NULL; mpicmd = MPP_DEC_SET_FRAME_INFO; - - /**hightest of p->ImgWidth bit show current dec bitdepth - * 0 - 8bit - * 1 - 10bit - **/ - if (p->ImgWidth & 0x80000000) - p->CodecType = (p->ImgWidth & 0x40000000) ? MPP_FMT_YUV422SP_10BIT : MPP_FMT_YUV420SP_10BIT; - else - p->CodecType = (p->ImgWidth & 0x40000000) ? MPP_FMT_YUV422SP : MPP_FMT_YUV420SP; - + if (ctx->extra_cfg.bit_depth + || ctx->extra_cfg.yuv_format) { + if (ctx->extra_cfg.bit_depth == 10) + p->CodecType = (ctx->extra_cfg.yuv_format == 1) + ? MPP_FMT_YUV422SP_10BIT : MPP_FMT_YUV420SP_10BIT; + else + p->CodecType = (ctx->extra_cfg.yuv_format == 1) + ? MPP_FMT_YUV422SP : MPP_FMT_YUV420SP; + } else { + /**hightest of p->ImgWidth bit show current dec bitdepth + * 0 - 8bit + * 1 - 10bit + **/ + if (p->ImgWidth & 0x80000000) + p->CodecType = (p->ImgWidth & 0x40000000) + ? MPP_FMT_YUV422SP_10BIT : MPP_FMT_YUV420SP_10BIT; + else + p->CodecType = (p->ImgWidth & 0x40000000) + ? MPP_FMT_YUV422SP : MPP_FMT_YUV420SP; + } p->ImgWidth = (p->ImgWidth & 0xFFFF); mpp_frame_init(&frame);