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;
96 line_size = (w >> hsub1) * pixel_step[plane];
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;
116 p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
117 for (i = 0; i < (h >> vsub1); i++) {
118 memcpy(p + (x >> hsub1) * pixelstep[plane],
119 src[plane], (w >> hsub1) * pixelstep[plane]);
120 p += dst_linesize[plane];
126 uint8_t *
src[4],
int src_linesize[4],
int pixelstep[4],
127 int hsub,
int vsub,
int x,
int y,
int y2,
int w,
int h)
132 for (plane = 0; plane < 4 && dst[plane]; plane++) {
133 int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
134 int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
136 p = dst[plane] + (y >> vsub1) * dst_linesize[plane];
137 for (i = 0; i < (h >> vsub1); i++) {
138 memcpy(p + (x >> hsub1) * pixelstep[plane],
139 src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), (w >> hsub1) * pixelstep[plane]);
140 p += dst_linesize[plane];
149 unsigned i, nb_planes = 0;
164 if (pixelstep[c->
plane] != 0 &&
168 if (pixelstep[c->
plane] >= 8)
174 memset(draw, 0,
sizeof(*draw));
194 if (rgba != color->
rgba)
195 memcpy(color->
rgba, rgba,
sizeof(color->
rgba));
198 for (i = 0; i < 4; i++)
199 color->
comp[0].
u8[rgba_map[i]] = rgba[i];
205 color->
comp[3].
u8[0] = rgba[3];
208 color->
comp[1].
u8[0] = rgba[3];
211 "Color conversion not implemented for %s\n", draw->
desc->
name);
212 memset(color, 128,
sizeof(*color));
217 int plane,
int x,
int y)
220 (y >> draw->
vsub[plane]) * linesize[plane] +
227 int dst_x,
int dst_y,
int src_x,
int src_y,
230 int plane,
y, wp, hp;
233 for (plane = 0; plane < draw->
nb_planes; plane++) {
234 p =
pointer_at(draw, src, src_linesize, plane, src_x, src_y);
235 q =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
237 hp = (h >> draw->
vsub[plane]);
238 for (y = 0; y < hp; y++) {
240 p += src_linesize[plane];
241 q += dst_linesize[plane];
248 int dst_x,
int dst_y,
int w,
int h)
250 int plane, x,
y, wp, hp;
253 for (plane = 0; plane < draw->
nb_planes; plane++) {
254 p0 =
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
255 wp = (w >> draw->
hsub[plane]);
256 hp = (h >> draw->
vsub[plane]);
261 for (x = 0; x < wp; x++) {
267 p = p0 + dst_linesize[plane];
268 for (y = 1; y < hp; y++) {
270 p += dst_linesize[plane];
301 int mask = (1 << sub) - 1;
303 *start = (-*x) & mask;
305 *start =
FFMIN(*start, *w);
313 return (draw->
comp_mask[plane] >> comp) & 1;
320 int dx,
int w,
unsigned hsub,
int left,
int right)
322 unsigned asrc = alpha *
src;
323 unsigned tau = 0x1010101 -
alpha;
327 unsigned suba = (left *
alpha) >> hsub;
328 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
331 for (x = 0; x < w; x++) {
332 *dst = (*dst * tau + asrc) >> 24;
336 unsigned suba = (right *
alpha) >> hsub;
337 *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
343 int dst_w,
int dst_h,
344 int x0,
int y0,
int w,
int h)
346 unsigned alpha, nb_planes, nb_comp, plane,
comp;
347 int w_sub, h_sub, x_sub, y_sub, left, right, top, bottom,
y;
353 if (w <= 0 || h <= 0 || !color->rgba[3])
356 alpha = 0x10203 * color->
rgba[3] + 0x2;
358 for (plane = 0; plane < nb_planes; plane++) {
360 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
367 for (comp = 0; comp < nb_comp; comp++) {
374 draw->
hsub[plane], left, right);
375 p += dst_linesize[plane];
377 for (y = 0; y < h_sub; y++) {
380 draw->
hsub[plane], left, right);
381 p += dst_linesize[plane];
386 draw->
hsub[plane], left, right);
393 unsigned w,
unsigned h,
unsigned shift,
unsigned xm0)
395 unsigned xm, x,
y,
t = 0;
396 unsigned xmshf = 3 - l2depth;
397 unsigned xmmod = 7 >> l2depth;
398 unsigned mbits = (1 << (1 << l2depth)) - 1;
399 unsigned mmult = 255 / mbits;
401 for (y = 0; y < h; y++) {
403 for (x = 0; x < w; x++) {
404 t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
408 mask += mask_linesize;
410 alpha = (t >>
shift) * alpha;
411 *dst = ((0x1010101 -
alpha) * *dst + alpha * src) >> 24;
416 uint8_t *
mask,
int mask_linesize,
int l2depth,
int w,
417 unsigned hsub,
unsigned vsub,
418 int xm,
int left,
int right,
int hband)
423 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
424 left, hband, hsub + vsub, xm);
428 for (x = 0; x < w; x++) {
429 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
430 1 << hsub, hband, hsub + vsub, xm);
435 blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
436 right, hband, hsub + vsub, xm);
440 uint8_t *
dst[],
int dst_linesize[],
int dst_w,
int dst_h,
441 uint8_t *
mask,
int mask_linesize,
int mask_w,
int mask_h,
442 int l2depth,
unsigned endianness,
int x0,
int y0)
444 unsigned alpha, nb_planes, nb_comp, plane,
comp;
445 int xm0, ym0, w_sub, h_sub, x_sub, y_sub, left, right, top, bottom,
y;
450 mask += ym0 * mask_linesize;
451 if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
455 alpha = (0x10307 * color->
rgba[3] + 0x3) >> 8;
457 for (plane = 0; plane < nb_planes; plane++) {
459 p0 =
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
466 for (comp = 0; comp < nb_comp; comp++) {
473 color->
comp[plane].
u8[comp], alpha,
474 m, mask_linesize, l2depth, w_sub,
475 draw->
hsub[plane], draw->
vsub[plane],
476 xm0, left, right, top);
477 p += dst_linesize[plane];
478 m += top * mask_linesize;
480 for (y = 0; y < h_sub; y++) {
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, 1 << draw->
vsub[plane]);
486 p += dst_linesize[plane];
487 m += mask_linesize << draw->
vsub[plane];
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, bottom);
507 value += round_dir ? (1 <<
shift) - 1 : 1 << (shift - 1);
508 return (value >> shift) <<
shift;
540 printf(
"Testing %s...%*s", desc->
name,
541 (
int)(16 - strlen(desc->
name)),
"");
546 printf(
"no: %s\n", buf);
550 for (i = 0; i <
sizeof(
color); i++)
551 if (((
uint8_t *)&color)[i] != 128)
553 if (i ==
sizeof(color)) {
554 printf(
"fallback color\n");