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++)