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 5th March 2013, 21:22   #61  |  Link
forclip
Registered User
 
Join Date: Dec 2009
Posts: 63
I can easily reproduce this AccessViolations with simple script like this:

Code:
BlankClip(1001, 754, 562, Pixel_type="y8")
ConvertToRGB32()
In VirtualDubMod - by pressing F5 button or reloading the script again and again.
In MPC-HC - by reloading the script.
In MeGUI script creator - by reloading preview window.
...

All the time it is AccesViolation, or app just dissapeared, or other things like "Parser: Unknown error".

Actually, I came to this not from this bugreport, but from my own bug report, when the user told me that everything works fine when he uses DirectShow preview of the script (a simple player that based on DirectShow), but when switching to our own preview engine (that uses AviSynth.dll directly via AviSynthWrapper.dll) he've got alot of AcessViolations. Most of the time - on unloading AviSynth (when PClip var = some_clip; do something; and then on unloading var=NULL; - here, when destroying IClip on Release()). And then I remembered that in second case everything is Convert`edToRGB32() in AviSynthWrapper. Added ConvertToRGB32() at the end of the script - and now I can reproduce AVs with DirectShow too.

Tested with Alpha4 and latest MT build; on Win XP SP2 with Intel Q6600 cpu.
forclip is offline   Reply With Quote
Old 6th March 2013, 09:02   #62  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Confirmed with VDMod and VD 1.9.11

Also Access violation with arg names supplied ie

Code:
#BlankClip(1001, 754, 562, Pixel_type="y8")
BlankClip(length=1001, width=754, height=562, Pixel_type="y8")
ConvertToRGB32()
Seems to mostly work ok on first load but on reload bombs.

VD 1st load may play OK, bomb on reload.

VDMod, Bombs on reload and if exit without reload or play.

XP32SP3

AppCompat.txt From VDMod bomb on noplay exit:

http://www.mediafire.com/?dmy86jv3uxsogke
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 6th March 2013, 13:06   #63  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Failure is for aligned SSE3+ code path in ConvertYV24toRGB for widths 16*N+1, N a positive integer greater than 1.
Code:
N=2
BlankClip(10, 16*N+1, 16, Pixel_type="YV24")
ConvertToRGB()
The packbuf array was being overrun. Repeatedly reloading the script eventually clobbers something that matters. It may happen on the first try, it may take 50 tries.

Fixed in CVS.
IanB is offline   Reply With Quote
Old 6th March 2013, 16:23   #64  |  Link
forclip
Registered User
 
Join Date: Dec 2009
Posts: 63
Thanks!
forclip is offline   Reply With Quote
Old 6th March 2013, 16:38   #65  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by forclip View Post
I can easily reproduce this AccessViolations with simple script like this:
Code:
BlankClip(1001, 754, 562, Pixel_type="y8")
ConvertToRGB32()
Quote:
Originally Posted by IanB View Post
Failure is for aligned SSE3+ code path in ConvertYV24toRGB for widths 16*N+1, N a positive integer greater than 1.
Code:
N=2
BlankClip(10, 16*N+1, 16, Pixel_type="YV24")
ConvertToRGB()
754 does not have the form 16*N+1. (754%16 is 2, not 1)
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 6th March 2013, 17:06   #66  |  Link
forclip
Registered User
 
Join Date: Dec 2009
Posts: 63
There is also different source colorspaces (Y8 in my sample and YV12 was reported to me), but I hope that it makes no difference and affected code path is the same.

P.S. it would be nice to have a project files for something like MSVC2008\2010 on the CVS..

Last edited by forclip; 6th March 2013 at 18:49.
forclip is offline   Reply With Quote
Old 6th March 2013, 22:20   #67  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Well it's actually 16*N+[1..7] that are wrong, but they get harder to expose.

Wrong buffer length is (width*4 + 32), used buffer length is ((width+15)/16*64), the overrun is ((7 - (width-1)%16)*4)

Code:
W%16		Overrun
 1		28
 2		24
 3		20
 4		16
 5		12
 6		 8
 7		 4
IanB is offline   Reply With Quote
Old 13th March 2013, 15:03   #68  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
I was looking at the additions for BlankClip. Why not add video (with the default parameters) when supplying an audio only template, instead of checking of the one the parameters width, height or pixel_type is set? Likewise for a video only template.
Wilbert is offline   Reply With Quote
Old 13th March 2013, 21:58   #69  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@Wilbert,

So when you do BlankClip(Clip) you get identical clip properties to the template. If it's audio only you get a blank audio only clip. If it's video only you get a blank video only clip. If you start to modify the parameters to force a video or audio track, now you start with good defaults rather then possibly (probably) invalid junk from the template.
IanB is offline   Reply With Quote
Old 14th March 2013, 17:01   #70  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Quote:
... If it's audio only you get a blank audio only clip. ...
Somehow I missed that. Makes sense now. Thanks.
Wilbert is offline   Reply With Quote
Old 17th March 2013, 17:58   #71  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
Mmmm, i didn't realize you already documented everything ;( My fault of course.

Regarding the bit functions. Is there a difference between BitRShiftL, BitRShiftU and BitRShiftU for example? If not, why the need for three of them?
I would also like to ask you to remove tau (as being 2 pi). It's not used in the scientific literature: http://en.wikipedia.org/wiki/Tau_%28...opular_culture, while it can denote a lot of other things: http://en.wikipedia.org/wiki/Tau.
Wilbert is offline   Reply With Quote
Old 17th March 2013, 23:44   #72  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Possibly a bit over-redundant but this is what we have, it allows building selections from Bit[LR]shift[AL] or Bit[LR]shift[SU] :-

7 synonyms for Left Shift, X << Y, bottom bits are always zero filled.
bitlshift Left Shift
bitlshiftl Left Shift Logical
bitlshifta Left Shift Arithmetic
bitlshiftu Left Shift Unsigned
bitlshifts Left Shift Signed
bitshl Shift Left
bitsal Shift Arithmetic Left


3 synonyms for Unsigned Right Shift, (unsigned int)X << Y, top bits are zero filled.
bitrshiftl Right Shift Logical
bitrshiftu Right Shift Unsigned
bitshr Shift Right


3 synonyms for Signed Right Shift, (int)X << Y, top bits are sign filled.
bitrshifta Right Shift Arithmetic
bitrshifts Right Shift Signed
bitsar Shift Arithmetic Right


2 synonyms for Rotate Left, Top bit rolls to Bottom bit.
bitlrotate Left Rotate
bitrol Rotate Left


2 synonyms for Rotate Right, Bottom bit rolls to Top bit.
bitrrotate Right Rotate
bitror Rotate Right


I added Tau() as a stir of a friend who is an avid Tau'ist, who I regularly poke with "The area of a circle is ∏rē". So I will take it out.
IanB is offline   Reply With Quote
Old 8th April 2013, 13:03   #73  |  Link
Reino
Registered User
 
Reino's Avatar
 
Join Date: Nov 2005
Posts: 693
Quote:
Originally Posted by http://avisynth.org/mediawiki/Trim
Since v2.60 you can trim the audio using AudioTrim. The start_time, end_time and duration need to be specified in seconds (but can be float)
Is it really?
I'm trying to load a cue-indexed audiosong from a TAK-image which starts at 40053972 samples (908.25333s) and is 16986144 samples (385.17333s) long:
Code:
LoadDll("C:\Program Files\AviSynth 2.6.0\plugins\tak_deco_lib.dll")
BassAudioSource("D:\Test\Image.tak")

AudioTrim(40053972/44100,-16986144/44100)
AudioTrim(Float(40053972)/44100,Float(-16986144)/44100)

ConvertAudioTo16bit
With the 1st AudioTrim foobar returns a length of 16978500 samples or exactly 385s. It seems the start_time and end_time are floored somehow. I'd figure the starting point would also be 40042800 samples or 908s.

With the 2nd AudioTrim foobar returns 16986144 samples, but when I then bit-compare the Avisynth-script and the cue-indexed TAK-song, it doesn't seem to be accurate:
Code:
Differences found in 1 out of 1 track pairs.

Comparing:
"D:\Test\Image.tak" / index: 3
"D:\Test\Image.avs"
Differences found: 33952821 sample(s), starting at 0.0000000 second(s), peak: 1.4393005 at 35.8453061 second(s), 2ch
- How come Float() is needed?
- Is it possible to AudioTrim with sample accuracy?
__________________
My hobby website
Reino is offline   Reply With Quote
Old 8th April 2013, 15:03   #74  |  Link
Rumbah
Registered User
 
Join Date: Mar 2003
Posts: 480
Quote:
Originally Posted by CoRoNe View Post
- How come Float() is needed?
If you divide two integers the result will be an integer.
Just add a .0 to the integers to do a floating point division.
Rumbah is offline   Reply With Quote
Old 8th April 2013, 20:05   #75  |  Link
Reino
Registered User
 
Reino's Avatar
 
Join Date: Nov 2005
Posts: 693
Ah, got it. Thanks for the heads-up, Rumbah.

Another weird example:
Another song within the same TAK-image starts at 113414616 samples (2571.76s) and is 21692496 samples (491.89333s) long:
Code:
LoadDll("C:\Program Files\AviSynth 2.6.0\plugins\tak_deco_lib.dll")
BassAudioSource("D:\Test\Image.tak")

AudioTrim(113414616/44100.0,-21692496/44100.0)
AudioTrim(113414616/44100.0,135107112/44100.0)

ConvertAudioTo16bit
The 1st AudioTrim returns a length of 21692497 samples (491.89337s), but although code for the 2nd AudioTrim should have the same result as the 1st, it returns 21692485 samples (491.89308s)! Does anyone have an explanation?

Happens to WavSource() too, so at least BassAudio isn't faulty. Remove both AudioTrim()'s and bit-compare that to the entire TAK-image also results in 'no differences found'.
__________________
My hobby website
Reino is offline   Reply With Quote
Old 8th April 2013, 23:32   #76  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by CoRoNe View Post
Code:
AudioTrim(113414616/44100.0,-21692496/44100.0)
AudioTrim(113414616/44100.0,135107112/44100.0)
The 1st AudioTrim returns a length of 21692497 samples (491.89337s), but although code for the 2nd AudioTrim should have the same result as the 1st, it returns 21692485 samples (491.89308s)! Does anyone have an explanation?
You are being hit by the accuracy limits of floating point representation.
Avisynth floats have 24 bit precision, which gives an accuracy of about 1 part in 16.8 million (2^24).
So any sample start, end or length values larger than this (which your examples all have) will not be sample-accurate.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 9th April 2013, 00:56   #77  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@CoRoNe,

You are running into lack of precision with single precision floats.

Floats only have a 24 bit mantissa so numbers bigger than 16,777,216 can not be represented exactly. Which for the way you are using the arithmetic and with 44100Hz streams is about 380.4 seconds (349.5 for 48000Hz).

The code internally uses 64 bit integers and double precision floats, so as long as you feed it from the script with single precision numbers that can be represented exactly you can achieve audio sample exact results.

You can trim between 1.0 and 16,777,215.0 integer seconds of audio exactly from the start of a clip.

So to crib the precision do the AudioTrim in stages. Using integer arithmetic calculate whole seconds and a remainder.
Code:
...
Start=113414616/44100
Sremainder=(113414616%44100)/44100.0

Duration=21692496/44100
Dremainder=(21692496%44100)/44100.0

AudioTrim(Start, 0)  # Chop off start integer seconds
AudioTrim(Sremainder, 0)  # Chop off start remaining fractional second
# Chop full seconds and join with remaining fractional second
AudioTrim(0, -Duration) + AudioTrim(Duration, -Dremainder)
The relevant code inside AudioTrim :-
Code:
  Trim::Trim(double starttime, double endtime, PClip ...
...
  __int64 esampleno = 0; 
 ...	
  audio_offset = min(max(__int64(starttime*vi.audio_samples_per_second + 0.5), 0), ...
...
  if (endtime == 0.0)
    esampleno = vi.num_audio_samples;
  else if (endtime < 0.0)
    esampleno = __int64((starttime-endtime)*vi.audio_samples_per_second + 0.5);
  else
    esampleno = __int64(endtime*vi.audio_samples_per_second + 0.5);
IanB is offline   Reply With Quote
Old 9th April 2013, 21:29   #78  |  Link
Reino
Registered User
 
Reino's Avatar
 
Join Date: Nov 2005
Posts: 693
Code:
LoadDll("C:\Program Files\AviSynth 2.6.0\plugins\tak_deco_lib.dll")
BassAudioSource("D:\Test\Image.tak")

AudioTrim(113414616/44100, 0)
AudioTrim((113414616%44100)/44100.0, 0)
AudioTrim(0, -21692496/44100) + AudioTrim(21692496/44100, -(21692496%44100)/44100.0)

ConvertAudioTo16bit
Code:
All tracks decoded fine, no differences found.

Comparing:
"D:\Test\Image.tak" / index: 7
"D:\Test\Image.avs"
No differences in decoded data found.
IanB!

However, I've tried to come up with some script to mimic the cutting I did with Audacity earlier, but although the amount of samples are the same, there's a glitch at the cutting-point:
Code:
Src=BassAudioSource("D:\Test\Image.tak")
Prt1=Src.AudioTrim(113414616/44100, 0)
Prt1=Prt1.AudioTrim((113414616%44100)/44100.0, 0)
Prt1=Prt1.AudioTrim(0, -11161180/44100) + AudioTrim(11161180/44100, -(11161180%44100)/44100.0)
Prt2=Src.AudioTrim(128129206/44100, 0)
Prt2=Prt2.AudioTrim((128129206%44100)/44100.0, 0)
Prt2=Prt2.AudioTrim(0, -6977906/44100) + AudioTrim(6977906/44100, -(6977906%44100)/44100.0)
Prt1+Prt2
Yesterday this code still looked like this:
Code:
A=AudioTrim(113414616/44100.0, 124575796/44100.0)
B=AudioTrim(128129206/44100.0, 135107112/44100.0)
A+B
I haven't touched Avisynth in quite some time, so I must be doing something rather silly.
__________________
My hobby website
Reino is offline   Reply With Quote
Old 9th April 2013, 23:38   #79  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by CoRoNe View Post
I've tried to come up with some script to mimic the cutting I did with Audacity earlier, but although the amount of samples are the same, there's a glitch at the cutting-point:
Code:
Src=BassAudioSource("D:\Test\Image.tak")
Prt1=Src.AudioTrim(113414616/44100, 0)
Prt1=Prt1.AudioTrim((113414616%44100)/44100.0, 0)
Prt1=Prt1.AudioTrim(0, -11161180/44100) + AudioTrim(11161180/44100, -(11161180%44100)/44100.0)
Prt2=Src.AudioTrim(128129206/44100, 0)
Prt2=Prt2.AudioTrim((128129206%44100)/44100.0, 0)
Prt2=Prt2.AudioTrim(0, -6977906/44100) + AudioTrim(6977906/44100, -(6977906%44100)/44100.0)
Prt1+Prt2
It should be:
Code:
...
Prt1=Prt1.AudioTrim(0, -11161180/44100) + Prt1.AudioTrim(11161180/44100, -(11161180%44100)/44100.0)
...
Prt2=Prt2.AudioTrim(0, -6977906/44100) + Prt2.AudioTrim(6977906/44100, -(6977906%44100)/44100.0)
Does the quoted script match the one you actually used?
It should give an error 'invalid params to AudioTrim()' (unless some earlier part of the script sets an implicit 'last').
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 10th April 2013, 00:14   #80  |  Link
Reino
Registered User
 
Reino's Avatar
 
Join Date: Nov 2005
Posts: 693
Quote:
Originally Posted by Gavino View Post
(unless some earlier part of the script sets an implicit 'last').
Yeah, that! Lot's of '#'s for testing, but I forgot one it seems. Prt1 and Prt2 did the trick. Thanks! Silly me. Like I said, it's been a while.
__________________
My hobby website
Reino 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 23:02.


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