diff --git a/inc/rk_mpi.h b/inc/rk_mpi.h index ce26e731..55ebb064 100644 --- a/inc/rk_mpi.h +++ b/inc/rk_mpi.h @@ -139,12 +139,30 @@ typedef struct MppEncConfig_t { RK_S32 trans8x8_en; } MppEncConfig; +/* + * mpp main work function set + * size : MppApi structure size + * version : Mpp svn revision + * + * decode : both send video stream packet to decoder and get video frame from + * decoder at the same time. + * decode_put_packet: send video stream packet to decoder only, async interface + * decode_get_frame : get video frame from decoder only, async interface + * + * encode : both send video frame to encoder and get encoded video stream from + * encoder at the same time. + * encode_put_frame : send video frame to encoder only, async interface + * encode_get_packet: get encoded video packet from encoder only, async interface + * + * reset : discard all packet and frame, reset all component, + * for both decoder and encoder + * control : control function for mpp property setting + * config : config function for encoder, not implement yet. + */ typedef struct MppApi_t { RK_U32 size; RK_U32 version; - MPP_RET (*config)(MppCtx ctx, MppEncConfig cfg); - // sync interface MPP_RET (*decode)(MppCtx ctx, MppPacket packet, MppFrame *frame); MPP_RET (*encode)(MppCtx ctx, MppFrame frame, MppPacket *packet); @@ -156,8 +174,9 @@ typedef struct MppApi_t { MPP_RET (*encode_put_frame)(MppCtx ctx, MppFrame frame); MPP_RET (*encode_get_packet)(MppCtx ctx, MppPacket *packet); - MPP_RET (*flush)(MppCtx ctx); + MPP_RET (*reset)(MppCtx ctx); MPP_RET (*control)(MppCtx ctx, MpiCmd cmd, MppParam param); + MPP_RET (*config)(MppCtx ctx, MppEncConfig cfg); RK_U32 reserv[16]; } MppApi; @@ -168,7 +187,13 @@ extern "C" { #endif /* - * mpp interface + * mpp interface work flow + * + * 1. mpp_create : Create empty context structure and mpi function pointers. + * 2. mpp_init : Call after mpp_create to setup mpp type and video format. + * This function will call internal context init function. + * 3. Use functions in MppApi to access mpp services. + * 4. mpp_destory: Destroy mpp context and free both context and mpi structure */ MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi); MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding); diff --git a/mpp/codec/dec/h264/h264d_sei.c b/mpp/codec/dec/h264/h264d_sei.c index 6a772fc5..6250334d 100644 --- a/mpp/codec/dec/h264/h264d_sei.c +++ b/mpp/codec/dec/h264/h264d_sei.c @@ -29,7 +29,7 @@ #ifndef _WIN32 #include -char *strupr(char *str) +char *_strupr(char *str) { char *orign=str; for (; *str != '\0'; str++) { @@ -86,7 +86,7 @@ static MPP_RET interpret_user_data_unregistered_info(RK_U8 *payload, RK_S32 size } #endif - sei_msg->user_data_DivX_flag = strstr(strupr((char *)&payload[16]), "DIVX") ? 1 : 0; + sei_msg->user_data_DivX_flag = strstr(_strupr((char *)&payload[16]), "DIVX") ? 1 : 0; if (sei_msg->user_data_DivX_flag) { H264D_ERR("DivX is not supported. \n"); sei_msg->p_Dec->err_ctx.err_flag |= VPU_FRAME_ERR_UNSUPPORT; @@ -217,7 +217,7 @@ static MPP_RET interpret_mvc_scalable_nesting_info(RK_U8 *payload, RK_S32 size, READ_BITS(p_strm, 3, &sei_op_temporal_id, "sei_op_temporal_id"); } - p_bitctx->used_bits = p_strm->used_bits; + p_bitctx->used_bits = p_strm->used_bits; return ret = MPP_OK; __BITREAD_ERR: ret = p_bitctx->ret; @@ -404,7 +404,7 @@ MPP_RET process_sei(H264_SLICE_t *currSlice) sei_msg->payload_size += tmp_byte; // this is the last byte //--- read sei info - FUN_CHECK(ret = parserSEI(currSlice, p_bitctx, sei_msg, p_bitctx->data_)); + FUN_CHECK(ret = parserSEI(currSlice, p_bitctx, sei_msg, p_bitctx->data_)); //--- set offset to read next sei nal if (SEI_MVC_SCALABLE_NESTING == sei_msg->type) { sei_msg->payload_size = ((p_bitctx->used_bits + 0x07) >> 3); diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index b572b6ba..34a0a117 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -85,8 +85,8 @@ RK_S32 VpuApi::flush(VpuCodecContext *ctx) { (void)ctx; mpp_log_f("in\n"); - if (mpi && mpi->flush) { - mpi->flush(mpp_ctx); + if (mpi && mpi->reset) { + mpi->reset(mpp_ctx); } mpp_log_f("ok\n"); return 0; diff --git a/mpp/mpi.cpp b/mpp/mpi.cpp index 11d275a9..14dd5442 100644 --- a/mpp/mpi.cpp +++ b/mpp/mpi.cpp @@ -126,7 +126,7 @@ static MPP_RET mpi_encode_get_packet(MppCtx ctx, MppPacket *packet) return ret; } -static MPP_RET mpi_flush(MppCtx ctx) +static MPP_RET mpi_reset(MppCtx ctx) { MpiImpl *p = (MpiImpl *)ctx; MPP_RET ret = MPP_OK; @@ -150,15 +150,15 @@ static MPP_RET mpi_control(MppCtx ctx, MpiCmd cmd, MppParam param) static MppApi mpp_api = { sizeof(mpp_api), 0, - mpi_config, mpi_decode, mpi_encode, mpi_decode_put_packet, mpi_decode_get_frame, mpi_encode_put_frame, mpi_encode_get_packet, - mpi_flush, + mpi_reset, mpi_control, + mpi_config, {0}, }; @@ -202,7 +202,6 @@ MPP_RET mpp_create(MppCtx *ctx, MppApi **mpi) return MPP_OK; } - MPP_RET mpp_init(MppCtx ctx, MppCtxType type, MppCodingType coding) { MpiImpl *p = (MpiImpl*)ctx; diff --git a/test/mpi_test.c b/test/mpi_test.c index 92a7f5c9..708d9438 100644 --- a/test/mpi_test.c +++ b/test/mpi_test.c @@ -166,9 +166,9 @@ int mpi_test() } - ret = mpi->flush(ctx); + ret = mpi->reset(ctx); if (MPP_OK != ret) { - mpp_err("mpi->flush failed\n"); + mpp_err("mpi->reset failed\n"); goto MPP_TEST_FAILED; } @@ -247,9 +247,9 @@ int mpi_test() } - ret = mpi->flush(ctx); + ret = mpi->reset(ctx); if (MPP_OK != ret) { - mpp_err("mpi->flush failed\n"); + mpp_err("mpi->reset failed\n"); goto MPP_TEST_FAILED; }