[h264d]: add split mode

1. add split mode prepare branch
2. modify h264d_test for verify split mode

Change-Id: I387a78b45ef2417a118d03cb4b171557cf8534aa
Signed-off-by: leo.ding <leo.ding@rock-chips.com>
This commit is contained in:
leo.ding
2016-12-01 10:20:59 +08:00
committed by ding wei
parent 4273a46252
commit fb718f33fc
4 changed files with 54 additions and 31 deletions

View File

@@ -668,7 +668,11 @@ MPP_RET h264d_prepare(void *decoder, MppPacket pkt, HalDecTask *task)
} else { } else {
fwrite_stream_to_file(p_Inp, p_Inp->in_buf, (RK_U32)p_Inp->in_length); fwrite_stream_to_file(p_Inp, p_Inp->in_buf, (RK_U32)p_Inp->in_length);
do { do {
(ret = parse_prepare_fast(p_Inp, p_Dec->p_Cur)); if (p_Inp->init.need_split) {
ret = parse_prepare(p_Inp, p_Dec->p_Cur);
} else {
ret = parse_prepare_fast(p_Inp, p_Dec->p_Cur);
}
task->valid = p_Inp->task_valid; //!< prepare valid flag task->valid = p_Inp->task_valid; //!< prepare valid flag
} while (mpp_packet_get_length(pkt) && !task->valid); } while (mpp_packet_get_length(pkt) && !task->valid);
} }

View File

@@ -685,7 +685,7 @@ MPP_RET h264d_open_files(InputParams *p_in)
char *outpath_dir = NULL; char *outpath_dir = NULL;
mpp_env_get_str(logenv_name.outpath, &outpath_dir, NULL); mpp_env_get_str(logenv_name.outpath, &outpath_dir, NULL);
FLE_CHECK(ret, p_in->fp_bitstream = fopen(p_in->infile_name, "rb")); FLE_CHECK(ret, p_in->fp_bitstream = fopen(p_in->infile_name, "rb"));
p_in->fp_yuv_data = open_file(outpath_dir, p_in->infile_name, ".yuv", "wb"); p_in->fp_yuv_data = fopen("out.yuv", "wb");
return MPP_OK; return MPP_OK;
__FAILED: __FAILED:
h264d_close_files(p_in); h264d_close_files(p_in);
@@ -741,22 +741,25 @@ __FAILED:
*/ */
MPP_RET h264d_read_one_frame(InputParams *p_in) MPP_RET h264d_read_one_frame(InputParams *p_in)
{ {
p_in->strm.strmbytes = 0; if (0) {
p_in->is_new_frame = 0; p_in->strm.strmbytes = 0;
//-- copy first nalu p_in->is_new_frame = 0;
if (!p_in->is_fist_frame) { //-- copy first nalu
write_nalu_prefix(p_in); if (!p_in->is_fist_frame) {
memcpy(&p_in->strm.pbuf[p_in->strm.strmbytes], p_in->IO.pNALU, p_in->IO.nalubytes); write_nalu_prefix(p_in);
p_in->strm.strmbytes += p_in->IO.nalubytes; memcpy(&p_in->strm.pbuf[p_in->strm.strmbytes], p_in->IO.pNALU, p_in->IO.nalubytes);
p_in->strm.strmbytes += p_in->IO.nalubytes;
}
//-- read one nalu and copy to stream buffer
do {
find_next_nalu(p_in);
read_next_nalu(p_in);
} while (!p_in->is_new_frame && !p_in->is_eof);
} else {
RK_U32 read_len = 512;
p_in->strm.strmbytes = fread(p_in->strm.pbuf, 1, read_len, p_in->fp_bitstream);
p_in->is_eof = p_in->strm.strmbytes ? 0 : 1;
} }
//-- read one nalu and copy to stream buffer
do {
find_next_nalu(p_in);
read_next_nalu(p_in);
} while (!p_in->is_new_frame && !p_in->is_eof);
//if (first_mb_in_slice == 0) {
//FPRINT(g_debug_file0, "--- new frame ---- \n");
//}
return MPP_OK; return MPP_OK;
} }

View File

@@ -66,9 +66,9 @@ extern RK_U32 rkv_h264d_test_debug;
#define H264D_TEST_TRACE (0x00000001) #define H264D_TEST_TRACE (0x00000001)
#define H264D_TEST_TIME (0x00000002) #define H264D_TEST_TIME (0x00000002)
#define H264D_TEST_MUTI_THREAD (0x00000004) #define H264D_TEST_DUMPYUV (0x00000004)
#define H264D_TEST_DUMPYUV (0x00000008) #define H264D_TEST_FPGA (0x00000008)
#define H264D_TEST_FPGA (0x00000010) #define H264D_TEST_MUTI_THREAD (0x00000010)
#define H264D_TEST_LOG(level, fmt, ...)\ #define H264D_TEST_LOG(level, fmt, ...)\

View File

@@ -110,17 +110,21 @@ static MPP_RET decoder_deinit(H264dTestCtx_t *pctx)
} }
if (pctx->m_dec_pkt_buf) { if (pctx->m_dec_pkt_buf) {
mpp_buffer_put(pctx->m_dec_pkt_buf); mpp_buffer_put(pctx->m_dec_pkt_buf);
pctx->m_dec_pkt_buf = NULL;
} }
if (pctx->m_dec_pic_buf) { if (pctx->m_dec_pic_buf) {
mpp_buffer_put(pctx->m_dec_pic_buf); mpp_buffer_put(pctx->m_dec_pic_buf);
pctx->m_dec_pic_buf = NULL;
} }
if (pctx->mFrameGroup != NULL) { if (pctx->mFrameGroup) {
mpp_err("mFrameGroup deInit"); mpp_err("mFrameGroup deInit");
mpp_buffer_group_put(pctx->mFrameGroup); mpp_buffer_group_put(pctx->mFrameGroup);
pctx->mFrameGroup = NULL;
} }
if (pctx->mStreamGroup != NULL) { if (pctx->mStreamGroup) {
mpp_err("mStreamGroup deInit"); mpp_err("mStreamGroup deInit");
mpp_buffer_group_put(pctx->mStreamGroup); mpp_buffer_group_put(pctx->mStreamGroup);
pctx->mStreamGroup = NULL;
} }
return MPP_OK; return MPP_OK;
} }
@@ -138,14 +142,24 @@ static MPP_RET decoder_init(H264dTestCtx_t *pctx)
mpp_env_get_u32("rkv_h264d_test_debug", &rkv_h264d_test_debug, 0); mpp_env_get_u32("rkv_h264d_test_debug", &rkv_h264d_test_debug, 0);
if (pctx->mFrameGroup == NULL) { if (pctx->mFrameGroup == NULL) {
ret = mpp_buffer_group_get_internal(&pctx->mFrameGroup, MPP_BUFFER_TYPE_ION); #ifdef RKPLATFORM
mpp_log_f("mFrameGroup used ion In");
FUN_CHECK(ret = mpp_buffer_group_get_internal(&pctx->mFrameGroup, MPP_BUFFER_TYPE_ION));
#else
FUN_CHECK(ret = mpp_buffer_group_get_internal(&pctx->mFrameGroup, MPP_BUFFER_TYPE_NORMAL));
#endif
if (MPP_OK != ret) { if (MPP_OK != ret) {
mpp_err("h264d mpp_buffer_group_get failed\n"); mpp_err("h264d mpp_buffer_group_get failed\n");
goto __FAILED; goto __FAILED;
} }
} }
if (pctx->mStreamGroup == NULL) { if (pctx->mStreamGroup == NULL) {
ret = mpp_buffer_group_get_internal(&pctx->mStreamGroup, MPP_BUFFER_TYPE_ION); #ifdef RKPLATFORM
mpp_log_f("mStreamGroup used ion In");
FUN_CHECK(ret = mpp_buffer_group_get_internal(&pctx->mStreamGroup, MPP_BUFFER_TYPE_ION));
#else
FUN_CHECK(ret = mpp_buffer_group_get_internal(&pctx->mStreamGroup, MPP_BUFFER_TYPE_NORMAL));
#endif
if (MPP_OK != ret) { if (MPP_OK != ret) {
mpp_err("h264d mpp_buffer_group_get failed\n"); mpp_err("h264d mpp_buffer_group_get failed\n");
goto __FAILED; goto __FAILED;
@@ -209,7 +223,7 @@ static MPP_RET flush_decoded_frames(MppDec *pApi, FILE *fp)
stride_h = mpp_frame_get_ver_stride(out_frame); stride_h = mpp_frame_get_ver_stride(out_frame);
framebuf = mpp_frame_get_buffer(out_frame); framebuf = mpp_frame_get_buffer(out_frame);
ptr = mpp_buffer_get_ptr(framebuf); ptr = mpp_buffer_get_ptr(framebuf);
if ((rkv_h264d_test_debug & H264D_TEST_DUMPYUV) && fp) { if (fp) {
fwrite(ptr, 1, stride_w * stride_h * 3 / 2, fp); fwrite(ptr, 1, stride_w * stride_h * 3 / 2, fp);
fflush(fp); fflush(fp);
} }
@@ -246,8 +260,6 @@ static MPP_RET decoder_single_test(H264dTestCtx_t *pctx)
FUN_CHECK(ret = h264d_read_one_frame(pIn)); FUN_CHECK(ret = h264d_read_one_frame(pIn));
mpp_packet_init(&pkt, pIn->strm.pbuf, pIn->strm.strmbytes); mpp_packet_init(&pkt, pIn->strm.pbuf, pIn->strm.strmbytes);
} }
H264D_TEST_LOG(H264D_TEST_TRACE, "[H264D_TEST] ---- decoder, read_one_frame Frame_no = %d", pIn->iFrmdecoded);
pIn->iFrmdecoded++;
} }
//!< prepare //!< prepare
FUN_CHECK(ret = parser_prepare(pApi->parser, pkt, &task->dec)); FUN_CHECK(ret = parser_prepare(pApi->parser, pkt, &task->dec));
@@ -277,10 +289,12 @@ static MPP_RET decoder_single_test(H264dTestCtx_t *pctx)
//!< deinit packet //!< deinit packet
if (mpp_packet_get_length(pkt) == 0) { if (mpp_packet_get_length(pkt) == 0) {
if (mpp_packet_get_eos(pkt)) { if (mpp_packet_get_eos(pkt)) {
if (task->dec.valid) {
mpp_buf_slot_clr_flag(pApi->packet_slots, task->dec.input, SLOT_HAL_INPUT);
mpp_buf_slot_clr_flag(pApi->frame_slots, task->dec.output, SLOT_HAL_OUTPUT);
task->dec.valid = 0;
}
end_of_flag = 1; //!< end of stream end_of_flag = 1; //!< end of stream
task->dec.valid = 0;
mpp_buf_slot_clr_flag(pApi->packet_slots, task->dec.input, SLOT_HAL_INPUT);
mpp_buf_slot_clr_flag(pApi->frame_slots, task->dec.output, SLOT_HAL_OUTPUT);
} }
mpp_packet_deinit(&pkt); mpp_packet_deinit(&pkt);
pkt = NULL; pkt = NULL;
@@ -322,6 +336,8 @@ static MPP_RET decoder_single_test(H264dTestCtx_t *pctx)
memset(task, 0, sizeof(HalTaskInfo)); memset(task, 0, sizeof(HalTaskInfo));
memset(task->dec.refer, -1, sizeof(task->dec.refer)); memset(task->dec.refer, -1, sizeof(task->dec.refer));
task->dec.input = -1; task->dec.input = -1;
H264D_TEST_LOG(H264D_TEST_TRACE, "[H264D_TEST] ---- had decode frame_no = %d", pIn->iFrmdecoded);
pIn->iFrmdecoded++;
} }
} while (!end_of_flag); } while (!end_of_flag);
@@ -615,6 +631,6 @@ __FAILED:
MPP_FREE(pctx); MPP_FREE(pctx);
H264D_TEST_LOG(H264D_TEST_TRACE, "[H264D_TEST] decoder_deinit over."); H264D_TEST_LOG(H264D_TEST_TRACE, "[H264D_TEST] decoder_deinit over.");
return ret; return 0;
} }