diff --git a/mpp/codec/dec/h264/h264d_global.h b/mpp/codec/dec/h264/h264d_global.h index ccab3ea2..081c6355 100644 --- a/mpp/codec/dec/h264/h264d_global.h +++ b/mpp/codec/dec/h264/h264d_global.h @@ -946,6 +946,8 @@ typedef struct h264d_video_ctx_t { RK_U32 PicWidthInMbs; RK_U32 FrameHeightInMbs; RK_S32 yuv_format; + RK_U32 bit_depth_chroma; + RK_U32 bit_depth_luma; RK_S32 width; RK_S32 height; RK_U32 width_after_crop; diff --git a/mpp/codec/dec/h264/h264d_init.c b/mpp/codec/dec/h264/h264d_init.c index 1f0d91cd..29100068 100644 --- a/mpp/codec/dec/h264/h264d_init.c +++ b/mpp/codec/dec/h264/h264d_init.c @@ -381,7 +381,7 @@ __FAILED: static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, RK_S32 structure, RK_U8 combine_flag, RK_S32 layer_id) { RK_U8 idx = 1; - H264_DpbMark_t *cur_mark = NULL; + H264_DpbMark_t *cur_mark = NULL; H264_DecCtx_t *p_Dec = p_Vid->p_Dec; H264_DpbMark_t *p_mark = p_Vid->p_Dec->dpb_mark; @@ -403,12 +403,21 @@ static void dpb_mark_malloc(H264dVideoCtx_t *p_Vid, RK_S32 structure, RK_U8 comb //mpp_print_slot_flag_info(g_debug_file1, p_Dec->frame_slots, cur_mark->slot_idx); //mpp_log("[Malloc] lay_id=%d, g_framecnt=%d, mark_idx=%d, slot_idx=%d, pts=%lld \n", layer_id, // p_Vid->g_framecnt, cur_mark->mark_idx, cur_mark->slot_idx, p_Vid->p_Inp->in_pts); + if((YUV420 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) { + mpp_frame_set_fmt(cur_mark->frame, MPP_FMT_YUV420SP); + } else if ((YUV420 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) { + mpp_frame_set_fmt(cur_mark->frame, MPP_FMT_YUV420SP_10BIT); + mpp_log_f(" alloc_picture ----- MPP_FMT_YUV420SP_10BIT ------ \n"); + } else if ((YUV422 == p_Vid->yuv_format) && (8 == p_Vid->bit_depth_luma)) { + mpp_frame_set_fmt(cur_mark->frame, MPP_FMT_YUV422SP); + } else if ((YUV422 == p_Vid->yuv_format) && (10 == p_Vid->bit_depth_luma)) { + mpp_frame_set_fmt(cur_mark->frame, MPP_FMT_YUV422SP_10BIT); + } + mpp_frame_set_hor_stride(cur_mark->frame, ((p_Vid->width * p_Vid->bit_depth_luma) >> 3)); // before crop + mpp_frame_set_width(cur_mark->frame, ((p_Vid->width_after_crop * p_Vid->bit_depth_luma)>>3)); // after crop - mpp_frame_set_hor_stride(cur_mark->frame, p_Vid->width); // before crop - mpp_frame_set_ver_stride(cur_mark->frame, p_Vid->height); - mpp_frame_set_width(cur_mark->frame, p_Vid->width_after_crop); // after crop - mpp_frame_set_height(cur_mark->frame, p_Vid->height_after_crop); - + mpp_frame_set_ver_stride(cur_mark->frame, p_Vid->height); + mpp_frame_set_height(cur_mark->frame, p_Vid->height_after_crop); mpp_frame_set_pts(cur_mark->frame, p_Vid->p_Cur->last_pts); mpp_frame_set_dts(cur_mark->frame, p_Vid->p_Cur->last_dts); diff --git a/mpp/codec/dec/h264/h264d_sps.c b/mpp/codec/dec/h264/h264d_sps.c index 2d009a8c..7c2cb0a3 100644 --- a/mpp/codec/dec/h264/h264d_sps.c +++ b/mpp/codec/dec/h264/h264d_sps.c @@ -356,7 +356,9 @@ static void update_video_pars(H264dVideoCtx_t *p_Vid, H264_SPS_t *sps) p_Vid->width = p_Vid->PicWidthInMbs * 16; p_Vid->height = p_Vid->FrameHeightInMbs * 16; - + p_Vid->bit_depth_luma = sps->bit_depth_luma_minus8 + 8; + p_Vid->bit_depth_chroma = sps->bit_depth_chroma_minus8 + 8; + if (p_Vid->yuv_format == YUV420) { p_Vid->width_cr = (p_Vid->width >> 1); p_Vid->height_cr = (p_Vid->height >> 1); diff --git a/mpp/codec/mpp_dec.cpp b/mpp/codec/mpp_dec.cpp index cc2c5022..5a95ae97 100644 --- a/mpp/codec/mpp_dec.cpp +++ b/mpp/codec/mpp_dec.cpp @@ -562,7 +562,12 @@ void *mpp_dec_hal_thread(void *data) HalTaskHnd task = NULL; HalTaskInfo task_info; HalDecTask *task_dec = &task_info.dec; - +#ifdef ANDROID + RK_S32 cur_deat = 0; + RK_U64 dec_no = 0, total_time = 0; + static struct timeval tv1, tv2; + gettimeofday(&tv1, NULL); +#endif while (MPP_THREAD_RUNNING == hal->get_status()) { /* * hal thread wait for dxva interface intput firt @@ -594,6 +599,14 @@ void *mpp_dec_hal_thread(void *data) mpp->mThreadCodec->signal(); } mpp_hal_hw_wait(dec->hal, &task_info); +#ifdef ANDROID + gettimeofday(&tv2, NULL); + cur_deat = (tv2.tv_sec - tv1.tv_sec) * 1000 + (tv2.tv_usec - tv1.tv_usec) / 1000; + total_time += cur_deat; + //mpp_log("[Cal_time] dec_no=%lld, time=%d ms, av_time=%lld ms. \n", dec_no, cur_deat, total_time/(dec_no + 1)); + dec_no++; + tv1 = tv2; +#endif /* * when hardware decoding is done: * 1. clear decoding flag (mark buffer is ready) diff --git a/mpp/hal/rkdec/h264d/hal_h264d_global.h b/mpp/hal/rkdec/h264d/hal_h264d_global.h index 28507ab1..5c239a69 100644 --- a/mpp/hal/rkdec/h264d/hal_h264d_global.h +++ b/mpp/hal/rkdec/h264d/hal_h264d_global.h @@ -52,8 +52,8 @@ typedef struct h264d_hal_ctx_t { MppBufferGroup buf_group; MppBuffer cabac_buf; RK_S32 vpu_socket; - RK_S64 total_time; - RK_S64 iDecodedNum; + RK_U64 total_time; + RK_U64 iDecodedNum; } H264dHalCtx_t; diff --git a/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c b/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c index e66a03e3..b1f22716 100644 --- a/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c +++ b/mpp/hal/rkdec/h264d/hal_h264d_rkv_reg.c @@ -393,11 +393,14 @@ MPP_RET rkv_h264d_wait(void *hal, HalTaskInfo *task) VPU_CMD_TYPE ret_cmd = VPU_CMD_BUTT; static struct timeval tv1, tv2; gettimeofday(&tv1, NULL); - wait_ret = VPUClientWaitResult(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, DEC_RKV_REGISTERS, &ret_cmd, &ret_len); - //mpp_log("H264 RKV FlushRegs success, g_grame_no=%d. \n", p_hal->iDecodedNum); + wait_ret = VPUClientWaitResult(p_hal->vpu_socket, (RK_U32 *)p_hal->regs, DEC_RKV_REGISTERS, &ret_cmd, &ret_len); gettimeofday(&tv2, NULL); cur_deat = (tv2.tv_sec - tv1.tv_sec) * 1000 + (tv2.tv_usec - tv1.tv_usec) / 1000; p_hal->total_time += cur_deat; + + //mpp_log("H264 RKV FlushRegs success, dec_no=%lld, time=%d ms, av_time=%lld ms. \n", + // p_hal->iDecodedNum, cur_deat, p_hal->total_time/(p_hal->iDecodedNum + 1)); + //ALOGI("dec %lld frame time %d ms,average time %lld ms",decNum,deat,total/decNum); p_hal->iDecodedNum++; (void)wait_ret; #endif