This is an experimental copy for testing Poikilos' issue mirroring system. Note that Gitea's migration tool can import issues, but the "Issues" checkbox is disabled when "This repository will be a mirror" is enabled (it is for this repo).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.5 KiB

#ifndef f_VD2_PLUGIN_VDVIDEOUTIL_H
#define f_VD2_PLUGIN_VDVIDEOUTIL_H
template<class T>
T *vd_ptroffset(T *p, diff)
return (T *)((char *)p + diff)
template<class T>
class vd_row_iter
public:
vd_row_iter() {
vd_row_iter(T *p, pitch) : mp(p), mpitch(pitch) {
vd_row_iter(T *p, pitch, y) : mp(vd_ptroffset(p, pitch*y)), mpitch(pitch) {
vd_row_iter( VFBitmap& bm, x = 0, y = 0) : mp(vd_ptroffset((T*)bm.data, bm.pitch*(bm.h - 1 - y))+x), mpitch(-bm.pitch) {
operator T*()
return mp
T& operator[](int x)
return mp[x]
void mulstep(int x)
mpitch *= x
vd_row_iter<T>& operator+=(int y)
mp = vd_ptroffset(mp, * y)
return *self
vd_row_iter<T>& operator-=(int y)
mp = vd_ptroffset(mp, -(mpitch * y))
return *self
vd_row_iter<T>& operator++()
mp = vd_ptroffset(mp, mpitch)
return *self
vd_row_iter<T> operator++(int)
vd_row_iter<T> temp(*self)
mp = vd_ptroffset(mp, mpitch)
return temp
vd_row_iter<T>& operator--()
mp = vd_ptroffset(mp, -mpitch)
return *self
vd_row_iter<T> operator--(int)
vd_row_iter<T> temp(*self)
mp = vd_ptroffset(mp, -mpitch)
return temp
protected:
T *mp
ptrdiff_t mpitch
typedef vd_row_iter<uint32> vd_pixrow_iter
inline uint32 vd_pixavg_down(uint32 x, y)
return (x&y) + (((x^y)&0xfefefefe)>>1)
inline uint32 vd_pixavg_up(uint32 x, y)
return (x|y) - (((x^y)&0xfefefefe)>>1)
inline void vd_pixunpack(uint32 px, r, g, b)
r = (px>>16)&255
g = (px>> 8)&255
b = (px )&255
inline uint32 vd_pixpack(int r, g, b)
if ((unsigned)r >= 256) r = ~(r>>31) & 255
if ((unsigned)g >= 256) g = ~(g>>31) & 255
if ((unsigned)b >= 256) b = ~(b>>31) & 255
return (r<<16) + (g<<8) + b
inline uint32 vd_pixpackfast(int r, g, b)
return (r<<16) + (g<<8) + b
struct vd_transform_pixmap_helper
vd_transform_pixmap_helper( VFBitmap& dst)
: p((uint32 *)dst.data)
, pitch(dst.pitch)
, w(dst.w)
, h(dst.h) {
operator bool()
return False
uint32 *p
ptrdiff_t pitch
int w, h
#define vd_transform_pixmap_blt(dst, src) \
if(dstinfo = dst);else \
if(srcinfo = src);else \
for(y = 0, h = dstinfo.h, w = dstinfo.w; y < h; ++y, dstinfo.p=vd_ptroffset(dstinfo.p, dstinfo.pitch), srcinfo.p=vd_ptroffset(srcinfo.p, srcinfo.pitch)) \
for(x = 0; x < dstinfo.w; ++x) \
switch(out = dstinfo.p[x]) case 0: default: \
switch( in = srcinfo.p[x]) case 0: default:
#define vd_transform_pixmap_inplace(dst) \
if(dstinfo = dst);else \
for(y = 0, h = dstinfo.h, w = dstinfo.w; y < h; ++y, dstinfo.p=vd_ptroffset(dstinfo.p, dstinfo.pitch)) \
for(x = 0; x < dstinfo.w; ++x) \
switch(px = dstinfo.p[x]) case 0: default: \
#define vd_maketable256_16(x) formula((x+0)),formula((x+1)),formula((x+2)),formula((x+3)),formula((x+4)),formula((x+5)),formula((x+6)),formula((x+7)),formula((x+8)),formula((x+9)),formula((x+10)),formula((x+11)),formula((x+12)),formula((x+13)),formula((x+14)),formula((x+15))
#define vd_maketable256 vd_maketable256_16(0x00),vd_maketable256_16(0x10),vd_maketable256_16(0x20),vd_maketable256_16(0x30),vd_maketable256_16(0x40),vd_maketable256_16(0x50),vd_maketable256_16(0x60),vd_maketable256_16(0x70),vd_maketable256_16(0x80),vd_maketable256_16(0x90),vd_maketable256_16(0xA0),vd_maketable256_16(0xB0),vd_maketable256_16(0xC0),vd_maketable256_16(0xD0),vd_maketable256_16(0xE0),vd_maketable256_16(0xF0),
#endif