Index: test/test.c =================================================================== --- test/test.c (revision 1091) +++ test/test.c (working copy) @@ -39,6 +39,7 @@ static int h264_30 = 0; static char * audios = NULL; static int audio_mixdown = HB_AMIXDOWN_DOLBYPLII; +static float dynamic_range_compression = 0; static int sub = 0; static int width = 0; static int height = 0; @@ -823,7 +824,11 @@ { job->acodec = acodec; } - + if ( dynamic_range_compression ) + { + job->dynamic_range_compression = dynamic_range_compression; + } + if( size ) { job->vbitrate = hb_calc_bitrate( job, size ); @@ -1181,6 +1186,10 @@ fprintf( stderr, "/" ); } fprintf( stderr, " kHz)\n" + " -D, --normalize Normalize the source's audio by applying dynamic\n" + " range compression, so soft sounds are louder.\n" + " Range is 0.0 (off) to 4.0 (too loud), with\n" + " 1.0 - 2.5 being a good range for... normal use.\n" @@ -1267,6 +1276,7 @@ { "markers", optional_argument, NULL, 'm' }, { "audio", required_argument, NULL, 'a' }, { "mixdown", required_argument, NULL, '6' }, + { "normalize", required_argument, NULL, 'D' }, { "subtitle", required_argument, NULL, 's' }, { "subtitle-scan", no_argument, NULL, 'U' }, { "subtitle-forced", no_argument, NULL, 'F' }, @@ -1308,7 +1318,7 @@ int c; c = getopt_long( argc, argv, - "hvuC:f:4i:Io:t:Lc:ma:6:s:UFN:e:E:2d789gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:VZ:z", + "hvuC:f:4i:Io:t:Lc:ma:6:s:UFN:e:E:2dD:789gpOP::w:l:n:b:q:S:B:r:R:Qx:TY:X:VZ:z", long_options, &option_index ); if( c < 0 ) { @@ -1416,6 +1426,9 @@ audio_mixdown = HB_AMIXDOWN_6CH; } break; + case 'D': + dynamic_range_compression = atof( optarg ); + break; case 's': sub = atoi( optarg ); break; Index: libhb/deca52.c =================================================================== --- libhb/deca52.c (revision 1091) +++ libhb/deca52.c (working copy) @@ -56,6 +56,30 @@ static hb_buffer_t * Decode( hb_work_object_t * w ); /*********************************************************************** + * dynrng_call + *********************************************************************** + * Boosts soft audio -- taken from gbooker's work in A52Decoder, comment and all.. + * Two cases + * 1) The user requested a compression of 1 or less, return the typical power rule + * 2) The user requested a compression of more than 1 (decompression): + * If the stream's requested compression is less than 1.0 (loud sound), return the normal compression + * If the stream's requested compression is more than 1.0 (soft sound), use power rule (which will make + * it louder in this case). + * + **********************************************************************/ +static sample_t dynrng_call (sample_t c, void *data) +{ + double *level = (double *)data; + float levelToUse = (float)*level; + if(c > 1.0 || levelToUse <= 1.0) + { + return powf(c, levelToUse); + } + else + return c; +} + +/*********************************************************************** * hb_work_deca52_init *********************************************************************** * Allocate the work object, initialize liba52 @@ -200,7 +224,13 @@ /* Feed liba52 */ a52_frame( pv->state, pv->frame, &pv->flags_out, &pv->level, 0 ); - + + if ( pv->job->dynamic_range_compression ) + { + float dynamic_compression_level = pv->job->dynamic_range_compression;; + a52_dynrng( pv->state, dynrng_call, &pv->job->dynamic_range_compression); + } + /* 6 blocks per frame, 256 samples per block, channelsused channels */ buf = hb_buffer_init( 6 * 256 * pv->out_discrete_channels * sizeof( float ) ); if (pts == -1) Index: libhb/work.c =================================================================== --- libhb/work.c (revision 1091) +++ libhb/work.c (working copy) @@ -159,7 +159,7 @@ title->width, title->height, job->width, job->height, job->crop[0], job->crop[1], job->crop[2], job->crop[3] ); hb_log( " + grayscale %s", job->grayscale ? "on" : "off" ); - + if ( job->vfr ) { job->vrate_base = 900900; @@ -324,6 +324,9 @@ "faac" : ( ( job->acodec & HB_ACODEC_LAME ) ? "lame" : "vorbis" ) ); } + + if ( job->dynamic_range_compression ) + hb_log(" + normalizing audio at strength: %f", job->dynamic_range_compression); /* if we are doing AC3 passthru, then remove any non-AC3 audios from the job */ /* otherwise, Bad Things will happen */ Index: libhb/common.h =================================================================== --- libhb/common.h (revision 1091) +++ libhb/common.h (working copy) @@ -236,6 +236,7 @@ int acodec; int abitrate; int arate; + float dynamic_range_compression; /* Subtitle settings: subtitle: index in hb_title_t's subtitles list, starting