summaryrefslogtreecommitdiffstats
path: root/libhb/platform
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-04-18 12:10:07 +0000
committersr55 <[email protected]>2011-04-18 12:10:07 +0000
commite63f490b2e0a90bafb690e1d1f1f1e2f44729309 (patch)
treeba6efe28059341ad798d5e20d1682233e057e55c /libhb/platform
parent4d2dce20625d08032eb25dd2d98c3d4319d8e0d9 (diff)
HE-AAC support for the OSX port. Thanks go to amarcus, ritsuka and rodeo.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3937 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/platform')
-rw-r--r--libhb/platform/macosx/encca_aac.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/libhb/platform/macosx/encca_aac.c b/libhb/platform/macosx/encca_aac.c
index 21b458960..85c9c2d88 100644
--- a/libhb/platform/macosx/encca_aac.c
+++ b/libhb/platform/macosx/encca_aac.c
@@ -6,7 +6,11 @@
#include <AudioToolbox/AudioToolbox.h>
#include <CoreAudio/CoreAudio.h>
-int encCoreAudioInit( hb_work_object_t *, hb_job_t * );
+enum AAC_MODE { AAC_MODE_LC, AAC_MODE_HE };
+
+int encCoreAudioInitLC( hb_work_object_t *, hb_job_t * );
+int encCoreAudioInitHE( hb_work_object_t *, hb_job_t * );
+int encCoreAudioInit( hb_work_object_t *, hb_job_t *, enum AAC_MODE mode );
int encCoreAudioWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** );
void encCoreAudioClose( hb_work_object_t * );
@@ -14,7 +18,16 @@ hb_work_object_t hb_encca_aac =
{
WORK_ENC_CA_AAC,
"AAC encoder (Apple)",
- encCoreAudioInit,
+ encCoreAudioInitLC,
+ encCoreAudioWork,
+ encCoreAudioClose
+};
+
+hb_work_object_t hb_encca_haac =
+{
+ WORK_ENC_CA_HAAC,
+ "HE-AAC encoder (Apple)",
+ encCoreAudioInitHE,
encCoreAudioWork,
encCoreAudioClose
};
@@ -93,11 +106,26 @@ static long ReadESDSDescExt(void* descExt, UInt8 **buffer, UInt32 *size, int ver
}
/***********************************************************************
+ * hb_work_encCoreAudio_init switches
+ ***********************************************************************
+ *
+ **********************************************************************/
+int encCoreAudioInitLC( hb_work_object_t * w, hb_job_t * job )
+{
+ return encCoreAudioInit( w, job, AAC_MODE_LC );
+}
+
+int encCoreAudioInitHE( hb_work_object_t * w, hb_job_t * job )
+{
+ return encCoreAudioInit( w, job, AAC_MODE_HE );
+}
+
+/***********************************************************************
* hb_work_encCoreAudio_init
***********************************************************************
*
**********************************************************************/
-int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
+int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job, enum AAC_MODE mode )
{
hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) );
hb_audio_t * audio = w->audio;
@@ -122,7 +150,16 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
input.mBitsPerChannel = 32;
bzero( &output, sizeof( AudioStreamBasicDescription ) );
- output.mFormatID = kAudioFormatMPEG4AAC;
+ switch ( mode )
+ {
+ case AAC_MODE_HE:
+ output.mFormatID = kAudioFormatMPEG4AAC_HE;
+ break;
+ case AAC_MODE_LC:
+ default:
+ output.mFormatID = kAudioFormatMPEG4AAC;
+ break;
+ }
output.mSampleRate = ( Float64 ) audio->config.out.samplerate;
output.mChannelsPerFrame = pv->nchannels;
// let CoreAudio decide the rest...
@@ -133,7 +170,16 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
{
// Retry without the samplerate
bzero( &output, sizeof( AudioStreamBasicDescription ) );
- output.mFormatID = kAudioFormatMPEG4AAC;
+ switch ( mode )
+ {
+ case AAC_MODE_HE:
+ output.mFormatID = kAudioFormatMPEG4AAC_HE;
+ break;
+ case AAC_MODE_LC:
+ default:
+ output.mFormatID = kAudioFormatMPEG4AAC;
+ break;
+ }
output.mChannelsPerFrame = pv->nchannels;
err = AudioConverterNew( &input, &output, &pv->converter );
@@ -161,7 +207,7 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
// set encoder bitrate control mode to constrained variable
tmp = kAudioCodecBitRateControlMode_VariableConstrained;
AudioConverterSetProperty( pv->converter, kAudioCodecPropertyBitRateControlMode,
- sizeof( tmp ), &tmp );
+ sizeof( tmp ), &tmp );
// get available bitrates
AudioValueRange *bitrates;
@@ -180,8 +226,11 @@ int encCoreAudioInit( hb_work_object_t * w, hb_job_t * job )
if( tmp > bitrates[bitrateCounts-1].mMinimum )
tmp = bitrates[bitrateCounts-1].mMinimum;
free( bitrates );
+ if( tmp != audio->config.out.bitrate * 1000 )
+ hb_log( "encca_aac: sanitizing track %d audio bitrate %d to %"PRIu32"",
+ audio->config.out.track, audio->config.out.bitrate, tmp/1000 );
AudioConverterSetProperty( pv->converter, kAudioConverterEncodeBitRate,
- sizeof( tmp ), &tmp );
+ sizeof( tmp ), &tmp );
// get real input
tmpsiz = sizeof( input );
@@ -256,7 +305,7 @@ static OSStatus inInputDataProc( AudioConverterRef converter, UInt32 *npackets,
{
*npackets = 0;
hb_log( "CoreAudio: no data to use in inInputDataProc" );
- return noErr;
+ return 1;
}
if( pv->buf != NULL )