From: Jason T. <ta...@ur...> - 2009-01-04 18:06:45
|
# HG changeset patch # User Jason Tackaberry <ta...@ur...> # Date 1230955231 18000 # Node ID 7e6648318dc89de95dcc97ac0993ac7d08e03c4c # Parent 19e93775fbe510f08719efc291c1ef8c1c519d45 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. diff -r 7e6648318dc89de95dcc97ac0993ac7d08e03c4c -r 19e93775fbe510f08719efc291c1ef8c1c519d45 src/post/deinterlace/tvtime.c --- a/src/post/deinterlace/tvtime.c Fri Jan 02 23:00:31 2009 -0500 +++ b/src/post/deinterlace/tvtime.c Wed Nov 19 16:13:49 2008 +0100 @@ -36,14 +36,6 @@ #include "deinterlace.h" #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 @@ -192,13 +184,13 @@ int tvtime_build_deinterlaced_frame( tvt 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 *tvt 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 -r 7e6648318dc89de95dcc97ac0993ac7d08e03c4c -r 19e93775fbe510f08719efc291c1ef8c1c519d45 src/post/deinterlace/tvtime.h --- a/src/post/deinterlace/tvtime.h Fri Jan 02 23:00:31 2009 -0500 +++ b/src/post/deinterlace/tvtime.h Wed Nov 19 16:13:49 2008 +0100 @@ -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 -r 7e6648318dc89de95dcc97ac0993ac7d08e03c4c -r 19e93775fbe510f08719efc291c1ef8c1c519d45 src/post/deinterlace/xine_plugin.c --- a/src/post/deinterlace/xine_plugin.c Fri Jan 02 23:00:31 2009 -0500 +++ b/src/post/deinterlace/xine_plugin.c Wed Nov 19 16:13:49 2008 +0100 @@ -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, enable "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->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 * 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; @@ -211,6 +216,9 @@ static char * get_static_help (void) { "explanation of each method.\n" "\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 " @@ -350,6 +358,7 @@ static void *deinterlace_init_plugin(xin 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; |