Image decoding method, encoding method, and apparatus
The image decoding and encoding methods address the issue of bitstream overflow by analyzing and adjusting the bitstream buffer usage, ensuring stable image decoding through a fallback mode, thus maintaining image quality and preventing data loss.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
- Filing Date
- 2023-07-25
- Publication Date
- 2026-04-27
AI Technical Summary
Existing video encoding technologies face challenges in controlling the bitrate generated by the encoder based on the remaining memory space in the buffer, leading to potential bitstream overflow and loss of image information.
Implementing an image decoding method that analyzes the bitstream to determine if a fallback mode is needed based on the available memory in the buffer, and an encoding method that pre-encodes blocks to ensure they fit within the allowed code length, using a fallback mode if necessary to prevent overflow or underflow.
The proposed methods effectively prevent bitstream overflow and underflow, ensuring the integrity of image information by allowing the decoding side to handle variable bitrates and maintain image quality.
Smart Images

Figure 0007852141000010 
Figure 0007852141000011 
Figure 0007852141000012
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of video encoding and decoding, and in particular, to an image decoding method, an encoding method, and an apparatus.
Background Art
[0002] Video encoding technology, also called video compression technology, is used to reduce the data bandwidth of video signals. Here, a video is a continuous image sequence consisting of consecutive image frames, and one frame of an image is one image. Due to the afterimage effect in the human eye's vision, when the frame sequence is played back at a certain rate, what the human eye sees is a continuous video. Encoding and decoding a video means encoding and decoding the images of each frame of the video. Taking one frame of an image as an example, on the encoding side, an image encoder encodes the image to obtain a bitstream corresponding to the image, and transmits the bitstream to the decoding side. On the decoding side, an image decoder analyzes the bitstream and reconstructs the image.
[0003] In the process of image encoding and decoding, in order to improve the compression efficiency, general video compression technology adopts variable-length coding. The bitstream obtained after a video sequence is compressed and encoded has a variable rate and is not suitable for transmission in a real-time fixed-bitrate channel. Therefore, usually, the variable-bitrate data generated by the encoder is output to a buffer with a specific storage space and then output from the buffer at a certain bitrate. The size of the storage space of the buffer is fixed. If the bitstream data input to the buffer is too large and the data that needs to be temporarily stored in the buffer exceeds the size of its storage space, it should be understood that a "buffer overflow" of the bitstream occurs and subsequent image information is lost.
[0004] Therefore, a pressing issue is how to control the bitrate generated by the encoder based on the remaining memory space in the buffer during the image encoding and decoding process. [Overview of the project]
[0005] Embodiments of the present invention provide an image decoding method, encoding method, and apparatus for avoiding bitstream overflow.
[0006] To achieve the above objective, embodiments of the present invention employ the following technical solutions.
[0007] According to a first aspect, an embodiment of the present invention provides an image decoding method performed by a decoding side, the method comprising the steps of analyzing the bitstream of a block to be decoded, and determining whether the image block corresponding to the block to be decoded uses a fallback mode if the bitstream of the block to be decoded contains a first codeword, wherein the code length of the block to be decoded is less than the maximum code length of the block to be decoded, the maximum code length is determined based on a set overflow line of the bitstream buffer, the set overflow line is used to indicate the maximum memory space that is permitted to be occupied by the bitstream in the bitstream buffer, and the first codeword uses a fallback mode or sampleThe method includes: a step used to indicate a mode; a step to determine a fixed code length for each component of the block to be decoded based on the excess code length of the bitstream buffer, where the image block corresponding to the block to be decoded uses a fallback mode and the code length stored in the bitstream buffer exceeds a set overflow line, wherein the block to be decoded includes one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is the code length that exceeds the set overflow line of the code length stored in the bitstream buffer; and a step to decode the block to be decoded by analyzing the pixel points of each component based on the fixed code length of each component.
[0008] The image decoding method provided in embodiments of the present invention has at least the following beneficial effects. When the encoding side uses a fallback mode, the decoding side can decode the block to be decoded using the fallback mode, and based on the remaining memory in the bitstream buffer, it is possible to avoid bitstream overflow or underflow. This prevents the loss of image information of the block to be decoded.
[0009] According to a second aspect, embodiments of the present invention provide an image coding method performed by an encoding side, the method comprising: obtaining the maximum code length of a block to be coded, the maximum code length being determined based on a set overflow line of a bitstream buffer, the set overflow line being used to indicate the maximum memory space that is permitted to be occupied by a bitstream in the bitstream buffer; pre-coding the block to be coded to obtain a first code length of the block to be coded, the first code length being the length of a bitstream obtained after the block to be coded has been pre-coded; and coding the block to be coded using a fallback mode if the first code length is greater than or equal to the maximum code length, wherein the code length obtained by coding the block to be coded based on the fallback mode is less than the maximum code length, and the bitstream obtained by coding the block to be coded based on the fallback mode includes a first codeword, and the first codeword is in a fallback mode or sample Includes a step, which is used to indicate a mode.
[0010] Based on the above embodiment, the method first pre-encodes the block to be encoded, compares the length of the bitstream obtained by pre-encoding with the code length that is allowed to be occupied by the block to be encoded, and determines whether or not a bitstream overflow or underflow will occur based on the comparison result. If it is determined that a bitstream overflow or underflow will occur, the block to be encoded is encoded using a fallback mode so that the image information of the block to be encoded is not lost.
[0011] According to a third aspect, the present invention provides an image decoding device, which may be a video decoder or a device including a video decoder. The decoding device includes modules configured to perform a method in any one of the possible embodiments of the first aspect. The decoding device has functions to perform the operations in the embodiments of the related method. These functions may be performed by hardware, or by the hardware running corresponding software. The hardware or software includes one or more modules corresponding to the functions. For their beneficial effects, see the description of the corresponding method.
[0012] According to a fourth aspect, the present invention provides an image encoding apparatus, which may be a video encoder or a device including a video encoder. The encoding apparatus includes modules configured to perform a method in any one of the possible embodiments of the second aspect. The encoding apparatus has functions to perform the operations in the embodiments of the associated method. These functions may be performed by hardware, or by the hardware running corresponding software. The hardware or software includes one or more modules corresponding to the functions. For their beneficial effects, see the description of the corresponding method.
[0013] The 5 In one aspect of the present invention, the present invention provides a computer-readable storage medium in which a computer program or instruction is stored, and when the computer program or instruction is executed by a computing device or a storage system in which a computing device is located, a method in any one of the embodiments of the first and second aspects is carried out.
[0014] The present invention may be further combined to provide more embodiments based on the embodiments provided in each of the above embodiments. In other words, any one possible embodiment of any one of the above embodiments may be applied to the other embodiments to obtain a new embodiment, provided that it does not conflict with the other embodiments. For example, any image decoding method provided in the first embodiment above may be combined in pairs or in three embodiments, provided that it does not conflict with the other embodiments, thereby obtaining a new image decoding method. [Brief explanation of the drawing]
[0015] [Figure 1] This is a schematic architecture diagram of an encoding / decoding system 1 to which embodiments of the present invention are applied. [Figure 2] This is a schematic block diagram of an example encoder 100 for carrying out a method according to one embodiment of the present invention. [Figure 3] This is a schematic diagram showing the correspondence between an image, a parallel encoding unit, an independent encoding unit, and an encoding unit according to one embodiment of the present invention. [Figure 4] This is a schematic block diagram of an example of a decoder 200 for carrying out a method according to one embodiment of the present invention. [Figure 5] This is a schematic flowchart of an image coding method according to one embodiment of the present invention. [Figure 6] This is a schematic diagram of a subblock to be encoded according to one embodiment of the present invention. [Figure 7] This is a schematic flowchart of an image decoding method according to one embodiment of the present invention. [Figure 8] This is a schematic flowchart of another image decoding method according to one embodiment of the present invention. [Figure 9] This is a schematic diagram of an image encoding device 900 according to one embodiment of the present invention. [Figure 10] This is a schematic diagram of an image decoding device 1000 according to one embodiment of the present invention. [Figure 11] This is a schematic diagram of the structure of an electronic device 1100 according to one embodiment of the present invention.
Embodiments for Carrying Out the Invention
[0016] Hereinafter, while referring to the drawings in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative labor belong to the protection scope of the present invention.
[0017] In the description of the present invention, unless otherwise specified, " / " represents the meaning of "or". For example, A / B can represent A or B. The term "and / or" in this specification is only used to explain the relationship of related objects and indicates that there may be three types of relationships. For example, A and / or B can indicate three situations: A exists alone, A and B exist simultaneously, and B exists alone. Also, "at least one" means one or more, and "a plurality of" means two or more. Words such as "first" and "second" do not limit the quantity or execution order, and words such as "first" and "second" do not necessarily limit that they are different.
[0018] In addition, in the present invention, terms such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the present invention should not be construed as being more preferable or advantageous than other embodiments or design solutions. Specifically speaking, the use of terms such as "exemplary" or "for example" is intended to specifically present related concepts.
[0019] Hereinafter, the system architecture to which the embodiments of the present invention are applied will be described.
[0020] <FIG. 1 is a schematic architecture diagram of an encoding / decoding system 1 to which an embodiment of the present invention is applied. As shown in FIG. 1, the encoding / decoding system 1 may include an encoding side 10 and a decoding side 20. The encoding side 10 generates encoded video data. Therefore, the encoding side 10 may be called an encoding device. The decoding side 20 may decode the encoded video data generated by the encoding side 10. Therefore, the decoding side 20 may be called a decoding device.
[0021] Specific forms of the encoding side 10 and the decoding side 20 may be various devices including a desktop computer, a mobile computing device, a notebook (e.g., laptop) computer, a tablet computer, a set-top box, a telephone handset such as a so-called "smart" phone, a television, a camera, a display device, a digital media player, a video game console, an in-vehicle computer, or the like.
[0022] Optionally, the encoding side 10 and the decoding side 20 in FIG. 1 may be two separate devices. Alternatively, the encoding side 10 and the decoding side 20 may be the same device, that is, the encoding side 10 or the corresponding function, and the decoding side 20 or the corresponding function may be integrated into the same device.
[0023] Communication can take place between the encoding side 10 and the decoding side 20. For example, the decoding side 20 may receive encoded video data from the encoding side 10 via link 30. Link 30 may include one or more media or devices that can move the encoded video data from the encoding side 10 to the decoding side 20. In one example, link 30 may include one or more communication media that enable the encoding side 10 to directly transmit encoded video data to the decoding side 20 in real time. In this example, the encoding side 10 may modulate the encoded video data according to a communication standard (e.g., a wireless communication protocol) and transmit the modulated video data to the decoding side 20. The one or more communication media may include wireless and / or wired communication media such as a 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 (LAN), a wide area network (WAN), or a global network (e.g., the Internet). The one or more communication media may include a router, a switch, a base station, or other devices that facilitate communication from the encoding side 10 to the decoding side 20.
[0024] Optionally, the encoding side 10 may output the encoded data from the output interface 140 to an internal or external storage device. The storage device may include one of several distributed or locally accessible data storage media, such as a hard disk drive, Blu-ray disc, digital video disc (DVD), compact disc read-only memory (CD-ROM), flash memory, volatile or non-volatile memory, or any other suitable digital storage medium for storing encoded video data.
[0025] As shown in Figure 1, the encoding side 10 includes a video source 120, an encoder 100, and an output interface 140. In some examples, the output interface 140 may include a modulator / demodulator (modem) and / or transmitter. The video source 120 may include a video capture device (e.g., a camera), a video archive containing previously captured video data, a video feed-in interface for receiving video data from a video content provider, and / or a computer graphics system for generating video data, or a combination of these sources of video data. The encoder 100 can encode the video data from the video source 120. In some examples, the encoding side 10 transmits the encoded video data directly to the decoding side 20 via the output interface 140. In other examples, the encoded video data may be stored in a storage device for the decoding side 20 to access for decoding and / or playback.
[0026] As shown in Figure 1, the decoding side 20 includes an input interface 240, a decoder 200, and a display device 220. In some examples, the input interface 240 includes a receiver and / or modem. The input interface 240 can receive encoded video data via link 30 and / or from a storage device. The display device 220 may be integrated with the decoding side 20 or may be external to the decoding side 20. Generally, the display device 220 displays the decoded video data. The display device 220 may include various types of displays, such as a liquid crystal display (LCD), a plasma display, an organic light-emitting diode (OLED) display, or other types of displays.
[0027] Optionally, the encoding side 10 further includes a bitstream buffer (not shown in Figure 1), which is configured to receive the bitstream data generated by encoding and output bitstream data at a fixed bitrate. The size of the bitstream data generated after different blocks to be encoded can generally vary considerably based on the nature of the blocks to be encoded. Therefore, the bitstream obtained after a video sequence has been compressed and encoded is variable-rate and unsuitable for transmission in real time over a fixed-bitrate channel. The bitstream buffer can smooth out rate changes in the compressed video. The larger the memory space of the bitstream buffer, the more it can withstand bitrate fluctuations.
[0028] Optionally, the decoding side 20 may include another buffer. This buffer is configured to receive bitstream data at a fixed bitrate and output it from the buffer to the bitstream analysis unit 201 of the decoder 200.
[0029] Although not shown in Figure 1, in some embodiments, the encoder 100 and decoder 200 may be integrated with an audio encoder and decoder, respectively, and may include a suitable multiplexer-demultiplexer unit or other hardware and software to handle the encoding of both audio and video in a common data stream or separate data streams.
[0030] The encoding / decoding system 1 shown in Figure 1 is merely an example, and it should be understood that the technology of the present invention is applicable to video encoding / decoding configurations (e.g., video encoding and video decoding) that do not necessarily involve data communication between the encoding device and the decoding device. In other examples, data may be retrieved from local memory and streamed over a network. The video encoding device may encode the data and store it in memory, and / or the video decoding device may read the data from memory and decode it. In many examples, encoding and decoding are performed by devices that do not communicate with each other, encoding the data into memory and / or retrieving the data from memory and decoding it.
[0031] The specific structures of the encoder 100 and decoder 200 in Figure 1 will be briefly described below with reference to the drawings.
[0032] Figure 2 is a schematic block diagram of an example encoder 100 for carrying out a method according to one embodiment of the present invention. As shown in Figure 2, the encoder 100 includes a prediction processing unit 101, a residual calculation unit 102, a residual conversion unit 103, a quantization unit 104, a coding unit 105, an inverse quantization unit 106, an inverse residual conversion unit 107, a reconstruction unit 108, and a filter unit 109.
[0033] In one example, the input to encoder 100 is an image block of the image to be encoded (i.e., a block or encoding unit to be encoded).
[0034] In another example, if the input to encoder 100 is an image to be encoded, encoder 100 may further include a splitting unit (not shown in Figure 2). The splitting unit is configured to divide the image to be encoded into multiple image blocks. Encoder 100 is configured to encode the multiple image blocks of the image to be encoded block by block to complete the encoding of the image to be encoded. For example, encoder 100 completes the encoding of the image to be encoded by performing an encoding process on each image block.
[0035] For example, a method for dividing an image to be encoded into multiple image blocks may include the following steps 11-13.
[0036] In step 11, the image of one frame is divided into one or more non-overlapping slices. Each slice contains multiple encoding units, and there are no dependencies between the slices, allowing them to be encoded and decoded in parallel / independently.
[0037] In step 12, for each slice, the encoding side may divide it into one or more independent encoding units that do not overlap with each other, and the independent encoding units do not have to be dependent on each other, but they may share some header information of the parallel encoding units.
[0038] In step 13, for each independent coding unit, the coding side may divide it into one or more non-overlapping coding units. When an independent coding unit is divided into multiple non-overlapping coding units, the division method may be a horizontal equal division method, a vertical equal division method, or a horizontal-vertical equal division method. Of course, the specific implementation method is not limited to these. Each coding unit within an independent coding unit may be dependent on one another, that is, they may refer to each other in the process of performing the prediction step.
[0039] The width of an encoded unit is w_cu, and its height is h_cu, optionally the width being greater than the height (unless it is an edge region). Typically, an encoded unit can be a fixed w_cu × h_cu, where both w_cu and h_cu are 2 to the power of N (where N is greater than or equal to 0). For example, the sizes of encoded units can be 16×4, 8×4, 16×2, 8×2, 4×2, 8×1, 4×1, etc.
[0040] The encoding unit may contain three components: luminance Y, chromaticity Cb, and chromaticity Cr (or three components: red R, green G, and blue B, or luminance Y, chromaticity U, and chromaticity V), or it may contain only one of these components. If the encoding unit contains three components, the sizes of the three components may be exactly the same or different, specifically relating to the image input format.
[0041] Figure 3 is a schematic diagram illustrating the correspondence between an image, parallel coding units, independent coding units, and coding units. In Figure 3, an image is divided into parallel coding unit 1 and parallel coding unit 2 according to a 3:1 ratio, and one independent coding unit contains four coding units as an example.
[0042] Optionally, the partitioning unit divides the image to be encoded into multiple image blocks, which may be further divided into smaller blocks, for example, image block partitioning based on a quadtree or binary tree structure. This partitioning may also include dividing into tiles, slices, or other larger units. A tile may be divided into multiple image blocks (or into sets of image blocks called slices).
[0043] The prediction processing unit 101 is configured to receive or acquire the original value of the block to be encoded and the reconstructed image data, predict the block to be encoded based on the relevant data in the reconstructed image data, and acquire the predicted block to be encoded.
[0044] Optionally, the prediction processing unit 101 may include an inter-predictor and an intra-predictor. The inter-predictor may determine an inter-prediction mode for encoding the block to be encoded, predict motion information, e.g., motion vectors (MV), for one or more subblocks within the current image block based on the determined inter-prediction mode, and use the motion information (e.g., motion vectors) for one or more subblocks within the current image block to obtain or generate a predicted block for the current image block. The intra-predictor may determine an intra-prediction mode for encoding the block to be encoded.
[0045] Here, intra-prediction refers to using the correlation of the video space domain to predict using the encoded block of the current image block, in order to achieve the objective of eliminating redundancy in the video space domain. For example, intra-prediction defines multiple prediction modes, each prediction mode corresponding to one texture direction (except for DC mode). For example, if the image texture is horizontal, the horizontal prediction mode can predict the image information better.
[0046] Interpretation refers to predicting the pixels of the current image using pixels from neighboring encoded images, based on the correlations in the video time domain, because video sequences contain strong time domain correlations. The interpretation portion of video encoding standards all employ block-based motion compensation techniques. The main principle is to find the optimal matching block in a previously encoded image for each pixel block of the current image. This process is called motion estimation (ME).
[0047] Furthermore, in interpretation mode, motion vectors can be used to represent the relative displacement between the block to be encoded and the optimal matching block in the reference image. Since the corresponding motion vector is transmitted to the decoding side for each divided block, if the motion vector of each block is encoded and transmitted independently, especially when the blocks are small, a considerable number of bits are required. To reduce the number of bits required to encode the motion vector, the spatial correlation between adjacent image blocks is used to predict the motion vector of the block to be encoded based on the motion vectors of adjacent encoded blocks, and the prediction difference is encoded. This effectively reduces the number of bits required to represent the motion vector. In the process of encoding the motion vector of the block to be encoded, first, the motion vector of the block to be encoded is predicted using the motion vectors of adjacent encoded blocks, and then the difference between the predicted value of the motion vector (motion vector prediction, MVP) and the actual estimated value of the motion vector (motion vector difference, MVD) is encoded, thereby effectively reducing the number of bits used to encode the MV.
[0048] The residual calculation unit 102 is configured to calculate the residual value between the original value of the block to be encoded and the predicted block of the block to be encoded, and to obtain the residual block. For example, for each pixel, the pixel value of the predicted block is subtracted from the original pixel value of the block to be encoded.
[0049] In one example, the residual transformation unit 103 is configured to determine residual coefficients based on the residual block. Optionally, this process may include performing a transformation such as a discrete cosine transform (DCT) or discrete sine transform (DST) on the residual block to obtain transformation coefficients in the transformation domain. These transformation coefficients may be called transformation residual coefficients or residual coefficients. These residual coefficients can represent the residual block in the transformation domain. Of course, the residual transformation step is not required in the process by which the encoder 100 encodes the block to be encoded.
[0050] The quantization unit 104 is configured to obtain quantized residual coefficients (or quantized residual values) by quantizing the conversion coefficients or residual values by applying scalar quantization or vector quantization. The quantization process can reduce the bit depth for some or all of the residual coefficients. For example, p-bit conversion coefficients may be truncated to q-bit conversion coefficients during quantization, where p is greater than q. The degree of quantization can be changed by adjusting the quantization parameter (QP). For example, different scales can be applied to scalar quantization to achieve finer or coarser quantization. Smaller quantization steps correspond to finer quantization, and larger quantization steps correspond to coarser quantization. Appropriate quantization steps may be indicated by QP.
[0051] In the image encoding process, to achieve image compression, it is common practice to quantize the residual block of the block to be encoded, or to quantize the residual coefficient block obtained by performing a specific process on the residual block. This allows the quantized residual block or residual coefficient block to be encoded with fewer bits. The residual block is a residual value block obtained based on the original pixel block and the predicted block of the block to be encoded, and the residual coefficient block is a coefficient block obtained by performing a specific process and transformation on the residual block.
[0052] For example, when encoder 100 quantizes a residual block, encoder 100 may divide each residual value in the residual block of the block to be encoded by a quantization coefficient to reduce the residual value in that residual block. In this way, the residual values that have been reduced after quantization can be encoded with fewer bits compared to the unquantized residual values, thereby achieving compressed encoding of the image.
[0053] The encoding unit 105 encodes the quantized residual coefficients (or quantized residual values) and outputs encoded image data (i.e., the encoding result of the current block to be encoded) in the form of an encoded bitstream (or referred to as a bitstream), and is configured to transmit the encoded bitstream to a decoder or to store it for transmission to or retrieval to a subsequent decoder. The encoding unit 105 may be further configured to encode syntax elements of the block to be encoded, for example, the prediction mode used by the block to be encoded, into a bitstream.
[0054] In one example, a feasible method for the encoding unit 105 to encode residual coefficients is a semi-fixed-length encoding scheme. First, the maximum absolute value of residuals within a residual block (RB) is defined as the modified maximum (mm). The number of bits to encode the residual coefficients within the RB is determined (the number of bits to encode residual coefficients within the same RB is the same). For example, if the code length CL of the current RB is 2 and the current residual coefficient is 1, then 2 bits are needed to encode the residual coefficient of 1, which is represented as 01. The CL of the current RB is 9 If this is the case, it indicates that 8 bits of residual coefficients and 1 bit of sign bit are encoded. The CL decision is to find the smallest M value that satisfies the condition that all residuals of the current subblock are within the range [-2^(M-1), 2^(M-1)]. If both boundary values -2^(M-1) and 2^(M-1) exist simultaneously, M must be incremented by 1, i.e., M+1 bits are needed to encode all residuals of the current RB. If only one of the two boundary values -2^(M-1) and 2^(M-1) exists, one trailing bit must be encoded to determine whether the boundary value is -2^(M-1) or 2^(M-1). If neither -2^(M-1) nor 2^(M-1) is present in any of the residuals, the trailing bit does not need to be encoded.
[0055] Of course, other residual coefficient coding methods may also be used, such as exponential Golomb coding, Golomb-Rice coding, truncated unary (TU) coding, run-length coding (RLE), or direct coding of the original residual values.
[0056] Furthermore, in some special cases, the original value may be encoded directly instead of the residual value.
[0057] The inverse quantization unit 106 is configured to inverse quantize the above-mentioned quantized residual coefficient (or quantized residual value) to obtain the inverse quantized residual coefficient (residual value after inverse quantization). This inverse quantization is the reverse application of the above-mentioned quantization unit 104, and for example, applies the inverse quantization method of the quantization method applied by the quantization unit 104 based on or using the same quantization steps as the quantization unit 104.
[0058] The residual inverse transform unit 107 is configured to perform an inverse transform on the inverse quantization residual coefficients to obtain a reconstructed residual block. Optionally, the inverse transform may include an inverse discrete cosine transform (DCT) or an inverse discrete sine transform (DST). Thus, the inverse transform values obtained by performing an inverse transform on the inverse quantization residual coefficients are the reconstructed residual values in the pixel region (or sample region). That is, after the inverse quantized residual coefficient block is inversely transformed by the residual inverse transform unit 107, the resulting block is a reconstructed residual block. Of course, if the encoder 100 does not include the residual transform unit 103, the encoder 100 does not need to include the inverse transform step.
[0059] The reconstruction unit 108 is configured to add the reconstructed residual block to the prediction block to obtain the reconstructed block in the sample region. The reconstruction unit 108 may also be an adder. For example, the reconstruction unit 108 adds the residual value in the reconstructed residual block to the predicted value of the corresponding pixel in the prediction block to obtain the reconstructed value of the corresponding pixel. The reconstructed block output by the reconstruction unit 108 may then be used to predict other image blocks to be encoded.
[0060] The filter unit 109 (or abbreviated as "filter") is configured to filter the reconstruction blocks and obtain the filtered blocks in order to perform pixel conversion smoothly or to improve image quality.
[0061] In one example, the encoding process performed by the encoder 100 may include the following steps 21 to 25.
[0062] In step 21, the prediction processing unit 101 determines the prediction mode, predicts the blocks to be encoded based on the determined prediction mode and the reconstructed blocks of the encoded image blocks, and obtains the predicted blocks of the blocks to be encoded.
[0063] Here, the reconstructed block of the encoded image block is obtained by the inverse quantization unit 106, the residual inverse transform unit 107, and the reconstruction unit 108 sequentially processing the quantized residual coefficient block of the encoded image block.
[0064] In step 22, the residual calculation unit 102 obtains the residual block of the block to be encoded based on the predicted block and the original pixel value of the block to be encoded.
[0065] In step 23, the residual conversion unit 103 converts the residual block to obtain the residual coefficient block.
[0066] In step 24, the quantization unit 104 quantizes the residual coefficient block to obtain the quantized residual coefficient block.
[0067] In step 25, the encoding unit 105 encodes the quantized residual coefficient block and the associated syntax elements (e.g., prediction mode, encoding mode) to obtain the bitstream of the block to be encoded.
[0068] Figure 4 is a schematic block diagram of an example decoder 200 for carrying out a method according to one embodiment of the present invention. The decoder 200 is configured to receive, for example, image data encoded by the encoder 100 (i.e., an encoded bitstream, e.g., an encoded bitstream of an image block and associated syntax elements) and to obtain a decoded image block.
[0069] As shown in Figure 4, the decoder 200 includes a bitstream analysis unit 201, an inverse quantization unit 202, an inverse residual transform unit 203, a prediction processing unit 204, a reconstruction unit 205, and a filter unit 206. In some examples, the decoder 200 may perform a decoding process that is almost the reverse of the encoding process described for the encoder 100 in Figure 2.
[0070] The bitstream analysis unit 201 is configured to decode the encoded bitstream and obtain quantized residual coefficients (or quantized residual values) and / or decoding parameters (for example, the decoding parameters may include one or all of the inter-prediction parameters, intra-prediction parameters, filter parameters, and / or other syntax elements performed by the encoding side). The bitstream analysis unit 201 is further configured to transfer the above decoding parameters to the prediction processing unit 204 so that the prediction processing unit 204 performs a prediction process based on the decoding parameters.
[0071] The function of the inverse quantization unit 202 may be the same as that of the inverse quantization unit 106 of the encoder 100. The inverse quantization unit 202 is configured to inverse quantize the quantized residual coefficients that are decoded and output by the bitstream analysis unit 201.
[0072] Here, inverse quantization is the reverse process of quantization. Inverse quantization refers to mapping the quantized coefficients to the reconstructed signal in the input signal space, where the reconstructed signal is an approximation of the input signal. To reconstruct image blocks from the compressed and encoded bitstream, the inverse quantization unit 202 of the decoder 200 can inverse quantize the residual blocks or residual coefficient blocks analyzed from the bitstream to reconstruct the unquantized residual blocks or residual coefficient blocks corresponding to the image blocks, thereby allowing the decoder 200 to reconstruct the image blocks based on the reconstructed residual blocks or residual coefficient blocks to obtain the reconstructed image blocks.
[0073] As an example, let's describe the case where the decoder 200 analyzes the residual block after quantization of the block to be decoded from the bitstream. The decoder 200 may dequantize the residual block using an inverse quantization unit 202. Specifically, the inverse quantization unit 202 may multiply each residual value in the analyzed residual block by a quantization coefficient to reconstruct the residual values in the unquantized residual block corresponding to the block to be decoded, and obtain the reconstructed residual block. Here, the quantization coefficient is the quantization coefficient used when the encoding device quantizes the residual block of the block to be decoded when encoding the block to be decoded. In this way, the decoder 200 can reconstruct the block to be decoded based on the reconstructed residual block after inverse quantization, and obtain the reconstructed block of the block to be decoded. As those skilled in the art will understand, the block to be encoded is the image block to be processed on the encoding side, and the block to be decoded is the image block to be processed on the decoding side.
[0074] The function of the residual inverse transform unit 203 may be the same as that of the residual inverse transform unit 107 of the encoder 100. The residual inverse transform unit 203 is configured to perform an inverse transform (for example, inverse DCT, inverse integer transform, or a conceptually similar inverse transform process) on the inversely quantized residual coefficients to obtain reconstructed residual values. The block obtained by the inverse transform is the residual block of the reconstructed block to be decoded in the pixel region.
[0075] The function of the reconfiguration unit 205 (for example, an adder) may be the same as the function of the reconfiguration unit 108 of the encoder 100.
[0076] The prediction processing unit 204 is configured to receive or acquire encoded image data (e.g., the encoded bitstream of the current image block) and reconstructed image data. The prediction processing unit 204 may further receive or acquire relevant parameters of the prediction mode and / or information about the selected prediction mode (i.e., the above-mentioned decoding parameters) from the bitstream analysis unit 201, predict the current image block based on the relevant data and decoding parameters in the reconstructed image data, and acquire the predicted block of the current image block.
[0077] The reconstruction unit 205 is configured to add the reconstructed residual block to the prediction block to obtain the reconstructed block of the image to be decoded in the sample region. For example, it adds the residual value in the reconstructed residual block to the predicted value in the prediction block.
[0078] The filter unit 206 is configured to filter the reconstructed blocks and obtain the filtered blocks. These filtered blocks are the decoded image blocks.
[0079] Specifically, in embodiments of the present invention, the decoder 200 is configured to perform a decoding method described in a later embodiment.
[0080] In the encoder 100 and decoder 200 in the embodiment of the present invention, the processing result of a certain process may be further processed before being output to the next process. For example, after processes such as interpolation filtering, motion vector derivation, or filtering, the processing result of the corresponding process may be further processed, such as clipping or shifting.
[0081] In one example, the decoding process performed by the decoder 200 may include the following steps 31-36.
[0082] In step 31, the bitstream analysis unit 201 analyzes the prediction mode and the residual coding mode.
[0083] In step 32, the bitstream analysis unit 201 analyzes the quantized correlation value (e.g., near value or QP value) based on the prediction mode and the residual coding mode.
[0084] In step 33, the inverse quantization unit 202 analyzes the residual coefficients based on the prediction mode and the quantization correlation value.
[0085] In step 34, the prediction processing unit 204 obtains the predicted value for each pixel of the current image block based on the prediction mode.
[0086] In step 35, the residual inverse transform unit 203 inversely transforms the residual coefficients to reconstruct the residual values of each pixel in the current image block.
[0087] In step 36, the reconstruction unit 205 obtains the reconstructed value based on the predicted value and residual value of each pixel of the current coding unit.
[0088] Figures 1 to 4 are merely examples provided by one embodiment of the present invention, and in some examples, the encoder 100, decoder 200, and encoding / decoding system 1 may include more or fewer components or units, and the present invention is not limited thereto.
[0089] The following image coding and decoding method according to an embodiment of the present invention will be described below with reference to the drawings.
[0090] Figure 5 is a schematic flowchart of the image coding method according to the present invention. Optionally, the image coding method may be applied to the coding / decoding system 1 shown in Figure 1, and the image coding method may be performed by the coding side 10. Specifically, the coding method may be performed by an encoder 100 included in the coding side 10. As shown in Figure 5, the image coding method provided in an embodiment of the present invention includes the following steps S101 to S103.
[0091] In S101, the encoding side obtains the maximum code length of the block to be encoded.
[0092] It can be understood that the video to be encoded may contain one or more image frames. One image frame may contain one or more image blocks. In embodiments of the present invention, the current block to be encoded corresponds to one image block of the image to be processed (the image to be processed is one of one or more image frames), and the block to be encoded may be a coding unit (CU).
[0093] Optionally, a single block to be encoded may contain multiple components. These components may be luminance components or chromaticity components.
[0094] For example, for an image block corresponding to a block to be encoded with a size of 16x2, if the image format of the image block is YUV444, then the image block includes one luminance component with a size of 16x2 and two chromaticity components with a size of 16x2.
[0095] In another example, for an image block corresponding to a block to be encoded that has a size of 16x2, if the image format of the image block is YUV422, then the image block includes one luminance component with a size of 16x2 and two chromaticity components with a size of 8x2.
[0096] Here, the maximum code length is the maximum length of the bitstream of the block to be encoded that is allowed to be buffered in the bitstream buffer, determined based on the setting overflow line of the bitstream buffer, the setting overflow line is used to indicate the maximum storage space that is allowed to be occupied by the bitstream in the bitstream buffer.
[0097] It should be understood that, in order to prevent bitstream overflow, the maximum code length may be determined based on the actual size of the memory space of the encoding bitstream buffer in the encoding / decoding system shown in Figure 1. Both the encoding and decoding sides may determine the memory space that is allowed to buffer the encoded bitstream in the current bitstream buffer based on the actual size of the bitstream buffer's memory space and the above-mentioned overflow line. Thus, the encoding and decoding sides may determine the size of the space occupied by the bitstream currently stored in the bitstream buffer and determine the remaining space of the memory space by subtracting the size of the space occupied by the currently stored bitstream from the memory space that is allowed to buffer the encoded bitstream in the current bitstream buffer.
[0098] Therefore, the maximum code length is the maximum length of a bitstream that is currently allowed to be buffered in the memory space used by the encoder to buffer the encoded bitstream. The maximum code length is the sum of the length of the remaining space in the memory space that can accommodate the bitstream and the length of the bitstream output by the memory space per unit time.
[0099] In some embodiments, the encoding side can control the bitstream buffer's set overflow line so that the space allowed to buffer the encoded bitstream is less than or equal to the total storage space size of the bitstream buffer. This allows the encoding side to determine the range of the code length based on the current set overflow line of the bitstream buffer.
[0100] Furthermore, during the image encoding process, the encoding side may adjust the bitstream buffer's set overflow line to 1 / 2, 1 / 3, or other possible size of the total memory space size of the bitstream buffer. For example, for a single "slice," in order to output the encoded bitstream of the "slice" from the bitstream buffer as quickly as possible after the encoding of the "slice" is completed by the encoding side, the actual size of the space that the bitstream buffer is allowed to accommodate the encoded bitstream may be reduced. This reduces the amount of bitstream of the "slice" stored in the bitstream buffer after the encoding of the "slice" is completed by the encoding side. Also, when adjusting the set overflow line, the space occupied by the bitstream currently stored in the bitstream buffer may exceed the set overflow line. In this case, the encoding side may determine a fixed code length for encoding the block to be encoded, using the size of the space occupied by the portion exceeding the set overflow line as a determining factor.
[0101] In S102, the encoding side pre-encodes the block to be encoded and obtains the first code length of the block to be encoded.
[0102] The first code length is the length of the bitstream obtained after the block to be encoded has been encoded.
[0103] Furthermore, the encoding side uses the original value mode. (Also known as sample mode) The blocks to be encoded may be pre-encoded based on this.
[0104] The original value mode is a mode that directly encodes the original value of the image block corresponding to the block to be encoded.
[0105] Optionally, the encoding side may use original value mode to encode values obtained by quantizing and transforming the original pixel values of the block to be encoded. In this way, the encoding side can improve the effectiveness of reconstructing the image of the block to be encoded by encoding it using original value mode.
[0106] In near-lossless compression encoding schemes, the encoding side can encode the image to be encoded using the original value mode. Here, near-lossless compression refers to a compression technique between lossless compression and lossy compression, and the purpose of near-lossless compression is to obtain high image compression quality at a constant compression ratio.
[0107] Optionally, the encoding side may pre-encode the blocks to be encoded based on a pre-configured prediction mode on the encoding side, such as point-by-point prediction mode, intra-prediction mode, or block copy mode.
[0108] Intra prediction mode is a prediction mode in which the reconstructed pixel values of adjacent blocks surrounding the block to be predicted are used as the predicted values. Block copy prediction mode is a prediction mode in which the reconstructed pixel values of surrounding encoded (decoded) blocks (not necessarily adjacent) are used as the predicted values. Point-by-point prediction mode is a prediction mode in which the reconstructed pixel values of adjacent pixels surrounding the pixel to be predicted are used as the predicted values of the pixel to be predicted.
[0109] The point-by-point prediction mode may include one or more combinations of prediction methods such as vertical prediction, horizontal prediction, vertical average prediction, and horizontal average prediction.
[0110] Vertical prediction involves obtaining the predicted value (PointPredData) of the pixel to be predicted using the reconstructed value of the pixel above it (this could be an adjacent pixel above it, or a non-adjacent pixel above it that is close in distance). Horizontal prediction involves obtaining the predicted value of the pixel to be predicted using the reconstructed value of the pixel to the left of it (this could be an adjacent pixel to the left, or a non-adjacent pixel to the left that is close in distance). Vertical average prediction involves obtaining the predicted value of the pixel to be predicted using the reconstructed values of the pixels above and below it. Horizontal average prediction involves obtaining the predicted value of the pixel to be predicted using the reconstructed values of the pixels on both the left and right sides of it.
[0111] In S103, if the first code length is greater than or equal to the maximum code length, the encoding side encodes the block to be encoded using fallback mode.
[0112] Here, the code length obtained by encoding the block to be encoded based on the fallback mode is smaller than the maximum code length.
[0113] Here, encoding a block using fallback mode means encoding the block using a fixed code length encoding scheme based on a predetermined target code length. The total code length required to encode the block is the target code length. The target code length is smaller than the maximum code length.
[0114] The first code length is the maximum code length. smaller In this case, the encoding side should understand that it does not need to encode the blocks that should be encoded using fallback mode.
[0115] Furthermore, the size of the bitstream buffer's memory space is constant. If the bitstream data input to the bitstream buffer is too large, and the data that needs to be temporarily stored in the bitstream buffer exceeds the size of that memory space, a bitstream "overflow" occurs. As a result, the excess data is lost, causing the image information within the video image frame to be encoded to be lost, and making it impossible to fully analyze the image frame based on the bitstream data output from the bitstream buffer.
[0116] Therefore, the encoding side needs to control the target code length within the maximum code length mentioned above.
[0117] In some embodiments, the codeword for the original value mode and the codeword for the fallback mode are the same. For example, if both the codeword for the original value mode and the codeword for the fallback mode are a first codeword, the encoding side can adopt the first codeword when encoding the fallback mode, and this first codeword is used to indicate either the fallback mode or the original value mode.
[0118] In some embodiments, the encoding side may select a midpoint prediction fallback mode (MPPF mode) to predict the blocks to be encoded, obtain the predicted blocks, encode the blocks to be encoded based on a fixed code length encoding scheme, and obtain the bitstream of the blocks to be encoded.
[0119] Here, based on the midpoint prediction fallback mode, the encoding side can first divide the block to be encoded into multiple 2x2 pixel sub-image blocks. For each 2x2 sub-image block, one intermediate value needs to be calculated, and the intermediate value middle is calculated as shown in equation (1) below.
number
[0120] Here, bitDepth is the bit depth of the bitstream transmission channel of the subblock to be encoded, and 1<< indicates a 1-bit left shift.
[0121] Furthermore, the encoding side may determine the mean value of the subblocks to be encoded.
[0122] In one case, if the current subblock cannot obtain a reconstructed image of the surrounding area, the mean value is the middle value mentioned above.
[0123] In another case, the mean value is the average of the reconstructed values of the 2x1 pixel point subblocks in the row prior to the subblock in question. If the reconstructed value of the 2x1 pixel point subblock in the row prior to the subblock cannot be obtained, the average of the reconstructed images of the reconstructed 2x2 subblocks prior to the subblock in question is taken.
[0124] Furthermore, the encoding side may determine a bias value for the subblock. The bias value is used to limit the mean value. The encoding side may clamp the mean using the bias value and the middle value to limit the mean value to a range of values consisting of the bias value and the middle value. Thus, the mean value adjusted by the bias value and the middle value is determined as the predicted value for the subblock to be encoded for the current 2x2 pixel point.
[0125] Here, the bias value can be determined according to the following equation (2).
number
[0126] Here, mppStepSize is used to indicate the quantization step in the quantization process of one component of the block to be encoded, where [k] is the [k]th component of the block to be encoded, and 1<< indicates a left shift of 1 bit.
[0127] Alternatively, based on the MPPF Mode, the residual value of the 2x2 pixel subblock may be calculated based on the order of pixel point A in the upper left corner, pixel point B in the upper right corner, pixel point C in the lower left corner, and pixel point D in the lower right corner, as shown in Figure 6.
[0128] Optionally, in the process of reconstructing the subblock to be encoded, the reconstructed value of each pixel point may be determined sequentially in the order of pixel point A in the upper left corner, pixel point B in the upper right corner, pixel point C in the lower left corner, and pixel point D in the lower right corner.
[0129] In some embodiments, the encoding side may encode the blocks to be encoded using residual coding mode.
[0130] Optionally, the encoding side may predict the blocks to be encoded using a prediction mode corresponding to the fallback mode. Alternatively, the encoding side may predict the blocks to be encoded using one of the pre-configured prediction modes of the encoding side.
[0131] Here, the pre-configured prediction mode on the encoding side may include point-by-point prediction mode, intra-prediction mode, block copy mode, etc.
[0132] Optionally, the encoding side may determine a prediction mode corresponding to the fallback mode as one of the pre-configured prediction modes of the encoding side. Alternatively, the encoding side may select one of the pre-configured prediction modes as the prediction mode used when predicting the current block to be encoded during the encoding process.
[0133] As a result, for all blocks to be encoded using the fallback mode, the encoding side performs predictions using the fixed prediction mode.
[0134] Optionally, the fallback modes provided in embodiments of the present invention may include a first fallback mode and a second fallback mode. Here, the first fallback mode predicts the block to be encoded using a fixed prediction mode, such as a vertical average prediction mode, when encoding a block to be encoded using the fallback mode. The second fallback mode does not have a fixed prediction mode, and when encoding a block to be encoded using the second fallback mode, one of the preset prediction modes on the encoding side may be selected to predict the block to be encoded. Furthermore, the second fallback mode does not have a prediction mode, and when encoding a block to be encoded using the second fallback mode, the original value is directly quantized and dequantized to obtain the reconstructed value.
[0135] As a result, after obtaining the predicted block of the block to be encoded, the encoding side may perform steps 22 to 25 described above to obtain the residual block of the block to be encoded based on the original pixel values of the predicted block and the block to be encoded, and then transform the residual block to obtain the residual coefficient block. Furthermore, the residual coefficient block is quantized to obtain the quantized residual coefficient block. Finally, the quantized residual coefficient block is encoded to obtain the bitstream of the block to be encoded.
[0136] In some embodiments, the encoding side may first determine the quantization parameter QP value of the block to be encoded and then quantize the residual value.
[0137] Optionally, the encoding side may derive initial quantization parameters for the block to be encoded based on the complexity information of the image block corresponding to the block to be encoded and the remaining space in the bitstream buffer. Furthermore, the encoding side may determine target quantization parameters for the block to be encoded based on the initial quantization parameters and quantization parameter adjustment values. The range of values for the target quantization parameters is between zero and a preset maximum value of the encoding side's quantization parameters. For example, the target quantization parameters for the block to be encoded may be the sum of the initial quantization parameters and the quantization parameter adjustment values.
[0138] Here, the larger the remaining capacity of the bitstream buffer, the larger the quantization parameter adjustment value. This quantization parameter adjustment value may be a positive integer, such as 4 or 8.
[0139] Furthermore, the encoding side may determine a fixed code length for each component of the block to be encoded.
[0140] The block to be encoded contains one or more components. The block to be encoded may contain three components: luminance Y, chromaticity Cb, and chromaticity Cr (or three components: red R, green G, and blue B, or three components: luminance Y, chromaticity U, and chromaticity V), or it may contain only one of these components. If the block to be encoded contains three components, the sizes of the three components may be exactly the same or different, specifically related to the image input format.
[0141] For example, if the image format of the block to be encoded is YUV400, the block to be encoded contains only the luminance component, and the encoding side only needs to determine the fixed code length of the luminance component. Alternatively, if the image format of the block to be encoded is YUV420, the block to be encoded contains three components: luminance Y, chromaticity U, and chromaticity V, and the encoding side needs to determine the fixed code length of the luminance component, the fixed code length of the first chromaticity component, and the fixed code length of the second chromaticity component.
[0142] In one example, the encoding side may obtain the target total code length and the image format of the block to be encoded. The target total code length is the total code length required to encode each pixel point of the block to be encoded, determined based on the target bits per pixel (BPP). The image format of the block to be encoded is used to indicate the code length ratio between the chromaticity component and the luminance component. Based on the target total code length and code length ratio of the block to be encoded, the encoding side may determine the fixed code length of the luminance component and the fixed code length of the chromaticity component of the block to be encoded.
[0143] Here, the target BPP is used to indicate the code length required when encoding each pixel point of the block to be encoded at the target compression ratio. The target BPP may be determined based on the target compression ratio of the block to be encoded, or it may be considered as the average code length required when encoding each pixel point of the block to be encoded. The target BPP is analyzed from the image header information in the bitstream.
[0144] Here, the target BPP is also used to indicate the code length required when encoding each pixel point of the block to be encoded at the target compression ratio. The target BPP may be determined based on the target compression ratio of the block to be encoded.
[0145] Example 1: If the target BPP of the block to be encoded is 8, that is, the target total code length of the block to be encoded is (8 bits × number of pixels in the block to be encoded), and the image format is YUV400, then the block to be encoded may contain only the luminance component, and the total code length of the luminance component may be (8 bits × number of pixels in the block to be encoded), that is, the fixed code length of the luminance component (code length of one luminance pixel) is 8 bits. The encoding side may encode the block to be encoded using a fixed code length encoding scheme based on the total code length of the block to be encoded determined above. Here, if the block to be encoded is a 16 × 2 image block, the target total code length of the block to be encoded is 256 bits.
[0146] Example 2: If the current target BPP is 8, i.e., the target total code length of the block to be encoded is (8 bits × number of pixels in the block to be encoded), and the image format is YUV444, then the block to be encoded contains three components: luminance Y, chromaticity U, and chromaticity V. In this case, it should be understood that the target total code length cannot be equally allocated to the three components: luminance Y, chromaticity U, and chromaticity V. Based on the image format being YUV444, the code length ratio of the Y component:U component:V component may be 2:1:1. Thus, the encoding side may determine that the total code length of the Y component is (4 bits × number of pixels in the block to be encoded), and the total code lengths of both the U component and the V component are (2 bits × number of pixels in the block to be encoded). Therefore, the encoding side may encode the Y component of the block to be encoded using a fixed code length encoding scheme based on a code length of (4 bits × number of pixels in the block to be encoded), and encode the U and V components of the block to be encoded using a fixed code length encoding scheme based on a code length of (2 bits × number of pixels in the block to be encoded).
[0147] Furthermore, based on the fact that the image format is YUV444, the number of pixels in each chromaticity U or V component is the same as the number of pixels in the luminance (Y) component. Therefore, the encoding side may encode each pixel point in the luminance Y component using a fixed code length of 4 bits (i.e., the fixed code length for luminance is 4 bits). Alternatively, the encoding side may encode each pixel point in the chromaticity U or V component using a fixed code length of 2 bits (i.e., the fixed code length for chromaticity is 2 bits).
[0148] Example 3: If the current target BPP is 8, that is, the target total code length of the block to be encoded is (8 bits × number of pixels in the block to be encoded), and the image format is YUV422, then the block to be encoded contains three components: luminance Y, chromaticity U, and chromaticity V. In this case, it should be understood that (8 bits × number of pixels in the block to be encoded) cannot be equally allocated to the three components: luminance Y, chromaticity U, and chromaticity V. Based on the image format being YUV422, the code length ratio of the Y component:U component:V component may be 2:1:1. Thus, the encoding side may determine that the total code length of the Y component is (4 bits × number of pixels in the block to be encoded), and the total code lengths of both the U component and the V component are (2 bits × number of pixels in the block to be encoded). Therefore, the encoding side may encode the Y component of the block to be encoded using a fixed-length code based on a code length of 4 bits × the number of pixels in the block to be encoded, i.e., a fixed code length of 4, and encode the U and V components of the block to be encoded using an encoding scheme where the fixed code length is (64 / the number of pixels in the block to be encoded), based on a code length of (2 bits × the number of pixels in the block to be encoded), for example 2 bits × 16 × 2, i.e., 64 bits.
[0149] Furthermore, based on the fact that the image format is YUV422, since the number of pixels in each chromaticity U or V component is half the number of pixels in the luminance Y component, the encoding side may encode each pixel point in the luminance Y component with a fixed code length of 4 bits (i.e., the fixed code length of the luminance component is 4 bits). Similarly, the encoding side may encode each pixel point in the chromaticity U or V component with a fixed code length of 4 bits (i.e., the fixed code length of the chromaticity component is 4 bits).
[0150] In another example, the encoding side may obtain the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required to encode the header information of the block to be encoded. Furthermore, the encoding side may determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be encoded based on the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required to encode the header information of the block to be encoded.
[0151] For each image block's encoded bitstream, header information is data of a specific length at the beginning of the bitstream, which may be used to indicate the image parameters of the current image block. For example, these image parameters may include one or more of the bit depth, target BPP, quantization parameters, and texture complexity of the current image block.
[0152] For example, if the current target BPP is 8, meaning the target total code length of the block to be encoded is (8 bits × number of pixels in the block to be encoded), the code length required to encode the header information is (2 bits × number of pixels in the block to be encoded), and the image format is YUV400, then the block to be encoded may contain only the luminance component, and the total code length of the luminance component may be (6 bits × number of pixels in the block to be encoded). Therefore, the fixed code length of the luminance component is limited to 6 bits. In one example, the encoding side may encode the block to be encoded using a fixed code length encoding scheme based on a code length of (4 bits × number of pixels in the block to be encoded), for example, 4 bits × 16 × 2, i.e., 128 bits.
[0153] Furthermore, in the image coding and decoding process, since the human eye is more sensitive to image brightness, code lengths are usually preferentially assigned to the brightness Y component in an image block. Therefore, the sum of the fixed code lengths of all pixels in the brightness component is greater than or equal to the sum of the fixed code lengths of all pixels in the chromaticity component. This makes it possible to improve the image effect as seen by the human eye based on the image coding and decoding process.
[0154] In another example, the encoding side may obtain the target BPP of the block to be encoded, the image format of the block to be encoded, and the code length required to encode the header information of the block to be encoded. Furthermore, the encoding side may determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be encoded based on the remaining capacity of the bitstream buffer, the target BPP of the block to be encoded, the code length ratio, and the code length required to encode the header information of the block to be encoded.
[0155] Optionally, the sum of the code lengths of all components of the block to be encoded is the target code length of the block to be encoded minus the code length of the header information of the block to be encoded and the excess code length of the bitstream buffer.
[0156] Here, the target code length is the code length of the block to be encoded, determined based on the target BPP; the change in the set overflow line is less than the difference between the fixed code length of the block to be encoded and the code length of the header information of the block to be encoded; and the bitstream buffer excess code length is the code length of the code stored in the bitstream buffer that exceeds the current set overflow line.
[0157] For example, if the target BPP is 8, the target code length of the block to be encoded is (8 bits × number of pixels in the block to be encoded), and the header information needs to occupy (2 bits × number of pixels in the block to be encoded), then if the bitstream buffer state is greater than the currently set overflow line, the code length occupied by the portion greater than the overflow line is set to overflow_bpp. In this case, the sum of the code lengths of all components of the block to be encoded is the target total code length of the block to be encoded (i.e., 8 bits × number of pixels in the block to be encoded) minus the code length occupied to encode the header information (e.g., 2 bits × number of pixels in the block to be encoded) and overflow_bpp (e.g., 1 bit × number of pixels in the block to be encoded). Therefore, in this case, the sum of the code lengths of all components of the block to be encoded is 5 bits × number of pixels in the block to be encoded. Furthermore, the encoding side may determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be encoded based on the image format of the block to be encoded and 5 bits × the number of pixel points in the block to be encoded.
[0158] In some embodiments, if it is necessary to adjust the setting overflow line, the size of the setting overflow line satisfies equation (3) below.
number
[0159] Here, delta_bit = overflow_bpp × block_size, where block_size is the size of the encoded block. target_bpp indicates the target BPP. cu_header_bpp indicates the code length used to encode the header information of the block to be encoded, and cu_header_bpp is less than or equal to target_bpp. Also, overflow_bpp indicates the code length stored in the bitstream buffer that exceeds the current set overflow line.
[0160] In some embodiments, if the block to be encoded contains multiple components, the multiple components of the block to be encoded share a fallback mode (sharing means that all of the components either use a fallback mode or none of them use a fallback mode). This allows the encoding side to decide whether or not only one of the components uses a fallback mode, and if one of the components uses a fallback mode, the other components also use a fallback mode. Alternatively, if some of the multiple components of the block to be encoded share a fallback mode, the encoding side may decide whether or not only one of those components uses a fallback mode, and then decide whether or not the other components use a fallback mode. Alternatively, if none of the multiple components of the block to be encoded share a fallback mode, the encoding side may decide whether or not each component uses a fallback mode.
[0161] In some embodiments, when the current block to be encoded is encoded using fallback mode, the current bitrate control parameters are not updated; that is, the bitrate control parameters corresponding to the previously encoded block are determined as the bitrate control parameters for the block to be encoded. Here, these bitrate control parameters are used to derive encoding information for the next block to be encoded, such as parameters like the quantization step.
[0162] In the encoding and decoding process, for each image block to be encoded, after the encoding of the current image block is completed, the bitrate control parameters on the encoding and decoding sides are updated based on information such as the complexity of the current image block and the code length required during encoding. The updated bitrate control parameters are used to derive information for the next image block to be encoded, such as in the quantization step. However, when encoding an image block based on a fallback mode, the code length of the block to be encoded is fixed, so the code length required during encoding cannot accurately reflect the current image content. Therefore, if a fallback mode is selected for the current image block, the bitrate control parameters are not updated.
[0163] Optionally, for blocks to be encoded that have multiple components, if one component of the currently encoded block is encoded using fallback mode, the current bitrate control parameter is not updated.
[0164] The image encoding method provided in an embodiment of the present invention has at least the following beneficial effects. The method first pre-encodes the block to be encoded, compares the length of the bitstream obtained by pre-encoding with the code length that is permitted to be occupied by the block to be encoded, and determines whether or not a bitstream overflow or underflow will occur based on the comparison result. If it is determined that a bitstream overflow or underflow will occur, the block to be encoded is encoded using a fallback mode so that the image information of the block to be encoded is not lost.
[0165] In some embodiments, the present invention further provides an image decoding method, which corresponds to the encoding method shown in Figure 5. Figure 7 is a schematic flowchart of the image decoding method according to the present invention. The image decoding method may be performed by a decoder 200, or by a decoding side (for example, a decoding side 20 shown in Figure 1) that supports the functions of the decoder 200. Here, the case in which the decoding side performs the decoding method will be described as an example. The image decoding method includes the following steps S201 to S203.
[0166] In S201, the decoding side analyzes the bitstream of the block to be decoded, and if the bitstream of the block to be decoded contains the first codeword, it decides whether or not the image block corresponding to the block to be decoded uses fallback mode.
[0167] In the bitstream of the block to be decoded, the codeword indicating the encoding mode is the first codeword, and the first codeword is used to indicate either the fallback mode or the original value mode.
[0168] In some embodiments, the decoding side may determine whether the image block corresponding to the block to be decoded uses a fallback mode based on whether the code length encoding the block to be decoded based on the original value mode overflows.
[0169] Optionally, if the code length of the image block corresponding to the block to be decoded, encoded based on the original value mode, is greater than or equal to the maximum code length of the block to be decoded, the decoder may decide that the image block corresponding to the block to be decoded uses the fallback mode.
[0170] Here, the bitstream of the block to be decoded may be a bitstream received by the decoder from the encoder, or it may be a bitstream obtained from another device, such as a bitstream obtained from a storage device, and the embodiments of the present invention are not limited thereto.
[0171] Here, the code length of the block to be decoded is less than the maximum code length of the block to be decoded. The maximum code length is the maximum length of the bitstream of the block to be decoded that is allowed to be buffered in the bitstream buffer, determined based on the bitstream buffer's setting overflow line, which is used to indicate the maximum memory space that is allowed to be occupied by the bitstream in the bitstream buffer.
[0172] The maximum code length of a bitstream that is permitted to be buffered in the bitstream buffer is the maximum length of a bitstream that is permitted to be buffered in the bitstream buffer when the encoding side encodes the block to be decoded. The decoding side may directly determine the maximum code length by analyzing the bitstream of the block to be decoded. Alternatively, the decoding side may analyze the bitstream of the block to be decoded and determine the remaining memory state of the bitstream buffer when the encoding side encodes the image block corresponding to the block to be decoded. Furthermore, the decoding side may determine the maximum code length based on the remaining memory state of the bitstream buffer.
[0173] For an explanation regarding the maximum code length, please refer to the relevant explanation in step S101 above.
[0174] In some embodiments, the codeword for original value mode and the codeword for fallback mode are the same. For example, if both the codeword for original value mode and fallback mode are the first codeword, the decoder may analyze the bitstream of the block to be decoded to obtain the first codeword, and then determine whether the block to be decoded uses fallback mode or original value mode.
[0175] Furthermore, the decryption side may decide whether or not the block to be decrypted uses fallback mode based on the size of the memory space occupied within the bitstream buffer.
[0176] If the decoding side determines that the memory space occupied in the bitstream buffer when the image block to be decoded is encoded is greater than a first preset memory value, i.e., an overflow occurs, the decoding side decides that the image block corresponding to the block to be decoded will use fallback mode. Otherwise, the decoding side decides that the image block corresponding to the block to be decoded will use original value mode.
[0177] The size of the first pre-set memory value may be determined based on the actual memory size of the bitstream buffer, without any particular limitations.
[0178] Optionally, if the decoding side determines that the length of the bitstream of the block to be decoded is the sum of the products of the image bit width and pixel count of all components, the decoding side may analyze the bitstream of the block to be decoded and reconstruct the image block of the block to be decoded based on the original value mode.
[0179] In some embodiments, the block to be decoded may contain one or more components.
[0180] Optionally, the block to be decoded may contain only the luminance component. Alternatively, the block to be decoded may contain three components, for example, luminance Y, chromaticity Cb, and chromaticity Cr (or red R, green G, and blue B, or luminance Y, chromaticity U, and chromaticity V). Alternatively, in addition to the above three components, the block to be decoded may also contain an α component, i.e., the block to be decoded may contain a total of four components. Here, the α component is the pixel transparency component. When the value of component α is 0, the pixel corresponding to the decoded block is transparent, and the image bit width of the α component is different from the other three components.
[0181] In some embodiments, if the block to be decoded contains multiple components, the multiple components of the block to be decoded share a fallback mode (sharing a fallback mode means that all of the components either use the fallback mode or none of them use the fallback mode). This allows the decoder to decide whether or not only one of the components uses the fallback mode, and if one of the components uses the fallback mode, the other components also use the fallback mode. Alternatively, if some of the multiple components of the block to be decoded share a fallback mode, the decoder may decide whether or not only one of those components uses the fallback mode, and then decide whether or not the other components use the fallback mode. Alternatively, if none of the multiple components of the block to be decoded share a fallback mode, the decoder may decide whether or not each component uses the fallback mode.
[0182] Specifically, the bitstream of the block to be decoded may include an identifier to indicate the situation in which the above fallback mode is shared. The decoder may then determine, based on this identifier, which components share the fallback mode, and whether or not each component uses the fallback mode.
[0183] In S202, if the image block corresponding to the block to be decoded uses fallback mode and the code length stored in the bitstream buffer exceeds the set overflow line, the decoding side determines a fixed code length for each component of the block to be decoded based on the excess code length of the bitstream buffer.
[0184] Here, the block to be decoded contains one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required when analyzing a single pixel point of the first component, and the overcode length of the bitstream buffer is the code length of the code length stored in the bitstream buffer that exceeds the current set overflow line.
[0185] In some embodiments, the decoding side may determine the fixed code length of each component of the block to be decoded based on one or more of the target BPP of the block to be decoded, the image format of the block to be decoded, the code length of the header information of the block to be decoded, and the remaining memory of the bitstream buffer when encoding the image block to be decoded.
[0186] Here, the target BPP is further used to indicate the code length required when decoding each pixel point of the block to be decoded at the target compression ratio. The target BPP may be determined based on the target compression ratio of the block to be decoded, and the target BPP may be understood as the average code length required when decoding each pixel point of the block to be decoded. Furthermore, the image format of the block to be decoded may be used to indicate the code length ratio between the chromaticity component and the luminance component. For example, if the image format is YUV444, the code length ratio of the Y component:U component:V component in the image block to be decoded may be 2:1:1.
[0187] Optionally, the decoding side may analyze the bitstream of the block to be decoded to obtain the BPP of each component of the block to be decoded, or the decoding side may determine the BPP of each component of the block to be decoded according to the following possible embodiments. It should be understood that the method by which the decoding side determines the fixed code length of each component of the block to be decoded is the same as the method by which the encoding side determines the fixed code length of each component when encoding the bitstream of the image block corresponding to the block to be decoded.
[0188] In one embodiment, the decoding side may obtain the target BPP and image format of the block to be decoded, and determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be decoded based on the target BPP and code length ratio of the block to be decoded.
[0189] Furthermore, the method by which the decoding side determines the fixed code length of each component corresponds to the encoding side. When the encoding side determines the fixed code length of each component of an image block based on the target BPP and image format of the image block, the decoding side similarly determines the fixed code length of each component of the image block based on the target BPP and image format of the image block when decoding the encoded bitstream of the image block.
[0190] Example 1: If the target BPP of the block to be decoded is 8, the target total code length of the block to be decoded is 8 bits × the number of pixels in the block to be decoded, and the image format is YUV400, then the block to be decoded may contain only the luminance component, and the total code length of the luminance component may be 8 bits × the number of pixels in the block to be decoded, that is, the fixed code length of the luminance component (code length of one luminance pixel) is 8 bits. The decoding side may decode the block to be decoded using a fixed code length decoding method based on the code length of 8 bits × the number of pixels in the block to be decoded. Here, if the block to be decoded is a 16 × 2 image block, the code length of the block to be decoded is 256 bits.
[0191] Example 2: If the current target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixels in the block to be decoded, and the image format is YUV444, then the block to be decoded contains three components: luminance Y, chromaticity U, and chromaticity V. In this case, it should be understood that 8 bits × the number of pixels in the block to be decoded cannot be equally allocated to the three components: luminance Y, chromaticity U, and chromaticity V. Based on the image format being YUV444, the code length ratio of the Y component:U component:V component may be 2:1:1. In this case, the decoding side may determine that the total code length of the Y component is 4 bits × the number of pixels in the block to be decoded, and the total code lengths of the U and V components are both 2 bits × the number of pixels in the block to be decoded. Therefore, the decoding side may decode the Y component of the block to be decoded using a fixed code length decoding method based on a code length of 4 bits × the number of pixels in the block to be decoded, and decode the U and V components of the block to be decoded using a fixed code length decoding method based on a code length of 2 bits × the number of pixels in the block to be decoded.
[0192] Furthermore, based on the fact that the image format is YUV444, the number of pixels in each chromaticity U or V component is the same as the number of pixels in the luminance Y component. Therefore, the decoding side may decode each pixel point in the luminance Y component using a fixed code length of 4 bits (i.e., the fixed code length of the luminance component is 4 bits). Alternatively, the decoding side may decode each pixel point in the chromaticity U or V component using a fixed code length of 2 bits (i.e., the fixed code length of the chromaticity component is 2 bits).
[0193] Example 3: If the current target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixels in the block to be decoded, and the image format is YUV422, then the block to be decoded contains three components: luminance Y, chromaticity U, and chromaticity V. In this case, it should be understood that 8 bits × the number of pixels in the block to be decoded cannot be equally allocated to the fixed code lengths of the three components: luminance Y, chromaticity U, and chromaticity V. Based on the image format being YUV422, the code length ratio of the Y component:U component:V component may be 2:1:1. In this case, the decoding side may determine that the total code length of the Y component is 4 bits × the number of pixels in the block to be decoded, and the total code lengths of the U and V components are both 2 bits × the number of pixels in the block to be decoded. Therefore, the decoding side may decode the Y component of the block to be decoded using a fixed code length decoding method based on a code length of 4 bits × the number of pixels in the block to be decoded, and decode the U and V components of the block to be decoded using a fixed code length decoding method based on a code length of 2 bits × the number of pixels in the block to be decoded.
[0194] Furthermore, based on the image format being YUV422, since the number of pixels in each chromaticity U or V component is half the number of pixels in the luminance Y component, the decoding side may decode each pixel point in the luminance Y component using a fixed code length of 4 bits (i.e., the fixed code length of the luminance component is 4 bits). Similarly, the decoding side may decode each pixel point in the chromaticity U or V component using a fixed code length of 4 bits (i.e., the fixed code length of the chromaticity component is 4 bits).
[0195] In another embodiment, the decoding side may obtain the target BPP of the block to be decoded, the image format of the block to be decoded, and the code length required to decode the header information of the block to be decoded. Furthermore, the decoding side may determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be decoded based on the target BPP of the block to be decoded, the image format of the block to be decoded, and the code length required to decode the header information of the block to be decoded.
[0196] For example, if the current target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixels in the block to be decoded, the code length required to decode the header information is 2 bits × the number of pixels in the block to be decoded, and the image format is YUV400, then the block to be decoded may contain only the luminance component, and the total code length of the luminance component may be 6 bits × the number of pixels in the block to be decoded. Therefore, the fixed code length of the luminance component is 6 bits. The decoding side may decode the block to be decoded using a fixed code length decoding scheme based on the code length of 6 bits × the number of pixels in the block to be decoded. In another example, the decoding side may obtain the target BPP of the block to be decoded, the image format of the block to be decoded, and the code length required to decode the header information of the block to be decoded. Furthermore, the decoding side may determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be decoded based on the remaining capacity of the bitstream buffer, the target BPP of the block to be decoded, the code length ratio, and the code length required to decode the header information of the block to be decoded.
[0197] Optionally, the sum of the code lengths of all components of the block to be decoded is the target code length of the block to be decoded minus the code length of the header information of the block to be decoded and the excess code length of the bitstream buffer.
[0198] Here, the target code length is the code length of the block to be decoded, determined based on the target BPP; the change in the set overflow line is less than or equal to the difference between the fixed code length of the block to be decoded and the code length of the header information of the block to be decoded; and the excess code length of the bitstream buffer is the code length of the code length stored in the bitstream buffer that exceeds the current set overflow line.
[0199] For example, if the target BPP is 8, the target code length of the block to be decoded is 8 bits × the number of pixels in the block to be decoded, and the header information needs to occupy 2 bits × the number of pixels in the block to be decoded, then if the bitstream buffer state is greater than the currently set overflow line, the code length occupied by the portion greater than the overflow line is set to overflow_bpp. In this case, the sum of the code lengths of all components of the block to be decoded is the code length obtained by subtracting the code length occupied to decode the header information (e.g., 2 bits × the number of pixels in the block to be decoded) and overflow_bpp (e.g., 1 bit × the number of pixels in the block to be decoded) from the target code length of the block to be decoded (i.e., 8 bits × the number of pixels in the block to be decoded). Therefore, in this case, the sum of the code lengths of all components of the block to be decoded is 5 bits × the number of pixels in the block to be decoded. Furthermore, the decoding side may determine the fixed code length of the chromaticity component and the fixed code length of the luminance component of the block to be decoded based on the image format of the block to be decoded and 5 bits × the number of pixel points in the block to be decoded.
[0200] In S203, the decoding side analyzes the pixel points of each component in the block to be decoded based on the fixed code length of each component, and decodes the block to be decoded.
[0201] In some embodiments, as shown in Figure 8, step S203 may be specifically implemented by the following steps S2031 to S2034.
[0202] In S2031, the decoding side determines the residual value of each component of the block to be decoded based on the fixed code length of each component.
[0203] For example, the decoding side may determine the residual values of each pixel point of each component in the block to be decoded based on the fixed code length of each component of the block to be decoded determined in step S202 above.
[0204] In S2032, the decoding side obtains the prediction mode of the block to be decoded in fallback mode, predicts the image block corresponding to the block to be decoded based on the prediction mode, and obtains the predicted value of the block to be decoded.
[0205] Optionally, the decryption side may predict the blocks to be decrypted using a prediction mode corresponding to the fallback mode, i.e., the first fallback mode described above. Alternatively, the decryption side may predict the blocks to be decrypted using one of the prediction modes pre-configured by the decryption side, i.e., the second fallback mode described above. It should be understood that the decryption side may determine the prediction mode corresponding to the fallback mode as one of the pre-configured prediction modes of the decryption side. In this case, the decryption side makes predictions using the fixed prediction mode for all blocks to be decrypted using the fallback mode.
[0206] The pre-set prediction mode on the decoding side is the same as the pre-set prediction mode on the encoding side. For a detailed explanation of the prediction mode, please refer to the relevant explanation in step S103 above, and the explanation will be omitted here.
[0207] In one embodiment, if the block to be decoded contains one component, the decoder may analyze the bitstream of the block to be decoded to determine the prediction mode for the block. Alternatively, the decoder may determine a pre-configured prediction mode as the prediction mode for the block to be decoded. It should be understood that this pre-configured prediction mode is the same as the prediction mode used by the encoding side in the prediction process.
[0208] In another embodiment, if the block to be decoded contains multiple components, the multiple components of the block to be decoded may use the same prediction mode. In this case, the decoder may determine the prediction mode for only one component, and this prediction mode is the prediction mode for all components of the block to be decoded. Alternatively, some of the multiple components of the block to be decoded may use the same prediction mode. In this case, the decoder only needs to determine the prediction mode for one of the components and the prediction modes for the other components. Alternatively, the decoder may determine the prediction mode for each component individually.
[0209] In S2033, the decoding side determines the quantization parameters of the block to be decoded and dequantizes the residual values of the block to be decoded based on the quantization parameters.
[0210] Optionally, the decoder may first determine the initial quantization parameters of the block to be decoded, and then adjust these initial quantization parameters based on quantization parameter adjustment values to determine the target quantization parameters of the block to be decoded. The range of the target quantization parameter value is between zero and the preset maximum value of the encoding side's quantization parameters.
[0211] For example, the target quantization parameter of the block to be decoded may be the sum of the initial quantization parameter and the quantization parameter adjustment value. It should be understood that the method by which the decoding side determines the target quantization parameter is the same as the method by which the encoding side determines the target quantization parameter of the image block described above.
[0212] Here, the larger the remaining capacity of the bitstream buffer, the larger the quantization parameter adjustment value. This quantization parameter adjustment value may be a positive integer, such as 4 or 8.
[0213] The method by which the decoding side determines the original quantization parameters includes at least the following embodiments.
[0214] In one embodiment, the header information of the block to be decoded includes quantization parameters when performing quantization processing on the image block corresponding to the block to be decoded, and the decoding side may analyze the header information of the block to be decoded to determine the initial quantization parameters of the block to be decoded.
[0215] In another embodiment, the decoding side may derive the initial quantization parameters of the block to be decoded based on the complexity information of the image block corresponding to the block to be encoded and the remaining space in the bitstream buffer.
[0216] Furthermore, the decoding side can determine the quantization step Qstep based on the QP value by at least one of formula derivation or table lookup, and three possible implementations are provided below. Next, for the selected combination of quantizers, inverse quantization is performed on each pixel point of the block to be decoded using the Qstep of the block to be decoded.
[0217] Method 1:
number
[0218] Method 2:
number
[0219] Method 3:
number
[0220] Optionally, quantization and dequantization may be achieved using the conventional scalar quantization method in H.265 described below. Quantization:
number
number
[0221] However, l is the level value obtained after quantization, c is the residual coefficient to be quantized (this residual coefficient may be the residual coefficient of the transformation region, i.e., the transformed residual coefficient, or the residual coefficient of the pixel region, i.e., the residual value), Qstep is the quantization step, f is a parameter for controlling rounding, f∈[0,1), sign represents the sign function, floor represents the truncation function, and c' is the value after inverse quantization.
[0222] It can be understood that a larger QP value results in a larger Qstep value, leading to coarser quantization, greater image distortion due to quantization, and a smaller bitrate for coefficient coding.
[0223] [0,1-f) represents the quantization dead zone, and the parameter f is related to the length of the quantization dead zone. The smaller f is, the longer the quantization dead zone becomes, and the closer the quantized level value is to zero. When f=0.5, the above quantization and inverse quantization formulas are equivalent to rounding, and the quantization distortion is minimized. When f<0.5, the smaller f is, the greater the quantization distortion becomes, and the bitrate of coefficient coding decreases. In H.265, f=1 / 3 is selected for I frames and f=1 / 6 for B / P frames.
[0224] For example, the quantization or inverse quantization formulas for a homogeneous quantizer can refer to the above quantization and inverse quantization formulas, and the parameter f can be taken in the following way.
[0225] Method 1: f takes the value 0.5 or another fixed value.
[0226] Method 2: f is adaptively determined based on the QP value, prediction mode, and whether or not a transformation is performed.
[0227] In S2034, the decoding side reconstructs the block to be decoded based on the residual value and predicted value after inverse quantization of the block to be decoded, and obtains the reconstructed block of the image block.
[0228] Based on the above embodiment, when the encoding side uses fallback mode, the decoding side can decode the blocks to be decoded using fallback mode, and based on the remaining memory in the bitstream buffer, it is possible to avoid bitstream overflow or underflow. This prevents the loss of image information of the blocks to be decoded.
[0229] In some embodiments, the image decoding process provided in the present invention may specifically include the following steps.
[0230] In step 1, it is determined whether the block to be decrypted satisfies condition 1. If condition 1 is met, the block to be decrypted is decrypted using fallback mode.
[0231] Condition 1 above specifically means that the total code length obtained by encoding all components of the block to be decoded in original value mode exceeds the currently scalable code length of the bitstream buffer. Here, the currently scalable code length of the bitstream buffer can be determined by subtracting the memory capacity occupied by the code length currently stored in the bitstream buffer from the memory capacity indicated by the current setting overflow line.
[0232] In other words, if the current bitstream buffer state cannot simultaneously satisfy the requirement of encoding all components in original value mode, the system analyzes the blocks to be decoded based on the fallback mode and turns off original value mode.
[0233] Optionally, the decoder may first obtain the code length (CurrBits) stored in the current bitstream buffer. Furthermore, the decoder may determine that the image size of one block to be decoded is, for example, 16 width (CbWidth) and 2 height (CbHeight). The decoder then determines the code length required to encode the block to be decoded in original value mode (FallbackFlag=0). Specifically, the image format (image_format) and image size (cbChromaSize) of each component of the block to be decoded may be analyzed to obtain the code length (modeBits) required to encode each component in original value mode.
[0234] Furthermore, the decoding side may calculate the total code length (BitDepth[0] × cbLumaSize + BitDepth[1] × cbChromaSize × 2 - (TargetBpp << 1)) required to encode the block to be decoded in original value mode. Then, it determines whether the total code length satisfies condition 1, and if it satisfies condition 1, it decodes the block to be decoded in fallback mode. Finally, the decoding side may position the decoded block (CuPosX[0], CuPosY[0]). This allows for the analysis of the next image block.
[0235] In step 2, the decryption side may analyze the complexity and encoding mode of the block to be decrypted.
[0236] Optionally, the decoder may analyze the complexity (complexity_level_flag) of one component of the block to be decoded with a fixed code length of 1 bit (u(1)) or 3 bits.
[0237] Furthermore, the decryption side may analyze the encoding mode of the block to be decrypted.
[0238] The decoding side may first determine the prediction mode and, based on that prediction mode, determine the decoding mode for the block to be decoded. Currently, if the fallback mode is allowed (allowfallback) and the original value mode is selected, the prediction mode for the current block to be decoded is first assigned the block prediction mode (IBC_MODE), i.e., the prediction mode corresponding to the first fallback mode. As a result, the decoding side analyzes the coordinates (abs_bvd_minus1[blkIdx]) in the search area of the prediction block corresponding to the current block to be decoded, using a fixed code length of 5 bits (u(5)).
[0239] In step 3, the decoding side derives a fixed-length code and uses the fixed-length code to analyze the coefficient values after each quantization.
[0240] In the first fallback mode, the coefficient value represents the residual value after quantization. In the second fallback mode, there is no prediction mode, and the coefficient value represents the original value after quantization.
[0241] Finally, inverse quantization is performed. In the first fallback mode, the residual value is added to the predicted value to obtain the reconstructed value. In the second fallback mode, the value after inverse quantization is used as the reconstructed value.
[0242] The above process may be implemented as a text description like the following. coding_unit_data_substream0 (cuIdxX, cuIdxY) { BitsRecord = CurrBits CbWidth[0] = 16 CbHeight[0] = 2 FallbackFlag = 0 cbLumaSize = CbWidth[0] × CbHeight[0] if (image_format == ‘001’){ / * YUV400 * / cbChromaSize = 0 modeBits = 8 } else if (image_format == ‘001’) { / * YUV420 * / cbChromaSize = cbLumaSize >> 2 modeBits = 15 } else if (image_format == ‘010’) { / * YUV422 * / cbChromaSize = cbLumaSize >> 1 modeBits = 15 } else { cbChromaSize = cbLumaSize modeBits = 21 } allowfallback = modeBits + (BitDepth[0] × cbLumaSize + BitDepth[1] × cbChromaSize × 2 - (TargetBpp << 1)) >= MaxBufferSize - (CurrBits - OutBits) CuPosX[0] = cuIdxX << 4 CuPosY[0] = cuIdxY << 1 CurrBlocks++ complexity_level_flag[0] u(1) if (ComplexityLevelFlag[0] = 0) { delta_level[0] u(2) if (delta_level[0] >= PrevComplexityLevel) { ComplexityLevel[0] = DeltaLevel[0] + 1 } else { ComplexityLevel[0] = DeltaLevel[0] } } else { ComplexityLevel[0] = PrevComplexityLevel } PrevComplexityLevel = ComplexityLevel[0] pred_mode[0] ae(v) if (PredMode[0] == ORG_MODE && allowfallback) { FallbackFlag = 1 u(1) fallback_type PredMode[0] == FallbackType == 1 ‘ORG_MODE’ : ‘IBC_MODE’ } if (PredMode[0] == ‘IBC_MODE’) { for (blkIdx=0; blkIdx<8; blkIdx++) { abs_bvd_minus1[blkIdx] u(5) } } if (PredMode[0] != POINT_MODE_1 && PredMode[0] != POINT_MODE_1 && PredMode[0] != ORG_MODE && !LosslessFlag && !FallbackFlag) { resi_skip[0] u(1) } if (ResiSkip[0] != 1) { coeff_data(BitDepth[0], 0) }
[0243] Here, in the above text description, the type of fallback mode is determined using a binary variable. A value of "1" indicates that the fallback mode used by the current coding unit is original value truncated mode, and a value of "0" indicates that the fallback mode used by the current coding unit is residual truncated mode. The value of FallbackType is equal to the value of fallback_type.
[0244] In some embodiments, the decryption side obtains binary data representing the fixed-length code of the block to be decrypted in the bitstream, processes the binary data using an inverse binarization method to obtain the specific BPP data.
[0245] The decoding side first determines the fixed-length coded binary data (org_data).
[0246] If the FallbackFlag is equal to 0, i.e., if fallback mode is not used during encoding, the current channel's bit depth (BitDepth[component]) is set to the code length (len) of the fixed-length code, and the value of org_data is equal to the value of "synElVal" in Table 1.
[0247] Otherwise, the decoding side uses the value of the fixed-length code as the code length len, and the value of org_data is equal to the value of synElVal (see Table 1 below).
[0248] The specific derivation of fixed-length codes is as follows:
[0249] 1) The decoding side first calculates the value of the target BPP (adjTargetBpp) after adjusting the overflow line.
[0250] If (BitsRecord - ((TargetBpp << 1) × (CurrBlocks - 1))) is greater than the maximum set overflow line (MaxBufferSize), adjTargetBpp is equal to (((Target_bpp << 1) - (BitsRecord - ((TargetBpp << 1) × (CurrBlocks - 1)) - MaxBufferSize)) >> 5).
[0251] Otherwise, adjTargetBpp is equal to (Target_bpp >> 4).
[0252] Here, (Target_bpp >> 4) refers to the target BPP.
[0253] 2) The decoding side determines the code length of the fixed - length code for each component based on adjTargetBpp.
[0254] When the image format is YUV400, the fixed - length code is (adjTargetBpp - 2).
[0255] Otherwise, it is determined whether the current component is equal to the luminance component.
[0256] When it is equal to the luminance component, the fixed - length code is equal to (adjTargetBpp - 2) / 3+(adjTargetBpp - 2) / 3.
[0257] If not, when the image format is YUV420, the fixed - length code is (adjTargetBpp - 2) / 3 << 2.
[0258] If not, when the image format is YUV422, the fixed - length code is (adjTargetBpp - 2) / 3 << 1.
[0259] If not, the fixed - length code is (adjTargetBpp - 2) / 3.
Table 1
[0260] Hereinafter, an encoding device and a decoding device according to embodiments of the present invention will be described. The encoding device may be a video encoder or a device including a video encoder. The encoding device includes each module configured to perform an image encoding method in any one of the possible embodiments. The encoding device has functions to perform the operations in the embodiments of the related method. These functions may be implemented by hardware, or by hardware running corresponding software. The hardware or software includes one or more modules corresponding to the functions. For their beneficial effects, see the description of the corresponding method. The decoding device may be a video decoder or a device including a video decoder. The decoding device includes each module configured to perform an image decoding method in any one of the possible embodiments. The decoding device has functions to perform the operations in the embodiments of the related method. These functions may be implemented by hardware, or by hardware running corresponding software. The hardware or software includes one or more modules corresponding to the functions. For their beneficial effects, see the description of the corresponding method.
[0261] In one example, any encoding device according to the embodiment of the present invention may be the encoding side 10 or encoder 100 in Figure 1. In another example, any decoding device provided below may be the decoding side 20 or decoder 200 in Figure 1. Further explanation of this is omitted below.
[0262] Figure 9 is a schematic diagram of an image encoding device 900 according to the present invention. Any one of the embodiments of the encoding method described above can be performed by the encoding device 900. The image encoding device 900 includes a determination module 901 and an encoding module 902. The determination module 901 is configured to obtain the maximum code length of a block to be encoded. The maximum code length is the maximum length of the bitstream of the block to be encoded that is allowed to be buffered in the bitstream buffer, determined based on the setting overflow line of the bitstream buffer. The setting overflow line is used to indicate the maximum storage space that is allowed to be occupied by the bitstream in the bitstream buffer. The encoding module 902 is configured to pre-encode the block to be encoded to obtain a first code length of the block to be encoded. The first code length is the length of the bitstream obtained after the block to be encoded has been encoded. The encoding module 902 is further configured to encode the block to be encoded using a fallback mode if the first code length is greater than or equal to the maximum code length, and the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length, and the bitstream obtained by encoding the block to be encoded based on the fallback mode includes a first codeword, and the first codeword is used to indicate the fallback mode or the original value mode.
[0263] For a more detailed description of the determination module 901 and the encoding module 902, a more detailed description of their respective technical features, and a description of their beneficial effects, please refer to the corresponding embodiment of the method described above, and the description will be omitted here.
[0264] Figure 10 is a schematic diagram of an image decoding device 1000 according to the present invention. Any one of the embodiments of the decoding method described above can be performed by the decoding device 1000. The image decoding device 1000 includes an analysis module 1001 and a decision module 1002. The analysis module 1001 is configured to analyze the bitstream of a block to be decoded and, if the bitstream of the block to be decoded contains a first codeword, to determine whether the image block corresponding to the block to be decoded uses a fallback mode. The code length of the block to be decoded is smaller than the maximum code length of the block to be decoded, and the maximum code length is the maximum length of the bitstream of the block to be decoded that is allowed to be buffered in the bitstream buffer, determined based on the bitstream buffer's setting overflow line. The setting overflow line is used to indicate the maximum memory space that is allowed to be occupied by the bitstream in the bitstream buffer, and the first codeword is used to indicate the fallback mode or the original value mode. The determination module 1002 is configured to determine the fixed code length of each component of the block to be decoded based on the excess code length of the bitstream buffer when the image block corresponding to the block to be decoded uses fallback mode and the code length stored in the bitstream buffer exceeds the set overflow line. The block to be decoded contains one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is the code length that exceeds the current set overflow line when the code length stored in the bitstream buffer exceeds the set overflow line. The analysis module 1001 is further configured to analyze the pixel points of each component based on the fixed code length of each component and decode the block to be decoded.
[0265] For a more detailed explanation of the analysis module 1001 and the decision module 1002 described above, as well as a more detailed explanation of their respective technical features and a description of their beneficial effects, please refer to the corresponding embodiment of the method described above, and the explanation will be omitted here.
[0266] The present invention The system includes a processor and memory, the memory being configured to store computer instructions, and the processor calling and executing the computer instructions from the memory. Perform one of the above image encoding / decoding methods. It is configured in such a way. We will provide even more electronic devices. For example, the electronic device may be a video encoder or a device including a video encoder. In another example, the electronic device may be a video decoder or a device including a video decoder. Figure 11 is a schematic diagram of the electronic device according to the present invention. As shown in Figure 11, the electronic device 1100 includes a processor 1101 and a communication interface 1102. The processor 1101 and the communication interface 1102 are coupled to each other. The communication interface 1102 may be a transceiver or an input / output interface.
[0267] In one example, the electronic device 1100 may further include a memory 1103 configured to store instructions executed by the processor 1101, input data necessary for the processor 1101 to execute the instructions, or data generated after the processor 1101 has executed the instructions.
[0268] In embodiments of the present invention, the specific connection medium between the communication interface 1102, the processor 1101, and the memory 1103 is not limited. In embodiments of the present invention, in Figure 11, the communication interface 1102, the processor 1101, and the memory 1103 are connected via a bus 1104, which is shown as a thick line in Figure 11. Connection methods between other components are illustrative and not limited. Buses can be classified as address buses, data buses, control buses, etc. For ease of representation, they are shown as a single thick line in Figure 11, but this does not mean that there is only one bus or only one type of bus.
[0269] Memory 1103 may be used to store software programs and modules, such as program instructions / modules corresponding to the image decoding method or image encoding method provided in embodiments of the present invention, and the processor 1101 executes various functional applications and data processing by executing the software programs and modules stored in memory 1103, thereby implementing any of the image decoding method or image encoding method provided above. The communication interface 1102 may be used for signaling and data communication with other devices. In the present invention, the electronic device 1100 may have a plurality of communication interfaces 1102.
[0270] To make it clear, the processor in the embodiments of the present invention may be a central processing unit (CPU), a neural processing unit (NPU), or a graphics processing unit (GPU), or it may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or another programmable logic device, a transistor logic device, a hardware component, or any combination thereof. The general-purpose processor may be a microprocessor or any conventional processor.
[0271] The steps of the method in the embodiments of the present invention may be implemented by hardware or by a processor executing software instructions. The software instructions may be composed of corresponding software modules, and the software modules may be stored in a random access memory (RAM), flash memory, read-only memory (ROM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), register, hard disk, removable hard disk, CD-ROM, or any other form of storage medium well-known in the art. The present invention provides a computer-readable storage medium in which a computer program or instruction is stored, and when the computer program or instruction is executed by a computing device or a storage system in which a computing device is located, an image decoding method or image encoding method according to any one of the embodiments is performed. An exemplary storage medium is coupled to the processor such that the processor can read information from and write information to the storage medium. Of course, the storage medium may be a component of the processor. The processor and the storage medium may be disposed within an ASIC. Also, the ASIC may be disposed within a network device or a terminal device. Of course, the processor and the storage medium may exist within a network device or a terminal device as independent components.
[0272] The present invention provides a computer program product including instructions, which, when executed on a computing device or processor, causes the computing device or processor to execute the instructions and carry out the method in any one of the embodiments.
[0273] The present invention provides a chip including memory and a processor, wherein the memory is configured to store computer instructions, and the processor is configured to call and execute the computer instructions from the memory to carry out a method in any one of the embodiments.
[0274] The embodiments of the present invention further provide an encoding / decoding system including an encoding side and a decoding side. The encoding side may be configured to execute any one of the foregoing image encoding methods, and the decoding side is configured to execute a corresponding image decoding method.
[0275] In the embodiments described above, all or part of the process or function may be implemented by software, hardware, firmware, or any combination thereof. If implemented by software, all or part of the process or function may be implemented in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer programs or instructions are loaded on a computer and executed, all or part of the process or function described in the embodiments of the present invention is executed. The computer may be a general-purpose computer, a dedicated computer, a computer network, a network device, user equipment, or other programmable device. The computer programs or instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer programs or instructions may be transmitted by wire or wirelessly from one website, computer, server, or data center to another website, computer, server, or data center. The computer-readable storage medium may be any available medium accessible by a computer, or a data storage device such as a server or data center that integrates one or more available media. The aforementioned usable media may be magnetic media such as floppy disks, hard disks, or magnetic tapes, optical media such as digital video discs (DVDs), or semiconductor media such as solid state drives (SSDs).
[0276] In each embodiment of the present invention, unless otherwise specified and logically contradictory, the terminology and / or descriptions between different embodiments are consistent and can be referenced to one another, and the technical features of different embodiments can be combined according to their internal logical relationships to form new embodiments.
[0277] To ensure clarity, the various numerical designations related to the embodiments of the present invention are provided solely for illustrative purposes and are not intended to limit the scope of the embodiments. The magnitude of the numbers in the above processes does not indicate the execution order; the execution order of each process should be determined by its function and internal logic.
Claims
1. An image decoding method applied to the decoding side, A step of analyzing the bitstream of a block to be decoded, and determining whether the image block corresponding to the block to be decoded uses a fallback mode if the bitstream of the block to be decoded contains a first codeword, wherein the code length of the block to be decoded is smaller than the maximum code length of the block to be decoded, the maximum code length is determined based on a set overflow line of the bitstream buffer, the set overflow line is used to indicate the maximum memory space that is allowed to be occupied by the bitstream in the bitstream buffer, and the first codeword is used to indicate the fallback mode or sample mode. Steps to determine a fixed code length for each component of the block to be decoded based on the excess code length of the bitstream buffer, where the image block corresponding to the block to be decoded uses a fallback mode and the code length stored in the bitstream buffer exceeds the set overflow line, wherein the block to be decoded includes one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is the code length of the code length stored in the bitstream buffer that exceeds the set overflow line. The step of analyzing the pixel points of each component based on the fixed code length of each component and decoding the block to be decoded, The aforementioned sample mode is a mode that directly encodes or analyzes the sample value. An image decoding method characterized by the following:
2. Determining whether the image block corresponding to the block to be decoded uses a fallback mode is: The image decoding method according to claim 1, further comprising determining that the image block corresponding to the block to be decoded uses a fallback mode if the coded length of the image block corresponding to the block to be decoded, based on the sample mode, is greater than or equal to the maximum coded length of the block to be decoded.
3. Determining whether the image block corresponding to the block to be decoded uses a fallback mode is: If the code length of the image block corresponding to the block to be decoded, encoded based on the sample mode, is smaller than the maximum code length of the block to be decoded, the system includes determining that the image block corresponding to the block to be decoded uses the sample mode. The image decoding method according to feature 1.
4. Determining the fixed code length of each component of the block to be decoded based on the excess code length of the bitstream buffer is: The process includes determining a fixed code length for the luminance component and a fixed code length for the chromaticity component of the block to be decoded, based on the excess code length of the bitstream buffer, the target total code length of the block to be decoded, and the image format of the block to be decoded. The fixed code length of the luminance component is used to indicate the code length required when analyzing a single pixel point of the luminance component, and the fixed code length of the chromaticity component is used to indicate the code length required when analyzing a single pixel point of the chromaticity component. The target total code length is the total code length required when decoding the block to be decoded. The image decoding method according to feature 1.
5. Determining the fixed code length of the luminance component and the fixed code length of the chromaticity component of the block to be decoded based on the excess code length of the bitstream buffer, the target total code length of the block to be decoded, and the image format of the block to be decoded is: Obtaining the code length of the header information of the block to be decoded, This includes determining a fixed code length for the luminance component and a fixed code length for the chromaticity component based on the target total code length of the block to be decoded, the image format, the excess code length, and the code length of the header information. The image decoding method according to feature 4.
6. The sum of the fixed code lengths of all pixels in the luminance component is greater than or equal to the sum of the fixed code lengths of all pixels in the chromaticity component. The image decoding method according to feature 4.
7. The sum of the fixed code lengths of all components of the block to be decoded is equal to the code length obtained by subtracting the code length of the header information of the block to be decoded and the excess code length of the bitstream buffer from the target total code length of the block to be decoded. The image decoding method according to feature 5.
8. Analyzing the pixel points of each component based on the fixed code length of each component is: This includes analyzing the pixel points of the luminance component based on a fixed code length for the luminance component, and analyzing the pixel points of the chromaticity component based on a fixed code length for the chromaticity component. The image decoding method according to feature 1.
9. Analyzing the pixel points of the luminance component based on the fixed code length of the luminance component is: Based on the fixed code length of the luminance component, the residual value of the luminance component of the block to be decoded is determined. The process involves obtaining the prediction mode of the block to be decoded in the fallback mode, predicting the image block corresponding to the block to be decoded based on the prediction mode, and obtaining the predicted value of the block to be decoded. The quantization parameters of the block to be decoded are determined, and the residual values of the luminance components of the block to be decoded are inversely quantized based on the quantization parameters. This includes reconstructing the block to be decoded based on the residual value after inverse quantization of the luminance component of the block to be decoded and the predicted value, thereby obtaining a luminance reconstructed block of the image block. The image decoding method according to feature 8.
10. Analyzing the pixel points of the chromaticity component based on the fixed code length of the chromaticity component is: Based on the fixed code length of the chromaticity component, the residual value of the chromaticity component of the block to be decoded is determined. The process involves obtaining the prediction mode of the block to be decoded in the fallback mode, predicting the image block corresponding to the block to be decoded based on the prediction mode, and obtaining the predicted value of the block to be decoded. The quantization parameters of the block to be decoded are determined, and the residual values of the chromaticity components of the block to be decoded are inversely quantized based on the quantization parameters. This includes reconstructing the block to be decoded based on the residual value after inverse quantization of the chromaticity component of the block to be decoded and the predicted value, thereby obtaining the chromaticity reconstructed block of the image block. The image decoding method according to feature 8.
11. Obtaining the prediction mode of the block to be decoded in the fallback mode is, The prediction mode for the block to be decoded is the prediction mode corresponding to the fallback mode. Or, The prediction mode of the block to be decoded is one of several prediction modes on the decoding side, The image decoding method according to feature 9.
12. An image encoding method applied to the encoding side, A step of obtaining the maximum code length of a block to be encoded, wherein the maximum code length is determined based on a setting overflow line of a bitstream buffer, and the setting overflow line is used to indicate the maximum storage space that is permitted to be occupied by the bitstream in the bitstream buffer. A step of pre-encoding the block to be encoded and obtaining a first code length of the block to be encoded, wherein the first code length is the length of the bitstream obtained after the block to be encoded has been pre-encoded. If the first code length is greater than or equal to the maximum code length, the step of encoding the block to be encoded using a fallback mode, wherein the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length, and the bitstream obtained by encoding the block to be encoded based on the fallback mode includes a first codeword, and the first codeword is used to indicate the fallback mode or sample mode, The aforementioned sample mode is a mode that directly encodes or analyzes the sample value. An image encoding method characterized by the following.
13. If the code length stored in the bitstream buffer exceeds the set overflow line, a step of determining the fixed code length of the luminance component and the fixed code length of the chromaticity component of the block to be encoded based on the excess code length of the bitstream buffer, wherein the fixed code length of the luminance component is used to indicate the code length required when encoding a single pixel point of the luminance component, the fixed code length of the chromaticity component is used to indicate the code length required when encoding a single pixel point of the chromaticity component, and the excess code length of the bitstream buffer is the code length of the code length stored in the bitstream buffer that exceeds the set overflow line, The further step includes encoding the block to be encoded based on a fixed code length for the luminance component and a fixed code length for the chromaticity component. The image encoding method according to feature 12.
14. An image decoding device applied to the decoding side, An analysis module configured to analyze the bitstream of a block to be decoded, and if the bitstream of the block to be decoded contains a first codeword, to determine whether the image block corresponding to the block to be decoded uses a fallback mode, wherein the code length of the block to be decoded is smaller than the maximum code length of the block to be decoded, the maximum code length is determined based on a set overflow line of the bitstream buffer, the set overflow line is used to indicate the maximum memory space that is allowed to be occupied by the bitstream in the bitstream buffer, and the first codeword is used to indicate the fallback mode or sample mode. A determination module configured to determine a fixed code length for each component of the block to be decoded based on the excess code length of the bitstream buffer when the image block corresponding to the block to be decoded uses a fallback mode and the code length stored in the bitstream buffer exceeds the set overflow line, wherein the block to be decoded includes one or more components, and for the first component of the block to be decoded, the fixed code length of the first component is used to indicate the code length required when analyzing a single pixel point of the first component, and the excess code length of the bitstream buffer is the code length of the code length stored in the bitstream buffer that exceeds the set overflow line, The analysis module is further configured to analyze the pixel points of each component based on the fixed code length of each component, and to decode the block to be decoded. The aforementioned sample mode is a mode that directly encodes or analyzes the sample value. An image decoding device characterized by the following features.
15. An image encoding device applied to the encoding side, A decision module configured to obtain the maximum code length of a block to be encoded, wherein the maximum code length is determined based on a setting overflow line of a bitstream buffer, and the setting overflow line is used to indicate the maximum storage space that is permitted to be occupied by the bitstream in the bitstream buffer. An encoding module configured to pre-encode the block to be encoded and obtain a first code length of the block to be encoded, wherein the first code length is the length of the bitstream obtained after the block to be encoded has been pre-encoded, includes: The encoding module is further configured to encode the block to be encoded using a fallback mode if the first code length is greater than or equal to the maximum code length, and the code length obtained by encoding the block to be encoded based on the fallback mode is less than the maximum code length, and the bitstream obtained by encoding the block to be encoded based on the fallback mode includes a first codeword, and the first codeword is used to indicate the fallback mode or sample mode. The aforementioned sample mode is a mode that directly encodes or analyzes the sample value. An image coding device characterized by the following:
16. A memory configured to store computer instructions, and a processor configured to call and execute the computer instructions from the memory to perform the method according to any one of claims 1 to 11, A decoding device characterized by the following features.
17. A memory configured to store computer instructions, and a processor configured to call and execute the computer instructions from the memory to carry out the method according to claim 12 or 13, An encoding device characterized by the following features.
18. A computer-readable storage medium in which a computer program or instruction is stored, wherein when the computer program or instruction is executed by an electronic device, the method according to any one of claims 1 to 13 is performed. A computer-readable storage medium characterized by the following features.
Citation Information
Patent Citations
Variable length coding controlling system
JP1993068243A
Picture processor
JP1994152984A
Rate constrained fallback mode for display stream compression
JP2018516491A