WO2012159295A1 - 一种熵解码方法、装置 - Google Patents

一种熵解码方法、装置 Download PDF

Info

Publication number
WO2012159295A1
WO2012159295A1 PCT/CN2011/076357 CN2011076357W WO2012159295A1 WO 2012159295 A1 WO2012159295 A1 WO 2012159295A1 CN 2011076357 W CN2011076357 W CN 2011076357W WO 2012159295 A1 WO2012159295 A1 WO 2012159295A1
Authority
WO
WIPO (PCT)
Prior art keywords
decoding
suffix
codeword
prefixnum
variable
Prior art date
Application number
PCT/CN2011/076357
Other languages
English (en)
French (fr)
Inventor
徐苏珊
Original Assignee
深圳市融创天下科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市融创天下科技股份有限公司 filed Critical 深圳市融创天下科技股份有限公司
Publication of WO2012159295A1 publication Critical patent/WO2012159295A1/zh

Links

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
    • H03M7/30Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction
    • H03M7/40Conversion to or from variable length codes, e.g. Shannon-Fano code, Huffman code, Morse code

Definitions

  • the present invention relates to the field of video coding and decoding, and in particular, to an entropy decoding method and apparatus.
  • video coding technology effectively solves the problem of encoding and compressing massive digital video data. It is the premise of digital information transmission, storage and playback.
  • the mainstream international standards for video compression mainly include MPEG-x and H.26x.
  • These video coding algorithms are block-based hybrid coding methods, which eliminate video time redundancy by motion estimation and motion compensation, and discretize the difference image.
  • the cosine transform transform eliminates spatial redundancy and performs variable length coding on the quantized coefficients to eliminate statistical redundancy.
  • H.264/AVC the latest standard jointly introduced by the advantages of H.263+ and MPEG-4
  • H.263+ and MPEG-4 ASP standards 50% of the code stream is saved under the same reconstructed image quality.
  • the high compression performance of H.264 comes at the cost of high codec complexity.
  • H.264 uses two broad categories of entropy coding methods: arithmetic coding and variable length coding. Variable length coding is further divided into exponential Columbus coded Exp-Golomb and context-based adaptive variable length coding CAVLC. Index Columbus coding uses a fixed coding rule to encode various syntax elements, such as image sequence parameters, image layer parameters, slice parameters, macroblock types, coding block types, etc.; and prediction residual coefficients are encoded according to entropy coding mode.
  • CABAC Context-based Adaptive Binary Arithmetic Coding
  • CAVLC For applications such as real-time video communication such as mobile video, the entropy codec technology generally uses CAVLC codec and index Columbus codec. CAVLC still adopts the Huffman coding idea to construct a binary tree with the smallest length of the weighted path according to the probability of occurrence of characters, so that the average codeword length is the shortest, and the prefixes of each symbol code are different, that is, the coding of any symbol. Neither will be a prefix for another symbolic code. Based on the traditional variable length coding method, CAVLC defines multiple sets of code tables by introducing an adaptive model of context, and dynamically switches the code table according to the characteristics of coded code words. Therefore, CAVLC is in the currently published video standard. The most efficient coding adaptive variable length coding technique.
  • the main steps of the traditional entropy decoding operation are as follows: Read the received binary code stream and then traverse the lookup table matching codeword bit by bit. This requires repeatedly querying the variable length code table to determine the exact matching codeword, thereby determining the codeword. Decoding according to the corresponding relationship between the codeword and the corresponding syntax element, and obtaining the value of the corresponding syntax element. However, this also causes the CAVLC decoding process to be too computationally intensive. On the one hand, CAVLC decoding must distinguish codewords of different lengths from successive bitstreams. For example, the full search algorithm needs to traverse the entire binary tree, which requires multiple readings and judgments. Therefore, the table lookup process takes a lot of time; Since the codeword tree is sparse, the storage space of the code table increases with the length of the codeword. The index has grown, but most of it is vacant and has not been used effectively.
  • the lookup table operation here mainly involves two technical problems: 1) How to determine the complete codeword of variable length; 2) Indirectly obtain the corresponding syntax element from the codeword by looking up the table.
  • it is first necessary to store a complex variable length code table in the memory.
  • bit by bit traversing the lookup table to match the code words, and repeatedly reading and writing memory operations will also lead to a sharp increase in power consumption.
  • the operation of entropy decoding can generally be implemented by a Look Up Table (LUT) structure.
  • LUT Look Up Table
  • the lookup table mode can obtain better speed by occupying memory space, but these methods are suitable for embedded terminals such as mobile phones and PDAs. Resources are often very limited, and the lookup table traverses the lookup table to match the codewords in the decoding process. Repeated read and write memory operations also lead to a sharp increase in power consumption. Therefore, it is necessary to propose an entropy suitable for low resource requirements of embedded platforms. Decoding implementation method.
  • An object of the embodiments of the present invention is to provide an entropy decoding method and apparatus.
  • the entropy decoding method is specifically:
  • an embodiment of the present invention further provides an entropy decoding apparatus, where the apparatus includes: an acquiring unit, a decoding mode determining unit, a variable length code decoding unit, and a fixed length code decoding unit; and an acquiring unit, configured to acquire a binary a bitstream, obtaining a prefix portion of the codeword according to the binary bitstream; acquiring the first variable according to the binary bitstream;
  • a decoding mode determining unit configured to determine after acquiring the first variable; if the first variable is within the variable length codeword parameter range, determining that the decoding mode is one of the first to fourth decoding modes; Within the range of the word parameters, determining that the current codeword is a fixed length codeword; a variable length code decoding unit, configured to determine, according to the prefix, whether the current codeword is based on the prefix in one of the determined first to fourth decoding modes It is a special short code; if it is decoded according to a preset special short code decoding formula, the first parameter and the second parameter are obtained; if otherwise, the corresponding decoding formula is selected according to the prefix part of the code word for decoding, and an index is obtained.
  • the fixed length code decoding unit is configured to: when determining that the current codeword is a fixed length codeword, set an index value equal to the fixed length codeword; obtain according to the index value The first parameter and the second parameter.
  • An object of the embodiments of the present invention is to provide an entropy decoding method and apparatus.
  • the codeword rules and the order of the code table are newly designed.
  • the order index of the codewords in the code table is calculated according to the codeword rules, and the syntax elements in the code table are indexed and sorted.
  • Fast decoding operation is directly calculated into a simple arithmetic expression to calculate the corresponding syntax element value.
  • the embodiment of the present invention eliminates the operation of traversing the binary tree and the operation of matching the codeword, thereby greatly reducing the requirement of the entropy coding algorithm for hardware such as memory.
  • FIG. 1 is a flow chart of a preferred embodiment of the entropy decoding method of the present invention
  • FIG. 2 is a diagram showing a relationship between a current macroblock and a left and upper macroblock of a preferred embodiment of the entropy decoding method of the present invention
  • 3 is a schematic structural diagram of a preferred embodiment of an entropy decoding apparatus of the present invention
  • FIG. 4 is a decoding mode determining unit in a preferred embodiment of the entropy decoding apparatus of the present invention.
  • FIG. 5 is a special short code decoding unit in a preferred embodiment of the entropy decoding apparatus of the present invention.
  • FIG. 6 is an entropy decoding apparatus of the present invention.
  • Non-special short code decoding unit in a preferred embodiment
  • a macroblock is the basic unit of video coding.
  • the macroblock size is 16x16.
  • Each macroblock consists of four 4x4 blocks, each block consisting of one 4x4 luma block and two chroma blocks.
  • the predicted and quantized residual coefficients require the corresponding syntax elements of the image block residual coefficients to be obtained by scanning.
  • the syntax elements that need to be encoded are: Level (the magnitude of non-zero coefficients), Run (a continuous zero-coefficient run before a non-zero coefficient), and data terminators.
  • the entropy coding performs pre-processing on the Zigzag scan of the system after the prediction transform is quantized, and the non-zero coefficient encountered in the scan is recorded as Level, and the continuous zero-coefficient run before the non-zero coefficient is recorded as Run.
  • the entropy coding of video coding is encoded in addition to the syntax elements of the residual coefficients, and other syntax elements of the auxiliary information need to be encoded, such as motion vectors, image sequence parameters, picture layer parameters, slice parameters, macroblock types. , coding block type, etc.
  • CAVLC of H.264/AVC video coding standard defines multiple sets of code tables based on the adaptive model of context, and dynamically according to the characteristics of coded code words.
  • the code table is switched, and the Level and Run are separately coded, and the best coding efficiency effect in the currently released video standard is obtained.
  • the basic principle of CAVLC coding still follows the Huffman coding principle, that is, the symbol with high probability is assigned a short codeword, and the symbol with a small probability is assigned a long codeword, so as to achieve the shortest average code length.
  • the embodiment of the present invention will follow the basic idea of the CAVLC coding method of the H.264/AVC video coding standard and the statistical probability distribution of the corresponding syntax elements, but the code table is completely new. Therefore, the residual coefficient syntax elements that need to be processed mainly include: (a) coeff_token (the number of non-zero coefficients TotalCoeff and the number of trailing coefficients TrailingOnes); (b) the sign of the trailing coefficient trailing- ones-sign- Flag; (c) non-zero coefficient ⁇ value (Level); (d) total-zeros; (e) run- before.
  • coeff_token the number of non-zero coefficients TotalCoeff and the number of trailing coefficients TrailingOnes
  • the sign of the trailing coefficient trailing- ones-sign- Flag (c) non-zero coefficient ⁇ value (Level); (d) total-zeros; (e) run- before.
  • the decoding operation of these parameter coefficient syntax elements mainly requires two technical conditions: the requirement of memory resources and the power consumption of the bit-by-bit traversal lookup table, which poses a challenge to the video decoding design of the embedded terminal.
  • the codewords are sorted by introducing a code table sequential index by analyzing the probability distribution of the codeword rules and the syntax elements, and the special short expressions of the high-frequency special short codewords are directly calculated into corresponding corresponding expressions.
  • the value of the syntax element eliminates the operation of traversing the binary tree and the operation of matching the codeword, thereby greatly reducing the requirement of the entropy coding algorithm for hardware such as memory, and is very suitable for the method and system for entropy decoding application of the embedded terminal.
  • each syntax element of the residual coefficient is designed with multiple code tables, which are adaptively selected through context.
  • the Huffman coding principle that is, a symbol with a high probability of assigning a short codeword and a symbol with a small probability of a long codeword, thereby achieving the shortest average code length.
  • the codeword in the code table constructs the binary tree with the smallest length of the weighted path according to the probability of occurrence of the syntax element, so that the average codeword length is the shortest, and the prefixes of each symbol code are different, that is, the coding of any syntax symbol is It does not become a prefix for another syntax symbol encoding.
  • Embodiment 1 According to the above idea, an embodiment of the present invention provides an entropy decoding method, where the method may be: acquiring a first variable according to a binary bit stream;
  • the method further includes the step of: obtaining a prefix portion of the codeword in the binary bitstream before the "decoding according to the type of the current codeword using the corresponding decoding method";
  • Decoding according to the type of the current codeword by using a corresponding decoding method may be: when determining that the current codeword is a variable length codeword, determining that the decoding mode is a variable length codeword decoding mode; according to the prefix portion of the codeword Determining whether the current codeword is a special short code, if yes, decoding according to a preset special short code decoding formula to obtain a first parameter and a second parameter; if otherwise, selecting according to the prefix in the variable length codeword decoding mode The preset decoding formula is decoded to obtain an index value, and the first parameter and the second parameter are obtained according to the index value.
  • decoding according to the type of the current codeword using the corresponding decoding method may be: determining that the decoding mode is a fixed length codeword decoding mode; setting the index value value equal to the fixed length codeword The value is used to find a preset fixed length code table according to the index value, and obtain a first parameter and a second parameter corresponding to the index value.
  • Step 101 Obtain a first variable (NC); if the first variable (NC) is within a variable length codeword parameter range, for example, may be -1 ⁇ NC ⁇ 8; then determine that the decoding mode is the first to fourth decoding modes. If the first variable (NC) is within the range of the fixed length codeword parameter, for example, NC ⁇ 8, then the current codeword is determined to be a fixed length codeword, and step 106 is performed; The first variable obtained in this step (the method of Ncy can be:
  • Step 102 Acquiring a binary bitstream, and obtaining a prefix portion of the codeword according to the binary bitstream;
  • the prefix portion may be obtained by using a first "1" detector;
  • Step 103 In the first to fourth decoding modes determined in step 101, determining whether the current codeword is a special short code according to the prefix; if yes, performing the step 104; If otherwise, step 105 is performed; the step may be: assigning the number of "0"s of the prefix part to the intermediate variable PrefixNum, and then determining whether the codeword is special according to the relationship between the intermediate variable PrefixNum and the threshold.
  • Short code can be determined according to the first variable NC, for example:
  • the threshold S can be set to 3, and when PrefixNum ⁇ 3, it is determined that the current codeword is a special short code
  • the threshold S can be set to 2, and when PrefixNum ⁇ 2, it is determined that the current codeword is a special short code
  • the threshold S can be set to 1, and when PrefixNum ⁇ 1, it is determined that the current codeword is a special short code
  • Step 104 The first to the determined in step 101 In one of the fourth decoding modes, decoding is performed according to a preset special short code decoding formula, and the first parameter TrailingOnes and the second parameter are obtained. TotalCoeff;
  • TrailingOnes 3 (Suffix/4)+(Suffix%4) (l-Suffix/4)
  • TrailingOnes are actually the same, the former one is simple calculation, and the latter one is based on bit operation;
  • TrailingOnes is the first parameter
  • TotalCoeff is the second parameter
  • PrefixNum is the intermediate variable
  • Prefix is the prefix
  • Suffix is the suffix
  • Suffix[2:0] represents the 2nd to 0th bit of the 3-bit binary number
  • Suffix[l: 0] represents a 2-bit binary number from the 1st to the 0th bit
  • Suffix[2:2] represents a 1-bit binary number of the 2nd bit.
  • PrefixNum [1 : 0] represents the 2-bit binary number from bit 1 to bit
  • PrefixNum[l : l] represents the 1-bit binary number of the first
  • PrefixNum [0:0] represents The 1-bit binary number of the 0th bit.
  • Step 105 Decoding according to the prefix selection corresponding preset decoding formula in the first to fourth decoding modes determined in step 101, obtaining an index value, and the index value characterizing the syntax element (the first parameter TrailingOnes and The second parameter TotalCoeff) is arranged in order to obtain the first parameter TrailingOnes and the second parameter TotalCoeff according to the index value.
  • the step of decoding is performed according to determining different decoding modes and selecting a corresponding preset decoding formula by using the prefix, and obtaining an index value may be:
  • Index is the index value
  • PrefixNum is the intermediate variable
  • Suffix is the suffix
  • "" means the bitwise left shift operation.
  • Index is the index value
  • PrefixNum is the intermediate variable
  • Suffix is the suffix
  • "" means the bitwise left shift operation.
  • the obtaining the index value, obtaining the first parameter and the second parameter according to the index value may be: after obtaining the index value, in determining one of the first to fourth decoding modes, according to The index value searches for a preset parameter table, and obtains a first parameter and a second parameter corresponding to the index value.
  • the corresponding parameter table of the search preset is Table 2
  • the first variable length code table (VLC-1) in the second decoding mode, the parameter table of the corresponding search preset is Table 3.
  • the corresponding parameter table for finding the preset is Table 5, the fourth variable length code table (VLC-4).
  • the current codeword determined in step 101 is a fixed length codeword; if the fixed length codeword length is a preset length, the index value Index is set to be equal to the fixed length codeword; and the first parameter is obtained according to the index value.
  • the preset length of the fixed length codeword is an integer not less than log 2 N, and N is the number of values of the syntax element; in this example, the preset length may be 6.
  • the step may be: when determining that the current codeword is a fixed length codeword, after setting the index value equal to the fixed length codeword, searching for the preset fixed length code table according to the index value, and obtaining the first parameter corresponding to the index value and The second parameter.
  • step 105 since it is determined to be the first decoding mode
  • PrefixNum is the intermediate variable
  • Suffix is the suffix
  • Suffixlength is the suffix length
  • && means "and”
  • (judgment condition) ? a: b” means: when the judgment condition is established, then a, when the judgment condition is not true Take b.
  • step 102 a binary bit stream OOlOllOxxxxx is obtained, and the prefix part is 0010110;
  • the intermediate variable is obtained.
  • a binary bit stream OOOO Ol lOlxxxx is obtained, then the prefix part is 0000 01;
  • step 105 since it is determined to be the second decoding mode
  • PrefixNum is the intermediate variable
  • Suffix is the suffix
  • Suffixlength is the suffix length
  • "? : " is the conditional operator.
  • step 102 a binary bit stream 011011 lxxx is obtained, and the prefix part is 01;
  • step 102 a binary bit stream 0000 OllOlxxxx is obtained, and the prefix part is 000001;
  • step 105 since it is determined to be the third decoding mode
  • Index ((PrefixNum-3) «2) Ten Suffix where Index is the index value, PrefixNum is the intermediate variable, Suffix is the suffix, and "" means the bitwise left shift operation.
  • step 102 a binary bit 10011 lxxx is obtained, then the prefix part is
  • TrailingOnes 3 (Suffix/4)+(Suffix%4) (l-Suffix/4)
  • the suffix "001" can be obtained according to the binary bit stream 10011 lxxx;
  • TrailingOnes are actually the same, the former one is simple calculation, and the latter one is based on bit operation;
  • TrailingOnes is the first parameter
  • TotalCoeff is the second parameter
  • Prefix is the prefix
  • step 102 a binary bit stream OOOO OlOOlxxxx is obtained, and the prefix part is 0000 01;
  • step 105 since it is determined to be the fourth decoding mode;
  • Index ((PrexfixNum-3) «2)
  • Index is the index value
  • PrefixNum is the intermediate variable
  • Suffix is the suffix. "" indicates a bitwise left shift operation.
  • TrailingOnes is the first parameter
  • TotalCoeff is the second parameter
  • PrefixNum is the intermediate variable
  • PrefixNum [1:0] represents the 1-bit binary number from the 1st to the 0th
  • Suffix[l:l] Indicates the 1-bit binary number of the first
  • Suffix[0:0] represents the 1-bit binary number of the 0th bit. " ⁇ " indicates that the bit is inverted.
  • the codeword is a fixed length codeword"; therefore, it can be determined that the current codeword is a fixed length codeword;
  • step 106 a binary bit 10011 lxxx is obtained.
  • the embodiment of the present invention further provides an entropy decoding apparatus.
  • the apparatus includes: an acquiring unit, a codeword type determining unit, and a decoding unit;
  • the obtaining unit is configured to acquire a first variable according to a binary bit stream;
  • a codeword type determining unit configured to determine a type of the current codeword according to a range of the first variable
  • a decoding unit configured to perform decoding according to a type of the current codeword by using a corresponding decoding method.
  • the obtaining unit includes:
  • bitstream acquisition unit configured to acquire a binary bitstream
  • the first variable acquisition unit is configured to acquire the first variable.
  • the first variable acquiring unit is configured to: obtain the first variable specifically:
  • the first variable the number of second non-zero coefficients
  • the first variable the number of first non-zero coefficients.
  • the obtaining unit further includes a prefix obtaining unit, configured to obtain a prefix portion of the current codeword according to the binary bit stream;
  • the codeword type determining unit is further configured to determine, according to a range of the first variable, that the type of the current codeword is a variable length codeword;
  • the decoding unit includes: a decoding mode determining unit, a determining unit, and a special short code decoding unit; a mode determining unit, configured to: when determining that the current codeword is a variable length codeword, determine that the decoding mode is a variable length codeword decoding mode;
  • a determining unit configured to determine, according to a prefix portion of the codeword, whether the current codeword is a special short code when determining that the decoding mode is a variable length codeword decoding mode
  • a special short code decoding unit configured to determine a current codeword as a special short code according to a preset
  • the special short code decoding formula is decoded to obtain the first parameter and the second parameter.
  • the codeword type determining unit is configured to determine, according to the range of the first variable, that the type of the current codeword is a variable length codeword, which is specifically: when -1 ⁇ the first variable ⁇ 8, the type of the current codeword is determined.
  • Variable length code word is specifically: when -1 ⁇ the first variable ⁇ 8, the type of the current codeword is determined.
  • the structure of the decoding mode determining unit is shown in FIG. 4.
  • the unit includes: a first decoding mode determining unit, a second decoding mode determining unit, a third decoding mode determining unit, and a fourth decoding mode determining unit;
  • a first decoding mode determining unit configured to determine that if 0 ⁇ the first variable ⁇ 2, determine to decode the first decoding mode
  • a second decoding mode determining unit configured to determine that if the second variable ⁇ 4, the second decoding mode is determined to be decoded
  • a third decoding mode determining unit configured to determine that if the third variable ⁇ 8, the third decoding mode is determined to be decoded; and the fourth decoding mode determining unit is configured to determine that if the first variable is -1, the determining is The fourth decoding mode is decoded.
  • the decoding mode determining unit determines that one of the first to fourth decoding modes is to be decoded
  • the determining unit is configured to determine, according to the prefix, whether the current codeword is a special short code according to the prefix when determining that the decoding mode is a variable length codeword decoding mode:
  • the structure of the special short code decoding unit is specifically as follows:
  • the special short code decoding unit includes a first special short code decoding unit;
  • the first special short code decoding unit is configured to, when determining to be the first decoding mode,
  • TrailingOnes is the first parameter
  • TotalCoeff is the second parameter
  • PrefixNum is the middle.
  • TrailingOnes is the first parameter
  • TotalCoeff is the second parameter
  • PrefixNum is the intermediate variable
  • Suffix is the suffix
  • Prefix is the prefix
  • Suffixlength is the suffix length
  • "" indicates the bitwise left shift operation
  • TrailingOnes is the first parameter
  • TotalCoeff is the second parameter
  • PrefixNum is the intermediate variable
  • PrefixNum [1:0] represents the 1-bit binary number from the 1st to the 0th
  • PrefixNum[l:l] represents the 1st.
  • Bit binary number PrefixNum [0:0] represents the 1-bit binary number of the 0th bit
  • " ⁇ " means the bit is inverted.
  • the decoding unit further includes: a non-special short code decoding unit, configured to: when determining, according to the prefix portion of the codeword, that the current codeword is not a special short code, according to the variable length codeword decoding mode, The prefix part of the codeword is selected to be decoded by the corresponding preset decoding formula to obtain an index value, and the first parameter and the second parameter are obtained according to the index value.
  • the non-special short code decoding unit further includes a second decoding unit; when used to determine the second decoding mode,
  • Index (PrefixNum-3) «2) + Suffix
  • Index is the index value
  • PrefixNum is the intermediate variable
  • Suffix is the suffix
  • "" means the bitwise left shift operation
  • Index (PrefixNum-3) «3) + Suffix
  • Index is the index value
  • PrefixNum is the intermediate variable
  • Suffix is the suffix.
  • "" indicates a bitwise left shift operation.
  • the "acquiring index value, obtaining the first parameter and the second parameter according to the index value" described in the non-special short code decoding unit is specifically: after obtaining the index value, in the determined variable length decoding mode And searching for the preset parameter table according to the index value, and acquiring the first parameter and the second parameter corresponding to the index value.
  • the decoding mode determining unit further includes: a fixed length codeword decoding mode determining unit; a fixed length codeword decoding mode determining unit, configured to determine that if the first variable is ⁇ 8, determine that the fixed length codeword decoding mode is performed.
  • the decoding unit further includes: a fixed length codeword decoding unit, configured to determine that the decoding mode is a fixed length codeword decoding mode; set an index value value equal to a fixed length codeword value, and search for a preset according to the index value.
  • the fixed length code table obtains the first parameter and the second parameter corresponding to the index value.
  • An object of the embodiments of the present invention is to provide an entropy decoding method and apparatus.
  • the codeword rules and the order of the code tables are newly designed, according to the codeword rules.
  • the order index of the code words in the code table is calculated, and the syntax elements in the code table are indexed and sorted, thereby implementing a fast decoding operation.
  • a special short codeword with a high frequency of use is directly calculated into a simple arithmetic expression to calculate the corresponding syntax element value.
  • the embodiment of the invention eliminates the operation of traversing the binary tree and the operation of matching the codeword, thereby greatly reducing the requirement of the entropy coding algorithm for hardware such as memory.

Abstract

公开了一种熵解码方法和装置。该方法包括:获取二进制比特流;获取第一变量;根据第一变量的范围确定当前码字的类型;根据当前码字的类型采用相应的解码方法进行解码。该装置包括:获取单元、码字类型确定单元以及解码单元。该方案通过分析语法元素的概率分布情况,对码字规则和码表排列顺序进行设计,根据码字规则计算出码表中码字的顺序索引,对码表中的语法元素进行索引排序,进而实现快速解码。

Description

技术领域
本发明涉及视频编解码领域, 尤其涉及一种熵解码方法、 装置。
背景技术
视频编码技术作为多媒体通信中最重要的环节之一,有效地解决了海量数 字视频数据的编码压缩问题, 它是数字信息传输、 存储、 播放等环节的前提。 目前主流的视频压缩国际标准主要有 MPEG-x和 H.26x等,这些视频编码算法 都是基于块的混合编码方法, 即通过运动估计和运动补偿消除视频时间冗余, 对差值图像进行离散余弦变换变换消除空间冗余,对量化后的系数进行可变长 编码消除统计冗余。
2003年, ISO/IEC (动态图像专家组) 的运动图像专家组(MPEG Moving Pictures Experts Group/Motion Pictures Experts Group )与 ITU-T (ITU-T for ITU Telecommunication Standardization Sector 国际电信联盟远程通信标准化组织) 的视频编码专家组 (VCEG) 联手制定了最新的视频编码标准 H.264/AVC (集 合 H.263+和 MPEG-4的优点联合推出的最新标准),其主要目的是获得更高的 编码效率和更好的网络亲和性。在相同重构图象质量下,与 H.263 +和 MPEG-4 ASP标准相比,节约 50%的码流。 H.264的高压缩性能是以高编解码复杂度为 代价的。 诸多新的编码算法被采用: 帧内预测、 多参考帧运动补偿、 增强的熵 编码、 去方块滤波等。这导致了视频编解码的复杂性显著增大, 庞大的运算量 会造成严重的功耗, 这些都对嵌入式平台的视频熵解码实现提出挑战。
在 H.264/AVC标准中, 残差数据经过整数变换、 量化后被送往熵编码器 进行编码。 H.264采用了两大类熵编码方法: 算术编码和可变长度编码。 可变 长编码又分为指数哥伦布编码 Exp-Golomb 和基于上下文的自适应变长编码 CAVLC。 指数哥伦布编码采用固定的编码规则对各种语法元素进行编码, 如 图像序列参数、 图像层参数、 片层参数、 宏块类型、 编码块类型等; 而预测残 差系数的编码需要根据熵编码模式来选择使用基于上下文的 CAVLC自适应变 长编码 (Context-based Adaptive Variable Length Coding, 自适应变长编码)或是 基于上下文的二进制算术编码(Context-based Adaptive Binary Arithmetic Coding, CAB AC) H.264/AVC视频编码标准的 CAVLC熵编码充分利用了上下 文信息, 通过建立多个码表自适应选择优化, 取得了良好的编码效果。 H.264/AVC的 CABAC熵编码属于算术编码器,算术编码的性能要优于变长编 码, 而且 CABAC通过自适应的概率估计和更新以及二进制算术编码, 更加逼 近香农定理, 编码效果更高, 但其算法计算复杂度高, 硬件实现要求复杂, 是 一种以软硬件的复杂度换取编码效率的提高。
对于移动视频等实时视频通信这类应用场合, 熵编解码技术一般采用 CAVLC编解码和指数哥伦布编解码。 CAVLC仍采用了哈夫曼编码的思想依据 字符出现概率来构造带权路径长度最小的二叉树从而实现平均码字长度最短, 且各个符号编码的字头都是相异的,即任何一个符号的编码都不会成为另一个 符号编码的前缀。 CAVLC在传统变长编码方法的基础上, 通过引入上下文的 自适应模型, 定义了多组码表, 根据编码码字特征, 动态的进行码表切换, 因 此, CAVLC是以目前已发布视频标准中编码效率最高的上下文自适应变长编 码技术。
传统的熵解码操作的主要步骤如下: 读取接收到的二进制码流, 然后逐位 遍历查找表匹配码字, 这需要反复查询变长码表, 确定了完全匹配的码字, 从 而确定码字, 根据码字在码表和相应语法元素的相应关系进行解码, 获得相应 语法元素的数值。但是,这也导致了 CAVLC的解码过程计算量过大。一方面, CAVLC解码必须从连续的比特流中分辨各个长度不定的码字, 如采用全搜索 算法需要遍历整个二叉树, 需要进行多次读取和判断, 因此查表过程耗费时间 很多; 另一方面, 由于码字树很稀疏, 码表的存储空间随着码字长度的增加成 指数增长, 但其中的绝大部分是空置的, 没有得到有效利用。
具体来看, 这里的查找表操作主要涉及两个技术问题: 1 ) 如何确定变长 的完整码字; 2) 由码字通过查表间接获得相应的语法元素。 显然, 要解决这 两个技术问题, 首先需要内存中保存着复杂的变长码表, 其次, 逐位遍历查找 表匹配码字, 反复读写内存操作也会导致功耗的剧增。
综上所述, CAVLC的编码高效率是以众多的码表为代价的, 过多的码表 意味着编解码操作需要更多的计算资源。 熵解码的操作一般可以采用查找表 (Look Up Table, LUT)结构实现, 查找表模式会通过占用内存空间而获得较好 的速度, 但是这些方法对于诸如手机、 PDA 等嵌入式终端而言, 内存资源往 往是非常有限的, 而且解码过程中逐位遍历查找表匹配码字, 反复读写内存操 作也会导致功耗的剧增,因此有必要提出一种适用于嵌入式平台低资源要求的 熵解码实现方法。
发明内容
本发明实施例的目的在于提出一种熵解码方法、 装置。
该熵解码方法具体为:
根据所述的二进制比特流获取码字的前缀部分;
根据二进制比特流获取第一变量; 若第一变量在变长码字参数范围内, 则 确定解码模式为第一至第四解码模式其中之一; 若在定长码字参数范围内, 则 确定当前码字为定长码字;
在所述确定的第一至第四其中之一解码模式下,根据所述前缀判断当前码 字是否为特殊短码; 若是, 根据预置相应的特殊短码解码公式进行解码, 获得 第一参数和第二参数;若否则根据所述码字的前缀部分选择预置相应的解码公 式进行解码, 获得索引值, 根据索引值获得第一参数和第二参数;
当确定当前码字为定长码字时, 则设置索引值等于定长码字; 根据所述索 引值获取第一参数和第二参数。 相应于该方法, 本发明实施例还提供了一种熵解码装置, 所述装置包括: 获取单元、 解码模式确定单元、 变长码解码单元、 定长码解码单元; 获取单元,用于获取二进制比特流, 根据所述的二进制比特流获取码字的 前缀部分; 根据二进制比特流获取第一变量;
解码模式确定单元,用于在获取第一变量后进行判断; 若第一变量在变长 码字参数范围内, 则确定解码模式为第一至第四解码模式其中之一; 若在定长 码字参数范围内, 则确定当前码字为定长码字; 变长码解码单元,用于在所述确定的第一至第四其中之一解码模式下, 根 据所述前缀判断当前码字是否为特殊短码;若是根据预置相应的特殊短码解码 公式进行解码, 获得第一参数和第二参数; 若否则根据所述码字的前缀部分选 择预置相应的解码公式进行解码, 获得索引值, 根据索引值获得第一参数和第 二参数; 定长码解码单元,用于当确定当前码字为定长码字时, 则设置索引值等于 定长码字; 根据所述索引值获取第一参数和第二参数。
本发明实施例的目的在于提供一种熵解码方法、装置。通过分析语法元素 的概率分布情况,对码字规则和码表排列顺序进行全新设计, 根据码字规则计 算出码表中码字的顺序索引,对码表中的语法元素进行索引排序,进而实现快 速解码操作。此外,将部分高使用频率的特殊短码字直接简单算术表达式计算 出相应的语法元素数值。本发明实施例实施例消除了遍历二叉树的操作和匹配 码字的操作, 从而极大降低熵编码算法对内存等硬件的要求。
附图说明
图 1是本发明的熵解码方法的优选实施例的流程图;
图 2是本发明的熵解码方法的优选实施例的当前宏块与左边、上面宏块位 置关系图; 图 3是本发明的熵解码装置的优选实施例的结构示意图;
图 4 是本发明的熵解码装置的优选实施例中的解码模式确定单元的 图 5 是本发明的熵解码装置的优选实施例中的特殊短码解码单元的 图 6 是本发明的熵解码装置的优选实施例中的非特殊短码解码单元的
具体实施方式 为了使本发明的目的、技术方案及优点更加清楚明白, 以下结合附图和实 施例, 对本发明进行进一步详细说明, 为了便于说明, 仅示出了与本发明实施 例相关的部分。 应当理解, 此处所描写的具体实施例, 仅仅用于解释本发明, 并不用以限制本发明。
在视频编码中, 宏块是视频编码的基本单元, 宏块大小为 16x16, 每个宏 块由 4个 4x4块组成, 每个块由 1个 4x4亮度块和 2个色度块组成。 对于图 像块而言,预测和量化后的残差系数需要通过扫描获得图像块残差系数的相应 的语法元素。这些需要编码的语法元素主要有: Level (非零系数的幅值)、 Run (一个非零系数前的连续零系数游程)以及数据结束符等。通常熵编码先对预 测变换量化后的系统进行 Zigzag扫描进行预处理, 把扫描中遇到的非零系数 记为 Level, —个非零系数前的连续零系数游程记为 Run。 当然, 视频编码的 熵编码除了残差系数的语法元素进行编码,还有其他各种辅助信息的语法元素 需要进行编码, 如运动矢量、 图像序列参数、 图片层参数、 片层参数、 宏块类 型、 编码块类型等。
H.264/AVC视频编码标准的 CAVLC在传统变长编码方法的基础上, 通过 引入上下文的自适应模型, 定义了多组码表, 根据编码码字特征, 动态的进行 码表切换, 将 Level、 Run分开进行编码, 取得了目前已发布视频标准中最佳 编码效率效果。 CAVLC的编码基本原理仍然遵循 Huffman编码原理, 即大概 率的符号分配短码字、小概率的符号分配长码字, 从而达到平均码长最短的目 的。
因此,本发明实施例将遵循 H.264/AVC视频编码标准的 CAVLC编码方法 基本思想和相应的语法元素的统计概率分布, 但对码表进行了全新的设计。 因 此, 需要处理的残差系数语法元素主要包括: (a) coeff— token (非零系数个数 TotalCoeff 和拖尾系数的个数 TrailingOnes ) ; ( b ) 拖尾系数的符号 trailing— ones— sign— flag; ( c ) 非零系数巾 §值 (Level ); ( d ) total— zeros ; ( e ) run— before。
这些参数系数语法元素的解码操作主要需要两个技术条件:内存资源的要 求和逐位遍历查找表的功耗问题, 这对嵌入式终端的视频解码设计带来了挑 战。本发明实施例通过对码字规则和语法元素的概率分布分析,通过引入码表 顺序索引对码字进行了排序,并且将部分高使用频率的特殊短码字直接简单算 术表达式计算出相应的语法元素数值,消除了遍历二叉树的操作和匹配码字的 操作, 从而极大降低熵编码算法对内存等硬件的要求, 非常适合于嵌入式终端 的熵解码应用的方法和系统。
为了获得高的熵编码下来, 每个残差系数的语法元素, 设计了多张码表, 通过上下文自适应选择。 Huffman编码原理, 即大概率的符号分配短码字、 小 概率的符号分配长码字, 从而达到平均码长最短的目的。码表中的码字完全依 据语法元素出现概率来构造带权路径长度最小的二叉树从而实现平均码字长 度最短, 且各个符号编码的字头都是相异的, 即任何一个语法符号的编码都不 会成为另一个语法符号编码的前缀。 实施例 1, 依据上述思想, 本发明实施例提供了一种熵解码方法, 该方法可以是: 根据二进制比特流获取第一变量;
根据第一变量的范围确定当前码字的类型; 根据当前码字的类型采用相应的解码方法进行解码。
其中如果当前码字的类型为变长码字,那么在所述的 "根据当前码字的类 型采用相应的解码方法进行解码"之前还包括步骤: 获取二进制比特流中码字 的前缀部分;
"根据当前码字的类型采用相应的解码方法进行解码"可以为: 当确定当 前码字为变长码字时, 则确定解码模式为变长码字解码模式; 根据所述码字的 前缀部分判断当前码字是否为特殊短码,若是则根据预置相应的特殊短码解码 公式进行解码, 获得第一参数和第二参数; 若否则在变长码字解码模式下根据 所述前缀选择相应的预置解码公式进行解码, 获得索引值, 根据所述的索引值 获得第一参数和第二参数。
如果当前码字的类型为定长码字, "根据当前码字的类型采用相应的解码 方法进行解码 "可以为: 确定解码模式为定长码字解码模式; 设置索引值数值 等于定长码字数值, 根据所述的索引值查找预置的定长码表, 获取索引值相应 的第一参数与第二参数。
参见图 1, 该方法具体为:
在本发明实施例中, 设置第一参数为拖尾系数的个数 TrailingOnes, 设置 第二参数为非零系数个数 TotalCoeff;
步骤 101 : 获取第一变量 (NC) ; 若第一变量 (NC)在变长码字参数范围 内, 例如可以是 -1≤NC<8; 则确定解码模式为第一至第四解码模式其中之一; 若第一变量(NC)在定长码字参数范围内, 例如可以是 NC≥8, 则确定当前码 字为定长码字, 执行步骤 106; 该步骤中所述的"获取的第一变量 (Ncy的方法可以为:
( 1 ) 预先计算当前宏块左边 4X4宏块的第一非零系数数目 (NA) 和当 前宏块上面 4X4宏块的第二非零系数数目 (NB) ; 当前宏块与左边、 上面宏 块位置关系图, 参见图 2。
当 NA和 NB都有效时, NC=(NA+NB)/2;当 NB有效, NA无效时, NC=NB; 当 NB无效, NA有效时, NC=NA; 表 1 NC与 NA和 NB的相应关系
Figure imgf000009_0001
(2)该步骤中所述的"若 -1≤NC<8; 则确定解码模式为第一至第四解码模 式其中之一"可以为:
例如: 若 0≤NC<2, 则选择第一解码模式 (表 2, 第一变长码表 VLC-1 ) 进行解码;
若 2≤NC<4, 则选择第二解码模式 (表 3, 第二变长码表 VLC-2 ) 进行解 码;
若 5≤NC<8, 则选择第三解码模式 (表 4, 第三变长码表 VLC-3 ) 进行解 码; 若 NC=-1,则选择第四解码模式 (表 5, 第四变长码表 VLC-4) ;
(3 ) 该步骤中所述当 NC≥8, 则确定当前码字为定长码字进行解码; 步骤 102: 获取二进制比特流, 根据所述的二进制比特流获取码字的前缀 部分;
例如可以通过首" 1"检测器来获取前缀部分; 步骤 103 : 在步骤 101中确定的第一至第四解码模式下, 根据所述前缀判 断当前码字是否为特殊短码; 若是则执行步骤 104; 若否则执行步骤 105 ; 该步骤可以为:将所述前缀部分的" 0"的个数赋予中间变量 PrefixNum,然 后根据所述的中间变量 PrefixNum 与阈值的关系, 来确定码字是否为特殊短 码。 阈值 S可以根据所述的第一变量 NC来决定, 例如:
当 0≤NC<2 时为第一解码模式, 那么此时阈值 S 可以设置为 3, 当 PrefixNum<3时, 则确定当前码字为特殊短码;
当 2≤NC<4 时为第二解码模式, 那么此时阈值 S 可以设置为 2, 当 PrefixNum<2时, 则确定当前码字为特殊短码;
当 5≤NC<8 时为第三解码模式, 那么此时阈值 S 可以设置为 1, 当 PrefixNum<l时, 则确定当前码字为特殊短码;
当 NC=-1 时为第四解码模式, 那么此时阈值 S 可以设置为 3, 当 PrefixNum<3时, 则确定当前码字为特殊短码; 步骤 104: 在步骤 101中确定的第一至第四其中之一解码模式下根据预置 相应的特殊短码解码公式进行解码, 获得第一参数 TrailingOnes 和第二参数 TotalCoeff;
例如: ( 1 ) 当确定 0≤NC<2时为第一解码模式:
TrailingOnes=TotalCoeff=PrefixNum
(2 ) 当确定 2≤NC<4时为第二解码模式:
第二解码模式下特殊短码时, 根据预置的 SUffixlength=l读取二进制比特 流, 获取 Suffix;
TrailingOnes=TotalCoeff=(Prefix«l)+Suffix;
(3 ) 当确定 5≤NC<8时为第三解码模式:
第三解码模式下特殊短码时, 根据预置的 SUffixlength=3读取二进制比特 流, 获取 Suffix;
TotalCoeff= Suffix
TrailingOnes=3 (Suffix/4)+(Suffix%4) (l- Suffix/4)
或 TrailingOnes= 3xSuffix[2:2]+suffix[l :0] x(〜 Suffix[2:2])
其中, 获得 TrailingOnes的 2个公式实际是相同的, 前一个是简单计算, 后一个是根据位操作;
(4 ) 当确定 NC=-1时为第四解码模式,
TrailingOnes = TotalCoeff = 2 PrefixNum[l : l] + ( 〜 PrefixNum[0:0]) (- PrefixNum[l : l])
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 Prefix 为前缀、 Suffix为后缀, Suffix[2:0]表示第 2位到第 0位的 3比 特二进制数, Suffix[l :0]表示第 1位至第 0位的 2比特二进制数, Suffix[2:2] 表 示第 2位的 1比特二进制数。 PrefixNum [1 :0]表示第 1位到第 0位的 2比特二 进制数, PrefixNum[l : l]表示第 1为的 1比特二进制数, PrefixNum [0:0] 表示 第 0位的 1比特二进制数。 "/"表示除法运算符, "% "表示取余运算符, "~"表 示位取反运算符。 步骤 105; 在步骤 101中确定的第一至第四其中之一解码模式下根据所述 前缀选择相应的预置解码公式进行解码, 获得索引值, 索引值表征了语法元素 (第一参数 TrailingOnes和第二参数 TotalCoeff) 的排列顺序, 根据索引值获 得第一参数 TrailingOnes和第二参数 TotalCoeff。
该步骤根据确定不同的解码模式、所述前缀选择相应的预置解码公式进行 解码, 获得索引值可以为:
( 1 ) 确定为第一解码模式时,
Suffixlength=(PrefixNum>=9 && PrefixNum<13) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
((PrefixNum-3)«2) + Suffix 3 < Pr efixNum < 9
Index =
((PrefixNum-9)«3)+Suffix+24 9 < Pr efixNum<l 3
56 + Suffix 13≤ Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "&&"表示逻辑与运算符、 "? : "表示条件运算符、 "«"表示按 位左移运算;
(2 ) 当确定为第二解码模式时,
Suffixlength=(PrefixNum>=7) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
Index = ((PrefixNum-2)«2)+Suffix 2 < Pr efixNum<7
((PrefixNum-7)«3)+Suffix+20 7 < Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "? : "表示条件运算符" <<"表示按位左移运算。
(3 )当确定为第三解码模式时,根据预置的 SUffiXlength=3读取二进制比 特流, 获取 Suffix;
Index= ((PrefixNum-3)«2) + Suffix;
其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
(4)当确定为第四解码模式时,根据预置的 SUffiXlength=2读取二进制比 特流, 获取 Suffix;
Index=(PrefixNum-3)«3) + Suffix
其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
并且在步骤 105中, 所述的"获得索引值, 根据索引值获得第一参数和第 二参数 "可以为: 获得索引值后, 在确定的第一至第四其中之一解码模式下, 根据所述索引值查找预置的参数表, 获取索引值相应的第一参数与第二参数。 其中在第一解码模式时, 相应的查找预置的参数表为表 2, 第一变长码表 (VLC-1 ) ; 在第二解码模式时, 相应查找预置的参数表为表 3, 第二变长码 表 (VLC-2 ) ; 其中在第三解码模式时, 相应的查找预置的参数表为表 4, 第 三变长码表 (VLC-3 ) ; 在第四解码模式时, 相应查找预置的参数表为表 5, 第四变长码表 (VLC-4) 。 步骤 106: 在步骤 101中确定的当前码字是定长码字; 则设置定长码字长 度为预置长度, 则设置索引值 Index等于定长码字; 根据所述索引值获取第一 参数和第二参数。 定长码字的预置长度为不低于 log2 N的整数, N是语法元素取值的个数; 本例中预置长度可以为 6。
该步骤可以为: 当确定当前码字为定长码字时, 设置索引值等于定长码字 后, 根据所述索引值查找预置的定长码表, 获取索引值相应的第一参数与第二 参数。 下面从具体码字的角度来进行描述:
( 1 ) 第一解码模式的非特殊短码情况:
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=1, 那么根据步骤 101中确定解码模式中"若 0≤NC<2, 则选择第一解码模式(VLC-1码表)进行 解码", 可以确定当前解码模式为第一解码模式;
根据步骤 102的方法, 获取一个二进制比特流 OOOO Ol lOxxxxx,那么前缀 部分为 0000 01 ;
根据步骤 103 的方法, 由于前缀部分为 0000 01, 那么得到中间变量 PrefixNum=5 ; 由于是在第一解码模式下, 阈值 S=3, 那么 PrefixNum=5>3, 因此该码字不是特殊短码;
根据步骤 105的方法, 由于确定是第一解码模式;
那么根据预置的公式: Suffixlength=(PrefixNum>=9 && PrefixNum<13)? 3: 2 =(5>=9 && 5<13)? 3: 2=2
PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "&&" 表示"与"、 " (判断条件) ? a: b"表示: 当判断条件成立时, 则取 a, 当判断 条件不成立时则取 b。
根据所述的 Suffixlength=2读取二进制比特流 0000 01 ΙΟχχχχχ,获取 Suffix 为" 10";
((PrefixNum-3)«2) + Suffix 3 < Pr efixNum < 9
Index =
((PrefixNum-9)«3)+Suffix+24 9 < Pr efixNum<l 3
56 + Suffix 13≤ Pr efixNum 由于 PrefixNum=5, 那么根据公式 ((PrefixNum-3)«2) + Suffix进行计算, 获 取 索 引 值 Index , 那 么 最 后 得 到 Index=(PrefixNumb-3)«2+Suffix)=((5-3)«2)+2=10。
然后根据 Index=10, 至第一变长码表 (VLC-1 ) 查表获取第一参数 TrailingOnes和第二参数 TotalCoeff; 那么通过表 1-第一变长码表 VLC-1以及 索引值 10可以查找到 TrailingOnes为 0、 TotalCoeff为 3。
表 2 第一变长码表 VLC-1
Figure imgf000015_0001
Figure imgf000016_0001
(2 ) 第一解码模式的特殊短码情况:
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=1, 那么根据步骤 101中确定解码模式中"若 0≤NC<2, 则选择第一解码模式(VLC-1码表)进行 解码", 可以确定当前解码模式为第一解码模式;
根据步骤 102的方法, 获取一个二进制比特流 OOlOllOxxxxx, 那么前缀 部分为 0010110;
根据步骤 103 的方法, 由于前缀部分为 0000 01, 那么得到中间变量 PrefixNum=2; 由于是在第一解码模式下, 阈值 S=3, 那么 PrefixNum=2<3, 因此该码字是特殊短码;
根据步骤 104中的方法, 根据 TrailingOnes=TotalCoeff=PrefixNum; 可以得知 TrailingOnes=TotalCoeff=2。
(3 ) 第二解码模式的非特殊短码情况;
根据步骤 102的方法, 获取一个二进制比特流 OOOO Ol lOlxxxx,那么前缀 部分为 0000 01 ; 根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=3, 那么根据步骤 10x 中确定解码模式中"若 2≤NC<4, 则选择第二解码模式 (第二变长码表 VLC-2码表) 进行解码", 可以确定当前解码模式为第二解码模式;
根据步骤 103 的方法, 由于前缀部分为 0000 01, 那么得到中间变量 PrefixNum=5 ; 由于是在第二解码模式下, 阈值 S=2, 那么 PrefixNum=5>2, 因此该码字不是特殊短码;
根据步骤 105的方法, 由于确定是第二解码模式;
那么根据预置的公式: Suffixlength=(PrefixNum>=7) ? 3 : 2 =(5>=7 )? 3 : 2
PrefixNum为中间变量、 Suffix为后缀, Suffixlength为后缀长度, "? : " 表示条件运算符。
根据所述的 Suffixlength=3读取二进制比特流 0000 01 ΙΟΙχχχχ,获取 Suffix 为 "101";
Index = <! ((PrefixNum-2)«2)+Suffix 2 < Pr efixNum<7
((PrefixNum-7)«3)+Suffix+20 7 < Pr efixNum 由于 PrefixNum=5, 那么根据公式((PrefixNum-3)«2) + Suffix进行计算, 获 取 索 引 值 Index , 那 么 最 后 得 到 Index=(PrefixNumb-2)«2+Suffix)=((5-2)«2)+5 = 17
然后根据 Index=17, 至第二变长码表 (VLC-2 ) 查表获取第一参数 TrailingOnes和第二参数 TotalCoeff; 那么通过表 2-第二变长码表 VLC-2以及 索引值 14可以查找到 TrailingOnes为 2、 TotalCoeff为 6。
表 3 第二变长码表 VLC-2
Figure imgf000018_0001
Figure imgf000019_0001
(4) 第二解码模式的特殊短码情况:
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=3, 那么根据步骤 101中确定解码模式中"若 2≤NC<4, 则选择第二解码模式(VLC-2码表)进行 解码", 可以确定当前解码模式为第二解码模式;
根据步骤 102的方法, 获取一个二进制比特流 011011 lxxx, 那么前缀部 分为 01 ;
根据步骤 103 的方法, 由于前缀部分为 01, 那么得到中间变量 PrefixNum=l ; 由于是在第二解码模式下, 阈值 S=2, 那么 PrefixNum=l<2, 因此该码字是特殊短码;
根据步骤 104中的方法, 根据: 根据预置的 SUffiXlength=l读取二进制比 TrailingOnes=TotalCoeff=(Prefix«l)+Suffix= (1«1) +1=2+1=3;
(5) 第三解码模式的非特殊短码情况:
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=6, 那么根据步骤 101中确定解码模式中"若 5≤NC<8, 则选择第三解码模式(VLC-1码表)进行 解码", 可以确定当前解码模式为第三解码模式;
根据步骤 102的方法, 获取一个二进制比特流 0000 OllOlxxxx,那么前缀 部分为 000001;
根据步骤 103 的方法, 由于前缀部分为 0000 01, 那么得到中间变量 PrefixNum=5; 由于是在第三解码模式下, 阈值 S=l, 那么 PrefixNum=5>l, 因此该码字不是特殊短码;
根据步骤 105的方法, 由于确定是第三解码模式;
那么根据预置的公式:
Index=((PrefixNum-3 )«2)十 Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
其中, 在第三解码模式下, 由于码字后缀长度预置为 3, 那么可以根据二 进制比特流 0000 OllOlxxxx获取后缀为 "101"; 因此 Index= ( (5-3) «2) +5 = 8+5=13;
那么通过 Index=13查找第三变长码表(VCL-3 )可以获得 TrailingOnes = 1、 TotalCoeff=7
表 4 变长码表 3 (VLC-3)
Figure imgf000021_0001
Figure imgf000022_0001
( 6) 第三解码模式的特殊短码情况:
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=6, 那么根据步骤 101 中确定解码模式中"若 5≤NC<8, 则选择第三解码模式进行解码", 可以确 定当前解码模式为第三解码模式;
根据步骤 102的方法, 获取一个二进制比特 10011 lxxx, 那么前缀部分为
10;
根据步骤 103的方法,由于前缀部分为 1,那么得到中间变量 PrefixNum=0; 由于是在第三解码模式下, 阈值 S=l, 因此该码字是特殊短码;
根据步骤 104中的方法, 根据预置的 Suffixlength=3读取二进制比特流, 获取 Suffix=001 ;
TotalCoeff= Suffix
TrailingOnes=3 (Suffix/4)+(Suffix%4) (l- Suffix/4)
或 TrailingOnes= 3xSuffix[2:2]+suffix[l :0] x(〜 Suffix[2:2])
其中, 在第三解码模式下, 由于码字后缀长度预置为 3, 那么可以根据二 进制比特流 10011 lxxx获取后缀为" 001";
其中, 获得 TrailingOnes的 2个公式实际是相同的, 前一个是简单计算, 后一个是根据位操作;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 Prefix 为前缀、
Suffix后缀; Suffix[2:0]表示第 3位到第 0位的 3比特二进制数, Suffix[l :0] 表示第 2为至第 0位的 3比特二进制数, Suffix[2:2] 表示第 2位的 1比特二进 制数。 "/"表示除法运算符, "% "表示取余运算符, " ~"表示位取反运算符; 那 么 通 过 : TrailingOnes=3xSuffix[3:3]+suffix[2:0] x(〜 Suffix[3:3])=3x0+l x(~ 0)=0+1 1 = 1。
(7) 第四解码模式的非特殊短码情况:
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=-1, 那么根据步骤 101中确定解码模式中" NC=-1,则选择第四解码模式( VLC-4码表)进行解码", 可以确定当前解码模式为第四解码模式;
根据步骤 102的方法, 获取一个二进制比特流 OOOO OlOOlxxxx,那么前缀 部分为 0000 01 ;
根据步骤 103 的方法, 由于前缀部分为 0000 01, 那么得到中间变量 PrefixNum=5 ; 由于是在第四解码模式下, 阈值 S=3, 那么 PrefixNum=5>3, 因此该码字不是特殊短码;
根据步骤 105的方法, 由于确定是第四解码模式;
那么根据预置的公式:
Index=((PrexfixNum-3 )«2)十 Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
其中, 在第三解码模式下, 由于码字后缀长度预置为 3, 那么可以根据二 进制比特流 OOOO OlOOlxxxx获取后缀为" 001"; 因此 Index= ( ( 5-3 ) «2 ) +1 = 9; 那么通过 Index=9;查找第四变长码表(VCL-4)可以获得 TrailingOnes=2、 TotalCoeff=4o 表 5 变长码表 4 (VLC-4)
Figure imgf000024_0001
(8) 第四解码模式的特殊短码情况: 根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=-1, 那么根据步骤 101 中确定解码模式中" NC=-1, 则选择第四解码模式进行解码", 可以确定当 前解码模式为第四解码模式; 根据步骤 102的方法, 获取一个二进制比特 10011 lxxx, 那么前缀部分为
10; 根据步骤 103的方法,由于前缀部分为 1,那么得到中间变量 PrefixNum=0; 由于是在第四解码模式下, 阈值 S=3, 因此该码字是特殊短码。 那么根据公式
TrailingOnes=TotalCoefF= 2xPrefixNum[l:l]+(〜 PrefixNum[0:0])x(〜 PrefixNum[l:l]) = 2x0+0x1=0
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中 间变量、 PrefixNum [1:0]表示第 1位到第 0位的 2比特二进制数, Suffix[l:l] 表示第 1为的 1比特二进制数, Suffix[0:0] 表示第 0位的 1比特二进制数。" ~" 表示位取反运算符。
(9 ) 定长码字情况
根据步骤 101的方法, 根据宏块情况, 获取到当前 NC=9, 那么根据步骤 101 中确定解码模式中"若第一变量 (NC) 在定长码字参数范围内 NC≥8, 则 确定当前码字为定长码字"; 因此可以确定当前码字为定长码字;
那么根据步骤 106的方法, 获取一个二进制比特 10011 lxxx, 本例中的由 于定长码字长度为 6,设置索引值 Index=定长码字 =100111=39,根据 Index=39 至表五-定长码表获取 TrailingOnes=0; TotalCoeff=12。
Figure imgf000025_0001
Figure imgf000026_0001
在本发明实施例提供的表 1至表 4中, 为了说明方便, 能够索引值直接在 表中快速找到 TrailingOnes和 TotalCoeff分别列出了 TrailingOnes、 TotalCoeff 和 Index, 实际在系统中, 表 1至表 4只有 TrailingOnes和 TotalCoeff两项。 实施例 2, 相应于实施例 1的熵解码方法, 本发明实施例还提供一种熵解 码装置, 参见图 3, 该装置包括: 获取单元、 码字类型确定单元、 解码单元; 所述获取单元, 用于根据二进制比特流获取第一变量;
码字类型确定单元, 用于根据第一变量的范围确定当前码字的类型; 解码单元, 用于根据当前码字的类型采用相应的解码方法进行解码。
其中, 所述的获取单元包括:
比特流获取单元, 用于获取二进制比特流;
第一变量获取单元, 用于获取第一变量。 其中, 所述的第一变量获取单元: 用于获取第一变量具体为:
用于预先计算当前宏块左边 4X4块的第一非零系数数目和当前宏块上面
4X4块的第二非零系数数目;
当第一非零系数数目和第二非零系数数目都有效时,第一变量 第一非零 系数数目 +第二非零系数数目、11
当第二非零系数数目有效, 第一非零系数数目无效时, 第一变量=第二非 零系数数目;
当第二非零系数数目无效, 第一非零系数数目有效时, 第一变量=第一非 零系数数目。
其中,所述的获取单元进一步包括前缀获取单元,用于根据所述的二进制 比特流, 获取当前码字的前缀部分;
所述码字类型确定单元,进一步用于根据第一变量的范围确定当前码字的 类型为变长码字; 所述解码单元包括:解码模式确定单元、判断单元以及特殊短码解码单元; 解码模式确定单元,用于当确定所述当前码字为变长码字时, 则确定解码 模式为变长码字解码模式;
判断单元,用于当确定解码模式为变长码字解码模式时, 根据所述码字的 前缀部分判断当前码字是否为特殊短码;
特殊短码解码单元,用于当确定当前码字为特殊短码时, 根据预置相应的 特殊短码解码公式进行解码, 获得第一参数和第二参数。
其中,所述的码字类型确定单元,用于根据第一变量的范围确定当前码字 的类型为变长码字具体为: 当 -1≤第一变量<8时确定为当前码字的类型为变长 码字;
所述的解码模式确定单元结构图请参见图 4, 该单元包括: 第一解码模式 确定单元、第二解码模式确定单元、第三解码模式确定单元、第四解码模式确 定单元;
第一解码模式确定单元, 用于判断若 0≤第一变量<2, 则确定为第一解码 模式进行解码;
第二解码模式确定单元, 用于判断若 2≤第一变量<4, 则确定为第二解码 模式进行解码;
第三解码模式确定单元, 用于判断若 5≤第一变量<8, 则确定为第三解码 模式进行解码; 第四解码模式确定单元, 用于判断若第一变量 =-1,则确定为第四解码模式 进行解码。
其中,所述的解码模式确定单元当确定第一至第四其中之一解码模式进行 解码时,
所述的判断单元,用于当确定解码模式为变长码字解码模式时, 根据所述 前缀判断当前码字是否为特殊短码具体为:
将所述前缀部分的" 0"的个数赋予中间变量, 在所述第一至第四其中之一 的解码模式下, 若所述的中间变量小于阈值, 则确定当前码字为特殊短码; 若 中间变量大于或等于阈值, 则确定当前码字为非特殊短码;
参见图 5, 所述的特殊短码解码单元的结构具体为:
所述的特殊短码解码单元包括第一特殊短码解码单元; 所述第一特殊短码解码单元, 用于当确定为第一解码模式时,
TrailingOnes=TotalCoeff=PrefixNum;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间
其中, 所述的特殊短码解码单元进一步包括第二特殊短码解码单元; 所述第二特殊短码解码单元, 用于根据预置的 SUffiXlength=l读取二进制 比特流, 获取 Suffix;
TrailingOnes=TotalCoeff=(Prefix« 1 )+Suffix;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 Suffix为后缀、 Prefix 为前缀、 Suffixlength为后缀长度、 "《"表示按位 左移运算;
其中, 所述的特殊短码解码单元进一步包括第三特殊短码解码单元; 所述的第三特殊短码解码单元,用于当确定为第三解码模式时, 根据预置 的 Suffixlength=3读取二进制比特流, 获取 Suffix;
TotalCoeff= Suffix; Trailing0nes=3 (Suffix/4)+(Suffix%4) ( 1 - Suffix/4) 或 TrailingOnes= 3 Suffix[2:2]+suffix[l :0] x(〜 Suffix[2:2]); 其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 Prefix 为前缀、 Suffix为后缀, Suffix[2:0]表示第 2位到第 0位的 3比 特二进制数, Suffix[l :0]表示第 1位至第 0位的 2比特二进制数, Suffix[2:2] 表 示第 2位的 1比特二进制数。 "/"表示除法运算符, "% "表示取余运算符, "~" 表 示位取反运算符。
其中, 所述的特殊短码解码单元进一步包括第四特殊短码解码单元; 所述的第四特殊短码解码单元, 用于当确定为第四解码模式时, TrailingOnes = TotalCoeff = 2xPrefixNum[l : l] + ( 〜 PrefixNum[0:0]) (- PrefixNum[l : l])
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 PrefixNum [1 :0]表示第 1位到第 0位的 2比特二进制数, PrefixNum[l : l] 表示第 1为的 1比特二进制数, PrefixNum [0:0] 表示第 0位的 1比特二进制 数," ~"表示位取反运算符。
其中, 所述的解码单元进一步包括: 非特殊短码解码单元, 用于当根据所 述码字的前缀部分判断当前码字不是特殊短码时,则在变长码字解码模式下根 据所述码字的前缀部分选择相应的预置解码公式进行解码, 获得索引值, 根据 所述的索引值获得第一参数和第二参数。 其中, 所述的非特殊短码解码单元结构参见图 6, 包括: 第一解码单元; 用于 Suffixlength=(PrefixNum>=9 && PrefixNum<13) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
((PrefixNum-3)«2) + Suffix 3 < Pr efixNum < 9
Index =
((PrefixNum-9)«3)+Suffix+24 9 < Pr efixNum<l 3
56 + Suffix 13≤ Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "&&"表示逻辑与运算符、 "? : "表示条件运算符、 "«"表示按 位左移运算。
其中,所述的非特殊短码解码单元进一步包括第二解码单元;用于当确定 为第二解码模式时,
Suffixlength=(PrefixNum>=7) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
Index = ((PrefixNum-2)«2)+Suffix 2 < Pr efixNum<7
((PrefixNum-7)«3)+Suffix+20 7 < Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "? : "表示条件运算符, "<<"表示按位左移运算。 其中,所述的非特殊短码解码单元进一步包括第三解码单元,用于根据预 置的 Suffixlength=3读取二进制比特流, 获取 Suffix;
Index=(PrefixNum-3)«2) + Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
其中,所述的非特殊短码解码单元进一步包括第四解码单元,用于当确定 为第四解码模式时,根据预置的 SUffiXlength=2读取二进制比特流,获取 Suffix;
Index=(PrefixNum-3)«3) + Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。 在上述的熵解码装置中, 非特殊短码解码单元中所述的"获得索引值, 根 据索引值获得第一参数和第二参数 "具体为: 获得索引值后,在确定的变长解码模式下, 根据所述索引值查找预置的参 数表, 获取索引值相应的第一参数与第二参数。 其中,所述的解码模式确定单元进一步包括:定长码字解码模式确定单元; 定长码字解码模式确定单元, 用于判断若第一变量≥8,则确定为定长码字 解码模式进行解码; 所述的解码单元进一步包括: 定长码字解码单元,用于确定解码模式为定 长码字解码模式; 设置索引值数值等于定长码字数值, 根据所述的索引值查找 预置的定长码表, 获取索引值相应的第一参数与第二参数。
本发明实施例的目的在于提供一种熵解码方法、装置。通过分析语法元素 的概率分布情况,对码字规则和码表排列顺序进行全新设计, 根据码字规则计 算出码表中码字的顺序索引,对码表中的语法元素进行索引排序,进而实现快 速解码操作。此外,将部分高使用频率的特殊短码字直接简单算术表达式计算 出相应的语法元素数值。本发明实施例消除了遍历二叉树的操作和匹配码字的 操作, 从而极大降低熵编码算法对内存等硬件的要求。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分步骤 是可以通过程序来指令相关的硬件完成,该程序可以存储于一种计算机可读存 储介质中, 上述提到的存储介质可以是只读存储器, 磁盘或光盘等。
以上所述仅为本发明的较佳实施例而已, 并不用以限制本发明, 凡在本发 明的精神和原则之内所作的任何修改、等同替换和改进等, 均应包含在本发明 的保护范围之内。

Claims

权 利 要 求
1、 一种熵解码方法, 其特征在于, 所述的方法具体为:
根据二进制比特流获取第一变量;
根据所述第一变量的范围确定当前码字的类型;
根据所述当前码字的类型采用相应的解码方法进行解码。
2、 根据权利要求 1所述的熵解码方法, 其特征在于, 所述的 "根据二进 制比特流获取第一变量" 的方法具体为: 预先计算当前宏块左边 4X4块的第 一非零系数数目和当前宏块上面 4X4块的第二非零系数数目;
当所述第一非零系数数目和所述第二非零系数数目都有效时,所述第一变 量 所述第一非零系数数目 +所述第二非零系数数目 2 ;
当所述第二非零系数数目有效,所述第一非零系数数目无效时, 所述第一 变量 =所述第二非零系数数目;
当所述第二非零系数数目无效,所述第一非零系数数目有效时, 所述第一 变量 =所述第一非零系数数目。
3、 根据权利要求 1所述的熵解码方法, 其特征在于,
所述的 "根据当前码字的类型采用相应的解码方法进行解码"之前还包括 步骤: 获取所述二进制比特流中码字的前缀部分;
"根据所述当前码字的类型采用相应的解码方法进行解码"具体为: 当确 定所述当前码字为变长码字时, 则确定所述解码模式为变长码字解码模式; 根 据所述码字的前缀部分判断当前码字是否为特殊短码,若是则根据预置的特殊 短码解码公式进行解码, 获得第一参数和第二参数。
4、 根据权利要求 3所述的熵解码方法, 其特征在于, "根据所述码字的 前缀部分判断当前码字是否为特殊短码"具体为:
将所述前缀部分的" 0"的个数赋予中间变量,
在所述变长码字解码模式下, 若所述中间变量小于阈值, 则确定当前码字 为特殊短码, 若否则确定当前码字为非特殊短码。
5、 根据权利要求 4所述熵解码方法, 其特征在于, 所述的变长码字解码 模式包括第一至第四解码模式;
若 0≤所述第一变量 <2, 则确定使用第一解码模式进行解码, 所述阈值为 若 2≤所述第一变量 <4, 则确定使用第二解码模式进行解码, 所述阈值为
2;
若 5≤所述第一变量 <8, 则确定使用第三解码模式进行解码, 所述阈值为
1;
若所述第一变量 =-1,则确定使用第四解码模式进行解码, 所述阈值为 3。
6、 权利要求 5所述的熵解码方法, 其特征在于, "根据预置的特殊短码 解码公式进行解码, 获得第一参数和第二参数"具体为:
当 确 定 使 用 所 述 第 一 解 码 模 式 进 行 解 码 时 , TrailingOnes=TotalCoeff=PrefixNum;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中 间变量。
7、 权利要求 5所述的熵解码方法, 其特征在于, "根据预置的特殊短码 解码公式进行解码, 获得第一参数和第二参数"具体为:
当确定使用所述第二解码模式进行解码时, 根据预置的 SUffiXlength=l读 取二进制比特流, 获取 Suffix;
TrailingOnes=TotalCoeff=(Prefix«l)+Suffix;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中 间变量、 Prefix 为前缀、 Suffix为后缀、 Suffixlength为后缀长度、 "《"表示按 位左移运算。
8、 权利要求 5所述的熵解码方法, 其特征在于, "根据预置的特殊短码 解码公式进行解码, 获得第一参数和第二参数"具体为: 当确定使用所述第三解码模式进行解码时, 根据预置的 SUffiXlength=3读 取二进制比特流, 获取 Suffix;
TotalCoeff= Suffix; TrailingOnes=3 (Suffix/4)+(Suffix%4) ( 1 - Suffix/4) 或 TrailingOnes= 3 Suffix[2:2]+suffix[l :0] x(〜 Suffix[2:2]); 其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 Prefix 为前缀、 Suffix为后缀, Suffix[2:0]表示第 2位到第 0位的 3比 特二进制数, Suffix[l :0]表示第 1位至第 0位的 2比特二进制数, Suffix[2:2] 表 示第 2位的 1比特二进制数 ,"/"表示除法运算符, "% "表示取余运算符," ~"表 示位取反运算符。
9、 根据权利要求 5所述的熵解码方法, 其特征在于, "根据预置的特殊 短码解码公式进行解码, 获得第一参数和第二参数"具体为: 当确定使用所述第四解码模式进行解码时,
TrailingOnes=TotalCoeff= 2 PrefixNum[l : l] + ( 〜 PrefixNum[0:0]) (- PrefixNum[l : l]); 其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 PrefixNum [1 :0]表示第 1位到第 0位的 2比特二进制数, PrefixNum[l : l] 表示第 1为的 1比特二进制数, PrefixNum [0:0] 表示第 0位的 1比特二进制 数," ~"表示位取反运算符。
10、根据权利要求 5所述的熵解码方法, 其特征在于, 当根据所述码字的 前缀部分判断当前码字不是特殊短码时,则在所述变长码字解码模式下根据所 述码字的前缀部分选择预置解码公式进行解码, 获得索引值, 并根据所述的索 引值获得第一参数和第二参数。
11、 根据权利要求 10所述的熵解码方法, 其特征在于, 所述的 "在所述 变长码字解码模式下根据所述码字的前缀部分选择预置解码公式进行解码, 得索引值"具体为: 当使用第一解码模式进行解码时,
Suffixlength=(PrefixNum>=9 && PrefixNum<13) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
((PrefixNum-3)«2) + Suffix 3 < Pr efixNum < 9
Index =
((PrefixNum-9)«3)+Suffix+24 9 < Pr efixNum<l 3
56 + Suffix 13≤ Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "&&"表示逻辑与运算符、 "? : "表示条件运算符、 "<<"表示按 位左移运算。
12、 根据权利要求 10所述的熵解码方法, 其特征在于, 所述的 "在所述 变长码字解码模式下根据所述码字的前缀部分选择预置解码公式进行解码,获 得索引值"具体为: 当使用第二解码模式进行解码时, Suffixlength=(PrefixNum>=7) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
Index = <j ((PrefixNum-2)«2)+Suffix 2 < Pr efixNum<7
((PrefixNum-7)«3)+Suffix+20 7 < Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "? : "表示条件运算符" <<"表示按位左移运算。
13、 根据权利要求 10所述的熵解码方法, 其特征在于, 所述的 "在所述 变长码字解码模式下根据所述码字的前缀部分选择预置解码公式进行解码,获 得索引值"具体为:
当使用第三解码模式进行解码时, 根据预置的 SUffiXlength=3读取二进制 比特流, 获取 Suffix;
Index=(PrefixNum-3)«2) + Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
14、 根据权利要求 10所述的熵解码方法, 其特征在于, 所述的 "在所述 变长码字解码模式下根据所述码字的前缀部分选择预置解码公式进行解码,获 得索引值"具体为:
当使用第四解码模式进行解码时, 根据预置的 SUffiXlength=2读取二进制 比特流, 获取 Suffix;
Index=(PrefixNum-3)«3) + Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
15、 根据权利要求 10所述的熵解码方法, 其特征在于, 所述的 "根据所 述的索引值获得第一参数和第二参数"具体为:
在确定的变长解码模式下, 根据所述索引值查找预置的参数表, 获取所述 索引值相应的第一参数与第二参数。
16、 根据权利要求 1所述的熵解码方法, 其特征在于, "根据所述当前 码字的类型采用相应的解码方法进行解码"具体为: 当确定所述当前码字为定 长码字时, 则确定所述解码模式为定长码字解码模式; 设置索引值数值等于定 长码字数值, 根据所述索引值查找预置的定长码表, 获取所述索引值相应的第 一参数与第二参数。
17、 根据权利要求 16所述的熵解码方法, 其特征在于, 所述的 "确定所 述解码模式为定长解码模式 "具体为: 若所述第一变量≥8, 则确定当前码字为 定长码字, 确定解码模式为定长解码模式。
18、 一种熵解码装置, 其特征在于, 所述的装置包括: 获取单元、 码字类 型确定单元以及解码单元;
所述获取单元, 用于根据二进制比特流获取第一变量;
所述码字类型确定单元,用于根据所述第一变量的范围确定当前码字的类 型;
所述解码单元,用于根据所述当前码字的类型采用相应的解码方法进行解 码。
19、 根据权利要求 18所述的熵解码装置, 其特征在于, 所述的获取单元 包括:
比特流获取单元, 用于获取二进制比特流;
第一变量获取单元, 用于获取第一变量。
20、 根据权利要求 19所述的熵解码装置, 其特征在于, 所述的第一变量 获取单元具体:
用于预先计算当前宏块左边 4X4块的第一非零系数数目和当前宏块上面
4X4块的第二非零系数数目;
当所述第一非零系数数目和所述第二非零系数数目都有效时,所述第一变 量 所述第一非零系数数目 +所述第二非零系数数目 2 ;
当所述第二非零系数数目有效,所述第一非零系数数目无效时, 所述第一 变量 =所述第二非零系数数目;
当所述第二非零系数数目无效,所述第一非零系数数目有效时, 所述第一 变量 =所述第一非零系数数目。
21、 根据权利要求 18所述的熵解码装置, 其特征在于, 所述获取单元进 一步包括前缀获取单元, 用于获取所述二进制比特流中码字的前缀部分; 所述码字类型确定单元,进一步用于根据第一变量的范围确定当前码字的 类型为变长码字; 所述解码单元包括:解码模式确定单元、判断单元以及特殊短码解码单元; 所述解码模式确定单元,用于当确定所述当前码字为变长码字时, 则确定 所述解码模式为变长码字解码模式;
判断单元,用于当确定所述解码模式为变长码字解码模式时, 根据所述码 字的前缀部分判断当前码字是否为特殊短码;
特殊短码解码单元,用于当确定当前码字为特殊短码时, 根据预置特殊短 码解码公式进行解码, 获得第一参数和第二参数。
22、 根据权利要求 21所述的熵解码装置, 其特征在于,
所述判断单元的用于当确定解码模式为变长码字解码模式时,根据所述前 缀判断当前码字是否为特殊短码具体为:
将所述前缀部分的" 0"的个数赋予中间变量,在所述变长码字解码模式下, 若所述的中间变量小于阈值, 则确定当前码字为特殊短码; 若否则确定当前码 字为非特殊短码。
23、 根据权利要求 22所述的熵解码装置, 其特征在于, 所述码字类型确 定单元的 "根据所述码字的部分前缀判断当前码字是否为特殊短码"具体为: 当 -1≤第一变量<8时确定为当前码字的类型为变长码字;
所述的解码模式确定单元包括:第一解码模式确定单元、第二解码模式确 定单元、 第三解码模式确定单元以及第四解码模式确定单元;
第一解码模式确定单元, 用于判断若 0≤第一变量<2, 则确定为第一解码 模式进行解码, 所述阈值为 3 ;
第二解码模式确定单元, 用于判断若 2≤第一变量<4, 则确定为第二解码 模式进行解码, 所述阈值为 2;
第三解码模式确定单元, 用于判断若 5≤第一变量<8, 则确定为第三解码 模式进行解码, 所述阈值为 1 ; 第四解码模式确定单元, 用于判断若第一变量 =-1,则确定为第四解码模式 进行解码, 所述阈值为 3。
24、 根据权利要求 23所述的熵解码装置, 其特征在于, 所述的特殊短码 解码单元包括第一特殊短码解码单元;
所述第一特殊短码解码单元,用于当确定使用所述第一解码模式进行解码 时, TrailingOnes=TotalCoeff=PrefixNum;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间
25、 根据权利要求 23所述的熵解码装置, 其特征在于, 所述的特殊短码 解码单元进一步包括第二特殊短码解码单元;
所述第二特殊短码解码单元,用于当确定使用所述第二解码模式进行解码 时, 根据预置的 Suffixlength=l读取二进制比特流, 获取 Suffix;
TrailingOnes=TotalCoeff=(Prefix« 1 )+Suffix;
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 Prefix 为前缀、 Suffix为后缀、 Suffixlength为后缀长度、 "《"表示按位 左移运算。
26、 根据权利要求 23所述的熵解码装置, 其特征在于, 所述的特殊短码 解码单元进一步包括第三特殊短码解码单元; 所述的第三特殊短码解码单元,用于当确定使用所述第三解码模式进行解 码时, 根据预置的 Suffixlength=3读取二进制比特流, 获取 Suffix;
TotalCoeff= Suffix; Trailing0nes=3 (Suffix/4)+(Suffix%4) ( 1 - Suffix/4) 或 TrailingOnes= 3 Suffix[2:2]+suffix[l :0] x(〜 Suffix[2:2]);
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 Prefix 为前缀、 Suffix为后缀, Suffix[2:0]表示第 2位到第 0位的 3比 特二进制数, Suffix[l :0]表示第 1位至第 0位的 2比特二进制数, Suffix[2:2] 表 示第 2位的 1比特二进制数, "/"表示除法运算符, "% "表示取余运算符, "~" 表 示位取反运算符。
27、 根据权利要求 23所述的熵解码装置, 其特征在于, 所述的特殊短码 解码单元进一步包括第四特殊短码解码单元; 所述的第四特殊短码解码单元,用于当确定使用所述第四解码模式进行解 码时, TrailingOnes = TotalCoeff = 2 PrefixNum[l : l] + (〜 PrefixNum[0:0]) x (~ PrefixNum[ 1 : 1]);
其中 TrailingOnes是第一参数、 TotalCoeff是第二参数、 PrefixNum为中间 变量、 PrefixNum [1 :0]表示第 1位到第 0位的 2比特二进制数, PrefixNum[l : l] 表示第 1为的 1比特二进制数, PrefixNum [0:0] 表示第 0位的 1比特二进制 数," ~"表示位取反运算符。
28、 根据权利要求 23所述的熵解码装置, 其特征在于, 所述的解码单元 进一步包括: 非特殊短码解码单元,用于当根据所述码字的前缀部分判断当前 码字不是特殊短码时,则在所述变长码字解码模式下根据所述码字的前缀部分 选择预置解码公式进行解码, 获得索引值, 并根据所述的索引值获得第一参数 和第二参数。
29、 根据权利要求 28所述的熵解码装置, 其特征在于, 所述的非特殊短 码解码单元包括: 第一解码单元; 用于当使用第一解码模式进行解码时,
Suffixlength=(PrefixNum>=9 && PrefixNum<13) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
((PrefixNum-3)«2) + Suffix 3 < Pr efixNum < 9
Index =
((PrefixNum-9)«3)+Suffix+24 9 < Pr efixNum<l 3
56 + Suffix 13≤ Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "&&"表示逻辑与运算符、 "? : "表示条件运算符、 "<<"表示按 位左移运算。
30、 根据权利要求 28所述的熵解码装置, 其特征在于, 所述的非特殊短 码解码单元进一步包括第二解码单元; 用于当使用第二解码模式进行解码时, Suffixlength=(PrefixNum>=7) ? 3 : 2 根据所述的 Suffixlength读取二进制比特流, 获取 Suffix;
Index = <j ((PrefixNum-2)«2)+Suffix 2 < Pr efixNum<7
((PrefixNum-7)«3)+Suffix+20 7 < Pr efixNum 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, Suffixlength 为后缀长度, "? : "表示条件运算符, "<<"表示按位左移运算。
31、 根据权利要求 28所述的熵解码装置, 其特征在于, 所述的非特殊短 码解码单元进一步包括第三解码单元, 用于当使用第三解码模式进行解码时, 根据预置的 Suffixlength=3读取二进制比特流, 获取 Suffix;
Index=(PrefixNum-3)«2) + Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
32、 根据权利要求 28所述的熵解码单元, 其特征在于, 所述的非特殊短 码解码单元进一步包括第四解码单元, 用于当使用第四解码模式进行解码时, 根据预置的 Suffixlength=2读取二进制比特流, 获取 Suffix;
Index=(PrefixNum-3)«3) + Suffix 其中 Index为索引值、 PrefixNum为中间变量、 Suffix为后缀, "《"表示 按位左移运算。
33、 根据权利要求 28所述的熵解码单元, 其特征在于, 所述非特殊短码 解码单元中所述的"获得索引值,并根据索引值获得第一参数和第二参数"具体 为:
在确定的变长解码模式下, 根据所述索引值查找预置的参数表, 获取所述 索引值相应的第一参数与第二参数。
34、 根据权利要求 21所述的熵解码装置, 其特征在于, 所述的解码模式 确定单元进一步包括: 定长码字解码模式确定单元;
定长码字解码模式确定单元, 用于判断若第一变量≥8,则确定为定长码字 解码模式进行解码;
所述的解码单元进一步包括: 定长码字解码单元,用于当确定所述当前码 字为定长码字时, 则确定所述解码模式为定长码字解码模式; 设置索引值数值 等于定长码字数值, 根据所述索引值查找预置的定长码表, 获取所述索引值相 应的第一参数与第二参数。
35、 一种记录介质, 其特征在于, 该介质包括权利要求 1至 17其中之一 的熵解码方法的程序。
PCT/CN2011/076357 2011-05-25 2011-06-25 一种熵解码方法、装置 WO2012159295A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110139078.8A CN102355578B (zh) 2011-05-25 2011-05-25 一种熵解码方法、装置
CN201110139078.8 2011-05-25

Publications (1)

Publication Number Publication Date
WO2012159295A1 true WO2012159295A1 (zh) 2012-11-29

Family

ID=45579066

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/076357 WO2012159295A1 (zh) 2011-05-25 2011-06-25 一种熵解码方法、装置

Country Status (2)

Country Link
CN (1) CN102355578B (zh)
WO (1) WO2012159295A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103384329A (zh) * 2013-05-07 2013-11-06 广东工业大学 一种基于无码表查找cavlc解码方法
CN103533360B (zh) * 2013-10-19 2016-06-08 山东大学 一种avs编码芯片中优化码表存储的方法
CN106303531B (zh) * 2015-06-09 2019-08-16 富士通株式会社 拷贝信息的编码方法、装置以及图像处理设备
EP3317972B1 (en) * 2015-07-03 2023-01-18 Kinematicsoup Technologies Inc. Method of compression for fixed-length data
CN110446047A (zh) * 2019-08-16 2019-11-12 苏州浪潮智能科技有限公司 视频码流的解码方法及装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101175210A (zh) * 2006-10-30 2008-05-07 中国科学院计算技术研究所 用于视频预测残差系数解码的熵解码方法及熵解码装置
CN101198051A (zh) * 2006-12-07 2008-06-11 深圳艾科创新微电子有限公司 基于h.264的熵解码器的实现方法及装置
US7830963B2 (en) * 2003-07-18 2010-11-09 Microsoft Corporation Decoding jointly coded transform type and subblock pattern information

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101072034B (zh) * 2007-06-12 2010-06-02 华为技术有限公司 一种变长解码方法及其装置
CN101370138B (zh) * 2007-08-17 2011-02-09 中国科学院计算技术研究所 一种h.264标准cavlc残差系数的解码方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7830963B2 (en) * 2003-07-18 2010-11-09 Microsoft Corporation Decoding jointly coded transform type and subblock pattern information
CN101175210A (zh) * 2006-10-30 2008-05-07 中国科学院计算技术研究所 用于视频预测残差系数解码的熵解码方法及熵解码装置
CN101198051A (zh) * 2006-12-07 2008-06-11 深圳艾科创新微电子有限公司 基于h.264的熵解码器的实现方法及装置

Also Published As

Publication number Publication date
CN102355578B (zh) 2016-12-07
CN102355578A (zh) 2012-02-15

Similar Documents

Publication Publication Date Title
US9338478B2 (en) Video compression using multiple variable length coding methods for multiple types of transform coefficient blocks
KR101356733B1 (ko) 컨텍스트 기반 적응적 이진 산술 부호화, 복호화 방법 및장치
KR101187243B1 (ko) 가변-대-고정 길이 코드들의 빠른 분석
US8265162B2 (en) Context adaptive position and amplitude coding of coefficients for video compression
US8520965B2 (en) Context adaptive hybrid variable length coding
TWI657692B (zh) 於視訊寫碼程序中用於係數層級寫碼之萊斯(rice)參數初始化
RU2506710C2 (ru) Способ моделирования информации кодирования видеосигнала для компрессии/декомпрессии информации кодирования
WO2020253828A1 (zh) 一种编解码方法、装置及存储介质
US7839311B2 (en) Architecture for multi-stage decoding of a CABAC bitstream
TWI556632B (zh) 視訊之算術編碼方法及其裝置、以及視訊之算術解碼方法及其裝置
TWI662830B (zh) 資料編碼與解碼
WO2005027521A1 (en) Entropy coding method for encoding remanet coefficient in video predicting
TWI629895B (zh) 視訊解碼的裝置
CN115361561B (zh) 残差和系数编解码的方法和装置
JP5881747B2 (ja) 変換係数の符号化及び復号方法及び装置
WO2012159301A1 (zh) 一种视频熵编码、熵解码方法、装置及介质
JP7439841B2 (ja) ループ内フィルタリングの方法及びループ内フィルタリングの装置
WO2012159295A1 (zh) 一种熵解码方法、装置
WO2024022356A1 (zh) 一种编解码方法、装置及其设备
WO2022193386A1 (zh) 系数编解码方法、编解码设备、终端及存储介质
TW202348026A (zh) 圖像編解碼方法、裝置、電子設備及儲存媒體
Dai et al. Adaptive Binarization for Arithmetic Coding in Video Compression

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11865964

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS (EPO FORM 1205A DATED 16-04-2014)

122 Ep: pct application non-entry in european phase

Ref document number: 11865964

Country of ref document: EP

Kind code of ref document: A1