mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 16:52:40 +08:00
[vpu]: Fix encoder's improper operation with eos
When encoder receives an empty frame with eos flag set, encoder will encode an unreasonable extra frame. Change-Id: I3bd1a2c84780f1b6212171117b67319b2f613b9f Signed-off-by: Johnson Ding <johnson.ding@rock-chips.com>
This commit is contained in:
@@ -1167,8 +1167,6 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a
|
|||||||
/* try import input buffer and output buffer */
|
/* try import input buffer and output buffer */
|
||||||
MppFrame frame = NULL;
|
MppFrame frame = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ret = mpp_frame_init(&frame);
|
ret = mpp_frame_init(&frame);
|
||||||
if (MPP_OK != ret) {
|
if (MPP_OK != ret) {
|
||||||
mpp_err_f("mpp_frame_init failed\n");
|
mpp_err_f("mpp_frame_init failed\n");
|
||||||
@@ -1181,6 +1179,18 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a
|
|||||||
mpp_frame_set_ver_stride(frame, ver_stride);
|
mpp_frame_set_ver_stride(frame, ver_stride);
|
||||||
mpp_frame_set_pts(frame, pts);
|
mpp_frame_set_pts(frame, pts);
|
||||||
|
|
||||||
|
if (aEncInStrm->nFlags) {
|
||||||
|
mpp_log_f("found eos true\n");
|
||||||
|
mpp_frame_set_eos(frame, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size <= 0) {
|
||||||
|
mpp_frame_set_buffer(frame, NULL);
|
||||||
|
if (!aEncInStrm->nFlags)
|
||||||
|
mpp_err_f("found empty frame without eos flag set!\n");
|
||||||
|
goto PUT_FRAME;
|
||||||
|
}
|
||||||
|
|
||||||
if (fd_input < 0) {
|
if (fd_input < 0) {
|
||||||
fd_input = is_valid_dma_fd(fd);
|
fd_input = is_valid_dma_fd(fd);
|
||||||
}
|
}
|
||||||
@@ -1235,14 +1245,11 @@ RK_S32 VpuApiLegacy::encoder_sendframe(VpuCodecContext *ctx, EncInputStream_t *a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PUT_FRAME:
|
||||||
|
|
||||||
vpu_api_dbg_input("w %d h %d input fd %d size %d pts %lld, flag %d \n",
|
vpu_api_dbg_input("w %d h %d input fd %d size %d pts %lld, flag %d \n",
|
||||||
width, height, fd, size, aEncInStrm->timeUs, aEncInStrm->nFlags);
|
width, height, fd, size, aEncInStrm->timeUs, aEncInStrm->nFlags);
|
||||||
|
|
||||||
if (aEncInStrm->nFlags) {
|
|
||||||
mpp_log_f("found eos true");
|
|
||||||
mpp_frame_set_eos(frame, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = mpi->encode_put_frame(mpp_ctx, frame);
|
ret = mpi->encode_put_frame(mpp_ctx, frame);
|
||||||
if (ret)
|
if (ret)
|
||||||
mpp_err_f("encode_put_frame ret %d\n", ret);
|
mpp_err_f("encode_put_frame ret %d\n", ret);
|
||||||
@@ -1293,7 +1300,7 @@ RK_S32 VpuApiLegacy::encoder_getstream(VpuCodecContext *ctx, EncoderOut_t *aEncO
|
|||||||
mpp_packet_deinit(&packet);
|
mpp_packet_deinit(&packet);
|
||||||
} else {
|
} else {
|
||||||
aEncOut->size = 0;
|
aEncOut->size = 0;
|
||||||
vpu_api_dbg_output("encode_get_packet get NULL packet\n");
|
vpu_api_dbg_output("get NULL packet, eos %d\n", mEosSet);
|
||||||
if (mEosSet)
|
if (mEosSet)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
@@ -387,9 +387,13 @@ MPP_RET test_mpp_run(MpiEncTestData *p)
|
|||||||
mpp_frame_set_hor_stride(frame, p->hor_stride);
|
mpp_frame_set_hor_stride(frame, p->hor_stride);
|
||||||
mpp_frame_set_ver_stride(frame, p->ver_stride);
|
mpp_frame_set_ver_stride(frame, p->ver_stride);
|
||||||
mpp_frame_set_fmt(frame, p->fmt);
|
mpp_frame_set_fmt(frame, p->fmt);
|
||||||
mpp_frame_set_buffer(frame, p->frm_buf);
|
|
||||||
mpp_frame_set_eos(frame, p->frm_eos);
|
mpp_frame_set_eos(frame, p->frm_eos);
|
||||||
|
|
||||||
|
if (p->fp_input && feof(p->fp_input))
|
||||||
|
mpp_frame_set_buffer(frame, NULL);
|
||||||
|
else
|
||||||
|
mpp_frame_set_buffer(frame, p->frm_buf);
|
||||||
|
|
||||||
ret = mpi->encode_put_frame(ctx, frame);
|
ret = mpi->encode_put_frame(ctx, frame);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mpp_err("mpp encode put frame failed\n");
|
mpp_err("mpp encode put frame failed\n");
|
||||||
|
Reference in New Issue
Block a user