[FFmpeg-cvslog] flac: only set channel layout if not previously set or on channel count change

Justin Ruggles git at videolan.org
Sat Dec 22 13:54:31 CET 2012


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Sun Dec 16 11:02:39 2012 -0500| [aef5150719f03ce87e67c17d2006e24d8961aa17] | committer: Justin Ruggles

flac: only set channel layout if not previously set or on channel count change

Fixes Bug 402

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aef5150719f03ce87e67c17d2006e24d8961aa17
---

 libavcodec/flac_parser.c |    7 +++++--
 libavcodec/flacdec.c     |    3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
index f0a37f3..3d8e17f 100644
--- a/libavcodec/flac_parser.c
+++ b/libavcodec/flac_parser.c
@@ -457,9 +457,12 @@ static int get_best_header(FLACParseContext* fpc, const uint8_t **poutbuf,
         check_header_mismatch(fpc, header, child, 0);
     }
 
+    if (header->fi.channels != fpc->avctx->channels ||
+        (!fpc->avctx->channel_layout && header->fi.channels <= 6)) {
+        fpc->avctx->channels = header->fi.channels;
+        ff_flac_set_channel_layout(fpc->avctx);
+    }
     fpc->avctx->sample_rate = header->fi.samplerate;
-    fpc->avctx->channels    = header->fi.channels;
-    ff_flac_set_channel_layout(fpc->avctx);
     fpc->pc->duration       = header->fi.blocksize;
     *poutbuf = flac_fifo_read_wrap(fpc, header->offset, *poutbuf_size,
                                         &fpc->wrap_buf,
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index fd47929..51fd196 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -426,7 +426,8 @@ static int decode_frame(FLACContext *s)
             return ret;
     }
     s->channels = s->avctx->channels = fi.channels;
-    ff_flac_set_channel_layout(s->avctx);
+    if (!s->avctx->channel_layout && s->channels <= 6)
+        ff_flac_set_channel_layout(s->avctx);
     s->ch_mode = fi.ch_mode;
 
     if (!s->bps && !fi.bps) {



More information about the ffmpeg-cvslog mailing list