38 memset(max_pixsteps, 0, 4*
sizeof(max_pixsteps[0]));
39 if (max_pixstep_comps)
40 memset(max_pixstep_comps, 0, 4*
sizeof(max_pixstep_comps[0]));
42 for (i = 0; i < 4; i++) {
46 if (max_pixstep_comps)
47 max_pixstep_comps[comp->
plane] = i;
54 int max_step,
int max_step_comp,
57 int s, shifted_w, linesize;
64 s = (max_step_comp == 1 || max_step_comp == 2) ? desc->
log2_chroma_w : 0;
65 shifted_w = ((width + (1 << s) - 1)) >> s;
66 if (shifted_w && max_step > INT_MAX / shifted_w)
68 linesize = max_step * shifted_w;
71 linesize = (linesize + 7) >> 3;
95 memset(linesizes, 0, 4*
sizeof(linesizes[0]));
101 for (i = 0; i < 4; i++) {
111 uint8_t *ptr,
const int linesizes[4])
113 int i, total_size,
size[4] = { 0 }, has_plane[4] = { 0 };
116 memset(data , 0,
sizeof(data[0])*4);
122 if (linesizes[0] > (INT_MAX - 1024) / height)
124 size[0] = linesizes[0] *
height;
128 size[0] = (size[0] + 3) & ~3;
129 data[1] = ptr + size[0];
130 return size[0] + 256 * 4;
133 for (i = 0; i < 4; i++)
136 total_size = size[0];
137 for (i = 1; i < 4 && has_plane[i]; i++) {
139 data[i] = data[i-1] + size[i-1];
140 h = (height + (1 << s) - 1) >> s;
141 if (linesizes[i] > INT_MAX / h)
143 size[i] = h * linesizes[i];
144 if (total_size > INT_MAX - size[i])
146 total_size += size[i];
156 for (i = 0; i < 256; i++) {
186 pal[i] = b + (g << 8) + (r << 16) + (0xFF
U << 24);
207 for (i = 0; i < 4; i++)
208 linesizes[i] =
FFALIGN(linesizes[i], align);
224 pointers[1] - pointers[0] > linesizes[0] * h) {
226 memset(pointers[0] + linesizes[0] * h, 0,
227 pointers[1] - pointers[0] - linesizes[0] * h);
245 if ((
int)w>0 && (
int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
256 if (sar.
den <= 0 || sar.
num < 0)
275 int bytewidth,
int height)
281 for (;height > 0; height--) {
282 memcpy(dst, src, bytewidth);
289 const uint8_t *src_data[4],
const int src_linesizes[4],
300 src_data[0], src_linesizes[0],
303 memcpy(dst_data[1], src_data[1], 4*256);
305 int i, planes_nb = 0;
310 for (i = 0; i < planes_nb; i++) {
317 if (i == 1 || i == 2) {
321 src_data[i], src_linesizes[i],
341 for (i = 0; i < 4; i++)
342 dst_linesize[i] =
FFALIGN(dst_linesize[i], align);
366 width, height, align);
370 const uint8_t *
const src_data[4],
371 const int src_linesize[4],
375 int i, j, nb_planes = 0, linesize[4];
379 if (size > dst_size || size < 0 || !desc)
388 for (i = 0; i < nb_planes; i++) {
391 h = (height + (1 << shift) - 1) >> shift;
393 for (j = 0; j <
h; j++) {
394 memcpy(dst,
src, linesize[i]);
395 dst +=
FFALIGN(linesize[i], align);
396 src += src_linesize[i];
401 uint32_t *
d32 = (uint32_t *)(((
size_t)dst + 3) & ~3);
402 for (i = 0; i<256; i++)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
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 enum AVPixelFormat pix_fmt
static int shift(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
ptrdiff_t const GLvoid * data
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.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
#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...
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.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar)
Check if the given sample aspect ratio of an image is valid.
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.
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.
simple assert() macros that are a bit more flexible than ISO C assert().
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 FF_CEIL_RSHIFT(a, b)
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
static int image_get_linesize(int width, int plane, int max_step, int max_step_comp, const AVPixFmtDescriptor *desc)
const AVS_VideoInfo int align
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...
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.
rational number numerator/denominator
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)
number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of...
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.