|
|
|
@ -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); |
|
|
|
|
|
|
|
|
|