From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YQikE-0000Yk-KK for mharc-grub-devel@gnu.org; Wed, 25 Feb 2015 15:39:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQik9-0000PG-3d for grub-devel@gnu.org; Wed, 25 Feb 2015 15:39:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQik7-0004LZ-Nr for grub-devel@gnu.org; Wed, 25 Feb 2015 15:39:41 -0500 Received: from mail-we0-x22b.google.com ([2a00:1450:400c:c03::22b]:38026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQik7-0004LQ-Ch for grub-devel@gnu.org; Wed, 25 Feb 2015 15:39:39 -0500 Received: by wesw55 with SMTP id w55so6073355wes.5 for ; Wed, 25 Feb 2015 12:39:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=b/ILrwEthmYWmWucN/IFX17UPRY0XLujxgnqIUYLwV0=; b=HVOy02O0O7E9i+P0QEye9UMvFs5yphtZCrIjhhS05cf1XRLsB8iUlAeXWaAPPyHiR0 Md9PwH8Nr73HznuAqwt+gDUPy7v1r+9K7rFBlHNcEtL+9sgNyECBG5rjXItUiN1dUzaW TJqhwv5dtHfrF5ur5bV6em2cZWMQfMGANgpVFK3HHqs5+e+iLLRhfbJTS1xdThZq25d5 F5CWQuWwiTfkGT8DwVpVw86Y3KXpP4kdJz90/+frA/9RSJb7q9IP+ta0FAPtVaPqt2cv VITk2HhyN7tZf+BQCS3n+CH69Lac19Xyit4TCzrvTajrRG1uhdDTIUdVVJU9GyWPLa15 r9BQ== X-Received: by 10.180.90.237 with SMTP id bz13mr17074652wib.45.1424896778767; Wed, 25 Feb 2015 12:39:38 -0800 (PST) Received: from ?IPv6:2a02:1205:501d:9210:863a:4bff:fe50:abc4? ([2a02:1205:501d:9210:863a:4bff:fe50:abc4]) by mx.google.com with ESMTPSA id ka1sm66388807wjc.2.2015.02.25.12.39.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 12:39:37 -0800 (PST) Message-ID: <54EE3309.4010605@gmail.com> Date: Wed, 25 Feb 2015 21:39:37 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: Image scaling performance References: <20150225154540.GR4278@bivouac.eciton.net> <20150225162352.GT4278@bivouac.eciton.net> <54EE1AF7.50305@gmail.com> In-Reply-To: Content-Type: multipart/mixed; boundary="------------090908070601020801030908" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22b X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2015 20:39:42 -0000 This is a multi-part message in MIME format. --------------090908070601020801030908 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 25.02.2015 20:28, Michael Zimmermann wrote: > your patch still has graphical glitches: http://puu.sh/gcpco/da369f26c7.png --------------090908070601020801030908 Content-Type: text/x-diff; name="scale.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="scale.diff" diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c index 0b93d02..70c32f0 100644 --- a/grub-core/video/bitmap_scale.c +++ b/grub-core/video/bitmap_scale.c @@ -361,35 +361,46 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) unsigned dh = dst->mode_info.height; unsigned sw = src->mode_info.width; unsigned sh = src->mode_info.height; - unsigned dstride = dst->mode_info.pitch; - unsigned sstride = src->mode_info.pitch; + int dstride = dst->mode_info.pitch; + int sstride = src->mode_info.pitch; /* bytes_per_pixel is the same for both src and dst. */ - unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel; + int bytes_per_pixel = dst->mode_info.bytes_per_pixel; + unsigned dy, sy, ystep, yfrac, yover; + unsigned sx, xstep, xfrac, xover; + grub_uint8_t *dptr, *dline_end, *sline; - unsigned dy; - for (dy = 0; dy < dh; dy++) + xstep = sw / dw; + xover = sw % dw; + ystep = sh / dh; + yover = sh % dh; + + for (dy = 0, sy = 0, yfrac = 0; dy < dh; dy++, sy += ystep, yfrac += yover) { - unsigned dx; - for (dx = 0; dx < dw; dx++) + if (yfrac >= dh) + { + yfrac -= dh; + sy++; + } + dptr = ddata + dy * dstride; + dline_end = dptr + dw * bytes_per_pixel; + sline = sdata + sy * sstride; + for (sx = 0, xfrac = 0; dptr < dline_end; sx += xstep, xfrac += xover, dptr += bytes_per_pixel) { - grub_uint8_t *dptr; grub_uint8_t *sptr; - unsigned sx; - unsigned sy; - unsigned comp; + int comp; - /* Compute the source coordinate that the destination coordinate - maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */ - sx = sw * dx / dw; - sy = sh * dy / dh; + if (xfrac >= dw) + { + xfrac -= dw; + sx++; + } /* Get the address of the pixels in src and dst. */ - dptr = ddata + dy * dstride + dx * bytes_per_pixel; - sptr = sdata + sy * sstride + sx * bytes_per_pixel; + sptr = sline + sx * bytes_per_pixel; - /* Copy the pixel color value. */ - for (comp = 0; comp < bytes_per_pixel; comp++) - dptr[comp] = sptr[comp]; + /* Copy the pixel color value. */ + for (comp = 0; comp < bytes_per_pixel; comp++) + dptr[comp] = sptr[comp]; } } return GRUB_ERR_NONE; @@ -422,27 +433,40 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) int sstride = src->mode_info.pitch; /* bytes_per_pixel is the same for both src and dst. */ int bytes_per_pixel = dst->mode_info.bytes_per_pixel; + unsigned dy, syf, sy, ystep, yfrac, yover; + unsigned sxf, sx, xstep, xfrac, xover; + grub_uint8_t *dptr, *dline_end, *sline; + + xstep = (sw << 8) / dw; + xover = (sw << 8) % dw; + ystep = (sh << 8) / dh; + yover = (sh << 8) % dh; - unsigned dy; - for (dy = 0; dy < dh; dy++) + for (dy = 0, syf = 0, yfrac = 0; dy < dh; dy++, syf += ystep, yfrac += yover) { - unsigned dx; - for (dx = 0; dx < dw; dx++) + if (yfrac >= dh) + { + yfrac -= dh; + syf++; + } + sy = syf >> 8; + dptr = ddata + dy * dstride; + dline_end = dptr + dw * bytes_per_pixel; + sline = sdata + sy * sstride; + for (sxf = 0, xfrac = 0; dptr < dline_end; sxf += xstep, xfrac += xover, dptr += bytes_per_pixel) { - grub_uint8_t *dptr; grub_uint8_t *sptr; - unsigned sx; - unsigned sy; int comp; - /* Compute the source coordinate that the destination coordinate - maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */ - sx = sw * dx / dw; - sy = sh * dy / dh; + if (xfrac >= dw) + { + xfrac -= dw; + sxf++; + } /* Get the address of the pixels in src and dst. */ - dptr = ddata + dy * dstride + dx * bytes_per_pixel; - sptr = sdata + sy * sstride + sx * bytes_per_pixel; + sx = sxf >> 8; + sptr = sline + sx * bytes_per_pixel; /* If we have enough space to do so, use bilinear interpolation. Otherwise, fall back to nearest neighbor for this pixel. */ @@ -453,27 +477,27 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) /* Fixed-point .8 numbers representing the fraction of the distance in the x (u) and y (v) direction within the box of 4 pixels in the source. */ - int u = (256 * sw * dx / dw) - (sx * 256); - int v = (256 * sh * dy / dh) - (sy * 256); + unsigned u = sxf & 0xff; + unsigned v = syf & 0xff; for (comp = 0; comp < bytes_per_pixel; comp++) { /* Get the component's values for the four source corner pixels. */ - int f00 = sptr[comp]; - int f10 = sptr[comp + bytes_per_pixel]; - int f01 = sptr[comp + sstride]; - int f11 = sptr[comp + sstride + bytes_per_pixel]; + unsigned f00 = sptr[comp]; + unsigned f10 = sptr[comp + bytes_per_pixel]; + unsigned f01 = sptr[comp + sstride]; + unsigned f11 = sptr[comp + sstride + bytes_per_pixel]; /* Count coeffecients. */ - int c00 = (256 - u) * (256 - v); - int c10 = u * (256 - v); - int c01 = (256 - u) * v; - int c11 = u * v; + unsigned c00 = (256 - u) * (256 - v); + unsigned c10 = u * (256 - v); + unsigned c01 = (256 - u) * v; + unsigned c11 = u * v; /* Interpolate. */ - int fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11; - fxy = fxy / (256 * 256); + unsigned fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11; + fxy = fxy >> 16; dptr[comp] = fxy; } --------------090908070601020801030908--