summaryrefslogtreecommitdiffstats
path: root/libhb/decmpeg2.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-04-13 23:31:37 +0000
committervan <[email protected]>2008-04-13 23:31:37 +0000
commitd3aeb74cdf94f70b643da897dfb666d81a743817 (patch)
tree56f6c5ba9b69726d925e7c13f0e2e0245a134c3f /libhb/decmpeg2.c
parent280d49d8ae91af433b4df17b2e42b267dbdbc083 (diff)
Fixes for different number of frames between pass 1 & 2, missing frames at end, and an deadlock with pcm audio.
- since the SCR clock recovery is done in reader.c we can't currently skip audio frames during pass 1 or we miss clock changes signaled by those frames & end up dropping more video frames in pass 1 than pass 2. - since many modules buffer frames we can't tell if we're done just by looking for empty fifos. Send an empty buffer to mark end-of-stream all the way along the processing pipeline & use it to flush internally buffered data. - in a processing pipeline you're done when the end of the pipe says your done. add a thread status variable so we can tell when individual threads are finished then make do_job wait until the encoder thread is done so that we're sure all the frames have been processed and sent to the muxer. - since the muxer alternates between reading video & audio packets we have to have enough buffer in the audio pipeline to handle a video-frame's worth of audio packets (33ms). Since pcm packets are <1ms we need >60 slots in the audio fifos or we'll deadlock. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1412 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decmpeg2.c')
-rw-r--r--libhb/decmpeg2.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/libhb/decmpeg2.c b/libhb/decmpeg2.c
index 76bece134..03f6656b6 100644
--- a/libhb/decmpeg2.c
+++ b/libhb/decmpeg2.c
@@ -77,14 +77,17 @@ int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
hb_buffer_t * buf;
uint8_t * data;
- /* Feed libmpeg2 */
- if( buf_es->start > -1 )
+ if ( buf_es->size )
{
- mpeg2_tag_picture( m->libmpeg2, buf_es->start >> 32,
- buf_es->start & 0xFFFFFFFF );
+ /* Feed libmpeg2 */
+ if( buf_es->start > -1 )
+ {
+ mpeg2_tag_picture( m->libmpeg2, buf_es->start >> 32,
+ buf_es->start & 0xFFFFFFFF );
+ }
+ mpeg2_buffer( m->libmpeg2, buf_es->data,
+ buf_es->data + buf_es->size );
}
- mpeg2_buffer( m->libmpeg2, buf_es->data,
- buf_es->data + buf_es->size );
for( ;; )
{
@@ -397,6 +400,13 @@ int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_libmpeg2_decode( pv->libmpeg2, *buf_in, pv->list );
+ /* if we got an empty buffer signaling end-of-stream send it downstream */
+ if ( (*buf_in)->size == 0 )
+ {
+ hb_list_add( pv->list, *buf_in );
+ *buf_in = NULL;
+ }
+
*buf_out = NULL;
while( ( buf = hb_list_item( pv->list, 0 ) ) )
{
@@ -424,6 +434,7 @@ int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
void decmpeg2Close( hb_work_object_t * w )
{
hb_work_private_t * pv = w->private_data;
+ hb_log( "mpeg2 done: %d frames", pv->libmpeg2->nframes );
hb_list_close( &pv->list );
hb_libmpeg2_close( &pv->libmpeg2 );
free( pv );