27#include "libmythbase/mythconfig.h"
29#ifndef __cpp_size_t_suffix
36extern volatile uint32_t
resolx;
44static int zf_use_xmmx = 0;
45static int zf_use_mmx = 0;
48 static int s_firsttime = 1;
52 printf (
"Extended MMX detected. Using the fastest method !\n");
56 printf (
"MMX detected. Using fast method !\n");
59 printf (
"Too bad ! No MMX detected.\n");
68 static int firsttime = 1;
70 printf (
"No MMX support compiled in\n");
125static inline int ShiftRight(
int x,
int s) {
return (x<0) ? -((-x)>>s) : (x>>s); }
133void setPixelRGB (
unsigned int * buffer,
unsigned int x,
unsigned int y,
Color c);
135inline void getPixelRGB (
const unsigned int * buffer,
unsigned int x,
unsigned int y,
Color * c);
141 static int s_firstime = 1;
146 for (
int coefh = 0; coefh < 16; coefh++) {
148 for (
int coefv = 0; coefv < 16; coefv++) {
155 if (!(coefh || coefv))
158 int i1 = diffcoeffh * diffcoeffv;
159 int i2 = coefh * diffcoeffv;
160 int i3 = diffcoeffh * coefv;
161 int i4 = coefh * coefv;
171 i = (i1) | (i2 << 8) | (i3 << 16) | (i4 << 24);
188 static int s_wave = 0;
189 static int s_wavesp = 0;
192 yy = std::max(yy, 0);
196 *px = (x << 4) +
firedec[yy] + (s_wave / 10);
206 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));
381void c_zoom (
unsigned int *lexpix1,
unsigned int *lexpix2,
382 unsigned int lprevX,
unsigned int lprevY,
388 unsigned int ax = (lprevX - 1) <<
PERTEDEC;
389 unsigned int ay = (lprevY - 1) <<
PERTEDEC;
391 int bufsize = lprevX * lprevY * 2;
392 int bufwidth = lprevX;
394 lexpix1[0]=lexpix1[lprevX-1]=lexpix1[(lprevX*lprevY)-1]=lexpix1[(lprevX*lprevY)-lprevX]=0;
396 for (
int myPos = 0; myPos < bufsize; myPos += 2) {
401 int brutSmypos = lbrutS[myPos];
403 int myPos2 = myPos + 1;
406 brutSmypos = lbrutS[myPos2];
409 px = std::max(px, 0);
410 py = std::max(py, 0);
416 if ((py >= (
int)ay) || (px >= (
int)ax)) {
426 int c2 = (c1 & 0x0000ff00) >> 8;
427 int c3 = (c1 & 0x00ff0000) >> 16;
428 int c4 = (c1 & 0xff000000) >> 24;
431 couleur.r = (col1.r * c1) + (col2.r * c2) + (col3.r * c3) + (col4.r * c4);
436 couleur.v = (col1.v * c1) + (col2.v * c2) + (col3.v * c3) + (col4.v * c4);
441 couleur.b = (col1.b * c1) + (col2.b * c2) + (col3.b * c3) + (col4.b * c4);
454 [[maybe_unused]]
static unsigned char s_pertedec = 8;
455 static char s_firstTime = 1;
457 static constexpr int8_t INTERLACE_INCR { 16 };
460 static int s_interlaceStart = -2;
480 if (s_interlaceStart != -2)
485 static bool s_reverse =
false;
502 if (s_firstTime || zf) {
510#ifdef __cpp_size_t_suffix
511 brutS.resize(2Z * resx * resy);
512 brutD.resize(2Z * resx * resy);
513 brutT.resize(2Z * resx * resy);
515 brutS.resize(2_Z * resx * resy);
516 brutD.resize(2_Z * resx * resy);
517 brutT.resize(2_Z * resx * resy);
524 for (
unsigned int y = 0; y < resy; y++, yofs += resx) {
525 int xofs = yofs << 1;
528 for (
unsigned int x = 0; x < resx; x++) {
529 brutS[xofs++] = xperte;
530 brutS[xofs++] = yperte;
538 for (
uint16_t us = 0; us < 0xffff; us++) {
540 roundf(1024 * sinf ((
float) us * 360
542 * std::numbers::pi_v<float> / 180));
548 for (
int loopv =
prevY; loopv != 0;) {
549 static int s_decc = 0;
550 static int s_spdc = 0;
551 static int s_accel = 0;
555 s_decc += s_spdc / 10;
568 if (s_decc > 8 && s_spdc > 1)
571 if (s_decc < -8 && s_spdc < -1)
574 if (s_decc > 8 || s_decc < -8)
575 s_decc = s_decc * 8 / 9;
586 s_interlaceStart = 0;
589 if (s_interlaceStart==-1) {
594 for (
unsigned int x = 0; x < y; x += 2) {
595 int brutSmypos =
brutS[x];
608 s_interlaceStart = -2;
611 if (s_interlaceStart>=0) {
612 int maxEnd = (s_interlaceStart+INTERLACE_INCR);
614 auto y = (
unsigned int)s_interlaceStart;
615 for ( ; (y <
prevY) && (y < (
unsigned int)maxEnd); y++) {
616 unsigned int premul_y_prevX = y *
prevX * 2;
617 for (
unsigned int x = 0; x <
prevX; x++) {
623 brutT[premul_y_prevX] = px;
624 brutT[premul_y_prevX + 1] = py;
628 s_interlaceStart += INTERLACE_INCR;
629 if (y >=
prevY-1) s_interlaceStart = -1;
632 if (switchIncr != 0) {
637 if (switchMult != 1.0F) {
650 }
else if (zf_use_mmx) {
664 auto x = (
unsigned int) ((
int) (
resolx/2) + (
int) (t1 * cosf ((
float)
cycle / t3)));
665 auto y = (
unsigned int) ((
int) (
c_resoly/2) + (
int) (t2 * sinf ((
float)
cycle / t4)));
667 if ((x > 1) && (y > 1) && (x <
resolx - 2) && (y <
c_resoly - 2)) {
static std::array< int, 0x10000 > sintable
static bool hypercosEffect
void calculatePXandPY(int x, int y, int *px, int *py)
void getPixelRGB_(const unsigned int *buffer, unsigned int x, Color *c)
static constexpr int8_t PERTEMASK
void getPixelRGB(const unsigned int *buffer, unsigned int x, unsigned int y, Color *c)
static constexpr int8_t EFFECT_DISTORS_SL
static void select_zoom_filter(void)
void zoomFilterFastRGB(unsigned int *pix1, unsigned int *pix2, ZoomFilterData *zf, unsigned int resx, unsigned int resy, int switchIncr, float switchMult)
void pointFilter(unsigned int *pix1, Color c, float t1, float t2, float t3, float t4, unsigned int cycle)
static constexpr uint8_t BUFFPOINTNB
static void c_zoom(unsigned int *lexpix1, unsigned int *lexpix2, unsigned int lprevX, unsigned int lprevY, const sintvec &lbrutS, const sintvec &lbrutD)
void setPixelRGB_(unsigned int *buffer, unsigned int x, Color c)
static constexpr int8_t sqrtperte
void setPixelRGB(unsigned int *buffer, unsigned int x, unsigned int y, Color c)
unsigned int * freecoeffs
static constexpr int32_t BUFFPOINTMASK
GoomCoefficients precalCoef
modif d'optim by Jeko : precalcul des 4 coefs résultant des 2 pos
static std::vector< int > firedec
void generatePrecalCoef(void)
int buffratio
modif by jeko : fixedpoint : buffration = (16:16) (donc 0<=buffration<=2^16)
static constexpr int8_t EFFECT_DISTORS
static int ShiftRight(int x, int s)
static constexpr uint8_t PERTEDEC
volatile uint32_t c_resoly
#define CRYSTAL_BALL_MODE
#define ROUGE
position des composantes
Convenience inline random number generator functions.
int MythRandomTriangularInt(int x)
Generate a random signed int over a symmetric triangular distribution with a minimum of -x,...
int MythRandomInt(int min, int max)
generate a uniformly distributed random signed int in the closed interval [min, max].
int zoom_filter_mmx_supported()
void zoom_filter_mmx(int prevX, int prevY, const unsigned int *expix1, unsigned int *expix2, const sintvec &brutS, const sintvec &brutD, int buffratio, const GoomCoefficients &precalCoef)
void zoom_filter_xmmx(int prevX, int prevY, unsigned int *expix1, unsigned int *expix2, const sintvec &brutS, const sintvec &brutD, int buffratio, GoomCoefficients &precalCoef)
int zoom_filter_xmmx_supported()
std::vector< signed int > sintvec
std::array< std::array< int, 16 >, 16 > GoomCoefficients