[FFmpeg-devel] [PATCH]Fix flac channel layout

Carl Eugen Hoyos cehoyos at ag.or.at
Sat Apr 23 00:51:07 CEST 2011


Hi!

http://flac.sourceforge.net/format.html Channel assignment, only tested with 
one (5.1) sample.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 62ac899..1561954 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -140,7 +140,7 @@ OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o
 OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o
-OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o vorbis_data.o
 OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o
 OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
diff --git a/libavcodec/flac.c b/libavcodec/flac.c
index 484a44e..6e94c2c 100644
--- a/libavcodec/flac.c
+++ b/libavcodec/flac.c
@@ -22,6 +22,7 @@
 #include "libavutil/crc.h"
 #include "flac.h"
 #include "flacdata.h"
+#include "vorbis.h"
 
 static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 };
 
@@ -54,6 +55,8 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
     fi->ch_mode = get_bits(gb, 4);
     if (fi->ch_mode < FLAC_MAX_CHANNELS) {
         fi->channels = fi->ch_mode + 1;
+        if (fi->ch_mode <= 5)
+            avctx->channel_layout = ff_vorbis_channel_layouts[fi->ch_mode];
         fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
     } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
         fi->channels = 2;


More information about the ffmpeg-devel mailing list