#include "ditherMMX.h" #include using namespace std; #ifndef INTEL // nothing void ditherBlock(unsigned char *lum, unsigned char *cr, unsigned char *cb, unsigned char *out, int cols, int rows, int screen_width) { printf("call to ditherBlock. this should never happen\n"); printf("check mmx detection routine.\n"); exit(0); } #else static long long MMX16_0 = 0L; static unsigned long MMX16_10w[] = {0x00100010, 0x00100010}; static unsigned long MMX16_80w[] = {0x00800080, 0x00800080}; static unsigned long MMX16_00FFw[] = {0x00ff00ff, 0x00ff00ff}; static unsigned short MMX16_Ublucoeff[] = {0x81, 0x81, 0x81, 0x81}; static unsigned short MMX16_Vredcoeff[] = {0x66, 0x66, 0x66, 0x66}; static unsigned short MMX16_Ugrncoeff[] = {0xffe8, 0xffe8, 0xffe8, 0xffe8}; static unsigned short MMX16_Vgrncoeff[] = {0xffcd, 0xffcd, 0xffcd, 0xffcd}; static unsigned short MMX16_Ycoeff[] = {0x4a, 0x4a, 0x4a, 0x4a}; static unsigned short MMX16_redmask[] = {0xf800, 0xf800, 0xf800, 0xf800}; static unsigned short MMX16_grnmask[] = {0x7e0, 0x7e0, 0x7e0, 0x7e0}; void dummy_dithermmx16() { cout << "MMX16_0"<register "movq (%2),%%mm6\n" // 0 0 0 0 L3 L2 L1 L0 (load lum2) //"movq (%2, %5), %%mm6\n" // L3 load lum2 "psraw $6, %%mm7\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm5, %%mm5\n" "packuswb %%mm7, %%mm7\n" "pand MMX16_00FFw, %%mm6\n" // L3 "punpcklbw %%mm3, %%mm3\n" // "psubw MMX16_10w, %%mm6\n" // L3 "punpcklbw %%mm5, %%mm5\n" "pmullw MMX16_Ycoeff, %%mm6\n" // lum3 "punpcklbw %%mm7, %%mm7\n" "psllw $3, %%mm5\n" // GREEN 2 "pand MMX16_redmask, %%mm7\n" "pand MMX16_redmask, %%mm3\n" "psrlw $11, %%mm7\n" // BLUE 2 "pand MMX16_grnmask, %%mm5\n" "por %%mm7, %%mm3\n" "movq (%2), %%mm7\n" // L4 load lum2 "movl 16%5,%2\n" // tmp0->register "por %%mm5, %%mm3\n" // "psrlw $8, %%mm7\n" // L4 "movq %%mm4, %%mm5\n" // "psubw MMX16_10w, %%mm7\n" // L4 "punpcklwd %%mm3, %%mm4\n" "pmullw MMX16_Ycoeff, %%mm7\n" // lum4 "punpckhwd %%mm3, %%mm5\n" "movq %%mm4, (%3)\n" // write row1 "movq %%mm5, 8(%3)\n" // write row1 "movq %%mm6, %%mm4\n" // Lum3 "paddw %%mm0, %%mm6\n" // Lum3 +blue "movq %%mm4, %%mm5\n" // Lum3 "paddw %%mm1, %%mm4\n" // Lum3 +red "paddw %%mm2, %%mm5\n" // Lum3 +green "psraw $6, %%mm4\n" "movq %%mm7, %%mm3\n" // Lum4 "psraw $6, %%mm5\n" "paddw %%mm0, %%mm7\n" // Lum4 +blue "psraw $6, %%mm6\n" // Lum3 +blue "movq %%mm3, %%mm0\n" // Lum4 "packuswb %%mm4, %%mm4\n" "paddw %%mm1, %%mm3\n" // Lum4 +red "packuswb %%mm5, %%mm5\n" "paddw %%mm2, %%mm0\n" // Lum4 +green "packuswb %%mm6, %%mm6\n" "punpcklbw %%mm4, %%mm4\n" "punpcklbw %%mm5, %%mm5\n" "punpcklbw %%mm6, %%mm6\n" "psllw $3, %%mm5\n" // GREEN 3 "pand MMX16_redmask, %%mm4\n" "psraw $6, %%mm3\n" // psr 6 "psraw $6, %%mm0\n" "pand MMX16_redmask, %%mm6\n" // BLUE "pand MMX16_grnmask, %%mm5\n" "psrlw $11, %%mm6\n" // BLUE 3 "por %%mm5, %%mm4\n" "psraw $6, %%mm7\n" "por %%mm6, %%mm4\n" "packuswb %%mm3, %%mm3\n" "packuswb %%mm0, %%mm0\n" "packuswb %%mm7, %%mm7\n" "punpcklbw %%mm3, %%mm3\n" "punpcklbw %%mm0, %%mm0\n" "punpcklbw %%mm7, %%mm7\n" "pand MMX16_redmask, %%mm3\n" "pand MMX16_redmask, %%mm7\n" // BLUE "psllw $3, %%mm0\n" // GREEN 4 "psrlw $11, %%mm7\n" "pand MMX16_grnmask, %%mm0\n" "por %%mm7, %%mm3\n" "por %%mm0, %%mm3\n" "movq %%mm4, %%mm5\n" "punpcklwd %%mm3, %%mm4\n" "punpckhwd %%mm3, %%mm5\n" "movq %%mm4, (%4)\n" "movq %%mm5, 8(%4)\n" "subl $8, 8%5\n" // x-=8 "addl $8, %5\n" // lum2+8 "addl $8, %2\n" "addl $4, %0\n" "addl $4, %1\n" "cmpl $0, 8%5\n" "leal 16(%3), %3\n" "leal 16(%4), %4\n" // row2+16 "jne 1b\n" "addl 20%5, %2\n" // lum += cols "movl %2,16%5\n" // store register in tmp0 "movl 20%5,%2\n" // cols->register "addl %2, %5\n" // lum2 += cols "addl 12%5, %3\n" // row1+= mod "addl 12%5, %4\n" // row2+= mod "movl %2, 8%5\n" // x=cols "movl 16%5,%2\n" // store tmp0 in register "cmpl 4%5, %2\n" "jl 1b\n" : :"r" (cr), "r"(cb),"r"(lum), "r"(row1),"r"(row2),"m"(buf[0]) ); __asm__ ( "emms\n" ); } #endif