From: Dr.Smile Date: Mon, 10 Nov 2014 19:36:21 +0000 (+0300) Subject: Flip coordinate system in rasterizer X-Git-Tag: 0.12.1~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3f8230189634e0ce4ffe06c1e380bea829d85d9;p=libass Flip coordinate system in rasterizer --- diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index e6bec82..0eb4577 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -323,17 +323,16 @@ Bitmap *outline_to_bitmap(ASS_Renderer *render_priv, if (!bm) return NULL; bm->left = x_min - bord; - bm->top = -y_max - bord; + bm->top = y_min - bord; int offs = bord & ~mask; - int bord_h = tile_h - h - bord; if (!rasterizer_fill(rst, bm->buffer + offs * (bm->stride + 1), x_min - bord + offs, - y_min - bord_h + (bord_h & ~mask), + y_min - bord + offs, ((w + bord + mask) & ~mask) - offs, ((h + bord + mask) & ~mask) - offs, - bm->stride, 1)) { + bm->stride)) { ass_msg(render_priv->library, MSGL_WARN, "Failed to rasterize glyph!\n"); ass_free_bitmap(bm); return NULL; diff --git a/libass/ass_rasterizer.c b/libass/ass_rasterizer.c index a2488ad..93a4d5a 100644 --- a/libass/ass_rasterizer.c +++ b/libass/ass_rasterizer.c @@ -137,11 +137,11 @@ static inline int add_line(ASS_Rasterizer *rst, OutlinePoint pt0, OutlinePoint p ++rst->size[0]; line->flags = SEGFLAG_EXACT_LEFT | SEGFLAG_EXACT_RIGHT | - SEGFLAG_EXACT_BOTTOM | SEGFLAG_EXACT_TOP; + SEGFLAG_EXACT_TOP | SEGFLAG_EXACT_BOTTOM; if (x < 0) - line->flags ^= SEGFLAG_UR_DL; + line->flags ^= SEGFLAG_UL_DR; if (y >= 0) - line->flags ^= SEGFLAG_UP | SEGFLAG_UR_DL; + line->flags ^= SEGFLAG_DN | SEGFLAG_UL_DR; line->x_min = FFMIN(pt0.x, pt1.x); line->x_max = FFMAX(pt0.x, pt1.x); @@ -249,8 +249,8 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path) switch (FT_CURVE_TAG(path->tags[j])) { case FT_CURVE_TAG_ON: - p[0].x = path->points[j].x; - p[0].y = path->points[j].y; + p[0].x = path->points[j].x; + p[0].y = -path->points[j].y; start = p[0]; st = S_ON; break; @@ -258,19 +258,19 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path) case FT_CURVE_TAG_CONIC: switch (FT_CURVE_TAG(path->tags[last])) { case FT_CURVE_TAG_ON: - p[0].x = path->points[last].x; - p[0].y = path->points[last].y; - p[1].x = path->points[j].x; - p[1].y = path->points[j].y; + p[0].x = path->points[last].x; + p[0].y = -path->points[last].y; + p[1].x = path->points[j].x; + p[1].y = -path->points[j].y; process_end = 0; st = S_Q; break; case FT_CURVE_TAG_CONIC: - p[1].x = path->points[j].x; - p[1].y = path->points[j].y; + p[1].x = path->points[j].x; + p[1].y = -path->points[j].y; p[0].x = (p[1].x + path->points[last].x) >> 1; - p[0].y = (p[1].y + path->points[last].y) >> 1; + p[0].y = (p[1].y - path->points[last].y) >> 1; start = p[0]; st = S_Q; break; @@ -289,16 +289,16 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path) case FT_CURVE_TAG_ON: switch (st) { case S_ON: - p[1].x = path->points[j].x; - p[1].y = path->points[j].y; + p[1].x = path->points[j].x; + p[1].y = -path->points[j].y; if (!add_line(rst, p[0], p[1])) return 0; p[0] = p[1]; break; case S_Q: - p[2].x = path->points[j].x; - p[2].y = path->points[j].y; + p[2].x = path->points[j].x; + p[2].y = -path->points[j].y; if (!add_quadratic(rst, p[0], p[1], p[2])) return 0; p[0] = p[2]; @@ -306,8 +306,8 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path) break; case S_C2: - p[3].x = path->points[j].x; - p[3].y = path->points[j].y; + p[3].x = path->points[j].x; + p[3].y = -path->points[j].y; if (!add_cubic(rst, p[0], p[1], p[2], p[3])) return 0; p[0] = p[3]; @@ -322,14 +322,14 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path) case FT_CURVE_TAG_CONIC: switch (st) { case S_ON: - p[1].x = path->points[j].x; - p[1].y = path->points[j].y; + p[1].x = path->points[j].x; + p[1].y = -path->points[j].y; st = S_Q; break; case S_Q: - p[3].x = path->points[j].x; - p[3].y = path->points[j].y; + p[3].x = path->points[j].x; + p[3].y = -path->points[j].y; p[2].x = (p[1].x + p[3].x) >> 1; p[2].y = (p[1].y + p[3].y) >> 1; if (!add_quadratic(rst, p[0], p[1], p[2])) @@ -346,14 +346,14 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path) case FT_CURVE_TAG_CUBIC: switch (st) { case S_ON: - p[1].x = path->points[j].x; - p[1].y = path->points[j].y; + p[1].x = path->points[j].x; + p[1].y = -path->points[j].y; st = S_C1; break; case S_C1: - p[2].x = path->points[j].x; - p[2].y = path->points[j].y; + p[2].x = path->points[j].x; + p[2].y = -path->points[j].y; st = S_C2; break; @@ -408,9 +408,9 @@ static void segment_move_x(struct segment *line, int32_t x) line->x_min = FFMAX(line->x_min, 0); line->c -= line->a * (int64_t)x; - static const int test = SEGFLAG_EXACT_LEFT | SEGFLAG_UR_DL; + static const int test = SEGFLAG_EXACT_LEFT | SEGFLAG_UL_DR; if (!line->x_min && (line->flags & test) == test) - line->flags &= ~SEGFLAG_EXACT_BOTTOM; + line->flags &= ~SEGFLAG_EXACT_TOP; } static void segment_move_y(struct segment *line, int32_t y) @@ -420,7 +420,7 @@ static void segment_move_y(struct segment *line, int32_t y) line->y_min = FFMAX(line->y_min, 0); line->c -= line->b * (int64_t)y; - static const int test = SEGFLAG_EXACT_BOTTOM | SEGFLAG_UR_DL; + static const int test = SEGFLAG_EXACT_TOP | SEGFLAG_UL_DR; if (!line->y_min && (line->flags & test) == test) line->flags &= ~SEGFLAG_EXACT_LEFT; } @@ -435,9 +435,9 @@ static void segment_split_horz(struct segment *line, struct segment *next, int32 next->x_max -= x; line->x_max = x; - line->flags &= ~SEGFLAG_EXACT_BOTTOM; - next->flags &= ~SEGFLAG_EXACT_TOP; - if (line->flags & SEGFLAG_UR_DL) { + line->flags &= ~SEGFLAG_EXACT_TOP; + next->flags &= ~SEGFLAG_EXACT_BOTTOM; + if (line->flags & SEGFLAG_UL_DR) { int32_t tmp = line->flags; line->flags = next->flags; next->flags = tmp; @@ -458,33 +458,33 @@ static void segment_split_vert(struct segment *line, struct segment *next, int32 line->flags &= ~SEGFLAG_EXACT_LEFT; next->flags &= ~SEGFLAG_EXACT_RIGHT; - if (line->flags & SEGFLAG_UR_DL) { + if (line->flags & SEGFLAG_UL_DR) { int32_t tmp = line->flags; line->flags = next->flags; next->flags = tmp; } - line->flags |= SEGFLAG_EXACT_TOP; - next->flags |= SEGFLAG_EXACT_BOTTOM; + line->flags |= SEGFLAG_EXACT_BOTTOM; + next->flags |= SEGFLAG_EXACT_TOP; } -static inline int segment_check_right(const struct segment *line, int32_t x) +static inline int segment_check_left(const struct segment *line, int32_t x) { - if (line->flags & SEGFLAG_EXACT_RIGHT) - return line->x_max <= x; + if (line->flags & SEGFLAG_EXACT_LEFT) + return line->x_min >= x; int64_t cc = line->c - line->a * (int64_t)x - - line->b * (int64_t)(line->flags & SEGFLAG_UR_DL ? line->y_max : line->y_min); - if (line->a > 0) + line->b * (int64_t)(line->flags & SEGFLAG_UL_DR ? line->y_min : line->y_max); + if (line->a < 0) cc = -cc; return cc >= 0; } -static inline int segment_check_left(const struct segment *line, int32_t x) +static inline int segment_check_right(const struct segment *line, int32_t x) { - if (line->flags & SEGFLAG_EXACT_LEFT) - return line->x_min >= x; + if (line->flags & SEGFLAG_EXACT_RIGHT) + return line->x_max <= x; int64_t cc = line->c - line->a * (int64_t)x - - line->b * (int64_t)(line->flags & SEGFLAG_UR_DL ? line->y_min : line->y_max); - if (line->a < 0) + line->b * (int64_t)(line->flags & SEGFLAG_UL_DR ? line->y_max : line->y_min); + if (line->a > 0) cc = -cc; return cc >= 0; } @@ -492,10 +492,10 @@ static inline int segment_check_left(const struct segment *line, int32_t x) static inline int segment_check_top(const struct segment *line, int32_t y) { if (line->flags & SEGFLAG_EXACT_TOP) - return line->y_max <= y; + return line->y_min >= y; int64_t cc = line->c - line->b * (int64_t)y - - line->a * (int64_t)(line->flags & SEGFLAG_UR_DL ? line->x_max : line->x_min); - if (line->b > 0) + line->a * (int64_t)(line->flags & SEGFLAG_UL_DR ? line->x_min : line->x_max); + if (line->b < 0) cc = -cc; return cc >= 0; } @@ -503,10 +503,10 @@ static inline int segment_check_top(const struct segment *line, int32_t y) static inline int segment_check_bottom(const struct segment *line, int32_t y) { if (line->flags & SEGFLAG_EXACT_BOTTOM) - return line->y_min >= y; + return line->y_max <= y; int64_t cc = line->c - line->b * (int64_t)y - - line->a * (int64_t)(line->flags & SEGFLAG_UR_DL ? line->x_min : line->x_max); - if (line->b < 0) + line->a * (int64_t)(line->flags & SEGFLAG_UL_DR ? line->x_max : line->x_min); + if (line->b > 0) cc = -cc; return cc >= 0; } @@ -526,7 +526,7 @@ static int polyline_split_horz(const struct segment *src, size_t n_src, const struct segment *end = src + n_src; for (; src != end; ++src) { int delta = 0; - if (!src->y_min && (src->flags & SEGFLAG_EXACT_BOTTOM)) + if (!src->y_min && (src->flags & SEGFLAG_EXACT_TOP)) delta = src->a < 0 ? 1 : -1; if (segment_check_right(src, x)) { winding += delta; @@ -543,7 +543,7 @@ static int polyline_split_horz(const struct segment *src, size_t n_src, ++(*dst1); continue; } - if (src->flags & SEGFLAG_UR_DL) + if (src->flags & SEGFLAG_UL_DR) winding += delta; **dst0 = *src; segment_split_horz(*dst0, *dst1, x); @@ -565,7 +565,7 @@ static int polyline_split_vert(const struct segment *src, size_t n_src, int delta = 0; if (!src->x_min && (src->flags & SEGFLAG_EXACT_LEFT)) delta = src->b < 0 ? 1 : -1; - if (segment_check_top(src, y)) { + if (segment_check_bottom(src, y)) { winding += delta; if (src->y_min >= y) continue; @@ -574,13 +574,13 @@ static int polyline_split_vert(const struct segment *src, size_t n_src, ++(*dst0); continue; } - if (segment_check_bottom(src, y)) { + if (segment_check_top(src, y)) { **dst1 = *src; segment_move_y(*dst1, y); ++(*dst1); continue; } - if (src->flags & SEGFLAG_UR_DL) + if (src->flags & SEGFLAG_UL_DR) winding += delta; **dst0 = *src; segment_split_vert(*dst0, *dst1, y); @@ -724,19 +724,13 @@ static int rasterizer_fill_level(ASS_Rasterizer *rst, } int rasterizer_fill(ASS_Rasterizer *rst, - uint8_t *buf, int x0, int y0, int width, int height, ptrdiff_t stride, - int vert_flip) + uint8_t *buf, int x0, int y0, int width, int height, ptrdiff_t stride) { assert(width > 0 && height > 0); assert(!(width & ((1 << rst->tile_order) - 1))); assert(!(height & ((1 << rst->tile_order) - 1))); x0 *= 1 << 6; y0 *= 1 << 6; - if (vert_flip) { - buf += (height - 1) * stride; - stride = -stride; - } - size_t n = rst->size[0]; struct segment *line = rst->linebuf[0]; struct segment *end = line + n; diff --git a/libass/ass_rasterizer.h b/libass/ass_rasterizer.h index 93c7e6f..9da475e 100644 --- a/libass/ass_rasterizer.h +++ b/libass/ass_rasterizer.h @@ -26,12 +26,12 @@ enum { - SEGFLAG_UP = 1, - SEGFLAG_UR_DL = 2, + SEGFLAG_DN = 1, + SEGFLAG_UL_DR = 2, SEGFLAG_EXACT_LEFT = 4, SEGFLAG_EXACT_RIGHT = 8, - SEGFLAG_EXACT_BOTTOM = 16, - SEGFLAG_EXACT_TOP = 32 + SEGFLAG_EXACT_TOP = 16, + SEGFLAG_EXACT_BOTTOM = 32, }; // Polyline segment struct @@ -88,12 +88,11 @@ int rasterizer_set_outline(ASS_Rasterizer *rst, const FT_Outline *path); * \param x0, y0, width, height in: source window (full pixel units) * \param buf out: aligned output buffer (size = stride * height) * \param stride output buffer stride (aligned) - * \param vert_flip vertical flip flag * \return zero on error * Deletes preprocessed polyline after work. */ int rasterizer_fill(ASS_Rasterizer *rst, uint8_t *buf, int x0, int y0, - int width, int height, ptrdiff_t stride, int vert_flip); + int width, int height, ptrdiff_t stride); #endif /* LIBASS_RASTERIZER_H */ diff --git a/libass/ass_rasterizer_c.c b/libass/ass_rasterizer_c.c index f702c54..f15f91b 100644 --- a/libass/ass_rasterizer_c.c +++ b/libass/ass_rasterizer_c.c @@ -147,16 +147,16 @@ void ass_fill_halfplane_tile32_c(uint8_t *buf, ptrdiff_t stride, static inline void update_border_line16(int16_t res[16], int16_t abs_a, const int16_t va[16], int16_t b, int16_t abs_b, - int16_t c, int dn, int up) + int16_t c, int up, int dn) { - int16_t size = up - dn; + int16_t size = dn - up; int16_t w = (1 << 10) + (size << 4) - abs_a; w = FFMIN(w, 1 << 10) << 3; int16_t dc_b = abs_b * (int32_t)size >> 6; int16_t dc = (FFMIN(abs_a, dc_b) + 2) >> 2; - int16_t base = (int32_t)b * (int16_t)(dn + up) >> 7; + int16_t base = (int32_t)b * (int16_t)(up + dn) >> 7; int16_t offs1 = size - ((base + dc) * (int32_t)w >> 16); int16_t offs2 = size - ((base - dc) * (int32_t)w >> 16); @@ -191,31 +191,31 @@ void ass_fill_generic_tile16_c(uint8_t *buf, ptrdiff_t stride, assert(line->y_max > 0 && line->y_max <= 1 << 10); assert(line->y_min <= line->y_max); - int16_t dn_delta = line->flags & SEGFLAG_UP ? 4 : 0; - int16_t up_delta = dn_delta; - if (!line->x_min && (line->flags & SEGFLAG_EXACT_LEFT))up_delta ^= 4; - if (line->flags & SEGFLAG_UR_DL) { - int16_t tmp = dn_delta; - dn_delta = up_delta; - up_delta = tmp; + int16_t up_delta = line->flags & SEGFLAG_DN ? 4 : 0; + int16_t dn_delta = up_delta; + if (!line->x_min && (line->flags & SEGFLAG_EXACT_LEFT))dn_delta ^= 4; + if (line->flags & SEGFLAG_UL_DR) { + int16_t tmp = up_delta; + up_delta = dn_delta; + dn_delta = tmp; } - int dn = line->y_min >> 6, up = line->y_max >> 6; - int16_t dn_pos = line->y_min & 63; - int16_t dn_delta1 = dn_delta * dn_pos; - int16_t up_pos = line->y_max & 63; + int up = line->y_min >> 6, dn = line->y_max >> 6; + int16_t up_pos = line->y_min & 63; int16_t up_delta1 = up_delta * up_pos; - delta[dn + 1] -= dn_delta1; - delta[dn] -= (dn_delta << 6) - dn_delta1; - delta[up + 1] += up_delta1; - delta[up] += (up_delta << 6) - up_delta1; + int16_t dn_pos = line->y_max & 63; + int16_t dn_delta1 = dn_delta * dn_pos; + delta[up + 1] -= up_delta1; + delta[up] -= (up_delta << 6) - up_delta1; + delta[dn + 1] += dn_delta1; + delta[dn] += (dn_delta << 6) - dn_delta1; if (line->y_min == line->y_max) continue; int16_t a = (line->a * (int64_t)line->scale + ((int64_t)1 << 49)) >> 50; int16_t b = (line->b * (int64_t)line->scale + ((int64_t)1 << 49)) >> 50; int16_t c = ((int32_t)(line->c >> 11) * (int64_t)line->scale + ((int64_t)1 << 44)) >> 45; - c -= (a >> 1) + b * dn; + c -= (a >> 1) + b * up; int16_t va[16]; for (i = 0; i < 16; ++i) @@ -227,16 +227,16 @@ void ass_fill_generic_tile16_c(uint8_t *buf, ptrdiff_t stride, int16_t dc1 = base + dc; int16_t dc2 = base - dc; - if (dn_pos) { - if (up == dn) { - update_border_line16(res[dn], abs_a, va, b, abs_b, c, dn_pos, up_pos); + if (up_pos) { + if (dn == up) { + update_border_line16(res[up], abs_a, va, b, abs_b, c, up_pos, dn_pos); continue; } - update_border_line16(res[dn], abs_a, va, b, abs_b, c, dn_pos, 64); - dn++; + update_border_line16(res[up], abs_a, va, b, abs_b, c, up_pos, 64); + up++; c -= b; } - for (j = dn; j < up; ++j) { + for (j = up; j < dn; ++j) { for (i = 0; i < 16; ++i) { int16_t c1 = c - va[i] + dc1; int16_t c2 = c - va[i] + dc2; @@ -246,8 +246,8 @@ void ass_fill_generic_tile16_c(uint8_t *buf, ptrdiff_t stride, } c -= b; } - if (up_pos) - update_border_line16(res[up], abs_a, va, b, abs_b, c, 0, up_pos); + if (dn_pos) + update_border_line16(res[dn], abs_a, va, b, abs_b, c, 0, dn_pos); } int16_t cur = 256 * winding; @@ -266,16 +266,16 @@ void ass_fill_generic_tile16_c(uint8_t *buf, ptrdiff_t stride, static inline void update_border_line32(int16_t res[32], int16_t abs_a, const int16_t va[32], int16_t b, int16_t abs_b, - int16_t c, int dn, int up) + int16_t c, int up, int dn) { - int16_t size = up - dn; + int16_t size = dn - up; int16_t w = (1 << 9) + (size << 3) - abs_a; w = FFMIN(w, 1 << 9) << 5; int16_t dc_b = abs_b * (int32_t)size >> 6; int16_t dc = (FFMIN(abs_a, dc_b) + 2) >> 2; - int16_t base = (int32_t)b * (int16_t)(dn + up) >> 7; + int16_t base = (int32_t)b * (int16_t)(up + dn) >> 7; int16_t offs1 = size - ((base + dc) * (int32_t)w >> 16); int16_t offs2 = size - ((base - dc) * (int32_t)w >> 16); @@ -310,31 +310,31 @@ void ass_fill_generic_tile32_c(uint8_t *buf, ptrdiff_t stride, assert(line->y_max > 0 && line->y_max <= 1 << 11); assert(line->y_min <= line->y_max); - int16_t dn_delta = line->flags & SEGFLAG_UP ? 4 : 0; - int16_t up_delta = dn_delta; - if (!line->x_min && (line->flags & SEGFLAG_EXACT_LEFT))up_delta ^= 4; - if (line->flags & SEGFLAG_UR_DL) { - int16_t tmp = dn_delta; - dn_delta = up_delta; - up_delta = tmp; + int16_t up_delta = line->flags & SEGFLAG_DN ? 4 : 0; + int16_t dn_delta = up_delta; + if (!line->x_min && (line->flags & SEGFLAG_EXACT_LEFT))dn_delta ^= 4; + if (line->flags & SEGFLAG_UL_DR) { + int16_t tmp = up_delta; + up_delta = dn_delta; + dn_delta = tmp; } - int dn = line->y_min >> 6, up = line->y_max >> 6; - int16_t dn_pos = line->y_min & 63; - int16_t dn_delta1 = dn_delta * dn_pos; - int16_t up_pos = line->y_max & 63; + int up = line->y_min >> 6, dn = line->y_max >> 6; + int16_t up_pos = line->y_min & 63; int16_t up_delta1 = up_delta * up_pos; - delta[dn + 1] -= dn_delta1; - delta[dn] -= (dn_delta << 6) - dn_delta1; - delta[up + 1] += up_delta1; - delta[up] += (up_delta << 6) - up_delta1; + int16_t dn_pos = line->y_max & 63; + int16_t dn_delta1 = dn_delta * dn_pos; + delta[up + 1] -= up_delta1; + delta[up] -= (up_delta << 6) - up_delta1; + delta[dn + 1] += dn_delta1; + delta[dn] += (dn_delta << 6) - dn_delta1; if (line->y_min == line->y_max) continue; int16_t a = (line->a * (int64_t)line->scale + ((int64_t)1 << 50)) >> 51; int16_t b = (line->b * (int64_t)line->scale + ((int64_t)1 << 50)) >> 51; int16_t c = ((int32_t)(line->c >> 12) * (int64_t)line->scale + ((int64_t)1 << 44)) >> 45; - c -= (a >> 1) + b * dn; + c -= (a >> 1) + b * up; int16_t va[32]; for (i = 0; i < 32; ++i) @@ -346,16 +346,16 @@ void ass_fill_generic_tile32_c(uint8_t *buf, ptrdiff_t stride, int16_t dc1 = base + dc; int16_t dc2 = base - dc; - if (dn_pos) { - if (up == dn) { - update_border_line32(res[dn], abs_a, va, b, abs_b, c, dn_pos, up_pos); + if (up_pos) { + if (dn == up) { + update_border_line32(res[up], abs_a, va, b, abs_b, c, up_pos, dn_pos); continue; } - update_border_line32(res[dn], abs_a, va, b, abs_b, c, dn_pos, 64); - dn++; + update_border_line32(res[up], abs_a, va, b, abs_b, c, up_pos, 64); + up++; c -= b; } - for (j = dn; j < up; ++j) { + for (j = up; j < dn; ++j) { for (i = 0; i < 32; ++i) { int16_t c1 = c - va[i] + dc1; int16_t c2 = c - va[i] + dc2; @@ -365,8 +365,8 @@ void ass_fill_generic_tile32_c(uint8_t *buf, ptrdiff_t stride, } c -= b; } - if (up_pos) - update_border_line32(res[up], abs_a, va, b, abs_b, c, 0, up_pos); + if (dn_pos) + update_border_line32(res[dn], abs_a, va, b, abs_b, c, 0, dn_pos); } int16_t cur = 256 * winding; diff --git a/libass/x86/rasterizer.asm b/libass/x86/rasterizer.asm index fc5ca20..d4941c6 100644 --- a/libass/x86/rasterizer.asm +++ b/libass/x86/rasterizer.asm @@ -362,8 +362,8 @@ endstruc ;------------------------------------------------------------------------------ ; CALC_DELTA_FLAG res, line, tmp1, tmp2 ; Set bits of result register (res): -; bit 3 - for nonzero dn_delta, -; bit 2 - for nonzero up_delta. +; bit 3 - for nonzero up_delta, +; bit 2 - for nonzero dn_delta. ;------------------------------------------------------------------------------ %macro CALC_DELTA_FLAG 4 @@ -372,7 +372,7 @@ endstruc cmp %4d, [%2 + line.x_min] cmovz %4d, %3d xor %1d, %1d - test %3d, 2 ; SEGFLAG_UR_DL + test %3d, 2 ; SEGFLAG_UL_DR cmovnz %1d, %4d shl %3d, 2 xor %1d, %3d @@ -383,21 +383,21 @@ endstruc %endmacro ;------------------------------------------------------------------------------ -; UPDATE_DELTA up/dn, dst, flag, pos, tmp +; UPDATE_DELTA dn/up, dst, flag, pos, tmp ; Update delta array ;------------------------------------------------------------------------------ %macro UPDATE_DELTA 5 -%ifidn %1, up +%ifidn %1, dn %define %%op add %define %%opi sub %assign %%flag 1 << 2 -%elifidn %1, dn +%elifidn %1, up %define %%op sub %define %%opi add %assign %%flag 1 << 3 %else - %error "up/dn expected" + %error "dn/up expected" %endif test %3d, %%flag @@ -575,7 +575,7 @@ endstruc ;------------------------------------------------------------------------------ %macro FILL_GENERIC_TILE 2 - ; t3=line t4=dn/cur t5=up/end t6=up_pos t7=dn_pos + ; t3=line t4=up/cur t5=dn/end t6=dn_pos t7=up_pos ; t8=a/abs_a/abs_ab t9=b t10=c/abs_b %if ARCH_X86_64 DECLARE_REG_TMP 10,11,5,2, 4,9,6,7, 8,12,13 @@ -649,10 +649,10 @@ cglobal fill_generic_tile%2, 0,7,8 %if ARCH_X86_64 mova mm_index, [words_index] mova mm_full, [words_tile%2] - %define up_addr t5 + %define dn_addr t5 %else - %define up_addr [rstk + delta_offs + 2 * tile_size + 4] - %define up_pos [rstk + delta_offs + 2 * tile_size + 8] + %define dn_addr [rstk + delta_offs + 2 * tile_size + 4] + %define dn_pos [rstk + delta_offs + 2 * tile_size + 8] %endif .line_loop @@ -668,15 +668,15 @@ cglobal fill_generic_tile%2, 0,7,8 %if ARCH_X86_64 mov t8d, t4d mov t6d, t4d - and t6d, 63 ; dn_pos - shr t4d, 6 ; dn + and t6d, 63 ; up_pos + shr t4d, 6 ; up mov t5d, t2d mov t7d, t2d - and t7d, 63 ; up_pos - shr t5d, 6 ; up + and t7d, 63 ; dn_pos + shr t5d, 6 ; dn - UPDATE_DELTA dn, rstk + 2 * t4 + delta_offs, t0,t6, t1 - UPDATE_DELTA up, rstk + 2 * t5 + delta_offs, t0,t7, t1 + UPDATE_DELTA up, rstk + 2 * t4 + delta_offs, t0,t6, t1 + UPDATE_DELTA dn, rstk + 2 * t5 + delta_offs, t0,t7, t1 cmp t8d, t2d %else lea t1d, [t0d + 1] @@ -684,18 +684,18 @@ cglobal fill_generic_tile%2, 0,7,8 cmovnz t0d, t1d ; bit 0 -- not horz line mov t6d, t2d - and t6d, 63 ; up_pos - shr t2d, 6 ; up - UPDATE_DELTA up, rstk + 2 * t2 + delta_offs, t0,t6, t1 + and t6d, 63 ; dn_pos + shr t2d, 6 ; dn + UPDATE_DELTA dn, rstk + 2 * t2 + delta_offs, t0,t6, t1 CALC_RES_ADDR %1, t2, t1 - mov up_addr, t2 - mov up_pos, t6d + mov dn_addr, t2 + mov dn_pos, t6d mov t6d, t4d - and t6d, 63 ; dn_pos - shr t4d, 6 ; dn - UPDATE_DELTA dn, rstk + 2 * t4 + delta_offs, t0,t6, t1 + and t6d, 63 ; up_pos + shr t4d, 6 ; up + UPDATE_DELTA up, rstk + 2 * t4 + delta_offs, t0,t6, t1 test t0d, 1 %endif jz .end_line_loop @@ -772,7 +772,7 @@ cglobal fill_generic_tile%2, 0,7,8 %if ARCH_X86_64 CALC_RES_ADDR %1, t5, t0, skip %endif - cmp t4, up_addr + cmp t4, dn_addr jz .single_line %if ARCH_X86_64 || a_shift == 0 @@ -782,12 +782,12 @@ cglobal fill_generic_tile%2, 0,7,8 test t6d, t6d jz .generic_fist mov t2d, 64 - sub t2d, t6d ; 64 - dn_pos - add t6d, 64 ; 64 + dn_pos + sub t2d, t6d ; 64 - up_pos + add t6d, 64 ; 64 + up_pos FILL_BORDER_LINE %1, t4,t8,t9,t10,t2,t6, t0,t1, 0,1,2,3,4,5 %if ARCH_X86_64 == 0 - mov t5, up_addr + mov t5, dn_addr %if a_shift CALC_VBA %1, t9 %endif @@ -803,7 +803,7 @@ cglobal fill_generic_tile%2, 0,7,8 .generic_fist %if ARCH_X86_64 == 0 - mov t5, up_addr + mov t5, dn_addr %if a_shift CALC_VBA %1, t9 %endif @@ -871,7 +871,7 @@ cglobal fill_generic_tile%2, 0,7,8 jz .end_line_loop xor t6d, t6d %else - mov t2d, up_pos + mov t2d, dn_pos test t2d, t2d jz .end_line_loop mov t6d, t2d @@ -880,11 +880,11 @@ cglobal fill_generic_tile%2, 0,7,8 .single_line %if ARCH_X86_64 == 0 - mov t7d, up_pos + mov t7d, dn_pos %endif mov t2d, t7d - sub t2d, t6d ; up_pos - dn_pos - add t6d, t7d ; up_pos + dn_pos + sub t2d, t6d ; dn_pos - up_pos + add t6d, t7d ; dn_pos + up_pos .last_line FILL_BORDER_LINE %1, t4,t8,t9,t10,t2,t6, t0,t1, 0,1,2,3,4,5