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);
237 if ((
int)w>0 && (
int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8)
248 if (sar.
den <= 0 || sar.
num < 0)
267 int bytewidth,
int height)
273 for (;height > 0; height--) {
274 memcpy(dst, src, bytewidth);
281 const uint8_t *src_data[4],
const int src_linesizes[4],
292 src_data[0], src_linesizes[0],
295 memcpy(dst_data[1], src_data[1], 4*256);
297 int i, planes_nb = 0;
302 for (i = 0; i < planes_nb; i++) {
309 if (i == 1 || i == 2) {
313 src_data[i], src_linesizes[i],
333 for (i = 0; i < 4; i++)
334 dst_linesize[i] =
FFALIGN(dst_linesize[i], align);
358 width, height, align);
362 const uint8_t *
const src_data[4],
363 const int src_linesize[4],
367 int i, j, nb_planes = 0, linesize[4];
371 if (size > dst_size || size < 0 || !desc)
380 for (i = 0; i < nb_planes; i++) {
383 h = (height + (1 << shift) - 1) >> shift;
385 for (j = 0; j < h; j++) {
386 memcpy(dst,
src, linesize[i]);
387 dst +=
FFALIGN(linesize[i], align);
388 src += src_linesize[i];
393 uint32_t *
d32 = (uint32_t *)(((
size_t)dst + 3) & ~3);
394 for (i = 0; i<256; i++)