diff options
author | Andreas Auras <yak54@gmx.net> | 2011-02-01 20:55:25 +0100 |
---|---|---|
committer | Andreas Auras <yak54@gmx.net> | 2011-02-01 20:55:25 +0100 |
commit | b9aadb8feda0e0dc2b1ba7341208553e286c4e5e (patch) | |
tree | f7dc65288b6945a902125c6f0ee8bd9a5f5eba03 | |
parent | c0f50b50200f8c65a5bb0626218739e73fb73360 (diff) | |
download | xine-lib-atmolight-0.7.tar.gz xine-lib-atmolight-0.7.tar.bz2 |
Added uniform average brightness calculation mode which is configurable with new plugin parameter 'uniform_brightness'.v0.7
-rw-r--r-- | HISTORY | 3 | ||||
-rw-r--r-- | README | 32 | ||||
-rw-r--r-- | xine_post_atmo.c | 42 |
3 files changed, 63 insertions, 14 deletions
@@ -1,5 +1,6 @@ --- Version 0.7 -Added output delay filter which is configurable with new plugin parameter 'filter_delay' +Added output delay filter which is configurable with new plugin parameter 'filter_delay'. +Added uniform average brightness calculation mode which is configurable with new plugin parameter 'uniform_brightness'. --- Version 0.6 Add xine-ui-atmolight-switch patch. @@ -122,21 +122,21 @@ center top_left top_right bottom_left -bottom_right 0 Number of RGB channel groups per area. - For top, bottom, left and right area more then one group could be +bottom_right 0 Number of sections (RGB channel groups) in area. + For top, bottom, left and right area more then one section could be specified. Valid values: 0 ... 25 for top, bottom, left, right Valid values: 0 ... 1 for center, top_left, top_right, bottom_left, bottom_right NOTE!!!: Starting from plugin version 0.3 for "classic" controllers you must define one - group for area top, bottom, left, right and center as plugin parameter!!! + section for area top, bottom, left, right and center as plugin parameter!!! For DF10CH controller you do not have to specify these parameters here because they are read from the controller configuration data. Use the DF10CH setup program to configure your desired layout. -analyze_rate * 40 Rate of frame grabbing and video analysis. Unit milliseconds. +analyze_rate * 35 Rate of frame grabbing and video analysis. Unit milliseconds. Valid values: 10 ... 500 analyze_size * 1 Size of analyze window. The window width is calculated by (analyze_size+1)*64 pixel. @@ -176,6 +176,21 @@ sat_win_size * 3 Windowing size for saturation. Valid values hue_treshold * 93 Threshold limit for change of color. Unit percentage of 100. Valid values 1 ... 100 +brightness * 100 Controls brightness of generated color values. + Unit percentage of 100. Valid values 50 ... 300 + + Note: When using DF10CH controller(s) it is better to use the white calibration or + common brightness feature of the DF10CH setup program instead of this + parameter because you will lose lesser or no PWM resolution. + +uniform_brightness * 0 Enable/Disable uniform brightness calculation. + Valid values: 0 (disable), 1 (enable) + When enabled only one uniform average brightness value is calculated + for all sections. This is the behavior of the "classic" + VDR Atmolight plugin. + When disabled a average brightness value is calculated for each + section. This mode is more suitable when many sections for a area exists. + filter * combined Select smoothness filter. Currently there are two filters supported: percentage and combined. Valid values: off, percentage, combined @@ -193,13 +208,6 @@ filter_delay * 0 Controls delay of output send to controller. Unit milliseconds. Valid values 0 ... 1000 Note: Delay should be specified as multiples of 20ms -brightness * 100 Controls brightness of generated color values. - Unit percentage of 100. Valid values 50 ... 300 - - Note: When using DF10CH controller(s) it is better to use the white calibration or - common brightness feature of the DF10CH setup program instead of this - parameter because you will lose lesser or no PWM resolution. - wc_red wc_green wc_blue * 255 White calibration values for red, green and blue channel. @@ -221,6 +229,8 @@ start_delay * 250 Delay after stream start before first output Valid values 0 ... 5000. enabled * 1 Enable/Disable output of color values to atmolight controller. + Valid values: 0 (disable), 1 (enable) + For some parameters (e.g. filter parameters) you will find a more detailed description here: diff --git a/xine_post_atmo.c b/xine_post_atmo.c index c24549d..12de7db 100644 --- a/xine_post_atmo.c +++ b/xine_post_atmo.c @@ -90,6 +90,7 @@ typedef struct { int hue_win_size; int sat_win_size; int hue_threshold; + int uniform_brightness; int brightness; int filter; int filter_smoothness; @@ -154,6 +155,8 @@ PARAM_ITEM(POST_PARAM_TYPE_INT, hue_threshold, NULL, 0, 100, 0, "hue threshold [%]") PARAM_ITEM(POST_PARAM_TYPE_INT, brightness, NULL, 50, 300, 0, "brightness [%]") +PARAM_ITEM(POST_PARAM_TYPE_BOOL, uniform_brightness, NULL, 0, 1, 0, + "calculate uniform brightness") PARAM_ITEM(POST_PARAM_TYPE_INT, filter, filter_enum, 0, NUM_FILTERS, 0, "filter mode") PARAM_ITEM(POST_PARAM_TYPE_INT, filter_smoothness, NULL, 1, 100, 0, @@ -275,7 +278,7 @@ static int parse_post_api_parameter_string(xine_post_api_descr_t *descr, void *v while (p->type != POST_PARAM_TYPE_LAST) { if (!p->readonly) { char *arg = strstr(param, p->name); - if (arg && arg[strlen(p->name)] == '=') { + if (arg && arg[strlen(p->name)] == '=' && (arg == param || arg[-1] == ',' || isspace(arg[-1]))) { arg += strlen(p->name) + 1; char *v = (char *)values + p->offset; int iv; @@ -659,6 +662,36 @@ static void calc_average_brightness(atmo_post_plugin_t *this, hsv_color_t *hsv, } +static void calc_uniform_average_brightness(atmo_post_plugin_t *this, hsv_color_t *hsv, int img_size) { + const int darkness_limit = this->active_parm.darkness_limit; + uint64_t avg = 0; + int cnt = 0; + + while (img_size--) { + const int v = hsv->v; + if (v >= darkness_limit) { + avg += v; + ++cnt; + } + ++hsv; + } + + if (cnt) + avg /= cnt; + else + avg = darkness_limit; + + avg = (avg * this->active_parm.brightness) / 100; + if (avg > v_MAX) + avg = v_MAX; + + uint64_t * const avg_bright = this->avg_bright; + int c = this->sum_channels; + while (c) + avg_bright[--c] = avg; +} + + static void hsv_to_rgb(rgb_color_t *rgb, double h, double s, double v) { rgb->r = rgb->g = rgb->b = 0; @@ -833,7 +866,10 @@ static void *atmo_grab_loop (void *this_gen) { calc_sat_hist(this, hsv_img, weight, img_size); calc_windowed_sat_hist(this); calc_most_used_sat(this); - calc_average_brightness(this, hsv_img, weight, img_size); + if (this->active_parm.uniform_brightness) + calc_uniform_average_brightness(this, hsv_img, img_size); + else + calc_average_brightness(this, hsv_img, weight, img_size); pthread_mutex_lock(&this->lock); calc_rgb_values(this); pthread_mutex_unlock(&this->lock); @@ -1404,6 +1440,7 @@ static int atmo_set_parameters(xine_post_t *this_gen, void *parm_gen) else { this->active_parm.analyze_rate = this->parm.analyze_rate; this->active_parm.brightness = this->parm.brightness; + this->active_parm.uniform_brightness = this->parm.uniform_brightness; this->active_parm.darkness_limit = this->parm.darkness_limit; this->active_parm.filter = this->parm.filter; this->active_parm.filter_length = this->parm.filter_length; @@ -1523,6 +1560,7 @@ static post_plugin_t *atmo_open_plugin(post_class_t *class_gen, this->parm.analyze_rate = 35; this->parm.analyze_size = 1; this->parm.brightness = 100; + this->parm.uniform_brightness = 0; this->parm.darkness_limit = 1; this->parm.edge_weighting = 60; this->parm.filter = 2; |