[FFmpeg-user] How chrRangeToJpeg_c() works?

Andrew Randrianasulu randrianasulu at gmail.com
Mon Sep 9 23:04:16 EEST 2024


пн, 9 сент. 2024 г., 18:06 Andrew Randrianasulu <randrianasulu at gmail.com>:

> Looking at libswscale/swscale.c (due to
> https://trac.ffmpeg.org/ticket/11182#comment:5) I do not understand
> how it works :)
>
> why shits to 11 and to 12 ?
>
> // FIXME all pal and rgb srcFormats could do this conversion as well
> // FIXME all scalers more complex than bilinear could do half of this
> transform
> static void chrRangeToJpeg_c(int16_t *dstU, int16_t *dstV, int width)
> {
>     int i;
>     for (i = 0; i < width; i++) {
>         dstU[i] = (FFMIN(dstU[i], 30775) * 4663 - 9289992) >> 12; // -264
>         dstV[i] = (FFMIN(dstV[i], 30775) * 4663 - 9289992) >> 12; // -264
>     }
> }
>
> static void chrRangeFromJpeg_c(int16_t *dstU, int16_t *dstV, int width)
> {
>     int i;
>     for (i = 0; i < width; i++) {
>         dstU[i] = (dstU[i] * 1799 + 4081085) >> 11; // 1469
>         dstV[i] = (dstV[i] * 1799 + 4081085) >> 11; // 1469
>     }
> }
>
> ===
> can anyone knowledgeable  write/add some more comments in code ? please :)
>


it seems that same code (under slightly different name) was living in
swscale_template.c since at least 2009 ...


https://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff/c1977fbbd7d1e7825010e301fa236e910b760aab..bae76dc3eb6e5cd07f5881092d375ddc0270f693:/libswscale/swscale_template.c


More information about the ffmpeg-user mailing list