<div dir="ltr"><div>I was using artificial test source from ffmpeg, yuvtestsrc.</div><div><br></div><div>It sounds very simple</div><div><br></div><div> ffmpeg -f lavfi -color_range 2 -i yuvtestsrc -color_range 2 -frames 2 /dev/shm/yuv-pc-yuv444.y4m</div><div><br></div><div>but here lies dragons, at least when roundtrip to RGB is needed.</div><div><br></div><div>This old BBC article explained to me for the first time that YUV as color space fundamentally bigger than RGB!<br></div><div><br></div><div><a href="https://web.archive.org/web/20200719051405/http://downloads.bbc.co.uk/rd/pubs/reports/1987-22.pdf">https://web.archive.org/web/20200719051405/http://downloads.bbc.co.uk/rd/pubs/reports/1987-22.pdf</a></div><div><br></div><div>By way stuff defined normal calculations can give you negative RGB values!</div><div><br></div><div>An normally those are clipped to either min or max allowed channel value.</div><div><br></div><div>But result is ...unintuitive, at least for me</div><div><br></div><div>Here is online calculator:</div><div><br></div><div> <a href="https://kdashg.github.io/misc/colors/from-coeffs.html">https://kdashg.github.io/misc/colors/from-coeffs.html</a></div><div><br></div><div>if you enter RGB 601, narrow range</div><div>Y=16, Cb=100 Cr=100</div><div>R=-44.68875 (minus 44!)</div><div>G=33.73244</div><div>B=-56.4825 (minus 56!)</div><div><br></div><div>so, if both negative channels will be clipped to 0 we will have visually purely green pixel ?!</div><div><br></div><div>This probably explains some STRANGE results I was seeing in compositor and vectoroscope, because even if timeline set to YUV- for display values converted to RGB, and scope also works in RGB ?<br></div><div><br></div><div>There was another patent paper from broadcom aimed at fixing this issue</div><div><br></div><div><a href="https://patents.google.com/patent/EP1560417A2/en">https://patents.google.com/patent/EP1560417A2/en</a></div><div>"System and method for clipping values of pixels in one color
space so not to exceed the limits of a second color space
<div class="gmail-horizontal gmail-layout gmail-style-scope gmail-patent-result">
<div class="gmail-flex-3 gmail-style-scope gmail-patent-result" style="overflow:hidden">
<h3 class="gmail-layout gmail-horizontal gmail-style-scope gmail-patent-result">
<div class="gmail-flex gmail-style-scope gmail-patent-result">Abstract</div>
</h3>
<span name="abstract" class="gmail-style-scope gmail-patent-result" style="padding-top:0px">
<div class="gmail-layout gmail-horizontal gmail-style-scope gmail-patent-text">
<span class="gmail-style-scope gmail-patent-text" lang="EN">
<div class="gmail-abstract gmail-style-scope gmail-patent-text">A system and method that detects when pixels from one color space would exceed the
range of a second color space, and restrict the range of the pixels without distorting their
brightness, while preserving their color. The method may provide the ability to restrict the
range of pixels in the first color space that may ordinarily transform to "illegal" values with
erroneous brightness in the second color space, to a sub-space containing the entire second
color space, while preserving the brightness of the pixels. The parameters used to define the
sub-space may be programmable. The first color space may be YC<sub class="gmail-style-scope gmail-patent-text">r</sub>C<sub class="gmail-style-scope gmail-patent-text">b</sub> and the second color
space may be RGB."</div><div class="gmail-abstract gmail-style-scope gmail-patent-text"><br></div><div class="gmail-abstract gmail-style-scope gmail-patent-text">=====</div><div class="gmail-abstract gmail-style-scope gmail-patent-text"><br></div><div class="gmail-abstract gmail-style-scope gmail-patent-text">so, while in theory this problem is combatable in practice I do not think we have any out of the box plugin for dealing with this?</div><div class="gmail-abstract gmail-style-scope gmail-patent-text"><br></div><div class="gmail-abstract gmail-style-scope gmail-patent-text">So .... back to hunting for relevant test image, may be rgbtestsrc stored as y4m will do?<br></div>
</span>
</div></span></div></div></div></div>