diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-10-03 20:03:59 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-10-03 20:03:59 +0100 |
commit | 562b7dcefad5d0acd7c906dfa97107e8be8ff536 (patch) | |
tree | 9c8d3dc5530299b5053c3dcb0361d8aab7f2cb7e /src/libffmpeg | |
parent | 7679851773f5f4586a3a74b7da722607a61625d4 (diff) | |
parent | edadcb8edb2b0cff8d7408186d581065ea4fe3a6 (diff) | |
download | xine-lib-562b7dcefad5d0acd7c906dfa97107e8be8ff536.tar.gz xine-lib-562b7dcefad5d0acd7c906dfa97107e8be8ff536.tar.bz2 |
Merge from 1.1.
Diffstat (limited to 'src/libffmpeg')
-rw-r--r-- | src/libffmpeg/ff_video_decoder.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/libffmpeg/ff_video_decoder.c b/src/libffmpeg/ff_video_decoder.c index ab8a34cb0..6cbb152a2 100644 --- a/src/libffmpeg/ff_video_decoder.c +++ b/src/libffmpeg/ff_video_decoder.c @@ -65,6 +65,7 @@ typedef struct ff_video_class_s { video_decoder_class_t decoder_class; int pp_quality; + int thread_count; xine_t *xine; } ff_video_class_t; @@ -366,6 +367,12 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HANDLED, 0); return; } + + if (this->class->thread_count > 1) { + avcodec_thread_init(this->context, this->class->thread_count); + this->context->thread_count = this->class->thread_count; + } + pthread_mutex_unlock(&ffmpeg_lock); lprintf("lavc decoder opened\n"); @@ -420,6 +427,12 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) } +static void thread_count_cb(void *user_data, xine_cfg_entry_t *entry) { + ff_video_class_t *class = (ff_video_class_t *) user_data; + + class->thread_count = entry->num_value; +} + static void pp_quality_cb(void *user_data, xine_cfg_entry_t *entry) { ff_video_class_t *class = (ff_video_class_t *) user_data; @@ -1292,14 +1305,17 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) { } if (!got_one_picture) { - /* skipped frame, output a bad frame */ + /* skipped frame, output a bad frame (of size 1x1 when size still uninitialized) */ img = this->stream->video_out->get_frame (this->stream->video_out, - this->bih.biWidth, - this->bih.biHeight, + (this->bih.biWidth <= 0) ? 1 : this->bih.biWidth, + (this->bih.biHeight <= 0) ? 1 : this->bih.biHeight, this->aspect_ratio, this->output_format, VO_BOTH_FIELDS|this->frame_flags); - img->pts = 0; + /* set PTS to allow early syncing */ + img->pts = this->pts; + this->pts = 0; + img->duration = this->video_step; img->bad_frame = 1; this->skipframes = img->draw(img, this->stream); @@ -1525,6 +1541,15 @@ void *init_video_plugin (xine_t *xine, void *data) { "too much."), 10, pp_quality_cb, this); + this->thread_count = xine->config->register_num(config, "video.processing.ffmpeg_thread_count", 1, + _("FFmpeg video decoding thread count"), + _("You can adjust the number of video decoding threads which FFmpeg may use.\n" + "Higher values should speed up decoding but it depends on the codec used " + "whether parallel decoding is supported. A rule of thumb is to have one " + "decoding thread per logical CPU (typically 1 to 4). A change will take " + "effect with playing the next stream."), + 10, thread_count_cb, this); + return this; } |