On 2/23/2022 7:24 AM, Anton Khirnov wrote:
Quoting James Almer (2022-01-13 03:04:50)
From: Anton Khirnov <an...@khirnov.net>

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
Signed-off-by: Anton Khirnov <an...@khirnov.net>
Signed-off-by: James Almer <jamr...@gmail.com>
---
  libavcodec/flac.c        | 39 +++++++++++++++++++++------------------
  libavcodec/flac.h        |  2 +-
  libavcodec/flac_parser.c |  7 ++-----
  libavcodec/flacdec.c     |  9 ++++-----
  libavcodec/flacenc.c     | 26 +++++++++++++-------------
  5 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/libavcodec/flac.c b/libavcodec/flac.c
index 7b075d4bd3..51014faea1 100644
--- a/libavcodec/flac.c
+++ b/libavcodec/flac.c
@@ -29,15 +29,15 @@
static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; -static const uint64_t flac_channel_layouts[8] = {
-    AV_CH_LAYOUT_MONO,
-    AV_CH_LAYOUT_STEREO,
-    AV_CH_LAYOUT_SURROUND,
-    AV_CH_LAYOUT_QUAD,
-    AV_CH_LAYOUT_5POINT0,
-    AV_CH_LAYOUT_5POINT1,
-    AV_CH_LAYOUT_6POINT1,
-    AV_CH_LAYOUT_7POINT1
+static const AVChannelLayout flac_channel_layouts[8] = {
+    AV_CHANNEL_LAYOUT_MONO,
+    AV_CHANNEL_LAYOUT_STEREO,
+    AV_CHANNEL_LAYOUT_SURROUND,
+    AV_CHANNEL_LAYOUT_QUAD,
+    AV_CHANNEL_LAYOUT_5POINT0,
+    AV_CHANNEL_LAYOUT_5POINT1,
+    AV_CHANNEL_LAYOUT_6POINT1,
+    AV_CHANNEL_LAYOUT_7POINT1
  };
static int64_t get_utf8(GetBitContext *gb)
@@ -193,12 +193,19 @@ int ff_flac_is_extradata_valid(AVCodecContext *avctx,
      return 1;
  }
-void ff_flac_set_channel_layout(AVCodecContext *avctx)
+void ff_flac_set_channel_layout(AVCodecContext *avctx, int channels)
  {
-    if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts))
-        avctx->channel_layout = flac_channel_layouts[avctx->channels - 1];
+    if (channels == avctx->ch_layout.nb_channels &&
+        avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE &&
+        avctx->ch_layout.u.mask)

Not sure why I wrote this check like this originally, now it seems
better to check for order != UNSPEC, so that a user-supplied custom
layout is preserved.

You didn't write that, i did it to prevent the failure of fate-matroska-flac-extradata-update (a very recent test). Changing it to != UNSPEC also works, so I'll do that.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to