Image decoding, image encoding method, apparatus and device thereof
Patent Information
- Application Number
- CN202510543863.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2026-10-27
AI Technical Summary
[0004]但是,在对残差值进行编码时,编码算法复杂度较高,编码算法的需求资源也较大,在对残差值进行解码时,解码算法复杂度较高,解码法的需求资源也较大
[0016]由以上技术方案可见,本申请实施例中,在对系数值进行编码时,编码算法复杂度较低,编码算法的需求资源较小,在对系数值进行解码时,解码算法复杂度较低,解码法的需求资源较小。能够提出低复杂度且高效的数据编码方法和数据解码方法,针对多种数据实现高性能数据压缩,能够提高编码性能和解码性能,能够降低编码和解码算法的复杂度。
Smart Images

Figure CN122994500A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of encoding and decoding technology, and in particular to an image decoding, image encoding method, apparatus and device. Background Technology
[0002] To save space, video images are encoded before transmission. Complete video encoding includes processes such as prediction, transform, quantization, entropy coding, and filtering. The prediction process can be divided into intra-frame prediction and inter-frame prediction. Inter-frame prediction utilizes temporal correlation to predict the current pixel using pixels from neighboring encoded images, effectively removing temporal redundancy. Intra-frame prediction utilizes spatial correlation to predict the current pixel using pixels from the encoded blocks of the current frame, removing spatial redundancy.
[0003] Lossless compression refers to the technique of compressing redundant information in the original image to reconstruct the original image without causing any distortion. If there are errors between the reconstructed image and the original image, but these errors are limited to a certain range, it can be called near-lossless compression. During the compression coding process, it is necessary to predict the residual values between pixels in the original image; these residual values indicate the differences between pixels. By encoding the residual values, the coding length can be further reduced.
[0004] However, encoding residual values involves high complexity and resource requirements, and decoding residual values involves high complexity and resource requirements. Summary of the Invention
[0005] In view of this, this application provides an image decoding and image encoding method, apparatus and device, which can improve encoding performance and decoding performance, reduce the complexity of encoding algorithm and reduce the complexity of decoding algorithm.
[0006] This application provides an image decoding method, the method comprising: for each coefficient unit to be decoded, decoding a first coefficient block and a second coefficient block of the coefficient unit to be decoded; concatenating the first coefficient block and the second coefficient block into a target coefficient block of the coefficient unit to be decoded; wherein the first coefficient block includes first-type coefficients located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients located later in the target coefficient block; wherein the first-type coefficients are parsed from a first coefficient set of a maximum coding unit, and the second-type coefficients are parsed from a second coefficient set of the maximum coding unit; the maximum coding unit includes N coefficient units to be decoded, where N is greater than 1, and the coefficient unit to be decoded is any one of the N coefficient units to be decoded.
[0007] This application provides an image coding method, the method comprising: for each coefficient unit to be encoded, determining a target coefficient block for the coefficient unit to be encoded based on the original value of the coefficient unit to be encoded, and determining a first coefficient block and a second coefficient block for the coefficient unit to be encoded based on the target coefficient block; wherein, the first coefficient block includes first-type coefficients located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients located later in the target coefficient block; encoding a first coefficient set and a second coefficient set of the largest coding unit; wherein, the largest coding unit includes N coefficient units to be encoded, N being greater than 1, and the coefficient unit to be encoded is any one of the N coefficient units to be encoded; wherein, the first coefficient set includes first-type coefficients within the first coefficient block of the N coefficient units to be encoded, and the second coefficient set includes second-type coefficients within the second coefficient block of the N coefficient units to be encoded.
[0008] This application provides an image decoding apparatus, comprising: a decoding module for decoding a first coefficient block and a second coefficient block for each coefficient unit to be decoded; and a processing module for concatenating the first coefficient block and the second coefficient block into a target coefficient block for the coefficient unit to be decoded; wherein the first coefficient block includes first-type coefficients located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients located later in the target coefficient block; wherein the first-type coefficients are parsed from a first coefficient set of a maximum coding unit, and the second-type coefficients are parsed from a second coefficient set of the maximum coding unit; the maximum coding unit includes N coefficient units to be decoded, where N is greater than 1, and the coefficient unit to be decoded is any one of the N coefficient units to be decoded.
[0009] This application provides an image encoding apparatus, the apparatus comprising: a determining module, configured to, for each coefficient unit to be encoded, determine a target coefficient block for the coefficient unit to be encoded based on the original value of the coefficient unit to be encoded, and determine a first coefficient block and a second coefficient block for the coefficient unit to be encoded based on the target coefficient block; wherein the first coefficient block includes first-type coefficients located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients located later in the target coefficient block; and an encoding module, configured to encode a first coefficient set and a second coefficient set of the largest encoding unit; wherein the largest encoding unit includes N coefficient units to be encoded, N being greater than 1, and the coefficient unit to be encoded is any one of the N coefficient units to be encoded; wherein the first coefficient set includes first-type coefficients within the first coefficient block of the N coefficient units to be encoded, and the second coefficient set includes second-type coefficients within the second coefficient block of the N coefficient units to be encoded.
[0010] This application provides an image decoding device, the image decoding device comprising: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor;
[0011] The processor is used to execute machine-executable instructions to implement the image decoding method described above.
[0012] This application provides an image encoding device, the image encoding device comprising: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor;
[0013] The processor is used to execute machine-executable instructions to implement the image encoding method described above.
[0014] This application provides a machine-readable storage medium storing a plurality of computer instructions, which, when executed by a processor, implement the above-described image decoding method or image encoding method.
[0015] This application provides a computer program product, which includes a computer program; wherein, when the computer program is executed by a processor, it implements the above-described image decoding method or image encoding method.
[0016] As can be seen from the above technical solutions, in the embodiments of this application, the encoding algorithm has low complexity and requires fewer resources when encoding coefficient values, and the decoding algorithm has low complexity and requires fewer resources when decoding coefficient values. It is possible to propose low-complexity and efficient data encoding and decoding methods, achieve high-performance data compression for various types of data, improve encoding and decoding performance, and reduce the complexity of encoding and decoding algorithms. Attached Figure Description
[0017] Figure 1A This is a schematic diagram of a video coding framework in one embodiment of this application;
[0018] Figure 1B and Figure 1C This is a schematic diagram of the maximum coding unit division in one embodiment of this application;
[0019] Figures 2A-2C This is a schematic diagram of the video encoding framework and the video decoding framework;
[0020] Figure 3A This is a schematic diagram of the scanning area in one embodiment of this application;
[0021] Figure 3B This is a schematic diagram of the scanning sequence in one embodiment of this application;
[0022] Figure 4A This is a flowchart of an image decoding method according to one embodiment of this application;
[0023] Figure 4B This is a flowchart of an image encoding method according to one embodiment of this application;
[0024] Figure 5A This is a schematic diagram of the grating scanning sequence in one embodiment of this application;
[0025] Figure 5B This is a schematic diagram of the z-scan scanning sequence in one embodiment of this application;
[0026] Figure 5C This is a schematic diagram of the Zig-Zag scanning sequence in one embodiment of this application;
[0027] Figure 5D This is a schematic diagram of a scanning and stitching method for AC coefficients according to one embodiment of this application;
[0028] Figure 5E This is a schematic diagram of a scanning and stitching method for AC coefficients according to one embodiment of this application;
[0029] Figure 5F This is a schematic diagram of a non-stitching scanning method for AC coefficients according to one embodiment of this application;
[0030] Figure 6A This is a schematic diagram of the GroupType corresponding to the processing unit group in one embodiment of this application;
[0031] Figure 6B This is a schematic diagram illustrating four cases of gt0 for all coefficients to be encoded in one embodiment of this application;
[0032] Figure 6C This is a schematic diagram of one embodiment of the present application, in which the coefficients to be encoded are unequally divided into two parts;
[0033] Figure 7A This is a hardware structure diagram of the decoding end device in one embodiment of this application;
[0034] Figure 7B This is a hardware structure diagram of the encoding end device in one embodiment of this application. Detailed Implementation
[0035] This application provides an image decoding and image encoding method, apparatus, and device, which may involve the following concepts:
[0036] Near-lossless compression: Near-lossless compression is a compression technique that lies between lossless and lossy compression. The goal of near-lossless compression is to achieve high image compression quality at a certain compression ratio.
[0037] Quantization and Dequantization: Quantization is the process of mapping continuous (or numerous discrete) values of a signal to a finite number of discrete amplitudes, achieving a many-to-one mapping of signal values. In video image encoding, the transform coefficients of the residual signal often have a large dynamic range after transformation. Therefore, quantizing the transform coefficients can effectively reduce the signal value space and achieve better compression. Due to the many-to-one mapping mechanism, the quantization process inevitably introduces distortion, which is the root cause of distortion in video image encoding. Dequantization is the reverse process of quantization, mapping the quantized coefficients to a reconstructed signal in the input signal space. The reconstructed signal is an approximation of the input signal.
[0038] Residual value: In the video encoding process, spatial and temporal redundancy can be removed through the prediction process. The encoding end can obtain the predicted value through the prediction process. The residual value can be obtained by subtracting the predicted value from the original pixel value.
[0039] Transform coefficients: Transform coding transforms an image from a time-domain signal to a frequency-domain signal. Since most of the energy in an image is concentrated in the low-frequency region, and the human eye is more sensitive to low frequencies, quantizing high-frequency coefficients to zero can reduce the dynamic range of the image coding based on the transform. Removing transform coefficients in the high-frequency region can reduce the bit rate overhead without causing significant distortion. Specifically, the residual values are grouped into residual blocks, and the coefficients of the residual blocks after transformation and quantization are called transform coefficients.
[0040] Binarization: Binarization, also known as binaryization, is the process of converting symbols or coefficients that need to be encoded into binary strings. Different binarization methods may result in different binary probability models and different string lengths for the same coefficients.
[0041] Context: Different syntactic elements are not completely independent, and even identical syntactic elements possess a certain degree of memory. Based on this, and according to the theory of conditional entropy, using already encoded syntactic elements to conditionally encode the current encoding element can improve encoding performance compared to independent encoding or memoryless encoding. This information of encoded symbols used as conditions is called the context.
[0042] Context Model: In video coding, the process of updating symbol probabilities based on context can be called a context model. For example, depending on the specific application conditions, the same syntax element can use multiple context models, that is, the symbol probabilities are adaptively updated under the current conditions through multiple context models, thereby further compressing the bitrate.
[0043] Entropy coding: Entropy coding is a lossless coding method based on the principle of information entropy. It is the last processing module in video compression. Entropy coding transforms a series of symbolic elements 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 compression of the original video. Entropy coding can effectively remove statistical redundancy from these video symbolic elements and is one of the important tools for ensuring video encoding and compression efficiency.
[0044] Rate-Distortion Optimized (RDBEM) principle: Two main metrics for evaluating coding efficiency are bitrate and PSNR (Peak Signal-to-Noise Ratio). A smaller bitrate results in a higher compression ratio, and a higher PSNR leads to better reconstructed image quality. In mode selection, the decision formula essentially evaluates both factors. For example, the cost of a mode is: J(mode) = D + λ*R, where D represents Distortion, typically measured using the SSE metric (Sum of Mean Squares of Differences between the Reconstructed Image Patch and the Source Image). Alternatively, the SAD metric (Sum of Absolute Differences between the Reconstructed Image Patch and the Source Image) can be used to consider the cost. λ is a Lagrange multiplier, and R is the actual number of bits required to encode the image patch in that mode, including the total number of bits needed for encoding mode information, motion information, residuals, etc. Using the RDBEM principle to compare and decide on coding modes during mode selection usually ensures optimal coding performance.
[0045] Video coding framework: see Figure 1A The diagram shown is a schematic of the video encoding framework at the encoding end. This video encoding framework can be used to implement the encoding end processing flow of the embodiments of this application. The schematic diagram of the video decoding framework is similar to... Figure 1A Similarly, without repeating the details here, the decoding end processing flow of the embodiments of this application can be implemented using a video decoding framework.
[0046] For example, see Figure 1AAs shown, a video coding framework can include modules such as prediction, transform, quantization, entropy encoder, inverse quantization, inverse transform, reconstruction, and filtering. At the encoding end, the cooperation between these modules enables the processing flow. Similarly, a video decoding framework can include modules such as prediction, transform, quantization, entropy decoder, inverse quantization, inverse transform, reconstruction, and filtering. At the decoding end, the cooperation between these modules enables the processing flow.
[0047] exist Figure 1A In this model, the intra-frame prediction unit and motion estimation / motion compensation representation prediction module are represented by three filters: DBF, SAO, and ALF. For example, DBF (Deblocking Filter) removes block boundary artifacts caused by block coding. SAO (Sample Adaptive Offset) classifies pixels based on their pixel values and the gradient values of surrounding blocks, adding different compensation values to each category to make the reconstructed image closer to the original image. ALF (Adaptive Loop Filter) uses a Wiener filter to enhance the reconstructed image, making it even closer to the original image.
[0048] When encoding images based on a video coding framework, for a single frame of an image, the image needs to be divided into multiple equal-sized maximum coding units, and then each maximum coding unit is further divided before encoding the divided units.
[0049] For example, see Figure 1B The diagram shows a schematic of the maximum coding unit (MCU) partitioning. When using intra-prediction mode (intra represents intra-prediction mode), the size of the MCU can be 16*16. It can be divided into four 8*8 coding units or sixteen 4*4 coding units.
[0050] When using inter-frame prediction mode (inter represents inter-frame prediction mode), the size of the maximum coding unit can be 16*16. The maximum coding unit can be divided into two 16*8 coding units, two 8*16 coding units, or four 8*8 coding units.
[0051] For example, see Figure 1C The diagram illustrates the partitioning of the maximum coding unit (MCU). The MCU can be divided into 16 coding units of varying sizes. For details on the partitioning method, please refer to [link to relevant documentation]. Figure 1C As shown, Figure 1CThe left side shows the position and size of the 16 coding units. Figure 1C The right side represents a quadtree representation of 16 coding units.
[0052] Dividing an image into multiple equally sized maximum coding units (MCUs), and then further subdividing each MCU, followed by encoding the resulting units, results in high complexity and resource requirements for both the encoding and decoding algorithms. Therefore, this algorithm is unsuitable for cost- and latency-sensitive devices.
[0053] For example, numerous encoding tools are proposed for various modules at the encoding end, and each tool often has multiple modes. The encoding tool that achieves optimal encoding performance often differs for different video sequences. Therefore, during the encoding process, Restricted Directives (RDOs) are typically used to compare the encoding performance of different tools or modes to select the best mode. After determining the optimal tool or mode, the decision information for the tool or mode is transmitted by encoding marker information in the bitstream. Although this method introduces higher encoding complexity, it can adaptively select the optimal combination of modes for different content to achieve optimal encoding performance. The decoding end can obtain relevant mode information by directly parsing the marker information, with minimal impact on complexity.
[0054] For example, regarding modules such as prediction, transform, quantization, entropy coding, and filtering, the prediction module includes intra-frame prediction and inter-frame prediction. Intra-frame prediction uses reconstructed pixels around the current block for prediction, removing spatial redundancy. Inter-frame prediction uses reconstructed pixels on a temporal reference frame for prediction, removing temporal redundancy. The transform module linearly maps the spatial residual information to the transform domain (e.g., the frequency domain), making the energy more concentrated and removing frequency domain correlations. The quantization module is a "many-to-one" mapping process, which introduces signal loss but significantly reduces the signal's value range, allowing the encoder to provide a good approximation of the original signal with a small number of symbols, thereby improving the compression ratio. The entropy coding module is a lossless coding method based on the principle of information entropy, transforming a series of element symbols used to represent the video sequence (such as transform coefficients and mode information) into a binary bitstream, removing statistical redundancy of these video element symbols. The filtering module enhances the reconstructed image, aiming to make the reconstructed image closer to the original image while reducing the effects of block artifacts and ringing artifacts, thus improving the quality of the reconstructed image.
[0055] The following is a brief introduction to the structure of the encoding end (i.e., image encoding device) and the decoding end (i.e., image decoding device).
[0056] See Figure 2AThe diagram illustrates a schematic block diagram of an example for implementing an encoder (also known as an encoder). The encoder includes a prediction processing unit, a residual calculation unit, a transform processing unit, a quantization unit, an encoding unit, an inverse quantization unit (also known as an inverse quantization unit), an inverse transform processing unit (also known as an inverse transform processing unit), a reconstruction unit, and a filter unit. For example, the encoder may also include a buffer and a decoded image buffer. The buffer is used to buffer the reconstructed image blocks output by the reconstruction unit, and the decoded image buffer is used to buffer the filtered image blocks output by the filter unit.
[0057] The input to the encoding end is an image block (which can be called the image to be encoded), also known as the current block or the block to be encoded. The encoding end may also include a segmentation unit (not shown in the figure), which is used to segment the image to be encoded into multiple image blocks. The encoding end is used to encode the image block by block to complete the encoding of the image to be encoded, for example, to perform the encoding process for each image block. The prediction processing unit is used to receive or acquire the image block (the current image block to be encoded of the current image to be encoded, which can also be called the current block, and this image block can be understood as the true value of the image block) and the reconstructed image data, and to predict the current block based on the relevant data in the reconstructed image data to obtain the predicted block of the current block.
[0058] The prediction processing unit may include an inter-frame prediction unit, an intra-frame prediction unit, and a mode selection unit. The mode selection unit is used to select either an intra-frame prediction mode or an inter-frame prediction mode. If the intra-frame prediction mode is selected, the intra-frame prediction unit performs the prediction process. If the inter-frame prediction mode is selected, the inter-frame prediction unit performs the prediction process.
[0059] The residual calculation unit is used to calculate the residual between the true value of an image patch and the predicted patch of the image patch to obtain the residual patch. For example, the residual calculation unit can subtract the pixel value of the predicted patch from the pixel value of the image patch pixel by pixel.
[0060] The transform processing unit is used to transform the residual block, such as by discrete cosine transform (DCT) or discrete sine transform (DST), to obtain transform coefficients in the transform domain. The transform coefficients can also be called transform residual coefficients, which can represent the residual block in the transform domain.
[0061] Quantization units are used to quantize transform coefficients by applying scalar or vector quantization to obtain quantized transform coefficients, also known as quantized residual coefficients. The quantization process can reduce the bit depth associated with some or all of the transform coefficients. For example, n-bit transform coefficients can be rounded down to m-bit transform coefficients during quantization, where n is greater than m. The degree of quantization can be modified by adjusting the quantization parameter (QP). For example, for scalar quantization, different scales can be applied to achieve finer or coarser quantization. Smaller quantization steps correspond to finer quantization, while larger quantization steps correspond to coarser quantization. The appropriate quantization step size can be indicated by the quantization parameter (QP).
[0062] The encoding unit encodes the quantized residual coefficients to output encoded image data (i.e., the encoding result of the current image block to be encoded) in the form of an encoded bitstream. This encoded bitstream is then transmitted to the decoder, or stored for later transmission to the decoder or for retrieval. The encoding unit can also encode other syntax elements of the current image block, such as encoding the prediction mode into the bitstream. Encoding algorithms include, but are not limited to, variable length coding (VLC), context adaptive VLC (CAVLC), arithmetic coding, context adaptive binary arithmetic coding (CABAC), syntax-based context-adaptive binary arithmetic coding (SBAC), and probability interval partitioning entropy (PIPE).
[0063] The dequantization unit is used to dequantize the aforementioned quantized coefficients to obtain dequantized coefficients. This dequantization can be the reverse application of the aforementioned quantization unit, for example, based on or using the same quantization step size as the quantization unit, employing the inverse quantization scheme of the quantization scheme applied by the quantization unit. The dequantized coefficients can also be called dequantized residual coefficients.
[0064] The inverse transform processing unit is used to perform an inverse transform on the aforementioned inverse quantization coefficients. This inverse transform can be the reverse application of the aforementioned transform processing unit. For example, the inverse transform can include the inverse discrete cosine transform (DCT) or the inverse discrete sine transform (DST) to obtain an inverse transform block in the pixel domain (or sample domain). The inverse transform block can also be called an inverse transform dequantized block or an inverse transform residual block.
[0065] The reconstruction unit adds the inverse transform block (i.e., the inverse transform residual block) to the prediction block to obtain the reconstructed block in the sample domain. The reconstruction unit can be a summer, for example, adding the sample values (i.e., pixel values) of the residual block to the sample values of the prediction block. The reconstructed block output by this reconstruction unit can be subsequently used to predict other image blocks, for example, in intra-frame prediction mode.
[0066] A filter unit (or simply "filter") is used to filter the reconstructed block to obtain a filtered block, thereby facilitating pixel transformation or improving image quality. The filter unit can be a loop filter unit, intended to represent one or more loop filters. For example, the filter unit can be a deblocking filter, a sample-adaptive offset (SAO) filter, or other filters such as a bilateral filter, an adaptive loop filter (ALF), a sharpening or smoothing filter, or a collaborative filter. Exemplarily, the filtered block output by this filter unit can be subsequently used to predict other image blocks, for example, in inter-frame prediction mode, without limitation.
[0067] See Figure 2B The diagram illustrates a schematic block diagram of an example of a decoding end (also called a decoder). The decoding end receives encoded image data (i.e., encoded bitstream, such as an encoded bitstream including image blocks and associated syntax elements) to obtain a decoded image. The decoding end may include a decoding unit, an inverse quantization unit, an inverse transform processing unit, a prediction processing unit, a reconstruction unit, a filter unit, etc. The decoding end can perform operations related to... Figure 2A The decoding process is the inverse of the encoding process described at the encoding end. For example, the decoding end may also include a buffer and a decoded image buffer. The buffer is used to buffer the reconstructed image blocks output by the reconstruction unit, and the decoded image buffer is used to buffer the filtered image blocks output by the filter unit.
[0068] The decoding unit is used to decode the encoded image data to obtain quantized coefficients and / or decoded encoded parameters (e.g., 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 decoding unit is also used to forward the decoded encoded parameters to the prediction processing unit, so that the prediction processing unit can perform a prediction process based on the encoded parameters. The dequantization unit may function the same as the dequantization unit at the encoding end, used to dequantize (i.e., inversely quantize) the quantized coefficients decoded by the decoding unit.
[0069] The function of the inverse transform processing unit can be the same as that of the inverse transform processing unit at the encoding end. The function of the reconstruction unit (e.g., a summer) can be the same as that of the reconstruction unit at the encoding end. It is used to perform an inverse transform on the quantized coefficients (e.g., inverse DCT, inverse integer transform, or a conceptually similar inverse transform process) to obtain an inverse transform block (the inverse transform block can also be called an inverse transform residual block). This inverse transform block is the residual block of the current image block in the pixel domain.
[0070] The prediction processing unit is used to receive or acquire encoded image data and reconstructed image data. The prediction processing unit can also acquire prediction-related parameters and / or prediction mode information (i.e., decoded encoding parameters), 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.
[0071] For example, the prediction processing unit may 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 intra-frame prediction unit performs the prediction process. If the inter-frame prediction mode is selected, the inter-frame prediction unit performs the prediction process.
[0072] The reconstruction unit is used to add the inverse transform block (i.e., the inverse transform residual block) to the prediction block to obtain the reconstructed block in the sample domain. For example, the sample values of the inverse transform residual block can be added to the sample values of the prediction block.
[0073] The filter unit is used to filter the reconstructed block to obtain the filtered block, which is the decoded image block.
[0074] It should be understood that the processing results of the encoding and decoding ends in this embodiment can also be further processed before being output to the next stage. For example, after interpolation filtering, motion vector derivation or filtering, the processing results of the corresponding stage can be further clipped or shifted before being output to the next stage.
[0075] Based on the encoding and decoding ends, embodiments of this application provide a possible encoding and decoding implementation method, see [link to relevant documentation]. Figure 2C The diagram shows the encoding and decoding process. The encoding and decoding implementation includes processes ① to ⑤. Processes ① to ⑤ can be executed by the encoding end or the decoding end.
[0076] Process ①: Divide a frame of image into one or more non-overlapping parallel coding units. There is no dependency between the one or more parallel coding units, and they can be encoded and decoded in complete parallel / independent manner, such as parallel coding unit 1 and parallel coding unit 2.
[0077] Process ②: For each parallel coding unit, it is further divided into one or more independent coding units that do not overlap. These independent coding units are independent of each other, but can share some parallel coding unit header information. 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 that of the parallel coding unit; otherwise, the width of the independent coding unit should be greater than its height (unless it is an edge region).
[0078] Typically, an independent coding unit can be a fixed w_lcu×h_lcu, where w_lcu and h_lcu are both powers of 2 (N≥0). For example, the size of an independent coding unit can be 128×4, 64×4, 32×4, 16×4, 8×4, 32×2, 16×2, or 8×2, etc.
[0079] For example, an independent coding unit can be a fixed 128×4. If the size of the parallel coding unit is 256×8, it can be divided into 4 independent coding units. If the size of the parallel coding unit is 288×10, it can be divided into: the first / second row consists of two 128×4 units and one 32×4 unit; the third row consists of two 128×2 units and one 32×2 unit. An independent coding unit can include three components: luminance (Y), chrominance (Cb), and chrominance (Cr); or three components: red (R), green (G), and blue (B); or three components: luminance (Y), chrominance (Co), and chrominance (Cg). An independent coding unit can also contain only one of these components. If an independent coding unit contains three components, the dimensions of these three components can be exactly the same or different, depending on the input format of the image.
[0080] Process ③: Each independent coding unit can be further divided into one or more non-overlapping coding units. Each coding unit within an independent coding unit can depend on the others, such as multiple coding units can refer to each other for pre-coding and decoding.
[0081] If the coding unit has the same size as the independent coding unit (i.e., the independent coding unit is divided into only one coding unit), then its size can be any of the sizes described in process ②. If the independent coding unit is divided into multiple non-overlapping coding units, then feasible examples of division 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., with horizontal equal division being preferred.
[0082] The width of a coding unit is w_cu, and the height is h_cu, with the width generally greater than the height (unless it's an edge region). Typically, a coding unit is a fixed w_cu x h_cu, where both w_cu and h_cu are powers of 2 (N ≥ 0), such as 16x4, 8x4, 16x2, 8x2, 8x1, 4x1, etc. For example, if the coding unit is fixed at 16x4, and the size of an independent coding unit is 64x4, then the independent coding unit is divided into 4 equal coding units; if the size of an independent coding unit is 72x4, then the coding unit is divided into: 4 x 16x4 units + 1 x 8x4 unit. For instance, a coding unit can include three components: luminance (Y), chrominance (Cb), and chrominance (Cr) (or red (R), green (G), and blue (B), or luminance (Y), chrominance (Co), and chrominance (Cg), or it can include only one of these components. If it includes three components, the dimensions of the components can be exactly the same or different, depending on the image input format.
[0083] It is worth noting that process ③ can be an optional step in the encoding and decoding methods. The encoding end / decoding end can encode and decode the independent encoding units obtained in process ② by performing residual coefficients (or residual values).
[0084] Process 4: For a coding unit, it can be further divided into one or more non-overlapping prediction groups (PGs). Each PG is encoded and decoded according to the selected prediction mode to obtain the prediction value of the PG, which forms the prediction value of the entire coding unit. Based on the prediction value and the original value of the coding unit, the residual value of the coding unit is obtained.
[0085] Step 5: 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, this can be divided into two categories: those that transform the residual coefficients and those that do not.
[0086] In process ⑤, the selected mode for the residual coefficient encoding and decoding method can include, but is not limited to, any of the following: semi-fixed-length encoding, exponential Golomb encoding, Golomb-Rice encoding, truncated unary code encoding, run-length encoding, direct encoding of the original residual value, etc. For example, the encoder can directly encode the coefficients within the RB. Another example is that the encoder can transform the residual block, such as using DCT, DST, or Hadamard transform, and then encode the transformed coefficients. As a possible example, when the RB is small, the encoder can directly perform uniform quantization on each coefficient within the RB, and then perform binarization encoding. If the RB is large, it can be further divided into multiple coefficient groups (CGs), and then each CG can be uniformly quantized and then binarized. In some embodiments of this application, the coefficient group (CG) and the quantization group (QG) can be the same; of course, the coefficient group and the quantization group can also be different.
[0087] In one possible implementation, lossless compression means that the compressed and reconstructed image is identical to the original image without any loss. If there is a difference between the reconstructed image and the original image, but the error is limited to a certain range, it can be called near-lossless compression. Although near-lossless compression involves some loss, its visual impact is minimal, and it can also be considered lossless compression. Encoding and decoding schemes for lossless and near-lossless compression include prediction and coefficient coding. Due to the similarity between pixels, prediction can remove redundancy in pixel similarity. Subtracting the predicted value from the original pixel value yields a residual value, which needs to be encoded. During encoding, the residual value needs to be converted into a binary bitstream, and a certain encoding technique is used to minimize the length of the binary bitstream.
[0088] To achieve lossless or near-lossless compression, ProRes coefficient coding, SRCC (Systematic Recursive Convolutional Code) coding, CABAC (Context-Adaptive Binary Arithmetic Coding) coding, semi-fixed-length coding, and CAVLC (Context-Adaptive Variable-Length Coding) coding can be used.
[0089] In the ProRes coefficient encoding scheme, for coefficients on the Y / U / V components that have undergone DCT transformation, AC coefficients use run-length encoding, while DC coefficients use variable-length encoding, which is a hybrid encoding of exponential Golomb and Golomb-Rice encoding. For smaller non-negative integer values, Golomb-Rice encoding is used; for larger non-negative integer values, exponential Golomb encoding is used.
[0090] This hybrid encoding method requires three parameters: Rice parameter Krice, exponent KExp, and switching parameter lastRiceQ, used to switch between the two encoding schemes. lastRiceQ refers to the maximum quantization step size Q when using Rice encoding. Otherwise, exponential Golomb encoding is used. When the value of the encoding coefficient n is less than (lastRiceQ+1)*2kRice, Golomb-Rice encoding is used; otherwise, exponential Golomb encoding is used. In this case, lastRiceQ+1 zeros are encoded, and exponential Golomb encoding n-(lastRiceQ+1)*2kRice is used. For all non-negative integers k, in Golomb hybrid encoding, lastRiceQ=0, Krice=k, and Kexp=k+1.
[0091] Therefore, when decoding the coefficients, we can first decode how many zeros precede the 1 in the parameter lastRiceQ to obtain the quantization step size q. If the quantization step size q is less than lastRiceQ, we can decode the parameter Krice and the suffix. Otherwise, we can decode the parameter Kexp and the suffix. Then, we add (lastRiceQ+1)*2kRice to obtain the decoded coefficients.
[0092] In SRCC encoding, (SRx, SRy) is used to determine the quantization coefficient region to be scanned in the TU. SRx is the x-coordinate of the rightmost non-zero coefficient in the coefficient matrix, and SRy is the y-coordinate of the bottommost non-zero coefficient in the coefficient matrix. See [link to relevant documentation]. Figure 3A The diagram shows a schematic of the scanning area. Only the coefficients within the scanning area defined by (SRx, SRy) need to be encoded. The scanning sequence is a reverse zigzag scan from the bottom right corner to the top left corner. See [link to documentation]. Figure 3B The image shows a schematic diagram of the scanning sequence.
[0093] The coefficient encoding employs a hierarchical representation method, which includes a significant flag, GT1 flag, GT2 flag, remaining level, and sign. The significant flag indicates whether the current coefficient is non-zero, and the sign indicates the positive or negative sign of the current non-zero coefficient. GT1 flag indicates whether the magnitude of the current non-zero coefficient is greater than 1, GT2 flag indicates whether the magnitude of the current non-zero coefficient is greater than 2, and the remaining level indicates the remaining portion of the current non-zero coefficient whose magnitude is greater than 2.
[0094] For the context model of significant flag, GT1 flag, and GT2 flag, it is determined based on the number of relevant flags of the partially encoded or decoded coefficients in the scan order, and according to the relative position of the coefficients in the scan region, TU size, and channel grouping. Furthermore, exponential Golomb coding can be used when encoding the remaining level. Specific settings are as follows:
[0095] For significant flags: a) Luminance (luma): ctxIdxInc = log2_block_size <= 2 ? 0 : NUM_CTX_GT0_LUMA_TU << (COM_MIN(1, (log2_block_size - 3))), grouped according to TU size. ctxIdxInc+ = (pos_x == 0 && pos_y == 0) ? 0 : ((pos_x <= sr_x / 2 && pos_y <= sr_y / 2) ? 4 : 8), grouped according to the relative position of coefficients in the scan area. ctxIdxInc+ = num_gt0, where num_gt0 is the number of non-zero coefficients of the 5 coefficients encoded or decoded according to the scan order, with a maximum of 3. b) Chroma (chroma): ctxIdxInc = (pos_x == 0 && pos_y == 0) ? 0 : 4, grouped according to the relative position of coefficients in the scan area. ctxIdxInc+=num_gt0, where num_gt0 is the number of non-zero coefficients among the 5 coefficients, with a maximum of 3.
[0096] For GT1flag and GT2flag: a) Luminance (luma): ctxIdxInc+=(pos_x==0&&pos_y==0)? 0:((pos_x<=sr_x / 2&&pos_y<=r_y / 2)?4:8), grouping coefficients according to their relative positions in the scan area. ctxIdxInc+=num_gt12, where num_gt12 is the number of 5 non-zero coefficients encoded or decoded according to the scan order whose absolute values are greater than 1 or 2, with a maximum of 3. b) Chroma (chroma): ctxIdxInc+=num_gt12, where num_gt12 is the number of 5 non-zero coefficients encoded or decoded according to the scan order whose absolute values are greater than 1 or 2, with a maximum of 3.
[0097] The coefficients in the lower right corner of the scan area for the significant flags, GT1flag, and GT2flag each use a separate ctxIdx.
[0098] The number of SRCC coefficient encoding context models can be found in Table 1.
[0099] Table 1
[0100] Scan region x Scan region y Significant flag Gt1 gt2 luma 25 25 39 13 chroma 3 3 9 5 total 28 28 48 18
[0101] In CABAC encoding, an adaptive binary arithmetic coding method combined with a context model, non-binary signals can be converted into binary signals. It effectively utilizes higher-order information between syntax element values, further improving coding efficiency. In CABAC-based encoding, the encoding of each symbol is related to the results of previous encodings, allowing for adaptive codeword allocation based on the statistical characteristics of the symbol stream. CABAC encoding is particularly suitable for symbols with non-equilibrium occurrence probabilities, further reducing the code rate.
[0102] In the semi-fixed-length coding method, the coefficients to be coded are grouped according to the prediction direction and the residual size. Based on the coding grouping mode, each group is encoded with a code length, and the coefficients within the same group are encoded with the same fixed length.
[0103] In CAVLC encoding, CAVLC is an entropy coding method that improves coding efficiency by utilizing the statistical correlation between elements within a block. The encoding steps are as follows: Coefficient scanning: The two-dimensional DCT coefficients are converted into a one-dimensional sequence using a Zig-Zag scan or another scanning mode (such as an inverse Zig-Zag scan). The scan order is usually based on the block type and position. Coefficient classification: The scanned coefficients are classified into non-zero coefficients and zero coefficients. The absolute value and sign of the non-zero coefficients are encoded separately. Run-Length encoding: Consecutive zero coefficients (called "runs") are counted until the first non-zero coefficient is encountered. The number of zero coefficients preceding each non-zero coefficient (runs) and the absolute value of that non-zero coefficient (level) are encoded together. Context modeling: Based on the current block position, the encoding information of neighboring blocks, and the frequency position of the current coefficient, an appropriate context model is selected. The context model is used to determine the encoding probability distribution of the current coefficient. Variable-length encoding: Based on the selected context model, the run and level are encoded using a predefined VLC (Variable-Length Code) table. VLC tables are designed based on statistical probability, with shorter codewords for high-frequency combinations and longer codewords for low-frequency combinations.
[0104] Among the above encoding methods, SRCC encoding is mainly used in lossy coding, encoding coefficients with many residual values of 0. It is not suitable for lossless or near-lossless coding. CABAC and CAVLC encoding methods need to be used in conjunction with the context, and the calculation process is relatively complex. Semi-fixed-length encoding methods are inefficient.
[0105] In response to the above findings, this application proposes an image decoding method and an image encoding method that are applicable to lossless or near-lossless encoding, and realize coefficient encoding and decoding processes based on lossless or near-lossless encoding.
[0106] The image decoding method and image encoding method in the embodiments of this application will be described below in conjunction with specific application scenarios.
[0107] This application proposes an image decoding method that can be applied to a decoding end (also known as a video decoder). See [link to relevant documentation]. Figure 4A The diagram shown is a flowchart of the image decoding method, which may include:
[0108] Step 411: For each coefficient unit to be decoded, decode the first coefficient block and the second coefficient block of that coefficient unit. The first coefficient block may include first-type coefficients that appear earlier in the target coefficient block, and the second coefficient block may include second-type coefficients that appear later in the target coefficient block. For example, the prediction accuracy of the first-type coefficients in the first coefficient block may be higher than the prediction accuracy of the second-type coefficients in the second coefficient block.
[0109] Step 412: Concatenate the first coefficient block and the second coefficient block to form the target coefficient block of the coefficient unit to be decoded.
[0110] For example, the first type of coefficients are parsed from the first set of coefficients of the largest coding unit, and the second type of coefficients are parsed from the second set of coefficients of the largest coding unit; the largest coding unit may include N coefficient units to be decoded, N may be greater than 1, and the coefficient unit to be decoded may be any one of the N coefficient units to be decoded.
[0111] This application proposes an image encoding method that can be applied to the encoding end (also known as a video encoder). See [link to relevant documentation]. Figure 4B The diagram shown is a flowchart of the image encoding method, which may include:
[0112] Step 421: For each coefficient unit to be encoded, determine the target coefficient block of the coefficient unit based on the original value of the coefficient unit to be encoded, and determine the first coefficient block and the second coefficient block of the coefficient unit to be encoded based on the target coefficient block; wherein, the first coefficient block includes the first type coefficients in the target coefficient block that are located earlier, and the second coefficient block includes the second type coefficients in the target coefficient block that are located later.
[0113] Step 422: Encode the first set of coefficients and the second set of coefficients of the largest coding unit; wherein, the largest coding unit includes N coefficient units to be encoded, where N is greater than 1, and the coefficient unit to be encoded is any one of the N coefficient units to be encoded; wherein, the first set of coefficients includes the first type of coefficients in the first coefficient block of the N coefficient units to be encoded, and the second set of coefficients includes the second type of coefficients in the second coefficient block of the N coefficient units to be encoded.
[0114] For example, the above execution order is merely an example for ease of description. In practical applications, the execution order between steps can be changed, and there is no limitation on this execution order. Moreover, in other embodiments, the steps of the corresponding method are not necessarily executed in the order shown and described in this specification, and the method may include more or fewer steps than described in this specification. Furthermore, a single step described in this specification may be broken down into multiple steps in other embodiments; multiple steps described in this specification may also be combined into a single step in other embodiments.
[0115] As can be seen from the above technical solutions, in the embodiments of this application, the encoding algorithm has low complexity and requires fewer resources when encoding coefficient values, and the decoding algorithm has low complexity and requires fewer resources when decoding coefficient values. It is possible to propose low-complexity and efficient data encoding and decoding methods, achieve high-performance data compression for various types of data, improve encoding and decoding performance, and reduce the complexity of encoding and decoding algorithms.
[0116] In one possible implementation, decoding the first coefficient block of the coefficient unit to be decoded may include, but is not limited to: scanning the first coefficient group set of the largest coding unit based on the unit scanning order to obtain the first coefficient group of the coefficient unit to be decoded; wherein the unit scanning order is used to indicate the arrangement order of the N coefficient units to be decoded; scanning all first type coefficients in the first coefficient group based on the first scanning order corresponding to the coefficient unit to be decoded to obtain the first coefficient block of the coefficient unit to be decoded; wherein the first scanning order is used to indicate the pixel position of each first type coefficient in the first coefficient group in the first coefficient block. For example, after decoding to obtain the first coefficient group set of the largest coding unit, the first coefficient group set is divided into N first coefficient groups corresponding to the N coefficient units to be decoded based on the unit scanning order, thereby obtaining the first coefficient group of each coefficient unit to be decoded, that is, obtaining the first coefficient group of the current coefficient unit to be decoded.
[0117] For example, decoding the second coefficient block of the coefficient unit to be decoded may include, but is not limited to: scanning the second coefficient group set of the largest coding unit based on the unit scanning order to obtain the second coefficient group of the coefficient unit to be decoded; wherein, the unit scanning order is used to indicate the arrangement order of the N coefficient units to be decoded.
[0118] If the second coefficient group includes one second-type coefficient, then the second coefficient block of the coefficient unit to be decoded is obtained based on that second-type coefficient, and the second coefficient block includes one second-type coefficient. Alternatively, if the second coefficient group includes multiple second-type coefficients, then all second-type coefficients in the second coefficient group are scanned based on the second scanning order corresponding to the coefficient unit to be decoded to obtain the second coefficient block of the coefficient unit to be decoded. The second scanning order indicates the pixel position of each second-type coefficient in the second coefficient group within the second coefficient block. For example, after decoding to obtain the second coefficient group set of the largest coding unit, the second coefficient group set is divided into N second coefficient groups corresponding to N coefficient units to be decoded based on the unit scanning order, thus obtaining the second coefficient group for each coefficient unit to be decoded, i.e., obtaining the second coefficient group of the current coefficient unit to be decoded.
[0119] For example, by decoding the bitstream of the largest coding unit, a first set of coefficient groups of the largest coding unit is obtained; by decoding the bitstream of the largest coding unit, a second set of coefficient groups of the largest coding unit is obtained.
[0120] For example, for the first set of coefficients of the largest coding unit, the first set of coefficients may sequentially include all first-class coefficients corresponding to the first coefficient unit to be decoded, all first-class coefficients corresponding to the second coefficient unit to be decoded, ..., and so on, up to all first-class coefficients corresponding to the Nth coefficient unit to be decoded; or, the first set of coefficients may sequentially include the first-class coefficients at the first position of the N coefficient units to be decoded, the first-class coefficients at the second position of the N coefficient units to be decoded, ..., and so on, up to the first-class coefficients at the Mth position of the N coefficient units to be decoded; wherein each coefficient unit to be decoded may include M positions of first-class coefficients, where M is greater than 1; or, the first set of coefficients may include M subsets of the first set of coefficients, where the first subset of the first set of coefficients includes the first-class coefficients at the first position of the N coefficient units to be decoded, the second subset of the first set of coefficients includes the first-class coefficients at the second position of the N coefficient units to be decoded, ..., and so on, up to the Mth subset of the first set of coefficients includes the first-class coefficients at the Mth position of the N coefficient units to be decoded; wherein, the M subsets of the first set of coefficients may be decoded in parallel.
[0121] For example, for the second coefficient set of the largest coding unit, if each coefficient unit to be decoded includes a second type coefficient at one position, then the second coefficient set can sequentially include the second type coefficient at the first position of N coefficient units to be decoded; or, if each coefficient unit to be decoded includes K second type coefficients at K positions, where K is greater than 1, the second coefficient set can sequentially include all second type coefficients corresponding to the first coefficient unit to be decoded, all second type coefficients corresponding to the second coefficient unit to be decoded, ..., all second type coefficients corresponding to the Nth coefficient unit to be decoded; or, the second coefficient set can sequentially include the second type coefficient at the first position of N coefficient units to be decoded, ..., the second type coefficient at the Kth position of N coefficient units to be decoded.
[0122] For example, the first scanning order corresponding to different coefficient units to be decoded is the same, or the first scanning order corresponding to different coefficient units to be decoded is different; wherein, for each coefficient unit to be decoded, the first scanning order corresponding to the coefficient unit to be decoded may include, but is not limited to, any of the following: raster scanning order; z-scan scanning order; Zig-Zag scanning order; block scanning order; horizontal scanning order; vertical scanning order; horizontal round-trip scanning order; vertical round-trip scanning order; diagonal scanning order; anti-diagonal scanning order; inverse horizontal scanning order; inverse vertical scanning order; scanning order based on a fixed scanning template.
[0123] For example, based on the first scanning order corresponding to the coefficient unit to be decoded, before scanning all the first type coefficients in the first coefficient group, the first scanning order corresponding to the coefficient unit to be decoded can also be obtained by decoding the bitstream; wherein, the first scanning order can be a raster scanning order or a z-scan scanning order.
[0124] For example, the first coefficient group may include an AC coefficient group, the first coefficient block may include an AC coefficient block, and the first type of coefficients in the first coefficient group may include transformed AC coefficients, where AC coefficients are high-frequency coefficients within the AC coefficient block; the second coefficient group may include a DC coefficient group, the second coefficient block may include a DC coefficient block, and the second type of coefficients in the second coefficient group may include transformed DC coefficients, where DC coefficients are low-frequency coefficients within the DC coefficient block.
[0125] For example, decoding the first coefficient block and the second coefficient block of the coefficient unit to be decoded may include, but is not limited to: decoding multiple first-type coefficients corresponding to each processing unit within the first coefficient set of the largest coding unit; wherein the first coefficient set may include at least one processing unit, and for each processing unit, the processing unit may include multiple first-type coefficients. Decoding multiple second-type coefficients corresponding to each processing unit within the second coefficient set of the largest coding unit; wherein the second coefficient set may include at least one processing unit, and for each processing unit, the processing unit may include multiple second-type coefficients.
[0126] For example, the coefficients to be decoded are either type I or type II coefficients. The decoding method for multiple coefficients to be decoded corresponding to this processing unit may include: decoding the GroupType corresponding to the processing unit group; the processing unit group includes at least two processing units, and the GroupType is used to indicate whether the processing units within the processing unit group use the same code length value. For the first processing unit within the processing unit group, the target code length value corresponding to that processing unit is decoded; for non-first processing units within the processing unit group, if the GroupType indicates that the processing unit uses the same code length value as the previous processing unit, then the target code length value corresponding to the previous processing unit is determined as the target code length value corresponding to this processing unit; if the GroupType indicates that the processing unit uses a different code length value than the previous processing unit, then the initial code length value corresponding to that processing unit is decoded, and the target code length value corresponding to that processing unit is determined based on the initial code length value. Multiple coefficients to be decoded corresponding to this processing unit are decoded based on the target code length value.
[0127] For example, determining the target code length value corresponding to the processing unit based on the initial code length value may include: if the target code length value corresponding to the processing unit is not less than the target code length value corresponding to the previous processing unit, determining the sum of the initial code length value and the target code length value corresponding to the previous processing unit as the target code length value corresponding to the processing unit; or determining the sum of the initial code length value and a fixed value as the target code length value corresponding to the processing unit; or, if the target code length value corresponding to the processing unit is less than the target code length value corresponding to the previous processing unit, determining the initial code length value as the target code length value corresponding to the processing unit.
[0128] For example, the coefficients to be decoded are either type I coefficients or type II coefficients. The decoding method for the multiple coefficients to be decoded corresponding to the processing unit may include: decoding the first flag bit corresponding to each coefficient to be decoded, the first flag bit being used to indicate whether the coefficient to be decoded is 0; for coefficients to be decoded that are not 0, decoding the second flag bit and sign bit corresponding to the coefficient to be decoded, the second flag bit being used to indicate whether the absolute value of the coefficient to be decoded is 1, and the sign bit being used to indicate whether the coefficient to be decoded is positive or negative; for coefficients to be decoded that are neither 0 nor 1, decoding the coefficient residual absolute value corresponding to the coefficient to be decoded, the coefficient residual absolute value representing the difference between the absolute value of the coefficient to be decoded and 2; and deriving the multiple coefficients to be decoded corresponding to the processing unit based on the first flag bit, the second flag bit, the coefficient residual absolute value, and the sign bit.
[0129] For example, decoding the first flag bit corresponding to each coefficient to be decoded may include, but is not limited to: decoding the GroupType corresponding to the processing unit; if the GroupType is used to indicate that there are no non-zero values in the first half of the coefficients to be decoded in the processing unit and there are no non-zero values in the second half of the coefficients to be decoded in the processing unit, then the first flag bit corresponding to the first half of the coefficients to be decoded is derived based on the GroupType, and the first flag bit corresponding to the second half of the coefficients to be decoded is derived based on the GroupType; or, if the GroupType is used to indicate that there are no non-zero values in the first half of the coefficients to be decoded and there are non-zero values in the second half of the coefficients to be decoded, then the first flag bit corresponding to the first half of the coefficients to be decoded is derived based on the GroupType. The first flag bit corresponding to the coefficient to be decoded is determined, and the first flag bit corresponding to the second half of the coefficient to be decoded is decoded from the bitstream; or, if GroupType is used to indicate that there is a non-zero value in the first half of the coefficients to be decoded and there is no non-zero value in the second half of the coefficients to be decoded, then the first flag bit corresponding to the second half of the coefficients to be decoded is derived based on GroupType, and the first flag bit corresponding to the first half of the coefficients to be decoded is decoded from the bitstream; or, if GroupType is used to indicate that there is a non-zero value in the first half of the coefficients to be decoded and there is a non-zero value in the second half of the coefficients to be decoded, then the first flag bit corresponding to the first half of the coefficients to be decoded is decoded from the bitstream, and the first flag bit corresponding to the second half of the coefficients to be decoded is decoded from the bitstream.
[0130] For example, the coefficients to be decoded are either type I coefficients or type II coefficients. The decoding method for multiple coefficients to be decoded corresponding to the processing unit may include: decoding the maximum absolute value of the coefficients of all coefficients to be decoded corresponding to the processing unit; if the maximum absolute value of the coefficients is 0, then deduce that each coefficient to be decoded corresponding to the processing unit is 0; if the maximum absolute value of the coefficients is 1, then decode the first flag bit corresponding to each coefficient to be decoded, the first flag bit being used to indicate whether the coefficient to be decoded is 0; for coefficients to be decoded that are not 0, decode the sign bit corresponding to the coefficient to be decoded; based on the first flag bit and the sign bit, deduce multiple coefficients to be decoded corresponding to the processing unit; if the maximum absolute value of the coefficients is 2, then decode the first flag bit corresponding to each coefficient to be decoded, the first flag bit being used to indicate whether the coefficient to be decoded is 0; for coefficients to be decoded that are not 0, decode the second flag bit and the sign bit corresponding to the coefficient to be decoded, the second flag bit being used to indicate whether the absolute value of the coefficient to be decoded is 1; based on the first flag bit, the second flag bit, and the sign bit, deduce multiple coefficients to be decoded corresponding to the processing unit.
[0131] For example, the coefficients to be decoded can be either first-type coefficients or second-type coefficients. The decoding method for the multiple coefficients to be decoded corresponding to the processing unit can include: decoding the third flag bit corresponding to each coefficient to be decoded; wherein, for each coefficient to be decoded, if the absolute value of the coefficient to be decoded is greater than n, then the third flag bit corresponding to the coefficient to be decoded can be n+1; if the absolute value of the coefficient to be decoded is not greater than n, then the third flag bit corresponding to the coefficient to be decoded is the absolute value of the coefficient to be decoded, and n can be a positive integer greater than 1; for coefficients to be decoded whose third flag bit is not 0, decoding the sign bit corresponding to the coefficient to be decoded; for coefficients to be decoded whose third flag bit is n+1, decoding the coefficient residual absolute value corresponding to the coefficient to be decoded, the coefficient residual absolute value can represent the difference between the absolute value of the coefficient to be decoded and (n+1); based on the third flag bit, the sign bit and the coefficient residual absolute value, deriving the multiple coefficients to be decoded corresponding to the processing unit.
[0132] For example, the coefficients to be decoded are either type I or type II coefficients. The decoding method for the multiple coefficients to be decoded corresponding to the processing unit may include: decoding the fourth flag bit corresponding to each coefficient to be decoded; wherein, for each coefficient to be decoded, if the absolute value of the coefficient to be decoded is greater than n, then the fourth flag bit corresponding to the coefficient to be decoded is (n+1) or -(n+1); if the absolute value of the coefficient to be decoded is not greater than n, then the fourth flag bit corresponding to the coefficient to be decoded is the coefficient to be decoded, where n is a positive integer greater than 1; for the coefficients to be decoded whose fourth flag bit is (n+1) or -(n+1), decoding the coefficient residual absolute value corresponding to the coefficient to be decoded, where the coefficient residual absolute value represents the difference between the absolute value of the coefficient to be decoded and (n+1); and deriving the multiple coefficients to be decoded corresponding to the processing unit based on the fourth flag bit and the coefficient residual absolute value.
[0133] For example, each coefficient unit to be decoded may include at least one of a luminance component Y, a chrominance component Cb, and a chrominance component Cr; or, the coefficient unit to be decoded may include at least one of a red component R, a green component G, and a blue component B. For instance, the coefficient unit to be decoded may include at least two components, and the dimensions of the different components may be the same or different. The width of the coefficient unit to be decoded is w, and the width w is 2 to the power of N1, where N1 may be greater than or equal to 0; the height of the coefficient unit to be decoded is h, and the height h is 2 to the power of N2, where N2 may be greater than or equal to 0.
[0134] For example, the above method can be the processing procedure at the decoding end, that is, the decoding end uses the above method to decode the image. The processing procedure at the encoding end is similar, that is, the encoding end uses a similar method to encode the image, which will not be repeated here.
[0135] This application proposes an image encoding method that can be applied to the encoding end (also known as an encoder), enabling low-complexity, low-latency, and efficient image encoding. This image encoding method may include:
[0136] Step S11: Divide the image to be encoded into one or more non-overlapping sub-images.
[0137] For example, the image to be encoded can be divided into a sub-image, where the sub-image is the image to be encoded itself. Alternatively, the image to be encoded can be divided into multiple non-overlapping sub-images, with no dependency between them, allowing for parallel encoding. For instance, a frame of image (the image to be encoded) can be divided into two sub-images using a horizontal 3:1 non-equal division method, a horizontal 1:1 equal division method, a vertical 3:1 non-equal division method, or a horizontal 3:1:1 non-equal division method to divide a frame into three sub-images, and so on.
[0138] When dividing an image to be encoded into multiple non-overlapping sub-images, the sub-images are independent of each other and can be encoded in complete parallel, meaning each sub-image is encoded independently. For example, when encoding sub-image 1, since the encoding process of sub-image 2 does not depend on sub-image 1, sub-image 2 can be encoded simultaneously, i.e., sub-image 1 and sub-image 2 are encoded in parallel. This reduces image encoding time and enables low-complexity, low-latency, and efficient image encoding.
[0139] Step S12: For each subgraph, divide the subgraph into one or more non-overlapping coding units.
[0140] For example, a subgraph can be divided into a single coding unit, where the coding unit is the subgraph itself. Alternatively, the subgraph can be divided into multiple non-overlapping coding units, which can depend on each other, meaning they can perform cross-reference precoding. When dividing a subgraph into multiple non-overlapping coding units, the width of each coding unit is greater than its height, and the height of each coding unit is no greater than 8 (e.g., the height of the coding unit is 8, or less than 8).
[0141] For example, when dividing a subgraph into multiple non-overlapping coding units, the coding units can depend on each other and cannot be encoded in complete parallel. For instance, when encoding coding unit 2, the encoding process of coding unit 2 depends on coding unit 1. Therefore, coding unit 2 can only be encoded after coding unit 1 has completed its encoding.
[0142] For example, step S11 is optional. Alternatively, the image to be encoded may not be divided into one or more non-overlapping sub-images, that is, sub-images are not involved. Instead, the image to be encoded may be directly divided into one or more non-overlapping coding units.
[0143] Step S13: For each coding unit, predict the coding unit based on the prediction mode of the coding unit to obtain the predicted value of the coding unit, and determine the residual value of the coding unit based on the original value and the predicted value of the coding unit. For example, the difference between the original value and the predicted value can be used as the residual value.
[0144] For example, the prediction mode of the coding unit can be determined first. This prediction mode can be an intra-frame prediction mode, an inter-frame prediction mode, or a raw value prediction mode, etc. Then, the coding unit is predicted based on its prediction mode to obtain its predicted value. There are no restrictions on this prediction process. Then, the difference between the raw value and the predicted value of the coding unit can be calculated, and this difference can be used as the residual value of the coding unit.
[0145] For example, if the prediction mode of the coding unit is intra-frame prediction mode, then the intra-frame prediction mode is used to predict the coding unit and obtain its predicted value. If the prediction mode of the coding unit is inter-frame prediction mode, then the inter-frame prediction mode is used to predict the coding unit and obtain its predicted value. If the prediction mode of the coding unit is raw value prediction mode, then the raw value prediction mode is used to predict the coding unit and obtain its predicted value.
[0146] For example, intra-frame prediction modes can include, but are not limited to, angle prediction mode, block copy prediction mode, and point-by-point prediction mode; there are no restrictions on these. Inter-frame prediction modes can include, but are not limited to, regular inter mode, direct mode, and HMVP mode; there are no restrictions on these. For the raw value prediction mode, the predicted value of the coding unit is not obtained based on reconstructed pixels in the adjacent spatial domain, nor is it obtained based on reconstructed pixels in the temporal domain. When obtaining a predicted value using the raw value prediction mode, the pre-configured default value is used to determine the predicted value of the coding unit. This default value can be configured empirically; for example, the default value could be 1 shifted left by M bits, where M can be any value, such as M being the current image's bit width minus 1. Specifically, when the default value is 0, the raw value prediction mode has no predicted value.
[0147] Step S14: For each coding unit, transform the residual value of the coding unit based on the transformation parameters of the coding unit to obtain the transformation coefficient value of the coding unit (i.e. the transformed residual value).
[0148] For example, the transformation parameters of the coding unit can be determined first. These transformation parameters are used to transform the residual value. In this embodiment, the process of determining these transformation parameters is not limited. Then, based on the transformation parameters of the coding unit, the residual value of the coding unit is transformed to obtain the transformation coefficient value of the coding unit.
[0149] Step S15: For each coding unit, quantize the transform coefficient value of the coding unit based on the quantization parameter of the coding unit to obtain the final coefficient value of the coding unit (i.e., the residual value after transformation and quantization).
[0150] For example, the quantization parameters of the coding unit can be determined first. These quantization parameters are used to quantize the transform coefficient values, such as the quantization step size. The process of determining these quantization parameters is not limited. Then, based on the quantization parameters of the coding unit, the transform coefficient values of the coding unit are quantized to obtain the final coefficient values of the coding unit.
[0151] Step S16: For each coding unit, encode the pixel information of that coding unit in the bitstream.
[0152] For example, the original pixels of the coding unit can be encoded in the bitstream. That is, steps S13-S15 are not executed, the original pixels of the coding unit are obtained, and the original pixels of the coding unit are encoded in the bitstream.
[0153] For example, the residual value (residual coefficient) of the coding unit can be encoded in the bitstream. That is, without executing steps S14 and S15, the residual value of the coding unit is obtained and encoded in the bitstream.
[0154] For example, the transform coefficient value (the residual value after transformation) of the coding unit can be encoded in the bitstream. That is, without executing step S15, the transform coefficient value of the coding unit is obtained and encoded in the bitstream.
[0155] For example, the final coefficient value of the coding unit (i.e., the residual value after transformation and quantization) can be encoded in the bitstream. In other words, the final coefficient value of the coding unit is obtained and encoded in the bitstream.
[0156] This application proposes an image decoding method that can be applied to a decoding end (also known as a decoder). This method enables low-complexity, low-latency, and efficient image decoding. The image decoding method may include:
[0157] Step S21: For each coding unit, parse the final coefficient value of the coding unit from the bitstream.
[0158] For example, the encoder can encode the final coefficient value of the coding unit in the bitstream. Therefore, the decoder can parse the final coefficient value of the coding unit from the bitstream. The final coefficient value can be the residual value after transformation and quantization. Alternatively, the encoder can encode the transform coefficient value of the coding unit in the bitstream, without involving the quantization process. Therefore, the decoder can parse the transform coefficient value of the coding unit from the bitstream. The transform coefficient value can be the residual value after transformation.
[0159] Alternatively, for each coding unit, the residual value of that coding unit can be parsed from the bitstream. For example, the encoder can encode the residual value (residual coefficient) of that coding unit in the bitstream, so the decoder can parse the residual value of that coding unit from the bitstream, without involving the transformation and quantization of the residual value. Or, the encoder can encode the quantized residual value of that coding unit in the bitstream (i.e., after obtaining the residual value, quantize the residual value to obtain the quantized residual value), so the decoder can parse the quantized residual value of that coding unit from the bitstream, without involving the transformation of the residual value.
[0160] Alternatively, for each coded unit, the raw value of that coded unit can be parsed from the bitstream. For example, the encoder can encode the raw value of that coded unit in the bitstream, so the decoder can parse the raw value of that coded unit from the bitstream.
[0161] For example, the decoder can parse a flag bit from the bitstream. This flag bit indicates whether the coding unit performs an inverse transform or not. Based on this flag bit, the decoder knows whether the coding unit performs an inverse transform or not. If the coding unit performs an inverse transform, the decoder parses the final coefficient value of the coding unit from the bitstream, or parses the transform coefficient value of the coding unit from the bitstream. If the coding unit does not perform an inverse transform, the decoder parses the residual value of the coding unit from the bitstream, or parses the quantized residual value of the coding unit from the bitstream.
[0162] For ease of description, in the following embodiments, we will take the example of the encoding unit undergoing inverse transformation and the decoding end parsing the final coefficient value of the encoding unit from the bitstream, that is, the encoding end performs transformation and quantization operations on the residual value.
[0163] Step S22: For each coding unit, dequantize the final coefficient value of the coding unit based on the dequantization parameter corresponding to the coding unit to obtain the transform coefficient value (i.e. the residual value after transformation) of the coding unit.
[0164] For example, the inverse quantization parameter corresponding to the coding unit can be determined first. The inverse quantization parameter is a parameter used to inverse quantize the coefficient value. For instance, the decoding end can derive the inverse quantization parameter corresponding to the coding unit locally, or the encoding end can encode the quantization parameter information in the bitstream, and the decoding end can parse the inverse quantization parameter corresponding to the coding unit from the bitstream.
[0165] After obtaining the inverse quantization parameter corresponding to the coding unit, the final coefficient value of the coding unit can be inverse quantized based on the inverse quantization parameter to obtain the transform coefficient value of the coding unit. There are no restrictions on this inverse quantization process.
[0166] Step S23: For each coding unit, perform an inverse transform on the transform coefficient value of the coding unit based on the inverse transform parameter corresponding to the coding unit to obtain the residual reconstruction value of the coding unit (corresponding to the residual value at the encoding end).
[0167] For example, the inverse transform parameters corresponding to the coding unit can be determined first. The inverse transform parameters are used to perform the inverse transform on the transform coefficient values. For instance, the decoder can derive the inverse transform parameters corresponding to the coding unit locally, or the encoder can encode the inverse transform parameter information in the bitstream, and the decoder can parse the inverse transform parameters corresponding to the coding unit from the bitstream.
[0168] After obtaining the inverse transform parameters corresponding to the coding unit, the transform coefficient values of the coding unit can be inversely transformed based on the inverse transform parameters to obtain the residual reconstruction value of the coding unit. There are no restrictions on this inverse transform process.
[0169] Step S24: For each coding unit, predict the coding unit based on its prediction mode to obtain the predicted value of the coding unit. Determine the reconstructed value of the coding unit based on the residual reconstructed value and the predicted value of the coding unit. For example, the sum of the residual reconstructed value and the predicted value is used as the reconstructed value.
[0170] For example, the prediction mode of the coding unit can be determined first. This prediction mode can be an intra-frame prediction mode, an inter-frame prediction mode, or a raw value prediction mode, etc. Then, based on the prediction mode of the coding unit, a prediction is made for the coding unit to obtain the predicted value of the coding unit. There are no restrictions on this prediction process. Then, the sum between the residual reconstructed value of the coding unit and the predicted value of the coding unit can be calculated, and this sum can be used as the reconstructed value of the coding unit.
[0171] For example, if the prediction mode of the coding unit is intra-frame prediction mode, then the intra-frame prediction mode is used to predict the coding unit and obtain its predicted value. If the prediction mode of the coding unit is inter-frame prediction mode, then the inter-frame prediction mode is used to predict the coding unit and obtain its predicted value. If the prediction mode of the coding unit is raw value prediction mode, then the raw value prediction mode is used to predict the coding unit and obtain its predicted value.
[0172] For example, intra-frame prediction modes may include, but are not limited to, angle prediction mode, block copy prediction mode, and point-by-point prediction mode, while inter-frame prediction modes may include, but are not limited to, regular inter mode, direct mode, and HMVP mode.
[0173] For example, the prediction mode of the coding unit can be determined first, such as intra-frame prediction mode, inter-frame prediction mode, and raw value prediction mode. For instance, the decoder can deduce the prediction mode of the coding unit locally, or the encoder can encode the prediction mode information of the coding unit in the bitstream, and the decoder can parse the prediction mode of the coding unit from the bitstream.
[0174] Step S25: Determine the reconstruction value of the subgraph based on the reconstruction value of each coding unit within the subgraph.
[0175] For example, the decoding end can deduce the subgraph partitioning information locally, or the encoding end can encode the subgraph partitioning information in the bitstream, and the decoding end can parse the subgraph partitioning information from the bitstream. The subgraph partitioning information represents the partitioning information that divides the subgraph into multiple coding units. Based on the subgraph partitioning information, after obtaining the reconstruction value of each coding unit in the subgraph, the reconstruction values of each coding unit in the subgraph can be combined based on the partitioning information to obtain the reconstruction value of the subgraph.
[0176] When the encoder divides the subgraph into multiple non-overlapping coding units, these coding units can depend on each other, meaning they can perform cross-reference pre-coding. Therefore, when the decoder combines the reconstructed values of each coding unit within the subgraph, these coding units can also depend on each other, meaning they can perform cross-reference pre-decoding.
[0177] Step S26: Determine the reconstruction value of the image to be decoded based on the reconstruction value of each sub-image within the image to be decoded.
[0178] For example, the decoding end can locally deduce the segmentation information of the image to be decoded, or the encoding end can encode the segmentation information of the image to be decoded in the bitstream, and the decoding end can parse the segmentation information of the image to be decoded from the bitstream. The segmentation information of the image to be decoded represents the segmentation information that divides the image to be decoded into multiple sub-images. Based on the segmentation information of the image to be decoded, after obtaining the reconstruction value of each sub-image in the image to be decoded, the reconstruction values of each sub-image in the image to be decoded can be combined based on the segmentation information to obtain the reconstruction value of the image to be decoded. At this point, the image decoding process is completed, and the image to be decoded can be obtained.
[0179] For example, when the encoder divides the image to be encoded into multiple non-overlapping sub-images, there is no dependency between the sub-images, allowing for completely parallel encoding, meaning each sub-image is encoded completely independently. Therefore, when the decoder determines the reconstructed value of each sub-image within the image to be decoded, there is no dependency between the sub-images, allowing for completely parallel decoding, meaning each sub-image is decoded completely independently.
[0180] For example, when the decoding end is decoding sub-image 1, since the decoding process of sub-image 2 does not depend on the decoding process of sub-image 1, the decoding end can decode sub-image 2 simultaneously, that is, sub-image 1 and sub-image 2 are decoded in parallel. In this way, the image decoding time can be reduced, and low-complexity, low-latency and efficient image decoding can be achieved.
[0181] In one possible implementation, for lossless and near-lossless compression coding frameworks, the encoding end can encode the original pixel values (the quantized values of the original pixel values, or the original pixel values themselves not being quantized), and the decoding end can parse the original pixel values (the quantized original pixel values or the original pixel values themselves) from the bitstream. Alternatively, the encoding end can encode the residual values (the residual values are the predicted residual coefficients, the quantized values of the residual values, or the residual values themselves not being quantized), and the decoding end can parse the residual values (the quantized residual values or the residual values themselves) from the bitstream. Alternatively, the encoding end can encode the transform coefficient values (the transformed transform coefficients, the quantized values of the transform coefficient values, or the transform coefficient values themselves not being quantized), and the decoding end can parse the transform coefficient values (the quantized transform coefficient values or the transform coefficient values themselves) from the bitstream.
[0182] For example, considering the different data distributions among the original pixel values, residual values, and transform coefficient values, different encoding methods are used for different types of data (original pixel values, residual values, and transform coefficient values) based on their distribution characteristics.
[0183] For example, different scanning methods can be designed for different types of data (original pixel values, residual values, and transformation coefficient values). The scanning method can take into account the distribution of the data and distribute coefficients with similar amplitudes together as much as possible.
[0184] For example, the data obtained after scanning can be grouped. The grouping method can be irregular based on the data distribution, or it can be fixed. The specific grouping of the data can be agreed upon between the encoder and decoder, or it can be derived from the context (including derived from encoded data, derived from prediction coefficients, and derived from encoded parameters), or it can be carried to the decoder by the encoder in the bitstream.
[0185] For example, for different data distributions, you can choose to encode directly based on the data to be encoded (such as original pixel values, residual values, and transform coefficient values), or you can estimate the encoding range of the data to be encoded based on the context, or directly estimate the coefficient values of the relevant data to be encoded. 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 parameters more accurate.
[0186] For example, for different data distributions, parameters can be estimated based on the context, the numerical range of the next set of coded coefficients (each set of coefficients can have more than or equal to 1) can be estimated, and the encoding method for the next set of coefficients can be selected based on the estimated value.
[0187] For example, for different data distributions, parameters can be estimated 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 encoding parameters. Based on this numerical range, the encoding method for the next set of coefficients can be selected. Different encoding schemes and encoding methods can be selected based on different ranges of coefficients.
[0188] For example, since the data distribution in the time domain is different from that in the frequency domain, the data distribution in the time domain is more uniform, while the greater energy of the data in the frequency domain is distributed in the low-frequency information, when encoding the transform coefficients, we can consider to group the positions of the transformed coefficients in a special way and encode the transform coefficients under the special grouping method.
[0189] For example, when encoding coefficient values, one can choose unary codes, truncated unary codes, truncated binary codes, fixed-length codes, semi-fixed-length codes, run-length codes, k-order exponential Golomb codes, truncated Rice codes, Golomb-Rice codes, Huffman codes, arithmetic codes, adaptive variable-length codes, etc., and can use one or more encoding methods to encode the coefficients.
[0190] For example, the scanning methods for coding coefficients may include, but are not limited to: raster scanning, block scanning, horizontal scanning, vertical scanning, round-trip (horizontal / vertical) scanning, diagonal (top left, top right, bottom left, bottom right) scanning, reverse diagonal scanning, reverse horizontal scanning, and reverse vertical scanning, or scanning based on a fixed scanning template.
[0191] In one possible implementation, for the decoding end, the image decoding method may include: determining the scanning method for coefficients; parsing decoding parameters (including the number of parameters, parameter groups, parameter scanning order, and parameter values); determining whether prediction parameters need to be derived based on context information based on different parameters; if prediction parameters exist, then decoding is performed according to the coefficient encoding method based on the prediction parameters and the parameters parsed in the bitstream; otherwise, decoding is performed directly according to the coefficient encoding method based on the prediction parameters and the parameters parsed in the bitstream; if groups exist, then the decoded coefficients in each group are placed back to their original positions in order according to the bitstream; otherwise, all coefficient values are directly decoded.
[0192] The process of "determining the scanning method for the coefficients" can be achieved through bitstream parsing, agreement between the encoder and decoder, or derivation by the decoder (based on parameters such as the size of the current block, prediction method, and transformation method).
[0193] The process of "parse decoding parameters" can be parsed from the bitstream, agreed upon by the encoder and decoder, or derived by the decoder (determined based on parameters such as the size of the current block, prediction method, and transformation method).
[0194] The process of "determining whether to export prediction parameters" can be done through bitstream parsing, by agreement between the encoder and decoder, or by exporting them from the decoder (based on parameters such as the current block size, prediction method, and transformation method).
[0195] For example, regarding the block decoding process, the scanning method of the blocks can be determined; the grouping method of the scanned coefficients can be determined; then, the common parameters of each group can be decoded using a certain method; based on the common parameters, each coefficient value within the group can be decoded using a certain decoding method. Finally, based on the scanning method, the coefficients within the block can be restored to their original arrangement.
[0196] For example, for a block-based decoding process, the scanning method of the block can be determined; the current range of coding coefficients can be predicted based on the context; and a decoding method can be selected based on the range of coefficient values.
[0197] In one possible implementation, for the encoding end, the image encoding method and the image decoding method are similar in processing. For the parameters that need to be written into the bitstream, they can be obtained through RDO at the encoding end or estimated.
[0198] For the block coding process, coefficients can be scanned into a one-dimensional vector. If the region to be encoded is a three-dimensional image, it is first divided into one or more two-dimensional coefficient blocks. If the region to be encoded is a two-dimensional coefficient block, the block is scanned into a one-dimensional coefficient vector using a specific scanning order. Then, the coefficient vector is grouped according to coefficient magnitude, with coefficients of similar magnitude grouped together. The one-dimensional coefficients are grouped according to several fixed grouping methods. Finally, the specific grouping information is encoded, or the one-dimensional coefficient grouping method is derived based on prediction or transformation methods. Coefficients within the same group can use a common parameter, which guides the encoding of all subsequent coefficients.
[0199] Common parameters can be encoded using fixed-length codes, unary codes, or truncated unary codes.
[0200] Then, each coefficient within the group is encoded using a certain encoding method based on the common parameters.
[0201] For encoding processes that do not require grouping, similar to grouped encoding processes, the grouping method is removed (i.e., the process of grouping one-dimensional coefficients is removed), and each coefficient is encoded individually. For each coefficient to be encoded, the range of values of the coefficient to be encoded can be derived based on the context, and an encoding method is selected to encode it based on this range.
[0202] In one possible implementation, for each coefficient unit to be encoded, the encoder can determine the target coefficient block of the coefficient unit based on its original value. The determination process is described in steps S11-S15. The target coefficient block may include the original pixels of the coefficient unit to be encoded (quantized original pixels or unquantized original pixels), or it may include the residual values of the coefficient unit to be encoded (i.e., residual coefficients, quantized residual values or unquantized residual values), or it may include the coefficient values of the coefficient unit to be encoded (quantized final coefficient values or unquantized transform coefficient values). For ease of description, this example assumes that the target coefficient block includes the coefficient values of the coefficient unit to be encoded (such as final coefficient values or transform coefficient values), and the subsequent process assumes that the coefficient unit to be encoded is an encoding unit.
[0203] For example, the target coefficient block may include a first coefficient block corresponding to the coding unit and a second coefficient block corresponding to the coding unit. The first coefficient block may include multiple first-type coefficients, and the second coefficient block may include multiple second-type coefficients.
[0204] For example, the first coefficient block may include an AC (Alternating Current) coefficient block. The first type of coefficients within the AC coefficient block may include transformed AC coefficients (i.e., quantized AC coefficients or unquantized AC coefficients), which are high-frequency coefficients. The second coefficient block includes a DC (Direct Current) coefficient block. The second type of coefficients within the DC coefficient block may include transformed DC coefficients (i.e., quantized DC coefficients or unquantized DC coefficients), which are low-frequency coefficients.
[0205] For example, after the encoder transforms the residual value (such as DCT (Discrete Cosine Transform)), there are at least one DC coefficient and multiple AC coefficients in the transformed coefficients. Therefore, the coefficient block composed of at least one DC coefficient is called the DC coefficient block, and the coefficient block composed of multiple AC coefficients is called the AC coefficient block. That is, we can obtain the AC coefficient block and the DC coefficient block. The AC coefficient block and the DC coefficient block are combined to obtain the target coefficient block.
[0206] It is important to note that the target coefficient block is in two-dimensional form, i.e., the AC coefficient block and the DC coefficient block are both in two-dimensional form. In step S16, in order to encode the coefficient values in the bitstream, the two-dimensional coefficients need to be converted to one-dimensional coefficients. Based on this, the encoder can scan all the AC coefficients in the AC coefficient block corresponding to the coding unit according to the first scanning order corresponding to the coding unit, to obtain the AC coefficient group corresponding to the coding unit. The AC coefficient group includes the transformed AC coefficients, and the transformed AC coefficients are in one-dimensional form, such as the AC coefficient group including AC coefficient 1 to AC coefficient 15 in sequence.
[0207] If the DC coefficient block corresponding to the coding unit includes one DC coefficient, the encoder directly obtains the DC coefficient group, and the DC coefficient group includes one DC coefficient within the DC coefficient block. Alternatively, if the DC coefficient block corresponding to the coding unit includes at least two DC coefficients, the encoder can scan all DC coefficients within the DC coefficient block corresponding to the coding unit based on the second scanning order corresponding to the coding unit to obtain the DC coefficient group corresponding to the coding unit. The DC coefficient group includes the transformed DC coefficients, and the transformed DC coefficients are in one-dimensional form, such as the DC coefficient group sequentially including multiple DC coefficients.
[0208] For example, the second scanning order can be the same as the first scanning order, or it can be different from the first scanning order. For instance, the first scanning order can indicate the scanning order from the two-dimensional coefficients of the AC coefficient block to the one-dimensional coefficients of the AC coefficient group, that is, it can indicate the pixel position of each AC coefficient within the AC coefficient group in the AC coefficient block, and the first scanning order can be configured arbitrarily. Similarly, the second scanning order can indicate the scanning order from the two-dimensional coefficients of the DC coefficient block to the one-dimensional coefficients of the DC coefficient group, that is, it can indicate the pixel position of each DC coefficient within the DC coefficient group in the DC coefficient block, and the second scanning order can be configured arbitrarily.
[0209] In summary, for each coding unit, we can obtain the corresponding AC coefficient set and DC coefficient set. We can form an AC coefficient set from the AC coefficient sets of the largest coding unit and a DC coefficient set from the DC coefficient sets of the largest coding unit. The largest coding unit can include N coefficient units to be decoded, and the value of N can be chosen empirically. Thus, the AC coefficient set includes N AC coefficient sets corresponding to N coding units, and the DC coefficient set includes N DC coefficient sets corresponding to N coding units, where N is a positive integer greater than 1. For example, if N is 8, the AC coefficient set includes 8 AC coefficient sets, and the DC coefficient set includes 8 DC coefficient sets.
[0210] Based on this, the encoder can encode the first set of coefficients and the second set of coefficients of the largest coding unit in the bitstream. For example, the encoder can encode 8 AC coefficients in the bitstream, that is, encode these 8 AC coefficients; and the encoder can encode 8 DC coefficients in the bitstream, that is, encode these 8 DC coefficients.
[0211] For example, when the encoder assembles all AC coefficient groups of the largest coding unit into an AC coefficient group set, it can scan the AC coefficient group of the largest coding unit based on the third scan order (i.e., the unit scan order). The third scan order is used to indicate the arrangement order of the N coding units. For instance, if the N coding units are 8 coding units in a 2*4 (two rows and four columns) configuration, based on the scan order of the 8 coding units indicated by the third scan order, the AC coefficient group of the coding unit in the first row and first column can be scanned first, then the AC coefficient group of the coding unit in the first row and second column, then the AC coefficient group of the coding unit in the first row and third column, then the AC coefficient group of the coding unit in the first row and fourth column, then the AC coefficient group of the coding unit in the second row and first column, then the AC coefficient group of the coding unit in the second row and second column, then the AC coefficient group of the coding unit in the second row and third column, and finally the AC coefficient group of the coding unit in the second row and fourth column.
[0212] Scanning the AC coefficient group of the coding unit in row 1, column 1 first means adding the AC coefficients within that group to the AC coefficient group set. Then scanning the AC coefficient group of the coding unit in row 1, column 2 means adding the AC coefficients from that group to the AC coefficient group set, starting from the last AC coefficient in the set, and so on.
[0213] For example, the scanning order of the 8 coding units is as follows: row 1, column 1; row 1, column 2; row 1, column 3; row 1, column 4; row 2, column 4; row 2, column 3; row 2, column 2; row 2, column 1.
[0214] For example, the scanning order of the 8 coding units is as follows: row 1, column 1; row 2, column 1; row 2, column 2; row 1, column 2; row 1, column 3; row 2, column 3; row 2, column 4; row 1, column 4.
[0215] For example, the scanning order of the 8 coding units is as follows: row 1, column 1; row 2, column 1; row 1, column 2; row 2, column 2; row 1, column 3; row 2, column 3; row 1, column 4; row 2, column 4.
[0216] Of course, the above are just a few examples. In this embodiment, the scanning order of these N coding units is not limited.
[0217] For example, when the encoding end assembles the DC coefficient groups of the largest coding unit into a DC coefficient group set, it can scan the DC coefficient groups of the largest coding unit based on the fourth scanning order to obtain the DC coefficient group set. The fourth scanning order is used to indicate the arrangement order of the N coding units. The fourth scanning order can be the same as the third scanning order, or it can be different from the third scanning order. Taking the fourth scanning order as the same as the third scanning order as an example, if the N coding units are 8 coding units in a 2*4 (two rows and four columns) configuration, the DC coefficient groups of each coding unit can be scanned sequentially based on the scanning order of the 8 coding units indicated by the third scanning order, and finally the DC coefficient group set is obtained.
[0218] In one possible implementation, the decoder can decode the first set of coefficient groups and the second set of coefficient groups of the largest coding unit from the bitstream. The first set of coefficient groups is divided into N first coefficient groups corresponding to N coefficient units to be decoded, and the second set of coefficient groups is divided into N second coefficient groups corresponding to N coefficient units to be decoded. For example, the largest coding unit may include N coefficient units to be decoded. The coefficient groups of the coefficient units to be decoded may include original pixel reconstruction values (quantized original pixel reconstruction values or unquantized original pixel reconstruction values), or residual reconstruction values (quantized residual reconstruction values or unquantized residual reconstruction values), or coefficient values (quantized final coefficient values or unquantized transform coefficient values). For ease of description, this is taken as an example where the first coefficient group / second coefficient group includes the coefficient values of the coefficient units to be decoded (such as final coefficient values or transform coefficient values). The subsequent process assumes that the coefficient units to be decoded are coding units.
[0219] For example, the first coefficient group may include the AC coefficient group, and the first type of coefficients in the first coefficient group may include the transformed AC coefficients; the second coefficient group may include the DC coefficient group, and the second type of coefficients in the second coefficient group may include the transformed DC coefficients.
[0220] Assuming N is 8, each AC coefficient group includes 15 AC coefficients, and the first set of coefficient groups includes 120 AC coefficients. The first 15 AC coefficients in the first set are assigned to the AC coefficient group corresponding to the first coding unit, which also includes 15 AC coefficients. The 16th to 30th AC coefficients in the first set are assigned to the AC coefficient group corresponding to the second coding unit, which also includes 15 AC coefficients. This process continues, assigning the 105th to 120th AC coefficients in the first set to the AC coefficient group corresponding to the eighth coding unit, which also includes 15 AC coefficients.
[0221] Assuming each DC coefficient set contains one DC coefficient, and the second set of coefficient sets contains eight DC coefficients, the first DC coefficient in the second set of coefficient sets is assigned to the DC coefficient set corresponding to the first coding unit. This DC coefficient set contains one AC coefficient. The second DC coefficient in the second set of coefficient sets is assigned to the DC coefficient set corresponding to the second coding unit. Similarly, the eighth DC coefficient in the second set of coefficient sets is assigned to the DC coefficient set corresponding to the eighth coding unit.
[0222] For example, when the decoder divides the AC coefficient set into N AC coefficient groups corresponding to N coding units, it can scan the AC coefficient set based on the third scanning order (unit scanning order) to obtain N AC coefficient groups. The third scanning order is used to indicate the arrangement order of the N coding units. For instance, if the N coding units are 8 coding units in a 2*4 (two rows and four columns) configuration, based on the scanning order of the 8 coding units indicated by the third scanning order, it can first scan the AC coefficients of the first AC coefficient group (e.g., 15 AC coefficients) within the AC coefficient set, and assign the AC coefficients of this AC coefficient group to the coding unit in the first row and first column (based on the third scanning order). Then, it scans the AC coefficients of the first AC coefficient group within the AC coefficient set, assigning the AC coefficients of this AC coefficient group to the coding unit in the first row and second column. Then, it scans the AC coefficients of the third AC coefficient group within the AC coefficient set, assigning the AC coefficients of this AC coefficient group to the coding unit in the first row and third column. Then, it scans the AC coefficients of the fourth AC coefficient group within the AC coefficient set. The AC coefficients of the AC coefficient group are assigned to the encoding unit in the 1st row and 4th column. Then, the AC coefficients of the 5th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 5th AC coefficient group are assigned to the encoding unit in the 2nd row and 1st column. Then, the AC coefficients of the 6th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 6th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 6th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 6th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 7th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 7th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 7th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 7th AC coefficient group are scanned from the set of AC coefficient groups, and the AC coefficients of the 8 ...
[0223] In summary, the AC coefficients of each AC coefficient group can be scanned from within the set of AC coefficient groups. The assignment of each AC coefficient group's AC coefficients to a specific coding unit can be determined based on the third scanning order.
[0224] For example, when the decoding end divides the DC coefficient set into N DC coefficient groups corresponding to N coding units, it can scan the DC coefficient set based on the fourth scanning order to obtain the N DC coefficient groups. The fourth scanning order is used to indicate the scanning order of the N coding units. The fourth scanning order can be the same as the third scanning order, or it can be different from the third scanning order. Taking the fourth scanning order being the same as the third scanning order as an example, if the N coding units are 8 coding units in a 2*4 (two rows and four columns) configuration, the DC coefficients of each DC coefficient group can be divided into coding units at the relevant positions in the two rows and four columns based on the scanning order of the 8 coding units indicated by the fourth scanning order.
[0225] For each coding unit, the corresponding third scanning order (fourth scanning order) can be, but is not limited to, any of the following: raster scanning order; z-scan scanning order; Zig-Zag scanning order; block scanning order; horizontal scanning order; vertical scanning order; horizontal round-trip scanning order; vertical round-trip scanning order; diagonal scanning order; reverse diagonal scanning order; reverse horizontal scanning order; reverse vertical scanning order; and scanning order based on a fixed scanning template.
[0226] In summary, for each of the N coding units, the corresponding AC coefficient group and DC coefficient group can be obtained. It's important to note that both the AC and DC coefficient groups are one-dimensional. In steps S22 and S23, to perform operations such as inverse quantization and inverse transform, the one-dimensional coefficients need to be converted to two-dimensional coefficients. Therefore, for each coding unit, the decoder can scan all AC coefficients within the corresponding AC coefficient group based on the first scan order, obtaining the corresponding AC coefficient block. For example, for a 4x4 coefficient block with 16 pixel positions, assuming the AC coefficient group includes 15 AC coefficients, excluding the top-left pixel position, the 15 AC coefficients are mapped to the 15 pixel positions based on the first scan order, resulting in the AC coefficient block.
[0227] Furthermore, if the DC coefficient group corresponding to the coding unit includes one DC coefficient, the decoder directly obtains the DC coefficient block corresponding to the coding unit, and the DC coefficient block includes only one DC coefficient. Alternatively, if the DC coefficient group includes at least two DC coefficients, the decoder can scan all the DC coefficients in the DC coefficient group corresponding to the coding unit based on the second scanning order corresponding to the coding unit to obtain the DC coefficient block corresponding to the coding unit.
[0228] For example, the second scanning order can be the same as the first scanning order, or it can be different from the first scanning order. For instance, the first scanning order can be used to indicate the scanning order from the one-dimensional coefficients of the AC coefficient group to the two-dimensional coefficients of the AC coefficient block, and the first scanning order can be configured arbitrarily. Similarly, the second scanning order can be used to indicate the scanning order from the one-dimensional coefficients of the DC coefficient group to the two-dimensional coefficients of the DC coefficient block, and the second scanning order can be configured arbitrarily.
[0229] In summary, for each coding unit, the decoder can obtain the corresponding AC coefficient block and DC coefficient block. These two blocks can then be concatenated to form the target coefficient block for that coding unit. For example, the target coefficient block can be a 4x4 block, with the top-left pixel representing one DC coefficient from the DC coefficient block, and the remaining 15 pixels representing the 15 AC coefficients from the AC coefficient block. Based on the target coefficient block, steps S22-S24 are performed to obtain the reconstructed value.
[0230] For example, when determining the reconstructed value of a coding unit based on a target coefficient block, the coefficient values of the target coefficient block can be dequantized based on the dequantization parameters corresponding to the coding unit to obtain the dequantized coefficient block; the coefficient values of the dequantized coefficient block can be inversely transformed based on the inverse transform parameters corresponding to the coding unit to obtain the residual reconstructed block of the coding unit; furthermore, the coding unit can be predicted based on its prediction mode to obtain the predicted value of the coding unit, and the reconstructed value of the coding unit can be determined based on the predicted value and the residual reconstructed block of the coding unit. Alternatively,
[0231] The coefficient values of the target coefficient block are inversely transformed based on the inverse transform parameters corresponding to the coding unit to obtain the residual reconstruction block of the coding unit. The coding unit is then predicted based on its prediction mode to obtain the predicted value of the coding unit. The reconstructed value of the coding unit is determined based on the predicted value and the residual reconstruction block of the coding unit.
[0232] In one possible implementation, when the encoding end scans all AC coefficients within an AC coefficient block to obtain an AC coefficient group based on a first scan order, for N coding units, the first scan order corresponding to different coding units can be the same, or the first scan order corresponding to different coding units can be different. When the decoding end scans all AC coefficients within an AC coefficient group to obtain an AC coefficient block based on the first scan order, for N coding units, the first scan order corresponding to different coding units can be the same, or the first scan order corresponding to different coding units can be different. Similarly, the second scan order corresponding to different coding units can be the same, or the second scan order corresponding to different coding units can be different.
[0233] For each coding unit, the first scanning order (second scanning order) corresponding to the coding unit may include, but is not limited to, any of the following: raster scanning order; z-scan scanning order; Zig-Zag scanning order; block scanning order; horizontal scanning order; vertical scanning order; horizontal round-trip scanning order; vertical round-trip scanning order; diagonal scanning order; reverse diagonal scanning order; reverse horizontal scanning order; reverse vertical scanning order; and scanning order based on a fixed scanning template.
[0234] Regarding raster scan order: Raster scan order is used to map a two-dimensional rectangular raster to a one-dimensional raster. The entry point for the one-dimensional raster starts from the first row of the two-dimensional raster, then scans the second row, the third row, and so on, with the rows in the raster scanned from left to right. For example, see... Figure 5A The diagram illustrates the raster scanning sequence. When the encoder scans all AC coefficients within an AC coefficient block to obtain an AC coefficient group, the AC coefficient at scan position 0 (if present) is used as the first coefficient value of the AC coefficient group, the AC coefficient at scan position 1 (if present) is used as the second coefficient value, the AC coefficient at scan position 2 (if present) is used as the third coefficient value, and so on, in the scanning order of 0, 1, 2, 3, ..., 15. When the decoder scans all AC coefficients within an AC coefficient group to obtain an AC coefficient block, the first coefficient value of the AC coefficient group is used as position 0 of the AC coefficient block (if present), the second coefficient value is used as position 1 of the AC coefficient block (if present), the third coefficient value is used as position 2 of the AC coefficient block (if present), and so on, in the scanning order of 0, 1, 2, 3, ..., 15.
[0235] Regarding the z-scan scanning order (i.e., the Z-scan order): For any square with an even side length, you can scan the top-left corner first, then the top-right corner, then the bottom-left corner, and finally the bottom-right corner. For example, see... Figure 5B The diagram illustrates the z-scan scanning sequence. At the encoding end, the AC coefficient at scan position 0 (if present) becomes the first coefficient value of the AC coefficient group, the AC coefficient at scan position 1 becomes the second coefficient value, the AC coefficient at scan position 2 becomes the third coefficient value, and so on, scanning in the order of 0, 1, 2, 3, ..., 15. At the decoding end, the first coefficient value of the AC coefficient group becomes position 0 of the AC coefficient block (if present), the second coefficient value becomes position 1 of the AC coefficient block, the third coefficient value becomes position 2 of the AC coefficient block, and so on, placing them in the order of 0, 1, 2, 3, ..., 15.
[0236] For diagonal scan sequences, such as the up-right diagonal scan, the scan begins with the last coefficient in the bottom right corner of the coefficient block and ends with the first coefficient in the top left corner. The scan order between blocks is the same as the scan order between coefficients, i.e., the scan order between blocks is bottom right, top right, bottom left, top left.
[0237] For horizontal traverse scan: a two-dimensional rectangle is mapped to a one-dimensional string. The entry point of the one-dimensional string starts from the first row of the two-dimensional rectangle, and the entire two-dimensional rectangle is scanned row by row. The row scanning direction of the first row is from left to right, the row scanning direction of the adjacent rows of the first row is from right to left, and any two adjacent rows have opposite row scanning directions.
[0238] For the reverse horizontal scan order: the scan starts from the last coefficient in the lower right corner of the coefficient block and ends at the first coefficient in the upper left corner of the coefficient block. Within each coefficient block, the scan proceeds from right to left and from bottom to top. When using the reverse horizontal scan order, the scan order between blocks is lower right block, upper right block, lower left block, upper left block.
[0239] For the reverse vertical scanning order: start scanning from the last coefficient in the lower right corner of the coefficient block and end at the first coefficient in the upper left corner of the coefficient block, scanning from bottom to top and from right to left within each small block.
[0240] For Zig-Zag scan order (e.g., forward zigzag scan order): See [link / reference] Figure 5C The diagram shows the Zig-Zag scanning sequence, with the encoder and decoder following the... Figure 5C Simply perform the scan in the indicated order.
[0241] In one possible implementation, the encoding end and the decoding end can pre-agree on which scanning order to use as the first scanning order (second scanning order). For example, they can pre-agree to use the raster scanning order as the first scanning order, or they can pre-agree to use the z-scan scanning order as the first scanning order. There is no restriction on this first scanning order.
[0242] Alternatively, the encoder can select a first scan order and encode this information in the bitstream. The decoder can then obtain the first scan order corresponding to the encoded unit by decoding the bitstream. This first scan order can be either a raster scan order or a z-scan scan order. For example, if the encoder encodes raster scan order information in the bitstream, the decoder can determine that the first scan order is raster scan order by decoding the bitstream. Or, the encoder can encode z-scan scan order information in the bitstream, and the decoder can determine that the first scan order is z-scan scan order by decoding the bitstream.
[0243] In one possible implementation, a scanning and stitching method for AC coefficients is proposed, see [link to relevant documentation]. Figure 5D The diagram illustrates the scanning and concatenation method for AC coefficients. The encoder can scan N sets of AC coefficients (one set of AC coefficients represents all AC coefficients within a coding unit, such as 15 AC coefficients) to obtain N sets of AC coefficients. That is, one coding unit corresponds to one set of AC coefficients, and the N sets of AC coefficients form a set of AC coefficient sets. This results in a one-dimensional set of AC coefficient sets with a length of N*M, where N represents the number of coding units and M represents the number of AC coefficients within each coding unit. Figure 5D In this system, the AC coefficient set consists of 8 AC coefficient sets, each containing 15 AC coefficients. The total length of the AC coefficient set is 120 AC coefficients, and these 120 AC coefficients are encoded.
[0244] When the encoder scans N sets of AC coefficients, the scanning order can be raster scan order, z-scan scan order, Zig-Zag scan order, etc., and there is no restriction on this scanning order. Figure 5D In this example, we take the raster scanning sequence. Figure 5D In the original text, each coding unit is scanned in the same order. However, in practical applications, the scanning order of different coding units can be different.
[0245] The decoding end can decode to obtain a set of AC coefficient groups, and the set of AC coefficient groups includes 120 AC coefficients, based on... Figure 5D The AC coefficient scanning and splicing method shown in the figure involves the decoding end decoding the set of AC coefficients for N (e.g., 8) coding units. The set of AC coefficients includes all AC coefficients corresponding to the first coding unit (e.g., 15 AC coefficients), all AC coefficients corresponding to the second coding unit, ..., and so on, up to all AC coefficients corresponding to the Nth coding unit.
[0246] Based on this, the decoder can assign AC coefficients 1-15 to the AC coefficient group of the first coding unit and scan them into the AC coefficient block according to the raster scan order. The decoder can assign AC coefficients 16-30 to the AC coefficient group of the second coding unit and scan them into the AC coefficient block according to the raster scan order. This process continues until the final result is obtained according to... Figure 5D This method yields 8 AC coefficient blocks.
[0247] In one possible implementation, a scanning and stitching method for AC coefficients is proposed, see [link to relevant documentation]. Figure 5EThe diagram illustrates the scanning and splicing method for AC coefficients. The encoder can scan N sets of AC coefficients to obtain N AC coefficient sets, meaning one coding unit corresponds to one AC coefficient set, and N AC coefficient sets form an AC coefficient set. This results in a one-dimensional AC coefficient set with a length of N*M. Figure 5E In this context, the AC coefficient set comprises 8 AC coefficient groups, each containing 15 AC coefficients, and the total length of the AC coefficient set is 120 AC coefficients. Figure 5D The difference is that, in Figure 5E In this model, the AC coefficient set does not sequentially include the 15 AC coefficients in each AC coefficient set. Instead, it first includes the first AC coefficient in each of the eight AC coefficient sets, that is, eight AC coefficients with the same frequency spliced together. Then it includes the second AC coefficient in each of the eight AC coefficient sets, then the third AC coefficient in each of the eight AC coefficient sets, and so on, until it includes the 15 AC coefficients in each of the eight AC coefficient sets.
[0248] When the encoder scans N sets of AC coefficients, the scanning order can be raster scan order, z-scan scan order, Zig-Zag scan order, etc., and there is no restriction on this scanning order. Figure 5E In the example of raster scanning order, the positions of pixels 1-15 in the first row are obtained by scanning from the coefficient block of the coding unit according to the raster scanning order.
[0249] The decoding end can decode to obtain a set of AC coefficient groups, and the set of AC coefficient groups includes 120 AC coefficients, based on... Figure 5E The AC coefficient scanning and splicing method shown in the figure involves the decoding end decoding the set of AC coefficients of N (e.g., 8) coding units. The set of AC coefficients includes, in sequence, the AC coefficients at the first position of the N coding units (e.g., 8 AC coefficients), the AC coefficients at the second position of the N coding units, ..., and so on, up to the AC coefficients at the Mth position of the N coding units. Each coding unit can include AC coefficients at M positions, and M can be greater than 1.
[0250] Based on this, the decoder can assign the 1st, 9th, 17th, 25th, 33rd, 41st, 49th, 57th, 65th, 73rd, 81st, 89th, 97th, 105th, and 113th AC coefficients from the AC coefficient set to the AC coefficient group of the first coding unit, and scan these AC coefficients into the AC coefficient block according to the raster scan order. The decoder can assign the 2nd, 10th, 18th, 26th, 34th, 42nd, 50th, 58th, 66th, 77th, 82nd, 90th, 98th, 106th, and 114th AC coefficients from the AC coefficient set to the AC coefficient group of the second coding unit, and scan these AC coefficients into the AC coefficient block according to the raster scan order. This process continues, with AC coefficients spaced 8s apart corresponding to the same AC coefficient group, and finally... Figure 5E This method yields 8 AC coefficient blocks.
[0251] See Figure 5E As shown, the encoder can scan N groups of DC coefficients to obtain N DC coefficient groups. Taking an example where each DC coefficient group contains only one DC coefficient, the N DC coefficient groups form a DC coefficient set. This yields a one-dimensional DC coefficient set. Figure 5E In the code, the DC coefficient set consists of 8 DC coefficient groups, each containing 1 DC coefficient. The length of the DC coefficient set is 8 DC coefficients. The decoder can decode to obtain the DC coefficient set, which sequentially includes the DC coefficient at the first position of N coding units (e.g., 8 DC coefficients), the DC coefficient at the second position of N coding units, ..., and so on. Figure 5E In this structure, the DC coefficient set sequentially includes the DC coefficients at the first position of N coding units. Thus, the decoder can assign the first DC coefficient of the DC coefficient set to the DC coefficient set of the first coding unit, the second DC coefficient to the DC coefficient set of the second coding unit, and so on. Finally, according to... Figure 5E Eight DC coefficient blocks were obtained in this way.
[0252] In one possible implementation, a scan-without-stitching method for AC coefficients is proposed, see [link to relevant documentation]. Figure 5F The diagram illustrates a non-concatenated scanning method for AC coefficients. The encoder can scan N sets of AC coefficients to obtain N AC coefficient groups, which together form an AC coefficient set. Figure 5F In the set of AC coefficient groups, there are 8 AC coefficient groups, each containing 15 AC coefficients, and the length of the set of AC coefficient groups is 120 AC coefficients.
[0253] The AC coefficient set first includes the first AC coefficient in the 8 AC coefficient sets, that is, 8 AC coefficients with the same frequency spliced together. Then, it includes the second AC coefficient in the 8 AC coefficient sets, then the third AC coefficient in the 8 AC coefficient sets, and so on, until it includes 15 AC coefficients in the 8 AC coefficient sets.
[0254] and Figure 5E The difference is that, in Figure 5F In this model, AC coefficients of different frequencies are not concatenated together. For example, the first AC coefficient in an 8-coefficient set is not concatenated with the second AC coefficient in the same 8-coefficient set, and so on. Thus, the above set of AC coefficient sets can be understood as M subsets (e.g., 15 subsets). The first subset includes the first AC coefficient in the 8-coefficient set, the second subset includes the second AC coefficient in the same 8-coefficient set, and so on, with the 15th subset including the 15th AC coefficient in the same 8-coefficient set.
[0255] Building upon this foundation, different subsets can be encoded in parallel. For instance, some or all subsets of M subsets can be encoded in parallel. For example, when encoding the AC coefficients in the second subset, the encoder does not depend on the encoding of the first subset; that is, the second and first subsets can be encoded in parallel. Similarly, the third and second subsets can be encoded in parallel, the fourth and third subsets can be encoded in parallel, and so on.
[0256] When the encoder scans N sets of AC coefficients, the scanning order can be raster scan order, z-scan scan order, Zig-Zag scan order, etc., and there is no restriction on this scanning order. Figure 5F In this example, we take the raster scanning sequence.
[0257] The decoding end can decode to obtain a set of AC coefficient groups, and the set of AC coefficient groups includes 120 AC coefficients, based on... Figure 5F The AC coefficient scanning non-concatenation method shown in the diagram involves the decoder decoding a set of AC coefficients from N (e.g., 8) coding units. Each set of AC coefficients sequentially includes M subsets of AC coefficient sets, where M can be greater than 1. For example, the first subset of AC coefficient sets includes the AC coefficients at the first position of N coding units (e.g., 8 AC coefficients), the second subset includes the AC coefficients at the second position of N coding units, and so on, with the Mth subset including the AC coefficients at the Mth position of N coding units.
[0258] During the decoding of M subsets of AC coefficients, these subsets can be decoded in parallel. This means that some or all subsets of AC coefficients can be decoded in parallel. For example, when the decoding end decodes the AC coefficients within the second subset, it does not depend on the decoding of the first subset. That is, the second and first subsets of AC coefficients can be decoded in parallel. Similarly, the third and second subsets of AC coefficients can be decoded in parallel, and so on.
[0259] Based on this, when the decoder obtains the first subset of AC coefficient groups, it sequentially assigns the 8 AC coefficients within that subset to the AC coefficient groups of 8 coding units. Similarly, when the decoder obtains the second subset of AC coefficient groups, it assigns the same 8 AC coefficients to the AC coefficient groups of 8 coding units, and so on, until the AC coefficient groups of 8 coding units are obtained. These AC coefficients are then scanned into the AC coefficient blocks according to the raster scanning order, and finally... Figure 5F This method yields 8 AC coefficient blocks.
[0260] In one possible implementation, when the decoding end decodes the DC coefficient set of N coding units, if each coding unit includes a DC coefficient at one position, then the DC coefficient set can sequentially include the DC coefficients at the first position of the N coding units, see [link to relevant documentation]. Figure 5E and Figure 5F As shown. Alternatively, if each coding unit includes K DC coefficients at positions K, where K is greater than 1, then the set of DC coefficients can sequentially include all DC coefficients corresponding to the 1st coding unit, all DC coefficients corresponding to the 2nd coding unit, ..., all DC coefficients corresponding to the Nth coding unit. This case is similar to... Figure 5D The method for calculating AC coefficients is similar and will not be repeated here. Alternatively, if each coding unit includes DC coefficients at K positions, then the set of DC coefficients sequentially includes the DC coefficients at the 1st position of N coding units, the DC coefficients at the 2nd position of N coding units, ..., the DC coefficients at the Kth position of N coding units. This case is similar to... Figure 5E The AC coefficient is calculated in a similar way, or, in this case, it is similar to... Figure 5F The method for calculating the AC coefficients is similar and will not be repeated here.
[0261] In one possible implementation, for each coding unit, the encoding end can encode the original pixel of the coding unit, and the decoding end can decode the original pixel (quantized original pixel or unquantized original pixel) of the coding unit. Alternatively, the encoding end can encode the residual value of the coding unit, and the decoding end can decode the residual value (i.e., residual coefficient, quantized residual value or unquantized residual value) of the coding unit. Alternatively, the encoding end can encode the coefficient value of the coding unit, and the decoding end can decode the coefficient value (quantized final coefficient value or unquantized transform coefficient value, i.e., AC coefficient and DC coefficient in the above embodiment).
[0262] In this embodiment, at the encoding end, the information to be encoded is referred to as the coefficients to be encoded (such as original pixels, residual values, coefficient values, etc.), and at the decoding end, the information to be decoded is referred to as the coefficients to be decoded (such as original pixels, residual values, coefficient values, etc.). For example, if the coefficients to be decoded are coefficient values, then the decoding end needs to decode AC coefficients and DC coefficients. Based on this, when the decoding end decodes the AC coefficient set and DC coefficient set of N encoding units, it needs to decode multiple AC coefficients corresponding to each processing unit in the AC coefficient set and multiple DC coefficients corresponding to each processing unit in the DC coefficient set.
[0263] For example, an AC coefficient set can include at least one processing unit, and for each processing unit, that processing unit can include multiple AC coefficients. For instance, assuming a processing unit includes 4 AC coefficients, and the AC coefficient set includes 120 AC coefficients, the AC coefficient set can include 30 processing units, and decoding is performed separately for each processing unit.
[0264] For example, a DC coefficient set can include at least one processing unit, and for each processing unit, the processing unit can include multiple DC coefficients. For instance, assuming a processing unit includes 4 DC coefficients and the DC coefficient set includes 8 DC coefficients, the DC coefficient set can include 2 processing units, and decoding is performed separately for each processing unit.
[0265] The decoding process for the coefficients to be decoded (such as original pixels, residual values, coefficient values, etc.) is explained below.
[0266] For decoding method a of the coefficients to be decoded: Under decoding method a, the encoding end can use a semi-fixed-length encoding method to encode the coefficients to be encoded, and the decoding end can use a semi-fixed-length decoding method to decode the coefficients to be decoded.
[0267] For the encoding end, the coefficients to be encoded can be encoded using the following steps:
[0268] Step 1: Calculate the parameter to be encoded, which can be GroupType.
[0269] Assuming that a CL is calculated for every 4 coefficients to be encoded, that is, every 4 coefficients to be encoded form a processing unit, and the fixed-length code length of the CL includes the sign bit, then the GroupType corresponding to the processing unit group can be obtained. The processing unit group includes at least two processing units. The GroupType is used to indicate whether the processing units within the processing unit group use the same code length value.
[0270] For example, taking a processing unit group consisting of two processing units, each processing unit includes four coefficients to be encoded. See [link to relevant documentation]. Figure 6A The diagram illustrates the GroupType corresponding to a processing unit group. If GroupType is 0, it indicates that two processing units within the group use the same code length (i.e., the same CL). In this case, only one CL needs to be encoded for these two processing units. If GroupType is 1, it indicates that two processing units within the group use different code lengths (i.e., different CLs). In this case, two CLs need to be encoded for these two processing units. In summary, if two adjacent processing units (i.e., 4*1 coefficients to be encoded) have the same CL, then these two processing units are merged into one group.
[0271] For example, if the processing unit group includes three or more processing units, the implementation of GroupType is similar. For example, when GroupType is 00, it means that all processing units in the processing unit group use the same code length value. When GroupType is 01, it means that the first two processing units in the processing unit group use the same code length value. When GroupType is 10, it means that the last two processing units in the processing unit group use the same code length value. When GroupType is 11, it means that all processing units in the processing unit group use different code length values. Of course, the above are just examples of the implementation of GroupType and are not limited thereto.
[0272] Step 2: Write the GroupType corresponding to the processing unit group into the bitstream.
[0273] Step 3: Write the CL corresponding to the processing unit group according to GroupType.
[0274] For example, taking a processing unit group containing two processing units as an example, when GroupType equals 0, a unary code is written to CL0; if CL0 = 3, CL0 is written with 0001. In this case, both processing units within the processing unit group correspond to CL0.
[0275] When GroupType equals 1, unary code is first used to write CL0. For example, if CL0 = 3, CL0 is written as 0001. In this case, the first processing unit within the processing unit group corresponds to CL0. Furthermore, if CL1 is greater than or equal to CL0, unary code can be used to write CL1-1, where the value of "1" can be replaced with other values. Alternatively, unary code can be used to write CL1-CL0. If CL1 is less than CL0, unary code can be used to write CL1. For example, if CL0 = 3 and CL1 = 5, unary code is used to write CL1-1, such as CL1 being written as 00001. In this case, the second processing unit within the processing unit group corresponds to CL1.
[0276] Step 4: Write the coefficients to be encoded in each processing unit in the bitstream using fixed-length codes according to CL.
[0277] For example, when GroupType equals 0, for the four coefficients to be encoded in the first processing unit within the processing unit group, CL0 can be used to write these four coefficients into the bitstream. For the four coefficients to be encoded in the second processing unit within the processing unit group, CL0 can be used to write these four coefficients into the bitstream.
[0278] For example, when GroupType equals 1, for the four coefficients to be encoded in the first processing unit within the processing unit group, CL0 can be used to write these four coefficients into the bitstream, and for the four coefficients to be encoded in the second processing unit within the processing unit group, CL1 can be used to write these four coefficients into the bitstream.
[0279] Step 5: For each coefficient to be encoded, determine whether the coefficient is equal to a boundary extremum. Write the sign of the boundary extremum into the trailing of each group and end the bitstream writing. For example, the condition for determining the boundary extremum is: whether the absolute value of the coefficient to be encoded is equal to (1<<(CL-1)), where CL can be CL0 or CL1.
[0280] For the decoding end, the following steps can be used to decode the coefficients to be decoded:
[0281] Step 1: Decode the GroupType corresponding to the processing unit group. The processing unit group can include at least two processing units. The GroupType is used to indicate whether the processing units in the processing unit group use the same code length value.
[0282] For example, taking a processing unit group that includes two processing units, each processing unit includes 4 coefficients to be encoded. If GroupType is 0, it means that the two processing units in the processing unit group use the same code length value (i.e., the same CL). If GroupType is 1, it means that the two processing units in the processing unit group use different code length values.
[0283] Step 2: For the first processing unit in the processing unit group, decode the target code length value corresponding to that processing unit.
[0284] For example, when GroupType equals 0, unary code is used to decode CL0, and when GroupType equals 1, unary code is used to decode CL0. CL0 is the target code length value corresponding to the first processing unit in the processing unit group.
[0285] Step 3: For processing units that are not the first processing unit in the processing unit group, obtain the target code length value corresponding to that processing unit.
[0286] For example, if GroupType indicates that the processing unit uses the same code length value as the previous processing unit, then the target code length value corresponding to the previous processing unit is determined as the target code length value corresponding to this processing unit. For instance, when GroupType equals 0, it means that the processing unit uses the same code length value as the previous processing unit. Therefore, the target code length value CL0 corresponding to the previous processing unit is used as the target code length value corresponding to this processing unit, that is, the target code length value is CL0.
[0287] For example, if GroupType indicates that the processing unit uses a different code length value than the previous processing unit, then the initial code length value corresponding to the processing unit is decoded, and the target code length value corresponding to the processing unit is determined based on the initial code length value. For instance, if the target code length value corresponding to the processing unit is not less than the target code length value corresponding to the previous processing unit, then the sum of the initial code length value corresponding to the processing unit and the target code length value corresponding to the previous processing unit can be determined as the target code length value corresponding to the processing unit; or, the sum of the initial code length value corresponding to the processing unit and a fixed value (such as 1) can be determined as the target code length value corresponding to the processing unit; or, if the target code length value corresponding to the processing unit is less than the target code length value corresponding to the previous processing unit, then the initial code length value can be determined as the target code length value corresponding to the processing unit.
[0288] For example, when GroupType equals 1, it indicates that this processing unit uses a different code length value than the previous processing unit, and the initial code length value corresponding to this processing unit can be decoded from the bitstream. If the target code length value CL1 corresponding to this processing unit is not less than the target code length value CL0 corresponding to the previous processing unit, then the sum of the initial code length value and CL0 is taken as CL1; or the sum of the initial code length value and 1 is taken as the target code length value. If CL1 is less than CL0, then the initial code length value is taken as CL1.
[0289] Step 4: Decode the multiple coefficients to be decoded corresponding to the processing unit based on the target code length value corresponding to the processing unit. For example, the signed coefficients to be decoded within the processing unit can be decoded based on the CL value corresponding to the processing unit.
[0290] For example, for the four coefficients to be decoded in the first processing unit within a processing unit group, CL0 can be used to decode these four coefficients from the bitstream. Furthermore, for the four coefficients to be decoded in the second processing unit within a processing unit group, when GroupType equals 0, CL0 can be used to decode these four coefficients from the bitstream. When GroupType equals 1, CL1 can be used to decode these four coefficients from the bitstream.
[0291] For example, when there are boundary extrema in the coefficients to be decoded, each set of coefficients is parsed using a trailing method, and the sign of the boundary extrema is obtained by decoding based on the trailing method. The condition for determining the boundary extrema is: whether the coefficient to be decoded is equal to (1 << (CL-1)).
[0292] Here's an example of trailing: If the CL (Clearing Limit) within a processing unit is 3, then the signed coefficients to be decoded using fixed-length code are [0, 4, -1, 4]. Since 4 equals (1 << (3-1)), 4 is equal to the boundary extremum. Therefore, we further parse the trailing, and determine the sign of the boundary extremum based on the value of the trailing. If the value of the trailing is 0, then the sign of 4 is positive; if the value of the trailing is 1, then the sign of 4 is negative. If the trailing is 1, then the final coefficients to be decoded are [0, -4, -1, -4].
[0293] For example, see Table 2 for examples of CL values and trailing representation of the value range.
[0294] Table 2
[0295] CL value CL can represent the range (Trailing = 0). CL can represent the range (Trailing = 1). 0 (No Trailing) 0 0 1 0,1 -1,0 2 -1,0,1,2 -2,-1,0,1 3 -3,-2,-1,0,1,2,3,4 -4,-3,-2,-1,0,1,2,3 4 -7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8 -8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7 ... ... ...
[0296] For decoding method b of the coefficients to be decoded: Under decoding method b, the encoding end can use a semi-fixed-length encoding method to encode the coefficients to be encoded, and the decoding end can use a semi-fixed-length decoding method to decode the coefficients to be decoded.
[0297] For the encoding end, the coefficients to be encoded can be encoded using the following steps:
[0298] Step 1: Calculate the parameter to be encoded, which can be GroupType.
[0299] Assuming that a CL is calculated for every four coefficients to be encoded, meaning that every four coefficients form a processing unit, and the fixed-length code length of the CL does not include the sign bit, then the GroupType corresponding to the processing unit group can be obtained. The GroupType is used to indicate whether the processing units within the processing unit group use the same code length value. It should be noted that in decoding mode b, the fixed-length code length of the CL does not include the sign bit. Therefore, for each non-zero coefficient to be encoded, an additional sign (symbol) needs to be encoded.
[0300] For example, taking a processing unit group consisting of two processing units as an example, see [link to relevant documentation]. Figure 6A As shown, if GroupType is 0, it means that the two processing units use the same code length value; if GroupType is 1, it means that the two processing units use different code length values.
[0301] Step 2: Write the GroupType corresponding to the processing unit group into the bitstream.
[0302] Step 3: Write the CL corresponding to the processing unit group according to GroupType.
[0303] For example, when GroupType equals 0, unary code is used to write CL0. For example, when CL0 = 3, CL0 is written with 0001. When GroupType equals 1, unary code is first used to write CL0. If CL1 is greater than or equal to CL0, unary code can be used to write CL1-1. If CL1 is less than CL0, unary code can be used to write CL1. For example, when CL0 = 3 and CL1 = 5, CL1 is written with 00001.
[0304] Step 4: Write the coefficients to be encoded in each processing unit in the bitstream using fixed-length codes according to CL.
[0305] Step 5: For coefficients to be encoded that are not equal to 0, encode the sign of the coefficient and end the bitstream writing.
[0306] For the decoding end, the following steps can be used to decode the coefficients to be decoded:
[0307] Step 1: Decode the GroupType corresponding to the processing unit group. The processing unit group can include at least two processing units. The GroupType is used to indicate whether the processing units in the processing unit group use the same code length value.
[0308] Step 2: For the first processing unit in the processing unit group, decode the target code length value corresponding to that processing unit.
[0309] Step 3: For processing units that are not the first processing unit in the processing unit group, obtain the target code length value corresponding to that processing unit.
[0310] Step 4: Decode the multiple coefficients to be decoded corresponding to the processing unit based on the target code length value corresponding to the processing unit. For example, the unsigned coefficients to be decoded within the processing unit can be decoded based on the CL value corresponding to the processing unit. For example, when the decoded coefficient is 3, this coefficient may be +3 or -3.
[0311] Step 5: For all non-zero values (non-zero coefficients to be decoded) among all coefficients to be decoded, decode the sign corresponding to the coefficient to be decoded. This sign indicates whether it is positive or negative. Based on the coefficient to be decoded and the sign, obtain the final value of the coefficient to be decoded.
[0312] For decoding method c of the coefficients to be decoded: Under decoding method c, the encoding end encodes the coefficients to be encoded in segments and groups within the processing unit, and the decoding end decodes the coefficients to be decoded in segments and groups within the processing unit.
[0313] For the encoding end, the coefficients to be encoded can be encoded using the following steps:
[0314] Step 1: For each processing unit, iterate through all the coefficients to be encoded within that processing unit to obtain four types of parameters. These four types of parameters can be values greater than 0 (gt0), values greater than 1 (gt1), signs, and remainders.
[0315] gt0: For each coefficient to be encoded within a processing unit, if the coefficient is equal to 0, then the gt0 corresponding to that coefficient is equal to 0; if the coefficient is not equal to 0, then the gt0 corresponding to that coefficient is equal to 1. Clearly, each coefficient to be encoded corresponds to one gt0. gt0 is called the first flag bit, and the first flag bit is used to indicate whether the coefficient to be encoded is 0.
[0316] gt1: For each non-zero coefficient to be encoded (each coefficient to be encoded where gt0 equals 1), if the absolute value of the coefficient is equal to 1 (i.e., the coefficient is positive or negative 1), then the corresponding gt1 value is 0; if the absolute value of the coefficient is not equal to 1, then the corresponding gt1 value is 1. Clearly, each non-zero coefficient to be encoded corresponds to one gt1 value. gt1 is called the second flag bit, which indicates whether the absolute value of the coefficient to be encoded is 1.
[0317] sign: For each non-zero coefficient to be encoded, if the coefficient is positive, the sign corresponding to the coefficient is equal to 0; if the coefficient is negative, the sign corresponding to the coefficient is equal to 1. Obviously, each non-zero coefficient to be encoded corresponds to a sign (sign bit), and the sign bit is used to indicate whether the coefficient to be encoded is positive or negative.
[0318] remians: For each coefficient to be encoded whose absolute value is not 1 (for each coefficient to be encoded whose gt1 equals 1), the residual absolute value of the coefficient to be encoded can be determined. The residual absolute value of the coefficient represents the difference between the absolute value of the coefficient to be encoded and 2. That is, the value of the absolute value of the coefficient to be encoded minus 2 constitutes the remians.
[0319] Assume there are 8 coefficients to be encoded in the processing unit, as shown in Table 3, which lists 4 types of parameters for the 8 coefficients to be encoded.
[0320] Table 3
[0321] enter 0,3,-2,1,0,0,0,0 gt0 0,1,1,1,0,0,0,0 gt1 1,1,0 sign 1,0,1 remains 1,0
[0322] Step 2: Encode the gt0 of all coefficients to be encoded within the processing unit.
[0323] For example, based on the gt0 of all coefficients to be encoded within a processing unit, there are four cases, see [link to relevant documentation]. Figure 6B The diagram illustrates four possible cases for gt0 of all coefficients to be encoded. In the first case, it indicates that neither the first half of the coefficients to be encoded in the processing unit contains non-zero values, nor the second half contains non-zero values; this is represented by GroupType = 0. Therefore, only GroupType = 0 needs to be encoded in the bitstream; gt0 encoding is unnecessary.
[0324] In the second case, it indicates that the first half of the coefficients to be encoded in the processing unit contains non-zero values (i.e., at least one of the n / 2 coefficients is 1, i.e., gt0 is 1, where n represents the total number of coefficients in the processing unit), and the second half of the coefficients to be encoded in the processing unit does not contain non-zero values (i.e., all n / 2 coefficients are equal to 0, i.e., gt0 is 0). This case is represented by GroupType = 110. Based on this, GroupType = 110 needs to be encoded in the bitstream, and the gt0 of each coefficient to be encoded in the first half needs to be encoded in the bitstream.
[0325] In the third case, it indicates that there are no non-zero coefficients in the first half of the coefficients to be encoded in the processing unit, but there are non-zero coefficients in the second half of the coefficients to be encoded in the processing unit. This case is represented by GroupType=111. Based on this, GroupType=111 needs to be encoded in the bitstream, and the gt0 of each coefficient to be encoded in the second half needs to be encoded in the bitstream.
[0326] In the fourth case, it indicates that both the first half and the second half of the coefficients to be encoded in the processing unit contain non-zero values, represented by GroupType=10. In the bitstream, GroupType=10 is encoded, meaning the gt0 of each coefficient in the first half and the gt0 of each coefficient in the second half are encoded.
[0327] In summary, taking n=8 as an example, the code length of GroupType is equal to... Figure 6B The length of the 0 / 1 is determined by encoding the non-all-zero parts using 4 or 8 bits, i.e., gt0. See Table 3 for an example of encoding gt0.
[0328] Table 3
[0329] Encoding gt0 0,1,1,1,0,0,0,0 GroupType 1,1,0 Only the first half is a 1-bit fixed-length code. 0,1,1,1
[0330] Step 3: Based on the actual number of gt1 and sign, encode the actual values of gt1 and sign using a fixed-length code.
[0331] For example, for each non-zero coefficient to be encoded, if the absolute value of the coefficient is equal to 1, then the corresponding gt1 is equal to 0; if the absolute value of the coefficient is not equal to 1, then the corresponding gt1 is equal to 1. If the coefficient to be encoded is positive, then the corresponding sign is equal to 0; if the coefficient to be encoded is negative, then the corresponding sign is equal to 1. See Table 4 for examples of encoding gt1 and sign.
[0332] Table 4
[0333] GT1 fixed-length encoding 1,1,0 sign fixed-length encoding: 1,0,1
[0334] Step 4: Encode the value of remains using the zero-order exponent Golomb code.
[0335] For example, for each coefficient to be encoded whose absolute value is not 1, the residual absolute value of the coefficient to be encoded (remians) can be encoded in the bitstream. That is, the value of the absolute value of the coefficient to be encoded minus 2. Remians can be encoded using zero-order exponent Golomb or other encoding methods. See Table 5 for an example of zero-order exponent Golomb encoding.
[0336] Table 5
[0337] Typing CodeNum 1 0 010 1 011 2 00100 3 00101 4 00110 5 00111 6 0001000 7
[0338] For the decoding end, the following steps can be used to decode the coefficients to be decoded:
[0339] Step 1: For each processing unit, decode the gt0 (i.e., the first flag bit) corresponding to each coefficient to be decoded within that processing unit. The first flag bit is used to indicate whether the coefficient to be decoded is 0.
[0340] For example, the decoding end can first decode the GroupType corresponding to the processing unit.
[0341] If GroupType is used to indicate that there are no non-zero coefficients in the first half of the coefficients to be decoded in the processing unit and there are no non-zero coefficients in the second half of the coefficients to be decoded in the processing unit, if GroupType is 0, then the first flag bit corresponding to the coefficients to be decoded in the first half is derived based on GroupType (that is, the gt0 of the first n / 2 coefficients to be decoded is all 0), and the first flag bit corresponding to the coefficients to be decoded in the second half is derived based on GroupType (that is, the gt0 of the second n / 2 coefficients to be decoded is all 0).
[0342] If GroupType is used to indicate that there are no non-zero values in the first half of the coefficients to be decoded and there are non-zero values in the second half of the coefficients to be decoded, such as GroupType being 111, then the first flag bit corresponding to the first half of the coefficients to be decoded is derived based on GroupType (i.e., the gt0 of the first n / 2 coefficients to be decoded is all 0), and the first flag bit corresponding to the second half of the coefficients to be decoded is decoded from the bitstream. For example, if 1 is used to parse the gt0 of each of the last n / 2 coefficients to be decoded using a specific length code, the gt0 of the coefficients to be decoded may be 0 or 1.
[0343] If GroupType is used to indicate that there are non-zero values in the first half of the coefficients to be decoded and no non-zero values in the second half of the coefficients to be decoded, such as GroupType being 110, then the first flag bit corresponding to the coefficients to be decoded in the second half of the coefficients to be decoded is derived based on GroupType (that is, the gt0 of the coefficients to be decoded in the last n / 2 are all 0), and the first flag bit corresponding to the coefficients to be decoded in the first half of the coefficients to be decoded is decoded from the bitstream. For example, if a 1-to-a-specific-length code is used to parse the gt0 of each coefficient to be decoded in the first n / 2, the gt0 of the coefficient to be decoded may be 0 or it may be 1.
[0344] If GroupType indicates that both the first half and the second half of the coefficients to be decoded contain non-zero values, such as GroupType being 10, then the first flag bit corresponding to the first half of the coefficients to be decoded is decoded from the bitstream, and the first flag bit corresponding to the second half of the coefficients to be decoded is also decoded from the bitstream. For example, a 1:1 code of a specific length can be used to parse the gt0 of each of the first n / 2 coefficients to be decoded, and a 1:1 code of a specific length can be used to parse the gt0 of each of the last n / 2 coefficients to be decoded.
[0345] Step 2: For the non-zero coefficient to be decoded, decode the second flag bit and sign bit corresponding to the coefficient. The second flag bit is used to indicate whether the absolute value of the coefficient to be decoded is 1, and the sign bit is used to indicate whether the coefficient to be decoded is positive or negative.
[0346] For example, if there are m (m<=n) non-zero coefficients to be decoded in gt0, then the m values are parsed using a 1-to-specific-length code to obtain the values of the second flag bit (gt1) and sign bit (sign) of all non-zero coefficients to be decoded.
[0347] Step 3: For the coefficients to be decoded that are neither 0 nor 1, decode the coefficient remainder absolute value corresponding to the coefficient. The coefficient remainder absolute value represents the difference between the absolute value of the coefficient to be decoded and 2. For example, if there are k (k <= m) coefficients to be decoded that are greater than 1 in gt1, then use the 0th-order exponent Golomb to decode the k remainder values (coefficient remainder absolute values).
[0348] Step 4: Based on the first flag bit (gt0), the second flag bit (gt1), the remaining absolute value of the coefficients (remains), and the sign bit (sign), derive the multiple coefficients to be decoded corresponding to this processing unit, such as n coefficients to be decoded.
[0349] For example, based on the values of gt0, gt1, sign, and remains, n actual coefficients to be decoded are obtained. For instance, when gt0[i] equals 0, the coefficient at position i among the n coefficients to be decoded is equal to 0; otherwise, the coefficient at that position is not equal to 0. When gt1[j] equals 0, the absolute value of the coefficient at position j among all positions where gt0 equals 1 is equal to 1; otherwise, the coefficient at that position is not equal to 1. The absolute value of the coefficient at position k among all positions where gt1 equals 1 is equal to 2 + remains[k], where remains[k] represents the remaining absolute value of the coefficient at position k. When sign[j] equals 0, the sign of the coefficient at position j among all positions where gt0 equals 1 is positive; otherwise, the sign of the coefficient at that position is negative. Finally, n coefficients to be decoded can be obtained, as shown in Table 6.
[0350] Table 6
[0351]
[0352]
[0353] For decoding method d of the coefficients to be decoded: Under decoding method d, the encoding end encodes the coefficients to be encoded in segments and groups within the processing unit, and the decoding end decodes the coefficients to be decoded in segments and groups within the processing unit.
[0354] For the encoding end, the coefficients to be encoded can be encoded using the following steps:
[0355] Step 1: For each processing unit, encode the corresponding all-zero flag. This flag indicates whether all coefficients to be encoded within the unit are all zero. For example, if the flag is at its first value, it means all coefficients to be encoded within the unit are zero, and entropy encoding ends. If the flag is at its second value, it means not all coefficients to be encoded within the unit are zero, and the entropy encoding process continues, proceeding to Step 2.
[0356] Step 2: Traverse all the coefficients to be encoded within the processing unit to obtain four types of parameters. These four types of parameters can be values greater than 0 (gt0), values greater than 1 (gt1), signs, and remainders.
[0357] Step 3: Encode the gt0 of all coefficients to be encoded within the processing unit.
[0358] In one possible implementation, the first set of coefficient groups (such as the AC coefficient group set) can be divided into at least two parts of coefficients to be encoded, and the number of coefficients to be encoded in different parts can be the same or different; alternatively, the second set of coefficient groups (such as the DC coefficient group set) can be divided into at least two parts of coefficients to be encoded, and the number of coefficients to be encoded in different parts can be the same or different. In the following steps, the AC coefficient group set will be used as an example.
[0359] For example, see Figure 6C As shown, assuming the AC coefficient set includes 120 coefficients to be encoded, the 120 coefficients to be encoded are divided into two parts of coefficients to be encoded unequally. The first part of coefficients to be encoded (referred to as the first part) has 32 coefficients to be encoded, and the second part of coefficients to be encoded (referred to as the second part) has 88 coefficients to be encoded.
[0360] For each part of coefficients to be encoded, all coefficients in that part can be divided (equally or unequally) into m processing units, and each processing unit includes n coefficients to be encoded. For each processing unit, the encoder can use RDO to determine the value of n for that processing unit and write the value of n into the bitstream so that the decoder can know the value of n.
[0361] exist Figure 6C In the first part of the coefficients to be encoded, all coefficients can be divided into one processing unit, which includes 32 coefficients; or, all coefficients can be divided into four processing units, each including eight coefficients. For the second part of the coefficients to be encoded, all coefficients can be divided into two processing units, with the first unit including 32 coefficients and the second unit including 56 coefficients; or, all coefficients can be divided into eleven processing units, each including eight coefficients.
[0362] Clearly, for the first set of coefficients to be encoded, n can be either 8 or 32, indicating that there are 8 or 32 coefficients to be encoded within the processing unit. For the second set of coefficients to be encoded, n can also be either 8 or 32. When n is 32, since the coefficients to be encoded in the second processing unit are not divisible by 32, the non-divisible portion is directly merged with the previous 32 coefficients, meaning that the second processing unit contains 56 coefficients to be encoded.
[0363] In summary, a processing unit may contain 8 coefficients to be encoded, 32 coefficients to be encoded, or 56 coefficients to be encoded. The gt0 of all coefficients within a processing unit can be encoded. Of course, these are just a few examples of processing units, and there is no limit to the number of coefficients to be encoded within a processing unit.
[0364] Based on the gt0 of all coefficients to be encoded within the processing unit, there are four cases, see [link to relevant documentation]. Figure 6B The diagram illustrates four scenarios. In the first scenario, only GroupType=0 needs to be encoded in the bitstream; gt0 is not required. In the second scenario, GroupType=110 needs to be encoded in the bitstream, and gt0 for each coefficient to be encoded in the first half needs to be encoded. In the third scenario, GroupType=111 needs to be encoded in the bitstream, and gt0 for each coefficient to be encoded in the second half needs to be encoded. In the fourth scenario, GroupType=10 needs to be encoded in the bitstream, and gt0 for each coefficient to be encoded in the first half and the second half needs to be encoded.
[0365] Step 4: Encode the gt1 of all non-zero coefficients to be encoded.
[0366] For example, all non-zero coefficients to be encoded can be grouped. Assume all coefficients are divided into r groups, each containing w coefficients. The r groups are analogous to the m processing units in step three, and the w coefficients are analogous to the n coefficients within each processing unit. w can be 16 or 8, etc., without restriction. Taking 16 as an example, each group contains 16 coefficients. When grouping all coefficients, if the number of gt1 values is not divisible by 16, the non-divisible portion is merged with the previous group. For example, if there are 38 coefficients to be encoded, the first group contains 16 coefficients, and the second group contains 22 coefficients; the 22 coefficients are not split into two groups.
[0367] In summary, for each group, there may be 8 coefficients to be encoded, 16 coefficients to be encoded, or 22 coefficients to be encoded. The gt1 of all coefficients to be encoded in the group can be encoded.
[0368] Based on the gt1 of all the coefficients to be encoded within the group, there are four cases, namely: Figure 6B Taking the four cases shown as examples, of course, Figure 6BThese are just examples; the value of GroupType is not restricted. In the first case, it means that the gt1 values of the coefficients to be encoded in the first half of the group are all 0, and the gt1 values of the coefficients to be encoded in the second half of the group are all 0. In this case, GroupType = 0 needs to be encoded in the bitstream, and gt1 does not need to be encoded. In the second case, it means that the gt1 values of the coefficients to be encoded in the first half of the group are not all 0, and the gt1 values of the coefficients to be encoded in the second half of the group are all 0. In this case, GroupType = 110 needs to be encoded in the bitstream, and the gt1 values of each coefficient to be encoded in the first half need to be encoded in the bitstream. In the third case, it means that the gt1 values of the coefficients to be encoded in the first half of the group are all 0, and the gt1 values of the coefficients to be encoded in the second half of the group are not all 0. In this case, GroupType = 111 needs to be encoded in the bitstream, and the gt1 values of each coefficient to be encoded in the second half need to be encoded in the bitstream. In the fourth case, it means that the gt1 values of the coefficients to be encoded in the first half of the group are not all 0 and the gt1 values of the coefficients to be encoded in the second half of the group are not all 0. In this case, GroupType=10 needs to be encoded in the bitstream, the gt1 values of each coefficient to be encoded in the first half need to be encoded in the bitstream, and the gt1 values of each coefficient to be encoded in the second half need to be encoded in the bitstream.
[0369] Step 5: Based on the actual number of signs, encode the actual value of each sign using a fixed-length code.
[0370] Step 6: Encode the value of remains using the zero-order exponent Golomb code.
[0371] For the decoding end, the following steps can be used to decode the coefficients to be decoded:
[0372] Step 1: For each processing unit, decode the gt0 (i.e., the first flag bit) corresponding to each coefficient to be decoded within that processing unit. The first flag bit is used to indicate whether the coefficient to be decoded is 0.
[0373] For example, when dividing the AC coefficient set into at least two parts to be decoded, the number of coefficients to be decoded in different parts can be the same or different. For each part, all coefficients to be decoded can be divided (equally or unequally) into m processing units, and each processing unit includes n coefficients to be decoded. Based on this, the decoding end can obtain the value of m within the part to be decoded, that is, know that there are a total of m processing units. For example, the value of m can be parsed from the bitstream, or the value of m can be determined by a fixed division.
[0374] For each processing unit, the decoder can obtain the value of n within that unit, that is, it can determine that there are a total of n coefficients to be decoded in that unit. For example, the value of n can be parsed from the bitstream, or the value of n can be determined by a fixed division.
[0375] After obtaining the values of m and n, we can determine the number of processing units and the number of coefficients to be decoded within each processing unit. Thus, for each processing unit, we can decode the gt0 corresponding to each coefficient to be decoded within that processing unit.
[0376] For example, the decoder can first decode the GroupType corresponding to the processing unit. If GroupType is 0, then the gt0 of the first n / 2 coefficients to be decoded is 0, and the gt0 of the last n / 2 coefficients to be decoded is 0. If GroupType is 111, then the gt0 of the first n / 2 coefficients to be decoded is 0, and a 1-to-specific-length code is used to parse the gt0 of each of the last n / 2 coefficients to be decoded. If GroupType is 110, then the gt0 of the last n / 2 coefficients to be decoded is 0, and a 1-to-specific-length code is used to parse the gt0 of each of the first n / 2 coefficients to be decoded. If GroupType is 10, then a 1-to-specific-length code can be used to parse the gt0 of each of the first n / 2 coefficients to be decoded, and a 1-to-specific-length code can also be used to parse the gt0 of each of the last n / 2 coefficients to be decoded.
[0377] Step 2: For the non-zero coefficient to be decoded, decode the second flag bit (gt1) corresponding to the coefficient.
[0378] For example, if there are m (m <= n) non-zero coefficients to be decoded in gt0, these coefficients (m coefficients) are divided into r groups, and each group contains w coefficients to be decoded. Based on this, the decoder can obtain the value of m in r, that is, it knows that there are a total of r groups. For example, the value of r can be parsed from the bitstream, or the value of r can be determined by a fixed division. For each group, the decoder can obtain the value of w in that group, that is, it knows that there are a total of w coefficients to be decoded in that group. For example, the value of w can be parsed from the bitstream, or the value of w can be determined by a fixed division.
[0379] After obtaining the values of r and w, we can determine the r groups and the number of coefficients to be decoded in each group. Thus, for each group, the decoding end can decode the gt1 corresponding to each coefficient to be decoded in that group.
[0380] For example, the decoder can first decode the corresponding GroupType. If GroupType is 0, then the gt1 of the coefficients to be decoded in the first half (e.g., w / 2) is 0, and the gt1 of the coefficients to be decoded in the second half is also 0. If GroupType is 111, then the gt1 of the coefficients to be decoded in the first half is 0, and a 1-to-specific-length code is used to parse the gt1 of each coefficient to be decoded in the second half. If GroupType is 110, then the gt1 of the coefficients to be decoded in the second half is 0, and a 1-to-specific-length code is used to parse the gt1 of each coefficient to be decoded in the first half. If GroupType is 10, then a 1-to-specific-length code can be used to parse the gt1 of each coefficient to be decoded in the first half, and a 1-to-specific-length code can also be used to parse the gt1 of each coefficient to be decoded in the second half.
[0381] Step 3: For each non-zero coefficient to be decoded, decode its corresponding sign bit. The sign bit indicates whether the coefficient is positive or negative. For example, if there are m (m <= n) non-zero coefficients to be decoded in gt0, then use a 1-to-a-length code to parse the m values to obtain the sign bit (sign) of all non-zero coefficients.
[0382] Step 4: For the coefficients to be decoded that are neither 0 nor 1, decode the coefficient remainder absolute value corresponding to the coefficient. The coefficient remainder absolute value represents the difference between the absolute value of the coefficient and 2. For example, if there are k (k <= m) coefficients to be decoded that are greater than 1 in gt1, then use the 0th-order exponent Golomb to decode the k remainder values (coefficient remainder absolute values).
[0383] Step 5: Based on the first flag bit (gt0), the second flag bit (gt1), the remaining absolute value of the coefficients (remains), and the sign bit (sign), derive the multiple coefficients to be decoded corresponding to this processing unit, such as n coefficients to be decoded.
[0384] For decoding method e of the coefficients to be decoded: In decoding method e, the encoder needs to obtain the maximum absolute value of the coefficients to be decoded within the processing unit and encode the maximum absolute value of the coefficients in the bitstream. The decoder then decodes the maximum absolute value of the coefficients to be decoded corresponding to that processing unit. Based on this, the encoder can encode gt0, gt1, sign, and remains according to the maximum absolute value of the coefficients. The encoding method can be found in decoding methods c and d. The decoder can decode gt0, gt1, sign, and remains according to the maximum absolute value of the coefficients. The decoding method can be found in decoding methods c and d.
[0385] For example, see Table 7, which shows the reason for the maximum absolute value of the coding coefficient.
[0386] Table 7
[0387]
[0388] In summary, if the absolute value of the maximum coefficient is 0, the encoder can skip encoding. If the absolute value of the maximum coefficient is 1, the encoder can encode only gt0 and sign. If the absolute value of the maximum coefficient is 2, the encoder can encode only gt0, gt1, and sign. If the absolute value of the maximum coefficient is 3 (or greater than 3), the encoder needs to encode gt0, gt1, sign, and remainians. When encoding remainians, if there is only one remainian, then remains equals remains-1.
[0389] For the decoding end, it can decode the maximum absolute value of all coefficients to be decoded corresponding to this processing unit. If the maximum absolute value of the coefficient is 0, then it is deduced that each coefficient to be decoded corresponding to this processing unit is 0.
[0390] If the absolute value of the largest coefficient is 1, then the first flag bit (gt0) corresponding to each coefficient to be decoded is decoded. The first flag bit is used to indicate whether the coefficient to be decoded is 0. For coefficients to be decoded that are not 0, the sign bit corresponding to the coefficient to be decoded can also be decoded; based on the first flag bit and the sign bit, multiple coefficients to be decoded (0, 1, -1) corresponding to this processing unit are derived.
[0391] If the absolute value of the largest coefficient is 2, then decode the first flag bit corresponding to each coefficient to be decoded. The first flag bit is used to indicate whether the coefficient to be decoded is 0. For coefficients to be decoded that are not 0, decode the second flag bit and sign bit corresponding to that coefficient. The second flag bit is used to indicate whether the absolute value of the coefficient to be decoded is 1. Based on the first flag bit, the second flag bit, and the sign bit, derive the multiple coefficients to be decoded (0, 1, -1, 2, -2) corresponding to this processing unit.
[0392] If the absolute value of the largest coefficient is greater than 2, then the first flag (gt0) is set for each coefficient to be decoded within the decoding unit. This first flag indicates whether the coefficient to be decoded is 0. For coefficients that are not 0, the second flag (gt1) is decoded. For coefficients that are not 0, the sign bit (sign) is decoded. For coefficients that are neither 0 nor 1, the remaining absolute value (remains) is decoded, representing the difference between the absolute value of the coefficient and 2. Based on the first flag (gt0), the second flag (gt1), the remaining absolute value (remains), and the sign bit (sign), multiple coefficients to be decoded corresponding to this processing unit are derived. The above decoding process can be found in decoding methods c and d, and will not be repeated here.
[0393] For decoding method f of the coefficients to be decoded: Under decoding method f, for gt0, gt1, sign, and remians in decoding methods c, d, and e, since gt0, gt1, and remians only contain 0 / 1 values, we can choose to use fixed-length encoding (fixed 1:1), semi-fixed-length encoding based on fixed blocks, or run-length encoding. For remians, we can use zero-order exponential Golomb encoding, k-order exponential Golomb encoding (the value of k can be agreed upon by the encoder and decoder, or written into the bitstream by the encoder and transmitted to the decoder), Golomb-Rice encoding, or unary code encoding. Of course, the above are just a few examples of encoding methods and are not restrictive.
[0394] For the CL (CL in semi-fixed-length blocks) in decoding methods a and b, unary codes can be used to encode the CL. Alternatively, truncated unary codes (with the truncated value agreed upon by the encoder and decoder, or determined by the image bit width) can be used. A mixture of fixed-length codes and truncated unary codes can also be used to encode the CL. Huffman coding can also be used, encoding and decoding the CL value according to a code table.
[0395] Combining decoding methods a through e, select either a semi-fixed-length encoding scheme or a segmented block encoding scheme, and write the selection result into the bitstream. The decoding end selects a decoding scheme based on the parsed result.
[0396] For example, the encoding end can select a semi-fixed-length encoding scheme of decoding method a, write the information of decoding method a into the bit stream, and the decoding end can parse the information of decoding method a and use decoding method a to perform decoding.
[0397] Alternatively, the encoding end can select the segmented block encoding scheme of decoding method c, write the information of decoding method c into the bit stream, and the decoding end can parse the information of decoding method c and perform decoding using the decoding method c.
[0398] Exemplarily, the unary code is a binarization method. For a non-negative integer N, its unary code representation is N 1s followed by 1 zero. The truncated unary code is a variant of the unary code. When the maximum value Nmax of the symbol to be encoded is known, assuming that the current symbol to be encoded is a non-negative integer N, if N < Nmax, the truncated unary code is the unary code, and if N = Nmax, the truncated unary code is N 1s. The k-th order exponential Golomb code consists of a prefix and a suffix. The encoding method of the k-th order exponential Golomb code is as follows: write the number X in binary form, remove the lowest k bits, and then add 1 to obtain T. Then, calculate the number of bits of T, and pad T-1 zeros in front. Pad the removed lowest k bits back to the tail of the bit string.
[0399] For the truncated binary code, the related variables of val (stage, num0, num1 and thd) are calculated. For 0 ~ (thd-1), the binary symbol string is a fixed-length code with a length of stage. For thd ~ val, the binary symbol string is a fixed-length code with a length of (stage+1). For run-length encoding, the number of consecutive occurrences of each value is recorded as the encoded value. For example: 0001110011010100001100, the output after compression is: 33221111422. For Huffman coding, the occurrence frequency of all coefficients is counted, a Huffman tree is constructed, shorter codewords are assigned to coefficients with higher probability, and longer codewords are assigned to coefficients with lower probability.
[0400] For truncated Rice binarization, the truncated Rice code includes two parts: a prefix and a suffix. Given the maximum upper limit value cMax and the Rice parameter cRice, the symbol cVal to be encoded is encoded as follows: calculate the prefix: prefix = cVal >> cRice, and binarize the prefix using the truncated unary code with cMax >> cRice as the upper limit. Then 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 that when cRice = 0, the truncated Rice code is actually the truncated unary code.
[0401] For the decoding mode g of the coefficient to be decoded: under the decoding mode g, in addition to the modes of gt0, gt1, sign and remains, the mode of gtn, sign and remains can also be adopted, where n is greater than or equal to 2, and gtn is taken as gt2 as an example.
[0402] For the encoding end, `gt2` indicates that all coefficients greater than 2 are marked as 3(n+1), and the remaining positions are marked with the absolute value of the coefficients to be encoded. `remians` indicates that the absolute value of all coefficients greater than 2 is reduced by 3(n+1). `sign` indicates the sign of all non-zero positions of the coefficients to be encoded. For example, `gt2`, `sign`, and `remians` can be found in Table 8.
[0403] Table 8
[0404] enter [-8,-6,-4,-2,-1,0,1,2,4,6,8] gt2 [3,3,3,2,1,0,1,2,3,3,3] remians [5,3,1,1,3,5] sign [0,0,0,0,0,1,1,1,1,1]
[0405] First, the gt2 of all coefficients to be encoded is encoded. The number of gt2 is the same as the number of coefficients to be encoded, that is, each coefficient to be encoded corresponds to one gt2. Therefore, both the encoding end and the decoding end can know the number of gt2.
[0406] When encoding gt2, all gt2 data points can be grouped. For each group (e.g., a processing unit), the gt2 data points within that group can be encoded using semi-fixed-length coding, truncated unary coding, or Huffman coding. When using Huffman coding, the encoder and decoder can agree on a code table, or the encoder can transmit the code table to the decoder.
[0407] When grouping all gt2 values, there are no restrictions on whether the groups are of fixed length, variable length, or other methods. For example, the encoder and decoder can pre-agree on the grouping method, or the encoder can encode the group_type to represent the grouping method.
[0408] Then, the sign (symbol) of all coefficients to be encoded is encoded. For example, a 1-bit fixed-length encoding method can be used to encode the sign of all coefficients to be encoded. Alternatively, the sign of all coefficients to be encoded can be grouped and the sign in each group can be encoded. The encoding method of the sign in each group can be seen in Table 9.
[0409] Table 9
[0410] Within-group coefficients Specific code All zeros (2 bits) 00 All 1s (2 bits) 01 It can be either 0 or 1 (1+mbit). 1 + (m specific values)
[0411] Then, for remians, exponential Columbus or other entropy encoding methods can be used.
[0412] For the decoding end, the third flag bit (e.g., gtn) corresponding to each coefficient to be decoded within the processing unit (i.e., group) can be decoded. For each coefficient to be decoded, if the absolute value of the coefficient to be decoded is greater than n, then the third flag bit corresponding to the coefficient to be decoded can be n+1; if the absolute value of the coefficient to be decoded is not greater than n, then the third flag bit corresponding to the coefficient to be decoded is the absolute value of the coefficient to be decoded, where n can be a positive integer greater than 1. For example, referring to Table 8, taking n as 2, if the absolute value of the coefficient to be decoded "-8" is greater than 2, then gt2 is 3; if the absolute value of the coefficient to be decoded "-2" is not greater than 2, then gt2 is 2.
[0413] For example, for each processing unit (i.e. each group), the specific value of each gt2 within the group can be parsed. The decoding method can be semi-fixed-length decoding, truncated unary code decoding, Huffman decoding, etc., without any restrictions.
[0414] For coefficients whose third flag is not 0, decode the sign bit corresponding to the coefficient. For example, use a 1-bit fixed-length code to parse the sign bit of the coefficient, or parse the sign bit of the coefficient in groups. For each group: use a 1-bit fixed-length code to parse whether there are two types of symbols in the current group. If so, use a 1-bit fixed-length code to parse the symbols of all m coefficients. Otherwise, use a 1-bit fixed-length code to parse the symbols of all coefficients in the current group, where 0 represents all negative and 1 represents all positive.
[0415] For a coefficient to be decoded with the third flag bit set to n+1 (such as a coefficient equal to 3 in gt2), the residual absolute value of the coefficient can also be decoded. The residual absolute value represents the difference between the absolute value of the coefficient and (n+1). For example, the residual absolute value of the coefficient can be decoded using exponential Golomb or other entropy decoding methods.
[0416] Based on this, multiple coefficients to be decoded corresponding to the processing unit (group) can be derived using the third flag bit, the sign bit, and the residual absolute value of the coefficients. For example, for a position in gt2 that is less than 3, the coefficient to be decoded at that position can be derived based on the value at that position and the sign bit. If the value at that position is 2 and the sign bit indicates a negative value, then the coefficient to be decoded is -2.
[0417] For the k-th position among all positions equal to 3 in gt2, the absolute value of the coefficient to be decoded at that position is equal to 3 + remains[k]. For the j-th position among all non-zero positions in gt2, the sign of the coefficient to be decoded at that position is equal to the sign of sign[j]. In this way, the coefficient to be decoded can be obtained from the absolute value and the sign of the coefficient.
[0418] For the decoding method h of the coefficients to be decoded: In decoding method h, in addition to gt0, gt1, sign and remains, gtn and remains can also be used, where n is greater than or equal to 2. Taking gtn as gt2 as an example.
[0419] For the encoding end, `gt2` indicates that all coefficients greater than 2 are marked as 3(n+1)*, and the remaining positions are marked with the value of the coefficient to be encoded. `remians` indicates that the absolute value of all coefficients greater than 2 is reduced by 3(n+1). The decoding method `h` does not involve `sign`; `gt2` represents the sign of all non-zero positions of the coefficients to be encoded. `gt2` and `remians` are shown in Table 10.
[0420] Table 10
[0421] enter [-8,-6,-4,-2,-1,0,1,2,4,6,8] gt2 [-3,-3,-3,-2,-1,0,1,2,3,3,3] remians [5,3,1,1,3,5]
[0422] First, the gt2 of all coefficients to be encoded is encoded. When encoding gt2, all gt2 values can be grouped. For each group (e.g., a processing unit), the gt2 values within that group can be encoded using semi-fixed-length encoding, truncated unary code encoding, or Huffman coding. When encoding gt2, the sign of the coefficients to be encoded also needs to be encoded. For example, if the coefficient to be encoded is -8, then gt2 is -3; if the coefficient to be encoded is 8, then gt2 is 3.
[0423] Then, for remians, exponential Columbus or other entropy encoding methods can be used.
[0424] For the decoding end, the fourth flag bit (e.g., gtn) corresponding to each coefficient to be decoded within the decoding processing unit (i.e., group) can be decoded. For each coefficient to be decoded, if the absolute value of the coefficient to be decoded is greater than n, then the fourth flag bit corresponding to the coefficient to be decoded is (n+1) or -(n+1), such as 3 or -3, that is, the fourth flag bit can reflect the sign of the coefficient to be decoded. If the absolute value of the coefficient to be decoded is not greater than n, then the fourth flag bit corresponding to the coefficient to be decoded is the value of the coefficient to be decoded. For example, if the coefficient to be decoded is -2, then the fourth flag bit corresponding to the coefficient to be decoded is -2. n can be a positive integer greater than 1.
[0425] For a coefficient to be decoded whose fourth flag is (n+1) or -(n+1) (such as a coefficient to be decoded equal to 3 or -3 in gt2), the residual absolute value of the coefficient can also be decoded. The residual absolute value of the coefficient represents the difference between the absolute value of the coefficient to be decoded and (n+1). For example, the residual absolute value of the coefficient to be decoded can be decoded using Exponential Columbus.
[0426] Based on this, multiple coefficients to be decoded corresponding to this processing unit can be derived using the fourth flag bit and the remaining absolute value of the coefficients. For example, for positions in gt2 that are less than 3, the coefficient to be decoded at that position can be derived based on the value at that position. If the value at that position is 2, then the coefficient to be decoded is 2; if the value at that position is -2, then the coefficient to be decoded is -2.
[0427] For the k-th position among all positions in gt2 that equal 3, the coefficient to be decoded at the k-th position is equal to 3 + remains[k], where remains[k] represents the absolute value of the remaining coefficient at the k-th position. Furthermore, for the k-th position among all positions in gt2 that equal -3, the coefficient to be decoded at the k-th position is equal to -(3 + remains[k]).
[0428] In one possible implementation, one or a combination of decoding methods from decoding method a to decoding method h can be selected based on different prediction modes. Any scanning scheme can be selected based on different prediction modes.
[0429] As can be seen from the above technical solutions, in this embodiment, the encoding algorithm has low complexity and requires fewer resources when encoding coefficient values, and the decoding algorithm has low complexity and requires fewer resources when decoding coefficient values. It can propose low-complexity and efficient data encoding and decoding methods, achieving high-performance data compression for various types of data, improving encoding and decoding performance, and reducing the complexity of encoding and decoding algorithms. In this embodiment, multiple fixed grouping patterns and multiple intra-block scanning methods can be designed. For coefficient encoding, different encoding methods are selected according to the size of the coefficient value, and an efficient and low-cost entropy encoding / decoding scheme is designed for near-lossless compression.
[0430] Based on the same application concept as the above method, this application also proposes an image decoding device, which is applied to a decoding end. The image decoding device includes: a memory configured to store video data; and a decoder configured to implement the image decoding method of the above embodiment, i.e., the processing flow of the decoding end.
[0431] Based on the same application concept as the above method, this application also proposes an image encoding device, which is applied to the encoding end. The device includes: a memory configured to store video data; and an encoder configured to implement the image encoding method of the above embodiment, i.e., the processing flow of the encoding end.
[0432] Based on the same concept as the above method, the decoding device (video decoder) provided in this application embodiment, from a hardware perspective, its hardware architecture diagram can be found in [reference needed]. Figure 7A As shown, it includes: a processor 701 and a machine-readable storage medium 702, the machine-readable storage medium 702 storing machine-executable instructions that can be executed by the processor 701; the processor 701 is used to execute the machine-executable instructions to implement the image decoding method of the above embodiments of this application.
[0433] Based on the same concept as the above method, the encoding end device (video encoder) provided in this application embodiment, from a hardware perspective, its hardware architecture diagram can be found in [reference needed]. Figure 7B As shown, it includes: a processor 711 and a machine-readable storage medium 712, the machine-readable storage medium 712 storing machine-executable instructions that can be executed by the processor 711; the processor 711 is used to execute the machine-executable instructions to implement the image encoding method of the above embodiments of this application.
[0434] Based on the same application concept as the above methods, embodiments of this application also provide a machine-readable storage medium storing a plurality of computer instructions. When the computer instructions are executed by a processor, they can implement the methods disclosed in the above examples of this application, such as the image decoding method or image encoding method in the above embodiments.
[0435] Based on the same application concept as the above method, this application embodiment also provides a computer application that, when executed by a processor, can implement the image decoding method or image encoding method disclosed in the above examples.
[0436] Based on the same application concept as the above method, this application also proposes an image decoding device, which can be applied to a decoding end. The image decoding device may include: a decoding module, used to decode a first coefficient block and a second coefficient block for each coefficient unit to be decoded; and a processing module, used to concatenate the first coefficient block and the second coefficient block into a target coefficient block for the coefficient unit to be decoded; wherein the first coefficient block includes first-type coefficients that are located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients that are located later in the target coefficient block; wherein the first-type coefficients are parsed from the first coefficient group set of the largest coding unit, and the second-type coefficients are parsed from the second coefficient group set of the largest coding unit; the largest coding unit includes N coefficient units to be decoded, where N is greater than 1, and the coefficient unit to be decoded is any one of the N coefficient units to be decoded.
[0437] For example, when the decoding module decodes the first coefficient block of the coefficient unit to be decoded, it is specifically used for:
[0438] The first coefficient group of the coefficient unit to be decoded is obtained by scanning the first coefficient group set of the largest coding unit based on the unit scanning order; wherein, the unit scanning order is used to indicate the arrangement order of the N coefficient units to be decoded;
[0439] Based on the first scanning order corresponding to the coefficient unit to be decoded, all first-type coefficients in the first coefficient group are scanned to obtain the first coefficient block of the coefficient unit to be decoded; wherein, the first scanning order is used to indicate which pixel position of each first-type coefficient in the first coefficient group is in the first coefficient block.
[0440] For example, when the decoding module decodes the second coefficient block of the coefficient unit to be decoded, it is specifically used for:
[0441] The second coefficient set of the largest coding unit is scanned based on the unit scanning order to obtain the second coefficient set of the coefficient unit to be decoded; wherein, the unit scanning order is used to indicate the arrangement order of the N coefficient units to be decoded;
[0442] If the second coefficient group includes a second type coefficient, then the second coefficient block of the coefficient unit to be decoded is obtained based on the second type coefficient, and the second coefficient block includes the second type coefficient; or, if the second coefficient group includes multiple second type coefficients, then all second type coefficients in the second coefficient group are scanned based on the second scanning order corresponding to the coefficient unit to be decoded to obtain the second coefficient block of the coefficient unit to be decoded; wherein, the second scanning order is used to indicate which pixel position of each second type coefficient in the second coefficient group is in the second coefficient block.
[0443] For example, the decoding module is further configured to obtain a first set of coefficient groups of the maximum coding unit by decoding the bitstream of the maximum coding unit; and to obtain a second set of coefficient groups of the maximum coding unit by decoding the bitstream of the maximum coding unit.
[0444] For example, for the first set of coefficients of the largest coding unit,
[0445] The first set of coefficients sequentially includes all first-type coefficients corresponding to the first coefficient unit to be decoded, all first-type coefficients corresponding to the second coefficient unit to be decoded, ..., all first-type coefficients corresponding to the Nth coefficient unit to be decoded;
[0446] Alternatively, the first set of coefficients may sequentially include the first type coefficient at the first position of the N coefficient units to be decoded, the first type coefficient at the second position of the N coefficient units to be decoded, ..., the first type coefficient at the Mth position of the N coefficient units to be decoded; wherein each coefficient unit to be decoded includes M first type coefficients at M positions, where M is greater than 1;
[0447] Alternatively, the first set of coefficient groups includes M subsets of first coefficient groups, the first subset of first coefficient groups includes the first type coefficient at the first position of the N coefficient units to be decoded, the second subset of first coefficient groups includes the first type coefficient at the second position of the N coefficient units to be decoded, ..., the Mth subset of first coefficient groups includes the first type coefficient at the Mth position of the N coefficient units to be decoded; wherein, the M subsets of first coefficient groups are decoded in parallel.
[0448] For example, for the second set of coefficients of the largest coding unit,
[0449] If each coefficient unit to be decoded includes a second-type coefficient at one position, then the second coefficient set sequentially includes the second-type coefficient at the first position of the N coefficient units to be decoded; or,
[0450] If each coefficient unit to be decoded includes K positions of second-type coefficients, where K is greater than 1, the second coefficient set sequentially includes all second-type coefficients corresponding to the first coefficient unit to be decoded, all second-type coefficients corresponding to the second coefficient unit to be decoded, ..., all second-type coefficients corresponding to the Nth coefficient unit to be decoded; or, the second coefficient set sequentially includes the second-type coefficient at the first position of the N coefficient units to be decoded, ..., the second-type coefficient at the Kth position of the N coefficient units to be decoded.
[0451] For example, the decoding module is further configured to obtain the first scanning order corresponding to the coefficient unit to be decoded by decoding the bitstream; wherein the first scanning order is a raster scanning order or a z-scan scanning order.
[0452] For example, when the decoding module decodes the first coefficient block and the second coefficient block of the coefficient unit to be decoded, it is specifically used for:
[0453] Decode multiple first-type coefficients corresponding to each processing unit within the first coefficient set of the largest coding unit; wherein, the first coefficient set includes at least one processing unit, and each processing unit includes multiple first-type coefficients;
[0454] Decode multiple second-type coefficients corresponding to each processing unit within the second coefficient set of the largest coding unit; wherein the second coefficient set includes at least one processing unit, and each processing unit includes multiple second-type coefficients.
[0455] Based on the same application concept as the above method, this application also proposes an image encoding device, which can be applied to an encoding end. The device may include: a determining module, used for determining a target coefficient block for each coefficient unit to be encoded based on the original value of the coefficient unit to be encoded, and determining a first coefficient block and a second coefficient block for the coefficient unit to be encoded based on the target coefficient block; wherein the first coefficient block includes first-type coefficients that are located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients that are located later in the target coefficient block; and an encoding module, used to encode a first coefficient set and a second coefficient set of the largest encoding unit; wherein the largest encoding unit includes N coefficient units to be encoded, where N is greater than 1, and the coefficient unit to be encoded is any one of the N coefficient units to be encoded; wherein the first coefficient set includes first-type coefficients within the first coefficient block of the N coefficient units to be encoded, and the second coefficient set includes second-type coefficients within the second coefficient block of the N coefficient units to be encoded.
[0456] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. An image decoding method, characterized in that, The method includes: For each coefficient unit to be decoded, decode the first coefficient block and the second coefficient block of that coefficient unit; The first coefficient block and the second coefficient block are concatenated to form the target coefficient block of the coefficient unit to be decoded; Wherein, the first coefficient block includes the first type of coefficients that are located at the beginning of the target coefficient block, and the second coefficient block includes the second type of coefficients that are located at the end of the target coefficient block; Wherein, the first type of coefficients is parsed from the first set of coefficient groups of the maximum coding unit, and the second type of coefficients is parsed from the second set of coefficient groups of the maximum coding unit; the maximum coding unit includes N coefficient units to be decoded, where N is greater than 1, and the coefficient unit to be decoded is any one of the N coefficient units to be decoded.
2. The method according to claim 1, characterized in that, The first coefficient block for decoding the coefficient unit to be decoded includes: The first coefficient group of the coefficient unit to be decoded is obtained by scanning the first coefficient group set of the largest coding unit based on the unit scanning order; wherein, the unit scanning order is used to indicate the arrangement order of the N coefficient units to be decoded; Based on the first scanning order corresponding to the coefficient unit to be decoded, all first-type coefficients in the first coefficient group are scanned to obtain the first coefficient block of the coefficient unit to be decoded; wherein, the first scanning order is used to indicate which pixel position of each first-type coefficient in the first coefficient group is in the first coefficient block.
3. The method according to claim 1, characterized in that, The second coefficient block for decoding the coefficient unit to be decoded includes: The second coefficient set of the largest coding unit is scanned based on the unit scanning order to obtain the second coefficient set of the coefficient unit to be decoded; wherein, the unit scanning order is used to indicate the arrangement order of the N coefficient units to be decoded; If the second coefficient group includes a second type coefficient, then the second coefficient block of the coefficient unit to be decoded is obtained based on the second type coefficient, and the second coefficient block includes the second type coefficient; or, if the second coefficient group includes multiple second type coefficients, then all second type coefficients in the second coefficient group are scanned based on the second scanning order corresponding to the coefficient unit to be decoded to obtain the second coefficient block of the coefficient unit to be decoded; wherein, the second scanning order is used to indicate which pixel position of each second type coefficient in the second coefficient group is in the second coefficient block.
4. The method according to claim 2 or 3, characterized in that, The method further includes: By decoding the bitstream of the maximum coding unit, a first set of coefficients for the maximum coding unit is obtained; By decoding the bitstream of the maximum coding unit, a second set of coefficients for the maximum coding unit is obtained.
5. The method according to any one of claims 1-3, characterized in that, For the first set of coefficients of the largest coding unit, The first set of coefficients sequentially includes all first-type coefficients corresponding to the first coefficient unit to be decoded, all first-type coefficients corresponding to the second coefficient unit to be decoded, ..., all first-type coefficients corresponding to the Nth coefficient unit to be decoded; Alternatively, the first set of coefficients may sequentially include the first type coefficient at the first position of the N coefficient units to be decoded, the first type coefficient at the second position of the N coefficient units to be decoded, ..., the first type coefficient at the Mth position of the N coefficient units to be decoded; wherein each coefficient unit to be decoded includes M first type coefficients at M positions, where M is greater than 1; Alternatively, the first set of coefficient groups includes M subsets of first coefficient groups, the first subset of first coefficient groups includes the first type coefficient at the first position of the N coefficient units to be decoded, the second subset of first coefficient groups includes the first type coefficient at the second position of the N coefficient units to be decoded, ..., the Mth subset of first coefficient groups includes the first type coefficient at the Mth position of the N coefficient units to be decoded; wherein, the M subsets of first coefficient groups are decoded in parallel.
6. The method according to any one of claims 1-3, characterized in that, For the second set of coefficients of the largest coding unit, If each coefficient unit to be decoded includes a second-type coefficient at one position, then the second coefficient set sequentially includes the second-type coefficient at the first position of the N coefficient units to be decoded; or, If each coefficient unit to be decoded includes K positions of second-type coefficients, where K is greater than 1, the second coefficient set sequentially includes all second-type coefficients corresponding to the first coefficient unit to be decoded, all second-type coefficients corresponding to the second coefficient unit to be decoded, ..., all second-type coefficients corresponding to the Nth coefficient unit to be decoded; or, the second coefficient set sequentially includes the second-type coefficient at the first position of the N coefficient units to be decoded, ..., the second-type coefficient at the Kth position of the N coefficient units to be decoded.
7. The method according to claim 2, characterized in that, The first scan order corresponding to different coefficient units to be decoded is the same, or the first scan order corresponding to different coefficient units to be decoded is different; wherein, for each coefficient unit to be decoded, the first scan order corresponding to that coefficient unit includes any of the following: Raster scanning sequence; z-scan scanning sequence; Zig-Zag scanning sequence; block scanning sequence; horizontal scanning sequence; vertical scanning sequence; horizontal reciprocating scanning sequence; vertical reciprocating scanning sequence; diagonal scanning sequence; reverse diagonal scanning sequence; reverse horizontal scanning sequence; reverse vertical scanning sequence; scanning sequence based on a fixed scanning template.
8. The method according to claim 2, characterized in that, Before scanning all first-type coefficients within the first coefficient group based on the first scanning order corresponding to the coefficient unit to be decoded, the method further includes: The first scanning order corresponding to the coefficient unit to be decoded is obtained by decoding the bitstream; The first scanning order is either a raster scanning order or a z-scan scanning order.
9. The method according to any one of claims 1-8, characterized in that, The first coefficient block includes an AC coefficient block, and the first type of coefficients includes transformed AC coefficients, wherein the AC coefficients are high-frequency coefficients within the AC coefficient block; the second coefficient block includes a DC coefficient block, and the second type of coefficients includes transformed DC coefficients, wherein the DC coefficients are low-frequency coefficients within the DC coefficient block.
10. The method according to any one of claims 1-8, characterized in that, The decoding of the first coefficient block and the second coefficient block of the coefficient unit to be decoded includes: Decode multiple first-type coefficients corresponding to each processing unit within the first coefficient set of the largest coding unit; wherein, the first coefficient set includes at least one processing unit, and each processing unit includes multiple first-type coefficients; Decode multiple second-type coefficients corresponding to each processing unit within the second coefficient set of the largest coding unit; wherein the second coefficient set includes at least one processing unit, and each processing unit includes multiple second-type coefficients.
11. The method according to claim 10, characterized in that, The coefficients to be decoded are either type I or type II coefficients. The decoding methods for multiple coefficients corresponding to this processing unit include: The GroupType corresponding to the decoding processing unit group; wherein, the processing unit group includes at least two processing units, and the GroupType is used to indicate whether the processing units within the processing unit group use the same code length value; For the first processing unit within the processing unit group, decode the target code length value corresponding to that processing unit; For a non-first processing unit within the processing unit group, if the GroupType indicates that the processing unit uses the same code length value as the previous processing unit, then the target code length value corresponding to the previous processing unit is determined as the target code length value corresponding to this processing unit; if the GroupType indicates that the processing unit uses a different code length value than the previous processing unit, then the initial code length value corresponding to the processing unit is decoded, and the target code length value corresponding to the processing unit is determined based on the initial code length value. Based on the target code length value, decode the multiple coefficients to be decoded corresponding to the processing unit.
12. The method according to claim 11, characterized in that, Determining the target code length value corresponding to the processing unit based on the initial code length value includes: If the target code length value corresponding to the processing unit is not less than the target code length value corresponding to the previous processing unit, then the sum of the initial code length value and the target code length value corresponding to the previous processing unit is determined as the target code length value corresponding to the processing unit; or, the sum of the initial code length value and a fixed value is determined as the target code length value corresponding to the processing unit. Alternatively, if the target code length value corresponding to the processing unit is less than the target code length value corresponding to the previous processing unit, then the initial code length value is determined as the target code length value corresponding to the processing unit.
13. The method according to claim 10, characterized in that, The coefficients to be decoded are either type I or type II coefficients. The decoding methods for multiple coefficients corresponding to this processing unit include: Decode the first flag bit corresponding to each coefficient to be decoded. The first flag bit is used to indicate whether the coefficient to be decoded is 0. For a non-zero coefficient to be decoded, the second flag bit and sign bit corresponding to the coefficient to be decoded are decoded. The second flag bit is used to indicate whether the absolute value of the coefficient to be decoded is 1, and the sign bit is used to indicate whether the coefficient to be decoded is positive or negative. For a coefficient to be decoded that is neither 0 nor 1, decode the residual absolute value of the coefficient to be decoded, where the residual absolute value of the coefficient to be decoded represents the difference between the absolute value of the coefficient to be decoded and 2. Based on the first flag bit, the second flag bit, the remaining absolute value of the coefficient, and the sign bit, the multiple coefficients to be decoded corresponding to the processing unit are derived.
14. The method according to claim 13, characterized in that, The decoding of the first flag bit corresponding to each coefficient to be decoded includes: Decode the GroupType corresponding to this processing unit; If the GroupType is used to indicate that there are no non-zero coefficients in the first half of the coefficients to be decoded in the processing unit and there are no non-zero coefficients in the second half of the coefficients to be decoded in the processing unit, then the first flag bit corresponding to the first half of the coefficients to be decoded is derived based on the GroupType, and the first flag bit corresponding to the second half of the coefficients to be decoded is derived based on the GroupType. Alternatively, if the GroupType is used to indicate that there are no non-zero values in the first half of the coefficients to be decoded and there are non-zero values in the second half of the coefficients to be decoded, then the first flag bit corresponding to the first half of the coefficients to be decoded is derived based on the GroupType, and the first flag bit corresponding to the second half of the coefficients to be decoded is decoded from the bitstream; Alternatively, if the GroupType is used to indicate that there are non-zero values in the first half of the coefficients to be decoded and there are no non-zero values in the second half of the coefficients to be decoded, then the first flag bit corresponding to the second half of the coefficients to be decoded is derived based on the GroupType, and the first flag bit corresponding to the first half of the coefficients to be decoded is decoded from the bitstream; Alternatively, if the GroupType is used to indicate that there is a non-zero value in the first half of the coefficients to be decoded and a non-zero value in the second half of the coefficients to be decoded, then the first flag bit corresponding to the first half of the coefficients to be decoded is decoded from the bitstream, and the first flag bit corresponding to the second half of the coefficients to be decoded is decoded from the bitstream.
15. The method according to claim 10, characterized in that, The coefficients to be decoded are either type I or type II coefficients. The decoding methods for multiple coefficients corresponding to this processing unit include: Decode the maximum absolute value of all coefficients to be decoded corresponding to this processing unit; If the absolute value of the maximum coefficient is 0, then it is deduced that each coefficient to be decoded corresponding to this processing unit is 0; If the absolute value of the maximum coefficient is 1, then the first flag bit corresponding to each coefficient to be decoded is decoded, and the first flag bit is used to indicate whether the coefficient to be decoded is 0; for the coefficient to be decoded that is not 0, the sign bit corresponding to the coefficient to be decoded is decoded; based on the first flag bit and the sign bit, the multiple coefficients to be decoded corresponding to the processing unit are derived. If the absolute value of the maximum coefficient is 2, then the first flag bit corresponding to each coefficient to be decoded is decoded, and the first flag bit is used to indicate whether the coefficient to be decoded is 0; for the coefficient to be decoded that is not 0, the second flag bit and the sign bit corresponding to the coefficient to be decoded are decoded, and the second flag bit is used to indicate whether the absolute value of the coefficient to be decoded is 1; based on the first flag bit, the second flag bit and the sign bit, the multiple coefficients to be decoded corresponding to the processing unit are derived.
16. An image encoding method, characterized in that, The method includes: For each coefficient unit to be encoded, a target coefficient block for the coefficient unit is determined based on the original value of the coefficient unit to be encoded, and a first coefficient block and a second coefficient block for the coefficient unit to be encoded are determined based on the target coefficient block; wherein, the first coefficient block includes first-type coefficients that are located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients that are located later in the target coefficient block; The system encodes a first set of coefficient groups for the largest coding unit and a second set of coefficient groups for the largest coding unit; wherein the largest coding unit includes N coefficient units to be encoded, where N is greater than 1, and the coefficient unit to be encoded is any one of the N coefficient units to be encoded; wherein the first set of coefficient groups includes first-type coefficients within a first coefficient block of the N coefficient units to be encoded, and the second set of coefficient groups includes second-type coefficients within a second coefficient block of the N coefficient units to be encoded.
17. An image decoding apparatus, characterized in that, The device includes: The decoding module is used to decode the first coefficient block and the second coefficient block of each coefficient unit to be decoded. The processing module is used to concatenate the first coefficient block and the second coefficient block into a target coefficient block of the coefficient unit to be decoded; wherein, the first coefficient block includes first type coefficients that are located earlier in the target coefficient block, and the second coefficient block includes second type coefficients that are located later in the target coefficient block; Wherein, the first type of coefficients is parsed from the first set of coefficient groups of the maximum coding unit, and the second type of coefficients is parsed from the second set of coefficient groups of the maximum coding unit; the maximum coding unit includes N coefficient units to be decoded, where N is greater than 1, and the coefficient unit to be decoded is any one of the N coefficient units to be decoded.
18. An image encoding device, characterized in that, The device includes: The determination module is used to determine a target coefficient block for each coefficient unit to be encoded based on the original value of the coefficient unit to be encoded, and to determine a first coefficient block and a second coefficient block for the coefficient unit to be encoded based on the target coefficient block; wherein, the first coefficient block includes first-type coefficients that are located earlier in the target coefficient block, and the second coefficient block includes second-type coefficients that are located later in the target coefficient block; The encoding module uses a first set of coefficient groups for encoding the largest encoding unit and a second set of coefficient groups for the largest encoding unit; wherein the largest encoding unit includes N coefficient units to be encoded, where N is greater than 1, and the coefficient unit to be encoded is any one of the N coefficient units to be encoded; wherein the first set of coefficient groups includes first-type coefficients within a first coefficient block of the N coefficient units to be encoded, and the second set of coefficient groups includes second-type coefficients within a second coefficient block of the N coefficient units to be encoded.
19. An image decoding device, characterized in that, The image decoding device includes: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; The processor is configured to execute machine-executable instructions to implement the method according to any one of claims 1-15.
20. An image encoding device, characterized in that, The image encoding device includes: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; The processor is configured to execute machine-executable instructions to implement the method of claim 16.
21. A machine-readable storage medium, characterized in that, The machine-readable storage medium stores a plurality of computer instructions, which, when executed by a processor, implement the method described in any one of claims 1-16.
22. A computer program product, the computer program product comprising a computer program; wherein, When the computer program is executed by a processor, it implements the method described in any one of claims 1-16.