From d4cae78524f12c57fe6bd4db58fd4378170e3385 Mon Sep 17 00:00:00 2001 From: Francis Fan Date: Fri, 20 Mar 2020 10:48:40 +0800 Subject: [PATCH] [mpp]: cancel release mpp_frame in put_frame api NOTE: This change may effect some existed program. MPP caller should always follow the rule that the resouce creator must be the resource destoryer. So caller of encode_put_frame should release the input MppFrame structure and MPP should not release the input frame. Change-Id: I36897dbbf1697002ae64868f2385961472eeb7c5 Signed-off-by: Francis Fan Signed-off-by: Herman Chen --- mpp/legacy/vpu_api_legacy.cpp | 3 +++ mpp/mpp.cpp | 9 --------- test/mpi_enc_test.c | 9 +++++++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mpp/legacy/vpu_api_legacy.cpp b/mpp/legacy/vpu_api_legacy.cpp index f7f4300d..d0ed621a 100644 --- a/mpp/legacy/vpu_api_legacy.cpp +++ b/mpp/legacy/vpu_api_legacy.cpp @@ -1269,7 +1269,10 @@ PUT_FRAME: mpp_err_f("encode_put_frame ret %d\n", ret); else aEncInStrm->size = 0; + FUNC_RET: + if (frame) + mpp_frame_deinit(&frame); vpu_api_dbg_func("leave ret %d\n", ret); return ret; diff --git a/mpp/mpp.cpp b/mpp/mpp.cpp index 944828b2..65395a09 100644 --- a/mpp/mpp.cpp +++ b/mpp/mpp.cpp @@ -426,15 +426,6 @@ MPP_RET Mpp::put_frame(MppFrame frame) mpp_assert(mInputTask); - /* clear the enqueued task back */ - if (mInputTask) { - ret = mpp_task_meta_get_frame(mInputTask, KEY_INPUT_FRAME, &frame); - if (frame) { - mpp_frame_deinit(&frame); - frame = NULL; - } - } - RET: return ret; } diff --git a/test/mpi_enc_test.c b/test/mpi_enc_test.c index 5d6ebe55..a4efe4fa 100644 --- a/test/mpi_enc_test.c +++ b/test/mpi_enc_test.c @@ -415,11 +415,20 @@ MPP_RET test_mpp_run(MpiEncTestData *p) else mpp_frame_set_buffer(frame, p->frm_buf); + /* + * NOTE: in non-block mode the frame can be resent. + * The default input timeout mode is block. + * + * User should release the input frame to meet the requirements of + * resource creator must be the resource destroyer. + */ ret = mpi->encode_put_frame(ctx, frame); if (ret) { mpp_err("mpp encode put frame failed\n"); + mpp_frame_deinit(&frame); goto RET; } + mpp_frame_deinit(&frame); ret = mpi->encode_get_packet(ctx, &packet); if (ret) {