[FFmpeg-user] Trying to get lossless PNG -> VP9 (yuv) -> PNG
Kirk Liberty
kirk.liberty at gmail.com
Wed Aug 1 22:24:11 EEST 2018
On Wed, Aug 1, 2018 at 2:00 PM, Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> 2018-08-01 6:12 GMT+02:00, Kirk Liberty <kirk.liberty at gmail.com>:
>> On Tue, Jul 31, 2018 at 7:04 PM, Carl Eugen Hoyos <ceffmpeg at gmail.com>
>> wrote:
>>>
>>> 2018-07-29 0:16 GMT+02:00, Kirk Liberty <kirk.liberty at gmail.com>:
>>> > My plan is to use the YCgCo
>>> > colorspace to get lossless conversion of rgb->yuv->rgb
>>>
>>> This conversion (may be lossless in theory but) is not lossless
>>> with FFmpeg, both x264 and libvpx-vp9 support encoding rgb
>>> which can be lossless.
>>
>> Why is YCgCo not lossless in FFmpeg?
>
> It is / can be.
> What is not lossless is the conversion from PIX_FMT_GBR* (or RGB*)
> to PIX_FMT_YUV*
Are you referring to rgba2ycocg() in texturedspenc.c?
574 * Convert a RGBA buffer to unscaled YCoCg.
575 * Scale is usually introduced to avoid banding over a certain
range of colors,
576 * but this version of the algorithm does not introduce it as much as other
577 * implementations, allowing for a simpler and faster conversion.
578 */
579 static void rgba2ycocg(uint8_t *dst, const uint8_t *pixel)
580 {
581 int r = pixel[0];
582 int g = (pixel[1] + 1) >> 1;
583 int b = pixel[2];
584 int t = (2 + r + b) >> 2;
585
586 dst[0] = av_clip_uint8(128 + ((r - b + 1) >> 1)); /* Co */
587 dst[1] = av_clip_uint8(128 + g - t); /* Cg */
588 dst[2] = 0;
589 dst[3] = av_clip_uint8(g + t); /* Y */
590 }
Kirk
More information about the ffmpeg-user
mailing list