Commit d1eebb29 authored by Henrik Gramner's avatar Henrik Gramner Committed by Anton Mitrofanov
Browse files

cabac: Make the cabac_contexts array static

Also drop the x264 prefix from all static cabac arrays.
parent 3f9f6554
......@@ -28,7 +28,7 @@
#include "common.h"
static const int8_t x264_cabac_context_init_I[1024][2] =
static const int8_t cabac_context_init_I[1024][2] =
{
/* 0 - 10 */
{ 20, -15 }, { 2, 54 }, { 3, 74 }, { 20, -15 },
......@@ -340,7 +340,7 @@ static const int8_t x264_cabac_context_init_I[1024][2] =
{ -3, 70 }, { -8, 93 }, { -10, 90 }, { -30, 127 }
};
static const int8_t x264_cabac_context_init_PB[3][1024][2] =
static const int8_t cabac_context_init_PB[3][1024][2] =
{
/* i_cabac_init_idc == 0 */
{
......@@ -1325,30 +1325,27 @@ const uint16_t x264_cabac_entropy[128] =
FIX8(0.9285), FIX8(1.0752), FIX8(1.0000), FIX8(1.0000)
};
uint8_t x264_cabac_contexts[4][QP_MAX_SPEC+1][1024];
static uint8_t cabac_contexts[4][QP_MAX_SPEC+1][1024];
void x264_cabac_init( x264_t *h )
{
int ctx_count = CHROMA444 ? 1024 : 460;
for( int i = 0; i < 4; i++ )
{
const int8_t (*cabac_context_init)[1024][2] = i == 0 ? &x264_cabac_context_init_I
: &x264_cabac_context_init_PB[i-1];
const int8_t (*cabac_context_init)[1024][2] = i == 0 ? &cabac_context_init_I
: &cabac_context_init_PB[i-1];
for( int qp = 0; qp <= QP_MAX_SPEC; qp++ )
for( int j = 0; j < ctx_count; j++ )
{
int state = x264_clip3( (((*cabac_context_init)[j][0] * qp) >> 4) + (*cabac_context_init)[j][1], 1, 126 );
x264_cabac_contexts[i][qp][j] = (X264_MIN( state, 127-state ) << 1) | (state >> 6);
cabac_contexts[i][qp][j] = (X264_MIN( state, 127-state ) << 1) | (state >> 6);
}
}
}
/*****************************************************************************
*
*****************************************************************************/
void x264_cabac_context_init( x264_t *h, x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model )
{
memcpy( cb->state, x264_cabac_contexts[i_slice_type == SLICE_TYPE_I ? 0 : i_model + 1][i_qp], CHROMA444 ? 1024 : 460 );
memcpy( cb->state, cabac_contexts[i_slice_type == SLICE_TYPE_I ? 0 : i_model + 1][i_qp], CHROMA444 ? 1024 : 460 );
}
void x264_cabac_encode_init_core( x264_cabac_t *cb )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment