]> granicus.if.org Git - handbrake/commitdiff
libhb: drop HB_INPUT_CH_LAYOUT_*
authorRodeo <tdskywalker@gmail.com>
Mon, 18 Jun 2012 21:11:48 +0000 (21:11 +0000)
committerRodeo <tdskywalker@gmail.com>
Mon, 18 Jun 2012 21:11:48 +0000 (21:11 +0000)
AV_CH_LAYOUT_* works for us, and as its usage becomes more widespread in libhb, translating between the two formats gets increasingly tedious.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4754 b64f7644-9d1e-0410-96f1-a4d463321fa5

22 files changed:
gtk/configure.ac
gtk/src/hb-backend.c
libhb/common.c
libhb/common.h
libhb/deca52.c
libhb/decavcodec.c
libhb/decdca.c
libhb/declpcm.c
libhb/downmix.c
libhb/downmix.h
libhb/encavcodecaudio.c
libhb/hb.c
libhb/hbffmpeg.h
libhb/muxmkv.c
libhb/muxmp4.c
libhb/platform/macosx/encca_aac.c
libhb/scan.c
libhb/stream.c
libhb/sync.c
macosx/HBAudio.m
macosx/HBAudioController.m
macosx/HandBrake.xcodeproj/project.pbxproj

index 94219c32d3406d10f2c68e1331e5348a999e93da..b4965c48ff5b2f8e0bf841a7770f8bc203ac8f0a 100644 (file)
@@ -36,21 +36,21 @@ AC_ARG_WITH(hb,
 if test  $hb_PATHSET = 1 ; then
     case ${with_hb} in
     /*)
-               CXXFLAGS="$CXXFLAGS -I$with_hb/libhb"
-               CFLAGS="$CFLAGS -I$with_hb/libhb"
+               CXXFLAGS="$CXXFLAGS -I$with_hb/libhb -I$with_hb/contrib/include"
+               CFLAGS="$CFLAGS -I$with_hb/libhb -I$with_hb/contrib/include"
                LDFLAGS="$LDFLAGS -L$with_hb/libhb -L$with_hb/contrib/lib"
                AC_SUBST(HB_DIR, "$with_hb")
         ;;
     *)
-               CXXFLAGS="$CXXFLAGS "'-I$(top_srcdir)/'"$with_hb/libhb"
-               CFLAGS="$CFLAGS "'-I$(top_srcdir)/'"$with_hb/libhb"
+               CXXFLAGS="$CXXFLAGS "'-I$(top_srcdir)/'"$with_hb/libhb "'-I$(top_srcdir)/'"$with_hb/contrib/include"
+               CFLAGS="$CXXFLAGS "'-I$(top_srcdir)/'"$with_hb/libhb "'-I$(top_srcdir)/'"$with_hb/contrib/include"
                LDFLAGS="$LDFLAGS "'-L$(top_srcdir)/'"$with_hb/libhb "'-L$(top_srcdir)/'"$with_hb/contrib/lib"
                AC_SUBST(HB_DIR, '$(top_srcdir)/'"$with_hb")
         ;;
     esac
 else
-       CXXFLAGS="$CXXFLAGS "'-I$(top_srcdir)/'"../libhb"
-       CFLAGS="$CFLAGS "'-I$(top_srcdir)/'"../libhb"
+       CXXFLAGS="$CXXFLAGS "'-I$(top_srcdir)/'"../libhb "'-I$(top_srcdir)/'"../contrib/include"
+       CFLAGS="$CXXFLAGS "'-I$(top_srcdir)/'"../libhb "'-I$(top_srcdir)/'"../contrib/include"
        LDFLAGS="$LDFLAGS "'-L$(top_srcdir)/'"../libhb "'-L$(top_srcdir)/'"../contrib/lib"
        AC_SUBST(HB_DIR, '$(top_srcdir)/'"..")
 fi
index 46898b9c89b76dfaa471700b0a49d411abf43814..a4d5ee0402f12c0eaece720db861b43f77ab8192 100644 (file)
@@ -1702,8 +1702,7 @@ gint
 ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix)
 {
        gint layout;
-       layout = aconfig ? aconfig->in.channel_layout : 
-                                               HB_INPUT_CH_LAYOUT_3F2R | HB_INPUT_CH_LAYOUT_HAS_LFE;
+       layout = aconfig ? aconfig->in.channel_layout : AV_CH_LAYOUT_5POINT1;
        return hb_get_best_mixdown( acodec, layout, mix );
 }
 
@@ -2438,7 +2437,7 @@ ghb_find_audio_track(
                        if (used[ii])
                                continue;
 
-                       channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+                       channels = av_get_channel_layout_nb_channels(
                                                                                                        audio->in.channel_layout);
                        // Find a track that is not visually impaired or dirctor's
                        // commentary, and has the highest channel count.
@@ -2482,7 +2481,7 @@ ghb_find_audio_track(
                        if (passthru_used[ii])
                                continue;
                }
-               channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+               channels = av_get_channel_layout_nb_channels(
                                                                                                audio->in.channel_layout);
                // Find a track that is not visually impaired or dirctor's commentary
                if ((audio->lang.type < 2) &&
@@ -2519,7 +2518,7 @@ ghb_find_audio_track(
                        if (used[ii])
                                continue;
 
-                       channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+                       channels = av_get_channel_layout_nb_channels(
                                                                                                        audio->in.channel_layout);
                        // Find a track that is not visually impaired or dirctor's
                        // commentary, and has the highest channel count.
@@ -2554,7 +2553,7 @@ ghb_find_audio_track(
                audio = (hb_audio_config_t*)hb_list_audio_config_item( 
                                                                                                        title->list_audio, ii );
                passthru_acodec = HB_ACODEC_PASS_MASK & audio->in.codec;
-               channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+               channels = av_get_channel_layout_nb_channels(
                                                                                                audio->in.channel_layout);
                if (passthru_acodec && passthru)
                {
index 87f4766bb80341a5483e01f5a1984b6056f7c536..93c98ffa49d7bb4f4b58f9093bc95c85d10ba217 100644 (file)
@@ -720,37 +720,35 @@ int hb_get_best_mixdown( uint32_t codec, int layout, int mixdown )
         // Audio pass-thru.  No mixdown.
         return HB_AMIXDOWN_NONE;
     }
-    switch (layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK)
+    switch (layout & ~AV_CH_LOW_FREQUENCY)
     {
         // mono input
-        case HB_INPUT_CH_LAYOUT_MONO:
+        case AV_CH_LAYOUT_MONO:
             best_mixdown = HB_AMIXDOWN_MONO;
             break;
 
         // Dolby Pro Logic (a.k.a. Dolby Surround), 4.0 channels (matrix-encoded)
         // The A52 flags don't allow for a way to distinguish between DPL1 and
         // DPL2 on a DVD so we always assume a DPL1 source for A52_DOLBY.
-        case HB_INPUT_CH_LAYOUT_DOLBY:
+        case AV_CH_LAYOUT_STEREO_DOWNMIX:
         // 3 or 4 discrete channels
-        // case HB_INPUT_CH_LAYOUT_3F:   // FIXME: can it be downmixed to Dolby?
-        // case HB_INPUT_CH_LAYOUT_2F1R: // FIXME: can it be downmixed to Dolby?
-        case HB_INPUT_CH_LAYOUT_2F2R:
-        case HB_INPUT_CH_LAYOUT_3F1R:
-            // a52dec and libdca can't upmix to 6ch, 
-            // so we must downmix these.
-            // libdca only supports DPLII if the source is 3F2R to begin with
+        case AV_CH_LAYOUT_2_1:
+        case AV_CH_LAYOUT_2_2:
+        case AV_CH_LAYOUT_QUAD:
+        case AV_CH_LAYOUT_4POINT0:
+        case AV_CH_LAYOUT_SURROUND:
+            // a52dec and libdca can't upmix to 6ch, so we must downmix these.
+            // libdca only supports DPLII if the source is 3F2R to begin with.
             best_mixdown = HB_AMIXDOWN_DOLBY;
             break;
 
         // 5 to 8 discrete channels
-        case HB_INPUT_CH_LAYOUT_4F2R:
-        case HB_INPUT_CH_LAYOUT_3F4R:
-        case HB_INPUT_CH_LAYOUT_3F2R:
-            if (!(layout & HB_INPUT_CH_LAYOUT_HAS_LFE))
+        case AV_CH_LAYOUT_5POINT0:
+        case AV_CH_LAYOUT_7POINT0:
+            if (!(layout & AV_CH_LOW_FREQUENCY))
             {
                 // we don't do 5-channel discrete
-                // a52dec and libdca can't upmix to 6ch, 
-                // so we must downmix this.
+                // a52dec and libdca can't upmix to 6ch, so we must downmix this.
                 best_mixdown = HB_AMIXDOWN_DOLBYPLII;
             }
             else
index c0cd46e5eaf6614a30a9a4c8a4a8205769141a11..059defc68be1b96bf68d3bd947b45bba9819830d 100644 (file)
@@ -20,6 +20,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include "libavutil/audioconvert.h"
 
 /*
  * It seems WinXP doesn't align the stack of new threads to 16 bytes.
@@ -423,34 +424,6 @@ struct hb_job_s
 #define HB_SUBSTREAM_BD_DTSHD   0x72
 #define HB_SUBSTREAM_BD_DTS     0x71
 
-/* Input Channel Layout */
-/* define some masks, used to extract the various information from the HB_INPUT_CH_LAYOUT_* values */
-#define HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK  0x00F0000
-#define HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK   0x000F000
-#define HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK    0x0000F00
-#define HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK 0xFFFF0FF
-#define HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK   0x00000F0
-#define HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK    0x000000F
-/* define the input channel layouts used to describe the channel layout of this audio */
-#define HB_INPUT_CH_LAYOUT_MONO    0x0110010
-#define HB_INPUT_CH_LAYOUT_STEREO  0x0220020
-#define HB_INPUT_CH_LAYOUT_DOLBY   0x0320031
-#define HB_INPUT_CH_LAYOUT_3F      0x0430030
-#define HB_INPUT_CH_LAYOUT_2F1R    0x0521021
-#define HB_INPUT_CH_LAYOUT_3F1R    0x0631031
-#define HB_INPUT_CH_LAYOUT_2F2R    0x0722022
-#define HB_INPUT_CH_LAYOUT_3F2R    0x0832032
-#define HB_INPUT_CH_LAYOUT_4F2R    0x0942042
-#define HB_INPUT_CH_LAYOUT_3F4R    0x0a34034
-#define HB_INPUT_CH_LAYOUT_HAS_LFE 0x0000100
-/* define some macros to extract the various information from the HB_INPUT_CH_LAYOUT_* values */
-#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT( a ) ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK ) >> 16 )
-#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT( a )  ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK ) >> 12 )
-#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT( a )   ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK ) >> 8 )
-#define HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( a ) ( ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_FRONT_MASK ) >> 16 ) + ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_REAR_MASK ) >> 12 ) + ( ( a & HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK ) >> 8 ) )
-#define HB_INPUT_CH_LAYOUT_GET_ENCODED_FRONT_COUNT( a )   ( ( a & HB_INPUT_CH_LAYOUT_ENCODED_FRONT_MASK ) >> 4 )
-#define HB_INPUT_CH_LAYOUT_GET_ENCODED_REAR_COUNT( a )   ( ( a & HB_INPUT_CH_LAYOUT_ENCODED_REAR_MASK ) )
-
 /* define an invalid VBR quality compatible with all VBR-capable codecs */
 #define HB_INVALID_AUDIO_QUALITY (-3.)
 
@@ -495,7 +468,7 @@ struct hb_audio_config_s
         PRIVATE int samplerate; /* Input sample rate (Hz) */
         PRIVATE int samples_per_frame; /* Number of samples per frame */
         PRIVATE int bitrate; /* Input bitrate (bps) */
-        PRIVATE int channel_layout; /* Source channel layout, set by the audio decoder */
+        PRIVATE uint64_t channel_layout; /* Source channel layout, set by the audio decoder */
         PRIVATE hb_chan_map_t * channel_map; /* Source channel map, set by the audio decoder */
     } in;
 
@@ -778,18 +751,21 @@ typedef struct hb_work_info_s
     uint32_t     version;
     uint32_t     flags;
     uint32_t     mode;
-    union {
-        struct {    // info only valid for video decoders
-            int     width;
-            int     height;
-            int     pixel_aspect_width;
-            int     pixel_aspect_height;
-            int     color_prim;
-            int     color_transfer;
-            int     color_matrix;
+    union
+    {
+        struct
+        {    // info only valid for video decoders
+            int width;
+            int height;
+            int pixel_aspect_width;
+            int pixel_aspect_height;
+            int color_prim;
+            int color_transfer;
+            int color_matrix;
         };
-        struct {    // info only valid for audio decoders
-            int     channel_layout;
+        struct
+        {    // info only valid for audio decoders
+            uint64_t channel_layout;
             hb_chan_map_t * channel_map;
             int samples_per_frame;
         };
index d832002a89f360582d1519a6795627070cee3825..22bfb55da9f906d8a5e64805fd0a8e64d0f6f3bd 100644 (file)
@@ -108,11 +108,11 @@ static int deca52Init( hb_work_object_t * w, hb_job_t * job )
     switch( audio->config.out.mixdown )
     {
         case HB_AMIXDOWN_6CH:
-            pv->flags_out = ( A52_3F2R | A52_LFE );
+            pv->flags_out = (A52_3F2R|A52_LFE);
             break;
 
         case HB_AMIXDOWN_DOLBYPLII:
-            pv->flags_out = ( A52_DOLBY | A52_USE_DPLII );
+            pv->flags_out = (A52_DOLBY|A52_USE_DPLII);
             break;
 
         case HB_AMIXDOWN_DOLBY:
@@ -445,43 +445,43 @@ static int deca52BSInfo( hb_work_object_t *w, const hb_buffer_t *b,
         case A52_MONO:
         case A52_CHANNEL1:
         case A52_CHANNEL2:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_MONO;
+            info->channel_layout = AV_CH_LAYOUT_MONO;
             break;
         /* stereo input */
         case A52_CHANNEL:
         case A52_STEREO:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
+            info->channel_layout = AV_CH_LAYOUT_STEREO;
             break;
         /* Dolby Pro Logic (a.k.a. Dolby Surround), 4.0 channels (matrix-encoded) */
         case A52_DOLBY:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_DOLBY;
+            info->channel_layout = AV_CH_LAYOUT_STEREO_DOWNMIX;
             break;
         /* 3F/2R input */
         case A52_3F2R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_3F2R;
+            info->channel_layout = AV_CH_LAYOUT_5POINT0;
             break;
         /* 3F/1R input */
         case A52_3F1R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_3F1R;
+            info->channel_layout = AV_CH_LAYOUT_4POINT0;
             break;
         /* other inputs */
         case A52_3F:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_3F;
+            info->channel_layout = AV_CH_LAYOUT_SURROUND;
             break;
         case A52_2F1R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_2F1R;
+            info->channel_layout = AV_CH_LAYOUT_2_1;
             break;
         case A52_2F2R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_2F2R;
+            info->channel_layout = AV_CH_LAYOUT_2_2;
             break;
         /* unknown */
         default:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
+            info->channel_layout = AV_CH_LAYOUT_STEREO;
     }
 
     if (flags & A52_LFE)
     {
-        info->channel_layout |= HB_INPUT_CH_LAYOUT_HAS_LFE;
+        info->channel_layout |= AV_CH_LOW_FREQUENCY;
     }
 
     info->channel_map = &hb_ac3_chan_map;
index 527b5791f03b11eb02787c4f75369c2406d8700e..8a236ca4ad74fc78d646c6d3ce187c34e43f7a2c 100644 (file)
@@ -212,24 +212,22 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job )
     }
 
     // DTS: work around lack of 6.0/6.1 support in libhb
-    if( hb_ff_dts_disable_xch( pv->context ) )
+    if (hb_ff_dts_disable_xch(pv->context))
     {
-        hb_deep_log( 2, "decavcodecaInit: found DTS-ES, requesting DTS core" );
+        hb_deep_log(2, "decavcodecaInit: found DTS-ES, requesting DTS core");
     }
-    else if( ( !pv->context->channels || !pv->context->channel_layout ) &&
-             ( w->audio->config.in.codec == HB_ACODEC_DCA_HD ) &&
-             ( ( w->audio->config.in.channel_layout & ~HB_INPUT_CH_LAYOUT_HAS_LFE ) == HB_INPUT_CH_LAYOUT_3F2R ) )
+    else if ((!pv->context->channels || !pv->context->channel_layout) &&
+             (w->audio->config.in.codec == HB_ACODEC_DCA_HD) &&
+             ((w->audio->config.in.channel_layout & ~AV_CH_LOW_FREQUENCY) == AV_CH_LAYOUT_5POINT0))
     {
         /* XXX: when we are demuxing the stream ourselves, it seems we have no
          * channel count/layout info in the context until we decode audio for
          * the first time. If the scan info says the source is 5.0 or 5.1,
          * make sure XCh processing is disabled in Libav before decoding. */
         pv->context->request_channels = pv->context->channels =
-            HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( w->audio->config.in.channel_layout );
-        pv->context->channel_layout = AV_CH_LAYOUT_5POINT0;
-        if( w->audio->config.in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE )
-            pv->context->channel_layout |= AV_CH_LOW_FREQUENCY;
-        hb_deep_log( 2, "decavcodecaInit: scan detected DTS 5.0/5.1, disabling XCh processing" );
+            av_get_channel_layout_nb_channels(w->audio->config.in.channel_layout);
+        pv->context->channel_layout = w->audio->config.in.channel_layout;
+        hb_deep_log(2, "decavcodecaInit: scan detected DTS 5.0/5.1, disabling XCh processing");
     }
 
     if ( w->audio != NULL )
index c9236b0f88014f265341c1f90910abc2a55187ea..9f426d6a4de466945db2c87391207a7fa9aa71a1 100644 (file)
@@ -84,56 +84,58 @@ static int decdcaInit( hb_work_object_t * w, hb_job_t * job )
     /* Decide what format we want out of libdca;
      * work.c has already done some of this deduction for us in do_job().
      * Dolby Surround and Pro Logic II are a bit tricky. */
-    int layout = ( audio->config.in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK );
-    switch( audio->config.out.mixdown )
+    int layout = (audio->config.in.channel_layout & ~AV_CH_LOW_FREQUENCY);
+    switch (audio->config.out.mixdown)
     {
         case HB_AMIXDOWN_6CH:
-            pv->flags_out = ( DCA_3F2R | DCA_LFE );
+            pv->flags_out = (DCA_3F2R|DCA_LFE);
             break;
 
         case HB_AMIXDOWN_DOLBYPLII:
         {
-            if( layout == HB_INPUT_CH_LAYOUT_3F2R )
+            if (layout == AV_CH_LAYOUT_5POINT0)
             {
                 // Dolby Pro Logic II output is supported
-                pv->flags_out = ( DCA_3F2R | DCA_OUT_DPLII );
+                pv->flags_out = (DCA_3F2R|DCA_OUT_DPLII);
             }
-            else if( layout == HB_INPUT_CH_LAYOUT_3F1R )
+            else if (layout == AV_CH_LAYOUT_4POINT0)
             {
                 // Dolby Surround output and DCA_3F1R downmix are supported
-                pv->flags_out = ( DCA_3F1R | DCA_OUT_DPLI );
+                pv->flags_out = (DCA_3F1R|DCA_OUT_DPLI);
             }
-            else if( layout > HB_INPUT_CH_LAYOUT_DOLBY )
-            {
-                // Dolby Surround output is supported, but DCA_3F1R downmix isn't
-                pv->flags_out = DCA_DOLBY;
-            }
-            else
+            else if (layout == AV_CH_LAYOUT_STEREO ||
+                     layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
             {
                 // Dolby Surround output not supported OR
                 // Dolby Surround input just gets passed through as is
                 pv->flags_out = DCA_STEREO;
             }
+            else
+            {
+                // Dolby Surround output is supported, but DCA_3F1R downmix isn't
+                pv->flags_out = DCA_DOLBY;
+            }
         } break;
 
         case HB_AMIXDOWN_DOLBY:
         {
-            if( layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_3F1R )
+            if (layout == AV_CH_LAYOUT_5POINT0 || layout == AV_CH_LAYOUT_4POINT0)
             {
                 // Dolby Surround output and DCA_3F1R downmix are supported
-                pv->flags_out = ( DCA_3F1R | DCA_OUT_DPLI );
+                pv->flags_out = (DCA_3F1R|DCA_OUT_DPLI);
             }
-            else if( layout > HB_INPUT_CH_LAYOUT_DOLBY )
-            {
-                // Dolby Surround output is supported, but DCA_3F1R downmix isn't
-                pv->flags_out = DCA_DOLBY;
-            }
-            else
+            else if (layout == AV_CH_LAYOUT_STEREO ||
+                     layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
             {
                 // Dolby Surround output not supported OR
                 // Dolby Surround input just gets passed through as is
                 pv->flags_out = DCA_STEREO;
             }
+            else
+            {
+                // Dolby Surround output is supported, but DCA_3F1R downmix isn't
+                pv->flags_out = DCA_DOLBY;
+            }
         } break;
 
         case HB_AMIXDOWN_MONO:
@@ -379,48 +381,48 @@ static int decdcaBSInfo( hb_work_object_t *w, const hb_buffer_t *b,
     {
         /* mono sources */
         case DCA_MONO:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_MONO;
+            info->channel_layout = AV_CH_LAYOUT_MONO;
             break;
         /* stereo input */
         case DCA_CHANNEL:
         case DCA_STEREO:
         case DCA_STEREO_SUMDIFF:
         case DCA_STEREO_TOTAL:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
+            info->channel_layout = AV_CH_LAYOUT_STEREO;
             break;
         /* Dolby Pro Logic (a.k.a. Dolby Surround), 4.0 channels (matrix-encoded) */
         case DCA_DOLBY:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_DOLBY;
+            info->channel_layout = AV_CH_LAYOUT_STEREO_DOWNMIX;
             break;
         /* 3F/2R input */
         case DCA_3F2R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_3F2R;
+            info->channel_layout = AV_CH_LAYOUT_5POINT0;
             break;
         /* 3F/1R input */
         case DCA_3F1R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_3F1R;
+            info->channel_layout = AV_CH_LAYOUT_4POINT0;
             break;
         /* other inputs */
         case DCA_3F:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_3F;
+            info->channel_layout = AV_CH_LAYOUT_SURROUND;
             break;
         case DCA_2F1R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_2F1R;
+            info->channel_layout = AV_CH_LAYOUT_2_1;
             break;
         case DCA_2F2R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_2F2R;
+            info->channel_layout = AV_CH_LAYOUT_2_2;
             break;
         case DCA_4F2R:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_4F2R;
+            info->channel_layout = AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER;
             break;
         /* unknown */
         default:
-            info->channel_layout = HB_INPUT_CH_LAYOUT_STEREO;
+            info->channel_layout = AV_CH_LAYOUT_STEREO;
     }
 
     if (flags & DCA_LFE)
     {
-        info->channel_layout |= HB_INPUT_CH_LAYOUT_HAS_LFE;
+        info->channel_layout |= AV_CH_LOW_FREQUENCY;
     }
 
     info->channel_map = &hb_qt_chan_map;
index 3ee4a636c695cdeb94527f8f70e90aa49d5ad386..5c6a0e4a1d6247b515c3a777336afbe60b1d452f 100644 (file)
@@ -51,11 +51,12 @@ hb_work_object_t hb_declpcm =
 
 static const int hdr2samplerate[] = { 48000, 96000, 44100, 32000 };
 static const int hdr2samplesize[] = { 16, 20, 24, 16 };
-static const int hdr2layout[] = {
-        HB_INPUT_CH_LAYOUT_MONO,   HB_INPUT_CH_LAYOUT_STEREO,
-        HB_INPUT_CH_LAYOUT_2F1R,   HB_INPUT_CH_LAYOUT_2F2R,
-        HB_INPUT_CH_LAYOUT_3F2R,   HB_INPUT_CH_LAYOUT_4F2R,
-        HB_INPUT_CH_LAYOUT_STEREO, HB_INPUT_CH_LAYOUT_STEREO,
+static const uint64_t hdr2layout[] =
+{
+    AV_CH_LAYOUT_MONO,    AV_CH_LAYOUT_STEREO,
+    AV_CH_LAYOUT_2_1,     AV_CH_LAYOUT_2_2,
+    AV_CH_LAYOUT_5POINT0, AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER,
+    AV_CH_LAYOUT_STEREO,  AV_CH_LAYOUT_STEREO,
 };
 
 static void lpcmInfo( hb_work_object_t *w, hb_buffer_t *in )
index 52bef7f2055aa0f52651c81552df6312148bf72b..e5ed1c599fcdd5749c77d2f0efdb1ded68bdec86 100644 (file)
@@ -828,47 +828,77 @@ static int channel_layout_map[DOWNMIX_NUM_MODES] =
     (HB_CH_FRONT_LEFT|HB_CH_FRONT_RIGHT)
 };
 
-int hb_layout_to_mode(int layout)
+int hb_layout_to_mode(uint64_t layout)
 {
-    int mode;
-    switch (layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK)
+    int mode = 0;
+    if (layout & AV_CH_LOW_FREQUENCY)
+        mode |= DOWNMIX_LFE_FLAG;
+    switch (layout & ~AV_CH_LOW_FREQUENCY)
     {
-        case HB_INPUT_CH_LAYOUT_MONO:
-            mode = DOWNMIX_MONO;
-            break;
-        case HB_INPUT_CH_LAYOUT_STEREO:
-            mode = DOWNMIX_STEREO;
+        case AV_CH_LAYOUT_MONO:
+            mode |= DOWNMIX_MONO;
             break;
-        case HB_INPUT_CH_LAYOUT_3F:
-            mode = DOWNMIX_3F;
+        case AV_CH_LAYOUT_STEREO:
+        case AV_CH_LAYOUT_STEREO_DOWNMIX:
+            mode |= DOWNMIX_STEREO;
             break;
-        case HB_INPUT_CH_LAYOUT_2F1R:
-            mode = DOWNMIX_2F1R;
+        case AV_CH_LAYOUT_SURROUND:
+            mode |= DOWNMIX_3F;
             break;
-        case HB_INPUT_CH_LAYOUT_3F1R:
-            mode = DOWNMIX_3F1R;
+        case AV_CH_LAYOUT_2_1:
+            mode |= DOWNMIX_2F1R;
             break;
-        case HB_INPUT_CH_LAYOUT_2F2R:
-            mode = DOWNMIX_2F2R;
+        case AV_CH_LAYOUT_4POINT0:
+            mode |= DOWNMIX_3F1R;
             break;
-        case HB_INPUT_CH_LAYOUT_3F2R:
-            mode = DOWNMIX_3F2R;
+        case AV_CH_LAYOUT_2_2:
+        case AV_CH_LAYOUT_QUAD:
+            mode |= DOWNMIX_2F2R;
             break;
-        case HB_INPUT_CH_LAYOUT_4F2R:
-            mode = DOWNMIX_3F2R|DOWNMIX_LFE_FLAG;
+        case AV_CH_LAYOUT_5POINT0:
+        case AV_CH_LAYOUT_5POINT0_BACK:
+            mode |= DOWNMIX_3F2R;
             break;
-        case HB_INPUT_CH_LAYOUT_3F4R:
-            mode = DOWNMIX_3F4R;
-            break;
-        case HB_INPUT_CH_LAYOUT_DOLBY:
-            mode = DOWNMIX_STEREO;
+        case AV_CH_LAYOUT_7POINT0:
+            mode |= DOWNMIX_3F4R;
             break;
         default:
-            mode = DOWNMIX_STEREO;
-            break;
+        {
+            switch (av_get_channel_layout_nb_channels(layout))
+            {
+                case 1:
+                    mode = DOWNMIX_MONO;
+                    break;
+                case 2:
+                    mode = DOWNMIX_STEREO;
+                    break;
+                case 3:
+                    mode = DOWNMIX_3F;
+                    break;
+                case 4:
+                    mode = DOWNMIX_2F2R;
+                    break;
+                case 5:
+                    mode = DOWNMIX_3F2R;
+                    break;
+                case 6:
+                    mode = DOWNMIX_3F2R|DOWNMIX_LFE_FLAG;
+                    break;
+                case 7:
+                    mode = DOWNMIX_3F4R;
+                    break;
+                case 8:
+                    mode = DOWNMIX_3F4R|DOWNMIX_LFE_FLAG;
+                    break;
+                default:
+                    // This will likely not sound very good ;)
+                    mode = DOWNMIX_STEREO;
+                    hb_error("hb_layout_to_mode: unsupported layout 0x%"PRIx64" with %d channels",
+                             layout, av_get_channel_layout_nb_channels(layout));
+                    break;
+            }
+        } break;
     }
-    if (layout & HB_INPUT_CH_LAYOUT_DISCRETE_LFE_MASK)
-        mode |= DOWNMIX_LFE_FLAG;
     return mode;
 }
 
@@ -1142,12 +1172,11 @@ hb_chan_map_t hb_ac3_chan_map =
 static const uint8_t nchans_tbl[] = {1, 2, 3, 3, 4, 4, 5, 7, 2, 2};
 
 // Takes a set of samples and remaps the channel layout
-void hb_layout_remap( 
-    hb_chan_map_t * map_in, 
-    hb_chan_map_t * map_out, 
-    int layout, 
-    hb_sample_t * samples, 
-    int nsamples )
+void hb_layout_remap(hb_chan_map_t *map_in,
+                     hb_chan_map_t *map_out,
+                     uint64_t layout,
+                     hb_sample_t *samples,
+                     int nsamples)
 {
     int nchans;
     int ii, jj;
index e8efe9bb0d6f6e6de797e91ed37e80854480c646..b67889f56bda987827402d24cfb271e78e423c5f 100644 (file)
@@ -57,12 +57,11 @@ void hb_downmix_set_chan_map(
     hb_chan_map_t * map_in, 
     hb_chan_map_t * map_out );
 void hb_downmix( hb_downmix_t * downmix, hb_sample_t * dst, hb_sample_t * src, int nsamples);
-void hb_layout_remap( 
-    hb_chan_map_t * map_in, 
-    hb_chan_map_t * map_out, 
-    int layout, 
-    hb_sample_t * samples, 
-    int nsamples );
+void hb_layout_remap(hb_chan_map_t *map_in,
+                     hb_chan_map_t *map_out,
+                     uint64_t layout,
+                     hb_sample_t *samples,
+                     int nsamples);
 int hb_need_downmix( int layout, int mixdown );
 
 #endif /* DOWNMIX_H */
index 761379832a5ecc5d9569c15f91f51e8f0ee5995a..14df3f3172b96b9d12da3b263297702c9a0b92a6 100644 (file)
@@ -19,7 +19,6 @@ struct hb_work_private_s
 
     int              out_discrete_channels;
     int              samples_per_frame;
-    int              layout;
     unsigned long    input_samples;
     unsigned long    output_bytes;
     hb_list_t      * list;
@@ -75,28 +74,25 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job )
         }
     }
 
-    context->channel_layout = AV_CH_LAYOUT_STEREO;
-    switch( audio->config.out.mixdown )
+    switch (audio->config.out.mixdown)
     {
         case HB_AMIXDOWN_MONO:
             context->channel_layout = AV_CH_LAYOUT_MONO;
-            pv->layout = HB_INPUT_CH_LAYOUT_MONO;
             break;
 
         case HB_AMIXDOWN_STEREO:
         case HB_AMIXDOWN_DOLBY:
         case HB_AMIXDOWN_DOLBYPLII:
             context->channel_layout = AV_CH_LAYOUT_STEREO;
-            pv->layout = HB_INPUT_CH_LAYOUT_STEREO;
             break;
 
         case HB_AMIXDOWN_6CH:
             context->channel_layout = AV_CH_LAYOUT_5POINT1;
-            pv->layout = HB_INPUT_CH_LAYOUT_3F2R | HB_INPUT_CH_LAYOUT_HAS_LFE;
             break;
 
         default:
-            hb_log("encavcodecaInit: bad mixdown" );
+            context->channel_layout = AV_CH_LAYOUT_STEREO;
+            hb_log("encavcodecaInit: bad mixdown");
             break;
     }
 
@@ -226,10 +222,11 @@ static hb_buffer_t * Encode( hb_work_object_t * w )
     //      do it here - this hack should be removed if Libav fixes the bug
     hb_chan_map_t * out_map = ( w->codec_param == CODEC_ID_AAC ) ? &hb_qt_chan_map : &hb_smpte_chan_map;
 
-    if ( audio->config.in.channel_map != out_map )
+    if (audio->config.in.channel_map != out_map)
     {
-        hb_layout_remap( audio->config.in.channel_map, out_map, pv->layout,
-                         (float*)pv->buf, pv->samples_per_frame );
+        hb_layout_remap(audio->config.in.channel_map, out_map,
+                        pv->context->channel_layout, (float*)pv->buf,
+                        pv->samples_per_frame);
     }
 
     // Do we need to convert our internal float format?
index 64c03b3c42d4db09844bc7cdf54f37eca5c30b86..0d881b888323bb8ca1c74dddbac6f99fe6f74d3a 100644 (file)
@@ -203,94 +203,46 @@ hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat,
     return ctx;
 }
 
-int hb_ff_layout_xlat( int64_t ff_channel_layout, int channels )
+uint64_t hb_ff_layout_xlat(uint64_t ff_channel_layout, int nchannels)
 {
-    int hb_layout;
-
-    switch( ff_channel_layout )
+    uint64_t hb_layout = ff_channel_layout;
+    if (!hb_layout ||
+        av_get_channel_layout_nb_channels(hb_layout) != nchannels)
     {
-        case AV_CH_LAYOUT_MONO:
-            hb_layout = HB_INPUT_CH_LAYOUT_MONO;
-            break;
-        case AV_CH_LAYOUT_STEREO:
-        case AV_CH_LAYOUT_STEREO_DOWNMIX:
-            hb_layout = HB_INPUT_CH_LAYOUT_STEREO;
-            break;
-        case AV_CH_LAYOUT_SURROUND:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F;
-            break;
-        case AV_CH_LAYOUT_4POINT0:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F1R;
-            break;
-        case AV_CH_LAYOUT_2_2:
-        case AV_CH_LAYOUT_QUAD:
-            hb_layout = HB_INPUT_CH_LAYOUT_2F2R;
-            break;
-        case AV_CH_LAYOUT_5POINT0:
-        case AV_CH_LAYOUT_5POINT0_BACK:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F2R;
-            break;
-        case AV_CH_LAYOUT_5POINT1:
-        case AV_CH_LAYOUT_5POINT1_BACK:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F2R|HB_INPUT_CH_LAYOUT_HAS_LFE;
-            break;
-        case AV_CH_LAYOUT_7POINT0:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F4R;
-            break;
-        case AV_CH_LAYOUT_7POINT1:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F4R|HB_INPUT_CH_LAYOUT_HAS_LFE;
-            break;
-        default:
-            hb_layout = HB_INPUT_CH_LAYOUT_STEREO;
-            break;
-    }
-    // Now make sure the chosen layout agrees with the number of channels
-    // ffmpeg tells us there are.  It seems ffmpeg is sometimes confused
-    // about this. So we will make a best guess based on the number
-    // of channels.
-    int chans = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( hb_layout );
-    if( ff_channel_layout && chans == channels )
-    {
-        return hb_layout;
-    }
-    if( !ff_channel_layout )
-    {
-        hb_log( "No channel layout reported by Libav; guessing one from channel count." );
-    }
-    else
-    {
-        hb_log( "Channels reported by Libav (%d) != computed layout channels (%d). Guessing layout from channel count.", channels, chans );
-    }
-    switch( channels )
-    {
-        case 1:
-            hb_layout = HB_INPUT_CH_LAYOUT_MONO;
-            break;
-        case 2:
-            hb_layout = HB_INPUT_CH_LAYOUT_STEREO;
-            break;
-        case 3:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F;
-            break;
-        case 4:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F1R;
-            break;
-        case 5:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F2R;
-            break;
-        case 6:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F2R|HB_INPUT_CH_LAYOUT_HAS_LFE;
-            break;
-        case 7:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F4R;
-            break;
-        case 8:
-            hb_layout = HB_INPUT_CH_LAYOUT_3F4R|HB_INPUT_CH_LAYOUT_HAS_LFE;
-            break;
-        default:
-            hb_log( "Unsupported number of audio channels (%d).", channels );
-            hb_layout = 0;
-            break;
+        switch (nchannels)
+        {
+            // TODO: use av_get_default_channel_layout when available
+            case 1:
+                hb_layout = AV_CH_LAYOUT_MONO;
+                break;
+            case 2:
+                hb_layout = AV_CH_LAYOUT_STEREO;
+                break;
+            case 3:
+                hb_layout = AV_CH_LAYOUT_SURROUND;
+                break;
+            case 4:
+                hb_layout = AV_CH_LAYOUT_QUAD;
+                break;
+            case 5:
+                hb_layout = AV_CH_LAYOUT_5POINT0;
+                break;
+            case 6:
+                hb_layout = AV_CH_LAYOUT_5POINT1;
+                break;
+            case 7:
+                hb_layout = AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER;
+                break;
+            case 8:
+                hb_layout = AV_CH_LAYOUT_7POINT1;
+                break;
+            default:
+                // This will likely not sound very good ;)
+                hb_layout = AV_CH_LAYOUT_STEREO;
+                hb_error("hb_ff_layout_xlat: unsupported layout 0x%"PRIx64" with %d channels",
+                         ff_channel_layout, nchannels);
+                break;
+        }
     }
     return hb_layout;
 }
index 8c1bc57e7ca544bb9443fceb6c34352d107b636f..e4cf63474218f8204468b5cd1ba6cca4610d86cb 100644 (file)
@@ -9,9 +9,10 @@
 
 #include "libavcodec/avcodec.h"
 #include "libavformat/avformat.h"
-#include "libavutil/opt.h"
-#include "libavutil/mathematics.h"
+#include "libavutil/audioconvert.h"
 #include "libavutil/imgutils.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/opt.h"
 #include "libswscale/swscale.h"
 
 #define HB_FFMPEG_THREADS_AUTO (-1) // let hb_avcodec_open decide thread_count
@@ -19,7 +20,7 @@
 void hb_avcodec_init(void);
 int hb_avcodec_open( AVCodecContext *, struct AVCodec *, AVDictionary **av_opts, int thread_count );
 int hb_avcodec_close( AVCodecContext * );
-int hb_ff_layout_xlat(int64_t ff_layout, int channels);
+uint64_t hb_ff_layout_xlat(uint64_t ff_channel_layout, int nchannels);
 struct SwsContext* hb_sws_get_context( int srcW, int srcH, 
     enum PixelFormat srcFormat, int dstW, int dstH, 
     enum PixelFormat dstFormat, int flags);
index 5761be013fb01d856e0fc1d4b5840db97d590ff0..bca946bfbe0a338bc373cee27c71ca863e384a60 100644 (file)
@@ -300,13 +300,13 @@ static int MKVInit( hb_mux_object_t * m )
         {
             track->extra.audio.samplingFreq = (float)audio->config.out.samplerate;
         }
-        if( audio->config.out.codec & HB_ACODEC_PASS_FLAG )
+        if (audio->config.out.codec & HB_ACODEC_PASS_FLAG)
         {
-            track->extra.audio.channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( audio->config.in.channel_layout );
+            track->extra.audio.channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout);
         }
         else
         {
-            track->extra.audio.channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
+            track->extra.audio.channels = hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown);
         }
         mux_data->track = mk_createTrack(m->file, track);
         if( audio->config.out.codec == HB_ACODEC_VORBIS ||
index 5b553e5a3881d281f3bc3e2f1c5be1febe4e494f..2203193a1c27eb495199be2c32a0bec29f953525 100644 (file)
@@ -413,17 +413,17 @@ static int MP4Init( hb_mux_object_t * m )
                         audio_type = 0xA9;
                     } break;
                 }
-                if( audio->config.out.codec & HB_ACODEC_PASS_FLAG )
+                if (audio->config.out.codec & HB_ACODEC_PASS_FLAG)
                 {
                     samplerate = audio->config.in.samplerate;
                     samples_per_frame = audio->config.in.samples_per_frame;
-                    channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( audio->config.in.channel_layout );
+                    channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout);
                 }
                 else
                 {
                     samplerate = audio->config.out.samplerate;
                     samples_per_frame = audio->config.out.samples_per_frame;
-                    channels = hb_mixdown_get_discrete_channel_count( audio->config.out.mixdown );
+                    channels = hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown);
                 }
                 mux_data->track = MP4AddAudioTrack( m->file, samplerate, 
                                                 samples_per_frame, audio_type );
index d97311a20fecfda385a11dbd1810e8e70acbc572..8d1615418a238a4b68ff3cc97470cd4a1665dc10 100644 (file)
@@ -279,16 +279,16 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job, enum AAC_MODE mode )
     switch( audio->config.out.mixdown )
     {
         case HB_AMIXDOWN_MONO:
-            pv->layout = HB_INPUT_CH_LAYOUT_MONO;
+            pv->layout = AV_CH_LAYOUT_MONO;
             break;
         case HB_AMIXDOWN_STEREO:
         case HB_AMIXDOWN_DOLBY:
         case HB_AMIXDOWN_DOLBYPLII:
-            pv->layout = HB_INPUT_CH_LAYOUT_STEREO;
+            pv->layout = AV_CH_LAYOUT_STEREO;
             break;
         case HB_AMIXDOWN_6CH:
         default:
-            pv->layout = HB_INPUT_CH_LAYOUT_3F2R | HB_INPUT_CH_LAYOUT_HAS_LFE;
+            pv->layout = AV_CH_LAYOUT_5POINT1;
             break;
     }
 
index 646e56003f65191a266e4a431529d12b39c193fa..4fff7b736545977a67214af8fe0dc4ee13cf7f49 100644 (file)
@@ -1072,19 +1072,17 @@ static void LookForAudio( hb_title_t * title, hb_buffer_t * b )
     audio->config.in.mode = info.mode;
 
     // update the audio description string based on the info we found
-    if( audio->config.in.channel_layout == HB_INPUT_CH_LAYOUT_DOLBY )
+    if (audio->config.in.channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
     {
-        strcat( audio->config.lang.description, " (Dolby Surround)" );
+        strcat(audio->config.lang.description, " (Dolby Surround)");
     }
-    else
+    else if (audio->config.in.channel_layout)
     {
-        int layout = audio->config.in.channel_layout;
-        char *desc = audio->config.lang.description +
-                        strlen( audio->config.lang.description );
-        sprintf( desc, " (%d.%d ch)",
-                 HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT(layout) +
-                     HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT(layout),
-                 HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT(layout) );
+        int lfe      = !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY);
+        int channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout);
+        char *desc   = audio->config.lang.description +
+                        strlen(audio->config.lang.description);
+        sprintf(desc, " (%d.%d ch)", channels - lfe, lfe);
     }
 
     hb_log( "scan: audio 0x%x: %s, rate=%dHz, bitrate=%d %s", audio->id,
index 9a287dc88610a7a4c41fcc1e9041a3ab9007926c..3e4a682e3797a8842107c35b63167c7bbb436503 100644 (file)
@@ -2041,19 +2041,17 @@ static void set_audio_description(
               sizeof( audio->config.lang.description ), "%s (%s)",
               audio->config.lang.simple, codec_name );
 
-    if( audio->config.in.channel_layout == HB_INPUT_CH_LAYOUT_DOLBY )
+    if (audio->config.in.channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
     {
-        strcat( audio->config.lang.description, " (Dolby Surround)" );
+        strcat(audio->config.lang.description, " (Dolby Surround)");
     }
-    else if( audio->config.in.channel_layout )
+    else if (audio->config.in.channel_layout)
     {
-        int layout = audio->config.in.channel_layout;
-        char *desc = audio->config.lang.description +
-                        strlen( audio->config.lang.description );
-        sprintf( desc, " (%d.%d ch)",
-                 HB_INPUT_CH_LAYOUT_GET_DISCRETE_FRONT_COUNT(layout) +
-                     HB_INPUT_CH_LAYOUT_GET_DISCRETE_REAR_COUNT(layout),
-                 HB_INPUT_CH_LAYOUT_GET_DISCRETE_LFE_COUNT(layout) );
+        int lfe      = !!(audio->config.in.channel_layout & AV_CH_LOW_FREQUENCY);
+        int channels = av_get_channel_layout_nb_channels(audio->config.in.channel_layout);
+        char *desc   = audio->config.lang.description +
+                        strlen(audio->config.lang.description);
+        sprintf(desc, " (%d.%d ch)", channels - lfe, lfe);
     }
 }
 
index af228e03f370b0497cb1b00d8e5a8484704618dd..181d0acb307583cfdb879ad020a66925ac779f36 100644 (file)
@@ -948,49 +948,16 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i )
 
         c->bit_rate    = w->audio->config.in.bitrate;
         c->sample_rate = w->audio->config.in.samplerate;
-        c->channels    = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT( w->audio->config.in.channel_layout );
+        c->channels    = av_get_channel_layout_nb_channels(w->audio->config.in.channel_layout);
         hb_ff_set_sample_fmt( c, codec );
 
-        switch( w->audio->config.in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK )
+        if (w->audio->config.in.channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
         {
-            case HB_INPUT_CH_LAYOUT_MONO:
-                c->channel_layout = AV_CH_LAYOUT_MONO;
-                break;
-
-            case HB_INPUT_CH_LAYOUT_STEREO:
-            case HB_INPUT_CH_LAYOUT_DOLBY:
-                c->channel_layout = AV_CH_LAYOUT_STEREO;
-                break;
-
-            case HB_INPUT_CH_LAYOUT_3F2R:
-                c->channel_layout = AV_CH_LAYOUT_5POINT0;
-                break;
-
-            case HB_INPUT_CH_LAYOUT_3F1R:
-                c->channel_layout = AV_CH_LAYOUT_4POINT0;
-                break;
-
-            case HB_INPUT_CH_LAYOUT_3F:
-                c->channel_layout = AV_CH_LAYOUT_SURROUND;
-                break;
-
-            case HB_INPUT_CH_LAYOUT_2F1R:
-                c->channel_layout = AV_CH_LAYOUT_2_1;
-                break;
-
-            case HB_INPUT_CH_LAYOUT_2F2R:
-                c->channel_layout = AV_CH_LAYOUT_QUAD;
-                break;
-
-            default:
-                c->channel_layout = AV_CH_LAYOUT_STEREO;
-                hb_log("sync: unrecognized channel layout" );
-                break;
+            c->channel_layout = AV_CH_LAYOUT_STEREO;
         }
-
-        if ( w->audio->config.in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE )
+        else
         {
-            c->channel_layout |= AV_CH_LOW_FREQUENCY;
+            c->channel_layout = w->audio->config.in.channel_layout;
         }
 
         if( hb_avcodec_open( c, codec, NULL, 0 ) < 0 )
index 3b5f2d4cf2790c7e0094f49d71efa851198472a3..51743dcfa6af4987bf86d934f7c77eb23de14ffb 100644 (file)
@@ -229,9 +229,9 @@ static NSMutableArray *masterBitRateArray = nil;
     BOOL shouldAdd;
     int currentMixdown;
 
+    unsigned long long channelLayout = [[track objectForKey: keyAudioInputChannelLayout] unsignedLongLongValue];
     unsigned int count = [masterMixdownArray count];
     int codecCodec = [[codec objectForKey: keyAudioCodec] intValue];
-    int channelLayout = [[track objectForKey: keyAudioInputChannelLayout] intValue];
     int theDefaultMixdown = hb_get_default_mixdown(codecCodec, channelLayout);
     int theBestMixdown = hb_get_best_mixdown(codecCodec, channelLayout, 0);
 
index fe4b6072e9cdbe3ae7152076b44a4451d9d1cadf..2c60b0fcab52de64f051da150a374ff6874d2203 100644 (file)
@@ -598,7 +598,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
                                        [NSNumber numberWithInt: audio->in.bitrate / 1000], keyAudioInputBitrate,
                                        [NSNumber numberWithInt: audio->in.samplerate], keyAudioInputSampleRate,
                                        [NSNumber numberWithInt: audio->in.codec], keyAudioInputCodec,
-                                       [NSNumber numberWithInt: audio->in.channel_layout], keyAudioInputChannelLayout,
+                                       [NSNumber numberWithUnsignedLongLong: audio->in.channel_layout], keyAudioInputChannelLayout,
                                        nil]];
         }
         self.masterTrackArray = newTrackArray;
index 3f8c59561c00270ddc0699ec33634f60051eca73..073b9448bedee905bbeafd8cf76f3c7347d32a05 100644 (file)
                273F200814ADAE950021BE6D /* debug */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               HEADER_SEARCH_PATHS = (
+                                       "\"$(EXTERNAL_BUILD)/libhb\"",
+                                       "\"$(EXTERNAL_BUILD)/contrib/include\"",
+                               );
                                LIBRARY_SEARCH_PATHS = (
                                        "$(inherited)",
                                        "\"$(EXTERNAL_BUILD)/libhb\"",
                273F200914ADAE950021BE6D /* release */ = {
                        isa = XCBuildConfiguration;
                        buildSettings = {
-                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               HEADER_SEARCH_PATHS = (
+                                       "\"$(EXTERNAL_BUILD)/libhb\"",
+                                       "\"$(EXTERNAL_BUILD)/contrib/include\"",
+                               );
                                LIBRARY_SEARCH_PATHS = (
                                        "$(inherited)",
                                        "\"$(EXTERNAL_BUILD)/libhb\"",
                                        "$(inherited)",
                                        "\"$(SRCROOT)\"",
                                );
-                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               HEADER_SEARCH_PATHS = (
+                                       "\"$(EXTERNAL_BUILD)/libhb\"",
+                                       "\"$(EXTERNAL_BUILD)/contrib/include\"",
+                               );
                                INFOPLIST_FILE = "$(EXTERNAL_BUILD)/macosx/Info.plist";
                                LIBRARY_SEARCH_PATHS = (
                                        "$(inherited)",
                                        "$(inherited)",
                                        "\"$(SRCROOT)\"",
                                );
-                               HEADER_SEARCH_PATHS = "$(EXTERNAL_BUILD)/libhb";
+                               HEADER_SEARCH_PATHS = (
+                                       "\"$(EXTERNAL_BUILD)/libhb\"",
+                                       "\"$(EXTERNAL_BUILD)/contrib/include\"",
+                               );
                                INFOPLIST_FILE = "$(EXTERNAL_BUILD)/macosx/Info.plist";
                                LIBRARY_SEARCH_PATHS = (
                                        "$(inherited)",