slice.c
来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 2,200 行 · 第 1/5 页
C
2,200 行
goto normal_code; } break; /* illegal, check needed to avoid buffer overflow */ } dest[63] ^= mismatch & 1; DUMPBITS (bit_buf, bits, 4); /* dump end of block code */ decoder->bitstream_buf = bit_buf; decoder->bitstream_bits = bits; decoder->bitstream_ptr = bit_ptr;}#endif#ifdef JZ4740_MXU_OPTstatic int get_non_intra_block (mpeg2_decoder_t * const decoder, const uint16_t * const quant_matrix){ int i; int j; int val; const uint8_t * const scan = decoder->scan; int mismatch; const DCTtab * tab; uint32_t bit_buf; int bits; const uint8_t * bit_ptr; int16_t * const dest = decoder->DCTblock; S32CPS(xr11, xr0, xr0); // xr11 gets the max position i = -1; mismatch = 1; bit_buf = decoder->bitstream_buf; bits = decoder->bitstream_bits; bit_ptr = decoder->bitstream_ptr; NEEDBITS (bit_buf, bits, bit_ptr); if (bit_buf >= 0x28000000) { tab = DCT_B14DC_5 + (UBITS (bit_buf, 5) - 5); goto entry_1; } else goto entry_2; while (1) { int32_t my_run, my_len, my_lvl, tmp; if (bit_buf >= 0x28000000) { tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5); entry_1: i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i >= 64) break; /* end of block */ normal_code: i_noreorder; j = scan[i]; bit_buf <<= my_len; bits += my_len + 1; val = quant_matrix[j]; S32I2M(xr10, j); tmp = (my_lvl<<1) + 1; val *= tmp; S32MAX(xr11, xr11, xr10); tmp = SBITS (bit_buf, 1); val >>= 5; val = (val ^ tmp) - tmp; i_reorder; SATURATE (val); dest[j] = val; mismatch ^= val; bit_buf <<= 1; NEEDBITS (bit_buf, bits, bit_ptr); continue; } entry_2: if (bit_buf >= 0x04000000) { tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; /* escape code */ i += UBITS (bit_buf << 6, 6) - 64; if (i >= 64) break; /* illegal, check needed to avoid buffer overflow */ i_noreorder; j = scan[i]; DUMPBITS (bit_buf, bits, 12); NEEDBITS (bit_buf, bits, bit_ptr); tmp = quant_matrix[j]; S32I2M(xr10, j); val = SBITS (bit_buf, 12) + SBITS (bit_buf, 1); val = (val<<1) + 1; val *= tmp; S32MAX(xr11, xr11, xr10); val >>= 5; i_reorder; SATURATE (val); dest[j] = val; mismatch ^= val; DUMPBITS (bit_buf, bits, 12); NEEDBITS (bit_buf, bits, bit_ptr); continue; } else if (bit_buf >= 0x02000000) { tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00800000) { tab = DCT_13 + (UBITS (bit_buf, 13) - 16); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00200000) { tab = DCT_15 + (UBITS (bit_buf, 15) - 16); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } else { tab = DCT_16 + UBITS (bit_buf, 16); bit_buf <<= 16; GETWORD (bit_buf, bits + 16, bit_ptr); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } break; /* illegal, check needed to avoid buffer overflow */ } // S32STD(xr11, idct_max, 0); val = S32M2I(xr11); dest[63] ^= mismatch & 1; DUMPBITS (bit_buf, bits, 2); /* dump end of block code */ decoder->bitstream_buf = bit_buf; decoder->bitstream_bits = bits; decoder->bitstream_ptr = bit_ptr; idct_row_max = val>>3; return i;}#elsestatic int get_non_intra_block (mpeg2_decoder_t * const decoder, const uint16_t * const quant_matrix){ int i; int j; int val; const uint8_t * const scan = decoder->scan; int mismatch; const DCTtab * tab; uint32_t bit_buf; int bits; const uint8_t * bit_ptr; int16_t * const dest = decoder->DCTblock; i = -1; mismatch = -1; bit_buf = decoder->bitstream_buf; bits = decoder->bitstream_bits; bit_ptr = decoder->bitstream_ptr; NEEDBITS (bit_buf, bits, bit_ptr); if (bit_buf >= 0x28000000) { tab = DCT_B14DC_5 + (UBITS (bit_buf, 5) - 5); goto entry_1; } else goto entry_2; while (1) { if (bit_buf >= 0x28000000) { tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5); entry_1: i += tab->run; if (i >= 64) break; /* end of block */ normal_code: j = scan[i]; bit_buf <<= tab->len; bits += tab->len + 1; val = ((2 * tab->level + 1) * quant_matrix[j]) >> 5; /* if (bitstream_get (1)) val = -val; */ val = (val ^ SBITS (bit_buf, 1)) - SBITS (bit_buf, 1); SATURATE (val); dest[j] = val; mismatch ^= val; bit_buf <<= 1; NEEDBITS (bit_buf, bits, bit_ptr); continue; } entry_2: if (bit_buf >= 0x04000000) { tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4); i += tab->run; if (i < 64) goto normal_code; /* escape code */ i += UBITS (bit_buf << 6, 6) - 64; if (i >= 64) break; /* illegal, check needed to avoid buffer overflow */ j = scan[i]; DUMPBITS (bit_buf, bits, 12); NEEDBITS (bit_buf, bits, bit_ptr); val = 2 * (SBITS (bit_buf, 12) + SBITS (bit_buf, 1)) + 1; val = (val * quant_matrix[j]) / 32; SATURATE (val); dest[j] = val; mismatch ^= val; DUMPBITS (bit_buf, bits, 12); NEEDBITS (bit_buf, bits, bit_ptr); continue; } else if (bit_buf >= 0x02000000) { tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8); i += tab->run; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00800000) { tab = DCT_13 + (UBITS (bit_buf, 13) - 16); i += tab->run; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00200000) { tab = DCT_15 + (UBITS (bit_buf, 15) - 16); i += tab->run; if (i < 64) goto normal_code; } else { tab = DCT_16 + UBITS (bit_buf, 16); bit_buf <<= 16; GETWORD (bit_buf, bits + 16, bit_ptr); i += tab->run; if (i < 64) goto normal_code; } break; /* illegal, check needed to avoid buffer overflow */ } dest[63] ^= mismatch & 16; DUMPBITS (bit_buf, bits, 2); /* dump end of block code */ decoder->bitstream_buf = bit_buf; decoder->bitstream_bits = bits; decoder->bitstream_ptr = bit_ptr; return i;}#endif#ifdef JZ4740_MXU_OPTstatic void get_mpeg1_intra_block (mpeg2_decoder_t * const decoder){ int i; int j; int val; const uint8_t * const scan = decoder->scan; const uint16_t * const quant_matrix = decoder->quantizer_matrix[0]; const DCTtab * tab; uint32_t bit_buf; int bits; const uint8_t * bit_ptr; int16_t * const dest = decoder->DCTblock; S32CPS(xr11, xr0, xr0); i = 0; bit_buf = decoder->bitstream_buf; bits = decoder->bitstream_bits; bit_ptr = decoder->bitstream_ptr; NEEDBITS (bit_buf, bits, bit_ptr); while (1) { int32_t my_run, my_len, my_lvl, tmp; if (bit_buf >= 0x28000000) { tab = DCT_B14AC_5 + (UBITS (bit_buf, 5) - 5); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i >= 64) break; /* end of block */ normal_code: i_noreorder; j = scan[i]; bit_buf <<= my_len; bits += my_len + 1; val = quant_matrix[j]; S32I2M(xr10, j); tmp = my_lvl; val *= tmp; S32MAX(xr11, xr11, xr10); tmp = SBITS (bit_buf, 1); val >>= 4; /* oddification */ val = (val - 1) | 1; val = (val ^ tmp) - tmp; /* if (bitstream_get (1)) val = -val; */ i_reorder; SATURATE (val); dest[j] = val; bit_buf <<= 1; NEEDBITS (bit_buf, bits, bit_ptr); continue; } else if (bit_buf >= 0x04000000) { tab = DCT_B14_8 + (UBITS (bit_buf, 8) - 4); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; /* escape code */ i += UBITS (bit_buf << 6, 6) - 64; if (i >= 64) break; /* illegal, check needed to avoid buffer overflow */ i_noreorder; j = scan[i]; DUMPBITS (bit_buf, bits, 12); NEEDBITS (bit_buf, bits, bit_ptr); S32I2M(xr10, j); tmp = quant_matrix[j]; val = SBITS (bit_buf, 8); if (! (val & 0x7f)) { DUMPBITS (bit_buf, bits, 8); val = UBITS (bit_buf, 8) + 2 * val; } val *= tmp; S32MAX(xr11, xr11, xr10); val >>= 4; i_reorder; /* oddification */ val = (val + ~SBITS (val, 1)) | 1; SATURATE (val); dest[j] = val; DUMPBITS (bit_buf, bits, 8); NEEDBITS (bit_buf, bits, bit_ptr); continue; } else if (bit_buf >= 0x02000000) { tab = DCT_B14_10 + (UBITS (bit_buf, 10) - 8); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00800000) { tab = DCT_13 + (UBITS (bit_buf, 13) - 16); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } else if (bit_buf >= 0x00200000) { tab = DCT_15 + (UBITS (bit_buf, 15) - 16); i_noreorder; my_run = (uint32_t)tab->run; my_len = (uint32_t)tab->len; my_lvl = (uint32_t)tab->level; i += my_run; i_reorder; if (i < 64) goto normal_code; } else { tab = DCT_16 + UBITS (bit_buf, 16); bit_buf <<= 16; GETWORD (bit_buf, bits + 16, bit_ptr);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?