summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-07-27 15:09:49 +0000
committerjstebbins <[email protected]>2011-07-27 15:09:49 +0000
commit7a47aa6da23391fa2f4f0bc46eb4f814e4590661 (patch)
treec464eed037523e1fee104e78b68c4a75e71e478d /libhb/work.c
parente71ac4bb36c9cec69ed4cb45a48e179d662fa828 (diff)
libhb: fix or simplify several hacks involved with Libav support
For files that are demuxed by Libav, we must share the format context with the decoder iso that it can obtain the codec context for each stream. The code that did this was very convoluted and difficult to understand. It is simplified by simply passing the context in hb_title_t. Reader was closing stream files before the decoder was finished with the context. This created the need to delay the actual close and cache the context. Changed reader so it behaves more like the rest of handbrake's work objects which lets us explicitly close after the decoders are finished. Libav does some probing of the file when av_find_stream_info is called. This probing leaves the format context in a bad state for some files and causes subsequent reads or seeks to misbehave. So open 2 contexts in ffmpeg_open. One is used only for probing, and the other only for reading. decavcodec.c had 2 separate decoders for files demuxed by hb and files demuxed by Libav. They have been combined and simplified. Previously, it was not possible to decode one source audio track multiple times in order to fan it out to multiple output tracks if the file is demuxed by Libav. We were using the codec context from the format context. Since there is only one of these for each stream, we could only do one decode for each stream. Use avcodec_copy_context to make copies of the codec context and allow multiple decodes. This allows removal of a lot of special case code for Libav streams that was necessary to duplicate the output of the decoder. Patch Libav's mkv demux to fix a seek problem. This has been pushed upstreams, so the next time we update Libav, we must remove this patch. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4141 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c59
1 files changed, 17 insertions, 42 deletions
diff --git a/libhb/work.c b/libhb/work.c
index 90209dbd2..ffd48ec4b 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -116,10 +116,7 @@ hb_work_object_t * hb_codec_decoder( int codec )
default:
if ( codec & HB_ACODEC_FF_MASK )
{
- if ( codec & HB_ACODEC_FF_I_FLAG )
- return hb_get_work( WORK_DECAVCODECAI );
- else
- return hb_get_work( WORK_DECAVCODEC );
+ return hb_get_work( WORK_DECAVCODEC );
}
break;
}
@@ -414,27 +411,6 @@ void correct_framerate( hb_job_t * job )
interjob->vrate_base = job->vrate_base;
}
-static int check_ff_audio( hb_list_t *list_audio, hb_audio_t *ff_audio )
-{
- int i;
-
- for( i = 0; i < hb_list_count( list_audio ); i++ )
- {
- hb_audio_t * audio = hb_list_item( list_audio, i );
-
- if ( audio == ff_audio )
- break;
-
- if ( ( audio->config.in.codec & HB_ACODEC_FF_MASK ) &&
- audio->id == ff_audio->id )
- {
- hb_list_add( audio->priv.ff_audio_list, ff_audio );
- return 1;
- }
- }
- return 0;
-}
-
/**
* Job initialization rountine.
* Initializes fifos.
@@ -719,19 +695,7 @@ static void do_job( hb_job_t * job )
audio->priv.fifo_raw = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );
audio->priv.fifo_sync = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );
audio->priv.fifo_out = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE );
-
- audio->priv.ff_audio_list = hb_list_init();
- if ( audio->config.in.codec & HB_ACODEC_FF_MASK )
- {
- if ( !check_ff_audio( title->list_audio, audio ) )
- {
- audio->priv.fifo_in = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE );
- }
- }
- else
- {
- audio->priv.fifo_in = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE );
- }
+ audio->priv.fifo_in = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE );
}
}
@@ -980,8 +944,15 @@ static void do_job( hb_job_t * job )
hb_display_job_info( job );
/* Init read & write threads */
- job->reader = hb_reader_init( job );
-
+ hb_work_object_t *reader = hb_get_work(WORK_READER);
+ if ( reader->init( reader, job ) )
+ {
+ hb_error( "Failure to initialise thread '%s'", reader->name );
+ *job->die = 1;
+ goto cleanup;
+ }
+ reader->done = &job->done;
+ reader->thread = hb_thread_init( reader->name, ReadLoop, reader, HB_NORMAL_PRIORITY );
job->done = 0;
@@ -1111,8 +1082,12 @@ cleanup:
hb_list_close( &job->list_work );
/* Stop the read thread */
- if( job->reader != NULL )
- hb_thread_close( &job->reader );
+ if( reader->thread != NULL )
+ {
+ hb_thread_close( &reader->thread );
+ reader->close( reader );
+ }
+ free( reader );
/* Close fifos */
hb_fifo_close( &job->fifo_mpeg2 );