From: Anton Khirnov <[email protected]>
Signed-off-by: Vittorio Giovara <[email protected]>
Signed-off-by: Anton Khirnov <[email protected]>
Signed-off-by: James Almer <[email protected]>
---
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)