summaryrefslogtreecommitdiffstats
path: root/macosx/HBAudioTrackPreset.m
diff options
context:
space:
mode:
authorRodeo <[email protected]>2015-05-19 20:21:47 +0000
committerRodeo <[email protected]>2015-05-19 20:21:47 +0000
commitaef3d731cabd8a5f5a7166741b848f482246a51b (patch)
treeaa6ea6d5e2954ae2f093d0afd652fa85ea4c646a /macosx/HBAudioTrackPreset.m
parente4c5f142c7a496f3f1f40faf52d9e0defa79ff49 (diff)
MacGui: better samplerate validation.
Not all encoders support all samplerate, so we filter the list based on the encoder and validate the selected samplerate when switching encoders. Also improve bitrate validation a bit. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7210 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBAudioTrackPreset.m')
-rw-r--r--macosx/HBAudioTrackPreset.m40
1 files changed, 38 insertions, 2 deletions
diff --git a/macosx/HBAudioTrackPreset.m b/macosx/HBAudioTrackPreset.m
index 4ebb2071d..fc73fe333 100644
--- a/macosx/HBAudioTrackPreset.m
+++ b/macosx/HBAudioTrackPreset.m
@@ -56,6 +56,7 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex;
{
_encoder = encoder;
[self validateMixdown];
+ [self validateSamplerate];
[self validateBitrate];
}
@@ -85,9 +86,34 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex;
}
}
+- (void)validateSamplerate
+{
+ if (self.encoder & HB_ACODEC_PASS_FLAG)
+ {
+ self.sampleRate = 0; // Auto (same as source)
+ }
+ else if (self.sampleRate)
+ {
+ self.sampleRate = hb_audio_samplerate_get_best(self.encoder, self.sampleRate, NULL);
+ }
+}
+
- (void)validateBitrate
{
- self.bitRate = hb_audio_bitrate_get_best(self.encoder, self.bitRate, self.sampleRate, self.mixdown);
+ if (self.encoder & HB_ACODEC_PASS_FLAG)
+ {
+ self.bitRate = -1;
+ }
+ else if (self.bitRate == -1) // switching from passthru
+ {
+ self.bitRate = hb_audio_bitrate_get_default(self.encoder,
+ self.sampleRate ? self.sampleRate : DEFAULT_SAMPLERATE,
+ self.mixdown);
+ }
+ else
+ {
+ self.bitRate = hb_audio_bitrate_get_best(self.encoder, self.bitRate, self.sampleRate, self.mixdown);
+ }
}
- (BOOL)mixdownEnabled
@@ -184,7 +210,11 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex;
audio_samplerate != NULL;
audio_samplerate = hb_audio_samplerate_get_next(audio_samplerate))
{
- [samplerates addObject:@(audio_samplerate->name)];
+ int rate = audio_samplerate->rate;
+ if (rate == hb_audio_samplerate_get_best(self.encoder, rate, NULL))
+ {
+ [samplerates addObject:@(audio_samplerate->name)];
+ }
}
return samplerates;
}
@@ -400,6 +430,12 @@ static void *HBAudioEncoderContex = &HBAudioEncoderContex;
- (id)transformedValue:(id)value
{
+ // treat -1 as a special invalid value
+ // e.g. passthru has no bitrate since we have no source
+ if ([value intValue] == -1)
+ {
+ return @"N/A";
+ }
return [value stringValue];
}