E-Male
24th May 2003, 18:37
since i got a problem compiling filters:
see: http://forum.doom9.org/showthread.php?s=&threadid=54077
could someone test this code for me
it should turn a movie into just black&white (for smaller endcredits)
------------------------------------------------
#include "windows.h"
#include "avisynth.h"
class blackwhite : public GenericVideoFilter {
int edge;
public:
blackwhite(PClip _child, int _edge, IScriptEnvironment* env);
~blackwhite();
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
blackwhite::blackwhite(PClip _child, int _edge, IScriptEnvironment* env) :
GenericVideoFilter(_child), edge(_edge) {
}
blackwhite::~blackwhite() {
}
PVideoFrame __stdcall blackwhite::GetFrame(int n, IScriptEnvironment* env) {
PVideoFrame src = child->GetFrame(n, env);
PVideoFrame dst = env->NewVideoFrame(vi);
const unsigned char* srcp = src->GetReadPtr();
unsigned char* dstp = dst->GetWritePtr();
const int dst_pitch = dst->GetPitch();
const int dst_width = dst->GetRowSize();
const int dst_height = dst->GetHeight();
const int src_pitch = src->GetPitch();
const int src_width = src->GetRowSize();
const int src_height = src->GetHeight();
int w, h;
for (h=0; h < src_height;h++) {
for (w = 0; w < src_width; w+=2) {
*((unsigned int *)dstp + w) = 128;
if (*((unsigned int *)srcp + w+1) > edge)
*((unsigned int *)dstp + w+1) = 235;
else
*((unsigned int *)dstp + w+1) = 16;
}
srcp = srcp + src_pitch;
dstp = dstp + dst_pitch;
}
return dst;
}
AVSValue __cdecl Create_blackwhite(AVSValue args, void* user_data, IScriptEnvironment* env) {
return new blackwhite(args[0].AsClip(),
args[1].AsInt(0),
env);
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("blackwhite", "c[EDGE]i", Create_blackwhite, 0);
return "`blackwhite' blackwhite plugin";
}
------------------------------------------------
i hope someone can compile it
thx in advance
e-male
see: http://forum.doom9.org/showthread.php?s=&threadid=54077
could someone test this code for me
it should turn a movie into just black&white (for smaller endcredits)
------------------------------------------------
#include "windows.h"
#include "avisynth.h"
class blackwhite : public GenericVideoFilter {
int edge;
public:
blackwhite(PClip _child, int _edge, IScriptEnvironment* env);
~blackwhite();
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};
blackwhite::blackwhite(PClip _child, int _edge, IScriptEnvironment* env) :
GenericVideoFilter(_child), edge(_edge) {
}
blackwhite::~blackwhite() {
}
PVideoFrame __stdcall blackwhite::GetFrame(int n, IScriptEnvironment* env) {
PVideoFrame src = child->GetFrame(n, env);
PVideoFrame dst = env->NewVideoFrame(vi);
const unsigned char* srcp = src->GetReadPtr();
unsigned char* dstp = dst->GetWritePtr();
const int dst_pitch = dst->GetPitch();
const int dst_width = dst->GetRowSize();
const int dst_height = dst->GetHeight();
const int src_pitch = src->GetPitch();
const int src_width = src->GetRowSize();
const int src_height = src->GetHeight();
int w, h;
for (h=0; h < src_height;h++) {
for (w = 0; w < src_width; w+=2) {
*((unsigned int *)dstp + w) = 128;
if (*((unsigned int *)srcp + w+1) > edge)
*((unsigned int *)dstp + w+1) = 235;
else
*((unsigned int *)dstp + w+1) = 16;
}
srcp = srcp + src_pitch;
dstp = dstp + dst_pitch;
}
return dst;
}
AVSValue __cdecl Create_blackwhite(AVSValue args, void* user_data, IScriptEnvironment* env) {
return new blackwhite(args[0].AsClip(),
args[1].AsInt(0),
env);
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
env->AddFunction("blackwhite", "c[EDGE]i", Create_blackwhite, 0);
return "`blackwhite' blackwhite plugin";
}
------------------------------------------------
i hope someone can compile it
thx in advance
e-male