diff options
author | jstebbins <[email protected]> | 2012-07-11 20:10:20 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2012-07-11 20:10:20 +0000 |
commit | 8b91bcb733913afea795cfea6178372eee5b4abe (patch) | |
tree | 09b4bd5693f2c361861d803522d2340b6beab985 /libhb/sync.c | |
parent | 7f1f338df87f6075e7edf0cd598523acaf0f82a1 (diff) |
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
Diffstat (limited to 'libhb/sync.c')
-rw-r--r-- | libhb/sync.c | 36 |
1 files changed, 26 insertions, 10 deletions
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 ); |