diff options
author | van <[email protected]> | 2008-04-13 23:31:37 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-04-13 23:31:37 +0000 |
commit | d3aeb74cdf94f70b643da897dfb666d81a743817 (patch) | |
tree | 56f6c5ba9b69726d925e7c13f0e2e0245a134c3f /libhb/work.c | |
parent | 280d49d8ae91af433b4df17b2e42b267dbdbc083 (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/work.c')
-rw-r--r-- | libhb/work.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libhb/work.c b/libhb/work.c index a3507027e..d2290ebf0 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -103,6 +103,7 @@ static void do_job( hb_job_t * job, int cpu_count ) /* FIXME: This feels really hackish, anything better? */ hb_work_object_t * audio_w = NULL; hb_work_object_t * sub_w = NULL; + hb_work_object_t * encoder_w = NULL; hb_audio_t * audio; hb_subtitle_t * subtitle; @@ -274,6 +275,8 @@ static void do_job( hb_job_t * job, int cpu_count ) w->config = &job->config; hb_list_add( job->list_work, w ); + /* remember the encoder so we can wait for it to finish */ + encoder_w = w; if( job->select_subtitle && !job->indepth_scan ) { @@ -504,9 +507,9 @@ static void do_job( hb_job_t * job, int cpu_count ) audio->priv.config.vorbis.language = audio->config.lang.simple; /* set up the audio work structures */ - audio->priv.fifo_in = hb_fifo_init( 2048 ); + audio->priv.fifo_in = hb_fifo_init( 256 ); audio->priv.fifo_raw = hb_fifo_init( FIFO_CPU_MULT * cpu_count ); - audio->priv.fifo_sync = hb_fifo_init( FIFO_CPU_MULT * cpu_count ); + audio->priv.fifo_sync = hb_fifo_init( 256 ); audio->priv.fifo_out = hb_fifo_init( FIFO_CPU_MULT * cpu_count ); @@ -618,8 +621,7 @@ static void do_job( hb_job_t * job, int cpu_count ) done = 1; } if( done && - !hb_fifo_size( job->fifo_sync ) && - !hb_fifo_size( job->fifo_render ) && + encoder_w->status == HB_WORK_DONE && !hb_fifo_size( job->fifo_mpeg4 ) ) { break; @@ -831,7 +833,7 @@ static void work_loop( void * _w ) } // w->thread_sleep_interval = MAX(1, (w->thread_sleep_interval - 1)); - w->work( w, &buf_in, &buf_out ); + w->status = w->work( w, &buf_in, &buf_out ); // Propagate any chapter breaks for the worker if and only if the // output frame has the same time stamp as the input frame (any |