Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
18th July 2020, 11:14 | #1 | Link |
Registered User
Join Date: Jun 2020
Posts: 303
|
Convert to Linear Gamma for processing ?
I occasionnaly read people recommending re-converting to linear gamma to perform image/video processing, but I don't think I've seen it actually being done.
When does it apply ? How best to test whether the processing is correct ? My own application is realtime effects/filters in video players. Input: encoded video (mp4: x264, x265), typ: 720p, 1080p Video player (mpc-hc) Output LCD display, typ: 1080p proposed Pixel shader in mpc-hc (.hlsl): // overhead for gamma conversion: 9 arithmetic ops #define Gamma 2.2 color = pow(color, Gamma); //color is rgb float(32, 32, 32) in range [0, 1] // Do color processing return pow(color, 1./Gamma);
__________________
bShaders: realtime Effects/filters for video players |
30th July 2020, 20:50 | #3 | Link |
Registered User
Join Date: Jun 2020
Posts: 303
|
I was trying out an encoder GUI with some HDR content (with the goal of doing HDR passthrough) and the default avisynth script did the resize to 1080p without any reference to converting to linear and back. I guess it musn't have too much of an impact in this case ?
In areas where linear gamma processing is critical (3D rendering/lighting) a sRGB-888 gpu framebuffer may be used. Reads/Writes from the framebuffer are converted transparently to linear gamma/sRGB in hardware (not approximation) in order to perform fast accurate processing and to preserve accuracy with multiple passes. A higher bitdepth framebuffer would be required to keep the intermediate steps in linear before the final conversion to sRGB.
__________________
bShaders: realtime Effects/filters for video players |
30th July 2020, 21:18 | #4 | Link |
Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
The impact depends on the content. If, for some reason, you've got a sharp boundary between bright green and bright magenta then you'll get a noticeable dark line between them - but that just doesn't happen very often. But given that the encoder can't know what'll be thrown at it, it should ideally take gamma into account.
|
1st August 2020, 11:58 | #5 | Link |
Angel of Night
Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,559
|
White surrounded by dark is the poster child for how non-linear darkens everything during a resize. Starscapes, night shots, lens flare, you can see it anywhere there's a point light source. You might get used to it, or never notice, but it's always there. IM has an excellent example:
vs Prior to resizing, the image looked like the lower one, but the top is what all generic non-linear resizers will give you. Last edited by foxyshadis; 1st August 2020 at 12:00. |
Tags |
linear gamma conversion |
|
|