37 memset(max_pixsteps, 0, 4*
sizeof(max_pixsteps[0]));
38 if (max_pixstep_comps)
39 memset(max_pixstep_comps, 0, 4*
sizeof(max_pixstep_comps[0]));
41 for (i = 0; i < 4; i++) {
43 if (comp->
step > max_pixsteps[comp->
plane]) {
45 if (max_pixstep_comps)
46 max_pixstep_comps[comp->
plane] = i;
62 return (width * desc->
comp[0].
step + 7) >> 3;
65 s = (max_step_comp[plane] == 1 || max_step_comp[plane] == 2) ? desc->
log2_chroma_w : 0;
66 return max_step[plane] * (((width + (1 << s) - 1)) >> s);
76 memset(linesizes, 0, 4*
sizeof(linesizes[0]));
82 if (width > (INT_MAX - 7) / desc->
comp[0].
step)
84 linesizes[0] = (width * desc->
comp[0].
step + 7) >> 3;
89 for (i = 0; i < 4; i++) {
90 int s = (max_step_comp[i] == 1 || max_step_comp[i] == 2) ? desc->
log2_chroma_w : 0;
91 int shifted_w = ((width + (1 << s) - 1)) >> s;
92 if (max_step[i] > INT_MAX / shifted_w)
94 linesizes[i] = max_step[i] * shifted_w;
101 uint8_t *ptr,
const int linesizes[4])
103 int i, total_size,
size[4] = { 0 }, has_plane[4] = { 0 };
106 memset(data , 0,
sizeof(data[0])*4);
112 if (linesizes[0] > (INT_MAX - 1024) / height)
114 size[0] = linesizes[0] *
height;
118 size[0] = (size[0] + 3) & ~3;
119 data[1] = ptr + size[0];
120 return size[0] + 256 * 4;
123 for (i = 0; i < 4; i++)
126 total_size = size[0];
127 for (i = 1; i < 4 && has_plane[i]; i++) {
129 data[i] = data[i-1] + size[i-1];
130 h = (height + (1 << s) - 1) >> s;
131 if (linesizes[i] > INT_MAX / h)
133 size[i] = h * linesizes[i];
134 if (total_size > INT_MAX - size[i])
136 total_size += size[i];
146 for (i = 0; i < 256; i++) {
176 pal[i] = b + (g << 8) + (r << 16) + (0xFF
U << 24);
197 for (i = 0; i < 4; i++)
198 linesizes[i] =
FFALIGN(linesizes[i], align);
227 if ((
int)w>0 && (
int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
257 int bytewidth,
int height)
261 for (;height > 0; height--) {
262 memcpy(dst, src, bytewidth);
269 const uint8_t *src_data[4],
const int src_linesizes[4],
280 src_data[0], src_linesizes[0],
283 memcpy(dst_data[1], src_data[1], 4*256);
285 int i, planes_nb = 0;
290 for (i = 0; i < planes_nb; i++) {
293 if (i == 1 || i == 2) {
297 src_data[i], src_linesizes[i],
317 for (i = 0; i < 4; i++)
318 dst_linesize[i] =
FFALIGN(dst_linesize[i], align);
342 width, height, align);
346 const uint8_t *
const src_data[4],
347 const int src_linesize[4],
351 int i, j, nb_planes = 0, linesize[4];
355 if (size > dst_size || size < 0 || !desc)
364 for (i = 0; i < nb_planes; i++) {
367 h = (height + (1 << shift) - 1) >> shift;
369 for (j = 0; j < h; j++) {
370 memcpy(dst,
src, linesize[i]);
371 dst +=
FFALIGN(linesize[i], align);
372 src += src_linesize[i];
377 memcpy((
unsigned char *)(((
size_t)dst + 3) & ~3),
378 src_data[1], 256 * 4);
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
int plane
Which of the 4 planes contains the component.
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_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.
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
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
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.
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.
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_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
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
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...
#define AVERROR_BUG
Bug detected, please report the issue.
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
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
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.
int step
Number of elements between 2 horizontally consecutive pixels.
#define AV_CEIL_RSHIFT(a, b)
Fast a / (1 << b) rounded toward +inf, assuming a >= 0 and b >= 0.