📄 putvlc.c
字号:
}
else if (run > 9 && run < 13 && level < 3)
{
BitstreamPutBits(bitstream, (LInt)coeff_RVLCtab8[run-10][level-1].code,
(LInt)coeff_RVLCtab8[run-10][level-1].len);
length = coeff_RVLCtab8[run-10][level-1].len;
}
else if (run > 12 && run < 20 && level == 1)
{
BitstreamPutBits(bitstream, (LInt)coeff_RVLCtab9[run-13].code,
(LInt)coeff_RVLCtab9[run-13].len);
length = coeff_RVLCtab9[run-13].len;
}
}
else if (last == 1)
{
if (run >= 0 && run < 2 && level < 6)
{
BitstreamPutBits(bitstream, (LInt)coeff_RVLCtab10[run][level-1].code,
(LInt)coeff_RVLCtab10[run][level-1].len);
length = coeff_RVLCtab10[run][level-1].len;
}
else if (run == 2 && level < 4)
{
BitstreamPutBits(bitstream, (LInt)coeff_RVLCtab11[level-1].code,
(LInt)coeff_RVLCtab11[level-1].len);
length = coeff_RVLCtab11[level-1].len;
}
else if (run > 2 && run < 14 && level < 3)
{
BitstreamPutBits(bitstream, (LInt)coeff_RVLCtab12[run-3][level-1].code,
(LInt)coeff_RVLCtab12[run-3][level-1].len);
length = coeff_RVLCtab12[run-3][level-1].len;
}
else if (run > 13 && run < 46 && level == 1)
{
BitstreamPutBits(bitstream, (LInt)coeff_RVLCtab13[run-14].code,
(LInt)coeff_RVLCtab13[run-14].len);
length = coeff_RVLCtab13[run-14].len;
}
}
return length;
}
/* The following is for 3-mode VLC */
Int
PutRunCoeff_Inter(Int run, Int level, Int last, Image *bitstream)
{
Int length = 0;
MOMCHECK (last >= 0 && last < 2);
MOMCHECK (run >= 0 && run < 64);
MOMCHECK (level > 0 && level < 128);
if (last == 0)
{
if (run < 2 && level < 13 )
{
length = coeff_tab0[run][level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab0[run][level-1].code,
(LInt)coeff_tab0[run][level-1].len);
}
}
else if (run > 1 && run < 27 && level < 5)
{
length = coeff_tab1[run-2][level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab1[run-2][level-1].code,
(LInt)coeff_tab1[run-2][level-1].len);
}
}
}
else if (last == 1)
{
if (run < 2 && level < 4)
{
length = coeff_tab2[run][level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab2[run][level-1].code,
(LInt)coeff_tab2[run][level-1].len);
}
}
else if (run > 1 && run < 42 && level == 1)
{
length = coeff_tab3[run-2].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab3[run-2].code,
(LInt)coeff_tab3[run-2].len);
}
}
}
return length;
}
Int
PutRunCoeff_Intra(Int run, Int level, Int last, Image *bitstream)
{
Int length = 0;
MOMCHECK (last >= 0 && last < 2);
MOMCHECK (run >= 0 && run < 64);
MOMCHECK (level > 0 && level < 128);
if (last == 0)
{
if (run == 0 && level < 28 )
{
length = coeff_tab4[level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab4[level-1].code,
(LInt)coeff_tab4[level-1].len);
}
}
else if (run == 1 && level < 11)
{
length = coeff_tab5[level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab5[level-1].code,
(LInt)coeff_tab5[level-1].len);
}
}
else if (run > 1 && run < 10 && level < 6)
{
length = coeff_tab6[run-2][level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab6[run-2][level-1].code,
(LInt)coeff_tab6[run-2][level-1].len);
}
}
else if (run > 9 && run < 15 && level == 1)
{
length = coeff_tab7[run-10].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab7[run-10].code,
(LInt)coeff_tab7[run-10].len);
}
}
}
else if (last == 1)
{
if (run == 0 && level < 9)
{
length = coeff_tab8[level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab8[level-1].code,
(LInt)coeff_tab8[level-1].len);
}
}
else if (run > 0 && run < 7 && level < 4)
{
length = coeff_tab9[run-1][level-1].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab9[run-1][level-1].code,
(LInt)coeff_tab9[run-1][level-1].len);
}
}
else if (run > 6 && run < 21 && level == 1)
{
length = coeff_tab10[run-7].len;
if (length != 0)
{
/* boon 120697 */
BitstreamPutBits(bitstream, 3L, 7L);
/* boon 120697 */
BitstreamPutBits(bitstream, 2L, 2L);
length += 9; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab10[run-7].code,
(LInt)coeff_tab10[run-7].len);
}
}
}
return length;
}
Int
PutLevelCoeff_Inter(Int run, Int level, Int last, Image *bitstream)
{
Int length = 0;
MOMCHECK (last >= 0 && last < 2);
MOMCHECK (run >= 0 && run < 64);
MOMCHECK (level > 0 && level < 128);
if (last == 0)
{
if (run < 2 && level < 13 )
{
length = coeff_tab0[run][level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab0[run][level-1].code,
(LInt)coeff_tab0[run][level-1].len);
}
}
else if (run > 1 && run < 27 && level < 5)
{
length = coeff_tab1[run-2][level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab1[run-2][level-1].code,
(LInt)coeff_tab1[run-2][level-1].len);
}
}
}
else if (last == 1)
{
if (run < 2 && level < 4)
{
length = coeff_tab2[run][level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab2[run][level-1].code,
(LInt)coeff_tab2[run][level-1].len);
}
}
else if (run > 1 && run < 42 && level == 1)
{
length = coeff_tab3[run-2].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits (bitstream, (LInt)coeff_tab3[run-2].code,
(LInt)coeff_tab3[run-2].len);
}
}
}
return length;
}
Int
PutLevelCoeff_Intra(Int run, Int level, Int last, Image *bitstream)
{
Int length = 0;
MOMCHECK (last >= 0 && last < 2);
MOMCHECK (run >= 0 && run < 64);
MOMCHECK (level > 0 && level < 128);
if (last == 0)
{
if (run == 0 && level < 28 )
{
length = coeff_tab4[level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab4[level-1].code,
(LInt)coeff_tab4[level-1].len);
}
}
else if (run == 1 && level < 11)
{
length = coeff_tab5[level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab5[level-1].code,
(LInt)coeff_tab5[level-1].len);
}
}
else if (run > 1 && run < 10 && level < 6)
{
length = coeff_tab6[run-2][level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab6[run-2][level-1].code,
(LInt)coeff_tab6[run-2][level-1].len);
}
}
else if (run > 9 && run < 15 && level == 1)
{
length = coeff_tab7[run-10].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab7[run-10].code,
(LInt)coeff_tab7[run-10].len);
}
}
}
else if (last == 1)
{
if (run == 0 && level < 9)
{
length = coeff_tab8[level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab8[level-1].code,
(LInt)coeff_tab8[level-1].len);
}
}
else if (run > 0 && run < 7 && level < 4)
{
length = coeff_tab9[run-1][level-1].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab9[run-1][level-1].code,
(LInt)coeff_tab9[run-1][level-1].len);
}
}
else if (run > 6 && run < 21 && level == 1)
{
length = coeff_tab10[run-7].len;
if (length != 0)
{
BitstreamPutBits(bitstream, 3L, 7L);
/* boon19970701 */
BitstreamPutBits(bitstream, 0L, 1L);
length += 8; /* boon */
BitstreamPutBits(bitstream, (LInt)coeff_tab10[run-7].code,
(LInt)coeff_tab10[run-7].len);
}
}
}
return length;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -