Inter-frame prediction methods, encoders, decoders, and storage media

By determining the forward and backward motion vectors of the current block during video encoding and decoding, setting the BDOF flag, and deciding whether to execute BDOF, the problem of high computational complexity is solved, and the efficiency of inter-frame prediction is improved.

CN114365498BActive Publication Date: 2025-11-14GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201980100103.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-12-30
Publication Date
2025-11-14
Estimated Expiration
2039-12-30

AI Technical Summary

Technical Problem

In the video encoding and decoding process, prediction based on bidirectional optical flow has high computational complexity and is very time-consuming, resulting in low efficiency of inter-frame prediction.

Method used

By determining the forward and backward motion vectors of the current block, it is judged whether the set conditions are met, the value of the BDOF flag is set, and it is decided whether to execute BDOF, thus avoiding unnecessary calculations for blocks or sub-blocks that do not meet the conditions.

Benefits of technology

It reduces the computational complexity of the inter-frame prediction process, decreases computation time, and improves the efficiency of inter-frame prediction in the video encoding and decoding process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114365498B_ABST
    Figure CN114365498B_ABST
Patent Text Reader

Abstract

An inter-frame prediction method, apparatus, related devices, and storage medium are disclosed. The method includes: determining a first motion vector and a second motion vector of a current block; the first motion vector being a forward motion vector of the current block; the second motion vector being a backward motion vector of the current block; determining, based on the first motion vector and the second motion vector, whether a set condition is met, and obtaining a determination result; setting a value for a BDOF flag according to the determination result; and determining an inter-frame prediction value for the current block or at least one sub-block within the current block based on the value of the BDOF flag.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of video encoding and decoding technology, specifically to an inter-frame prediction method, an encoder, a decoder, and a storage medium. Background Technology

[0002] In the video encoding and decoding process, when performing inter-frame prediction based on bidirectional optical flow prediction (BDOF), related technologies need to calculate spatial gradient, temporal gradient, autocorrelation parameter, cross-correlation parameter, optical flow vector and luminance offset value for each sub-block in the coding or decoding block, and finally obtain the luminance prediction value corresponding to each sub-block. The calculation process is complex, time-consuming and inefficient. Summary of the Invention

[0003] To address the related technical issues, embodiments of this application provide an inter-frame prediction method, an encoder, a decoder, and a storage medium.

[0004] The technical solution of this application embodiment can be implemented as follows:

[0005] In a first aspect, embodiments of this application provide an inter-frame prediction method applied to an encoder, the method comprising:

[0006] Determine the first motion vector and the second motion vector of the current block; the first motion vector is the forward motion vector of the current block; the second motion vector is the backward motion vector of the current block.

[0007] Based on the first motion vector and the second motion vector, determine whether the set conditions are met, and obtain the judgment result;

[0008] Set the value of the BDOF flag based on the judgment result;

[0009] Based on the value of the BDOF flag, the inter-frame prediction value of the current block or at least one sub-block in the current block is determined.

[0010] Secondly, embodiments of this application provide an inter-frame prediction method applied to a decoder, the method comprising:

[0011] Determine the first motion vector and the second motion vector of the current block; the first motion vector is the forward motion vector of the current block; the second motion vector is the backward motion vector of the current block.

[0012] Based on the first motion vector and the second motion vector, determine whether the set conditions are met, and obtain the judgment result;

[0013] Set the value of the BDOF flag based on the judgment result;

[0014] Based on the value of the BDOF flag, the inter-frame prediction value of the current block or at least one sub-block in the current block is determined.

[0015] Thirdly, embodiments of this application provide an encoder, including:

[0016] The first determining unit is configured to determine a first motion vector and a second motion vector of the current block; the first motion vector is the forward motion vector of the current block; and the second motion vector is the backward motion vector of the current block.

[0017] The first judgment unit is configured to determine whether a set condition is met based on the first motion vector and the second motion vector, and obtain a judgment result.

[0018] The first setting unit is configured to set the value of the BDOF flag according to the judgment result;

[0019] The first prediction unit is configured to determine the inter-frame prediction value of the current block or at least one sub-block in the current block based on the value of the BDOF flag.

[0020] Fourthly, embodiments of this application provide a decoder, including:

[0021] The second determining unit is configured to determine a first motion vector and a second motion vector of the current block; the first motion vector is the forward motion vector of the current block; and the second motion vector is the backward motion vector of the current block.

[0022] The second judgment unit is configured to determine whether a set condition is met based on the first motion vector and the second motion vector, and obtain a judgment result.

[0023] The second setting unit is configured to set the value of the BDOF flag according to the judgment result;

[0024] The second prediction unit is configured to determine the inter-frame prediction value of the current block or at least one sub-block in the current block based on the value of the BDOF flag.

[0025] Fifthly, embodiments of this application provide an encoder, including: a first processor and a first memory for storing a computer program capable of running on the processor.

[0026] Wherein, when the first processor is used to run the computer program, it executes the steps of the method described in the first aspect above.

[0027] Sixthly, embodiments of this application provide a decoder, including: a second processor and a second memory for storing a computer program capable of running on the processor.

[0028] Wherein, when the second processor is used to run the computer program, it executes the steps of the method described in the second aspect above.

[0029] In a seventh aspect, embodiments of this application provide a storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method described in the first aspect; or,

[0030] When the computer program is executed by a processor, it implements the steps of the method described in the second aspect above.

[0031] This application provides an inter-frame prediction method, encoder, decoder, and storage medium. During inter-frame prediction in video encoding and decoding, the forward and backward motion vectors corresponding to the current block are determined. Based on these vectors, corresponding set conditions are used for judgment, and the value of the BDOF flag corresponding to the current block or at least one sub-block within the current block is set according to the judgment result. This determines whether to perform BDOF on the current block or at least one sub-block within the current block. Based on the solution provided by this application, if the current block or any sub-block within the current block does not meet the BDOF usage conditions, BDOF execution can be skipped, avoiding unnecessary calculations for the current block or sub-block that does not meet the BDOF usage conditions. This reduces the computational complexity and time consumption in the inter-frame prediction process, thereby improving the computational efficiency of inter-frame prediction during video encoding and decoding. Attached Figure Description

[0032] Figure 1 A schematic diagram illustrating the implementation process of the prediction process using BDOF technology for related technical solutions;

[0033] Figure 2 A schematic diagram of the BDOF input block provided for the relevant technical solution;

[0034] Figure 3A A block diagram of a video encoding system provided in an embodiment of this application;

[0035] Figure 3B A block diagram of a video decoding system provided in an embodiment of this application;

[0036] Figure 4 A schematic diagram illustrating the implementation process of the inter-frame prediction method provided in this application embodiment;

[0037] Figure 5A A schematic diagram illustrating the implementation process of the encoder determining motion vectors provided in the embodiments of this application;

[0038] Figure 5B A schematic diagram illustrating the implementation process of the decoder determining motion vectors in the embodiments of this application;

[0039] Figure 6 A schematic diagram illustrating the implementation process of the inter-frame prediction method provided in this application embodiment, which determines whether set conditions are met based on motion vectors;

[0040] Figure 7 A schematic diagram illustrating the implementation process of the inter-frame prediction method provided in this application embodiment, which determines whether the set conditions are met based on the difference block;

[0041] Figure 8 A schematic diagram of the encoder structure provided in the embodiments of this application;

[0042] Figure 9 A schematic diagram of the decoder structure provided in the embodiments of this application;

[0043] Figure 10 A schematic diagram of the hardware structure of the encoder provided in an embodiment of this application;

[0044] Figure 11 This is a schematic diagram of the hardware structure of the decoder provided in an embodiment of this application. Detailed Implementation

[0045] In order to gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit the embodiments of this application.

[0046] The following section describes the relevant technical solutions for the current BDOF prediction process.

[0047] The next-generation video coding standard (H.266) incorporates the BDOF technology proposed by InterDigital Communications in JVET-L0256. BDOF technology is used to perform sub-block-based luminance compensation on bidirectional prediction blocks during motion compensation in inter-frame prediction. The luminance prediction values ​​used for luminance compensation are obtained through sub-block-based optical flow calculations.

[0048] In related technologies, such as Figure 1As shown, the BDOF prediction process includes: acquiring the BDOF flag 11, configuring the BDOF core parameters 12, constructing the BDOF input 13, and generating the luminance prediction value 14. Specifically, acquiring the BDOF flag 11 involves two steps: first, acquiring the BDOF flag bdofFlag at the Prediction Unit (PU) level corresponding to the current block; when the bdofFlag corresponding to the current block is set to true (the value of bdofFlag is "1"), calculating the Sum of Absolute Error (SAD) of each 4x4 sub-block in the current block. The threshold (difference) is set to bdofBlkDiffThres, and the SAD value is considered. If the SAD value of the current sub-block is greater than or equal to bdofBlkDiffThres, the BDOF flag sbdofFlag at the sub-block level corresponding to the current sub-block is set to true (sbdofFlag's value is "1"). The corresponding sub-block BDOF utilization flag bdofUtilizationFlag[xIdx][yIdx] is set to true, and BDOF is performed on the current sub-block. If the SAD value of the current sub-block is less than bdofBlkDiffThres, the BDOF flag is set to true. `kDiffThres` sets the `sbdofFlag` corresponding to the current sub-block to false (the value of `sbdofFlag` is "0"), and sets the corresponding `bdofUtilizationFlag[xIdx][yIdx]` to false, terminating the subsequent prediction process of BDOF for the current sub-block. When the `bdofFlag` corresponding to the current block is set to false (the value of `bdofFlag` is "0"), the BDOF prediction process for the current block is terminated. This can also be understood as terminating the BDOF prediction process for all 4x4 sub-blocks in the current block. For configuring BDOF core parameters 12, the BDOF core parameters include shift parameters `shift1` to `shift4` and clamping values ​​`mvRefineThres`. Based on the configuration of the BDOF core parameters, during the calculation of temporal and spatial gradients, shifting is performed according to the shift parameters to filter gradients of different granularities and remove gradient noise. During the calculation of the optical flow vector, the optical flow vector is clamped according to the clamping value. Table 1 shows an example of setting the BDOF core parameters:

[0049] Table 1

[0050] Shift1 Shift2 Shfit3 Shfit4 Offset4 mvRefineThres 6 4 1 Max(3, 15-BitDepth) 1<<(shift4-1) 1<<4

[0051] For constructing the BDOF input 13, it includes pu block padding boundary value acquisition 131 and pu block in-block filter interpolation 132. Specifically, the BDOF input block is composed of a (sbWidth+2)x(sbHeight+2) pu block after boundary padding and in-block 8-tap filter interpolation of the forward prediction block and the backward prediction block with size sbWidth x sbHeight. Figure 2 As shown, the white blocks at the boundaries of the PU block represent fill values, while the gray blocks within the PU block represent values ​​interpolated by an 8-tap filter. Generating the luminance prediction value 14 involves sequentially performing spatial and temporal gradient calculations 141, autocorrelation and cross-correlation parameter calculations 142, optical flow vector calculations 143, and luminance offset and luminance prediction value calculations 144 for each pixel within each 4x4 sub-block of the PU block. This ultimately yields the luminance prediction value for each 4x4 sub-block within the PU block, thus creating the luminance prediction block of the PU block.

[0052] As described above, in the process of generating luminance prediction values ​​using BDOF technology, it is necessary to sequentially perform spatial gradient calculation and temporal gradient calculation 141, autocorrelation parameter and cross-correlation parameter calculation 142, optical flow vector calculation 143, and luminance offset value and luminance prediction value calculation 144 for each pixel in each sub-block of the current block. This results in high computational complexity, significant time consumption, and low computational efficiency.

[0053] Based on this, in the embodiments of this application, during the inter-frame prediction process of video encoding and decoding, the forward motion vector and backward motion vector corresponding to the current block are determined. Based on these, corresponding set conditions are used for judgment, and the value of the BDOF flag corresponding to the current block or at least one sub-block within the current block is set according to the judgment result. This determines whether to perform BDOF on the current block or at least one sub-block within the current block. Based on the solution provided by the embodiments of this application, if the current block or any sub-block within the current block does not meet the BDOF usage conditions, the execution of BDOF can be skipped for the current block or current sub-block, avoiding unnecessary calculations for the current block or current sub-block that does not meet the BDOF usage conditions. This reduces the computational complexity and computation time in the inter-frame prediction process, and improves the computational efficiency of inter-frame prediction during video encoding and decoding.

[0054] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0055] See Figure 3A This illustrates an example block diagram of a video encoding system provided in an embodiment of this application. Figure 3AAs 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 Units (CTUs) to perform encoding. The partitioning of a TreeUnit (TreeUnit) 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. The motion compensation is performed. 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, reconstruct the residual block in the pixel domain, and remove the block artifacts by the filter control analysis unit 107 and the filtering unit 108. 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 and output the bitstream of the video signal. 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.

[0056] See Figure 3B It illustrates an example block diagram of a video decoding system provided in an embodiment of this application; as shown Figure 3B 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 3A 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.

[0057] The inter-frame prediction method in this application embodiment is mainly applied in, for example... Figure 3A The motion compensation unit 104 shown and as follows Figure 3BThe motion compensation unit 204 is shown. In other words, the inter-frame prediction method in this embodiment can be applied to a video coding system, a video decoding system, or even simultaneously. It should also be noted that when the inter-frame prediction method is applied to the motion compensation unit 104, "current block" specifically refers to the current coding block in inter-frame prediction, and "current sub-block" specifically refers to the current 4x4 sub-block within the current coding block in inter-frame prediction; when the inter-frame prediction method is applied to the motion compensation unit 204, "current block" specifically refers to the current decoding block in inter-frame prediction, and "current sub-block" specifically refers to the current 4x4 sub-block within the current decoding block in inter-frame prediction.

[0058] Based on the above Figure 3A or Figure 3B For application scenario examples, see Figure 4 This illustrates a schematic diagram of the implementation flow of the inter-frame prediction method provided in an embodiment of this application. For example... Figure 4 As shown, the method may include:

[0059] Step 401: Determine the first motion vector and the second motion vector of the current block.

[0060] Wherein, the first motion vector is the forward motion vector (mv0) of the current block, and the second motion vector is the backward motion vector (mv1) of the current block. The motion vector (MV) includes the motion distance and motion direction, and is obtained by motion estimation of the video coding block.

[0061] In one embodiment, when the inter-frame prediction method is applied to a video coding system, such as Figure 5A As shown, determining the first motion vector and the second motion vector of the current block includes:

[0062] Step 4011: Perform motion estimation on the current block to determine the first motion vector and the second motion vector of the current block.

[0063] Here, based on the correlation and continuity of image content between adjacent image frames, the image frame is divided into several PU blocks. The position of each PU block in adjacent image frames is searched, and the relative offset between the position of the PU block in the current image frame and its position in adjacent image frames is obtained, thus yielding the motion vector corresponding to the PU block. Specifically, the relative offset between the position of the current block in the current image frame and its position in the previous image frame is determined as the first motion vector (forward motion vector), and the relative offset between the position of the current block in the current image frame and its position in the next image frame is determined as the second motion vector (backward motion vector).

[0064] In one embodiment, when the inter-frame prediction method is applied to a video decoding system, such as Figure 5B As shown, determining the first motion vector and the second motion vector of the current block includes:

[0065] Step 4012: Parse the video stream to obtain the motion information index of the current block in Merges mode.

[0066] Step 4013: Select the corresponding motion information from the candidate list of motion information corresponding to the current block according to the motion information index.

[0067] Step 4014: Determine the first motion vector and the second motion vector from the selected motion information.

[0068] Here, in Merge mode, the motion information of the current block is derived by using the motion information of neighboring blocks. Based on the motion information of the neighboring blocks of the current block, a candidate list of motion information corresponding to the current block is determined. By parsing the video bitstream, the motion information index corresponding to the current block is obtained. The motion information indicated by the motion information index is selected from the candidate list of motion information, and the forward motion vector and backward motion vector corresponding to the current block are further determined from the selected motion information.

[0069] Step 402: Based on the first motion vector and the second motion vector, determine whether the set conditions are met, and obtain the judgment result.

[0070] Here, based on the first and second motion vectors, a judgment is made using set conditions to obtain a judgment result that either meets or does not meet the set conditions. The judgment result is used to determine the value of the corresponding BDOF flag.

[0071] It should be noted that, in some embodiments, it can be determined whether the first motion vector and the second motion vector meet the corresponding set conditions, and the determination result is used to determine the value of the BDOF flag corresponding to the current block; in some embodiments, based on the first reference block pointed to by the first motion vector and the second reference block pointed to by the second motion vector, the difference block corresponding to any sub-block in the current block can be determined, and it can be determined whether the difference block meets the corresponding set conditions, and the determination result is used to determine the value of the BDOF flag corresponding to the corresponding sub-block in the current block.

[0072] Step 403: Set the value of the BDOF flag according to the judgment result.

[0073] Step 404: Based on the value of the BDOF flag, determine the inter-frame prediction value of the current block or at least one sub-block in the current block.

[0074] Here, if the BDOF flag values ​​corresponding to the current block and the current sub-block are both the first preset value, BDOF is performed on the current sub-block. It should be noted that the inter-frame prediction value determined here includes the luminance prediction value calculated based on BDOF. If the BDOF flag value corresponding to the current block is the second preset value, BDOF execution on the current block is terminated. Technically, terminating BDOF execution on the current block is equivalent to not using BDOF on any of the 4x4 sub-blocks in the current block. If the BDOF flag value corresponding to the current block is the first preset value, and the BDOF flag value corresponding to the current sub-block is also the first preset value, then BDOF is not used on the current sub-block. However, it is still necessary to determine whether to use BDOF on the next sub-block based on the value of the BDOF flag corresponding to the next sub-block in the current block.

[0075] It should be noted that, when BDOF is terminated for the current block, the inter-frame prediction value for the current block is determined based on the first motion vector and the second motion vector; or, when BDOF is terminated for the current sub-block, the inter-frame prediction value for the current sub-block is determined based on the first motion vector and the second motion vector. Here, the determined inter-frame prediction value does not include the luminance prediction value calculated based on BDOF.

[0076] In one embodiment, the co-directional orientation of the first and second motion vectors is used as a setting condition. The value of the BDOF flag corresponding to the current block is set by determining whether the first and second motion vectors are in the same direction. Here, the motion vector represents the relative displacement between the current block and the best-matching block in the reference image of the current block. Specifically, as... Figure 6 As shown, setting the value of the BDOF flag based on the judgment result includes:

[0077] Step 4031: When the judgment result indicates that the first motion vector and the second motion vector point differently, set the value of the BDOF flag corresponding to the current block to a first preset value.

[0078] In other words, when the first motion vector and the second motion vector are in the same direction, the value of the BDOF flag corresponding to the current block is set to a first preset value. When the value of the BDOF flag corresponding to the current block is the first preset value, the BDOF flag corresponding to the current block is set to true. In practical applications, the bdofFlag corresponding to the current block can be set to true, that is, the first preset value is "1".

[0079] Step 4032: When the judgment result indicates that the first motion vector and the second motion vector point in the same direction, the value of the BDOF flag corresponding to the current block is set to a second preset value.

[0080] In other words, when the first motion vector and the second motion vector are not in the same direction, the BDOF flag corresponding to the current block is set to a second preset value. When the BDOF flag corresponding to the current block is set to the second preset value, the BDOF flag corresponding to the current block is set to false. In practical applications, the bdofFlag corresponding to the current block can be set to false, that is, the second preset value is "0". Here, if the BDOF flag corresponding to the current block is set to false, then BDOF is not used for all 4x4 sub-blocks in the current block.

[0081] Specifically, when determining whether a set condition is met based on the first motion vector and the second motion vector to obtain a determination result, the method includes:

[0082] Based on the horizontal and vertical components of the first motion vector, and the horizontal and vertical components of the second motion vector, determine whether the first and second motion vectors point in the same direction.

[0083] In one embodiment, when determining whether two motion vectors are in the same direction based on their horizontal and vertical components, the sign values ​​of the horizontal and vertical components are primarily used to determine this. Specifically, determining whether the directions of the first and second motion vectors are the same based on their horizontal and vertical components, and the horizontal and vertical components of the second motion vector, includes:

[0084] First, determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector.

[0085] Here, the sign value is determined based on the value of the corresponding component. That is, the sign value of the vertical component is determined based on the value of the vertical component, and the sign value of the horizontal component is determined based on the value of the horizontal component. Specifically:

[0086] When the value of the corresponding component is greater than 0, the sign value of the corresponding component is determined to be 1;

[0087] When the value of the corresponding component is equal to 0, the sign value of the corresponding component is determined to be 0;

[0088] When the value of the corresponding component is less than 0, the sign value of the corresponding component is determined to be -1.

[0089] Based on the above scheme, assign corresponding sign values ​​to the vertical or horizontal components, thus:

[0090] In one embodiment, the first motion vector and the second motion vector are determined to have different directions when one of the following conditions is met:

[0091] The first symbol value, the second symbol value, the third symbol value, and the fourth symbol value are all equal to 0;

[0092] The first symbol value is different from the third symbol value, and the second symbol value is different from the fourth symbol value;

[0093] The first symbol value and the third symbol value are both equal to 0, and the second symbol value is different from the fourth symbol value;

[0094] The first symbol value is different from the third symbol value, and the second symbol value and the fourth symbol value are both equal to 0.

[0095] Conversely, if none of the following conditions are met, the first motion vector and the second motion vector are determined to point in the same direction:

[0096] The first symbol value, the second symbol value, the third symbol value, and the fourth symbol value are all 0;

[0097] The first symbol value is different from the third symbol value, and the second symbol value is different from the fourth symbol value;

[0098] The first symbol value and the third symbol value are both equal to 0, and the second symbol value is different from the fourth symbol value;

[0099] The first symbol value is different from the third symbol value, and the second symbol value and the fourth symbol value are both equal to 0.

[0100] In one embodiment, the first motion vector and the second motion vector are determined to have different directions when all of the following conditions are met:

[0101] The product of the first symbol value and the third symbol value is less than or equal to 0;

[0102] The product of the second symbol value and the fourth symbol value is less than or equal to 0.

[0103] Conversely, if any of the following conditions are not met, the first motion vector and the second motion vector are determined to point in the same direction:

[0104] The product of the first symbol value and the third symbol value is less than or equal to 0;

[0105] The product of the second symbol value and the fourth symbol value is less than or equal to 0.

[0106] In one embodiment, when determining whether two motion vectors are in the same direction based on their horizontal and vertical components, the determination is made based on whether the horizontal and vertical components of the first and second motion vectors are identical. Specifically:

[0107] In one embodiment, determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, includes:

[0108] The first motion vector and the second motion vector are determined to have different directions when one of the following conditions is met;

[0109] The horizontal component, vertical component, horizontal component, and vertical component of the first motion vector are all 0;

[0110] The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is not equal to the vertical component of the second motion vector.

[0111] The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is equal to 0.

[0112] The horizontal components of the first motion vector and the second motion vector are both equal to 0, and the vertical components of the first motion vector and the second motion vector are not equal.

[0113] Conversely, if none of the following conditions are met, the first motion vector and the second motion vector are determined to point in the same direction:

[0114] The horizontal component, vertical component, horizontal component, and vertical component of the first motion vector are all 0;

[0115] The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is not equal to the vertical component of the second motion vector.

[0116] The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is equal to 0.

[0117] The horizontal components of the first motion vector and the second motion vector are both equal to 0, and the vertical components of the first motion vector and the second motion vector are not equal.

[0118] In one embodiment, determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, includes:

[0119] The first motion vector and the second motion vector are determined to have different directions when all of the following conditions are met:

[0120] The product of the horizontal component of the first motion vector and the horizontal component of the second motion vector is less than or equal to 0;

[0121] The product of the vertical component of the first motion vector and the vertical component of the second motion vector is less than or equal to 0.

[0122] Conversely, if any of the following conditions are not met, the first motion vector and the second motion vector are determined to point in the same direction:

[0123] The product of the horizontal component of the first motion vector and the horizontal component of the second motion vector is less than or equal to 0;

[0124] The product of the vertical component of the first motion vector and the vertical component of the second motion vector is less than or equal to 0.

[0125] In one embodiment, when determining whether a set condition is met based on the first motion vector and the second motion vector to obtain a determination result, the method includes:

[0126] When the first motion vector is opposite to the second motion vector, it is determined that the first motion vector and the second motion vector point in different directions; when the first motion vector is not opposite to the second motion vector, it is determined that the first motion vector and the second motion vector point in the same direction.

[0127] Here, the direction of the first motion vector is determined by whether it is opposite to the second motion vector. Specifically:

[0128] In one embodiment, the method further includes:

[0129] Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector;

[0130] When the first symbol value is not equal to the third symbol value, and the second symbol value is not equal to the third symbol value, the first motion vector is opposite to the second motion vector.

[0131] Here, following the scheme described above, the corresponding sign value is determined based on the value of the corresponding component, that is:

[0132] When the value of the corresponding component is greater than 0, the sign value of the corresponding component is determined to be 1;

[0133] When the value of the corresponding component is equal to 0, the sign value of the corresponding component is determined to be 0;

[0134] When the value of the corresponding component is less than 0, the sign value of the corresponding component is determined to be -1.

[0135] In one embodiment, the method further includes:

[0136] When either the first motion vector or the second motion vector is 0, the first motion vector is opposite to the second motion vector.

[0137] In one embodiment, the method further includes:

[0138] Determine the angle between the first motion vector and the second motion vector;

[0139] Taking the direction of the first motion vector as the 0-degree direction, when the included angle is within a first predetermined range, the first motion vector is opposite to the second motion vector; wherein,

[0140] The lower limit of the first set range is greater than 90 degrees; the upper limit of the first set range is less than 270 degrees.

[0141] Furthermore, in one embodiment, when determining whether the directions of the first motion vector and the second motion vector are different, in addition to determining whether the first motion vector and the second motion vector are opposite, it is also necessary to determine whether the amplitudes of the first motion vector and the second motion vector satisfy the first amplitude condition. Here, the amplitude of the motion vector can be obtained by taking the absolute value of the motion vector, or by performing a square root operation on the motion vector. Specifically:

[0142] In one embodiment, when determining whether a set condition is met based on the first motion vector and the second motion vector to obtain a determination result, the method includes:

[0143] When the first motion vector is opposite to the second motion vector, and the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition, it is determined that the first motion vector and the second motion vector have different directions;

[0144] When the first motion vector and the second motion vector are not opposite, or when the amplitude of the first motion vector and the amplitude of the second motion vector do not satisfy the first amplitude condition, it is determined that the first motion vector and the second motion vector point in the same direction.

[0145] In one embodiment, the method further includes:

[0146] When the amplitude of the first motion vector is equal to the amplitude of the second motion vector, it is determined that the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition.

[0147] In one embodiment, the method further includes:

[0148] When the first amplitude ratio is within a second preset range, it is determined that the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition; wherein,

[0149] The first amplitude ratio is determined based on the amplitude of the first motion vector and the amplitude of the second motion vector.

[0150] In one embodiment, the method further includes:

[0151] The first amplitude ratio is determined based on the ratio of the first amplitude to the second amplitude.

[0152] When the first amplitude ratio is less than or equal to the first set ratio, it is determined that the first amplitude ratio is within the second set range;

[0153] Wherein, the first amplitude is the larger of the amplitude of the first motion vector and the amplitude of the second motion vector; the second amplitude is the smaller of the amplitude of the first motion vector and the amplitude of the second motion vector; and the first set ratio is a real number greater than 1.

[0154] In one embodiment, the first set ratio is equal to 2.

[0155] In one embodiment, when determining whether a set condition is met based on the first motion vector and the second motion vector to obtain a determination result, the method includes:

[0156] Determine the sum vector of the first motion vector and the second motion vector;

[0157] The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met:

[0158] The horizontal and vertical components of the sum vector are both equal to 0;

[0159] The magnitude of the sum vector is less than the first set magnitude;

[0160] The second amplitude ratio is less than the second set ratio; the second amplitude ratio is the ratio of the amplitude of the sum vector to the second amplitude; the second amplitude is the smaller value between the amplitude of the first motion vector and the amplitude of the second motion vector.

[0161] The ratio of the sum vector's amplitude to the third amplitude is less than a third predetermined ratio; the third amplitude is the sum of the amplitudes of the first motion vector and the second motion vector.

[0162] The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector;

[0163] The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the magnitude of the sum vector is less than the second set magnitude;

[0164] The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the second amplitude ratio is less than the fourth set ratio;

[0165] The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the ratio of the magnitude of the sum vector to the third magnitude is less than the fifth set ratio.

[0166] In one embodiment, based on the first motion vector and the second motion vector, the difference block corresponding to the current sub-block in the current block is determined, and the value of the BDOF flag corresponding to the current sub-block is set by determining whether the difference block meets the set conditions. Specifically, as shown... Figure 7 As shown, based on the first motion vector and the second motion vector, it is determined whether the set conditions are met, and the determination result is obtained, including:

[0167] Step 4021: Determine the first reference block to which the first motion vector points and the second reference block to which the second motion vector points.

[0168] Here, the first motion vector is the forward motion vector of the current block, and the first reference block pointed to by the first motion vector is the forward prediction block of the current block; the second motion vector is the backward motion vector of the current block, and the second reference block pointed to by the second motion vector is the backward prediction block of the current block.

[0169] Step 4022: Determine the difference block corresponding to the current sub-block.

[0170] Here, the difference block is determined based on the corresponding pixels in the first reference block and the corresponding pixels in the second reference block. Specifically, pixels that correspond one-to-one with the pixel range of the current sub-block (hereinafter referred to as the forward prediction sub-block of the current sub-block) are determined in the first reference block, and pixels that correspond one-to-one with the pixel range of the current sub-block (hereinafter referred to as the backward prediction sub-block of the current sub-block) are determined in the second reference block. Based on the pixels determined in the first reference block and the pixels determined in the second reference block, the difference block corresponding to the current sub-block is determined.

[0171] Step 4023: Determine whether the difference block meets the set conditions and obtain the determination result.

[0172] Specifically, setting the value of the BDOF flag based on the judgment result includes:

[0173] Step 4033: When the judgment result indicates whether the difference block meets the set conditions, set the value of the BDOF flag corresponding to the current sub-block to the first set value.

[0174] Here, when the difference block meets the set conditions, the BDOF flag corresponding to the current sub-block is set to a first set value. When the BDOF flag corresponding to the current sub-block is set to the first set value, the BDOF flag corresponding to the current sub-block is set to true. In practical applications, sbBdofFlag and bdofUtilizationFlag[xIdx][yIdx] corresponding to the current sub-block can be set to true, that is, the first set value is "1".

[0175] Step 4034: When the judgment result indicates whether the difference block meets the set conditions, set the value of the BDOF flag corresponding to the current sub-block to the second set value.

[0176] Here, if the difference block does not meet the set conditions, the BDOF flag corresponding to the current sub-block is set to a second set value. When the BDOF flag corresponding to the current sub-block is set to the second set value, the BDOF flag corresponding to the current sub-block is set to false. In practical applications, sbBdofFlag and bdofUtilizationFlag[xIdx][yIdx] corresponding to the current block can be set to false, that is, the second set value is "0".

[0177] In one embodiment, determining the difference block corresponding to the current sub-block includes:

[0178] The difference block is determined based on the temporal gradient corresponding to the pixels in the current sub-block.

[0179] Here, when calculating the temporal gradient for the current block, the temporal gradient is obtained based on each 4x4 sub-block within the current block, along with the boundary of the same layer (i.e., the 6x6 pixel range corresponding to each 4x4 sub-block). Specifically, the backward prediction sub-block of the current sub-block is shifted right by shift2 positions, the forward prediction sub-block of the current sub-block is shifted right by shift2 positions, and the corresponding pixels in the backward prediction sub-block (which has been shifted right by shift2 positions) are subtracted from the corresponding pixels in the forward prediction sub-block (which has been shifted right by shift2 positions) to obtain the temporal gradient corresponding to the current sub-block. The corresponding temporal gradient calculation formula is as follows:

[0180] diff[x][y]=(predSamplesL1[hx][vy]>>shift2)-(predSamplesL0[hx][vy]>>shift2)

[0181] Where, diff[x][y] is the temporal gradient of the pixel at coordinates (x,y) in the current sub-block, predSamplesL1[hx][vy]>>shift2 is the corresponding pixel in the backward prediction sub-block after shifting right by shifte2 positions for the pixel at coordinates (x,y) in the current sub-block, and predSamplesL0[hx][vy]>>shift2 is the corresponding pixel in the forward prediction sub-block after shifting right by shifte2 positions for the pixel at coordinates (x,y) in the current sub-block.

[0182] Based on determining the difference block corresponding to the current sub-block according to the time gradient, in one embodiment, determining whether the difference block meets the set conditions and obtaining the determination result includes:

[0183] A first maximum value is determined; the first maximum value is the maximum value within the current sub-block range of the difference block; when the first maximum value is a third set value, a judgment result is obtained that the difference block meets the set conditions; when the first maximum value is not the third set value, a judgment result is obtained that the difference block does not meet the set conditions.

[0184] In other words, here, when the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is the third set value, the judgment result that the difference block meets the set condition is obtained, the BDOF flag corresponding to the current sub-block is set to false, and BDOF is not used for the current sub-block; when the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is not the third set value, the judgment result that the difference block does not meet the set condition is obtained, the BDOF flag corresponding to the current sub-block is set to true, and BDOF is used for the current sub-block.

[0185] In practical applications, the third setting value can be set to 0. When the third setting value is set to 0, there will be no loss in coding performance.

[0186] In one embodiment, determining whether the difference block meets a set condition and obtaining a determination result includes:

[0187] Determine a second maximum value; the second maximum value is the maximum value within a 6x4 pixel range corresponding to the current sub-block in the difference block; when the second maximum value is a third set value, obtain a judgment result that the difference block meets the set conditions; when the second maximum value is not the third set value, obtain a judgment result that the difference block does not meet the set conditions.

[0188] In other words, within the 6x4 pixel range corresponding to the current sub-block, when the maximum value of the temporal gradient corresponding to each pixel is the third set value, the difference block is judged to meet the set conditions, the BDOF flag corresponding to the current sub-block is set to false, and BDOF is not used for the current sub-block; when the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is not the third set value, the difference block is judged to not meet the set conditions, the BDOF flag corresponding to the current sub-block is set to true, and BDOF is used for the current sub-block.

[0189] Similarly, in practical applications, the third setting value can be set to 0. When the third setting value is set to 0, there will be no loss in coding performance.

[0190] In one embodiment, determining whether the difference block meets a set condition and obtaining a determination result includes:

[0191] When the sum of the differences within the current sub-block range of the difference block is equal to a third set value, a judgment result is obtained that the difference block meets the set condition; when the sum of the differences within the current sub-block range of the difference block is not equal to the third set value, a judgment result is obtained that the difference block does not meet the set condition.

[0192] In other words, here, when the sum of the temporal gradients corresponding to each pixel in the current sub-block is equal to the third set value, the difference block is judged to meet the set conditions, the BDOF flag corresponding to the current sub-block is set to false, and BDOF is not used for the current sub-block; when the sum of the temporal gradients corresponding to each pixel in the current sub-block is not equal to the third set value, the difference block is judged to not meet the set conditions, the BDOF flag corresponding to the current sub-block is set to true, and BDOF is used for the current sub-block.

[0193] Similarly, in practical applications, the third setting value can be set to 0. When the third setting value is set to 0, there will be no loss in coding performance.

[0194] In one embodiment, determining whether the difference block meets a set condition and obtaining a determination result includes:

[0195] When the sum of the differences within the 6x4 pixel range corresponding to the current sub-block in the difference block is equal to a third set value, a judgment result is obtained that the difference block meets the set condition; when the sum of the differences within the 6x4 pixel range corresponding to the current sub-block in the difference block is not equal to the third set value, a judgment result is obtained that the difference block does not meet the set condition.

[0196] In other words, here, when the sum of the temporal gradients of each pixel within the 6x4 pixel range corresponding to the current sub-block is equal to the third set value, the difference block is deemed to meet the set conditions, the BDOF flag corresponding to the current sub-block is set to false, and BDOF is not used for the current sub-block; when the sum of the temporal gradients of each pixel within the 6x4 pixel range corresponding to the current sub-block is not equal to the third set value, the difference block is deemed to not meet the set conditions, the BDOF flag corresponding to the current sub-block is set to true, and BDOF is used for the current sub-block.

[0197] Similarly, in practical applications, the third setting value can be set to 0. When the third setting value is set to 0, there will be no loss in coding performance.

[0198] In one embodiment, determining the difference block corresponding to the current sub-block includes:

[0199] The difference block is obtained by subtracting the corresponding pixel points in the first reference block from those in the second reference block.

[0200] Compared to obtaining the difference block based on the temporal gradient, instead of shifting the pixels of the forward and backward prediction sub-blocks to the right by shift2, we directly calculate the difference between the pixels of the forward and backward prediction sub-blocks to obtain the difference block.

[0201] In one embodiment, determining whether the difference block meets a set condition and obtaining a determination result includes:

[0202] Determine the first absolute maximum value; the first absolute maximum value is the maximum absolute value within the range of the current sub-block in the difference block; when the first absolute maximum value is less than the fourth set value, obtain the judgment result that the difference block meets the set condition; when the first absolute maximum value is greater than or equal to the fourth set value, obtain the judgment result that the difference block does not meet the set condition.

[0203] In other words, here, when the maximum absolute value within the current sub-block range of the difference block is less than the fourth set value, the difference block is deemed to meet the set conditions, the BDOF flag corresponding to the current sub-block is set to false, and BDOF is not used for the current sub-block; when the maximum absolute value within the current sub-block range of the difference block is greater than or equal to the fourth set value, the difference block is deemed to not meet the set conditions, the BDOF flag corresponding to the current sub-block is set to true, and BDOF is used for the current sub-block.

[0204] Because BDOF, in order to remove gradient noise when calculating the temporal gradient, first shifts the pixels of the forward and backward prediction sub-blocks to the right by shift2 before calculating the difference, the granularity of the temporal gradient is (shift2)^2 (i.e., 4^2 = 16). Here, however, the difference between the pixels of the forward and backward prediction sub-blocks is directly calculated to obtain the difference block. Therefore, in practical applications, the fourth setting value can be set to 16, corresponding to the third setting value. When the fourth setting value is set to 16, it will not cause a loss in coding performance.

[0205] In one embodiment, determining whether the difference block meets a set condition and obtaining a determination result includes:

[0206] Determine the second absolute maximum value; the second maximum value is the absolute maximum value within the 6x6 pixel range corresponding to the current sub-block in the difference block; when the second absolute maximum value is less than the fourth set value, obtain the judgment result that the difference block meets the set condition; when the second absolute maximum value is greater than or equal to the fourth set value, obtain the judgment result that the difference block does not meet the set condition.

[0207] In other words, here, when the maximum absolute value within the 6x6 pixel range corresponding to the current sub-block in the difference block is less than the fourth set value, the difference block is deemed to meet the set conditions, the BDOF flag corresponding to the current sub-block is set to false, and BDOF is not used for the current sub-block; when the maximum absolute value within the 6x6 pixel range corresponding to the current sub-block in the difference block is greater than or equal to the fourth set value, the difference block is deemed to not meet the set conditions, the BDOF flag corresponding to the current sub-block is set to true, and BDOF is used for the current sub-block.

[0208] Similarly, in practical applications, the fourth setting value can be set to 16. When the fourth setting value is set to 16, there will be no loss in coding performance.

[0209] It should be noted that in the embodiments related to determining whether the set conditions are met based on the difference block corresponding to the current sub-block, whether the difference block corresponding to the current sub-block is obtained based on the temporal gradient or based on the difference between the predicted sub-blocks before and after the current sub-block, the implementation of the scheme is based on the following: when the set conditions are not met, the cross-correlation parameters sGxdI and sGydI of the sub-block are both 0, so the optical flow vectors vx and vy are also both 0, and the brightness offset value bdofoffset is also 0, which is equivalent to not executing BDOF. Therefore, terminating the execution of BDOF will not affect the inter-frame prediction results, and the termination of BDOF execution is lossless.

[0210] This application provides an inter-frame prediction method, encoder, decoder, and storage medium. During inter-frame prediction in video encoding and decoding, the forward and backward motion vectors corresponding to the current block are determined. Based on these vectors, corresponding set conditions are used for judgment, and the value of the BDOF flag corresponding to the current block or at least one sub-block within the current block is set according to the judgment result. This determines whether to perform BDOF on the current block or at least one sub-block within the current block. Based on the solution provided by this application, if the current block or any sub-block within the current block does not meet the BDOF usage conditions, BDOF execution can be skipped, avoiding unnecessary calculations for the current block or sub-block that does not meet the BDOF usage conditions. This reduces the computational complexity and time consumption in the inter-frame prediction process, thereby improving the computational efficiency of inter-frame prediction during video encoding and decoding.

[0211] To implement the inter-frame prediction method of this application embodiment, this application embodiment also provides an encoder. Figure 8 This is a schematic diagram of the composition structure of the encoder 100 according to an embodiment of this application. Figure 8 As shown, the encoder 100 includes:

[0212] The first determining unit 1001 is configured to determine a first motion vector and a second motion vector of the current block; the first motion vector is the forward motion vector of the current block; and the second motion vector is the backward motion vector of the current block.

[0213] The first judgment unit 1002 is configured to determine whether a set condition is met based on the first motion vector and the second motion vector, and obtain a judgment result.

[0214] The first setting unit 1003 is configured to set the value of the BDOF flag according to the judgment result;

[0215] The first prediction unit 1004 is configured to determine the inter-frame prediction value of the current block or at least one sub-block in the current block based on the value of the BDOF flag.

[0216] In practical applications, the first determining unit 1001, the first judging unit 1002, the first setting unit 1003, and the first prediction unit 1004 can be implemented by a processor in the encoder, such as a central processing unit (CPU), a digital signal processor (DSP), a microcontroller unit (MCU), or a field-programmable gate array (FPGA).

[0217] It should be noted that the encoder 100 provided in the above embodiments is only illustrated by the division of the above-described program modules when performing inter-frame prediction. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the encoder 100 can be divided into different program modules to complete all or part of the processing described above. In addition, the encoder 100 provided in the above embodiments and the inter-frame prediction method embodiments belong to the same concept, and its specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0218] To implement the inter-frame prediction method of this application embodiment, this application embodiment also provides a decoder. Figure 9 This is a schematic diagram of the composition structure of the decoder 200 according to an embodiment of this application. As shown in the figure, the decoder 200 includes:

[0219] The second determining unit 2001 is configured to determine a first motion vector and a second motion vector of the current block; the first motion vector is the forward motion vector of the current block; and the second motion vector is the backward motion vector of the current block.

[0220] The second judgment unit 2002 is configured to determine whether a set condition is met based on the first motion vector and the second motion vector, and obtain a judgment result.

[0221] The second setting unit 2003 is configured to set the value of the BDOF flag according to the judgment result;

[0222] The second prediction unit 2004 is configured to determine the inter-frame prediction value of the current block or at least one sub-block in the current block based on the value of the BDOF flag.

[0223] In practical applications, the second determining unit 2001, the second judging unit 2002, the first setting unit 2003 and the second prediction unit 2004 can be implemented by a processor in the decoder, such as a CPU, DSP, MCU or FPGA.

[0224] It should be noted that the decoder 200 provided in the above embodiments is only illustrated by the division of the above-described program modules when performing inter-frame prediction. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the decoder 200 can be divided into different program modules to complete all or part of the processing described above. In addition, the decoder 200 provided in the above embodiments and the inter-frame prediction method embodiments belong to the same concept, and its specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0225] Based on the hardware implementation of the above program modules, and in order to implement the inter-frame prediction method of the embodiments of this application, the embodiments of this application also provide an encoder, such as... Figure 10 As shown, the encoder 100 includes:

[0226] The first communication interface 1005 is configured to receive and send signals during the process of sending and receiving information with other external network elements;

[0227] The first processor 1006 is configured to execute the methods provided by one or more of the above-described technical solutions when running a computer program. The computer program is stored in the first memory 1007.

[0228] Specifically, when the first processor 1006 runs a computer program, it executes:

[0229] Determine the first motion vector and the second motion vector of the current block; the first motion vector is the forward motion vector of the current block; the second motion vector is the backward motion vector of the current block.

[0230] Based on the first motion vector and the second motion vector, determine whether the set conditions are met, and obtain the judgment result;

[0231] Set the value of the BDOF flag based on the judgment result;

[0232] Based on the value of the BDOF flag, the inter-frame prediction value of the current block or at least one sub-block in the current block is determined.

[0233] Of course, in practical applications, the various components in encoder 100 are coupled together via bus system 1008. It can be understood that bus system 1008 is used to implement communication between these components. In addition to a data bus, bus system 1008 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 10 The general labeled all buses as Bus System 1008.

[0234] The first memory 1007 in this embodiment is used to store various types of data to support the operation of the encoder 100. Examples of such data include any computer program used to operate on the encoder 100.

[0235] The methods disclosed in the above embodiments of this application can be applied to the first processor 1006, or implemented by the first processor 1006. The first processor 1006 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware or by instructions in the form of software in the first processor 1006. The first processor 1006 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The first processor 1006 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, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in the first memory 1007. The first processor 1006 reads the information in the first memory 1007 and completes the steps of the aforementioned method in combination with its hardware.

[0236] Based on the hardware implementation of the above program modules, and in order to implement the inter-frame prediction method of this application embodiment, this application embodiment also provides a decoder, such as... Figure 11 As shown, the decoder 200 includes:

[0237] The second communication interface 2005 is configured to receive and send signals during the process of sending and receiving information with other external network elements;

[0238] The second processor 2006 is configured to execute the methods provided by one or more of the above-described technical solutions when running a computer program. The computer program is stored in the second memory 2007.

[0239] Specifically, when the second processor 2006 runs a computer program, it executes:

[0240] Determine the first motion vector and the second motion vector of the current block; the first motion vector is the forward motion vector of the current block; the second motion vector is the backward motion vector of the current block.

[0241] Based on the first motion vector and the second motion vector, determine whether the set conditions are met, and obtain the judgment result;

[0242] Set the value of the BDOF flag based on the judgment result;

[0243] Based on the value of the BDOF flag, the inter-frame prediction value of the current block or at least one sub-block in the current block is determined.

[0244] Of course, in practical applications, the various components in decoder 200 are coupled together via bus system 2008. It can be understood that bus system 2008 is used to implement communication between these components. In addition to the data bus, bus system 2008 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 11 The general labeled all buses as Bus System 2008.

[0245] The second memory 2007 in this embodiment is used to store various types of data to support the operation of the decoder 200. Examples of such data include any computer program used to operate on the decoder 200.

[0246] The methods disclosed in the embodiments of this application can be applied to the second processor 2006, or implemented by the second processor 2006. The second processor 2006 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware or by instructions in the form of software in the second processor 2006. The second processor 2006 may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The second processor 2006 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, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as being executed by a hardware decoding processor, or being executed by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, which is located in the second memory 2007. The second processor 2006 reads the information in the second memory 2007 and completes the steps of the aforementioned method in conjunction with its hardware.

[0247] In an exemplary embodiment, the encoder 100 or decoder 200 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.

[0248] It is understood that the first memory 1007 or the second memory 2007 in the embodiments of this application can be volatile memory or non-volatile memory, or both. 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), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); the magnetic surface memory can be disk storage or magnetic tape storage. 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), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memories.

[0249] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium. For example, it may include a first memory 1007 storing a computer program, which can be executed by a first processor 1006 of the encoder 100 to complete the steps described in the aforementioned inter-frame prediction method applied to the encoder. It may also include a second memory 2007 storing a computer program, which can be executed by a second processor 2006 of the decoder 200 to complete the steps described in the aforementioned inter-frame prediction method applied to the decoder. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.

[0250] 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.

[0251] It should be noted that the terms "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0252] 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.

[0253] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.

[0254] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes 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.

Claims

1. An inter-frame prediction method applied to an encoder, the method comprising: Determine the first and second motion vectors of the current block; The first motion vector is the forward motion vector of the current block; The second motion vector is the backward motion vector of the current block; Based on whether the first motion vector and the second motion vector are in the same direction, the value of the bidirectional optical flow prediction (BDOF) flag is set. Specifically, when the first motion vector and the second motion vector point in different directions, the BDOF flag corresponding to the current block is set to a first preset value; when the first motion vector and the second motion vector point in the same direction, the BDOF flag corresponding to the current block is set to a second preset value; or... Based on whether the difference block corresponding to the current sub-block meets the set conditions, the value of the BDOF flag is set. The difference block is determined based on the corresponding pixel in the first reference block pointed to by the first motion vector and the corresponding pixel in the second reference block pointed to by the second motion vector. The set conditions include one of the following: the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is a third set value; the sum of the temporal gradients corresponding to each pixel in the current sub-block is the third set value; or, the maximum absolute value within the range of the current sub-block in the difference block is less than a fourth set value. Based on the value of the BDOF flag, the inter-frame prediction value of the current block or at least one sub-block in the current block is determined.

2. The method according to claim 1, wherein determining the first motion vector and the second motion vector of the current block comprises: Motion estimation is performed on the current block to determine the first motion vector and the second motion vector of the current block.

3. The method according to claim 1 or 2, wherein, When the value of the BDOF flag corresponding to the current block is the first set value, the BDOF flag corresponding to the current block is set to true; when the value of the BDOF flag corresponding to the current block is the second set value, the BDOF flag corresponding to the current block is set to false.

4. The method according to claim 1, wherein when setting the value of the bidirectional optical flow prediction (BDOF) flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: Based on the horizontal and vertical components of the first motion vector, and the horizontal and vertical components of the second motion vector, determine whether the first and second motion vectors point in the same direction.

5. The method according to claim 4, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector; The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The first symbol value, the second symbol value, the third symbol value, and the fourth symbol value are all equal to 0; The first symbol value is different from the third symbol value, and the second symbol value is different from the fourth symbol value; The first symbol value and the third symbol value are both equal to 0, and the second symbol value is different from the fourth symbol value; The first symbol value is different from the third symbol value, and the second symbol value and the fourth symbol value are both equal to 0.

6. The method according to claim 4, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector; The first motion vector and the second motion vector are determined to point in different directions when all of the following conditions are met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The product of the first symbol value and the third symbol value is less than or equal to 0; The product of the second symbol value and the fourth symbol value is less than or equal to 0.

7. The method according to claim 4, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The horizontal component, vertical component, horizontal component, and vertical component of the first motion vector are all equal to 0. The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is not equal to the vertical component of the second motion vector. The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is equal to 0. The horizontal components of the first motion vector and the second motion vector are both equal to 0, and the vertical components of the first motion vector and the second motion vector are not equal.

8. The method according to claim 4, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: The first motion vector and the second motion vector are determined to have different directions when all of the following conditions are met; If any of the following conditions are not met, the first motion vector and the second motion vector are determined to point in the same direction: The product of the horizontal component of the first motion vector and the horizontal component of the second motion vector is less than or equal to 0; The product of the vertical component of the first motion vector and the vertical component of the second motion vector is less than or equal to 0.

9. The method according to claim 1, wherein when setting the value of the bidirectional optical flow prediction (BDOF) flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: When the first motion vector is opposite to the second motion vector, it is determined that the first motion vector and the second motion vector point in different directions; When the first motion vector and the second motion vector are not opposite, it is determined that the first motion vector and the second motion vector point in the same direction.

10. The method according to claim 9, further comprising: Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector; When the first symbol value is not equal to the third symbol value, and the second symbol value is not equal to the third symbol value, the first motion vector is opposite to the second motion vector.

11. The method according to claim 9, further comprising: When either the first motion vector or the second motion vector is 0, the first motion vector is opposite to the second motion vector.

12. The method according to claim 11, further comprising: Determine the angle between the first motion vector and the second motion vector; Taking the direction of the first motion vector as the 0-degree direction, when the included angle is within a first predetermined range, the first motion vector is opposite to the second motion vector; wherein, The lower limit of the first set range is greater than 90 degrees; the upper limit of the first set range is less than 270 degrees.

13. The method according to claim 9, 10, or 12, wherein when setting the value of the bidirectional optical flow prediction (BDOF) flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: When the first motion vector is opposite to the second motion vector, and the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition, it is determined that the first motion vector and the second motion vector have different directions; When the first motion vector and the second motion vector are not opposite, or when the amplitude of the first motion vector and the amplitude of the second motion vector do not satisfy the first amplitude condition, it is determined that the first motion vector and the second motion vector point in the same direction.

14. The method according to claim 13, further comprising: When the amplitude of the first motion vector is equal to the amplitude of the second motion vector, it is determined that the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition.

15. The method according to claim 13, further comprising: When the first amplitude ratio is within a second preset range, it is determined that the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition; wherein, The first amplitude ratio is determined based on the amplitude of the first motion vector and the amplitude of the second motion vector.

16. The method according to claim 15, further comprising: The first amplitude ratio is determined based on the ratio of the first amplitude to the second amplitude. When the first amplitude ratio is less than or equal to the first set ratio, it is determined that the first amplitude ratio is within the second set range; Wherein, the first amplitude is the larger of the amplitude of the first motion vector and the amplitude of the second motion vector; the second amplitude is the smaller of the amplitude of the first motion vector and the amplitude of the second motion vector; and the first set ratio is a real number greater than 1.

17. The method according to claim 16, wherein the first set ratio is equal to 2.

18. The method according to claim 1, wherein when setting the value of the bidirectional optical flow prediction (BDOF) flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: Determine the sum vector of the first motion vector and the second motion vector; The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The horizontal and vertical components of the sum vector are both equal to 0; The magnitude of the sum vector is less than the first set magnitude; The second amplitude ratio is less than the second set ratio; The second amplitude ratio is the ratio of the amplitude of the sum vector to the second amplitude; The second amplitude is the smaller value between the amplitude of the first motion vector and the amplitude of the second motion vector; The ratio of the magnitude of the sum vector to the third magnitude is less than the third predetermined ratio; The third amplitude is the sum of the amplitudes of the first motion vector and the second motion vector; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the magnitude of the sum vector is less than the second set magnitude; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the second amplitude ratio is less than the fourth set ratio; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the ratio of the magnitude of the sum vector to the third magnitude is less than the fifth set ratio.

19. The method according to claim 5, 6, or 10, further comprising: The sign value is determined based on the value of the corresponding component; where, When the value of the corresponding component is greater than 0, the corresponding sign value is determined to be 1; When the value of the corresponding component is equal to 0, the corresponding sign value is determined to be 0; When the value of the corresponding component is less than 0, the corresponding sign value is determined to be -1.

20. The method according to claim 1 or 2, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions includes: When it is determined that the difference block meets the set condition, the value of the BDOF flag corresponding to the current sub-block is set to the first set value; When it is determined that the difference block does not meet the set condition, the value of the BDOF flag corresponding to the current sub-block is set to a second set value; wherein, When the value of the BDOF flag corresponding to the current sub-block is the first preset value, the BDOF flag corresponding to the current sub-block is set to true; when the value of the BDOF flag corresponding to the current sub-block is the second preset value, the BDOF flag corresponding to the current sub-block is set to false.

21. The method according to claim 20, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: The difference block is determined based on the temporal gradient corresponding to the pixels in the current sub-block.

22. The method according to claim 21, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the first maximum value; The first maximum value is the maximum value within the range of the current sub-block in the difference block; When the first maximum value is the third set value, a judgment result is obtained that the difference block satisfies the set condition; When the first maximum value is not the third set value, a judgment result is obtained that the difference block does not meet the set condition.

23. The method according to claim 21, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the second maximum value; The second maximum value is the maximum value within a 6x4 pixel range corresponding to the current sub-block in the difference block; When the second maximum value is the third set value, a judgment result is obtained that the difference block satisfies the set condition; When the second maximum value is not the third set value, a judgment result is obtained that the difference block does not meet the set condition.

24. The method according to claim 21, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: When the sum of the differences within the current sub-block range of the difference block is equal to the third set value, a judgment result is obtained that the difference block satisfies the set condition; When the sum of the differences within the current sub-block range of the difference block is not equal to the third set value, a judgment result is obtained that the difference block does not meet the set condition.

25. The method according to claim 21, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: When the sum of the differences within the 6x4 pixel range corresponding to the current sub-block in the difference block is equal to the third set value, a judgment result is obtained that the difference block satisfies the set condition; When the sum of the differences within the 6x4 pixel range corresponding to the current sub-block in the difference block is not equal to the third set value, a judgment result is obtained that the difference block does not meet the set condition.

26. The method according to any one of claims 22 to 25, wherein the third set value is 0.

27. The method according to claim 20, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: The difference block is obtained by subtracting the corresponding pixel points in the first reference block from those in the second reference block.

28. The method according to claim 27, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the maximum value of the first absolute value; The first maximum absolute value is the maximum absolute value within the range of the current sub-block in the difference block; When the maximum value of the first absolute value is less than the fourth set value, the judgment result that the difference block satisfies the set condition is obtained; When the maximum value of the first absolute value is greater than or equal to the fourth set value, a judgment result is obtained that the difference block does not meet the set condition.

29. The method according to claim 27, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the maximum value of the second absolute value; The second maximum absolute value is the maximum absolute value within the 6x6 pixel range corresponding to the current sub-block in the difference block; When the maximum value of the second absolute value is less than the fourth set value, the judgment result that the difference block satisfies the set condition is obtained; When the maximum value of the second absolute value is greater than or equal to the fourth set value, a judgment result is obtained that the difference block does not meet the set condition.

30. The method according to claim 28 or 29, wherein the fourth setting value is 16.

31. An inter-frame prediction method applied to a decoder, the method comprising: Determine the first and second motion vectors of the current block; The first motion vector is the forward motion vector of the current block; The second motion vector is the backward motion vector of the current block; Based on whether the first motion vector and the second motion vector are in the same direction, the value of the BDOF flag is set. Specifically, when the first motion vector and the second motion vector point in different directions, the value of the BDOF flag corresponding to the current block is set to a first preset value; when the first motion vector and the second motion vector point in the same direction, the value of the BDOF flag corresponding to the current block is set to a second preset value; or... Based on whether the difference block corresponding to the current sub-block meets the set conditions, the value of the BDOF flag is set. The difference block is determined based on the corresponding pixel in the first reference block pointed to by the first motion vector and the corresponding pixel in the second reference block pointed to by the second motion vector. The set conditions include one of the following: the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is a third set value; the sum of the temporal gradients corresponding to each pixel in the current sub-block is the third set value; or, the maximum absolute value within the range of the current sub-block in the difference block is less than a fourth set value. Based on the value of the BDOF flag, the inter-frame prediction value of the current block or at least one sub-block in the current block is determined.

32. The method according to claim 31, wherein determining the first motion vector and the second motion vector of the current block comprises: Parse the video stream to obtain the motion information index of the current block in the Merges fusion mode; Based on the motion information index, select the corresponding motion information from the candidate list of motion information corresponding to the current block; The first motion vector and the second motion vector are determined from the selected motion information.

33. The method according to claim 31 or 32, wherein, The step of determining the inter-frame prediction value of the current block or at least one sub-block within the current block based on the value of the BDOF flag includes: When the value of the BDOF flag corresponding to the current block is the first set value, the inter-frame prediction value of the current block is determined based on BDOF. When the BDOF flag corresponding to the current block is set to the second set value, the inter-frame prediction value of the current block is determined based on the first motion vector and the second motion vector.

34. The method according to claim 31, wherein when setting the value of the BDOF flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: Based on the horizontal and vertical components of the first motion vector, and the horizontal and vertical components of the second motion vector, determine whether the first and second motion vectors point in the same direction.

35. The method according to claim 34, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector; The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The first symbol value, the second symbol value, the third symbol value, and the fourth symbol value are all 0; The first symbol value is different from the third symbol value, and the second symbol value is different from the fourth symbol value; The first symbol value and the third symbol value are both equal to 0, and the second symbol value is different from the fourth symbol value; The first symbol value is different from the third symbol value, and the second symbol value and the fourth symbol value are both equal to 0.

36. The method according to claim 34, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector; The first motion vector and the second motion vector are determined to point in different directions when all of the following conditions are met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The product of the first symbol value and the third symbol value is less than or equal to 0; The product of the second symbol value and the fourth symbol value is less than or equal to 0.

37. The method according to claim 34, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The horizontal component, vertical component, horizontal component, and vertical component of the first motion vector are all equal to 0. The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is not equal to the vertical component of the second motion vector. The horizontal component of the first motion vector is not equal to the horizontal component of the second motion vector, and the vertical component of the first motion vector is equal to 0. The horizontal components of the first motion vector and the second motion vector are both equal to 0, and the vertical components of the first motion vector and the second motion vector are not equal.

38. The method according to claim 34, wherein determining whether the directions of the first motion vector and the second motion vector are the same based on the horizontal component and the vertical component of the first motion vector, and the horizontal component and the vertical component of the second motion vector, comprises: The first motion vector and the second motion vector are determined to have different directions when all of the following conditions are met; If any of the following conditions are not met, the first motion vector and the second motion vector are determined to point in the same direction: The product of the horizontal component of the first motion vector and the horizontal component of the second motion vector is less than or equal to 0; The product of the vertical component of the first motion vector and the vertical component of the second motion vector is less than or equal to 0.

39. The method according to claim 31, wherein when setting the value of the BDOF flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: When the first motion vector is opposite to the second motion vector, it is determined that the first motion vector and the second motion vector point in different directions; When the first motion vector and the second motion vector are not opposite, it is determined that the first motion vector and the second motion vector point in the same direction.

40. The method according to claim 39, further comprising: Determine the first sign value of the horizontal component of the first motion vector, the second sign value of the vertical component of the first motion vector, the third sign value of the horizontal component of the second motion vector, and the fourth sign value of the second motion vector; When the first symbol value is not equal to the third symbol value, and the second symbol value is not equal to the third symbol value, the first motion vector is opposite to the second motion vector.

41. The method according to claim 39, further comprising: When either the first motion vector or the second motion vector is 0, the first motion vector is opposite to the second motion vector.

42. The method according to claim 41, further comprising: Determine the angle between the first motion vector and the second motion vector; Taking the direction of the first motion vector as the 0-degree direction, when the included angle is within a first predetermined range, the first motion vector is opposite to the second motion vector; wherein, The lower limit of the first set range is greater than 90 degrees; the upper limit of the first set range is less than 270 degrees.

43. The method according to claim 39, 40, or 42, wherein when setting the value of the BDOF flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: When the first motion vector is opposite to the second motion vector, and the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition, it is determined that the first motion vector and the second motion vector have different directions; When the first motion vector and the second motion vector are not opposite, or when the amplitude of the first motion vector and the amplitude of the second motion vector do not satisfy the first amplitude condition, it is determined that the first motion vector and the second motion vector point in the same direction.

44. The method according to claim 43, further comprising: When the amplitude of the first motion vector is equal to the amplitude of the second motion vector, it is determined that the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition.

45. The method according to claim 43, further comprising: When the first amplitude ratio is within a second preset range, it is determined that the amplitude of the first motion vector and the amplitude of the second motion vector satisfy the first amplitude condition; wherein, The first amplitude ratio is determined based on the amplitude of the first motion vector and the amplitude of the second motion vector.

46. ​​The method according to claim 45, further comprising: The first amplitude ratio is determined based on the ratio of the first amplitude to the second amplitude. When the first amplitude ratio is less than or equal to the first set ratio, it is determined that the first amplitude ratio is within the second set range; Wherein, the first amplitude is the larger of the amplitude of the first motion vector and the amplitude of the second motion vector; the second amplitude is the smaller of the amplitude of the first motion vector and the amplitude of the second motion vector; and the first set ratio is a real number greater than 1.

47. The method according to claim 46, wherein the first set ratio is equal to 2.

48. The method according to claim 31, wherein when setting the value of the BDOF flag based on whether the first motion vector and the second motion vector are in the same direction, the method includes: Determine the sum vector of the first motion vector and the second motion vector; The first motion vector and the second motion vector are determined to point in different directions when one of the following conditions is met; the first motion vector and the second motion vector are determined to point in the same direction when none of the following conditions are met: The horizontal and vertical components of the sum vector are both equal to 0; The magnitude of the sum vector is less than the first set magnitude; The second amplitude ratio is less than the second set ratio; The second amplitude ratio is the ratio of the amplitude of the sum vector to the second amplitude; The second amplitude is the smaller value between the amplitude of the first motion vector and the amplitude of the second motion vector; The ratio of the magnitude of the sum vector to the third magnitude is less than the third predetermined ratio; The third amplitude is the sum of the amplitudes of the first motion vector and the second motion vector; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the magnitude of the sum vector is less than the second set magnitude; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the second amplitude ratio is less than the fourth set ratio; The direction of the sum vector is the same as the direction of the first motion vector or the direction of the second motion vector, and the ratio of the magnitude of the sum vector to the third magnitude is less than the fifth set ratio.

49. The method according to claim 35, 36, or 40, further comprising: The sign value is determined based on the value of the corresponding component; where, When the value of the corresponding component is greater than 0, the corresponding sign value is determined to be 1; When the value of the corresponding component is equal to 0, the corresponding sign value is determined to be 0; When the value of the corresponding component is less than 0, the corresponding sign value is determined to be -1.

50. The method according to claim 31 or 32, wherein, The step of determining the inter-frame prediction value of the current block or at least one sub-block within the current block based on the value of the BDOF flag includes: When the value of the BDOF flag corresponding to the current sub-block is the first set value, the inter-frame prediction value of the current sub-block is determined based on BDOF. When the BDOF flag corresponding to the current sub-block is set to the second set value, the inter-frame prediction value of the current sub-block is determined based on the first motion vector and the second motion vector.

51. The method according to claim 50, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: The difference block is determined based on the temporal gradient corresponding to the pixels in the current sub-block.

52. The method according to claim 51, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the first maximum value; The first maximum value is the maximum value within the range of the current sub-block in the difference block; When the judgment result indicates that the first maximum value is the third set value, the value of the BDOF flag corresponding to the current sub-block is set to the second set value.

53. The method according to claim 51, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the second maximum value; The second maximum value is the maximum value within a 6x4 pixel range corresponding to the current sub-block in the difference block; When the judgment result indicates that the second maximum value is the third set value, the value of the BDOF flag corresponding to the current sub-block is set to the second set value.

54. The method according to claim 51, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: When the judgment result indicates that the sum of the differences within the current sub-block range in the difference block is equal to the third set value, the value of the BDOF flag corresponding to the current sub-block is set to the second set value.

55. The method according to claim 51, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: When the judgment result indicates that the sum of the differences within the 6x4 pixel range corresponding to the current sub-block in the difference block is the third set value, the value of the BDOF flag corresponding to the current sub-block is set to the second set value.

56. The method according to any one of claims 52 to 55, wherein the third set value is 0.

57. The method according to claim 50, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions includes: The difference block is obtained by subtracting the corresponding pixel points in the first reference block from those in the second reference block.

58. The method according to claim 57, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the maximum value of the first absolute value; The first maximum absolute value is the maximum absolute value within the range of the current sub-block in the difference block; When the judgment result indicates that the maximum value of the first absolute value is less than the fourth set value, the value of the BDOF flag corresponding to the current sub-block is set to the second set value.

59. The method according to claim 57, wherein setting the value of the BDOF flag based on whether the difference block corresponding to the current sub-block satisfies the set conditions, further includes: Determine the maximum value of the second absolute value; The second maximum absolute value is the maximum absolute value within the 6x6 pixel range corresponding to the current sub-block in the difference block; When the judgment result indicates that the maximum value of the second absolute value is less than the fourth set value, the value of the BDOF flag corresponding to the current sub-block is set to the second set value.

60. The method according to claim 58 or 59, wherein the fourth setting value is 16.

61. An encoder, comprising: The first determining unit is configured to determine the first motion vector and the second motion vector of the current block; The first motion vector is the forward motion vector of the current block; The second motion vector is the backward motion vector of the current block; The first setting unit is configured to set the value of the BDOF flag based on whether the first motion vector and the second motion vector are in the same direction. Specifically, when the first motion vector and the second motion vector point in different directions, the value of the BDOF flag corresponding to the current block is set to a first preset value; when the first motion vector and the second motion vector point in the same direction, the value of the BDOF flag corresponding to the current block is set to a second preset value. Alternatively, the value of the BDOF flag is set based on whether the difference block corresponding to the current sub-block meets a set condition. The difference block is determined based on the corresponding pixel in the first reference block pointed to by the first motion vector and the corresponding pixel in the second reference block pointed to by the second motion vector. The set condition includes one of the following: the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is a third preset value; the sum of the temporal gradients corresponding to each pixel in the current sub-block is the third preset value; or, the maximum absolute value within the range of the current sub-block in the difference block is less than a fourth preset value. The first prediction unit is configured to determine the inter-frame prediction value of the current block or at least one sub-block in the current block based on the value of the BDOF flag.

62. A decoder, comprising: The second determining unit is configured to determine the first motion vector and the second motion vector of the current block; The first motion vector is the forward motion vector of the current block; The second motion vector is the backward motion vector of the current block; The second setting unit is configured to set the value of the BDOF flag based on whether the first motion vector and the second motion vector are in the same direction. Specifically, when the first motion vector and the second motion vector point in different directions, the value of the BDOF flag corresponding to the current block is set to a first preset value; when the first motion vector and the second motion vector point in the same direction, the value of the BDOF flag corresponding to the current block is set to a second preset value. Alternatively, the value of the BDOF flag is set based on whether the difference block corresponding to the current sub-block meets a set condition. The difference block is determined based on the corresponding pixel in the first reference block pointed to by the first motion vector and the corresponding pixel in the second reference block pointed to by the second motion vector. The set condition includes one of the following: the maximum value of the temporal gradient corresponding to each pixel in the current sub-block is a third preset value; the sum of the temporal gradients corresponding to each pixel in the current sub-block is the third preset value; or, the maximum absolute value within the current sub-block range of the difference block is less than a fourth preset value. The second prediction unit is configured to determine the inter-frame prediction value of the current block or at least one sub-block in the current block based on the value of the BDOF flag.

63. An encoder, comprising: A first processor and a first memory for storing computer programs capable of running on the processor. Wherein, when the first processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 30.

64. A decoder, comprising: A second processor and a second memory for storing computer programs that can run on the processor. Wherein, when the second processor is used to run the computer program, it performs the steps of the method according to any one of claims 31 to 60.

65. A storage medium having a computer program stored thereon, said computer program, when executed by a processor, implementing the steps of the method according to any one of claims 1 to 30; or, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 31 to 60.

Citation Information

Patent Citations

  • A BI-directional optical flow method with simplified gradient derivation

    WO2019195643A1