stickboy
27th June 2004, 21:28
To test some of the frame reordering filters I've written (DeleteFrames, DeleteEvery, InterleaveEvery, RemapFrames, Shuffle, etc.), I've basically been doing things like:
logFile = "output.log"
expectedLogFile = "output.good.log"
BlankClip(pixel_type="yuy2", length=100)
WriteFile(logFile, "current_frame", append=false)
DeleteEvery(9, 2, 3)
ScanClip()
Assert(CompareFiles(logFile, expectedLogFile),
\ "FAILED: unexpected results")ScanClip is a trivial plug-in function that tries to request every frame in the clip:static AVSValue __cdecl ScanClip(AVSValue args, void* /* userDataP */,
IScriptEnvironment* envP)
{
PClip& clip = args[0].AsClip();
const int numFrames = clip->GetVideoInfo().num_frames;
for (int i = 0; i < numFrames; ++i)
{
(void) clip->GetFrame(i, envP);
}
return args[0];
}and CompareFiles, not surprisingly, is another simple plug-in function that compares the contents of two files.
The test script requests all frames from the clip, which in turn causes WriteFile to output the corresponding frame numbers from the original clip. It then checks the output against expected values.
This normally works great for making automated tests that verify correctness. However, if the same frame from the original clip is requested multiple times (e.g. frames are duplicated with FreezeFrame or RemapFrames), the cache causes a problem: WriteFile doesn't receive the GetFrame call again, so it writes the frame number only the first time a particular frame is requested.
To summarize, if I have something such as:
BlankClip(pixel_type="yuy2", length=10)
WriteFile("foo.log", "current_frame", append=false)
FreezeFrame(2, 5, 0)
ScanClip()then the output is going to be:0
1
6
7
8
9but I want:0
1
0
0
0
0
6
7
8
9Does anyone have any ideas how I can work around this?
Thanks.
logFile = "output.log"
expectedLogFile = "output.good.log"
BlankClip(pixel_type="yuy2", length=100)
WriteFile(logFile, "current_frame", append=false)
DeleteEvery(9, 2, 3)
ScanClip()
Assert(CompareFiles(logFile, expectedLogFile),
\ "FAILED: unexpected results")ScanClip is a trivial plug-in function that tries to request every frame in the clip:static AVSValue __cdecl ScanClip(AVSValue args, void* /* userDataP */,
IScriptEnvironment* envP)
{
PClip& clip = args[0].AsClip();
const int numFrames = clip->GetVideoInfo().num_frames;
for (int i = 0; i < numFrames; ++i)
{
(void) clip->GetFrame(i, envP);
}
return args[0];
}and CompareFiles, not surprisingly, is another simple plug-in function that compares the contents of two files.
The test script requests all frames from the clip, which in turn causes WriteFile to output the corresponding frame numbers from the original clip. It then checks the output against expected values.
This normally works great for making automated tests that verify correctness. However, if the same frame from the original clip is requested multiple times (e.g. frames are duplicated with FreezeFrame or RemapFrames), the cache causes a problem: WriteFile doesn't receive the GetFrame call again, so it writes the frame number only the first time a particular frame is requested.
To summarize, if I have something such as:
BlankClip(pixel_type="yuy2", length=10)
WriteFile("foo.log", "current_frame", append=false)
FreezeFrame(2, 5, 0)
ScanClip()then the output is going to be:0
1
6
7
8
9but I want:0
1
0
0
0
0
6
7
8
9Does anyone have any ideas how I can work around this?
Thanks.