]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mlp_parser.c
mxf: Support AAC
[ffmpeg] / libavcodec / mlp_parser.c
index 7f6739fabfb23475899ee928cde4742310900985..075227f302dbbdb1ec9e0294006617bc2109f7fc 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
+#include "libavutil/internal.h"
 #include "get_bits.h"
 #include "parser.h"
 #include "mlp_parser.h"
@@ -168,13 +169,16 @@ int ff_mlp_read_major_sync(void *log, MLPHeaderInfo *mh, GetBitContext *gb)
         mh->group1_samplerate = mlp_samplerate(ratebits);
         mh->group2_samplerate = 0;
 
-        skip_bits(gb, 8);
+        skip_bits(gb, 4);
+
+        mh->channel_modifier_thd_stream0 = get_bits(gb, 2);
+        mh->channel_modifier_thd_stream1 = get_bits(gb, 2);
 
         channel_arrangement            = get_bits(gb, 5);
         mh->channels_thd_stream1       = truehd_channels(channel_arrangement);
         mh->channel_layout_thd_stream1 = truehd_layout(channel_arrangement);
 
-        skip_bits(gb, 2);
+        mh->channel_modifier_thd_stream2 = get_bits(gb, 2);
 
         channel_arrangement            = get_bits(gb, 13);
         mh->channels_thd_stream2       = truehd_channels(channel_arrangement);
@@ -323,13 +327,17 @@ static int mlp_parse(AVCodecParserContext *s,
         if (mh.stream_type == 0xbb) {
             /* MLP stream */
 #if FF_API_REQUEST_CHANNELS
+FF_DISABLE_DEPRECATION_WARNINGS
             if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
                 mh.num_substreams > 1) {
                 avctx->channels       = 2;
                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
             } else
+FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-            if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
+            if (avctx->request_channel_layout &&
+                (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) ==
+                avctx->request_channel_layout &&
                 mh.num_substreams > 1) {
                 avctx->channels       = 2;
                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
@@ -340,6 +348,7 @@ static int mlp_parse(AVCodecParserContext *s,
         } else { /* mh.stream_type == 0xba */
             /* TrueHD stream */
 #if FF_API_REQUEST_CHANNELS
+FF_DISABLE_DEPRECATION_WARNINGS
             if (avctx->request_channels > 0 && avctx->request_channels <= 2 &&
                 mh.num_substreams > 1) {
                 avctx->channels       = 2;
@@ -349,13 +358,18 @@ static int mlp_parse(AVCodecParserContext *s,
                 avctx->channels       = mh.channels_thd_stream1;
                 avctx->channel_layout = mh.channel_layout_thd_stream1;
             } else
+FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-            if (avctx->request_channel_layout == AV_CH_LAYOUT_STEREO &&
-                mh.num_substreams > 1) {
+                if (avctx->request_channel_layout &&
+                    (avctx->request_channel_layout & AV_CH_LAYOUT_STEREO) ==
+                    avctx->request_channel_layout &&
+                    mh.num_substreams > 1) {
                 avctx->channels       = 2;
                 avctx->channel_layout = AV_CH_LAYOUT_STEREO;
-            } else if (avctx->request_channel_layout == mh.channel_layout_thd_stream1 ||
-                       !mh.channels_thd_stream2) {
+            } else if (!mh.channels_thd_stream2 ||
+                       (avctx->request_channel_layout &&
+                        (avctx->request_channel_layout & mh.channel_layout_thd_stream1) ==
+                        avctx->request_channel_layout)) {
                 avctx->channels       = mh.channels_thd_stream1;
                 avctx->channel_layout = mh.channel_layout_thd_stream1;
             } else {