summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-06-18 21:11:48 +0000
committerRodeo <[email protected]>2012-06-18 21:11:48 +0000
commitfc3e44b2ba28772fa559d39bd57b7a595a83292f (patch)
tree738449c393dcd8da6edf6881e53353b35e5c47b8
parent510564b19b5a6d7ac77091cd02ec9c557941399f (diff)
libhb: drop HB_INPUT_CH_LAYOUT_*
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
-rw-r--r--gtk/configure.ac12
-rw-r--r--gtk/src/hb-backend.c11
-rw-r--r--libhb/common.c30
-rw-r--r--libhb/common.h56
-rw-r--r--libhb/deca52.c24
-rw-r--r--libhb/decavcodec.c18
-rw-r--r--libhb/decdca.c66
-rw-r--r--libhb/declpcm.c11
-rw-r--r--libhb/downmix.c99
-rw-r--r--libhb/downmix.h11
-rw-r--r--libhb/encavcodecaudio.c17
-rw-r--r--libhb/hb.c124
-rw-r--r--libhb/hbffmpeg.h7
-rw-r--r--libhb/muxmkv.c6
-rw-r--r--libhb/muxmp4.c6
-rw-r--r--libhb/platform/macosx/encca_aac.c6
-rw-r--r--libhb/scan.c18
-rw-r--r--libhb/stream.c18
-rw-r--r--libhb/sync.c43
-rw-r--r--macosx/HBAudio.m2
-rw-r--r--macosx/HBAudioController.m2
-rw-r--r--macosx/HandBrake.xcodeproj/project.pbxproj20
22 files changed, 267 insertions, 340 deletions
diff --git a/gtk/configure.ac b/gtk/configure.ac
index 94219c32d..b4965c48f 100644
--- a/gtk/configure.ac
+++ b/gtk/configure.ac
@@ -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
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 46898b9c8..a4d5ee040 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -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)
{
diff --git a/libhb/common.c b/libhb/common.c
index 87f4766bb..93c98ffa4 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -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
diff --git a/libhb/common.h b/libhb/common.h
index c0cd46e5e..059defc68 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -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;
};
diff --git a/libhb/deca52.c b/libhb/deca52.c
index d832002a8..22bfb55da 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -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;
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 527b5791f..8a236ca4a 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -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 )
diff --git a/libhb/decdca.c b/libhb/decdca.c
index c9236b0f8..9f426d6a4 100644
--- a/libhb/decdca.c
+++ b/libhb/decdca.c
@@ -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;
diff --git a/libhb/declpcm.c b/libhb/declpcm.c
index 3ee4a636c..5c6a0e4a1 100644
--- a/libhb/declpcm.c
+++ b/libhb/declpcm.c
@@ -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 )
diff --git a/libhb/downmix.c b/libhb/downmix.c
index 52bef7f20..e5ed1c599 100644
--- a/libhb/downmix.c
+++ b/libhb/downmix.c
@@ -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;
diff --git a/libhb/downmix.h b/libhb/downmix.h
index e8efe9bb0..b67889f56 100644
--- a/libhb/downmix.h
+++ b/libhb/downmix.h
@@ -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 */
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c
index 761379832..14df3f317 100644
--- a/libhb/encavcodecaudio.c
+++ b/libhb/encavcodecaudio.c
@@ -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?
diff --git a/libhb/hb.c b/libhb/hb.c
index 64c03b3c4..0d881b888 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -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;
}
diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h
index 8c1bc57e7..e4cf63474 100644
--- a/libhb/hbffmpeg.h
+++ b/libhb/hbffmpeg.h
@@ -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);
diff --git a/libhb/muxmkv.c b/libhb/muxmkv.c
index 5761be013..bca946bfb 100644
--- a/libhb/muxmkv.c
+++ b/libhb/muxmkv.c
@@ -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 ||
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index 5b553e5a3..2203193a1 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -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 );
diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c
index d97311a20..8d1615418 100644
--- a/libhb/platform/macosx/encca_aac.c
+++ b/libhb/platform/macosx/encca_aac.c
@@ -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;
}
diff --git a/libhb/scan.c b/libhb/scan.c
index 646e56003..4fff7b736 100644
--- a/libhb/scan.c
+++ b/libhb/scan.c
@@ -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,
diff --git a/libhb/stream.c b/libhb/stream.c
index 9a287dc88..3e4a682e3 100644
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -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);
}
}
diff --git a/libhb/sync.c b/libhb/sync.c
index af228e03f..181d0acb3 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -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 )
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index 3b5f2d4cf..51743dcfa 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -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);
diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m
index fe4b6072e..2c60b0fca 100644
--- a/macosx/HBAudioController.m
+++ b/macosx/HBAudioController.m
@@ -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;
diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj
index 3f8c59561..073b9448b 100644
--- a/macosx/HandBrake.xcodeproj/project.pbxproj
+++ b/macosx/HandBrake.xcodeproj/project.pbxproj
@@ -961,7 +961,10 @@
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\"",
@@ -974,7 +977,10 @@
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\"",
@@ -991,7 +997,10 @@
"$(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)",
@@ -1010,7 +1019,10 @@
"$(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)",