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 October 2008, 12:02 | #21 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
@ CruNcher: We're talking about burning wood here. You are talking about vacuum energy. Yes, vacuum energy is much more fertile, no doubt. Problem is that it hasn't been implemented yet. Burning wood works right here, right now.
@ pitch.fr: I used bicubic for good resons. Look at this chart: In brief: Using any other resizer in GrainFactory() ... ... offers no benefit at all ... is slower (though not much) ... breaks the "sharpness" settings (they're not functional anymore, then) When will people finally learn that amongst Avisynth's resizers there are no "bad / good / better / best" ones. A 10mm spanner is neither better nor worse than a 16mm spanner. The trick is you have to use the one that fits to the screw.
__________________
- 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!) |
2nd October 2008, 12:22 | #22 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
are you sure we can draw so many conclusions from your test charts
you use "bicubicresize" in your original script, so is it -0.6/-0.75/-1 ? is it also a bad idea to upgrade LSF with spline36 ? anyway, I guess you agree that the same grainsize for bright and dark areas is a problem ? you don't wanna have huge grains in open skies for instance and what is "grain_texture" supposed to do ? |
2nd October 2008, 13:25 | #23 | Link | ||||
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Quote:
The chart should give the idea that whatever any of the other resizers do achieve, can be achieved by bicubic just as well - and even *more*, if you're after "sharp" grain. Of course, if you feel better when filling your lawnmower with super-duper-$$$$-120octane gasoline, then by all means do so. My lawnmower gets only standard gasoline, and it runs very well. Quote:
Code:
bicubic( 1.0,0.00) -> grainX_sharpness = 0 bicubic( 0.0,0.50) -> grainX_sharpness = 50 bicubic(-0.5,0.75) -> grainX_sharpness = 75 bicubic(-1.0,1.00) -> grainX_sharpness = 100 Quote:
Quote:
__________________
- 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!) Last edited by Didée; 2nd October 2008 at 13:29. |
||||
2nd October 2008, 14:48 | #24 | Link |
Bored...
Join Date: Apr 2003
Location: Unknown
Posts: 2,812
|
Good to see this function alive again! Remembers me my Gain generation procedure in Photoshop... Gaussian Noise -> Gaussian Blur -> UnsharpMask (With higher blur radius for low luma parts, lower blur radius for high luma parts, more sharpening for high luma parts, less sharpening for teh low luma parts etc...). Hmm, how about a Grain3 param for this function? Having separate params for low, mid and high luma would be advantageous imo! :]
Bye |
2nd October 2008, 15:17 | #25 | Link | |||
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
Quote:
I didn't realize the sharpness setting was playing around with the bicubic coeff Quote:
Quote:
agreed, that would be the icing on the cake Last edited by pitch.fr; 2nd October 2008 at 15:22. |
|||
3rd October 2008, 06:24 | #26 | Link | |
ангел смерти
Join Date: Nov 2004
Location: Lost
Posts: 9,556
|
Quote:
As for addgrainC, I don't see how it could be leaking memory unless using it with MT somehow causes its pointers to be overwritten. I'd expect it to crash a lot in that case. |
|
3rd October 2008, 09:39 | #27 | Link | |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
Quote:
here's AddGrainC 1.1 with 4 thread in ffdshow(1st value is RAM usage, second one is virtual memory usage) : here's AddGrainC 1.4 with 4 thread in ffdshow on the same exact movie, with the same exact config : if I use SetMemoryMax(256), 1.0/1.1 will obey but newer versions won't with 8 threads, it crashes in VDUB for me(it's bypassed), uses +1.6Gb of RAM in ffdshow/MPC..then crashes MPC(also tried with other players) tests were conducted on XP SP3, with MT 0.7 and the latest ffdshow/MPC on a Q6600 Last edited by pitch.fr; 3rd October 2008 at 13:20. |
|
3rd October 2008, 14:38 | #28 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
@ foxyshadis: That's too simplistic for what CruNcher has in mind. That way you'll "only" get noise with varying sigma per frame, but still it'll be the "same kind" of noise all over the frame. The idea, however, was to have noise varying acc. to local brighness, and/or acc. to local amount of R/G/B component. That's a bit more complex.
__________________
- 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!) |
3rd October 2008, 21:47 | #30 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Here you go. Look into the default() section to inform yourself about the parameters - I decided to shorten parameters' names for less typing effort when using named values in the function call. The zone transitions get specified by th1/th2 and th3/th4.
The structure of script & parameters should be kind of obvious ... in case you come to the idea of needing "dark dark" + "bright dark" and/or "dark/medium/bright medium" etc. zones, you can do it on your own. Code:
function GrainFactory3(clip clp,int "g1str",int "g2str",int "g3str",int "g1shrp",int "g2shrp",int "g3shrp", \ float "g1size", float "g2size", float "g3size", \ int "g1tex", int "g2tex", int "g3tex", int "temp_avg", int "ontop_grain", \ int "th1", int "th2", int "th3", int "th4") { g1str = default( g1str, 13 ) # [ 0 - ???] strength of grain / for dark areas g2str = default( g2str, 15 ) # [ 0 - ???] strength of grain / for midtone areas g3str = default( g3str, 25 ) # [ 0 - ???] strength of grain / for bright areas g1shrp = default( g1shrp, 60 ) # [ 0 - 100] sharpness of grain / for dark areas (NO EFFECT when g1size=1.0 !!) g2shrp = default( g2shrp, 66 ) # [ 0 - 100] sharpness of grain / for midtone areas (NO EFFECT when g2size=1.0 !!) g3shrp = default( g3shrp, 80 ) # [ 0 - 100] sharpness of grain / for bright areas (NO EFFECT when g3size=1.0 !!) g1size = default( g1size, 1.50 ) # [0.5 - 4.0] size of grain / for dark areas g2size = default( g2size, 1.20 ) # [0.5 - 4.0] size of grain / for mid-tone areas g3size = default( g3size, 0.90 ) # [0.5 - 4.0] size of grain / for bright areas g1tex = default( g1tex, 0 ) # [ 0 - 100] strength of "material texture" appearance g2tex = default( g2tex, 0 ) # [ 0 - 100] (in fact: 'bump' effect) g3tex = default( g3tex, 0 ) # [ 0 - 100] for dark / midtone / bright grain temp_avg = default( temp_avg, 0 ) # [ 0 - 100] percentage of noise's temporal averaging th1 = default( th1, 24 ) # start of dark->midtone mixing zone th2 = default( th2, 56 ) # end of dark->midtone mixing zone th3 = default( th3, 128 ) # start of midtone->bright mixing zone th4 = default( th4, 160 ) # end of midtone->bright mixing zone ontop_grain = default( ontop_grain, 0 ) # [ 0 - ???] additional grain to put on top of prev. generated grain #----------------------------------------------------------------------------------- o = clp ox = o.width oy = o.height sx1 = m4(ox/float(g1size)) sy1 = m4(oy/float(g1size)) sx1a = m4((ox+sx1)/2.0) sy1a = m4((oy+sy1)/2.0) sx2 = m4(ox/float(g2size)) sy2 = m4(oy/float(g2size)) sx2a = m4((ox+sx2)/2.0) sy2a = m4((oy+sy2)/2.0) sx3 = m4(ox/float(g3size)) sy3 = m4(oy/float(g3size)) sx3a = m4((ox+sx3)/2.0) sy3a = m4((oy+sy3)/2.0) b1 = g1shrp/(-50.0) + 1.0 b2 = g2shrp/(-50.0) + 1.0 b3 = g3shrp/(-50.0) + 1.0 b1a = b1/2.0 b2a = b2/2.0 b3a = b3/2.0 c1 = (1.0-b1)/2.0 c2 = (1.0-b2)/2.0 c3 = (1.0-b3)/2.0 c1a = (1.0-b1a)/2.0 c2a = (1.0-b2a)/2.0 c3a = (1.0-b3a)/2.0 T1a = string(int(g1tex*1.28)) T1b = string(128-int(g1tex*1.28)) T2a = string(int(g2tex*1.28)) T2b = string(128-int(g2tex*1.28)) T3a = string(int(g3tex*1.28)) T3b = string(128-int(g3tex*1.28)) th1str = string(th1) th2str = string(th2) th3str = string(th3) th4str = string(th4) tmpavg = temp_avg/100.0 #----------------------------------------------------------------------------------- BUMPKERNEL1 = T1a + " 0 0 0 " + T1b + " 0 0 0 0 128" BUMPKERNEL2 = T2a + " 0 0 0 " + T2b + " 0 0 0 0 128" BUMPKERNEL3 = T3a + " 0 0 0 " + T3b + " 0 0 0 0 128" #----------------------------------------------------------------------------------- grainlayer1 = blankclip(o, width=sx1, height=sy1, color_yuv=$808080) .AddGrainC(g1str, 0,0,0) grainlayer1 = (g1tex==0) \ ? grainlayer1 \ : mt_makediff(grainlayer1,grainlayer1.mt_edge(BUMPKERNEL1, 0,255,0,0, U=1,V=1 ), U=1,V=1) grainlayer1 = (g1size == 1.0 || sx1==ox && sy1==oy) ? grainlayer1 \ : (g1size > 1.5) ? grainlayer1.bicubicresize(sx1a,sy1a, b1a,c1a).bicubicresize(ox,oy, b1a,c1a) \ : grainlayer1.bicubicresize(ox,oy, b1,c1) #----------------------------------------------------------------------------------- grainlayer2 = blankclip(o, width=sx2, height=sy2, color_yuv=$808080) .AddGrainC(g2str, 0,0,0) grainlayer2 = (g2tex==0) \ ? grainlayer2 \ : mt_makediff(grainlayer2,grainlayer2.mt_edge(BUMPKERNEL2, 0,255,0,0, U=1,V=1 ), U=1,V=1) grainlayer2 = (g2size==1.0 || sx2==ox && sy2==oy) ? grainlayer2 \ : (g2size > 1.5) ? grainlayer2.bicubicresize(sx2a,sy2a, b2a,c2a).bicubicresize(ox,oy, b2a,c2a) \ : grainlayer2.bicubicresize(ox,oy, b2,c2) #----------------------------------------------------------------------------------- grainlayer3 = blankclip(o, width=sx3, height=sy3, color_yuv=$808080) .AddGrainC(g3str, 0,0,0) grainlayer3 = (g3tex==0) \ ? grainlayer3 \ : mt_makediff(grainlayer3,grainlayer3.mt_edge(BUMPKERNEL2, 0,255,0,0, U=1,V=1 ), U=1,V=1) grainlayer3 = (g3size==1.0 || sx3==ox && sy3==oy) ? grainlayer3 \ : (g3size > 1.5) ? grainlayer3.bicubicresize(sx3a,sy3a, b3a,c3a).bicubicresize(ox,oy, b3a,c3a) \ : grainlayer3.bicubicresize(ox,oy, b3,c3) #----------------------------------------------------------------------------------- grainlayer = grainlayer1.mt_merge(grainlayer2, o.mt_lut("x "+th1str+" < 0 x "+th2str+" > 255 255 "+th2str+" "+th1str+" - / x "+th1str+" - * ? ?"), U=1,V=1) \ .mt_merge(grainlayer3, o.mt_lut("x "+th3str+" < 0 x "+th4str+" > 255 255 "+th4str+" "+th3str+" - / x "+th3str+" - * ? ?"), U=1,V=1) grainlayer = (temp_avg==0) ? grainlayer \ : grainlayer.mergeluma(grainlayer.temporalsoften(1,255,0,255,2), tmpavg) grainlayer = (ontop_grain==0) ? grainlayer \ : grainlayer.AddGrainC(ontop_grain,0,0,0) #----------------------------------------------------------------------------------- result = o.mt_makediff(grainlayer, U=2,V=2) return( result ) #----------------------------------------------------------------------------------- function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) } #===================================================================================}
__________________
- 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!) Last edited by Didée; 3rd October 2008 at 22:29. |
3rd October 2008, 21:50 | #31 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
awesome Didee, you're the man
gonna try it right now with : Code:
GrainFactory3(6,5,3,100,100,100,1.50,1,0.70,0,0,0,0,0,24,56,128,160) it brings back the grain h264 stole from us Code:
MT("GrainFactory_MT2(3,5,100,100,1.0,0.7,0,0,0,96,0)",4) Code:
MT("GrainFactory3(7,5,3,100,100,100,1.30,1,0.70,0,0,0,0,0,24,56,128,160)",4) Code:
MT("GrainFactory(3,5,100,100)",4) (1.15/0.8 default sizes and no temporal thingie) Last edited by pitch.fr; 3rd October 2008 at 23:17. |
3rd October 2008, 22:20 | #32 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
apparently you need to add these lines at the end of the GrainF3 script to be standalone from the MT1/MT2 :
Code:
#----------------------------------------------------------------------------------- function m4(float x) {return( x<16?16:int(round(x/4.0)*4)) } #=================================================================================== |
3rd October 2008, 22:27 | #33 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
Ah yes, the modulo function accidentially was left out during copy/paste. Thanks for noting. It's now included in the script above.
__________________
- 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!) |
3rd October 2008, 22:35 | #34 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
I think I've edited after you read it, so here it is again :
GrainF3 gives less FPS than the original GrainF script, yet it's fully usable in realtime on my 3.4Ghz Q6600 apparently there's 2 different problems with using an AVS script in ffdshow : 1-fps, of course 2-but more importantly latency.....and the latency seems far better with MT2 than MT1 my CPU load is 55% with a 1.78 20mbit 720p h264 movie, and LSF/Ulevels/GrainF + gamut conversion through AVIshader + ConvertToRGB32 |
4th October 2008, 01:23 | #35 | Link |
Resize Abuser
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
|
I added GrainFactory to the wiki http://avisynth.org/mediawiki/External_filters#Effects
Should I change the link to point to GrainFactory3? Does it need a new entry in the wiki? Some guidance would be nice. GrainFactory3 got it's closing "}" commented out
__________________
Mine: KenBurnsEffect/ZoomBox CutFrames Helped: DissolveAGG ColorBalance LQ Animation Fixer |
4th October 2008, 10:15 | #36 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
I think I like the same grain size for dark and mid areas(1), and then finer grain for bright ones(0.7)
big grain sizes for dark ones look rather distracting at least it's good that we can set different strengths Last edited by pitch.fr; 4th October 2008 at 10:25. |
4th October 2008, 14:23 | #38 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
good point, but then it makes the picture a bit blurry, doesn't it ?
I think I might settle down to Code:
GrainFactory3(6,5,3,100,100,100,1,1,0.70,0,0,0,0,0,24,56,128,160) |
4th October 2008, 15:32 | #39 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,389
|
More and more it deteriorates to a foolish act ... you realize that with grainsizeX=1.0 you get exactly the output of AddGrain()? A few more such requests, and it'll be a huge placebo function that does the same as a simple AddGrain() would do ...
With th1=0 and th2=0, this mod uses layer2 for both dark & midtones. Know why usually I don't react to any such "realtime function" requests? Most of the time it creates "more simplification" and "even more simplification", up to the point where the sophisticated idea you once had started with has turned into a thing so primitive and ugly that one should be ashamed about. And truly, we're on that way here.
__________________
- 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!) |
4th October 2008, 16:41 | #40 | Link |
Didée 4 President
Join Date: Jun 2008
Posts: 239
|
cool, thanks again Didee!
well the whole idea is to have big grain in dark stuff, and very fine in bright ones. maybe a 50/50 would be fine after all ? or at least better than having the same size in dark/bright, and different in mid. but I've done my tests on a 19" CRT mainly, I'll look more into it this evening on the pj. I'm not asking for 50/50 stuff because it sucks too much ressources, but simply coz huge grain in dark areas looks a bit distracting and very small one a bit weak. I'll try to play around w/ the sharpness as SoulHunter said. and this script is great, even for non realtime use I think Last edited by pitch.fr; 4th October 2008 at 16:56. |
Thread Tools | Search this Thread |
Display Modes | |
|
|