Some work on PCM.
This commit is contained in:
1 parent
1125e84048
commit
ae0c27b8a8
4 files changed
+61
-15
No files matched your search
+17
-1
@@ -65,6 +65,22 @@ void FFInitFFmpeg()
|
|||||||
REGISTER_DECODER(dca);
|
REGISTER_DECODER(dca);
|
||||||
REGISTER_DECODER(truehd);
|
REGISTER_DECODER(truehd);
|
||||||
REGISTER_DECODER(mlp);
|
REGISTER_DECODER(mlp);
|
||||||
|
REGISTER_DECODER(pcm_f32be);
|
||||||
|
REGISTER_DECODER(pcm_f32le);
|
||||||
|
REGISTER_DECODER(pcm_f64be);
|
||||||
|
REGISTER_DECODER(pcm_f64le);
|
||||||
|
REGISTER_DECODER(pcm_s16be);
|
||||||
|
REGISTER_DECODER(pcm_s16le);
|
||||||
|
REGISTER_DECODER(pcm_s16le_planar);
|
||||||
|
REGISTER_DECODER(pcm_s24be);
|
||||||
|
REGISTER_DECODER(pcm_s24le);
|
||||||
|
REGISTER_DECODER(pcm_s32be);
|
||||||
|
REGISTER_DECODER(pcm_s32le);
|
||||||
|
REGISTER_DECODER(pcm_s8);
|
||||||
|
REGISTER_DECODER(pcm_u16be);
|
||||||
|
REGISTER_DECODER(pcm_u16le);
|
||||||
|
REGISTER_DECODER(pcm_u24be);
|
||||||
|
REGISTER_DECODER(pcm_u24le);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +104,7 @@ static const struct {
|
|||||||
{ 'DTS ', AV_CODEC_ID_DTS },
|
{ 'DTS ', AV_CODEC_ID_DTS },
|
||||||
{ 'trhd', AV_CODEC_ID_TRUEHD },
|
{ 'trhd', AV_CODEC_ID_TRUEHD },
|
||||||
{ 'mlp ', AV_CODEC_ID_MLP },
|
{ 'mlp ', AV_CODEC_ID_MLP },
|
||||||
{ kAudioFormatLinearPCM, AV_CODEC_ID_PCM_S16LE },
|
{ kAudioFormatLinearPCM, AV_CODEC_ID_PCM_S16BE },
|
||||||
{ kAudioFormatLinearPCM, AV_CODEC_ID_PCM_U8 },
|
{ kAudioFormatLinearPCM, AV_CODEC_ID_PCM_U8 },
|
||||||
{ kAudioFormatALaw, AV_CODEC_ID_PCM_ALAW },
|
{ kAudioFormatALaw, AV_CODEC_ID_PCM_ALAW },
|
||||||
{ kAudioFormatULaw, AV_CODEC_ID_PCM_MULAW },
|
{ kAudioFormatULaw, AV_CODEC_ID_PCM_MULAW },
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "MP42FileImporter.h"
|
#import "MP42FileImporter.h"
|
||||||
|
|
||||||
@class AVAsset;
|
|
||||||
|
|
||||||
@interface MP42AVFImporter : MP42FileImporter
|
@interface MP42AVFImporter : MP42FileImporter
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
+20
-5
@@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
@interface AVFDemuxHelper : NSObject {
|
@interface AVFDemuxHelper : NSObject {
|
||||||
@public
|
@public
|
||||||
int64_t currentTime;
|
int64_t currentTime;
|
||||||
int64_t minDisplayOffset;
|
int64_t minDisplayOffset;
|
||||||
|
|
||||||
AVAssetReaderOutput *assetReaderOutput;
|
AVAssetReaderOutput *assetReaderOutput;
|
||||||
MP42EditListsReconstructor *editsConstructor;
|
MP42EditListsReconstructor *editsConstructor;
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray<NSString *> *)supportedFileFormats {
|
+ (NSArray<NSString *> *)supportedFileFormats {
|
||||||
return @[@"mov", @"mp4", @"m4v", @"m4a", @"m2ts", @"ts", @"mts", @"ac3", @"eac3", @"ec3", @"webvtt", @"vtt"];
|
return @[@"mov", @"mp4", @"m4v", @"m4a", @"m2ts", @"ts", @"mts", @"ac3", @"eac3", @"ec3", @"webvtt", @"vtt", @"caf", @"aif", @"aiff"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (FourCharCode)formatForTrack:(AVAssetTrack *)track {
|
- (FourCharCode)formatForTrack:(AVAssetTrack *)track {
|
||||||
@@ -725,6 +725,22 @@
|
|||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (AudioStreamBasicDescription)audioDescriptionForTrack:(MP42AudioTrack *)track
|
||||||
|
{
|
||||||
|
AudioStreamBasicDescription result;
|
||||||
|
bzero(&result, sizeof(AudioStreamBasicDescription));
|
||||||
|
|
||||||
|
AVAssetTrack *assetTrack = [_localAsset trackWithTrackID:track.sourceId];
|
||||||
|
CMFormatDescriptionRef formatDescription = (CMFormatDescriptionRef)assetTrack.formatDescriptions.firstObject;
|
||||||
|
|
||||||
|
if (formatDescription) {
|
||||||
|
const AudioStreamBasicDescription *asbd = CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
|
||||||
|
memcpy(&result, asbd, sizeof(AudioStreamBasicDescription));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)demux {
|
- (void)demux {
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
|
|
||||||
@@ -754,7 +770,7 @@
|
|||||||
demuxHelper->assetReaderOutput = assetReaderOutput;
|
demuxHelper->assetReaderOutput = assetReaderOutput;
|
||||||
demuxHelper->editsConstructor = [[MP42EditListsReconstructor alloc] initWithMediaFormat:track.format];
|
demuxHelper->editsConstructor = [[MP42EditListsReconstructor alloc] initWithMediaFormat:track.format];
|
||||||
|
|
||||||
totalDataLength += [track dataLength];
|
totalDataLength += track.dataLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,7 +952,6 @@
|
|||||||
if ([dict valueForKey:(NSString*)kCMSampleAttachmentKey_DoNotDisplay]) {
|
if ([dict valueForKey:(NSString*)kCMSampleAttachmentKey_DoNotDisplay]) {
|
||||||
doNotDisplay = YES;
|
doNotDisplay = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+24
-7
@@ -131,6 +131,12 @@ typedef struct MP42DecodeContext MP42DecodeContext;
|
|||||||
av_dict_set(&av_opts, "drc_scale", drc_scale, 0);
|
av_dict_set(&av_opts, "drc_scale", drc_scale, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (asbd.mFormatID == kAudioFormatLinearPCM)
|
||||||
|
{
|
||||||
|
_avctx->channels = asbd.mChannelsPerFrame;
|
||||||
|
_avctx->sample_rate = asbd.mSampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
if (avcodec_open2(_avctx, _codec, &av_opts)) {
|
if (avcodec_open2(_avctx, _codec, &av_opts)) {
|
||||||
NSLog(@"Error opening audio decoder");
|
NSLog(@"Error opening audio decoder");
|
||||||
av_freep(&_avctx);
|
av_freep(&_avctx);
|
||||||
@@ -271,6 +277,11 @@ static void configureDescriptors(MP42DecodeContext *context, AVFrame *frame)
|
|||||||
int nb_channels = av_get_channel_layout_nb_channels(frame->channel_layout);
|
int nb_channels = av_get_channel_layout_nb_channels(frame->channel_layout);
|
||||||
int sample_rate = frame->sample_rate;
|
int sample_rate = frame->sample_rate;
|
||||||
|
|
||||||
|
// FIXME PCM
|
||||||
|
if (nb_channels == 0) {
|
||||||
|
nb_channels = context->inputFormat->mChannelsPerFrame;
|
||||||
|
}
|
||||||
|
|
||||||
// Reset the channels per frame and sample rate
|
// Reset the channels per frame and sample rate
|
||||||
if (context->inputFormat->mChannelsPerFrame == context->outputFormat->mChannelsPerFrame) {
|
if (context->inputFormat->mChannelsPerFrame == context->outputFormat->mChannelsPerFrame) {
|
||||||
context->outputFormat->mChannelsPerFrame = nb_channels;
|
context->outputFormat->mChannelsPerFrame = nb_channels;
|
||||||
@@ -296,7 +307,7 @@ static void configureDescriptors(MP42DecodeContext *context, AVFrame *frame)
|
|||||||
context->out_layout = AV_CH_LAYOUT_MONO;
|
context->out_layout = AV_CH_LAYOUT_MONO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (frame->channel_layout) {
|
||||||
context->out_layout = frame->channel_layout;
|
context->out_layout = frame->channel_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,12 +363,18 @@ static int resample(MP42DecodeContext *context, AVFrame *frame, uint8_t **output
|
|||||||
center_mix_level,
|
center_mix_level,
|
||||||
downmix_info->lfe_mix_level);
|
downmix_info->lfe_mix_level);
|
||||||
}
|
}
|
||||||
hb_audio_resample_set_channel_layout(context->resampler,
|
if (frame->channel_layout) {
|
||||||
frame->channel_layout);
|
hb_audio_resample_set_channel_layout(context->resampler,
|
||||||
hb_audio_resample_set_sample_rate(context->resampler,
|
frame->channel_layout);
|
||||||
frame->sample_rate);
|
}
|
||||||
hb_audio_resample_set_sample_fmt(context->resampler,
|
if (frame->sample_rate) {
|
||||||
frame->format);
|
hb_audio_resample_set_sample_rate(context->resampler,
|
||||||
|
frame->sample_rate);
|
||||||
|
}
|
||||||
|
if (frame->format) {
|
||||||
|
hb_audio_resample_set_sample_fmt(context->resampler,
|
||||||
|
frame->format);
|
||||||
|
}
|
||||||
if (hb_audio_resample_update(context->resampler))
|
if (hb_audio_resample_update(context->resampler))
|
||||||
{
|
{
|
||||||
NSLog(@"decavcodec: hb_audio_resample_update() failed");
|
NSLog(@"decavcodec: hb_audio_resample_update() failed");
|
||||||
|
|||||||
Reference in new issue
Block a user