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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th July 2014, 20:16   #1  |  Link
bxyhxyh
Registered User
 
Join Date: Dec 2011
Posts: 354
nnedi3 shift

I'm upscaling a dvd to 720p, I needed yv24 colorspace for further part of my script.

I'm using this script
Code:
#Source
ColorMatrix("Rec.601->Rec.709",clamp=0)
y=ConvertToY8().nnedi3_rpow2(2).Dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).Ditherpost()
u=UToY8().nnedi3_rpow2(4).Dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).Ditherpost()
v=VToY8().nnedi3_rpow2(4).Dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).Ditherpost()
YToUV(u,v,y)
How much my shifts should be on this case?

Last edited by bxyhxyh; 21st July 2014 at 04:16.
bxyhxyh is offline   Reply With Quote
Old 21st July 2014, 02:43   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
Add the center shift argument to nnedi3_rpow2, and no chroma shift correction will be needed:
Code:
nnedi3_rpow2(2, cshift="Spline16Resize")
EDIT Note,
- I tested your script sans dither calls, for simplicity
- I tested at 4x enlargement to exaggerate the artifacts. The output looks great; this is a good idea!
- nnedi3_rpow2 does not accept Y8, only YV12, YUY2 and RGB24 - at least for me.
Code:
## source = YV12
y=nnedi3_rpow2(4, cshift="Spline16Resize")
u=UToY8.ConvertToYV12
\  .nnedi3_rpow2(8, cshift="Spline16Resize")
v=VToY8.ConvertToYV12
\  .nnedi3_rpow2(8, cshift="Spline16Resize")
YToUV(u, v, y) 
## output=YV24
EDIT 2 completely wrong, please ignore

Last edited by raffriff42; 22nd July 2014 at 13:08.
raffriff42 is offline   Reply With Quote
Old 21st July 2014, 03:05   #3  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
Quote:
Originally Posted by raffriff42 View Post
- nnedi3_rpow2 does not accept Y8, only YV12, YUY2 and
The updated nnedi3 accepts the additional planar colorspaces. Also, VToY() is probably better than VToY8.ConvertToYV12.
Reel.Deel is offline   Reply With Quote
Old 21st July 2014, 03:28   #4  |  Link
bxyhxyh
Registered User
 
Join Date: Dec 2011
Posts: 354
Yes I'm using updated nnedi3 and UToY8() and VToY8() for speed and low memory usage.

Last edited by bxyhxyh; 21st July 2014 at 04:06.
bxyhxyh is offline   Reply With Quote
Old 21st July 2014, 07:16   #5  |  Link
colours
Registered User
 
colours's Avatar
 
Join Date: Mar 2014
Posts: 308
Quote:
Originally Posted by bxyhxyh View Post
I'm using this script
Code:
#Source
ColorMatrix("Rec.601->Rec.709",clamp=0)
y=ConvertToY8().nnedi3_rpow2(2).Dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).Ditherpost()
u=UToY8().nnedi3_rpow2(4).Dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).Ditherpost()
v=VToY8().nnedi3_rpow2(4).Dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).Ditherpost()
YToUV(u,v,y)
Why are you using an invks resize after nnedi3_rpow2? If you want sharpening, you'd be better served with nonlinear sharpening filters instead of resorting to Dither_resize16's invks.

Quote:
Originally Posted by raffriff42 View Post
Add the center shift argument to nnedi3_rpow2, and no chroma shift correction will be needed:
Code:
nnedi3_rpow2(2, cshift="Spline16Resize")
Assuming that the chroma channels are copied to luma before calling nnedi3_rpow2 with UToY/VToY, this is only correct for MPEG-1/JPEG chroma siting, not for MPEG-2 chroma siting.

Also, nnedi3_resize16 is a thing and it probably already handles converting from 4:2:0 to 4:4:4 using nnedi3 for upscaling correctly.
colours is offline   Reply With Quote
Old 21st July 2014, 10:50   #6  |  Link
bxyhxyh
Registered User
 
Join Date: Dec 2011
Posts: 354
I've changed my script to this
Code:
y=converttoy8().nnedi3_rpow2(2,cshift="spline16resize").dither_convert_8_to_16().dither_resize16(1280,720,kernel="bilinear",invks=true).ditherpost()
u=utoy8().nnedi3_rpow2(4,cshift="spline16resize").dither_convert_8_to_16().dither_resize16(1280,720,0.25,kernel="bilinear",invks=true).ditherpost()
v=vtoy8().nnedi3_rpow2(4,cshift="spline16resize").dither_convert_8_to_16().dither_resize16(1280,720,0.25,kernel="bilinear",invks=true).ditherpost()
YToUV(u,v,y)
Now, Is 0.25 still needed here? Or is nnedi3 shifts as well?
bxyhxyh is offline   Reply With Quote
Old 21st July 2014, 11:37   #7  |  Link
colours
Registered User
 
colours's Avatar
 
Join Date: Mar 2014
Posts: 308
The shift of 0.25 px is correct only for the original resolution; in this case, nnedi3_rpow2 results in chroma with four times the width of the original, so the shift should also be scaled to 1 px.
colours is offline   Reply With Quote
Old 21st July 2014, 15:14   #8  |  Link
Reel.Deel
Registered User
 
Join Date: Mar 2012
Location: Texas
Posts: 1,664
I forgot that nnedi3_resize16 does colorspace conversion. For learning purposes I compared nnedi3_resize16(1280,720, output="YV24") against a manual conversion. The following seems to produce the closest output between the 2.

Code:
Y = ConvertToY8().nnedi3_rpow2(2).Dither_convert_8_to_16().Dither_resize16(1280,720, src_left=-0.5, src_top=-0.5).Ditherpost(mode=6)
U =       UToY8().nnedi3_rpow2(4).Dither_convert_8_to_16().Dither_resize16(1280,720, src_left= 0.5, src_top=-0.5).Ditherpost(mode=6)
V =       VToY8().nnedi3_rpow2(4).Dither_convert_8_to_16().Dither_resize16(1280,720, src_left= 0.5, src_top=-0.5).Ditherpost(mode=6)
YToUV(U, V, Y)
Any thoughts?
Reel.Deel is offline   Reply With Quote
Old 22nd July 2014, 10:20   #9  |  Link
bxyhxyh
Registered User
 
Join Date: Dec 2011
Posts: 354
Quote:
Originally Posted by Reel.Deel View Post
Any thoughts?
That's what I'm asking for.
For nnedi3_rpow2(2), -0.5 works.

But is it same -0.5 for nnedi3_rpow2(4)?
bxyhxyh is offline   Reply With Quote
Old 22nd July 2014, 12:54   #10  |  Link
DarkSpace
Registered User
 
Join Date: Oct 2011
Posts: 204
Quote:
Originally Posted by bxyhxyh View Post
That's what I'm asking for.
For nnedi3_rpow2(2), -0.5 works.

But is it same -0.5 for nnedi3_rpow2(4)?
It's either 0.5 or -1.5 for rpow(4), depending on whether rpow() switches the field it interpolates from or not.
DarkSpace is offline   Reply With Quote
Reply

Tags
chromashift, nnedi3

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:16.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.