|
|
@ -1565,7 +1565,12 @@ DECLARE_ASM_CONST(1, uint8_t, last_coeff_flag_offset_8x8)[63] = { |
|
|
|
5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 |
|
|
|
5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff, int is_dc ) { |
|
|
|
static av_always_inline void |
|
|
|
|
|
|
|
decode_cabac_residual_internal(H264Context *h, DCTELEM *block, |
|
|
|
|
|
|
|
int cat, int n, const uint8_t *scantable, |
|
|
|
|
|
|
|
const uint32_t *qmul, int max_coeff, |
|
|
|
|
|
|
|
int is_dc, int chroma422) |
|
|
|
|
|
|
|
{ |
|
|
|
static const int significant_coeff_flag_offset[2][14] = { |
|
|
|
static const int significant_coeff_flag_offset[2][14] = { |
|
|
|
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 }, |
|
|
|
{ 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 }, |
|
|
|
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 } |
|
|
|
{ 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 } |
|
|
@ -1587,12 +1592,16 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT |
|
|
|
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9, |
|
|
|
9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9, |
|
|
|
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 } |
|
|
|
9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 } |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
static const uint8_t sig_coeff_offset_dc[7] = { 0, 0, 1, 1, 2, 2, 2 }; |
|
|
|
/* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
|
|
|
|
/* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0).
|
|
|
|
* 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter). |
|
|
|
* 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter). |
|
|
|
* map node ctx => cabac ctx for level=1 */ |
|
|
|
* map node ctx => cabac ctx for level=1 */ |
|
|
|
static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; |
|
|
|
static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; |
|
|
|
/* map node ctx => cabac ctx for level>1 */ |
|
|
|
/* map node ctx => cabac ctx for level>1 */ |
|
|
|
static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 }; |
|
|
|
static const uint8_t coeff_abs_levelgt1_ctx[2][8] = { |
|
|
|
|
|
|
|
{ 5, 5, 5, 5, 6, 7, 8, 9 }, |
|
|
|
|
|
|
|
{ 5, 5, 5, 5, 6, 7, 8, 8 }, // 422/dc case
|
|
|
|
|
|
|
|
}; |
|
|
|
static const uint8_t coeff_abs_level_transition[2][8] = { |
|
|
|
static const uint8_t coeff_abs_level_transition[2][8] = { |
|
|
|
/* update node ctx after decoding a level=1 */ |
|
|
|
/* update node ctx after decoding a level=1 */ |
|
|
|
{ 1, 2, 3, 3, 4, 5, 6, 7 }, |
|
|
|
{ 1, 2, 3, 3, 4, 5, 6, 7 }, |
|
|
@ -1650,13 +1659,21 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT |
|
|
|
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) |
|
|
|
#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) |
|
|
|
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, |
|
|
|
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, |
|
|
|
last_coeff_ctx_base, sig_off); |
|
|
|
last_coeff_ctx_base, sig_off); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (is_dc && chroma422) { // dc 422
|
|
|
|
|
|
|
|
DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, |
|
|
|
coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, |
|
|
|
last_coeff_ctx_base-significant_coeff_ctx_base); |
|
|
|
last_coeff_ctx_base-significant_coeff_ctx_base); |
|
|
|
|
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] ); |
|
|
|
DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] ); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
DECODE_SIGNIFICANCE( max_coeff - 1, last, last ); |
|
|
|
if (is_dc && chroma422) { // dc 422
|
|
|
|
|
|
|
|
DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
DECODE_SIGNIFICANCE(max_coeff - 1, last, last); |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
assert(coeff_count > 0); |
|
|
|
assert(coeff_count > 0); |
|
|
@ -1691,7 +1708,7 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT |
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
} else { \
|
|
|
|
int coeff_abs = 2; \
|
|
|
|
int coeff_abs = 2; \
|
|
|
|
ctx = coeff_abs_levelgt1_ctx[node_ctx] + abs_level_m1_ctx_base; \
|
|
|
|
ctx = coeff_abs_levelgt1_ctx[is_dc && chroma422][node_ctx] + abs_level_m1_ctx_base; \
|
|
|
|
node_ctx = coeff_abs_level_transition[1][node_ctx]; \
|
|
|
|
node_ctx = coeff_abs_level_transition[1][node_ctx]; \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \
|
|
|
|
while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \
|
|
|
@ -1733,11 +1750,18 @@ static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCT |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) { |
|
|
|
static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) { |
|
|
|
decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1); |
|
|
|
decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 0); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void decode_cabac_residual_dc_internal_422(H264Context *h, DCTELEM *block, |
|
|
|
|
|
|
|
int cat, int n, const uint8_t *scantable, |
|
|
|
|
|
|
|
int max_coeff) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void decode_cabac_residual_nondc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
|
|
|
static void decode_cabac_residual_nondc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
|
|
|
decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0); |
|
|
|
decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* cat: 0-> DC 16x16 n = 0
|
|
|
|
/* cat: 0-> DC 16x16 n = 0
|
|
|
@ -1761,6 +1785,19 @@ static av_always_inline void decode_cabac_residual_dc( H264Context *h, DCTELEM * |
|
|
|
decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff ); |
|
|
|
decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static av_always_inline void |
|
|
|
|
|
|
|
decode_cabac_residual_dc_422(H264Context *h, DCTELEM *block, |
|
|
|
|
|
|
|
int cat, int n, const uint8_t *scantable, |
|
|
|
|
|
|
|
int max_coeff) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/* read coded block flag */ |
|
|
|
|
|
|
|
if (get_cabac(&h->cabac, &h->cabac_state[get_cabac_cbf_ctx(h, cat, n, max_coeff, 1)]) == 0) { |
|
|
|
|
|
|
|
h->non_zero_count_cache[scan8[n]] = 0; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
decode_cabac_residual_dc_internal_422(h, block, cat, n, scantable, max_coeff); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
|
|
|
static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { |
|
|
|
/* read coded block flag */ |
|
|
|
/* read coded block flag */ |
|
|
|
if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) { |
|
|
|
if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) { |
|
|
@ -2313,7 +2350,36 @@ decode_intra_mb: |
|
|
|
if(CHROMA444){ |
|
|
|
if(CHROMA444){ |
|
|
|
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1); |
|
|
|
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1); |
|
|
|
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2); |
|
|
|
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2); |
|
|
|
|
|
|
|
} else if (CHROMA422) { |
|
|
|
|
|
|
|
if( cbp&0x30 ){ |
|
|
|
|
|
|
|
int c; |
|
|
|
|
|
|
|
for( c = 0; c < 2; c++ ) { |
|
|
|
|
|
|
|
//av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
|
|
|
|
|
|
|
|
decode_cabac_residual_dc_422(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, |
|
|
|
|
|
|
|
CHROMA_DC_BLOCK_INDEX + c, |
|
|
|
|
|
|
|
chroma422_dc_scan, 8); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( cbp&0x20 ) { |
|
|
|
|
|
|
|
int c, i, i8x8; |
|
|
|
|
|
|
|
for( c = 0; c < 2; c++ ) { |
|
|
|
|
|
|
|
DCTELEM *mb = h->mb + (16*(16 + 16*c) << pixel_shift); |
|
|
|
|
|
|
|
qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; |
|
|
|
|
|
|
|
for (i8x8 = 0; i8x8 < 2; i8x8++) { |
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) { |
|
|
|
|
|
|
|
const int index = 16 + 16 * c + 8*i8x8 + i; |
|
|
|
|
|
|
|
//av_log(s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16);
|
|
|
|
|
|
|
|
decode_cabac_residual_nondc(h, mb, 4, index, scan + 1, qmul, 15); |
|
|
|
|
|
|
|
mb += 16<<pixel_shift; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); |
|
|
|
|
|
|
|
fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else /* yuv420 */ { |
|
|
|
if( cbp&0x30 ){ |
|
|
|
if( cbp&0x30 ){ |
|
|
|
int c; |
|
|
|
int c; |
|
|
|
for( c = 0; c < 2; c++ ) { |
|
|
|
for( c = 0; c < 2; c++ ) { |
|
|
|