26#include "libmythbase/mythconfig.h"
41static int zf_use_xmmx = 0;
42static int zf_use_mmx = 0;
45 static int s_firsttime = 1;
49 printf (
"Extended MMX detected. Using the fastest method !\n");
53 printf (
"MMX detected. Using fast method !\n");
56 printf (
"Too bad ! No MMX detected.\n");
65 static int firsttime = 1;
67 printf (
"No MMX support compiled in\n");
122static inline int ShiftRight(
int x,
int s) {
return (x<0) ? -((-x)>>s) : (x>>s); }
138 static int s_firstime = 1;
143 for (
int coefh = 0; coefh < 16; coefh++) {
145 for (
int coefv = 0; coefv < 16; coefv++) {
152 if (!(coefh || coefv))
155 int i1 = diffcoeffh * diffcoeffv;
156 int i2 = coefh * diffcoeffv;
157 int i3 = diffcoeffh * coefv;
158 int i4 = coefh * coefv;
168 i = (i1) | (i2 << 8) | (i3 << 16) | (i4 << 24);
185 static int s_wave = 0;
186 static int s_wavesp = 0;
188 int yy = y + (
RAND () % 4) - (
RAND () % 4) + (s_wave / 10);
189 yy = std::max(yy, 0);
193 *px = (x << 4) +
firedec[yy] + (s_wave / 10);
197 s_wavesp += (
RAND () % 3) - (
RAND () % 3);
202 s_wave += (s_wavesp / 10) + (
RAND () % 3) - (
RAND () % 3);
204 s_wavesp = (s_wavesp * 9) / 10;
241 dist = (vx9 * vx9) + (vy9 * vy9);
279 fvitesse = std::max(fvitesse, -3024);
284 ppx = -(-(vx * fvitesse) >> 16);
288 ppx = ((vx * fvitesse) >> 16);
292 ppy = -(-(vy * fvitesse) >> 16);
294 ppy = ((vy * fvitesse) >> 16);
309 fprintf (
stderr,
"setPixel ERROR : hors du tableau... %i, %i\n", x, y);
314 buffer[(y *
resolx) + x] =
324 printf (
"setPixel ERROR : hors du tableau... %i\n", x);
339 printf (
"getPixel ERROR : hors du tableau... %i, %i\n", x, y);
345 unsigned int i = *(buffer + (x + y *
resolx));
346 c->
b = (i >> (
BLEU * 8)) & 0xff;
347 c->
v = (i >> (
VERT * 8)) & 0xff;
348 c->
r = (i >> (
ROUGE * 8)) & 0xff;
355 unsigned char *tmp8 =
nullptr;
359 printf (
"getPixel ERROR : hors du tableau... %i\n", x);
365 c->
b = *(
unsigned char *) (tmp8 = (
unsigned char *) (buffer + x));
366 c->
r = *(
unsigned char *) (++tmp8);
367 c->
v = *(
unsigned char *) (++tmp8);
368 c->
b = *(
unsigned char *) (++tmp8);
372 c->
b = *(tmp8 = (
unsigned char *) (buffer + x));
380void c_zoom (
unsigned int *lexpix1,
unsigned int *lexpix2,
381 unsigned int lprevX,
unsigned int lprevY,
382 const signed int *lbrutS,
const signed int *lbrutD)
387 unsigned int ax = (lprevX - 1) <<
PERTEDEC;
388 unsigned int ay = (lprevY - 1) <<
PERTEDEC;
390 int bufsize = lprevX * lprevY * 2;
391 int bufwidth = lprevX;
393 lexpix1[0]=lexpix1[lprevX-1]=lexpix1[(lprevX*lprevY)-1]=lexpix1[(lprevX*lprevY)-lprevX]=0;
395 for (
int myPos = 0; myPos < bufsize; myPos += 2) {
400 int brutSmypos = lbrutS[myPos];
402 int myPos2 = myPos + 1;
405 brutSmypos = lbrutS[myPos2];
408 px = std::max(px, 0);
409 py = std::max(py, 0);
415 if ((py >= (
int)ay) || (px >= (
int)ax)) {
425 int c2 = (c1 & 0x0000ff00) >> 8;
426 int c3 = (c1 & 0x00ff0000) >> 16;
427 int c4 = (c1 & 0xff000000) >> 24;
430 couleur.r = (col1.r * c1) + (col2.r * c2) + (col3.r * c3) + (col4.r * c4);
435 couleur.v = (col1.v * c1) + (col2.v * c2) + (col3.v * c3) + (col4.v * c4);
440 couleur.b = (col1.b * c1) + (col2.b * c2) + (col3.b * c3) + (col4.b * c4);
453 [[maybe_unused]]
static unsigned char s_pertedec = 8;
454 static char s_firstTime = 1;
456 static constexpr int8_t INTERLACE_INCR { 16 };
459 static int s_interlaceStart = -2;
487 if (s_interlaceStart != -2)
492 static bool s_reverse =
false;
509 if (s_firstTime || zf) {
517 freebrutS = (
signed int *) calloc ((resx * resy * 2) + 128,
sizeof(
signed int));
518 brutS = (
signed int *) ((1 + ((uintptr_t) (
freebrutS)) / 128) * 128);
520 freebrutD = (
signed int *) calloc ((resx * resy * 2) + 128,
sizeof(
signed int));
521 brutD = (
signed int *) ((1 + ((uintptr_t) (
freebrutD)) / 128) * 128);
523 freebrutT = (
signed int *) calloc ((resx * resy * 2) + 128,
sizeof(
signed int));
524 brutT = (
signed int *) ((1 + ((uintptr_t) (
freebrutT)) / 128) * 128);
531 for (
Uint y = 0; y < resy; y++, yofs += resx) {
532 int xofs = yofs << 1;
535 for (
Uint x = 0; x < resx; x++) {
536 brutS[xofs++] = xperte;
537 brutS[xofs++] = yperte;
545 for (
uint16_t us = 0; us < 0xffff; us++) {
547 roundf(1024 * sinf ((
float) us * 360
555 for (
int loopv =
prevY; loopv != 0;) {
556 static int s_decc = 0;
557 static int s_spdc = 0;
558 static int s_accel = 0;
562 s_decc += s_spdc / 10;
564 s_spdc += (
RAND () % 3) - (
RAND () % 3);
572 s_spdc = s_spdc - (
RAND () % 3) + (s_accel / 10);
574 s_spdc = s_spdc + (
RAND () % 3) + (s_accel / 10);
576 if (s_decc > 8 && s_spdc > 1)
577 s_spdc -= (
RAND () % 3) - 2;
579 if (s_decc < -8 && s_spdc < -1)
580 s_spdc += (
RAND () % 3) + 2;
582 if (s_decc > 8 || s_decc < -8)
583 s_decc = s_decc * 8 / 9;
586 s_accel += (
RAND () % 2) - (
RAND () % 2);
595 s_interlaceStart = 0;
598 if (s_interlaceStart==-1) {
603 for (
Uint x = 0; x < y; x += 2) {
604 int brutSmypos =
brutS[x];
622 s_interlaceStart = -2;
625 if (s_interlaceStart>=0) {
626 int maxEnd = (s_interlaceStart+INTERLACE_INCR);
637 brutT[premul_y_prevX] = px;
638 brutT[premul_y_prevX + 1] = py;
642 s_interlaceStart += INTERLACE_INCR;
643 if (y >=
prevY-1) s_interlaceStart = -1;
646 if (switchIncr != 0) {
651 if (switchMult != 1.0F) {
664 }
else if (zf_use_mmx) {
681 if ((x > 1) && (y > 1) && (x <
resolx - 2) && (y <
c_resoly - 2)) {
static std::array< int, 0x10000 > sintable
void getPixelRGB(const Uint *buffer, Uint x, Uint y, Color *c)
static bool hypercosEffect
void calculatePXandPY(int x, int y, int *px, int *py)
static constexpr int8_t PERTEMASK
static constexpr int8_t EFFECT_DISTORS_SL
static void select_zoom_filter(void)
static constexpr uint8_t BUFFPOINTNB
void c_zoom(unsigned int *expix1, unsigned int *expix2, unsigned int prevX, unsigned int prevY, const signed int *brutS, const signed int *brutD)
void getPixelRGB_(const Uint *buffer, Uint x, Color *c)
static constexpr int8_t sqrtperte
void zoomFilterFastRGB(Uint *pix1, Uint *pix2, ZoomFilterData *zf, Uint resx, Uint resy, int switchIncr, float switchMult)
unsigned int * freecoeffs
static constexpr int32_t BUFFPOINTMASK
GoomCoefficients precalCoef
modif d'optim by Jeko : precalcul des 4 coefs résultant des 2 pos
void generatePrecalCoef(void)
int buffratio
modif by jeko : fixedpoint : buffration = (16:16) (donc 0<=buffration<=2^16)
void setPixelRGB_(Uint *buffer, Uint x, Color c)
void setPixelRGB(Uint *buffer, Uint x, Uint y, Color c)
static constexpr int8_t EFFECT_DISTORS
static int ShiftRight(int x, int s)
static constexpr uint8_t PERTEDEC
volatile guint32 c_resoly
void pointFilter(Uint *pix1, Color c, float t1, float t2, float t3, float t4, Uint cycle)
#define CRYSTAL_BALL_MODE
#define ROUGE
position des composantes
void zoom_filter_mmx(int prevX, int prevY, const unsigned int *expix1, unsigned int *expix2, const int *brutS, const int *brutD, int buffratio, const GoomCoefficients &precalCoef)
int zoom_filter_mmx_supported()
void zoom_filter_xmmx(int prevX, int prevY, unsigned int *expix1, unsigned int *expix2, const int *brutS, const int *brutD, int buffratio, GoomCoefficients &precalCoef)
int zoom_filter_xmmx_supported()
std::array< std::array< int, 16 >, 16 > GoomCoefficients