summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-08-01 23:05:00 +0000
committerjstebbins <[email protected]>2012-08-01 23:05:00 +0000
commitad257c9dac38fe3f7502b1058247b4458465c0a8 (patch)
treec142e7b68aa0406b64e77a7f844b0622172fc5c9 /test
parentdbec0d898d37f3b9a1fed8158543115fbdb3ce91 (diff)
libhb: Allow control of audio mix normalization
Since switching to libavresample for audio mixing, our output volume levels have been reduced because libavresample does mix level normalization by default. This change applies a patch to libav to allow us to disable this behavior and adds a new field to hb_audio_config_t to allow the hb frontends to control this feature. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4884 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'test')
-rw-r--r--test/test.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c
index 5d61b579c..b59534d44 100644
--- a/test/test.c
+++ b/test/test.c
@@ -71,6 +71,7 @@ static int allowed_audio_copy = -1;
static char * mixdowns = NULL;
static char * dynamic_range_compression = NULL;
static char * audio_gain = NULL;
+static char ** normalize_mix_level = NULL;
static char * atracks = NULL;
static char * arates = NULL;
static char ** abitrates = NULL;
@@ -2096,6 +2097,41 @@ static int HandleEvents( hb_handle_t * h )
}
/* Audio Gain */
+ /* Audio Mix Normalization */
+ i = 0;
+ int norm = 0;
+ if( normalize_mix_level )
+ {
+ for ( i = 0; normalize_mix_level[i] != NULL && i < num_audio_tracks; i++ )
+ {
+ char * token = normalize_mix_level[i];
+ norm = atoi(token);
+ audio = hb_list_audio_config_item(job->list_audio, i);
+
+ if( audio != NULL )
+ {
+ audio->out.normalize_mix_level = norm;
+ }
+ else
+ {
+ fprintf(stderr, "Ignoring normalization %d, no audio tracks\n", norm);
+ }
+ }
+ }
+ if (i < num_audio_tracks && i == 1)
+ {
+ /* We have fewer inputs than audio tracks,
+ * and we only have one input, use
+ * that for all tracks.
+ */
+ for (; i < num_audio_tracks; i++)
+ {
+ audio = hb_list_audio_config_item(job->list_audio, i);
+ audio->out.normalize_mix_level = norm;
+ }
+ }
+ /* Audio Mix Normalization */
+
/* Audio Track Names */
if ( anames )
{
@@ -2883,6 +2919,10 @@ static void ShowHelp()
" Separated by commas for more than one audio track.\n"
" (mono/stereo/dpl1/dpl2/6ch, default: up to 6ch for ac3,\n"
" up to dpl2 for other encoders)\n"
+ " --normalize-mix Normalize audio mix levels to prevent clipping.\n"
+ " <string> Separated by commas for more than one audio track.\n"
+ " 0 = Disable Normalization (default)\n"
+ " 1 = Enable Normalization\n"
" -R, --arate Set audio samplerate(s) (" );
for( i = 0; i < hb_audio_rates_count; i++ )
{
@@ -3186,6 +3226,7 @@ static int ParseOptions( int argc, char ** argv )
#define X264_PRESET 284
#define X264_TUNE 285
#define H264_LEVEL 286
+ #define NORMALIZE_MIX 287
for( ;; )
{
@@ -3212,6 +3253,7 @@ static int ParseOptions( int argc, char ** argv )
{ "markers", optional_argument, NULL, 'm' },
{ "audio", required_argument, NULL, 'a' },
{ "mixdown", required_argument, NULL, '6' },
+ { "normalize-mix", required_argument, NULL, NORMALIZE_MIX },
{ "drc", required_argument, NULL, 'D' },
{ "gain", required_argument, NULL, AUDIO_GAIN },
{ "subtitle", required_argument, NULL, 's' },
@@ -3430,6 +3472,12 @@ static int ParseOptions( int argc, char ** argv )
audio_gain = strdup( optarg );
}
break;
+ case NORMALIZE_MIX:
+ if( optarg != NULL )
+ {
+ normalize_mix_level = str_split( optarg, ',' );
+ }
+ break;
case 's':
subtracks = str_split( optarg, ',' );
break;