CABAC编码协议详细分析(初稿)

合集下载

cabac编码过程的解读

cabac编码过程的解读

cabac编码过程的解读cabac编码过程的解读CABAC是H.264/AVC标准中两种熵编码方法中的一种,是将自适应的二进制算术编码与一个设计精良的上下文模型结合起来得到的方法。

它很好地利用了语法元素数值之间的高阶信息,使得熵编码的效率得到了进一步提高。

它的主要特点有:利用每个语法元素的上下文关系,根据已编码元素为待编码元素选择概率模型,即上下文建模;根据当前的统计特性自适应地进行概率估计;使用算术编码。

[5] 在CABAC中编码一个单独的句法元素的通用方框图。

这个编码过程主要由三个基本步骤组成:1、二值化;2、上下文建模;3、基于表格的二进制算术编码。

在第一步,一个给出的非二进制值的句法元素唯一地对应到一个二进制序列,叫二进制串。

当给出一个二进制值的句法元素时,这一初始步骤将被跳过,如图1所示。

对于每个元素的二进制串或每个二进制值的句法元素,后面会根据编码模式有一两个子步骤。

接下来就是对二元数据进行编码,标准中有两种编码模式可供选择。

在常规编码模式(regular coding mode)中,一个句法元素的每一个二进值(bin)按其判决产生的顺序进入上下文模型器,在这里,模型器根据已经编码过的句法元素或二进值为每一个输入的二进值分配一个概率模型,这就是上下文模型化。

然后该二进值和分配给它的概率模型一起被送进常规算术编码器进行编码,此外编码器还要根据该二元位的值反馈一个信息给上下文模型器,用以更新上下文模型,这就是编码中的自适应;另一种模式是旁路编码模式(bypass coding mode),在该模式中,没有模型器为每个二进值分配一个特定的概率模型,输入的二元数据是直接用一个简单的旁路编码器进行编码的,这样做是为了加快整个编码(以及另一端解码)的速度,当然,该模式只用于某些特殊的二进值。

后面将更加详细地讨论二值化,上下文建模与基于表格的二进制算术编码这三个主要步骤以及它们之间的相互联系。

2.2二值化CABAC的二值化方案有四种基本类型:一元码,截断一元码,k 阶指数哥伦布编码,与定长编码。

CABAC

CABAC

Context-Based Adaptive Binary Arithmetic Coding in the H.264/A VC简称Cabac,H264中的一种熵编码方式:基于上下文的自适应二进制算术编码内容安排:1,介绍算术编码2,介绍二进制算术编码3介绍Cabac及其一些实用的实现方式(参考JSVM代码,也可以参考JM)---张新发一,算术编码算术编码是一种常用的变字长编码,它是利用信源概率分布特性、能够趋近熵极限的编码方法。

它与Huffman 一样,也是对出现概率大的符号赋予短码,对概率小的符号赋予长码。

但它的编码过程与Huffman 编码却不相同,而且在信源概率分布比较均匀的情况下其编码效率高于Huffman 编码。

它和Huffman 编码最大的区别在于它不是使用整数码。

Huffman 码是用整数长度的码字来编码的最佳方法,而算法编码是一种并不局限于整数长度码字的最佳编码方法。

算术编码是把各符号出现的概率表示在单位概率[0,1] 区间之中,区间的宽度代表概率值的大小。

符号出现的概率越大对应于区间愈宽,可用较短码字表示;符号出现概率越小对应于区间愈窄,需要较长码字表示。

举例如下:S S S S为例以符号3324在算术编码中通常采用二进制分数表示概率,每个符号所对应的概率区间都是半开区间,即该区间包括左端点,而不包括右端点,如S1对应[0, 0.001),S2 对应[0.001, 0.01) 等。

算术编码产生的码字实际上是一个二进制数值的指针,指向所编的符号对应的概率区间。

S S S S…… 的第一个符号S3 用指向第3 个子区间的指针 符号序列3324来代表,可以用这个区间内的任意一个小数来表示这个指针,这里约定这个区间的左端点代表这个指针,因此得到第一个码字.011。

⏹后续的编码将在前面编码指向的子区间内进行,将[.011, .111] 区间再按概率大小划分为 4 份,第二个符号S3 指向.1001 (S3 区间的左端),输出码字变为.1001。

CABAC 上下文自适应算术编码

CABAC 上下文自适应算术编码

High Throughput CABAC EntropyCoding in HEVCVivienne Sze,Member,IEEE,and Madhukar Budagavi,Senior Member,IEEEAbstract—Context-adaptive binary arithmetic coding(CAB-AC)is a method of entropy codingfirst introduced in H.264/A VC and now used in the newest standard High Efficiency Video Coding(HEVC).While it provides high coding efficiency,the data dependencies in H.264/A VC CABAC make it challenging to parallelize and thus,limit its throughput.Accordingly,during the standardization of entropy coding for HEVC,both coding efficiency and throughput were considered.This paper highlights the key techniques that were used to enable HEVC to potentially achieve higher throughput while delivering coding gains relative to H.264/A VC.These techniques include reducing context coded bins,grouping bypass bins,grouping bins with the same context, reducing context selection dependencies,reducing total bins, and reducing parsing dependencies.It also describes reductions to memory requirements that benefit both throughput and implementation costs.Proposed and adopted techniques up to draft international standard(test model HM-8.0)are discussed. In addition,analysis and simulation results are provided to quantify the throughput improvements and memory reduction compared with H.264/A VC.In HEVC,the maximum number of context-coded bins is reduced by8×,and the context memory and line buffer are reduced by3×and20×,respectively.This paper illustrates that accounting for implementation cost when designing video coding algorithms can result in a design that enables higher processing speed and lowers hardware costs,while still delivering high coding efficiency.Index Terms—Context-adaptive binary arithmetic coding (CABAC),entropy coding,high-efficiency video coding(HEVC), video coding.I.IntroductionH IGH EFFICIENCY Video Coding(HEVC)is currentlybeing developed by the Joint Collaborative Team for Video Coding(JCT-VC).It is expected to deliver up to a 50%higher coding efficiency compared to its predecessor H.264/A VC.HEVC uses several new tools for improving coding efficiency,including larger block and transform sizes, additional loopfilters,and highly adaptive entropy coding. While high coding efficiency is important for reducing the transmission and storage cost of video,processing speed and area cost also need to be considered in the development of next-generation video coding to handle the demand for higher resolution and frame rates.Manuscript received April16,2012;revised July7,2012;accepted August 21,2012.Date of publication October2,2012;date of current version January 8,2013.This paper was recommended by Associate Editor F.Wu.The authors are with Texas Instruments,Dallas,TX75243USA(e-mail: sze@;madhukar@).Color versions of one or more of thefigures in this paper are available online at .Digital Object Identifier10.1109/TCSVT.2012.2221526Context-adaptive binary arithmetic coding(CABAC)[1]is a form of entropy coding used in H.264/A VC[2]and also in HEVC[3].While CABAC provides high coding efficiency, its data dependencies cause it to be a throughput bottleneck for H.264/A VC video codecs[4].This makes it difficult to support the growing throughput requirements for next-generation video codecs.Furthermore,since high throughput can be traded off for power savings using voltage scaling [5],the serial nature of CABAC limits the battery life for video codecs that reside on mobile devices.This limitation is a critical concern,as a significant portion of the video codecs today are battery operated.Accordingly,both coding efficiency and throughput improvement tools,and the tradeoff between these requirements,were investigated in the standard-ization of entropy coding for HEVC.The tradeoff between coding efficiency and throughput exists,since dependencies are a result of removing redundancy,which improves coding efficiency;however,dependencies make parallel processing difficult,which degrades throughput.This paper describes how CABAC entropy coding has evolved from H.264/A VC to HEVC(Draft International Stan-dard,HM-8.0)[3],[6].While both coding efficiency and throughput improvement tools are discussed,the focus of this paper will be on tools that increase throughput while maintaining coding efficiency.Section II provides an overview of CABAC entropy coding.Section III explains the cause of the throughput bottleneck.Section IV describes several key techniques used to improve the throughput of the CABAC engine.Sections V and VI describe how these techniques are applied to prediction unit(PU)coding and transform unit(TU) coding,respectively.Section VII compares the overall CABAC throughput and memory requirements of H.264/A VC and HEVC for both common conditions and worst-case conditions.II.CABAC Entropy CodingEntropy coding is a form of lossless compression used at the last stage of video encoding(and thefirst stage of video decoding),after the video has been reduced to a series of syntax elements.Syntax elements describe how the video sequence can be reconstructed at the decoder.This includes the method of prediction(e.g.,spatial or temporal prediction,intra prediction mode,and motion vectors)and prediction error,also referred to as residual.Table I shows the syntax elements used in HEVC and H.264/A VC.These syntax elements describe properties of the coding unit(CU),1051-8215/$31.00c 2012IEEETABLE ICABAC Coded Syntex Elements in HEVC and H.264/AVCHEVC H.264/A VCsplit−cu−flag,pred−mode−flag,part−mode,pcm−flag,mb−type,sub−mb−type,Coding unit Block structure and cu−transquant−bypass−flag,skip−flag,cu−qp−delta−abs,mb−skip−flag,mb−qp−delta, (CU)quantization cu−qp−delta−sign,end−of−slice−flag end−of−slice−flag,mb−field−decoding−flagprev−intra4x4−pred−mode−flag,prev−intra−luma−pred−flag,mpm−idx,prev−intra8×8−pred−mode−flag, Intra mode coding rem−intra−luma−pred−mode,rem−intra4x4−pred−mode,intra−chroma−pred−mode rem−intra8x8−pred−mode,intra−chroma−pred−mode Prediction unit merge−flag,merge−idx,inter−pred−idc,(PU)ref−idx−l0,ref−idx−l1,Motion data abs−mvd−greater0−flag,abs−mvd−greater1−flag,ref−idx−l0,ref−idx−l1,mvd−l0,mvd−l1abs−mvd−minus2,mvd−sign−flag,mvp−l0−flag,mvp−l1−flagno−residual−syntax−flag,split−transform−flag,cbf−luma,coded−block−flag,cbf−cb,cbf−cr,transform−skip−flag,last−significant−coded−block−pattern,coeff−x−prefix,last−significant−coeff−y−prefix,last−significant−transform−size−8x8−flag,Transform Unit (TU)Transform coefficient coeff−x−suffix,last−significant−coeff−y−suffix,coded−sub−significant−coeff−flag, coding block−flag,significant−coeff−flag,coeff−abs−level−last−significant−coeff−flag, greater1−flag,coeff−abs−level−greater2−flag,coeff−abs−level−coeff−abs−level−minus1,remaining,coeff−sign−flag coeff−sign−flag Sample adaptive sao−merge−left−flag,sao−merge−up−flag,sao−type−idx−luma,Loopfilter(LF)offset(SAO)sao−type−idx−chroma,sao−offset−abs,sao−offset−sign,n/a parameters sao−band−position,sao−eo−class−luma,sao−eo−class−chromaprediction unit(PU),transform unit(TU),and loopfilter(LF) of a coded block of pixels.For a CU,the syntax elements describe the block structure and whether the CU is inter or intra predicted.For a PU,the syntax elements describe the intra prediction mode or a set of motion data.For a TU,the syntax elements describe the residual in terms of frequency position,sign,and magnitude of the quantized transform coefficients.The LF syntax elements are sent once per largest coding unit(LCU),and describe the type(edge or band)and offset for sample adaptive offset in-loopfiltering. Arithmetic coding is a type of entropy coding that can achieve compression close to the entropy of a sequence by effectively mapping the symbols(i.e.,syntax elements)to codewords with a noninteger number of bits.In H.264/A VC, CABAC provides a9%to14%improvement over the Huffman-based CA VLC[1].In an early test model for HEVC (HM-3.0),CABAC provides a5%–9%improvement over CA VLC[7].CABAC involves three main functions:binarization,con-text modeling,and arithmetic coding.Binarization maps the syntax elements to binary symbols(bins).Context modeling estimates the probability of the bins.Finally,arithmetic coding compresses the bins to bits based on the estimated probability.A.BinarizationSeveral different binarization processes are used in HEVC, including unary(U),truncated unary(TU),k th-order Exp-Golomb(EGk),andfixed length(FL).These forms of binarization were also used in H.264/A VC.These various methods of binarization can be explained in terms of how they would signal an unsigned value N.An example is also provided in Table II.1)Unary coding involves signaling a bin string of lengthN+1,where thefirst N bins are1and the last bin isTABLE IIExample of Different Binarizations Used in HEVC Unary(U)Truncated Exp-Golomb Fixed N unary(TU)(EGk)length(FL)cMax=7k=0cMax=7 000100011010010001211011001101031110111000100011411110111100010110051111101111100011010161111110111111000111110711111110111111100010001110.The decoder searches for a0to determine when thesyntax element is complete.2)Truncated unary coding has one less bin than unarycoding by setting a maximum on the largest possible value of the syntax element(cMax).When N+1<cMax, the signaling is the same as unary coding.However, when N+1=cMax,all bins are1.The decoder searches for a0up to cMax bins to determine when the syntax element is complete.3)k th order Exp-Golomb is a type of universal code.Thedistribution can be changed based on the k parameter.More details can be found in[1].4)Fixed length uses afixed number of bins,ceil(log2(cMax+1)),with most significant bits signaled before least significant bits.The binarization process is selected based on the type of syntax element.In some cases,binarization also de-pends on the value of a previously processed syntax ele-ments(e.g.,the binarization of coeff−abs−level−remaining depends on the previous coefficient levels)or slice pa-rameters that indicate if certain modes are enabled(e.g., the binarization of partition mode,part−mode,depends on whether asymmetric motion partition is enabled).The ma-jority of the syntax elements use the binarization pro-cesses listed in Table II,or some combination of them(e.g.,coeff−abs−level−remaining uses U(prefix)+FL(suffix)[8];cu−qp−delta−abs uses TU(prefix)+EG0(suffix)[9]). However,certain syntax elements(e.g.,part−mode and intra−chroma−pred−mode)use custom binarization processes.B.Context ModelingContext modeling provides an accurate probability estimate required to achieve high coding efficiency.Accordingly,it is highly adaptive and different context models can be used for different bins and the probability of that context model is updated based on the values of the previously coded bins. Bins with similar distributions often share the same context model.The context model for each bin can be selected based on the type of syntax element,bin position in syntax element(binIdx),luma/chroma,neighboring information,etc.A context switch can occur after each bin.The probability models are stored as7-b entries[6-b for the probability state and1-b for the most probable symbol(MPS)]in a context memory and addressed using the context index computed by the context selection logic.HEVC uses the same probability update method as H.264/A VC;however,the context selection logic has been modified to improve throughput.C.Arithmetic CodingArithmetic coding is based on recursive interval division.A range,with an initial value of0to1,is divided into two subintervals based on the probability of the bin.The encoded bits provide an offset that,when converted to a binary fraction, selects one of the two subintervals,which indicates the value of the decoded bin.After every decoded bin,the range is updated to equal the selected subinterval,and the interval division process repeats itself.The range and offset have limited bit precision,so renormalization is required whenever the range falls below a certain value to prevent underflow. Renormalization can occur after each bin is decoded. Arithmetic coding can be done using an estimated proba-bility(context coded),or assuming equal probability of0.5 (bypass coded).For bypass coded bins,the division of the range into subintervals can be done by a shift,whereas a look up table is required for the context coded bins.HEVC uses the same arithmetic coding as H.264/A VC.III.Throughput BottleneckCABAC is a well-known throughput bottleneck in the video codec implementations(particularly,at the decoder). The throughput of CABAC is determined based on the number of binary symbols(bins)that it can process per second.The throughput can be improved by increasing the number of bins that can be processed in a cycle.However,the data dependencies in CABAC make processing multiple bins in parallel difficult and costly toachieve.Fig.1.Three key operations in CABAC:binarization,context selection,and arithmetic coding.Feedback loops in the decoder are highlighted with dashed lines.Fig.1highlights the feedback loops in the CABAC decoder. Below is a list and description of these feedback loops.1)The updated range is fed back for recursive intervaldivision.2)The updated context is fed back for an accurate proba-bility estimate.3)The context selection depends on the type of syntaxelement.At the decoder,the decoded bin is fed back to determine whether to continue processing the same syntax element,or to switch to another syntax element.If a switch occurs,the bin may be used to determine which syntax element to decode next.4)The context selection also depends on the bin position inthe syntax element(binIdx).At the decoder,the decoded bin is fed back to determine whether to increment binIdx and continue to decode the current syntax element,or set binIdx equal to0and switch to another syntax element. Note that the context update and range update feedback loops are simpler than the context selection loops and thus do not affect throughput as severely.If the context of a bin depends on the value of another bin being decoded in parallel, then speculative computations are required,which increases area cost and critical path delay[10].The amount of specula-tion can grow exponentially with the number of parallel bins which limits the throughput that can be achieved[11].Fig.2 shows an example of the speculation tree for significance map in H.264/A VC.Thus,the throughput bottleneck is primarily due to the context selection dependencies.IV.Techniques to Improve Throughput Several techniques were used to improve the throughput of CABAC in HEVC.There was a lot of effort spent in determining how to use these techniques with minimal coding loss.They were applied to various parts of entropy coding in HEVC and will be referred to throughout the rest of this paper.1)Reduce Context Coded Bins:Throughput is limited for context coded bins due to the data dependencies described in Section III.However,it is easier to process bypass coded bins in parallel since they do not have the data dependencies related to context selection(i.e.,feedback loops2,3,and4in Fig.1). In addition,arithmetic coding for bypass bins is simpler as it only requires a right shift versus a table look up for context coded bins.Thus,the throughput can be improved by reducing the number of context coded bins and using bypass coded bins instead[12]–[14].Fig.2.Context speculation required to achieve 5×parallelism when processing the significance map in H.264/A VC.i =coefficient position,i 1=MaxNumCoeff(BlockType)−1,EOB =end of block,SIG =significant −coeff −flag,LAST =last −significant −coeff −flag.2)Group Bypass Coded Bins:Multiple bypass bins can be processed in the same cycle if they occur consecutively within the bitstream.Thus,bins should be reordered such that bypass coded bins are grouped together in order to increase the likelihood that multiple bins are processed per cycle [15]–[17].3)Group Bins With the Same Context:Processing multiple context coded bins in the same cycle often requires speculative calculations for context selection.The amount of speculative computations increases if bins using different contexts and context selection logic are interleaved,since various combina-tions and permutations must be accounted for.Thus,to reduce speculative computations,bins should be reordered such that bins with the same contexts and context selection logic are grouped together so that they are likely to be processed in the same cycle [18]–[20].This also reduces context switching resulting in fewer memory accesses,which also increases throughput and reduces power consumption.This technique was first introduced in [18]and referred to as parallel context processing (PCP)throughout the standardization process.4)Reduce Context Selection Dependencies:Speculative computations are required for multiple bins per cycle decoding due to the dependencies in the context selection.Reducing these dependencies simplifies the context selection logic and reduces the amount of speculative calculations required to process multiple bins in parallel [11],[21],[22].5)Reduce Total Number of Bins:In addition to increasing the throughput,it is desirable to reduce the workload itself by reducing the total number of bins that need to be processed.This can be achieved by changing binarization,inferring the value of some bins,and sending higher level flags to avoid signaling redundant bins [23],[24].6)Reduce Parsing Dependencies:As parsing with CABAC is already a tight bottleneck,it is important to minimize any dependency on other video coding modules,which could cause the CABAC to stall [25].Ideally,the parsing process should be decoupled from all other processing.7)Reduce Memory Requirements:Memory accesses often contribute to the critical path delay.Thus,reducing memory storage requirements is desirable as fewer memory accesses increases throughput as well as reduces implementation cost and power consumption [26],[27].V .Prediction Unit CodingThe PU syntax elements describe how the prediction is performed in order to reconstruct the pixels.For inter prediction,the motion data are described by merge flag(merge −flag),merge index (merge −idx),prediction direction (inter −pred −idc),reference index (ref −idx −l0,ref −idx −l1),motion vector predictor flag (mvp −l0−flag,mvp −l1−flag)and motion vector difference (abs −mvd −greater0−flag,abs −mvd −greater1−flag,abs −mvd −minus2,mvd −sign −flag).For intra prediction,the intra prediction mode is described by prediction flag (prev −intra −luma −pred −flag),most probable mode index (mpm −idx),remainder mode (rem −intra −luma −pred −mode)and intra prediction mode for chroma (intra −chroma −pred −mode).Coding efficiency improvements have been made in HEVC for both motion data coding and intra mode coding.While H.264/A VC uses a single motion vector predictor (unless direct mode is used)or most probable mode,HEVC uses multiple candidate predictors and an index or flag is signaled to select the predictor.This section will discuss how to avoid parsing dependencies for the various methods of prediction and other throughput improvements.A.Motion Data CodingIn HEVC,merge mode enables motion data (e.g.,predic-tion direction,reference index,and motion vectors)to be inherited from a spatial or temporal (co-located)neighbor.A list of merge candidates are generated from these neighbors.merge −flag is signaled to indicate whether merge is used in a given PU.If merge is used,then merge −idx is signaled to indi-cate from which candidate the motion data should be inherited.merge −idx is coded with truncated unary,which means that the bins are parsed until a nonzero is reached or when the number of bins is equal to the cMax,the max allowed number of bins.1)Removing Parsing Dependencies for Merge:Determin-ing how to set cMax involved evaluating the throughput and coding efficiency tradeoffs in a core experiment [28].For optimal coding efficiency,cMax should be set to equal the merge candidate list size of the PU.Furthermore,merge −flag should not be signaled if the list is empty.However,this makes parsing depend on list construction,which is needed to determine the list size.Constructing the list requires a large amount of computation since it involves reading from multiple locations (i.e.,fetching the co-located neighbor and spatial neighbors)and performing several comparisons to prune the list;thus,dependency on list construction would significantly degrade parsing throughput [25],[29].To decouple the list generation process from the parsing process such that they can operate in parallel in HEVC,cMax is signaled in the slice header and does not depend on list size.To compensate for the coding loss due to the fixed cMax,combined and zero merging candidates are added when the list size is less than cMax as described in[30].This ensures that the list is never empty and that merge−flag is always signaled [31].2)Removing Parsing Dependencies for Motion Vector Prediction:If merge mode is not used,then the motion vector is predicted from its neighboring blocks and the difference between motion vector prediction(mvp)and motion vector (mv),referred to as motion vector difference(mvd),is signaled asmvd=mv-mvp.In H.264/A VC,a single predictor is calculated for mvp from the median of the left,top,and top-right spatial4×4neighbors. In HEVC,advanced motion vector prediction(AMVP)is used,where several candidates for mvp are determined from spatial and temporal neighbors[32].A list of mvp candidates is generated from these neighbors,and the list is pruned to remove redundant candidates such that there is a maximum of2candidates.A syntax element called mvp−l0−flag(or mvp−l1−flag depending on the reference list)is used to indicate which candidate is used from the list as the mvp. To ensure that parsing is independent of list construction, mvp−l0−flag is signaled even if there is only one candidate in the list.The list is never empty as the zero vector is used as the default candidate.3)Reducing Context Coded Bins:In HEVC,improve-ments were also made on the coding process of mvd it-self.In H.264/A VC,thefirst9bins of mvd are context coded truncated unary bins,followed by bypass coded third-order Exp-Golomb bins.In HEVC,the number of context coded bins for mvd is significantly reduced[13].Only the first two bins are context coded(abs−mvd−greater0−flag, abs−mvd−greater1−flag),followed by bypass codedfirst-order Exp-Golomb bins(abs−mvd−minus2).4)Reducing Memory Requirements:In H.264/A VC,con-text selection for thefirst bin in mvd depends on whether the sum of the motion vectors of the top and left4×4 neighbors are greater than32(or less than3).This requires 5-b storage per neighboring motion vector,which accounts 24576of the30720-b CABAC line buffer needed to support a4k×2k sequence.[27]highlighted the need to reduce the line buffer size in HEVC by modifying the context selection logic.It proposed that the motion vector for each neighbor befirst compared to a threshold of16,and then use the sum of the comparison for context selection,which would reduce the storage to1-b per neighboring motion vector.This was further extended in[33]and[34],where all dependencies on the neighbors were removed and the context is selected based on the binIdx(i.e.,whether it is thefirst or second bin).5)Grouping Bypass Bins:To maximize the impact of fast bypass coding,the bypass coded bins for both the x and y components of mvd are grouped together in HEVC[16]. B.Intra Mode CodingSimilar to motion coding,a predictor mode(most probable mode)is calculated for intra mode coding.In H.264/A VC,the minimum mode of the top and left neighbors is used as theTABLE IIIDifferences Between PU Coding in HEVC and H.264/AVCProperties HEVC H.264/A VCIntra mode AMVP Merge Intra mode MVP Max number of32511 candidates in listSpatial neighbor Used Used Used Used Used Temporal co-located Not Used Used Not Not neighbor used used used Number of contexts2102620 Max context coded2122798 bins per PUmost probable mode.prev−intra4x4−pred−mode−flag (or prev−intra8x8−pred−mode−flag)is signaled to indicate whether the most probable mode is used.If the most probable mode is not used,the remainder mode rem−intra4x4−pred−mode−flag(or rem−intra8x8−pred−mode−flag)is signaled.In HEVC,additional most probable modes are used to improve coding efficiency.A candidate list of most probable modes with afixed length of three is constructed based on the left and top neighbors.The additional candidate modes (DC,planar,vertical,+1or−1angular mode)can be added if the left and top neighbors are the same or unavailable. prev−intra−pred−mode−flag is signaled to indicate whether one of the most probable modes is used.If a most probable mode is used,a most probable mode index(mpm−idx)is signaled to indicate which candidate to use.It should be noted that in HEVC,the order in which the coefficients of the residual are parsed(e.g.,diagonal,vertical,or horizontal) depends on the reconstructed intra mode(i.e.,the parsing of the TU data that follows depends on list construction and intra mode reconstruction).Thus,the candidate list size was limited to three for reduced computation to ensure that it would not affect entropy decoding throughput[35],[36].1)Reducing Context Coded Bins:The number of context coded bins was reduced for intra mode coding in HEVC.In H.264/A VC,the remainder mode is a7-bin value where the first bin is context coded,while in HEVC,the remainder mode is a5-bin value that is entirely bypass coded.The most proba-ble mode index(mpm−idx)is also entirely bypass coded.The number of contexts used to code intra−chroma−pred−mode is reduced from4to1.2)Grouping Bypass Bins:To maximize the impact of fast bypass coding,the bypass coded bins for intra mode within a CU are grouped together in HEVC[17].C.Summary of Differences Between HEVC and H.264/AVC The differences between H.264/A VC and HEVC are sum-marized in Table III.HEVC uses both spatial and temporal neighbors as predictors,while H.264/A VC only uses spatial neighbors(unless direct mode is enabled).In terms of the impact of the throughput improvement techniques,HEVC has8×fewer maximum context coded bins per PU than H.264/A VC.HEVC also requires1.8×fewer contexts for PU syntax elements than H.264/A VC.VI.Transform Unit CodingIn video coding,both intra and inter prediction are used to reduce the amount of data that needs to be transmitted. Rather than sending the pixels,the prediction error is trans-mitted.This prediction error is transformed from spatial to frequency domain to leverage energy compaction properties, and after quantization,it can be represented in terms of a few coefficients.The method of signaling the value and the frequency position of these coefficients is referred to as transform coefficient coding.For regions with many edges (e.g.,screen content coding),coding gains can be achieved by skipping the transform from spatial to frequency domain [37],[38];when transform is skipped,the prediction error is coded in the same manner as transform coefficient coding(i.e., the spatial error is coded as transform coefficients).Syntax elements of the transform unit account for a signif-icant portion of the bin workload as shown in Table IV.At the same time,the transform coefficients also account for a significant portion of the total bits of a compressed video,and as a result the compression of transform coefficients signifi-cantly impacts the overall coding efficiency.Thus,transform coefficient coding with CABAC must be carefully designed in order to balance coding efficiency and throughput demands. Accordingly,as part of the HEVC standardization process, a core experiment on coefficient scanning and coding was established to investigate tools related to transform coefficient coding[39].It is also important to note that HEVC supports more transform sizes than H.264/A VC;H.264/A VC uses4×4and 8×8transforms,where as HEVC uses4×4,8×8,16×16, and32×32transforms.While these larger transforms provide significant coding gains,they also have implications in terms of memory storage as this represents an increase of4×to 16×in the number of coefficients that need to be stored per transform unit(TU).In CABAC,the position of the coefficients is transmitted in the form of a significance map.Specifically,the significance map indicates the location of the nonzero coefficients.The coefficient level information is then only transmitted for the coefficients with values greater than one,while the coefficient sign is transmitted for all nonzero coefficients.This section describes how transform coefficient coding evolved from H.264/A VC to thefirst test model of HEVC (HM-1.0)to the Draft International Standard of HEVC(HM-8.0),and discusses the reasons behind design choices that were made.Many of the throughput improvement techniques were applied,and new tools for improved coding efficiency were simplified.As a reference for the beginning and end points of the development,Figs.3and4show examples of transform coefficient coding in H.264/A VC and HEVC(HM-8.0),respectively.A.Significance MapIn H.264/A VC,the significance map is signaled by transmit-ting a significant−coeff−flag(SCF)for each position to indi-cate whether the coefficient is nonzero.The positions are pro-cessed in an order based on a zig–zag scan.After eachnonzero Fig.3.Example of transform coefficient coding for a4×4TU in H.264/AVC.Fig.4.Example of transform coefficient coding for a4×4TU in HEVC (HM-8.0).SCF,an additionalflag called last−significant−coeff−flag (LSCF)is immediately sent to indicate whether it is the last nonzero SCF;this prevents unnecessary SCF from being signaled.Different contexts are used depending on the position within the4×4and8×8transform unit(TU),and whether the bin represents an SCF or LSCF.Since SCF and LSCF are interleaved,the context selection of the current bin depends on the immediate preceding bin.The dependency of LSCF on SCF results in a strong bin to bin dependency for context selection for significance map in the H.264/A VC as illustrated in Fig.2.1)significant−coeff−flag(SCF):In HM-1.0,additional dependencies were introduced in the context selection of SCF for16×16and32×32TU to improve coding efficiency.The context selection for SCF in these larger TU depended on the number of nonzero neighbors to give coding gains between 1.4%to2.8%[42].Specifically,the context of SCF depended on up to ten neighbors as shown in Fig.5(a)[42],[43].To reduce context selection dependencies,and storage costs,[21]proposed using fewer neighbors and showed that it could be done with minimal cost to coding efficiency.For。

CABAC解码

CABAC解码

other
• cabac采用3种解码模式,分别为 DecodeRegular,DecodeBypass,DecodeTerminal . 在H.264中,句法元素mvd, coeff_abs_level_minusl[i]的后缀及 coeff_sign_flag[i]采用DecodeBypass 模式进行解 码;而对end_of_slice_flag和mb_type的第一比特 位(从零开始)DecodeTerminal模式进行解码; 其余的句法元素采用DecodeRegular解码模式。 • 见3.3.2算术解码过程 本过程的输入是 9.3.3.1节导出的 bypassFlag, ctxIdx,算 术解码引擎中的状态变量 codIRange和 codIOffset。 本过程的输出是二进制码值。 图9-2为对于一个单独的二进制码值的整个算术解码处理 过程。对于每一个二进制码值,上下文索引ctxIdx作为 DecodeBin(ctxIdx)解码过程的一个参数,规定如下: — 如果bypassFlag等于1,调用9.3.3.2.3中规定 DecodeBypass()。 — 否则,如果bypassFlag等于0并且ctxIdx等于276,调 用9.3.3.2.4中定义的DecodeTerminate()。 — 否则(bypassFlag等于0且ctxIdx不等于276),调用 9.3.3.2.1中规定的DecodeDecision()
2.给定 ctxIdx,通过 9.3.3.2中定义的过程解码比 特流。
初始化过程
1.上下文模型变量(Context Variable)的初始化 和解码端相同,用同一函数函数x264_cabac_context_init () 2. 算术解码引擎的初始化 本过程的调用在解码条带的第一个宏块之前,或者解码类 型为 I_PCM宏块的 解码后。 本过程的输出为初始化的解码引擎注册器 codIRange 和 codIOffset 算术解码引起的状态通过变量 codIRange和 codIOffset表 示。在算术解码处理的初始化过程中,codIRange设为 0x01FE,codIOffset设为 read_bits( 9 )的返回值,使用高 位在先的无符号整数的 9比特二进制表示。 比特流中不能包含会导致 codIOffset等于 0x01FE 或者 0x01FF的数据

H_264中CABAC算法与CAVLC算法比较和改进

H_264中CABAC算法与CAVLC算法比较和改进
再看表 2,对于运动剧烈的 coastguard 序列,两 种编码方案处理得到的图像在亮度、色度、色差方面 的优劣分布较为均匀,很难分辨两种编码方式的优 劣。
从两表表现出的差异,我们可以得出,在 PSNR 方面,对于运动剧烈的图像序列,对两种编码方案选 择的要求不高。对于运动迟缓的图像序列,就要考虑 一下选择哪种熵编码方案了。
编码符号具有上下文相关性,利用已编码符号 提供的上下文信息,为编码符号选择合适的概率,这 就是上下文建模。利用上下文信息可以降低符号间 的冗余度,进一步提高编码效率。
CABAC 在编码前,编码器预先给出了 126 种不 同的基于上下文的模型和起始概率,降低了计算复 杂度,提高了编码效率。随着符号编码的进行,又不 断根据编码完成的符号更新符号出现的概率,以达 到自适应算术编码的目的,更高效地减少了冗余。
47.95
48.14
25
36.78
36.74
45.38
45.42
46.06
45.84
30
32.91
32.89
42.97
43.00
44.07
44.07
35
29.61
29.54
41.54
41.11
42.23
42.17
40
26.99
27.01Βιβλιοθήκη 40.0840.18
41.39
40.42
45
24.91
24.92
从表 1 可以看出, 运动缓慢的 foreman 序列,在 QP<30 时 ,CABAC 编 码 方 式 下 PSNR 值 多 高 于 CAVLC 下的 PSNR 值,QP≥30 时 CAVLC 编码方式 下的 PSNR 值多高于 CABAC 下的 PSNR 值。说明在 QP<30 时经 CABAC 编码压缩后输出图像质量优于 CAVLC 编码压缩后输出图像质量,QP≥30 时,经 CAVLC 编码压缩后输出图像质量优于 CABAC 编码 压缩后输出图像质量。

CAVLC和CABAC简介

CAVLC和CABAC简介

拖尾系数指值为+1/-1的系数,最大数目为3。

如果超过3个,那么只有最后三个被视为拖尾系数。

拖尾系数的数目被赋值到变量TrailingOnes。

非零系数包括所有的拖尾系数,其数目被赋值到变量TotalCoeffs)。

2. 计算nC(numberCurrent,当前块值)。

nC值由左边块的非零系数nA和上面块非零系数nB来确定,计算公式为:nC=round((nA+nB)/2);若nA存在nB不存在,则nC=nA;若nA不存在而nB存在,则nC=nB;若nA和nB都不存在,则nC=0。

nC值用于选择VLC编码表,如下图所示。

这里体现了上下文相关(contextadaptive)的特性,例如当nC值较小即周围块的非零系数较少时,就会选择比较短的码,从而实现了数据压缩。

3. 查表获得coff_token的编码。

根据之前编码和计算过程所得的变量TotalCoeffs、TrailingOnes和nC值可以查H.264标准附录CAVLC码表,即可得出coeff_token编码序列。

4. 编码每个拖尾系数的符号,按zig-zag的逆序进行编码。

每个符号用1个bit位来表示,0表示―+‖,1表示―—‖。

当拖尾系数超过三个时只有最后三个被认定为拖尾系数,引词编码顺序为从后向前编码。

5. 编码除拖尾系数之外非零系数的level(Levels)。

每个非零系数的level包括sign和magnitude,扫描顺序是逆zig-zag序。

level的编码由前缀(level_prefix)和后缀(level_suffix)组成。

前缀的长度在0到6之间,后缀的长度则可通过下面的步骤来确定:将后缀初始化为0。

(若非零系数的总数超过10且拖尾系数不到3,则初始化为1)。

编码频率最高(即按扫描序最后)的除拖尾系数之外的非零系数。

若这个系数的magnitude超过某个门槛值(threshold),则增加后缀的长度。

下表是门槛值的列表:6. 编码最后一个非零系数之前0的个数(totalZeos)。

CABAC举例

CABAC举例

上下文建模为基本的CABAC 编码过程,一种regular coding mode 另一种为 bypass coding mode.只有regular coding mode 应用了上下文模型,而直通模式用于加速编码流程,当概率近似为50%的时候。

这部分主要说明regular coding mode的进程。

这里,先说理论,再讲流程。

理论:1,CABAC 算术编码基础算术编码的复杂度主要体现在概率的估计和更新,CABAC建立了一个基于查表的概率模型,将0~0.5 划分为64个概率量化值,这些概率对应于LPS字符,而MPS的概率为(1-Plps),概率的估计值被限制在查表内,概率的刷新也是依据于查表。

如果当前出现的字符是MPS,则Plps 变小。

划分子区间的乘法运算 R=R x Px对于这里的乘法运算,CABAC首先建立了一个二维表格,存储预先计算好的乘法结果,表格的入口参数一个来自Px( 对应于theta,概率量化值),另一个来自R(R的量化为:p=(R>>6)&3 ),流程图:图中,灰色部分是概率的刷新部分,表TABRangeLPS存储预先计算好的乘法结果,表TransIDxLPS是与对应的概率表。

有三个值是比较特殊的,:theata=0 时,LPS的概率已达到了最大值0.5,如果下一个出现的是LPS,则此时LPS和MPS的字符交换位置.Theta=63对应着LPS的最小概率值,但它并没有纳入CABAC的概率估计和更新的范围,这个值被用做特殊场合,传递特殊信息,比如,当解码器检测到当前区间的划分依据是这个值时,认为表示当前流的结束.Theta=62 ,这是表中的最小值,它对应的刷新值是它自身,当MPS连续出现,LPS 的概率持续减小,到62保持不变。

2 CABAC 上下文模型CABAC将片作为算术编码的生命周期,h.264将一个片内可能出现的数据划分为399个上下文模型,每个模型均有自己的CtxIdx(上下文序号),每个不同的字符依据对应的上下文模型,来索引自身的概率查找表。

CABAC编码协议详细分析(初稿)

CABAC编码协议详细分析(初稿)

CABAC详细分析CABAC的三个步骤:1.二进制转换:把非二进制语法元素唯一映射到一个二进制码字2.上下文建模:利用已编码的符号为语法元素选择合适的上下文模型并自动更新概率模型3基于表格的算术编码:利用查表的方式进行算术编码,有效地避免了乘法运算二进制转换一.一元码对于一个非二进制数C来说,编码个1并在最后加上一个c二.一元截断码对于C小于Cmax时,用一元码的编码方法,当C=Cmax时,编码个1而不在最后加0三.UEGK二进制转换前缀由Cmax=UCoff的一元截断码组成,后缀用k阶哥伦布编码数字C—Ucoff,其中k阶哥伦布编码用以下程序编码(对于要编码符号S)四.固定长度二进制转换对于字母表【0,1,2,…,Cmax】,编码的二进制长度其中,二进制1对应其中重要性最低的符号,随着重要性的增加,二进制也会跟着增加五.对于宏块与子宏块类型的具体二进制化对应当adaptive_block_size_transform_flag==0时(非ABT变换,以下都针对非ABT变换),参看表格9-20,9-21,9-22:关于表格的说明:对应在SI帧内的宏块类型二进制转换按以下方法:前缀构成:当类型为mb_type_Sintra_4*4没有后缀,否则由表9-20给出对于在P和SP图像的帧内预测宏块,mb_type=7~30的前缀由表9-21给出,后缀用表9-20 对于在B图像中的帧内预测宏块,mb_type=23~47的前缀由表9-21给出,后缀用表9-20以上都是对非ABT变换来说的,对于ABT变换,要参考其他二进制方案表格,此处略去。

各种不同的语法元素,都是用到前面的4种二进制方案或者某两种二进制方案的串接,下面举例对变换系数的二进制方案进行说明:首先该过程分为3个步骤:1.如果coded_block_flag=0,说明没有重要系数(非0系数),不需要对宏块的信息进行编码,否则进行第二步2.在扫描的过程中,对于每个扫描位置i,如果i位置的系数是0,那么significant_coeff_flag[i]=0,否则significant_coeff_flag[i]=1,当significant_coeff_flag[i]=1时,继续编码last_ significant_coeff_flag[i],如果该系数不是最后一个非0系数,last_ significant_coeff_flag[i]=0,否则=1,当等于1时不需要再对宏块剩余的0系数进行编码3.对应那些significant_coeff_flag[i]=1的系数,要编码coeff_absolute_value_minus_1和coeff_sign,对于前者,采用UEG0编码(UCoff=14),对于后者直接采用旁路编码器(将在后文说到)上下文定义与分配首先,每个语法元素对应一个或者多个上下文指示器context_id,经过二进制转换后的语法元素可能有不止一位的二进制值,以mb_type_I(I帧图像内的宏块类型)为例,对应的context_id为ctx_mb_type_I,该语法元素二进制化后有6位二进制值,分别对应ctx_mb_type_I[k],1<=k<=6即max_idx_ctx_id=6,而每个context_id 对应一定范围内的上下文变量context label,可参看下表:具体每个CTX_ID[K]对应哪几个LABEL可进一步参考下表:上下文模板具体某一位context_id[k]可能对应几个不同的context label,那么究竟具体对应哪个就由上下文模板来决定,上下文模板将在下面进行说明;一.利用两个相邻符号的上下文模板如图所示,正要编码的符号S是在当前宏块块C中,A,B是C的相邻宏块通过关系式:ctx_var_spat=cond_term(A,B) (9-1)计算出符号S的上下文增量X,通过用OFFSET+X得出对应的context label的值。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

CABAC 详细分析CABAC 的三个步骤:1.二进制转换:把非二进制语法元素唯一映射到一个二进制码字2.上下文建模:利用已编码的符号为语法元素选择合适的上下文模型并自动更新概率模型 3基于表格的算术编码:利用查表的方式进行算术编码,有效地避免了乘法运算二进制转换一.一元码对于一个非二进制数C 来说,编码 个1并在最后加上一个0二.一元截断码对于C 小于Cmax 时,用一元码的编码方法,当C=Cmax 时,编码 个1而不在最后加0 三.UEGK 二进制转换前缀由Cmax =UCoff 的一元截断码组成,后缀用k 阶哥伦布编码数字C —Ucoff ,其中k 阶哥伦布编码用以下程序编码(对于要编码符号S )c四.固定长度二进制转换对于字母表【0,1,2,…,Cmax】,编码的二进制长度其中,二进制1对应其中重要性最低的符号,随着重要性的增加,二进制也会跟着增加五.对于宏块与子宏块类型的具体二进制化对应当adaptive_block_size_transform_flag==0时(非ABT变换,以下都针对非ABT变换),参看表格9-20,9-21,9-22:关于表格的说明:对应在SI帧内的宏块类型二进制转换按以下方法:前缀构成:当类型为mb_type_Sintra_4*4没有后缀,否则由表9-20给出对于在P和SP图像的帧内预测宏块,mb_type=7~30的前缀由表9-21给出,后缀用表9-20 对于在B图像中的帧内预测宏块,mb_type=23~47的前缀由表9-21给出,后缀用表9-20以上都是对非ABT变换来说的,对于ABT变换,要参考其他二进制方案表格,此处略去。

各种不同的语法元素,都是用到前面的4种二进制方案或者某两种二进制方案的串接,下面举例对变换系数的二进制方案进行说明:首先该过程分为3个步骤:1.如果coded_block_flag=0,说明没有重要系数(非0系数),不需要对宏块的信息进行编码,否则进行第二步2.在扫描的过程中,对于每个扫描位置i,如果i位置的系数是0,那么significant_coeff_flag[i]=0,否则significant_coeff_flag[i]=1,当significant_coeff_flag[i]=1时,继续编码last_ significant_coeff_flag[i],如果该系数不是最后一个非0系数,last_ significant_coeff_flag[i]=0,否则=1,当等于1时不需要再对宏块剩余的0系数进行编码3.对应那些significant_coeff_flag[i]=1的系数,要编码coeff_absolute_value_minus_1和coeff_sign,对于前者,采用UEG0编码(UCoff=14),对于后者直接采用旁路编码器(将在后文说到)上下文定义与分配首先,每个语法元素对应一个或者多个上下文指示器context_id,经过二进制转换后的语法元素可能有不止一位的二进制值,以mb_type_I(I帧图像内的宏块类型)为例,对应的context_id为ctx_mb_type_I,该语法元素二进制化后有6位二进制值,分别对应ctx_mb_type_I[k],1<=k<=6即max_idx_ctx_id=6,而每个context_id 对应一定范围内的上下文变量context label,可参看下表:具体每个CTX_ID[K]对应哪几个LABEL可进一步参考下表:上下文模板具体某一位context_id[k]可能对应几个不同的context label,那么究竟具体对应哪个就由上下文模板来决定,上下文模板将在下面进行说明;一.利用两个相邻符号的上下文模板如图所示,正要编码的符号S是在当前宏块块C中,A,B是C的相邻宏块通过关系式:ctx_var_spat=cond_term(A,B) (9-1)计算出符号S的上下文增量X,通过用OFFSET+X得出对应的context label的值。

其中cond_term()表示的是一种函数关系,对于9-1式,有以下3种具体情况:此外,ctx_coded_block依赖的是表9-28中的6种块类型,对于上下文变量ctx_abs_mvd_h[1]和ctx_abs_mvd_v[1],按以下式子编码:二、利用先前bin值的上下文模板关系式:对应的表格:三.关于变换系数信息的上下文定义有关变换系数的上下文信息都由context_category决定,参看context_category的定义表:ctx_sig_coeff和ctx_last_coeff对应的是significant_coeff_flag和last_significant_coeff_flag,有以下关系式:其中scanning_pos指示的位置与zig-zag扫描相关,对于ctx_abs_level包含2个变量ctx_abs_level[1]和ctx_abs_level[2],有以下关系式:其中num_decod_abs_lev_eql指的是已编码的绝对值等于1的系数,Num_decod_abs_lev_gtl指的是已编码的绝对值大于1的系数(两者都在当前宏块中计算)上下文模型的初始化前文解决了如何给语法元素的每一位分配context label的问题,现在来解决一下究竟每一个context label对应什么样的状态。

首先是状态的初始化问题,状态包含一个代表状态的数字和MPS(最大概率符号),实质上上下文模型状态的初始化是由该帧图像的量化参数QP决定的,对于每一个context label都分配一对数组{m,n},状态的初始化按以下的三步进行:1.计算pre_state=((m*(QP-12))>>4)+n;2.对于P和B帧图像限制pre_state在[0,101]内,对于I帧图像,限制pre_state在[27,74]内,即pre_state= min(101,max(0, pre_state)) (对P和B帧),pre_state=min (74,max(27, pre_state)) (对I帧)3.将pre_state按以下规则映射到数组{state,MPS},规则:如果pre_state<=50, {state=50- pre_state,MPS=0},否则{state= pre_state-51,MPS=1}对于不同context label的{m,n}分配,参看以下表格:基于表格的算术编码算术编码是基于区间细分的,CABAC的算术编码有以下3个明显性质:1.概率的估计是对小概率符号LPS的概率而言的,是通过基于表格中64个不同状态之间的转换而实现的。

2.区间长度R通过一组预先量化的值{Q1,Q2,Q3,Q4}进行量化以计算新的间隔区间。

通过储存一个64*4的表格(Qi*Pk)来避免R*Pk的乘法运算。

3.一个独立的编码路径(旁路编码)用于对近似均匀分布(Plps=0.5)的语法元素一. 概率估计概率估计在H.264/A VC 中的免除乘法的二进制编码基本思想依赖于一个假设:每一个上下文模型估计的概率可以用一个有效的有限的特征值集合来表征。

对于CABAC ,对LPS 有64个特征概率值[0.01875,0.5]p σ∈。

11/6301 (63)0.01875()0.50.5p p for all and p σσασα-====伸缩因子0.95α≈,N =64一方面想要获得快速的自适应0;α→N 要小;另一方面,如果想获得更加稳定更加精确的估计,则1;α→需要更大的N 。

注意在MQ 编码中,在CABAC 方法中,不需要对LPS 的概率值{|063}p σσ≤≤进行表格化。

在算术编码中,每一个概率p σ仅仅用其相关的索引σ作为地址。

这样设计的结果导致,CABAC 中的每一个上下文模型可以有两个参数完全决定:LPS 概率当前估计值(063σ≤≤)和MPS 的值ϖ(0或者1)。

这样,在CABAC 的概率估计中有128个不同的状态,每一个状态用一个7位整型数来表达。

实际上,有一个状态的索引(63σ=)与一个自治的非自适应的状态相关,它带有一个固定值的MPS ,它仅仅在算术码字终止前用于编码二进制决定位(binary decisions ).因此只有126个有效概率状态。

1)概率状态的更新对于一个给定概率状态,概率的更新取决于状态索引和已经编码的符号值(MPS or LPS )。

更新过程导致一个新的概率状态,潜在的LPS 概率修正,如果有必要需要修改MPS 的值。

62max(,),,M PS (1),M PS LPS old new old p p if a M PS occurs p p if a LPS occurs ααα⋅⎧=⎨⋅+-⎩保持不变,与切换表格9-35显示的是编码MPS 或LPS 后的状态转移规则。

对于I 帧图像来说把状态控制在前24个内是有利的,因此,表9-35包含了独立的一列用作I 帧图像。

在编码一个MPS 或者LPS 后,概率估计自动从一个状态转移到另外一个状态进行自动更新,对于I 帧图像来说,有:If (decision==MPS)State<-Next_State_MPS_INTRA(State)ElseState<-Next_State_LPS (State)对于其他帧的图像来说,有:If (decision==MPS)State<-Next_State_MPS (State)ElseState<-Next_State_LPS (State)此外,当状态在0的时候(就是Plps=0.5), 如果编码得到的是一个LPS,那么LPS的概率就超过了原来MPS的概率,因此,LPS与MPS的值要进行交换。

二.算术编码器的总体描述算术编码器的情形是由一个指向编码子区间的V值和一个表示该区间长度的R值描述的。

图9-3显示了编码的流程:对于编码器的初始化(InitDecoder),将在后文中谈到,其中V和R将被初始化。

对于每一个编码决定的S(具体说编1或者0),有两个步骤。

一是读取上下文模型,上文已经解决了该问题;二是根据上下文决定S的值,这将在后面给出。

A.算术编码器的初始化初始化如图9-4所示,V是通过GetByte函数获得2个压缩数据的字节,R的初始化设置为0x8000。

关于GetByte函数:图9-7显示了压缩数据是如何输入的;首先,一个新的压缩数据的字节从比特串C中读取,然后指向当前比特串位置的CL增加1,比特计算器BG被设置成7B.编码决定图9-5显示的是一个编码决定,即决定具体编码的符号是MPS还是LPS。

相关文档
最新文档