Encoding method, decoding method, and related apparatus
Patent Information
- Application Number
- PCT/CN2026/076046
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2025-02-28
- Filing Date
- 2026-01-30
- Publication Date
- 2026-09-03
Smart Images

Figure CN2026076046_03092026_PF_FP_ABST
Abstract
Description
Encoding methods, decoding methods and related devices
[0001] This application claims priority to Chinese Patent Application No. 202510246563.7, filed on February 28, 2025, entitled "Encoding Method, Decoding Method and Related Apparatus", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of image processing, and in particular to an encoding method, a decoding method, and related apparatus. Background Technology
[0003] Digital video capabilities can be applied to a wide variety of digital video devices, including digital television, digital live broadcasting systems, wireless broadcasting systems, personal digital assistants (PDAs), laptops or desktop computers, tablet computers, e-book readers, digital cameras, digital recording devices, digital media players, video game devices, video game consoles, cellular or satellite radio phones (i.e., "smartphones"), video conferencing devices, video streaming devices, and the like. Digital video devices implement video compression technologies, such as those described in standards defined by MPEG-2, MPEG-4, ITU-T H.263, ITU-T H.264 / MPEG-4 Part 10 Advanced Video Coding (AVC), the H.265 / HEVC video coding standard, and extensions to such standards. By implementing such video compression technologies, digital video devices can transmit, receive, encode, decode, and / or store digital video information more efficiently.
[0004] Current encoding and decoding technologies suffer from low encoding efficiency. Summary of the Invention
[0005] This application provides an encoding method, a decoding method, and related apparatus to improve the compression ratio.
[0006] Firstly, this application provides an encoding method, comprising: obtaining N quantization coefficients of a block to be encoded, wherein the N quantization coefficients include non-zero quantization coefficients, and N is an integer greater than 1; obtaining M context indices corresponding to M first identifiers, wherein the M first identifiers correspond to M quantization coefficients respectively, each of the M first identifiers indicating whether the corresponding quantization coefficient is zero, the first identifier being represented by a binary bit bin, and the N quantization coefficients including M quantization coefficients, where M is an integer greater than 1; encoding the M first identifiers based on their respective context indices to obtain a bitstream of an image to be encoded, wherein the image to be encoded includes a block to be encoded; wherein, during encoding, the context indices of adjacent first identifiers are different. Thus, this application, by assigning different context indices to adjacent first identifiers during encoding, can effectively improve encoding and decoding speed and enhance encoding efficiency.
[0007] In one possible implementation, the N quantization coefficients of the block to be encoded are one-dimensional data obtained by scanning the quantization coefficient block of the block to be encoded, and the encoding order of the N quantization coefficients is the same as or the reverse of the scanning order. In this way, the encoding and decoding sides of this application agree on the scanning order, which allows the decoding side to determine the position of each quantization coefficient in the quantization coefficient block based on the scanning order.
[0008] In one possible implementation, the context index value of the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color components of the quantization coefficient block, and i; the i-th quantization coefficient belongs to M quantization coefficients. Thus, this application assigns a context index to the corresponding first identifier based on different encoding objects, which can further improve encoding efficiency and increase encoding / decoding speed.
[0009] In one possible implementation, obtaining the context indices corresponding to the M first identifiers includes: obtaining the basic value of the context index of the first identifier of the i-th quantization coefficient based on the color components and size of the quantization coefficient block; obtaining the context index offset of the first identifier of the i-th quantization coefficient based on i and a preset context index offset table; and obtaining the value of the context index of the first identifier of the i-th quantization coefficient based on the basic value and the context index offset. Thus, this application can obtain the value of the context index corresponding to the first identifier based on the context index offset and the basic value, ensuring that the context index values of adjacent first identifiers are different, thereby effectively improving encoding and decoding speed and increasing coding efficiency.
[0010] In one possible implementation, the context index offset table includes N context index offsets, each corresponding one-to-one with one of the N positions in the scan sequence. Two or more consecutive context index offsets in the table are distinct. Thus, by setting the context index offset table, this application can assign a context index to the first identifier of a quantization coefficient at any position. Furthermore, when adjacent context index offsets in the table are different, the context index values of adjacent first identifiers can be different, thereby effectively improving encoding and decoding speed and increasing encoding efficiency.
[0011] In one possible implementation, the context index offset of the first identifier of the i-th quantization coefficient is obtained based on i and a preset context offset table. This includes: obtaining the context index offset table based on the size of the quantization coefficient block; wherein: each size of quantization coefficient block corresponds to a context index offset table, and the context index offsets contained in the context index offset tables corresponding to each size of quantization coefficient block come from the same set of values. Thus, this application sets corresponding context index offset tables for different quantization block sizes, which is applicable to scenarios involving the allocation of context indexes for the first identifiers of different encoded objects.
[0012] In one possible implementation, the scan starts from the DC quantization coefficients of the quantization coefficient block and continues to the last quantization coefficient of the quantization coefficient block.
[0013] In one possible implementation, the M quantization coefficients are the quantization coefficients between the DC quantization coefficients and the last non-zero quantization coefficient scanned.
[0014] In one possible implementation, the method further includes: obtaining the context indices corresponding to L second identifiers, where each of the L second identifiers corresponds to one of L quantization coefficients, and each of the L second identifiers indicates whether the corresponding quantization coefficient is greater than a first value. Each second identifier is represented using a bin, and the N quantization coefficients include L quantization coefficients, where L is an integer greater than 1. Based on the second context indices corresponding to the L second identifiers, the L second identifiers are encoded to obtain encoded data for the L second identifiers. Wherein: if a first quantization coefficient among the N quantization coefficients corresponds to both a first identifier and a second identifier, the first identifier and the second identifier of the first quantization coefficient are interleaved during encoding. The bitstream of the image to be encoded also includes encoded data for the L second identifiers. Thus, the first and second identifiers in this application can be interleaved, improving encoding and decoding speed and increasing encoding efficiency.
[0015] In one possible implementation, the M first identifiers are encoded based on their respective context indices, including: obtaining a first context probability model corresponding to the context index of each of the M first identifiers based on a first correspondence; encoding the bin of the first identifier based on the first context probability model; and encoding the L second identifiers based on their respective context indices, including: obtaining a second context probability model corresponding to the context index of each second identifier based on a second correspondence; and encoding the bin of the second identifier based on the second context probability model. The first correspondence includes the correspondence between the context indices usable by the first identifier and the context probability model, and the second correspondence includes the correspondence between the context indices usable by the second identifier and the context probability model. The first and second correspondences are different. By using different correspondences to assign corresponding context indices to the first and second identifiers, the context indices of adjacent first and second identifiers are not the same during encoding, thereby effectively improving encoding and decoding speed and increasing encoding efficiency.
[0016] Secondly, this application provides a decoding method, comprising: acquiring a bitstream of an image to be decoded, the image to be decoded including a block to be decoded, the block to be decoded including N quantization coefficients, the bitstream including encoded data of M first identifiers, the M first identifiers respectively corresponding to the M quantization coefficients, the N quantization coefficients including the M quantization coefficients, and M being an integer greater than 1; decoding the bitstream based on the M first context indices to obtain M first identifiers, each of the M first identifiers being represented by a binary bit bin, the first identifier being used to indicate whether the corresponding quantization coefficient is zero; wherein: during decoding, the first context indices corresponding to adjacent first identifiers are different; decoding the bitstream based on the M first identifiers to obtain M quantization coefficients; and acquiring reconstructed data of the block to be decoded based on the M quantization coefficients. Thus, this application, by assigning different context indices to adjacent first identifiers during encoding, ensures that the context indices of adjacent first identifiers are different during decoding, effectively improving encoding and decoding speed and increasing encoding efficiency.
[0017] In one possible implementation, the bitstream is decoded according to a preset scanning order, which starts from the DC quantization coefficients of the quantization coefficient block to be decoded and ends at the last quantization coefficient of the quantization coefficient block. The quantization coefficient block includes N quantization coefficients.
[0018] In one possible implementation, the value of the first context index corresponding to the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to M quantization coefficients.
[0019] In one possible implementation, before decoding the bitstream based on M first context indices, the method further includes: obtaining the basic value of the context index corresponding to the first identifier of the i-th quantization coefficient based on the color components of the quantization coefficient block and the size of the quantization coefficient block; obtaining the context index offset corresponding to the first identifier of the i-th quantization coefficient based on i and a preset context index offset table; and obtaining the value of the first context index corresponding to the first identifier of the i-th quantization coefficient based on the basic value of the context index and the context index offset.
[0020] In one possible implementation, the context index offset table includes N context index offsets, which correspond one-to-one with N positions in the scan order. Two or more consecutive context index offsets in the context index offset table are different.
[0021] In one possible implementation, the context index offset corresponding to the first identifier of the i-th quantization coefficient is obtained based on i and a preset context index offset table, including: obtaining the context index offset table based on the size of the quantization coefficient block; wherein: each size of quantization coefficient block corresponds to a context index offset table, and the context index offsets contained in the context index offset table corresponding to each size of quantization coefficient block come from the same set of values.
[0022] In one possible implementation, the decoding order of the M quantization coefficients is the same as or the reverse of the scanning order.
[0023] In one possible implementation, the M quantization coefficients are the quantization coefficients between the DC quantization coefficients and the last non-zero quantization coefficient scanned.
[0024] In one possible implementation, the method further includes: decoding the bitstream based on L second context indices to obtain L second identifiers, each of the L second identifiers indicating whether the corresponding quantization coefficient is greater than a first value, the second identifier being represented by a bin value, and the N quantization coefficients including L quantization coefficients, where L is an integer greater than 1; wherein: if the first quantization coefficient among the N quantization coefficients corresponds to a first identifier and a second identifier, the first identifier and the second identifier of the first quantization coefficient are interleaved during decoding; and decoding the bitstream based on the L second identifiers to obtain L quantization coefficients.
[0025] In one possible implementation, the bitstream is decoded based on M first context indices, including: obtaining a first context probability model corresponding to each of the M first context indices based on a first correspondence; decoding the bitstream based on the first context probability model to obtain the bin value of the first identifier corresponding to the first context index; and decoding the bitstream based on L second context indices, including: obtaining a second context probability model corresponding to the second context index among the L second context indices based on a second correspondence; and decoding the bitstream based on the second context probability model to obtain the bin value of the second identifier corresponding to the second context index; wherein: the first correspondence includes the correspondence between the context indices usable by the first identifier and the context probability model, the second correspondence includes the correspondence between the context indices usable by the second identifier and the context probability model, and the first correspondence and the second correspondence are different.
[0026] Thirdly, this application provides an encoding apparatus, comprising: an acquisition module, configured to acquire N quantization coefficients of a block to be encoded, wherein the N quantization coefficients include non-zero quantization coefficients, and N is an integer greater than 1; the acquisition module is further configured to acquire context indices corresponding to M first identifiers, wherein the M first identifiers correspond to M quantization coefficients respectively, and each of the M first identifiers is used to indicate whether the corresponding quantization coefficient is zero, wherein the first identifier is represented by a binary bit bin, and the N quantization coefficients include M quantization coefficients, where M is an integer greater than 1; and an encoding module, configured to encode the M first identifiers based on the context indices corresponding to the M first identifiers to obtain a bitstream of an image to be encoded, wherein the image to be encoded includes a block to be encoded; wherein: during encoding, the context indices of adjacent first identifiers are different.
[0027] In one possible implementation, the N quantization coefficients of the block to be encoded are one-dimensional data obtained by scanning the quantization coefficient block of the block to be encoded, and the encoding order of the N quantization coefficients is the same as or the reverse of the scanning order.
[0028] In one possible implementation, the value of the context index of the first identifier of the i-th quantization coefficient in the scan order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to M quantization coefficients.
[0029] Fourthly, this application provides a decoding apparatus, comprising: an acquisition module for acquiring a bitstream of an image to be decoded, the image to be decoded including a block to be decoded, the block to be decoded including N quantization coefficients, the bitstream including encoded data of M first identifiers, the M first identifiers respectively corresponding to the M quantization coefficients, the N quantization coefficients including the M quantization coefficients, and M being an integer greater than 1; a decoding module for decoding the bitstream based on the M first context indices to obtain M first identifiers, each of the M first identifiers being represented by a binary bit bin, the first identifier being used to indicate whether the corresponding quantization coefficient is zero; wherein: during decoding, the first context indices corresponding to adjacent first identifiers are different; the decoding module is further configured to decode the bitstream based on the M first identifiers to obtain M quantization coefficients; and a reconstruction module for acquiring reconstructed data of the block to be decoded based on the M quantization coefficients.
[0030] In one possible implementation, the bitstream is decoded according to a preset scanning order, which starts from the DC quantization coefficients of the quantization coefficient block to be decoded and ends at the last quantization coefficient of the quantization coefficient block. The quantization coefficient block includes N quantization coefficients.
[0031] In one possible implementation, the value of the first context index corresponding to the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to M quantization coefficients.
[0032] Fifthly, this application provides an encoder, including: a memory and a processor, the memory being coupled to the processor; the memory storing program instructions, which, when executed by the processor, cause the encoder to perform the method in the first aspect or any possible implementation thereof.
[0033] In a sixth aspect, this application provides a decoder, comprising: a memory and a processor, the memory being coupled to the processor; the memory storing program instructions, which, when executed by the processor, cause the decoder to perform the method in the second aspect or any possible implementation thereof.
[0034] In a seventh aspect, this application provides a chip including one or more interface circuits and one or more processors; the one or more processors receive or transmit data through the one or more interface circuits, and when the one or more processors execute computer instructions, cause the electronic device to perform the method in the first aspect or any possible implementation of the first aspect.
[0035] Eighthly, this application provides a chip including one or more interface circuits and one or more processors; the one or more processors receive or transmit data through the one or more interface circuits, and when the one or more processors execute computer instructions, cause the electronic device to perform the method in the second aspect or any possible implementation of the second aspect.
[0036] Ninthly, this application provides a computer-readable storage medium storing a computer program that, when run on a computer or processor, causes the computer or processor to perform the method of the first aspect or any possible implementation thereof.
[0037] In a tenth aspect, this application provides a computer-readable storage medium storing a computer program that, when run on a computer or processor, causes the computer or processor to perform the method of the second aspect or any possible implementation thereof.
[0038] In one aspect, this application provides a computer program product, which includes computer instructions that, when executed by a computer or processor, cause the computer or processor to perform the method in the first aspect or any possible implementation thereof.
[0039] In a twelfth aspect, this application provides a computer program product including computer instructions that, when executed by a computer or processor, cause the computer or processor to perform the method in the second aspect or any possible implementation thereof.
[0040] In a thirteenth aspect, this application provides a computer-readable storage medium that stores a bitstream from the first aspect or any possible implementation thereof.
[0041] In a fourteenth aspect, this application provides an encoder including processing circuitry that can be used to perform the methods in the first aspect or any possible implementation thereof.
[0042] In a fifteenth aspect, this application provides a decoder including processing circuitry that can be used to perform the methods in the second aspect or any possible implementation thereof.
[0043] In a sixteenth aspect, this application provides a bitstream generated according to the first aspect and any implementation thereof.
[0044] The electronic devices, computer-readable storage media, computer program products, chips, or codecs provided in this application are all used to perform the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above. Attached Figure Description
[0045] Figure 1A is a schematic block diagram of an exemplary video encoding and decoding system;
[0046] Figure 1B is a schematic block diagram of an exemplary video decoding system;
[0047] Figure 2 is a schematic block diagram of an encoder as an example;
[0048] Figure 3 is a schematic block diagram of an exemplary decoder;
[0049] Figure 4 is a schematic block diagram of an encoder based on wavelet transform, which is an example shown.
[0050] Figure 5 is an exemplary schematic diagram of subgraph partitioning;
[0051] Figure 6 is an exemplary schematic diagram of wavelet transform;
[0052] Figures 7A and 7B are schematic block diagrams of an exemplary decoder;
[0053] Figure 8 is a schematic diagram of the structure of a code stream as an example;
[0054] Figure 9 is a flowchart illustrating an exemplary encoding method;
[0055] Figure 10 is a flowchart illustrating an exemplary encoding method;
[0056] Figure 11 is an exemplary scanning diagram;
[0057] Figure 12 is a schematic diagram of the scanning results as an example;
[0058] Figure 13 is a flowchart illustrating an exemplary encoding method;
[0059] Figure 14A is an exemplary schematic diagram of the scan results;
[0060] Figure 14B is an exemplary schematic diagram of the scan results;
[0061] Figure 15 is an exemplary schematic diagram of context index allocation;
[0062] Figure 16 is a schematic diagram of the bin value encoding process as an example;
[0063] Figure 17 is an exemplary diagram illustrating the remaining value;
[0064] Figure 18 is a flowchart illustrating an exemplary decoding method;
[0065] Figure 19 is a schematic flowchart illustrating the decoding method;
[0066] Figure 20 is a schematic diagram of the structure of an exemplary video decoding device;
[0067] Figure 21 is a schematic diagram of the structure of an exemplary device;
[0068] Figure 22 is a schematic diagram of the structure of an exemplary device;
[0069] Figure 23 is a schematic diagram of the structure of an exemplary device. Detailed Implementation
[0070] The following is a brief introduction to some concepts that may be involved in the embodiments of this application. These concepts are only used to explain the specific embodiments of this application and are not intended to limit this application.
[0071] The residual is the difference between the reconstructed value and the predicted value of a sample or data element.
[0072] A residual block is a residual matrix composed of the residuals corresponding to the coded blocks.
[0073] Dequantization is the process of scaling the quantized residual to obtain the reconstructed residual value.
[0074] A partition divides a set into subsets. Each element in the set belongs to one and only one subset.
[0075] Partition type: The way the subsets obtained from the partition are organized.
[0076] A decoded picture is an image reconstructed by the decoder based on the bitstream.
[0077] Prediction is the specific implementation of the prediction process.
[0078] The prediction process uses previously decoded samples to obtain the predicted value for the current sample.
[0079] Syntax element: The result of parsing data units in a bitstream.
[0080] A bitstream is a binary data stream that encodes all or part of an image sample.
[0081] Video coding generally refers to the processing of a sequence of images that form a video or video sequence. In the field of video coding, the terms "picture," "frame," or "image" can be used synonymously. Video coding is performed on the source side and typically involves processing (e.g., by compression) the raw video images to reduce the amount of data required to represent them, thus enabling more efficient storage and / or transmission. Video decoding is performed on the destination side and typically involves inverse processing relative to the encoder to reconstruct the video images. The combination of encoding and decoding is also known as encoding and decoding.
[0082] A video sequence consists of a series of images, which are further divided into slices, and slices into blocks. Video coding is performed on a block-by-block basis. In some newer video coding standards, the concept of a block has been further expanded. For example, the H.264 standard uses macroblocks (MBs), which can be further divided into multiple prediction blocks (partitions) that can be used for predictive coding. In the High Efficiency Video Coding (HEVC) standard, basic concepts such as coding units (CUs), prediction units (PUs), and transform units (TUs) are used to functionally divide various block units, and a new tree-based structure is used for description.
[0083] In this paper, for ease of description and understanding, the image block to be processed in the current image is referred to as the current block. For example, in encoding, it refers to the block currently being encoded; in decoding, it refers to the block currently being decoded. The decoded image block in the reference image used to predict the current block is called the reference block. That is, the reference block is the block that provides a reference signal for the current block, where the reference signal represents the pixel value within the image block. The block in the reference image that provides a prediction signal for the current block is called the prediction block, where the prediction signal represents the pixel value, sampled value, or sampled signal within the prediction block. For example, after traversing multiple reference blocks, an optimal reference block is found. This optimal reference block will provide prediction for the current block; this block is called the prediction block.
[0084] In lossless video coding, the original video image can be reconstructed, meaning the reconstructed video image has the same quality as the original (assuming no transmission loss or other data loss during storage or transmission). In lossy video coding, further compression is performed, for example, through quantization, to reduce the amount of data required to represent the video image. However, the decoder cannot fully reconstruct the video image, meaning the quality of the reconstructed video image is lower or worse than the original video image.
[0085] YUV is a color space model used to represent colors, widely used in image encoding and decoding, video encoding and decoding, digital image processing, television broadcasting, and other fields. YUV separates the luminance information from the chrominance information of an image.
[0086] The three components of YUV:
[0087] Y (luminance) component: Y represents the luminance information of an image, that is, the brightness or darkness of the image. It is obtained by weighting the red, green, and blue color channels according to certain weights. The Y component plays an important role in the sharpness and detail of an image.
[0088] U (chromaticity) component: U represents the chromaticity information of the image, indicating the offset of the blue channel relative to the luminance Y. It measures the change in the blue component.
[0089] V (chromaticity) component: V represents the chromaticity information of the image, indicating the offset of the red channel relative to the luminance Y.
[0090] The encoding / decoding method of this application embodiment encodes and decodes images or videos on a block-by-block basis.
[0091] In some embodiments, the block to be encoded or the block to be decoded may be an image block or a video block obtained from an image or video.
[0092] In some embodiments, the block to be encoded or the block to be decoded may be an image block or video block within a subgraph obtained by dividing the image or video into subgraphs.
[0093] In some embodiments, the block to be encoded or the block to be decoded can be a block obtained from the transformed data of the image or video to be encoded after transformation processing (e.g., wavelet transform (also known as wavelet forward transform, etc., without limitation).
[0094] This application does not restrict the specific division method of the blocks to be encoded or decoded in an image or video, nor does it restrict the method of obtaining the blocks.
[0095] On the encoding side, the image to be encoded can be a frame from an image or video, a sub-image obtained by dividing a frame from an image or video, an image obtained after transformation (such as wavelet transform), or a sub-image from the transformed image; there are no restrictions here. On the encoding side, "current frame" can represent "image to be encoded," and "current block" can represent "block to be encoded." A frame is a frame of image to be displayed.
[0096] Similarly, the decoding side corresponds to the encoding side. On the decoding side, the image to be decoded can be the original image in an image or video, or an image obtained after processing the original image (e.g., left shifting), or a sub-image obtained by dividing the original image or video, or an image obtained after transformation (e.g., wavelet transform), or a sub-image in the transformed image; there are no restrictions here. On the decoding side, "current image" can be used to represent "image to be decoded," and "current block" can be used to represent "block to be decoded."
[0097] Whether on the encoding or decoding side, the reconstructed data (also called the reconstructed value) of a block can be described as a reconstructed block, and the already encoded or decoded block referenced when encoding or decoding the current block can be described as a "reference block".
[0098] Whether on the encoding or decoding side, the reference image, also known as the reference frame, can be an image that has been encoded before the current image in the video sequence, or, when the current image is a sub-image, the reference image is a sub-image that has been encoded before the current image, without any restrictions.
[0099] Whether on the encoding or decoding side, the prediction data for the current block is also referred to as the prediction block or the prediction value for the current block.
[0100] Whether on the encoding or decoding side, reconstruction can also be described as remodeling.
[0101] Whether on the encoding or decoding side, the bitstream is also described as a bitstream, etc.
[0102] Whether on the encoding or decoding side, the residual is also referred to as a residual block.
[0103] The embodiments of this application are described below with reference to the accompanying drawings.
[0104] Referring to Figure 1A, Figure 1A provides an exemplary block diagram of a video encoding and decoding system 10 used in an embodiment of this application. As shown in Figure 1A, the video encoding and decoding system 10 may include a source device 12 and a destination device 14. The source device 12 generates encoded video data; therefore, the source device 12 may be referred to as a video encoding device. The destination device 14 can decode the encoded video data generated by the source device 12; therefore, the destination device 14 may be referred to as a video decoding device. Various embodiments of the source device 12, the destination device 14, or both may include one or more processors and memory coupled to the one or more processors. The memory may include, but is not limited to, RAM, ROM, EEPROM, flash memory, or any other media that can be used to store desired program code in the form of computer-accessible instructions or data structures. The source device 12 and the destination device 14 may include a variety of devices, including desktop computers, mobile computing devices, notebook (e.g., laptop) computers, tablet computers, set-top boxes, handsets, televisions, cameras, display devices, digital media players, video game consoles, in-vehicle computers, wireless communication devices, or the like.
[0105] Source device 12 and destination device 14 can communicate via link 13, through which destination device 14 can receive encoded video data from source device 12. Link 13 may include one or more media or devices capable of transmitting encoded video data from source device 12 to destination device 14. In one example, link 13 may include one or more communication media enabling source device 12 to transmit encoded video data to destination device 14 in real time. In this example, source device 12 may modulate the encoded video data according to a communication standard (e.g., a wireless communication protocol) and transmit the modulated video data to destination device 14. The one or more communication media may include wireless and / or wired communication media, such as radio frequency (RF) spectrum or one or more physical transmission lines. The one or more communication media may form part of a packet-based network, such as a local area network, wide area network, or global network (e.g., the Internet). The one or more communication media may include routers, switches, base stations, or other devices facilitating communication from source device 12 to destination device 14.
[0106] The source device 12 includes an encoder 20. Optionally, the source device 12 may also include an image source 16, an image preprocessor 18, and a communication interface 22. In specific implementations, the encoder 20, image source 16, image preprocessor 18, and communication interface 22 may be hardware components or software programs within the source device 12. These are described below:
[0107] Image source 16 may include or be any type of image capture device for, for example, capturing real-world images, and / or any type of image or commentary (for screen content encoding, some text on the screen is also considered as an image to be encoded or part of an image) generation device, such as a computer graphics processor for generating computer-animated images, or any type of device for acquiring and / or providing real-world images, computer-animated images (e.g., screen content, virtual reality (VR) images), and / or any combination thereof (e.g., augmented reality (AR) images). Image source 16 may be a camera for capturing images or a memory for storing images. Image source 16 may also include any type of (internal or external) interface for storing previously captured or generated images and / or acquiring or receiving images. When image source 16 is a camera, image source 16 may be, for example, a local or integrated camera integrated into a source device; when image source 16 is a memory, image source 16 may be a local or integrated memory integrated into a source device. When the image source 16 includes an interface, the interface may be, for example, an external interface for receiving images from an external video source, such as an external image capture device, like a camera, external storage, or an external image generation device, such as an external computer graphics processor, computer, or server. The interface can be any type of interface according to any proprietary or standardized interface protocol, such as a wired or wireless interface, or an optical interface.
[0108] An image can be viewed as a two-dimensional array or matrix of pixels. Pixels in the array are also called sampling points. The number of sampling points in the array or image along the horizontal and vertical directions (or axes) defines the image size and / or resolution. To represent color, three color components are typically used; that is, an image can be represented as or contain three sampling arrays. For example, in RBG format or color space, an image includes corresponding red, green, and blue sampling arrays. However, in video coding, each pixel is typically represented in a luma / chroma format or color space. For example, for a YUV format image, this includes a luma component indicated by Y (sometimes also indicated by L) and two chroma components indicated by U and V. The luma component Y represents the brightness or grayscale level intensity (e.g., both are the same in a grayscale image), while the two chroma components U and V represent chroma or color information components. Accordingly, a YUV format image includes a luma sampling array of luma sample values (Y) and two chroma sampling arrays of chroma values (U and V). An RGB format image can be converted or transformed to YUV format, and vice versa; this process is also called color transformation or conversion. If the image is black and white, it may only include a luminance sampling array. In this embodiment, the image transmitted from image source 16 to image processor can also be referred to as raw image data 17.
[0109] Image preprocessor 18 is configured to receive raw image data 17 and perform preprocessing on the raw image data 17 to obtain a preprocessed image 19 or preprocessed image data 19. For example, the preprocessing performed by image preprocessor 18 may include retouching, color format conversion (e.g., from RGB format to YUV format), color correction, or noise reduction.
[0110] Encoder 20 (or video encoder 20) is used to receive preprocessed image data 19 and process the preprocessed image data 19 using a relevant prediction mode (such as the prediction mode in the various embodiments herein) to provide encoded image data 21.
[0111] Communication interface 22 can be used to receive encoded image data 21 and transmit the encoded image data 21 via link 13 to destination device 14 or any other device (such as a memory) for storage or direct reconstruction. The other device can be any device used for decoding or storage. Communication interface 22 can, for example, be used to encapsulate the encoded image data 21 into a suitable format, such as data packets, for transmission over link 13.
[0112] Destination device 14 includes decoder 30. Optionally, destination device 14 may also include communication interface 28, image post-processor 32, and display device 34. These are described below:
[0113] Communication interface 28 can be used to receive encoded image data 21 from source device 12 or any other source, such as a storage device, for example, an encoded image data storage device. Communication interface 28 can be used to transmit or receive encoded image data 21 via link 13 between source device 12 and destination device 14 or via any type of network, such as a wired or wireless connection, any type of network, such as a wired or wireless network or any combination thereof, or any type of private and public network, or any combination thereof. Communication interface 28 can be used, for example, to decapsulate data packets transmitted by communication interface 22 to obtain encoded image data 21.
[0114] Both communication interface 28 and communication interface 22 can be configured as unidirectional or bidirectional communication interfaces, and can be used, for example, to send and receive messages to establish connections, acknowledge and exchange any other information related to the communication link and / or data transmission, such as encoded image data transmission.
[0115] Decoder 30 (or video decoder 30) is used to receive encoded image data 21 and provide decoded image data 31 or decoded image 31 (the structural details of decoder 30 will be further described below based on Figure 3, Figure 4 or Figure 5).
[0116] Image post-processor 32 is used to perform post-processing on decoded image data 31 (also known as reconstructed image data) to obtain post-processed image data 33.
[0117] Display device 34 is used to receive post-processed image data 33 to display an image to, for example, a user or viewer. Display device 34 can be or may include any class of displays for presenting reconstructed images, such as integrated or external displays or monitors. For example, displays may include liquid crystal displays (LCDs), organic light emitting diode (OLED) displays, plasma displays, projectors, micro-LED displays, liquid crystal on silicon (LCoS), digital light processors (DLP), or any other class of displays.
[0118] Both encoder 20 and decoder 30 can be implemented as any of a variety of suitable circuits, such as one or more microprocessors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), discrete logic, hardware, or any combination thereof. If the technology is implemented in part in software, the device can store the software instructions in a suitable non-transitory computer-readable storage medium, and one or more processors can be used to execute the instructions in hardware to perform the technology of this disclosure. Any of the foregoing (including hardware, software, combinations of hardware and software, etc.) can be considered as one or more processors.
[0119] Referring to FIG1B, FIG1B is an illustrative diagram of an example of a video decoding system 40 including the encoder 20 of FIG2 and / or the decoder 30 of FIG3 according to an exemplary embodiment. The video decoding system 40 can implement various combinations of technologies of the embodiments of this application. In the illustrated embodiment, the video decoding system 40 may include an imaging device 41, an encoder 20, a decoder 30 (and / or a video encoder / decoder implemented by logic circuitry of a processing unit 46), an antenna 42, one or more processors 43, one or more memories 44, and a display device 45.
[0120] As shown in Figure 1B, the imaging device 41, antenna 42, processing unit 46, logic circuit, encoder 20, decoder 30, processor 43, memory 44, and display device 45 are capable of communicating with each other. As discussed, although encoder 20 and decoder 30 are used as examples to describe the video decoding system 40, in different instances, the video decoding system 40 may contain only encoder 20 or only decoder 30.
[0121] In some instances, antenna 42 can be used to transmit or receive encoded video data streams. Additionally, in some instances, display device 45 can be used to present video data. In some instances, logic circuitry can be implemented using processing unit 46. Processing unit 46 can include an ASIC, graphics processor, general-purpose processor, etc. Video decoding system 40 can also include an optional processor 43, which can similarly include an ASIC, graphics processor, general-purpose processor, etc. In some instances, logic circuitry can be implemented in hardware, such as dedicated video encoding hardware, while processor 43 can be implemented in general-purpose software, operating system, etc. Furthermore, memory 44 can be any type of memory, such as volatile memory (e.g., static random access memory (SRAM), dynamic random access memory (DRAM), etc.) or non-volatile memory (e.g., flash memory, etc.). In a non-limiting instance, memory 44 can be implemented using cache memory. In some instances, logic circuitry can access memory 44 (e.g., for implementing an image buffer). In other instances, the logic circuitry and / or processing unit 46 may include memory (e.g., cache, etc.) for implementing image buffers, etc.
[0122] In some instances, the encoder 20 implemented via logic circuitry may include (e.g., implemented via processing unit 46 or memory 44) an image buffer and (e.g., implemented via processing unit 46) a graphics processing unit. The graphics processing unit may be communicatively coupled to the image buffer. The graphics processing unit may include the encoder 20 implemented via logic circuitry to implement various modules discussed with reference to Figure 2 and / or any other encoder system or subsystem described herein. The logic circuitry may be used to perform various operations discussed herein.
[0123] In some instances, decoder 30 may be implemented via logic circuitry in a similar manner to implement the various modules discussed in reference to decoder 30 of Figure 3 and / or any other decoder system or subsystem described herein. In some instances, the logic circuitry-implemented decoder 30 may include an image buffer (implemented via processing unit 46 or memory 44) and a graphics processing unit (e.g., implemented via processing unit 46). The graphics processing unit may be communicatively coupled to the image buffer. The graphics processing unit may include decoder 30 implemented via logic circuitry to implement the various modules discussed in reference to Figure 3 and / or any other decoder system or subsystem described herein.
[0124] In some instances, antenna 42 can be used to receive an encoded stream of video data. As discussed herein, the encoded stream may contain data related to encoded video frames, indicators, index values, mode selection data, etc., such as data related to code segmentation (e.g., transform coefficients or quantized transform coefficients, optional indicators, and / or data defining code segmentation). Video decoding system 40 may also include a decoder 30 coupled to antenna 42 for decoding the encoded stream. Display device 45 is used to display the video frames.
[0125] It should be understood that, referring to the examples described for encoder 20 in the embodiments of this application, decoder 30 can be used to perform the reverse process. Regarding signaling syntax elements, decoder 30 can be used to receive and parse such syntax elements, and accordingly decode the associated video data. In some examples, encoder 20 can entropy-encode syntax elements into an encoded video stream. In such instances, decoder 30 can parse such syntax elements and accordingly decode the associated video data.
[0126] It should be noted that the encoding and decoding method described in the embodiments of this application is mainly used for the encoding and decoding process of video or images. This process exists in both encoder 20 and decoder 30. The encoder 20 and decoder 30 in the embodiments of this application can be, for example, the encoding / decoder corresponding to video standard protocols such as H.263, H.264, HEVV, MPEG-2, MPEG-4, VP8, VP9, H.266, or next-generation video standard protocols (such as H.267).
[0127] Referring to Figure 2, which is a schematic / conceptual block diagram of an exemplary example of encoder 20, encoder 20 includes a residual calculation unit 204, a transform processing unit 206, a quantization unit 208, an inverse quantization unit 210, an inverse transform processing unit 212, a reconstruction unit 214, a buffer 216, a loop filter unit 220, a decoded picture buffer (DPB) 230, a prediction processing unit 260, and an entropy coding unit 270. Prediction processing unit 260 may include inter-frame prediction unit 244, intra-frame prediction unit 254, and mode selection unit 262. Inter-frame prediction unit 244 may include a motion estimation unit and a motion compensation unit (not shown). Encoder 20 shown in Figure 2 may also be referred to as a hybrid video encoder or a video encoder based on a hybrid video codec.
[0128] Specifically, encoder 20 receives image 201 or image blocks 203 of image 201 via, for example, input 202. Encoder 20 is used to encode image 201 block by block, for example, by performing encoding and prediction for each image block 203.
[0129] The residual calculation unit 204 is used to calculate the residual block 205 based on the image block 203 and the prediction block 265. The transform processing unit 206 is used to apply a transform, such as a discrete cosine transform (DCT) or a discrete sine transform (DST), to the sample values of the residual block 205 to obtain transform coefficients 207 in the transform domain. The transform coefficients 207 can also be called transform residual coefficients.
[0130] The quantization unit 208 is used to quantize the transform coefficients 207, for example, by applying scalar quantization or vector quantization, to obtain the quantized transform coefficients 209.
[0131] The inverse quantization unit 210 is used to apply the inverse quantization of the quantization unit 208 to the quantized coefficients to obtain the inverse quantization coefficients 211.
[0132] The inverse transformation processing unit 212 is used to apply the inverse transformation of the transformation applied by the transformation processing unit 206 to obtain the inverse transformation block 213.
[0133] Reconstruction unit 214 (e.g., summer 214) is used to add inverse transform block 213 (i.e. reconstructed residual block 213) to prediction block 265 to obtain reconstructed block 215.
[0134] The loop filter unit 220 (or simply "loop filter" 220) is used to filter the reconstructed block 215 to obtain the filtered block 221.
[0135] The decoded image buffer 230 can be used as a reference image memory to store reference image data for the encoder 20 to encode video data.
[0136] The prediction processing unit 260, also known as the block prediction processing unit 260, is used to receive or acquire image block 203 (current image block 203 of current image 201) and reconstructed image data, and to process such data to make predictions, i.e., to provide prediction block 265 which can be either inter-frame prediction block 245 or intra-frame prediction block 255.
[0137] The mode selection unit 262 can be used to select a prediction mode (e.g., intra-frame or inter-frame prediction mode) and / or the corresponding prediction block 245 or 255 used as prediction block 265 to compute residual block 205 and reconstructed block 215.
[0138] Specifically, the intra-frame prediction unit 254 can transmit syntax elements to the entropy coding unit 270. The entropy coding unit 270 is used to apply an entropy coding algorithm or scheme (e.g., variable length coding (VLC) scheme, context adaptive VLC (CAVLC) scheme, arithmetic coding scheme, context adaptive binary arithmetic coding (CABAC), syntax-based context-adaptive binary arithmetic coding (SBAC), probability interval partitioning entropy (PIPE) coding, or other entropy coding methods or techniques) to one or all (or not apply) of the quantized residual coefficients 209, inter-frame prediction parameters, intra-frame prediction parameters, and / or loop filter parameters to obtain encoded image data 21 that can be output by output 272 in the form of, for example, an encoded bitstream 21.
[0139] Referring to Figure 3, which is a schematic / conceptual block diagram of an example of a decoder 30, the decoder 30 is used to receive, for example, encoded image data (e.g., encoded bitstream) 21 encoded by encoder 20 to obtain a decoded image 331. During the decoding process, the decoder 30 receives video data from encoder 20, such as encoded video bitstreams representing image blocks of encoded video stripes and associated syntax elements.
[0140] In the example of Figure 3, decoder 30 includes an entropy decoding unit 304, an inverse quantization unit 310, an inverse transform processing unit 312, a reconstruction unit 314 (e.g., a summer 314), a buffer 316, a loop filter 320, a decoded image buffer 330, and a prediction processing unit 360. Prediction processing unit 360 may include an inter-frame prediction unit 344, an intra-frame prediction unit 354, and a mode selection unit 362. In some instances, decoder 30 may perform a decoding process that is generally the inverse of the encoding process described in video encoder 20 of Figure 2.
[0141] Specifically, the entropy decoding unit 304 is used to perform entropy decoding on the encoded image data 21 to obtain, for example, quantization coefficients 309 and / or decoded encoding parameters (not shown in Figure 3).
[0142] The inverse quantization unit 310 can function the same as the inverse quantization unit 110, the inverse transform processing unit 312 can function the same as the inverse transform processing unit 212, the reconstruction unit 314 can function the same as the reconstruction unit 214, the buffer 316 can function the same as the buffer 216, the loop filter 320 can function the same as the loop filter 220, and the decoded image buffer 330 can function the same as the decoded image buffer 230.
[0143] The prediction processing unit 360 is typically used to perform block prediction and / or obtain prediction blocks 365 from the encoded data 21, and to receive or obtain prediction-related parameters and / or information about the selected prediction mode from, for example, the entropy decoding unit 304 (explicitly or implicitly).
[0144] The inverse quantization unit 310 can be used to inverse quantize (i.e., dequantize) the quantized transform coefficients provided in the bitstream and decoded by the entropy decoding unit 304. The inverse transform processing unit 312 is used to apply an inverse transform (e.g., inverse DCT, inverse integer transform, or a conceptually similar inverse transform process) to the transform coefficients to generate a residual block in the pixel domain.
[0145] Reconstruction unit 314 (e.g., summer 314) is used to add inverse transform block 313 (i.e. reconstructed residual block 313) to prediction block 365 to obtain reconstructed block 315 in the sample domain.
[0146] The loop filter unit 320 (during or after the encoding loop) is used to filter the reconstructed block 315 to obtain the filtered block 321.
[0147] Decoder 30 is used, for example, to output decoded image 31 via output 332 for presentation to or viewing by the user.
[0148] For example, commonly used transform methods in image coding include discrete cosine transform and wavelet transform. Wavelet transform is a local transform method that can perform localized, multi-scale analysis of images, focusing on the details of signal changes, making it very suitable for image coding tasks.
[0149] This application provides a wavelet transform-based codec that can independently encode and decode low-frequency and high-frequency sub-bands, effectively reducing encoding and decoding complexity and improving efficiency. For example, an image undergoes wavelet transform to obtain low-frequency and high-frequency sub-bands, which are then encoded to generate low-frequency and high-frequency sub-band bitstreams, respectively. The low-frequency sub-band can be understood as a sub-image representing the low-frequency signal (or low-frequency information) of the original image, and the high-frequency sub-band can be understood as a sub-image representing the high-frequency signal (or high-frequency information) of the original image.
[0150] Referring to Figure 4, which is a schematic / conceptual block diagram of an encoder as an example, the encoder in the example of Figure 4 includes, but is not limited to, a sub-graph partitioning unit 410, a wavelet forward transform unit 420, a low-frequency sub-band processing path 430, and a high-frequency sub-band processing path 440.
[0151] The sub-image partitioning unit 410 is used to acquire the current image and partition it to obtain at least one sub-image. Specifically, the sub-image partitioning unit 410 partitions the current image into N sub-images according to a sub-image partitioning method, where N is an integer greater than 0 (or an integer greater than 1). The sub-image partitioning method can include, but is not limited to, at least one of the following:
[0152] The width and / or height of the subgraph are multiples of 128;
[0153] The maximum width of the subimage is 1024 pixels;
[0154] The minimum height and / or width of the subimage is 256 pixels;
[0155] The original image resolution is less than or equal to 1080p, and N is an integer greater than 1 and less than or equal to 8; or,
[0156] The original image has a length greater than or equal to 4320 pixels, a width greater than or equal to 2160 pixels, and N is an integer greater than 1 and less than or equal to 16; or,
[0157] The original image has a length greater than or equal to 7680 pixels, a width greater than or equal to 4320 pixels, and N is an integer greater than 1 and less than or equal to 32.
[0158] The values mentioned above are merely illustrative examples and can be set according to actual needs.
[0159] Referring to Figure 5, which is an exemplary schematic diagram of sub-image partitioning, in the example of Figure 5, the sub-image partitioning unit 410 can partition the image 401 into m multiplied by n sub-images according to the sub-image partitioning method. Optionally, in this example, the width and height of each sub-image satisfy a multiple of 128.
[0160] The sub-image partitioning unit 410 can partition the image into m multiplied by n sub-images according to the sub-image partitioning method. Among them, for sub-images whose width and height are not multiples of 128, the sub-image partitioning unit 410 can pad these sub-images so that the height and width of each padded sub-image can be multiples of 16.
[0161] The wavelet forward transform unit 420 is used to perform wavelet transform (also called wavelet forward transform) on the subgraph to obtain low-frequency subband and high-frequency subband. The low-frequency subband includes low-frequency signals in the subgraph that satisfy the low-frequency filter coefficients, and the high-frequency subband includes high-frequency signals in the subgraph that have been decomposed by the high-frequency filter in the wavelet transform.
[0162] Referring to Figure 6, which is an exemplary schematic diagram of wavelet transform, in the example of Figure 6, the wavelet forward transform unit 420 acquires the current sub-image, for example, sub-image 1_1. The wavelet forward transform unit 420 performs a wavelet transform on the current sub-image, wherein the wavelet transform includes one horizontal wavelet transform and one vertical wavelet transform to obtain the wavelet coefficients of the low-low (LL) sub-band (abbreviated as LL sub-band), the wavelet coefficients of the low-high (LH) sub-band (abbreviated as LH sub-band), the wavelet coefficients of the high-high (HH) sub-band (abbreviated as HH sub-band), and the wavelet coefficients of the high-low (HL) sub-band (abbreviated as HL sub-band).
[0163] In this embodiment, the low-frequency subband includes an LL subband, and the high-frequency subband includes an LH subband, an HH subband, and an HL subband. Optionally, the LL subband, LH subband, HH subband, and HL subband have the same size (including width and height).
[0164] Referring again to Figure 4, the low-frequency subband processing path 430 is used to obtain the wavelet coefficients 403 of the low-frequency subband to obtain the low-frequency subband encoded data 413. The low-frequency subband processing path 430 includes, but is not limited to: a block partitioning unit 431 (also called a low-frequency subband block partitioning unit 431), a residual calculation unit 432, a prediction unit 437, a control unit 438, a transform / quantization unit (also called a low-frequency subband transform / quantization unit 433), an inverse quantization / inverse transform unit 434 (also called a low-frequency subband inverse quantization / inverse transform unit 434), a low-frequency subband reconstruction unit 435, a low-frequency subband splicing unit 436, and a low-frequency subband entropy coding unit 439, etc.
[0165] The high-frequency subband processing path 440 is used to acquire high-frequency subbands to obtain high-frequency subband encoded data. The high-frequency subband processing path 440 includes, but is not limited to: a block partitioning unit 431 (also referred to as a high-frequency subband block partitioning unit 431 or a second block partitioning unit 431), a transform / quantization unit (also referred to as a transform / quantization unit 442 or a second transform / quantization unit), and a high-frequency subband entropy coding unit 443, etc.
[0166] Alternatively, in some instances, the encoder may include more or fewer units or modules than in the structure shown in Figure 4.
[0167] The image 401 encoding method provided in this application will be described in detail below with reference to the encoder shown in Figure 4:
[0168] The codec receives image 401. A description of image 401 can be found above and will not be repeated here.
[0169] Sub-image partitioning unit 410 partitions image 401 into sub-images and outputs N sub-images. N is an integer greater than 0. In this embodiment, each sub-image is encoded and decoded independently. During the encoding process, sub-image 402 can be referred to as the current sub-image or the sub-image to be encoded.
[0170] Wavelet forward transform unit 420 performs wavelet forward transform on the current sub-image to obtain wavelet coefficients 403 (hereinafter referred to as low-frequency sub-band) and wavelet coefficients 414 (hereinafter referred to as high-frequency sub-band) of the current sub-image. The wavelet coefficients 403 of the low-frequency sub-band include the wavelet coefficients of the LL sub-band, and the wavelet coefficients of the LH, HL, and HH sub-bands are included in the high-frequency sub-band. In this embodiment, each sub-image of the image can be independently encoded and decoded, and the high-frequency sub-band and low-frequency sub-band of each sub-image are independently encoded and decoded. The LH, HL, and HH sub-bands in the high-frequency sub-band can also be independently encoded and decoded.
[0171] The block partitioning unit 431 (which may be called the low-frequency sub-band block partitioning unit) is used to obtain the wavelet coefficients 403 of the low-frequency sub-band of the current sub-graph 402, so as to obtain at least one macroblock 404 of the low-frequency sub-band of the sub-graph 402. The macroblock can also be understood as a set of partial coefficients in the wavelet coefficients of the low-frequency sub-band.
[0172] Specifically, the block partitioning unit 431 partitions the wavelet coefficients 403 of the low-frequency sub-band of the current subgraph 402 into blocks based on the block partitioning method, obtaining at least one macroblock 404 of the low-frequency sub-band of the current subgraph, for example, M macroblocks, where M is an integer greater than 0 (or greater than 1). The low-frequency block partitioning unit 431 outputs the macroblocks 404 of the wavelet coefficients 403 of the current low-frequency sub-band one by one to the residual calculation unit 432 and the control unit 438.
[0173] In the embodiments of this application, macroblock 404 is a basic encoding / decoding unit. During the encoding process, macroblock 404 may also be referred to as the current block, current image block 401, macroblock 404 to be encoded, block to be encoded, image block 404 to be encoded, etc.
[0174] Alternatively, the block partitioning method includes, but is not limited to:
[0175] The wavelet coefficients 403 of both the high-frequency subband and the low-frequency subband are divided into basic coding units of 8x8 macroblocks 404 (unit is pixels).
[0176] For example, as described above, each subband uses macroblock 404 as the basic coding unit. The macroblock 404 currently to be encoded is referred to as the current macroblock 404. Specifically, the low-frequency subband processing path 430 encodes each macroblock 404 of the wavelet coefficients 403 of the low-frequency subband block by block. For example, encoding and prediction are performed on each macroblock 404. The encoding process for the current macroblock 404 will be described below; the processing flow for other macroblocks is the same, and will not be illustrated individually in this application. For example, in encoding, it refers to the macroblock currently being encoded; in decoding, it refers to the macroblock currently being decoded. The decoded macroblock in the reference image used for predicting the current macroblock 404 is called the reference block (i.e., the low-frequency subband reconstruction block 409 in the figure). The reference block is the block that provides the reference signal for the current block, where the reference signal represents the pixel value within the macroblock 404. The block in the reference image that provides the prediction signal for the current block can be called prediction block 405, where the prediction signal represents the pixel value, sample value, or sample signal within prediction block 405. For example, after traversing multiple reference blocks, an optimal reference block is found, and this optimal reference block will provide the prediction for the current block; this block is called prediction block 405.
[0177] Specifically, referring to Figure 4, the residual calculation unit 432 is used to obtain the current macroblock 404 and the prediction block 405 (further details of the prediction block 405 are provided below) to obtain the residual block 406. Specifically, the residual calculation unit performs residual calculation on the current macroblock 404 and the prediction block 405 to obtain the residual block 406. The residual calculation unit 432 outputs the residual block 406 to the transform / quantization unit 433.
[0178] The transform / quantization unit 433 is used to obtain the residual block 406 to obtain the residual quantized block 407. Specifically, the transform / quantization unit 433 performs transform and / or quantization processing on the residual block 406 to obtain the residual quantized block 407, which can also be called the quantized residual block. The residual quantized block 407 includes the quantization coefficients of the residual block 406.
[0179] The transform / quantization unit 433 outputs the residual quantization block 407 to the inverse quantization single / inverse transform unit 434 and the low-frequency subband entropy coding unit 439.
[0180] The inverse quantization / inverse transform unit 434, also known as the inverse quantization / inverse transform unit, is used to obtain the residual coefficients 407 to obtain the residual reconstruction block 408. Specifically, the inverse quantization / inverse transform unit 434 performs inverse quantization and / or inverse transform processing on the residual quantization block 407 to obtain the residual reconstruction block 408, which can also be called the inverse quantization residual block, etc. The residual reconstruction block 408 includes the inverse quantization coefficients of the residual block 406. The inverse quantization / inverse transform unit 434 outputs the residual reconstruction block 408 to the low-frequency subband splicing unit 436.
[0181] The dequantization / inverse transform unit 434 may include a dequantization unit and an inverse transform unit (not shown in the figure). The dequantization unit is used to dequantize the input coefficients, and the inverse transform unit is used to inverse transform the input coefficients.
[0182] The low-frequency subband reconstruction unit 435 is used to obtain a low-frequency subband reconstruction block 409 based on the prediction block 405 and the residual reconstruction block 408. Specifically, the low-frequency subband reconstruction unit 435 adds the residual reconstruction block 408 to the prediction block 405 to obtain the low-frequency subband reconstruction block 409, which can also be called a reconstructed low-frequency subband macroblock. Optionally, the low-frequency subband reconstruction unit 435 outputs the low-frequency subband reconstruction block 409 to the prediction unit 437 and the low-frequency subband splicing unit 436. Optionally, the low-frequency subband reconstruction unit 435 outputs the low-frequency subband reconstruction block 409 to the control unit 438.
[0183] The low-frequency subband stitching unit 436 is used to obtain the reconstructed low-frequency subband 411 based on the low-frequency subband reconstruction block 409, which can also be referred to as the reconstructed value of the low-frequency subband or the reconstructed data of the low-frequency subband. Optionally, the low-frequency subband stitching unit 436 outputs the reconstructed low-frequency subband 411 to the prediction unit 437. Optionally, the low-frequency subband stitching unit 436 outputs the reconstructed low-frequency subband 411 to the control unit 438.
[0184] Specifically, as described above, the low-frequency subband uses macroblocks as the basic coding unit, and the low-frequency subband splicing unit 436 can obtain M low-frequency subband reconstruction blocks of a low-frequency subband. The low-frequency subband splicing unit 436 can reconstruct the corresponding low-frequency subband based on the M low-frequency subband reconstruction blocks, that is, obtain the reconstructed low-frequency subband 411.
[0185] The control unit 438 is used to acquire control information 418 and output the control information 418 to the low-frequency subband entropy coding unit 439. For example, the control information 418 may include, but is not limited to, mode information 412. The control unit may determine the mode information 412 based on macroblock 404 (i.e., the current block); or it may determine the mode information 412 based on the current macroblock 404, the low-frequency subband reconstruction block 409, and the reconstructed low-frequency subband 411.
[0186] The mode information, also known as prediction mode information, is used to indicate the prediction mode (or prediction method) of the prediction unit 437, such as inter-frame or intra-frame prediction mode. The control unit 438 can output mode information 412 to the prediction unit 437.
[0187] Prediction unit 437, also known as prediction processing unit, is used to acquire mode information 412 and perform prediction processing based on mode information 412. Specifically, prediction unit 437 can select a prediction mode based on mode information 412. In one example, prediction unit 437 can acquire low-frequency sub-band reconstruction block 409 based on mode information 412 to obtain prediction block 405. Specifically, prediction unit 437 can perform intra-frame prediction based on low-frequency sub-band reconstruction block 409 to obtain prediction block 405. In another example, prediction unit 437 can acquire reconstructed low-frequency sub-band 411 based on mode information 412 to obtain prediction block 405.
[0188] The prediction unit 437 outputs prediction block 405 to the residual calculation unit 432 and the low-frequency sub-band splicing unit 436.
[0189] The low-frequency subband entropy coding unit 439 is used to obtain low-frequency subband encoded data 413, also known as encoded low-frequency subband, based on the residual quantization block 407 and mode information 412. Specifically, the low-frequency subband entropy coding unit 439 uses an entropy coding algorithm or scheme (e.g., variable length coding (VLC), context adaptive VLC (CAVLC), arithmetic coding, context adaptive binary arithmetic coding (CABAC), syntax-based context-adaptive binary arithmetic coding (SBAC), probability interval partitioning entropy (PIPE) coding, or other entropy coding methods or techniques) to entropy code the residual quantization block 407 and mode information 412 to obtain low-frequency subband encoded data 413 output in the form of, for example, an encoded bitstream.
[0190] Referring again to Figure 4, block partitioning unit 441, also known as high-frequency subband block partitioning unit, is used to obtain the high-frequency subband of the current subgraph 402 to obtain at least one macroblock 415 of the high-frequency subband of the subgraph 402. For a detailed description, please refer to the low-frequency subband section; it will not be repeated here. Specifically, block partitioning unit 441 partitions the high-frequency subband 414 of the current subgraph 402 (hereinafter referred to as the current high-frequency subband) into blocks based on the block partitioning method, obtaining at least one macroblock 415 of the current subgraph 402, for example, M macroblocks, where M is an integer greater than 0 (or an integer greater than 1). Other undescribed parts can be referred to the relevant description of block partitioning unit 431; it will not be repeated here.
[0191] Block partitioning unit 441 outputs the macroblocks of the current high-frequency subband one by one to quantization / conversion unit 442.
[0192] The transform / quantization unit 442 is used to transform and / or quantize the macroblock 415 to obtain the quantization coefficients 416 of the high-frequency subband block (i.e., the quantization coefficients of the current macroblock). The transform / quantization unit 442 outputs the quantization coefficients 416 of the high-frequency subband block to the high-frequency subband entropy coding unit 443.
[0193] The high-frequency subband entropy coding unit 443 is used to perform entropy coding on the data to be encoded to obtain high-frequency subband encoded data 417. The data to be encoded may include, but is not limited to, the quantization coefficients and syntax elements of each high-frequency subband block. The high-frequency subband encoded data 417 includes, but is not limited to, HH subband encoded data, HL subband encoded data, and LH subband encoded data.
[0194] The high-frequency subband entropy coding unit 443 uses an entropy coding algorithm or scheme to encode the data to be coded. The aforementioned entropy coding scheme can be, for example, at least one of the following: VLC scheme, CAVLC scheme, arithmetic coding scheme, and CABAC.
[0195] The encoding and decoding method provided in this application supports two scenarios: full I-frame configuration and I / P frame alternating encoding configuration. The encoder architecture shown in Figure 4 adds relevant modules required for the prediction process on the basis of the wavelet transform architecture, which can improve the compression efficiency of I / P frame alternating encoding for scenarios such as fixed camera positions and slow camera movement.
[0196] Optionally, encoder 40 may also include, but is not limited to, a combining unit (not shown in the figure), also known as a multiplexer (MUX). The combining unit is used to generate a bitstream based on low-frequency subband coded data and high-frequency subband coded data.
[0197] Specifically, the combining unit writes low-frequency subband coded data 413 into the bitstream and writes high-frequency subband coded data 417 into the bitstream. In this embodiment, by encoding the low-frequency subband and high-frequency subband separately, the low-frequency subband coded data and high-frequency subband coded data can be decoded independently. That is, at the decoding end, it can independently decode the low-frequency subband coded data and high-frequency subband coded data in the bitstream, thereby improving decoding efficiency.
[0198] Referring to Figure 7A, which is a schematic / conceptual block diagram of an exemplary decoder, in the example of Figure 7A, the decoder receives, for example, a bitstream encoded by an encoder to obtain a decoded image of the original image, also referred to as a decoded image, reconstructed image, etc. During the decoding process, the decoder receives the bitstream from the encoder, including, but not limited to, image header information and image data.
[0199] In the example shown in Figure 7A, the decoder includes, but is not limited to: low-frequency subband processing path 710, high-frequency subband processing path 720, wavelet inverse transform unit 730, image combination unit 740 (also known as image stitching unit), etc.
[0200] For example, the low-frequency subband processing path 710 is used to acquire low-frequency subband encoded data to obtain reconstructed low-frequency subband 706 (also known as decoded low-frequency subband). The low-frequency subband processing path includes, but is not limited to: low-frequency subband entropy decoding unit 711, inverse quantization / inverse transform unit 74 (also known as low-frequency subband inverse quantization / inverse transform unit), low-frequency subband reconstruction unit 713, low-frequency subband splicing unit 715, prediction unit 714, etc.
[0201] The high-frequency subband processing path 720 is used to acquire high-frequency subband encoded data to obtain reconstructed high-frequency subband 731, which can also be called the reconstructed value of high-frequency subband or the reconstructed data of high-frequency subband, including but not limited to: high-frequency subband entropy decoding unit 721, inverse quantization / inverse transform unit 721 (also called high-frequency subband inverse quantization / inverse transform unit), high-frequency subband reconstruction unit 731, etc.
[0202] In some instances, the decoder shown in Figure 7A can perform a decoding process that is largely the reverse of the encoding process described with reference to the encoder in Figure 4.
[0203] The decoding method in the embodiments of this application will be described in detail below with reference to the decoder 70 shown in Figure 7A.
[0204] For example, decoder 70 can obtain high-frequency subband encoded data and low-frequency subband encoded data in the bitstream based on the image header information in the bitstream. Furthermore, as described above, during the encoding process, the encoder uses macroblocks as the basic encoding unit, and correspondingly, during the decoding process, the decoder also uses macroblocks (e.g., encoded macroblocks) as the basic decoding unit for decoding.
[0205] For example, the low-frequency subband entropy decoding unit 711 performs entropy decoding on the low-frequency subband encoded data 701 in the bitstream, using macroblocks as the basic decoding unit, to obtain the quantization coefficients 702 (i.e., the quantization coefficients of the current macroblock) and syntax elements 707 of the low-frequency subband block. The description of the quantization coefficients 702 of the low-frequency subband can be found on the encoder side and will not be repeated here. Specifically, the low-frequency subband entropy decoding unit 711 obtains the encoded macroblocks (i.e., the encoded data of the macroblocks) of the low-frequency subbands (e.g., LL subbands) of each subgraph in the bitstream, and performs entropy decoding on each encoded macroblock to obtain the quantization coefficients 702 (which can be simply referred to as the quantization coefficients of the macroblock of the low-frequency subband) and syntax elements 707 of the corresponding low-frequency subband for each encoded macroblock. During the decoding process, the currently decoded encoded macroblock can be called the current block.
[0206] The low-frequency subband decoding unit is used to output the quantization coefficients 702 of the low-frequency subband block to the inverse quantization / inverse transform unit 712, and to output the mode information 707 to the prediction unit 714.
[0207] The inverse quantization / inverse transform unit 712 is used to obtain the quantization coefficients 702 of the low-frequency subband block to obtain the inverse quantization coefficients 703 of the low-frequency subband block. Alternatively, it can be the inverse transform coefficients of the current block of the low-frequency subband (depending on whether inverse transform processing was performed). Specifically, the inverse quantization / inverse transform unit 712 performs inverse quantization on the quantization coefficients of the current block of the low-frequency subband, or performs both inverse quantization and inverse transform, to obtain the inverse quantization coefficients of the current block of the low-frequency subband. The inverse quantization / inverse transform unit 712 outputs the inverse quantization coefficients 703 of the low-frequency subband block to the low-frequency subband reconstruction unit 713, for example, the inverse quantization coefficients of the current block of the low-frequency subband.
[0208] The low-frequency subband reconstruction unit 713 is used to obtain the low-frequency subband reconstruction block 704, which can also be called the reconstruction coefficient of the low-frequency subband block, based on the quantization coefficients 703 and the prediction block 705 of the low-frequency subband. Specifically, the low-frequency subband reconstruction unit 713 adds the prediction block to the inverse quantization coefficients of the current block of the low-frequency subband to obtain the low-frequency subband reconstruction block 704 corresponding to the current macroblock.
[0209] The prediction unit 714 is used to acquire mode information 412 and perform corresponding prediction processing according to the mode information 412. For example, it can perform intra-frame prediction based on the low-frequency subband reconstruction block 704, or perform inter-frame prediction based on the reconstructed low-frequency subband 706. Its execution method can be referred to the coding side, and will not be repeated here. The prediction unit 714 outputs prediction block 705 to the low-frequency subband reconstruction block 704 unit.
[0210] For example, the high-frequency subband entropy decoding unit 721 acquires the high-frequency subband encoded data 707 in the bitstream, and, using macroblocks as the basic decoding unit, acquires the quantization coefficients 708 of each high-frequency subband block (which are the quantization coefficients of the current macroblock). Specifically, the high-frequency subband entropy decoding unit 721 performs entropy decoding on the current block of the high-frequency subband encoded data 707 to obtain the quantization coefficients of the current block of the high-frequency subband. Optionally, based on entropy decoding, control information corresponding to the current block can also be acquired, such as mode information 412. The high-frequency subband entropy decoding unit 721 outputs the quantization coefficients 708 of the high-frequency subband block to the inverse quantization / inverse transform unit 722.
[0211] The inverse quantization / inverse transform unit 722, also known as the high-frequency subband inverse quantization / inverse transform unit, is used to obtain the quantization coefficients 708 of the high-frequency subband block to obtain the reconstruction coefficients 709 of the high-frequency subband block. The reconstruction coefficients can be either inverse quantization coefficients after inverse quantization processing, or inverse transform coefficients after inverse quantization and inverse transform processing.
[0212] The high-frequency subband reconstruction unit 723 (also known as the high-frequency subband splicing unit) is used to obtain the reconstruction coefficients 709 of the high-frequency subband block to obtain the reconstructed high-frequency subband 731, which can also be referred to as the reconstructed value or reconstructed data of the high-frequency subband. Specifically, the high-frequency subband reconstruction unit 723 can obtain the reconstruction coefficients corresponding to each macroblock of the high-frequency subband, that is, reconstruct the high-frequency subband block. The high-frequency subband reconstruction unit 723 can splice the obtained multiple macroblocks to obtain the corresponding high-frequency subband. Among them, the reconstructed high-frequency subband may optionally include reconstructing the HL subband (e.g., the reconstruction coefficients of the HL subband), reconstructing the HH subband (e.g., the reconstruction coefficients of the HH subband), and reconstructing the LH subband (e.g., the reconstruction coefficients of the LH subband).
[0213] The inverse wavelet transform unit 730 is used to acquire the reconstructed high-frequency subband 731 and the reconstructed low-frequency subband 706 to obtain the reconstructed sub-image 732. Specifically, the inverse wavelet transform unit 730 acquires the reconstructed low-frequency subband 706 output by the low-frequency subband stitching unit 715 and the reconstructed high-frequency subband 731 output by the high-frequency subband reconstruction unit 723, and performs an inverse wavelet transform on the reconstructed low-frequency subband 706 and the reconstructed high-frequency subband 731 to obtain the reconstructed sub-image 732. The inverse wavelet transform unit 730 outputs the reconstructed sub-image 732 to the image combining unit (also known as the image stitching unit, etc.).
[0214] Image combining unit 740 is used to acquire reconstructed sub-images 732 to obtain a reconstructed image 733 of the original image, which can also be called a decoded image or a decoded image, etc. Specifically, image combining unit 740 can acquire N reconstructed sub-images (N is an integer greater than 0) of the image (referring to the original image), and stitch (or combine) the N reconstructed sub-images according to the division method (including size and position) of each reconstructed sub-image during encoding to obtain the reconstructed image 733.
[0215] Optionally, after acquiring the reconstructed image, the image combining unit 740 can determine whether the reconstructed image contains a padding portion based on the image size information in the image header information and the size information of the current reconstructed image. In one example, if the size of the current reconstructed image is the same as the size indicated by the image size information (i.e., the same as the original image size), the image combining unit 740 can send the reconstructed image to the display device. In this case, the sizes of the displayed image, the original image, and the reconstructed image are all the same. In another example, if the size of the current reconstructed image is different from the size indicated by the image size information (e.g., larger than the original image size), the image combining unit 740 can remove the padding portion of the current reconstructed image based on the size indicated by the image size information to obtain the displayed image. The size of the displayed image is the same as the size of the original image. Optionally, the decoder is used, for example, to output the reconstructed image through the decoder's output port (or output interface) for presentation to the user or for the user to view.
[0216] Other variations of the decoder can be used to decode compressed bitstreams.
[0217] Referring to Figure 7B, which is an exemplary schematic / conceptual block diagram of a decoder, in this example, the wavelet inverse transform unit 730 is used to obtain the reconstruction coefficients 709 of the high-frequency subband block, i.e., the high-frequency subband reconstruction block, and the low-frequency subband reconstruction block 704 output by the low-frequency subband reconstruction block unit 713. The wavelet inverse transform is then performed on the high-frequency subband reconstruction block (e.g., including HH subband reconstruction blocks, HL subband reconstruction blocks, and LH subband reconstruction blocks) and the low-frequency subband reconstruction block 704 to obtain the reconstruction block 734, which is the reconstruction block of the current subgraph, and can also be referred to as the reconstruction data of the current block of the current subgraph or the reconstruction value of the current block of the current subgraph, etc.
[0218] The wavelet inverse transform unit 730 outputs a reconstructed block 734 to the sub-image combination unit 750. The sub-image combination unit 750 can obtain a reconstructed sub-image 732 of the current sub-image based on at least one reconstructed block corresponding to the current sub-image; this can also be referred to as the reconstructed value or reconstructed data of the current sub-image. The undescribed parts of Figure 7B can be referred to Figure 7A, and will not be elaborated here.
[0219] The bitstream output by the encoder in the embodiments of this application will be described in detail below. The bitstream structure described below can be applied to the encoder shown in Figure 4, and of course, it can also be applied to other encoder variations based on Figure 4.
[0220] Referring to Figure 8, which is an exemplary schematic diagram of the bitstream structure, the bitstream in the example of Figure 8 includes, but is not limited to, image header information and image data.
[0221] For example, the image data includes at least one image data region (also referred to as an image data sub-region), such as, but not limited to, a first image data region and a second image data region. During the encoding process, the encoder (e.g., through a combination unit) writes high-frequency subband encoded data and low-frequency subband encoded data into the bitstream. Specifically, the encoder writes high-frequency subband encoded data into the first image data region and low-frequency subband encoded data into the second image data region. The order in which the encoded data is written is merely illustrative and will not be repeated below.
[0222] For example, image header information includes, but is not limited to, offset information and image size information.
[0223] For example, image size information is used to indicate the size of the original image. As mentioned above, during the encoding process, some sub-images may be padded during sub-image partitioning to ensure that the length and width of each sub-image are multiples of 16. Thus, during decoding, the size of the reconstructed image obtained by the decoder may be larger than the original image size. The decoder can process the reconstructed image based on the image size information to remove the padded portions.
[0224] For example, offset information is used to indicate the position of a data region in the bitstream, and can also be understood as indicating the position of independently decodeable coded data in the bitstream. When decoding coded data (i.e., the bitstream) according to this application, the offset information in the image header information can be used to obtain independently decodeable coded data, and decoding operations can be performed on the coded data. The independently decodeable coded data (e.g., low-frequency subband coded data and high-frequency subband coded data) can be decoded synchronously during decoding to improve decoding efficiency.
[0225] In one example, the offset information can be the length of the image data region containing adjacent, independently decodeable encoded data in the bitstream.
[0226] In another example, the offset information can be the offset (i.e., the difference) between the starting position of the image data region where the independently decoded encoded data is located and the ending position of the image header information.
[0227] It should be noted that the embodiments in this application only use a single image stream as an example for illustration, that is, the stream includes only one image data. During the encoding of video images, the encoder can generate a bitstream after encoding each image, that is, the bitstream includes multiple image data, and each image data carries the encoded data of the corresponding image.
[0228] Specifically, in the example shown in Figure 8, the high-frequency subband encoded data (including LH subband encoded data, HH subband encoded data and HL subband encoded data) of each sub-image of the image are continuously written into the first image data area.
[0229] For example, as shown in Figure 8, sub-images 1-HL-MB0, 1-HH-MB0, and 1-LH-MB0 are consecutively written into the first image data region. Here, 1-HL-MB0 represents the encoded macroblock MB0 of the HL subband of sub-image 1, 1-HH-MB0 represents the encoded macroblock MB0 of the HH subband of sub-image 1, and 1-LH-MB0 represents the encoded macroblock MB0 of the LH subband of sub-image 1. The figure only shows the encoded data structure of sub-image 1 in the bitstream; the other sub-images are similar and will not be illustrated individually here.
[0230] In this example, during decoding, the decoding end can decode the high-frequency subband encoded data according to the sub-image order, that is, each sub-image in the first image data region is decoded independently. The low-frequency subband encoded data is also decoded according to the sub-image order, that is, each sub-image in the second image data region is decoded independently. When decoding the first image data region, the decoding end can decode each coded macroblock one by one according to the coded macroblock order of each sub-image in the region. That is, the three high-frequency subband encoded data of sub-image 1 are written continuously into the first image data region; therefore, during decoding, the three high-frequency subband encoded data of sub-image 1 can be decoded one by one to obtain the decoded high-frequency subband. The structure of the LL subband encoded data is also based on each sub-image as the granularity, and the encoded data of each sub-image includes the LL subband encoded data of each macroblock in the sub-image.
[0231] In the embodiments of this application, multiple independently decoded encoded data can be decoded simultaneously, or one or more high-frequency subbands can be decoded simultaneously, and the number of simultaneous decodes depends on the decoder hardware performance.
[0232] Referring to Figure 9, which is a flowchart illustrating an exemplary encoding method, the specific steps include, but are not limited to, the following:
[0233] S901, obtain N quantization coefficients of the block to be encoded, including non-zero quantization coefficients, where N is an integer greater than 1;
[0234] For example, the block to be encoded can be a macroblock, such as an 8x8 block (unit is pixels). The block to be encoded can include chroma components and luminance components, or it can be understood that the block to be encoded includes chroma transformation blocks and luminance transformation blocks.
[0235] For example, in the embodiments of this application, the quantization coefficients of the block to be encoded include the quantization coefficients of the chroma component and the quantization coefficients of the luma component. For example, in the wavelet architecture shown in Figure 4, the residual quantization block 407 (also called the quantization coefficient block) can optionally be a quantization coefficient block of the chroma component or a quantization coefficient block of the luma component. The sizes of the quantization coefficient blocks of the chroma component and the quantization coefficient blocks of the luma component can be the same or different, and both are less than or equal to the size of the macroblock. For example, the size of the quantization coefficient block of the luma component can be 4x4, that is, the quantization coefficients of the macroblock include the quantization coefficients in the four 4x4 quantization coefficient blocks corresponding to the chroma component. Accordingly, in the embodiments of this application, the quantization coefficients of the block to be encoded include the quantization coefficients in the quantization coefficient block of the chroma component and the quantization coefficients in the quantization coefficient block of the luma component. The quantization coefficient block is a matrix that includes multiple quantization coefficients.
[0236] Specifically, taking the chroma component as an example, as shown in Figure 4, the encoder can obtain the residual block of the chroma component based on the current block (i.e., macroblock 404) and the prediction block. The encoder quantizes the residual block to obtain the residual quantization block 407 (which can also be called the quantization coefficient block of the chroma component).
[0237] In another example, the quantization coefficient of the block to be encoded can be quantization coefficient 209 as shown in Figure 2.
[0238] Referring to Figure 10, which is a schematic flowchart illustrating an exemplary encoding method, step S901 in this embodiment may also include, but is not limited to, the following steps:
[0239] Specifically, the encoder acquires quantization coefficient blocks (which can be quantization coefficient blocks for the chroma component or quantization coefficient blocks for the luminance component, as will not be repeated below).
[0240] The encoding and decoding methods in this application embodiment are applied to the encoding and decoding process of quantization coefficient blocks including non-zero quantization coefficients. That is, the quantization coefficient blocks involved in this application embodiment are all non-all-zero quantization coefficient blocks, meaning they include at least one non-zero quantization coefficient. Optionally, the encoder can encode a `coded_block_flag` syntax element corresponding to each quantization coefficient block during encoding. This syntax element is used to indicate whether the corresponding quantization coefficient block includes non-zero coefficients. `coded_block_flag` being 0 indicates that the quantization coefficient block does not include non-zero coefficients, i.e., the quantization coefficients in the quantization coefficient block are all zeros. `coded_block_flag` being 1 indicates that the quantization coefficient block includes non-zero coefficients. Thus, the decoding end can determine whether the corresponding quantization coefficient block includes non-zero quantization coefficients by decoding the `coded_block_flag` syntax element. If non-zero quantization coefficients are included, decoding can continue according to the decoding method in this application embodiment.
[0241] Referring again to Figure 10, the encoder scans the acquired quantization coefficient block to obtain a scan result. The scan result includes the quantization coefficients in the scanned quantization coefficient block, and the scan result is one-dimensional data. The encoder can encode based on the scan result (i.e., the quantization coefficients of the block to be encoded) to obtain a bitstream.
[0242] Referring to Figure 11, which is an exemplary scanning diagram, this example illustrates a 4x4 quantization coefficient block, comprising 16 quantization coefficients, where each square represents one quantization coefficient. After acquiring the quantization coefficient block, the encoder scans it according to a preset scanning order to obtain the scanning result of the current quantization coefficient block. In this embodiment, the scanning order may optionally start from the direct current (DC) quantization coefficient of the quantization coefficient block (i.e., the quantization coefficient in the upper left corner) and end at the last quantization coefficient of the current quantization coefficient block (i.e., the quantization coefficient in the lower right corner).
[0243] Optionally, the scanning method in Figure 11 is a horizontal scanning method. This method is only an illustrative example. In other embodiments, other scanning sequences such as vertical scanning can also be used to scan the quantization coefficient block to obtain the corresponding scanning results. The scanning sequence can be set according to actual needs.
[0244] In this embodiment, the scanning result is one-dimensional data. That is, the encoder can obtain the one-dimensional quantization coefficients corresponding to the quantization coefficient block by scanning the quantization coefficient block.
[0245] For example, referring to Figure 12, which is an exemplary schematic diagram of the scanning result, the encoder scans the quantization coefficient block in Figure 12 in the order shown in Figure 11 to obtain a one-dimensional scanning result. In this example, the quantization coefficient block includes 16 quantization coefficients, namely X_0, X_1, ..., X15. The one-dimensional data in the scanning result is arranged in the order of scanning; that is, the first quantization coefficient in the scanning result is the first quantization coefficient scanned, which in this example is the DC quantization coefficient, and the 16th quantization coefficient in the scanning result is the last quantization coefficient scanned, which in this example is the last quantization coefficient located at the lower right corner of the quantization coefficient block.
[0246] In one example, this application can represent the corresponding quantization coefficient as the i-th quantization coefficient in the scan coefficients by the number information. The i-th quantization coefficient in the scan result refers to its order in the scan sequence. Accordingly, the value of i is an integer greater than 0, that is, counting from 1. As shown in Figure 14, the DC quantization coefficient is the first quantization coefficient in the scan result (also called the first quantization coefficient), and the last quantization coefficient in the quantization coefficient block (i.e., X_15) is the sixteenth quantization coefficient in the scan result.
[0247] In another example, this application can use position information to represent the position of the corresponding quantization coefficient in the scan result. The value of the position information is (number - 1), and in this embodiment, the position value starts counting from 0. As shown in Figure 14, the position information value of the DC quantization coefficient in the scan result is 0, which is position 0, also known as the 0th bit. The position information value of the last quantization coefficient in the quantization coefficient block, i.e., the last quantization coefficient scanned, is 15, which is the number of quantization coefficients in the quantization coefficient block, and its value is N (in this embodiment, it can be denoted as MaxNumCoeff, for example, 16) minus 1. The position of the quantization coefficient in the scan result described in this embodiment can be described using any of the above methods. Typically, the second position indication method is used during encoding and decoding.
[0248] Optionally, in the embodiments of this application, the quantization coefficients of the block to be encoded can be understood as the quantization coefficients in the quantization coefficient block, or as the scanning result of the quantization coefficient block of the block to be encoded. Specifically, before encoding the quantization coefficients, a scanning operation needs to be performed to obtain one-dimensional data corresponding to the quantization coefficient block.
[0249] S902, obtain the context index corresponding to each of the M first identifiers. The M first identifiers correspond to the M quantization coefficients respectively. Each of the M first identifiers is used to indicate whether the corresponding quantization coefficient is zero. The first identifier is represented by a binary bit bin. The N quantization coefficients include M quantization coefficients, where M is an integer greater than 1.
[0250] In this embodiment, the encoder encodes N quantization coefficients. During the encoding process, the encoder encodes the first identifier of each of the M quantization coefficients out of the N quantization coefficients. Specifically, the encoder obtains the context index (denoted as ctxInx) corresponding to the first identifier of each of the M quantization coefficients.
[0251] For example, the first flag is denoted as significant_coeff_flag.
[0252] For example, each first identifier is represented by a bin, and the value of its bin (referred to as bin value) can be 0 or 1.
[0253] For example, the first identifier is used to indicate whether the corresponding quantization coefficient is 0. Wherein: a value of 0 for the first identifier indicates that the corresponding quantization coefficient is 0, and a value of 1 for the first identifier indicates that the corresponding quantization coefficient is non-zero, i.e., a non-zero quantization coefficient. The values in this embodiment are merely illustrative examples and can be set according to actual needs.
[0254] Referring to Figure 13, which is a schematic flowchart illustrating an exemplary encoding method, in this embodiment, S902 further includes, but is not limited to, the following steps:
[0255] The encoder determines M quantization coefficients. In embodiments of this application, the M quantization coefficients may include the coefficient between the DC quantization coefficient and the last non-zero quantization coefficient. In some instances, the M quantization coefficients may include the DC quantization coefficient in the scan result, and at least one quantization coefficient between the DC quantization coefficient and the last non-zero quantization coefficient (if present).
[0256] Wherein: the last non-zero quantization coefficient in the embodiments of this application may optionally be the last quantization coefficient whose value is not 0 when scanned.
[0257] For example, referring to Figure 14A, which is an exemplary schematic diagram of the scan result, the encoder still uses a 4x4 block as an example. Based on the scan result, the encoder determines that the last non-zero quantization coefficient in the scan result is X_15 (for example, the value is -9, which is only an illustrative example), and further determines that the position value of the last non-zero quantization coefficient is 15 (i.e., position 15).
[0258] To illustrate further, refer to Figure 14B, which is an exemplary schematic diagram of the scan result. In this example, we still use a 4x4 block as an example. Based on the scan result, the encoder determines the last non-zero quantization coefficient in the scan result as X_14 (e.g., a value of -9, merely illustrative), where the value of the last quantization coefficient in the scan result is 0. The encoder further determines the position value of the last non-zero quantization coefficient as 14 (i.e., position 14). That is, in the scan result, all quantization coefficients after the last non-zero quantization coefficient (if any) are 0. Referring again to Figure 13, the encoder obtains the first identifier for each of the M quantization coefficients. In this embodiment, the first identifier is used to indicate whether the corresponding quantization coefficient is 0. The encoder can determine the corresponding first identifier (significant_coeff_flag) based on the value of the quantization coefficient. In one example, if the quantization coefficient is 0, the corresponding significant_coeff_flag value is 0. In another example, if the quantization coefficient is non-zero, the corresponding significant_coeff_flag value is 1.
[0259] The encoder obtains the context index (ctxInx) corresponding to the first identifier of the M quantization coefficients. In this embodiment, the encoder obtains the first identifier of the M quantization coefficients in the encoding order and encodes them.
[0260] Specifically, the encoder can encode the significance_coeff_flag of each quantization coefficient in reverse order of the scan sequence. This can be understood as the process of encoding the significance_coeff_flag of M quantization coefficients being executed in the encoding order. That is, the encoder encodes the quantization coefficients in the scan result in the encoding order. When encoding the M quantization coefficients described in this embodiment, the encoder obtains the first identifier of the currently encoded quantization coefficient, assigns a context index to the first identifier, and encodes the first identifier based on the context index of the first identifier of the current quantization coefficient. After encoding is completed, the encoder continues to encode the significance_coeff_flag of the next quantization coefficient (if the next encoded quantization coefficient also belongs to the M quantization coefficients). Typically, the M quantization coefficients are M consecutive quantization coefficients from the N quantization coefficients. In this embodiment, the M quantization coefficients include the quantization coefficients between the DC quantization coefficient and the last non-zero quantization coefficient as an example.
[0261] Optionally, this embodiment only uses the example of M being greater than 1, i.e., the encoder encodes at least two adjacent quantization coefficients' first identifiers. In other embodiments, the encoder may encode only one of the quantization coefficients' first identifiers, or it may not encode any of the quantization coefficients' first identifiers. The implementation of the encoder's encoding and decoding of a quantization coefficient's first identifier can also refer to the encoding and decoding schemes in this embodiment.
[0262] Optionally, as described above, the scanning order in this embodiment is: scanning from the DC quantization coefficient of the quantization coefficient block to the last quantization coefficient of the quantization coefficient block, as shown in Figure 11. Correspondingly, the encoding order (and decoding order below) described in this embodiment is the reverse of the scanning order, optionally: the encoder encodes from the last non-zero quantization coefficient in the scanning result to the DC quantization coefficient. Wherein: quantization coefficients after the last non-zero quantization coefficient (referring to quantization coefficients located after the last non-zero quantization coefficient in the scanning order) (if they exist, for example, as shown in Figure 14B) are all 0 values and do not need to be encoded. Of course, in some instances, the encoding order (and decoding order) can also be the same as the scanning order; the order in this embodiment is merely an illustrative example.
[0263] In this embodiment, during the encoding of the first identifier, the context indices of two first identifiers with adjacent encoding orders are different. That is, when the encoder assigns a context index to the first identifier of the current quantization coefficient, its corresponding context index is different from the context index of the previously encoded first identifier.
[0264] For example, refer to Figure 15, which is an exemplary schematic diagram of context index allocation. In this example, taking the M quantization coefficients as the quantization coefficients between the DC quantization coefficient and the last non-zero quantization coefficient, when encoding the significance_coeff_flag of the quantization coefficient X_2, the significance_coeff_flag of quantization coefficient X_2 and the significance_coeff_flag of the already encoded quantization coefficient X_3 are adjacent significance_coeff_flags. As mentioned above, the context indices of two adjacent significance_coeff_flags are different during encoding. For example, the context index used to encode the significance_coeff_flag of quantization coefficient X_3 is ctxInx0, and the context index used to encode the significance_coeff_flag of quantization coefficient X_2 is ctxInx1. These values are only illustrative examples.
[0265] Therefore, to ensure that adjacent significant_coeff_flag values have different context indices during encoding, in this embodiment, when the encoder assigns a context index to the i-th quantization coefficient in the scanning sequence, the value of the corresponding context index can be determined based on the size of the quantization coefficient block, the color components of the quantization coefficient block, and i. The i-th quantization coefficient is any one of the M quantization coefficients.
[0266] Specifically, the encoder obtains the context index value of the first identifier of the i-th quantization coefficient based on the context index base value and the context index offset. Wherein: the context value of the first identifier is the sum of the context index base value (denoted as ctxIdx_base) and the context index offset (also called the context index offset value, denoted as pos2ctx_map), expressed as: ctxIdx=ctxIdx_base+pos2ctx_map[i].
[0267] For example, the encoder obtains the context index base value of the first identifier of the i-th quantization coefficient based on the color components and the size of the quantization coefficient block. That is, the context index base value is associated with the size of the quantization coefficient block and the color components, as shown in Table 1:
[0268] Table 1
[0269] Referring to Table 1, LUMA_8x8 represents a quantization block of the luminance component with a quantization block size of 8x8, and its corresponding ctxIdx_base is 0. LUMA_4x4 represents a quantization block of the luminance component with a quantization block size of 4x4, and its corresponding ctxIdx_base value is 14. CB_4x8 represents a quantization block of the chrominance component U with a quantization block size of 4x8, and its corresponding ctxIdx_base value is 28. CR_4x8 represents a quantization block of the chrominance component V with a quantization block size of 4x8, and its corresponding ctxIdx_base value is 42.
[0270] For example, the encoder obtains the context index offset of the significance_coeff_flag of the i-th quantization coefficient based on i and a preset context index offset table. Specifically, the encoder has a preset context index offset table corresponding to each size of quantization coefficient block. The encoder obtains the corresponding context index offset table based on the size of the quantization coefficient block.
[0271] For example, the encoder's preset offset table is as follows: pos2ctx_map8x8={-1,0,1,0,1,2,3,2,3,4,5,4,5,4,5,6,7,6,7,6,7,8,9,8,9,8,9,8,9,8,9,8,9,10,11,10,11,10,11,10,11,10,11,10,11,10,11,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,-1}; pos2ctx_map4x8={-1,0,1,2,3,4,5,6,7,6,7,6,7,8,9,8,9,8,9,10,11,10,11,10,11,12,13,12,13,12,13,-1}; pos2ctx_map4x4={-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,-1}
[0272] Wherein: pos2ctx_map4x4 is the context index offset table corresponding to the quantization coefficient block with a size of 4x4, pos2ctx_map4x8 is the context index offset table corresponding to the quantization coefficient block with a size of 4x8, and pos2ctx_map8x8 is the context index offset table corresponding to the quantization coefficient block with a size of 8x8.
[0273] In this embodiment of the application, each context index offset table includes N context index offsets, and the N context index offsets correspond one-to-one with the N positions in the scanning order.
[0274] In one possible implementation, if the encoder does not encode the DC quantization coefficients and the significance_coeff_flag of the last non-zero quantization coefficient, then the first and last context index offsets in each context index quantization coefficient table are set to "-1", which is a value used to indicate that the context index offset will not be used, as shown in the table content in the example above. Alternatively, this value can be omitted (i.e., not included), meaning the table includes N-2 context index offsets.
[0275] In another possible implementation, if the encoder does not encode the significance_coeff_flag of the last non-zero quantization coefficient, the value of the last context index offset in each context index quantization coefficient table is "-1", or the value is omitted (i.e. not included), that is, the table includes N-1 context index offsets.
[0276] Specifically, the encoder can determine the corresponding context index offset table based on the size of the quantization coefficient block. Then, based on the position of the quantization coefficient corresponding to the currently to-be-encoded significant_coeff_flag in the scan result (i.e., its position in the scan order), it searches the context index offset table for the context index offset corresponding to that position.
[0277] The following explanation uses the context index offset quantization table pos2ctx_map4x4 as an example. This table includes 16 context index offsets (hereinafter referred to as offsets). In this example, the encoder does not encode the DC quantization coefficient and the significance_coeff_flag of the last non-zero quantization coefficient. Accordingly, the values of the first and last context index offsets in this table are "-1". Each offset corresponds to a position in the scan sequence. For example, the second offset "0" corresponds to the second quantization coefficient in the scan sequence, i.e., the quantization coefficient at position 1. Specifically, when the encoder encodes the significance_coeff_flag of the quantization coefficient at position 1, it can look up the corresponding context index offset table, i.e., pos2ctx_map4x4, based on the size of the current block (e.g., 4x4). The encoder looks up the context index offset corresponding to the quantization coefficient of the first identifier to be encoded in the scan result (e.g., position 1), which is 0.
[0278] In the embodiments of this application, two or more consecutive context index offsets in each context index offset table are different.
[0279] Furthermore, in this embodiment, the values in each context index offset table come from the same set of values. Optionally, the set of values includes 16 values, for example, 0 to 15, which can be set according to actual needs. Accordingly, the context index offset in each context index offset table is a value in the range of 0 to 15, and two or more adjacent context index offsets are different.
[0280] In one possible implementation, as described above, if the encoder does not encode the DC quantization coefficients and the significance_coeff_flag of the last non-zero quantization coefficient, then the set of values includes N-2 values, for example, 0 to 13.
[0281] In another possible implementation, if the encoder does not encode the significance_coeff_flag of the last non-zero quantization coefficient, then the set of values includes N-1 values, for example, 0 to 14.
[0282] S903, based on the context indices corresponding to the M first identifiers respectively, the M first identifiers are encoded to obtain the bitstream of the image to be encoded, the image to be encoded includes the block to be encoded; wherein: the context indices of adjacent first identifiers are different during encoding.
[0283] For example, the encoder encodes the significance_coeff_flag of each of the M quantization coefficients one by one in the encoding order. The encoder encodes the current significance_coeff_flag (referred to as the current significance_coeff_flag) based on the context index of the current significance_coeff_flag to be encoded, and obtains the encoded data of significance_coeff_flag.
[0284] Referring to Figure 16, which is an exemplary schematic diagram of the bin value encoding process, as mentioned above, the length of `significant_coeff_flag` is 1, meaning it includes one bin, whose bin value can be 0 or 1. The encoder obtains the bin value of the current `significant_coeff_flag`, also known as the bin value to be encoded. Furthermore, the encoder obtains the context index of the current `significant_coeff_flag`'s bin value. The encoder performs context modeling based on the context index of the current `significant_coeff_flag`'s bin value to obtain the context probability model corresponding to that context index. For example, the context probability models are different for different context indices.
[0285] Referring again to Figure 16, specifically, the encoder encodes the current bin value based on the context probability model of the current bin value (that is, the context probability model corresponding to the context index of the current bin value) to obtain the encoded data of the current bin. Optionally, the encoder can also update the context probability model corresponding to the context index of the current bin based on the encoded data of the current bin (not shown in the figure).
[0286] Optionally, in this application, the context indices of two or more adjacent significant_coeff_flags are different during encoding. The encoder can encode two or more adjacent significant_coeff_flags in parallel without waiting for the context probability model update process.
[0287] In one possible implementation, during the encoding process, the encoder may also encode a second identifier for each of the L quantization coefficients out of the N quantization coefficients, wherein the second identifier is used to indicate whether the corresponding quantization coefficient is greater than a first value. In this embodiment, the first value is 1, and can be set according to actual needs.
[0288] In this embodiment, the encoding process for the second identifiers of the L quantization coefficients includes: the encoder obtaining the second identifier of each of the L quantization coefficients, and obtaining the context index corresponding to each second identifier. The second identifier is also represented using a bin, where L is an integer greater than 1. The encoder can encode the L second identifiers based on their respective second context indices to obtain encoded data for the L second identifiers. The encoded data for the L second identifiers is then written into the bitstream.
[0289] Optionally, in this embodiment, the last non-zero quantization coefficient is not included in the M quantization coefficients; that is, the encoder does not encode the significant_coeff_flag of the last non-zero quantization coefficient. The last non-zero quantization coefficient may be included in the L quantization coefficients; that is, the encoder may encode the second identifier of the last non-zero quantization coefficient, such as coeff_abs_level_greater1_flag. In this embodiment, except for the last non-zero quantization coefficient, the other quantization coefficients in the L quantization coefficients are included in the M quantization coefficients. That is, if a quantization coefficient corresponds to a second identifier, i.e., coeff_abs_level_greater1_flag, then it also corresponds to a first identifier, i.e., significant_coeff_flag. The encoder encodes the first identifier and the second identifier. If a quantization coefficient does not correspond to a second identifier, it may correspond to a first identifier, which can be set according to actual needs.
[0290] Accordingly, in the embodiments of this application, if a quantization coefficient (e.g., a first quantization coefficient) corresponds to a first identifier (significant_coeff_flag) and a second identifier (coeff_abs_level_greater1_flag), then the first identifier and the second identifier of the first quantization coefficient are interleaved during encoding. That is, after the encoder encodes the significant_coeff_flag of the first quantization coefficient, it encodes the coeff_abs_level_greater1_flag of the first quantization coefficient.
[0291] Specifically, in the interleaved encoding scenario, during the encoding of the first identifier, the encoder obtains a first context probability model corresponding to the context index of each of the M first identifiers based on a first correspondence. Then, it encodes the bin of the first identifier based on the first context probability model. During the encoding of the second identifier, the encoder obtains a second context probability model corresponding to the context index of each second identifier based on a second correspondence, and encodes the bin of the second identifier based on the second context probability model. The specific implementation process can be seen in Figure 16. Wherein: the first correspondence includes the correspondence between the context indexes usable by the first identifier and the context probability model; the second correspondence includes the correspondence between the context indexes usable by the second identifier and the context probability model; the first correspondence and the second correspondence are different. In this way, by maintaining two different sets of correspondences (i.e., the first correspondence and the second correspondence), during the encoding of the first and second identifiers, if there are cases where the first and second identifiers are adjacent during encoding, even if the values of the context indices corresponding to the first and second identifiers are the same, their corresponding context probability models are different, thereby enabling parallel encoding or decoding of the first and second identifiers.
[0292] For example, the encoder may encode the significant_coeff_flag of the quantization coefficients, and / or the coeff_abs_level_greater1_flag (hereinafter referred to as the indicator information), and may also encode the residual value of the absolute value of the quantization coefficients. The encoder may encode the indicator information of the quantization coefficients and the residual value of the absolute value of the quantization coefficients in parallel.
[0293] Optionally, the encoder may use the standard CABAC encoding method to encode the indication information. The encoder may use either the CABAC bypass encoding method or the VLC encoding method to encode the residual values of the absolute values of the quantization coefficients.
[0294] Referring to Figure 17, which is an exemplary illustration of the residual value, the syntax element for the residual value of the absolute value of a quantization coefficient is represented as `coeff_abs_level_remaining`. The residual value of the absolute value of a quantization coefficient is the portion (or numerical value) greater than a given value. Referring to Figure 17, assuming the given value is B0, the residual value of the absolute value of the quantization coefficient is the portion greater than B0, with an initial value of B0+1.
[0295] For example, taking a given value of 1, in one example, if the quantization coefficient to be encoded is 0, the encoder can encode `significant_coeff_flag`, a syntax element used to indicate whether the corresponding quantization coefficient is 0. Specifically, `significant_coeff_flag` being 0 indicates that the corresponding quantization coefficient is 0, and `significant_coeff_flag` being 1 indicates that the corresponding quantization coefficient is not 0. Correspondingly, the bitstream includes encoded data where `significant_coeff_flag` = 0 to indicate that the corresponding quantization coefficient is 0, but does not include encoded data for that quantization coefficient itself. In other words, during decoding, the decoder can determine that the corresponding quantization coefficient is 0 based on `significant_coeff_flag` being 0.
[0296] Of course, in some instances, significant_coeff_flag (and coeff_abs_level_greater1_flag below) can also be considered as one type of quantization coefficient encoded data. Correspondingly, in this example, it can also be understood as the encoded data in the bitstream that includes the quantization coefficient, including encoded data where significant_coeff_flag = 0, but excluding encoded data of the residual value of the absolute value of the quantization coefficient. This will not be repeated below.
[0297] For example, when the current quantization factor is 0, the encoder encodes significant_coeff_flag = 0 and then continues encoding the significant_coeff_flag of the next quantization factor, meaning that significant_coeff_flag is adjacent during encoding. When the current quantization factor is not 0, the encoder encodes significant_coeff_flag and then encodes coeff_abs_level_greater1_flag, meaning that coeff_abs_level_greater1_flag and significant_coeff_flag are adjacent during encoding. Optionally, after the encoder encodes the coeff_abs_level_greater1_flag of the current quantization factor, it can continue encoding the significant_coeff_flag of the next quantization factor; this can also be considered as coeff_abs_level_greater1_flag and significant_coeff_flag being adjacent during encoding.
[0298] In another example, if the current quantization coefficient to be encoded is 1, the encoder can encode `significant_coeff_flag` and `coeff_abs_level_greater1_flag`. Here, `coeff_abs_level_greater1_flag` indicates whether the absolute value of the corresponding quantization coefficient is greater than a first value (e.g., 1, which can be set according to actual needs). If `coeff_abs_level_greater1_flag` is 0, it indicates that the absolute value of the corresponding quantization coefficient is not greater than 1. Therefore, when `significant_coeff_flag` is 1, indicating that the corresponding quantization coefficient is not 0, and `coeff_abs_level_greater1_flag` is 0, then the absolute value of the corresponding quantization coefficient is 1. If `coeff_abs_level_greater1_flag` is 1, it indicates that the absolute value of the corresponding quantization coefficient is greater than 1. Optionally, in this example (i.e., the absolute value of the quantization coefficient is 1), the encoder can encode the significant_coeff_flag and coeff_abs_level_greater1_flag of the quantization coefficient, where significant_coeff_flag is 1 and coeff_abs_level_greater1_flag is 0. Accordingly, the bitstream includes encoded data where significant_coeff_flag = 1 and coeff_abs_level_greater1_flag = 0 to indicate that the absolute value of the corresponding quantization coefficient is 1, but does not include the encoded data of the quantization coefficient itself. That is, during decoding, the decoder can determine that the absolute value of the corresponding quantization coefficient is 1 based on significant_coeff_flag and coeff_abs_level_greater1_flag.
[0299] In another example, if the quantization coefficient to be encoded is greater than 1, the encoder can encode the quantization coefficient's significance_coeff_flag, coeff_abs_level_greater1_flag, and the remaining value of the absolute value of the quantization coefficient (denoted as coeff_abs_level_remaining). Here, significance_coeff_flag being 1 indicates that the corresponding quantization coefficient is non-zero; coeff_abs_level_greater1_flag being 1 indicates that the corresponding quantization coefficient is greater than 1; and coeff_abs_level_remaining is the portion (or value) of the absolute value of the quantization coefficient that is greater than a given value.
[0300] During the encoding of significant_coeff_flag and coeff_abs_level_greater1_flag, the encoder can use the context index acquisition method and encoding method described in the above embodiment to encode significant_coeff_flag and coeff_abs_level_greater1_flag.
[0301] Referring to Figure 18, which is a schematic flowchart of an exemplary decoding method, the specific steps include, but are not limited to, the following:
[0302] S1801, Obtain the bitstream of the image to be decoded. The image to be decoded includes a block to be decoded, and the block to be decoded includes N quantization coefficients. The bitstream includes coded data of M first identifiers, each of which corresponds to one of the M quantization coefficients. The N quantization coefficients include M quantization coefficients, where M is an integer greater than 1.
[0303] For example, the decoder acquires a bitstream generated by, for instance, the encoder. The bitstream includes the encoded data of the image to be decoded. For example, the image to be decoded can also be called the current image. The image to be decoded includes blocks to be decoded, also called the current block. That is, the encoded data of the image to be decoded includes the encoded data of the blocks to be decoded. During the decoding process, decoding is also performed using macroblocks (i.e., the blocks to be decoded) as the basic decoding unit.
[0304] In an optional embodiment, the image to be decoded can be the original image, or a sub-image after the original image has been divided, etc.
[0305] For example, the block to be decoded includes N quantization coefficients, wherein the bitstream includes first identifier encoded data of M quantization coefficients out of the N quantization coefficients. The bitstream also includes encoded data of the residual values of the absolute values of the quantization coefficients. M and N are both integers greater than 1. The block to be decoded may correspond to the block to be encoded on the encoding side; a detailed description can be found on the encoding side.
[0306] S1802, based on M first context indices, decode the bitstream to obtain M first identifiers. Each of the M first identifiers is represented by a binary bit bin. The first identifier is used to indicate whether the corresponding quantization coefficient is zero. During decoding, the first context indices corresponding to adjacent first identifiers are different.
[0307] For example, the decoder can obtain the context index (i.e., the first context index) corresponding to the first identifier of each of the M quantization coefficients to be decoded, using the same method as the encoder. Then, it decodes the bitstream based on the context index to obtain the corresponding first identifier. Specifically, during the decoding of the first identifier of the i-th quantization coefficient in the scanning sequence, the decoder can determine the value of the context index of the first identifier of the i-th quantization coefficient based on the size of the quantization coefficient block, the color components of the quantization coefficient block, and i. Specifically, during the decoding of the first identifier of the i-th quantization coefficient, the decoder can obtain the basic value of the context index and the context index offset corresponding to the first identifier of the i-th quantization coefficient by looking up a table. Based on the basic value of the context index and the context index offset, it obtains the value of the corresponding context index. The method for obtaining this value can be referred to the encoder side, and will not be elaborated here.
[0308] Referring to Figure 19, which is a schematic flowchart illustrating the decoding method, specifically, after the decoder obtains the context index value of the currently to-be-decoded significant_coeff_flag (hereinafter referred to as the current significant_coeff_flag), it can execute the context modeling process. Specifically, based on the first correspondence (described in the encoding side), the decoder obtains the context probability model corresponding to the context index value of the current significant_coeff_flag. The decoder can decode the bitstream based on the context probability model to obtain the bin value of significant_coeff_flag (e.g., 0 or 1). The decoder can update the context probability model corresponding to the context index (not shown in the figure) based on the decoded bin value. Similar to the encoding side, during the decoding process of adjacent first identifiers, since adjacent first identifiers use different context indices, adjacent first identifiers do not need to wait for the context probability model update process of the previous first identifier during decoding, which can effectively improve the decoding speed.
[0309] Similar to the encoding side, during decoding, the context indices of adjacent `significant_coeff_flag` values are different. The specific implementation is the same as the encoding side.
[0310] In one possible implementation, corresponding to the encoding side, the bitstream may also include encoded data of the second identifier (coeff_abs_level_greater1_flag) with L quantization coefficients. The decoder can decode the bitstream based on the L second context indices to obtain the L second identifiers. The description of the second identifier can be referenced from the encoding side, and the method for obtaining the context index of the second identifier is the same as that of the encoding side. The decoder can obtain the second context probability model corresponding to each of the L second context indices based on the second correspondence (the description can be referenced from the encoding side). Based on the second context probability model, the bitstream is decoded to obtain the bin value of the second identifier corresponding to the second context index. The implementation process can be seen in Figure 19.
[0311] In this embodiment, during the decoding process, the first and second identifiers of any quantization coefficient (e.g., the first quantization coefficient) are interleaved during decoding. In one example, the decoder decodes the significance_coeff_flag of the current quantization coefficient. If significance_coeff_flag is 0, it decodes the significance_coeff_flag of the next quantization coefficient, i.e., the case where significance_coeff_flag is adjacent. In another example, the decoder decodes the significance_coeff_flag of the current quantization coefficient. If significance_coeff_flag is 1, it decodes the second identifier (coeff_abs_level_greater1_flag) of the current quantization coefficient, i.e., the case where significance_coeff_flag and coeff_abs_level_greater1_flag are adjacent.
[0312] S1803 decodes the bitstream based on M first identifiers to obtain M quantization coefficients.
[0313] For example, after the decoder obtains the first identifier (significant_coeff_flag) corresponding to the quantization coefficient among the M quantization coefficients, it can decode the bitstream based on the significant_coeff_flag to obtain the corresponding quantization coefficient.
[0314] Specifically, after the decoder decodes the `significant_coeff_flag` corresponding to the quantization coefficient, it can determine whether there is encoded data in the bitstream representing the residual absolute value of that quantization coefficient. In one example, if `significant_coeff_flag` is 0, the corresponding quantization coefficient has a value of 0. In another example, if `significant_coeff_flag` is 1, the decoder continues decoding the bitstream to obtain the residual absolute value of the corresponding quantization coefficient.
[0315] The decoder can determine whether there is encoded data in the bitstream with the residual value of the corresponding quantization coefficient based on significant_coeff_flag and / or coeff_abs_level_greater1_flag.
[0316] In one example, if these elements are not present, the decoder can directly decode the corresponding quantization coefficients based on syntax elements such as significant_coeff_flag and coeff_abs_level_greater1_flag.
[0317] In another example, if present, the decoder can decode the bitstream to obtain the residual values of the absolute values of the corresponding quantization coefficients.
[0318] For example, after the decoder decodes the remainder of the absolute value of a quantization coefficient, it can also obtain the numerical value of the quantization coefficient based on other syntax elements corresponding to that quantization coefficient. Other syntax elements include, but are not limited to, the sign bit and `coeff_abs_level_greater1_flag`. Specifically, the decoder can obtain the absolute values of L quantization coefficients based on the second identifier of the L quantization coefficients. For example, if any one of the L quantization coefficients corresponds to `coeff_abs_level_greater1_flag`, then the absolute value of its quantization coefficient is the sum of the remainder of the absolute value of the quantization coefficient and (given value + 1). Here, `coeff_abs_level_greater1_flag` indicates whether the remainder of the absolute value of the quantization coefficient is greater than 1, and the corresponding given value is 1. By obtaining the sign bit and the absolute value of the quantization coefficient, the decoder can obtain the corresponding quantization coefficient.
[0319] S1804, based on M quantization coefficients, obtains the reconstructed data of the block to be decoded.
[0320] For example, the decoder can obtain the corresponding quantization coefficient block based on the decoded M quantization coefficients. The description of the quantization coefficient block can be found on the encoding side. For example, during encoding, the encoder encodes the quantization coefficients before the last non-zero quantization coefficient in the scan result; that is, the bitstream does not include encoded data for quantization coefficients with a value of 0 after the last non-zero quantization coefficient. Correspondingly, during decoding, after the decoder obtains the position of the last non-zero quantization coefficient, it can determine that the values of all quantization coefficients after the last non-zero quantization coefficient in the scan order are 0. Based on the scan order, it determines the position of these quantization coefficients with a value of 0 in the quantization coefficient block, thereby obtaining the quantization coefficient block.
[0321] For example, the decoder can obtain the reconstructed data of the low-frequency subband of the block to be decoded based on the quantization coefficient block of the block to be decoded. Then, it performs an inverse wavelet transform based on the reconstructed data of the low-frequency subband to obtain the reconstructed data of the block to be decoded.
[0322] Specifically, the decoder obtains the quantization coefficient block of the block to be decoded, such as the quantization coefficient 702 of the low-frequency subband block in Figure 7A or Figure 7B.
[0323] The decoder obtains the reconstructed low-frequency subband data of the block to be decoded based on the quantization coefficient block of the block to be decoded, such as the low-frequency subband reconstruction block 704 in Figure 7A or Figure 7B.
[0324] Next, the decoder can perform an inverse wavelet transform based on the reconstructed data of the low-frequency subband of the block to be decoded to obtain the reconstructed data of the block to be decoded, such as reconstructed block 734 in Figure 7B. Based on the reconstructed data of the block to be decoded, the decoder can obtain the reconstructed data of the image to be decoded, such as reconstructed image 733 in Figure 7B.
[0325] In the example shown in Figure 7A, the decoder can obtain the reconstructed low-frequency subband data of the image to be decoded based on the reconstructed low-frequency subband data of the block to be decoded, such as the reconstructed low-frequency subband 706 in Figure 7A. The decoder can perform inverse wavelet transform based on the reconstructed low-frequency subband data of the image to be decoded to obtain the reconstructed data of the image to be decoded, such as the reconstructed sub-image 732.
[0326] Referring to Figure 20, which is a schematic diagram of the structure of a video decoding device 2000 provided in an embodiment of this application, the video decoding device 2000 is suitable for implementing the embodiments described herein. In one embodiment, the video decoding device 2000 may be a video decoder (e.g., the decoder shown in Figures 3, 7A, and 7B) or a video encoder (e.g., the encoder shown in Figures 2 and 4). In another embodiment, the video decoding device 2000 may be one or more components of the aforementioned decoder or encoder.
[0327] The video decoding device 2000 includes: an input port 2010 and a receiving unit (Rx) 2020 for receiving data; a processor, logic unit, or central processing unit (CPU) 2030 for processing data; a transmitter unit (Tx) 2040 and an output port 2050 for transmitting data; and a memory 2060 for storing data. The video decoding device 2000 may also include photoelectric conversion components and electro-optical (EO) components coupled to the input port 2010, the receiver unit 2020, the transmitter unit 2040, and the output port 2050 for the input or output of optical or electrical signals.
[0328] Processor 2030 is implemented in hardware and software. Processor 2030 can be implemented as one or more CPU chips, cores (e.g., multi-core processors), FPGAs, ASICs, and DSPs. Processor 2030 communicates with ingress port 2010, receiver unit 2020, transmitter unit 2040, egress port 2050, and memory 2060. Processor 2030 includes encoding module 2070 or decoding module 2070. Encoding / decoding module 2070 implements the embodiments disclosed herein to implement the encoding or decoding methods provided in the embodiments of this application. For example, encoding / decoding module 2070 implements, processes, or provides various encoding operations. Therefore, encoding / decoding module 2070 provides substantial improvements to the functionality of video decoding device 2000 and affects the transitions of video decoding device 2000 to different states. Alternatively, encoding / decoding module 2070 can be implemented with instructions stored in memory 2060 and executed by processor 2030.
[0329] Memory 2060 includes one or more disks, tape drives, and solid-state drives, which can be used as overflow data storage devices to store programs while they are selectively executed, and to store instructions and data read during program execution. Memory 2060 can be volatile and / or non-volatile, and can be read-only memory (ROM), random access memory (RAM), ternary content-addressable memory (TCAM), and / or static random access memory (SRAM).
[0330] Referring to FIG21, FIG21 is a simplified block diagram of a device 2100 that can be used as either or both of the source device 12 and destination device 14 in FIG1A according to an exemplary embodiment. Device 2100 can implement the technology of this application. In other words, FIG21 is a schematic block diagram of an implementation of an encoder or decoder (referred to as decoding device 2100) according to an embodiment of this application. Device 2100 may include a processor 2110, a memory 2130, and a bus system 2150. The processor 2110 and the memory 2130 are connected via the bus system 2150. The memory 2130 is used to store instruction / program code, and the processor 2110 is used to execute the instruction / program code stored in the memory 2130. The memory 2130 of the decoding device 2100 stores instruction / program code, and the processor 2110 can call the program code stored in the memory 2130 to execute various video encoding or decoding methods described in this application. To avoid repetition, detailed descriptions are omitted here.
[0331] In this embodiment, the processor 2110 may be a central processing unit (CPU), or it may be other general-purpose processors, DSPs, ASICs, FPGAs, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0332] The memory 2130 may include read-only memory (ROM) or random access memory (RAM). Any other suitable type of storage device may also be used as memory 2130. Memory 2130 may include program code and data 2131 accessed by processor 2110 using bus 2150. Memory 2130 may further include an operating system 2133 and an application program 2135, which includes at least one program that allows processor 2110 to execute the encoding or decoding methods described in this application. For example, application program 2135 may include applications 1 to N, which further include video encoding or decoding applications that execute the encoding or decoding methods described in this application.
[0333] In addition to the data bus, the bus system 2150 may also include a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as bus system 2150 in the figure.
[0334] Optionally, the decoding device 2100 may also include one or more output devices, such as a display 2170. In one example, the display 2170 may be a haptic display that combines a display with a haptic unit capable of operatively sensing touch input. The display 2170 may be connected to the processor 2110 via a bus 2150.
[0335] Based on the same inventive concept as the above method, this embodiment of the invention also provides an encoding device 2200, which includes: an acquisition module 2201 and an encoding module 2202. The acquisition module 2201 is used to acquire N quantization coefficients of the block to be encoded, where the N quantization coefficients include non-zero quantization coefficients, and N is an integer greater than 1. The acquisition module 2201 is also used to acquire the context indices corresponding to M first identifiers, where the M first identifiers correspond to M quantization coefficients, and each of the M first identifiers indicates whether the corresponding quantization coefficient is zero. The first identifier is represented by a binary bit bin, and the N quantization coefficients include M quantization coefficients, where M is an integer greater than 1. The encoding module 2202 is used to encode the M first identifiers based on their respective context indices to obtain the bitstream of the image to be encoded, where the image to be encoded includes the block to be encoded. During encoding, the context indices of adjacent first identifiers are different.
[0336] This application embodiment also provides a decoding device 2300, which includes: an acquisition module 2301, a decoding module 2302, and a reconstruction module 2303. Specifically: the acquisition module 2301 is used to acquire the bitstream of an image to be decoded, the image to be decoded including a block to be decoded, the block to be decoded including N quantization coefficients, the bitstream including encoded data of M first identifiers, the M first identifiers respectively corresponding to the M quantization coefficients, the N quantization coefficients including the M quantization coefficients, and M being an integer greater than 1; the decoding module 2302 is used to decode the bitstream based on the M first context indices to obtain M first identifiers, each of the M first identifiers being represented by a binary bit bin, the first identifier being used to indicate whether the corresponding quantization coefficient is zero; wherein, during decoding, adjacent first identifiers correspond to different first context indices; the decoding module 2302 is also used to decode the bitstream based on the M first identifiers to obtain M quantization coefficients; the reconstruction module 2303 is used to acquire reconstructed data of the block to be decoded based on the M quantization coefficients.
[0337] All relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0338] This application also provides a chip, including one or more interface circuits and one or more processors; the one or more processors receive or send data through the one or more interface circuits, and when the one or more processors execute computer instructions, the steps of the above-described related method steps to implement the methods in the above embodiments are executed. This embodiment also provides a computer-readable storage medium storing computer instructions, which, when executed on an electronic device, cause the electronic device to perform the above-described related method steps to implement the methods in the above embodiments. This embodiment also provides a computer program product containing computer instructions, which, when executed by a computer or processor, cause the computer to perform the above-described related steps to implement the methods in the above embodiments. Exemplarily, the computer program product may be stored in a computer-readable storage medium.
[0339] The computer-readable storage medium in this application includes random access memory (RAM), flash memory, read-only memory (ROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, portable hard disks, read-only optical discs (CD-ROMs), or any other form of storage medium known in the art.
[0340] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the methods in the above-described method embodiments.
[0341] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the corresponding methods provided above.
[0342] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0343] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0344] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0345] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0346] Any content in the various embodiments of this application, as well as any content in the same embodiment, can be freely combined. Any combination of the above content is within the scope of this application.
[0347] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. An encoding method, characterized in that, include: Obtain N quantization coefficients of the block to be encoded, wherein the N quantization coefficients include non-zero quantization coefficients, and N is an integer greater than 1; Obtain the context index corresponding to each of the M first identifiers, where each of the M first identifiers corresponds to one of the M quantization coefficients. Each of the M first identifiers is used to indicate whether the corresponding quantization coefficient is zero. The first identifier is represented by a binary bit bin. The N quantization coefficients include the M quantization coefficients, where M is an integer greater than 1. Based on the context indices corresponding to the M first identifiers, the M first identifiers are encoded to obtain the bitstream of the image to be encoded, wherein the image to be encoded includes the block to be encoded; wherein, during encoding, the context indices of adjacent first identifiers are different.
2. The method according to claim 1, characterized in that, The N quantization coefficients of the block to be encoded are one-dimensional data obtained by scanning the quantization coefficient block of the block to be encoded. The encoding order of the N quantization coefficients is the same as or the reverse of the scanning order.
3. The method according to claim 2, characterized in that, The value of the context index of the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to the M quantization coefficients.
4. The method according to claim 3, characterized in that, The step of obtaining the context indices corresponding to the M first identifiers includes: Based on the color components of the quantization coefficient block and the size of the quantization coefficient block, obtain the context index base value of the first identifier of the i-th quantization coefficient; Based on i and a preset context index offset table, obtain the context index offset of the first identifier of the i-th quantization coefficient; Based on the context index base value and the context index offset, obtain the value of the context index of the first identifier of the i-th quantization coefficient.
5. The method according to claim 4, characterized in that, The context index offset table includes N context index offsets, which correspond one-to-one with the N positions in the scan order. Two or more consecutive context index offsets in the context index offset table are different.
6. The method according to claim 4, characterized in that, The method for obtaining the context index offset of the first identifier of the i-th quantization coefficient based on i and a preset context offset table includes: Based on the size of the quantization coefficient block, the context index offset table is obtained; wherein: each size of quantization coefficient block corresponds to a context index offset table, and the context index offsets contained in the context index offset table corresponding to each size of quantization coefficient block come from the same set of values.
7. The method according to any one of claims 2 to 6, characterized in that, The scan starts from the DC quantization coefficients of the quantization coefficient block and continues to the last quantization coefficient of the quantization coefficient block.
8. The method according to claim 7, characterized in that, The M quantization coefficients are the quantization coefficients between the DC quantization coefficient and the last non-zero quantization coefficient scanned.
9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: Obtain the context index corresponding to each of the L second identifiers, where each of the L second identifiers corresponds to one of the L quantization coefficients. Each of the L second identifiers is used to indicate whether the corresponding quantization coefficient is greater than a first value. The second identifier is represented by a bin. The N quantization coefficients include the L quantization coefficients, where L is an integer greater than 1. Based on the second context index corresponding to the L second identifiers respectively, the L second identifiers are encoded to obtain the encoded data of the L second identifiers; wherein: if the first quantization coefficient among the N quantization coefficients corresponds to a first identifier and a second identifier, the first identifier of the first quantization coefficient and the second identifier of the first quantization coefficient are interleaved during encoding; the bitstream of the image to be encoded also includes the encoded data of the L second identifiers.
10. The method according to claim 9, characterized in that: The process of encoding the M first identifiers based on their respective context indices includes: Based on the first correspondence, obtain the first context probability model corresponding to the context index of each of the M first identifiers; The bin of the first identifier is encoded based on the first context probability model; The process of encoding the L second identifiers based on their corresponding context indices includes: Based on the second correspondence, obtain the second context probability model corresponding to the context index of each second identifier; The bin of the second identifier is encoded based on the second context probability model; Wherein: the first correspondence includes the correspondence between the context index that the first identifier can use and the context probability model, the second correspondence includes the correspondence between the context index that the second identifier can use and the context probability model, and the first correspondence and the second correspondence are different.
11. A decoding method, characterized in that, include: Obtain the bitstream of the image to be decoded, wherein the image to be decoded includes a block to be decoded, the block to be decoded includes N quantization coefficients, the bitstream includes coded data of M first identifiers, the M first identifiers correspond to M quantization coefficients respectively, and the N quantization coefficients include the M quantization coefficients, where M is an integer greater than 1; Based on M first context indices, the bitstream is decoded to obtain the M first identifiers. The M first context indices correspond to the M first identifiers. Each of the M first identifiers is represented by a binary bit bin. The first identifier is used to indicate whether the corresponding quantization coefficient is zero. During decoding, adjacent first identifiers correspond to different first context indices. Based on the M first identifiers, the bitstream is decoded to obtain the M quantization coefficients; Based on the M quantization coefficients, the reconstructed data of the block to be decoded is obtained.
12. The method according to claim 11, characterized in that, When decoding the bitstream, the decoding is performed according to a preset scanning order. The scanning order starts from the DC quantization coefficients of the quantization coefficient block of the block to be decoded and ends at the last quantization coefficient of the quantization coefficient block. The quantization coefficient block includes the N quantization coefficients.
13. The method according to claim 12, characterized in that, The value of the first context index corresponding to the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to the M quantization coefficients.
14. The method according to claim 13, characterized in that, Before decoding the bitstream based on M first context indices, the method further includes: Based on the color components of the quantization coefficient block and the size of the quantization coefficient block, obtain the context index base value corresponding to the first identifier of the i-th quantization coefficient; Based on i and a preset context index offset table, obtain the context index offset corresponding to the first identifier of the i-th quantization coefficient; Based on the context index base value and the context index offset, obtain the value of the first context index corresponding to the first identifier of the i-th quantization coefficient.
15. The method according to claim 14, characterized in that, The context index offset table includes N context index offsets, which correspond one-to-one with the N positions in the scan order. Two or more consecutive context index offsets in the context index offset table are different.
16. The method according to claim 14, characterized in that, The method for obtaining the context index offset corresponding to the first identifier of the i-th quantization coefficient based on i and a preset context index offset table includes: Based on the size of the quantization coefficient block, the context index offset table is obtained; wherein: each size of quantization coefficient block corresponds to a context index offset table, and the context index offsets contained in the context index offset table corresponding to each size of quantization coefficient block come from the same set of values.
17. The method according to any one of claims 12 to 16, characterized in that, The decoding order of the M quantization coefficients is the same as or the reverse of the scanning order.
18. The method according to any one of claims 12 to 17, characterized in that, The M quantization coefficients are the quantization coefficients between the DC quantization coefficient and the last non-zero quantization coefficient scanned.
19. The method according to any one of claims 11 to 18, characterized in that, The method further includes: Based on L second context indices, the bitstream is decoded to obtain L second identifiers. Each of the L second identifiers indicates whether the corresponding quantization coefficient is greater than a first value. The second identifier is represented by a bin value. The N quantization coefficients include the L quantization coefficients, where L is an integer greater than 1. Wherein: if the first quantization coefficient among the N quantization coefficients corresponds to a first identifier and a second identifier, the first identifier and the second identifier of the first quantization coefficient are interleaved during decoding. Based on the L second identifiers, the bitstream is decoded to obtain the L quantization coefficients.
20. The method according to claim 19, characterized in that: The decoding of the bitstream based on M first context indices includes: Based on the first correspondence, obtain the first context probability model corresponding to each of the M first context indices; Based on the first context probability model, the bitstream is decoded to obtain the bin value of the first identifier corresponding to the first context index; The decoding of the bitstream based on L second context indices includes: Based on the second correspondence, obtain the second context probability model corresponding to the second context index among the L second context indices; Based on the second context probability model, the bitstream is decoded to obtain the bin value of the second identifier corresponding to the second context index; Wherein: the first correspondence includes the correspondence between the context index that the first identifier can use and the context probability model, the second correspondence includes the correspondence between the context index that the second identifier can use and the context probability model, and the first correspondence and the second correspondence are different.
21. An encoding device, characterized in that, include: The acquisition module is used to acquire N quantization coefficients of the block to be encoded, wherein the N quantization coefficients include non-zero quantization coefficients and N is an integer greater than 1; The acquisition module is further configured to acquire the context indexes corresponding to the M first identifiers respectively, the M first identifiers respectively correspond to the M quantization coefficients, each of the M first identifiers is used to indicate whether the corresponding quantization coefficient is zero, the first identifier is represented by a binary bit bin, and the N quantization coefficients include the M quantization coefficients, where M is an integer greater than 1; An encoding module is used to encode the M first identifiers based on their respective context indices to obtain a bitstream of an image to be encoded, wherein the image to be encoded includes the block to be encoded; wherein, during encoding, the context indices of adjacent first identifiers are different.
22. The apparatus according to claim 21, characterized in that, The N quantization coefficients of the block to be encoded are one-dimensional data obtained by scanning the quantization coefficient block of the block to be encoded. The encoding order of the N quantization coefficients is the same as or the reverse of the scanning order.
23. The apparatus according to claim 22, characterized in that, The value of the context index of the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to the M quantization coefficients.
24. A decoding device, characterized in that, include: The acquisition module is used to acquire the bitstream of the image to be decoded. The image to be decoded includes a block to be decoded, the block to be decoded includes N quantization coefficients, the bitstream includes coded data of M first identifiers, the M first identifiers correspond to M quantization coefficients respectively, and the N quantization coefficients include the M quantization coefficients, where M is an integer greater than 1. A decoding module is used to decode the bitstream based on M first context indices to obtain the M first identifiers. Each of the M first identifiers is represented by a binary bit bin, and the first identifier is used to indicate whether the corresponding quantization coefficient is zero. During decoding, adjacent first identifiers correspond to different first context indices. The decoding module is further configured to decode the bitstream based on the M first identifiers to obtain the M quantization coefficients; The reconstruction module is used to obtain the reconstruction data of the block to be decoded based on the M quantization coefficients.
25. The apparatus according to claim 24, characterized in that, When decoding the bitstream, the decoding is performed according to a preset scanning order. The scanning order starts from the DC quantization coefficients of the quantization coefficient block of the block to be decoded and ends at the last quantization coefficient of the quantization coefficient block. The quantization coefficient block includes the N quantization coefficients.
26. The apparatus according to claim 25, characterized in that, The value of the first context index corresponding to the first identifier of the i-th quantization coefficient in the scanning order is related to the size of the quantization coefficient block, the color component of the quantization coefficient block, and i; the i-th quantization coefficient belongs to the M quantization coefficients.
27. An encoder, characterized in that, include: A memory and a processor, wherein the memory is coupled to the processor; The memory stores program instructions that, when executed by the processor, cause the decoder to perform the method as described in any one of claims 1 to 10.
28. A decoder, characterized in that, include: A memory and a processor, wherein the memory is coupled to the processor; The memory stores program instructions that, when executed by the processor, cause the decoder to perform the method as described in any one of claims 11 to 20.
29. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed on a computer or processor, causes the computer or processor to perform the method as described in any one of claims 1 to 20.
30. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a bitstream generated according to the encoding method described in any one of claims 1 to 10.