avfilter/vf_lut: gammaval709()

See http://www.itu.int/rec/R-REC-BT.709
Item 1.2, overall opto-electronic transfer characteristics at source

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit b186b7131e)
This commit is contained in:
Peter Ross 2014-11-14 09:14:24 +11:00 committed by Carl Eugen Hoyos
parent e386241d54
commit 057ee35924
1 changed files with 17 additions and 0 deletions

View File

@ -161,15 +161,32 @@ static double compute_gammaval(void *opaque, double gamma)
return pow((val-minval)/(maxval-minval), gamma) * (maxval-minval)+minval;
}
/**
* Compute Rec.709 gama correction of value val
*/
static double compute_gammaval709(void *opaque, double gamma)
{
LutContext *s = opaque;
double val = s->var_values[VAR_CLIPVAL];
double minval = s->var_values[VAR_MINVAL];
double maxval = s->var_values[VAR_MAXVAL];
double level = (val - minval) / (maxval - minval);
level = level < 0.018 ? 4.5 * level
: 1.099 * pow(level, 1.0 / gamma) - 0.099;
return level * (maxval - minval) + minval;
}
static double (* const funcs1[])(void *, double) = {
(void *)clip,
(void *)compute_gammaval,
(void *)compute_gammaval709,
NULL
};
static const char * const funcs1_names[] = {
"clip",
"gammaval",
"gammaval709",
NULL
};