Log in

View Full Version : color manipulation on 8 bit videos on 2025


OvejaNegra
15th February 2025, 10:43
Using and abusing tweak and coloryuv on 8 bit videos on old versions of
avisynth, could create banding and maybe other undesired artifacts a long time ago.

I remember old advices about using dither when converting from 601 to 709 when scaling or when doing color manipulation on the RGB world and then
coming back to yuv.

A lot must have changed on the new versions of avs+, and maybe some

of this stuff is not needed anymore:

Do i need to increase bits before doing color manipulations (on 8bit videos)?

would be safer something like:


Convertbits(10)
ColorYUV (etc)
Convertbits(8,dither=1)

or is not needed anymore?

Do i need to increase bits before converting to RGB and back (or to any
other mode for doing any processing and coming back?

and if i need to change color matrix and resolution?

-----
(im talking about a possible scenario where i need to make many operations
on color and i want to avoid possible banding, something like converting to
rgb, doing rgbadjust, coming back to yuv, using tweak or coloryuv, adjusting levels, etc)
-----

after
Convertbits(10)
--something
--something

do i need to come back to 8 bit with Convertbits (8,dither=1), or can i encode
in 10 bits with YUV420P10 on x265?

Thanks!!!

FranceBB
15th February 2025, 22:44
Do i need to increase bits before doing color manipulations (on 8bit videos)?


Yes, it's always advisable to work in high bit depth before dithering down to the target bit depth, regardless of what the bit depth of your source is. This has actually always been the case, even back in the 8bit days, which was what led to the creation of 16bit stacked (MSB and LSB stacked one on top of the other), also called "double height" as it used twice the vertical resolution to carry those, and 16bit interleaved (MSB and LSB interleaved together), also called "double width" as it used twice the horizontal resolution to carry those. Nowadays pretty much everything supports 16bit planar (i.e the "normal" high bit depth), so I would definitely use ConvertBits(16) whenever any filtering operation is needed. Some people go as far as using 32bit float, but since not everything supports it I'd advise against using ConvertBits(32) unless you really need to. I'm pretty much fine with 16bit in the overwhelming majority of the cases.


do i need to come back to 8 bit with Convertbits (8,dither=1), or can i encode in 10 bits with YUV420P10 on x265?

if you're using an encoder that doesn't support high bit depth, like x262, then by all means use ConvertBits(bits=8, dither=1) to dither down to 8bit using the Floyd Steinberg Error Diffusion before feeding the encoder, otherwise if you're using high bit depth aware encoders like x264 and x265, you can feed them with 16bit planar high bit depth data and they will dither it down themselves before encoding. Please note that x264 will automatically use the Sierra A2-4 Error Diffusion, while for x265 you need to specify --dither in the command line.

Emulgator
15th February 2025, 23:10
...and may I recommend the SmoothAdjust16() family to Oveja, a snippet here with YUV bending spots 1/2, 1/4, 1/8 scale pre-set:
[* # +++++ Start of Block "SmoothAdjust" +++++
smoothdebug=0 #0 no Diagram, 1 = Curve only, 2: Tweak only, 3: Both
ShowSmoothCurveDiagram=smoothdebug==1 ? true : smoothdebug==3 ? true : false
ShowSmoothTweakDiagram=smoothdebug==2 ? true : smoothdebug==3 ? true : false
smoothdebugwidth=1920
smoothdebugheight=1080
linear3="0-0;32767-32767;65535-65535"
linear5="0-0;16383-16383;32767-32767;49151-49151;65535-65535"
linear9="0-0;8191-8191;16383-16383;24575-24575;32767-32767;40959-40959;49151-49151;57343-57343;65535-65535"
SmoothCurve16(ConvertTo16bit().ConvertToStacked(), \
Ycurve=linear3, \
Ucurve=linear3, \
Vcurve=linear3, \
limiter=false, HQ=true, interp=100, debug=ShowSmoothCurveDiagram, screenW=smoothdebugwidth, screenH=smoothdebugheight)
#SmoothTweak(HQ=true, brightness=0, contrast=1.0, saturation=1.0, hue1=-0, hue2=+0, limiter=false, debug=ShowSmoothTweakDiagram, screenW=smoothdebugwidth, screenH=smoothdebugheight)
ConvertFromStacked()
*] # -------- End of Block "SmoothAdjust" --------

OvejaNegra
18th February 2025, 10:05
Sorry, little busy on these days.
Thanks for the advices!!

FranceBB
18th February 2025, 10:49
Sorry, little busy on these days.

Weather where you are:
https://i.imgur.com/hFVtRgT.png

Weather where I am:
https://i.imgur.com/DtEhAIk.png


I would also be busy going to the beach if I were living there hahahahahahaha

*cries in the cold*