Log in

View Full Version : Good quality 4:2:0 to 4:2:2 upconversion


Aegwyn11
4th May 2013, 04:03
I need to upconvert some 4:2:0 8-bit clips to 4:2:2 10-bit and want to do it with maximum fidelity.

I came up with a way using Dither tools, but for the 4:2:0 to 4:2:2 conversion, I'm not sure if this method is better due to the RGB conversion. Is this better, or would it be better to just do a straight ConvertToYV16 and avoid the RGB conversions?

FFVideoSource(input.mkv,fpsnum=60000,fpsden=1001)

#Convert to Stack16 for processing
Dither_convert_8_to_16()

#Convert to 4:2:2 10-bit
Dither_convert_yuv_to_rgb(matrix="709", output="rgb48y", lsb_in=true, interlaced=false)
ConvertToYV16()
r = SelectEvery (3, 0)
g = SelectEvery (3, 1)
b = SelectEvery (3, 2)
Dither_convert_rgb_to_yuv(r, g, b, matrix="709", lsb=true, mode=0, output="YV16", interlaced=false)
Dither_quantize(10,reducerange=true)

#Output
Dither_out()


#Example command to save as v210 MOV for BM Shuttle playback
#avs2yuv -raw -csp I422 output.avs - | ffmpeg -y -f rawvideo -pix_fmt yuv422p10le -s widthxheight -r framerate -i - -c:v v210 output.mov

Reel.Deel
4th May 2013, 05:19
Here's (http://forum.doom9.org/showthread.php?p=1578312#post1578312) a solution by cretindesalpes to go to YV12 to YV16 without converting to RGB.

For YV16 use w = Width () / 2 and src_left=0
For YV24 use w = Width () and src_left=0.25
# Stack16 clip on input

w = Width () / 2
h = Height () / 2
u = UToY8 ().Dither_resize16 (w, h, kernel="spline36", src_left=0, u=1, v=1)
v = VToY8 ().Dither_resize16 (w, h, kernel="spline36", src_left=0, u=1, v=1)
YToUV (u, v, last)

# Stack16 clip on output

Yellow_
5th May 2013, 06:53
Or triticals t3dlut from here http://web.missouri.edu/~kes25c/ has a yv12->yuy2 option, no need for 3d lut of coarse, just that to use a the 3d lut part of the filter chain requires yuy2 first so he provided an upsampler.

Aegwyn11
6th May 2013, 21:04
Thanks for the responses!

Here's what I've altered my conversion script to be:
FFVideoSource(input.mkv,fpsnum=60000,fpsden=1001)

#Convert to Stack16 for processing
Dither_convert_8_to_16()

#Convert to 4:2:2 (if interlaced, SeperateFields and Weave must be used)
#SeparateFields()
w = Width()/2
h = Height()/2
u = UToY8().Dither_resize16(w, h, kernel="spline36", src_left=0, u=1, v=1)
v = VToY8().Dither_resize16(w, h, kernel="spline36", src_left=0, u=1, v=1)
YToUV(u, v, last)
#Weave()

#Convert to 10-bit and output
Dither_quantize(10,reducerange=true)
Dither_out()


#Example command to save as v210 MOV for BM Shuttle playback
#avs2yuv -raw -csp I422 output.avs - | ffmpeg -y -f rawvideo -pix_fmt yuv422p10le -s widthxheight -r framerate -i - -c:v v210 output.mov


#For testing only (8-bit output)
#DitherPost()