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 Development

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 28th January 2018, 07:48   #3921  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,537
Image corruption - Regression?

@pinterf

Do you remember this topic about image corruption on pure white and regional settings that you solved?

Well, it happened again.

Yesterday night I was watching an encoded version of Hitman's bodyguard and it showed again, mostly on scene changes. I dunno if it still AviSynth+ fault. Let me grab it again from BD and will provide some raw material to work with and script.
__________________
@turment on Telegram
tormento is offline  
Old 28th January 2018, 07:55   #3922  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
It was a decimal point or comma issue? I don't think we have the same problems here.
pinterf is offline  
Old 28th January 2018, 09:17   #3923  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
@pinterf

Do you remember this topic about image corruption on pure white and regional settings that you solved?

Well, it happened again.

Yesterday night I was watching an encoded version of Hitman's bodyguard and it showed again, mostly on scene changes. I dunno if it still AviSynth+ fault. Let me grab it again from BD and will provide some raw material to work with and script.
what masktools you use?
__________________
See My Avisynth Stuff
real.finder is offline  
Old 28th January 2018, 09:18   #3924  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,537
Quote:
Originally Posted by pinterf View Post
It was a decimal point or comma issue? I don't think we have the same problems here.
Here we go.

OS: Windows 10 ent x64 rs4 17083 italian

Environment:
Code:
VersionString:              AviSynth+ 0.1 (r2580, MT, x86_64)
VersionNumber:              2.60
File / Product version:     0.1.0.0 / 0.1.0.0
Interface Version:          6
Multi-threading support:    Yes
Avisynth.dll location:      C:\WINDOWS\SYSTEM32\avisynth.dll
Avisynth.dll time stamp:    2017-12-27, 19:55:46 (UTC)
PluginDir2_5 (HKLM, x64):   D:\Programmi\Media\AviSynth+\plugins64
PluginDir+   (HKLM, x64):   D:\Programmi\Media\AviSynth+\plugins64+


[CPP 2.5 Plugins (64 Bit)]
D:\Programmi\Media\AviSynth+\plugins64\Dither-1.27.2.dll  [2015-12-30]
D:\Programmi\Media\AviSynth+\plugins64\f3kdb-2.020140721-SAPikachu.dll  [2015-02-19]

[CPP 2.6 Plugins (64 Bit)]
D:\Programmi\Media\AviSynth+\plugins64+\AutoAdjust-2.60.dll  [2.6.0.0]
D:\Programmi\Media\AviSynth+\plugins64+\ConvertStacked.dll  [2016-10-20]
D:\Programmi\Media\AviSynth+\plugins64+\DCTFilter-0.5.0-chikuzen.dll  [0.5.0.0]
D:\Programmi\Media\AviSynth+\plugins64+\DirectShowSource.dll  [2016-10-26]
D:\Programmi\Media\AviSynth+\plugins64+\FFT3dFilter-2.4-pinterf.dll  [2.4.0.0]
D:\Programmi\Media\AviSynth+\plugins64+\ImageSeq.dll  [2016-10-20]
D:\Programmi\Media\AviSynth+\plugins64+\KNLMeansCL-1.1.0.dll  [2017-05-04]
D:\Programmi\Media\AviSynth+\plugins64+\MaskTools-2.2.12-pinterf.dll  [2.2.12.0]
D:\Programmi\Media\AviSynth+\plugins64+\MedianBlur2-0.94-tp7.dll  [2014-02-10]
D:\Programmi\Media\AviSynth+\plugins64+\MVTools-2.7.24-pinterf.dll  [2.7.24.0]
D:\Programmi\Media\AviSynth+\plugins64+\RgTools-0.96-pinterf.dll  [0.96.0.0]
D:\Programmi\Media\AviSynth+\plugins64+\Shibatch.dll  [2016-10-20]
D:\Programmi\Media\AviSynth+\plugins64+\TimeStretch.dll  [2016-10-20]
D:\Programmi\Media\AviSynth+\plugins64+\VDubFilter.dll  [2016-10-20]

[Scripts (AVSI)]
D:\Programmi\Media\AviSynth+\plugins64+\colors_rgb.avsi  [2015-03-21]
D:\Programmi\Media\AviSynth+\plugins64\CompTest.avsi  [2010-09-05]
D:\Programmi\Media\AviSynth+\plugins64\DeHalo_alpha-realfinder.avsi  [2017-02-26]
D:\Programmi\Media\AviSynth+\plugins64\Dither-1.27.2.avsi  [2015-12-30]
D:\Programmi\Media\AviSynth+\plugins64\MT_xxpand_multi.avsi  [2010-09-11]
D:\Programmi\Media\AviSynth+\plugins64\SMDegrain-3.1.2ú94-realfinder.avsi  [2017-11-15]
D:\Programmi\Media\AviSynth+\plugins64\VHSHaloremover.avsi  [2017-02-25]

[Uncategorized files]
D:\Programmi\Media\AviSynth+\plugins64+\AutoAdjust-2.60.txt  [2015-11-15]
D:\Programmi\Media\AviSynth+\plugins64+\AviSynth-new.css  [2016-03-31]
D:\Programmi\Media\AviSynth+\plugins64+\AviSynth.css  [2016-03-31]
D:\Programmi\Media\AviSynth+\plugins64+\colors_rgb.txt  [2015-03-21]
D:\Programmi\Media\AviSynth+\plugins64+\DCTFilter-0.5.0-chikuzen.md  [2016-08-03]
D:\Programmi\Media\AviSynth+\plugins64+\FFT3dFilter-2.4-pinterf.gif  [2005-04-04]
D:\Programmi\Media\AviSynth+\plugins64+\FFT3dFilter-2.4-pinterf.htm  [2017-10-31]
D:\Programmi\Media\AviSynth+\plugins64+\FFT3dFilter-2.4-pinterf.txt  [2017-06-08]
D:\Programmi\Media\AviSynth+\plugins64+\MaskTools-2.0a48.htm  [2010-12-31]
D:\Programmi\Media\AviSynth+\plugins64+\MaskTools-2.2.12-pinterf.md  [2018-01-07]
D:\Programmi\Media\AviSynth+\plugins64+\MedianBlur-0.84.txt  [2004-12-07]
D:\Programmi\Media\AviSynth+\plugins64+\MVTools-2.7.24-pinterf.htm  [2017-12-05]
D:\Programmi\Media\AviSynth+\plugins64+\MVTools-2.7.24-pinterf.md  [2017-12-05]
D:\Programmi\Media\AviSynth+\plugins64+\RgTools-0.96-pinterf.md  [2017-06-09]
D:\Programmi\Media\AviSynth+\plugins64\AviSynth-new.css  [2016-03-31]
D:\Programmi\Media\AviSynth+\plugins64\AviSynth.css  [2016-03-31]
D:\Programmi\Media\AviSynth+\plugins64\Dither-1.27.2.htm  [2015-12-30]
D:\Programmi\Media\AviSynth+\plugins64\f3kdb-2.020140721-SAPikachu.htm  [2015-02-19]
D:\Programmi\Media\AviSynth+\plugins64\SMDegrain-3.1.2ú93-realfinder_avsi  [2017-05-05]
D:\Programmi\Media\AviSynth+\plugins64\SMDegrain-3.1.2d.htm  [2015-07-21]
Script:
PHP Code:
SetMemoryMax(8000)
SetFilterMTMode("DEFAULT_MT_MODE"2)
SetFilterMTMode("ChangeFPS"3)

SetFilterMTMode("DGSource"3)
LoadPlugin("D:\eseguibili\media\DGDecNV\x64\DGDecodeNV.dll")
DGSource("E:\in\1_58 Hitman's bodyguard\hitman01.dgi")

ChangeFPS(last,last,true)

SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,truemotion=true,plane=4,chroma=true,lsb=true,mode=0)

Prefetch(6
Hitman's raw.7z
Hitman's enc.7z
Hitman's dgi.7z
Hitman's dgi avs.7z

Enjoy.
__________________
@turment on Telegram

Last edited by tormento; 28th January 2018 at 09:22.
tormento is offline  
Old 28th January 2018, 09:29   #3925  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
I just see hitman01.mkv and hitman02.mkv they not same as old bug, I think they are new bug in mvtools or something, try with older versions of mvtools

edit: after see the others, it's kinda like the old one, try with older masktools too, and then try with tv_range=false if even old masktools not work
__________________
See My Avisynth Stuff

Last edited by real.finder; 28th January 2018 at 09:34.
real.finder is offline  
Old 28th January 2018, 09:43   #3926  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,537
Quote:
Originally Posted by real.finder View Post
I just see hitman01.mkv and hitman02.mkv they not same as old bug, I think they are new bug in mvtools or something, try with older versions of mvtools

edit: after see the others, it's kinda like the old one, try with older masktools too, and then try with tv_range=false if even old masktools not work
Reverting to previous versions of MVTools and MaskTools did not solve, tv_range=false yes.
Something wrong in avisynth again or SMDegrain? Strange 264 input?
Tried also with up to 2 versions of AviSynth back, i.e. up to 2544.
__________________
@turment on Telegram

Last edited by tormento; 28th January 2018 at 09:50.
tormento is offline  
Old 28th January 2018, 10:08   #3927  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
if only tv_range=false solve it then yes the old bug is back, try with many avs+ versions until you get the one that work
__________________
See My Avisynth Stuff
real.finder is offline  
Old 28th January 2018, 10:19   #3928  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,537
Quote:
Originally Posted by real.finder View Post
if only tv_range=false solve it then yes the old bug is back, try with many avs+ versions until you get the one that work
Using too old AviSynth versions throws no ExtractU function. Can't remember since when it was introduced.

We definitely need Pinterf help

EDIT: I have tried every version back to 2420 and got same error. From 2294 and before, I get no ExtractU function and can't test.
__________________
@turment on Telegram

Last edited by tormento; 28th January 2018 at 10:41.
tormento is offline  
Old 28th January 2018, 15:08   #3929  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,373
In all RGB Planar modes, Subtitle colors appear with R and G swapped
Code:
Colorbars
ConvertToPlanarRGBA
tc = $ff00  ## green
Subtitle(Hex(tc), text_color=tc, size=56, align=5)
return ConvertToRGB32 ## for viewing purposes
raffriff42 is offline  
Old 28th January 2018, 17:41   #3930  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Quote:
Originally Posted by raffriff42 View Post
In all RGB Planar modes, Subtitle colors appear with R and G swapped
Thanks, fixed.
pinterf is offline  
Old 28th January 2018, 18:59   #3931  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Quote:
Originally Posted by tormento View Post
Here we go.
OS: Windows 10 ent x64 rs4 17083 italian
Enjoy.
Thanks, almost as enjoyable as the 8th hour in an ultra running race
This one is different though.

In the old (fixed) problem the String(1.04) yielded "1,04" instead of "1.04" in our windows input local. It was fixed to always using decimal _point_ for separator (input local = "C language"), because dither tools' lut interpreter could not recognize constants with commas as decimal separator. Now it's s different problem since I can see only decimal points in the expression.
Since then I was also moving to Win10 and see the problem (I'm testing with another clip): greyish/burnt out parts in fast moving scenes.
pinterf is offline  
Old 28th January 2018, 19:50   #3932  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Quote:
Originally Posted by real.finder View Post
if only tv_range=false solve it then yes the old bug is back, try with many avs+ versions until you get the one that work
The old bug is back, but now it's dither_lut16 is the culprit.
It seems that under Win10 (?) configuration it understands only the decimal separator of the current input local.

Just replace the decimal point to commas in yexpr parameter and it will work fine. (the used ReplaceStr is built-in in AVS+)

Code:
function Dither_Luma_Rebuild (clip src, float "s0", float "c",int "uv", bool "lsb", bool "lsb_in", bool "lsb_out", int "mode", float "ampn", bool "slice"){
[...]
src
lsb ? (lsb_in ? Dither_lut16  (yexpr=ReplaceStr(e,".",","),expr="x 32768 - 32768 * 28672 / 32768 +",y=3, u=uv, v=uv)                 : \
                Dither_lut8   (yexpr=ReplaceStr(e,".",","),expr="x 128 - 32768 * 112 / 32768 +"    ,y=3, u=uv, v=uv))                : \
                avs26 ? mt_lut(yexpr=e,expr="x range_half - range_half * 112 scaleb / range_half +",y=3, u=uv, v=uv) : \
                        mt_lut(yexpr=e,expr="x 128 - 128 * 112 / 128 +"        ,y=3, u=uv, v=uv)

[...]
}
And one more remark. When you want to scale the YUV TV range limits 16-235, 16-240, or their difference (like 112 = (240-16)/2), use scaleb instead of scalef. scaleb correctly converts "official" bit-shifted limits (e.g. 16*4, 235*4: 64-940 for 10 bits), while scalef (Scale _F_ull range) is for stretching a range of 0-255,1023,4095,16383,65535 to another bit-depth's full range of 0..255,1023,4095,16383,65535. So 235 in a 8bit world would become 235*1023/255 = 942 in 10 bits, which is not correct.
pinterf is offline  
Old 29th January 2018, 00:06   #3933  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by pinterf View Post
The old bug is back, but now it's dither_lut16 is the culprit.
It seems that under Win10 (?) configuration it understands only the decimal separator of the current input local.

Just replace the decimal point to commas in yexpr parameter and it will work fine. (the used ReplaceStr is built-in in AVS+)

Code:
function Dither_Luma_Rebuild (clip src, float "s0", float "c",int "uv", bool "lsb", bool "lsb_in", bool "lsb_out", int "mode", float "ampn", bool "slice"){
[...]
src
lsb ? (lsb_in ? Dither_lut16  (yexpr=ReplaceStr(e,".",","),expr="x 32768 - 32768 * 28672 / 32768 +",y=3, u=uv, v=uv)                 : \
                Dither_lut8   (yexpr=ReplaceStr(e,".",","),expr="x 128 - 32768 * 112 / 32768 +"    ,y=3, u=uv, v=uv))                : \
                avs26 ? mt_lut(yexpr=e,expr="x range_half - range_half * 112 scaleb / range_half +",y=3, u=uv, v=uv) : \
                        mt_lut(yexpr=e,expr="x 128 - 128 * 112 / 128 +"        ,y=3, u=uv, v=uv)

[...]
}
And one more remark. When you want to scale the YUV TV range limits 16-235, 16-240, or their difference (like 112 = (240-16)/2), use scaleb instead of scalef. scaleb correctly converts "official" bit-shifted limits (e.g. 16*4, 235*4: 64-940 for 10 bits), while scalef (Scale _F_ull range) is for stretching a range of 0-255,1023,4095,16383,65535 to another bit-depth's full range of 0..255,1023,4095,16383,65535. So 235 in a 8bit world would become 235*1023/255 = 942 in 10 bits, which is not correct.
yes that right, will did next time when do update, in fact I stopped updating scripts waiting for the new changes of bit convert, even if SMDegrain don't need those changes, I will do adding some parameters that come with the next update of masktools to make sure that no one will run it with older masktools and get some wrong outputs like https://forum.doom9.org/showthread.p...70#post1813270
__________________
See My Avisynth Stuff
real.finder is offline  
Old 29th January 2018, 14:01   #3934  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,537
Quote:
Originally Posted by real.finder View Post
I stopped updating scripts waiting for the new changes of bit convert
Could you please release an intermediate version to make things usable now?

I applied the fix proposed from Pinterf and things are working. Dunno if other mods are needed.
__________________
@turment on Telegram

Last edited by tormento; 29th January 2018 at 14:07.
tormento is offline  
Old 29th January 2018, 14:09   #3935  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
Quote:
Originally Posted by tormento View Post
Could you please release an intermediate version to make things usable now?

I applied the fix proposed from Pinterf and things are working. Dunno if other mods are needed.
find and replace what Pinterf edit in his last post then
__________________
See My Avisynth Stuff
real.finder is offline  
Old 2nd February 2018, 15:57   #3936  |  Link
Aktan
Registered User
 
Join Date: Feb 2002
Posts: 303
I find that these two return different Stack16 clips, am I missing something?

Code:
#YV16 Source 8-bit
ConvertBits(bits=32)
ConvertBits(bits=16)
ConvertToStacked()
Code:
#YV16 Source 8-bit
ConvertBits(bits=16)
ConvertBits(bits=32)
ConvertBits(bits=16)
ConvertToStacked()
Aktan is offline  
Old 20th February 2018, 17:53   #3937  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
This would be nice addition to +.

Code:
RT_BitSetCount(int)
 Return an int, the count of the number of set bits (1's) in arg int.
 NOTE, Previous Bit functions are similar to the v2.6 bit manipulation functions, however this one has no equivalent in v2.6
 [perhaps it should, it is quite handy, as used in the ApparentFPS() script prototype)]
BitClrCount easily calc'd from above.

EDIT: Here, S_ApparentFPS(), ApparentFPS prototype script function, would have been difficult/impossibly_slow without RT_BitSetCount.
https://forum.doom9.org/showthread.p...88#post1698788
EDIT: This line, about 80% of the way through the script function.
Code:
            Unique = RT_BitSetCount(BITS0) + RT_BitSetCount(BITS1) + RT_BitSetCount(BITS2) + RT_BitSetCount(BITS3) +
                \ RT_BitSetCount(BITS4) + RT_BitSetCount(BITS5) + RT_BitSetCount(BITS6) + RT_BitSetCount(BITS7)
Above script function limited to 256 frame sample spread, was later increased to 1024 frames for plugin only (@ request of Scharfis_Brain, would maybe be a bit much for the script function, even with BitSetCount).
__________________
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; 20th February 2018 at 21:46.
StainlessS is offline  
Old 21st February 2018, 14:43   #3938  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 2,309
Quote:
Originally Posted by StainlessS View Post
This would be nice addition to +.

Code:
RT_BitSetCount(int)
 Return an int, the count of the number of set bits (1's) in arg int.
 NOTE, Previous Bit functions are similar to the v2.6 bit manipulation functions, however this one has no equivalent in v2.6
 [perhaps it should, it is quite handy, as used in the ApparentFPS() script prototype)]
BitClrCount easily calc'd from above.
This one?
https://stackoverflow.com/questions/...32-bit-integer

RT_xxx collection have quite a few useful function, do you (or others) recommend to cherry-pick some of them, which are worth of integration and futureproof?

Edit:
Code:
  - New script function: int BitSetCount(int[,int, int, ...])
    Function accepts one or more integer parameters
    Returns the number of bits set to 1 in the number or the total number of '1' bits in the supplied integers.

Last edited by pinterf; 21st February 2018 at 15:21. Reason: Implemented
pinterf is offline  
Old 21st February 2018, 20:54   #3939  |  Link
real.finder
Registered User
 
Join Date: Jan 2012
Location: Mesopotamia
Posts: 2,587
since the topic now is runtime, pinterf can you have a look at https://forum.doom9.org/showthread.php?t=175212

and any news about fix the old mt problem with runtime?
__________________
See My Avisynth Stuff
real.finder is offline  
Old 22nd February 2018, 13:42   #3940  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by pinterf View Post
From StackOverflow: (Looks more efficient than my naive effort).
Code:
int numberOfSetBits(int i)
{
     // Java: use >>> instead of >>
     // C or C++: use uint32_t
     i = i - ((i >> 1) & 0x55555555);
     i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
     return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}
From RT_Logic.cpp (my naive effort)
Code:
env->AddFunction("RT_BitSetCount","i",RT_BitSetCount, 0);
AVSValue __cdecl RT_BitSetCount(AVSValue args, void* user_data, IScriptEnvironment* env) {
    unsigned int n      = (unsigned int)args[0].AsInt();
    int cnt=0;
    for(int i=0;i<32;n>>=1,++i)
        if(n&0x01) ++cnt;
    return (int)cnt;
}
I think I recently saw some Intrinsic to count number of set bits, not sure, might have been for 64 bit only.

I dont think avs 2.6 implements Arithmetic Shift Left, just Logical Shift Left, probably not needed but I also
implemented in RT_.

Quote:
Originally Posted by pinterf View Post
Edit:
Code:
  - New script function: int BitSetCount(int[,int, int, ...])
    Function accepts one or more integer parameters
    Returns the number of bits set to 1 in the number or the total number of '1' bits in the supplied integers.
Oh My, I had not even considered multiple args to BitSetCount, very nice

Quote:
Originally Posted by pinterf View Post
This one?
RT_xxx collection have quite a few useful function, do you (or others) recommend to cherry-pick some of them, which are worth of integration and futureproof?
Here, some suggested additions.

From RT_File.cpp
Code:
 env->AddFunction("RT_FileDelete",              "s",RT_FileDelete, 0);

 env->AddFunction("RT_WriteFile",               "ss.*[Append]b",RT_WriteFile, 0);
From RT_Call.cpp, call external command [EDIT: Most often used to delete a file, prior to RT_FileDelete.]
Code:
env->AddFunction("RT_Call",                 "s[Hide]b[Debug]b", RT_Call, 0);

From RT_Debug.cpp [EDIT: In desparate need of this one, probably the singularly most useful function]
Code:
env->AddFunction("RT_DebugF",                   "s.*[name]s[tabsz]i", RT_DebugF, 0);
From RT_Func.cpp,
Code:
# Mod, add width arg.
 env->AddFunction("RT_Hex",                     "i[width]i",RT_Hex, 0);

RT_Hex(int , int "width"=0)
 First arg is an integer to convert to a hexadecimal string.
 Width, (0, 0 -> 8) is the minimum width of the returned string.
  eg RT_Hex(255,4) returns "00FF".

AVSValue __cdecl RT_Hex(AVSValue args, void* user_data, IScriptEnvironment* env) {
    int n       = args[0].AsInt();
    int wid     = args[1].AsInt(0);
    wid=(wid<0) ? 0 : (wid > 8) ? 8 : wid;
    char buf[8+1];
    sprintf(buf,"%0*X",wid,n);
    return  env->SaveString(buf);                       // Get pointer to Avisynth saved string
}

# Mod, add pos arg.
RT_HexValue(String,"pos"=1)
 Returns an int conversion of the supplied hexadecimal string.
 Conversion will cease at the first non legal number base digit, without producing an error
 Fixes HexValue bug in 2.58 & 2.6a3. eg "FFFFFFFF" returns 2147483647 (0x7FFFFFFF) instead of the correct -1 (As most/all calculators)
 Bug is fixed in Avisynth v2.6a4.
 v1.14, Added optional pos arg default=1, start position in string of the HexString, 1 denotes the string beginning. Will return 0
 if error in 'pos' ie if pos is less than 1 or greater than string length.

 env->AddFunction("RT_HexValue",                "s[pos]i",RT_HexValue, 0);

AVSValue RT_HexValue(AVSValue args, void*, IScriptEnvironment* env) {
    const char *str = args[0].AsString();
    int pos = args[1].AsInt(1) - 1;
    int sz=strlen(str);
    if(pos<0 || pos>=sz)
        return 0;
    str+=pos;
    char *stopstring;
    return (int)(strtoul(str,&stopstring,16));
}

# Mod
 env->AddFunction("RT_NumberString",            "i[base]i[width]i",RT_NumberString, 0);

RT_NumberString(int ,int "base"=10, int "width"=0)
 First arg is an integer to convert to a number base/radix string.
 Base, (10, 2 -> 36), is the number base or radix, eg 2 == Binary, 8 == Octal, 10 == Denary/Decimal, 16 == Hexadecimal.
  The default of 10 (decimal) will just convert a number to its decimal string equivalent possibly with a '-' minus sign.
  All number bases with the exception of decimal, will be unsigned form, ie -1 to hexadecimal will produce "FFFFFFFF",
  (the sign is in the digits rather than as separate 'sign and magnitude' used in decimal representation).
  The digits used for the base are, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ". Binary uses first two; decimal, the first 10;
  Hexadecimal the first 16; base 36 all 36 digits.
 Width, (0, 0 -> 32) is the minimum width of the returned string.
  eg RT_NumberString(255,16,4) returns "00FF".
 To convert a Float to a decimal string use Avisynth native "String()" func.

# Mod
 env->AddFunction("RT_NumberValue",             "s[base]i[pos]i",RT_NumberValue, 0);

RT_NumberValue(String,int "base"=10,int "pos"=1)
 Returns an int conversion of the supplied number base string.
 Base, (10, 2 -> 36) is the number base that the string uses.
 To convert a Decimal string to a Float, use Avisynth native "Value()" func.
 Conversion will cease at the first non legal number base digit, without producing an error.
  eg RT_NumberValue("1100",2) returns 12 from the binary string.
 v1.14, Added optional pos arg default=1, start position in string of the number string, 1 denotes the string beginning. Will return 0
 if error in 'pos' ie if pos is less than 1 or greater than string length.

from RT_Odds.cpp
Code:
 env->AddFunction("RT_VarExist",                "s",RT_VarExist, 0);

 env->AddFunction("RT_VarType",                 ".",RT_VarType, 0);

 env->AddFunction("RT_Ord",                     "s[pos]i",RT_Ord, 0);

 env->AddFunction("RT_TimerHP",                 "",RT_TimerHP, 0);

 env->AddFunction("RT_GetSystemEnv",            "s",RT_GetSystemEnv, 0);

 env->AddFunction("RT_GetFileTime",             "si",RT_GetFileTime, 0);

 env->AddFunction("RT_LocalTimeString",         "[file]b",RT_LocalTimeString, 0);
from RT_String.cpp
Code:
 env->AddFunction("RT_StrReplace",              "sss[sig]b",RT_StrReplace, 0);

# Replace multiple strings, not so often used but is very powerful, allows for a sort of macro language where
# strings can replace substrings of already replaced strings.

 env->AddFunction("RT_StrReplaceMulti",         "sss[sig]b",RT_StrReplaceMulti, 0);

 env->AddFunction("RT_StrPad",                  "si[c]s",RT_StrPad, 0);

# Mod,
 env->AddFunction("RT_FindStr",                 "ss[sig]b[pos]i",RT_FindStr, 0);

# Must have. Although take source from RT_Stats v2.0, with bug fix. Or from StrFmt() plugins, also suggest StrFmt as name.
AVSValue __cdecl RT_String(AVSValue args, void* user_data, IScriptEnvironment* env);

 env->AddFunction("RT_String",                  "s.*[esc]i",RT_String, 0);
StrFmt():- https://forum.doom9.org/showthread.p...ghlight=StrFmt
EDIT: StrFmt does not support the Esc arg, probably best omitted as StrFmt does (Esc arg, very demanding on script developer).

from RT_Sundry.cpp
Code:
 env->AddFunction("RT_ColorSpaceXMod",          "c",RT_ColorSpaceXMod, 0);

 env->AddFunction("RT_ColorSpaceYMod",          "c[Laced]b",RT_ColorSpaceYMod, 0);
EDIT: Additional from RT_String.cpp
Code:
 env->AddFunction("RT_TxtAddStr",				"ss+",RT_TxtAddStr, 0);

RT_TxtAddStr(String, String s1, ... , String sn)
 Non-clip function.
 Function to concatenate (join together) 2 or more strings with Chr(10) line separators.
 If the first string is an empty string ("") it will not have a newline [Chr(10)] appended.
 All other strings even empty strings will have a  newline [Chr(10)] inserted after them
 (if they dont already have a trailing newline).
 Any source string containing carriage return Chr(13) will have them converted to Chr(10).
 X = RT_TxtAddStr("A","B","C")    same as X = "A" + Chr(10) + "B" + Chr(10) +"C" + Chr(10)
 X = RT_TxtAddStr("","A","B","C") same as X = "" + "A" + Chr(10) + "B" + Chr(10) + "C" + Chr(10)

 env->AddFunction("RT_TxtQueryLines",			"s",RT_TxtQueryLines, 0);

RT_TxtQueryLines(String)
 Non-clip function.
 String, the multiline string that you require a line count from.
 Returns the number of Newline [Chr(10)] separated lines in a multiline string.
  The last line does not have to be Chr(10) terminated, it still counts. [EDIT: awkward/slow to do in script alone]

 env->AddFunction("RT_TxtGetLine",				"s[Line]i",RT_TxtGetLine, 0);

RT_TxtGetLine(String, Int "Line"=0)
 Non-clip function.
 Extract a single line from a multiline Newline[Chr(10)] separated string. Default=0 == first line.
 The Line index is Zero Relative like frame number versus FrameCount.
 The returned string has trailing Newlines and carriage returns stripped from it.
 Throws an error if your requested line is >= to the number of lines in the multiline string.
EDIT: Above stuff for use where strings can be used as a sort of simple array.
__________________
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; 22nd February 2018 at 14:51.
StainlessS is offline  
Closed Thread

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 05:18.


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