Some small optimisations to speed up the color reduction algorithm... still a little bit slow for me ...
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@373 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
8695c31c1b
commit
de726cae2f
156
op_c.c
156
op_c.c
@ -370,29 +370,18 @@ void Cluster_Analyser(Cluster * c,Table_occurence * to)
|
|||||||
|
|
||||||
// On cherche les mins et les maxs de chaque composante sur la couverture
|
// On cherche les mins et les maxs de chaque composante sur la couverture
|
||||||
|
|
||||||
#ifdef OPTIMISATIONS_ASSEMBLEUR
|
|
||||||
|
|
||||||
rmin=(c->rmin << to->dec_r); rmax=(c->rmax << to->dec_r);
|
|
||||||
vmin=(c->vmin << to->dec_v); vmax=(c->vmax << to->dec_v);
|
|
||||||
bmin=(c->bmin << to->dec_b); bmax=(c->bmax << to->dec_b);
|
|
||||||
OPASM_Analyser_cluster(to->table,&rmin,&vmin,&bmin,&rmax,&vmax,&bmax,
|
|
||||||
to->dec_r,to->dec_v,to->dec_b,
|
|
||||||
(1 << to->dec_r),(1 << to->dec_v),(1 << to->dec_b),
|
|
||||||
&c->occurences);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int nbocc;
|
int nbocc;
|
||||||
|
|
||||||
rmin=c->rmax; rmax=c->rmin;
|
// On prédécale tout pour éviter de faire trop de bazar en se forçant à utiliser TO_Get, plus rapide
|
||||||
vmin=c->vmax; vmax=c->vmin;
|
rmin=c->rmax <<16; rmax=c->rmin << 16;
|
||||||
|
vmin=c->vmax << 8; vmax=c->vmin << 8;
|
||||||
bmin=c->bmax; bmax=c->bmin;
|
bmin=c->bmax; bmax=c->bmin;
|
||||||
c->occurences=0;
|
c->occurences=0;
|
||||||
for (r=c->rmin;r<=c->rmax;r++)
|
for (r=c->rmin<<16;r<=c->rmax<<16;r+=1<<16)
|
||||||
for (v=c->vmin;v<=c->vmax;v++)
|
for (v=c->vmin<<8;v<=c->vmax<<8;v+=1<<8)
|
||||||
for (b=c->bmin;b<=c->bmax;b++)
|
for (b=c->bmin;b<=c->bmax;b++)
|
||||||
{
|
{
|
||||||
nbocc=TO_Get(to,r,v,b);
|
nbocc=to->table[r + v + b]; // TO_Get
|
||||||
if (nbocc)
|
if (nbocc)
|
||||||
{
|
{
|
||||||
if (r<rmin) rmin=r;
|
if (r<rmin) rmin=r;
|
||||||
@ -405,10 +394,8 @@ void Cluster_Analyser(Cluster * c,Table_occurence * to)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
c->rmin=rmin>>16; c->rmax=rmax>>16;
|
||||||
|
c->vmin=vmin>>8; c->vmax=vmax>>8;
|
||||||
c->rmin=rmin; c->rmax=rmax;
|
|
||||||
c->vmin=vmin; c->vmax=vmax;
|
|
||||||
c->bmin=bmin; c->bmax=bmax;
|
c->bmin=bmin; c->bmax=bmax;
|
||||||
|
|
||||||
// On regarde la composante qui a la variation la plus grande
|
// On regarde la composante qui a la variation la plus grande
|
||||||
@ -456,18 +443,6 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int teinte,Table_occure
|
|||||||
cumul=0;
|
cumul=0;
|
||||||
if (teinte==0)
|
if (teinte==0)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef OPTIMISATIONS_ASSEMBLEUR
|
|
||||||
|
|
||||||
OPASM_Split_cluster_Rouge(to->table,
|
|
||||||
(c->rmin << to->dec_r),(c->vmin << to->dec_v),
|
|
||||||
(c->bmin << to->dec_b),(c->rmax << to->dec_r),
|
|
||||||
(c->vmax << to->dec_v),(c->bmax << to->dec_b),
|
|
||||||
(1 << to->dec_r),(1 << to->dec_v),
|
|
||||||
(1 << to->dec_b),limite,to->dec_r,&r);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
for (r=c->rmin;r<=c->rmax;r++)
|
for (r=c->rmin;r<=c->rmax;r++)
|
||||||
{
|
{
|
||||||
for (v=c->vmin;v<=c->vmax;v++)
|
for (v=c->vmin;v<=c->vmax;v++)
|
||||||
@ -485,8 +460,6 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int teinte,Table_occure
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (r==c->rmin)
|
if (r==c->rmin)
|
||||||
r++;
|
r++;
|
||||||
// R est la valeur de d‚but du 2nd cluster
|
// R est la valeur de d‚but du 2nd cluster
|
||||||
@ -508,17 +481,6 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int teinte,Table_occure
|
|||||||
if (teinte==1)
|
if (teinte==1)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef OPTIMISATIONS_ASSEMBLEUR
|
|
||||||
|
|
||||||
OPASM_Split_cluster_Vert(to->table,
|
|
||||||
(c->rmin << to->dec_r),(c->vmin << to->dec_v),
|
|
||||||
(c->bmin << to->dec_b),(c->rmax << to->dec_r),
|
|
||||||
(c->vmax << to->dec_v),(c->bmax << to->dec_b),
|
|
||||||
(1 << to->dec_r),(1 << to->dec_v),
|
|
||||||
(1 << to->dec_b),limite,to->dec_v,&v);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
for (v=c->vmin;v<=c->vmax;v++)
|
for (v=c->vmin;v<=c->vmax;v++)
|
||||||
{
|
{
|
||||||
for (r=c->rmin;r<=c->rmax;r++)
|
for (r=c->rmin;r<=c->rmax;r++)
|
||||||
@ -536,8 +498,6 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int teinte,Table_occure
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (v==c->vmin)
|
if (v==c->vmin)
|
||||||
v++;
|
v++;
|
||||||
// V est la valeur de d‚but du 2nd cluster
|
// V est la valeur de d‚but du 2nd cluster
|
||||||
@ -558,17 +518,6 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int teinte,Table_occure
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef OPTIMISATIONS_ASSEMBLEUR
|
|
||||||
|
|
||||||
OPASM_Split_cluster_Bleu(to->table,
|
|
||||||
(c->rmin << to->dec_r),(c->vmin << to->dec_v),
|
|
||||||
(c->bmin << to->dec_b),(c->rmax << to->dec_r),
|
|
||||||
(c->vmax << to->dec_v),(c->bmax << to->dec_b),
|
|
||||||
(1 << to->dec_r),(1 << to->dec_v),
|
|
||||||
(1 << to->dec_b),limite,to->dec_b,&b);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
for (b=c->bmin;b<=c->bmax;b++)
|
for (b=c->bmin;b<=c->bmax;b++)
|
||||||
{
|
{
|
||||||
for (v=c->vmin;v<=c->vmax;v++)
|
for (v=c->vmin;v<=c->vmax;v++)
|
||||||
@ -586,8 +535,6 @@ void Cluster_Split(Cluster * c,Cluster * c1,Cluster * c2,int teinte,Table_occure
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (b==c->bmin)
|
if (b==c->bmin)
|
||||||
b++;
|
b++;
|
||||||
// B est la valeur de d‚but du 2nd cluster
|
// B est la valeur de d‚but du 2nd cluster
|
||||||
@ -1030,91 +977,6 @@ Table_conversion * Optimiser_palette(Bitmap24B image,int taille,struct Composant
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef OPTIMISATIONS_ASSEMBLEUR
|
|
||||||
|
|
||||||
void Convert_bitmap_24B_to_256_Floyd_Steinberg(Bitmap256 dest,Bitmap24B source,int largeur,int hauteur,struct Composantes * palette,Table_conversion * tc)
|
|
||||||
// Cette fonction dégrade au fur et à mesure le bitmap source, donc soit on ne
|
|
||||||
// s'en ressert pas, soit on passe à la fonction une copie de travail du
|
|
||||||
// bitmap original.
|
|
||||||
{
|
|
||||||
Bitmap24B courant;
|
|
||||||
Bitmap256 d;
|
|
||||||
int y;
|
|
||||||
|
|
||||||
|
|
||||||
// On initialise les variables de parcours:
|
|
||||||
courant=source;
|
|
||||||
d =dest;
|
|
||||||
|
|
||||||
if ((largeur>0) && (hauteur>0))
|
|
||||||
{
|
|
||||||
if (hauteur>1)
|
|
||||||
{
|
|
||||||
// Traitement de la 1ère ligne à l'avant-dernière
|
|
||||||
|
|
||||||
if (largeur>1)
|
|
||||||
{
|
|
||||||
// Il y a plusieurs colonnes
|
|
||||||
for (y=0;y<hauteur-1;y++)
|
|
||||||
{
|
|
||||||
// Premier pixel de la ligne
|
|
||||||
OPASM_DitherFS_623(d,courant,largeur-2,palette,tc->table,
|
|
||||||
tc->red_r,tc->red_v,tc->red_b,
|
|
||||||
tc->nbb_v,tc->nbb_b);
|
|
||||||
courant++;
|
|
||||||
d++;
|
|
||||||
// Pixels interm‚diaires de la ligne
|
|
||||||
if (largeur>2)
|
|
||||||
{
|
|
||||||
OPASM_DitherFS_6123(d,courant,largeur-2,palette,tc->table,
|
|
||||||
tc->red_r,tc->red_v,tc->red_b,
|
|
||||||
tc->nbb_v,tc->nbb_b);
|
|
||||||
courant+=largeur-2;
|
|
||||||
d+=largeur-2;
|
|
||||||
}
|
|
||||||
// Dernier pixel de la ligne
|
|
||||||
OPASM_DitherFS_12(d,courant,largeur-2,palette,tc->table,
|
|
||||||
tc->red_r,tc->red_v,tc->red_b,
|
|
||||||
tc->nbb_v,tc->nbb_b);
|
|
||||||
courant++;
|
|
||||||
d++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OPASM_DitherFS_2(d,courant,hauteur-1,palette,tc->table,
|
|
||||||
tc->red_r,tc->red_v,tc->red_b,
|
|
||||||
tc->nbb_v,tc->nbb_b);
|
|
||||||
courant+=hauteur-1;
|
|
||||||
d+=hauteur-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Traitement de la derniŠre ligne
|
|
||||||
|
|
||||||
if (largeur>1)
|
|
||||||
{
|
|
||||||
// Il y a plusieurs colonnes
|
|
||||||
OPASM_DitherFS_6(d,courant,largeur-1,palette,tc->table,
|
|
||||||
tc->red_r,tc->red_v,tc->red_b,
|
|
||||||
tc->nbb_v,tc->nbb_b);
|
|
||||||
courant+=largeur-1;
|
|
||||||
d+=largeur-1;
|
|
||||||
}
|
|
||||||
// Le dernier pixel
|
|
||||||
OPASM_DitherFS(d,courant,tc->table,
|
|
||||||
tc->red_r,tc->red_v,tc->red_b,
|
|
||||||
tc->nbb_v,tc->nbb_b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int Valeur_modifiee(int valeur,int modif)
|
int Valeur_modifiee(int valeur,int modif)
|
||||||
{
|
{
|
||||||
valeur+=modif;
|
valeur+=modif;
|
||||||
@ -1225,8 +1087,6 @@ void Convert_bitmap_24B_to_256_Floyd_Steinberg(Bitmap256 Dest,Bitmap24B Source,i
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const byte precision_24b[]=
|
static const byte precision_24b[]=
|
||||||
|
|||||||
2
op_c.h
2
op_c.h
@ -158,7 +158,7 @@ void HSLtoRGB(byte h, byte s, byte l, byte* r, byte* g, byte* b);
|
|||||||
void TO_Init(Table_occurence * t);
|
void TO_Init(Table_occurence * t);
|
||||||
Table_occurence * TO_New(int nbb_r,int nbb_v,int nbb_b);
|
Table_occurence * TO_New(int nbb_r,int nbb_v,int nbb_b);
|
||||||
void TO_Delete(Table_occurence * t);
|
void TO_Delete(Table_occurence * t);
|
||||||
int TO_Get(Table_occurence * t,int r,int v,int b);
|
inline int TO_Get(Table_occurence * t,int r,int v,int b);
|
||||||
void TO_Set(Table_occurence * t,int r,int v,int b,int i);
|
void TO_Set(Table_occurence * t,int r,int v,int b,int i);
|
||||||
void TO_Inc(Table_occurence * t,int r,int v,int b);
|
void TO_Inc(Table_occurence * t,int r,int v,int b);
|
||||||
void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int taille);
|
void TO_Compter_occurences(Table_occurence * t,Bitmap24B image,int taille);
|
||||||
|
|||||||
@ -748,7 +748,6 @@ void Loupe_12_0(void)
|
|||||||
|
|
||||||
// On fait de notre mieux pour restaurer l'ancienne opération:
|
// On fait de notre mieux pour restaurer l'ancienne opération:
|
||||||
Demarrer_pile_operation(Operation_avant_interruption);
|
Demarrer_pile_operation(Operation_avant_interruption);
|
||||||
DEBUG("OP",0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////// OPERATION_RECTANGLE_?????
|
/////////////////////////////////////////////////// OPERATION_RECTANGLE_?????
|
||||||
|
|||||||
1
pages.c
1
pages.c
@ -714,6 +714,7 @@ int Initialiser_les_listes_de_backups_en_debut_de_programme(int Taille,int Large
|
|||||||
// On ne peut pas démarrer le programme avec ne serait-ce qu'une
|
// On ne peut pas démarrer le programme avec ne serait-ce qu'une
|
||||||
// page de la dimension souhaitée, donc on laisse tout tomber et on
|
// page de la dimension souhaitée, donc on laisse tout tomber et on
|
||||||
// le renvoie chier.
|
// le renvoie chier.
|
||||||
|
free(Page);
|
||||||
Retour=0;
|
Retour=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user