[mpp_enc]: release input frame when get packet success

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1067 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-07-21 12:11:50 +00:00
parent 7bd91fe000
commit cf143f2766
2 changed files with 17 additions and 7 deletions

View File

@@ -564,6 +564,8 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a
RK_U32 hor_stride = MPP_ALIGN(width, 16);
RK_U32 ver_stride = MPP_ALIGN(height, 16);
RK_S32 pts = aEncInStrm->timeUs;
RK_S32 import_fd = -1;
RK_U32 import_size = 0;
/* try import input buffer and output buffer */
MppFrame frame = NULL;
@@ -598,16 +600,21 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a
aEncInStrm->bufPhyAddr, aEncInStrm->size);
goto FUNC_RET;
}
import_fd = mpp_buffer_get_fd(buffer);
import_size = mpp_buffer_get_size(buffer);
mpp_frame_set_buffer(frame, buffer);
mpp_buffer_put(buffer);
buffer = NULL;
}
mpp_frame_set_buffer(frame, buffer);
if (aEncInStrm->nFlags || aEncInStrm->size == 0) {
mpp_log_f("found eos true");
mpp_frame_set_eos(frame, 1);
}
vpu_api_dbg_input("w %d h %d fd %d size %d\n", width, height,
mpp_buffer_get_fd(buffer), mpp_buffer_get_size(buffer));
vpu_api_dbg_input("w %d h %d fd %d size %d\n", width, height, import_fd, import_size);
ret = mpi->encode_put_frame(mpp_ctx, frame);
if (ret)
@@ -615,10 +622,6 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a
aEncInStrm->size = 0;
FUNC_RET:
if (buffer) {
mpp_buffer_put(buffer);
buffer = NULL;
}
vpu_api_dbg_func("leave ret %d\n", ret);
return ret;

View File

@@ -332,6 +332,7 @@ MPP_RET Mpp::get_packet(MppPacket *packet)
MPP_RET ret = MPP_OK;
MppTask task = NULL;
MppFrame frame = NULL;
do {
if (NULL == task) {
@@ -354,6 +355,12 @@ MPP_RET Mpp::get_packet(MppPacket *packet)
mpp_assert(task);
mpp_task_meta_get_frame(task, MPP_META_KEY_INPUT_FRM, &frame);
if (frame) {
mpp_frame_deinit(&frame);
frame = NULL;
}
ret = mpp_task_meta_get_packet(task, MPP_META_KEY_OUTPUT_PKT, packet);
if (ret) {
mpp_log_f("failed to get output packet from task ret %d\n", ret);