[FFmpeg-cvslog] avcodec/opus: always use ambisonic layout for mapping family 2

James Almer git at videolan.org
Mon Mar 21 00:23:47 EET 2022


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Thu Mar 17 22:41:12 2022 -0300| [efdde028bb420b7bd96d61aad33f6ef549ee07bd] | committer: James Almer

avcodec/opus: always use ambisonic layout for mapping family 2

No need to use a Custom layout when the non diegetic channels can be
described as a standard mask.

This fixes:

45684/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBOPUS_fuzzer-5039410989629440

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/opus.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index 7eccc17e80..3540206347 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -399,21 +399,10 @@ av_cold int ff_opus_parse_extradata(AVCodecContext *avctx,
                 goto fail;
             }
 
+            layout.order = AV_CHANNEL_ORDER_AMBISONIC;
             layout.nb_channels = channels;
-            if (channels == (ambisonic_order + 1) * (ambisonic_order + 1)) {
-                layout.order = AV_CHANNEL_ORDER_AMBISONIC;
-            } else {
-                layout.order = AV_CHANNEL_ORDER_CUSTOM;
-                layout.u.map = av_calloc(channels, sizeof(*layout.u.map));
-                if (!layout.u.map) {
-                    ret = AVERROR(ENOMEM);
-                    goto fail;
-                }
-                for (i = 0; i < channels - 2; i++)
-                    layout.u.map[i].id = AV_CHAN_AMBISONIC_BASE + i;
-                layout.u.map[channels - 2].id = AV_CHAN_FRONT_LEFT;
-                layout.u.map[channels - 1].id = AV_CHAN_FRONT_RIGHT;
-            }
+            if (channels != ((ambisonic_order + 1) * (ambisonic_order + 1)))
+                layout.u.mask = AV_CH_LAYOUT_STEREO;
         } else {
             layout.order       = AV_CHANNEL_ORDER_UNSPEC;
             layout.nb_channels = channels;



More information about the ffmpeg-cvslog mailing list