Youka
4th May 2012, 13:07
I wrote an Avisynth plugin, which creates a pointer to the IScriptEnvironment and a PClip at startup for further processing.
char *token = strtok(avs_variable_names, " ");
while(token != NULL){
AVSValue val = env->GetVar(token);
if(val.IsClip()){
//Just allocates enough memory for a PClip object
PClip *clip = lua_createuserdata<PClip>(L, LUACLIP);
try{
*clip = env->Invoke("ConvertAudioTo16bit", env->Invoke("ConvertToRGB32", val)).AsClip();
}catch(IScriptEnvironment::NotFound){
throw "Cannot convert audio or video!";
}
//Adds PClip address to a registry
lua_rawseti(L, -2, ++n);
}else
throw "Userdata contains undefined variable names!";
token = strtok(NULL, " ");
}
In GetFrame, during filter process, it tries to access audio data from my saved PClip.
PClip *clip = (PClip*)luaL_checkuserdata(L, 1, LUACLIP);
VideoInfo info = (*clip)->GetVideoInfo();
__int64 start = luaL_checknumber(L, 2);
__int64 count = luaL_checknumber(L, 3);
if(info.HasAudio() && start >= 0 && start+count < info.num_audio_samples && count > 0){
signed short *buf = new signed short[count * info.nchannels];
(*clip)->GetAudio(buf, start, count, (IScriptEnvironment*)userdata_avs[1]);
...It works by playing it in MPC without problems! Always getting data by (*clip)->GetAudio(...).
But by encoding it, programs are crashing with an access violation message from Avisynth (it's exactly the last code line i posted).
VirtualDubMod - Uncompressed, Lagarith
http://img24.imageshack.us/img24/4733/lagarithvdubmod.jpg
MeGUI - x264, xVid
Problemereignisname: APPCRASH
Application Name: MeGUI.exe
Application Version: 1.0.2112.0
Application Timestamp: 4f303ff9
Fault Module Name: unknown
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 06228a1b
Betriebsystemversion: 6.0.6001.2.1.0.768.3
Gebietsschema-ID: 1031
It seems to be an Avisynth bug (using 2.5.8), so i ask if there's a known fix or something?
char *token = strtok(avs_variable_names, " ");
while(token != NULL){
AVSValue val = env->GetVar(token);
if(val.IsClip()){
//Just allocates enough memory for a PClip object
PClip *clip = lua_createuserdata<PClip>(L, LUACLIP);
try{
*clip = env->Invoke("ConvertAudioTo16bit", env->Invoke("ConvertToRGB32", val)).AsClip();
}catch(IScriptEnvironment::NotFound){
throw "Cannot convert audio or video!";
}
//Adds PClip address to a registry
lua_rawseti(L, -2, ++n);
}else
throw "Userdata contains undefined variable names!";
token = strtok(NULL, " ");
}
In GetFrame, during filter process, it tries to access audio data from my saved PClip.
PClip *clip = (PClip*)luaL_checkuserdata(L, 1, LUACLIP);
VideoInfo info = (*clip)->GetVideoInfo();
__int64 start = luaL_checknumber(L, 2);
__int64 count = luaL_checknumber(L, 3);
if(info.HasAudio() && start >= 0 && start+count < info.num_audio_samples && count > 0){
signed short *buf = new signed short[count * info.nchannels];
(*clip)->GetAudio(buf, start, count, (IScriptEnvironment*)userdata_avs[1]);
...It works by playing it in MPC without problems! Always getting data by (*clip)->GetAudio(...).
But by encoding it, programs are crashing with an access violation message from Avisynth (it's exactly the last code line i posted).
VirtualDubMod - Uncompressed, Lagarith
http://img24.imageshack.us/img24/4733/lagarithvdubmod.jpg
MeGUI - x264, xVid
Problemereignisname: APPCRASH
Application Name: MeGUI.exe
Application Version: 1.0.2112.0
Application Timestamp: 4f303ff9
Fault Module Name: unknown
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 00000000
Exception Code: c0000005
Exception Offset: 06228a1b
Betriebsystemversion: 6.0.6001.2.1.0.768.3
Gebietsschema-ID: 1031
It seems to be an Avisynth bug (using 2.5.8), so i ask if there's a known fix or something?