From a204a7468566e9aa0ce38c5b6bbf35d3b68cf398 Mon Sep 17 00:00:00 2001 From: saintdev Date: Sat, 7 Jul 2007 05:25:00 +0000 Subject: vorbis: gracefully fail if encoder setup fails, and remove depriciated OV_ECTL_RATEMANAGE_AVG. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@656 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/encvorbis.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'libhb') diff --git a/libhb/encvorbis.c b/libhb/encvorbis.c index f8aa365a9..5c919c6b0 100644 --- a/libhb/encvorbis.c +++ b/libhb/encvorbis.c @@ -45,6 +45,7 @@ int encvorbisInit( hb_work_object_t * w, hb_job_t * job ) { int i; ogg_packet header[3]; + struct ovectl_ratemanage2_arg ctl_rate_arg; hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) ); w->private_data = pv; @@ -57,11 +58,27 @@ int encvorbisInit( hb_work_object_t * w, hb_job_t * job ) /* init */ vorbis_info_init( &pv->vi ); if( vorbis_encode_setup_managed( &pv->vi, pv->out_discrete_channels, - job->arate, -1, 1000 * job->abitrate, -1 ) || - vorbis_encode_ctl( &pv->vi, OV_ECTL_RATEMANAGE_AVG, NULL ) || - vorbis_encode_setup_init( &pv->vi ) ) + job->arate, -1, 1000 * job->abitrate, -1 ) ) { hb_log( "encvorbis: vorbis_encode_setup_managed failed" ); + *job->die = 1; + return 0; + } + + if( vorbis_encode_ctl( &pv->vi, OV_ECTL_RATEMANAGE2_GET, &ctl_rate_arg) ) + { + hb_log( "encvorbis: vorbis_encode_ctl( ratemanage2_get ) failed" ); + } + + ctl_rate_arg.bitrate_average_kbps = 1000 * job->abitrate; + ctl_rate_arg.managed = 1; + + if( vorbis_encode_ctl( &pv->vi, OV_ECTL_RATEMANAGE2_SET, &ctl_rate_arg ) || + vorbis_encode_setup_init( &pv->vi ) ) + { + hb_log( "encvorbis: vorbis_encode_ctl( ratemanage2_set ) OR vorbis_encode_setup_init failed" ); + *job->die = 1; + return 0; } /* add a comment */ -- cgit v1.2.3