From 8b91bcb733913afea795cfea6178372eee5b4abe Mon Sep 17 00:00:00 2001 From: jstebbins Date: Wed, 11 Jul 2012 20:10:20 +0000 Subject: bump libav to libav-v0.8-2197-g1a068bf Resolves several deprecated api's Eliminates several libav patches Eliminates our builtin downmix in favour of avresample Eliminate HB_INPUT_CH_LAYOUT_* and replace with AV_CH_LAYOUT_* Resolves 6.x and 7.0 input channel layout issues HB had Adds downmix support to declpcm. We never had it! git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4825 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/sync.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'libhb/sync.c') diff --git a/libhb/sync.c b/libhb/sync.c index 181d0acb3..fc01c3b12 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -922,7 +922,6 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) gap */ AVCodec * codec; AVCodecContext * c; - short * zeros; switch ( w->audio->config.out.codec ) { @@ -966,8 +965,18 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) return; } - int input_size = c->frame_size * av_get_bytes_per_sample( c->sample_fmt ) * c->channels; + // Prepare input frame + AVFrame frame; + uint8_t * zeros; + + frame.nb_samples= c->frame_size; + int input_size = av_samples_get_buffer_size(NULL, c->channels, + frame.nb_samples, c->sample_fmt, 1); zeros = calloc( 1, input_size ); + avcodec_fill_audio_frame(&frame, c->channels, + c->sample_fmt, zeros, input_size, 1); + frame.pts = 0; + // Allocate enough space for the encoded silence // The output should be < the input sync->silence_buf = malloc( input_size ); @@ -977,19 +986,26 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) int ii; for ( ii = 0; ii < 10; ii++ ) { - sync->silence_size = avcodec_encode_audio( c, sync->silence_buf, - input_size, zeros ); + // Prepare output packet + AVPacket pkt; + int got_packet; + av_init_packet(&pkt); + pkt.data = zeros; + pkt.size = input_size; + + int ret = avcodec_encode_audio2( c, &pkt, &frame, &got_packet); + if ( ret < 0 ) + { + hb_log( "sync: avcodec_encode_audio failed" ); + break; + } - if (sync->silence_size) + if ( got_packet ) { + sync->silence_size = pkt.size; break; } } - if (!sync->silence_size) - { - hb_log( "sync: avcodec_encode_audio failed" ); - } - free( zeros ); hb_avcodec_close( c ); av_free( c ); -- cgit v1.2.3