Le Tue Feb 24 2015 at 11:01:03 AM, Michael Zimmermann <
sigmaepsilo...@gmail.com> a écrit :

> the function seems to use __aeabi_uidiv. I'm not sure if this is a sw
> or hw implementation.
>
software. Try attached patch

> Full code:
> ASM: http://pastebin.com/FnPRZt1H
> pseudo-C <http://pastebin.com/FnPRZt1Hpseudo-C>:
> http://pastebin.com/dH3YBk46
>
> On Tue, Feb 24, 2015 at 10:51 AM, Vladimir 'phcoder' Serbinenko
> <phco...@gmail.com> wrote:
> > Did you try to look at ASM of the function in question? Do you compile to
> > thumb? Multiplication sometimes generates function calls in thumb. Try
> > marking the scaling function as arm explicitly
> >
> > Le 2015-02-24 10:39, "Michael Zimmermann" <sigmaepsilo...@gmail.com> a
> écrit
> > :
> >>
> >> Any ideas what could slow down the image scaling algorithm?
> >> The only reasons I could think of would either be slow memory or some
> >> compiler problems. Since my Ram is mapped cachable I don't think the
> >> RAM is too slow.
> >>
> >> I even forces using the Nearest neighbor algorithm already. It speeds
> >> things up a lot but it's not as fast as you'd expect.
> >>
> >> Some technical info:
> >> ARMv7
> >> Linaro GCC 4.9
> >> MMU setup is done by the previous bootloader(I disabled GRUB's (uboot)
> >> MMU setup - it prooved to be faster)
> >>
> >> _______________________________________________
> >> Grub-devel mailing list
> >> Grub-devel@gnu.org
> >> https://lists.gnu.org/mailman/listinfo/grub-devel
> >
> >
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> >
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c
index 0b93d02..1c7195f 100644
--- a/grub-core/video/bitmap_scale.c
+++ b/grub-core/video/bitmap_scale.c
@@ -366,22 +366,32 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
   /* bytes_per_pixel is the same for both src and dst. */
   unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel;
 
-  unsigned dy;
-  for (dy = 0; dy < dh; dy++)
+  unsigned dy, sy, ystep, yfrac, yover;
+  unsigned dx, sx, xstep, xfrac, xover;
+  ystep = sw / dw;
+  yover = sw % dw;
+  xstep = sh / dh;
+  xover = sh % dh;
+
+  for (dy = 0, sy = 0; dy < dh; dy++, sy += ystep, yfrac += yover)
     {
       unsigned dx;
-      for (dx = 0; dx < dw; dx++)
+      if (yfrac > dw)
+	{
+	  yfrac -= dw;
+	  sy++;
+	}
+      for (dx = 0, sx = 0; dx < dw; dx++, sx += xstep, xfrac += xover)
         {
           grub_uint8_t *dptr;
           grub_uint8_t *sptr;
-          unsigned sx;
-          unsigned sy;
           unsigned 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 > dh)
+	    {
+	      xfrac -= dh;
+	      sx++;
+	    }
 
           /* Get the address of the pixels in src and dst. */
           dptr = ddata + dy * dstride + dx * bytes_per_pixel;
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to