64 int *is_packed_rgba,
uint8_t rgba_map_ptr[4])
73 if (*is_packed_rgba) {
75 for (i = 0; i < 4; i++)
76 dst_color[rgba_map[i]] = rgba_color[i];
79 for (i = 0; i < w; i++)
80 memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
82 memcpy(rgba_map_ptr, rgba_map,
sizeof(rgba_map[0]) * 4);
86 dst_color[0] =
RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
87 dst_color[1] =
RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
88 dst_color[2] =
RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
89 dst_color[3] = rgba_color[3];
91 for (plane = 0; plane < 4; plane++) {
93 int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
95 pixel_step[plane] = 1;
98 memset(line[plane], dst_color[plane], line_size);
107 int hsub,
int vsub,
int x,
int y,
int w,
int h)
112 for (plane = 0; plane < 4 && dst[plane]; plane++) {
113 int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
114 int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
118 p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
119 for (i = 0; i <
height; i++) {
120 memcpy(p + (x >> hsub1) * pixelstep[plane],
121 src[plane], width * pixelstep[plane]);
122 p += dst_linesize[plane];
128 uint8_t *
src[4],
int src_linesize[4],
int pixelstep[4],
129 int hsub,
int vsub,
int x,
int y,
int y2,
int w,
int h)
134 for (plane = 0; plane < 4 && dst[plane]; plane++) {
135 int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
136 int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
140 p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
141 for (i = 0; i <
height; i++) {
142 memcpy(p + (x >> hsub1) * pixelstep[plane],
143 src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), width * pixelstep[plane]);
144 p += dst_linesize[plane];
153 unsigned i, nb_planes = 0;
168 if (pixelstep[c->
plane] != 0 &&
172 if (pixelstep[c->
plane] >= 8)
178 memset(draw, 0,
sizeof(*draw));
196 if (rgba != color->
rgba)
197 memcpy(color->
rgba, rgba,
sizeof(color->
rgba));
201 for (i = 0; i < 4; i++)
202 color->
comp[0].
u8[rgba_map[i]] = rgba[i];
204 for (i = 0; i < 4; i++)
205 color->
comp[rgba_map[i]].
u8[0] = rgba[i];
212 color->
comp[3].
u8[0] = rgba[3];
215 color->
comp[1].
u8[0] = rgba[3];
218 "Color conversion not implemented for %s\n", draw->
desc->
name);
219 memset(color, 128,
sizeof(*color));
224 int plane,
int x,
int y)
227 (y >> draw->
vsub[plane]) * linesize[plane] +
232 uint8_t *dst[],
int dst_linesize[],
234 int dst_x,
int dst_y,
int src_x,
int src_y,
237 int plane,
y, wp, hp;
240 for (plane = 0; plane < draw->
nb_planes; plane++) {
241 p =
pointer_at(draw, src, src_linesize, plane, src_x, src_y);
242 q =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
245 for (y = 0; y < hp; y++) {
247 p += src_linesize[plane];
248 q += dst_linesize[plane];
254 uint8_t *dst[],
int dst_linesize[],
255 int dst_x,
int dst_y,
int w,
int h)
257 int plane, x,
y, wp, hp;
260 for (plane = 0; plane < draw->
nb_planes; plane++) {
261 p0 =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
268 for (x = 0; x < wp; x++) {
274 p = p0 + dst_linesize[plane];
275 for (y = 1; y < hp; y++) {
277 p += dst_linesize[plane];
308 int mask = (1 << sub) - 1;
310 *start = (-*x) & mask;
312 *start =
FFMIN(*start, *w);
320 return (draw->
comp_mask[plane] >> comp) & 1;
327 int dx,
int w,
unsigned hsub,
int left,
int right)
329 unsigned asrc = alpha *
src;
330 unsigned tau = 0x1010101 -
alpha;
334 unsigned suba = (left *
alpha) >> hsub;
335 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
338 for (x = 0; x < w; x++) {
339 *dst = (*dst * tau + asrc) >> 24;
343 unsigned suba = (right *
alpha) >> hsub;
344 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
349 uint8_t *dst[],
int dst_linesize[],
350 int dst_w,
int dst_h,
351 int x0,
int y0,
int w,
int h)
353 unsigned alpha, nb_planes, nb_comp, plane,
comp;
354 int w_sub, h_sub, x_sub, y_sub, left, right, top, bottom,
y;
360 if (w <= 0 || h <= 0 || !color->rgba[3])
363 alpha = 0x10203 * color->
rgba[3] + 0x2;
365 for (plane = 0; plane < nb_planes; plane++) {
367 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
374 for (comp = 0; comp < nb_comp; comp++) {
381 draw->
hsub[plane], left, right);
382 p += dst_linesize[plane];
384 for (y = 0; y < h_sub; y++) {
387 draw->
hsub[plane], left, right);
388 p += dst_linesize[plane];
393 draw->
hsub[plane], left, right);
400 unsigned w,
unsigned h,
unsigned shift,
unsigned xm0)
402 unsigned xm, x,
y,
t = 0;
403 unsigned xmshf = 3 - l2depth;
404 unsigned xmmod = 7 >> l2depth;
405 unsigned mbits = (1 << (1 << l2depth)) - 1;
406 unsigned mmult = 255 / mbits;
408 for (y = 0; y < h; y++) {
410 for (x = 0; x < w; x++) {
411 t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
415 mask += mask_linesize;
417 alpha = (t >>
shift) * alpha;
418 *dst = ((0x1010101 -
alpha) * *dst + alpha * src) >> 24;
423 uint8_t *
mask,
int mask_linesize,
int l2depth,
int w,
424 unsigned hsub,
unsigned vsub,
425 int xm,
int left,
int right,
int hband)
430 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
431 left, hband, hsub + vsub, xm);
435 for (x = 0; x < w; x++) {
436 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
437 1 << hsub, hband, hsub + vsub, xm);
442 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
443 right, hband, hsub + vsub, xm);
447 uint8_t *dst[],
int dst_linesize[],
int dst_w,
int dst_h,
448 uint8_t *
mask,
int mask_linesize,
int mask_w,
int mask_h,
449 int l2depth,
unsigned endianness,
int x0,
int y0)
451 unsigned alpha, nb_planes, nb_comp, plane,
comp;
452 int xm0, ym0, w_sub, h_sub, x_sub, y_sub, left, right, top, bottom,
y;
457 mask += ym0 * mask_linesize;
458 if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
462 alpha = (0x10307 * color->
rgba[3] + 0x3) >> 8;
464 for (plane = 0; plane < nb_planes; plane++) {
466 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
473 for (comp = 0; comp < nb_comp; comp++) {
480 color->
comp[plane].
u8[comp], alpha,
481 m, mask_linesize, l2depth, w_sub,
482 draw->
hsub[plane], draw->
vsub[plane],
483 xm0, left, right, top);
484 p += dst_linesize[plane];
485 m += top * mask_linesize;
487 for (y = 0; y < h_sub; y++) {
489 color->
comp[plane].
u8[comp], alpha,
490 m, mask_linesize, l2depth, w_sub,
491 draw->
hsub[plane], draw->
vsub[plane],
492 xm0, left, right, 1 << draw->
vsub[plane]);
493 p += dst_linesize[plane];
494 m += mask_linesize << draw->
vsub[plane];
498 color->
comp[plane].
u8[comp], alpha,
499 m, mask_linesize, l2depth, w_sub,
500 draw->
hsub[plane], draw->
vsub[plane],
501 xm0, left, right, bottom);
514 value += round_dir ? (1 <<
shift) - 1 : 1 << (shift - 1);
515 return (value >> shift) <<
shift;
547 printf(
"Testing %s...%*s", desc->
name,
548 (
int)(16 - strlen(desc->
name)),
"");
553 printf(
"no: %s\n", buf);
557 for (i = 0; i <
sizeof(
color); i++)
558 if (((
uint8_t *)&color)[i] != 128)
560 if (i ==
sizeof(color)) {
561 printf(
"fallback color\n");