The official software JM source code simple analysis-Decoder ldecod

Source: Internet
Author: User

A while ago looked at the official reference software JM of the source code, here to summarize its structure. JM codec the speed is very slow relative to the ffmpeg, but its code is written clearly and understandable, more suitable for academic research. JM contains video decoder ldecod and video encoder lencod. This document records the structure of the video decoder ldecod.

Function call diagram The function call diagram for the H. Ldecod Video Decoder in JM is shown below.
Click to see a larger image
The following explains the meaning of a key marker.

function background Color
The function is shown as a box in the diagram. Different background colors mark the different functions of the function:
function on white background: normal inner function.
Pink background function: analytic function (Parser). These functions are used to parse information such as SPS, PPS, and so on.
function of the purple background: Entropy decoding function (Entropy decoding). These functions read the bitstream data and perform CABAC or CAVLC entropy decoding.
Function of the green background: decoding function (Decode). These functions decode compressed data through intra-frame prediction, inter-frame prediction, and DCT inverse transformation.

function of the yellow background: loop filter function (loops filter). These functions filter the decoded data to remove the block effect.


Arrow Line
The Arrow line flags the function's call relationship:
Black Arrow Line: an indiscriminate call relationship.
Pink Arrow Line: The call relationship between analytic functions (Parser).
Purple Arrow Line: The call relationship between the Entropy decoding function (Entropy decoding).
Green Arrow Line: The call relationship between decoding functions (Decode).
Yellow Arrow Line: The call relationship between loop filter function (loop filter).

The file where the function resides
Each function identifies the file path in which it resides.

Several key sections in the chart are documented below.

Ordinary intrinsic functions refer to functions that are not yet classified in ldecod. For example:
The decoder's main () function calls the parameter configuration function configure (), the Open decoder function opendecoder (), the decoding function Decodeoneframe (), the output function writeoneframe (), Turn off the decoder function closedecoder () and so on.
Decoder main decoding function decodeoneframe () layer-by-call functions Decode_one_frame (), Decode_slice (), Decode_one_slice (), and so on.

analytic functions (Parser)The Analytic function (Parser) is used to parse some of the information in the code stream (e.g., SPS, PPS, Slice header, etc.). These parsing functions are called in Read_new_slice () to complete the parsing. Here are some examples of analytic functions.
Read_next_nalu (): Parse Nalu. This function is the precondition of the latter several analytic functions.
Processpps (): resolves slice Header. where Interpretpps () is called to parse pps.
Processsps (): Parse sei. where Interpretsps () is called to resolve the SPS.
where Read_next_nalu () calls the following functions:
Get_annex_b_nalu (): Read Nalu in ANNEXB format.
Getrtpnalu (): reads the NALU of the RTP format.
NALUTORBSP (): Nalu is processed into rbsp format.
(PS:ANNEXB and RTP are the 2 formats of the H-code stream)

entropy decoding function (Entropy decoding)The Entropy decoding function (Entropy decoding) reads the bitstream data and decodes Cabac or CAVLC entropy. The entropy decoding work is done in the Read_one_macroblock () function of the slice structure. This function calls different entropy decoding functions depending on the type of macro block. CAVLC corresponding decoding functions are:
READ_ONE_MACROBLOCK_P_SLICE_CAVLC (): Decode P macro block.
READ_ONE_MACROBLOCK_B_SLICE_CAVLC (): Decode the B macro block.
READ_ONE_MACROBLOCK_I_SLICE_CAVLC (): Decode the I macro block.
CABAC corresponding decoding functions are:
Read_one_macroblock_p_slice_cabac (): Decode P macro block.
Read_one_macroblock_b_slice_cabac (): Decode the B macro block.
Read_one_macroblock_i_slice_cabac (): Decode the I macro block.

decoding function (Decode)decoding function (Decode) is used to decode macro-block compression data through intra-frame prediction and inter-frame prediction. The decoding work is done in Decode_one_macroblock (). Decode_one_macroblock () calls the Decode_one_component () in the slice struct to decode a luminance component. Decode_one_component () Different handler functions are called depending on the slice that the macro block is located in:
Decode_one_component_i_slice (): Decodes the macro block in the I slice.
Decode_one_component_p_slice (): Decodes the macro block in P slice.
Decode_one_component_b_slice (): Decodes the macro block in B slice.
I slice contains only macro blocks of type intra. So Decode_one_component_i_slice () calls the following function to decode the intra Type macro block:
mb_pred_intra16x16 (): Intra-frame prediction 16X16 Macro block
mb_pred_intra4x4 (): In-frame predictive 4x4 macro block
mb_pred_intra8x8 (): Intra-frame predictive 8x8 macro block
P slice contains macro blocks of type intra and inter type (unidirectional). So Decode_one_component_p_slice () calls the following function to decode the intra Type macro block:
mb_pred_intra16x16 (): Ibid.
mb_pred_intra4x4 (): Ibid.
mb_pred_intra8x8 (): Ibid.
mb_pred_p_inter16x16 (): One-way inter-frame prediction 16X16 Macro block
mb_pred_p_inter16x8 (): One-way inter-frame Prediction 16X8 macro block
mb_pred_p_inter8x16 (): One-way inter-frame prediction 8X16 macro block
mb_pred_p_inter8x8 (): One-way inter-frame Prediction 8x8 macro Block
B slice contains macro blocks of type intra and inter type (bidirectional). So the function called by Decode_one_component_b_slice () is similar to the macro block in P slice, except that it increases the processing of the B macro block.
For INTRA16X16 macro blocks with progressive scan, the specific Predictor function is Intra_pred_16x16_normal (), which calls different functions for processing depending on the type of prediction in the frame:
intra16x16_vert_pred (): Vertical mode
Intra16x16_hor_pred (): Horizontal mode
Intra16x16_dc_pred (): DC mode
Intra16x16_plane_pred (): Plane mode
For the P-type macro block of progressive-scan inter16x16, the specific Predictor function is mb_pred_p_inter16x16 (), where PERFORM_MC () is called to complete motion compensation. For one-way motion compensation, PERFORM_MC () calls Perform_mc_single (), and for bidirectional motion compensation, PERFORM_MC () invokes Perform_mc_bi (). During motion compensation, Get_block_luma () is called to complete the interpolation work of one-fourth pixels.
Regardless of the inter type macro block or the intra type macro block, the final call to imbtrans4x4 () completes the DCT inverse transformation and residuals overlay work. Where the DCT inverse transform is done in inverse4x4 (), and the residuals are superimposed in sample_reconstruct ().

Loop Filter function (loops filter)The Loop filter function filters the decoded data to remove the block effect. The de-block effect filter is done in Deblockpicture (). Deblockpicture () called DEBLOCKMB (). In DEBLOCKMB (), the Getstrengthver (), Getstrengthhor () function is called to get the filtering strength; call Edgelooplumaver (), Edgelooplumahor () to filter.




Lei Huawei
[Email protected]
http://blog.csdn.net/leixiaohua1020








Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The official software JM source code simple analysis-Decoder ldecod

Related Article

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.