summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/HBAudioTrackPreset.m73
1 files changed, 56 insertions, 17 deletions
diff --git a/macosx/HBAudioTrackPreset.m b/macosx/HBAudioTrackPreset.m
index 0e2e66a4c..9d785744b 100644
--- a/macosx/HBAudioTrackPreset.m
+++ b/macosx/HBAudioTrackPreset.m
@@ -13,6 +13,7 @@
@interface HBAudioTrackPreset ()
@property (nonatomic, readwrite) int container;
+@property (nonatomic, readwrite) int fallbackEncoder;
@end
@@ -25,6 +26,7 @@
{
// defaults settings
_encoder = HB_ACODEC_CA_AAC;
+ _fallbackEncoder = HB_ACODEC_INVALID;
_container = HB_MUX_MKV;
_sampleRate = 0;
_bitRate = 160;
@@ -60,14 +62,29 @@
if (!(self.undo.isUndoing || self.undo.isRedoing))
{
+ [self validateFallbackEncoder];
[self validateMixdown];
[self validateSamplerate];
[self validateBitrate];
}
}
+- (void)setFallbackEncoder:(int)fallbackEncoder
+{
+ if (fallbackEncoder != _fallbackEncoder)
+ {
+ [[self.undo prepareWithInvocationTarget:self] setFallbackEncoder:_fallbackEncoder];
+ }
+ _fallbackEncoder = fallbackEncoder;
+}
+
- (void)setMixdown:(int)mixdown
{
+ if (mixdown == HB_AMIXDOWN_NONE)
+ {
+ mixdown = hb_mixdown_get_default(self.encoderOrFallbackEncoder, 0);
+ }
+
if (mixdown != _mixdown)
{
[[self.undo prepareWithInvocationTarget:self] setMixdown:_mixdown];
@@ -107,43 +124,62 @@
#pragma mark Validation
/**
- * Validates the mixdown property.
+ If the encoder is a passthru, return its fallback if available
+ to make possible to set the fallback settings.
*/
+- (int)encoderOrFallbackEncoder
+{
+ return (self.fallbackEncoder != HB_ACODEC_INVALID) ? self.fallbackEncoder : self.encoder;
+}
+
+- (void)validateFallbackEncoder
+{
+ if (_encoder & HB_ACODEC_PASS_FLAG)
+ {
+ int fallbackEncoder = hb_audio_encoder_get_fallback_for_passthru(_encoder);
+ self.fallbackEncoder = (fallbackEncoder != HB_ACODEC_INVALID) ? fallbackEncoder : HB_ACODEC_INVALID;
+ }
+ else
+ {
+ self.fallbackEncoder = HB_ACODEC_INVALID;
+ }
+}
+
- (void)validateMixdown
{
- if (!hb_mixdown_has_codec_support(self.mixdown, self.encoder))
+ if (!hb_mixdown_has_codec_support(self.mixdown, self.encoderOrFallbackEncoder))
{
- self.mixdown = hb_mixdown_get_default(self.encoder, 0);
+ self.mixdown = hb_mixdown_get_default(self.encoderOrFallbackEncoder, 0);
}
}
- (void)validateSamplerate
{
- if (self.encoder & HB_ACODEC_PASS_FLAG)
+ if (self.encoderOrFallbackEncoder & HB_ACODEC_PASS_FLAG)
{
self.sampleRate = 0; // Auto (same as source)
}
else if (self.sampleRate)
{
- self.sampleRate = hb_audio_samplerate_find_closest(self.sampleRate, self.encoder);
+ self.sampleRate = hb_audio_samplerate_find_closest(self.sampleRate, self.encoderOrFallbackEncoder);
}
}
- (void)validateBitrate
{
- if (self.encoder & HB_ACODEC_PASS_FLAG)
+ if (self.encoderOrFallbackEncoder & 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.bitRate = hb_audio_bitrate_get_default(self.encoderOrFallbackEncoder,
self.sampleRate ? self.sampleRate : DEFAULT_SAMPLERATE,
self.mixdown);
}
else
{
- self.bitRate = hb_audio_bitrate_get_best(self.encoder, self.bitRate, self.sampleRate, self.mixdown);
+ self.bitRate = hb_audio_bitrate_get_best(self.encoderOrFallbackEncoder, self.bitRate, self.sampleRate, self.mixdown);
}
}
@@ -164,7 +200,7 @@
{
BOOL retval = YES;
- int myCodecDefaultBitrate = hb_audio_bitrate_get_default(self.encoder, 0, 0);
+ int myCodecDefaultBitrate = hb_audio_bitrate_get_default(self.encoderOrFallbackEncoder, 0, 0);
if (myCodecDefaultBitrate < 0)
{
retval = NO;
@@ -176,7 +212,7 @@
{
BOOL retval = YES;
- if (self.encoder & HB_ACODEC_PASS_FLAG)
+ if (self.encoderOrFallbackEncoder & HB_ACODEC_PASS_FLAG)
{
retval = NO;
}
@@ -244,7 +280,7 @@
mixdown != NULL;
mixdown = hb_mixdown_get_next(mixdown))
{
- if (hb_mixdown_has_codec_support(mixdown->amixdown, self.encoder))
+ if (hb_mixdown_has_codec_support(mixdown->amixdown, self.encoderOrFallbackEncoder))
{
[mixdowns addObject:@(mixdown->name)];
}
@@ -262,7 +298,7 @@
audio_samplerate = hb_audio_samplerate_get_next(audio_samplerate))
{
int rate = audio_samplerate->rate;
- if (rate == hb_audio_samplerate_find_closest(rate, self.encoder))
+ if (rate == hb_audio_samplerate_find_closest(rate, self.encoderOrFallbackEncoder))
{
[sampleRates addObject:@(audio_samplerate->name)];
}
@@ -275,7 +311,7 @@
int minBitRate = 0;
int maxBitRate = 0;
- hb_audio_bitrate_get_limits(self.encoder, self.sampleRate, self.mixdown, &minBitRate, &maxBitRate);
+ hb_audio_bitrate_get_limits(self.encoderOrFallbackEncoder, self.sampleRate, self.mixdown, &minBitRate, &maxBitRate);
NSMutableArray<NSString *> *bitRates = [[NSMutableArray alloc] init];
for (const hb_rate_t *audio_bitrate = hb_audio_bitrate_get_next(NULL);
@@ -300,19 +336,19 @@
[key isEqualToString:@"passThruDisabled"] ||
[key isEqualToString:@"mixdownEnabled"])
{
- retval = [NSSet setWithObjects:@"encoder", nil];
+ retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", nil];
}
else if ([key isEqualToString:@"mixdowns"])
{
- retval = [NSSet setWithObjects:@"encoder", nil];
+ retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", nil];
}
else if ([key isEqualToString:@"sampleRates"])
{
- retval = [NSSet setWithObjects:@"encoder", @"mixdown", nil];
+ retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", @"mixdown", nil];
}
else if ([key isEqualToString:@"bitRates"])
{
- retval = [NSSet setWithObjects:@"encoder", @"mixdown", @"sampleRate", nil];
+ retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", @"mixdown", @"sampleRate", nil];
}
else
{
@@ -339,6 +375,7 @@
if (copy)
{
copy->_encoder = _encoder;
+ copy->_fallbackEncoder = _fallbackEncoder;
copy->_mixdown = _mixdown;
copy->_sampleRate = _sampleRate;
copy->_bitRate = _bitRate;
@@ -388,6 +425,8 @@
decodeInt(_container);
+ [self validateFallbackEncoder];
+
return self;
}