Avidemux Forum

Avidemux => Windows => Topic started by: Cormy1 on July 13, 2020, 09:03:00 PM

Title: JPEG Imports incorrectly - Colour Discrepancy
Post by: Cormy1 on July 13, 2020, 09:03:00 PM
Warning: Links contain loud obnoxious sounds, video feed/image is semi-lewd anime garbage.

Source image: https://pbs.twimg.com/media/DnzVCAFXcAAhEv2.jpg
What Avidemux produces:
https://2eu.funnyjunk.com/comments/Okay+i+fix+there+is+no+1080p+version+of+_7a8ee1420b5abed6b149d8d4daac75fa.mp4

Even in the avidemux project I can see that the colour is wrong, like it was incorrectly imported from the beginning.
Title: Re: JPEG Imports incorrectly - Colour Discrepancy
Post by: eumagga0x2a on July 13, 2020, 10:06:28 PM
Limited vs full color (actually, luma) range (in Avidemux "Contrast" video filter jargon "MPEG" vs "PC").
Title: Re: JPEG Imports incorrectly - Colour Discrepancy
Post by: Cormy1 on July 13, 2020, 10:30:35 PM
What's the issue though?
I've heard of Limited colour palettes being "stretched" to full range in order to comply with PC, but why does it do it?
It's just a JPEG, so it's the same kind of data found in video streams, so this should be able to happen to video aswell no?
And then if you're in copy mode, you can't correct this since it's only in a filter.
The fact that it happens during the decoding step should mean that you can change the way it is decoded/imported before encoding, before using filters. You shouldn't need a filter for this.

Also the MPEG2 -> PC button makes this worse, so I guess I need the inverse of this button...? It was converted to PC during import/decode, now I need to go back in the other direction to Limited.
How can I do this?
Title: Re: JPEG Imports incorrectly - Colour Discrepancy
Post by: eumagga0x2a on July 13, 2020, 11:14:00 PM
There is a whole knot of problems arising from different handling of range / contrast / gamma by different decoders, displayed by different video drivers in a non-uniform way. If contrast was increased so that some color values got clipped, no satisfactory way back by reducing contrast is possible.

There should be ways to tell libavcodec whether to stretch the range or not when decoding JPEG. I'll try to investigate in not very near future.

QuoteIt's just a JPEG, so it's the same kind of data found in video streams, so this should be able to happen to video aswell no?

Yes, and as if it were not enough, different video output drivers behave differently on this topic.
Title: Re: JPEG Imports incorrectly - Colour Discrepancy
Post by: Cormy1 on February 09, 2021, 03:50:44 AM
Were you able to resolve this or look into it further?
Title: Re: JPEG Imports incorrectly - Colour Discrepancy
Post by: eumagga0x2a on February 09, 2021, 09:07:39 AM
I assume that topic was addressed by a number of commits in early autumn of 2020. You don't test nightlies, do you? Actually, you do. Are there still issues with color range not covered?
Title: Re: JPEG Imports incorrectly - Colour Discrepancy
Post by: Cormy1 on February 16, 2021, 04:43:29 PM
Ah, you are correct.
Thanks for the good work!