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. |
2nd March 2011, 00:53 | #363 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
Yes, but I'm thinking about changing it so that the weights are not compiled into the binary. There would be a string that points to a weight file. Then I don't have to have multiple versions of a 6MB dll on my web space (which is pretty limited) - only one copy of each set of weights. Although half of that 6MB size is due to the nns=256 weights, so I'm considering just dropping the 256 setting since it is too slow for video and does not offer much visual improvement over 128... metric wise the improvement is the same as 64->128. Also, the training takes a LONG time.
Last edited by tritical; 2nd March 2011 at 01:05. |
2nd March 2011, 13:44 | #364 | Link | |
Registered User
Join Date: Apr 2008
Posts: 418
|
Quote:
|
|
3rd March 2011, 15:24 | #365 | Link |
Registered User
Join Date: Apr 2005
Posts: 213
|
Thanks for the update, tritical. Indeed an improvement.
Source (400x300) >> Spline36Resize(1600, 1200) >> nnedi2_rpow2(rfactor=4, nsize=2, qual=2, cshift="Spline36Resize") >> nnedi3_rpow2(rfactor=4, nsize=0, nns=4, qual=2, cshift="Spline36Resize"), SQR >> nnedi3_rpow2(rfactor=4, nsize=0, nns=4, qual=2, cshift="Spline36Resize"), ABS >> Last edited by Archimedes; 3rd March 2011 at 15:40. |
10th May 2011, 19:33 | #368 | Link |
Registered User
Join Date: May 2008
Posts: 40
|
I've been toying with nnedi3 (abs version) for the past days and I've found a somewhat strange behaviour.
When using nnedi3_rpow2(rfactor=2,nns=2,nsize=3,cshift="Spline36Resize") I think the filter is not doing the chroma shift part quite correctly. In fact I think the filter actually does something very similar to nnedi3(1, dh=true,nns=2,nsize=3).turnright().nnedi3(1, dh=true,nns=2,nsize=3).turnleft() a=last Spline36Resize(OX,OY,-0.5,-0.5,OX*2,OY*2) MergeChroma(a.Spline36Resize(OX,OY,-0.5,-1.00,OX*2,OY*2)) Which is obviously not correct, because the correct version should end with something like MergeChroma(b.Spline36Resize(OX,OY,-1.00,-1.00,OX*2,OY*2)) If I'm correct the filter probably needs some kind of correction. On another note it would be helpful (to me, at least) if nnedi3_rpow2 had more parameters, I'd like to have the option to disable the chroma planes processing and to skip the chroma shift, I know it can be easily done with two nnedi3 calls, but it would help in writing clearer scripts. |
10th May 2011, 21:06 | #369 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Avisynth assumes MPEG-2 sampling, so chroma pixels are vertically aligned with luma. Hence, the horizontal shift correction is the same (-0.5) for both luma and chroma, and it is only the vertical one which differs (-0.5 for luma and -1.0 for chroma). |
|
10th May 2011, 22:38 | #370 | Link | |
Registered User
Join Date: May 2008
Posts: 40
|
Quote:
UToY() applied to the clip before processing http://www.cbland.net/images4/01azazel.png UToY() applied to the clip after -0.5 -1.0 chroma resize http://www.cbland.net/images4/01azazel050100.png UToY() applied to the clip after -1.0 -1.0 chroma resize http://www.cbland.net/images4/01azazel100100.png The second one is different from 1 and 3 (which are basically the same), that'd why I assumed -1.0 -1.0 was the way to go. Edit: Did try with a different source, same problem. Last edited by Sapo84; 10th May 2011 at 22:57. |
|
11th May 2011, 10:59 | #371 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
I can't see any difference visually between them, but using Compare shows they are all different, with 2 and 3 being (by a small margin) the most similar. 1 v 2: PSNR=51.99dB 1 v 3: PSNR=53.98dB 2 v 3: PSNR=55.88dB |
|
11th May 2011, 12:32 | #372 | Link | ||
Registered User
Join Date: May 2008
Posts: 40
|
Quote:
___________ nnedi3(1, dh=true,nns=2,nsize=3).turnright().nnedi3(1, dh=true,nns=2,nsize=3).turnleft() a=last Spline36Resize(OX,OY,-0.5,-0.5,OX*2,OY*2) MergeChroma(a.Spline36Resize(OX,OY,-0.5,-1.00,OX*2,OY*2)) UToY() ___________ nnedi3(1, dh=true,nns=2,nsize=3).turnright().nnedi3(1, dh=true,nns=2,nsize=3).turnleft() a=last Spline36Resize(OX,OY,-0.5,-0.5,OX*2,OY*2) MergeChroma(a.Spline36Resize(OX,OY,-1.0,-1.00,OX*2,OY*2)) UToY() Quote:
I did a quick crop and zoom. http://www.cbland.net/images4/Azazel_01.png http://www.cbland.net/images4/Azazel_02.png http://www.cbland.net/images4/Azazel_03.png While 1 and 3 are pretty much identical the 2 suffer from a little shift, and it's the one with the (-0.5,-1) chroma shift, which should be the correct one. Edit: After a bit of thinking I may have the reason why -1 -1 is correct, in fact nnedy does never resize horizontally, it just does Turnleft() and then Turnright(), so the chroma does get shifted by 1 pixel in both directions. |
||
11th May 2011, 14:27 | #373 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Are OX and OY the original clip width and height?
So you are upsizing with nnedi3 and downsizing back to the original size? I'm confused about your original point now. Where does nnedi3_rpow2 come into it? Quote:
|
|
11th May 2011, 14:47 | #374 | Link | ||
Registered User
Join Date: May 2008
Posts: 40
|
Yeah, I should have wrote a.width() and a.heigth() for clarity sake.
Quote:
And I'm finding the chroma is shifted by 1/4 of a pixel (also I would like to have more control on the parameters, because I'd like to write a script like naa() and I would like to skip chroma processing (if I don't want to process chroma) or chroma shifting (I would like to do it afterwards), but these are just feature request). Quote:
(well, that depends on what TurnLeft() and TurnRight() actually do to the chroma plane) Last edited by Sapo84; 11th May 2011 at 14:49. |
||
11th May 2011, 15:30 | #375 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
If anything can beat theory, it is practice.
Code:
loadplugin("nnedi3.dll") r = blankclip(width=64,height=64,pixel_type="YV12",color_yuv=$FF0000) g = blankclip(width=64,height=64,pixel_type="YV12",color_yuv=$00FF00) stackhorizontal(r,g) stackvertical(last,last.fliphorizontal()) o=last nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) interleave(o,last) return(last)
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) |
11th May 2011, 15:32 | #376 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Strictly speaking, you could argue that TurnLeft and TurnRight should resample chroma but that would mean they were no longer lossless operations. |
|
11th May 2011, 16:49 | #377 | Link | |
Registered User
Join Date: May 2008
Posts: 40
|
Quote:
Back to square one, I guess. Exactly. Edit: Also Code:
nnedi3(1, dh=true,nns=2,nsize=3).turnright().nnedi3(1, dh=true,nns=2,nsize=3).turnleft() a=last Spline36Resize(128,128,-0.5,-0.5,256,256)MergeChroma(a.Spline36Resize(128,128,-1.0,-1.0,256,256)) Last edited by Sapo84; 11th May 2011 at 17:12. |
|
6th June 2011, 15:18 | #378 | Link |
Registered User
Join Date: Dec 2003
Location: MO, US
Posts: 999
|
Gavino or Didée, any other thoughts on the horizontal shifting?
In terms of mpeg2 chroma placement nnedi2_rpow2() does not introduce a horizontal shift of chroma relative to luma... which to me can only mean that Avisynth's resizers do not assume mpeg2 chroma placement. I have not looked at the code to confirm this, but if it is the case then chaining many calls of nnedi3 (which assumes mpeg2 placement) with one of Avisynth's resizers (which assume mpeg1 maybe?) together would produce a shift as shown by Didée's script. However, if I change these lines of Didée's script: nnedi3_rpow2(2,cshift="spline36resize",fwidth=128,fheight=128) to nnedi3_rpow2(2).converttorgb24().spline36resize(128,128,-0.5,-0.5,256,256).convertbacktoyuy2().converttoyv12() there is no horizontal chroma shift. Which I believe confirms my suspicion as converttorgb24() + convertbacktoyuy2().converttoyv12() uses mpeg2 placement. Anyway, I'm planning to make a new release of nnedi3 with significantly faster prescreening + squared/abs weights in the same binary (with a parameter to switch between) and would like to get this issue cleared up. EDIT: after looking at the code it is indeed what I suspected. Avisynth's resizers are assuming mpeg1 chroma placement when performing subpixel shifting on YV12/YUY2 - which results in a leftward shift of the chroma. I'll adjust nnedi3 to take this into account. Last edited by tritical; 6th June 2011 at 16:35. |
6th June 2011, 16:59 | #379 | Link | |
Registered User
Join Date: Sep 2007
Posts: 5,374
|
Quote:
Does this apply to all versions of avisynth , or were there some changes made to 2.6 alpha 3 that might change this behaviour ? |
|
6th June 2011, 17:41 | #380 | Link | ||
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
I don't know why this hasn't occurred to me before - it's because the chroma sampling grid is not horizontally centred and is similar in nature to the problem in Bob that I deduced was present with interlaced YV12. I don't know whether this is a performance shortcut, an oversight, or (dare I say it) a bug. Quote:
The chroma is shifted right when upsizing and left when downsizing, and the amount depends on the scale ratio - probably imperceptible in most practical cases, but it definitely exists. Last edited by Gavino; 6th June 2011 at 21:26. Reason: upsizing is right shift, downsizing is left |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|