Thread: Avisynth+
View Single Post
Old 11th September 2019, 10:04   #4879  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Null() not useful to replace NOP.

Null(clip c, string "Copy"="none"), is not intended to be used from script.
from v2.60 std source, debug.h
Code:
class Null : public GenericVideoFilter 
/**
  * Class for debugging Avisynth internals.
 **/
As it is in avs v2.60 std source, seems to always produce error
debug.cpp
Code:
/*******************************
 *******   Null Filter   *******
 *******  for debugging  *******
 ******************************/

Null::Null(PClip _child, const char * _copy, IScriptEnvironment* env)
  : GenericVideoFilter(_child), copy(_copy)
{
}

Null::~Null()
{
}


PVideoFrame __stdcall Null::GetFrame(int n, IScriptEnvironment* env)
{
  PVideoFrame src = child->GetFrame(n, env);

  BYTE * foo = new BYTE[256];
  BYTE * bar = new BYTE[256];
  MemDebug md;

  md.randomFill(foo, 8, 8, 8);
  env->BitBlt(bar, 8, foo, 8, 8, 8);

  md.reset();
  int i = md.randomCheck(bar, 9, 8, 8);                                        // ssS: Looks like always forces error (9 instead of 8)

  if (i)
    env->ThrowError("bug found");                                              // ssS: OUR SHOWN ERROR "Error reading source frame 0: Avisynth read error: bug found"

  delete [] foo;
  delete [] bar;

  if (!lstrcmpi(copy, "makewritable"))
  {
    env->MakeWritable(&src);
    return src;
  }

  // TODO: no support for planar formats!
  if (!lstrcmpi(copy, "memcopy"))
  {
    PVideoFrame dst = env->NewVideoFrame(child->GetVideoInfo(), 16);
    if (dst->IsWritable() == false)
      env->ThrowError("new frame not writable"); // honestly don't know whether to expect this condition

    memcpy( dst->GetWritePtr(), src->GetReadPtr(), src->GetPitch() * src->GetHeight() );
    return dst;
  }

  if (!lstrcmpi(copy, "bitblt"))
  {
    PVideoFrame dst = env->NewVideoFrame(child->GetVideoInfo(), 16);
    if (dst->IsWritable() == false)
      env->ThrowError("new frame not writable"); // honestly don't know whether to expect this condition

    env->BitBlt( dst->GetWritePtr(), src->GetPitch(), src->GetReadPtr(), src->GetPitch(),
            src->GetRowSize(), src->GetHeight() );
    return dst;
  }

  //if (!lstrcmpi(copy, "none"))
    // do nothing
  return src;
}

AVSValue __cdecl Null::Create(AVSValue args, void*, IScriptEnvironment* env)
{
  return new Null(args[0].AsClip(), args[1].AsString("none"), env);
}
Cant say that I understand whats happening there, seems a bit weird.
EDIT: Dont know where this bit is coming from "Error reading source frame 0: Avisynth read error".

EDIT: Although this dont throw error (As no GetFrame called, only Null() constructor called)
Code:
# this just returns the info whatsit, no error thrown
colorbars(pixel_type="YV12")
O=Last

Last.Null(Copy="What the hell ! ")   # always do the Null thingy

return O.Info
EDIT: Maybe that particular code is intended to be "hacked as required", and above is just how it was left after last use.
__________________
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 ???

Last edited by StainlessS; 11th September 2019 at 10:41.
StainlessS is offline