From f654b11f2176d71c3c0971d9a87b749225eb229c Mon Sep 17 00:00:00 2001 From: Jason Tackaberry Date: Fri, 2 Jan 2009 23:00:31 -0500 Subject: configurable parameter for tvtime pulldown sync sensitivity Currently, once the tvtime plugin has locked onto a telecine pattern, it will wait PULLDOWN_ERROR_WAIT (a hardcoded #defined value) number of frames before switching to filmmode. This sensitivity is excessively high (i.e. the value is too low) for certain content -- the kind of content that was shot on film but edited in video mode, so telecine patterns are constantly breaking (examples like Buffy, Simpsons and Family Guy are especially egregious offenders). The attached patch turns this constant into a modifiable post plugin parameter called pulldown_error_wait. Xine helpfully emits a XINE_EVENT_POST_TVTIME_FILMMODE_CHANGE event when film mode changes (a patch I submitted some years back). With the attached patch, a front-end can monitor the frequency of these events, and dynamically adjust pulldown_error_wait in a sensible way. --- src/post/deinterlace/tvtime.c | 14 +++----------- src/post/deinterlace/tvtime.h | 5 +++++ src/post/deinterlace/xine_plugin.c | 9 +++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/post/deinterlace/tvtime.c b/src/post/deinterlace/tvtime.c index eff43d5e8..97da6543e 100644 --- a/src/post/deinterlace/tvtime.c +++ b/src/post/deinterlace/tvtime.c @@ -37,14 +37,6 @@ #include "pulldown.h" #include "tvtime.h" -/** - * This is how many frames to wait until deciding if the pulldown phase - * has changed or if we've really found a pulldown sequence. This is - * currently set to about 1 second, that is, we won't go into film mode - * until we've seen a pulldown sequence successfully for 1 second. - */ -#define PULLDOWN_ERROR_WAIT 60 - /** * This is how many predictions have to be incorrect before we fall back to * video mode. Right now, if we mess up, we jump to video mode immediately. @@ -192,13 +184,13 @@ int tvtime_build_deinterlaced_frame( tvtime_t *tvtime, uint8_t *output, if( !tvtime->pdoffset ) { /* No pulldown offset applies, drop out of pulldown immediately. */ tvtime->pdlastbusted = 0; - tvtime->pderror = PULLDOWN_ERROR_WAIT; + tvtime->pderror = tvtime->pulldown_error_wait; } else if( tvtime->pdoffset != predicted ) { if( tvtime->pdlastbusted ) { tvtime->pdlastbusted--; tvtime->pdoffset = predicted; } else { - tvtime->pderror = PULLDOWN_ERROR_WAIT; + tvtime->pderror = tvtime->pulldown_error_wait; } } else { if( tvtime->pderror ) { @@ -437,7 +429,7 @@ void tvtime_reset_context( tvtime_t *tvtime ) tvtime->last_botdiff = 0; tvtime->pdoffset = PULLDOWN_SEQ_AA; - tvtime->pderror = PULLDOWN_ERROR_WAIT; + tvtime->pderror = tvtime->pulldown_error_wait; tvtime->pdlastbusted = 0; tvtime->filmmode = 0; } diff --git a/src/post/deinterlace/tvtime.h b/src/post/deinterlace/tvtime.h index 8e4c5abc2..2253f264e 100644 --- a/src/post/deinterlace/tvtime.h +++ b/src/post/deinterlace/tvtime.h @@ -56,6 +56,11 @@ typedef struct { */ deinterlace_method_t *curmethod; + /** + * This is how many frames to wait until deciding if the pulldown phase + * has changed or if we've really found a pulldown sequence. + */ + unsigned int pulldown_error_wait; /* internal data */ int last_topdiff; diff --git a/src/post/deinterlace/xine_plugin.c b/src/post/deinterlace/xine_plugin.c index 8115198af..dfc07e434 100644 --- a/src/post/deinterlace/xine_plugin.c +++ b/src/post/deinterlace/xine_plugin.c @@ -69,6 +69,7 @@ typedef struct deinterlace_parameters_s { int method; int enabled; int pulldown; + int pulldown_error_wait; int framerate_mode; int judder_correction; int use_progressive_frame_flag; @@ -87,6 +88,8 @@ PARAM_ITEM( POST_PARAM_TYPE_BOOL, enabled, NULL, 0, 1, 0, "enable/disable" ) PARAM_ITEM( POST_PARAM_TYPE_INT, pulldown, enum_pulldown, 0, 0, 0, "pulldown algorithm" ) +PARAM_ITEM( POST_PARAM_TYPE_INT, pulldown_error_wait, NULL, 0, 0, 0, + "number of frames of telecine pattern sync required before mode change" ) PARAM_ITEM( POST_PARAM_TYPE_INT, framerate_mode, enum_framerate, 0, 0, 0, "framerate output mode" ) PARAM_ITEM( POST_PARAM_TYPE_BOOL, judder_correction, NULL, 0, 1, 0, @@ -165,6 +168,7 @@ static int set_parameters (xine_post_t *this_gen, void *param_gen) { this->enabled = param->enabled; this->pulldown = param->pulldown; + this->tvtime->pulldown_error_wait = param->pulldown_error_wait; this->framerate_mode = param->framerate_mode; this->judder_correction = param->judder_correction; this->use_progressive_frame_flag = param->use_progressive_frame_flag; @@ -185,6 +189,7 @@ static int get_parameters (xine_post_t *this_gen, void *param_gen) { param->method = this->cur_method; param->enabled = this->enabled; param->pulldown = this->pulldown; + param->pulldown_error_wait = this->tvtime->pulldown_error_wait; param->framerate_mode = this->framerate_mode; param->judder_correction = this->judder_correction; param->use_progressive_frame_flag = this->use_progressive_frame_flag; @@ -212,6 +217,9 @@ static char * get_static_help (void) { "\n" " Enabled: Enable/disable the plugin.\n" "\n" + " Pulldown_error_wait: Ensures that the telecine pattern has been " + "locked for this many frames before changing to filmmode.\n" + "\n" " Pulldown: Choose the 2-3 pulldown detection algorithm. 24 FPS films " "that have being converted to NTSC can be detected and intelligently " "reconstructed to their original (non-interlaced) frames.\n" @@ -350,6 +358,7 @@ static void *deinterlace_init_plugin(xine_t *xine, void *data) class->init_param.method = 1; /* First (plugin) method available */ class->init_param.enabled = 1; class->init_param.pulldown = 1; /* vektor */ + class->init_param.pulldown_error_wait = 60; /* about one second */ class->init_param.framerate_mode = 0; /* full */ class->init_param.judder_correction = 1; class->init_param.use_progressive_frame_flag = 1; -- cgit v1.2.3