]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpc8.c
ac3enc: use dsputil functions in apply_window()
[ffmpeg] / libavcodec / mpc8.c
index 780f0b7066a1fcaf5c4c44e05cec0a453509f81f..d8d62edd9c23f17c7f54668ba17dcf7727e30b85 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file libavcodec/mpc8.c Musepack SV8 decoder
+ * @file
  * MPEG Audio Layer 1/2 -like codec with frames of 1152 samples
  * divided into 32 subbands.
  */
@@ -99,6 +99,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
     MPCContext *c = avctx->priv_data;
     GetBitContext gb;
     static int vlc_initialized = 0;
+    int channels;
 
     static VLC_TYPE band_table[542][2];
     static VLC_TYPE q1_table[520][2];
@@ -125,11 +126,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
 
     skip_bits(&gb, 3);//sample rate
     c->maxbands = get_bits(&gb, 5) + 1;
-    skip_bits(&gb, 4);//channels
+    channels = get_bits(&gb, 4) + 1;
+    if (channels > 2) {
+        av_log_missing_feature(avctx, "Multichannel MPC SV8", 1);
+        return -1;
+    }
     c->MSS = get_bits1(&gb);
     c->frames = 1 << (get_bits(&gb, 3) * 2);
 
-    avctx->sample_fmt = SAMPLE_FMT_S16;
+    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
     avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
 
     if(vlc_initialized) return 0;
@@ -387,14 +392,14 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
         }
     }
 
-    ff_mpc_dequantize_and_synth(c, maxband, data);
+    ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
 
     c->cur_frame++;
 
     c->last_bits_used = get_bits_count(gb);
     if(c->cur_frame >= c->frames)
         c->cur_frame = 0;
-    *data_size =  MPC_FRAME_SIZE * 4;
+    *data_size =  MPC_FRAME_SIZE * 2 * avctx->channels;
 
     return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
 }