Quote:
Originally posted by sh0dan
Therefore we can force data to be continuous, I can't see any real arguments for not having this, honestly.
|
you are right.
i've taken a look in the avisynth internals (the first time i do this
) and i see know what you think. it make sense for me now
sorry if i didn't understood you immediatly
Okay, so when we use I420 colorspace with a bit alignement.
you need a new pitch,row_size and height.
my suggestion
Code:
class VideoFrame {
int refcount;
VideoFrameBuffer* const vfb;
const int offset, pitch, row_size, height;
const int pitch2, row_size2, height2; // needed for I420 alignement
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 GetPitch2() const {return pitch2;}
int GetRowSize() const { return row_size; }
int GetRowSize2() const { return row_size2; }
int GetHeight() const { return height; }
int GetHeight2() const { return height2; }
// 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 plane) const {
if (plane==Y_PLANE) {
return vfb->GetReadPtr() + offset;
} else if (plane==U_PLANE) {
return vfp->GetReadPtr() + offset + pitch*height(+alignement trick)
} else if (plane==V_PLANE) {
return vfp->GetReadPtr() + offset + pitch*height(+alignement trick) + pitch2*height2(+alignement trick)
} else {
return vfb->GetReadPtr() + offset; // default
}
}
vfp->GetReadPtr() + offset + pitch*height + pitch2*height2 +
bool IsWritable() const { return (refcount == 1 && vfb->refcount == 1); }
BYTE* GetWritePtr() const {
return IsWritable() ? (vfb->GetWritePtr() + offset) : 0;
}
~VideoFrame() { --vfb->refcount; }
};
seems logical, no ?
EDIT : sorry didn't see yours