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. |
18th May 2014, 21:03 | #1 | Link |
Registered User
Join Date: Oct 2010
Posts: 100
|
lossless YV12-RGB48-YV12 conversion?
Hi,
I read a while ago a vague comment somewhere that it's possible to have lossless YV12-to-RGB48-back-to-YV12 conversion in Avisynth since RGB48 supposedly gives enough precision for this. Does one use dithertools (because of RGB48) or something else? I have tried following script: Code:
dss2("HD_clip.mkv") Dither_convert_yuv_to_rgb (output="rgb48y") r = SelectEvery (3, 0) g = SelectEvery (3, 1) b = SelectEvery (3, 2) Dither_convert_rgb_to_yuv (r, g, b, lsb=false, mode=0) |
18th May 2014, 22:26 | #4 | Link |
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,666
|
Regarding the script you posted, shouldn't this be a bit more correct? (I'm not completely sure either):
Code:
# Source (YV12 with MPEG2 chroma placement) ConvertToYV24(chromaresample="point") MergeChroma(PointResize(width, height, src_left=0, src_top=1)) Dither_convert_yuv_to_rgb (matrix="709", tv_range=true, output="rgb48y") # matrix and tv_range are of course source dependent. r = SelectEvery (3, 0) g = SelectEvery (3, 1) b = SelectEvery (3, 2) Dither_convert_rgb_to_yuv (r, g, b, matrix="709", tv_range=true, cplace="MPEG2", chromak="point", lsb=false, mode=0, output="YV12") # Output is 8-bit YV12 Last edited by Reel.Deel; 18th May 2014 at 22:41. |
18th May 2014, 23:06 | #5 | Link |
Registered User
Join Date: Oct 2010
Posts: 100
|
Thanks for your comment! Reading dither tools docu, I noticed the option about the chroma placement, but I did not know which configuration my H.264 encoded YV12 input file uses, so I left that out. The matrix and tv range setting default to the correct ones, though. I will give your script a try.
EDIT: I gave Gavino's script from the link and your script above a try, both give much better results than before. I was able to find a difference only in the dark red range, where your script with dither tools also seems to get the edge over Gavino's (at least statistically). Last edited by Marin85; 18th May 2014 at 23:27. |
19th May 2014, 00:28 | #7 | Link |
Registered User
Join Date: Oct 2010
Posts: 100
|
Nothing fancy, just comparing lots of randomly picked pixels to see if the color values match or not :-)
I am still wondering though if there is in fact a way to have a completely lossless conversion back and forth between YV12 and RGB. |
19th May 2014, 13:07 | #9 | Link | ||
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,666
|
Quote:
Quote:
IIRC I read somewhere that YUV<-->RGB conversion needs at least 10-bits to be lossless. ------------- Technically, any mode used is not lossless. Dithering back to 8-bits will always add something to the original, hence not lossless. |
||
19th May 2014, 13:24 | #10 | Link | |
I'm Siri
Join Date: Oct 2012
Location: void
Posts: 2,633
|
Quote:
rounding is not dithering, so sometimes it can be lossless as for "at least 10bits" stuff, it's only true if your source is rgb24, here we talk about yv12-rgb-yv12 conversion, not rgb-yuv conversion Last edited by feisty2; 19th May 2014 at 14:06. |
|
19th May 2014, 15:24 | #11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
This is what I use to show clip difference, 8 bit ony but could probably be easily modded for 16 bit.
Code:
# Return Clip Difference of input clips (amp==true = Amplified, show==true = show background) Function ClipDelta(clip clip1,clip clip2,bool "amp",bool "show") { amp=Default(amp,false) show=Default(show,false) c2=clip1.levels(128-32,1.0,128+32,128-32,128+32).greyscale() c1=clip1.subtract(clip2) c1=(amp)?c1.levels(127,1.0,129,0,255):c1 return (show)?c1.Merge(c2):c1 } Show, shows a dimmed representaion of the frame, (best used with AMP) so you can see exactly where the differences are.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 19th May 2014 at 15:28. |
20th May 2014, 15:53 | #12 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
YV12 <-> RGB conversions are not lossless whatever the bitdepth, unless you’re resampling the chroma planes with a specific kernel in order to make YV12 -> RGB -> YV12 lossess, but this may reduce the overall quality of each conversion.
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
|
|