54 int *is_packed_rgba,
uint8_t rgba_map_ptr[4])
63 if (*is_packed_rgba) {
65 for (i = 0; i < 4; i++)
66 dst_color[rgba_map[i]] = rgba_color[i];
69 for (i = 0; i < w; i++)
70 memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
72 memcpy(rgba_map_ptr, rgba_map,
sizeof(rgba_map[0]) * 4);
76 dst_color[0] =
RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
77 dst_color[1] =
RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
78 dst_color[2] =
RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
79 dst_color[3] = rgba_color[3];
81 for (plane = 0; plane < 4; plane++) {
83 int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
85 pixel_step[plane] = 1;
86 line_size = (w >> hsub1) * pixel_step[plane];
88 memset(line[plane], dst_color[plane], line_size);
96 uint8_t *src[4],
int pixelstep[4],
97 int hsub,
int vsub,
int x,
int y,
int w,
int h)
102 for (plane = 0; plane < 4 && dst[plane]; plane++) {
103 int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
104 int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
106 p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
107 for (i = 0; i < (h >> vsub1); i++) {
108 memcpy(p + (x >> hsub1) * pixelstep[plane],
109 src[plane], (w >> hsub1) * pixelstep[plane]);
110 p += dst_linesize[plane];
116 uint8_t *src[4],
int src_linesize[4],
int pixelstep[4],
117 int hsub,
int vsub,
int x,
int y,
int y2,
int w,
int h)
122 for (plane = 0; plane < 4 && dst[plane]; plane++) {
123 int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
124 int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
126 p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
127 for (i = 0; i < (h >> vsub1); i++) {
128 memcpy(p + (x >> hsub1) * pixelstep[plane],
129 src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), (w >> hsub1) * pixelstep[plane]);
130 p += dst_linesize[plane];
139 unsigned i, nb_planes = 0;
154 if (pixelstep[c->
plane] != 0 &&
158 if (pixelstep[c->
plane] >= 8)
164 memset(draw, 0,
sizeof(*draw));
184 if (rgba != color->
rgba)
185 memcpy(color->
rgba, rgba,
sizeof(color->
rgba));
188 for (i = 0; i < 4; i++)
189 color->
comp[0].
u8[rgba_map[i]] = rgba[i];
195 color->
comp[3].
u8[0] = rgba[3];
198 color->
comp[1].
u8[0] = rgba[3];
201 "Color conversion not implemented for %s\n", draw->
desc->
name);
202 memset(color, 128,
sizeof(*color));
207 int plane,
int x,
int y)
210 (y >> draw->
vsub[plane]) * linesize[plane] +
216 uint8_t *src[],
int src_linesize[],
217 int dst_x,
int dst_y,
int src_x,
int src_y,
220 int plane, y, wp, hp;
223 for (plane = 0; plane < draw->
nb_planes; plane++) {
224 p =
pointer_at(draw, src, src_linesize, plane, src_x, src_y);
225 q =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
227 hp = (h >> draw->
vsub[plane]);
228 for (y = 0; y < hp; y++) {
230 p += src_linesize[plane];
231 q += dst_linesize[plane];
238 int dst_x,
int dst_y,
int w,
int h)
240 int plane, x, y, wp, hp;
243 for (plane = 0; plane < draw->
nb_planes; plane++) {
244 p0 =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
245 wp = (w >> draw->
hsub[plane]);
246 hp = (h >> draw->
vsub[plane]);
251 for (x = 0; x < wp; x++) {
257 p = p0 + dst_linesize[plane];
258 for (y = 1; y < hp; y++) {
260 p += dst_linesize[plane];
291 int mask = (1 << sub) - 1;
293 *start = (-*x) & mask;
295 *start =
FFMIN(*start, *w);
303 return (draw->
comp_mask[plane] >> comp) & 1;
310 int dx,
int w,
unsigned hsub,
int left,
int right)
312 unsigned asrc = alpha * src;
313 unsigned tau = 0x1010101 - alpha;
317 unsigned suba = (left * alpha) >> hsub;
318 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
321 for (x = 0; x < w; x++) {
322 *dst = (*dst * tau + asrc) >> 24;
326 unsigned suba = (right * alpha) >> hsub;
327 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
333 int dst_w,
int dst_h,
334 int x0,
int y0,
int w,
int h)
336 unsigned alpha, nb_planes, nb_comp, plane,
comp;
337 int w_sub, h_sub, x_sub, y_sub, left, right, top, bottom, y;
343 if (w <= 0 || h <= 0 || !color->rgba[3])
346 alpha = 0x10203 * color->
rgba[3] + 0x2;
348 for (plane = 0; plane < nb_planes; plane++) {
350 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
357 for (comp = 0; comp < nb_comp; comp++) {
364 draw->
hsub[plane], left, right);
365 p += dst_linesize[plane];
367 for (y = 0; y < h_sub; y++) {
370 draw->
hsub[plane], left, right);
371 p += dst_linesize[plane];
376 draw->
hsub[plane], left, right);
383 unsigned w,
unsigned h,
unsigned shift,
unsigned xm0)
385 unsigned xm, x, y,
t = 0;
386 unsigned xmshf = 3 - l2depth;
387 unsigned xmmod = 7 >> l2depth;
388 unsigned mbits = (1 << (1 << l2depth)) - 1;
389 unsigned mmult = 255 / mbits;
391 for (y = 0; y < h; y++) {
393 for (x = 0; x < w; x++) {
394 t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
398 mask += mask_linesize;
400 alpha = (t >>
shift) * alpha;
401 *dst = ((0x1010101 - alpha) * *dst + alpha * src) >> 24;
405 unsigned src,
unsigned alpha,
406 uint8_t *
mask,
int mask_linesize,
int l2depth,
int w,
407 unsigned hsub,
unsigned vsub,
408 int xm,
int left,
int right,
int hband)
413 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
414 left, hband, hsub + vsub, xm);
418 for (x = 0; x < w; x++) {
419 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
420 1 << hsub, hband, hsub + vsub, xm);
425 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
426 right, hband, hsub + vsub, xm);
430 uint8_t *
dst[],
int dst_linesize[],
int dst_w,
int dst_h,
431 uint8_t *
mask,
int mask_linesize,
int mask_w,
int mask_h,
432 int l2depth,
unsigned endianness,
int x0,
int y0)
434 unsigned alpha, nb_planes, nb_comp, plane,
comp;
435 int xm0, ym0, w_sub, h_sub, x_sub, y_sub, left, right, top, bottom, y;
440 mask += ym0 * mask_linesize;
441 if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
445 alpha = (0x10307 * color->
rgba[3] + 0x3) >> 8;
447 for (plane = 0; plane < nb_planes; plane++) {
449 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
456 for (comp = 0; comp < nb_comp; comp++) {
463 color->
comp[plane].
u8[comp], alpha,
464 m, mask_linesize, l2depth, w_sub,
465 draw->
hsub[plane], draw->
vsub[plane],
466 xm0, left, right, top);
467 p += dst_linesize[plane];
468 m += top * mask_linesize;
470 for (y = 0; y < h_sub; y++) {
472 color->
comp[plane].
u8[comp], alpha,
473 m, mask_linesize, l2depth, w_sub,
474 draw->
hsub[plane], draw->
vsub[plane],
475 xm0, left, right, 1 << draw->
vsub[plane]);
476 p += dst_linesize[plane];
477 m += mask_linesize << draw->
vsub[plane];
481 color->
comp[plane].
u8[comp], alpha,
482 m, mask_linesize, l2depth, w_sub,
483 draw->
hsub[plane], draw->
vsub[plane],
484 xm0, left, right, bottom);
497 value += round_dir ? (1 <<
shift) - 1 : 1 << (shift - 1);
498 return (value >> shift) <<
shift;
530 printf(
"Testing %s...%*s", desc->
name,
531 (
int)(16 - strlen(desc->
name)),
"");
536 printf(
"no: %s\n", buf);
540 for (i = 0; i <
sizeof(
color); i++)
541 if (((
uint8_t *)&color)[i] != 128)
543 if (i ==
sizeof(color)) {
544 printf(
"fallback color\n");