summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--gtk/src/hb-backend.c11
-rw-r--r--libhb/enclame.c11
-rw-r--r--libhb/muxmp4.c29
3 files changed, 40 insertions, 11 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index feef2b7fe..49962bd21 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1384,7 +1384,6 @@ ghb_grey_combo_options(GtkBuilder *builder)
}
if (container == HB_MUX_MP4)
{
- grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_LAME, TRUE);
grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_VORBIS, TRUE);
grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, TRUE);
}
@@ -4063,12 +4062,7 @@ ghb_validate_audio(signal_user_data_t *ud)
if (mux == HB_MUX_MP4)
{
mux_s = "MP4";
- // mp4/mp3|vorbis combination is not supported.
- if (codec == HB_ACODEC_LAME)
- {
- a_unsup = "MP3";
- codec = HB_ACODEC_FAAC;
- }
+ // mp4/vorbis|DTS combination is not supported.
if (codec == HB_ACODEC_VORBIS)
{
a_unsup = "Vorbis";
@@ -4517,8 +4511,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
}
}
if ((job->mux == HB_MUX_MP4) &&
- ((audio.out.codec & HB_ACODEC_LAME) ||
- (audio.out.codec & HB_ACODEC_DCA) ||
+ ((audio.out.codec & HB_ACODEC_DCA) ||
(audio.out.codec & HB_ACODEC_VORBIS)))
{
// mp4/mp3|dts|vorbis combination is not supported.
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 */