Exponential Columbus code in H.264

Source: Internet
Author: User

An important feature of H.264 is the use of UVLC (Universal Variable Length Coding, unified Variable Length Encoding) encoding, which improves the coding efficiency.

One of UVLC encoding methods is exponential Columbus encoding. The program needs to calculate the coding length Len and its value when implementing this encoding. The following analyzes the unsigned and signed exponent Columbus encoding respectively.

Set the encoding value to code_val.

Static const int I _size0_255 [1, 256] =
{
,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7,
7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7, 7,7,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8
};

Void bs_write (bs_t * s, int bit_len, int value );

1. UE (V)

1) value = code_val + 1 2) Len = 2 * I _size0_255 [value] + 1 Programming implementation is as follows:

Void ue_v (bs_t * s, unsigned int code_val)
{
Int I _size = 0;
If (val = 0)
{
Bs_write (s, 1, 1 );
}
Else
{
Unsigned int TMP = ++ code_val; If (TMP> = 0x00010000)
{
I _size + = 16;
TMP> = 16;
}
If (TMP> = 0x100)
{
I _size + = 8;
TMP> = 8;
}
I _size + = I _size0_255 [TMP]; bs_write (S, 2 * I _size-1, code_val );
}
}

2. Se (V)

1) if code_val> 0: value = 2 * code_val-1 if code_val> 0: value =-2 * val 2) Len = 2 * I _size0_255 [value] + 1 Programming implementation is as follows:

Static void se_v (bs_t * s, int code_val)
{
Ue_v (S, code_val <= 0? -Code_val * 2: code_val * 2-1 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.