00001
00016 #define CONTEXT_INI_C
00017
00018 #include "defines.h"
00019 #include "global.h"
00020 #include "biaridecod.h"
00021 #include "ctx_tables.h"
00022
00023
00024 #define IBIARI_CTX_INIT2(ii,jj,ctx,tab,num, qp) \
00025 { \
00026 for (i=0; i<ii; ++i) \
00027 for (j=0; j<jj; ++j) \
00028 { \
00029 biari_init_context (qp, &(ctx[i][j]), tab ## _I[num][i][j]); \
00030 } \
00031 }
00032
00033 #define PBIARI_CTX_INIT2(ii,jj,ctx,tab,num, qp) \
00034 { \
00035 for (i=0; i<ii; ++i) \
00036 for (j=0; j<jj; ++j) \
00037 { \
00038 biari_init_context (qp, &(ctx[i][j]), tab ## _P[num][i][j]); \
00039 } \
00040 }
00041
00042
00043 #define IBIARI_CTX_INIT1(jj,ctx,tab,num, qp) \
00044 { \
00045 for (j=0; j<jj; ++j) \
00046 { \
00047 biari_init_context (qp, &(ctx[j]), tab ## _I[num][0][j]); \
00048 } \
00049 }
00050
00051
00052 #define PBIARI_CTX_INIT1(jj,ctx,tab,num, qp) \
00053 { \
00054 { \
00055 for (j=0; j<jj; ++j) \
00056 { \
00057 biari_init_context (qp, &(ctx[j]), tab ## _P[num][0][j]); \
00058 } \
00059 } \
00060 }
00061
00062 void init_contexts (Slice *currSlice)
00063 {
00064 ImageParameters *p_Img = currSlice->p_Img;
00065 MotionInfoContexts* mc = currSlice->mot_ctx;
00066 TextureInfoContexts* tc = currSlice->tex_ctx;
00067 int i, j;
00068 int qp = imax(0, p_Img->qp);
00069 int model_number = currSlice->model_number;
00070
00071
00072
00073
00074 if ((currSlice->slice_type == I_SLICE)||(currSlice->slice_type == SI_SLICE))
00075 {
00076 IBIARI_CTX_INIT2 (3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE, model_number, qp);
00077 IBIARI_CTX_INIT2 (2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE, model_number, qp);
00078 IBIARI_CTX_INIT2 (2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES, model_number, qp);
00079 IBIARI_CTX_INIT2 (2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO, model_number, qp);
00080 IBIARI_CTX_INIT1 ( NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP, model_number, qp);
00081 IBIARI_CTX_INIT1 ( NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF, model_number, qp);
00082
00083
00084 IBIARI_CTX_INIT1 ( NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts, INIT_TRANSFORM_SIZE, model_number, qp);
00085 IBIARI_CTX_INIT1 ( NUM_IPR_CTX, tc->ipr_contexts, INIT_IPR, model_number, qp);
00086 IBIARI_CTX_INIT1 ( NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number, qp);
00087 IBIARI_CTX_INIT2 (3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number, qp);
00088 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts, INIT_BCBP, model_number, qp);
00089 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0], INIT_MAP, model_number, qp);
00090 #if ENABLE_FIELD_CTX
00091 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[1], INIT_FLD_MAP, model_number, qp);
00092 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1], INIT_FLD_LAST, model_number, qp);
00093 #endif
00094 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[0], INIT_LAST, model_number, qp);
00095 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE, model_number, qp);
00096 IBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS, model_number, qp);
00097 }
00098 else
00099 {
00100 PBIARI_CTX_INIT2 (3, NUM_MB_TYPE_CTX, mc->mb_type_contexts, INIT_MB_TYPE, model_number, qp);
00101 PBIARI_CTX_INIT2 (2, NUM_B8_TYPE_CTX, mc->b8_type_contexts, INIT_B8_TYPE, model_number, qp);
00102 PBIARI_CTX_INIT2 (2, NUM_MV_RES_CTX, mc->mv_res_contexts, INIT_MV_RES, model_number, qp);
00103 PBIARI_CTX_INIT2 (2, NUM_REF_NO_CTX, mc->ref_no_contexts, INIT_REF_NO, model_number, qp);
00104 PBIARI_CTX_INIT1 ( NUM_DELTA_QP_CTX, mc->delta_qp_contexts, INIT_DELTA_QP, model_number, qp);
00105 PBIARI_CTX_INIT1 ( NUM_MB_AFF_CTX, mc->mb_aff_contexts, INIT_MB_AFF, model_number, qp);
00106
00107
00108 PBIARI_CTX_INIT1 ( NUM_TRANSFORM_SIZE_CTX, tc->transform_size_contexts, INIT_TRANSFORM_SIZE, model_number, qp);
00109 PBIARI_CTX_INIT1 ( NUM_IPR_CTX, tc->ipr_contexts, INIT_IPR, model_number, qp);
00110 PBIARI_CTX_INIT1 ( NUM_CIPR_CTX, tc->cipr_contexts, INIT_CIPR, model_number, qp);
00111 PBIARI_CTX_INIT2 (3, NUM_CBP_CTX, tc->cbp_contexts, INIT_CBP, model_number, qp);
00112 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_BCBP_CTX, tc->bcbp_contexts, INIT_BCBP, model_number, qp);
00113 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[0], INIT_MAP, model_number, qp);
00114 #if ENABLE_FIELD_CTX
00115 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_MAP_CTX, tc->map_contexts[1], INIT_FLD_MAP, model_number, qp);
00116 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[1], INIT_FLD_LAST, model_number, qp);
00117 #endif
00118 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_LAST_CTX, tc->last_contexts[0], INIT_LAST, model_number, qp);
00119 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ONE_CTX, tc->one_contexts, INIT_ONE, model_number, qp);
00120 PBIARI_CTX_INIT2 (NUM_BLOCK_TYPES, NUM_ABS_CTX, tc->abs_contexts, INIT_ABS, model_number, qp);
00121 }
00122 }
00123