[FFmpeg-cvslog] libavfilter/vf_colorspace.c: fix demarcation point of gamma linearize function
Yonglin Luo
git at videolan.org
Wed Jul 3 21:14:08 EEST 2019
ffmpeg | branch: master | Yonglin Luo <vincenluo at tencent.com> | Wed Jul 3 10:05:36 2019 +0800| [664a27ea40be078fe452d0cded513af2078d4a52] | committer: Vittorio Giovara
libavfilter/vf_colorspace.c: fix demarcation point of gamma linearize function
The linearize function (usually refered to EOTF) is the inverse of
delinearize function (usually referred to OETF). Demarcation point of
EOTF should be beta*delta, but the actual value used now in the source
code is beta.
For ITU Rec.709, they are 0.081 (0.018*4.5) and 0.018 respectively
(beta = 0.018 and delta = 4.5), and they correspond to pixel value 5
and 21 for an 8-bit image. Linearized result of pixel within that range
(5-21) will be different, but this commit will make linearize function
of the filter more accurate in the mathematical sense.
Signed-off-by: Yonglin Luo <vincenluo at tencent.com>
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=664a27ea40be078fe452d0cded513af2078d4a52
---
libavfilter/vf_colorspace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 2120199bee..df6efffb3d 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -260,9 +260,9 @@ static int fill_gamma_table(ColorSpaceContext *s)
s->delin_lut[n] = av_clip_int16(lrint(d * 28672.0));
// linearize
- if (v <= -in_beta) {
+ if (v <= -in_beta * in_delta) {
l = -pow((1.0 - in_alpha - v) * in_ialpha, in_igamma);
- } else if (v < in_beta) {
+ } else if (v < in_beta * in_delta) {
l = v * in_idelta;
} else {
l = pow((v + in_alpha - 1.0) * in_ialpha, in_igamma);
More information about the ffmpeg-cvslog
mailing list