Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-05-07 09:20:32 +0400
committerJames Almer <jamrial@gmail.com>2022-03-15 15:42:41 +0300
commit5e257c1f7bf8bf277144b21200f3c6ed9a077af0 (patch)
tree300cf87cb7ee49ccd531725daf9cba479cf14343 /libavcodec/flac.c
parent06431f1997935b322e15e48a67cdd8714a035701 (diff)
flac: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/flac.c')
-rw-r--r--libavcodec/flac.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/libavcodec/flac.c b/libavcodec/flac.c
index 7b075d4bd3..dd68830622 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,18 @@ 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_UNSPEC)
+ return;
+
+ av_channel_layout_uninit(&avctx->ch_layout);
+ if (channels <= FF_ARRAY_ELEMS(flac_channel_layouts))
+ avctx->ch_layout = flac_channel_layouts[channels - 1];
else
- avctx->channel_layout = 0;
+ avctx->ch_layout = (AVChannelLayout){ .order = AV_CHANNEL_ORDER_UNSPEC,
+ .nb_channels = channels };
}
int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
@@ -229,13 +235,9 @@ int ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
return AVERROR_INVALIDDATA;
}
- avctx->channels = s->channels;
avctx->sample_rate = s->samplerate;
avctx->bits_per_raw_sample = s->bps;
-
- if (!avctx->channel_layout ||
- av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels)
- ff_flac_set_channel_layout(avctx);
+ ff_flac_set_channel_layout(avctx, s->channels);
s->samples = get_bits64(&gb, 36);