diff options
author | jstebbins <[email protected]> | 2012-01-04 22:46:45 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2012-01-04 22:46:45 +0000 |
commit | c76a5114cf145f954dbf7ca2938f482a972a44d8 (patch) | |
tree | c3b155f4320821fdb3b60f5ba67325f0c1c2b1db | |
parent | af9c16ff2657a0ef52b1fad917e938e0401bc728 (diff) |
Fix flac md5 sum
Two mistakes. First, we were sending NULL to the encoder twice, which
causes libav to finalize the md5 a second time and corrupt it. Second,
I forgot that the context extradata needs to be re-copied to our audio
config before the muxer updates the flac header information.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4398 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/encavcodecaudio.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c index d1af516da..3a23256fa 100644 --- a/libhb/encavcodecaudio.c +++ b/libhb/encavcodecaudio.c @@ -166,6 +166,13 @@ static void Finalize( hb_work_object_t * w ) // in context extradata avcodec_encode_audio( pv->context, buf->data, buf->alloc, NULL ); hb_buffer_close( &buf ); + + // Then we need to recopy the header since it was modified + if ( pv->context->extradata ) + { + memcpy( w->config->extradata.bytes, pv->context->extradata, pv->context->extradata_size ); + w->config->extradata.length = pv->context->extradata_size; + } } static void encavcodecaClose( hb_work_object_t * w ) @@ -275,7 +282,6 @@ static hb_buffer_t * Encode( hb_work_object_t * w ) static hb_buffer_t * Flush( hb_work_object_t * w ) { - hb_work_private_t * pv = w->private_data; hb_buffer_t *first, *buf, *last; first = last = buf = Encode( w ); @@ -288,17 +294,13 @@ static hb_buffer_t * Flush( hb_work_object_t * w ) if( last ) { - last->next = hb_buffer_init( pv->output_bytes ); - buf = last->next; + last->next = hb_buffer_init( 0 ); } else { - first = buf = hb_buffer_init( pv->output_bytes ); + first = hb_buffer_init( 0 ); } - // Finalize with NULL input needed by FLAC to generate md5sum - // in context extradata - avcodec_encode_audio( pv->context, buf->data, buf->alloc, NULL ); - buf->size = 0; + return first; } |