summaryrefslogtreecommitdiffstats
path: root/macosx/HBAudio.m
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-10-12 20:19:33 +0000
committerjstebbins <[email protected]>2011-10-12 20:19:33 +0000
commit9d95d88d5a05abf6086ab474c0aa2583a9da6345 (patch)
tree5ff672576f6efacb2f03a36b85a88a8b2d3e85e1 /macosx/HBAudio.m
parentd41d9e0d88a689a11fe0978d4e415b89e72c2e62 (diff)
Add flac + quality + compression level support
Adds flac audio to cli, lingui, and macgui Adds quality and compression level options to cli Adds quality option to lingui Quality option works for vorbis and lame git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4281 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBAudio.m')
-rw-r--r--macosx/HBAudio.m95
1 files changed, 59 insertions, 36 deletions
diff --git a/macosx/HBAudio.m b/macosx/HBAudio.m
index 10522b3d3..6b9c7a558 100644
--- a/macosx/HBAudio.m
+++ b/macosx/HBAudio.m
@@ -274,7 +274,8 @@ static NSMutableArray *masterBitRateArray = nil;
// Select the proper one
if (shouldSetDefault)
{
- [self setMixdown: [permittedMixdowns dictionaryWithObject: [NSNumber numberWithInt: theDefaultMixdown] matchingKey: keyAudioMixdown]];
+ [self setMixdown: [permittedMixdowns dictionaryWithObject: [NSNumber numberWithInt: theDefaultMixdown]
+ matchingKey: keyAudioMixdown]];
}
if (![self mixdown] || ![permittedMixdowns containsObject: [self mixdown]])
@@ -295,7 +296,6 @@ static NSMutableArray *masterBitRateArray = nil;
unsigned int count = [masterBitRateArray count];
int trackInputBitRate = [[[self track] objectForKey: keyAudioInputBitrate] intValue];
- BOOL limitsToTrackInputBitRate = ([[codec objectForKey: keyAudioCodec] intValue] & HB_ACODEC_PASS_FLAG) ? YES : NO;
int theSampleRate = [[[self sampleRate] objectForKey: keyAudioSamplerate] intValue];
if (0 == theSampleRate) // this means Auto
@@ -308,45 +308,46 @@ static NSMutableArray *masterBitRateArray = nil;
hb_get_audio_bitrate_limits(ourCodec, theSampleRate, ourMixdown, &minBitRate, &maxBitRate);
int theDefaultBitRate = hb_get_default_audio_bitrate(ourCodec, theSampleRate, ourMixdown);
- for (unsigned int i = 0; i < count; i++)
- {
- dict = [masterBitRateArray objectAtIndex: i];
- currentBitRate = [[dict objectForKey: keyAudioBitrate] intValue];
-
- // First ensure the bitrate falls within range of the codec
- shouldAdd = (currentBitRate >= minBitRate && currentBitRate <= maxBitRate);
+ BOOL codecIsPassthru = ([[codec objectForKey: keyAudioCodec] intValue] & HB_ACODEC_PASS_FLAG) ? YES : NO;
+ BOOL codecIsLossless = (theDefaultBitRate == -1) ? YES : NO;
- // Now make sure the mixdown is not limiting us to the track input bitrate
- if (shouldAdd && limitsToTrackInputBitRate)
- {
- if (currentBitRate != trackInputBitRate)
- {
- shouldAdd = NO;
- }
- }
-
- if (shouldAdd)
+ if (codecIsPassthru)
+ {
+ NSDictionary *sourceBitRate = [masterBitRateArray dictionaryWithObject: [NSNumber numberWithInt: trackInputBitRate]
+ matchingKey: keyAudioBitrate];
+ if (!sourceBitRate)
{
- [permittedBitRates addObject: dict];
+ // the source bitrate isn't in the master array - create it
+ sourceBitRate = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSString stringWithFormat: @"%d", trackInputBitRate], keyAudioBitrateName,
+ [NSNumber numberWithInt: trackInputBitRate], keyAudioBitrate,
+ nil];
}
+ [permittedBitRates addObject: sourceBitRate];
}
-
- // There is a situation where we have a mixdown requirement to match the track input bit rate,
- // but it does not fall into the range the codec supports. Therefore, we force it here.
- if (limitsToTrackInputBitRate && 0 == [permittedBitRates count])
+ else if (codecIsLossless)
{
- NSDictionary *missingBitRate = [masterBitRateArray dictionaryWithObject: [NSNumber numberWithInt: trackInputBitRate] matchingKey: keyAudioBitrate];
- if (!missingBitRate)
+ NSDictionary *bitRateNotApplicable = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSString stringWithString: @"N/A"], keyAudioBitrateName,
+ [NSNumber numberWithInt: -1], keyAudioBitrate,
+ nil];
+ [permittedBitRates addObject: bitRateNotApplicable];
+ }
+ else
+ {
+ for (unsigned int i = 0; i < count; i++)
{
- // We are in an even worse situation where the requested bit rate does not even exist in the underlying
- // library of supported bitrates. Of course since this value is ignored we can freely make a bogus one
- // for the UI just to make the user a little more aware.
- missingBitRate = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSString stringWithFormat: @"%d", trackInputBitRate], keyAudioBitrateName,
- [NSNumber numberWithInt: trackInputBitRate], keyAudioBitrate,
- nil];
+ dict = [masterBitRateArray objectAtIndex: i];
+ currentBitRate = [[dict objectForKey: keyAudioBitrate] intValue];
+
+ // First ensure the bitrate falls within range of the codec
+ shouldAdd = (currentBitRate >= minBitRate && currentBitRate <= maxBitRate);
+
+ if (shouldAdd)
+ {
+ [permittedBitRates addObject: dict];
+ }
}
- [permittedBitRates addObject: missingBitRate];
}
if (![self enabled])
@@ -479,7 +480,8 @@ static NSMutableArray *masterBitRateArray = nil;
- (void) setTrackFromIndex: (int) aValue
{
- [self setTrack: [self.controller.masterTrackArray dictionaryWithObject: [NSNumber numberWithInt: aValue] matchingKey: keyAudioTrackIndex]];
+ [self setTrack: [self.controller.masterTrackArray dictionaryWithObject: [NSNumber numberWithInt: aValue]
+ matchingKey: keyAudioTrackIndex]];
}
// This returns whether it is able to set the actual codec desired.
@@ -594,12 +596,29 @@ static NSMutableArray *masterBitRateArray = nil;
return retval;
}
+- (BOOL) bitrateEnabled
+
+{
+ BOOL retval = [self enabled];
+
+ if (retval)
+ {
+ int myCodecCodec = [[[self codec] objectForKey: keyAudioCodec] intValue];
+ int myCodecDefaultBitrate = hb_get_default_audio_bitrate(myCodecCodec, 0, 0);
+ if (myCodecDefaultBitrate < 0)
+ {
+ retval = NO;
+ }
+ }
+ return retval;
+}
+
- (BOOL) AC3Enabled
{
BOOL retval = [self enabled];
- if ( retval)
+ if (retval)
{
int myTrackCodec = [[[self track] objectForKey: keyAudioInputCodec] intValue];
int myCodecCodec = [[[self codec] objectForKey: keyAudioCodec] intValue];
@@ -644,6 +663,10 @@ static NSMutableArray *masterBitRateArray = nil;
{
retval = [NSSet setWithObjects: @"track", @"codec", nil];
}
+ else if ([key isEqualToString: @"bitrateEnabled"])
+ {
+ retval = [NSSet setWithObjects: @"track", @"codec", nil];
+ }
else if ([key isEqualToString: @"mixdownEnabled"])
{
retval = [NSSet setWithObjects: @"track", @"mixdown", nil];