Video encoding and decoding method and device
By combining multiple scanning and encoding methods, the problem of low performance and high complexity of existing video encoding and decoding methods is solved, and efficient video encoding and decoding is achieved, which is suitable for different data distribution characteristics.
Patent Information
- Application Number
- CN202111333832.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-11
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-11-11
AI Technical Summary
Existing video encoding and decoding methods have low performance and high complexity of encoding and decoding algorithms, making it difficult to meet the needs of efficient video storage and transmission.
Use a variety of combinations of scanning methods, grouping methods and encoding methods, including raster scanning, block scanning, horizontal scanning, vertical scanning, etc., combined with unary code, truncated unary code, fixed-length coding, semi-fixed-length coding, k-order exponential Columbus coding and other coding algorithms, determine the grouping method and coding method according to the prediction method, quantization method and transformation method to improve coding performance.
It achieves more efficient video encoding and decoding performance, reduces encoding complexity, adapts to different data distribution characteristics, and improves encoding flexibility and accuracy.
Smart Images

Figure CN116074499B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a video encoding and decoding method and device. Background Art
[0002] In the field of computer vision, in order to effectively store and transmit videos, it is usually necessary to perform image compression through video coding, which mainly includes lossy compression and lossless compression. Among them, lossless compression uses the statistical redundancy of image data to compress images, which can completely restore the original image data without causing any distortion; in addition, if there is an error between the reconstructed image and the original image, and the error is limited to a certain range, it is called near-lossless compression. Although near-lossless compression has certain distortion, it can be ignored for visual images, so near-lossless compression can also be considered as lossless compression.
[0003] In the current lossless compression (including near-lossless compression) coding and decoding schemes, for example, the context-based adaptive binary arithmetic coding (CABAC) compression technology involves many probability models and context modeling, binary arithmetic coding and other algorithms, and the processing process is relatively complicated. In addition, the Golomb-Rice coding based on Golomb coding has redundant calculations in its coding process, and the coding and decoding performance is not high. Therefore, it is urgent to propose a video coding and decoding method with high coding and decoding efficiency and low algorithm complexity. Summary of the invention
[0004] The present application provides a video encoding and decoding method and device, which solves the problem of low video encoding and decoding performance or high complexity of encoding and decoding algorithms in the prior art.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a video encoding and decoding method is provided, the method comprising: a decoding end obtains a code stream of a unit to be decoded; determines a scanning method, a grouping method and an encoding method corresponding to each group of the unit to be decoded; decodes according to the encoding method of each group to obtain a coefficient block corresponding to the unit to be decoded; according to the scanning method of the unit to be decoded, restores the coefficients in the coefficient block of each group one by one to obtain a reconstructed data block corresponding to the unit to be decoded.
[0007] In one embodiment, the grouping method includes: a fixed-length grouping method, or a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the arrangement position of coefficients.
[0008] In one embodiment, the encoding method is at least one of: unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Golomb code, truncated Rice code, Huffman code, and Golomb-Rice code.
[0009] In one embodiment, the scanning method includes at least one of: raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0010] In one embodiment, the reconstructed data block is a data block composed of original pixel values of the image to be decoded, residual values obtained by predicting the original pixel values, coefficients of the residual values after quantization, or transformation coefficients obtained after transforming the residual values.
[0011] In one embodiment, determining the scanning mode, grouping mode and encoding mode corresponding to each group of the unit to be decoded specifically includes: determining the scanning mode, grouping mode and encoding mode corresponding to each group of the unit to be decoded according to a pre-agreed agreement or context information between the encoding end and the decoding end; or, obtaining the scanning mode, grouping mode and encoding mode corresponding to each group of the unit to be decoded according to the code stream analysis; or, obtaining the grouping mode according to the prediction mode, quantization mode and / or transformation mode of the unit to be decoded.
[0012] In one embodiment, decoding is performed according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, specifically including: decoding according to the encoding algorithm to obtain the group parameters of each group; based on the group parameters of each group, decoding according to the semi-fixed-length encoding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0013] In one embodiment, the group parameters of each group are obtained by decoding according to the encoding algorithm, specifically including: decoding according to a decoding method corresponding to at least one of the following encoding methods to obtain the group parameters of each group: unary code, truncated unary code, truncated binary code, fixed-length coding, k-order exponential Columbus coding, truncated Rice coding, Huffman coding or Columbus-Rice coding.
[0014] In one embodiment, decoding is performed according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, specifically including: decoding according to a fixed-length coding algorithm to obtain the group Rice parameters of each group, or, obtaining the group Rice parameters of each group according to a context model; based on the group Rice parameters of each group, decoding according to the Columbus-Rice coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0015] In one embodiment, decoding is performed according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, specifically including: obtaining the group Rice parameters of each group according to the context model; obtaining the group parameter deviation of each group according to the fixed-length coding algorithm or the truncated unary code decoding; obtaining the group parameters of each group according to the group Rice parameters of each group and the group parameter deviation; according to the group parameters of each group, decoding according to the Columbus-Rice coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0016] In one embodiment, decoding is performed according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, specifically including: decoding according to a fixed-length coding algorithm to obtain the order k of each group, or, obtaining the order k of each group according to a context model; according to the order k of each group, decoding according to a k-order exponential Golomb coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0017] In one embodiment, decoding is performed according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, specifically including: obtaining the order k of each group according to the context model; obtaining the group parameter deviation of each group according to the fixed-length coding algorithm or the truncated unary code decoding; updating the order k of each group according to the group parameter deviation; according to the updated order k of each group, decoding according to the k-order exponential Golomb coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0018] In one embodiment, decoding is performed according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, specifically including: determining the encoding method of the current group according to at least one of the coefficients, prediction method, quantization method or transformation method of one or more groups that have been decoded; decoding is performed according to the decoding method corresponding to the encoding method of the current group to obtain the coefficients of the current group, wherein the encoding method of the current group is a combination of several encoding methods selected from Golomb-Rice coding, k-order exponential Golomb coding or semi-fixed-length coding.
[0019] In one implementation, among the multiple groups of the encoding unit, at least two groups are encoded in different ways.
[0020] In one embodiment, if the decoding method of the unit to be decoded is any one of Golomb-Rice coding or k-order exponential Golomb coding, then determining the grouping method of the unit to be decoded specifically includes: obtaining the grouping method of the unit to be decoded according to the prediction method, quantization method and / or transformation method of the unit to be decoded.
[0021] Through the above implementation of the present application, the decoding end can derive different scanning methods according to different prediction methods, and at the same time derive coefficient grouping methods. Such coefficient grouping combines the prediction information, making the grouped coefficients more uniform. The encoding end can allocate smaller codewords for encoding coefficients with small changes, so that the encoding method is more flexible and improves the encoding performance. In addition, by designing a variety of fixed grouping modes, it can better adapt to the semi-fixed length encoding method, and can flexibly select a better binarization method for each coding block, and the complexity of the encoding algorithm is low.
[0022] In a second aspect, a video encoding and decoding method is provided, the method comprising: an encoding end scans a data block to be encoded in an original image according to a first scanning method to obtain a coefficient sequence; grouping the coefficient sequence according to a first grouping method to obtain multiple groups of subsequences to be encoded; determining a coefficient encoding method corresponding to each group of subsequences to be encoded, and encoding them one by one to obtain an encoded code stream.
[0023] In one embodiment, the grouping method includes: a fixed-length grouping method, or a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the arrangement position of coefficients.
[0024] In one embodiment, the encoding method is at least one of: unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Golomb code, truncated Rice code, Huffman code, and Golomb-Rice code.
[0025] In one embodiment, the scanning method includes at least one of: raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0026] In one embodiment, the data block to be encoded is a data block consisting of original pixel values of the image to be encoded, residual values obtained by predicting the original pixel values, coefficients of the residual values after quantization, or transformation coefficients obtained after transforming the residual values.
[0027] According to a third aspect, a video decoding device is provided, which includes a transceiver module and a processing module. The transceiver module is used to obtain a code stream of a unit to be decoded; the processing module is used to determine a scanning method, a grouping method and an encoding method corresponding to each group of the unit to be decoded; decoding is performed according to the encoding method of each group to obtain a coefficient block corresponding to the unit to be decoded; according to the scanning method of the unit to be decoded, the coefficients in the coefficient block of each group are restored one by one to obtain a reconstructed data block corresponding to the unit to be decoded.
[0028] In one embodiment, the grouping method includes: a fixed-length grouping method, or a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the arrangement position of coefficients.
[0029] In one embodiment, the encoding method is at least one of: unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Golomb code, truncated Rice code, Huffman code, and Golomb-Rice code.
[0030] In one embodiment, the scanning method includes at least one of: raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0031] In one embodiment, the reconstructed data block is a data block composed of original pixel values of the image to be decoded, residual values obtained by predicting the original pixel values, coefficients of the residual values after quantization, or transformation coefficients obtained after transforming the residual values.
[0032] In one embodiment, the processing module is specifically used to: determine the scanning mode, grouping mode and at least one of the encoding modes corresponding to each group of the unit to be decoded according to the pre-agreement or context information of the encoding end and the decoding end; or, obtain the scanning mode, grouping mode and at least one of the encoding modes corresponding to each group of the unit to be decoded according to the code stream analysis; or, obtain the grouping mode according to the prediction mode, quantization mode and / or transformation mode of the unit to be decoded.
[0033] In one embodiment, the processing module is specifically used to: decode according to the encoding algorithm to obtain group parameters of each group; based on the group parameters of each group, decode according to the semi-fixed-length encoding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0034] In one embodiment, the processing module is specifically used to: decode according to a decoding method corresponding to at least one of the following encoding methods to obtain group parameters of each group: unary code, truncated unary code, truncated binary code, fixed-length code, k-order exponential Columbus code, truncated Rice code, Huffman code or Columbus-Rice code.
[0035] In one embodiment, the processing module is specifically used to: obtain the group Rice parameters of each group by decoding according to a fixed-length coding algorithm, or obtain the group Rice parameters of each group according to a context model; based on the group Rice parameters of each group, decode according to the Golomb-Rice coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0036] In one embodiment, the processing module is specifically used to: obtain group Rice parameters for each group based on a context model; obtain group parameter deviations for each group based on a fixed-length coding algorithm or truncated unary code decoding; obtain group parameters for each group based on the group Rice parameters and the group parameter deviations for each group; and obtain multiple coefficient values in each group based on the group parameters of each group by decoding according to the Columbus-Rice coding algorithm, wherein the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0037] In one embodiment, the processing module is specifically used to: obtain the order k of each group by decoding according to a fixed-length coding algorithm, or obtain the order k of each group according to a context model; based on the order k of each group, obtain multiple coefficient values in each group by decoding according to a k-order exponential Golomb coding algorithm, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0038] In one embodiment, the processing module is specifically used to: obtain the order k of each group according to the context model; obtain the group parameter deviation of each group according to the fixed-length coding algorithm or truncated unary code decoding; update the order k of each group according to the group parameter deviation; according to the updated order k of each group, decode according to the k-order exponential Golomb coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0039] In one embodiment, the processing module is specifically used to: determine the encoding method of the current group based on at least one of the coefficients, prediction methods, quantization methods or transformation methods of one or more groups that have been decoded; decode the coefficients of the current group according to the decoding method corresponding to the encoding method of the current group, wherein the encoding method of the current group is a combination of several encoding methods including Golomb-Rice coding, k-order exponential Golomb coding or semi-fixed-length coding.
[0040] In one implementation, among the multiple groups of the encoding unit, at least two groups are encoded in different ways.
[0041] In one embodiment, if the decoding method of the unit to be decoded is any one of Golomb-Rice coding or k-order exponential Golomb coding, the processing module is specifically used to obtain the grouping method of the unit to be decoded according to the prediction method, quantization method and / or transformation method of the unit to be decoded.
[0042] In a fourth aspect, a video encoding device is provided, the device comprising a transceiver module and a processing module, the processing module is used to scan the to-be-encoded data block in the original image according to a first scanning method to obtain a coefficient sequence; group the coefficient sequence according to a first grouping method to obtain multiple groups of to-be-encoded subsequences; determine the coefficient encoding method corresponding to each group of to-be-encoded subsequences, and encode them one by one to obtain an encoded code stream. The transceiver module is used to send the encoded code stream to a decoding end.
[0043] In one embodiment, the grouping method includes: a fixed-length grouping method, or a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the arrangement position of coefficients.
[0044] In one embodiment, the encoding method is at least one of: unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Golomb code, truncated Rice code, Huffman code, and Golomb-Rice code.
[0045] In one embodiment, the scanning method includes at least one of: raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0046] In one embodiment, the data block to be encoded is a data block consisting of original pixel values of the image to be encoded, residual values obtained by predicting the original pixel values, coefficients of the residual values after quantization, or transformation coefficients obtained after transforming the residual values.
[0047] In a fifth aspect, a coding and decoding system is provided, the coding and decoding system comprising the device as described in any one of the third aspect and the device as described in any one of the fourth aspect.
[0048] In a sixth aspect, a video encoding and decoding device is provided, the device comprising a processor, the processor being coupled to a memory; the memory being used to store computer programs or instructions; and the processor being used to execute the computer programs or instructions stored in the memory, so that the device performs a method as described in any one of the first aspects.
[0049] In a seventh aspect, a video encoding and decoding device is provided, the device comprising a processor, the processor being coupled to a memory; the memory being used to store computer programs or instructions; and the processor being used to execute the computer programs or instructions stored in the memory, so that the device performs a method as described in any one of the second aspects.
[0050] In an eighth aspect, an electronic device is provided, wherein the electronic device is used to execute the method as described in any one of the first aspects.
[0051] In a ninth aspect, an electronic device is provided, wherein the electronic device is used to execute the method as described in any one of the methods in the second aspect.
[0052] In a tenth aspect, a readable storage medium is provided, comprising a program or an instruction. When the program or the instruction is executed by a processor, the method described in any one of the first aspects is executed.
[0053] In an eleventh aspect, a readable storage medium is provided, comprising a program or an instruction, and when the program or the instruction is executed by a processor, the method described in any one of the second aspects is executed.
[0054] In a twelfth aspect, a chip or circuit is provided for executing any method described in the first aspect.
[0055] In a thirteenth aspect, a chip or circuit is provided for executing any method described in the second aspect.
[0056] In a fourteenth aspect, a computer application is provided, which, when executed on a computer or a processor, enables the computer or the processor to execute any method as described in the first aspect.
[0057] In a fifteenth aspect, a computer application is provided, which, when executed on a computer or a processor, enables the computer or the processor to execute any method as described in the second aspect.
[0058] It can be understood that any of the video coding and decoding devices, video coding and decoding systems, chips, computer-readable storage media or computer program products provided above can be implemented by the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 An architecture diagram of a coding and decoding system provided in an embodiment of the present application;
[0060] Figure 2 An internal architecture diagram of an encoder provided in an embodiment of the present application;
[0061] Figure 3 An internal architecture diagram of a decoder provided in an embodiment of the present application;
[0062] Figure 4A A schematic diagram of a video encoding and decoding process provided in an embodiment of the present application;
[0063] Figure 4B A schematic diagram of a video encoding and decoding method provided in an embodiment of the present application;
[0064] Figure 5 A schematic diagram of a unit to be decoded in a video encoding and decoding method provided in an embodiment of the present application;
[0065] Figure 6 A schematic diagram of grouping and scanning in a video encoding and decoding method provided in an embodiment of the present application;
[0066] Figure 7 A schematic diagram of a data portion in a to-be-decoded unit in a video encoding and decoding method provided in an embodiment of the present application;
[0067] Figure 8 A schematic diagram of a grouping method of units to be decoded in a video encoding and decoding method provided in an embodiment of the present application;
[0068] Fig. 9 A schematic diagram of a grouping method of units to be decoded in a video encoding and decoding method provided in an embodiment of the present application;
[0069] Fig.10 A schematic diagram of the structure of a video encoding and decoding device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0071] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0072] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0073] First, the technical terms involved in the embodiments of the present application are introduced:
[0074] Video sequence / image sequence: A complete image in a video is usually called a "frame", and a video composed of many frames in time sequence is called a video sequence (Video Sequence), or it can be called an image sequence.
[0075] Video coding technology: Video sequences contain a series of redundant information, including spatial redundancy, temporal redundancy, visual redundancy, information entropy redundancy, structural redundancy, knowledge redundancy, and importance redundancy. In order to remove redundant information in video sequences as much as possible and reduce the amount of data representing the video, video coding technology is proposed to achieve the effect of reducing storage space and saving transmission bandwidth. Video coding technology is also called video compression technology.
[0076] The video coding process generally includes prediction, transformation, quantization, entropy coding, etc., and the quantized transformation coefficients can be encoded by entropy coding. The specific process will be described below and will not be repeated here.
[0077] In the international scope, video compression coding standards, for example: Advanced Video Coding (AVC) in Part 10 of the MPEG-2 and MPEG-4 standards developed by the Motion Picture Experts Group (MPEG), H.263, H.264 and H.265 (also known as High Efficiency Video Coding standard, HEVC) developed by the International Telecommunication Union Telecommunication Standardization Sector (ITU-T).
[0078] It should be noted that in a coding algorithm based on a hybrid coding architecture, the above compression coding methods can be used in a mixed manner.
[0079] Residual: In the video encoding process, the spatial and temporal redundancy needs to be removed through the prediction process. The encoder obtains the predicted value through prediction, and the residual value is obtained by subtracting the predicted value from the original pixel value. The residual block is the basic unit of transformation, quantization, and entropy coding.
[0080] Transform: In the video encoding process, transformation refers to converting an image described in the form of pixels in the spatial domain to an image in the transform domain, and expressing it in the form of transform coefficients. Since most images contain a large number of flat areas and slowly changing areas, an appropriate transformation process can convert the dispersed distribution of image energy in the spatial domain into a relatively concentrated distribution in the transform domain, thereby removing the frequency domain correlation between signals. In conjunction with the quantization process, the bitstream can be effectively compressed. The transformation process can convert the pixel values in the time domain to the frequency domain. Since the low-frequency components account for a large proportion in the actual residual block, the energy is concentrated in the low-frequency area through transformation, that is, the value of the low-frequency coefficient after transformation is larger, and the value of the high-frequency coefficient is smaller.
[0081] Transformation coefficient: The coefficients of the residual block after transformation and quantization are called transformation coefficients. The pixel values in the residual block are called coefficients. After the residual is transformed, the upper left corner is the low-frequency coefficient and the lower right corner is the high-frequency coefficient. From the upper left corner to the lower right corner, the frequency increases.
[0082] Binarization: also called binarization, the symbols or coefficients to be encoded are binarized, and the binarized symbols or coefficients are converted into binary strings. Different binarization methods may encode the same coefficient to obtain binary strings with different binary probability models and different string lengths.
[0083] Context: In general, different syntax elements are not completely independent, and the same syntax elements themselves also have a certain degree of memory. Therefore, according to the theory of conditional entropy, using other encoded syntax elements for conditional encoding can further improve the encoding performance compared to independent encoding or memoryless encoding. These encoded symbol information used as conditions are called context.
[0084] Context model: In video encoding and decoding, the process of updating symbol probabilities based on context is called context model, and according to the specific application conditions, the same syntax element can use multiple context models to adaptively update the symbol probabilities under the current conditions, thereby further compressing the bit rate.
[0085] Entropy coding: It refers to a lossless coding method based on the principle of information entropy. It is in the last processing module of video compression, which converts a series of element symbols representing a video sequence into a binary bitstream for transmission or storage. The output data of the entropy coding module is the final bitstream after the original video is compressed. Entropy coding can effectively remove the statistical redundancy of these video element symbols and is one of the important tools to ensure the video coding compression efficiency.
[0086] Raster scan: It refers to mapping a two-dimensional rectangular raster to a one-dimensional raster. The entrance of the one-dimensional raster starts from the first row of the two-dimensional raster, and then scans the second row, the third row, and so on. The rows in the raster are scanned from left to right.
[0087] Upper right diagonal scan: It refers to starting the scan from the last coefficient in the lower right corner of the coefficient block and ending at the first coefficient in the upper left corner of the coefficient block. The scan order within each small block is in the order of lower right - upper right - lower left - upper left, and the same is true for other small blocks. The scan order between blocks is the same as the scan order between coefficients, which is also lower right - upper right - lower left - upper left.
[0088] Horizontal back-and-forth scan: It refers to mapping a two-dimensional rectangle to a one-dimensional string. The entrance of the one-dimensional string starts from the starting row of the two-dimensional rectangle and scans the entire two-dimensional rectangle row by row. The row scan direction of the starting row is from left to right, and the row scan direction of the adjacent row to the starting row is from right to left. Any two adjacent rows have opposite row scan directions.
[0089] Inverse horizontal scan: It refers to starting the scan from the last coefficient in the lower right corner of the coefficient block and ending at the first coefficient in the upper left corner of the coefficient block. It scans from right to left and from bottom to top within each coefficient block, and the scan order between blocks is in the order of lower right block - upper right block - lower left block - upper left block.
[0090] Inverse vertical scan: It refers to starting the scan from the last coefficient in the lower right corner of the coefficient block and ending at the first coefficient in the upper left corner of the coefficient block. It scans from bottom to top and from right to left within each small block.
[0091] Z-scan: It refers to for any square with an even side length, first scanning the upper left corner, then the upper right corner, then the lower left corner, and finally the lower right corner.
[0092] Unary code: It is a simple binarization method. Specifically, for a non-negative integer N, its unary code representation is N 1s plus 1 0.
[0093] Truncated unary code: It is a variant of the unary code. Specifically, when the maximum value of the symbol to be encoded is known as N_max, assuming the current symbol to be encoded is a non-negative integer N, if N < N_max, the truncated unary code is the unary code; if N = N_max, the truncated unary code is N 1s.
[0094] Truncated binary code: Calculate the related variables of val (stage, num0, num1 and thd, etc.). For 0~(thd-1), the length of its binary symbol string is the fixed-length code of stage. For thd~val, the length of its binary symbol string is the fixed-length code of (stage+1).
[0095] Run-length encoding: Record the number of times each value appears consecutively as the encoding value. For example: 0001110011010100001100, after compression, the output is: 33221111422.
[0096] Fixed-length coding: Use a fixed code length to encode the coefficients to be encoded, such as ASCII code encoded using 8-bit binary numbers.
[0097] Semi-fixed-length coding: refers to grouping the coefficients to be coded according to the prediction direction and the residual size, encoding the grouping mode, encoding each group with a code length, and using the same fixed-length coding for the coefficients in the same group.
[0098] k-order exponential Golomb coding: k-order exponential Golomb coding includes two parts: prefix prefix and suffix suffix. The coding method includes the following steps: 1) Write the number X in binary form, remove the lowest k bits, and then add 1 to obtain T; 2) Calculate the number of bits of T, and add T-1 zeros in front; 3) Add the removed lowest k bits back to the end of the bit string.
[0099] Truncated Rice code: The truncated Rice code consists of two parts: prefix prefix and suffix suffix. The maximum upper limit value cMax and Rice parameter cRice are known, and the symbol to be encoded cVal is encoded.
[0100] Huffman coding: Count the frequencies of all coefficients, construct a Huffman tree, assign shorter codewords to coefficients with higher probabilities, and assign longer codewords to coefficients with lower probabilities.
[0101] Golomb-Rice coding: Golomb-Rice is a variant of Golomb coding. Compared with Golomb coding, the restriction condition of parameter m is that m must be a power of 2. Specifically, initialize parameter m, which must be a power of 2; calculate q and r, where q = N / m; r = N&(m-1); use unary coding to encode q, and take the lower log2(m) bits of the binary bits of r as the codeword of r.
[0102] Next, the Columbus-Rice coding algorithm is introduced in conjunction with the JPEG-LS coding model.
[0103] In the JPEG-LS encoding algorithm, the pixel gradient in a certain direction is calculated using the surrounding reconstructed pixel values. A gradient value can be calculated based on the predicted direction of the current pixel, or based on experience, the gradient values in the horizontal and vertical directions can be calculated to quantize the gradient.
[0104] The gradient threshold parameters T1, T2 and T3 are calculated according to JPEG-LS.
[0105] maxval=2 n -1
[0106] factor=(maxval+128)>>8
[0107]
[0108] Where n is the image bit width and Near is the quantization distortion parameter. According to the threshold parameters T1, T2, T3, the gradient is quantized as follows:
[0109]
[0110] Where Di represents the calculated gradient value. i represents multiple directions. According to the quantized gradient, the corresponding context index is obtained: Q = (Q1*9+Q2)*9+Q3.
[0111] Adaptive error correction is performed based on the sign of the index value Q and the residual correction value C[Q] (calculated based on the cumulative residual of the context reconstructed pixel): (somewhat like SAO, the correction is to the predicted value):
[0112] if (sign == 1) Px = Px + c[Q];
[0113] else Px = Px - c[Q];
[0114] if (Px>Maxval) Px=Maxval;
[0115] else if (Px<0) Px=0;
[0116] In order to further reduce the amplitude of the residual value Errval, the nearly lossless compression quantization formula is:
[0117]
[0118] Among them, sign represents the sign of the index value Q, and the value range of the prediction error is: ±(range-1).
[0119] Range0 = (2n-1) original pixel range;
[0120] Range0 = ±range prediction residual range;
[0121] range1=-(range0-Near) / (2Near+1) minimum value after quantization;
[0122] range2 = (range0 + Near) / (2Near + 1) the maximum value after quantization;
[0123] range=range2+1.
[0124] In order to compress the range of the error value again, when the prediction error Errval is less than -range / 2, the prediction error Errval is added to the range value. After completing this step, if the prediction error Errval is greater than or equal to (1+range) / 2, the prediction error Errval needs to be subtracted from the range value. After processing, the absolute value of all prediction error Errval values will not be greater than (range+1) / 2. The formula for modular subtraction is as follows:
[0125]
[0126] Finally, the k value of the Golomb coding is estimated according to the context.
[0127] A context residual absolute value accumulator (i.e. the sum of the absolute values of the first n encoded residual values)
[0128] B+=Errval*(2Near+1) context reconstruction value residual accumulator (i.e., the sum of the first n encoded reconstruction values), is used to calculate the prediction error correction parameter C(Q). N is a counter corresponding to the context environment, which stores the number of times the context environment appears. Whenever the value of B / N (corrected residual average) increases by 0.5 or more, the value of C[Q] will increase by 1, and conversely, when the value of B / N decreases by 0.5 or more, the value of C[Q] will decrease by 1. At the same time, in order to make the calculation more in line with local characteristics, a threshold value N0 can be set. When N is greater than N0, the values of N and A are halved, and the values of B and C[Q] are also halved.
[0129] Among them, the calculation of K is the expected value derived under the condition that the current residual distribution conforms to the geometric distribution. With a positive integer m as a parameter, n is Golomb encoded and divided into two parts: a binary code of n%m and a unary code of n / m. For the encoded variables of geometric distribution, there is always an m that makes the average code length after encoding the shortest. When the value of m is 2^k, the Golomb encoding is called Golomb-Rice encoding. Among them, K=min{k1|2k1N>=A}.
[0130] The original range of the residual is ±(range+1) / 2, which is mapped:
[0131]
[0132] Use Columbus–Rice encoding for Merrval.
[0133] At the same time, for flat areas, that is, Di=0, run-length coding is used directly. When adjacent pixels a=b=c=d are detected, that is, g1=g2=g3=0, it means that the coding has reached a very flat area, and the run-length coding mode will be entered. In the run-length mode, the pixel after the current pixel x will continue to be detected to see if it is equal to x (in the lossless mode, it will determine whether the difference with x is within an allowable range). If it is satisfied, the detection will continue, and then the number of identical values (including x) will be recorded, which is the run length.
[0134] In the prior art, SRCC coding technology is mainly used for coding coefficients with a large number of residual values of 0 in lossy coding, and is not suitable for lossless coding or near-lossless coding. The context-based adaptive binary arithmetic coding (CABAC) technology process is relatively complicated, which will increase the complexity of encoding and decoding, so it is not suitable for near-lossless compression. The existing Golomb-Rice coding and semi-fixed-length coding have better effects than those used in lossless and near-lossless coding. However, the code length of Golomb coding depends on the selected order k. If the k value is inaccurate, the code length after binarization will be very long. Therefore, it is generally only suitable for point-by-point coding and fast update of k value. Semi-fixed-length coding can effectively control the code length within a certain range, but before encoding each coefficient, it is necessary to encode the code length of these coefficients first. Therefore, this method is generally suitable for group coding. If the number of coefficients in the group is too small, this method will increase the average code length, but increasing the number of coded coefficients will often increase the range of coefficient values. Since each coefficient in the group uses the same code length, the larger the maximum value in the group, the larger the average code length. In view of the shortcomings of both schemes, a coefficient coding scheme based on lossless and near-lossless coding is proposed in combination with these two coding methods.
[0135] Next, the implementation environment and application scenarios of the embodiments of the present application are briefly introduced. The video encoding and decoding method provided by the present application can be applied to the following Figure 1 The video coding system shown.
[0136] The following describes the system architecture used in the embodiments of the present application. Figure 1 , a schematic diagram of the architecture of a coding and decoding system (also referred to as a coding and decoding system) 10 used in an embodiment of the present application is given. Figure 1As shown, the coding and decoding system 10 may include a source device 11 and a destination device 12. The source device 11 is used to encode an image, so the source device 11 may be referred to as a video encoding device. The destination device 12 is used to decode the encoded image data generated by the source device 11, so the destination device 12 may be referred to as a video decoding device.
[0137] The source device 11 and the destination device 12 may include various devices, such as desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, mobile phones, televisions, cameras, display devices, digital media players, video game consoles, in-vehicle computers, wireless communication devices, etc.
[0138] Optionally, Figure 1 The source device 11 and the destination device 12 may be two separate devices, or the source device 11 and the destination device 12 may be the same device, that is, the source device 11 or the corresponding function and the destination device 12 or the corresponding function may be integrated on the same device.
[0139] The source device 11 and the destination device 12 may communicate with each other, for example, the destination device 12 may receive the encoded image data from the source device 11. In one example, one or more communication media may be included between the source device 11 and the destination device 12, and the encoded image data is transmitted through the one or more communication media, and the one or more communication media may include routers, switches, base stations, or other devices that facilitate communication from the source device 11 to the destination device 12.
[0140] like Figure 1 As shown, the source device 11 includes an encoder 112. Optionally, the source device 11 may also include an image preprocessor 111 and a communication interface 113. The image preprocessor 111 is used to perform preprocessing on the received image to be encoded. For example, the preprocessing performed by the image preprocessor 111 may include refurbishment, color format conversion (for example, from RGB format to YUV format), color adjustment or denoising, etc. The encoder 112 is used to receive the preprocessed image and process the preprocessed image using a related prediction mode (such as the prediction mode in each embodiment of this article) to provide encoded image data. In some embodiments, the encoder 112 can be used to perform the image encoding process in each embodiment described below. The communication interface 113 can be used to transmit the encoded image data to the destination device 12 or any other device (such as a memory) for storage or direct reconstruction. The other device can be any device for decoding or storage. The communication interface 113 can also encapsulate the encoded image data into a suitable format before transmission.
[0141] Optionally, the image preprocessor 111 , the encoder 112 , and the communication interface 113 may be hardware components in the source device 11 , or may be software programs in the source device 11 , which is not limited in the embodiment of the present application.
[0142] Continue as Figure 1 As shown, the destination device 12 includes a decoder 122. Optionally, the destination device 12 may also include a communication interface 121 and an image post-processor 123. The communication interface 121 may be used to receive encoded image data from the source device 11 or any other source device, such as a storage device. The communication interface 121 may also decapsulate the data transmitted by the communication interface 113 to obtain the encoded image data. The decoder 122 is used to receive the encoded image data and output the decoded image data (also referred to as reconstructed image data or reconstructed image data). In some embodiments, the decoder 122 may be used to perform the decoding process described in the various embodiments described below.
[0143] The image post-processor 123 is used to perform post-processing on the decoded image data to obtain post-processed image data. The post-processing performed by the image post-processor 123 may include: color format conversion (for example, from YUV format to RGB format), color adjustment, repair or resampling, or any other processing, and may also be used to transmit the post-processed image data to a display device for display.
[0144] Similarly, optionally, the communication interface 121, decoder 122 and image post-processor 123 may be hardware components in the destination device 12, or may be software programs in the destination device 12, which is not limited in the embodiment of the present application.
[0145] Below Figure 1 The structure of the encoder and decoder in is briefly introduced.
[0146] See also Figure 2 , Figure 2 1 is a schematic block diagram of an example of an encoder 20 for implementing an embodiment of the present application. Figure 2 In the embodiment, the encoder includes a prediction processing unit 201, a residual calculation unit 202, a transform processing unit 203, a quantization unit 204, an entropy coding unit 205, an inverse quantization unit (also referred to as an inverse quantization unit) 206, an inverse transform unit (also referred to as an inverse transform processing unit) 207, a reconstruction unit (or referred to as a reconstruction unit) 208, and a filter unit 209. Optionally, the encoder 20 may further include a buffer and a decoded image buffer, wherein the buffer is used to cache the reconstructed image block output by the reconstruction unit 208, and the decoded image buffer is used to cache the filtered image block output by the filter unit 209.
[0147] The input of the encoder 20 is an image block of an image (which may be referred to as an image to be encoded), and the image block may also be referred to as a current image block or an image block to be encoded. The encoder 20 may also include a segmentation unit ( Figure 2 The encoder 20 is used for encoding the image to be encoded block by block, for example, performing the encoding process on each image block.
[0148] The prediction processing unit 201 is used to receive or obtain an image block (the current image block to be encoded of the current image to be encoded, which may also be referred to as the current image block, and the image block may be understood as the true value of the image block) and reconstructed image data, and predict the current image block based on the relevant data in the reconstructed image data to obtain a prediction block of the current image block. Optionally, the prediction processing unit 201 may include an inter-frame prediction unit, an intra-frame prediction unit, and a mode selection unit, the mode selection unit being used to select an intra-frame prediction mode or an inter-frame prediction mode. If the intra-frame prediction mode is selected, the prediction process is performed by the intra-frame prediction unit, and if the inter-frame prediction mode is selected, the prediction process is performed by the inter-frame prediction unit.
[0149] The residual calculation unit 202 is used to calculate the residual between the real value of the image block and the prediction block of the image block to obtain the residual block, for example, by subtracting the pixel value of the prediction block from the pixel value of the image block pixel by pixel.
[0150] The transform processing unit 203 is used to perform a transform, such as discrete cosine transform (DCT) or discrete sine transform (DST), on the residual block to obtain a transform coefficient in the transform domain. The transform coefficient may also be referred to as a transform residual coefficient, which may represent the residual block in the transform domain.
[0151] The quantization unit 204 is used to quantize the transform coefficients by applying scalar quantization or vector quantization to obtain quantized transform coefficients, which may also be referred to as quantized residual coefficients. The quantization process may reduce the bit depth associated with some or all of the transform coefficients. For example, an n-bit transform coefficient may be rounded down to an m-bit transform coefficient during quantization, where n is greater than m. The degree of quantization may be modified by adjusting a quantization parameter (QP). For example, for scalar quantization, different scales may be applied to achieve finer or coarser quantization. A smaller quantization step size corresponds to finer quantization, while a larger quantization step size corresponds to coarser quantization. A suitable quantization step size may be indicated by a quantization parameter (QP).
[0152] The entropy coding unit 205 is used to entropy code the above-mentioned quantized residual coefficients, and the encoded image data (i.e., the encoding result of the current image block to be encoded) output in the form of an encoded bit stream can then be transmitted to a decoder, or stored, and subsequently transmitted to a decoder or used for retrieval. The entropy coding unit 205 can also be used to entropy code other syntax elements of the current image block, such as entropy coding the prediction mode to a bit stream, etc. Entropy coding algorithms include but are not limited to variable length coding (VLC) algorithms, context adaptive VLC (CAVLC) algorithms, arithmetic coding algorithms, context adaptive binary arithmetic coding (CABAC) algorithms, syntax-based context adaptive binary arithmetic coding (SBAC) algorithms, and probability interval partitioning entropy (PIPE) algorithms.
[0153] The dequantization unit 206 is used to dequantize the quantized coefficients to obtain dequantized coefficients, where the dequantization is the reverse application of the quantization unit 204, for example, based on or using the same quantization step size as the quantization unit 204, and applying an inverse quantization scheme of the quantization scheme applied by the quantization unit 204. The dequantized coefficients may also be referred to as dequantized residual coefficients.
[0154] The inverse transform unit 207 is used to perform an inverse transform on the inverse quantized coefficients. It should be understood that the inverse transform is the reverse application of the transform processing unit 203. For example, the inverse transform may include an inverse discrete cosine transform (DCT) or an inverse discrete sine transform (DST) to obtain an inverse transform block in the pixel domain (or sample domain). The inverse transform block may also be called an inverse transform dequantized block or an inverse transform residual block.
[0155] The reconstruction unit 208 is used to add the inverse transform block (i.e., the inverse transform residual block) to the prediction block to obtain a reconstructed block in the sample domain. The reconstruction unit 208 can be a summer, for example, adding the sample value (i.e., pixel value) of the residual block to the sample value of the prediction block. The reconstructed block output by the reconstruction unit 208 can be subsequently used to predict other image blocks, for example, in an intra-frame prediction mode.
[0156] The filter unit 209 (or simply "filter") is used to filter the reconstructed block to obtain a filtered block, so as to smoothly perform pixel conversion or improve image quality. The filter unit can be a loop filter unit, which is intended to represent one or more loop filters, such as a deblocking filter, a sample-adaptive offset (SAO) filter or other filters, such as a bilateral filter, an adaptive loop filter (ALF), or a sharpening or smoothing filter, or a collaborative filter. Optionally, the filtered block output by the filter unit 209 can be subsequently used to predict other image blocks, for example, in an inter-frame prediction mode.
[0157] Specifically, in the embodiment of the present application, the encoder 20 is used to implement the video encoding and decoding method described in the embodiments below.
[0158] See also Figure 3 , Figure 3 A schematic block diagram of an example of a decoder 30 for implementing an embodiment of the present application is shown. The video decoder 30 is used to receive, for example, encoded image data (i.e., an encoded bitstream, for example, an encoded bitstream including an image block and associated syntax elements) encoded by the encoder 20 to obtain a decoded image. The decoder 30 includes an entropy decoding unit 301, an inverse quantization unit 302, an inverse transform processing unit 303, a prediction processing unit 304, a reconstruction unit 305, and a filter unit 306. In some examples, the decoder 30 may perform substantially the same Figure 2 The decoding pass is the inverse of the encoding pass described by the encoder 20. Optionally, the decoder 30 may further include a buffer and a decoded image buffer, wherein the buffer is used to cache the reconstructed image block output by the reconstruction unit 305, and the decoded image buffer is used to cache the filtered image block output by the filter unit 306.
[0159] The entropy decoding unit 301 is used to perform entropy decoding on the encoded image data to obtain quantized coefficients and / or decoded encoding parameters (for example, the decoded parameters may include any one or all of inter-frame prediction parameters, intra-frame prediction parameters, filter parameters and / or other syntax elements). The entropy decoding unit 301 is also used to forward the above-mentioned decoded encoding parameters to the prediction processing unit 304, so that the prediction processing unit performs a prediction process according to the encoding parameters.
[0160] The function of the inverse quantization unit 302 may be the same as that of the inverse quantization unit 206 of the encoder 20 , for inverse quantizing (ie, inverse quantizing) the quantized coefficients decoded by the entropy decoding unit 301 .
[0161] The function of the inverse transform processing unit 303 may be the same as that of the inverse transform unit 207 of the encoder 20, and the function of the reconstruction unit 305 (e.g., a summer) may be the same as that of the reconstruction unit 208 of the encoder 20, and is used to perform an inverse transform (e.g., an inverse DCT, an inverse integer transform, or a conceptually similar inverse transform process) on the above-mentioned quantized coefficients to obtain an inverse transform block (also referred to as an inverse transform residual block), which is the residual block of the current image block in the pixel domain.
[0162] The prediction processing unit 304 is used to receive or obtain the encoded image data (e.g., the encoded bit stream of the current image block) and the reconstructed image data. The prediction processing unit 301 can also receive or obtain prediction related parameters and / or information about the selected prediction mode (i.e., decoded encoding parameters) from, for example, the entropy decoding unit 302, and predict the current image block based on the related data in the reconstructed image data and the decoded encoding parameters to obtain the prediction block of the current image block. Optionally, the prediction processing unit 304 can include an inter-frame prediction unit, an intra-frame prediction unit, and a mode selection unit. The mode selection unit is used to select an intra-frame prediction mode or an inter-frame prediction mode. If the intra-frame prediction mode is selected, the prediction process is performed by the intra-frame prediction unit. If the inter-frame prediction mode is selected, the prediction process is performed by the inter-frame prediction unit.
[0163] The reconstruction unit 305 is used to add the inverse transform block (ie, the inverse transform residual block) to the prediction block to obtain a reconstructed block in the sample domain, for example, adding the sample values of the inverse transform residual block to the sample values of the prediction block.
[0164] The filter unit 306 is configured to filter the reconstructed block to obtain a filtered block, where the filtered block is a decoded image block.
[0165] Specifically, in the embodiment of the present application, the decoder 30 is used to implement the video decoding method described in the embodiments below.
[0166] It should be understood that in the encoder 20 and decoder 30 of the embodiment of the present application, the processing result of a certain link can also be output to the next link after further processing. For example, after the interpolation filtering, motion vector derivation or filtering and other links, the processing results of the corresponding link are further subjected to operations such as Clip or shift.
[0167] The video decoding method and the video encoding method provided in the embodiments of the present application can be performed by an electronic device, and the electronic device can have the function of compressing and encoding or decoding any image or video image. In some embodiments, the electronic device can be a laptop computer, a tablet computer, a desktop computer, a portable computer, etc., which is not limited in the embodiments of the present application.
[0168] Below Figure 1 to Figure 3 Based on the video encoding and decoding system shown, the present application provides a possible video encoding / decoding implementation method, such as Figure 4A As shown, Figure 4A A schematic diagram of a video encoding / decoding process provided in the present application, wherein the video encoding / decoding implementation method includes process ① to process ⑤, and process ① to process ⑤ can be executed by any one or more of the above-mentioned encoder 20, decoder 30, source device 11 or destination device 12.
[0169] Process ①: Divide a frame of image into one or more non-overlapping parallel coding units. The one or more parallel coding units have no dependencies and can be completely parallel / independently encoded and decoded, such as Figure 4A A parallel encoding unit 1 and a parallel encoding unit 2 are shown.
[0170] Process ②: Each parallel coding unit can be further divided into one or more non-overlapping independent coding units. The independent coding units may not depend on each other, but may share some parallel coding unit header information.
[0171] For example, the width of an independent coding unit is w_lcu and the height is h_lcu. If a parallel coding unit is divided into an independent coding unit, the size of the independent coding unit is exactly the same as the parallel coding unit; otherwise, the width of the independent coding unit should be greater than the height (unless it is an edge area).
[0172] Typically, the independent coding unit may be a fixed w_lcu×h_lcu, where w_lcu and h_lcu are both 2 to the power of N (N≥0), such as the size of the independent coding unit is 128×4, 64×4, 32×4, 16×4, 8×4, 32×2, 16×2 or 8×2.
[0173] As a possible example, the independent coding unit may be fixed to 128×4. If the size of the parallel coding unit is 256×8, the parallel coding unit may be equally divided into 4 independent coding units; if the size of the parallel coding unit is 288×10, the parallel coding unit is divided into: the first / second row is 2 128×4 + 1 32×4 independent coding units; the third row is 2 128×2 + 1 32×2 independent coding units.
[0174] It is worth noting that the independent coding unit can include three components of brightness Y, chrominance Cb, and chrominance Cr, or three components of red (red, R), green (green, G), and blue (blue, B), or only one of them. If the independent coding unit contains three components, the sizes of the three components can be exactly the same or different, which is related to the input format of the image.
[0175] Process ③: Each independent coding unit can be further divided into one or more non-overlapping coding units. The coding units within the independent coding unit can be interdependent, such as multiple coding units can perform mutual reference pre-coding and decoding.
[0176] If the coding unit and the independent coding unit have the same size (ie, the independent coding unit is divided into only one coding unit), the size thereof can be any size described in process ②.
[0177] If the independent coding unit is divided into multiple non-overlapping coding units, feasible division examples include: horizontal equal division (the height of the coding unit is the same as that of the independent coding unit, but the width is different, which can be 1 / 2, 1 / 4, 1 / 8, 1 / 16, etc.), vertical equal division (the width of the coding unit is the same as that of the independent coding unit, but the height is different, which can be 1 / 2, 1 / 4, 1 / 8, 1 / 16, etc.), horizontal and vertical equal division (quadtree division), etc., preferably horizontal equal division.
[0178] The width of the coding unit is w_cu and the height is h_cu, so its width should be greater than its height (unless it is an edge area). Usually, the coding unit can be a fixed w_cu x h_cu, where w_cu and h_cu are both 2N powers (N is greater than or equal to 0), such as 16x4, 8x4, 16x2, 8x2, 8x1, 4x1, etc.
[0179] As a possible example, the coding unit may be a fixed 16x4. If the size of the independent coding unit is 64x4, the independent coding unit may be equally divided into 4 coding units; if the size of the independent coding unit is 72x4, the coding unit may be divided into: 4 16x4 + 1 8x4.
[0180] It is worth noting that the coding unit can include three components of brightness Y, chrominance Cb, and chrominance Cr (or three components of red R, green G, and blue B), or only one of them. If it includes three components, the sizes of the components can be exactly the same or different, which is related to the image input format.
[0181] It is worth noting that process ③ is an optional step in the video coding and decoding method, and the video codec can encode / decode the residual coefficients (or residual values) of the independent coding units obtained in process ②.
[0182] Process ④: For the coding unit, it can be further divided into one or more non-overlapping prediction groups (Prediction Group, PG), PG can also be referred to as Group, each PG is encoded and decoded according to the selected prediction mode to obtain the prediction value of PG, which constitutes the prediction value of the entire coding unit, and the residual value of the coding unit is obtained based on the prediction value and the original value of the coding unit.
[0183] Process ⑤: Based on the residual values of the coding units, the coding units are grouped to obtain one or more non-overlapping residual blocks (RBs). The residual coefficients of each RB are encoded and decoded according to the selected mode to form a residual coefficient stream. Specifically, it can be divided into two categories: transforming the residual coefficients and not transforming them.
[0184] Among them, the selected mode of the residual coefficient encoding and decoding method in process ⑤ may include, but is not limited to any of the following: semi-fixed length coding method, exponential Golomb coding method, Golomb-Rice coding method, truncated unary code coding method, run-length coding method, direct encoding of the original residual value, etc.
[0185] For example, a video encoder may directly encode coefficients within an RB.
[0186] For another example, the video encoder may also transform the residual block, such as DCT, DST, Hadamard transform, etc., and then encode the transformed coefficients.
[0187] As a possible example, when RB is small, the video encoder can directly perform uniform quantization on each coefficient in RB, and then perform binary encoding. If RB is large, it can be further divided into multiple coefficient groups (coefficient groups, CG), and then each CG is uniformly quantized and then binary encoded. In some embodiments of the present application, the coefficient group (CG) and the quantization group (QG) can be the same.
[0188] The following is an exemplary explanation of the residual coefficient encoding part in a semi-fixed length coding method. First, the maximum value of the absolute value of the residual in an RB block is defined as the modified maximum value (modified maximum, mm). Secondly, the number of coding bits for the residual coefficient in the RB block is determined (the number of coding bits for the residual coefficient in the same RB block is consistent). For example, if the critical limit (CL) of the current RB block is 2 and the current residual coefficient is 1, then 2 bits are required to encode the residual coefficient 1, which is expressed as 01. If the CL of the current RB block is 7, it means encoding an 8-bit residual coefficient and a 1-bit sign bit. The determination of CL is to find the minimum M value that satisfies that all residuals of the current sub-block are within the range of [-2^(M-1), 2^(M-1)]. If both -2^(M-1) and 2^(M-1) exist, M should be increased by 1, that is, M+1 bits are required to encode all residuals of the current RB block; if only one of the two boundary values of -2^(M-1) and 2^(M-1) exists, a Trailing bit needs to be encoded to determine whether the boundary value is -2^(M-1) or 2^(M-1); if all residuals do not exist in either -2^(M-1) or 2^(M-1), there is no need to encode the Trailing bit.
[0189] In addition, for some special cases, the video encoder can also directly encode the original value of the image instead of the residual value.
[0190] Based on the above problems, the present application proposes a video encoding and decoding method for a lossless and near-lossless compression coding framework, which can encode the original pixel (quantized / unquantized) value, or the predicted (quantized / unquantized) residual coefficient, or the transformed (quantized / unquantized) transform coefficient as follows:
[0191] (1) Taking into account the different data distributions among original pixels, residual coefficients and transform coefficients, different encoding methods are used for different data according to their distribution characteristics.
[0192] (2) At the same time, different scanning methods can be designed for the data. The scanning method should take into account the distribution of the data and try to distribute coefficients with similar amplitudes together.
[0193] (3) The data obtained after scanning can be grouped. The grouping method can be irregular grouping based on the distribution of the data, or fixed grouping can be performed directly. The specific grouping of the data can be consistent with the encoding and decoding convention, or derived based on the context (including deriving from the encoded data, deriving from the prediction coefficient, and deriving from the encoded parameters), or obtained by transmitting parameters from the encoding end.
[0194] (4) For different data distributions, you can choose to encode directly according to the data to be encoded, or you can perform parameter estimation based on the context to estimate the encoding range of the coefficients to be encoded, or directly estimate the relevant values of the coefficients to be encoded, and then you can calculate a parameter correction value based on the range of the estimated value. You can choose whether to pass another parameter correction value to make the estimated parameter more accurate.
[0195] (5) For different data distributions, parameter estimation can be performed based on the context to estimate the numerical range of the next group of coding coefficients (the number of coefficients in each group may be greater than or equal to 1), and the coding method for the next group of coefficients can be selected based on the estimated value.
[0196] (6) For different data distributions, parameter estimation can be performed based on the context, and then a parameter correction value can be parsed from the bitstream to obtain the numerical range of the next set of coding parameters. The encoding method for the next set of coefficients can be selected based on the numerical range. Different encoding schemes and encoding methods can be selected according to different coefficient ranges.
[0197] (7) Since the data distribution in the time domain is different from that in the frequency domain, the data distribution in the time domain is relatively uniform, while the larger energy of the data in the frequency domain is distributed on the low-frequency information. Therefore, when encoding the transform coefficients, special grouping can be performed based on the positions of the transformed coefficients.
[0198] (8) When encoding the coefficients, one may select unary code, truncated unary code, truncated binary code, fixed length code, semi-fixed length code, run-length code, k-order exponential Golomb code, truncated Rice code, Golomb-Rice code, Huffman code, arithmetic code or adaptive variable length code, etc. One or a combination of these coding methods may be used to encode the coefficients.
[0199] In a specific implementation, the scanning method for the coding coefficients can be selected from raster scanning, block scanning, horizontal scanning, vertical scanning, round-trip (horizontal / vertical) scanning, diagonal (upper left, upper right, lower left, lower right) scanning, reverse diagonal scanning, reverse horizontal scanning, reverse vertical scanning, or scanning based on a fixed scanning template, etc.
[0200] In general, the overall encoding process provided by the embodiment of the present application is consistent with the decoding process. The parameters that need to be written into the bitstream can be obtained through rate distortion optimization (RDO) at the encoding end or estimated. The video encoding and decoding process provided by the embodiment of the present application mainly includes a group encoding process and a process without group encoding.
[0201] 1. Group coding process:
[0202] First, the coefficients are converted into one-dimensional vectors. If the area to be encoded is a three-dimensional image, the three-dimensional image is first divided into one or more two-dimensional coefficient blocks. If the area to be encoded is a two-dimensional coefficient block, the block to be encoded is scanned into a one-dimensional coefficient vector using a certain scanning order.
[0203] Secondly, the coefficient vector is grouped according to the size of the coefficient, and the coefficients with similar amplitudes are grouped into the same group. According to several fixed grouping methods, the one-dimensional coefficients are grouped, and then the specific grouping information is encoded, or the one-dimensional coefficient grouping method is derived according to the prediction method and the transformation method. The coding coefficients in the same group can use a parameter group_param, which can guide the coding of all subsequent coefficients. The parameter group_param can be encoded with a fixed-length code, or it can be encoded with a unary code or a truncated unary code. Then, according to group_param, a certain coding method is used to encode each coefficient in the group.
[0204] 2. No need for group coding process:
[0205] Similar to the grouping scheme, the grouping method is removed and the coefficients are encoded one by one. For each coefficient to be encoded, the value range of the coefficient to be encoded can be derived based on the context, and a coding method is selected based on the range to encode it.
[0206] The following is a brief introduction to the overall decoding process of the embodiment of the present application:
[0207] a) Determine the scanning method for the coefficients;
[0208] b) Determine the coefficient type (original value, transformed coefficient, residual coefficient after prediction);
[0209] c) determine the coefficient coding method;
[0210] d) decoding each coefficient or the parameters required for each group of coefficients from the bit stream according to the encoding method;
[0211] e) determining whether it is necessary to derive prediction parameters based on context information according to the coefficient encoding method;
[0212] f) if there are prediction parameters, decoding is performed according to the prediction parameters and the parameters parsed in the bitstream in accordance with the coefficient coding method; otherwise, decoding is performed directly according to the prediction parameters and the parameters parsed in the bitstream in accordance with the coefficient coding method;
[0213] g) If there are groups, the decoded coefficients in each group are put back to the original coefficient positions in order according to the bit stream, otherwise all coefficient values are directly decoded.
[0214] Among them, the methods determined in steps a), b) and c) at the decoding end can be determined by bitstream parsing, or by the codec agreement, or by the decoding end export method (determined according to parameters such as the current block size or prediction method, transformation method, etc.).
[0215] 1. The process of group decoding mainly includes: first, determine the scanning method of the block; second, determine the grouping method of the coefficients after scanning; then, use a certain decoding method to decode each group parameter group_param, and according to group_param, use a certain decoding method to decode each coefficient value in the group; finally, according to the scanning method, restore the coefficients in the coded block to the original arrangement.
[0216] 2. The process of decoding without grouping mainly includes: first, determining the scanning method of the block; predicting the current coding coefficient range according to the context, and selecting a decoding method for decoding according to the coefficient value range.
[0217] Next, the video decoding method and the video encoding method provided in the embodiments of the present application will be described in detail with reference to the accompanying drawings.
[0218] This application provides a video decoding method, please refer to Figure 4B , is a flow chart of a video encoding and decoding method provided by an embodiment of the present application. The encoding process in the method can be performed by the aforementioned encoder, and the decoding process can be performed by the aforementioned decoder. The method may include the following steps.
[0219] 401: The encoding end scans the to-be-encoded unit in the original image data according to a first scanning method to obtain a coefficient sequence.
[0220] In one implementation, the encoding end scans the original data block and can obtain coefficients to be encoded based on different scanning methods. Specifically, the first scanning method can include any of the following: raster scanning, block scanning, horizontal scanning, vertical scanning, round-trip (horizontal / vertical) scanning, diagonal (upper left, upper right, lower left, lower right) scanning, reverse horizontal scanning, reverse vertical scanning, Hilbert scanning, or other scanning based on a fixed scanning template. The specific scanning process of each scanning method can refer to the relevant technical description, and this application does not make too many restrictions on this.
[0221] The encoder can derive one or more scanning modes according to the prediction mode or transformation mode of the current coefficient, etc. Alternatively, the encoder can select a scanning mode for all coefficients according to the pre-agreed agreement of the codec, so that the decoder can also determine the scanning mode according to the pre-agreed agreement.
[0222] In one implementation, the video coding and decoding method in the embodiment of the present application can be applied to the coding of original pixels, or the coding of residual values obtained by predicting original pixel values, or the coding of coefficients obtained by predicting original pixel values to obtain residual values and then quantizing them, or the coding of transformation coefficients obtained by transforming predicted residual values, or the coding of transformation coefficients obtained by transforming predicted residual values and then quantizing them, etc. The coding of the above data can be coded and compressed by the implementation methods provided by the present application.
[0223] That is to say, the original data block, the unit to be encoded or the reconstructed data block obtained by decoding referred to in the embodiments of the present application may be a data block composed of the original pixel values of the image to be encoded, or a data block composed of residual values obtained by predicting the original pixel values, or a data block composed of coefficients after quantization of the residual values, or a data block composed of transformation coefficients obtained after transformation of the residual values, or a data block composed of quantized coefficients after transformation of the residual values. This will not be repeated in the following embodiments.
[0224] It should be noted that if the image data to be encoded has multiple components, each component may be encoded using a different encoding method.
[0225] In one embodiment, the data sequence to be encoded in the embodiment of the present application can be coefficient blocks of various sizes, for example, it can be an m×n data block, where m and n are both less than or equal to 64, for example, the unit to be encoded is a 16×4 coefficient block, a 16×1 coefficient block, an 8×4 coefficient block, an 8×2 coefficient block or a 4×2 coefficient block, etc.
[0226] 402: The encoding end groups the coefficient sequence according to the first grouping method to obtain multiple groups of subsequences to be encoded.
[0227] In one implementation, the grouping method includes at least one of a fixed-length grouping method, a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the position of coefficients. The number of coefficients in the multiple groups of subsequences to be encoded may be the same or different. The specific grouping method will be introduced based on specific embodiments later and will not be described in detail here.
[0228] 403: The encoder determines the coefficient encoding mode corresponding to each group of subsequences to be encoded, and encodes them one by one to obtain an encoded bit stream.
[0229] In one embodiment, the encoding method may include at least one of the aforementioned unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Columbus code, truncated Rice code, Huffman code, Columbus-Rice code, etc. It may also be a combination of multiple encoding methods in the above encoding methods, which will be introduced based on specific embodiments later and will not be repeated here.
[0230] In one implementation, the encoding methods determined for the subsequences to be encoded may be the same or different. The specific encoding methods will be introduced based on specific embodiments later and will not be described in detail here.
[0231] 404: The encoder transmits the bitstreams to the decoder one by one.
[0232] 405: The decoding end obtains the bit stream, determines the scanning method of the unit to be decoded, the grouping method, and the encoding method corresponding to each group.
[0233] The decoding end obtains the encoded bit stream and can decode it segment by segment. The unit to be decoded can be a data unit in the encoded bit stream that the decoding end performs decoding processing.
[0234] In one embodiment, the decoding end may determine at least one of the scanning mode, grouping mode, and encoding mode corresponding to each group used by the unit to be decoded according to the pre-agreed agreement or context information of the encoding and decoding end. Alternatively, the decoding end may also parse out at least one of the scanning mode, grouping mode, and encoding mode corresponding to each group used by the unit to be decoded according to the bit stream. Alternatively, the decoding end may also obtain the grouping mode corresponding to each group according to the prediction mode, quantization mode, and / or transformation mode of the unit to be decoded. This will be described later based on specific embodiments and will not be repeated here.
[0235] 406: The decoding end decodes each group one by one according to the encoding method to obtain a coefficient block corresponding to the unit to be decoded.
[0236] In one implementation, the decoding process may specifically include:
[0237] 1. The decoding end decodes and obtains the group parameters of each group according to the encoding algorithm;
[0238] In one example, in one implementation, the decoding method of the group parameter may specifically include:
[0239] The decoding end decodes according to the decoding method corresponding to at least one of the following encoding methods to obtain the group parameters of each group: unary code, truncated unary code, truncated binary code, fixed-length coding, k-order exponential Columbus coding, truncated Rice coding, Huffman coding or Columbus-Rice coding.
[0240] 2. The decoding end decodes the group parameters of each group according to the semi-fixed-length coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0241] In one implementation, the decoding process may specifically include:
[0242] 1. The decoding end obtains the group Rice parameters of each group by decoding according to the fixed-length coding algorithm, or obtains the group Rice parameters of each group according to the context model;
[0243] 2. The decoding end decodes the group Rice parameters of each group according to the Columbus-Rice coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0244] In one implementation, the decoding process may specifically include:
[0245] 1. The decoding end obtains the group Rice parameters of each group according to the context model;
[0246] 2. The decoding end obtains the group parameter deviation of each group according to the fixed-length coding algorithm or the truncated unary code decoding; and obtains the group parameter of each group according to the group Rice parameter and the group parameter deviation of each group;
[0247] In an example, the group parameter of each group can be updated according to the group Rice parameter and the group parameter deviation. Specifically, the group parameter = group Rice parameter + group parameter deviation.
[0248] 3. The decoding end decodes the multiple coefficient values in each group according to the group parameters of each group and the Columbus-Rice coding algorithm, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0249] In one implementation, the decoding process may specifically include:
[0250] 1. The decoding end obtains the order k of each group by decoding according to the fixed-length coding algorithm, or obtains the order k of each group according to the context model;
[0251] 2. The decoding end decodes the multiple coefficient values in each group according to the order k of each group and the k-order exponential Golomb coding algorithm, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0252] In one implementation, the decoding process may specifically include:
[0253] 1. The decoding end obtains the order k of each group based on the context model;
[0254] 2. The decoding end obtains the group parameter deviation of each group according to the fixed-length coding algorithm or truncated unary code decoding; then, the order k of each group is updated according to the group parameter deviation;
[0255] In one example, the order k of each group = group parameter deviation + context model to obtain the original order k.
[0256] 3. According to the updated order k of each group, multiple coefficient values in each group are obtained by decoding according to the k-order exponential Golomb coding algorithm, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0257] In one implementation, the decoding process may specifically include:
[0258] 1. The decoding end determines the encoding mode of the current group according to at least one of the coefficients, prediction mode, quantization mode or transformation mode of one or more groups obtained by decoding;
[0259] 2. The decoding end decodes the coefficients of the current group according to the decoding method corresponding to the encoding method of the current group, wherein the encoding method of the current group can be a combination of several encoding methods in the Golomb-Rice encoding, the k-order exponential Golomb encoding or the semi-fixed length encoding method. The following will be introduced based on specific embodiments and will not be repeated here.
[0260] In one implementation, in any of the above encoding and decoding methods, among the multiple groups of the encoding unit, at least two groups are encoded in different ways.
[0261] 407: The decoding end recovers the coefficients in the coefficient block of the unit to be decoded according to the scanning mode of the unit to be decoded to obtain a reconstructed data block.
[0262] The decoding end recovers the coefficients in each group coefficient block one by one to obtain the reconstructed data block corresponding to the unit to be decoded.
[0263] In one implementation, the scanning method applicable to the embodiments of the present application may include at least one of raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0264] Through the above implementation of the present application, the decoding end can derive different scanning methods according to different prediction methods, and at the same time derive coefficient grouping methods. Such coefficient grouping combines the prediction information, making the grouped coefficients more uniform. The encoding end can allocate smaller codewords for encoding coefficients with small changes, so that the encoding method is more flexible and improves the encoding performance. In addition, by designing a variety of fixed grouping modes, it can better adapt to the semi-fixed length encoding method, and can flexibly select a better binarization method for each coding block, and the complexity of the encoding algorithm is low.
[0265] The technical aspects of the embodiments of the present application will be described below in conjunction with several specific embodiments.
[0266] Embodiment 1:
[0267] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0268] Step 2: The decoding end parses the bit stream to find out the grouping mode of the unit to be decoded according to the n grouping modes pre-configured by the encoding and decoding end.
[0269] The grouping method may include at least one of a fixed-length grouping method, a semi-fixed-length grouping method for grouping based on coefficient value size, or a grouping method for grouping based on coefficient arrangement position.
[0270] Specifically, a fixed-length grouping method, such as treating the entire unit to be encoded as a group, or treating every 4 coefficients in the entire unit to be decoded as a group, or treating every 3 coefficients in the entire unit to be encoded as a group. Exemplarily, the unit to be encoded is a data unit with 12 rows and 4 columns, that is, a 12×4 unit to be encoded. If the grouping method is based on treating every 4 coefficients as a group, the 12×4 unit to be encoded can be divided into 12 groups; if the grouping method is based on treating every 3 coefficients as a group, the 12×4 unit to be encoded can be divided into 16 groups; if the grouping method is based on treating the entire unit to be encoded as a group, the 12×4 unit to be encoded can be directly treated as 1 group.
[0271] In one example, the grouping method may also be a method of grouping based on the position of the coefficient arrangement. Specifically, each coefficient in the entire unit to be coded may be evenly divided into 2 groups, 3 groups, or 4 groups, etc., according to the arrangement position. For example, the coefficients are divided into 2 groups according to a ratio. For example, for a 12×4 unit to be coded, if the number of coefficients in the entire unit to be decoded is N=48, the coefficients are divided into 2 groups according to a ratio of 1:1. Then, the first 24 coefficients in the 12×4 unit to be coded are one group, and the remaining 24 coefficients are another group.
[0272] In one example, the coefficients in the entire unit to be encoded may be unevenly divided into 2 groups, 3 groups, or 4 groups according to the positions. Exemplarily, the coefficients may be unevenly divided into 3 groups, and the division ratio may be 2:1:1, that is, the coefficients 1 to 24 according to the coefficient arrangement position in the 12×4 unit to be encoded may be grouped into 1 group, the coefficients 25 to 36 may be grouped into 2 groups, and the coefficients 37 to 48 may be grouped into 3 groups.
[0273] In one example, the grouping method can also be based on the number of coefficients in each group, for example, every 2 adjacent coefficients in the entire unit to be encoded are grouped as a group, or every 3 adjacent coefficients are grouped as a group, or every 4 adjacent coefficients are grouped as a group, etc.
[0274] In one example, the grouping method may also be based on dividing the coefficient arrangement position in the entire unit to be coded into a group every a point. For example, when a is 1, the coefficients at every other point in the coefficient position in the entire unit to be coded can be grouped as a group and divided into 2 groups; when a is 2, the coefficients at every other point in the coefficient position in the entire unit to be coded can be grouped as a group and divided into 3 groups.
[0275] In one example, the grouping method may also be to group and divide based on the size of the coefficient value in the unit to be coded. Since the size of the coefficient value in the unit to be coded cannot be predicted, the number of coefficients in each group after grouping based on the size of the coefficient value is generally different. Therefore, this division method may be referred to as a semi-fixed-length grouping method in the present application.
[0276] Exemplarily, grouping according to the size of the coefficient value can determine whether each coefficient in the unit to be coded is greater than n, and the coefficients greater than or equal to n can be grouped as one group, and the coefficients less than n can be grouped as one group. Alternatively, the coefficients greater than n can be grouped as one group, and the coefficients less than or equal to n can be grouped as one group.
[0277] The value of n may be pre-agreed between the encoding end and the decoding end, or determined through information interaction, or determined through bitstream decoding.
[0278] For example, the encoding end and the decoding end may pre-agreed on a value, such as n=2. 3 Alternatively, the decoding end may make a prediction based on the decoded reconstructed value or the predicted value to determine the value n. Alternatively, the decoding end may make a prediction based on the decoded coefficient value to determine the value n.
[0279] Exemplarily, the decoding end can make a prediction based on the decoded reconstructed value or the predicted value to determine the value n; then parse the bit stream to see whether each coefficient value in each group of the current unit to be decoded is greater than the predicted value n, and then group the coefficients greater than n as a group, and group the coefficients less than or equal to n as a group.
[0280] Further, in the above-mentioned multiple grouping methods, after the coefficients in the unit to be coded are grouped, if the number of coefficients in a group is large, secondary grouping can be performed. For example, if the coefficients in the unit to be coded are greater than n and are grouped into one group, and the number of coefficients in the group is greater than the preset number of coefficients, the group can be secondary grouped. Specifically, the secondary grouping method can be grouped based on any of the above-mentioned grouping methods or a combination of multiple grouping methods.
[0281] In one example, for the coefficients in the coding unit to be transform coefficients, the grouping method can also be expressed as: taking the DC coefficient of the transform system in the entire coding unit to be coded as one group, and grouping the AC coefficients according to any one of the aforementioned grouping methods or a combination of multiple grouping methods.
[0282] Step 3: The decoding end decodes the parameters group_param of each group using a fixed-length code. Then, according to the parameters group_param of each group one by one, it decodes each coefficient value within each group using a fixed-length code to obtain the coefficient block corresponding to the decoding unit to be decoded.
[0283] Step 4: The decoding end restores the coefficients within the coefficient block according to the scanning method of the decoding unit to be decoded to obtain the original data block.
[0284] In one implementation manner, the encoding end and the decoding end can be pre-agreed or configured with one or more of the above several grouping methods. During the video encoding and decoding process, the encoding end selects one or several grouping methods for grouping and encoding according to the coefficient situation of the coding unit to be coded. The decoding end can determine the grouping method through bitstream parsing, signaling interaction with the encoding end, or methods such as context prediction and derivation, and perform grouped parsing on the bitstream based on the determined grouping method. In addition, the decoding end can also derive the grouping method of the coefficients in the current decoding unit to be decoded according to the prediction direction, prediction mode, or transform mode of different pixels within the decoding unit to be decoded. Specific examples will be described below and will not be elaborated here.
[0285] In one implementation manner, based on the fixed-length grouping coding method or semi-fixed-length grouping coding method in Example 1, for each group of parameters group_param for encoding and decoding, any one of the following coding methods can be used, or several coding methods can be combined.
[0286] 1. Unary code: It is a simple binarization method. Specifically, for a non-negative integer N, its unary code is represented as N 1s plus 1 0.
[0287] 2. Truncated unary code: It is a variant of the unary code. Specifically, when the maximum value of the symbol to be coded is known as N_max, assuming the current symbol to be coded is a non-negative integer N, if N < N_max, the truncated unary code is the unary code; if N = N_max, the truncated unary code is N 1s.
[0288] 3. Truncated Binary Code: Calculate the relevant variables of val (stage, num0, num1, thd, etc.). For values from 0 to (thd - 1), the binary symbol string has a fixed length of stage. For values from thd to val, the binary symbol string has a fixed length of (stage + 1).
[0289] 4. Fixed-Length Encoding: Use a fixed code length to encode the coefficient to be encoded. For example, use ASCII code encoded with 8-bit binary numbers.
[0290] 5. k-Order Exponential Golomb Coding: k-Order Exponential Golomb coding consists of two parts, a prefix and a suffix. The encoding method includes the following steps:
[0291] 1) Write the number X in binary form, remove the lowest k bits, then add 1 to obtain T; 2) Calculate the number of bits of T, and fill in T - 1 zeros in front; 3) Complement the removed lowest k bits to the end of the bit string.
[0292] 6. Truncated Rice Coding: Truncated Rice coding consists of two parts, a prefix and a suffix. Given the maximum upper limit value cMax and the Rice parameter cRice, encode the symbol cVal to be encoded.
[0293] The specific encoding process includes: (1) Calculate the prefix: prefix = cVal >> cRice, and binarize prefix using truncated unary code with cMax >> cRice as the upper limit. (2) Calculate the suffix: If cVal < cMax: suffix = cVal - prefix << cRice. If cVal >= cMax: there is no suffix. The suffix is calculated as a fixed-length code with the number of bits being cRice. It can be seen from the calculation process that when cRice = 0, truncated Rice coding is equivalent to truncated unary code. Here, the symbol >> represents a right shift operation, and << represents a left shift operation.
[0294] 7. Huffman Coding: Statistically analyze the frequencies of all coefficients, construct a Huffman tree, and assign shorter codewords to coefficients with higher probabilities and longer codewords to coefficients with lower probabilities.
[0295] 8. Golomb-Rice Coding: Golomb-Rice is a variant of Golomb coding. The difference compared to Golomb coding is that the parameter m has a restriction that m must be a power of 2. Specifically, initialize the parameter m, where m must be a power of 2; calculate q and r, where q = N / m; r = N & (m - 1); encode q using unary coding, and take the lower log2(m) bits of the binary representation of r as the codeword for r.
[0296] In addition, fixed-length encoding can be combined with truncated unary code to obtain the following combined decoding schemes:
[0297] Solution 1: Use a solution similar to truncated unary code. For prefixes greater than (N-1)>>1, use a truncated unary code that starts with 1 and ends with 0. For prefixes less than (N-1)>>1, use a truncated unary code that starts with 0 and ends with 1.
[0298] Solution 2: For prefixes greater than (N-1)>>1, a truncated unary code starting with 1 and ending with 0 is used. For prefixes less than (N-1)>>1, a fixed-length code starting with 0 is used.
[0299] Solution 3: For prefixes greater than (N-1)>>1, a fixed-length code starting with 1 is used to represent them. For prefixes less than (N-1)>>1, a truncated unary code starting with 0 and ending with 1 is used to represent them.
[0300] Solution 4: Use a scheme similar to truncated unary code. For prefixes greater than (N-1)>>1, use a truncated unary code starting with 0 and ending with 1. For prefixes less than (N-1)>>1, use a truncated unary code starting with 1 and ending with 0.
[0301] Scheme 5: For prefixes greater than (N-1)>>1, a truncated unary code starting with 0 and ending with 1 is used. For prefixes less than (N-1)>>1, a fixed-length code starting with 1 is used.
[0302] Solution 6: For prefixes greater than (N-1)>>1, a fixed-length code starting with 0 is used to represent them. For prefixes less than (N-1)>>1, a truncated unary code starting with 1 and ending with 0 is used to represent them.
[0303] In addition, in one implementation, the encoding end may also encode the grouping method based on the above encoding methods. That is, based on the multiple semi-fixed-length grouping methods in Example 1, the encoding end and the decoding end may be configured with n grouping methods, and then the encoding end may use one of the encoding methods to encode the unit to be encoded according to the configuration, so that the decoding end may derive the grouping method used by the unit to be decoded based on the code stream, and further perform decoding based on the grouping method.
[0304] In one implementation, the semi-fixed-length group decoding in the above-mentioned embodiment 1 can be combined with the context model to derive the prediction value and further decode. Specifically, for the group parameter group_param of each group in the unit to be decoded, the prediction value group_param_pred can be first derived from the context, and then the decoding method in the above-mentioned implementation is used to solve the difference group_delta between the real group_param and the predicted group_param_pred, and according to group_param=group_param_pred+group_delta, the group parameter group_param of each group in the unit to be decoded is obtained. Then, all the coefficients of each group are decoded according to the group parameters and the decoding algorithm.
[0305] In one embodiment, when the encoder needs to perform fixed-length coding on the coefficients of semi-fixed-length coding, for larger coefficients, the encoder can directly encode the original pixel values using fixed-length coding, or directly encode the reconstructed pixel values using fixed-length coding.
[0306] For example, if the bit width of the original pixel value is 8, when the encoding bit width of the coefficient group group_param>=6, or the encoding bit width of the coefficient group group_param>=7, the original pixel value can be directly encoded with a fixed-length code of 8, or the reconstructed pixel value can be encoded, thereby improving the encoding and decoding performance.
[0307] In one implementation, the decoding end may determine the grouping method of the units to be decoded by deriving the grouping method of the coefficients in the current unit to be decoded according to the prediction direction, prediction mode, or transformation mode of different pixels in the unit to be decoded.
[0308] Specifically, the decoding end may derive the grouping method and encoding method of the coefficients in the unit to be decoded according to the prediction mode.
[0309] For example, the first column currently uses a prediction mode, and all subsequent columns use a horizontal prediction mode. The first point can directly pass the original value, or be predicted by the reconstructed value of the previous block. Figure 5 As shown, taking a 16×4 unit to be decoded as an example, if the residual of the current prediction scheme is predicted as follows Figure 5 As shown, all residual values in the first column are grouped as 1. In the remaining coefficient block 15×4, each row of residual values is grouped as 1. The number of coefficients in the first group is small, so no further grouping is performed. The remaining groups are allowed to be smaller in each group.
[0310] Therefore, the scanning order of the entire block is to first scan vertically to obtain the first group of coefficients and encode them; then scan horizontally to obtain the second group of coefficients. The second group of coefficients can be divided into smaller groups from left to right, and different encoding schemes can be used in each group. The first group in the second group uses semi-fixed length coding. According to the size of the prefix value used in the first group, if the prefix is less than a certain threshold, the coefficients of the next group are encoded using Columbus-Rice coding. If the prefix is greater than a certain threshold, the coefficients of the next group are encoded using k-order Columbus coding. The k value is derived from the residual value of the previous group.
[0311] In addition, the decoding end can derive the grouping method and encoding method of the coefficients in the unit to be decoded according to the transformation mode.
[0312] Exemplarily, the encoding end may encode the transform coefficients according to the specific position of the DC coefficient. All DC coefficients may be grouped into one group, and all AC coefficients may be grouped into one group. When the number of DC coefficients is large, the DC coefficient group may be grouped again; when the number of AC coefficients is large, the AC coefficient group may be grouped again.
[0313] Specifically, since the DC coefficient value is relatively large in most cases, a more flexible coding scheme can be used for the DC coefficient, such as using a k-order exponential Golomb coding with finer grouping. When the DC coefficient amplitude values are relatively close, the DC coefficient is predicted, and the first DC coefficient is first encoded using the k-order exponential Golomb coding. The remaining DC coefficients only need to encode the DC coefficient sign and the difference with the first DC coefficient. Among them, the coding of the DC coefficient difference can use semi-fixed length coding.
[0314] Specifically, the AC coefficients are generally small in value, so the entire AC coefficient can be grouped as a group and semi-fixed length coding can be used; or the AC coefficients can be divided into 2 groups (for example, the upper right corner + lower left corner as a group, and the lower right corner as a group), and each group uses semi-fixed length coding. However, when the AC coefficient amplitude is large, the AC coefficients of the upper right corner and the lower left corner can be grouped into 2-3 coefficients, using Columbus-Rice coding, and semi-fixed length coding can be used for the lower right corner.
[0315] The scanning order of the coding unit to be processed may be to first divide the entire large block into DC coefficients and AC coefficients. Figure 6 As shown, taking a 16×4 unit to be coded as an example, the distribution of coefficients after transformation may be as follows Figure 6As shown. In the DC coefficient, if the entire DC coefficient is encoded as a group, then the DC coefficient is raster scanned, otherwise, Hilbert scan is used to encode the coefficients that are closer together. In the AC coefficient, if all AC coefficients are a group, raster scan is directly used for the AC coefficient, otherwise, first scan in the order of the upper right corner, the lower left corner, and the lower right corner, and the coefficients inside the three corners are scanned in raster scan order.
[0316] In another embodiment, taking a 16×4 unit to be coded as an example, the coefficient distribution after transformation may be as follows: Figure 7 As shown. Divide the coefficients into 2 blocks and perform transformations in each block. Figure 7 As shown, if there are only two DC coefficients, there are the following groups:
[0317] 1. Directly treat the two DC coefficients as a group and all AC coefficients as one group; the scanning order is to use raster scanning within each 8×4.
[0318] 2. Directly take the two DC coefficients as a group, and divide all AC coefficients into 2 groups, each 8×4 as a group (excluding the DC coefficient); the scanning order is to use raster scanning within each 8×4.
[0319] 3. Directly treat the two DC coefficients as a group, and divide all AC coefficients into 4 groups, each 4×4 as a group (excluding the DC coefficient), and use raster scanning within each 4×4.
[0320] 4. Directly treat the two DC coefficients as a group, and divide all AC coefficients into 8 groups (within 8×4, each two columns as a group) using vertical scanning.
[0321] Based on any of the above grouping methods, in one example, the encoding end may use k-order exponential Golomb coding for the DC coefficient and semi-fixed length coding for the AC coefficient.
[0322] Embodiment 2:
[0323] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0324] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0325] Step 3: The decoding end uses a fixed-length code to decode the Rice parameter CRice of each group, and then uses Columbus-Rice to decode each coefficient value in the group.
[0326] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0327] Embodiment 3:
[0328] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0329] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0330] Step 3: The decoder estimates the Rice parameter CRice of each group based on the context, and then uses the Columbus-Rice decoding method to decode each coefficient value in the group.
[0331] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0332] Embodiment 4:
[0333] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0334] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0335] Step 3: The decoder estimates the Rice parameter CRice of each group based on the context, and then uses a fixed-length code to decode the parameter deviation C of each group, and updates the original CRice+C to the Rice parameter CRice, that is, CRice+=C. Then, use the Columbus-Rice decoding method to decode each coefficient value in the group.
[0336] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0337] Embodiment 5:
[0338] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0339] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0340] Step 3: The decoding end determines the Rice parameter CRice of each group, and then uses the Columbus-Rice encoding to decode each coefficient value in the group.
[0341] Among them, the decoding end can derive the Rice parameter CRice based on the code stream, and its specific decoding method can be any one of the aforementioned embodiment 1, such as unary code, truncated unary code, truncated binary code, fixed-length coding, k-order exponential Columbus coding, truncated Rice coding, Huffman coding, Columbus-Rice coding, etc. The decoding end can group the coefficients according to the size of the coefficient value, using fixed-length code decoding combined with truncated unary code, which will not be repeated here.
[0342] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0343] Embodiment 6:
[0344] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0345] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0346] Step 3: The decoding end estimates the Rice parameter CRice of each group based on the context, and then uses a fixed-length code to decode the parameter deviation C of each group, the Rice parameter CRice+=C, and uses the Columbus-Rice encoding to decode each coefficient value in the group.
[0347] The decoding scheme of the parameter deviation C can be any one of the above-mentioned embodiments 1, such as unary code, truncated unary code, truncated binary code, fixed-length coding, k-order exponential Columbus coding, truncated Rice coding, Huffman coding, Columbus-Rice coding, etc. The decoding end can group the coefficients according to the size of the coefficient value, using fixed-length code decoding combined with truncated unary code, which will not be repeated here.
[0348] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0349] Embodiment 7:
[0350] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0351] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0352] Step 3: The decoding end uses a fixed-length code to decode the order k of each group, and then uses k-order Exponential Golomb decoding to decode each coefficient value in the group.
[0353] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0354] Embodiment 8:
[0355] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0356] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0357] Step 3: The decoding end context estimates the order k of each group, and then uses the k-order Exponential Golomb decoding to decode each coefficient value in the group.
[0358] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0359] Embodiment 9:
[0360] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0361] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0362] Step 3: The decoding end context estimates the order k of each group, and then uses a fixed-length code to decode the parameter deviation C of each group, and updates the original order k+C to the order k, that is, k+=C. Then, use k-order Exponential Golomb decoding to decode each coefficient value in the group.
[0363] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0364] Embodiment 10:
[0365] Step 1: The decoding end determines the scanning mode of the unit to be decoded.
[0366] Step 2: The decoding end parses the bit stream to find out the grouping mode of the units to be decoded according to the n fixed grouping modes pre-configured by the encoding and decoding end.
[0367] Step 3: The decoding end determines the order k of each group, and then uses the k-order Exponential Golomb decoding to decode each coefficient value in the group.
[0368] Among them, the decoding end can derive the order k based on the code stream, and its specific decoding method can be any one of the above-mentioned embodiment 1, such as unary code, truncated unary code, truncated binary code, fixed-length coding, k-order exponential Columbus coding, truncated Rice coding, Huffman coding, Columbus-Rice coding, etc. The decoding end can group the coefficients according to the size of the coefficient value, using fixed-length code decoding combined with truncated unary code, which will not be repeated here.
[0369] Step 4: The decoding end restores the coefficients in the coefficient block according to the scanning method of the unit to be decoded to obtain the original data block.
[0370] Embodiment 11:
[0371] Step 1: The decoder uses the surrounding reconstructed pixel values to calculate the pixel gradient in a certain direction. It can calculate a gradient value based on the predicted direction of the current pixel, or calculate the gradient value in the horizontal direction or the gradient value in the vertical direction based on experience, and quantize the gradient.
[0372] Step 2: The decoder estimates the value range of the current coefficient based on the context, and estimates the value of the Rice coefficient k of Columbus-Rice or the value of the order k of Exponential Columbus based on the value range.
[0373] Embodiment 12:
[0374] Step 1: The encoder estimates the value range of the current coefficient based on the context and selects a coding method based on the value range.
[0375] Step 2: The encoding end encodes the current coefficient using the corresponding Golomb coding method.
[0376] For example, when the absolute value of the estimated coefficient is greater than or equal to 2 5 When , the k value of the Columbus-Rice code is estimated, and then the current coefficient is encoded using the Columbus-Rice code. When the absolute value of the estimated coefficient is less than 2 5 When , the k value of the exponential Golomb coding is estimated, and then the current coefficient is encoded using the exponential Golomb coding.
[0377] Or, in one example, when the absolute value of the estimated coefficient is greater than 2 5 When , the k value of the exponential Golomb coding is estimated, and then the current coefficient is encoded using the exponential Golomb coding. When the absolute value of the estimated coefficient is less than or equal to 2 5 When , the k value of Columbus-Rice is estimated, and then the current coefficient is encoded using Columbus-Rice coding.
[0378] Furthermore, the value range of the coefficient may also be other positive integer values based on empirical values, and the embodiments of the present application do not specifically limit this.
[0379] Embodiment 13:
[0380] Step 1: The encoder estimates the value of the current coding coefficient based on the context.
[0381] For example, if the true value is greater than the current estimated value, the code is 1; otherwise, the code is 0. The code values 0 and 1 correspond to one coding mode respectively.
[0382] Step 2: The encoding end encodes the current coefficient using the corresponding Golomb coding method.
[0383] Exemplarily, 1 corresponds to exponential Columbus coding, and 0 corresponds to Columbus-Rice coding. When the code value is 1, the k value of the exponential Columbus coding is estimated according to the context, and then the current coefficient is encoded using the exponential Columbus coding. When the code value is 0, the k value of Columbus-Rice is estimated, and then the current coefficient is encoded using the Columbus-Rice coding.
[0384] Alternatively, in one example, when the coded value is 0, the k value of the Golomb-Rice coding is estimated according to the context; otherwise, the k value of the exponential Golomb coding is estimated, and then the current coefficient is encoded using the corresponding Golomb coding method.
[0385] Embodiment 14:
[0386] Step 1: When encoding coefficients, the encoder derives an estimated value n of the current coding coefficient based on the context, and reads from the bitstream whether the current coding coefficient is less than n.
[0387] Step 2: For parameters less than n, the encoder uses a fixed-length code; for coefficients greater than n, it estimates a k value, uses Exponential Columbus or Columbus to decode, and adds n to the decoded value.
[0388] Embodiment 15:
[0389] Step 1: When the encoder encodes the residual coefficients in groups, an estimated value n is derived according to the context, and the parameters of the coefficients to be encoded are divided into two groups according to the estimated value n.
[0390] Step 2: For parameters less than n, the encoder uses fixed-length code decoding; for coefficients greater than n, estimate a k value, use Exponential Columbus or Columbrax to decode, and add n to the decoded value.
[0391] Or for parameters less than n, estimate a k and use Exponential Columbus decoding; for coefficients greater than n, estimate a k value, use Columbus decoding, and add n to the decoded value.
[0392] Or for parameters less than n, estimate a k and use Columbus decoding; for coefficients greater than n, estimate a k value, use Exponential Columbus decoding, and add n to the decoded value.
[0393] Embodiment 16:
[0394] Step 1: When the encoder encodes the residual coefficients in groups, an estimated value n is derived according to the context, a correction value delta is read out according to the truncated unary code in the bitstream, and the value of n is updated according to delta: n+=delta. According to the value of n, the parameters of the coefficients in the unit to be decoded are divided into two groups.
[0395] Step 2: For parameters less than n, use fixed-length code decoding; for coefficients greater than n, estimate a value of k, use Exponential Columbus or Columbrax to decode, and add n to the decoded value.
[0396] Or for parameters less than n, estimate a k and use Exponential Columbus decoding; for coefficients greater than n, estimate a k value, use Columbus decoding, and add n to the decoded value.
[0397] Or for parameters less than n, estimate a k and use Columbus decoding; for coefficients greater than n, estimate a k value, use Exponential Columbus decoding, and add n to the decoded value.
[0398] Embodiment 17:
[0399] Step 1: The encoder parses the bitstream to determine whether to enable the run-length encoding mode based on the context information.
[0400] Specifically, based on the coding coefficients or if there are multiple consecutive equal values in the reconstructed data, the run-length coding mode is turned on; otherwise, the run-length coding mode is turned off and any of the aforementioned coding schemes is directly used.
[0401] Exemplarily, the context information may include one of the following descriptions:
[0402] a) according to the magnitude of the gradient or the sum of the gradients in each direction of the decoded reconstructed pixel value;
[0403] b) according to the magnitude of the gradient or the sum of the gradients in each direction of the adjacent predicted pixel values;
[0404] c) according to the magnitude of the gradient or the sum of the gradients of the decoded coefficients in each direction;
[0405] d) weighted by combining the magnitude of the sum of the two gradients in a, b or c;
[0406] e) Combine the magnitude of the sum of the three gradients in a, b, or c and perform the weighting.
[0407] Embodiment 18:
[0408] Since the code length of semi-fixed-length coding is related to the grouping method and the number of coefficients in the group, the compression rate or coding performance of the encoder will vary greatly according to different prediction schemes or different image contents. Therefore, a better grouping method needs to be agreed in advance: such as a fixed-size grouping method.
[0409] When decoding multiple fixed block partitions, the block partition method of the current coding unit may be decoded first, and then decoding may be performed according to the fixed partition method.
[0410] Exemplarily, the unit to be coded can be divided into multiple 2×2 small blocks as a coding group. Taking a 16×4 unit to be coded as an example, one CL is shared in the group. Semi-fixed-length coding is used, and the first CL value is coded using fixed-length coding, with a code length of 3 or 4 (related to the image bit width N). The second CL value is the difference of the CL obtained based on context prediction, and is coded using a truncated unary code. The longest truncated unary code is N-1.
[0411] like Figure 8 As shown, the 16×4 to-be-coded unit is divided into 2×2 small blocks in a fixed manner, and the groups are as follows Figure 8 Each 2×2 block can be scanned in accordance with the Hilbert scanning method. For example, the scanning order of the coding unit to be coded at the encoding end can be as follows: Figure 8 As shown in (2), scan in the order of numbers 0 to 15.
[0412] Each CL can be raster scanned, that is, the scanning order within each 2×2 block can be as follows: Figure 8 As shown in (3), scan in the order of numbers 0 to 3.
[0413] Context prediction can be used between CLs. CL0 is directly encoded using a fixed-length code. CL1 = (CL1-CL0) is encoded using a truncated unary code. n =(CL n -(CL n-2 +CL n-1 *3>>2), using truncated unary encoding.
[0414] Detection of CL n-2 With CL n-1 The reconstruction value of CL n-2 With CL n-1 If all internal reconstruction values are equal or almost equal, it is determined whether the current 2×2 small block directly reuses the previous CL n-2 With CL n-1 Internal reconstruction value. In one example, run-length coding can also be used directly to encode the current coding block, and the number of 2×2 small blocks of the encoded reconstruction value can be directly used. This number can be encoded using a fixed-length code, and the fixed-length code length is determined based on the number of uncoded CLs in the current coding unit, up to 15 uncoded units, so the maximum fixed-length code length is 4 bits.
[0415] In another embodiment, if Fig. 9As shown in FIG. 1 , the unit to be coded can be divided into multiple 4×1 small blocks. Taking a 16×4 unit to be coded as an example, the 16×4 unit to be coded can be divided into a grouping method of 4×1 small blocks in a fixed manner, and the groups are as follows: Fig. 9 The 16 small blocks shown in .
[0416] The encoding methods of multiple components (luminance values or chrominance values) of the image data may be consistent or inconsistent.
[0417] In one example, the fixed block division method of the coding unit to be coded by the coding end may also be: 2×1, 1×2, 1×4, 2×4, 4×2, 2×8, 2×16, 4×4, 8×4 or 16×4, etc. This application does not specifically limit the division method.
[0418] Exemplarily, taking 2×2 fixed block partition decoding as an example, the decoding process at the decoding end mainly includes the following steps.
[0419] 1) If the current block is the first block, use the fixed-length code to decode the CL value of the 0th block. According to the CL value, use the fixed-length code to solve the 4 coefficient values, and store the positions of the 4 residual values in the first 2×2 small block in raster scanning order.
[0420] 2) If the current block is not the first block, according to whether the reconstruction values of the previous blocks are equal, or the CL value (whether the first 1 or 2 CLs are 0), if the first 2 CL values are 0, parse a flag, that is, whether the current block directly uses the previous coefficient value or reconstruction value. If yes, do not parse the current block; if not, count into step 3 and continue decoding.
[0421] 3) If the current block is not the first block, use the truncated unary code to decode the residual value of the CL value of the current block and the CL value of the previous block, get the CL of the current value, and use the fixed-length code to decode the four coefficient values in the block. According to the Sheilbit scanning order, each 2×2 small block is stored in order.
[0422] It should be noted that a 16×4 unit to be coded needs to parse 16 2×2 small blocks in total. If the CL value of the current group is greater than or equal to the image bit width, the current group directly encodes the original value or the reconstructed value.
[0423] Embodiment 19:
[0424] The decoding process using a non-fixed-size block division method will be described below in conjunction with a specific embodiment.
[0425] Step 1: derive the prediction scheme of the previous block, obtain the prediction mode of each pixel in the current block, and group them according to the prediction mode.
[0426] Step 2: If the current block groups pixels when predicting, the current block is grouped according to the prediction grouping scheme. Otherwise, if the current block is directly predicted point by point when predicting, it can be grouped according to the prediction direction of each point.
[0427] Step 3: Decode the coefficients in each group according to the prediction order. If the prediction order is from top left to bottom right, the grouped coefficients are decoded in the same order. If the prediction order is from left to right, the grouped coefficients are also decoded in the same order.
[0428] Step 4: Derive whether transform coding is used for each group.
[0429] Step 5: If the current group uses transform coding, if the current group is the first group, the order k is derived based on the empirical value or the previous coding block, and k-order Golomb decoding is used for the DC coefficient; if the current group is not the first group, the DC coefficient parameter k of the current group is estimated based on the DC coefficient value of the previous group, and k-order Golomb decoding is used.
[0430] 1) For the remaining coefficients, if the DC coefficient value is greater than the threshold, the last 1 / 2 coefficients (i.e., the high-frequency coefficients) of the current group are analyzed from the bitstream to see if they are all 0. If so, the number of coefficients remaining in the current group of coefficients except the DC coefficient and the 0 coefficient is determined as the number of coefficients to be encoded.
[0431] 2) If the number of coefficients is less than 3, Golomb-Rice coding is used for the remaining coefficients. The first coded coefficient is derived from the Rice coefficient C according to the quantization step size and the DC coefficient value, and Golomb-Rice decoding is used. The subsequent coefficients are derived from the Rice coefficient C according to the size of the previous coefficient value and Golomb-Rice decoding is used. Otherwise, if the number of coefficients is greater than 3, semi-fixed length coding is used; if the last 1 / 2 coefficients of the previous group (i.e., the high-frequency coefficients) are non-zero, they are processed according to 2).
[0432] 3) Analyze the last 1 / 4 coefficients (i.e., high-frequency coefficients) of the current group from the bitstream to see if they are all 0. If they are all 0, except for the DC coefficient and the last 1 / 4 coefficients, the remaining coefficients are processed according to 2). Otherwise, all coefficients except the DC coefficient are processed according to 2. If the DC coefficient value is less than the threshold, process according to 3).
[0433] Step 6: If transform coding is not used in the current group, the quantization step size of the coefficients in the current group is derived for the coefficients in the group, and decoding is performed based on the quantization step size and the coefficient values of the previous group in the time domain.
[0434] 1) First, estimate the mean of the absolute values of the coefficients within the current group;
[0435] 2) Then, decode the comparison results of the absolute values of all coefficients in the current group with the estimated mean, and perform secondary grouping according to the comparison results, with those greater than the mean as one group and those less than or equal to the mean as another group;
[0436] 3) After the second grouping, according to the number of coefficients in the group, if the number of coefficients in the group smaller than the mean is greater than or equal to 4, semi-fixed length decoding is used, otherwise Columbrax decoding is used for the group smaller than the mean;
[0437] For the group of coefficients greater than the mean, if the number of coefficients is greater than 4 and the estimated mean is less than the threshold, semi-fixed length decoding is used, otherwise, k-order exponential Columbus decoding is used. The k value and C value can be estimated based on the estimated mean, or can be obtained based on the estimated mean and a parameter parsed by the decoding end.
[0438] Embodiment 20:
[0439] Step 1: After the decoding end determines the grouping mode, it determines whether the number x of coefficients in the current group is greater than a threshold m. For example, if m=30 and x=32, it is determined that the number x of coefficients in the current group is greater than the threshold m.
[0440] Step 2: The decoder parses up to n positions from the bit stream. These n positions represent the positions of n outliers (coefficients with larger amplitudes within the group) within the current group (for example, n=2). The position coding is decoded using a fixed-length code, and the code length is related to the size of the x value (if x=32, the code length is 5).
[0441] Step 3: The decoding end decodes the coefficient values of other positions in the current group.
[0442] Among them, the method for decoding the coefficient values at other positions of the current group can be the aforementioned semi-fixed length decoding, exponential Golomb decoding, Golomb-Rice decoding or Huffman decoding, etc.
[0443] Step 4: The decoding end uses k-order exponential Golomb decoding to decode the outlier value, and the decoded amplitude plus the maximum amplitude of the remaining position coefficient values is used as the amplitude of the outlier point.
[0444] Embodiment 21:
[0445] Step 1: After the decoding end determines the grouping mode, it determines whether the number x of coefficients in the current group is greater than a threshold m. For example, if m=30 and x=32, it is determined that the number x of coefficients in the current group is greater than the threshold m.
[0446] Step 2: The decoding end uses a fixed-length code to decode the maximum amplitude in the current group, and according to the value of the maximum amplitude, uses a fixed-length code to decode the minimum amplitude in the current group. According to the value range of the maximum amplitude and the minimum amplitude, all coefficients in the current group are decoded.
[0447] Specifically, if the maximum amplitude is equal to the minimum amplitude, the coefficients of the entire group do not need to be decoded;
[0448] If the difference between the maximum and minimum amplitudes is 1, then only 1 bit of specific length code is needed for each coefficient of the entire group to decode;
[0449] If the difference between the maximum amplitude and the minimum amplitude is less than n (for example, n=15), the coefficients at the remaining positions in the current group can be decoded using a fixed-length code. For example, when n=15, a 4-bit fixed-length code can be used for decoding.
[0450] If the difference between the maximum amplitude and the minimum amplitude is greater than n, the appropriate order k is selected according to the difference, and the k-order exponential Columbus decoding is used to decode the coefficients in the current group.
[0451] It should be noted that the various embodiments in the above-mentioned embodiments of the present application can be combined with each other. For example, the various different grouping methods in Embodiment 1 can be applied to other embodiments, the different encoding and decoding algorithms in Embodiment 2 can also be applied to other embodiments, and various different encoding and decoding algorithms can be used in combination as needed.
[0452] Based on the above implementation, the present application also provides a video encoding device and a corresponding video decoding device, which are collectively referred to as video encoding and decoding devices in the present application. Figures 1 to 3 ,like Fig.10 As shown, the device 1000 may include a transceiver module 1001 and a processing module 1002 .
[0453] The transceiver module 1001 may be used to obtain a code stream of a unit to be decoded.
[0454] The processing module 1002 can be used to determine the scanning method, grouping method and encoding method corresponding to each group of the unit to be decoded; decode according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded; according to the scanning method of the unit to be decoded, restore the coefficients in the coefficient block of each group one by one to obtain the reconstructed data block corresponding to the unit to be decoded.
[0455] In one embodiment, the grouping method includes: a fixed-length grouping method, or a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the arrangement position of coefficients.
[0456] In one embodiment, the encoding method is at least one of: unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Golomb code, truncated Rice code, Huffman code, and Golomb-Rice code.
[0457] In one embodiment, the scanning method includes at least one of: raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0458] In one embodiment, the reconstructed data block is a data block composed of original pixel values of the image to be decoded, residual values obtained by predicting the original pixel values, coefficients of the residual values after quantization, or transformation coefficients obtained after transforming the residual values.
[0459] In one embodiment, the processing module 1002 can be specifically used to: determine the scanning mode, grouping mode and at least one of the encoding modes corresponding to each group of the unit to be decoded according to the pre-agreement or context information of the encoding end and the decoding end; or, obtain the scanning mode, grouping mode and at least one of the encoding modes corresponding to each group of the unit to be decoded according to the code stream analysis; or, obtain the grouping mode according to the prediction mode, quantization mode and / or transformation mode of the unit to be decoded.
[0460] In one embodiment, the processing module 1002 can be specifically used to: decode according to the encoding algorithm to obtain the group parameters of each group; based on the group parameters of each group, decode according to the semi-fixed-length encoding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0461] In one embodiment, the processing module 1002 can be specifically used to: decode according to a decoding method corresponding to at least one of the following encoding methods to obtain group parameters of each group: unary code, truncated unary code, truncated binary code, fixed-length code, k-order exponential Columbus code, truncated Rice code, Huffman code or Columbus-Rice code.
[0462] In one embodiment, the processing module 1002 can be specifically used to: obtain the group Rice parameters of each group by decoding according to a fixed-length coding algorithm, or obtain the group Rice parameters of each group according to a context model; based on the group Rice parameters of each group, decode according to the Golomb-Rice coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0463] In one embodiment, the processing module 1002 can be specifically used to: obtain the group Rice parameters of each group according to the context model; obtain the group parameter deviation of each group according to the fixed-length coding algorithm or truncated unary code decoding; obtain the group parameters of each group according to the group Rice parameters of each group and the group parameter deviation; based on the group parameters of each group, decode according to the Columbus-Rice coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0464] In one embodiment, the processing module 1002 can be specifically used to: obtain the order k of each group by decoding according to a fixed-length coding algorithm, or obtain the order k of each group according to a context model; according to the order k of each group, obtain multiple coefficient values in each group by decoding according to a k-order exponential Golomb coding algorithm, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0465] In one embodiment, the processing module 1002 can be specifically used to: obtain the order k of each group according to the context model; obtain the group parameter deviation of each group according to the fixed-length coding algorithm or truncated unary code decoding; update the order k of each group according to the group parameter deviation; according to the updated order k of each group, decode according to the k-order exponential Golomb coding algorithm to obtain multiple coefficient values in each group, and the coefficient block corresponding to the unit to be decoded includes the multiple coefficient values in each group.
[0466] In one embodiment, the processing module 1002 can be specifically used to: determine the encoding method of the current group based on at least one of the coefficients, prediction methods, quantization methods or transformation methods of one or more groups that have been decoded; decode the coefficients of the current group according to the decoding method corresponding to the encoding method of the current group, wherein the encoding method of the current group is a combination of several encoding methods including Golomb-Rice coding, k-order exponential Golomb coding or semi-fixed-length coding.
[0467] In one implementation, among the multiple groups of the encoding unit, at least two groups are encoded in different ways.
[0468] In one embodiment, if the decoding method of the unit to be decoded is any one of Golomb-Rice coding or k-order exponential Golomb coding, the processing module 1002 can be specifically used to obtain the grouping method of the unit to be decoded according to the prediction method, quantization method and / or transformation method of the unit to be decoded.
[0469] Correspondingly, the present application provides a video encoding device, such as Fig.10 As shown, the device 1000 includes a transceiver module 1001 and a processing module 1002.
[0470] Among them, the processing module 1002 is used to scan the data block to be encoded in the original image according to the first scanning method to obtain a coefficient sequence; group the coefficient sequence according to the first grouping method to obtain multiple groups of subsequences to be encoded; determine the coefficient encoding method corresponding to each group of subsequences to be encoded, and encode them one by one to obtain an encoded code stream.
[0471] The transceiver module 1001 is used to send the encoded code stream to the decoding end.
[0472] In one embodiment, the grouping method includes: a fixed-length grouping method, or a semi-fixed-length grouping method based on the size of coefficient values, or a grouping method based on the arrangement position of coefficients.
[0473] In one embodiment, the encoding method is at least one of: unary code, truncated unary code, truncated binary code, fixed-length code, semi-fixed-length code, k-order exponential Golomb code, truncated Rice code, Huffman code, and Golomb-Rice code.
[0474] In one embodiment, the scanning method includes at least one of: raster scanning, block scanning, horizontal scanning, vertical scanning, reciprocating scanning, diagonal scanning, inverse horizontal scanning, inverse vertical scanning or Hilbert scanning.
[0475] In one embodiment, the data block to be encoded is a data block consisting of original pixel values of the image to be encoded, residual values obtained by predicting the original pixel values, coefficients of the residual values after quantization, or transformation coefficients obtained after transforming the residual values.
[0476] Specifically, the video encoding and decoding device provided in this application can be composed of the above Figure 2 and Figure 3 The encoder and decoder shown are implemented as follows Figure 1 The coding and decoding system shown in FIG. For a schematic diagram of the internal structure of the device, please refer to Figures 1 to 3 As shown, no further description is given here.
[0477] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instruction is loaded and executed on a computer, the process or function in accordance with the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instruction can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) mode or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a magnetic disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state drive (SSD)).
[0478] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0479] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0480] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0481] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0482] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, or all or part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk, and other media that can store program codes.
[0483] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A video image decoding method, characterized in that: The method comprises: Obtain the code stream of the unit to be decoded; Determine the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded; wherein, the determining the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded specifically includes: determining at least one of the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to a pre-agreed agreement between the encoding end and the decoding end; or, obtaining at least one of the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to the bitstream parsing; or, determining at least one type of scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to the pre-agreed agreement between the encoding end and the decoding end; based on the scanning mode, grouping mode and encoding mode corresponding to each group of the at least one type of units to be decoded, obtaining at least one of the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to the bitstream parsing; According to the magnitude of the coefficient value, the code stream is decoded by combining a fixed-length code with a truncated unary code to obtain a group parameter of each group; Decoding according to the encoding mode of each group to obtain a coefficient block corresponding to the unit to be decoded, wherein the coefficient block corresponding to the unit to be decoded includes multiple coefficient values in each group; wherein, if the encoding mode includes a fixed-length code mode, decoding according to the encoding mode of each group to obtain a coefficient block corresponding to the unit to be decoded includes: decoding according to the fixed-length code according to the group parameter of each group to obtain multiple coefficient values in each group; According to the scanning mode of the unit to be decoded, the coefficients in each group of coefficient blocks are restored one by one to obtain a reconstructed data block corresponding to the unit to be decoded.
2. The method according to claim 1, characterized in that The scanning method includes: vertical scanning.
3. A video image decoding device, characterized in that: The device comprises: An acquisition module, used to acquire the code stream of the unit to be decoded; A determination module, used to determine the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded; wherein, when the determination module determines the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded, it is specifically used to: determine at least one of the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to a pre-agreed agreement between the encoding end and the decoding end; or, obtain at least one of the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to the bitstream analysis; or, determine at least one type of scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to the pre-agreed agreement between the encoding end and the decoding end; based on the scanning mode, grouping mode and encoding mode corresponding to each group of the at least one type of units to be decoded, obtain at least one of the scanning mode, grouping mode and encoding mode corresponding to each group of the units to be decoded according to the bitstream analysis; A decoding module is used to decode the code stream according to the size of the coefficient value by combining a fixed-length code with a truncated unary code to obtain a group parameter of each group; decode according to the encoding method of each group to obtain a coefficient block corresponding to the unit to be decoded, and the coefficient block corresponding to the unit to be decoded includes multiple coefficient values in each group; wherein, if the encoding method includes a fixed-length code method, the decoding module decodes according to the encoding method of each group to obtain the coefficient block corresponding to the unit to be decoded, and is specifically used to: decode according to the group parameter of each group according to the fixed-length code to obtain multiple coefficient values in each group; A reconstruction module is used to restore the coefficients in each group of coefficient blocks one by one according to the scanning method of the unit to be decoded to obtain a reconstructed data block corresponding to the unit to be decoded.
4. A coding and decoding system, characterized in that: The encoding and decoding system includes the video image decoding device as claimed in claim 3.
5. A video encoding and decoding device, characterized in that: The apparatus includes a processor coupled to a memory; Memory, used to store computer programs or instructions; A processor, configured to execute the computer program or instructions stored in the memory, so that the device performs the method according to any one of claims 1 to 2.
6. An electronic device, characterized in that: The electronic device is used to execute the method according to any one of claims 1 to 2.
7. A readable storage medium, comprising a program or an instruction, wherein when the program or the instruction is executed by a processor, the method according to any one of claims 1 to 2 is executed.
Citation Information
Patent Citations
Method, apparatus and system for encoding and decoding subset of transform units of encoded video data
CN104221288A
Rice parameter update for coefficient level coding in video coding process
CN105191307A
