logo

English

How video compression works 2/5 - Quantization, coding, and prediction

by digipine posted Nov 02, 2017
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print Attachment
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print Attachment

Quantization, coding, and prediction 

Choosing the bits: quantization and coding
After the block transform is performed, the transform coefficients for each block are compressed using quantization and coding. Quantization reduces the precision of the transform coefficients in a biased manner: more bits are used for low-frequency coefficients and fewer bits for high-frequency coefficients. This takes advantage of the fact, as noted above, that human vision is more sensitive to low-frequency information, so the high-frequency information can be more approximate. Many bits are discarded in this step. For example, a 12-bit coefficient may be rounded to the nearest of 32 predetermined values. Each of these 32 values can be represented with a five-bit symbol. In the decompression algorithm, the coefficients are "dequantized"; i.e., the five-bit symbol is converted back to the 12-bit predetermined value used in the encoder. As illustrated in Figure 3, the dequantized coefficients are not equal to the original coefficients, but are close enough so that after the inverse transform is applied, the resulting image contains few or no visible artifacts.

 

 b03ecd45ee1305761fd63759f1cc7d94.gif

 


In older video algorithms, such as MPEG-2, dequantization can require anywhere from about 3% up to about 15% of the processor cycles spent in a video decoding application. Cycles spent on dequantization in modern video algorithms (such as H.264) are negligible, as are the memory requirements. 

Statistically Speaking
Next, the number of bits used to represent the quantized DCT coefficients is reduced by "coding," which takes advantage of some of the statistical properties of the coefficients. After quantization, many of the DCT coefficients—often, the vast majority of the high-frequency coefficients—are zero. A technique called "run-length coding" takes advantage of this fact by grouping consecutive zero-valued coefficients (a "run") and encoding the number of coefficients (the "length") instead of encoding the individual zero-valued coefficients. 


Run-length coding is typically followed by variable-length coding (VLC). In variable-length coding, commonly occurring symbols (representing quantized DCT coefficients or runs of zero-valued quantized coefficients) are represented using code words that contain only a few bits, while less common symbols are represented with longer code words. By using fewer bits for the most common symbols, VLC reduces the average number of bits required to encode a symbol thereby reducing the number of bits required to encode the entire image.

On the decompression side, variable-length decoding (VLD) reverses the steps performed by the VLC block in the compression algorithm. Variable-length decoding is much more computationally demanding than variable-length coding. VLC performs one table lookup per symbol (where a symbol is encoded using multiple bits); in contrast, the most straightforward implementation of VLD requires a table lookup and some simple decision making to be applied for each bit. VLD requires an average of about 11 operations per input bit. Thus, the processing requirements of VLD are proportional to the video codec's selected bit rate. VLD can consume as much as 25% of the cycles spent in a video decoder implementation.

In a typical video decompression algorithm, the straightforward VLD implementation described above (which operates on one bit at a time) requires several kilobytes of lookup table memory. It is possible to improve the performance of the VLD by operating on multiple bits at a time, but this optimization requires the use of much larger lookup tables.

Some of the newer standards (such as H.264) replace or augment the run-length coding and VLC techniques described above to achieve greater compression. For example, H.264 supports both CAVLC (context-adaptive VLC) and CABAC (context-adaptive arithmetic coding). CAVLC augments VLC by adapting the coding scheme based on previously-coded coefficients. CABAC replaces VLC entirely, using instead a more efficient—but also more computationally demanding—scheme of arithmetic coding. CABAC can consume as many as 50% of the cycles in an H.264 decoder.

Looking at a bigger picture
All of the techniques described so far operate on each 8x8 block independently from any other block. Since images typically contain features that are much larger than an 8x8 block, more efficient compression can be achieved by taking into account the similarities between adjacent blocks in the image.


To take advantage of inter-block similarities, a prediction step is often added prior to quantization of the transform coefficients. In this step, codecs attempt to predict the image information within a block using the information from the surrounding blocks. Some codecs (such as MPEG-4) perform this step in the frequency domain, by predicting DCT coefficients. Other codecs (such as H.264) do this step in the spatial domain, and predict pixels directly. The latter approach is called "intra prediction."

In this step, the encoder attempts 

 
TAG •

List of Articles
No. Subject Author Date Views
67 DaVinci 에 대한 소개글 digipine 2017.11.03 112
66 도커(Docker)와 쿠버네티스(Kubernetes)란 무엇인가? digipine 2021.10.20 159
65 트위터에서 다크모드 설정 방법 file digipine 2022.01.20 185
64 UC 환경을 위한 종합 네트워크 FMC digipine 2017.11.03 202
63 마이크로소프트, 차세대 운영체제 윈도우 11 공개 file digipine 2021.06.29 209
62 RFID와 USN 에 대해서 digipine 2017.11.03 226
61 애플, 서드파티 앱마켓 진출 허용하나 lizard2019 2022.12.18 237
60 차세대 비휘발성 메모리 기술동향 file digipine 2017.11.02 247
59 삼성전자 갤럭시 S22 발표, S펜을 탑재한 첫 S시리즈 file digipine 2022.02.10 249
58 Cubism Live2D Demo Windows D3D9 file lizard2019 2023.01.11 260
57 iOS 14.3 업데이트 릴리즈 file digipine 2020.12.16 266
56 애플 드디어 ARM 기반의 맥 출시 예정, 11월 10일 digipine 2020.11.09 300
55 딥마인드, 인간 개발자와 유사한 수준의 AI ‘알파코드’ 개발 file digipine 2022.02.03 302
54 퀄컴, 갤노트20 두뇌 '스냅드래곤865+' 공개 file digipine 2020.07.09 303
53 모바일 전용 CPU ARM이 노트북과 AI로 진화 한다 file digipine 2017.11.03 318
52 안드로이드 의 써드파티 어플의 SD RW 권한 부여 digipine 2017.11.03 336
51 HIGH QUALITY MOBILE EXPERIENCE (HQME) digipine 2017.11.03 339
50 구글 서비스, 데이터 유지 기간을 18개월로 조정 file digipine 2020.06.25 339
49 How video compression works 4/5 - Encoder secrets and motion compensation digipine 2017.11.02 340
48 IoT 악성 코드 "Mirai"변종이 급증 주의 file 엉뚱도마뱀 2017.11.28 344
Board Pagination Prev 1 2 3 ... 4 Next
/ 4