Process the last video frame

On H.264 stream EOF, the eof_reached flag is set, but av_read_frame()
still provides a frame, so check the flag only afterwards.

As a side-effect, it also fixes a memory leak (the very last packet was
not unref).
This commit is contained in:
Romain Vimont 2018-03-23 14:01:58 +01:00
parent 73c332e3e4
commit 35298bb0c6

View file

@ -92,10 +92,6 @@ static int run_decoder(void *data) {
packet.size = 0; packet.size = 0;
while (!av_read_frame(format_ctx, &packet)) { while (!av_read_frame(format_ctx, &packet)) {
if (avio_ctx->eof_reached) {
av_packet_unref(&packet);
goto run_quit;
}
// the new decoding/encoding API has been introduced by: // the new decoding/encoding API has been introduced by:
// <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726> // <http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=7fc329e2dd6226dfecaa4a1d7adf353bf2773726>
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0) #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
@ -129,6 +125,10 @@ static int run_decoder(void *data) {
} }
#endif #endif
av_packet_unref(&packet); av_packet_unref(&packet);
if (avio_ctx->eof_reached) {
break;
}
} }
LOGD("End of frames"); LOGD("End of frames");