📄 msvc_block_decode_asm.h
字号:
MOV EBX,cp_to_sp1 MOV [EDI+EBX],EAXrow2: // Test for coding pass membership MOV EBX,ECX AND EBX,__NBRHD_MASK*64 JZ row3 TEST ECX,__SIG_PROP_MEMBER_MASK*64 JNZ row3 OR ECX,__PI_BIT*64 MOV [EDI],ECX // Save context word indicating that sample belongs to pass // Find pointer to the relevant context state record SHR ECX,6 AND ECX,__NBRHD_MASK ADD ECX,sig_lut MOVZX ECX,byte ptr [ECX] MOV EBX,states LEA ECX,[EBX+8*ECX] // Decode symbol MOV EAX,[ECX] // Get `p_bar_mps' to EAX SUB EDX,EAX AND EAX,1 // Get MPS identity in LSB of EAX ADD EDX,EAX // Correct for the effect of the MPS JGE significance_test2 CALL mq_non_cdpsignificance_test2: MOV ECX,[EDI] // Get context word back again TEST EAX,EAX // If symbol != 0 JZ row3 // If we get here, we know that stripe row 2 is newly significant AND ECX,__CHI_BIT*8+__SIGMA_CC_BIT*8+__CHI_BIT*512+__SIGMA_CC_BIT*512 SHR ECX,7 MOV EAX,[EDI-4] // Get context word on left AND EAX,__CHI_BIT*64+__SIGMA_CC_BIT*64 SHR EAX,8 ADD ECX,EAX MOV EAX,[EDI+4] // Get context word on right AND EAX,__CHI_BIT*64+__SIGMA_CC_BIT*64 SHR EAX,6 ADD ECX,EAX MOV EAX,ECX SHR EAX,CHI_POS-1-SIGMA_CC_POS OR ECX,EAX AND ECX,0x000000FF MOVZX ECX,byte ptr [sign_lut+ECX] MOV EAX,ECX // Save the sign LUT result in EAX SHR ECX,1 // Get context label part of the LUT result MOV EBX,states LEA ECX,[EBX+8*ECX+8*KAPPA_SIGN_BASE] // ECX has pointer to context state MOV EBX,[ECX] // Get `p_bar_mps' to EBX XOR EAX,EBX AND EAX,1 // Leaves EAX with the MPS sign value in its LSB. BTR EBX,0 // Leaves `p_bar' in EBX SUB EDX,EBX JGE row2_broadcast CALL mq_non_cdprow2_broadcast: // Process newly significant sample; sign is in LSB of EAX // Broadcast significance to left and right neighbours MOV ECX,[EDI-4] OR ECX,__SIGMA_CR_BIT*64 MOV [EDI-4],ECX MOV ECX,[EDI+4] OR ECX,__SIGMA_CL_BIT*64 MOV [EDI+4],ECX // Recover and update context word, using ECX register MOV ECX,EAX SHL ECX,CHI_POS+6 OR ECX,[EDI] OR ECX,__SIGMA_CC_BIT*64 MOV [EDI],ECX // Write new significant sample value SHL EAX,31 // Get sign bit of result into right position ADD EAX,one_point_five MOV EBX,cp_to_sp2 MOV [EDI+EBX],EAXrow3: // Test for coding pass membership MOV EBX,ECX AND EBX,__NBRHD_MASK*512 JZ advance_stripe_column TEST ECX,__SIG_PROP_MEMBER_MASK*512 JNZ advance_stripe_column OR ECX,__PI_BIT*512 MOV [EDI],ECX // Save context word indicating that sample belongs to pass // Find pointer to the relevant context state record SHR ECX,9 AND ECX,__NBRHD_MASK ADD ECX,sig_lut MOVZX ECX,byte ptr [ECX] MOV EBX,states LEA ECX,[EBX+8*ECX] // Decode symbol MOV EAX,[ECX] // Get `p_bar_mps' to EAX SUB EDX,EAX AND EAX,1 // Get MPS identity in LSB of EAX ADD EDX,EAX // Correct for the effect of the MPS JGE significance_test3 CALL mq_non_cdpsignificance_test3: MOV ECX,[EDI] // Get context word back again TEST EAX,EAX // If symbol != 0 JZ advance_stripe_column // If we get here, we know that stripe row 3 is newly significant MOV EBX,ECX // Make copy of ECX for exceptional sign processing AND ECX,__CHI_BIT*64+__SIGMA_CC_BIT*64+__SIGMA_CC_BIT*4096 SHR ECX,10 TEST EBX,EBX JGE no_exceptional_sign_processing OR ECX,__CHI_BIT*4no_exceptional_sign_processing: MOV EAX,[EDI-4] // Get context word on left AND EAX,__CHI_BIT*512+__SIGMA_CC_BIT*512 SHR EAX,11 ADD ECX,EAX MOV EAX,[EDI+4] // Get context word on right AND EAX,__CHI_BIT*512+__SIGMA_CC_BIT*512 SHR EAX,9 ADD ECX,EAX MOV EAX,ECX SHR EAX,CHI_POS-1-SIGMA_CC_POS OR ECX,EAX AND ECX,0x000000FF MOVZX ECX,byte ptr [sign_lut+ECX] MOV EAX,ECX // Save the sign LUT result in EAX SHR ECX,1 // Get context label part of the LUT result MOV EBX,states LEA ECX,[EBX+8*ECX+8*KAPPA_SIGN_BASE] // ECX has pointer to context state MOV EBX,[ECX] // Get `p_bar_mps' to EBX XOR EAX,EBX AND EAX,1 // Leaves EAX with the MPS sign value in its LSB. BTR EBX,0 // Leaves `p_bar' in EBX SUB EDX,EBX JGE row3_broadcast CALL mq_non_cdprow3_broadcast: // Process newly significant sample; sign is in LSB of EAX // Broadcast significance and sign to first row of next stripe MOV EBX,EDI ADD EBX,context_row_gap MOV ECX,[EBX-4] OR ECX,__SIGMA_TR_BIT MOV [EBX-4],ECX MOV ECX,EAX SHL ECX,PREV_CHI_POS OR ECX,[EBX] OR ECX,__SIGMA_TC_BIT MOV [EBX],ECX MOV ECX,[EBX+4] OR ECX,__SIGMA_TL_BIT MOV [EBX+4],ECX // Broadcast significance to left and right neighbours MOV ECX,[EDI-4] OR ECX,__SIGMA_CR_BIT*512 MOV [EDI-4],ECX MOV ECX,[EDI+4] OR ECX,__SIGMA_CL_BIT*512 MOV [EDI+4],ECX // Recover and update context word, using ECX register MOV ECX,EAX SHL ECX,CHI_POS+9 OR ECX,[EDI] OR ECX,__SIGMA_CC_BIT*512 MOV [EDI],ECX // Write new significant sample value SHL EAX,31 // Get sign bit of result into right position ADD EAX,one_point_five MOV EBX,cp_to_sp3 MOV [EDI+EBX],EAXadvance_stripe_column: ADD EDI,4 CMP EDI,stripe_end JNZ next_stripe_columnadvance_stripe: ADD EDI,EXTRA_DECODE_CWORDS*4 MOV EAX,cp_to_sp_adjust MOV EBX,cp_to_sp0 ADD EBX,EAX MOV cp_to_sp0,EBX MOV EBX,cp_to_sp1 ADD EBX,EAX MOV cp_to_sp1,EBX MOV EBX,cp_to_sp2 ADD EBX,EAX MOV cp_to_sp2,EBX MOV EBX,cp_to_sp3 ADD EBX,EAX MOV cp_to_sp3,EBX MOV EAX,num_stripes SUB EAX,1 MOV num_stripes,EAX JNZ next_stripe JMP finished // We insert local fast function calls heremq_non_cdp: ASM_MQ_NON_CDP_DECODE ret // Return from fast function callfinished: MOV D_var,EDX // Save the D register ready for `coder.check_in' MOV A_var,ESI // Save the A register ready for `coder.check_in' EMMS // Restore the FPU registers from any MMX calls which we may have used } coder.check_in(A_var,C_var,D_var,t_var,temp_var,store_var,S_var);}/*****************************************************************************//* STATIC asm_decode_mag_ref_pass *//*****************************************************************************/static void asm_decode_mag_ref_pass(mq_decoder &coder, mqd_state states[], int p, bool causal, kdu_int32 *samples, kdu_int32 *contexts, int width, int num_stripes, int context_row_gap){ if ((num_stripes <= 0) || (width <= 0)) return; kdu_int32 A_var, C_var, D_var, t_var, temp_var; kdu_byte *store_var; int S_var; coder.check_out(A_var,C_var,D_var,t_var,temp_var,store_var,S_var); kdu_int32 half_lsb = (1<<p)>>1; context_row_gap <<= 2; // Convert to number of bytes width <<= 2; // Convert to number of bytes /* The following offsets are used to convert a context word pointer to a sample pointer. The offsets are correct for the first stripe and must be adjusted from stripe to stripe by the addition of 3*width-EXTRA_DECODE_CWORDS. */ int cp_to_sp0 = ((int) samples)-((int) contexts); // Offset for row 0 int cp_to_sp1 = cp_to_sp0+width; // Offset for row 1 int cp_to_sp2 = cp_to_sp1+width; // Offset for row 2 int cp_to_sp3 = cp_to_sp2+width; // Offset for row 3 int cp_to_sp_adjust = 3*width-4*EXTRA_DECODE_CWORDS; kdu_int32 *stripe_end; // Points to context word beyond end of current stripe kdu_int32 mag_mask = -1; mag_mask <<= (p+2); mag_mask &= KDU_INT32_MAX; states += KAPPA_MAG_BASE; mqd_state *states_2 = states+2; __asm { MOV EDI,contexts // Set EDI aside to hold the context word pointer MOV EDX,D_var // Set EDX aside to hold the critical MQ variable, D MOV ESI,A_var // Set ESI aside to hold the MQ coder's A registernext_stripe: MOV EAX,width ADD EAX,EDI MOV stripe_end,EAX // Set end pointer for this stripenext_stripe_column: MOV ECX,[EDI] TEST ECX,__MU_BIT+__MU_BIT*8+__MU_BIT*64+__MU_BIT*512 JNZ row0speedup_loop: // Invoke speedup trick to skip over runs of all-zero neighbourhoods MOV ECX,[EDI+8] ADD EDI,8 TEST ECX,ECX JZ speedup_loop SUB EDI,4 CMP EDI,stripe_end JNZ next_stripe_column JMP advance_striperow0: // Test for coding pass membership TEST ECX,__MU_BIT*1 JZ row1 // Find pointer to the relevant context state record MOV EBX,cp_to_sp0 MOV EAX,[EDI+EBX] TEST EAX,mag_mask JZ row0_first_mag_ref MOV ECX,states_2 JMP row0_decodingrow0_first_mag_ref: TEST ECX,__NBRHD_MASK*1 MOV ECX,states JZ row0_decoding ADD ECX,8row0_decoding: // Now we are ready to decode the symbol; ECX points to context MOV EAX,[ECX] // Get `p_bar_mps' to EAX SUB EDX,EAX AND EAX,1 // Get MPS identity in LSB of EAX ADD EDX,EAX // Correct for the effect of the MPS JGE row0_decoded CALL mq_non_cdp MOV EBX,cp_to_sp0 // Reload the sample offsetrow0_decoded: // Ready to update sample; EBX holds address offset from EDI MOV CL,byte ptr [p] XOR EAX,1 SHL EAX,CL XOR EAX,[EDI+EBX] OR EAX,half_lsb MOV [EDI+EBX],EAX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -