diff -r 71e347f905f2 -r 4a7fac7dd34a gst_plugins_base/gst/videoscale/vs_image.c --- a/gst_plugins_base/gst/videoscale/vs_image.c Fri Mar 19 09:35:09 2010 +0200 +++ b/gst_plugins_base/gst/videoscale/vs_image.c Fri Apr 16 15:15:52 2010 +0300 @@ -49,8 +49,16 @@ int x; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); + acc = 0; for (i = 0; i < dest->height; i++) { @@ -59,7 +67,8 @@ xacc = 0; vs_scanline_resample_nearest_RGBA (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, dest->width, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -86,8 +95,15 @@ int dest_size; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = dest->width * 4; @@ -97,8 +113,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_RGBA (tmp1, src->pixels, dest->width, &xacc, - x_increment); + vs_scanline_resample_linear_RGBA (tmp1, src->pixels, src->width, dest->width, + &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -112,7 +128,7 @@ } else { xacc = 0; vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -121,8 +137,8 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_RGBA (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, @@ -131,8 +147,8 @@ if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_RGBA (tmp1, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, @@ -140,11 +156,11 @@ } else { xacc = 0; vs_scanline_resample_linear_RGBA (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_RGBA (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, + src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_RGBA (dest->pixels + i * dest->stride, @@ -173,8 +189,15 @@ int x; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); acc = 0; for (i = 0; i < dest->height; i++) { @@ -183,7 +206,8 @@ xacc = 0; vs_scanline_resample_nearest_RGB (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, dest->width, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -210,8 +234,15 @@ int dest_size; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = dest->width * 3; @@ -221,8 +252,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_RGB (tmp1, src->pixels, dest->width, &xacc, - x_increment); + vs_scanline_resample_linear_RGB (tmp1, src->pixels, src->width, dest->width, + &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -236,7 +267,7 @@ } else { xacc = 0; vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -245,8 +276,8 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_RGB (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, @@ -255,8 +286,8 @@ if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_RGB (tmp1, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, @@ -264,11 +295,11 @@ } else { xacc = 0; vs_scanline_resample_linear_RGB (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_RGB (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, + src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_RGB (dest->pixels + i * dest->stride, @@ -297,12 +328,17 @@ int j; int x; int xacc; - int n_quads; + + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); - n_quads = ROUND_UP_2 (dest->width) / 2; acc = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -310,7 +346,8 @@ xacc = 0; vs_scanline_resample_nearest_YUYV (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, n_quads, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -335,14 +372,19 @@ int j; int x; int dest_size; - int n_quads; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = ROUND_UP_4 (dest->width * 2); - n_quads = ROUND_UP_2 (dest->width) / 2; tmp1 = tmpbuf; tmp2 = tmpbuf + dest_size; @@ -350,8 +392,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_YUYV (tmp1, src->pixels, n_quads, &xacc, - x_increment); + vs_scanline_resample_linear_YUYV (tmp1, src->pixels, src->width, dest->width, + &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -365,7 +407,7 @@ } else { xacc = 0; vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, - n_quads, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -374,31 +416,34 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_YUYV (tmp2, - src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, - tmp1, tmp2, n_quads, x); + tmp1, tmp2, dest->width, x); } else if (j == y2) { if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_YUYV (tmp1, - src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, - tmp2, tmp1, n_quads, x); + tmp2, tmp1, dest->width, x); } else { xacc = 0; vs_scanline_resample_linear_YUYV (tmp1, src->pixels + j * src->stride, - n_quads, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_YUYV (tmp2, - src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_YUYV (dest->pixels + i * dest->stride, - tmp1, tmp2, n_quads, x); + tmp1, tmp2, dest->width, x); } } @@ -423,12 +468,17 @@ int j; int x; int xacc; - int n_quads; + + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); - n_quads = (dest->width + 1) / 2; acc = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -436,7 +486,8 @@ xacc = 0; vs_scanline_resample_nearest_UYVY (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, n_quads, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -461,14 +512,19 @@ int j; int x; int dest_size; - int n_quads; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = ROUND_UP_4 (dest->width * 2); - n_quads = ROUND_UP_2 (dest->width) / 2; tmp1 = tmpbuf; tmp2 = tmpbuf + dest_size; @@ -476,8 +532,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_UYVY (tmp1, src->pixels, n_quads, &xacc, - x_increment); + vs_scanline_resample_linear_UYVY (tmp1, src->pixels, src->width, dest->width, + &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -491,7 +547,7 @@ } else { xacc = 0; vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, - n_quads, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -500,31 +556,34 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_UYVY (tmp2, - src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, - tmp1, tmp2, n_quads, x); + tmp1, tmp2, dest->width, x); } else if (j == y2) { if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_UYVY (tmp1, - src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, - tmp2, tmp1, n_quads, x); + tmp2, tmp1, dest->width, x); } else { xacc = 0; vs_scanline_resample_linear_UYVY (tmp1, src->pixels + j * src->stride, - n_quads, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_UYVY (tmp2, - src->pixels + (j + 1) * src->stride, n_quads, &xacc, x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_UYVY (dest->pixels + i * dest->stride, - tmp1, tmp2, n_quads, x); + tmp1, tmp2, dest->width, x); } } @@ -550,8 +609,15 @@ int x; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); acc = 0; for (i = 0; i < dest->height; i++) { @@ -560,7 +626,8 @@ xacc = 0; vs_scanline_resample_nearest_Y (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, dest->width, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -587,8 +654,15 @@ int dest_size; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = dest->width; @@ -598,8 +672,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_Y (tmp1, src->pixels, dest->width, &xacc, - x_increment); + vs_scanline_resample_linear_Y (tmp1, src->pixels, src->width, dest->width, + &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -613,7 +687,7 @@ } else { xacc = 0; vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -622,8 +696,8 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_Y (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, @@ -632,8 +706,8 @@ if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_Y (tmp1, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, @@ -641,11 +715,11 @@ } else { xacc = 0; vs_scanline_resample_linear_Y (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_Y (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, + src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_Y (dest->pixels + i * dest->stride, @@ -656,6 +730,142 @@ acc += y_increment; } } +#ifdef __SYMBIAN32__ +EXPORT_C +#endif + +void +vs_image_scale_nearest_Y16 (const VSImage * dest, const VSImage * src, + uint8_t * tmpbuf) +{ + int acc; + int y_increment; + int x_increment; + int i; + int j; + int x; + int xacc; + + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); + + acc = 0; + for (i = 0; i < dest->height; i++) { + j = acc >> 16; + x = acc & 0xffff; + + xacc = 0; + vs_scanline_resample_nearest_Y16 (dest->pixels + i * dest->stride, + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); + + acc += y_increment; + } +} +#ifdef __SYMBIAN32__ +EXPORT_C +#endif + +void +vs_image_scale_linear_Y16 (const VSImage * dest, const VSImage * src, + uint8_t * tmpbuf) +{ + int acc; + int y_increment; + int x_increment; + uint8_t *tmp1; + uint8_t *tmp2; + int y1; + int y2; + int i; + int j; + int x; + int dest_size; + int xacc; + + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); + + dest_size = 2 * dest->width; + + tmp1 = tmpbuf; + tmp2 = tmpbuf + dest_size; + + acc = 0; + xacc = 0; + y2 = -1; + vs_scanline_resample_linear_Y16 (tmp1, src->pixels, src->width, dest->width, + &xacc, x_increment); + y1 = 0; + for (i = 0; i < dest->height; i++) { + j = acc >> 16; + x = acc & 0xffff; + + if (x == 0) { + if (j == y1) { + memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); + } else if (j == y2) { + memcpy (dest->pixels + i * dest->stride, tmp2, dest_size); + } else { + xacc = 0; + vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride, + src->width, dest->width, &xacc, x_increment); + y1 = j; + memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); + } + } else { + if (j == y1) { + if (j + 1 != y2) { + xacc = 0; + vs_scanline_resample_linear_Y16 (tmp2, + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); + y2 = j + 1; + } + vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride, + tmp1, tmp2, dest->width, x); + } else if (j == y2) { + if (j + 1 != y1) { + xacc = 0; + vs_scanline_resample_linear_Y16 (tmp1, + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); + y1 = j + 1; + } + vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride, + tmp2, tmp1, dest->width, x); + } else { + xacc = 0; + vs_scanline_resample_linear_Y16 (tmp1, src->pixels + j * src->stride, + src->width, dest->width, &xacc, x_increment); + y1 = j; + xacc = 0; + vs_scanline_resample_linear_Y16 (tmp2, + src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, + x_increment); + y2 = (j + 1); + vs_scanline_merge_linear_Y16 (dest->pixels + i * dest->stride, + tmp1, tmp2, dest->width, x); + } + } + + acc += y_increment; + } +} /* RGB565 */ #ifdef __SYMBIAN32__ @@ -675,8 +885,15 @@ int x; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); acc = 0; for (i = 0; i < dest->height; i++) { @@ -685,7 +902,8 @@ xacc = 0; vs_scanline_resample_nearest_RGB565 (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, dest->width, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -712,8 +930,15 @@ int dest_size; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = dest->width * 2; @@ -723,8 +948,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_RGB565 (tmp1, src->pixels, dest->width, &xacc, - x_increment); + vs_scanline_resample_linear_RGB565 (tmp1, src->pixels, src->width, + dest->width, &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -738,7 +963,7 @@ } else { xacc = 0; vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -747,8 +972,8 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_RGB565 (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, @@ -757,8 +982,8 @@ if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_RGB565 (tmp1, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, @@ -766,11 +991,11 @@ } else { xacc = 0; vs_scanline_resample_linear_RGB565 (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_RGB565 (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, + src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_RGB565 (dest->pixels + i * dest->stride, @@ -800,8 +1025,15 @@ int x; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); acc = 0; for (i = 0; i < dest->height; i++) { @@ -810,7 +1042,8 @@ xacc = 0; vs_scanline_resample_nearest_RGB555 (dest->pixels + i * dest->stride, - src->pixels + j * src->stride, dest->width, &xacc, x_increment); + src->pixels + j * src->stride, src->width, dest->width, &xacc, + x_increment); acc += y_increment; } @@ -837,8 +1070,15 @@ int dest_size; int xacc; - y_increment = ((src->height - 1) << 16) / (dest->height - 1); - x_increment = ((src->width - 1) << 16) / (dest->width - 1); + if (dest->height == 1) + y_increment = 0; + else + y_increment = ((src->height - 1) << 16) / (dest->height - 1); + + if (dest->width == 1) + x_increment = 0; + else + x_increment = ((src->width - 1) << 16) / (dest->width - 1); dest_size = dest->width * 2; @@ -848,8 +1088,8 @@ acc = 0; xacc = 0; y2 = -1; - vs_scanline_resample_linear_RGB555 (tmp1, src->pixels, dest->width, &xacc, - x_increment); + vs_scanline_resample_linear_RGB555 (tmp1, src->pixels, src->width, + dest->width, &xacc, x_increment); y1 = 0; for (i = 0; i < dest->height; i++) { j = acc >> 16; @@ -863,7 +1103,7 @@ } else { xacc = 0; vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; memcpy (dest->pixels + i * dest->stride, tmp1, dest_size); } @@ -872,8 +1112,8 @@ if (j + 1 != y2) { xacc = 0; vs_scanline_resample_linear_RGB555 (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y2 = j + 1; } vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, @@ -882,8 +1122,8 @@ if (j + 1 != y1) { xacc = 0; vs_scanline_resample_linear_RGB555 (tmp1, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, - x_increment); + src->pixels + (j + 1) * src->stride, src->width, dest->width, + &xacc, x_increment); y1 = j + 1; } vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride, @@ -891,11 +1131,11 @@ } else { xacc = 0; vs_scanline_resample_linear_RGB555 (tmp1, src->pixels + j * src->stride, - dest->width, &xacc, x_increment); + src->width, dest->width, &xacc, x_increment); y1 = j; xacc = 0; vs_scanline_resample_linear_RGB555 (tmp2, - src->pixels + (j + 1) * src->stride, dest->width, &xacc, + src->pixels + (j + 1) * src->stride, src->width, dest->width, &xacc, x_increment); y2 = (j + 1); vs_scanline_merge_linear_RGB555 (dest->pixels + i * dest->stride,