📄 pnggccrd.c
字号:
{ s_start = 0; s_end = 6; s_inc = 2; } else#endif { s_start = 6; s_end = 0; s_inc = -2; } shift = s_start; for (i = 0; i < png_ptr->width; i++) { if (m & mask) { value = (*sp >> shift) & 0x3; *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff); *dp |= (png_byte)(value << shift); } if (shift == s_end) { shift = s_start; sp++; dp++; } else shift += s_inc; if (m == 1) m = 0x80; else m >>= 1; } break; } case 4: // png_ptr->row_info.pixel_depth { png_bytep sp; png_bytep dp; int s_start, s_end, s_inc; int m; int shift; png_uint_32 i; int value; sp = png_ptr->row_buf + 1; dp = row; m = 0x80;#if defined(PNG_READ_PACKSWAP_SUPPORTED) if (png_ptr->transformations & PNG_PACKSWAP) { s_start = 0; s_end = 4; s_inc = 4; } else#endif { s_start = 4; s_end = 0; s_inc = -4; } shift = s_start; for (i = 0; i < png_ptr->width; i++) { if (m & mask) { value = (*sp >> shift) & 0xf; *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff); *dp |= (png_byte)(value << shift); } if (shift == s_end) { shift = s_start; sp++; dp++; } else shift += s_inc; if (m == 1) m = 0x80; else m >>= 1; } break; } case 8: // png_ptr->row_info.pixel_depth { png_bytep srcptr; png_bytep dstptr; if (mmx_supported) { png_uint_32 len; int diff;#ifndef __PIC__ int unmask = ~mask;#else _unmask = ~mask; // global variable for -fPIC version#endif srcptr = png_ptr->row_buf + 1; dstptr = row; len = png_ptr->width &~7; // reduce to multiple of 8 diff = png_ptr->width & 7; // amount lost __asm__ (#ifdef __PIC__ "movd _unmask, %%mm7 \n\t" // load bit pattern#else// preload "movd unmask, %%mm7 \n\t" // (unmask is in ebx) "movd %%ebx, %%mm7 \n\t" // load bit pattern (unmask)#endif "psubb %%mm6, %%mm6 \n\t" // zero mm6 "punpcklbw %%mm7, %%mm7 \n\t" "punpcklwd %%mm7, %%mm7 \n\t" "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks "movq _mask8_0, %%mm0 \n\t" "pand %%mm7, %%mm0 \n\t" // nonzero if keep byte "pcmpeqb %%mm6, %%mm0 \n\t" // zeros->1s, v versa// preload "movl len, %%ecx \n\t" // load length of line// preload "movl srcptr, %%esi \n\t" // load source// preload "movl dstptr, %%edi \n\t" // load dest "cmpl $0, %%ecx \n\t" // len == 0 ? "je mainloop8end \n\t" "mainloop8: \n\t" "movq (%%esi), %%mm4 \n\t" // *srcptr "pand %%mm0, %%mm4 \n\t" "movq %%mm0, %%mm6 \n\t" "pandn (%%edi), %%mm6 \n\t" // *dstptr "por %%mm6, %%mm4 \n\t" "movq %%mm4, (%%edi) \n\t" "addl $8, %%esi \n\t" // inc by 8 bytes processed "addl $8, %%edi \n\t" "subl $8, %%ecx \n\t" // dec by 8 pixels processed "ja mainloop8 \n\t" "mainloop8end: \n\t"// preload "movl diff, %%ecx \n\t" // (diff is in eax) "movl %%eax, %%ecx \n\t" "cmpl $0, %%ecx \n\t" "jz end8 \n\t"// preload "movl mask, %%edx \n\t" "sall $24, %%edx \n\t" // make low byte, high byte "secondloop8: \n\t" "sall %%edx \n\t" // move high bit to CF "jnc skip8 \n\t" // if CF = 0 "movb (%%esi), %%al \n\t" "movb %%al, (%%edi) \n\t" "skip8: \n\t" "incl %%esi \n\t" "incl %%edi \n\t" "decl %%ecx \n\t" "jnz secondloop8 \n\t" "end8: \n\t" "EMMS \n\t" // DONE : // output regs (none) : "S" (srcptr), // esi // input regs "D" (dstptr), // edi "a" (diff), // eax#ifndef __PIC__ "b" (unmask), // ebx // Global Offset Table idx#endif "c" (len), // ecx "d" (mask) // edx : "%esi", "%edi", "%eax", // clobber list "%ecx", "%edx"#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ , "%mm0", "%mm4", "%mm6", "%mm7"#endif ); } else /* mmx _not supported - Use modified C routine */ { register png_uint_32 i; png_uint_32 initial_val = png_pass_start[png_ptr->pass]; // png.c: png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; register int stride = png_pass_inc[png_ptr->pass]; // png.c: png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; register int rep_bytes = png_pass_width[png_ptr->pass]; // png.c: png_pass_width[] = {8, 4, 4, 2, 2, 1, 1}; register png_uint_32 final_val = png_ptr->width; srcptr = png_ptr->row_buf + 1 + initial_val; dstptr = row + initial_val; for (i = initial_val; i < final_val; i += stride) { png_memcpy(dstptr, srcptr, rep_bytes); srcptr += stride; dstptr += stride; } } /* end of else */ break; } // end 8 bpp case 16: // png_ptr->row_info.pixel_depth { png_bytep srcptr; png_bytep dstptr; if (mmx_supported) { png_uint_32 len; int diff;#ifndef __PIC__ int unmask = ~mask;#else _unmask = ~mask; // global variable for -fPIC version#endif srcptr = png_ptr->row_buf + 1; dstptr = row; len = png_ptr->width &~7; // reduce to multiple of 8 diff = png_ptr->width & 7; // amount lost __asm__ (#ifdef __PIC__ "movd _unmask, %%mm7 \n\t" // load bit pattern#else// preload "movd unmask, %%mm7 \n\t" // (unmask is in ebx) "movd %%ebx, %%mm7 \n\t" // load bit pattern (unmask)#endif "psubb %%mm6, %%mm6 \n\t" // zero mm6 "punpcklbw %%mm7, %%mm7 \n\t" "punpcklwd %%mm7, %%mm7 \n\t" "punpckldq %%mm7, %%mm7 \n\t" // fill reg with 8 masks "movq _mask16_0, %%mm0 \n\t" "movq _mask16_1, %%mm1 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "pcmpeqb %%mm6, %%mm0 \n\t" "pcmpeqb %%mm6, %%mm1 \n\t"// preload "movl len, %%ecx \n\t" // load length of line// preload "movl srcptr, %%esi \n\t" // load source// preload "movl dstptr, %%edi \n\t" // load dest "cmpl $0, %%ecx \n\t" "jz mainloop16end \n\t" "mainloop16: \n\t" "movq (%%esi), %%mm4 \n\t" "pand %%mm0, %%mm4 \n\t" "movq %%mm0, %%mm6 \n\t" "movq (%%edi), %%mm7 \n\t" "pandn %%mm7, %%mm6 \n\t" "por %%mm6, %%mm4 \n\t" "movq %%mm4, (%%edi) \n\t" "movq 8(%%esi), %%mm5 \n\t" "pand %%mm1, %%mm5 \n\t" "movq %%mm1, %%mm7 \n\t" "movq 8(%%edi), %%mm6 \n\t" "pandn %%mm6, %%mm7 \n\t" "por %%mm7, %%mm5 \n\t" "movq %%mm5, 8(%%edi) \n\t" "addl $16, %%esi \n\t" // inc by 16 bytes processed "addl $16, %%edi \n\t" "subl $8, %%ecx \n\t" // dec by 8 pixels processed "ja mainloop16 \n\t" "mainloop16end: \n\t"// preload "movl diff, %%ecx \n\t" // (diff is in eax) "movl %%eax, %%ecx \n\t" "cmpl $0, %%ecx \n\t" "jz end16 \n\t"// preload "movl mask, %%edx \n\t" "sall $24, %%edx \n\t" // make low byte, high byte "secondloop16: \n\t" "sall %%edx \n\t" // move high bit to CF "jnc skip16 \n\t" // if CF = 0 "movw (%%esi), %%ax \n\t" "movw %%ax, (%%edi) \n\t" "skip16: \n\t" "addl $2, %%esi \n\t" "addl $2, %%edi \n\t" "decl %%ecx \n\t" "jnz secondloop16 \n\t" "end16: \n\t" "EMMS \n\t" // DONE : // output regs (none) : "S" (srcptr), // esi // input regs "D" (dstptr), // edi "a" (diff), // eax#ifndef __PIC__ "b" (unmask), // ebx // Global Offset Table idx#endif "c" (len), // ecx "d" (mask) // edx : "%esi", "%edi", "%eax", // clobber list "%ecx", "%edx"#if 0 /* MMX regs (%mm0, etc.) not supported by gcc 2.7.2.3 or egcs 1.1 */ , "%mm0", "%mm1", "%mm4", "%mm5", "%mm6", "%mm7"#endif ); } else /* mmx _not supported - Use modified C routine */ { register png_uint_32 i; png_uint_32 initial_val = 2 * png_pass_start[png_ptr->pass];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -