[FFmpeg-devel] [PATCH] avfilter/af_pan: ignore named channels not in current layout

Ricardo Constantino wiiaboo at gmail.com
Wed May 10 22:22:02 EEST 2017


instead of erroring out.

af pan=stereo|FL=FL|FR=FR|FC=FC would error because there's no
Front Center in stereo layout.

This allows just changing the output channel layout and keeping
the same channel configuration across more than one output.

Example usecase
* changing balance to the right-side channels for stereo and 7.1

before:
pan=stereo|FL=0.2*FL+0.8*FR|FR=0*FL+1*FR
pan=7.1|FL=0.2*FL+0.8*FR|FR=0.0*FL+1.0*FR|FC=FC|LFE=LFE|BL=0.2*BL+0.8*BR|BR=0.0*BL+1.0*BR|SL=0.2*SL+0.8*SR|SR=0.0*SL+1.0*SR

after:
pan=stereo|FL=0.2*FL+0.8*FR|FR=0.0*FL+1.0*FR|FC=FC|LFE=LFE|BL=0.2*BL+0.8*BR|BR=0.0*BL+1.0*BR|SL=0.2*SL+0.8*SR|SR=0.0*SL+1.0*SR
pan=7.1|FL=0.2*FL+0.8*FR|FR=0.0*FL+1.0*FR|FC=FC|LFE=LFE|BL=0.2*BL+0.8*BR|BR=0.0*BL+1.0*BR|SL=0.2*SL+0.8*SR|SR=0.0*SL+1.0*SR
---
 libavfilter/af_pan.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
index 63d7750f35..9c44ba1cda 100644
--- a/libavfilter/af_pan.c
+++ b/libavfilter/af_pan.c
@@ -136,10 +136,9 @@ static av_cold int init(AVFilterContext *ctx)
         }
         if (named) {
             if (!((pan->out_channel_layout >> out_ch_id) & 1)) {
-                av_log(ctx, AV_LOG_ERROR,
-                       "Channel \"%.8s\" does not exist in the chosen layout\n", arg0);
-                ret = AVERROR(EINVAL);
-                goto fail;
+                av_log(ctx, AV_LOG_VERBOSE,
+                       "Channel \"%.8s\" does not exist in the chosen layout, skipping\n", arg0);
+                continue;
             }
             /* get the channel number in the output channel layout:
              * out_channel_layout & ((1 << out_ch_id) - 1) are all the
-- 
2.12.1



More information about the ffmpeg-devel mailing list