Ok here it is. DSPF_ALUT44, the native format of Matrox CRTC2 sub-picture
layer :)
All software operations should work. I've been running df_dok and
df_porter on it without problems. Hardware acceleration isn't implemented.
I've initialized the palette to rgb121 values :) It works surprisingly
well but blend benchmarks would like more colors.
For palette lookups in the accel code I've used 0x80 as the alpha value
since palette alpha is irrelevant for this format.
--
Ville Syrj�l�
[EMAIL PROTECTED]
http://www.sci.fi/~syrjala/
diff -urN DirectFB/gfxdrivers/matrox/matrox_spic.c
DirectFB/gfxdrivers/matrox/matrox_spic.c
--- DirectFB/gfxdrivers/matrox/matrox_spic.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/gfxdrivers/matrox/matrox_spic.c 2003-03-19 17:37:46.000000000 +0200
@@ -106,7 +106,7 @@
default_config->width = 720;
default_config->height = dfb_config->matrox_ntsc ? 480 : 576;
- default_config->pixelformat = DSPF_LUT8;
+ default_config->pixelformat = DSPF_ALUT44;
default_config->buffermode = DLBM_FRONTONLY;
default_config->options = DLOP_NONE;
@@ -176,7 +176,7 @@
fail |= DLCONF_OPTIONS;
switch (config->pixelformat) {
- case DSPF_LUT8:
+ case DSPF_ALUT44:
break;
default:
fail |= DLCONF_PIXELFORMAT;
@@ -226,10 +226,8 @@
__u8 r, g, b, y, cb, cr;
int i;
-#if 0
if (palette->num_entries != 16)
return DFB_UNSUPPORTED;
-#endif
for (i = 0; i < 16; i++) {
r = palette->entries[i].r;
diff -urN DirectFB/include/directfb.h DirectFB/include/directfb.h
--- DirectFB/include/directfb.h 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/include/directfb.h 2003-03-19 17:37:46.000000000 +0200
@@ -797,12 +797,13 @@
DSPF_YV12 = 0x08100C0B, /* 8 bit Y plane followed by 8 bit
2x2 subsampled V and U planes */
DSPF_LUT8 = 0x4011080C, /* 8 bit lookup table (palette) */
+ DSPF_ALUT44 = 0x4011040D, /* 4 bit alpha + 4 bit lookup table */
DSPF_RGB15 = DSPF_ARGB1555
} DFBSurfacePixelFormat;
/* Number of pixelformats defined */
-#define DFB_NUM_PIXELFORMATS 12
+#define DFB_NUM_PIXELFORMATS 13
/* These macros extract information about the pixel format. */
#define DFB_PIXELFORMAT_INDEX(fmt) (((fmt) & 0x0000FF) - 1)
diff -urN DirectFB/src/core/fbdev/fbdev.c DirectFB/src/core/fbdev/fbdev.c
--- DirectFB/src/core/fbdev/fbdev.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/core/fbdev/fbdev.c 2003-03-19 17:37:46.000000000 +0200
@@ -1216,7 +1216,8 @@
DFBResult ret;
CorePalette *palette;
- ret = dfb_palette_create( 256, &palette );
+ ret = dfb_palette_create( 1 << DFB_BITS_PER_PIXEL( config->pixelformat ),
+ &palette );
if (ret)
return ret;
diff -urN DirectFB/src/core/palette.c DirectFB/src/core/palette.c
--- DirectFB/src/core/palette.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/core/palette.c 2003-03-19 17:39:13.000000000 +0200
@@ -138,6 +138,26 @@
dfb_palette_update( palette, 0, palette->num_entries - 1 );
}
+void
+dfb_palette_generate_rgb121_map( CorePalette *palette )
+{
+ int i;
+
+ DFB_ASSERT( palette != NULL );
+
+ if (!palette->num_entries)
+ return;
+
+ for (i=0; i<palette->num_entries; i++) {
+ palette->entries[i].a = i ? 0xff : 0x00;
+ palette->entries[i].r = (i & 0x8) ? 0xff : 0x00;
+ palette->entries[i].g = lookup2to8[ (i & 0x6) >> 1 ];
+ palette->entries[i].b = (i & 0x1) ? 0xff : 0x00;
+ }
+
+ dfb_palette_update( palette, 0, palette->num_entries - 1 );
+}
+
unsigned int
dfb_palette_search( CorePalette *palette,
__u8 r,
diff -urN DirectFB/src/core/palette.h DirectFB/src/core/palette.h
--- DirectFB/src/core/palette.h 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/core/palette.h 2003-03-19 17:38:00.000000000 +0200
@@ -62,6 +62,7 @@
CorePalette **ret_palette );
void dfb_palette_generate_rgb332_map( CorePalette *palette );
+void dfb_palette_generate_rgb121_map( CorePalette *palette );
unsigned int dfb_palette_search ( CorePalette *palette,
__u8 r,
diff -urN DirectFB/src/core/surfaces.c DirectFB/src/core/surfaces.c
--- DirectFB/src/core/surfaces.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/core/surfaces.c 2003-03-19 17:39:47.000000000 +0200
@@ -291,7 +291,8 @@
DFBResult ret;
CorePalette *palette;
- ret = dfb_palette_create( 256, &palette );
+ ret = dfb_palette_create( 1 << DFB_BITS_PER_PIXEL( format ),
+ &palette );
if (ret)
return ret;
@@ -689,6 +690,7 @@
case DSPF_YUY2:
case DSPF_YV12:
case DSPF_LUT8:
+ case DSPF_ALUT44:
break;
default:
@@ -718,12 +720,15 @@
DFBResult ret;
CorePalette *palette;
- ret = dfb_palette_create( 256, &palette );
+ ret = dfb_palette_create( 1 << DFB_BITS_PER_PIXEL( format ),
+ &palette );
if (ret)
return ret;
if (format == DSPF_LUT8)
dfb_palette_generate_rgb332_map( palette );
+ else if (format == DSPF_ALUT44)
+ dfb_palette_generate_rgb121_map( palette );
dfb_surface_set_palette( surface, palette );
diff -urN DirectFB/src/gfx/generic/generic.c DirectFB/src/gfx/generic/generic.c
--- DirectFB/src/gfx/generic/generic.c 2003-03-19 17:44:21.000000000 +0200
+++ DirectFB/src/gfx/generic/generic.c 2003-03-19 17:37:46.000000000 +0200
@@ -212,6 +212,7 @@
Cop_to_Aop_32,
Cop_to_Aop_8,
Cop_to_Aop_8,
+ Cop_to_Aop_8,
Cop_to_Aop_8
};
@@ -261,6 +262,19 @@
}
}
+static void Cop_toK_Aop_alut44()
+{
+ int w = Dlength;
+ __u8 *D = (__u8*)Aop;
+
+ while (w--) {
+ if ((__u8)Dkey == (*D & 0x0F))
+ *D = (__u8)Cop;
+
+ D++;
+ }
+}
+
static GFunc Cop_toK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
Cop_toK_Aop_16,
Cop_toK_Aop_16,
@@ -273,7 +287,8 @@
NULL,
NULL,
NULL,
- Cop_toK_Aop_8
+ Cop_toK_Aop_8,
+ Cop_toK_Aop_alut44
};
/********************************* Bop_PFI_to_Aop_PFI *************************/
@@ -314,7 +329,8 @@
Bop_16_to_Aop, /* DSPF_UYVY */
Bop_8_to_Aop, /* DSPF_I420 */
Bop_8_to_Aop, /* DSPF_YV12 */
- Bop_8_to_Aop /* DSPF_LUT8 */
+ Bop_8_to_Aop, /* DSPF_LUT8 */
+ Bop_8_to_Aop /* DSPF_ALUT44 */
};
/********************************* Bop_PFI_Kto_Aop_PFI ************************/
@@ -529,6 +545,28 @@
}
}
+static void Bop_alut44_Kto_Aop()
+{
+ int w = Dlength;
+ __u8 *D = (__u8*)Aop;
+ __u8 *S = (__u8*)Bop;
+
+ if (Ostep < 0) {
+ D+= Dlength - 1;
+ S+= Dlength - 1;
+ }
+
+ while (w--) {
+ __u8 spixel = *S;
+
+ if ((spixel & 0x0F) != (__u8)Skey)
+ *D = spixel;
+
+ S+=Ostep;
+ D+=Ostep;
+ }
+}
+
static GFunc Bop_PFI_Kto_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
Bop_rgb15_Kto_Aop,
Bop_rgb16_Kto_Aop,
@@ -541,7 +579,8 @@
NULL,
NULL,
NULL,
- Bop_8_Kto_Aop
+ Bop_8_Kto_Aop,
+ Bop_alut44_Kto_Aop
};
/********************************* Bop_PFI_Sto_Aop_PFI ****************************/
@@ -633,6 +672,7 @@
NULL,
NULL,
NULL,
+ Bop_8_Sto_Aop,
Bop_8_Sto_Aop
};
@@ -768,6 +808,24 @@
}
}
+static void Bop_alut44_SKto_Aop()
+{
+ int w = Dlength;
+ int i = 0;
+ __u8 *D = (__u8*)Aop;
+ __u8 *S = (__u8*)Bop;
+
+ while (w--) {
+ __u8 s = S[i>>16];
+
+ if ((s & 0x0F) != Skey)
+ *D = s;
+
+ D++;
+ i += SperD;
+ }
+}
+
static GFunc Bop_PFI_SKto_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
Bop_rgb15_SKto_Aop,
Bop_rgb16_SKto_Aop,
@@ -780,7 +838,8 @@
NULL,
NULL,
NULL,
- Bop_8_SKto_Aop
+ Bop_8_SKto_Aop,
+ Bop_alut44_SKto_Aop
};
/********************************* Sop_PFI_Sto_Dacc ***************************/
@@ -970,6 +1029,31 @@
}
}
+static void Sop_alut44_Sto_Dacc()
+{
+ int w = Dlength;
+ int i = 0;
+
+ Accumulator *D = Dacc;
+ __u8 *S = (__u8*)Sop;
+
+ DFBColor *entries = Slut->entries;
+
+ while (w--) {
+ __u8 s = S[i>>16];
+
+ D->a = s & 0xF0;
+ s &= 0x0F;
+ D->r = entries[s].r;
+ D->g = entries[s].g;
+ D->b = entries[s].b;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
static GFunc Sop_PFI_Sto_Dacc[DFB_NUM_PIXELFORMATS] = {
Sop_argb1555_Sto_Dacc,
Sop_rgb16_Sto_Dacc,
@@ -986,7 +1070,8 @@
NULL,
NULL,
NULL,
- Sop_lut8_Sto_Dacc
+ Sop_lut8_Sto_Dacc,
+ Sop_alut44_Sto_Dacc
};
/********************************* Sop_PFI_SKto_Dacc **************************/
@@ -1177,6 +1262,35 @@
}
}
+static void Sop_alut44_SKto_Dacc()
+{
+ int w = Dlength;
+ int i = 0;
+
+ Accumulator *D = Dacc;
+ __u8 *S = (__u8*)Sop;
+
+ DFBColor *entries = Slut->entries;
+
+ while (w--) {
+ __u8 s = S[i>>16];
+
+ if ((s & 0x0F) != Skey) {
+ D->a = s & 0xF0;
+ s &= 0x0F;
+ D->r = entries[s].r;
+ D->g = entries[s].g;
+ D->b = entries[s].b;
+ }
+ else
+ D->a = 0xF000;
+
+ i += SperD;
+
+ D++;
+ }
+}
+
static GFunc Sop_PFI_SKto_Dacc[DFB_NUM_PIXELFORMATS] = {
Sop_argb1555_SKto_Dacc,
Sop_rgb16_SKto_Dacc,
@@ -1189,7 +1303,8 @@
NULL,
NULL,
NULL,
- Sop_lut8_SKto_Dacc
+ Sop_lut8_SKto_Dacc,
+ Sop_alut44_SKto_Dacc
};
/********************************* Sop_PFI_to_Dacc ****************************/
@@ -1431,6 +1546,27 @@
}
}
+static void Sop_alut44_to_Dacc()
+{
+ int w = Dlength;
+ Accumulator *D = Dacc;
+ __u8 *S = (__u8*)Sop;
+
+ DFBColor *entries = Slut->entries;
+
+ while (w--) {
+ __u8 s = *S++;
+
+ D->a = s & 0xF0;
+ s &= 0x0F;
+ D->r = entries[s].r;
+ D->g = entries[s].g;
+ D->b = entries[s].b;
+
+ D++;
+ }
+}
+
static GFunc Sop_PFI_to_Dacc[DFB_NUM_PIXELFORMATS] = {
Sop_argb1555_to_Dacc,
Sop_rgb16_to_Dacc,
@@ -1447,7 +1583,8 @@
NULL,
NULL,
NULL,
- Sop_lut8_to_Dacc
+ Sop_lut8_to_Dacc,
+ Sop_alut44_to_Dacc
};
/********************************* Sop_PFI_Kto_Dacc ***************************/
@@ -1631,6 +1768,31 @@
}
}
+static void Sop_alut44_Kto_Dacc()
+{
+ int w = Dlength;
+ Accumulator *D = Dacc;
+ __u8 *S = (__u8*)Sop;
+
+ DFBColor *entries = Slut->entries;
+
+ while (w--) {
+ __u8 s = *S++;
+
+ if ((s & 0x0F) != (__u8)Skey) {
+ D->a = s & 0xF0;
+ s &= 0x0F;
+ D->r = entries[s].r;
+ D->g = entries[s].g;
+ D->b = entries[s].b;
+ }
+ else
+ D->a = 0xF000;
+
+ D++;
+ }
+}
+
static GFunc Sop_PFI_Kto_Dacc[DFB_NUM_PIXELFORMATS] = {
Sop_argb1555_Kto_Dacc,
Sop_rgb16_Kto_Dacc,
@@ -1647,7 +1809,8 @@
NULL,
NULL,
NULL,
- Sop_lut8_Kto_Dacc
+ Sop_lut8_Kto_Dacc,
+ Sop_alut44_Kto_Dacc
};
/********************************* Sacc_to_Aop_PFI ****************************/
@@ -1855,6 +2018,27 @@
}
}
+static void Sacc_to_Aop_alut44()
+{
+ int w = Dlength;
+ Accumulator *S = Sacc;
+ __u8 *D = (__u8*)Aop;
+
+ while (w--) {
+ if (!(S->a & 0xF000)) {
+ *D = (S->a & 0xFF00) ? 0xF0 : (S->a & 0xF0) +
+ dfb_palette_search( Alut,
+ (S->r & 0xFF00) ? 0xFF : S->r,
+ (S->g & 0xFF00) ? 0xFF : S->g,
+ (S->b & 0xFF00) ? 0xFF : S->b,
+ 0x80 );
+ }
+
+ D++;
+ S++;
+ }
+}
+
GFunc Sacc_to_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
Sacc_to_Aop_argb1555,
Sacc_to_Aop_rgb16,
@@ -1871,7 +2055,8 @@
NULL,
NULL,
NULL,
- Sacc_to_Aop_lut8
+ Sacc_to_Aop_lut8,
+ Sacc_to_Aop_alut44
};
/******************************** Sacc_toK_Aop_PFI ****************************/
@@ -2026,6 +2211,27 @@
}
}
+static void Sacc_toK_Aop_alut44()
+{
+ int w = Dlength;
+ Accumulator *S = Sacc;
+ __u8 *D = (__u8*)Aop;
+
+ while (w--) {
+ if (!(S->a & 0xF000) && ((*D & 0x0F) == (__u8)Dkey)) {
+ *D = (S->a & 0xFF00) ? 0xF0 : (S->a & 0xF0) +
+ dfb_palette_search( Alut,
+ (S->r & 0xFF00) ? 0xFF : S->r,
+ (S->g & 0xFF00) ? 0xFF : S->g,
+ (S->b & 0xFF00) ? 0xFF : S->b,
+ 0x80 );
+ }
+
+ D++;
+ S++;
+ }
+}
+
GFunc Sacc_toK_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
Sacc_toK_Aop_argb1555,
Sacc_toK_Aop_rgb16,
@@ -2042,7 +2248,8 @@
NULL,
NULL,
NULL,
- Sacc_toK_Aop_lut8
+ Sacc_toK_Aop_lut8,
+ Sacc_toK_Aop_alut44
};
/************** Bop_a8_set_alphapixel_Aop_PFI *********************************/
@@ -2289,6 +2496,37 @@
#undef SET_ALPHA_PIXEL_LUT8
}
+static void Bop_a8_set_alphapixel_Aop_alut44()
+{
+ int w = Dlength;
+ __u8 *S = Bop;
+ __u8 *D = Aop;
+
+#define SET_ALPHA_PIXEL_ALUT44(d,alpha) \
+ switch (alpha) {\
+ case 0xff: d = Cop;\
+ case 0: break; \
+ default: {\
+ register __u16 s = alpha+1;\
+ DFBColor dc = Alut->entries[d & 0x0f];\
+ __u16 sa = (d & 0xf0) + alpha;\
+ dc.r = ((color.r - dc.r) * s + (dc.r << 8)) >> 8;\
+ dc.g = ((color.g - dc.g) * s + (dc.g << 8)) >> 8;\
+ dc.b = ((color.b - dc.b) * s + (dc.b << 8)) >> 8;\
+ if (sa & 0xff00) sa = 0xf0;\
+ d = (sa & 0xf0) + \
+ dfb_palette_search( Alut, dc.r, dc.g, dc.b, 0x80 );\
+ }\
+ }
+
+ while (w--) {
+ SET_ALPHA_PIXEL_ALUT44( *D, *S );
+ D++, S++;
+ }
+
+#undef SET_ALPHA_PIXEL_ALUT44
+}
+
GFunc Bop_a8_set_alphapixel_Aop_PFI[DFB_NUM_PIXELFORMATS] = {
Bop_a8_set_alphapixel_Aop_argb1555,
Bop_a8_set_alphapixel_Aop_rgb16,
@@ -2305,7 +2543,8 @@
NULL,
NULL,
NULL,
- Bop_a8_set_alphapixel_Aop_lut8
+ Bop_a8_set_alphapixel_Aop_lut8,
+ Bop_a8_set_alphapixel_Aop_alut44
};
@@ -2865,6 +3104,10 @@
Cop = state->color_index;
Alut = destination->palette;
break;
+ case DSPF_ALUT44:
+ Cop = (color.a & 0xF0) + state->color_index;
+ Alut = destination->palette;
+ break;
default:
ONCE("unsupported destination format");
pthread_mutex_unlock( &generic_lock );
@@ -2894,6 +3137,7 @@
}
break;
case DSPF_LUT8:
+ case DSPF_ALUT44:
Blut = source->palette;
break;
default:
diff -urN DirectFB/src/idirectfb.c DirectFB/src/idirectfb.c
--- DirectFB/src/idirectfb.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/idirectfb.c 2003-03-19 17:41:18.000000000 +0200
@@ -390,6 +390,7 @@
case DSPF_ARGB1555:
case DSPF_I420:
case DSPF_LUT8:
+ case DSPF_ALUT44:
case DSPF_RGB16:
case DSPF_RGB24:
case DSPF_RGB32:
diff -urN DirectFB/src/misc/conf.c DirectFB/src/misc/conf.c
--- DirectFB/src/misc/conf.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/misc/conf.c 2003-03-19 17:37:46.000000000 +0200
@@ -157,6 +157,7 @@
static const FormatString format_strings[] = {
{ "A8", DSPF_A8 },
+ { "ALUT44", DSPF_ALUT44 },
{ "ARGB", DSPF_ARGB },
{ "ARGB1555", DSPF_ARGB1555 },
{ "I420", DSPF_I420 },
diff -urN DirectFB/src/misc/gfx_util.c DirectFB/src/misc/gfx_util.c
--- DirectFB/src/misc/gfx_util.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/src/misc/gfx_util.c 2003-03-19 17:37:46.000000000 +0200
@@ -116,6 +116,11 @@
*dst++ = dfb_palette_search( palette, r, g, b, a );
break;
+ case DSPF_ALUT44:
+ if (palette)
+ *dst++ = (a & 0xF0) + dfb_palette_search( palette, r, g, b, 0x80 );
+ break;
+
default:
ONCE( "unimplemented destination format" );
break;
diff -urN DirectFB/tools/dfbdump.c DirectFB/tools/dfbdump.c
--- DirectFB/tools/dfbdump.c 2003-03-19 17:44:11.000000000 +0200
+++ DirectFB/tools/dfbdump.c 2003-03-19 17:37:46.000000000 +0200
@@ -83,6 +83,10 @@
printf( "LUT8 " );
break;
+ case DSPF_ALUT44:
+ printf( "ALUT44 " );
+ break;
+
case DSPF_RGB16:
printf( "RGB16 " );
break;