Image prediction method, encoder, decoder, and storage medium
By performing motion estimation and gradient parameter correction on image blocks during video coding, the problem of inaccurate bidirectional prediction values is solved, improving the accuracy of prediction results and encoding/decoding efficiency, and enhancing video image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2020-03-02
- Publication Date
- 2026-07-21
Smart Images

Figure CN116647698B_ABST
Abstract
Description
[0001] This application is a divisional application of Chinese patent application No. 202080097798.X, which entered the Chinese national phase of PCT international patent application PCT / CN2020 / 077491 filed on March 2, 2020, and is entitled "Image Prediction Method, Encoder, Decoder and Storage Medium". Technical Field
[0002] This application relates to the field of video encoding and decoding technology, and in particular to an image prediction method, encoder, decoder, and storage medium. Background Technology
[0003] With the widespread application of multimedia technology, modern coding techniques employ a hybrid coding framework, including processes such as prediction, transform, quantization, and entropy coding. Predictive coding comprises intra-frame prediction and inter-frame prediction. The former uses already encoded and reconstructed image blocks within the same frame to predict the image block to be encoded, while the latter uses images from other already encoded and reconstructed frames to predict the image block to be encoded. Inter-frame predictive coding leverages the temporal correlation of video sequences and removes spatial redundancy, making it a crucial component of current video coding frameworks.
[0004] The next-generation digital audio and video coding standard (3rd Audio and Video Coding Standard, AVS3) introduced bidirectional prediction technology in its reference software model HPM6.0. When predicting the current block, two unidirectional prediction values are obtained based on two sets of reference frames and motion vectors (MV). These two unidirectional prediction values are then averaged to obtain the bidirectional prediction value. This averaging method may introduce bias into the bidirectional prediction value, potentially leading to inaccurate prediction results. Summary of the Invention
[0005] This application provides an image prediction method, encoder, decoder, and storage medium. By correcting the initial bidirectional prediction values, the accuracy of the prediction results can be improved.
[0006] The technical solution of this application embodiment can be implemented as follows:
[0007] In a first aspect, embodiments of this application provide an image prediction method applied to an encoder, the method comprising:
[0008] Motion estimation is performed on the image block to be encoded to determine the unidirectional prediction values of the image block in the two prediction directions respectively;
[0009] Determine the gradient parameters corresponding to the image patch, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value;
[0010] The gradient value of the image patch is calculated using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions.
[0011] The initial bidirectional prediction value is corrected based on the gradient value of the image patch and the preset correction intensity value to obtain the bidirectional prediction value of the image patch, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0012] Secondly, embodiments of this application provide an image prediction method applied to a decoder, the method comprising:
[0013] Parse the bitstream to obtain the prediction mode parameters of the image block to be decoded;
[0014] When the prediction mode parameter indicates that the image patch uses a bidirectional prediction mode, the motion parameters of the image patch are parsed, wherein the motion parameters include a motion vector and a reference image index;
[0015] Based on the motion parameters, determine the unidirectional prediction values of the image patch in the two prediction directions respectively;
[0016] Determine the gradient parameters of the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively;
[0017] The initial bidirectional prediction value is corrected based on the gradient value of the image patch and the preset correction intensity value to obtain the bidirectional prediction value of the image patch, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0018] Thirdly, embodiments of this application provide an encoder, which includes a first determining unit, a first calculating unit, and a first correcting unit, wherein...
[0019] The first determining unit is configured to perform motion estimation on the image block to be encoded and determine the unidirectional prediction values of the image block in two prediction directions respectively;
[0020] The first determining unit is further configured to determine the gradient parameters corresponding to the image block, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value;
[0021] The first calculation unit is configured to calculate the gradient value of the image patch using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions respectively.
[0022] The first correction unit is configured to correct the initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0023] Fourthly, embodiments of this application provide an encoder, which includes a first memory and a first processor, wherein...
[0024] A first memory for storing computer programs that can run on a first processor;
[0025] A first processor is configured to execute the method described in the first aspect when running a computer program.
[0026] Fifthly, embodiments of this application provide a decoder, which includes a parsing unit, a second determining unit, a second calculating unit, and a second correcting unit, wherein...
[0027] The parsing unit is configured to parse the bitstream to obtain the prediction mode parameters of the image block to be decoded; and when the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, to parse the motion parameters of the image block, wherein the motion parameters include motion vectors and reference image indices;
[0028] The second determining unit is configured to determine, based on the motion parameters, the unidirectional prediction values of the image block in the two prediction directions respectively;
[0029] The second calculation unit is configured to determine the gradient parameters of the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively.
[0030] The second correction unit is configured to correct the initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0031] Sixthly, embodiments of this application provide a decoder, which includes a second memory and a second processor, wherein,
[0032] The second memory is used to store computer programs that can run on the second processor;
[0033] A second processor is configured to execute the method described in the second aspect when running a computer program.
[0034] In a seventh aspect, embodiments of this application provide a computer storage medium storing a computer program that, when executed by a first processor, implements the method described in the first aspect, or when executed by a second processor, implements the method described in the second aspect.
[0035] This application provides an image prediction method, encoder, decoder, and storage medium. The method can be applied to an encoder. It involves performing motion estimation on an image block to be encoded to determine unidirectional prediction values for the image block in two prediction directions; determining gradient parameters corresponding to the image block, the gradient parameters including at least a gradient flag value and a gradient direction index value; calculating the gradient value of the image block using the determined gradient parameters and the unidirectional prediction values in the two prediction directions; and correcting the initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block. The initial bidirectional prediction value is a weighted sum of the unidirectional prediction values in the two prediction directions. This method can be applied to a decoder. By parsing the bitstream, the prediction mode parameters of the image block to be decoded are obtained. When the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, the motion parameters of the image block are parsed, wherein the motion parameters include motion vectors and reference image indices. Based on the motion parameters, the unidirectional prediction values corresponding to the image block in the two prediction directions are determined. The gradient parameters of the image block are determined, and the gradient value of the image block is calculated using the gradient parameters and the unidirectional prediction values corresponding to the image block in the two prediction directions. The initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block. In this way, the gradient parameters corresponding to the image block can be used to obtain the gradient value between two unidirectional prediction values, and then the initial bidirectional prediction value can be corrected based on the gradient value and the preset correction intensity value, thereby making the bidirectional prediction value more accurate. This not only improves the accuracy of the prediction results but also improves the encoding and decoding efficiency, thus enhancing the video image quality. Attached Figure Description
[0036] Figure 1A A schematic diagram of a unidirectional inter-frame prediction structure provided for related technical solutions;
[0037] Figure 1B A schematic diagram of a bidirectional inter-frame prediction structure provided for related technical solutions;
[0038] Figure 2A A block diagram of a video encoding system provided in an embodiment of this application;
[0039] Figure 2B A block diagram of a video decoding system provided in an embodiment of this application;
[0040] Figure 3 A flowchart illustrating an image prediction method provided in an embodiment of this application;
[0041] Figure 4 A schematic diagram of the trend of brightness value change provided in an embodiment of this application;
[0042] Figure 5 A flowchart illustrating another image prediction method provided in an embodiment of this application;
[0043] Figure 6 A schematic diagram of the composition structure of an encoder provided in an embodiment of this application;
[0044] Figure 7 This is a schematic diagram of the specific hardware structure of an encoder provided in an embodiment of this application;
[0045] Figure 8 A schematic diagram of the composition structure of a decoder provided in an embodiment of this application;
[0046] Figure 9 This is a schematic diagram of the specific hardware structure of a decoder provided in an embodiment of this application. Detailed Implementation
[0047] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It is understood that the specific embodiments described herein are merely for explaining the relevant application and not for limiting the application. Furthermore, it should be noted that, for ease of description, only the parts relevant to the application are shown in the accompanying drawings.
[0048] In video images, a first image component, a second image component, and a third image component are generally used to represent a coding block (CB) or a coding unit (CU). These three image components are a luminance component, a blue chrominance component, and a red chrominance component, respectively. Specifically, the luminance component is usually represented by the symbol Y, the blue chrominance component is usually represented by the symbol Cb or U, and the red chrominance component is usually represented by the symbol Cr or V. Thus, video images can be represented in YCbCr format or YUV format.
[0049] In the embodiments of this application, the first image component can be a luminance component, the second image component can be a blue chromaticity component, and the third image component can be a red chromaticity component, but no specific limitation is made.
[0050] The following section describes the relevant technical solutions for inter-frame prediction technology.
[0051] Inter-frame prediction utilizes the inter-frame correlation, or temporal correlation, of video images to achieve image compression. Consecutive video frames are generally similar in content and exhibit high correlation. When encoding video frames, predictive coding techniques can be used. These techniques use previously decoded video frames to predict the current frame, and then only the prediction residual is encoded. This effectively reduces the bitrate; this predictive coding method is simply called inter-frame prediction.
[0052] Inter-frame prediction can be divided into one-way prediction and two-way prediction. One-way prediction mainly obtains the predicted value directly through a set of reference frames and the MV (Motion View), while two-way prediction obtains the predicted value through correlation calculations using two sets of reference frames and the MV. For example... Figure 1A As shown, it provides a structural example of unidirectional prediction, which, in addition to the current frame, includes a set of parameters: a reference frame and a MV. Based on this reference frame and MV, unidirectional prediction can be performed on the current frame; for example... Figure 1B As shown, it provides a structural example of bidirectional prediction. In addition to the current frame, it also includes two sets of parameters, namely reference frame 0 and MV0, and reference frame 1 and MV1. Based on reference frame 0 and MV0, a unidirectional prediction in one direction can be performed on the current frame, while based on reference frame 1 and MV1, a unidirectional prediction in another direction can be performed on the current frame, so as to realize bidirectional prediction of the current frame.
[0053] Specifically, for one-way prediction, the predicted value is calculated using a set of reference frames and the MV (Modular Value). The MV can include the horizontal MV. H and vertical MV V , representing the horizontal and vertical positional relationships of the content in the CU between the current frame and the reference frame, respectively. Here, on the encoder side, the encoder can calculate the most suitable reference frame and MV through motion estimation; on the decoder side, the decoder can parse the reference frame and MV from the bitstream, thereby calculating the predicted value of the CU.
[0054] For bidirectional prediction, the predicted value is calculated using two sets of reference frames and the MV (Motion View). In the AVS3 reference software HPM6.0, the bidirectional prediction value is calculated as follows: two unidirectional prediction values are calculated using the two sets of reference frames and the MV respectively, and then the two unidirectional prediction values are averaged to obtain the bidirectional prediction value; the details are shown below.
[0055] pred BI =(pred0+pred1+1)>>1 (1)
[0056] Where pred0 represents a one-way predicted value in one direction, pred1 represents a one-way predicted value in another direction, and pred... BIThe symbol "=" indicates a bidirectional prediction value; "=" indicates an assignment operator; ">>" indicates a right shift operator, for example, ">>1" indicates a binary-based operation that shifts a bit to the right by one bit.
[0057] The latest generation video coding standard, H.266 / Versatile Video Coding (VVC), introduces Bi-prediction with CU-level Weight (BCW) technology, which obtains bi-prediction values through a weighted average. Assuming the unidirectional prediction values obtained in the two directions are pred0 and pred1, and the weight is w, then the bi-prediction value pred... BI The calculation formula is shown below.
[0058] pred BI =((8-w)×pred0+w×pred1+4)>>3 (2)
[0059] The w value includes five values, w∈{-2, 3, 4, 5, 10}, which can be selected based on the weight index. Specifically, the w value can be obtained in two ways: one is for CUs in non-merge mode, in which case motion vector difference (MVD) needs to be transmitted, and the decoder determines the weight index by parsing the motion vector difference in the bitstream; the other is for CUs in merge mode, where the weight index can be inferred from adjacent blocks, but this embodiment does not impose any limitations.
[0060] Furthermore, AVS3 employs bidirectional optical flow (BIO) technology, while VVC uses a similar bidirectional optical flow (BDOF) technology. Both bidirectional optical flow techniques perform motion optimization at the sampling point level, based on block motion compensation using bidirectional prediction, eliminating the need to transmit redundant signals. However, even after bidirectional prediction, motion deviations are still observed in certain regions of the current block.
[0061] In practical applications, for AVS3, the current method used by the reference software HPM6.0 to obtain bidirectional prediction values is as follows: first, two unidirectional prediction values can be obtained from two sets of reference frames and MV, and then the average of the two unidirectional prediction values is calculated. The resulting average value is the bidirectional prediction value. Even if bidirectional prediction techniques such as BIO are added to adjust the bidirectional prediction value, the averaging method of the two unidirectional prediction values may cause deviations in the bidirectional prediction value, resulting in inaccurate prediction results.
[0062] Based on this, embodiments of this application provide an image prediction method applied to an encoder or decoder. For the encoder, after motion estimation of the image block to be encoded to determine the unidirectional prediction values corresponding to the image block in two prediction directions, the gradient value of the image block is calculated based on the determined gradient parameters of the image block and the unidirectional prediction values in the two prediction directions. Then, the initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. For the decoder, after parsing the bitstream to obtain the prediction mode parameters of the image block to be decoded, when the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, the motion parameters of the image block are parsed. Based on the motion parameters, the unidirectional prediction values corresponding to the image block in the two prediction directions are determined. Then, the gradient value of the image block is calculated based on the determined gradient parameters of the image block and the unidirectional prediction values in the two prediction directions. Then, the initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block. In this way, the gradient parameters corresponding to the image patch can be used to obtain the gradient value between two unidirectional prediction values. Then, the initial bidirectional prediction value is corrected according to the gradient value and the preset correction intensity value, so that the bidirectional prediction value is more accurate. This not only improves the accuracy of the prediction results, but also improves the encoding and decoding efficiency, thereby improving the video image quality.
[0063] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0064] See Figure 2A It illustrates an example block diagram of a video encoding system provided in an embodiment of this application; as shown Figure 2AAs shown, the video coding system 10 includes a transform and quantization unit 101, an intra-frame estimation unit 102, an intra-frame prediction unit 103, a motion compensation unit 104, a motion estimation unit 105, an inverse transform and inverse quantization unit 106, a filter control and analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoded image buffer unit 110. The filtering unit 108 can implement deblocking filtering and Sample Adaptive Offset (SAO) filtering, while the encoding unit 109 can implement header information encoding and Context-based Adaptive Binary Arithmetic Coding (CABAC). For the input raw video signal, the system uses coding tree blocks (Coding Tree Blocks) to perform the encoding of the raw video signal. The partitioning of a TreeUnit (CTU) yields a video coding block. The residual pixel information obtained after intra- or inter-frame prediction is then transformed by the transform and quantization unit 101. This transformation involves converting the residual information from the pixel domain to the transform domain and quantizing the resulting transform coefficients to further reduce the bit rate. Intra-frame estimation unit 102 and intra-frame prediction unit 103 perform intra-frame prediction on the video coding block. Specifically, intra-frame estimation unit 102 and intra-frame prediction unit 103 determine the intra-frame prediction mode to be used to encode the video coding block. Motion compensation unit 104 and motion estimation unit 105 perform inter-frame prediction coding of the received video coding block relative to one or more blocks in one or more reference frames to provide temporal prediction information. The motion estimation performed by motion estimation unit 105 is a process of generating motion vectors, which can estimate the motion of the video coding block. Then, motion compensation unit 104 uses the motion vectors determined by motion estimation unit 105 to generate motion vectors. Motion vectors perform motion compensation; after determining the intra-prediction mode, the intra-prediction unit 103 is also used to provide the selected intra-prediction data to the coding unit 109, and the motion estimation unit 105 also sends the calculated motion vector data to the coding unit 109; in addition, the inverse transform and inverse quantization unit 106 is used to reconstruct the video coding block, reconstructing the residual block in the pixel domain, the reconstructed residual block is removed by the filter control analysis unit 107 and the filtering unit 108 to remove block artifacts, and then the reconstructed residual block is added to a predictive block in the frame of the decoding image buffer unit 110 to generate the reconstructed video coding block; the coding unit 109 is used to encode various coding parameters and quantized transform coefficients. In the CABAC-based coding algorithm, the context content can be based on adjacent coding blocks and can be used to encode information indicating the determined intra-prediction mode, outputting the bitstream of the video signal; and the decoding image buffer unit 110 is used to store the reconstructed video coding block for prediction reference.As video image encoding proceeds, new reconstructed video encoding blocks are continuously generated, and these reconstructed video encoding blocks are stored in the decoding image buffer unit 110.
[0065] See Figure 2B It illustrates an example block diagram of a video decoding system provided in an embodiment of this application; as shown Figure 2B As shown, the video decoding system 20 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra-frame prediction unit 203, a motion compensation unit 204, a filtering unit 205, and a decoding image buffer unit 206. The decoding unit 201 can perform header information decoding and CABAC decoding, while the filtering unit 205 can perform deblocking filtering and SAO filtering. The input video signal is processed... Figure 2A After encoding, the video signal bitstream is output. This bitstream is input into the video decoding system 20, first passing through the decoding unit 201 to obtain the decoded transform coefficients. The transform coefficients are then processed by the inverse transform and inverse quantization unit 202 to generate residual blocks in the pixel domain. The intra-frame prediction unit 203 can generate prediction data for the current video decoding block based on the determined intra-frame prediction mode and data from previously decoded blocks in the current frame or image. The motion compensation unit 204 determines the prediction information for the video decoding block by analyzing motion vectors and other associated syntax elements, and uses this prediction information. The predictive block of the video block being decoded is generated; the decoded video block is formed by summing the residual block from the inverse transform and inverse quantization unit 202 with the corresponding predictive block generated by the intra-prediction unit 203 or the motion compensation unit 204; the decoded video signal is passed through the filtering unit 205 to remove block artifacts, which can improve video quality; then the decoded video block is stored in the decoding image buffer unit 206, which stores reference images for subsequent intra-prediction or motion compensation, and is also used for the output of the video signal, thus obtaining the recovered original video signal.
[0066] The image prediction method in this application embodiment can be applied to, for example, Figure 2A The inter-frame prediction portions of the motion compensation unit 104 and motion estimation unit 105 shown can also be applied to, for example... Figure 2BThe motion compensation unit 204 shown is an inter-frame prediction section. That is, the image prediction method in this embodiment can be applied to both video encoding and video decoding systems, and even simultaneously, but this embodiment does not impose specific limitations. Here, when the method is applied to a video encoding system, "image block" specifically refers to the current block to be encoded during inter-frame prediction; when the method is applied to a video decoding system, "image block" specifically refers to the current block to be decoded during inter-frame prediction.
[0067] Based on the above Figure 2A For application scenario examples, see Figure 3 This illustrates a flowchart of an image prediction method provided in an embodiment of this application. Figure 3 As shown, when applied to an encoder, the method may include:
[0068] S301: Perform motion estimation on the image block to be encoded, and determine the unidirectional prediction values of the image block in the two prediction directions respectively;
[0069] It should be noted that a video frame can be divided into multiple image blocks, and each current image block to be encoded can be a CU. Here, the image block to be encoded specifically refers to the current image block in the video image that needs to be encoded and predicted for the first, second, or third image components.
[0070] In this embodiment, assuming that a first image component prediction is performed on the image block to be encoded, and the first image component is a luminance component, then it can be called luminance prediction of the image block to be encoded, and the obtained prediction value can be called luminance value; or, assuming that a second image component prediction is performed on the image block to be encoded, and the second image component is a chrominance component, then it can be called chrominance prediction of the image block to be encoded, and the obtained prediction value can be called chrominance value; in this embodiment, it is preferred to perform luminance prediction on the image block to be encoded, but no limitation is made.
[0071] Specifically, in some embodiments, the motion estimation of the image block to be encoded, and the determination of the unidirectional prediction values of the image block in the two prediction directions, may include:
[0072] Obtain the predicted image patches of the image patch in two prediction directions;
[0073] Motion estimation is performed based on the image patch and the two predicted image patches to determine the motion vectors corresponding to the two predicted directions;
[0074] Based on the two predicted image patches and the two motion vectors, determine the unidirectional predicted values corresponding to the two prediction directions respectively.
[0075] It should be noted that the video sequence includes multiple video frames, such as the current frame, the first reference frame (reference frame 0), and the second reference frame (reference frame 1). Assuming the image block to be encoded is located on the current frame, then the two predicted image blocks will be located on reference frame 0 and reference frame 1 in the video sequence, respectively. Furthermore, reference frame 0 and reference frame 1 can be located in one forward direction and one backward direction of the current frame, or in two backward directions, or even in two forward directions; that is, the two prediction directions can include one forward direction and one backward direction, or two forward directions or two backward directions, etc. In the embodiments of this application, preferably, the two prediction directions include one forward direction and one backward direction, but this is not limited in any way.
[0076] It should also be noted that the unidirectional predicted value can be one unidirectional predicted value in each prediction direction, resulting in a total of two unidirectional predicted values; or it can be at least one unidirectional predicted value in each prediction direction, resulting in a total of more than two unidirectional predicted values. Preferably, there is one unidirectional predicted value in each prediction direction, such as a first unidirectional predicted value determined in the first prediction direction and a second unidirectional predicted value determined in the second prediction direction.
[0077] In other words, assuming that the two prediction directions include a first prediction direction and a second prediction direction, then for the first prediction direction, the first unidirectional prediction value (denoted by Pred0) can be determined based on the corresponding prediction image patch and motion vector; for the second prediction direction, the second unidirectional prediction value (denoted by Pred1) can be determined based on the corresponding prediction image patch and motion vector.
[0078] In this way, after obtaining the unidirectional prediction values corresponding to the two prediction directions, on the one hand, the motion vector and the reference image index corresponding to the predicted image block can be written into the bitstream for the decoder to obtain by parsing the bitstream; on the other hand, a preset algorithm can be used to calculate the unidirectional prediction values corresponding to the two prediction directions to obtain the initial bidirectional prediction values (using Pred). BI (represented); where the preset algorithm can be a weighted sum algorithm, but the embodiments of this application do not impose any limitations.
[0079] It is understandable that, in addition to using equation (1) or equation (2) for calculation, bidirectional optical flow prediction algorithm can also be used for bidirectional prediction between frames. Specifically, BIO technology can use the principle of optical flow to perform motion compensation for the motion after bidirectional prediction. At the same time, BIO technology is only applicable to the case of bidirectional prediction. It calculates the gradient values in the x and y directions for each pixel in the predicted image block in the forward and backward directions, and calculates the calculation factor of each pixel based on the corresponding pixel value and gradient value.
[0080] To reduce computational complexity, all pixels within each cluster can be assumed to have the same motion vector, and using a window larger than the cluster size can improve the accuracy of the calculated motion vectors. Here, a cluster represents a 4×4 image block, and a window represents an image block larger than 4×4; a cluster or window can be considered a sub-block. That is, in BIO technology, the cluster size is 4×4, meaning the motion vector value (vx, vy) of a 4×4 cluster is calculated based on a window centered on the cluster. For each cluster, the motion vector value (vx, vy) can be calculated based on the calculation factors of all pixel positions within the window containing the cluster. Finally, the calculation is performed on each pixel within the cluster to obtain the bidirectional prediction value. The specific calculation formula is as follows:
[0081] pred BI (x,y)=(I (0) (x,y)+I (1) (x,y)+b+1)>>1 (3)
[0082] Among them, pred BI (x,y) represents the corrected bidirectional prediction value, I (0) (x,y) represents the one-way predicted value of the pixel position (x,y) within reference frame 0. (1) (x,y) represents the one-way predicted value of the pixel position (x,y) within reference frame 1. "=" represents the assignment operator, ">>" represents the right shift operator, and b is the correction value.
[0083] Specifically, the formula for calculating b is as follows:
[0084]
[0085] in, The partial derivative operator, v x v y The motion vector values obtained from bidirectional optical flow prediction are shown below.
[0086] v x =(S1+r)>m? clip3(-th BIO ,th BIO ,(S3<<5) / (S1+r)):0 (5)
[0087] v y =(S5+r)>m? clip3(-th BIO ,th BIO ,((S6<<6)-v x S2) / ((S5+r)<<1)):0 (6)
[0088] Where "<<" represents the left shift operator, "clip3" represents the clamping operator, and "-th" represents the left shift operator. BIO Indicates the lower bound value, th BIO The upper bound is indicated by the value of clip3(i, j, x), which means: when x is less than i, the value is i; when x is greater than j, the value is j; when x is greater than or equal to i and less than or equal to j, the value is x.
[0089] Here, S1 to S6 are the gradient values, and their calculation formulas are as follows:
[0090] S1=∑ (i,y)∈Ω ψ x (i,j)·ψ x (i,j) (7)
[0091] S2=∑ (i,y)∈Ω ψ x (i,j)·ψ y (i,j) (8)
[0092] S3=∑ (i,y)∈Ω θ(i,j)·ψ x (i,j) (9)
[0093] S5=∑ (i,y)∈Ω ψ y (i,j)·ψ y (i,j) (10)
[0094] S6=∑ (i,y)∈Ω θ(i,j)·ψ y (i,j) (11)
[0095] Where, ψ x (i,j), ψ y The formulas for calculating (i,j) and θ(i,j) are as follows:
[0096]
[0097]
[0098] θ(i,j)=I (1) (i,j)-I (0) (i,j) (14)
[0099] In addition, VVC also employs a very similar BDOF technique. Here, spatial and temporal gradients are used to calculate S1 to S6, and their calculation formulas are as follows:
[0100] S1=∑ (i,y)∈Ω Abs(ψ x (i,j)) (15)
[0101] S2=∑ (i,y)∈Ω ψ x (i,j)·Sign(ψ y (i,j)) (16)
[0102] S3=∑ (i,y)∈Ω θ(i,j)·Sign(ψ x (i,j)) (17)
[0103] S5=∑ (i,y)∈Ω Abs(ψ y (i,j)) (18)
[0104] S6=∑ (i,y)∈Ω θ(i,j)·Sign(ψ y (i,j)) (19)
[0105] Where, ψ x (i,j), ψ y The formulas for calculating (i,j) and θ(i,j) are as follows:
[0106]
[0107]
[0108] θ(i,j)=(I (1) (i,j)>>n b )-(I (0) (i,j)>>n b ) (twenty two)
[0109] Based on the above equations (15) to (19), the compensated motion vector value v can be calculated. x v y The calculation formula is shown below.
[0110]
[0111]
[0112] in, th' BIO =2 max(5,BD-7) BD represents bit depth; This indicates a round-down operation.
[0113] Then, the correction value b can be calculated according to equations (23) and (24), as shown in the following formula.
[0114]
[0115] The final formula for calculating the two-way prediction value is as follows.
[0116] pred BDOF (x,y)=(I (0) (x,y)+I (1) (x,y)+b(x,y)+o offset )>>shift (26)
[0117] Among them, pred BDOF (x,y) represents the corrected bidirectional prediction value under BDOF technology, "o offset "" indicates the preset compensation value, and "shift" indicates the number of bits to shift right.
[0118] It should also be noted that the method in this application embodiment is applied to inter-frame bidirectional prediction technology, mainly for the correction processing of the initial bidirectional prediction value, and can be applied after bidirectional prediction and / or BIO. That is, in HPM6.0, the initial bidirectional prediction value can be directly calculated using equation (1), or it can be calculated using equations (3) to (14). For example, if bidirectional prediction meets the preset conditions of BIO technology, then the initial bidirectional prediction value Pred can be calculated using equations (3) to (14). BI Otherwise, the initial bidirectional prediction value Pred can be calculated directly using equation (1). BI .
[0119] For example, see the brightness value of a sample point within an image patch. Figure 4 This illustrates a schematic curve showing the trend of brightness value change according to an embodiment of this application. Figure 4 As shown, assuming the image patch to be predicted is located within the current frame, the first predicted image patch is located within reference frame 0, and the second predicted image patch is located within reference frame 1, the brightness values of the sample points change continuously between the reference frames and the current frame. Reference frames 0 and 1 are on opposite sides of the current frame, and the brightness values of the sample points at corresponding positions are R0 and R1, respectively. The brightness change trend between R0 and R1 can be along curve 1, curve 2, or curve 3. If the current frame is located between reference frames 0 and 1, the change trend is close to linear, i.e., curve 2, and the bidirectional prediction value obtained by averaging is relatively accurate. However, when the change trend is close to curve 1 or curve 3, the accuracy of the bidirectional prediction value obtained by averaging is still relatively low.
[0120] To improve the accuracy of bidirectional predictions, it is necessary to determine the gradient parameters corresponding to the image patch to determine whether the trend is closer to curve 1 or curve 3. Then, subsequent steps are performed to correct the bidirectional predictions in order to improve their accuracy.
[0121] S302: Determine the gradient parameters corresponding to the image block, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value;
[0122] It should be noted that after determining the initial bidirectional prediction values, the gradient parameters corresponding to the image patches can also be determined. The gradient flag value can be represented by `grad_flag`, and the gradient direction index value can be represented by `grad_idx`. Here, the gradient flag value indicates whether gradient correction is performed on the initial bidirectional prediction values, and the gradient direction index value indicates the direction of the corrected gradient; both the gradient flag value and the gradient direction index value are binary variables, containing only two values: "0" and "1". For example, a value of 0 for `grad_flag` indicates no gradient correction; a value of 1 for `grad_flag` indicates gradient correction; a value of 0 for `grad_idx` indicates a positive gradient direction; and a value of 1 for `grad_idx` indicates a negative gradient direction.
[0123] It should also be noted that, on the encoder side, precoding is performed on the image patch to be predicted using multiple prediction modes. These multiple prediction modes typically include a first prediction mode, a second prediction mode, and a third prediction mode, etc., where the gradient parameters for the first, second, and third prediction modes are different. Specifically, in the first prediction mode, the gradient flag value in the gradient parameters can be set to 0; in the second prediction mode, the gradient flag value in the gradient parameters can be set to 1, and the gradient direction index value in the gradient parameters can be set to 0; in the third prediction mode, the gradient flag value in the gradient parameters can be set to 1, and the gradient direction index value in the gradient parameters can be set to 1.
[0124] In some embodiments, for S302, before determining the gradient parameters corresponding to the image patch, the method may further include:
[0125] The image patch is precoded using multiple prediction modes to obtain multiple precoding results; the gradient parameters are different for different prediction modes.
[0126] From the plurality of precoding results, a preferred precoding result is selected according to a preset strategy;
[0127] The prediction mode corresponding to the preferred precoding result is determined as the target prediction mode.
[0128] In other words, after precoding the image patch to be predicted using multiple prediction modes, the precoding result corresponding to each prediction mode can be obtained, i.e., multiple precoding results can be obtained. Then, the preferred precoding result is determined from these multiple precoding results, and the prediction mode corresponding to the preferred precoding result is determined as the target prediction mode, thereby determining the gradient parameters corresponding to the image patch to be predicted. In this way, subsequent encoding prediction based on the determined gradient parameters can result in a small prediction residual and improve coding efficiency.
[0129] Furthermore, for the decision on the preferred precoding result, a simple decision-making strategy can be adopted, such as making a decision based on the magnitude of the distortion value; or a complex decision-making strategy can be adopted, such as making a decision based on the result of rate distortion optimization (RDO). The embodiments of this application do not impose any limitations.
[0130] Optionally, in some embodiments, selecting a preferred precoding result from the plurality of precoding results according to a preset strategy may include:
[0131] Based on the multiple precoding results, determine the rate-distortion cost corresponding to each precoding result;
[0132] Select the minimum rate distortion value from the determined multiple rate distortion values, and determine the precoding result corresponding to the minimum rate distortion value as the preferred precoding result.
[0133] Optionally, in some embodiments, selecting a preferred precoding result from the plurality of precoding results according to a preset strategy may include:
[0134] Based on the multiple precoding results, determine the distortion value corresponding to each precoding result;
[0135] Select the minimum distortion value from the determined multiple distortion values, and determine the precoding result corresponding to the minimum distortion value as the preferred precoding result.
[0136] Here, taking RDO decision as an example, the rate-distortion value corresponding to each precoding result is determined based on the multiple precoding results obtained; then, the minimum rate-distortion value is selected from the multiple determined rate-distortion values, and the precoding result corresponding to the minimum rate-distortion value can be determined as the preferred precoding result.
[0137] Furthermore, after determining the target prediction mode, the gradient parameter settings can be obtained based on the target prediction mode. Specifically, in some embodiments, the multiple prediction modes include a first prediction mode, a second prediction mode, and a third prediction mode, and determining the prediction mode corresponding to the preferred precoding result as the target prediction mode may include:
[0138] If the target prediction mode is the first prediction mode, then the gradient flag value in the gradient parameter is set to 0.
[0139] If the target prediction mode is the second prediction mode, then the gradient flag value in the gradient parameter is set to 1, and the gradient direction index value in the gradient parameter is set to 0.
[0140] If the target prediction mode is the third prediction mode, then the gradient flag value in the gradient parameter is set to 1, and the gradient direction index value in the gradient parameter is set to 1.
[0141] In other words, if the target prediction mode is determined to be the first prediction mode, then the gradient flag value in the gradient parameter is equal to 0; if the target prediction mode is determined to be the second prediction mode, then the gradient flag value in the gradient parameter is equal to 1, and the gradient direction index value in the gradient parameter is equal to 0; if the target prediction mode is determined to be the third prediction mode, then the gradient flag value in the gradient parameter is equal to 1, and the gradient direction index value in the gradient parameter is equal to 1.
[0142] Furthermore, after obtaining the gradient flag value, it needs to be written into the bitstream; and if the gradient flag value is equal to 1, the gradient direction index values also need to be written into the bitstream. Specifically, in some embodiments, the method may further include:
[0143] If the gradient flag value is equal to 0, then the gradient flag value is written into the bitstream;
[0144] If the gradient flag value is equal to 1, then both the gradient flag value and the gradient direction index value are written into the bitstream.
[0145] Thus, on the encoder side, the gradient flag value, or the gradient flag value and gradient direction index value, needs to be written into the bitstream to facilitate subsequent parsing and processing on the decoder side, so as to directly obtain the gradient flag value, or the gradient flag value and gradient direction index value.
[0146] S303: Calculate the gradient value of the image patch using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions respectively;
[0147] It should be noted that after obtaining the gradient parameters, if the set gradient flag value is equal to 0, it indicates that gradient correction is not required for the initial bidirectional prediction value, i.e., gradient correction is turned off. In this case, step S303 does not need to be executed, and the initial bidirectional prediction value can be directly used as the bidirectional prediction value of the image patch. Therefore, in some embodiments, the method may further include: when the set gradient flag value is equal to 0, determining the initial bidirectional prediction value as the bidirectional prediction value of the image patch.
[0148] It should also be noted that, by default, the gradient flag value is equal to 1, which can be determined on the encoder side through the configuration file. When the gradient flag value is equal to 1, it indicates that gradient correction is required for the initial bidirectional prediction values, which necessitates executing step S303 to calculate the gradient value of the image patch to be encoded.
[0149] Specifically, in some embodiments, when the set gradient flag value is equal to 1, for S303, calculating the gradient value of the image patch using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions respectively may include:
[0150] Retrieve the set gradient flag value and gradient direction index value;
[0151] If the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then the gradient value of the image patch is obtained by subtracting the first one-way prediction value from the second one-way prediction value.
[0152] If the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then the gradient value of the image patch is obtained by subtracting the second unidirectional prediction value from the first unidirectional prediction value.
[0153] Here, the first unidirectional prediction value (Pred0) represents the unidirectional prediction value of the image block corresponding to the first prediction direction, and the second unidirectional prediction value (Pred1) represents the unidirectional prediction value of the image block corresponding to the second prediction direction.
[0154] It should be noted that when the gradient flag value is equal to 1, it indicates that the initial bidirectional prediction value needs to be corrected. At this time, if the gradient direction index value is equal to 0, it indicates that the gradient direction is the positive gradient direction, and the gradient value of the image patch can be obtained as Pred1-Pred0. If the gradient direction index value is equal to 1, it indicates that the gradient direction is the negative gradient direction, and the gradient value of the image patch can be obtained as Pred0-Pred1.
[0155] Still with Figure 4For example, when the trend of change is determined to be close to curve 1, it indicates that the gradient direction is a positive gradient direction, that is, the gradient direction index value is equal to 0. At this time, the gradient value (R1-R0) between reference frame 0 and reference frame 1 can be determined. When the trend of change is determined to be close to curve 3, it indicates that the gradient direction is a negative gradient direction, that is, the gradient direction index value is equal to 1. At this time, the gradient value (R0-R1) between reference frame 1 and reference frame 0 can be determined. Subsequently, the initial bidirectional prediction value can be corrected according to the determined gradient value, that is, step S304 is executed.
[0156] S304: Correct the initial bidirectional prediction value according to the gradient value of the image block and the preset correction intensity value to obtain the bidirectional prediction value of the image block.
[0157] It should be noted that the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. In terms of execution steps, the initial bidirectional prediction value can be calculated after obtaining the unidirectional prediction value in step S301, or before the correction operation in step S304, or even simultaneously during steps S302 and S303; there are no limitations on this.
[0158] It should also be noted that after determining the gradient value of the image patch, the initial bidirectional prediction value can be corrected by combining it with a preset correction intensity value to obtain the final bidirectional prediction value. Specifically, the step of correcting the initial bidirectional prediction value based on the gradient value of the image patch and the preset correction intensity value to obtain the bidirectional prediction value of the image patch may include:
[0159] The correction gradient value of the image block is determined based on the gradient value of the image block and the preset correction intensity value;
[0160] The initial bidirectional prediction value is corrected using the determined correction gradient value to obtain the bidirectional prediction value of the image patch.
[0161] Optionally, a shift method can be used to calculate the corrected gradient value of the image patch, and then the initial bidirectional prediction value can be corrected based on the corrected gradient value. Specifically, in some embodiments, determining the corrected gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value may include:
[0162] The gradient value of the image block is shifted using a preset correction intensity value to obtain the correction gradient value.
[0163] Further, the step of correcting the initial bidirectional prediction value using the determined correction gradient value to obtain the bidirectional prediction value of the image patch may include:
[0164] The corrected gradient value is superimposed on the initial bidirectional prediction value to obtain the bidirectional prediction value of the image patch.
[0165] Here, the preset correction strength value can be represented by k. Generally speaking, the default value of k can be set to a fixed value, preferably 3, or it can be defined using slice-level or higher syntax.
[0166] Assume the final bidirectional forecast value is denoted by Pred, and the initial bidirectional forecast value is denoted by Pred. BI Let Pred0 represent the first one-way predicted value and Pred1 represent the second one-way predicted value. Then, the bidirectional predicted value is represented as follows.
[0167]
[0168] In this context, "=" represents the assignment operator, and ">>" represents the right shift operator, meaning ">>k" means shifting the bit to the right by k bits.
[0169] Furthermore, the value of k can be a preset constant, such as k=3. Alternatively, it can be adaptively determined based on existing parameters, such as by selecting the optimal k value from the mapping list through RDO decision-making. Then, the index number corresponding to this k value in the mapping list is written into the bitstream, facilitating subsequent determination of the k value by parsing the bitstream on the decoder side. In other words, in some embodiments, the method may further include:
[0170] Obtain the mapping list corresponding to the corrected intensity value; wherein, the mapping list represents the correspondence between the corrected intensity value and the index number value;
[0171] Calculate the rate-distortion cost corresponding to each correction intensity value in the mapping list;
[0172] Select the minimum rate distortion value from the multiple calculated rate distortion values, and determine the correction intensity value corresponding to the minimum rate distortion value as the preset correction intensity value;
[0173] Obtain the index number value corresponding to the preset correction intensity value, and write the obtained index number value into the bit stream.
[0174] It should be noted that the mapping list reflects the correspondence between the correction intensity value and the index number value. Different intensity filtering can be achieved by using different correction intensity values. Generally, k can be a default value or an option in the mapping list, and this application embodiment does not specifically limit it. For example, Table 1 gives an example of a mapping list, which defines the correspondence between the correction intensity value and the index number value.
[0175] Table 1
[0176] Index number value 0 1 2 3 Corrected strength value 0 2 3 4
[0177] Optionally, the corrected gradient value of the image patch can be calculated using a multiplication method, and then the initial bidirectional prediction value can be corrected based on the corrected gradient value. Specifically, in some embodiments, determining the corrected gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value may include:
[0178] The preset correction intensity value is multiplied by the gradient value of the image block to obtain the correction gradient value.
[0179] Further, the step of correcting the initial bidirectional prediction value based on the corrected gradient value to obtain the bidirectional prediction value of the image patch may include:
[0180] The corrected gradient value is superimposed on the initial bidirectional prediction value to obtain the bidirectional prediction value of the image patch.
[0181] At this point, multiplication can be used instead of shifting for calculation, enabling more flexible corrections. The correction strength value here can also be called the multiplication factor, denoted by s; the bidirectional prediction value is then expressed as follows:
[0182]
[0183] It should also be noted that the value of s can be a preset constant value; or it can be determined adaptively based on existing parameters. For example, by using the mapping list shown in Table 1 and the ROD decision method, the optimal value of s can be selected, and then its corresponding index number value can be written into the bitstream for subsequent parsing processing on the decoder side.
[0184] This application provides an image prediction method applied to an encoder. By performing motion estimation on an image block to be encoded, unidirectional prediction values corresponding to the image block in two prediction directions are determined. Gradient parameters corresponding to the image block are determined, including at least a gradient flag value and a gradient direction index value. Using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions, the gradient value of the image block is calculated. The initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block. The initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. In this way, the gradient parameters corresponding to the image block can be used to obtain the gradient value between two unidirectional prediction values. Then, the initial bidirectional prediction value is corrected based on this gradient value and a preset correction intensity value, resulting in more accurate bidirectional prediction values. This not only improves the accuracy of the prediction results but also increases encoding and decoding efficiency, thereby improving video image quality.
[0185] Furthermore, regarding the image prediction method in this application embodiment, the image block to be encoded can be a CU. Exemplarily, the limitations on applying this method may include:
[0186] (1) Only used for bidirectional prediction CU, that is, only when both reference frame 0 and reference frame 1 are valid;
[0187] (2) Only applicable to CUs with a sample number greater than or equal to 256.
[0188] (3) Only used for CUs that transmit MVD.
[0189] (4) Use only under non-low-delay conditions.
[0190] (5) Use only for brightness values.
[0191] It should be noted that these conditions are merely illustrative examples of the limitations for applying this method, and are not intended to impose specific restrictions. Furthermore, for the image prediction method in this application embodiment, slice-level or higher-level syntax elements can also be used, and the relevant syntax elements will be described below.
[0192] First, for a video sequence, it's necessary to describe whether the video sequence can use inter-frame bidirectional prediction. Specifically, a syntax element can be introduced into the sequence header: the inter-frame bidirectional gradient enable flag, which can be represented by `grad_enable_flag`. This flag is a binary variable; a value of "1" indicates that the video sequence can use inter-frame bidirectional gradients, while a value of "0" indicates that the video sequence cannot use inter-frame bidirectional gradients. Table 2 provides a syntax description for this part, with the gray areas representing the newly added syntax.
[0193] Table 2
[0194]
[0195] Then, for the newly added gradient parameters, such as gradient flag values and gradient direction index values, two CU-level syntax elements are introduced: (1) Inter-frame bidirectional gradient CU-level allow flag, which can be represented by grad_flag. It is a binary variable. When the value is "1", it means that the CU uses inter-frame bidirectional gradient correction; when the value is "0", it means that the CU does not use inter-frame bidirectional gradient correction; (2) Inter-frame bidirectional gradient CU-level direction flag, which can be represented by grad_idx. It is a binary variable. When the value is "1", it means that the CU uses backward gradient correction; when the value is "0", it means that the CU uses forward gradient correction. Table 3 gives the syntax description of this part. The gray part is the newly added syntax content.
[0196] Table 3
[0197]
[0198] Furthermore, syntax elements can be set in sequence header definition, image header definition, slice definition, and coding tree unit definition, and lower layers can override higher layers.
[0199] Among them, the meaning of the modified CU-level syntax elements is: the inter-frame bidirectional gradient CU-level allow flag, represented by grad_flag, is a binary variable. When the value is "1", it indicates whether the CU uses gradient correction, which is the opposite of the CTU layer; when the value is "0", it indicates that it is consistent with the CTU layer.
[0200] The meanings of the syntax elements that can be added:
[0201] (1) Inter-frame bidirectional gradient sequence level allow flag, represented by grad_seq_flag; it is a binary variable. When the value is "1", it means that the video sequence uses inter-frame bidirectional gradient correction; when the value is "0", it means that the video sequence does not use inter-frame bidirectional gradient correction.
[0202] (2) Inter-frame bidirectional gradient image-level allow flag, denoted by grad_pic_flag; it is a binary variable. When the value is "1", it indicates whether the image uses gradient correction opposite to the sequence layer; when the value is "0", it indicates that it is consistent with the sequence layer.
[0203] (3) Inter-frame bidirectional gradient patch-level allow flag, denoted by grad_pat_flag; it is a binary variable. When the value is "1", it indicates whether the patch uses gradient correction opposite to the image layer; when the value is "0", it indicates that it is consistent with the image layer.
[0204] (4) Inter-frame bidirectional gradient CTU level allow flag, denoted by grad_ctu_flag; it is a binary variable. When the value is “1”, it indicates whether the CTU uses gradient correction opposite to the layer; when the value is “0”, it indicates that it is consistent with the layer.
[0205] Tables 4-1, 4-2, 4-3, and 4-4 provide syntactic descriptions of this content in the sequence header definition, inter-frame prediction image header definition, slice definition, and coding tree unit definition, respectively, and add syntactic elements to the corresponding parts of the syntactic description.
[0206] Table 4-1
[0207]
[0208]
[0209] Table 4-2
[0210]
[0211] Table 4-3
[0212]
[0213] Table 4-4
[0214]
[0215] Furthermore, syntax elements can be set in sequence header definition, image header definition, slice definition, and coding tree unit definition, and lower layers can override higher layers.
[0216] Among them, the meaning of the modified CU-level syntax elements is as follows: (1) Inter-frame bidirectional gradient CU-level allow flag, represented by grad_flag, is a binary variable. When the value is "1", it indicates whether the CU uses gradient correction, which is the opposite of the CTU layer; when the value is "0", it indicates that it is consistent with the CTU layer; (2) Inter-frame bidirectional gradient CU-level direction flag, represented by grad_idx, is a binary variable. When the value is "1", it indicates that the CU uses reverse gradient correction; when the value is "0", it indicates that the CU uses forward gradient correction.
[0217] The meanings of the syntax elements that can be added:
[0218] (1) Inter-frame bidirectional gradient sequence level allow flag, represented by grad_seq_flag; it is a binary variable. When the value is "1", it means that the video sequence uses inter-frame bidirectional gradient correction; when the value is "0", it means that the video sequence does not use inter-frame bidirectional gradient correction.
[0219] (2) Inter-frame bidirectional gradient sequence-level direction flag, represented by grad_seq_idx; it is a binary variable. When the value is "1", it means that the video sequence uses backward gradient correction; when the value is "0", it means that the video sequence uses forward gradient correction.
[0220] (3) Inter-frame bidirectional gradient image-level allow flag, denoted by grad_pic_flag; it is a binary variable. When the value is "1", it indicates whether the image uses gradient correction opposite to the sequence layer; when the value is "0", it indicates that it is consistent with the sequence layer.
[0221] (4) Inter-frame bidirectional gradient image-level orientation flag, denoted by grad_pic_idx; it is a binary variable. When the value is "1", it indicates that the image uses backward gradient correction; when the value is "0", it indicates that the image uses forward gradient correction.
[0222] (5) Inter-frame bidirectional gradient patch-level allow flag, denoted by grad_pat_flag; it is a binary variable. When the value is "1", it indicates whether the patch uses gradient correction opposite to the image layer; when the value is "0", it indicates that it is consistent with the image layer.
[0223] (6) Inter-frame bidirectional gradient slice-level direction flag, denoted by grad_pat_iadx; it is a binary variable. When the value is "1", it means that the slice uses backward gradient correction; when the value is "0", it means that the slice uses forward gradient correction.
[0224] (7) Inter-frame bidirectional gradient CTU level allow flag, denoted by grad_ctu_flag; it is a binary variable. When the value is “1”, it indicates whether the CTU uses gradient correction opposite to the layer; when the value is “0”, it indicates that it is consistent with the layer.
[0225] (8) Inter-frame bidirectional gradient CTU-level direction flag, represented by grad_ctu_idx; it is a binary variable. When the value is “1”, it means that CTU uses reverse gradient correction; when the value is “0”, it means that CTU uses forward gradient correction.
[0226] Tables 5-1, 5-2, 5-3, and 5-4 provide syntactic descriptions of this content in the sequence header definition, inter-frame prediction image header definition, slice definition, and coding tree unit definition, respectively, and add syntactic elements to the corresponding parts of the syntactic description.
[0227] Table 5-1
[0228]
[0229]
[0230] Table 5-2
[0231]
[0232] Table 5-3
[0233]
[0234] Table 5-4
[0235]
[0236] Furthermore, for the preset correction intensity value, the index number of the correction intensity value in the mapping list shown in Table 1 can be described by setting the syntax element grad_k_idx, thereby realizing filtering of different intensities.
[0237] At this point, the following syntax elements need to be added:
[0238] (1) Inter-frame bidirectional gradient sequence-level correction intensity value, denoted by k_idx_grad_seq; it is a multi-valued variable. The value is taken from the index number in Table 1.
[0239] (2) Inter-frame bidirectional gradient image-level modification correction intensity flag, represented by k_idx_grad_pic_flag, is a binary variable. When the value is "1", it means that the image does not use the sequence layer correction intensity value; when the value is "0", it means that it is consistent with the sequence layer. Otherwise, k_idx_grad_pic will be transmitted to modify the correction intensity value used in this image.
[0240] (3) The inter-frame bidirectional gradient image-level correction intensity value is represented by k_idx_grad_pic; it is a multi-valued variable and takes the index number value in Table 1 above.
[0241] (4) Inter-frame bidirectional gradient slice-level modification correction intensity flag, represented by k_idx_-grad_pat_flag; it is a binary variable. When the value is "1", it means that the slice does not use the image layer correction intensity k value; when the value is "0", it means that it is consistent with the image layer; otherwise, k_idx_grad_pat will be transmitted to modify the correction intensity value used internally by this slice.
[0242] (5) Inter-frame bidirectional gradient patch-level correction intensity value, denoted by k_idx_grad_pat; it is a multi-valued variable, and its value is the index number value in Table 1 above.
[0243] (6) Inter-frame bidirectional gradient CTU-level modification correction intensity flag, represented by k_idx_grad_ctu_flag; it is a binary variable. When the value is "1", it means that the CTU does not use the slice correction intensity k value; when the value is "0", it means that it is consistent with the slice. Otherwise, k_idx_grad_ctu will be transmitted to modify the correction intensity value used internally by this CTU.
[0244] (7) Inter-frame bidirectional gradient CTU level correction intensity value, denoted by k_idx_grad_ctu; it is a multi-valued variable, and its value is the index number value in Table 1 above.
[0245] (8) Inter-frame bidirectional gradient CU-level modification correction intensity flag, represented by k_idx_grad_cu_flag; it is a binary variable. When the value is “1”, it means that the CU does not use the CTU layer correction intensity k value; when the value is “0”, it means that it is consistent with the CTU layer. Otherwise, k_idx_grad_cu will be transmitted to modify the correction intensity value used inside this CU.
[0246] (9) Inter-frame bidirectional gradient CU-level correction intensity value, denoted by k_idx_grad_cu; it is a multi-valued variable, and its value is the index number value in Table 1 above.
[0247] Tables 6-1, 6-2, 6-3, 6-4, and 6-5 respectively provide the syntax descriptions of this part in the sequence header definition, inter-frame prediction image header definition, slice definition, coding tree unit definition, and coding unit definition. The correction strength value is represented by k, and the syntax elements are added to the corresponding parts of the syntax description.
[0248] Table 6-1
[0249]
[0250] Table 6-2
[0251]
[0252] Table 6-3
[0253]
[0254] Table 6-4
[0255]
[0256] Table 6-5
[0257]
[0258] Here, in the syntax elements, ae(v) represents a context-adaptive arithmetic entropy-coded syntax element; u(n) represents an unsigned integer using n bits. Among them, the syntax elements added at the CU level are ae(v), the flags in other header information, or other elements with only two possible values are u(1), and other elements with multiple possible values are u(n).
[0259] In the embodiments of this application, an implicit correction scheme can also be adopted. Specifically, grad_flag and grad_idx are determined based on CU characteristics. In this case, grad_flag and grad_idx may not be transmitted in the bitstream, or only grad_flag may be transmitted in the bitstream, and then grad_idx may be predicted based on CU characteristics, thereby reducing encoding decisions and lowering the bitrate; alternatively, for CUs in direct / skip mode in AVS3, grad_flag and grad_idx may be inherited or predicted, thereby making the prediction more accurate.
[0260] In addition, according to the variation trend of the sample brightness value, when the current frame is not in the middle of the two reference frames, assuming that the unidirectional prediction values obtained in the two directions are pred0 and pred1 respectively, then the following calculation formula can be used according to the relative positions of the reference frames:
[0261] Pred = pred BI +(pred1-pred0)>>k, or Pred=pred BI +(pred0-pred1)>>k
[0262] Based on these two calculation formulas, the final two-way prediction value is calculated.
[0263] In addition, in the embodiments of this application, when applying this method after bidirectional prediction or BIO, the essentially the same correction calculation can be performed by deriving the merging processing form through computation. Alternatively, implicit application conditions can be set, such as disabling gradient correction when the sum of absolute differences (SAD) of the two unidirectional predictions meets certain conditions, disabling gradient correction when the reference frame position meets certain conditions, or disabling gradient correction when using BIO. Alternatively, the existence conditions of syntax elements can even be added or modified, such as adjusting the CU size, encoding mode, and reference frame position relationship that allow the use of gradient correction.
[0264] For example, using AVS3's reference software HPM6 as a benchmark, the test was conducted on sequences B and C in Random Access (RA) mode, and the results are shown in Table 7 below. Specifically, Table 7 shows the gain effect of the three image components (Y / U / V) measured using the image prediction method of this application embodiment. It can be seen that this method can make the prediction results more accurate, thereby improving coding efficiency.
[0265] Table 7
[0266]
[0267] This embodiment provides an image prediction method applied to an encoder. This embodiment elaborates on the specific implementation of the aforementioned embodiments, demonstrating that, for an image block to be encoded, the gradient value between two unidirectional prediction values can be obtained using the gradient parameters corresponding to the image block. Then, the initial bidirectional prediction value is corrected based on this gradient value and a preset correction intensity value, thereby making the bidirectional prediction value more accurate. This not only improves the accuracy of the prediction results but also increases coding efficiency, ultimately enhancing the video image quality.
[0268] Based on the above Figure 2B For application scenario examples, see Figure 5 This illustrates a flowchart of another image prediction method provided in an embodiment of this application. Figure 5 As shown, the method may include:
[0269] S501: Parse the bitstream to obtain the prediction mode parameters of the image block to be decoded;
[0270] It should be noted that this method is applied to the decoder. On the decoder side, a single video frame can also be divided into multiple image blocks, and each currently undecoded image block can be a CU (User Unit). Specifically, the image block to be decoded refers to the current image block in the video image that needs to be decoded and predicted for the first, second, or third image component.
[0271] It should also be noted that the prediction mode parameter indicates the encoding mode of the image block and the parameters related to that mode. The encoding mode of the image block typically includes unidirectional prediction mode and bidirectional prediction mode, etc. That is, on the encoder side, predictive coding is performed on the image block. During this process, the encoding mode of the current block can be determined, and the corresponding encoding mode parameters are written into the bitstream, which is then transmitted from the encoder to the decoder.
[0272] In this way, on the decoder side, the prediction mode parameters of the image block can be obtained by parsing the bitstream, and the obtained prediction mode parameters are used to determine whether the image block uses bidirectional prediction mode.
[0273] S502: When the prediction mode parameter indicates that the image block uses a bidirectional prediction mode, the motion parameters of the image block are parsed;
[0274] It should be noted that the motion parameters include motion vectors and reference image indices. Therefore, if the prediction mode parameters indicate that the image patch uses a bidirectional prediction mode, the bitstream needs to be further parsed to obtain the motion vectors and reference image indices of the image patch, in order to determine the unidirectional prediction values corresponding to the image patch in the two prediction directions.
[0275] S503: Based on the motion parameters, determine the unidirectional prediction values of the image block in the two prediction directions respectively;
[0276] It should be noted that after obtaining the motion parameters (motion vector and reference image index) of the image patch, the unidirectional prediction values of the image patch in the two prediction directions can be determined based on the motion vector and reference image index. Specifically, in some embodiments, determining the unidirectional prediction values of the image patch in the two prediction directions based on the motion parameters may include:
[0277] Based on the reference image index in the motion parameters, the predicted image blocks of the image block in the two prediction directions are determined;
[0278] Based on the two predicted image patches and the motion vector in the motion parameters, determine the unidirectional prediction values of the image patches in the two prediction directions.
[0279] It should be noted that a video sequence includes multiple video images, such as the current frame, the first reference frame (reference frame 0), and the second reference frame (reference frame 1). Assuming that the image block to be decoded is located on the current frame, then the two predicted image blocks will be located on reference frame 0 and reference frame 1 in the video sequence, respectively.
[0280] Furthermore, reference frame 0 and reference frame 1 can be located in one forward direction and one backward direction of the current frame, or they can be located in two backward directions of the current frame, or even in two forward directions of the current frame; that is, the two prediction directions can include one forward direction and one backward direction, or two forward directions or two backward directions, etc. In the embodiments of this application, preferably, the two prediction directions include one forward direction and one backward direction, but this is not limited in any way.
[0281] It should also be noted that the unidirectional prediction value can be one unidirectional prediction value in each prediction direction, resulting in a total of two unidirectional prediction values; or it can be at least one unidirectional prediction value in each prediction direction, resulting in a total of more than two unidirectional prediction values. Preferably, there is one unidirectional prediction value in each prediction direction, such as a first unidirectional prediction value determined in the first prediction direction and a second unidirectional prediction value determined in the second prediction direction. Here, the determination of the unidirectional prediction value is the same as the steps on the encoder side, and will not be described in detail here.
[0282] S504: Determine the gradient parameters corresponding to the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively;
[0283] It should be noted that gradient parameters include at least gradient flag values and gradient direction index values. After setting the gradient parameters, the encoder also writes the gradient parameters into the bitstream, which is then transmitted from the encoder to the decoder. Thus, on the decoder side, the gradient parameters do not need to be determined again; the gradient parameters corresponding to the image blocks can be obtained directly by parsing the bitstream.
[0284] Specifically, in some embodiments, determining the gradient parameters of the image patch may include:
[0285] The bitstream is parsed to obtain the gradient parameters of the image block. The gradient parameters include at least a gradient flag value and a gradient direction index value.
[0286] Furthermore, in some embodiments, the parsing of the bitstream to obtain the gradient parameters of the image patch may include:
[0287] Parse the bitstream and obtain the gradient flag value from the gradient parameters;
[0288] Determine whether the acquired gradient flag value is equal to 1;
[0289] If the obtained gradient flag value is equal to 1, continue parsing the bitstream to obtain the gradient direction index value in the gradient parameters.
[0290] In other words, after parsing the bitstream, if the gradient flag value in the gradient parameters is 0, then the gradient direction index value in the gradient parameters will not be obtained again; if the gradient flag value in the gradient parameters is 1, then the bitstream needs to be parsed again to obtain the gradient direction index value in the gradient parameters.
[0291] It is understandable that after obtaining the gradient parameters, if the gradient flag value is equal to 0, it indicates that gradient correction is not required for the initial bidirectional prediction value, i.e., gradient correction is turned off. In this case, step S504 does not need to be executed, and the initial bidirectional prediction value can be directly used as the bidirectional prediction value of the image patch. Therefore, in some embodiments, the method may further include: if the gradient flag value is equal to 0, then determining the initial bidirectional prediction value as the bidirectional prediction value of the image patch.
[0292] It should also be noted that, by default, the gradient flag value is equal to 1, which indicates that gradient correction is required for the initial bidirectional prediction value. In this case, step S504 needs to be executed to calculate the gradient value of the image patch to be predicted.
[0293] Specifically, in some embodiments, when the gradient flag value is equal to 1, for S504, calculating the gradient value of the image patch using the gradient parameter and the unidirectional prediction values corresponding to the image patch in the two prediction directions may include:
[0294] If the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then the gradient value of the image patch is obtained by subtracting the first one-way prediction value from the second one-way prediction value.
[0295] If the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then the gradient value of the image patch is obtained by subtracting the second unidirectional prediction value from the first unidirectional prediction value.
[0296] Here, the first unidirectional prediction value (Pred0) represents the unidirectional prediction value of the image block corresponding to the first prediction direction, and the second unidirectional prediction value (Pred1) represents the unidirectional prediction value of the image block corresponding to the second prediction direction.
[0297] It should be noted that when the gradient flag value is equal to 1, it indicates that the initial bidirectional prediction value needs to be corrected. At this time, if the gradient direction index value is equal to 0, it indicates that the gradient direction is the positive gradient direction, and the gradient value of the image patch can be obtained as Pred1-Pred0. If the gradient direction index value is equal to 1, it indicates that the gradient direction is the negative gradient direction, and the gradient value of the image patch can be obtained as Pred0-Pred1.
[0298] Still with Figure 4 For example, when the trend of change is determined to be close to curve 1, it indicates that the gradient direction is a positive gradient direction, that is, the gradient direction index value is equal to 0. At this time, the gradient value (R1-R0) between reference frame 0 and reference frame 1 can be determined. When the trend of change is determined to be close to curve 3, it indicates that the gradient direction is a negative gradient direction, that is, the gradient direction index value is equal to 1. At this time, the gradient value (R0-R1) between reference frame 1 and reference frame 0 can be determined. Subsequently, the initial bidirectional prediction value can be corrected according to the determined gradient value, that is, step S505 is executed.
[0299] S505: Correct the initial bidirectional prediction value according to the gradient value of the image block and the preset correction intensity value to obtain the bidirectional prediction value of the image block.
[0300] It should be noted that the initial bidirectional prediction value is the weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively. In terms of execution steps, the initial bidirectional prediction value can be calculated after obtaining the unidirectional prediction value in step S503, or before the correction operation in step S505, or even simultaneously during step S504; there are no limitations on this.
[0301] After determining the gradient value of the image patch, the initial bidirectional prediction value can be corrected by combining it with a preset correction intensity value to obtain the final bidirectional prediction value. Specifically, the step of correcting the initial bidirectional prediction value based on the gradient value of the image patch and the preset correction intensity value to obtain the bidirectional prediction value of the image patch may include:
[0302] The correction gradient value of the image block is determined based on the gradient value of the image block and the preset correction intensity value;
[0303] The initial bidirectional prediction value is corrected using the determined correction gradient value to obtain the bidirectional prediction value of the image patch.
[0304] Optionally, in some embodiments, determining the correction gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value may include:
[0305] The gradient value of the image block is shifted using a preset correction intensity value to obtain the correction gradient value.
[0306] Optionally, in some embodiments, determining the correction gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value may include:
[0307] The preset correction intensity value is multiplied by the gradient value of the image block to obtain the correction gradient value.
[0308] Further, the step of correcting the initial bidirectional prediction value based on the corrected gradient value to obtain the bidirectional prediction value of the image patch may include:
[0309] The corrected gradient value is superimposed on the initial bidirectional prediction value to obtain the bidirectional prediction value of the image patch.
[0310] In other words, the correction gradient value of the image patch can be calculated by shifting, and then the initial bidirectional prediction value can be corrected based on the correction gradient value. Alternatively, the correction gradient value of the image patch can be calculated by multiplication, and then the initial bidirectional prediction value can be corrected based on the correction gradient value. This application does not impose any limitations on the embodiments.
[0311] Taking the shift method as an example, the preset correction intensity value can be represented by k. Generally speaking, the default value of k can be set to a preset constant value, preferably 3, or it can be defined using slice-level or higher syntax. Then the bidirectional prediction value of the image block is represented as shown in the above formula (27).
[0312] Furthermore, regarding the value of k, besides setting it to a preset constant value, an index number value can be obtained by parsing the bitstream, and then the k value corresponding to that index number value can be selected from the mapping list. Specifically, in some embodiments, the method may further include:
[0313] Obtain the mapping list corresponding to the corrected intensity value; wherein, the mapping list represents the correspondence between the corrected intensity value and the index number value;
[0314] Parse the bitstream and obtain the index sequence number value;
[0315] Select the correction intensity value corresponding to the index number value from the mapping list, and determine the selected correction intensity value as the preset correction intensity value.
[0316] It should be noted that the mapping list reflects the correspondence between the correction intensity value and the index number value. Different correction intensity values can be used to achieve different filtering intensities. This mapping list is the same as that on the encoder side, as shown in Table 1 above. Thus, after parsing the bitstream to obtain the index number value, the correction intensity value corresponding to the index number value can be selected from the mapping list, thereby achieving the final correction of the initial bidirectional prediction value.
[0317] It should also be noted that some steps on the decoder side are the same as those on the encoder side; please refer to the encoder side content for details, which will not be elaborated here.
[0318] This embodiment provides an image prediction method applied to a decoder. By parsing the bitstream, prediction mode parameters of the image block to be decoded are obtained. When the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, motion parameters of the image block are parsed, wherein the motion parameters include motion vectors and reference image indices. Based on the motion parameters, unidirectional prediction values corresponding to the image block in each of the two prediction directions are determined. Gradient parameters of the image block are determined, and the gradient value of the image block is calculated using the gradient parameters and the unidirectional prediction values corresponding to the image block in each of the two prediction directions. The initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the image block in each of the two prediction directions. In this way, the gradient parameters corresponding to the image block can be used to obtain the gradient value between two unidirectional prediction values, and then the initial bidirectional prediction value can be corrected based on this gradient value and a preset correction intensity value, thereby making the bidirectional prediction value more accurate. This not only improves the accuracy of the prediction results but also improves decoding efficiency, thus enhancing the video image quality.
[0319] Based on the same inventive concept as the foregoing embodiments, see [link to previous document]. Figure 6 This illustrates a schematic diagram of the composition structure of an encoder 60 provided in an embodiment of this application. Figure 6 As shown, the encoder 60 may include a first determining unit 601, a first calculating unit 602, and a first correcting unit 603; wherein,
[0320] The first determining unit 601 is configured to perform motion estimation on the image block to be encoded and determine the unidirectional prediction values of the image block in the two prediction directions respectively.
[0321] The first determining unit 601 is further configured to determine the gradient parameters corresponding to the image block, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value.
[0322] The first calculation unit 602 is configured to calculate the gradient value of the image patch using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions respectively.
[0323] The first correction unit 603 is configured to correct the initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0324] In the above scheme, see [reference] Figure 6 The encoder 60 may further include a precoding unit 604 and a first selection unit 605; wherein,
[0325] The precoding unit 604 is configured to precode the image patch using multiple prediction modes to obtain multiple precoding results; wherein, the gradient parameters corresponding to different prediction modes are different.
[0326] The first selection unit 605 is configured to select a preferred precoding result from the plurality of precoding results according to a preset strategy; and to determine the prediction mode corresponding to the preferred precoding result as the target prediction mode.
[0327] In the above scheme, the first selection unit 605 is specifically configured to determine the rate-distortion value corresponding to each precoding result based on the plurality of precoding results; and to select the minimum rate-distortion value from the determined plurality of rate-distortion values, and to determine the precoding result corresponding to the minimum rate-distortion value as the preferred precoding result.
[0328] In the above scheme, the multiple prediction modes include a first prediction mode, a second prediction mode, and a third prediction mode; see also Figure 6 The encoder 60 may further include a setting unit 606 configured to: if the target prediction mode is a first prediction mode, set the gradient flag value in the gradient parameters to 0; if the target prediction mode is a second prediction mode, set the gradient flag value in the gradient parameters to 1 and the gradient direction index value in the gradient parameters to 0; and if the target prediction mode is a third prediction mode, set the gradient flag value in the gradient parameters to 1 and the gradient direction index value in the gradient parameters to 1.
[0329] In the above scheme, the first determining unit 601 is further configured to determine the initial bidirectional prediction value as the bidirectional prediction value of the image block when the set gradient flag value is equal to 0.
[0330] In the above scheme, see [reference] Figure 6The encoder 60 may also include a first acquisition unit 607, configured to acquire the set gradient flag value and gradient direction index value;
[0331] The first calculation unit 602 is specifically configured to: if the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then subtract the first unidirectional prediction value from the second unidirectional prediction value to obtain the gradient value of the image patch; and if the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then subtract the second unidirectional prediction value from the first unidirectional prediction value to obtain the gradient value of the image patch; wherein, the first unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the first prediction direction, and the second unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the second prediction direction.
[0332] In the above scheme, the first determining unit 601 is further configured to determine the correction gradient value of the image block based on the gradient value of the image block and the preset correction intensity value.
[0333] The first correction unit 603 is specifically configured to correct the initial bidirectional prediction value using the determined correction gradient value to obtain the bidirectional prediction value of the image patch.
[0334] In the above scheme, the first calculation unit 602 is further configured to perform shift calculation on the gradient value of the image block using a preset correction intensity value to obtain the correction gradient value.
[0335] In the above scheme, the first calculation unit 602 is further configured to multiply the preset correction intensity value with the gradient value of the image block to obtain the correction gradient value.
[0336] In the above scheme, the preset correction intensity value is a preset constant value.
[0337] In the above scheme, see [reference] Figure 6 The encoder 60 may further include a writing unit 608; wherein,
[0338] The first acquisition unit 607 is further configured to acquire a mapping list corresponding to the corrected intensity value; wherein the mapping list represents the correspondence between the corrected intensity value and the index number value;
[0339] The first calculation unit 602 is further configured to calculate the rate distortion cost corresponding to each correction intensity value in the mapping list;
[0340] The first selection unit 605 is further configured to select the minimum rate distortion value from a plurality of calculated rate distortion values, and determine the correction intensity value corresponding to the minimum rate distortion value as the preset correction intensity value.
[0341] The writing unit 608 is configured to obtain the index number value corresponding to the preset correction intensity value and write the obtained index number value into the bit stream.
[0342] In the above scheme, the writing unit 608 is further configured to write the gradient flag value into the bitstream if the gradient flag value is equal to 0; and to write both the gradient flag value and the gradient direction index value into the bitstream if the gradient flag value is equal to 1.
[0343] In the above scheme, the first acquisition unit 607 is further configured to acquire the predicted image blocks of the image block in two prediction directions;
[0344] The first determining unit 601 is further configured to perform motion estimation based on the image block and the two predicted image blocks to determine motion vectors corresponding to the two prediction directions respectively; and is further configured to determine unidirectional prediction values corresponding to the two prediction directions based on the two predicted image blocks and the two motion vectors respectively.
[0345] Understandably, in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular component. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0346] If the integrated unit is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0347] Therefore, this embodiment provides a computer storage medium applied to an encoder 60, the computer storage medium storing an image prediction program, which, when executed by a first processor, implements the method described in any of the foregoing embodiments.
[0348] Based on the composition of the encoder 60 and the computer storage medium described above, see [link to documentation]. Figure 7 This illustrates the specific hardware structure of the encoder 60 provided in this embodiment, which may include: a first communication interface 701, a first memory 702, and a first processor 703; the various components are coupled together through a first bus system 704. It is understood that the first bus system 704 is used to implement communication between these components. In addition to a data bus, the first bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 7 The general designated all buses as the first bus system 704. Among them,
[0349] The first communication interface 701 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0350] The first memory 702 is used to store computer programs that can run on the first processor 703;
[0351] The first processor 703 is configured to, when running the computer program, perform:
[0352] Motion estimation is performed on the image block to be encoded to determine the unidirectional prediction values of the image block in the two prediction directions respectively;
[0353] Determine the gradient parameters corresponding to the image patch, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value;
[0354] The gradient value of the image patch is calculated using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions.
[0355] The initial bidirectional prediction value is corrected based on the gradient value of the image patch and the preset correction intensity value to obtain the bidirectional prediction value of the image patch, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0356] It is understood that the first memory 702 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The first memory 702 of the system and method described in this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0357] The first processor 703 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the first processor 703 or by instructions in software form. The first processor 703 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in the first memory 702. The first processor 703 reads the information in the first memory 702 and completes the steps of the above method in conjunction with its hardware.
[0358] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), DSP devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0359] Alternatively, as another embodiment, the first processor 703 is further configured to perform the method described in any of the foregoing embodiments when running the computer program.
[0360] This embodiment provides an encoder, which may include a first determining unit, a first calculating unit, and a first correcting unit. The first determining unit is configured to perform motion estimation on an image block to be encoded, determining unidirectional prediction values corresponding to the image block in two prediction directions. The first determining unit is also configured to determine gradient parameters corresponding to the image block, the gradient parameters including at least a gradient flag value and a gradient direction index value. The first calculating unit is configured to calculate the gradient value of the image block using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions. The first correcting unit is configured to correct an initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain a bidirectional prediction value for the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. In this way, for an image block to be encoded, the gradient value between two unidirectional prediction values can be obtained using the gradient parameters corresponding to the image block. Then, the initial bidirectional prediction value is corrected based on the gradient value and the preset correction intensity value, thereby making the bidirectional prediction value more accurate. This not only improves the accuracy of the prediction results but also improves the coding efficiency, thereby enhancing the video image quality.
[0361] Based on the same inventive concept as the foregoing embodiments, see [link to previous document]. Figure 8 This illustrates a schematic diagram of the composition structure of a decoder 80 provided in an embodiment of this application. Figure 8 As shown, the decoder 80 may include a parsing unit 801, a second determining unit 802, a second calculating unit 803, and a second correcting unit 804, wherein,
[0362] The parsing unit 801 is configured to parse the bitstream to obtain the prediction mode parameters of the image block to be decoded; and when the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, to parse the motion parameters of the image block, wherein the motion parameters include a motion vector and a reference image index;
[0363] The second determining unit 802 is configured to determine the unidirectional prediction values of the image block in the two prediction directions based on the motion parameters.
[0364] The second calculation unit 803 is configured to determine the gradient parameters of the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively.
[0365] The second correction unit 804 is configured to correct the initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0366] In the above scheme, the parsing unit 801 is also configured to parse the bitstream and obtain the gradient parameters of the image block, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value.
[0367] In the above scheme, the parsing unit 801 is specifically configured to parse the bitstream, obtain the gradient flag value in the gradient parameters, and determine whether the obtained gradient flag value is equal to 1. If the obtained gradient flag value is equal to 1, then continue to parse the bitstream to obtain the gradient direction index value in the gradient parameters.
[0368] In the above scheme, the second determining unit 802 is further configured to determine the initial bidirectional prediction value as the bidirectional prediction value of the image block if the gradient flag value is equal to 0.
[0369] In the above scheme, the second calculation unit 803 is specifically configured to: if the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then subtract the first unidirectional prediction value from the second unidirectional prediction value to obtain the gradient value of the image patch; and if the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then subtract the second unidirectional prediction value from the first unidirectional prediction value to obtain the gradient value of the image patch; wherein, the first unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the first prediction direction, and the second unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the second prediction direction.
[0370] In the above scheme, the second determining unit 802 is further configured to determine the corrected gradient value of the image block based on the gradient value of the image block and the preset corrected intensity value.
[0371] The second correction unit 804 is specifically configured to correct the initial bidirectional prediction value using the determined correction gradient value to obtain the bidirectional prediction value of the image patch.
[0372] In the above scheme, the second calculation unit 803 is further configured to perform shift calculation on the gradient value of the image block using a preset correction intensity value to obtain the correction gradient value.
[0373] In the above scheme, the second calculation unit 803 is further configured to multiply the preset correction intensity value with the gradient value of the image block to obtain the correction gradient value.
[0374] In the above scheme, the preset correction intensity value is a preset constant value.
[0375] In the above scheme, see [reference] Figure 8 The decoder 80 may further include a second acquisition unit 805 and a second selection unit 806; wherein,
[0376] The second acquisition unit 805 is configured to acquire a mapping list corresponding to the corrected intensity value; wherein, the mapping list represents the correspondence between the corrected intensity value and the index number value;
[0377] The parsing unit 801 is also configured to parse the bitstream and obtain the index sequence number value;
[0378] The second selection unit 806 is configured to select the correction intensity value corresponding to the index number value from the mapping list, and determine the selected correction intensity value as the preset correction intensity value.
[0379] In the above scheme, the second determining unit 802 is further configured to determine the predicted image block of the image block in two prediction directions based on the reference image index in the motion parameters; and is further configured to determine the unidirectional prediction value of the image block in the two prediction directions based on the two determined predicted image blocks and the motion vector in the motion parameters.
[0380] Understandably, in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular component. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0381] If the integrated unit is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this embodiment provides a computer storage medium applied to the decoder 80, which stores an image prediction program that, when executed by a second processor, implements the method described in any of the foregoing embodiments.
[0382] Based on the composition of the decoder 80 and the computer storage medium described above, see [link to documentation]. Figure 9This illustrates the specific hardware structure of the decoder 80 provided in this embodiment, which may include: a second communication interface 901, a second memory 902, and a second processor 903; the various components are coupled together through a second bus system 904. It is understood that the second bus system 904 is used to implement communication between these components. In addition to a data bus, the second bus system 904 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 9 The general designated all buses as the second bus system 904. Among them,
[0383] The second communication interface 901 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0384] The second memory 902 is used to store computer programs that can run on the second processor 903;
[0385] The second processor 903 is configured to perform the following when running the computer program:
[0386] Parse the bitstream to obtain the prediction mode parameters of the image block to be decoded;
[0387] When the prediction mode parameter indicates that the image patch uses a bidirectional prediction mode, the motion parameters of the image patch are parsed, wherein the motion parameters include a motion vector and a reference image index;
[0388] Based on the motion parameters, determine the unidirectional prediction values of the image patch in the two prediction directions respectively;
[0389] Determine the gradient parameters of the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively;
[0390] The initial bidirectional prediction value is corrected based on the gradient value of the image patch and the preset correction intensity value to obtain the bidirectional prediction value of the image patch, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively.
[0391] Alternatively, as another embodiment, the second processor 903 is also configured to perform the method described in any of the foregoing embodiments when running the computer program.
[0392] It is understood that the second memory 902 has similar hardware functions to the first memory 702, and the second processor 903 has similar hardware functions to the first processor 703; these will not be described in detail here.
[0393] This embodiment provides a decoder, which may include a parsing unit, a second determining unit, a second calculating unit, and a second correcting unit. The parsing unit is configured to parse the bitstream to obtain prediction mode parameters of the image block to be decoded; and when the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, to parse motion parameters of the image block, wherein the motion parameters include a motion vector and a reference image index. The second determining unit is configured to determine unidirectional prediction values of the image block in the two prediction directions based on the motion parameters. The second calculating unit is configured to determine gradient parameters of the image block and calculate the gradient value of the image block using the gradient parameters and the unidirectional prediction values of the image block in the two prediction directions. The second correcting unit is configured to correct an initial bidirectional prediction value based on the gradient value of the image block and a preset correction intensity value to obtain a bidirectional prediction value of the image block, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values in the two prediction directions. In this way, for an image block to be decoded, the gradient value between two unidirectional prediction values can be obtained using the gradient parameters corresponding to the image block. Then, the initial bidirectional prediction value is corrected based on the gradient value and the preset correction intensity value, thereby making the bidirectional prediction value more accurate. This not only improves the accuracy of the prediction results but also improves the coding efficiency, thereby enhancing the video image quality.
[0394] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0395] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0396] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0397] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0398] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0399] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0400] Industrial applicability
[0401] In this embodiment, the method is applied to an encoder or a decoder. For the encoder, after motion estimation of the image block to be encoded to determine the unidirectional prediction values corresponding to the image block in the two prediction directions, the gradient value of the image block is calculated based on the determined gradient parameters of the image block and the unidirectional prediction values corresponding to the two prediction directions. Then, the initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block. The initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. For the decoder, after parsing the bitstream to obtain the prediction mode parameters of the image block to be decoded, when the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, the motion parameters of the image block are parsed. Based on the motion parameters, the unidirectional prediction values corresponding to the image block in the two prediction directions are determined. Then, the gradient value of the image block is calculated based on the determined gradient parameters of the image block and the unidirectional prediction values corresponding to the two prediction directions. Then, the initial bidirectional prediction value is corrected based on the gradient value of the image block and a preset correction intensity value to obtain the bidirectional prediction value of the image block. In this way, the gradient parameters corresponding to the image patch can be used to obtain the gradient value between two unidirectional prediction values. Then, the initial bidirectional prediction value is corrected according to the gradient value and the preset correction intensity value, so that the bidirectional prediction value is more accurate. This not only improves the accuracy of the prediction results, but also improves the encoding and decoding efficiency, thereby improving the video image quality.
Claims
1. An image prediction method applied to an encoder, the method comprising: Motion estimation is performed on the image block to be encoded to determine the unidirectional prediction values of the image block in the two prediction directions respectively; Determine the gradient parameters corresponding to the image patch, wherein the gradient parameters include at least two syntax elements: gradient flag value and gradient direction index value; The gradient value of the image patch is calculated using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions. The initial bidirectional prediction value is corrected based on the gradient value of the image patch and a preset correction intensity value to obtain the bidirectional prediction value of the image patch. The initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. Prior to determining the gradient parameters corresponding to the image patch, the method further includes: The image patch is precoded using multiple prediction modes to obtain multiple precoding results; the gradient parameters are different for different prediction modes. From the plurality of precoding results, a preferred precoding result is selected according to a preset strategy; The prediction mode corresponding to the preferred precoding result is determined as the target prediction mode. The multiple prediction modes include a first prediction mode, a second prediction mode, and a third prediction mode. Determining the prediction mode corresponding to the preferred precoding result as the target prediction mode includes: If the target prediction mode is the first prediction mode, then the gradient flag value in the gradient parameter is set to 0. If the target prediction mode is the second prediction mode, then the gradient flag value in the gradient parameter is set to 1, and the gradient direction index value in the gradient parameter is set to 0. If the target prediction mode is the third prediction mode, then the gradient flag value in the gradient parameters is set to 1, and the gradient direction index value in the gradient parameters is set to 1. The method further includes: when the set gradient flag value is equal to 0, determining the initial bidirectional prediction value as the bidirectional prediction value of the image patch. Wherein, when the set gradient flag value is equal to 1, the step of calculating the gradient value of the image patch using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions respectively includes: Retrieve the set gradient flag value and gradient direction index value; If the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then the gradient value of the image patch is obtained by subtracting the first one-way prediction value from the second one-way prediction value. If the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then the gradient value of the image patch is obtained by subtracting the second unidirectional prediction value from the first unidirectional prediction value; wherein, the first unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the first prediction direction, and the second unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the second prediction direction.
2. The method according to claim 1, wherein, The step of selecting a preferred precoding result from the plurality of precoding results according to a preset strategy includes: Based on the multiple precoding results, determine the rate-distortion cost corresponding to each precoding result; Select the minimum rate distortion value from the determined multiple rate distortion values, and determine the precoding result corresponding to the minimum rate distortion value as the preferred precoding result.
3. The method according to claim 1, wherein, The step of correcting the initial bidirectional prediction value based on the gradient value of the image patch and a preset correction intensity value to obtain the bidirectional prediction value of the image patch includes: The correction gradient value of the image block is determined based on the gradient value of the image block and the preset correction intensity value; The initial bidirectional prediction value is corrected using the determined correction gradient value to obtain the bidirectional prediction value of the image patch.
4. The method according to claim 3, wherein, Determining the correction gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value includes: The gradient value of the image block is shifted using a preset correction intensity value to obtain the correction gradient value.
5. The method according to claim 3, wherein, Determining the correction gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value includes: The preset correction intensity value is multiplied by the gradient value of the image block to obtain the correction gradient value.
6. The method according to claim 1, wherein, The preset correction strength value is a preset constant value.
7. The method according to claim 6, wherein, The preset constant value is 3.
8. The method according to claim 1, wherein, The method further includes: Obtain the mapping list corresponding to the corrected intensity value; wherein, the mapping list represents the correspondence between the corrected intensity value and the index number value; Calculate the rate-distortion cost corresponding to each correction intensity value in the mapping list; Select the minimum rate distortion value from the multiple calculated rate distortion values, and determine the correction intensity value corresponding to the minimum rate distortion value as the preset correction intensity value; Obtain the index number value corresponding to the preset correction intensity value, and write the obtained index number value into the bit stream.
9. The method according to claim 1, wherein, The method further includes: If the gradient flag value is equal to 0, then the gradient flag value is written into the bitstream; If the gradient flag value is equal to 1, then both the gradient flag value and the gradient direction index value are written into the bitstream.
10. The method according to any one of claims 1 to 9, wherein, The motion estimation of the image block to be encoded, and the determination of the unidirectional prediction values of the image block in the two prediction directions, include: Obtain the predicted image patches of the image patch in two prediction directions; Motion estimation is performed based on the image patch and the two predicted image patches to determine the motion vectors corresponding to the two predicted directions; Based on the two predicted image patches and the two motion vectors, determine the unidirectional predicted values corresponding to the two prediction directions respectively.
11. An image prediction method applied to a decoder, the method comprising: Parse the bitstream to obtain the prediction mode parameters of the image block to be decoded; When the prediction mode parameter indicates that the image patch uses a bidirectional prediction mode, the motion parameters of the image patch are parsed, wherein the motion parameters include a motion vector and a reference image index; Based on the motion parameters, determine the unidirectional prediction values of the image patch in the two prediction directions respectively; Determine the gradient parameters of the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively; The initial bidirectional prediction value is corrected based on the gradient value of the image patch and a preset correction intensity value to obtain the bidirectional prediction value of the image patch. The initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions. The determination of the gradient parameters of the image patch includes: The bitstream is parsed to obtain the gradient parameters of the image patch. These gradient parameters include at least two syntax elements: a gradient flag value and a gradient direction index value. The parsed bitstream includes: Parse the bitstream and obtain the gradient flag value from the gradient parameters; Determine whether the acquired gradient flag value is equal to 1; If the obtained gradient flag value is equal to 1, continue parsing the bitstream to obtain the gradient direction index value in the gradient parameters. The method further includes, after determining whether the acquired gradient flag value is equal to 1: If the gradient flag value is equal to 0, then the initial bidirectional prediction value is determined as the bidirectional prediction value of the image patch. Wherein, when the gradient flag value is equal to 1, the step of calculating the gradient value of the image patch using the gradient parameter and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively includes: If the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then the gradient value of the image patch is obtained by subtracting the first one-way prediction value from the second one-way prediction value. If the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then the gradient value of the image patch is obtained by subtracting the second unidirectional prediction value from the first unidirectional prediction value; wherein, the first unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the first prediction direction, and the second unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the second prediction direction.
12. The method according to claim 11, wherein, The step of correcting the initial bidirectional prediction value based on the gradient value of the image patch and a preset correction intensity value to obtain the bidirectional prediction value of the image patch includes: The correction gradient value of the image block is determined based on the gradient value of the image block and the preset correction intensity value; The initial bidirectional prediction value is corrected using the determined correction gradient value to obtain the bidirectional prediction value of the image patch.
13. The method according to claim 12, wherein, Determining the correction gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value includes: The gradient value of the image block is shifted using a preset correction intensity value to obtain the correction gradient value.
14. The method according to claim 12, wherein, Determining the correction gradient value of the image patch based on the gradient value of the image patch and a preset correction intensity value includes: The preset correction intensity value is multiplied by the gradient value of the image block to obtain the correction gradient value.
15. The method according to claim 11, wherein, The preset correction strength value is a preset constant value.
16. The method according to claim 15, wherein, The preset constant value is 3.
17. The method according to claim 11, wherein, The method further includes: Obtain the mapping list corresponding to the corrected intensity value; wherein, the mapping list represents the correspondence between the corrected intensity value and the index number value; Parse the bitstream and obtain the index sequence number value; Select the correction intensity value corresponding to the index number value from the mapping list, and determine the selected correction intensity value as the preset correction intensity value.
18. The method according to any one of claims 11 to 17, wherein, The step of determining the unidirectional prediction values of the image patch in the two prediction directions based on the motion parameters includes: Based on the reference image index in the motion parameters, the predicted image blocks of the image block in the two prediction directions are determined; Based on the two predicted image patches and the motion vector in the motion parameters, determine the unidirectional prediction values of the image patches in the two prediction directions.
19. An encoder, the encoder comprising a first determining unit, a first calculating unit, and a first correcting unit, wherein, The first determining unit is configured to perform motion estimation on the image block to be encoded and determine the unidirectional prediction values of the image block in two prediction directions respectively; The first determining unit is further configured to determine the gradient parameters corresponding to the image block, wherein the gradient parameters include at least a gradient flag value and a gradient direction index value; The first calculation unit is configured to calculate the gradient value of the image patch using the determined gradient parameters and the unidirectional prediction values corresponding to the two prediction directions respectively. The first correction unit is configured to correct the initial bidirectional prediction value based on the gradient value of the image patch and a preset correction intensity value to obtain the bidirectional prediction value of the image patch, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively. The encoder further includes a precoding unit and a first selection unit, wherein, The precoding unit is configured to precode the image patch using multiple prediction modes to obtain multiple precoding results; wherein, different prediction modes correspond to different gradient parameters; The first selection unit is configured to select a preferred precoding result from the plurality of precoding results according to a preset strategy; and to determine the prediction mode corresponding to the preferred precoding result as the target prediction mode. The multiple prediction modes include a first prediction mode, a second prediction mode, and a third prediction mode. The encoder also includes a setting unit configured as follows: If the target prediction mode is the first prediction mode, then the gradient flag value in the gradient parameter is set to 0. If the target prediction mode is the second prediction mode, then the gradient flag value in the gradient parameter is set to 1, and the gradient direction index value in the gradient parameter is set to 0. If the target prediction mode is the third prediction mode, then the gradient flag value in the gradient parameters is set to 1, and the gradient direction index value in the gradient parameters is set to 1. The first determining unit is further configured to determine the initial bidirectional prediction value as the bidirectional prediction value of the image patch when the set gradient flag value is equal to 0. The encoder further includes a first acquisition unit configured to acquire the set gradient flag value and gradient direction index value; The first computing unit is specifically configured as follows: If the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then the gradient value of the image patch is obtained by subtracting the first one-way prediction value from the second one-way prediction value. If the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then the gradient value of the image patch is obtained by subtracting the second unidirectional prediction value from the first unidirectional prediction value; wherein, the first unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the first prediction direction, and the second unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the second prediction direction.
20. An encoder, the encoder comprising a first memory and a first processor, wherein, The first memory is used to store computer programs that can run on the first processor; The first processor is configured to perform the method as described in any one of claims 1 to 10 when running the computer program.
21. A decoder, the decoder comprising a parsing unit, a second determining unit, a second calculating unit, and a second correcting unit, wherein, The parsing unit is configured to parse the bitstream to obtain the prediction mode parameters of the image block to be decoded; and when the prediction mode parameters indicate that the image block uses a bidirectional prediction mode, to parse the motion parameters of the image block, wherein the motion parameters include motion vectors and reference image indices; The second determining unit is configured to determine, based on the motion parameters, the unidirectional prediction values of the image block in the two prediction directions respectively; The second calculation unit is configured to determine the gradient parameters of the image patch, and calculate the gradient value of the image patch using the gradient parameters and the unidirectional prediction values corresponding to the image patch in the two prediction directions respectively. The second correction unit is configured to correct the initial bidirectional prediction value based on the gradient value of the image patch and a preset correction intensity value to obtain the bidirectional prediction value of the image patch, wherein the initial bidirectional prediction value is a weighted sum of the unidirectional prediction values corresponding to the two prediction directions respectively. The parsing unit is further configured as follows: The bitstream is parsed to obtain the gradient parameters of the image patch. These gradient parameters include at least two syntax elements: a gradient flag value and a gradient direction index value. The parsing unit is specifically configured as follows: Parse the bitstream and obtain the gradient flag value from the gradient parameters; Determine whether the acquired gradient flag value is equal to 1; If the obtained gradient flag value is equal to 1, continue parsing the bitstream to obtain the gradient direction index value in the gradient parameters. The second determining unit is further configured to: if the gradient flag value is equal to 0, then determine the initial bidirectional prediction value as the bidirectional prediction value of the image patch. The second computing unit is specifically configured as follows: If the gradient flag value is equal to 1 and the gradient direction index value is equal to 0, then the gradient value of the image patch is obtained by subtracting the first one-way prediction value from the second one-way prediction value. If the gradient flag value is equal to 1 and the gradient direction index value is equal to 1, then the gradient value of the image patch is obtained by subtracting the second unidirectional prediction value from the first unidirectional prediction value; wherein, the first unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the first prediction direction, and the second unidirectional prediction value represents the unidirectional prediction value of the image patch corresponding to the second prediction direction.
22. A decoder, the decoder comprising a second memory and a second processor, wherein, The second memory is used to store computer programs that can run on the second processor; The second processor is configured to perform the method as described in any one of claims 11 to 18 when running the computer program.
23. A computer storage medium, wherein, The computer storage medium stores a computer program and a bitstream, and when the computer program is executed by the first processor, it implements the method as described in any one of claims 1 to 10 to generate the bitstream.