View Single Post
Old 23rd September 2002, 17:04   #21  |  Link
vlad59
Vlad, the Buffy slayer
 
vlad59's Avatar
 
Join Date: Oct 2001
Location: France
Posts: 445
@MarcFD

Of course as it's the first planar format in avisynth we'll have to change a little bit the architecture.

But I think we have to use a maximum current avisynth code when possible to use stable code a maximum.

I personnaly it's a good idea to keep only one VideoFrameBuffer* in VideoFrame so we don't have to change anything in cache specific code.

For now we just have to be talk about new functions of VideoFrame not the internal code (wich can evolve in the future).

So my proposition is :
Code:
class VideoFrame {
  int refcount;
  VideoFrameBuffer* const vfb;
  const int offset, pitch, row_size, height;

  friend class PVideoFrame;
  void AddRef() { ++refcount; }
  void Release() { if (refcount==1) --vfb->refcount; --refcount; }

  friend class ScriptEnvironment;
  friend class Cache;

  VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height);

  void* operator new(unsigned size);

public:
  int GetPitch() const { return pitch; }
  int GetYPitch () const {return pitch;}
  int GetUPitch () const {return pitch>>1;}
  int GetVPitch () const {return pitch>>1;}
// we could have done a int GetUVPitch () const {return pitch>>1;}

  int GetRowSize() const { return row_size; }
  int GetHeight() const { return height; }

  // generally you shouldn't use these two 
  VideoFrameBuffer* GetFrameBuffer() const { return vfb; }
  int GetOffset() const { return offset; }

  // in plugins use env->SubFrame()
  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const;

  const BYTE* GetReadPtr() const { return vfb->GetReadPtr() + offset; }
  const BYTE* GetReadPtr(BYTE p_channel) const { return vfb->GetReadPtr() + ???? (to be defined); }


  bool IsWritable() const { return (refcount == 1 && vfb->refcount == 1); }

  BYTE* GetWritePtr() const {
    return IsWritable() ? (vfb->GetWritePtr() + offset) : 0;
  }

  ~VideoFrame() { --vfb->refcount; }
};
the code defined can be changed of course it's only my current sources.

The problem will be eventually with U or V pointer wich could be only 2bytes aligned depending of the cropping values.

EDIT : Sorry Sh0dan and MarcFd I've waited too long before send my answer, I haven't read your last posts.
I also forgot to check for pixel_type in specific Get_Pitch.
__________________
Vlad59
Convolution3D for avisynth 2.0X : http://www.hellninjacommando.com/con3d
Convolution3D for avisynth 2.5 : http://www.hellninjacommando.com/con3d/beta

Last edited by vlad59; 23rd September 2002 at 17:13.
vlad59 is offline   Reply With Quote