xpra icon
Bug tracker and wiki

Opened 18 months ago

Closed 6 months ago

Last modified 6 months ago

#1438 closed enhancement (fixed)

decode jpeg to YUV

Reported by: Antoine Martin Owned by: Antoine Martin
Priority: major Milestone: 2.3
Component: encodings Version: trunk
Keywords: jpeg Cc:

Description

Split from #1423.

For some unknown reason, the YUV data loses some precision and so we decompress to RGB.
The opengl backend could use the YUV data directly. (the code is commented out as of r15062)

Attachments (2)

yuv16.cg (3.7 KB) - added by Antoine Martin 6 months ago.
source for clamped shader
yuv.cg (3.7 KB) - added by Antoine Martin 6 months ago.
source for full range shader

Download all attachments as: .zip

Change History (8)

comment:1 Changed 9 months ago by Antoine Martin

Milestone: 3.02.3
Status: newassigned
Summary: decode jpeg to YUVdecode webp and jpeg to YUV

comment:2 Changed 9 months ago by Antoine Martin

  • r17543 + r17544 + r17545 + r17546 + r17547: minor updates, cleanups + decoding jpeg to YUV???P can be enabled with XPRA_JPEG_YUV=1
  • r17548: decoding webp (#1694) to YUV can be enabled with XPRA_WEBP_YUV=1, defaults to 0 because we always compress from RGB and libwebp only currently supports YUV420P: the loss of quality is visible, even at very low quality settings

The type of colour shade that goes MIA is seen here: ticket:1423#comment:3.
webp doesn't have this problem (only the subsampling issue), so the paint code is unlikely to be the problem.

comment:3 Changed 6 months ago by Antoine Martin

jpeg uses BT.601, but using full range values. Y, Cb and Cr all use the full range of 0-255, with 128 being "0" for Cb and Cr: Full-range Y’CbCr in JPEG: If you are ever concerned about correctness, the easiest way is to simply never think about full-range Y’Cb'Cr'

So we'll need to use a different shader for those frames, and a new flag of some sort.

Last edited 6 months ago by Antoine Martin (previous) (diff)

Changed 6 months ago by Antoine Martin

Attachment: yuv16.cg added

source for clamped shader

Changed 6 months ago by Antoine Martin

Attachment: yuv.cg added

source for full range shader

comment:4 Changed 6 months ago by Antoine Martin

Resolution: fixed
Status: assignedclosed

Finally fixed in r18330. Decoding to YUV is now the default in r18331.
Thanks to wikipedia : YCbCr, we now use those authoritative matrix values in r18332.

Had to:

That was hard because those values are divided by 219 in the shader we have, and I had to figure that out... 219 is the limited range used by this encoding: 235-16!
Also, modulo minor floating point number inaccuracies, they must have used values with more precision?

  • now we can create a new shader, and use 255 to divide instead since the values we get use the full range

To compile those shaders, find the nvidia cdc compiler somewhere, then run:

cgc -profile arbfp1 -o yuv.pso yuv.cg
cgc -profile arbfp1 -o yuv16.pso yuv16.cg

comment:5 Changed 6 months ago by Antoine Martin

Summary: decode webp and jpeg to YUVdecode jpeg to YUV

edit title: we're not dealing with webp yuv decoding, see #1764

comment:6 Changed 6 months ago by Antoine Martin

Caused a regression: #1769

Note: See TracTickets for help on using tickets.