[FFmpeg-cvslog] filter_units: Don't use fake loop

Andreas Rheinhardt git at videolan.org
Mon Jul 8 00:17:19 EEST 2019


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Mon Jun 17 05:42:09 2019 +0200| [83be17cfcdd98a09d93960d6df2ac4bdee884059] | committer: Mark Thompson

filter_units: Don't use fake loop

According to the BSF API, when a BSF is finished with an input packet,
it should return AVERROR(EAGAIN) to signal that another packet should be
sent to the BSF via av_bsf_send_packet that the actual BSF can receive
via ff_bsf_get_packet[_ref]. filter_units on the other hand simply called
ff_bsf_get_packet again if the first packet received didn't result in
any output. This call of course returned AVERROR(EAGAIN) which was
returned, but it is nevertheless better to not include a fake loop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83be17cfcdd98a09d93960d6df2ac4bdee884059
---

 libavcodec/filter_units_bsf.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/filter_units_bsf.c b/libavcodec/filter_units_bsf.c
index 0876693c81..a787933f0a 100644
--- a/libavcodec/filter_units_bsf.c
+++ b/libavcodec/filter_units_bsf.c
@@ -105,7 +105,6 @@ static int filter_units_filter(AVBSFContext *bsf, AVPacket *out)
     AVPacket *in = NULL;
     int err, i, j;
 
-    while (1) {
         err = ff_bsf_get_packet(bsf, &in);
         if (err < 0)
             return err;
@@ -134,12 +133,10 @@ static int filter_units_filter(AVBSFContext *bsf, AVPacket *out)
             }
         }
 
-        if (frag->nb_units > 0)
-            break;
-
+    if (frag->nb_units == 0) {
         // Don't return packets with nothing in them.
-        av_packet_free(&in);
-        ff_cbs_fragment_reset(ctx->cbc, frag);
+        err = AVERROR(EAGAIN);
+        goto fail;
     }
 
     err = ff_cbs_write_packet(ctx->cbc, out, frag);



More information about the ffmpeg-cvslog mailing list