2
// C++ Interface: %{MODULE}
7
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
9
// Copyright: See COPYING file that comes with this distribution
12
// This is the base time for image exchanged between codec/filters/...
14
// We (optionnally) can carry extra informations
17
// - quantizer for each macroblock (16x16 pixels)
18
// For the latter 3 infos are used
19
// quant which leads to the int8 quant array
20
// qstride = stride of array. Usually width+15)/16. 0 MEANS NOT USABLE
21
// qsize = size of the array (needed to be able to copy it)
25
#include "ADM_assert.h"
26
#include "ADM_colorspace/ADM_rgb.h"
28
typedef enum ADM_ASPECT
34
// Avisynth compatibility layer
36
//#define vi.num_frames _info.nb_frames
37
//#define vi.IsYV12() 1
38
#define GetReadPtr GetWritePtr
39
#define GetRowSize GetPitch
41
typedef enum ADM_PLANE
52
uint8_t *data; /// Pointer to actual image data
53
uint32_t _width; /// Width of image
54
uint32_t _height; /// Height of image
55
uint32_t _qStride; /// Stride of Q infos, usually about width/8 <- ***if 0 means no quant usable***
56
uint8_t *quant; /// Byte representing quantize used for this block
57
uint32_t _Qp; /// Average quantizer for this image, Default=2
58
uint32_t _qSize; /// Size of the *quant bitfield
59
ADM_ASPECT _aspect; /// Aspect ratio
60
uint32_t flags; /// Flags for this image (AVI_KEY_FRAME/AVI_B_FRAME)
62
// This 3 fields are only used to convery container (reference to other datas)
63
// Between codec & editor
64
uint8_t _isRef; /// If True means the datas are just a link to data we don't own!
65
ADM_colorspace _colorspace; /// Colorspace we are moving, default is YV12
66
uint8_t _noPicture; /// No picture to display
68
// End of section dedicated to codec/editor transfer
70
void commonInit(uint32_t w,uint32_t h); /// sub constructor
72
uint32_t GetPitch(ADM_PLANE plane)
76
case PLANAR_Y:return _width;break;
78
case PLANAR_V:return _width>>1;break;
79
default: ADM_assert(0);
82
uint8_t *GetWritePtr(ADM_PLANE plane)
84
uint32_t plan=_width*_height;
87
case PLANAR_Y:return data;break;
88
case PLANAR_U:return data+plan;break;
89
case PLANAR_V:return data+((plan*5)>>2);break;
90
default: ADM_assert(0);
94
uint32_t GetHeight(ADM_PLANE plane)
98
case PLANAR_Y:return _height;break;
100
case PLANAR_V:return _height>>1;break;
101
default: ADM_assert(0);
104
uint8_t duplicateMacro(ADMImage *src,uint32_t swap); /// copy an image to ourself, including info
107
uint8_t *_planes[3]; /// In case of linked data store y/u/v pointers
108
uint32_t _planeStride[3]; /// Same story
110
ADMImage(uint32_t width, uint32_t height);
111
ADMImage(uint32_t width, uint32_t height,uint32_t dummy); /// To create linked datas image
115
uint8_t getWidthHeight(uint32_t *w,uint32_t *h)
121
uint8_t duplicate(ADMImage *src); /// copy an image to ourself, including info
122
uint8_t duplicateSwapUV(ADMImage *src); /// copy an image to ourself, including info
123
uint8_t duplicateFull(ADMImage *src); /// copy an image to ourself, including info
124
uint8_t copyInfo(ADMImage *src); /// copy all the flags, not the data themselves
125
uint8_t copyQuantInfo(ADMImage *src); /// copy quant table if any
126
uint8_t isRef(void) { return _isRef;};
127
uint8_t setLinkInfos(uint8_t *y, /// To fill in infos for linked image
128
uint8_t *u,uint8_t *v,uint32_t stridey,
129
uint32_t strideu, uint32_t stridev);
130
uint8_t merge(ADMImage *src1,ADMImage *src2);
131
uint8_t substract(ADMImage *src1,ADMImage *src2);
132
uint8_t blacken(void);
133
uint8_t copyTo(ADMImage *target, uint32_t x, uint32_t y);
134
uint8_t pack(uint8_t invertChroma); /// Transfer data from planes to regular packed space
135
static uint32_t lumaDiff(ADMImage *src1,ADMImage *src2,uint32_t noise);
137
void drawString(ADMImage *dst, int x, int y, const char *s) ;
138
#define YPLANE(x) (x->data)
139
#define UPLANE(x) (x->data+(x->_width*x->_height))
140
#define VPLANE(x) (x->data+(5*(x->_width*x->_height)>>2))
143
// Simple image resizer
147
class ADMImageResizer
151
uint32_t orgWidth,orgHeight;
152
uint32_t destWidth,destHeight;
154
ADMImageResizer(uint32_t ow,uint32_t oh, uint32_t dw, uint32_t dh);
156
uint8_t resize(ADMImage *src,ADMImage *dest);
164
uint8_t BitBlit(uint8_t *dst, uint32_t pitchDest,uint8_t *src,uint32_t pitchSrc,uint32_t width, uint32_t height);