]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mlpdec.c
Merge commit '36ac9a16a19a365ce58cc871484c20cffe9b6401'
[ffmpeg] / libavcodec / mlpdec.c
index 5fae4d1160f7ebe097668e0c4d05c6cea0df07da..d587982e8c89c30396dd50235ee0fca9880edfdb 100644 (file)
 #include <stdint.h>
 
 #include "avcodec.h"
-#include "dsputil.h"
 #include "libavutil/intreadwrite.h"
 #include "get_bits.h"
 #include "libavutil/crc.h"
 #include "parser.h"
 #include "mlp_parser.h"
+#include "mlpdsp.h"
 #include "mlp.h"
 
 /** number of bits used for VLC lookup - longest Huffman code is 9 */
@@ -145,7 +145,7 @@ typedef struct MLPDecodeContext {
     int8_t      bypassed_lsbs[MAX_BLOCKSIZE][MAX_CHANNELS];
     int32_t     sample_buffer[MAX_BLOCKSIZE][MAX_CHANNELS];
 
-    DSPContext  dsp;
+    MLPDSPContext dsp;
 } MLPDecodeContext;
 
 static VLC huff_vlc[3];
@@ -235,7 +235,7 @@ static av_cold int mlp_decode_init(AVCodecContext *avctx)
     m->avctx = avctx;
     for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
         m->substream[substr].lossless_check_data = 0xffffffff;
-    ff_dsputil_init(&m->dsp, avctx);
+    ff_mlpdsp_init(&m->dsp);
 
     avcodec_get_frame_defaults(&m->frame);
     avctx->coded_frame = &m->frame;
@@ -337,6 +337,12 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
         } else {
             m->avctx->channel_layout = ff_truehd_layout(mh.channels_thd_stream1);
         }
+        if (m->avctx->channels<=2 && m->avctx->channel_layout == AV_CH_LAYOUT_MONO && m->max_decoded_substream == 1) {
+            av_log(m->avctx, AV_LOG_DEBUG, "Mono stream with 2 substreams, ignoring 2nd\n");
+            m->max_decoded_substream = 0;
+            if (m->avctx->channels==2)
+                m->avctx->channel_layout = AV_CH_LAYOUT_STEREO;
+        }
         if (m->avctx->channels &&
             !m->avctx->request_channels && !m->avctx->request_channel_layout &&
             av_get_channel_layout_nb_channels(m->avctx->channel_layout) != m->avctx->channels) {