X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fplatform%2Fmacosx%2Fencca_aac.c;h=5012104f170b9bd7b6947cdb503d89efe0151712;hb=033e32de9c380f54c7d1362a3979da205ebc3a29;hp=69b29ec4b6d1c5811968753787e8168b5f3221c1;hpb=c0e795c30dffcb96c31a60737952d81c998d9a23;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c index 69b29ec4..5012104f 100644 --- a/libhb/platform/macosx/encca_aac.c +++ b/libhb/platform/macosx/encca_aac.c @@ -29,6 +29,7 @@ struct hb_work_private_s hb_list_t *list; unsigned long isamples, isamplesiz, omaxpacket, nchannels; uint64_t pts, ibytes; + Float64 osamplerate; }; #define MP4ESDescrTag 0x03 @@ -57,7 +58,7 @@ static int readDescr(UInt8 **buffer, int *tag) } // based off of mov_read_esds from mov.c in ffmpeg's libavformat -static long ReadESDSDescExt(void* descExt, UInt8 **buffer, int *size, int versionFlags) +static long ReadESDSDescExt(void* descExt, UInt8 **buffer, UInt32 *size, int versionFlags) { UInt8 *esds = (UInt8 *) descExt; int tag, len; @@ -121,8 +122,8 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job ) input.mBitsPerChannel = 32; bzero( &output, sizeof( AudioStreamBasicDescription ) ); - output.mSampleRate = ( Float64 ) audio->config.out.samplerate; output.mFormatID = kAudioFormatMPEG4AAC; + output.mSampleRate = ( Float64 ) audio->config.out.samplerate; output.mChannelsPerFrame = pv->nchannels; // let CoreAudio decide the rest... @@ -130,9 +131,19 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job ) err = AudioConverterNew( &input, &output, &pv->converter ); if( err != noErr) { - hb_log( "Error creating an AudioConverter %x %d", err, output.mBytesPerFrame ); - *job->die = 1; - return 0; + // Retry without the samplerate + bzero( &output, sizeof( AudioStreamBasicDescription ) ); + output.mFormatID = kAudioFormatMPEG4AAC; + output.mChannelsPerFrame = pv->nchannels; + + err = AudioConverterNew( &input, &output, &pv->converter ); + + if( err != noErr) + { + hb_log( "Error creating an AudioConverter err=%"PRId64" %"PRIu64, (int64_t)err, (uint64_t)output.mBytesPerFrame ); + *job->die = 1; + return 0; + } } if( audio->config.out.mixdown == HB_AMIXDOWN_6CH && audio->config.in.codec == HB_ACODEC_AC3 ) @@ -154,7 +165,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job ) // get available bitrates AudioValueRange *bitrates; - ssize_t bitrateCounts, n; + ssize_t bitrateCounts; err = AudioConverterGetPropertyInfo( pv->converter, kAudioConverterApplicableEncodeBitRates, &tmpsiz, NULL); bitrates = malloc( tmpsiz ); @@ -184,8 +195,9 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job ) &tmpsiz, &output ); // set sizes - pv->isamplesiz = input.mBytesPerPacket; - pv->isamples = output.mFramesPerPacket; + pv->isamplesiz = input.mBytesPerPacket; + pv->isamples = output.mFramesPerPacket; + pv->osamplerate = output.mSampleRate; // get maximum output size AudioConverterGetProperty( pv->converter, @@ -200,7 +212,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job ) &tmp, w->config->aac.bytes ); // CoreAudio returns a complete ESDS, but we only need // the DecoderSpecific info. - UInt8* buffer; + UInt8* buffer = NULL; ReadESDSDescExt(w->config->aac.bytes, &buffer, &tmpsiz, 0); w->config->aac.length = tmpsiz; memmove( w->config->aac.bytes, buffer, @@ -299,7 +311,7 @@ static hb_buffer_t * Encode( hb_work_object_t * w ) return NULL; obuf->start = pv->pts; - pv->pts += 90000LL * pv->isamples / w->audio->config.out.samplerate; + pv->pts += 90000LL * pv->isamples / pv->osamplerate; obuf->stop = pv->pts; obuf->size = odesc.mDataByteSize; obuf->frametype = HB_FRAME_AUDIO;