--- old/quantize_mpeg_mmx.asm Thu Sep 21 08:56:24 2006 +++ new/quantize_mpeg_mmx.asm Thu Sep 21 09:19:14 2006 @@ -221,21 +221,19 @@ ; calculate DC movsx eax, word [eax] ; data[0] mov ecx, [esp + 4 + 16] ; dcscalar - mov edx, ecx - shr edx, 1 ; edx = dcscalar /2 - mov edi, edx - neg edi + mov edx, eax + mov edi, ecx + shr ecx, 1 ; ecx = dcscalar/2 + sar edx, 31 ; edx = sign extend of eax (ready for division too) + xor ecx, edx ; adjust ecx according to the sign of data[0] + sub ecx, edx + add eax, ecx - cmp eax, 0 - cmovg edx, edi - sub eax, edx + mov ecx, [esp + 4 + 4] ; coeff again - mov edi, [esp + 4 + 4] ; coeff again + idiv edi ; eax = edx:eax / dcscalar - cdq ; expand eax -> edx:eax - idiv ecx ; eax = edx:eax / dcscalar - - mov [edi], ax ; coeff[0] = ax + mov [ecx], ax ; coeff[0] = ax pop edi