1. Field of the Invention
Embodiments of the present invention generally relate to a method and apparatus for simplifying error detection in CABAC.
2. Description of the Related Art
Decoder can detect bitstream errors in slice data by comparing the number decoded bits and the size of the current NAL unit. If the numbers are mismatched, it is likely that the decoded bitstream includes errors. During slice data decoding, decoder can detect bitstream errors, which maybe result from a number of reason, such as, decoded syntax element is out of range, alignment one bit is not 1, alignment zero bit is not 0, and the likes. In many cases, bit corruptions or packet loss may cause one or more of such conditions. A decoder can detect the errors. But if the corruption of bits or packet loss accidentally forms the correct syntax elements without causing the detectable conditions, the errors may not be detected during slice data decoding.
Detecting mismatch of NAL unit size and decoded bits is usually a strong tool for the error detection. Even if the corruption of bits or packet loss accidentally forms the correct syntax element, the error can be detected when the decoded number of bits does not match the size of NAL unit. In this contribution, this method is called detection of NAL unit size mismatch.
The detection of NAL unit size mismatch can be easily implemented in the case of CAVLC. But it is difficult to implement it in the case of CABAC. This is due to the existence of cabac_zero_word in CABAC syntax. AVC syntax structure can be written as follows by utilizing a software routine such as:
In AVC, encoder can change the size of NAL unit by inserting arbitrary numbers of cabac_zero_word in the case of CABAC. For decoder, decoder cannot judge whether the next “0x000003” is really cabac_zero_word plus EPB (Emulation Prevention Byte, 0x03) or not just by looking into the next 24 bits from the end of rbsp_trailing_bits( ) since “0x000003” can be existed in macroblock_layer( ).
In order to confirm the next 24 bits equal to “0x000003” is really cabac_zero_word plus EPB, decoder should read all the data from the end of rbsp_trailing_bits( ) to the end of NAL unit. If all the data are composed of cabac_zero_word plus EPBs, decoder can say the next 24 bits from the end of rbsp_trailing_bits( ) is surely cabac_zero_word plus EPBs. After detecting the starting position of arbitrary numbers of cabac_zero_word, decoder can know the size of NAL unit, and can use it for error detection. But it is too cycle consuming tasks for HW or SW to read all the data from the rbsp_trailing_bits( ) to the end of NAL unit to confirm the cabac_zero_word.
Therefore, there is a need for a method and/or apparatus for detecting error in CABAC.
Embodiments of the present invention relate to a method and apparatus for error detection. The method includes decoding slice header when a unit is a NAL unit, decoding a macroblock unit and detecting an end of slice flag setting indicating end of slice, decoding RBSP trailing bits and determining if it is really end of slice; and determining an error occurred when it is not end of slice.
So that the manner in which the above recited features of the present invention can be understood in detail, a more particular description of the invention, briefly summarized above, may be had by reference to embodiments, some of which are illustrated in the appended drawings. It is to be noted, however, that the appended drawings illustrate only typical embodiments of this invention and are therefore not to be considered limiting of its scope, for the invention may admit to other equally effective embodiments.
Considering the possibilities of bit corruption or/and packet loss in the decoded bitstream, the decoded value of end of slice indicator is not reliable. Therefore, the detection of NAL unit size mismatch in CABAC includes the detection of mismatch between the value of decoded end of slice indicator and end of slice condition derived from trailing bits, the remaining bits in the current NAL unit.
Whereas, appending an indicator to mark “zero words” makes it difficult to derive end of slice condition from trailing bits.
In one embodiment a decoder using a delimiter (e.g. startcode or pointer) to separate the slice data and the stuffing bytes Instead of using CABAC zero word of the rbsp railing bits. In another embodiment, the decoder may use a data filler, i.e. filler_data RBSP, from the current slice data NAL unit instead of using CABAC zero word from the rbspt railing bits.
For example, in one embodiment a decoder using delimiter is described by utilizing a software routine such as:
As such, the problem in detecting end of slice, as described in the examples shown
In another embodiment, a data filler (RBSP) maybe used, where the filler is out of the current slice data. Thus, using data filler may simplify the byte stuffing process. An advantage of using data filler, such as filler_data RBSP instead of cabac_zero_words, is in simplifying the byte stuffing process, where a variable k is set to Ceil((Ceil(3*(32*÷BinCountsInNALunits−RawMbBits*PicSizeInMbs)÷1024)−NumBytesInVclNALunits)÷3). In one embodiment, depending on the variable k the following applies: (1) If k is less than or equal to 0, no cabac_zero_word is appended to the NAL unit; (2) Otherwise (k is greater than 0), the 3-byte sequence 0x000003 is appended k times to the NAL unit after encapsulation, where the first two bytes 0x0000 represent a cabac_zero_word and the third byte 0x03 represents a 3 byte mulation prevention, which requires a costly multiply by 3 and divide by 3 to accommodate the cabac_zero_word plus EPB (0x03) 3 bytes and appending CABAC zero words, also handled in multiple of 3 bytes.
On the other hand, a data filler, such as filler_data RBSP, removes the requirement of using a multiply by 3 and divide by 3. As such, the equation is simplified to k=Ceil((32*BinCountsInNALunits−RawMbBits*PicSizeInMbs)÷1024)−NumBytesInVclNALunits). Hence, the byte stuffing process is simpler, with lower implementation cost. As a result, the complexity of decoder implementation to detect bitstream error is reduced when comparing decoded bits and NAL unit size. Thus, implementing a delimiter (e.g. startcode or pointer) to separate the slice data and the stuffing bytes and using a data filler, such as, filler_data RBSP, simplifies the encoder byte stuffing process compared to cabac_zero_words insertion.
At step 612, the method 600 determines if the next bytes include a delimiter, such as, 0x000002. If the next bytes are not 0x000002, the method 600 proceeds to step 614, wherein the method 600 determines that there is an end of slice error. Otherwise, the method 600 proceeds to step 616, wherein the decoder decodes the delimiter. At step 618, the method 600 decoded any CABAC zero words. The method 600 ends at step 620.
At step 712, the method 700 determines if the current pointer shows the end of slice position. If it is, the method determines it is end of slice, at step 716 and proceeds to step 718. Otherwise, the method determines that there is an end of slice error, at step 714, and proceeds to step 720. At step 718, the method 700 decodes a NAL unit with filler data and proceeds to step 720. The method 600 ends at step 720.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.
This application claims benefit of U.S. provisional patent application Ser. No. 61/431,971, filed Jan. 12, 2011, 61/450,848, filed Mar. 9, 2011 and 61/469,536, filed Mar. 30, 2011, which are herein incorporated by reference.
Number | Date | Country | |
---|---|---|---|
61431971 | Jan 2011 | US | |
61450848 | Mar 2011 | US | |
61469536 | Mar 2011 | US |