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.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th July 2020, 11:14   #1  |  Link
butterw2
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);
butterw2 is offline   Reply With Quote
Old 18th July 2020, 13:21   #2  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,496
I usually approximate gamma in my filters by squaring every value before processing and then taking the square root at the end. It makes for nicer blends and blurs and so on.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 30th July 2020, 20:50   #3  |  Link
butterw2
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.
butterw2 is offline   Reply With Quote
Old 30th July 2020, 21:18   #4  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
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.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 1st August 2020, 11:58   #5  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,558
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.
foxyshadis is offline   Reply With Quote
Reply

Tags
linear gamma conversion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:40.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.