diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-11-02 14:15:28 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-11-02 14:20:33 +0100 |
commit | 6788350281c418f0f395a8279eee82f7abe7c63b (patch) | |
tree | 69cd76f699eff929f5b13f76b42eabc7f25f9355 /libavcodec/flac.c | |
parent | 00aa7fa786e41b5fc8404732453869aa3c14e33a (diff) | |
parent | 50a65e7a540ce6747f81d6dbf6a602ad35be77ff (diff) | |
download | ffmpeg-6788350281c418f0f395a8279eee82f7abe7c63b.tar.gz |
Merge commit '50a65e7a540ce6747f81d6dbf6a602ad35be77ff'
* commit '50a65e7a540ce6747f81d6dbf6a602ad35be77ff': (24 commits)
vmdaudio: set channel layout
twinvq: validate sample rate code
twinvq: set channel layout
twinvq: validate that channels is not <= 0
truespeech: set channel layout
sipr: set channel layout
shorten: validate that the channel count in the header is not <= 0
ra288dec: set channel layout
ra144dec: set channel layout
qdm2: remove unneeded checks for channel count
qdm2: make sure channels is not <= 0 and set channel layout
qcelpdec: set channel layout
nellymoserdec: set channels to 1
libopencore-amr: set channel layout for amr-nb or if not set by the user
libilbc: set channel layout
dpcm: use AVCodecContext.channels instead of keeping a private copy
imc: set channels to 1 instead of validating it
gsmdec: always set channel layout and sample rate at initialization
libgsmdec: always set channel layout and sample rate at initialization
g726dec: do not validate sample rate
...
Conflicts:
libavcodec/dpcm.c
libavcodec/qdm2.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/flac.c')
-rw-r--r-- | libavcodec/flac.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libavcodec/flac.c b/libavcodec/flac.c index b07e4f8705..4c1bc58408 100644 --- a/libavcodec/flac.c +++ b/libavcodec/flac.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/audioconvert.h" #include "libavutil/crc.h" #include "libavutil/log.h" #include "bytestream.h" @@ -28,6 +29,15 @@ static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; +static const int64_t flac_channel_layouts[6] = { + AV_CH_LAYOUT_MONO, + AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_SURROUND, + AV_CH_LAYOUT_QUAD, + AV_CH_LAYOUT_5POINT0, + AV_CH_LAYOUT_5POINT1 +}; + static int64_t get_utf8(GetBitContext *gb) { int64_t val; @@ -181,6 +191,14 @@ int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, return 1; } +void ff_flac_set_channel_layout(AVCodecContext *avctx) +{ + if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts)) + avctx->channel_layout = flac_channel_layouts[avctx->channels - 1]; + else + avctx->channel_layout = 0; +} + void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer) { @@ -205,6 +223,7 @@ void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo * avctx->channels = s->channels; avctx->sample_rate = s->samplerate; avctx->bits_per_raw_sample = s->bps; + ff_flac_set_channel_layout(avctx); s->samples = get_bits_longlong(&gb, 36); |