bcm accelerated blit: avoid running out of clut data
authorpieterg <pieterg@users.sourceforge.net>
Wed, 12 Jan 2011 23:30:13 +0000 (00:30 +0100)
committerAndreas Oberritter <obi@opendreambox.org>
Thu, 13 Jan 2011 00:09:40 +0000 (01:09 +0100)
We were passing a hardcoded number of 256 entries to the framebuffer,
while the source surface could have a smaller color lookup table.
For instance, most dvb subtitle graphics have a palette of only 16 colors.
This would cause frequent segfaults.

lib/gdi/accel.cpp

index 9450ecc..fc739e9 100644 (file)
@@ -112,7 +112,7 @@ int gAccel::blit(gSurface *dst, const gSurface *src, const eRect &p, const eRect
                        pal_addr = src->stride * src->y;
                        unsigned long *pal = (unsigned long*)(((unsigned char*)src->data) + pal_addr);
                        pal_addr += src->data_phys;
                        pal_addr = src->stride * src->y;
                        unsigned long *pal = (unsigned long*)(((unsigned char*)src->data) + pal_addr);
                        pal_addr += src->data_phys;
-                       for (i = 0; i < 256; ++i)
+                       for (i = 0; i < src->clut.colors; ++i)
                                *pal++ = src->clut.data[i].argb() ^ 0xFF000000;
                } else
                        return -1; /* unsupported source format */
                                *pal++ = src->clut.data[i].argb() ^ 0xFF000000;
                } else
                        return -1; /* unsupported source format */