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

Reply
 
Thread Tools Search this Thread Display Modes
Old 26th April 2017, 16:19   #3321  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,095
I think that only runtime is affected. I'd like to see an "elegant" way to solve it, but either this way does not exist (unless we are breaking and rewriting the whole MT internal concepts - which I'm not willing to do ) or have to learn on and do more reverse engineering and experimenting.
pinterf is offline   Reply With Quote
Old 26th April 2017, 16:28   #3322  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,131
Eval doesn't do this, but EvalOop does the exact same "last" reset as ScriptClip.

It leaves room for bugs -- but has anyone encountered a problem with Clip.Eval ?

Which specific circumstance will be affected by that?
MysteryX is offline   Reply With Quote
Old 26th April 2017, 17:01   #3323  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 988
Quote:
Originally Posted by vcmohan View Post
After placing copy of this along with avs folder in my project itself, it started complaining not able to open the files in the avs folder.(#include <avs/config.h>
#include <avs/capi.h>
#include <avs/types.h>) may be <> to be replaced by " in the header file? I gave up trying.
This has been brought up before. The idea was that the directory avs/ resides in should be added to the project path so it's treated as a system directory like the <> denotes. Of course, it's still a problem because it was generally accepted that the proper install path for the headers would be include/avisynth/ when being installed system-wide.

I've long been in favor of changing the references in avisynth[_c].h to the avs/ subdir from <> to "" - it's not like plugins are going to need to rely on stuff in avs/ without also pulling in avisynth[_c].h as well. Or you know, at all, since avisynth[_c].h should be the single point of contact between the AviSynth+ API and the plugin.
qyot27 is offline   Reply With Quote
Old 26th April 2017, 17:17   #3324  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,131
Quote:
Originally Posted by qyot27 View Post
I've long been in favor of changing the references in avisynth[_c].h to the avs/ subdir from <> to ""
I'm not familiar with the background of this issue, but that's what I've been doing.
MysteryX is offline   Reply With Quote
Old 27th April 2017, 05:14   #3325  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,131
FrameRateConverter plays weird in Avisynth+, even without MT. It plays a bunch of frames, pauses, then plays another bunch of frames, then pauses again, etc.

With MT, it stalls at low CPU usage, but first it would be good to debug the issue without MT.
MysteryX is offline   Reply With Quote
Old 27th April 2017, 07:46   #3326  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 730
Quote:
Originally Posted by StainlessS View Post
[CODE]

Just pointing out a few things.

EDIT: What is effect of taking writeptr on non writable src frame ?
Thanks for pointing out. But those variables are used in my subsequent code which I deleted just for checking.
The main culprit is the Frame->GetWritePtr().
I forgot to change this to GetReadPtr after I deleted make writeable which I used earlier. Now it works OK. But wonder how it was working when I was just stepping frame by frame without crashing?
Also problem of compiling under debug and script I pointed out on 14th and 15th April is unresolved.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 27th April 2017, 09:58   #3327  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,095
Quote:
Originally Posted by vcmohan View Post
Also problem of compiling under debug and script I pointed out on 14th and 15th April is unresolved.
This problem, right? https://forum.doom9.org/showthread.p...88#post1803688
Could not reproduce. With and without imagesource.
I'd need to have the same conditiones.
So you are on 2420 x64 MT
- Can it be reproduced w/o ImageSource on your machine (just a BlankClip with similar dimensions and format?)
- Processor architecture (though no AVX2 code is used here)
- Does it happen when encoding to e.g. x264 or when viewing from VirtualDub or AvsPMod?
- Clip is of a single image or multiple frames? (e.g. ImageSource(...).Loop(20))
pinterf is offline   Reply With Quote
Old 27th April 2017, 16:49   #3328  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,131
Quote:
Originally Posted by StainlessS
new req Grunt, but that should be built-in to Avisynth, along with GScript (GScript is builtin in AVS+, already).
I said the same. GRunT should be built-in to Avisynth.

To put in the TODO list.
MysteryX is offline   Reply With Quote
Old 27th April 2017, 16:55   #3329  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,095
I have mentioned it already, and most of it is done. Except setting current_frame into global variable. But until the basic ScriptClip suffers in MT, I won't put it up in git and release.
pinterf is offline   Reply With Quote
Old 27th April 2017, 18:34   #3330  |  Link
MysteryX
Soul Architect
 
MysteryX's Avatar
 
Join Date: Apr 2014
Posts: 2,131
ScriptClip should be working now.

We just have to see whether "last" causes issues, not only with ScriptClip but with Eval and any other run-time expression evaluation.

Is there any other issue with global variables?
MysteryX is offline   Reply With Quote
Old 27th April 2017, 21:59   #3331  |  Link
mariush
Registered User
 
Join Date: Dec 2008
Posts: 568
Not sure if something like this is already implemented or not in AviSynth+ but just saying it anyway.

Would there be any interest in adding "native" support for reading and writing PNG files? Seems like a good idea: they support up to 16 bit per channel, so it could store 8 bit, 10bit, 12bit .. all the way up to 16 bit and also supports grayscale. Yeah, it's only RGB but as far as I know, so is BMP and eBMP right?

If speed is a concern (for ImageWriter) you can simply default to compression = 0 or 1 (just copy or ultra fast zlib compression) and the only added cpu cost would be the calculation of a 32bit checksum.

It would be also possible to use a bunch of custom tags (the png format allows for that) like let's say xACy, xACb , xACr for example for planar formats and YCbCr or whatever Rec.2020 uses if it's different (too lazy to search now) .... and maybe store a default generic small image maybe with some text saying "this is a custom png file which stores the image information in custom chunks readable by Avisynth+ ) and the png format also allows and has text chunks where Avisynth+ could store some encoded data required to understand what it actually stored in the png file ( planar or interleaved, color space, full range/limited range etc)

Could be a good replacement for that non-standard ebmp

ps. Just checking the ImageWriter wiki page ... also noticed something... seems the function defaults to "c:" if the path is not specified. Windows would most likely block writing directly to C:\ by default (to protect itself and file system, perhaps it would be a good idea to use C:\AviSynth or %AviSynth_Install_Folder\Images instead

Don't know how anyone thought the root of a drive to be a good default setting.

Last edited by mariush; 27th April 2017 at 22:10.
mariush is offline   Reply With Quote
Old 28th April 2017, 05:24   #3332  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
RGBAdjust - gain arguments autoscale, but bias does not. Levels - no arguments autoscale. Just noting it in passing.
raffriff42 is offline   Reply With Quote
Old 28th April 2017, 06:06   #3333  |  Link
vcmohan
Registered User
 
Join Date: Jul 2003
Location: India
Posts: 730
Quote:
Originally Posted by pinterf View Post
This problem, right? https://forum.doom9.org/showthread.p...88#post1803688
Could not reproduce. With and without imagesource.
I'd need to have the same conditiones.
So you are on 2420 x64 MT
- Can it be reproduced w/o ImageSource on your machine (just a BlankClip with similar dimensions and format?)
- Processor architecture (though no AVX2 code is used here)
- Does it happen when encoding to e.g. x264 or when viewing from VirtualDub or AvsPMod?
- Clip is of a single image or multiple frames? (e.g. ImageSource(...).Loop(20))
I checked with following script
Code:
#imagesource("c:\images\source1_z.jpg",end = 500)
imagereader("c:\images\stamil.jpg",end = 100)
#imagesource("C:\avi_plugins\DeNoise\grainnoise.png", end = 30).converttoYv12()
#imagereader("C:\avi_plugins\varianslim\theoin.jpg", end = 1000)
#colorbars()
converttoYUY2()
stackhorizontal(last,last)
stackvertical(last,last)
reduceby2()
return(last)
I found that it works ok excepting for that particular imagereader (or if replaced by imagesource) uncommented line. Appears that particular jpg is creating the problem. When I step through I get some green screens. File information looks OK.
Still I can not understand what the problem is, for if I comment out reduceby2() it runs ok with the same input. The particular stamil.jpg image is 602 x 566. I use vdub to monitor output. My Samsung laptop runs with windows 10 home edition. Processor intel i7-4500U1.80Ghz 2.4Ghz, 8GB memory.
__________________
mohan
my plugins are now hosted here
vcmohan is offline   Reply With Quote
Old 28th April 2017, 10:09   #3334  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,095
Quote:
Originally Posted by vcmohan View Post
The particular stamil.jpg image is 602 x 566.
Thanks, the size the key.
Replaced ImageSource with ColorBars
Code:
colorbars().Spline64Resize(610,566)
600 ok, 602 fail, 604 ok, 606 fail, 608 ok, 610 fail

EDIT: fixed (YUY2 HorizontalReduceBy2 did nothing if target width is not mod4)
The constructor of HorizontalReduceBy2 is checking YUY2 clip if the width of source is mod4 (valid YUY2 target width should be mod2). Then it sets output vi.width, divides by 2.
In GetFrame, it checks width again mod4, but the width here is already divided by 2.
It was doing the reduce operation only if width is mod4, which is wrong, here the width is mod2 already (The whole checking is not needed, because it was pre-checked in constructor). Or else it did nothing, frame is undefined content.

Last edited by pinterf; 28th April 2017 at 10:35.
pinterf is offline   Reply With Quote
Old 28th April 2017, 11:49   #3335  |  Link
pinterf
Registered User
 
Join Date: Jan 2014
Posts: 1,095
Quote:
Originally Posted by raffriff42 View Post
RGBAdjust - gain arguments autoscale, but bias does not. Levels - no arguments autoscale. Just noting it in passing.
Thanks, this is inconsistent, and we can call it bug, that was at the very beginning of the project. For a brand new project I'd choose nothing to scale, but keeping scripts easy to maintain is another aspect. Still I'd like to have an option for expert users providing parameters as-is, by something like "paramscale" in masktools.
pinterf is offline   Reply With Quote
Old 28th April 2017, 14:06   #3336  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
After thinking about it, I have no preference for or against autoscaling. One the one hand, it is convenient now, while adapting one's thinking in terms of 0-255 to deep color. On the other hand, it sets the current way of thinking into stone, forever.

In a few years people may instead think in terms of normalized (0-1) range, as strange as that may seem to us now. Maybe they will prefer 0-1023, 0-65535, or something else.

Scaling a non-autoscaled argument is easily done by the user. Re-scaling an 0-255 autoscaled argument to a different source range is also easily done. So I don't care which it is.

Here's an example of Levels (not currently autoscaling) with user-side scaling; changes in blue:
Code:
##################################
### scale 0-255 Levels arguments to clip 'C' bit depth (AVS+)
function ScaledLevels(clip C, 
\       int input_low, float gamma, int input_high,
\       int output_low, int output_high, 
\       bool "coring", bool "dither")
{
    return C.Levels(
    \           C.sb8x(input_low), 
    \           gamma, 
    \           C.sb8x(input_high),
    \           C.sb8x(output_low), 
    \           C.sb8x(output_high), 
    \           coring, dither)
}
You see how easy it is. Supporting code is below. (suggested filename 'argscale.avsi')
Code:
### manual scaling of arguments from one bit depth to another
## version 28-Apr-2017, raffriff42

#######################################
### scale a value from one bit depth to another
##
## @ bits_in  - the bit depth being converted from 
## @ bits_out - the bit depth being converted to
## @ cx       - clamp output (cf. sbx below)
## @ returns float if not clamped; 
##   else returns int for int formats, float for float
##
function sbf(int bits_in, int bits_out, float f, bool "cx")
{
    clamp = Default(cx, false)
    fsi   = getFullscale(bits_in)
    fso   = getFullscale(bits_out)
    fsi1  = Float( (bits_in==32)  ? 256.0/255.0 : fsi+1  )
    fso1  = Float( (bits_out==32) ? 256.0/255.0 : fso+1 )
    
    fr    = (bits_in==bits_out) ? f : f * fso1 / fsi1 ## unclamped result

    fr    =  (clamp==false) ? fr : Min(Max(0.0, fr), fso)
    fr    =  (clamp==false) ? fr : (bits_out==32) ? fr : Round(fr)
    return fr
}


#######################################
### scale a value from one bit depth to another; clamp output
##
## @ bits_in  - the bit depth being converted from 
## @ bits_out - the bit depth being converted to
## @ returns int for int formats, float for float
##
function sbx(int bits_in, int bits_out, float f)
{
    return sbf(bits_in, bits_out, f, true)
} 
#######################################
### scale an 8-bit value for target clip 'T'; clamp output
##
## @ T - clip with target bit depth
## @ returns int for int formats, float for float
##
function sb8x(clip T, float f)
{
    return sbf(8, T.BitsPerComponent, f, true)
} 
#######################################
### scale a 'normalized' (0 to 1) value for target clip 'T'; clamp output
##
## @ T - clip with target bit depth 
## @ returns int for int formats, float for float
##
function sbnx(clip T, float f)
{
    return sbf(32, T.BitsPerComponent, f, true)
}


#######################################
### scale a value from one bit depth to another; string result 
##
## @ bits_in  - the bit depth being converted from 
## @ bits_out - the bit depth being converted to
## @ returns String, unclamped
##
function sbs(int bits_in, int bits_out, float f, int "decimals")
{
    decimals = Min(Max(0, Default(decimals, 4)), 8)
    return String(sbf(bits_in, bits_out, f), "%0."+String(decimals)+"f") 
} 
#######################################
### scale an 8-bit value for target clip 'T'; string result
## @ T - clip with target bit depth (assume bits_in = 8)
## @ returns String, unclamped
##
function sb8s(clip T, float f, int "decimals")
{
    return sbs(8, T.BitsPerComponent, f, decimals)
} 
#######################################
### scale a 'normalized' (0 to 1) value for target clip 'T'; string result
## @ T - clip with target bit depth (assume bits_in = 8)
## @ returns String, unclamped
##
function sbns(clip T, float f, int "decimals")
{
    return sbs(32, T.BitsPerComponent, f, decimals)
} 

#######################################
### return integer fullscale value for given bit depth (mostly for internal use)
function getFullscale(int bits)
{
    return (bits==8)  ? 255
    \    : (bits==10) ? 1023 
    \    : (bits==12) ? 4095
    \    : (bits==14) ? 16383
    \    : (bits==16) ? 65535
    \    : (bits==32) ? 1
    \    : Assert(false,
    \        "getFullscale: 'bits' not one of (8|10|12|14|16|32)") 
}

## end

Last edited by raffriff42; 28th April 2017 at 21:00. Reason: suggested filename 'argscale.avsi'
raffriff42 is offline   Reply With Quote
Old 28th April 2017, 19:50   #3337  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 309
Apologies for this but where's the user-friendly document that explains the AviSynth+ MT stuff like SetFilterMTMode() and Prefetch(), and the changes required in scripts? Can't find it anywhere. Google doesn't know. I seem to remember it was on a wiki.
nhope is offline   Reply With Quote
Old 28th April 2017, 20:56   #3338  |  Link
LigH
German doom9/Gleitz SuMo
 
LigH's Avatar
 
Join Date: Oct 2001
Location: Germany, rural Altmark
Posts: 5,757
AviSynth Wiki
Multi-Threading (old MT() and v2.x-MT SetMTMode())
AviSynth+MT Notes (SetFilterMTMode() and Prefetch())
__________________

New German Gleitz board
MediaFire: x264 | x265 | VPx | AOM | Xvid
LigH is offline   Reply With Quote
Old 28th April 2017, 20:58   #3339  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
Join Date: Jun 2012
Posts: 1,377
Quote:
Originally Posted by nhope View Post
where's the user-friendly document that explains the AviSynth+ MT stuff like SetFilterMTMode() and Prefetch()
Some of it was 'hidden' on the AVS+ developers' page in the wiki; I've moved it to the AVS+ main page as a stopgap until the MT docs can be expanded.
raffriff42 is offline   Reply With Quote
Old 29th April 2017, 04:01   #3340  |  Link
nhope
partially-informed layman
 
Join Date: Jan 2002
Location: Bangkok, Thailand
Posts: 309
Thank you both. It was http://avisynth.nl/index.php/AviSynth%2B#MT_Notes that I was looking for.
nhope is offline   Reply With Quote
Reply

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 03:21.


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