diff mbox series

[FFmpeg-devel] libavcodec/bsf: do not ignore last packet after eof

Message ID 20211106015118.446635-1-niko.kurvinen@iki.fi
State New
Headers show
Series [FFmpeg-devel] libavcodec/bsf: do not ignore last packet after eof
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Niko Kurvinen Nov. 6, 2021, 1:51 a.m. UTC
After empty packet is sent and eof is set, remaining packet, if any, was not delivered by ff_bsf_get_packet*.

Signed-off-by: Niko Kurvinen <niko.kurvinen@iki.fi>
---
 libavcodec/bsf.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c
index 8ba021cb47..f9e6bbf499 100644
--- a/libavcodec/bsf.c
+++ b/libavcodec/bsf.c
@@ -233,11 +233,11 @@  int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
     FFBSFContext *const bsfi = ffbsfcontext(ctx);
     AVPacket *tmp_pkt;
 
-    if (bsfi->eof)
-        return AVERROR_EOF;
-
-    if (IS_EMPTY(bsfi->buffer_pkt))
+    if (IS_EMPTY(bsfi->buffer_pkt)) {
+        if (bsfi->eof)
+            return AVERROR_EOF;
         return AVERROR(EAGAIN);
+    }
 
     tmp_pkt = av_packet_alloc();
     if (!tmp_pkt)
@@ -253,11 +253,11 @@  int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
 {
     FFBSFContext *const bsfi = ffbsfcontext(ctx);
 
-    if (bsfi->eof)
-        return AVERROR_EOF;
-
-    if (IS_EMPTY(bsfi->buffer_pkt))
+    if (IS_EMPTY(bsfi->buffer_pkt)) {
+        if (bsfi->eof)
+            return AVERROR_EOF;
         return AVERROR(EAGAIN);
+    }
 
     av_packet_move_ref(pkt, bsfi->buffer_pkt);