33 memset(max_pixsteps, 0, 4*
sizeof(max_pixsteps[0]));
34 if (max_pixstep_comps)
35 memset(max_pixstep_comps, 0, 4*
sizeof(max_pixstep_comps[0]));
37 for (i = 0; i < 4; i++) {
41 if (max_pixstep_comps)
42 max_pixstep_comps[comp->
plane] = i;
58 s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->
log2_chroma_w : 0;
59 return max_step[plane] * (((width + (1 << s) - 1)) >> s);
69 memset(linesizes, 0, 4*
sizeof(linesizes[0]));
82 for (i = 0; i < 4; i++) {
83 int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->
log2_chroma_w : 0;
84 int shifted_w = ((width + (1 << s) - 1)) >> s;
85 if (max_step[i] > INT_MAX / shifted_w)
87 linesizes[i] = max_step[i] * shifted_w;
94 uint8_t *ptr,
const int linesizes[4])
96 int i, total_size,
size[4], has_plane[4];
99 memset(data , 0,
sizeof(data[0])*4);
100 memset(size , 0,
sizeof(size));
101 memset(has_plane, 0,
sizeof(has_plane));
107 if (linesizes[0] > (INT_MAX - 1024) / height)
109 size[0] = linesizes[0] *
height;
112 size[0] = (size[0] + 3) & ~3;
113 data[1] = ptr + size[0];
114 return size[0] + 256 * 4;
117 for (i = 0; i < 4; i++)
120 total_size = size[0];
121 for (i = 1; i < 4 && has_plane[i]; i++) {
123 data[i] = data[i-1] + size[i-1];
124 h = (height + (1 << s) - 1) >> s;
125 if (linesizes[i] > INT_MAX / h)
127 size[i] = h * linesizes[i];
128 if (total_size > INT_MAX - size[i])
130 total_size += size[i];
140 for (i = 0; i < 256; i++) {
170 pal[i] = b + (g<<8) + (r<<16);
187 for (i = 0; i < 4; i++)
188 linesizes[i] =
FFALIGN(linesizes[i], align);
217 if ((
int)w>0 && (
int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
225 const uint8_t *src,
int src_linesize,
226 int bytewidth,
int height)
230 for (;height > 0; height--) {
231 memcpy(dst, src, bytewidth);
238 const uint8_t *src_data[4],
const int src_linesizes[4],
248 src_data[0], src_linesizes[0],
251 memcpy(dst_data[1], src_data[1], 4*256);
253 int i, planes_nb = 0;
258 for (i = 0; i < planes_nb; i++) {
261 if (i == 1 || i == 2) {
265 src_data[i], src_linesizes[i],
static const AVClass imgutils_class
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4])
Fill plane data pointers for an image with pixel format pix_fmt and height height.
int ff_set_systematic_pal2(uint32_t pal[256], enum PixelFormat pix_fmt)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define PIX_FMT_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
void av_log(void *avcl, int level, const char *fmt,...)
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
int av_image_get_linesize(enum PixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane...
common internal API header
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
uint8_t nb_components
The number of components each pixel has, (1-4)
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum PixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
#define PIX_FMT_BITSTREAM
All values of a component are bit-wise packed end to end.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum PixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
#define PIX_FMT_HWACCEL
Pixel format is an HW accelerated format.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Describe the class of an AVClass context structure.
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
uint16_t step_minus1
Number of elements between 2 horizontally consecutive pixels minus 1.
uint16_t plane
which of the 4 planes contains the component
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
int av_image_fill_linesizes(int linesizes[4], enum PixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.