📄 dec_cavlc.c
字号:
5, 5, 5, 5,
4, 4, 4, 4, 4, 4, 4, 4
};
static const uint8_t prefix_table2[] =
{
-1,
11,
10, 10,
9, 9, 9, 9,
8, 8, 8, 8, 8, 8, 8, 8
};
static const uint8_t prefix_table3[] =
{
-1,
15,
14, 14,
13, 13, 13, 13,
12, 12, 12, 12, 12, 12, 12, 12
};
#undef VLC
#undef VLC2
#undef VLC4
#define VLC(a, b) {a, b}
#define VLC2(a, b) VLC(a, b), VLC(a, b)
#define VLC4(a, b) VLC2(a, b), VLC2(a, b)
#define VLC8(a, b) VLC4(a, b), VLC4(a, b)
typedef struct
{
uint8_t num;
uint8_t len;
} zero_count_t;
static const zero_count_t total_zero_table1_0[] =
{
VLC(-1, -1),
VLC(15, 9), /* 0000 0000 1 */
VLC(14, 9),
VLC(13, 9), /* 0000 0001 1 */
VLC2(12, 8),/* 0000 0010 */
VLC2(11, 8),/* 0000 0011 */
VLC4(10, 7),/* 0000 010 */
VLC4(9, 7), /* 0000 011 */
VLC8(8, 6), /* 0000 10 */
VLC8(7, 6), /* 0000 11 */
};
static const zero_count_t total_zero_table1_1[] =
{
VLC2(-1, -1),
VLC(6, 5), /* 0001 0 */
VLC(5, 5), /* 0001 1 */
VLC2(4, 4),/* 0010 */
VLC2(3, 4),/* 0011 */
VLC4(2, 3),/* 010 */
VLC4(1, 3),/* 011 */
VLC8(0, 1), /*1 */
VLC8(0, 1), /*1 */
};
static const zero_count_t total_zero_table2_0[] =
{
VLC(14, 6), /* 0000 00 */
VLC(13, 6),
VLC(12, 6),
VLC(11, 6),
VLC2(10, 5),/* 0001 0 */
VLC2(9, 5),
};
static const zero_count_t total_zero_table2_1[] =
{
VLC2(-1, -1),
VLC(8, 4), /* 0010 */
VLC(7, 4), /* 0011 */
VLC(6, 4),
VLC(5, 4),
VLC2(4, 3),/* 011 */
VLC2(3, 3),/* 100 */
VLC2(2, 3), /*101 */
VLC2(1, 3), /*110 */
VLC2(0, 3), /*111 */
};
static const zero_count_t total_zero_table3_0[] =
{
VLC(13, 6), /* 0000 00 */
VLC(11, 6),
VLC2(12, 5),/* 0000 1 */
VLC2(10, 5),/* 0001 0 */
VLC2(9, 5), /* 0001 1 */
};
static const zero_count_t total_zero_table3_1[] =
{
VLC2(-1, -1),
VLC(8, 4), /* 0010 */
VLC(5, 4), /* 0011 */
VLC(4, 4),
VLC(0, 4),
VLC2(7, 3),/* 011 */
VLC2(6, 3),/* 100 */
VLC2(3, 3), /*101 */
VLC2(2, 3), /*110 */
VLC2(1, 3), /*111 */
};
static const zero_count_t total_zero_table6_0[] =
{
VLC(10, 6), /* 0000 00 */
VLC(0, 6),
VLC2(1, 5),/* 0000 1 */
VLC4(8, 4),/* 0000 1 */
};
static const zero_count_t total_zero_table6_1[] =
{
VLC(-1, -1),
VLC(9, 3), /* 001 */
VLC(7, 3), /* 010 */
VLC(6, 3),
VLC(5, 3),
VLC(4, 3),
VLC(3, 3),
VLC(2, 3)
};
static const zero_count_t total_zero_table7_0[] =
{
VLC(9, 6), /* 0000 00 */
VLC(0, 6),
VLC2(1, 5),/* 0000 1 */
VLC4(7, 4),/* 0001 */
};
static const zero_count_t total_zero_table7_1[] =
{
VLC(-1, -1),
VLC(8, 3), /* 001 */
VLC(6, 3), /* 010 */
VLC(4, 3),
VLC(3, 3),
VLC(2, 3),
VLC2(5, 2)
};
static const zero_count_t total_zero_table8_0[] =
{
VLC(8, 6), /* 0000 00 */
VLC(0, 6),
VLC2(2, 5),/* 0000 1 */
VLC4(1, 4),/* 0001 */
};
static const zero_count_t total_zero_table8_1[] =
{
VLC(-1, -1),
VLC(7, 3), /* 001 */
VLC(6, 3), /* 010 */
VLC(3, 3),
VLC2(5, 2),
VLC2(4, 2)
};
static const zero_count_t total_zero_table9_0[] =
{
VLC(1, 6), /* 0000 00 */
VLC(0, 6),
VLC2(7, 5),/* 0000 1 */
VLC4(2, 4),/* 0001 */
};
static const zero_count_t total_zero_table9_1[] =
{
VLC(-1, -1),
VLC(5, 3), /* 001 */
VLC2(6, 2), /* 01 */
VLC2(4, 2),
VLC2(3, 2),
};
static const zero_count_t total_zero_table4_0[] =
{
VLC(12, 5), /* 0000 0 */
VLC(11, 5),
VLC(10, 5), /* 0000 1 */
VLC(0, 5), /* 0001 1 */
VLC2(9, 4), /* 0010 */
VLC2(7, 4),
VLC2(3, 4),
VLC2(2, 4), /* 0101 */
VLC4(8, 3), /* 011 */
};
static const zero_count_t total_zero_table4_1[] =
{
VLC(6, 3), /* 100 */
VLC(5, 3), /* 101 */
VLC(4, 3), /* 110 */
VLC(1, 3) /* 111 */
};
static const zero_count_t total_zero_table5_0[] =
{
VLC(11, 5), /* 0000 0 */
VLC(9, 5),
VLC2(10, 4), /* 0000 1 */
VLC2(8, 4), /* 0010 */
VLC2(2, 4),
VLC2(1, 4),
VLC2(0, 4),
VLC4(7, 3)
};
static const zero_count_t total_zero_table5_1[] =
{
VLC(6, 3), /* 100 */
VLC(5, 3),
VLC(4, 3),
VLC(3, 3)
};
static const zero_count_t total_zero_table10_0[] =
{
VLC(1, 5), /* 0000 0 */
VLC(0, 5),
VLC2(6, 4), /* 0000 1 */
};
static const zero_count_t total_zero_table10_1[] =
{
VLC(-1, -1),
VLC(2, 3), /* 001 */
VLC2(5, 2), /* 01 */
VLC2(4, 2),
VLC2(3, 2),
};
static const zero_count_t total_zero_table11_0[] =
{
VLC(0, 4), /* 0000 */
VLC(1, 4),
VLC2(2, 3), /* 010 */
VLC2(3, 3),
VLC2(5, 3),
VLC8(4, 1)
};
static const zero_count_t total_zero_table12_0[] =
{
VLC(0, 4), /* 0000 */
VLC(1, 4),
VLC2(4, 3), /* 010 */
VLC4(2, 2),
VLC8(3, 1)
};
static const zero_count_t total_zero_table13_0[] =
{
VLC(0, 3), /* 000 */
VLC(1, 3),
VLC2(3, 2), /* 01 */
VLC4(2, 1),
};
static const zero_count_t total_zero_table14_0[] =
{
VLC(0, 2),
VLC(1, 2),
VLC2(2, 1),
};
static const zero_count_t total_zero_table_chroma[3][8] =
{
{
VLC(3, 3),
VLC(2, 3),
VLC2(1, 2),
VLC4(0, 1)
},
{
VLC2(2, 2),
VLC2(1, 2),
VLC4(0, 1)
},
{
VLC4(1, 1),
VLC4(0, 1)
}
};
static const zero_count_t run_before_table_0[7][8] =
{
{
VLC4(1, 1),
VLC4(0, 1)
},
{
VLC2(2, 2),
VLC2(1, 2),
VLC4(0, 1)
},
{
VLC2(3, 2),
VLC2(2, 2),
VLC2(1, 2),
VLC2(0, 2)
},
{
VLC(4, 3),
VLC(3, 3),
VLC2(2, 2),
VLC2(1, 2),
VLC2(0, 2)
},
{
VLC(5, 3),
VLC(4, 3),
VLC(3, 3),
VLC(2, 3),
VLC2(1, 2),
VLC2(0, 2),
},
{
VLC(1, 3),
VLC(2, 3),
VLC(4, 3),
VLC(3, 3),
VLC(6, 3),
VLC(5, 3),
VLC2(0, 2)
},
{
VLC(-1, -1),
VLC(6, 3),
VLC(5, 3),
VLC(4, 3),
VLC(3, 3),
VLC(2, 3),
VLC(1, 3),
VLC(0, 3)
}
};
static const uint8_t run_before_table_1[] =
{
-1,
10,
9, 9,
8, 8, 8, 8,
7, 7, 7, 7, 7, 7, 7, 7
};
static const uint8_t run_before_table_2[] =
{
-1,
14,
13, 13,
12, 12, 12, 12,
11, 11, 11, 11, 11, 11, 11, 11
};
/* -- cavlc tables -- */
static void __inline
T264_mb_read_cavlc_i4x4_mode(T264_t* t)
{
int32_t i, j;
int32_t x, y;
int8_t* p = t->mb.i4x4_pred_mode_ref;
for(i = 0 ; i < 16 ; i ++)
{
int8_t pred;
j = luma_index[i];
pred = T264_mb_predict_intra4x4_mode(t, i);
/* prev_intra4x4_pred_mode_flag */
if (eg_read_direct1(t->bs))
{
t->mb.mode_i4x4[i] = pred;
}
else
{
int32_t mode = eg_read_direct(t->bs, 3);
if (mode < pred)
{
t->mb.mode_i4x4[i] = mode;
}
else
{
t->mb.mode_i4x4[i] = mode + 1;
}
}
x = j % 4;
y = j / 4;
p[IPM_LUMA + y * 8 + x] = t->mb.mode_i4x4[i];
}
}
/* nC == -1 */
void
T264dec_mb_read_coff_token_t4(T264_t* t, uint8_t* trailing_ones, uint8_t* total_coff)
{
int32_t code;
code = eg_show(t->bs, 8);
if (code >= 16)
{
if (code >= 128)
{
/* 1 */
*trailing_ones = 1;
*total_coff = 1;
eg_read_skip(t->bs, 1);
}
else if (code >= 64)
{
/* 01 */
*trailing_ones = 0;
*total_coff = 0;
eg_read_skip(t->bs, 2);
}
else if (code >= 32)
{
/* 001 */
*trailing_ones = 2;
*total_coff = 2;
eg_read_skip(t->bs, 3);
}
else
{
code = (code >> 2) - 4;
*trailing_ones = coeff4_0[code].trailing_ones;
*total_coff = coeff4_0[code].total_coeff;
eg_read_skip(t->bs, 6);
}
}
else
{
*trailing_ones = coeff4_1[code].trailing_ones;
*total_coff = coeff4_1[code].total_coeff;
eg_read_skip(t->bs, coeff4_1[code].len);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -