diff mm7_2.cpp @ 1129:9362028fccd1

sub_451007_scale_image_bicubic cleanup - extracting common bodies from conditions
author Grumpy7
date Fri, 31 May 2013 06:36:34 +0200
parents cf37177c0786
children d98415be04ca
line wrap: on
line diff
--- a/mm7_2.cpp	Fri May 31 05:44:34 2013 +0200
+++ b/mm7_2.cpp	Fri May 31 06:36:34 2013 +0200
@@ -2175,20 +2175,6 @@
   int v21; // eax@18
   unsigned int v22; // ecx@25
   unsigned int v23; // eax@29
-  int v26; // ecx@35
-  float v29; // ST34_4@37
-  float v30; // ST30_4@37
-  unsigned int v31; // esi@37
-  int v33; // eax@43
-  unsigned int v34; // ecx@50
-  unsigned __int16 v35; // ax@54
-  int v38; // ecx@60
-  float v41; // ST34_4@62
-  float v42; // ST30_4@62
-  unsigned int v43; // esi@62
-  int v45; // eax@68
-  unsigned int v46; // ecx@75
-  char v47; // al@79
   int v50; // ecx@88
   float v53; // ST34_4@90
   float v54; // ST30_4@90
@@ -2196,21 +2182,6 @@
   int v57; // eax@96
   unsigned int v58; // ecx@103
   unsigned int v59; // eax@107
-  int v62; // ecx@113
-  float v65; // ST34_4@115
-  float v66; // ST30_4@115
-  unsigned int v67; // esi@115
-  int v68; // eax@119
-  int v69; // eax@121
-  unsigned int v70; // ecx@128
-  unsigned __int16 v71; // ax@132
-  int v74; // ecx@138
-  float v77; // ST34_4@140
-  float v78; // ST30_4@140
-  unsigned int v79; // esi@140
-  int v81; // eax@146
-  unsigned int v82; // ecx@153
-  char v83; // al@157
   int v112; // ecx@216
   float v115; // ST34_4@218
   float v116; // ST30_4@218
@@ -2221,624 +2192,253 @@
   unsigned int v121; // ecx@231
   char v122; // al@235
   double v124; // [sp+Ch] [bp-7Ch]@12
-  double v125; // [sp+Ch] [bp-7Ch]@37
-  double v126; // [sp+Ch] [bp-7Ch]@62
-  double v127; // [sp+Ch] [bp-7Ch]@90
-  uint _v128;
-  double v129; // [sp+Ch] [bp-7Ch]@140
+  unsigned int v127; // [sp+Ch] [bp-7Ch]@90
   double v132; // [sp+Ch] [bp-7Ch]@218
   double v133; // [sp+14h] [bp-74h]@12
-  double v134; // [sp+14h] [bp-74h]@37
-  double v135; // [sp+14h] [bp-74h]@62
-  double v136; // [sp+14h] [bp-74h]@90
-  uint _v137;
-  double v138; // [sp+14h] [bp-74h]@140
+  unsigned int v136; // [sp+14h] [bp-74h]@90
   double v141; // [sp+14h] [bp-74h]@218
   double v142; // [sp+1Ch] [bp-6Ch]@12
-  double v143; // [sp+1Ch] [bp-6Ch]@37
-  double v144; // [sp+1Ch] [bp-6Ch]@62
-  double v145; // [sp+1Ch] [bp-6Ch]@90
-  uint _v146;
-  double v147; // [sp+1Ch] [bp-6Ch]@140
+  unsigned int v145; // [sp+1Ch] [bp-6Ch]@90
   double v150; // [sp+1Ch] [bp-6Ch]@218
   double v151; // [sp+24h] [bp-64h]@12
-  double v152; // [sp+24h] [bp-64h]@37
-  double v153; // [sp+24h] [bp-64h]@62
-  double v154; // [sp+24h] [bp-64h]@90
-  uint _v155;
-  double v156; // [sp+24h] [bp-64h]@140
+  unsigned int v154; // [sp+24h] [bp-64h]@90
   double v159; // [sp+24h] [bp-64h]@218
   int v160; // [sp+3Ch] [bp-4Ch]@13
   int v161; // [sp+40h] [bp-48h]@15
-  int v162; // [sp+44h] [bp-44h]@40
-  int v163; // [sp+44h] [bp-44h]@65
   int v164; // [sp+44h] [bp-44h]@93
-  int v165; // [sp+44h] [bp-44h]@118
-  int v166; // [sp+44h] [bp-44h]@143
   int v169; // [sp+44h] [bp-44h]@219
-  int v170; // [sp+48h] [bp-40h]@38
-  int v171; // [sp+48h] [bp-40h]@63
   int v172; // [sp+48h] [bp-40h]@91
-  int v173; // [sp+48h] [bp-40h]@116
-  int v174; // [sp+48h] [bp-40h]@141
   unsigned __int16 *v175; // [sp+4Ch] [bp-3Ch]@13
   int *v176; // [sp+50h] [bp-38h]@15
-  int *v177; // [sp+50h] [bp-38h]@40
-  int *v178; // [sp+50h] [bp-38h]@65
   int *v179; // [sp+50h] [bp-38h]@93
-  int *v180; // [sp+50h] [bp-38h]@118
-  int *v181; // [sp+50h] [bp-38h]@143
   char *v184; // [sp+50h] [bp-38h]@219
-  unsigned __int16 *v185; // [sp+54h] [bp-34h]@38
-  unsigned __int16 *v186; // [sp+54h] [bp-34h]@63
   unsigned __int16 *v187; // [sp+54h] [bp-34h]@91
-  unsigned __int16 *v188; // [sp+54h] [bp-34h]@116
-  unsigned __int16 *v189; // [sp+54h] [bp-34h]@141
   unsigned __int16 *v193; // [sp+5Ch] [bp-2Ch]@7
-  unsigned __int16 *v194; // [sp+5Ch] [bp-2Ch]@32
-  unsigned __int16 *v195; // [sp+5Ch] [bp-2Ch]@57
   unsigned __int16 *v196; // [sp+5Ch] [bp-2Ch]@85
-  unsigned __int16 *v197; // [sp+5Ch] [bp-2Ch]@110
-  unsigned __int16 *v198; // [sp+5Ch] [bp-2Ch]@135
   unsigned __int16 *v201; // [sp+5Ch] [bp-2Ch]@213
   signed int v231; // [sp+78h] [bp-10h]@7
-  signed int v232; // [sp+78h] [bp-10h]@32
-  signed int v233; // [sp+78h] [bp-10h]@57
   signed int v234; // [sp+78h] [bp-10h]@85
-  signed int v235; // [sp+78h] [bp-10h]@110
-  signed int v236; // [sp+78h] [bp-10h]@135
   signed int v239; // [sp+78h] [bp-10h]@213
   __int64 v240; // [sp+7Ch] [bp-Ch]@12
-  __int64 v241; // [sp+7Ch] [bp-Ch]@37
-  __int64 v242; // [sp+7Ch] [bp-Ch]@62
   __int64 v243; // [sp+7Ch] [bp-Ch]@90
-  __int64 v244; // [sp+7Ch] [bp-Ch]@115
-  __int64 v245; // [sp+7Ch] [bp-Ch]@140
   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 v253; // [sp+84h] [bp-4h]@37
-  unsigned int v254; // [sp+84h] [bp-4h]@62
   unsigned int v255; // [sp+84h] [bp-4h]@90
-  unsigned int v256; // [sp+84h] [bp-4h]@115
-  unsigned int v257; // [sp+84h] [bp-4h]@140
   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 a6u; // [sp+A0h] [bp+18h]@37
-  float a6v; // [sp+A0h] [bp+18h]@37
-  unsigned int a6d; // [sp+A0h] [bp+18h]@37
-  float a6w; // [sp+A0h] [bp+18h]@62
-  float a6x; // [sp+A0h] [bp+18h]@62
-  unsigned int a6f; // [sp+A0h] [bp+18h]@62
   float a6y; // [sp+A0h] [bp+18h]@90
   float a6z; // [sp+A0h] [bp+18h]@90
   unsigned int a6h; // [sp+A0h] [bp+18h]@90
-  float a6ba; // [sp+A0h] [bp+18h]@115
-  float a6bb; // [sp+A0h] [bp+18h]@115
-  unsigned int a6j; // [sp+A0h] [bp+18h]@115
-  float a6bc; // [sp+A0h] [bp+18h]@140
-  float a6bd; // [sp+A0h] [bp+18h]@140
-  unsigned int a6l; // [sp+A0h] [bp+18h]@140
   float a6bi; // [sp+A0h] [bp+18h]@218
   float a6bj; // [sp+A0h] [bp+18h]@218
   unsigned int a6r; // [sp+A0h] [bp+18h]@218
-  int a9a; // [sp+ACh] [bp+24h]@8
-  int a9b; // [sp+ACh] [bp+24h]@33
-  int a9c; // [sp+ACh] [bp+24h]@86
-  int a9d; // [sp+ACh] [bp+24h]@111
-  int vxx;
+  int dstdiffmult;
+
+
+  int probablyBitDepth = this->field_20.field_C;
+  switch(probablyBitDepth)
+  {
+  case 8: dstdiffmult = dstPitch - dstWidth;
+    break;
+  case 16: dstdiffmult = 2 * (dstPitch - dstWidth);
+    break;
+  case 32: dstdiffmult = 4 * (dstPitch - dstWidth);
+    break;
+  default:
+    return probablyBitDepth;
+  }
+
+
 
   result = this->field_0.field_C;
-  if ( result != 8 )
-  {
-    if ( result != 16 )
-    {
-      if ( result != 32 )
-        return result;
-      result = this->field_20.field_C;
-      if ( result != 8 )
-      {
-        if ( result != 16 )
-        {
-          if ( result != 32)
-            return result;
-          result = (int)pDst;
-          v193 = pDst;
-          v231 = 0;
-          if ( dstHeight <= 0 )
-            return result;
-          a9a = 4 * (dstPitch - dstWidth);
-          while ( 1 )
-          {
-            v14 = 0;
-            if ( dstWidth > 0 )
-              break;
-LABEL_30:
-            v193 = (unsigned __int16 *)((char *)v193 + a9a);
-            ++v231;
-            result = v231;
-            if ( v231 >= dstHeight )
-              return result;
-          }
-          while ( 1 )
-          {
-            a6s = (double)v14 / (double)dstWidth * (double)srcWidth;
-            v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
-            a6t = (double)(v14 + 1) / (double)dstWidth * (double)srcWidth;
-            v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
-            v17 = (double)v231 / (double)dstHeight * (double)srcHeight;
-            v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
-            v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight;
-            v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
-            v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
-            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)));
-            if ( v19 )
-            {
-              a6b /= v19;
-              v252 /= v19;
-              HIDWORD(v240) /= v19;
-            }
-            if ( v22 != 255 )
-              v22 &= 0x7FFFFFFFu;
-            v23 = _450F55(HIDWORD(v240) | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
-            *(_DWORD *)v193 = v23;
-            v193 += 2;
-            ++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;
-//LABEL_22:
-          a6b += BYTE2(v21);
-          v252 += BYTE1(v21);
-          HIDWORD(v240) += (unsigned __int8)v21;
-          goto LABEL_23;
-        }
-        result = (int)pDst;
-        v194 = pDst;
-        v232 = 0;
-        if ( dstHeight <= 0 )
-          return result;
-        a9b = 2 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v26 = 0;
-          if ( dstWidth > 0 )
-            break;
-LABEL_55:
-          v194 = (unsigned __int16 *)((char *)v194 + a9b);
-          ++v232;
-          result = v232;
-          if ( v232 >= dstHeight )
-            return result;
-        }
-        while ( 1 )
-        {
-          a6u = (double)v26 / (double)dstWidth * (double)srcWidth;
-          v125 = a6u + 6.7553994e15;
-          a6v = (double)(v26 + 1) / (double)dstWidth * (double)srcWidth;
-          v134 = a6v + 6.7553994e15;
-          v29 = (double)v232 / (double)dstHeight * (double)srcHeight;
-          v143 = v29 + 6.7553994e15;
-          v30 = (double)(v232 + 1) / (double)dstHeight * (double)srcHeight;
-          v152 = v30 + 6.7553994e15;
-          v31 = (LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125));
-          v253 = 0;
-          a6d = 0;
-          v241 = 0i64;
-          if ( SLODWORD(v143) < SLODWORD(v152) )
-            break;
-LABEL_50:
-          v34 = (unsigned int)v241 / ((LODWORD(v152) - LODWORD(v143)) * (LODWORD(v134) - LODWORD(v125)));
-          if ( v31 )
-          {
-            a6d /= v31;
-            v253 /= v31;
-            HIDWORD(v241) /= v31;
-          }
-          if ( v34 != 255 )
-            v34 &= 0x7FFFFFFFu;
-          v35 = _450F55(HIDWORD(v241) | ((v253 | ((a6d | (v34 << 8)) << 8)) << 8));
-          *v194 = v35;
-          ++v194;
-          ++v26;
-          if ( v26 >= dstWidth )
-            goto LABEL_55;
-        }
-        v170 = LODWORD(v152) - LODWORD(v143);
-        v185 = &pSrc[2 * (LODWORD(v125) + srcPitch * LODWORD(v143))];
-        while ( SLODWORD(v125) >= SLODWORD(v134) )
-        {
-LABEL_49:
-          v185 += 2 * srcPitch;
-          --v170;
-          if ( !v170 )
-            goto LABEL_50;
-        }
-        v177 = (int *)v185;
-        v162 = LODWORD(v134) - LODWORD(v125);
-        while ( 1 )
-        {
-          v33 = _450FB1(*v177);
-            break;
-LABEL_48:
-          ++v177;
-          --v162;
-          if ( !v162 )
-            goto LABEL_49;
-        }
-        LODWORD(v241) = ((unsigned int)v33 >> 24) + v241;
-        a6d += BYTE2(v33);
-        v253 += BYTE1(v33);
-        HIDWORD(v241) += (unsigned __int8)v33;
-        goto LABEL_48;
-      }
-      result = (int)pDst;
-      v195 = pDst;
-      v233 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      while ( 1 )
-      {
-        v38 = 0;
-        if ( dstWidth > 0 )
-          break;
-LABEL_80:
-        v195 = (unsigned __int16 *)((char *)v195 + dstPitch - dstWidth);
-        ++v233;
-        result = v233;
-        if ( v233 >= dstHeight )
-          return result;
-      }
-      while ( 1 )
-      {
-        a6w = (double)v38 / (double)dstWidth * (double)srcWidth;
-        v126 = a6w + 6.7553994e15;
-        a6x = (double)(v38 + 1) / (double)dstWidth * (double)srcWidth;
-        v135 = a6x + 6.7553994e15;
-        v41 = (double)v233 / (double)dstHeight * (double)srcHeight;
-        v144 = v41 + 6.7553994e15;
-        v42 = (double)(v233 + 1) / (double)dstHeight * (double)srcHeight;
-        v153 = v42 + 6.7553994e15;
-        v43 = (LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126));
-        v254 = 0;
-        a6f = 0;
-        v242 = 0i64;
-        if ( SLODWORD(v144) < SLODWORD(v153) )
-          break;
-LABEL_75:
-        v46 = (unsigned int)v242 / ((LODWORD(v153) - LODWORD(v144)) * (LODWORD(v135) - LODWORD(v126)));
-        if ( v43 )
-        {
-          a6f /= v43;
-          v254 /= v43;
-          HIDWORD(v242) /= v43;
-        }
-        if ( v46 != 255 )
-          v46 &= 0x7FFFFFFFu;
-        v47 = _450F55(HIDWORD(v242) | ((v254 | ((a6f | (v46 << 8)) << 8)) << 8));
-        *v195 = v47;
-        v195 = (unsigned __int16 *)((char *)v195 + 1);
-        ++v38;
-        if ( v38 >= dstWidth )
-          goto LABEL_80;
-      }
-      v171 = LODWORD(v153) - LODWORD(v144);
-      v186 = &pSrc[2 * (LODWORD(v126) + srcPitch * LODWORD(v144))];
-      while ( SLODWORD(v126) >= SLODWORD(v135) )
-      {
-LABEL_74:
-        v186 += 2 * srcPitch;
-        --v171;
-        if ( !v171 )
-          goto LABEL_75;
-      }
-      v178 = (int *)v186;
-      v163 = LODWORD(v135) - LODWORD(v126);
-      while ( 1 )
-      {
-        v45 = _450FB1(*v178);
-          break;
-LABEL_73:
-        ++v178;
-        --v163;
-        if ( !v163 )
-          goto LABEL_74;
-      }
-      LODWORD(v242) = ((unsigned int)v45 >> 24) + v242;
-      a6f += BYTE2(v45);
-      v254 += BYTE1(v45);
-      HIDWORD(v242) += (unsigned __int8)v45;
-      goto LABEL_73;
-    }
-    result = this->field_20.field_C;
-    if ( result != 8 )
-    {
-      if ( result != 16 )
-      {
-        if ( result != 32)
-          return result;
-        result = (int)pDst;
-        v196 = pDst;
-        v234 = 0;
-        if ( dstHeight <= 0 )
-          return result; 
-        a9c = 4 * (dstPitch - dstWidth);
-        while ( 1 )
-        {
-          v50 = 0;
-          if ( dstWidth > 0 )
-            break;
-LABEL_108:
-          v196 = (unsigned __int16 *)((char *)v196 + a9c);
-          ++v234;
-          result = v234;
-          if ( v234 >= dstHeight )
-            return result;
-        }
-        while ( 1 )
-        {
-          a6y = (double)v50 / (double)dstWidth * (double)srcWidth;
-          v127 = a6y + 6.7553994e15;
-          a6z = (double)(v50 + 1) / (double)dstWidth * (double)srcWidth;
-          v136 = a6z + 6.7553994e15;
-          v53 = (double)v234 / (double)dstHeight * (double)srcHeight;
-          v145 = v53 + 6.7553994e15;
-          v54 = (double)(v234 + 1) / (double)dstHeight * (double)srcHeight;
-          v154 = v54 + 6.7553994e15;
-          v55 = (LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(v127));
-          v255 = 0;
-          a6h = 0;
-          v243 = 0i64;
-          if ( SLODWORD(v145) < SLODWORD(v154) )
-            break;
-LABEL_103:
-          v58 = (unsigned int)v243 / ((LODWORD(v154) - LODWORD(v145)) * (LODWORD(v136) - LODWORD(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;
-          v196 += 2;
-          ++v50;
-          if ( v50 >= dstWidth )
-            goto LABEL_108;
-        }
-        v172 = LODWORD(v154) - LODWORD(v145);
-        v187 = &pSrc[LODWORD(v127) + srcPitch * LODWORD(v145)];
-        while ( SLODWORD(v127) >= SLODWORD(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;
-      }
-      result = (int)pDst;
-      v197 = pDst;
-      v235 = 0;
-      if ( dstHeight <= 0 )
-        return result;
-      a9d = 2 * (dstPitch - dstWidth);
-      while ( 1 )
-      {
-        v62 = 0;
-        if ( dstWidth > 0 )
-          break;
-LABEL_133:
-        v197 = (unsigned __int16 *)((char *)v197 + a9d);
-        ++v235;
-        result = v235;
-        if ( v235 >= dstHeight )
-          return result;
-      }
-      while ( 1 )
-      {
-        a6ba = (double)v62 / (double)dstWidth * (double)srcWidth;
-        _v128 = ceilf(a6ba - 0.5f);
-        a6bb = (double)(v62 + 1) / (double)dstWidth * (double)srcWidth;
-        _v137 = ceilf(a6bb - 0.5f);
-        v65 = (double)v235 / (double)dstHeight * (double)srcHeight;
-        _v146 = ceilf(v65 - 0.5f);
-        v66 = (double)(v235 + 1) / (double)dstHeight * (double)srcHeight;
-        _v155 = ceilf(v66 - 0.5f);
-        v67 = (_v155 - _v146) * (_v137 - _v128);
-        v256 = 0;
-        a6j = 0;
-        v244 = 0i64;
-        if (_v146 < _v155)
-          break;
-LABEL_128:
-        v70 = (unsigned int)v244 / ((_v155 - _v146) * (_v137 - _v128));
-        if ( v67 )
-        {
-          a6j /= v67;
-          v256 /= v67;
-          HIDWORD(v244) /= v67;
-        }
-        if ( v70 != 255 )
-          v70 &= 0x7FFFFFFFu;
-        v71 = _450F55(HIDWORD(v244) | ((v256 | ((a6j | (v70 << 8)) << 8)) << 8));
-        *v197 = v71;
-        ++v197;
-        ++v62;
-        if ( v62 >= dstWidth )
-          goto LABEL_133;
-      }
-      v173 = _v155 - _v146;
-      v188 = &pSrc[_v128 + srcPitch * _v146];
-      while (_v128 >= _v137)
-      {
-LABEL_127:
-        v188 += srcPitch;
-        --v173;
-        if ( !v173 )
-          goto LABEL_128;
-      }
-      v180 = (int *)v188;
-      v165 = _v137 - _v128;
-      while ( 1 )
-      {
-        v69 = _450FB1(*(_WORD *)v180);
-          break;
-LABEL_126:
-        v180 = (int *)((char *)v180 + 2);
-        --v165;
-        if ( !v165 )
-          goto LABEL_127;
-      }
-      LODWORD(v244) = ((unsigned int)v69 >> 24) + v244;
-      a6j += BYTE2(v69);
-      v256 += BYTE1(v69);
-      HIDWORD(v244) += (unsigned __int8)v69;
-      goto LABEL_126;
-    }
+  if ( result == 32 )
+  {
     result = (int)pDst;
-    v198 = pDst;
-    v236 = 0;
+    v193 = pDst;
+    v231 = 0;
     if ( dstHeight <= 0 )
       return result;
     while ( 1 )
     {
-      v74 = 0;
+      v14 = 0;
       if ( dstWidth > 0 )
         break;
-LABEL_158:
-      v198 = (unsigned __int16 *)((char *)v198 + dstPitch - dstWidth);
-      ++v236;
-      result = v236;
-      if ( v236 >= dstHeight )
+LABEL_30:
+      v193 = (unsigned __int16 *)((char *)v193 + dstdiffmult);
+      ++v231;
+      result = v231;
+      if ( v231 >= dstHeight )
         return result;
     }
     while ( 1 )
     {
-      a6bc = (double)v74 / (double)dstWidth * (double)srcWidth;
-      v129 = a6bc + 6.7553994e15;
-      a6bd = (double)(v74 + 1) / (double)dstWidth * (double)srcWidth;
-      v138 = a6bd + 6.7553994e15;
-      v77 = (double)v236 / (double)dstHeight * (double)srcHeight;
-      v147 = v77 + 6.7553994e15;
-      v78 = (double)(v236 + 1) / (double)dstHeight * (double)srcHeight;
-      v156 = v78 + 6.7553994e15;
-      v257 = 0;
-      v79 = (LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129));
-      a6l = 0;
-      v245 = 0i64;
-      if ( SLODWORD(v147) < SLODWORD(v156) )
+      a6s = (double)v14 / (double)dstWidth * (double)srcWidth;
+      v151 = floorf(a6s + 0.5f);//a6s + 6.7553994e15;
+      a6t = (double)(v14 + 1) / (double)dstWidth * (double)srcWidth;
+      v142 = floorf(a6t + 0.5f);//a6t + 6.7553994e15;
+      v17 = (double)v231 / (double)dstHeight * (double)srcHeight;
+      v133 = floorf(v17 + 0.5f);//v17 + 6.7553994e15;
+      v18 = (double)(v231 + 1) / (double)dstHeight * (double)srcHeight;
+      v124 = floorf(v18 + 0.5f);//v18 + 6.7553994e15;
+      v19 = (LODWORD(v124) - LODWORD(v133)) * (LODWORD(v142) - LODWORD(v151));
+      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)));
+      if ( v19 )
+      {
+        a6b /= v19;
+        v252 /= v19;
+        HIDWORD(v240) /= v19;
+      }
+      if ( v22 != 255 )
+        v22 &= 0x7FFFFFFFu;
+      v23 = _450F55(HIDWORD(v240) | ((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;
-LABEL_153:
-      v82 = (unsigned int)v245 / ((LODWORD(v156) - LODWORD(v147)) * (LODWORD(v138) - LODWORD(v129)));
-      if ( v79 )
-      {
-        a6l /= v79;
-        v257 /= v79;
-        HIDWORD(v245) /= v79;
-      }
-      if ( v82 != 255 )
-        v82 &= 0x7FFFFFFFu;
-      v83 = _450F55(HIDWORD(v245) | ((v257 | ((a6l | (v82 << 8)) << 8)) << 8));
-      *v198 = v83;
-      v198 = (unsigned __int16 *)((char *)v198 + 1);
-      ++v74;
-      if ( v74 >= dstWidth )
-        goto LABEL_158;
-    }
-    v174 = LODWORD(v156) - LODWORD(v147);
-    v189 = &pSrc[LODWORD(v129) + srcPitch * LODWORD(v147)];
-    while ( SLODWORD(v129) >= SLODWORD(v138) )
-    {
-LABEL_152:
-      v189 += srcPitch;
-      --v174;
-      if ( !v174 )
-        goto LABEL_153;
-    }
-    v166 = LODWORD(v138) - LODWORD(v129);
-    v181 = (int *)v189;
+      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 )
     {
-      v81 = _450FB1(*(_WORD *)v181);
+      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;
-LABEL_151:
-      v181 = (int *)((char *)v181 + 2);
-      --v166;
-      if ( !v166 )
-        goto LABEL_152;
-    }
-    LODWORD(v245) = ((unsigned int)v81 >> 24) + v245;
-    a6l += BYTE2(v81);
-    v257 += BYTE1(v81);
-    HIDWORD(v245) += (unsigned __int8)v81;
-    goto LABEL_151;
-  }
-
-  result = this->field_20.field_C;
-  int probablyBitDepth = this->field_20.field_C;
-  switch(result)
-  {
-  case 8: vxx = dstPitch - dstWidth;
-    break;
-  case 16: vxx = 2 * (dstPitch - dstWidth);
-    break;
-  case 32: vxx = 4 * (dstPitch - dstWidth);
-    break;
-  default:
-    return result;
-  }
-  if ( result == 8 )
+      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;
@@ -2914,13 +2514,17 @@
       }
       while ( v112 < dstWidth );
 LABEL_236:
-      v201 = (unsigned __int16 *)((char *)v201 + vxx);
+      v201 = (unsigned __int16 *)((char *)v201 + dstdiffmult);
       ++v239;
       result = v239;
       if ( v239 >= dstHeight )
         return result;
     }
   }
+  else //( result != 8 && result != 16 && result != 32 )
+  {
+    return result;
+  }
 }
 
 //----- (0044E1EC) --------------------------------------------------------