Remove some mix down conversions.
This commit is contained in:
6 files changed
+30
-25
No files matched your search
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#import "MP42MediaFormat.h"
|
||||
#import "MP42AudioUnit.h"
|
||||
|
||||
@class MP42SampleBuffer;
|
||||
@@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithAudioFormat:(AudioStreamBasicDescription)asbd
|
||||
channelLayout:(AudioChannelLayout *)channelLayout
|
||||
channelLayoutSize:(UInt32)channelLayoutSize
|
||||
mixdownType:(NSString *)mixdownType
|
||||
mixdownType:(MP42AudioMixdown)mixdownType
|
||||
drc:(float)drc
|
||||
initialPadding:(UInt32)initialPadding
|
||||
magicCookie:(NSData *)magicCookie
|
||||
|
||||
@@ -68,7 +68,7 @@ typedef struct MP42DecodeContext MP42DecodeContext;
|
||||
- (instancetype)initWithAudioFormat:(AudioStreamBasicDescription)asbd
|
||||
channelLayout:(AudioChannelLayout *)channelLayout
|
||||
channelLayoutSize:(UInt32)channelLayoutSize
|
||||
mixdownType:(NSString *)mixdownType
|
||||
mixdownType:(MP42AudioMixdown)mixdownType
|
||||
drc:(float)drc
|
||||
initialPadding:(UInt32)initialPadding
|
||||
magicCookie:(NSData *)magicCookie
|
||||
@@ -164,19 +164,19 @@ typedef struct MP42DecodeContext MP42DecodeContext;
|
||||
UInt32 channels = _inputFormat.mChannelsPerFrame;
|
||||
enum AVMatrixEncoding matrix_encoding = AV_MATRIX_ENCODING_NONE;
|
||||
if (channels > 1) {
|
||||
if ([mixdownType isEqualToString:SBMonoMixdown]) {
|
||||
if (mixdownType == kMP42AudioMixdown_Mono) {
|
||||
channels = 1;
|
||||
}
|
||||
}
|
||||
if (channels > 2) {
|
||||
if ([mixdownType isEqualToString:SBStereoMixdown]) {
|
||||
if (mixdownType == kMP42AudioMixdown_Stereo) {
|
||||
channels = 2;
|
||||
}
|
||||
else if ([mixdownType isEqualToString:SBDolbyMixdown]) {
|
||||
else if (mixdownType == kMP42AudioMixdown_Dolby) {
|
||||
matrix_encoding = AV_MATRIX_ENCODING_DOLBY;
|
||||
channels = 2;
|
||||
}
|
||||
else if ([mixdownType isEqualToString:SBDolbyPlIIMixdown]) {
|
||||
else if (mixdownType == kMP42AudioMixdown_DolbyPlII) {
|
||||
matrix_encoding = AV_MATRIX_ENCODING_DPLII;
|
||||
channels = 2;
|
||||
}
|
||||
|
||||
@@ -195,11 +195,11 @@
|
||||
|
||||
if ([self.name rangeOfString:@"surround" options:NSCaseInsensitiveSearch].location == NSNotFound) return;
|
||||
|
||||
if ([conversionSettings.mixDown isEqualToString:SBNoneMixdown] && self.channels > 3) {
|
||||
if (conversionSettings.mixDown == kMP42AudioMixdown_None && self.channels > 3) {
|
||||
self.name = (self.channels > FFmpegMaximumSupportedChannels) ? [NSString stringWithFormat:@"Surround %d.1", FFmpegMaximumSupportedChannels - 1] : nameForChannelLayoutTag(self.channelLayoutTag);
|
||||
}
|
||||
else {
|
||||
self.name = (self.channels == 1 || [conversionSettings.mixDown isEqualToString:SBMonoMixdown]) ? @"Mono" : @"Stereo";
|
||||
self.name = (self.channels == 1 || conversionSettings.mixDown == kMP42AudioMixdown_Mono) ? @"Mono" : @"Stereo";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,10 +231,10 @@
|
||||
if (self.conversionSettings && [self.conversionSettings isKindOfClass:[MP42AudioConversionSettings class]]) {
|
||||
MP42AudioConversionSettings *settings = (MP42AudioConversionSettings *)self.conversionSettings;
|
||||
unsigned int channels = _channels;
|
||||
if ([settings.mixDown isEqualToString:SBMonoMixdown] || self.channels == 1) {
|
||||
if (settings.mixDown == kMP42AudioMixdown_Mono || self.channels == 1) {
|
||||
channels = 1;
|
||||
}
|
||||
else if ([settings.mixDown isEqualToString:SBNoneMixdown]) {
|
||||
else if (settings.mixDown == kMP42AudioMixdown_None) {
|
||||
channels = MIN(channels, FFmpegMaximumSupportedChannels);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MP42MediaFormat.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -20,13 +21,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface MP42AudioConversionSettings : MP42ConversionSettings <NSCopying, NSSecureCoding>
|
||||
|
||||
+ (instancetype)audioConversionWithBitRate:(NSUInteger)bitrate mixDown:(NSString *)mixDown drc:(float)drc;
|
||||
+ (instancetype)audioConversionWithBitRate:(NSUInteger)bitrate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc;
|
||||
|
||||
- (instancetype)initWithFormat:(FourCharCode)format bitRate:(NSUInteger)bitRate mixDown:(NSString *)mixDown drc:(float)drc;
|
||||
- (instancetype)initWithFormat:(FourCharCode)format bitRate:(NSUInteger)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc;
|
||||
|
||||
@property (nonatomic, readonly) NSUInteger bitRate;
|
||||
|
||||
@property (nonatomic, readonly) NSString *mixDown;
|
||||
@property (nonatomic, readonly) MP42AudioMixdown mixDown;
|
||||
@property (nonatomic, readonly) float drc;
|
||||
|
||||
@end
|
||||
|
||||
@@ -64,17 +64,17 @@
|
||||
|
||||
@implementation MP42AudioConversionSettings
|
||||
|
||||
+ (instancetype)audioConversionWithBitRate:(NSUInteger)bitRate mixDown:(NSString *)mixDown drc:(float)drc
|
||||
+ (instancetype)audioConversionWithBitRate:(NSUInteger)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc
|
||||
{
|
||||
return [[MP42AudioConversionSettings alloc] initWithFormat:kMP42AudioCodecType_MPEG4AAC bitRate:bitRate mixDown:mixDown drc:drc];
|
||||
}
|
||||
|
||||
- (instancetype)initWithFormat:(FourCharCode)format bitRate:(NSUInteger)bitRate mixDown:(NSString *)mixDown drc:(float)drc
|
||||
- (instancetype)initWithFormat:(FourCharCode)format bitRate:(NSUInteger)bitRate mixDown:(MP42AudioMixdown)mixDown drc:(float)drc
|
||||
{
|
||||
self = [super initWitFormat:format];
|
||||
if (self) {
|
||||
_bitRate = bitRate;
|
||||
_mixDown = [mixDown copy];
|
||||
_mixDown = mixDown;
|
||||
_drc = drc;
|
||||
}
|
||||
return self;
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
if (copy) {
|
||||
copy->_bitRate = _bitRate;
|
||||
copy->_mixDown = [_mixDown copy];
|
||||
copy->_mixDown = _mixDown;
|
||||
copy->_drc = _drc;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeInteger:_bitRate forKey:@"bitRate"];
|
||||
[coder encodeObject:_mixDown forKey:@"mixDown"];
|
||||
[coder encodeInteger:_mixDown forKey:@"mixDownType"];
|
||||
[coder encodeFloat:_drc forKey:@"drc"];
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
self = [super initWithCoder:decoder];
|
||||
|
||||
_bitRate = [decoder decodeIntegerForKey:@"bitRate"];
|
||||
_mixDown = [decoder decodeObjectOfClass:[NSString class] forKey:@"mixDown"];
|
||||
_mixDown = [decoder decodeIntegerForKey:@"mixDownType"];
|
||||
_drc = [decoder decodeFloatForKey:@"drc"];
|
||||
|
||||
return self;
|
||||
|
||||
@@ -199,8 +199,12 @@ enum : MP42MetadataFormatType
|
||||
};
|
||||
|
||||
// Audio downmixes
|
||||
extern NSString * const SBNoneMixdown;
|
||||
extern NSString * const SBMonoMixdown;
|
||||
extern NSString * const SBStereoMixdown;
|
||||
extern NSString * const SBDolbyMixdown;
|
||||
extern NSString * const SBDolbyPlIIMixdown;
|
||||
typedef SInt64 MP42AudioMixdown;
|
||||
enum : MP42AudioMixdown
|
||||
{
|
||||
kMP42AudioMixdown_None = 5,
|
||||
kMP42AudioMixdown_Mono = 4,
|
||||
kMP42AudioMixdown_Stereo = 3,
|
||||
kMP42AudioMixdown_Dolby = 2,
|
||||
kMP42AudioMixdown_DolbyPlII = 1
|
||||
};
|
||||
Reference in new issue
Block a user