# HG changeset patch # User Ritor1 # Date 1370164470 -21600 # Node ID de17e53c55e07e933a3a2673d57f5490cab486fa # Parent 908c0061558793bbaa7afb89a6e3a0d7caaad32b# Parent 354ec6263123a3f2ddd506ac604a6c534ce3dc93 Слияние diff -r 908c00615587 -r de17e53c55e0 mm7_2.cpp --- a/mm7_2.cpp Sun Jun 02 15:14:22 2013 +0600 +++ b/mm7_2.cpp Sun Jun 02 15:14:30 2013 +0600 @@ -2163,367 +2163,125 @@ } //----- (00451007) -------------------------------------------------------- -int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, +int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, //changing this to some library function might be a good idea unsigned short *pDst, int dstWidth, int dstHeight, int dstPitch, int a10, int a11) { int result; // eax@1 - int v14; // ecx@10 float v17; // ST3C_4@12 float v18; // ST38_4@12 unsigned int v19; // esi@12 int v21; // eax@18 unsigned int v22; // ecx@25 unsigned int v23; // eax@29 - int v50; // ecx@88 - float v53; // ST34_4@90 - float v54; // ST30_4@90 - unsigned int v55; // esi@90 - int v57; // eax@96 - unsigned int v58; // ecx@103 - unsigned int v59; // eax@107 - int v112; // ecx@216 - float v115; // ST34_4@218 - float v116; // ST30_4@218 - unsigned int v117; // esi@218 - signed int v118; // eax@220 - int v119; // eax@221 - int v120; // eax@223 - unsigned int v121; // ecx@231 - char v122; // al@235 - double v124; // [sp+Ch] [bp-7Ch]@12 - unsigned int v127; // [sp+Ch] [bp-7Ch]@90 - double v132; // [sp+Ch] [bp-7Ch]@218 - double v133; // [sp+14h] [bp-74h]@12 - unsigned int v136; // [sp+14h] [bp-74h]@90 - double v141; // [sp+14h] [bp-74h]@218 - double v142; // [sp+1Ch] [bp-6Ch]@12 - unsigned int v145; // [sp+1Ch] [bp-6Ch]@90 - double v150; // [sp+1Ch] [bp-6Ch]@218 - double v151; // [sp+24h] [bp-64h]@12 - unsigned int v154; // [sp+24h] [bp-64h]@90 - double v159; // [sp+24h] [bp-64h]@218 + unsigned int heightRatioPlusOne; // [sp+Ch] [bp-7Ch]@12 + unsigned int widthRatio; // [sp+Ch] [bp-7Ch]@218 + unsigned int heightRatio; // [sp+14h] [bp-74h]@12 + unsigned int widthRatioPlusOne; // [sp+14h] [bp-74h]@218 int v160; // [sp+3Ch] [bp-4Ch]@13 - int v161; // [sp+40h] [bp-48h]@15 - int v164; // [sp+44h] [bp-44h]@93 - int v169; // [sp+44h] [bp-44h]@219 - int v172; // [sp+48h] [bp-40h]@91 unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13 - int *v176; // [sp+50h] [bp-38h]@15 - int *v179; // [sp+50h] [bp-38h]@93 - char *v184; // [sp+50h] [bp-38h]@219 - unsigned __int16 *v187; // [sp+54h] [bp-34h]@91 unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7 - unsigned __int16 *v196; // [sp+5Ch] [bp-2Ch]@85 - unsigned __int16 *v201; // [sp+5Ch] [bp-2Ch]@213 signed int v231; // [sp+78h] [bp-10h]@7 - signed int v234; // [sp+78h] [bp-10h]@85 - signed int v239; // [sp+78h] [bp-10h]@213 __int64 v240; // [sp+7Ch] [bp-Ch]@12 - __int64 v243; // [sp+7Ch] [bp-Ch]@90 - unsigned int v248; // [sp+7Ch] [bp-Ch]@218 unsigned int v251; // [sp+80h] [bp-8h]@218 - unsigned int v252; // [sp+84h] [bp-4h]@12 - unsigned int v255; // [sp+84h] [bp-4h]@90 - unsigned int v260; // [sp+84h] [bp-4h]@218 - float a6s; // [sp+A0h] [bp+18h]@12 - float a6t; // [sp+A0h] [bp+18h]@12 - unsigned int a6b; // [sp+A0h] [bp+18h]@12 - float a6y; // [sp+A0h] [bp+18h]@90 - float a6z; // [sp+A0h] [bp+18h]@90 - unsigned int a6h; // [sp+A0h] [bp+18h]@90 - float a6bi; // [sp+A0h] [bp+18h]@218 - float a6bj; // [sp+A0h] [bp+18h]@218 - unsigned int a6r; // [sp+A0h] [bp+18h]@218 - int dstdiffmult; + unsigned int v252; // [sp+84h] [bp-4h]@218 + float a6s; // [sp+A0h] [bp+18h]@218 + float a6t; // [sp+A0h] [bp+18h]@218 + unsigned int a6b; // [sp+A0h] [bp+18h]@218 + int field_0_bits; + int field_20_bits; - int probablyBitDepth = this->field_20.field_C; - switch(probablyBitDepth) - { - case 8: dstdiffmult = dstPitch - dstWidth; + int field0value = this->field_0.field_C; + switch(field0value) + { + case 8: field_0_bits = 1; break; - case 16: dstdiffmult = 2 * (dstPitch - dstWidth); + case 16: field_0_bits = 2; break; - case 32: dstdiffmult = 4 * (dstPitch - dstWidth); + case 32: field_0_bits = 4; break; default: - return probablyBitDepth; - } - - - - result = this->field_0.field_C; - if ( result == 32 ) - { - result = (int)pDst; - v193 = pDst; - v231 = 0; - if ( dstHeight <= 0 ) - return result; - while ( 1 ) - { - v14 = 0; - if ( dstWidth > 0 ) - break; -LABEL_30: - v193 = (unsigned __int16 *)((char *)v193 + dstdiffmult); - ++v231; - result = v231; - if ( v231 >= dstHeight ) - return result; - } - while ( 1 ) - { - a6s = (double)v14 / (double)dstWidth * (double)srcWidth; - v151 = bankersRounding(a6s);//a6s + 6.7553994e15; - a6t = (double)(v14 + 1) / (double)dstWidth * (double)srcWidth; - v142 = bankersRounding(a6t);//a6t + 6.7553994e15; + return field0value; + } + int field20value = this->field_20.field_C; + switch(field20value) + { + case 8: field_20_bits = 1; + break; + case 16: field_20_bits = 2; + break; + case 32: field_20_bits = 4; + break; + default: + return field20value; + } + + result = (int)pDst; + v193 = pDst; + v231 = 0; + if ( dstHeight <= 0 ) + return result; + do + { + for (int counter = 0; counter < dstWidth; counter++) + { + a6s = (double)counter / (double)dstWidth * (double)srcWidth; + widthRatio = bankersRounding(a6s); + a6t = (double)(counter + 1) / (double)dstWidth * (double)srcWidth; + widthRatioPlusOne = bankersRounding(a6t); v17 = (double)v231 / (double)dstHeight * (double)srcHeight; - v133 = bankersRounding(v17);//v17 + 6.7553994e15; + heightRatio = bankersRounding(v17); v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight; - v124 = bankersRounding(v18);//v18 + 6.7553994e15; - v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151)); + heightRatioPlusOne = bankersRounding(v18); + v251 = 0; + v19 = (heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio); v252 = 0; a6b = 0; v240 = 0i64; - if ( SLODWORD(v133) < SLODWORD(v124) ) - break; -LABEL_25: - v22 = (unsigned int)v240 / ((LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151))); + + v175 = (unsigned short*)((char *)pSrc + field_0_bits * (widthRatio + srcPitch * heightRatio)); + for (int heightDiff = 0; heightDiff < heightRatioPlusOne - heightRatio; heightDiff++) + { + int ratioDiff = widthRatioPlusOne - widthRatio; + for(int i = 0; i < ratioDiff; i++) + { + if(field0value == 32) + v21 = _450FB1((int)v175[i]); + else if(field0value == 16) + v21 = _450FB1((_WORD)v175[i]); + else + v21 = _450FB1((unsigned __int8)v175[i]); + v240 += ((unsigned int)v21 >> 24); + a6b += BYTE2(v21); + v252 += BYTE1(v21); + v251 += (unsigned __int8)v21; + } + if(field0value == 32) + v175 += 2 * srcPitch; + else if(field0value == 16) + v175 += srcPitch; + else + v175 = (unsigned short*)((char *)v175 + 2 * srcPitch); + } + v22 = (unsigned int)v240 / ((heightRatioPlusOne - heightRatio) * (widthRatioPlusOne - widthRatio)); if ( v19 ) { a6b /= v19; v252 /= v19; - HIDWORD(v240) /= v19; + v251 /= v19; } if ( v22 != 255 ) v22 &= 0x7FFFFFFFu; - v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8)); + v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8)); *(_DWORD *)v193 = v23; - switch(probablyBitDepth) - { - case 8: v193 = (unsigned __int16 *)((char *)v193 + 1); - break; - case 16: ++v193; - break; - case 32: v193 += 2; - break; - default: - assert(false); - return result; - } - ++v14; - if ( v14 >= dstWidth ) - goto LABEL_30; - } - v160 = LODWORD(v124) - LODWORD(v133); - v175 = &pSrc[2 * (LODWORD(v151) + srcPitch * LODWORD(v133))]; - while ( SLODWORD(v151) >= SLODWORD(v142) ) - { -LABEL_24: - v175 += 2 * srcPitch; - --v160; - if ( !v160 ) - goto LABEL_25; - } - v176 = (int *)v175; - v161 = LODWORD(v142) - LODWORD(v151); - while ( 1 ) - { - v21 = _450FB1(*v176); - break; -LABEL_23: - ++v176; - --v161; - if ( !v161 ) - goto LABEL_24; - } - LODWORD(v240) = ((unsigned int)v21 >> 24) + v240; - a6b += BYTE2(v21); - v252 += BYTE1(v21); - HIDWORD(v240) += (unsigned __int8)v21; - goto LABEL_23; - } - - else if ( result == 16 ) - { - result = (int)pDst; - v196 = pDst; - v234 = 0; - if ( dstHeight <= 0 ) - return result; - while ( 1 ) - { - v50 = 0; - if ( dstWidth > 0 ) - break; - LABEL_108: - v196 = (unsigned __int16 *)((char *)v196 + dstdiffmult); - ++v234; - result = v234; - if ( v234 >= dstHeight ) - return result; - } - while ( 1 ) - { - a6y = (double)v50 / (double)dstWidth * (double)srcWidth; - v127 = ceilf(a6y - 0.5f);//a6y + 6.7553994e15; - a6z = (double)(v50 + 1) / (double)dstWidth * (double)srcWidth; - v136 = ceilf(a6z - 0.5f);//a6z + 6.7553994e15; - v53 = (double)v234 / (double)dstHeight * (double)srcHeight; - v145 = ceilf(v53 - 0.5f);//v53 + 6.7553994e15; - v54 = (double)(v234 + 1) / (double)dstHeight * (double)srcHeight; - v154 = ceilf(v54 - 0.5f);//v54 + 6.7553994e15; - v55 = (v154 - v145) * (v136 - v127); - v255 = 0; - a6h = 0; - v243 = 0i64; - if ( v145 < v154 ) - break; - LABEL_103: - v58 = (unsigned int)v243 / ((v154 - v145) * (v136 - v127)); - if ( v55 ) - { - a6h /= v55; - v255 /= v55; - HIDWORD(v243) /= v55; - } - if ( v58 != 255 ) - v58 &= 0x7FFFFFFFu; - v59 = _450F55(HIDWORD(v243) | ((v255 | ((a6h | (v58 << 8)) << 8)) << 8)); - *(_DWORD *)v196 = v59; - switch(probablyBitDepth) - { - case 8: v196 = (unsigned __int16 *)((char *)v196 + 1); - break; - case 16: ++v196; - break; - case 32: v196 += 2; - break; - default: - assert(false); - return result; - } - ++v50; - if ( v50 >= dstWidth ) - goto LABEL_108; - } - v172 = v154 - v145; - v187 = &pSrc[v127 + srcPitch * v145]; - while ( v127 >= v136 ) - { - LABEL_102: - v187 += srcPitch; - --v172; - if ( !v172 ) - goto LABEL_103; - } - v179 = (int *)v187; - v164 = LODWORD(v136) - LODWORD(v127); - while ( 1 ) - { - v57 = _450FB1(*(_WORD *)v179); - break; - LABEL_101: - v179 = (int *)((char *)v179 + 2); - --v164; - if ( !v164 ) - goto LABEL_102; - } - LODWORD(v243) = ((unsigned int)v57 >> 24) + v243; - a6h += BYTE2(v57); - v255 += BYTE1(v57); - HIDWORD(v243) += (unsigned __int8)v57; - goto LABEL_101; - } - - else if ( result == 8 ) - { - result = (int)pDst; - v201 = pDst; - v239 = 0; - if ( dstHeight <= 0 ) - return result; - while ( 1 ) - { - v112 = 0; - if ( dstWidth <= 0 ) - goto LABEL_236; - do - { - a6bi = (double)v112 / (double)dstWidth * (double)srcWidth; - v132 = a6bi + 6.7553994e15; - a6bj = (double)(v112 + 1) / (double)dstWidth * (double)srcWidth; - v141 = a6bj + 6.7553994e15; - v115 = (double)v239 / (double)dstHeight * (double)srcHeight; - v150 = v115 + 6.7553994e15; - v116 = (double)(v239 + 1) / (double)dstHeight * (double)srcHeight; - v159 = v116 + 6.7553994e15; - v251 = 0; - v117 = (LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132)); - v260 = 0; - a6r = 0; - v248 = 0; - if ( SLODWORD(v150) >= SLODWORD(v159) ) - goto LABEL_231; - v169 = LODWORD(v159) - LODWORD(v150); - v184 = (char *)pSrc + srcPitch * LODWORD(v150); - do - { - v118 = LODWORD(v132); - while ( v118 < SLODWORD(v141) ) - { - v119 = (unsigned __int8)v184[v118]; - v120 = _450FB1(v119); - v248 += (unsigned int)v120 >> 24; - a6r += BYTE2(v120); - v260 += BYTE1(v120); - v251 += (unsigned __int8)v120; - ++v118; - } - v184 += srcPitch; - --v169; - } - while ( v169 ); -LABEL_231: - v121 = v248 / ((LODWORD(v159) - LODWORD(v150)) * (LODWORD(v141) - LODWORD(v132))); - if ( v117 ) - { - a6r /= v117; - v260 /= v117; - v251 /= v117; - } - if ( v121 != 255 ) - v121 &= 0x7FFFFFFFu; - v122 = _450F55(v251 | ((v260 | ((a6r | (v121 << 8)) << 8)) << 8)); - *v201 = v122; - switch(probablyBitDepth) - { - case 8: v201 = (unsigned __int16 *)((char *)v201 + 1); - break; - case 16: ++v201; - break; - case 32: v201 += 2; - break; - default: - assert(false); - return result; - } - ++v112; - } - while ( v112 < dstWidth ); -LABEL_236: - v201 = (unsigned __int16 *)((char *)v201 + dstdiffmult); - ++v239; - result = v239; - if ( v239 >= dstHeight ) - return result; - } - } - else //( result != 8 && result != 16 && result != 32 ) - { - return result; - } + v193 = (unsigned __int16 *)((char *)v193 + field_20_bits); + } + v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth)); + ++v231; + result = v231; + } + while(v231 < dstHeight); + return result; } //----- (0044E1EC) --------------------------------------------------------