On 06/13/2011 05:23 AM, Anton Khirnov wrote:

> From: Carl Eugen Hoyos <[email protected]>
> 
> TrueHD supports more channels than FFmpeg, so a valid sample
> could set the channel layout to a value that represents less
> channels than the sample actually consists of.
> 
> Signed-off-by: Anton Khirnov <[email protected]>
> ---
>  libavcodec/mlp_parser.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
> index e85eb72..7f694d9 100644
> --- a/libavcodec/mlp_parser.c
> +++ b/libavcodec/mlp_parser.c
> @@ -326,6 +326,10 @@ static int mlp_parse(AVCodecParserContext *s,
>                  avctx->channels = truehd_channels(mh.channels_thd_stream1);
>                  avctx->channel_layout = 
> truehd_layout(mh.channels_thd_stream1);
>              }
> +            if (av_get_channel_layout_nb_channels(avctx->channel_layout) != 
> avctx->channels) {
> +                avctx->channel_layout = 0;
> +                av_log_ask_for_sample(avctx, "Unknown channel layout.");
> +            }
>          }
>  
>          if (!mh.is_vbr) /* Stream is CBR */


This doesn't make sense.  If there are channels in TrueHD that aren't
"supported" (i.e. defined) then we should just define them.  It looks
like currently SIDE_LEFT and SIDE_RIGHT are duplicated twice, but all
the other channels are unique.

static const uint64_t thd_layout[13] = {
    ...
    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRs
    ...
    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRc
    ...
    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRsd
};

It looks like we need:
Left center
Right center
Left surround direct
Right surround direct

Like attached.

-Justin
>From 606323317b6791fb7965d9747578b4226be458f7 Mon Sep 17 00:00:00 2001
From: Justin Ruggles <[email protected]>
Date: Mon, 13 Jun 2011 08:38:18 -0400
Subject: [PATCH] Add new channel layouts and use them in the MLP/TrueHD parser.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------1.7.1"

This is a multi-part message in MIME format.
--------------1.7.1
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 libavcodec/mlp_parser.c  |    7 ++++---
 libavutil/audioconvert.h |    4 ++++
 2 files changed, 8 insertions(+), 3 deletions(-)


--------------1.7.1
Content-Type: text/x-patch; name="0001-Add-new-channel-layouts-and-use-them-in-the-MLP-True.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-Add-new-channel-layouts-and-use-them-in-the-MLP-True.patch"

diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
index e85eb72..5a77865 100644
--- a/libavcodec/mlp_parser.c
+++ b/libavcodec/mlp_parser.c
@@ -79,11 +79,11 @@ static const uint64_t thd_layout[13] = {
     AV_CH_LOW_FREQUENCY,                                    // LFE
     AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRs
     AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT,             // LRvh
-    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRc
+    AV_CH_LEFT_CENTER|AV_CH_RIGHT_CENTER,                   // LRc
     AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT,                       // LRrs
     AV_CH_BACK_CENTER,                                      // Cs
     AV_CH_TOP_BACK_CENTER,                                  // Ts
-    AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT,                       // LRsd
+    AV_CH_LEFT_SURROUND_DIRECT|AV_CH_RIGHT_SURROUND_DIRECT, // LRsd
     AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER, // LRw
     AV_CH_TOP_BACK_CENTER,                                  // Cvh
     AV_CH_LOW_FREQUENCY                                     // LFE2
@@ -109,7 +109,8 @@ static int truehd_channels(int chanmap)
 
 static int64_t truehd_layout(int chanmap)
 {
-    int layout = 0, i;
+    int i;
+    int64_t layout = 0;
 
     for (i = 0; i < 13; i++)
         layout |= thd_layout[i] * ((chanmap >> i) & 1);
diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h
index e37a2e8..2069bd1 100644
--- a/libavutil/audioconvert.h
+++ b/libavutil/audioconvert.h
@@ -50,6 +50,10 @@
 #define AV_CH_TOP_BACK_RIGHT         0x00020000
 #define AV_CH_STEREO_LEFT            0x20000000  ///< Stereo downmix.
 #define AV_CH_STEREO_RIGHT           0x40000000  ///< See AV_CH_STEREO_LEFT.
+#define AV_CH_LEFT_CENTER            0x80000000
+#define AV_CH_RIGHT_CENTER          0x100000000
+#define AV_CH_LEFT_SURROUND_DIRECT  0x200000000
+#define AV_CH_RIGHT_SURROUND_DIRECT 0x400000000
 
 /** Channel mask value used for AVCodecContext.request_channel_layout
     to indicate that the user requests the channel order of the decoder output

--------------1.7.1--


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

Reply via email to