---
 libavcodec/flac.c    |    3 ++-
 libavcodec/flac.h    |    8 ++++----
 libavcodec/flacenc.c |   13 +++----------
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/libavcodec/flac.c b/libavcodec/flac.c
index e6a427a..ac36376 100644
--- a/libavcodec/flac.c
+++ b/libavcodec/flac.c
@@ -55,8 +55,9 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, 
GetBitContext *gb,
     if (fi->ch_mode < FLAC_MAX_CHANNELS) {
         fi->channels = fi->ch_mode + 1;
         fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
-    } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
+    } else if (fi->ch_mode < FLAC_MAX_CHANNELS + FLAC_CHMODE_MID_SIDE) {
         fi->channels = 2;
+        fi->ch_mode -= FLAC_MAX_CHANNELS - 1;
     } else {
         av_log(avctx, AV_LOG_ERROR + log_level_offset,
                "invalid channel mode: %d\n", fi->ch_mode);
diff --git a/libavcodec/flac.h b/libavcodec/flac.h
index b826fd4..55bacea 100644
--- a/libavcodec/flac.h
+++ b/libavcodec/flac.h
@@ -37,10 +37,10 @@
 #define FLAC_MIN_FRAME_SIZE    11
 
 enum {
-    FLAC_CHMODE_INDEPENDENT =  0,
-    FLAC_CHMODE_LEFT_SIDE   =  8,
-    FLAC_CHMODE_RIGHT_SIDE  =  9,
-    FLAC_CHMODE_MID_SIDE    = 10,
+    FLAC_CHMODE_INDEPENDENT = 0,
+    FLAC_CHMODE_LEFT_SIDE   = 1,
+    FLAC_CHMODE_RIGHT_SIDE  = 2,
+    FLAC_CHMODE_MID_SIDE    = 3,
 };
 
 enum {
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index fc1f00a..5d67471 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -1000,15 +1000,8 @@ static int estimate_stereo_mode(int32_t *left_ch, 
int32_t *right_ch, int n)
     for (i = 1; i < 4; i++)
         if (score[i] < score[best])
             best = i;
-    if (best == 0) {
-        return FLAC_CHMODE_INDEPENDENT;
-    } else if (best == 1) {
-        return FLAC_CHMODE_LEFT_SIDE;
-    } else if (best == 2) {
-        return FLAC_CHMODE_RIGHT_SIDE;
-    } else {
-        return FLAC_CHMODE_MID_SIDE;
-    }
+
+    return best;
 }
 
 
@@ -1077,7 +1070,7 @@ static void write_frame_header(FlacEncodeContext *s)
     if (frame->ch_mode == FLAC_CHMODE_INDEPENDENT)
         put_bits(&s->pb, 4, s->channels-1);
     else
-        put_bits(&s->pb, 4, frame->ch_mode);
+        put_bits(&s->pb, 4, frame->ch_mode + FLAC_MAX_CHANNELS - 1);
 
     put_bits(&s->pb, 3, 4); /* bits-per-sample code */
     put_bits(&s->pb, 1, 0);
-- 
1.7.10.2

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to