Log in

View Full Version : Avisynth+


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 [56] 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

vcmohan
27th December 2016, 14:15
I found that if any parameter other than clip is specified it is giving an error. The parameter need not be calculated in the script. I found that placing Reformer(last, last) was ok, but Reformer(last,last, qr = true) raises error.

real.finder
27th December 2016, 16:41
Misc. video info properties

ComponentSize
8 bit: 1 (bytes)
10-16 bit: 2 (bytes)
32 bit float: 4 (bytes)
BitsPerComponent
8, 10, 12, 14, 16, 32
ComponentCount
1 for greyscale
3 for YUV, Planar RGB, RGB24 and RGB48
4 for YUVA, Planar RGBA, RGB32 and RGB64


ComponentCount not existing, it give me "There is no function named 'ComponentCount'"

and it will be more easy if we have "HasAlpha()"

LigH
28th December 2016, 00:06
No reason for a full quote. :)

ajp_anton
28th December 2016, 00:09
Found this weird problem...

http://ajpanton.se/avsbug/source.mkv (~4.2MB)

Script:
ffms2("source.mkv")

vectors = msuper().manalyse(isb = false)
mdata = mdepan(vectors, zoom=true, rot=true)
depanstabilize(data=mdata, dxmax=100, dymax=100, rotmax=2.0, mirror=15)

Using the old 1.13 version of DePan and Avisynth+ r2347 (and pinterf's latest mvtools). I can test with "vanilla" Avisynth tomorrow, as I'm again posting when I should go to sleep...

VirtualDub (FilterMod) handles this fine, the video is smooth. Laptop isn't fast enough for realtime playback, but I can encode it using VD into a smooth video. However, opening the .avs file in both x264 (cli) and avs2pipemod somehow result in really jerky video.

pinterf
28th December 2016, 13:35
ComponentCount not existing, it give me "There is no function named 'ComponentCount'"

and it will be more easy if we have "HasAlpha()"
Indeed. And it should be named the same as in the VideoInfo: NumComponents.

So I created a HasAlpha, NumComponents and IsPackedRGB script functions (no build yet).

ajp_anton
30th December 2016, 15:36
Feature requests:
1. Function "Info": Add a second clip as an optional argument. Write the info of the first clip onto the second clip (or vice versa, whichever is better/easier/more logical).
2. Function "Default": If the variable in the first argument is defined, don't try to evaluate the second argument. I have a function that has arguments for width, height and aspect ratio, but only two are needed. In Default(w,h*ar) I get an unnecessary error if either "h" or "ar" is the only one being left undefined.
3. The ability to add comments at the end of a line that continues on the next line using \.

StainlessS
31st December 2016, 08:27
2. Function "Default": If the variable in the first argument is defined, don't try to evaluate the second argument. I have a function that has arguments for width, height and aspect ratio, but only two are needed. In Default(w,h*ar) I get an unnecessary error if either "h" or "ar" is the only one being left undefined.


Default() must be a function, moving into the Parser as you suggest would likely result in a lot of work for printerf, and for no real reason, you can easily get around that (EDIT: rare) 'problem' yourself.

EDIT: Also, (1) whats wrong with y=x.info() ?

No problem with (3) [EDIT: I quite like the idea].

LigH
31st December 2016, 13:32
1. is probably asking for a chance to overlay the Info() details over a blank clip, for better readability. Well ... BlankClip(reference_clip) could be a base with mostly identical attributes, to display Info text onto. Except for the case that the clip has too small dimensions for the Info text to render completely; in that case it may indeed need a larger area than the original clip.

Sm3n
31st December 2016, 13:50
Hi,

I'm looking for a script capable to change the color of a harcoded subtitle. Here is a sample: https://framadrop.org/r/znJhfsO4lW#RLppqRZQ6Fk75G1JaNFT4WguyQN+syTNXzdQlpmmqi8=

I found something similar on videohelp: http://forum.videohelp.com/threads/364577-AviSynth-Color-exchange
So I tweaked a bit but I can't properly change the grey subtitles into white. And there is lot of artefact created on the picture and/or around the outline sub.

My script:

mask=MaskHS(30,30, 20,5).mt_expand().BilinearResize(last.width, last.height)
overlay(last, GreyScale().ColorYUV(cont_y=100), 0, 0, mask)

cheers

qyot27
31st December 2016, 18:16
Except for the case that the clip has too small dimensions for the Info text to render completely; in that case it may indeed need a larger area than the original clip.
That's no longer an issue, technically; you can choose font and text size for Info() now (https://github.com/AviSynth/AviSynthPlus/pull/101/commits/b09bc11ad347aaebe592a848f3d3ea19d7c68430).

(Although it was actually proposed because the default size made the output unreadable when dealing with 4K) (https://github.com/AviSynth/AviSynthPlus/issues/99)

ajp_anton
31st December 2016, 18:19
Default() must be a function, moving into the Parser as you suggest would likely result in a lot of work for printerf, and for no real reason, you can easily get around that (EDIT: rare) 'problem' yourself.Well, (2) isn't that important, I'm just using a simple "if" (? and :) to get around it. Took a while to be desperate enough to try it though, because I though that's basically how Default did it and it wasn't working there.

1. is probably asking for a chance to overlay the Info() details over a blank clip, for better readability. Well ... BlankClip(reference_clip) could be a base with mostly identical attributes, to display Info text onto. Except for the case that the clip has too small dimensions for the Info text to render completely; in that case it may indeed need a larger area than the original clip.Yes, I was thinking of the dimensions. Sure, can get around it by resizing, assuming that the clip dimension is not what you're interested in.

No problem with (3) [EDIT: I quite like the idea].Not sure what idea you quite like, because I just noticed that the forum messed up my (3) =). Apparently you can't put a \ between "". I now edited my previous post.
Basically, what I meant is that you could write
a = somefunction(argument1 #comment for arg1
\, argument2) #another commentor
a = somefunction(argument1,\ #comment for arg1
argument2) #another comment

StainlessS
31st December 2016, 18:40
Not sure what idea you quite like, because I just noticed that the forum messed up my (3) =). Apparently you can't put a \ between "". I now edited my previous post.
Basically, what I meant is that you could write
a = somefunction(argument1,\ #comment for arg1
argument2) #another comment

That is what I took you to mean :)

raffriff42
31st December 2016, 19:39
>1. Function "Info": Add a second clip as an optional argument.
## show information on clip 'C' over base clip 'B'
function Info(clip B, clip C)
{
return B.Overlay(
\ C.Levels(0, 1, 0, 0, 0) [* make black BG *]
\ .Info [* show info *]
\ .Crop(0, 0, 384, 240), [* crop to size *]
\ opacity=1.0 [* overlay *]
\ )
}

Can't support an optional second clip as this collides with built-in Info(clip C).

>3. The ability to add comments at the end of a line that continues on the next line
See above :)

ajp_anton
31st December 2016, 23:24
>1. Function "Info": Add a second clip as an optional argument.
## show information on clip 'C' over base clip 'B'
function Info(clip B, clip C)
{
return B.Overlay(
\ C.Levels(0, 1, 0, 0, 0) [* make black BG *]
\ .Info [* show info *]
\ .Crop(0, 0, 384, 240), [* crop to size *]
\ opacity=1.0 [* overlay *]
\ )
}

Can't support an optional second clip as this collides with built-in Info(clip C).

>3. The ability to add comments at the end of a line that continues on the next line
See above :)Nope, "you cannot use crop to enlarge or 'shift' a clip".
And the "CPU detected" line goes on even further than that 384, so an even bigger area is needed. I know, totally not important, but it looks ugly. Not to mention that the whole black rectangle is really ugly. So not really a "nice" solution.

Didn't know you could comment like that. Though I still prefer # because it's easier to keep track of.

StainlessS
1st January 2017, 00:00
from Docs

Avisynth ignores anything from a # character to the end of that line. This can be used to add comments to a script.

# comment

In v2.58 it is possible to add block and nested block comments in the following way:


# block comment:
/*
comment 1
comment 2
*/



# nested block comments:
[* [* a meaningful example will follow later :) *] *]

Avisynth ignores anything from an __END__ keyword (with double underscores) to the end of the script file. This can be used to disable some last commands of script.


Version()
__END__
ReduceBy2()
Result is not reduced and we can write any text here



Seems that we are still awaiting a meaningful example, since v2.58.

But below produces "Parse Error: orphan block comment closing */". [The 1st */ ends the comment]

/* /* something */ */

whereas

[* [* something *] *]

does not.

EDIT: (1) Perhaps new function InfoText() or Info_Text() would be easy to implement (as for Subtitle, with '\n').

jpsdr
1st January 2017, 14:33
Is there a way with the CPU flags to detect FMA4 ? I've seen there's allready FMA3, but didn't seen FMA4.

Foja
1st January 2017, 14:44
Hello,

since long time I am a silent reader in this discussion. I am using the plug-in RemoveDirt in the 8-bit version of avisynth for many years. I am very satisfied with this plug-in.
Now I am starting to use avisynth+ for my cleaning script, all plugins which i normaly use in the 8-bit version are already available exept "RemoveDirt".
RemoveDirt is for me a important plugin which I don't want to miss in my cleaning script for avisynth+.

Is there the plan to convert the plugin "RemoveDirt" to the new version avisynth+?

Thanks for the great work and for providing such a powerful software. :thanks:

Best wishes from Germany and a Happy New Year!

LigH
1st January 2017, 19:07
Hi, thanks, and same to you, from Germany as well.

In the AviSynth Wiki for RemoveDirt (http://avisynth.nl/index.php/RemoveDirt) I read that it "has now become a script function which involves RestoreMotionBlocks and various filters from the RemoveGrain (http://avisynth.nl/index.php/RemoveGrain) package." And if you substitute them with RgTools (http://avisynth.nl/index.php/RgTools), I guess it should be possible to run it with equivalent results and better speed in AviSynth+ ... so much guesswork from me; but other members may know it better.

pinterf
1st January 2017, 19:22
I didn't include fma4 in CPU flags. But it seems I will have to.

Foja
2nd January 2017, 17:05
Hi, thanks, and same to you, from Germany as well.

In the AviSynth Wiki for RemoveDirt (http://avisynth.nl/index.php/RemoveDirt) I read that it "has now become a script function which involves RestoreMotionBlocks and various filters from the RemoveGrain (http://avisynth.nl/index.php/RemoveGrain) package." And if you substitute them with RgTools (http://avisynth.nl/index.php/RgTools), I guess it should be possible to run it with equivalent results and better speed in AviSynth+ ... so much guesswork from me; but other members may know it better.

Thanks for your reply. Unfortunately, the "RestoreMotionBlocks" function is part of RemoveDirt and not the RemovGrain or RgTools package. Although there is an x64 version (RemoveDirt v1.0 pre-release x64), but this is not running under Avisynth +. The error message "System exeption - Access Violation" are shown.
I guess for the support of a bit depth of 10 - 16 bit, RemoveDirt is likely to be completely revised??!

Best wishes!

feisty2
2nd January 2017, 17:11
Thanks for your reply. Unfortunately, the "RestoreMotionBlocks" function is part of RemoveDirt and not the RemovGrain or RgTools package. Although there is an x64 version (RemoveDirt v1.0 pre-release x64), but this is not running under Avisynth +. The error message "System exeption - Access Violation" are shown.
I guess for the support of a bit depth of 10 - 16 bit, RemoveDirt is likely to be completely revised??!

Best wishes!

takes ~10min to make it work on higher bit depth integer samples, just reinterpret_cast all uint8_t * to uint16_t * and append "/ sizeof(uint16_t)" after all stride variables and you're done, do it yourself

LigH
2nd January 2017, 19:17
takes ~10min to make it work on higher bit depth integer samples, just reinterpret_cast all uint8_t * to uint16_t * and append "/ sizeof(uint16_t)" after all stride variables and you're done, do it yourself

What kind of programmer do I have to be to understand these instructions? And which kind of compiler do I have to know to use?

videoh
2nd January 2017, 21:51
C or C++. It's very basic. As they say, google is your friend.

Reel.Deel
3rd January 2017, 02:44
takes ~10min to make it work on higher bit depth integer samples, just reinterpret_cast all uint8_t * to uint16_t * and append "/ sizeof(uint16_t)" after all stride variables and you're done, do it yourself

~10 min? I call BS on that. Have you even looked at the source code? I'm no programmer but I've heard other knowledgeable people describe Kasandro's code as pure spaghetti. If it was so easy why was it not done here: https://github.com/handaimaoh/removedirtvs

Edit:
Thanks for your reply. Unfortunately, the "RestoreMotionBlocks" function is part of RemoveDirt and not the RemovGrain or RgTools package. Although there is an x64 version (RemoveDirt v1.0 pre-release x64), but this is not running under Avisynth +. The error message "System exeption - Access Violation" are shown.


The RemoveDirt script also uses SCSelect fucntion from the RemoveDirt plugin. Regarding the x64 version on the wiki, there's a note on there that says it's incompatible with AviSynth.

For the mean time you can use a similar workaround as described here: http://forum.doom9.org/showthread.php?p=1599783#post1599783


o16 = last #Stack16 video

o = DitherPost(mode=-1)
o.RemoveDirt(...)

dif = mt_makediff(last, o, y=3, u=3, v=3)
dif16 = dif.Dither_convert_8_to_16()
o16.Dither_add16(dif16, dif=true)

feisty2
3rd January 2017, 04:14
~10 min? I call BS on that. Have you even looked at the source code? I'm no programmer but I've heard other knowledgeable people describe Kasandro's code as pure spaghetti.


Lol ur full of crap, it doesn't matter how messed up the code is cuz ur not rewriting the whole plugin, simply modifying it a tiny little bit.

If it was so easy why was it not done here: https://github.com/handaimaoh/removedirtvs
Because unlike c and c++ which are easy to modify, assembly is an evil bitch

tuanden0
3rd January 2017, 08:18
I'm using filter MCTemporalDenoise.avsi (http://forum.doom9.org/showthread.php?t=139766)
Can everyone tell me what is the MT mode of this?

tormento
4th January 2017, 11:07
I'm using filter MCTemporalDenoise.avsi (http://forum.doom9.org/showthread.php?t=139766)
Can everyone tell me what is the MT mode of this?

I warmly suggest you to use SMDegrain.

pinterf
4th January 2017, 20:24
Happy New Year!

After having spent many days with understanding how multithreading works with runtime scripts I felt myself so miserable and tired that I had to abandon that investigation a bit. I have searched for an area with more success factor instead.

New dev build:
Download Avisynth Plus r2359 (http://www.mediafire.com/file/r6s3xs6eert41n9/avsplus-r2359.7z)

Changes since r2347:

Avisynth plus r2359dev (20170104)

Overlay:
new parameter: bool use444 (default true for compatibility/until under construction, etc...)

Parameter is valid only for "blend" at the moment
When set to false, and base clip/overlay clip is 420/422/Planar RGB, no conversion occurs to and back from YV24 (4:4:4 in general)

Mask can be either greyscale or can be any planar YUV when greymask=true (default)

Works for Planar RGB, so blending is basically lossless for this format (no YUV conversion)
todo: support for other modes, convert packed RGB to planar RGB internally instead of YUV
Overlay:
Add fast 4:2:0<->4:4:4 conversion, e.g. YV16<->YV24 (only fast YUY2 and YV12 existed so far)
instead of invoking generic core conversion
Overlay:
10-16bit SSE2/SSE4 for 420/422<->444 conversions
Info() made a bit more compact.
Bit depth info moved after color space info
Does not display pre-SSE2 CPU flags when at least AVX is available.
AVX512 flags in separate line (would be too long)
new CPU feature constants (see cpuid.h and avisynth_c.h)
Detect FMA4 and AVX512F,DQ,PF,ER,CD,BW,VL,IFMA,VBMI
new script function:
string ReplaceStr(string s, string pattern, string replacement)
Function is case sensitive, parameters are unnamed
new script function
int NumComponents(clip)
returns 1 for grayscale, 3 for YUVxxx, YUY2, planar RGB or RGB24/RGB48, 4 for YUVAxxx, Planar RGBA or RGB32/64
new script function:
bool HasAlpha(clip)
returns true when clip is YUVA, Planar RGBA, or packed RGB32 or RGB64

real.finder
4th January 2017, 21:03
Happy New Year!

After having spent many days with understanding how multithreading works with runtime scripts I felt myself so miserable and tired that I had to abandon that investigation a bit. I have searched for an area with more success factor instead.

New dev build:
Download Avisynth Plus r2359 (http://www.mediafire.com/file/r6s3xs6eert41n9/avsplus-r2359.7z)


Happy New Year and :thanks:

what about make AddAlphaPlane accept clip too?

pinterf
4th January 2017, 21:23
It was planned then forgotten :)

ryrynz
4th January 2017, 22:22
:thanks:


Could you please avoid quoting entire posts when there's no reason to? Also your post is directly after pinterf's post which makes it even worse.

Thanks for the new build pinterf!

Wilbert
4th January 2017, 23:28
new script function:
bool IsPackedRGB(clip)
returns true when clip is RGB24/32/48/64
This function is redundant. Please use IsInterleaved(clip) and IsRGB(clip) instead. (There is no IsPackedYUV(clip) either.)

and similarly IsPlanar(clip) and IsRGB(clip) / IsYUV(clip).

-----

With respect to this post: http://forum.doom9.org/showthread.php?p=1791946#post1791946

I think it would be great if (at least) the formats RGB64, YUV422P10 and YUV422P16 would be exposed through the VfW interface. Then we can open such scripts in Virtualdub and encode straight to MagicYUV (without any color conversion).

pinterf
6th January 2017, 12:47
This function is redundant. Please use IsInterleaved(clip) and IsRGB(clip) instead. (There is no IsPackedYUV(clip) either.)

and similarly IsPlanar(clip) and IsRGB(clip) / IsYUV(clip).

I think you are right, IsYUV does not follow this logic, as it applies to YUY2, too.


With respect to this post: http://forum.doom9.org/showthread.php?p=1791946#post1791946

I think it would be great if (at least) the formats RGB64, YUV422P10 and YUV422P16 would be exposed through the VfW interface. Then we can open such scripts in Virtualdub and encode straight to MagicYUV (without any color conversion).
BGR[48] and BRA[64] is already available, ignus2 has done it
https://github.com/pinterf/AviSynthPlus/commit/e10dcb8f640b2a1562dff75af3c6ee125243c82c

shekh
6th January 2017, 14:10
BGR[48] and BRA[64] is already available, ignus2 has done it
https://github.com/pinterf/AviSynthPlus/commit/e10dcb8f640b2a1562dff75af3c6ee125243c82c

But is this patch for source (not for output)?

gaak
6th January 2017, 14:23
Hello all,

When trying to encode a clip I get the following error:

avs [info]: AviSynth+ 0.1 (r2359, MT, i386)
avs [info]: Video colorspace: YV12
avs [info]: Video resolution: 988x720
avs [info]: Video framerate: 24000/1001
avs [info]: Video framecount: 121878
avs4x26x [info]: "C:\MKVideo Encoder\EXEs\x264_x64.exe" - --preset medium --tune
film --crf 18 --profile high --level 4.1 --open-gop --quiet --threads 0 --threa
d-input -o Output_Video_File.h264 --frames 121878 --fps 24000/1001 --input-res
988x720 --input-csp i420
avs [error]: Filter Error: Filter attempted to break alignment of VideoFrame. occurred while reading frame 0

I've tried earlier builds, only r1858 works for me.

The script follows:

SetFilterMTMode("DEFAULT_MT_MODE", 2)
SetFilterMTMode("DGDecodeNV", 3)
LoadPlugin("C:\MKVideo Encoder\FFMS2\ffms2.dll")
Import("C:\MKVideo Encoder\AVS Scripts\LoadPlugins.avs")
FFVideoSource(source = "C:\MKVideo Files\Input_Video_File.mkv")
Spline144Resize(1280, 720)
RoboCrop(Laced=False)
LSFmod(defaults="slow", preblur="DeGrainMedian(limitY=4, limitUV=6, mode=1, interlaced=false)")
Prefetch(3)

Thanks for any help.

pinterf
6th January 2017, 14:36
But is this patch for source (not for output)?
Yes. Avisource and DirectShowSource.

BakaProxy
6th January 2017, 14:36
Hello all,

When trying to encode a clip I get the following error:

avs [info]: AviSynth+ 0.1 (r2359, MT, i386)
avs [info]: Video colorspace: YV12
avs [info]: Video resolution: 988x720
avs [info]: Video framerate: 24000/1001
avs [info]: Video framecount: 121878
avs4x26x [info]: "C:\MKVideo Encoder\EXEs\x264_x64.exe" - --preset medium --tune
film --crf 18 --profile high --level 4.1 --open-gop --quiet --threads 0 --threa
d-input -o Output_Video_File.h264 --frames 121878 --fps 24000/1001 --input-res
988x720 --input-csp i420
avs [error]: Filter Error: Filter attempted to break alignment of VideoFrame. occurred while reading frame 0

I've tried earlier builds, only r1858 works for me.

The script follows:

SetFilterMTMode("DEFAULT_MT_MODE", 2)
SetFilterMTMode("DGDecodeNV", 3)
LoadPlugin("C:\MKVideo Encoder\FFMS2\ffms2.dll")
Import("C:\MKVideo Encoder\AVS Scripts\LoadPlugins.avs")
FFVideoSource(source = "C:\MKVideo Files\Input_Video_File.mkv")
Spline144Resize(1280, 720)
RoboCrop(Laced=False)
LSFmod(defaults="slow", preblur="DeGrainMedian(limitY=4, limitUV=6, mode=1, interlaced=false)")
Prefetch(3)

Thanks for any help.
First off try without MT before you start complaining online.

Verstuurd vanaf mijn SM-A500FU met Tapatalk

pinterf
6th January 2017, 14:57
avs [error]: Filter Error: Filter attempted to break alignment of VideoFrame. occurred while reading frame 0

I've tried earlier builds, only r1858 works for me.

The script follows:

SetFilterMTMode("DEFAULT_MT_MODE", 2)
SetFilterMTMode("DGDecodeNV", 3)
LoadPlugin("C:\MKVideo Encoder\FFMS2\ffms2.dll")
Import("C:\MKVideo Encoder\AVS Scripts\LoadPlugins.avs")
FFVideoSource(source = "C:\MKVideo Files\Input_Video_File.mkv")
Spline144Resize(1280, 720)
RoboCrop(Laced=False)
LSFmod(defaults="slow", preblur="DeGrainMedian(limitY=4, limitUV=6, mode=1, interlaced=false)")
Prefetch(3)
One of the filters used SubFrame or SubframePlanar and specified plane offsets and/or pitches that are incompatible with recent versions of Avisynth+. This prevention was introduced because Avisynth+ core and filters in general assume proper alignment for processing the frame. Avisynth plus' default alignment is 32 bytes. One of the filter is using the subframe function with frame properties that are aligned for less than 32 bytes.

I suspect the RoboCrop function in the script, try to use it with align=true

Internally Avisynth+'s Crop is alignment-safe. It checks whether alignment is o.k. for the fast SubFrame. If not, it creates a new frame instead (guaranteed to have proper alignment) and copies the cropped area there.

MysteryX
6th January 2017, 16:08
Hey folks, I haven't been around for a while (been busy with other things), and I'm glad the development has progressed.

Converting my auto-generated scripts to native 16-bit is something I'd like to do (and adapting AviSynthShader to support conversion to/from native 16-bit), but where I have hesitation is in compromising quality in doing so. Is there now a way of performing these 2 operations without DitherTools?
- Dithering with Floyd-Steinberg
- Resizing with NoRinging (Dither_resize16nr)

Actually, as I'm writing this, I'm remembering that NoRinging resize is simply a script-based wrapper around the standard resizer so it probably can be used just the same (would have to try to confirm). Still that leaves dithering which requires custom coding.

Have I missed any other major update that either impact quality of performance since I last interacted here, or was it mostly new features?

Motenai Yoda
6th January 2017, 16:55
dithering is possible with convertto8bits or convertbits, but IIRC there is only dither or not dither (truncate, round?)

as you can see from the wrapper function nr resize it's just a repair between the chosen one and gauss
Function Dither_resize16nr (clip src, int width, int height,
\ float "src_left",
\ float "src_top",
\ float "src_width",
\ float "src_height",
\ string "kernel",
\ float "fh",
\ float "fv",
\ int "taps",
\ float "a1",
\ float "a2",
\ float "a3",
\ int "kovrspl",
\ bool "cnorm",
\ bool "center",
\ string "cplace",
\ int "y",
\ int "u",
\ int "v",
\ string "kernelh",
\ string "kernelv",
\ float "totalh",
\ float "totalv",
\ bool "invks",
\ bool "invksh",
\ bool "invksv",
\ int "invkstaps",
\ string "cplaces",
\ string "cplaced",
\ string "csp",
\ bool "noring")
{
noring = Default (noring, true)

Assert (width > 0 && height > 0, "Dither_resize16nr: width and height must be > 0.")

sr_h = Float (width ) / Float (src.width () )
sr_v = Float (height) / Float (src.height ())
sr_up = Dither_max (sr_h, sr_v)
sr_dw = 1.0 / Dither_min (sr_h, sr_v)
sr = Dither_max (sr_up, sr_dw)
Assert (sr >= 1.0)

# Depending on the scale ratio, we may blend or totally disable
# the ringing cancellation
thr = 2.5
nrb = (sr > thr)
nrf = (sr < thr + 1.0 && noring)
nrr = (nrb) ? Dither_min (sr - thr, 1.0) : 1.0
nrv = (nrb) ? Round ((1.0 - nrr) * 255) * $010101 : 0

main = src.Dither_resize16 (width, height,
\ src_left =src_left,
\ src_top =src_top,
\ src_width =src_width,
\ src_height=src_height,
\ kernel =kernel,
\ fh =fh,
\ fv =fv,
\ taps =taps,
\ a1 =a1,
\ a2 =a2,
\ a3 =a3,
\ kovrspl =kovrspl,
\ cnorm =cnorm,
\ center =center,
\ cplace =cplace,
\ y =y,
\ u =u,
\ v =v,
\ kernelh =kernelh,
\ kernelv =kernelv,
\ totalh =totalh,
\ totalv =totalv,
\ invks =invks,
\ invksh =invksh,
\ invksv =invksv,
\ invkstaps =invkstaps,
\ cplaces =cplaces,
\ cplaced =cplaced,
\ csp =csp
\ )

nrng = (nrf) ? src.Dither_resize16 (width, height,
\ src_left =src_left,
\ src_top =src_top,
\ src_width =src_width,
\ src_height=src_height,
\ kernel ="gauss",
\ a1 =100,
\ center =center,
\ cplace =cplace,
\ cplaces =cplaces,
\ cplaced =cplaced,
\ csp =csp,
\ y =y,
\ u =u,
\ v =v
\ ) : main

nrm = (nrb && nrf) ? main.BlankClip (color_yuv=nrv, height=main.Height()/2) : main

# To do: use a simple frame blending instead of Dither_merge16
rgm = 1
rgc = (nrb) ? -1 : 0
rgy = Defined (y) ? ((y == 3) ? rgm : rgc) : rgm
rgu = Defined (u) ? ((u == 3) ? rgm : rgc) : rgm
rgv = Defined (v) ? ((v == 3) ? rgm : rgc) : rgm
rguv = Dither_max (rgu, rgv)
(nrf ) ? main.Dither_repair16 (nrng, rgy, rguv) : main
(nrf && nrb) ? Dither_merge16_8 (main, last, nrm, y=y, u=u, v=v) : last
}Function Dither_resize16nr (clip src, int width, int height,
\ float "src_left",
\ float "src_top",
\ float "src_width",
\ float "src_height",
\ string "kernel",
\ float "fh",
\ float "fv",
\ int "taps",
\ float "a1",
\ float "a2",
\ float "a3",
\ int "kovrspl",
\ bool "cnorm",
\ bool "center",
\ string "cplace",
\ int "y",
\ int "u",
\ int "v",
\ string "kernelh",
\ string "kernelv",
\ float "totalh",
\ float "totalv",
\ bool "invks",
\ bool "invksh",
\ bool "invksv",
\ int "invkstaps",
\ string "cplaces",
\ string "cplaced",
\ string "csp",
\ bool "noring")
{
noring = Default (noring, true)

Assert (width > 0 && height > 0, "Dither_resize16nr: width and height must be > 0.")

sr_h = Float (width ) / Float (src.width () )
sr_v = Float (height) / Float (src.height ())
sr_up = Dither_max (sr_h, sr_v)
sr_dw = 1.0 / Dither_min (sr_h, sr_v)
sr = Dither_max (sr_up, sr_dw)
Assert (sr >= 1.0)

# Depending on the scale ratio, we may blend or totally disable
# the ringing cancellation
thr = 2.5
nrb = (sr > thr)
nrf = (sr < thr + 1.0 && noring)
nrr = (nrb) ? Dither_min (sr - thr, 1.0) : 1.0
nrv = (nrb) ? Round ((1.0 - nrr) * 255) * $010101 : 0

main = src.Dither_resize16 (width, height,
\ src_left =src_left,
\ src_top =src_top,
\ src_width =src_width,
\ src_height=src_height,
\ kernel =kernel,
\ fh =fh,
\ fv =fv,
\ taps =taps,
\ a1 =a1,
\ a2 =a2,
\ a3 =a3,
\ kovrspl =kovrspl,
\ cnorm =cnorm,
\ center =center,
\ cplace =cplace,
\ y =y,
\ u =u,
\ v =v,
\ kernelh =kernelh,
\ kernelv =kernelv,
\ totalh =totalh,
\ totalv =totalv,
\ invks =invks,
\ invksh =invksh,
\ invksv =invksv,
\ invkstaps =invkstaps,
\ cplaces =cplaces,
\ cplaced =cplaced,
\ csp =csp
\ )

nrng = (nrf) ? src.Dither_resize16 (width, height,
\ src_left =src_left,
\ src_top =src_top,
\ src_width =src_width,
\ src_height=src_height,
\ kernel ="gauss",
\ a1 =100,
\ center =center,
\ cplace =cplace,
\ cplaces =cplaces,
\ cplaced =cplaced,
\ csp =csp,
\ y =y,
\ u =u,
\ v =v
\ ) : main

nrm = (nrb && nrf) ? main.BlankClip (color_yuv=nrv, height=main.Height()/2) : main

# To do: use a simple frame blending instead of Dither_merge16
rgm = 1
rgc = (nrb) ? -1 : 0
rgy = Defined (y) ? ((y == 3) ? rgm : rgc) : rgm
rgu = Defined (u) ? ((u == 3) ? rgm : rgc) : rgm
rgv = Defined (v) ? ((v == 3) ? rgm : rgc) : rgm
rguv = Dither_max (rgu, rgv)
(nrf ) ? main.Dither_repair16 (nrng, rgy, rguv) : main
(nrf && nrb) ? Dither_merge16_8 (main, last, nrm, y=y, u=u, v=v) : last
}
as rgtools and merge(luma/chroma) now works in 16bit it can be adapted

MysteryX
6th January 2017, 17:16
as rgtools and merge(luma/chroma) now works in 16bit it can be adapted
If someone wants to do that adaptation, it would then work for both 8-bit and 16-bit with the same code.

real.finder
6th January 2017, 18:00
Hello,

since long time I am a silent reader in this discussion. I am using the plug-in RemoveDirt in the 8-bit version of avisynth for many years. I am very satisfied with this plug-in.
Now I am starting to use avisynth+ for my cleaning script, all plugins which i normaly use in the 8-bit version are already available exept "RemoveDirt".
RemoveDirt is for me a important plugin which I don't want to miss in my cleaning script for avisynth+.

Is there the plan to convert the plugin "RemoveDirt" to the new version avisynth+?


yes its important for many

and if someone add it to rgtools I wish that he/she add the others mode of RemoveGrain too (more than 24) as there are some scripts use them, and there are RemoveGrainHD and RemoveGrainT too

gaak
6th January 2017, 18:11
I suspect the RoboCrop function in the script, try to use it with align=true

@pinterf Thank you very much for the answer, that worked!

ajp_anton
6th January 2017, 21:27
I'd also like to be able to do linear-light resizing in 16-bit. Dither tools has "Dither_y_gamma_to_linear" and "Dither_y_linear_to_gamma". But for these to work you need to convert to and from stacked as well. And also use "dither_resize16" unless you really want to go to and from stacked a lot of times.

Is there another way to convert between linear and gamma light? mt_lut could do it if it worked in 16 bits.

Wilbert
7th January 2017, 00:30
Yes. Avisource and DirectShowSource.
Was asking about the output. Apperantly the code is in main.cpp (*), but i don't know that part well enough to tell what and how it should be updated.

(*) see CAVIStreamSynth::Info, CAVIFileSynth::ImageSize, CAVIStreamSynth::ReadFrame and CAVIStreamSynth::ReadFormat.

StainlessS
8th January 2017, 14:59
One of the filters used SubFrame or SubframePlanar and specified plane offsets and/or pitches that are incompatible with Avisynth.

Pinterf, you really should use the term Avisynth+ or similar when talking about such, RoboCrop is totally compatible with Avisynth, it's Avs+ where
the problem arises.

Also might be related:- I wrote a plugin a few weeks/months ago with optional clip which produced some kind of access Violation when NULL clip,
(with avs+ I think), I suspect that the code that causes/detects above SubFrame error in avs+ was accessing the NULL clip at some point and causing the
access violation, (I'm not sure about that being the cause, but if internal avs+ is gonna mess with clips it should make sure not to mess with optional
NULL ones, I think that problem only appeared in avs+ and not avs standard, but am not completely sure).

Also, can you tell me how to reliably detect Avs+ in most recent versions (at least), without basing it on Version or VersionString, I'll have a go at doing modified RoboCrop behaviour only for avs+ and the default avs+ cropping alignment of 32.

Thanx very much :)

Groucho2004
8th January 2017, 16:29
Also, can you tell me how to reliably detect Avs+ in most recent versions (at least), without basing it on Version or VersionString, I'll have a go at doing modified RoboCrop behaviour only for avs+ and the default avs+ cropping alignment of 32.
See here (https://forum.doom9.org/showthread.php?p=1776891#post1776891). As for newer builds, just test for newly introduced functions.

StainlessS
8th January 2017, 17:00
Thanx G2K4, think i'll use "AddAutoloadDir()".

Any body aware of bulletproof way to call GScript() code in both avs+ and avs standard ?
(GScript does not appear in list of builtin functions in avs+, nor does eg GImport, GEval, for, if, else, etc.)

EDIT: I guess that easiest way is to still use GScript plugin even in avs+.
GScript() really should have been incorporated into avs many moons ago, then we would not have current nonsense.

EDIT: Maybe have to force Eval/GEval into use with some kind of string replace to select plus or standard.

dipje
9th January 2017, 09:55
Isn't it possible and an idea to port fmtconv from vapoursynth to avs+? Would give you all the resizers, kernels, chroma conversion, matrix conversion, gamma space conversion and dithering tools you would I guess.

real.finder
9th January 2017, 11:43
Isn't it possible and an idea to port fmtconv from vapoursynth to avs+? Would give you all the resizers, kernels, chroma conversion, matrix conversion, gamma space conversion and dithering tools you would I guess.

or just update dither tools to read all avs+ features