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));
198 if (rgba != color->
rgba)
199 memcpy(color->
rgba, rgba,
sizeof(color->
rgba));
203 for (i = 0; i < 4; i++)
204 color->
comp[0].
u8[rgba_map[i]] = rgba[i];
206 for (i = 0; i < 4; i++)
207 color->
comp[rgba_map[i]].
u8[0] = rgba[i];
214 color->
comp[3].
u8[0] = rgba[3];
217 color->
comp[1].
u8[0] = rgba[3];
220 "Color conversion not implemented for %s\n", draw->
desc->
name);
221 memset(color, 128,
sizeof(*color));
226 int plane,
int x,
int y)
229 (y >> draw->
vsub[plane]) * linesize[plane] +
234 uint8_t *dst[],
int dst_linesize[],
236 int dst_x,
int dst_y,
int src_x,
int src_y,
239 int plane,
y, wp, hp;
242 for (plane = 0; plane < draw->
nb_planes; plane++) {
243 p =
pointer_at(draw, src, src_linesize, plane, src_x, src_y);
244 q =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
247 for (y = 0; y < hp; y++) {
249 p += src_linesize[plane];
250 q += dst_linesize[plane];
256 uint8_t *dst[],
int dst_linesize[],
257 int dst_x,
int dst_y,
int w,
int h)
259 int plane, x,
y, wp, hp;
262 for (plane = 0; plane < draw->
nb_planes; plane++) {
263 p0 =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
270 for (x = 0; x < wp; x++) {
276 p = p0 + dst_linesize[plane];
277 for (y = 1; y < hp; y++) {
279 p += dst_linesize[plane];
310 int mask = (1 << sub) - 1;
312 *start = (-*x) & mask;
314 *start =
FFMIN(*start, *w);
322 return (draw->
comp_mask[plane] >> comp) & 1;
329 int dx,
int w,
unsigned hsub,
int left,
int right)
331 unsigned asrc = alpha *
src;
332 unsigned tau = 0x1010101 -
alpha;
336 unsigned suba = (left *
alpha) >> hsub;
337 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
340 for (x = 0; x < w; x++) {
341 *dst = (*dst * tau + asrc) >> 24;
345 unsigned suba = (right *
alpha) >> hsub;
346 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
351 uint8_t *dst[],
int dst_linesize[],
352 int dst_w,
int dst_h,
353 int x0,
int y0,
int w,
int h)
355 unsigned alpha, nb_planes, nb_comp, plane,
comp;
356 int w_sub, h_sub, x_sub, y_sub, left, right, top, bottom,
y;
362 if (w <= 0 || h <= 0 || !color->rgba[3])
365 alpha = 0x10203 * color->
rgba[3] + 0x2;
367 for (plane = 0; plane < nb_planes; plane++) {
369 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
376 for (comp = 0; comp < nb_comp; comp++) {
383 draw->
hsub[plane], left, right);
384 p += dst_linesize[plane];
386 for (y = 0; y < h_sub; y++) {
389 draw->
hsub[plane], left, right);
390 p += dst_linesize[plane];
395 draw->
hsub[plane], left, right);
402 unsigned w,
unsigned h,
unsigned shift,
unsigned xm0)
404 unsigned xm, x,
y,
t = 0;
405 unsigned xmshf = 3 - l2depth;
406 unsigned xmmod = 7 >> l2depth;
407 unsigned mbits = (1 << (1 << l2depth)) - 1;
408 unsigned mmult = 255 / mbits;
410 for (y = 0; y < h; y++) {
412 for (x = 0; x < w; x++) {
413 t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
417 mask += mask_linesize;
419 alpha = (t >>
shift) * alpha;
420 *dst = ((0x1010101 -
alpha) * *dst + alpha * src) >> 24;
425 uint8_t *
mask,
int mask_linesize,
int l2depth,
int w,
426 unsigned hsub,
unsigned vsub,
427 int xm,
int left,
int right,
int hband)
432 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
433 left, hband, hsub + vsub, xm);
437 for (x = 0; x < w; x++) {
438 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
439 1 << hsub, hband, hsub + vsub, xm);
444 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
445 right, hband, hsub + vsub, xm);
449 uint8_t *dst[],
int dst_linesize[],
int dst_w,
int dst_h,
450 uint8_t *
mask,
int mask_linesize,
int mask_w,
int mask_h,
451 int l2depth,
unsigned endianness,
int x0,
int y0)
453 unsigned alpha, nb_planes, nb_comp, plane,
comp;
454 int xm0, ym0, w_sub, h_sub, x_sub, y_sub, left, right, top, bottom,
y;
459 mask += ym0 * mask_linesize;
460 if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
464 alpha = (0x10307 * color->
rgba[3] + 0x3) >> 8;
466 for (plane = 0; plane < nb_planes; plane++) {
468 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
475 for (comp = 0; comp < nb_comp; comp++) {
482 color->
comp[plane].
u8[comp], alpha,
483 m, mask_linesize, l2depth, w_sub,
484 draw->
hsub[plane], draw->
vsub[plane],
485 xm0, left, right, top);
486 p += dst_linesize[plane];
487 m += top * mask_linesize;
489 for (y = 0; y < h_sub; y++) {
491 color->
comp[plane].
u8[comp], alpha,
492 m, mask_linesize, l2depth, w_sub,
493 draw->
hsub[plane], draw->
vsub[plane],
494 xm0, left, right, 1 << draw->
vsub[plane]);
495 p += dst_linesize[plane];
496 m += mask_linesize << draw->
vsub[plane];
500 color->
comp[plane].
u8[comp], alpha,
501 m, mask_linesize, l2depth, w_sub,
502 draw->
hsub[plane], draw->
vsub[plane],
503 xm0, left, right, bottom);
516 value += round_dir ? (1 <<
shift) - 1 : 1 << (shift - 1);
517 return (value >> shift) <<
shift;
549 printf(
"Testing %s...%*s", desc->
name,
550 (
int)(16 - strlen(desc->
name)),
"");
555 printf(
"no: %s\n", buf);
559 for (i = 0; i <
sizeof(
color); i++)
560 if (((
uint8_t *)&color)[i] != 128)
562 if (i ==
sizeof(color)) {
563 printf(
"fallback color\n");