From 7a47aa6da23391fa2f4f0bc46eb4f814e4590661 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Wed, 27 Jul 2011 15:09:49 +0000 Subject: 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 --- libhb/internal.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'libhb/internal.h') diff --git a/libhb/internal.h b/libhb/internal.h index b78072ad8..724ab7c2e 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -174,7 +174,7 @@ hb_thread_t * hb_scan_init( hb_handle_t *, volatile int * die, int store_previews, uint64_t min_duration ); hb_thread_t * hb_work_init( hb_list_t * jobs, volatile int * die, int * error, hb_job_t ** job ); -hb_thread_t * hb_reader_init( hb_job_t * ); +void ReadLoop( void * _w ); hb_work_object_t * hb_muxer_init( hb_job_t * ); hb_work_object_t * hb_get_work( int ); hb_work_object_t * hb_codec_decoder( int ); @@ -255,9 +255,9 @@ void hb_bd_set_angle( hb_bd_t * d, int angle ); int hb_bd_main_feature( hb_bd_t * d, hb_list_t * list_title ); hb_stream_t * hb_bd_stream_open( hb_title_t *title ); -hb_stream_t * hb_stream_open( char * path, hb_title_t *title ); +hb_stream_t * hb_stream_open( char * path, hb_title_t *title, int scan ); void hb_stream_close( hb_stream_t ** ); -hb_title_t * hb_stream_title_scan( hb_stream_t *); +hb_title_t * hb_stream_title_scan( hb_stream_t *, hb_title_t *); hb_buffer_t * hb_stream_read( hb_stream_t * ); int hb_stream_seek( hb_stream_t *, float ); int hb_stream_seek_ts( hb_stream_t * stream, int64_t ts ); @@ -267,9 +267,6 @@ int hb_stream_chapter( hb_stream_t * ); hb_buffer_t * hb_ts_decode_pkt( hb_stream_t *stream, const uint8_t * pkt ); -void * hb_ffmpeg_context( int codec_param ); -void * hb_ffmpeg_avstream( int codec_param ); - #define STR4_TO_UINT32(p) \ ((((const uint8_t*)(p))[0] << 24) | \ (((const uint8_t*)(p))[1] << 16) | \ @@ -353,8 +350,6 @@ enum WORK_DECDCA, WORK_DECAVCODEC, WORK_DECAVCODECV, - WORK_DECAVCODECVI, - WORK_DECAVCODECAI, WORK_DECLPCM, WORK_ENCFAAC, WORK_ENCLAME, @@ -362,7 +357,8 @@ enum WORK_ENC_CA_AAC, WORK_ENC_CA_HAAC, WORK_ENCAVCODEC_AUDIO, - WORK_MUX + WORK_MUX, + WORK_READER }; enum -- cgit v1.2.3