36 memset(max_pixsteps, 0, 4*
sizeof(max_pixsteps[0]));
37 if (max_pixstep_comps)
38 memset(max_pixstep_comps, 0, 4*
sizeof(max_pixstep_comps[0]));
40 for (i = 0; i < 4; i++) {
44 if (max_pixstep_comps)
45 max_pixstep_comps[comp->
plane] = i;
52 int max_step,
int max_step_comp,
55 int s, shifted_w, linesize;
62 s = (max_step_comp == 1 || max_step_comp == 2) ? desc->
log2_chroma_w : 0;
63 shifted_w = ((width + (1 << s) - 1)) >> s;
64 if (shifted_w && max_step > INT_MAX / shifted_w)
66 linesize = max_step * shifted_w;
69 linesize = (linesize + 7) >> 3;
93 memset(linesizes, 0, 4*
sizeof(linesizes[0]));
99 for (i = 0; i < 4; i++) {
109 uint8_t *ptr,
const int linesizes[4])
111 int i, total_size,
size[4] = { 0 }, has_plane[4] = { 0 };
114 memset(data , 0,
sizeof(data[0])*4);
120 if (linesizes[0] > (INT_MAX - 1024) / height)
122 size[0] = linesizes[0] *
height;
126 size[0] = (size[0] + 3) & ~3;
127 data[1] = ptr + size[0];
128 return size[0] + 256 * 4;
131 for (i = 0; i < 4; i++)
134 total_size = size[0];
135 for (i = 1; i < 4 && has_plane[i]; i++) {
137 data[i] = data[i-1] + size[i-1];
138 h = (height + (1 << s) - 1) >> s;
139 if (linesizes[i] > INT_MAX / h)
141 size[i] = h * linesizes[i];
142 if (total_size > INT_MAX - size[i])
144 total_size += size[i];
154 for (i = 0; i < 256; i++) {
184 pal[i] = b + (g<<8) + (r<<16) + (0xFF
U<<24);
205 for (i = 0; i < 4; i++)
206 linesizes[i] =
FFALIGN(linesizes[i], align);
235 if ((
int)w>0 && (
int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
244 int bytewidth,
int height)
250 for (;height > 0; height--) {
251 memcpy(dst, src, bytewidth);
258 const uint8_t *src_data[4],
const int src_linesizes[4],
269 src_data[0], src_linesizes[0],
272 memcpy(dst_data[1], src_data[1], 4*256);
274 int i, planes_nb = 0;
279 for (i = 0; i < planes_nb; i++) {
286 if (i == 1 || i == 2) {
290 src_data[i], src_linesizes[i],
308 for (i = 0; i < 4; i++)
309 dst_linesize[i] =
FFALIGN(dst_linesize[i], align);
334 const uint8_t *
const src_data[4],
const int src_linesize[4],
337 int i, j, nb_planes = 0, linesize[4];
341 if (size > dst_size || size < 0)
349 for (i = 0; i < nb_planes; i++) {
352 h = (height + (1 << shift) - 1) >> shift;
354 for (j = 0; j < h; j++) {
355 memcpy(dst,
src, linesize[i]);
356 dst +=
FFALIGN(linesize[i], align);
357 src += src_linesize[i];
362 uint32_t *
d32 = (uint32_t *)(((
size_t)dst + 3) & ~3);
363 for (i = 0; i<256; i++)
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...
static int shift(int a, int b)
int av_image_copy_to_buffer(uint8_t *dst, int dst_size, const uint8_t *const src_data[4], const int src_linesize[4], enum AVPixelFormat pix_fmt, int width, int height, int align)
Copy image data from an image into a buffer.
#define LIBAVUTIL_VERSION_INT
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
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], const uint8_t *src, enum AVPixelFormat pix_fmt, int width, int height, int align)
Setup the data pointers and linesizes based on the specified image parameters and the provided array...
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
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.
simple assert() macros that are a bit more flexible than ISO C assert().
const char * av_default_item_name(void *ctx)
Return the context name.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
#define FF_CEIL_RSHIFT(a, b)
packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
enum AVPixelFormat pix_fmt
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
#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.
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
AVPixelFormat
Pixel format.
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)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int image_get_linesize(int width, int plane, int max_step, int max_step_comp, const AVPixFmtDescriptor *desc)
packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
const AVS_VideoInfo int align
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
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...
BYTE int const BYTE int int int height
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.
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
#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
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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.
common internal and external API header
packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)