[FFmpeg-devel] [GSoC] Patch which adds support for gamma correct scaling
Nicolas George
george at nsup.org
Tue Apr 21 17:16:07 CEST 2015
Le duodi 2 floréal, an CCXXIII, Pedro Arthur a écrit :
> Subject: [FFmpeg-devel] [GSoC] Patch which adds support for gamma correct
"sws: add support for gamma-correct scaling"
> + { "true", "enable", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "gamma" },
> + { "false", "disable", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "gamma" },
This is not usually done.
> + float gamma_value;
> +static uint16_t * alloc_gamma_tbl(float e)
> + tbl[i] = (int) (pow( ((float)i)/65535.f, e) * 65535.f);
Do you have reasons to use float specifically? AFAIK, except when memory
consumption is relevant (i.e. large arrays), double should be preferred.
This is especially true in your last formula: you force i to float, you
force 65535 to float, but you use pow() rather than powf().
The cast to int seems dubious too, since your array is uint16_t.
IMHO, just use a double argument and write:
tbl[i] = pow(i / 65535.0, e) * 65535.0);
More readable, less confusing for the compiler.
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150421/3fadfb52/attachment.asc>
More information about the ffmpeg-devel
mailing list