Wilbert
26th June 2014, 18:46
Could someone tell me why the code below doesn't work (yes, it's just a test plugin)?
It should take an RGB clip and create a white Y8 clip with the same properties out of it.
The problem is, it doesn't. It leaves the 67%/75% (depending whether you feed it with RGB24/RGB32) upper lines black. I don't understand what is happening or how i should correct it.
#include <windows.h>
#include "avisynth.h"
class Test : public GenericVideoFilter {
VideoInfo vi_luma;
public:
Test(PClip _child, IScriptEnvironment* env);
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
Test::Test(PClip _child, IScriptEnvironment* env) :
GenericVideoFilter(_child) {
if (!vi.IsRGB()) {
env->ThrowError("Test: RGB data only!");
}
memset(&vi_luma, 0, sizeof(VideoInfo));
vi_luma = vi;
vi_luma.pixel_type = VideoInfo::CS_Y8;
}
PVideoFrame __stdcall Test::GetFrame(int n, IScriptEnvironment* env) {
PVideoFrame src = child->GetFrame(n, env);
PVideoFrame src_luma = env->NewVideoFrame(vi_luma);
int h,w;
unsigned char* srcp_luma = src_luma->GetWritePtr();
int src_luma_pitch = src_luma->GetPitch();
int src_luma_width = src_luma->GetRowSize();
int src_luma_height = src_luma->GetHeight();
for (h=0; h<src_luma_height; h++) {
for (w=0; w<src_luma_width; w++) {
srcp_luma[w] = 255;
}
srcp_luma += src_luma_pitch;
}
return src_luma;
}
AVSValue __cdecl Create_Test(AVSValue args, void* user_data, IScriptEnvironment* env) {
return new Test(args[0].AsClip(), env);
}
const AVS_Linkage *AVS_linkage = 0;
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
AVS_linkage = vectors;
env->AddFunction("Test", "c", Create_Test, 0);
return "Test plugin";
}
It should take an RGB clip and create a white Y8 clip with the same properties out of it.
The problem is, it doesn't. It leaves the 67%/75% (depending whether you feed it with RGB24/RGB32) upper lines black. I don't understand what is happening or how i should correct it.
#include <windows.h>
#include "avisynth.h"
class Test : public GenericVideoFilter {
VideoInfo vi_luma;
public:
Test(PClip _child, IScriptEnvironment* env);
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
Test::Test(PClip _child, IScriptEnvironment* env) :
GenericVideoFilter(_child) {
if (!vi.IsRGB()) {
env->ThrowError("Test: RGB data only!");
}
memset(&vi_luma, 0, sizeof(VideoInfo));
vi_luma = vi;
vi_luma.pixel_type = VideoInfo::CS_Y8;
}
PVideoFrame __stdcall Test::GetFrame(int n, IScriptEnvironment* env) {
PVideoFrame src = child->GetFrame(n, env);
PVideoFrame src_luma = env->NewVideoFrame(vi_luma);
int h,w;
unsigned char* srcp_luma = src_luma->GetWritePtr();
int src_luma_pitch = src_luma->GetPitch();
int src_luma_width = src_luma->GetRowSize();
int src_luma_height = src_luma->GetHeight();
for (h=0; h<src_luma_height; h++) {
for (w=0; w<src_luma_width; w++) {
srcp_luma[w] = 255;
}
srcp_luma += src_luma_pitch;
}
return src_luma;
}
AVSValue __cdecl Create_Test(AVSValue args, void* user_data, IScriptEnvironment* env) {
return new Test(args[0].AsClip(), env);
}
const AVS_Linkage *AVS_linkage = 0;
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
AVS_linkage = vectors;
env->AddFunction("Test", "c", Create_Test, 0);
return "Test plugin";
}