📄 msvc_block_decode_asm.h
字号:
MOV ECX,[EDI]row1: // Test for coding pass membership TEST ECX,__MU_BIT*8 JZ row2 // Find pointer to the relevant context state record MOV EBX,cp_to_sp1 MOV EAX,[EDI+EBX] TEST EAX,mag_mask JZ row1_first_mag_ref MOV ECX,states_2 JMP row1_decodingrow1_first_mag_ref: TEST ECX,__NBRHD_MASK*8 MOV ECX,states JZ row1_decoding ADD ECX,8row1_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 row1_decoded CALL mq_non_cdp MOV EBX,cp_to_sp1 // Reload the sample offsetrow1_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 MOV ECX,[EDI]row2: // Test for coding pass membership TEST ECX,__MU_BIT*64 JZ row3 // Find pointer to the relevant context state record MOV EBX,cp_to_sp2 MOV EAX,[EDI+EBX] TEST EAX,mag_mask JZ row2_first_mag_ref MOV ECX,states_2 JMP row2_decodingrow2_first_mag_ref: TEST ECX,__NBRHD_MASK*64 MOV ECX,states JZ row2_decoding ADD ECX,8row2_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 row2_decoded CALL mq_non_cdp MOV EBX,cp_to_sp2 // Reload the sample offsetrow2_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 MOV ECX,[EDI]row3: // Test for coding pass membership TEST ECX,__MU_BIT*512 JZ advance_stripe_column // Find pointer to the relevant context state record MOV EBX,cp_to_sp3 MOV EAX,[EDI+EBX] TEST EAX,mag_mask JZ row3_first_mag_ref MOV ECX,states_2 JMP row3_decodingrow3_first_mag_ref: TEST ECX,__NBRHD_MASK*512 MOV ECX,states JZ row3_decoding ADD ECX,8row3_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 row3_decoded CALL mq_non_cdp MOV EBX,cp_to_sp3 // Reload the sample offsetrow3_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],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_cleanup_pass *//*****************************************************************************/static void asm_decode_cleanup_pass(mq_decoder &coder, mqd_state states[], int p, bool causal, int orientation, 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_byte *sig_lut = significance_luts[orientation]; kdu_int32 one_point_five = 1<<p; one_point_five += (one_point_five>>1); int is_causal = (causal)?1:0; 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 __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,ECX JNZ row0 // Enter the run mode. MOV ECX,states ADD ECX,KAPPA_RUN_BASE*8 // Gets address of run context to ECX MOV EAX,[ECX] // Get `p_bar_mps' to EAX TEST EAX,1 JNZ decode_single_symbol_with_mps1 // Try to skip over 4 columns at once MOV EBX,[EDI+12] TEST EBX,EBX JNZ decode_single_symbol_with_mps0 SHL EAX,2 SUB EDX,EAX JL multi_symbol_decode_failed ADD EDI,16 CMP EDI,stripe_end JNZ next_stripe_column JMP advance_stripemulti_symbol_decode_failed: ADD EDX,EAX SHR EAX,2decode_single_symbol_with_mps0: SUB EDX,EAX JGE uninterrupted_run // MPS decoded and it is 0 CALL mq_non_cdp TEST EAX,1 JNZ run_interruptionuninterrupted_run: ADD EDI,4 CMP EDI,stripe_end JNZ next_stripe_column JMP advance_stripedecode_single_symbol_with_mps1: SUB EDX,EAX ADD EDX,1 // Compensate for the non-zero MPS bit in EAX JGE run_interruption // MPS decoded but it is 1 CALL mq_non_cdp TEST EAX,1 JZ uninterrupted_runrun_interruption: ASM_MQ_DECODE_RUN // Returns with the run in the 2 LSB's of EAX MOV ECX,[EDI] // Get context word back again TEST EAX,EAX JZ row0_significant JP row3_significant // Parity means there are an even number of 1's (run=3) TEST EAX,1 JNZ row1_significant JMP row2_significantrow0: // Test for coding pass membership TEST ECX,__CLEANUP_MEMBER_MASK*1 JNZ row1 // Find pointer to the relevant context state record 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_test0 CALL mq_non_cdpsignificance_test0: MOV ECX,[EDI] // Get context word back again TEST EAX,EAX // If symbol != 0 JZ row1row0_significant: // If we get here, we know that stripe row 0 is newly significant AND ECX,__CHI_BIT/8+__SIGMA_CC_BIT/8+__CHI_BIT*8+__SIGMA_CC_BIT*8 SHR ECX,1 MOV EAX,[EDI-4] // Get context word on left AND EAX,__CHI_BIT+__SIGMA_CC_BIT SHR EAX,2 ADD ECX,EAX MOV EAX,[EDI+4] // Get context word on right AND EAX,__CHI_BIT+__SIGMA_CC_BIT 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 row0_broadcast CALL mq_non_cdprow0_broadcast: // Process newly significant sample; sign is in LSB of EAX // Broadcast significance and sign to last row of previous stripe MOV EBX,is_causal TEST EBX,EBX JNZ row0_skip_non_causal MOV EBX,EDI SUB EBX,context_row_gap MOV ECX,[EBX-4] OR ECX,__SIGMA_BR_BIT*512 MOV [EBX-4],ECX MOV ECX,EAX SHL ECX,NEXT_CHI_POS OR ECX,[EBX] OR ECX,__SIGMA_BC_BIT*512 MOV [EBX],ECX MOV ECX,[EBX+4] OR ECX,__SIGMA_BL_BIT*512 MOV [EBX+4],ECX
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -