34 memset(max_pixsteps, 0, 4*
sizeof(max_pixsteps[0]));
35 if (max_pixstep_comps)
36 memset(max_pixstep_comps, 0, 4*
sizeof(max_pixstep_comps[0]));
38 for (i = 0; i < 4; i++) {
42 if (max_pixstep_comps)
43 max_pixstep_comps[comp->
plane] = i;
62 s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->
log2_chroma_w : 0;
63 return max_step[plane] * (((width + (1 << s) - 1)) >> s);
73 memset(linesizes, 0, 4*
sizeof(linesizes[0]));
86 for (i = 0; i < 4; i++) {
87 int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->
log2_chroma_w : 0;
88 int shifted_w = ((width + (1 << s) - 1)) >> s;
89 if (max_step[i] > INT_MAX / shifted_w)
91 linesizes[i] = max_step[i] * shifted_w;
98 uint8_t *ptr,
const int linesizes[4])
100 int i, total_size,
size[4] = { 0 }, has_plane[4] = { 0 };
103 memset(data , 0,
sizeof(data[0])*4);
109 if (linesizes[0] > (INT_MAX - 1024) / height)
111 size[0] = linesizes[0] *
height;
115 size[0] = (size[0] + 3) & ~3;
116 data[1] = ptr + size[0];
117 return size[0] + 256 * 4;
120 for (i = 0; i < 4; i++)
123 total_size = size[0];
124 for (i = 1; i < 4 && has_plane[i]; i++) {
126 data[i] = data[i-1] + size[i-1];
127 h = (height + (1 << s) - 1) >> s;
128 if (linesizes[i] > INT_MAX / h)
130 size[i] = h * linesizes[i];
131 if (total_size > INT_MAX - size[i])
133 total_size += size[i];
143 for (i = 0; i < 256; i++) {
173 pal[i] = b + (g<<8) + (r<<16);
194 for (i = 0; i < 4; i++)
195 linesizes[i] =
FFALIGN(linesizes[i], align);
224 if ((
int)w>0 && (
int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
232 const uint8_t *src,
int src_linesize,
233 int bytewidth,
int height)
237 for (;height > 0; height--) {
238 memcpy(dst, src, bytewidth);
245 const uint8_t *src_data[4],
const int src_linesizes[4],
256 src_data[0], src_linesizes[0],
259 memcpy(dst_data[1], src_data[1], 4*256);
261 int i, planes_nb = 0;
266 for (i = 0; i < planes_nb; i++) {
269 if (i == 1 || i == 2) {
273 src_data[i], src_linesizes[i],
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int av_image_alloc(uint8_t *pointers[4], int linesizes[4], int w, int h, enum AVPixelFormat pix_fmt, int align)
Allocate an image with size w and h and pixel format pix_fmt, and fill pointers and linesizes accordi...
static const AVClass imgutils_class
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
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.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
void av_log(void *avcl, int level, const char *fmt,...)
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
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 AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
common internal API header
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)
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
enum AVPixelFormat pix_fmt
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat 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.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Describe the class of an AVClass context structure.
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
uint16_t step_minus1
Number of elements between 2 horizontally consecutive pixels minus 1.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
uint16_t plane
which of the 4 planes contains the component
common internal and external API header
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
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.
AVPixelFormat
Pixel format.