diff options
author | Rodeo <[email protected]> | 2012-09-03 12:37:16 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-09-03 12:37:16 +0000 |
commit | 8d9969febdcec59fee453888ed0bb6a64adf7679 (patch) | |
tree | dbe81e961c2ed4c0f3e38d44c5afa86cc475693a /libhb/encfaac.c | |
parent | 56bf9b80b9b55ecaec9855addda41898261d26b1 (diff) |
Audio improvements.
New supported samplerates: 8, 11.025, 12, 16 kHz.
Now 8, 11.025, 12, 16, 22.05, 24, 42, 44.1, 48 Khz are supported.
Unsupported samplerates are sanitized to the closest samplerate for all encoders.
Samplerates < 32 kHz are now forbidden for AC3 encoding (sanitized to 32 kHz). Most AC3 decoders don't support such samplerates.
New upmixing: 3.0 (Front Left, Right & Center) can now be upmixed to 5.1 to preserve the center channel.
New mixdowns:
6.1 (Front Left, Right & Center, Surround Left, Right & Center, LFE)
7.1 (Front Left, Right & Center, Surround Left & Right, Rear Left & Right, LFE)
-> available to Vorbis & FLAC encoders for compatible input channel layouts
7.1 (Front Left, Right & Center, Front Left & Right of Center, Surround Left & Right, LFE)
-> available to AAC encoders (ca_aac, ca_haac, faac) for compatible input channel layouts
Mono (Left Only): Stereo to Mono by discarding the Right channel
Mono (Right Only): Stereo to Mono by discarding the Left channel
-> available to all encoders for non-Dolby Stereo input
The "6-channel discrete" mixdown becomes "5.1 Channels".
New bitrates: 960 - 1536 Kbps.
This lets users work around poor audio quality in crappy encoders by throwing more bits at them.
Bitrate limits have been re-worked and re-tested for all encoders.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4930 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encfaac.c')
-rw-r--r-- | libhb/encfaac.c | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/libhb/encfaac.c b/libhb/encfaac.c index 675881e8e..c6a3f8a16 100644 --- a/libhb/encfaac.c +++ b/libhb/encfaac.c @@ -40,21 +40,6 @@ hb_work_object_t hb_encfaac = encfaacClose }; -static const int valid_rates[] = -{ - 22050, 24000, 32000, 44100, 48000, 0 -}; - -static int find_samplerate( int rate ) -{ - int i; - - for ( i = 0; valid_rates[i] && rate > valid_rates[i]; ++i ) - { - } - return i; -} - /*********************************************************************** * hb_work_encfaac_init *********************************************************************** @@ -75,28 +60,6 @@ int encfaacInit( hb_work_object_t * w, hb_job_t * job ) /* pass the number of channels used into the private work data */ pv->out_discrete_channels = hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown); - /* if the sample rate is 'auto' and that has given us an invalid output */ - /* rate, map it to the next highest output rate or 48K if above the highest. */ - int rate_index = find_samplerate(audio->config.out.samplerate); - if ( audio->config.out.samplerate != valid_rates[rate_index] ) - { - int rate = valid_rates[valid_rates[rate_index]? rate_index : rate_index - 1]; - hb_log( "encfaac changing output samplerate from %d to %d", - audio->config.out.samplerate, rate ); - audio->config.out.samplerate = rate; - - /* if the new rate is over the max bandwidth per channel limit */ - /* lower the bandwidth. */ - double bw = audio->config.out.bitrate * 1000 / pv->out_discrete_channels; - if ( bw > (double)rate * (6144./1024.) ) - { - int newbr = (double)rate * (6.144/1024.) * pv->out_discrete_channels; - hb_log( "encfaac changing output bitrate from %d to %d", - audio->config.out.bitrate, newbr ); - audio->config.out.bitrate = newbr; - } - } - pv->faac = faacEncOpen( audio->config.out.samplerate, pv->out_discrete_channels, &pv->input_samples, &pv->output_bytes ); pv->buf = malloc( pv->input_samples * sizeof( float ) ); @@ -110,7 +73,7 @@ int encfaacInit( hb_work_object_t * w, hb_job_t * job ) cfg->aacObjectType = LOW; cfg->allowMidside = 1; - // channel remapping, LFE + /* channel configuration & remapping */ uint64_t layout; int *remap_table; layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, NULL); @@ -123,7 +86,33 @@ int encfaacInit( hb_work_object_t * w, hb_job_t * job ) pv->out_discrete_channels * sizeof(int)); free(remap_table); } - cfg->useLfe = !!(layout & AV_CH_LOW_FREQUENCY); + switch (audio->config.out.mixdown) + { + case HB_AMIXDOWN_7POINT1: + cfg->channelConfiguration = 0; + cfg->numFrontChannels = 3; + cfg->numSideChannels = 2; + cfg->numBackChannels = 2; + cfg->numLFEChannels = 1; + break; + + case HB_AMIXDOWN_6POINT1: + cfg->channelConfiguration = 0; + cfg->numFrontChannels = 3; + cfg->numSideChannels = 0; + cfg->numBackChannels = 3; + cfg->numLFEChannels = 1; + break; + + case HB_AMIXDOWN_5_2_LFE: + cfg->channelConfiguration = 7; + break; + + default: + cfg->channelConfiguration = + hb_mixdown_get_discrete_channel_count(audio->config.out.mixdown); + break; + } cfg->useTns = 0; cfg->bitRate = audio->config.out.bitrate * 1000 / pv->out_discrete_channels; /* Per channel */ |