TranscodingSetup : add framerate settings (25k, 50k)
[vuplus_dvbapp] / lib / gdi / gpixmap.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 6f93d56..ee304cf
@@ -3,8 +3,11 @@
 #include <lib/gdi/gpixmap.h>
 #include <lib/gdi/region.h>
 #include <lib/gdi/accel.h>
+#include <byteswap.h>
 
-#define RBG565
+#ifndef BYTE_ORDER
+#error "no BYTE_ORDER defined!"
+#endif
 
 gLookup::gLookup()
        :size(0), lookup(0)
@@ -164,10 +167,10 @@ void gPixmap::fill(const gRegion &region, const gColor &color)
                                icol=(surface->clut.data[color].a<<24)|(surface->clut.data[color].r<<16)|(surface->clut.data[color].g<<8)|(surface->clut.data[color].b);
                        else
                                icol=0x10101*color;
-#ifdef RBG565
-                       __u16 col = ((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF) >> 2) << 5 | (icol & 0xFF00) >> 11;
+#if BYTE_ORDER == LITTLE_ENDIAN
+                       __u16 col = bswap_16(((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19);
 #else
-                       __u16 col = ((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF) >> 3;
+                       __u16 col = ((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19;
 #endif
                        for (int y=area.top(); y<area.bottom(); y++)
                        {
@@ -233,10 +236,10 @@ void gPixmap::fill(const gRegion &region, const gRGB &color)
                } else if (surface->bpp == 16)
                {
                        __u32 icol = color.argb();
-#ifdef RBG565
-                       __u16 col = ((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF) >> 2) << 5 | (icol & 0xFF00) >> 11;
+#if BYTE_ORDER == LITTLE_ENDIAN
+                       __u16 col = bswap_16(((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19);
 #else
-                       __u16 col = ((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF) >> 3;
+                       __u16 col = ((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19;
 #endif
                        for (int y=area.top(); y<area.bottom(); y++)
                        {
@@ -318,6 +321,7 @@ static void blit_8i_to_32_ab(__u32 *dst, __u8 *src, __u32 *pal, int width)
 
 #define FIX 0x10000
 
+
 void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, int flag)
 {
 //     eDebug("blit: -> %d.%d %d:%d -> %d.%d %d:%d, flags=%d",
@@ -377,6 +381,96 @@ void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, i
                        continue;
                }
 
+#ifdef SET_RIGHT_HALF_VFD_SKIN
+               if ((surface->bpp == 8) && (src.surface->bpp==8))
+               {
+                       __u8 *srcptr=(__u8*)src.surface->data;
+                       __u8 *dstptr=(__u8*)surface->data;
+                       __u8 *nomptr = new __u8[area.width()];
+                       unsigned char gray_max = 0;
+                       unsigned char gray_min = 255;
+                       unsigned char index = 0;
+                       unsigned char gray_value = 0;
+                       gRGB pixdata;
+//                     printf("[bilt]srcarea.left:%d, src.surface->bypp : %d,srcarea.top() :%d,src.surface->stride : %d\n",srcarea.left(),src.surface->bypp,srcarea.top(),src.surface->stride);
+                       srcptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride;
+//                     nomptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride;
+                       dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
+                       if(src.surface->clut.colors != 0)
+                       {
+                               for (int y=0; y<area.height(); y++)
+                               {
+                                       for(int x=0;x<area.width();x++)
+                                       {
+                                               index = (unsigned char)(*(srcptr+x+y*src.surface->stride));
+                                               pixdata = src.surface->clut.data[index];
+                                               gray_value = ((pixdata.r+pixdata.g +pixdata.b)/3);
+       //                                      printf("%3d ",gray_value);
+                                               if(gray_value > gray_max)
+                                                       gray_max = gray_value;
+                                               if(gray_value < gray_min)
+                                                       gray_min = gray_value;
+                                       }
+       //                              printf("\n");
+                               }
+                       }
+//                     printf("\n[bilt] ### gray_min : %d, gray_max : %d\n\n",gray_min,gray_max);
+                       for (int y=0; y<area.height(); y++)
+                       {
+                               if(src.surface->clut.colors != 0)
+                               {
+                                       for(int x=0;x<area.width();x++)
+                                       {
+                                               pixdata = src.surface->clut.data[*(srcptr+x)];
+                                               gray_value = ((pixdata.r+pixdata.g +pixdata.b)/3);
+                                               if(gray_max==gray_min)
+                                                       *(nomptr+x)=gray_value;
+/*                                             else if(y == 0 || y == area.height()-1 || x == 0 || x == area.width()-1)
+                                                       *(nomptr+x) = 255;*/
+                                               else
+                                                       *(nomptr+x)=( ((gray_value - gray_min)*255)/(gray_max-gray_min) );
+       //                                      printf("%3d ",*(nomptr+x));
+                                       }
+       //                              printf("\n");
+                               }
+                               else
+                               {
+                                       for(int x=0;x<area.width();x++)
+                                       {
+/*                                             if(y == 0 || y == area.height()-1 || x == 0 || x == area.width()-1)
+                                                       *(nomptr+x) = 255;
+                                               else
+                                                       *(nomptr+x)=*(srcptr+x);*/
+                                               *(nomptr+x)=*(srcptr+x);
+//                                             printf("%3d ",*(nomptr+x));
+                                       }
+//                                     printf("\n");
+                               }
+                               if (flag & (blitAlphaTest|blitAlphaBlend))
+                               {
+                     // no real alphatest yet
+                                       int width=area.width();
+//                                     unsigned char *src=(unsigned char*)srcptr;
+                                       unsigned char *src=(unsigned char*)nomptr;
+                                       unsigned char *dst=(unsigned char*)dstptr;
+                                               // use duff's device here!
+                                       while (width--)
+                                       {
+                                               if (!*src)
+                                               {
+                                                       src++;
+                                                       dst++;
+                                               } else
+                                                       *dst++=*src++;
+                                       }
+                               } else
+//                                     memcpy(dstptr, srcptr, area.width()*surface->bypp);
+                                       memcpy(dstptr, nomptr, area.width()*surface->bypp);
+                               srcptr+=src.surface->stride;
+                               dstptr+=surface->stride;
+                       }
+                       delete [] nomptr;
+#else
                if ((surface->bpp == 8) && (src.surface->bpp==8))
                {
                        __u8 *srcptr=(__u8*)src.surface->data;
@@ -407,6 +501,7 @@ void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, i
                                srcptr+=src.surface->stride;
                                dstptr+=surface->stride;
                        }
+#endif
                } else if ((surface->bpp == 32) && (src.surface->bpp==32))
                {
                        __u32 *srcptr=(__u32*)src.surface->data;
@@ -510,10 +605,10 @@ void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, i
                                        icol=(src.surface->clut.data[i].a<<24)|(src.surface->clut.data[i].r<<16)|(src.surface->clut.data[i].g<<8)|(src.surface->clut.data[i].b);
                                else
                                        icol=0x010101*i;
-#ifdef RBG565
-                               pal[i]=icol&0xFF000000 | ((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF) >> 2) << 5 | (icol & 0xFF00) >> 11;
+#if BYTE_ORDER == LITTLE_ENDIAN
+                               pal[i] = bswap_16(((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19);
 #else
-                               pal[i]=icol&0xFF000000 | ((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF) >> 3;
+                               pal[i] = ((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19;
 #endif
                                pal[i]^=0xFF000000;
                        }
@@ -564,10 +659,10 @@ void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, i
                                                } else
                                                {
                                                        __u32 icol = *srcp++;
-#ifdef RBG565
-                                                       *dstp++=((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF) >> 2) << 5 | (icol & 0xFF00) >> 11;
+#if BYTE_ORDER == LITTLE_ENDIAN
+                                                       *dstp++ = bswap_16(((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19);
 #else
-                                                       *dstp++=((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF) >> 3;
+                                                       *dstp++ = ((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19;
 #endif
                                                }
                                        }
@@ -576,10 +671,10 @@ void gPixmap::blit(const gPixmap &src, const eRect &_pos, const gRegion &clip, i
                                        while (width--)
                                        {
                                                __u32 icol = *srcp++;
-#ifdef RBG565
-                                               *dstp++=((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF) >> 2) << 5 | (icol & 0xFF00) >> 11;
+#if BYTE_ORDER == LITTLE_ENDIAN
+                                               *dstp++ = bswap_16(((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19);
 #else
-                                               *dstp++=((icol & 0xFF0000) >> 19) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF) >> 3;
+                                               *dstp++ = ((icol & 0xFF) >> 3) << 11 | ((icol & 0xFF00) >> 10) << 5 | (icol & 0xFF0000) >> 19;
 #endif
                                        }
                                }
@@ -655,13 +750,11 @@ void gPixmap::line(const gRegion &clip, ePoint start, ePoint dst, gColor color)
        }
 
        if (surface->bpp == 16)
-       {
-#ifdef RBG565
-               col16=((col & 0xFF0000) >> 19) << 11 | ((col & 0xFF) >> 2) << 5 | (col & 0xFF00) >> 11;
+#if BYTE_ORDER == LITTLE_ENDIAN
+               col16=bswap_16(((col & 0xFF) >> 3) << 11 | ((col & 0xFF00) >> 10) << 5 | (col & 0xFF0000) >> 19);
 #else
-               col16=((col & 0xFF0000) >> 19) << 11 | ((col & 0xFF00) >> 10) << 5 | (col & 0xFF) >> 3;
+               col16=((col & 0xFF) >> 3) << 11 | ((col & 0xFF00) >> 10) << 5 | (col & 0xFF0000) >> 19;
 #endif
-       }
 
        int xa = start.x(), ya = start.y(), xb = dst.x(), yb = dst.y();
        int dx, dy, x, y, s1, s2, e, temp, swap, i;