HEVC Entropy decoding Code Analysis-class structure (1)

Source: Internet
Author: User

Recently started to do HEVC, wherein the entropy decoding as the lowest part, because and H264 almost, the difficulty coefficient is not very big, mainly is some check table operation

The specific implementation principle is not detailed, mainly from the code to explain

First of all, the entropy decoding part of HM Engineering is analyzed as the guide, because it will be run on DSP and then rewritten as C code, and the process is stronger.


Code Analysis

First, we introduce several important structures and functions in entropy decoding.

One enters the main function, the most important is the corresponding decoding class Tappdectop

int main (int argc, char* argv[]) {  tappdectop  ctappdectop;

Tappdectop classThe main is the create and destroy related member functions, the really important decoding class is still in Tdectop, open the Tdectop class and see some of the more important modules of the class

  Tcomprediction          m_cprediction;  Tcomtrquant             m_ctrquant;  Tdecgop                 M_cgopdecoder;  Tdecslice               M_cslicedecoder;  TDECCU                  M_ccudecoder;  Tdecentropy             M_centropydecoder;  TDECCAVLC               M_ccavlcdecoder;  Tdecsbac                M_csbacdecoder;  Tdecbincabac            M_cbincabac;  Seireader               M_seireader;  Tcomloopfilter          M_cloopfilter;  Tcomsampleadaptiveoffset M_csao;

There are obviously several relationships with entropy decoding:

tdecentropy M_centropydecoder; Take a look at the member function

  Void init (tcomprediction* p) {m_pcprediction = P;}  Void decodepuwise (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth, tcomdatacu* PCSUBCU);  Void Decodeinterdirpu (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth, uint uipartidx);  Void Decodereffrmidxpu (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth, uint uipartidx, refpiclist ereflist);  Void Decodemvdpu (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth, uint uipartidx, refpiclist ereflist);  Void Decodemvpidxpu (tcomdatacu* PCSUBCU, uint uipartaddr, uint uidepth, uint uipartidx, refpiclist ereflist);  Void Setentropydecoder (tdecentropyif* p);                    Void Setbitstream (tcominputbitstream* p) {M_pcentropydecoderif->setbitstream (P);                    } Void resetentropy (tcomslice* p) {m_pcentropydecoderif->resetentropy (P); } Void Decodevps (tcomvps* Pcvps) {M_pcentropydecoderif->p Arsevps (PCVPS);  } Void Decodesps (tcomsps* pcsps) {M_pcentropydecoderif->parsesps (Pcsps);} Void Decodepps (tcompps* pcpps) {M_pcentropydecoderif->parsepps (Pcpps);}
It can be seen that some of the decoding module corresponding function function

But here is a more important thing to note is that the function of the corresponding decoding, not only will use the entropy decoding correlation method, there will be CAVLC decoding method, then how to distinguish it

Here is a C + + related knowledge, C + + class of the implementation of polymorphism

tdecentropyif* M_pcentropydecoderif;

Class Tdecentropyif{public://Virtual list for SBAC/CAVLC virtual Void resetentropy (tcomslice* pcslice)  = 0;  Virtual Void setbitstream (tcominputbitstream* p) = 0;  Virtual Void Parsevps (tcomvps* Pcvps) = 0;  Virtual Void Parsesps (tcomsps* Pcsps) = 0;  Virtual Void Parsepps (tcompps* Pcpps) = 0;  Virtual Void Parsesliceheader (tcomslice* pcslice, parametersetmanagerdecoder *parametersetmanager) = 0;  Virtual Void parseterminatingbit (uint& ruilslast) = 0;  Virtual Void parseremainingbytes (Bool notrailingbytesexpected) = 0; Virtual Void parsemvpidx (int& rimvpidx) = 0;public:virtual Void Parseskipflag (tcomdatacu* PcCU, UIn  T Uiabspartidx, UInt uidepth) = 0;  Virtual Void Parsecutransquantbypassflag (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0; Virtual Void Parsesplitflag (TComdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void Parsepltmodeflag (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void parsepltmodesyntax (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth, uint uinumcomp) = 0;  Virtual Void Parsepltsharingmodeflag (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void Parsescanrotationmodeflag (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void Parsemergeflag (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth, uint uipuidx) = 0;  Virtual Void parsemergeindex (tcomdatacu* PcCU, uint& ruimergeindex) = 0;  Virtual Void parsepartsize (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void parsepartsizeintrabc (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void Parsepredmode (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0; Virtual Void Parseintradirlumaang (tcomdatacu* PcCU, UInt uiabsparTIDX, UInt uidepth) = 0;  Virtual Void parseintradirchroma (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void Parseintrabcflag (tcomdatacu* PcCU, uint uiabspartidx, uint uipartidx, uint uidepth) = 0;  Virtual Void parseintrabc (tcomdatacu* PcCU, uint uiabspartidx, uint uipartidx, uint uidepth) = 0; Virtual Void PARSEINTRABCBVD (tcomdatacu* PcCU, uint uiabspartaddr, uint uipartidx, uint uidepth, Refpiclist ereflist  ) = 0;  Virtual Void parseinterdir (tcomdatacu* PcCU, uint& ruiinterdir, UInt uiabspartidx) = 0;  Virtual Void parsereffrmidx (tcomdatacu* PcCU, int& rireffrmidx, refpiclist ereflist) = 0; Virtual Void PARSEMVD (tcomdatacu* PcCU, uint uiabspartaddr, uint uipartidx, uint uidepth, Refpiclist ereflist  ) = 0;  Virtual Void parsecrosscomponentprediction (class Tcomtu &rtu, ComponentID compid) = 0;  Virtual Void Parsetransformsubdivflag (uint& ruisubdivflag, UInt uilog2transformblocksize) = 0; VirtuAl Void PARSEQTCBF (tcomtu &rtu, const ComponentID compid, const Bool lowestlevel) = 0;  Virtual Void Parsecolourtransformflag (UInt uiabspartidx, bool& uiflag) = 0;  Virtual Void PARSEQTROOTCBF (UInt uiabspartidx, uint& UIQTROOTCBF) = 0;  Virtual Void parsedeltaqp (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void parsechromaqpadjustment (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void parseipcminfo (tcomdatacu* PcCU, uint uiabspartidx, uint uidepth) = 0;  Virtual Void Parsecoeffnxn (class Tcomtu &rtu, ComponentID compid) = 0;  Virtual Void parsetransformskipflags (class Tcomtu &rtu, ComponentID component) = 0;  Virtual Void Parseexplicitrdpcmmode (tcomtu &rtu, ComponentID compid) = 0; Virtual ~tdecentropyif () {}};

This class is a virtual member function, which is to select the appropriate decoding method by passing in the class-specific inheritance class.

Void Setentropydecoder (tdecentropyif* p);

Like what

Class Tdecsbac:public Tdecentropyif

Class Tdeccavlc:public Syntaxelementparser, public tdecentropyif

So the upper class is almost there.

The two most relevant classes of entropy decoding:

  Tdecsbac                M_csbacdecoder;  Tdecbincabac            M_cbincabac;

which TdecsbacM_csbacdecoder is a slice that contains all the functions of a solution module, including

  Void Load (const tdecsbac* PSRC);  Void loadcontexts (const tdecsbac* PSRC);  Void xcopyfrom (const tdecsbac* PSRC);  Void xcopycontextsfrom (const tdecsbac* PSRC);  Void resetentropy (tcomslice* pslice);  Void Setbitstream (tcominputbitstream* p) {m_pcbitstream = P; m_pctdecbinif->init (P);}   void Parsevps (tcomvps*/*pcvps*/) {} void Parsesps (tcomsps*/*pcsps*/) {} void Parsepps (tcompps*/*pcpps*/) {} Void Parsesliceheader (tcomslice*/*pcslice*/, Parameter  setmanagerdecoder*/*parametersetmanager*/) {} Void parseterminatingbit (uint& ruibit);  Void parseremainingbytes (Bool notrailingbytesexpected);  Void Parsemvpidx (int& rimvpidx);  Void PARSESAOMAXUVLC (uint& val, UInt Maxsymbol);  Void Parsesaomerge (uint& ruival); Void  Parsesaotypeidx (uint& ruival);  Void PARSESAOUFLC (UInt uilength, uint& ruival); Void Parsesaoblkparam (saoblkparam& saoblkparam, bool* sliceenabled, bool leftmergeavail, BOOL Abovemergeava  IL); Void parsesaosign (uint& val);

Code stream acquisition, the underlying entropy decoding a bit, according to the bit data inverse binary operation, and finally solve the syntax element corresponding value


The Tdecbincabac class is the lowest level in entropy decoding and the function of decoding the corresponding 1 bit data from the code stream.

Which is the lowest level of arithmetic decoding.

  Void  decodebin         (uint& ruibin, contextmodel& rcctxmodel);  Void  Decodebinep       (uint& ruibin                           );  Void  decodebinsep      (uint& ruibin, Int numbins              );  void  decodealignedbinsep (uint& ruibins, Int numbins             ), #endif  void  align             ();  Void  decodebintrm      (uint& ruibin                           );  Void  xreadpcmcode      (UInt uilength, uint& ruicode);  Void  copystate         (const tdecbinif* pctdecbinif);  tdecbincabac* Gettdecbincabac ()             {return this;}  Const tdecbincabac* GETTDECBINCABAC () const {return this;} Private:  tcominputbitstream* M_pctcombitstream;  UInt                M_uirange;  UInt                M_uivalue;  Int                 m_bitsneeded;};

To summarize:

The class structure in HM and entropy decoding is basically listed as follows:

Tappdectop

Tdectop

Tdecentropy

Tdecsbac

Tdecbincabac


HEVC Entropy decoding Code Analysis-class structure (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.