diff mbox series

[FFmpeg-devel,12/36] fftools/ffmpeg_filter: only use fallback parameters when necessary

Message ID 20230517102029.541-12-anton@khirnov.net
State Accepted
Commit a16d7171d1e1ee03ab2473257e275ac2a8c265bf
Headers show
Series [FFmpeg-devel,01/36] fftools/ffmpeg: shorten a variable name | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed

Commit Message

Anton Khirnov May 17, 2023, 10:20 a.m. UTC
With complex filtergraphs it can happen that the filtergraph is
unconfigured because some other filter than the one we just got EOF on
is missing parameters.

Make sure that the fallback parametes for a given input are only used
when that input is unconfigured.
---
 fftools/ffmpeg_filter.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 2c3e2a96f7..8eca0f2cae 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1521,17 +1521,19 @@  int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb)
         if (ret < 0)
             return ret;
     } else {
-        // the filtergraph was never configured, use the fallback parameters
-        ifilter->format                 = ifp->fallback.format;
-        ifilter->sample_rate            = ifp->fallback.sample_rate;
-        ifilter->width                  = ifp->fallback.width;
-        ifilter->height                 = ifp->fallback.height;
-        ifilter->sample_aspect_ratio    = ifp->fallback.sample_aspect_ratio;
-
-        ret = av_channel_layout_copy(&ifilter->ch_layout,
-                                     &ifp->fallback.ch_layout);
-        if (ret < 0)
-            return ret;
+        if (ifilter->format < 0) {
+            // the filtergraph was never configured, use the fallback parameters
+            ifilter->format                 = ifp->fallback.format;
+            ifilter->sample_rate            = ifp->fallback.sample_rate;
+            ifilter->width                  = ifp->fallback.width;
+            ifilter->height                 = ifp->fallback.height;
+            ifilter->sample_aspect_ratio    = ifp->fallback.sample_aspect_ratio;
+
+            ret = av_channel_layout_copy(&ifilter->ch_layout,
+                                         &ifp->fallback.ch_layout);
+            if (ret < 0)
+                return ret;
+        }
 
         if (ifilter->format < 0 && (ifilter->type == AVMEDIA_TYPE_AUDIO || ifilter->type == AVMEDIA_TYPE_VIDEO)) {
             av_log(NULL, AV_LOG_ERROR, "Cannot determine format of input stream %d:%d after EOF\n", ifilter->ist->file_index, ifilter->ist->st->index);