diff options
author | Reinhard Nißl <rnissl@gmx.de> | 2007-12-31 00:01:32 +0100 |
---|---|---|
committer | Reinhard Nißl <rnissl@gmx.de> | 2007-12-31 00:01:32 +0100 |
commit | e23ea1143257ede4cdbbe8ab89222978d43b0344 (patch) | |
tree | 18c42fe66e93fe09264ec9e905dc1cec7d425d1c | |
parent | aa3d3aacdb991ad989933d71734e300535c7d350 (diff) | |
download | xine-lib-e23ea1143257ede4cdbbe8ab89222978d43b0344.tar.gz xine-lib-e23ea1143257ede4cdbbe8ab89222978d43b0344.tar.bz2 |
Provide FFmpeg options skip_loop_filter and choose_speed_over_accuracy.
Both options tweak FFmpeg for the sake of decoding speed. The first one
skips the loop filter for certain frames while the latter allows FFmpeg
to violate the codec's specification. Both options may lead to artefacts.
-rw-r--r-- | src/libffmpeg/ff_video_decoder.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/libffmpeg/ff_video_decoder.c b/src/libffmpeg/ff_video_decoder.c index cceb96bf0..784571779 100644 --- a/src/libffmpeg/ff_video_decoder.c +++ b/src/libffmpeg/ff_video_decoder.c @@ -65,6 +65,8 @@ typedef struct ff_video_class_s { int pp_quality; int thread_count; + int8_t skip_loop_filter_enum; + int8_t choose_speed_over_accuracy; xine_t *xine; } ff_video_class_t; @@ -316,6 +318,24 @@ static const ff_codec_t ff_video_lookup[] = { {BUF_VIDEO_THEORA_RAW, CODEC_ID_THEORA, "Theora (ffmpeg)"}, }; +static const char *const skip_loop_filter_enum_names[] = { + "default", /* AVDISCARD_DEFAULT */ + "none", /* AVDISCARD_NONE */ + "nonref", /* AVDISCARD_NONREF */ + "bidir", /* AVDISCARD_BIDIR */ + "nonkey", /* AVDISCARD_NONKEY */ + "all", /* AVDISCARD_ALL */ + NULL +}; + +static const int skip_loop_filter_enum_values[] = { + AVDISCARD_DEFAULT, + AVDISCARD_NONE, + AVDISCARD_NONREF, + AVDISCARD_BIDIR, + AVDISCARD_NONKEY, + AVDISCARD_ALL +}; static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) { size_t i; @@ -360,6 +380,9 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) this->context->flags |= CODEC_FLAG_EMU_EDGE; } + if (this->class->choose_speed_over_accuracy) + this->context->flags2 |= CODEC_FLAG2_FAST; + pthread_mutex_lock(&ffmpeg_lock); if (avcodec_open (this->context, this->codec) < 0) { pthread_mutex_unlock(&ffmpeg_lock); @@ -376,6 +399,8 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) this->context->thread_count = this->class->thread_count; } + this->context->skip_loop_filter = skip_loop_filter_enum_values[this->class->skip_loop_filter_enum]; + pthread_mutex_unlock(&ffmpeg_lock); lprintf("lavc decoder opened\n"); @@ -433,6 +458,18 @@ static void init_video_codec (ff_video_decoder_t *this, unsigned int codec_type) } +static void choose_speed_over_accuracy_cb(void *user_data, xine_cfg_entry_t *entry) { + ff_video_class_t *class = (ff_video_class_t *) user_data; + + class->choose_speed_over_accuracy = entry->num_value; +} + +static void skip_loop_filter_enum_cb(void *user_data, xine_cfg_entry_t *entry) { + ff_video_class_t *class = (ff_video_class_t *) user_data; + + class->skip_loop_filter_enum = entry->num_value; +} + static void thread_count_cb(void *user_data, xine_cfg_entry_t *entry) { ff_video_class_t *class = (ff_video_class_t *) user_data; @@ -1572,10 +1609,28 @@ void *init_video_plugin (xine_t *xine, void *data) { _("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."), + "decoding thread per logical CPU (typically 1 to 4).\n" + "A change of this setting will take effect with playing the next stream."), 10, thread_count_cb, this); + this->skip_loop_filter_enum = xine->config->register_enum(config, "video.processing.ffmpeg_skip_loop_filter", 0, + (char **)skip_loop_filter_enum_names, + _("Skip loop filter"), + _("You can control for which frames the loop filter shall be skipped after " + "decoding.\n" + "Skipping the loop filter will speedup decoding but may lead to artefacts. " + "The number of frames for which it is skipped increases from 'none' to 'all'. " + "The default value leaves the decision up to the implementation.\n" + "A change of this setting will take effect with playing the next stream."), + 10, skip_loop_filter_enum_cb, this); + + this->choose_speed_over_accuracy = xine->config->register_bool(config, "video.processing.ffmpeg_choose_speed_over_accuracy", 0, + _("Choose speed over specification compliance"), + _("You may want to allow speed cheats which violate codec specification.\n" + "Cheating may speed up decoding but can also lead to decoding artefacts.\n" + "A change of this setting will take effect with playing the next stream."), + 10, choose_speed_over_accuracy_cb, this); + return this; } |