aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/flacdec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-02-09 22:44:10 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-02-22 20:14:00 -0500
commit62d5f9e5cab45df0505862e5ede2bae55d1881aa (patch)
tree35d87ccbdf5c29b4d57fd726ed02b7cbc6ee900b /libavcodec/flacdec.c
parent3798205a77ce275613098ecb48645e6029811f14 (diff)
downloadffmpeg-62d5f9e5cab45df0505862e5ede2bae55d1881aa.tar.gz
flacdec: set channel_layout based on channel count
Channel layouts are specified in the FLAC format description at http://flac.sourceforge.net/format.html fixes Bug 209
Diffstat (limited to 'libavcodec/flacdec.c')
-rw-r--r--libavcodec/flacdec.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 7454d8b7f7..ad3827b6cc 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -33,6 +33,7 @@
#include <limits.h>
+#include "libavutil/audioconvert.h"
#include "libavutil/crc.h"
#include "avcodec.h"
#include "internal.h"
@@ -62,6 +63,15 @@ typedef struct FLACContext {
int32_t *decoded[FLAC_MAX_CHANNELS]; ///< decoded samples
} FLACContext;
+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 void allocate_buffers(FLACContext *s);
int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
@@ -120,6 +130,9 @@ static av_cold int flac_decode_init(AVCodecContext *avctx)
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
+ if (avctx->channels <= FF_ARRAY_ELEMS(flac_channel_layouts))
+ avctx->channel_layout = flac_channel_layouts[avctx->channels - 1];
+
return 0;
}