summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2010-03-14 01:15:31 +0000
committerjstebbins <[email protected]>2010-03-14 01:15:31 +0000
commit70ce62705b318f5ca12791a87e24065401f844cc (patch)
tree1d753d41b24644f31242e16ea8f2adec0300c97d /libhb
parent8412fb04b943ce61befffe2caad64ed786d62415 (diff)
improve lame audio quality by using ABR mode and disabling joint stereo mode
add mp3 muxing into mp4 container. cli and gtk gui now support this. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3167 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/enclame.c11
-rw-r--r--libhb/muxmp4.c29
2 files changed, 38 insertions, 2 deletions
diff --git a/libhb/enclame.c b/libhb/enclame.c
index 027aa3add..a3f4a3882 100644
--- a/libhb/enclame.c
+++ b/libhb/enclame.c
@@ -48,10 +48,19 @@ int enclameInit( hb_work_object_t * w, hb_job_t * job )
hb_log( "enclame: opening libmp3lame" );
pv->lame = lame_init();
- lame_set_brate( pv->lame, audio->config.out.bitrate );
+ // use ABR
+ lame_set_VBR( pv->lame, vbr_abr );
+ lame_set_VBR_mean_bitrate_kbps( pv->lame, audio->config.out.bitrate );
lame_set_in_samplerate( pv->lame, audio->config.out.samplerate );
lame_set_out_samplerate( pv->lame, audio->config.out.samplerate );
lame_init_params( pv->lame );
+ // Lame's default encoding mode is JOINT_STEREO. This subtracts signal
+ // that is "common" to left and right (within some threshold) and encodes
+ // it separately. This improves quality at low bitrates, but hurts
+ // imaging (channel separation) at higher bitrates. So if the bitrate
+ // is suffeciently high, use regular STEREO mode.
+ if ( audio->config.out.bitrate >= 128 )
+ lame_set_mode( pv->lame, STEREO );
pv->input_samples = 1152 * 2;
pv->output_bytes = LAME_MAXMP3BUFFER;
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c
index dcab2e5a6..01ba94004 100644
--- a/libhb/muxmp4.c
+++ b/libhb/muxmp4.c
@@ -347,7 +347,8 @@ static int MP4Init( hb_mux_object_t * m )
(const uint8_t*)(audio->config.out.name),
strlen(audio->config.out.name));
}
- } else {
+ } else if( audio->config.out.codec == HB_ACODEC_FAAC ||
+ audio->config.out.codec == HB_ACODEC_CA_AAC ) {
mux_data->track = MP4AddAudioTrack(
m->file,
audio->config.out.samplerate, 1024, MP4_MPEG4_AUDIO_TYPE );
@@ -376,6 +377,32 @@ static int MP4Init( hb_mux_object_t * m )
/* Set the correct number of channels for this track */
MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.mp4a.channels", (uint16_t)HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown));
+ } else if( audio->config.out.codec == HB_ACODEC_LAME ) {
+ mux_data->track = MP4AddAudioTrack(
+ m->file,
+ audio->config.out.samplerate, 1152, MP4_MPEG2_AUDIO_TYPE );
+
+ /* Tune track chunk duration */
+ MP4TuneTrackDurationPerChunk( m, mux_data->track );
+
+ if (audio->config.out.name == NULL) {
+ MP4SetTrackBytesProperty(
+ m->file, mux_data->track,
+ "udta.name.value",
+ (const uint8_t*)"Stereo", strlen("Stereo"));
+ }
+ else {
+ MP4SetTrackBytesProperty(
+ m->file, mux_data->track,
+ "udta.name.value",
+ (const uint8_t*)(audio->config.out.name),
+ strlen(audio->config.out.name));
+ }
+
+ MP4SetAudioProfileLevel( m->file, 0x0F );
+
+ /* Set the correct number of channels for this track */
+ MP4SetTrackIntegerProperty(m->file, mux_data->track, "mdia.minf.stbl.stsd.mp4a.channels", (uint16_t)HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->config.out.mixdown));
}
/* Set the language for this track */