Encoding and decoding method, apparatus and device

The method enhances video coding by adjusting motion vectors for bidirectional blocks using weighted reference pictures, improving prediction quality and efficiency in video encoding and decoding processes.

JP2025186536AActive Publication Date: 2025-12-23HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2025165735
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Priority Date
2019-11-05
Filing Date
2025-10-01
Publication Date
2025-12-23
Estimated Expiration
2040-10-28

AI Technical Summary

Technical Problem

Existing video coding technologies face challenges in adjusting motion vectors for bidirectional blocks, leading to low prediction quality and prediction errors, which affect encoding performance.

Method used

A method and device that activate a motion vector adjustment mode for bidirectional blocks, using weighted reference blocks from two short-term reference pictures to determine target motion vectors, ensuring the same weighting and size conditions are met, and performing motion compensation.

Benefits of technology

Improves coding performance and efficiency by addressing low prediction quality and errors in bidirectional blocks through targeted motion vector adjustment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2025186536000001_ABST
    Figure 2025186536000001_ABST
Patent Text Reader

Abstract

To provide an encoding and decoding method, apparatus and device for improving encoding performance.SOLUTION: A decoding method includes the steps of determining, for each subblock among at least one subblock included in the current block, a first reference block on the basis of a first original motion vector of the subblock and a second reference block on the basis of a second original motion vector of the subblock when it is determined to use a motion vector adjustment mode for a current block, adjusting the first original motion vector and the second original motion vector to obtain a first target motion vector and a second target motion vector, determining a predicted value of the subblock on the basis of the first target motion vector and the second target motion vector, and determining a predicted value of the current block on the basis of the predicted values of all the subblocks.SELECTED DRAWING: Figure 4
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates to the field of encoding and decoding, and in particular to an encoding and decoding method, apparatus and device. [Background technology]

[0002] To achieve the purpose of saving space, all video images are coded before transmission, and a complete video coding method may include processes such as prediction, transformation, quantization, entropy coding, and filtering. Predictive coding includes intra coding and inter coding. Inter coding utilizes video temporal correlation to predict pixels of a current image using pixels of neighboring coded images, thereby achieving the purpose of effectively eliminating redundancy in the temporal domain of video. In inter coding, a motion vector (MV) can be used to represent the relative displacement between a current block of a current picture and a reference block of a reference picture. For example, if current picture A and reference picture B have a high temporal correlation and a current block A1 of current picture A needs to be transmitted, a motion search is performed in reference picture B to find a block B1 (i.e., a reference block) that best matches the current block A1, and the relative displacement between the current block A1 and the reference block B1 is determined, and the relative displacement is the motion vector of the current block A1. The encoding side does not send the current block A1 to the decoding side, but sends the motion vector to the decoding side, and the decoding side can obtain the current block A1 based on the motion vector and the reference block B1. Obviously, the number of bits occupied by the motion vector is smaller than the number of bits occupied by the current block A1, so a large amount of bits can be saved.

[0003] In related technology, when a current block is a unidirectional block, a motion vector of the current block (hereinafter referred to as an original motion vector) is obtained, and then the original motion vector is adjusted, and encoding / decoding can be performed based on the adjusted motion vector, thereby improving encoding performance. However, when the current block is a bidirectional block, after obtaining the first and second original motion vectors of the current block, there is currently no reasonable solution for, for example, how to adjust the first and second original motion vectors. That is, in scenes with bidirectional blocks, there are problems such as low prediction quality and prediction error, resulting in reduced encoding performance. Summary of the Invention

[0004] The present invention provides an encoding and decoding method, apparatus and device, which can improve the encoding performance.

[0005] The present invention provides an encoding and decoding method, the method comprising: As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are satisfied; If it is determined to activate the motion vector adjustment mode for the current block, performing motion compensation for the current block.

[0006] The present invention provides an encoding and decoding device, said device comprising: As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. a determining module for determining to activate a motion vector adjustment mode for the current block if the sizes of the two reference pictures of the current block are both the same as the size of the current picture; and a motion compensation module for performing motion compensation on the current block when it is determined to activate the motion vector adjustment mode for the current block.

[0007] The present invention provides a coding device, comprising a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor; The processor is used to execute machine-executable instructions to implement the following steps: As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are satisfied; performing motion compensation on the current block if it is determined to activate the motion vector adjustment mode for the current block;

[0008] The present invention provides a decoding device, comprising a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor; The processor is used to execute machine-executable instructions to implement the following steps: As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are satisfied; performing motion compensation on the current block if it is determined to activate the motion vector adjustment mode for the current block; [Effects of the Invention]

[0009] As can be seen from the above technical solutions, in an embodiment of the present invention, when it is determined to activate the motion vector adjustment mode for the current block, instead of determining a predicted value based on the first original motion vector and the second original motion vector, a first target motion vector and a second target motion vector are obtained based on the first original motion vector and the second original motion vector, and a predicted value is determined based on the first target motion vector and the second target motion vector, thereby solving problems such as low prediction quality and prediction error, and improving coding performance and coding efficiency. [Brief explanation of the drawings]

[0010] [Figure 1A] FIG. 2 is a schematic diagram of interpolation in one embodiment of the present invention. [Figure 1B] 1 is a schematic diagram of a video encoding framework in one embodiment of the present invention; [Figure 2] 1 is a flowchart of an encoding and decoding method according to an embodiment of the present invention. [Figure 3] 1 is a flowchart of an encoding and decoding method according to an embodiment of the present invention. [Figure 4] 1 is a flowchart of an encoding and decoding method according to an embodiment of the present invention. [Figure 5] FIG. 2 is a schematic diagram of a reference block obtained in one embodiment of the present invention; [Figure 6] FIG. 2 is a schematic diagram of motion vector repetition in one embodiment of the present invention; [Figure 7A] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 7B] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 7C] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 7D] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 7E] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 7F] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 7G] FIG. 10 is a schematic diagram of the ordering of candidate points in one embodiment of the present invention; [Figure 8] FIG. 10 is a schematic diagram illustrating extending a reference block according to an embodiment of the present invention. [Figure 9A] 1 is a structural diagram of an encoding and decoding device according to an embodiment of the present invention; [Figure 9B] FIG. 2 is a diagram illustrating the hardware architecture of a decoding device according to an embodiment of the present invention. [Figure 9C] FIG. 2 is a diagram illustrating the hardware architecture of an encoding device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE INVENTION

[0011] The terms used in the embodiments of the present invention are not intended to limit the embodiments of the present invention but are used only to describe particular embodiments. As used in the embodiments and claims of the present application, the singular forms "a," "an," "described," and "this" are intended to include the plural forms unless the context clearly dictates otherwise. The term "and / or" as used herein should also be understood to mean any or all possible combinations including one or more of the associated listed items. In the embodiments of the present invention, the terms "first," "second," and "third" may be used to describe various pieces of information, but it should be understood that such information should not be limited to these terms. These terms are used only to distinguish between pieces of information of the same type. For example, first information may be referred to as second information, and similarly, second information may be referred to as first information, without departing from the scope of the present application. Depending on the context, the word "if" may be interpreted as "when," "if," or "in response to."

[0012] Embodiments of the present invention provide encoding and decoding methods, apparatus and devices, and relate to the following concepts:

[0013] Intra prediction and inter prediction techniques: Intra prediction (within a frame) utilizes the spatial domain correlation of video to predict current pixels using pixels of coded blocks of the current image, thereby achieving the goal of eliminating redundancy in the spatial domain of video. Inter prediction (between frames) utilizes the temporal domain correlation of video to predict pixels of the current image using pixels of neighboring coded images, since video sequences usually have higher temporal domain correlation, thereby achieving the goal of effectively eliminating redundancy in the temporal domain of video. The inter prediction part of major video coding standards uses block-based motion compensation technology, the main principle of which is to search for a best-matching block in the previous coded image for each pixel block of the current image, a process called motion estimation.

[0014] Motion Vector (MV): In inter-coding, a motion vector is used to represent the relative displacement between a current block and its best-matching block in a reference picture. A corresponding motion vector is transmitted to the decoder for each divided block. The motion vector for each block is coded and transmitted independently, consuming a significant number of bits, especially when the block is divided into small blocks. To reduce the number of bits required to code a motion vector, the spatial relationship between neighboring image blocks is used to predict the motion vector of the current block based on the motion vector of a neighboring coded block, and then the predicted difference is coded, thereby effectively reducing the number of bits required to represent the motion vector. When coding the motion vector of the current block, the motion vector of the current block is predicted using the motion vector of a neighboring coded block, and the difference between the predicted value of the motion vector (MVP, Motion Vector Prediction) and the actual estimated value of the motion vector (MVD, Motion Vector Difference) is coded, thereby effectively reducing the number of coding bits.

[0015] Motion Information: A motion vector represents the position offset of a current block relative to a reference block. Therefore, in order to accurately obtain information about the image block toward which it points, in addition to the motion vector, reference picture index information is required to indicate which reference picture to use. A reference picture list is created for the image of the current picture, and reference picture index information indicates which reference picture in the reference picture list the current block uses. Many coding techniques also support multiple reference picture lists, and therefore can use one index value called a reference direction to indicate which reference picture list to use. Information related to motion, such as a motion vector, reference picture index, and reference direction, is called motion information.

[0016] Interpolation: If the current motion vector has non-integer pixel accuracy, we cannot directly copy the existing pixel values ​​from the reference picture corresponding to the current block. Instead, we can only obtain the required pixel values ​​of the current block through interpolation. As shown in Figure 1A, the pixel value Y 1 / 2 If it is necessary to obtain a pixel value X, it can be obtained by interpolating the surrounding existing pixel value X. For example, if an interpolation filter with N taps is used, it is necessary to interpolate N surrounding integer pixels to obtain the pixel value X.

[0017] Motion compensation: Motion compensation is the process of obtaining all pixel values ​​of the current block by interpolating or copying.

[0018] Merge mode: Includes normal fusion mode (i.e., normal merge mode, also called regular merge mode), subblock fusion mode (fusion mode using subblock motion information, also called subblock fusion mode), MMVD mode (fusion mode that encodes motion differentials, also called merge with MVD mode), CIIP mode (fusion mode that combines inter-intra predictions to generate a new prediction value, also called combine inter intra prediciton mode), TPM mode (fusion mode for triangular prediction, also called triangular prediction mode), and GEO mode (fusion mode based on an arbitrary geometric partitioning shape, also called geometrical partitioning).

[0019] Skip mode: Skip mode is a special fusion mode. The difference between skip mode and fusion mode is that skip mode does not require coding of residuals. If the current block is in skip mode, CIIP mode is off by default, but normal fusion mode, sub-block fusion mode, MMVD mode, TPM mode, and GEO mode are still applicable.

[0020] For example, how to generate a prediction value is determined based on a normal fusion mode, a sub-block fusion mode, an MMVD mode, a CIIP mode, a TPM mode, a GEO mode, etc. After generating a prediction value, in a fusion mode, a reconstructed value can be obtained using the prediction value and a residual. In a skip mode, there is no residual, and a reconstructed value is obtained directly using the prediction value.

[0021] Sequence Parameter Set (SPS): A sequence parameter set contains a flag that determines whether a tool is allowed to be enabled or disabled in the entire sequence. If the flag has a value of 1, the tool corresponding to the flag is allowed to be enabled in the video sequence; if the flag has a value of 0, the tool corresponding to the flag is not allowed to be enabled in the encoding process in the video sequence.

[0022] Normal fusion mode: Select one motion information from the candidate motion information list, and generate a prediction value for the current block based on the motion information. The candidate motion information list includes motion information for block candidates that are adjacent in the spatial domain, motion information for block candidates that are adjacent in the temporal domain, motion information for block candidates that are not adjacent in the spatial domain, motion information obtained by combining existing motion information, default motion information, etc.

[0023] MMVD mode: Based on the candidate motion information list of the normal fusion mode, select one motion information from the candidate motion information list of the normal fusion mode as the reference motion information, obtain the motion information difference through a table lookup method, obtain the final motion information based on the reference motion information and the motion information difference, and generate a prediction value for the current block based on the final motion information.

[0024] CIIP mode: Intra prediction and inter prediction are combined to obtain a new prediction for the current block.

[0025] Sub-block fusion modes: The sub-block fusion modes include Affine fusion mode and sub-block TMVP mode.

[0026] The Affine fusion mode is similar to the normal fusion mode in that it selects one motion information from the candidate motion information list and generates a prediction value for the current block based on the selected motion information. The difference from the normal fusion mode is that the motion information in the candidate motion information list of the normal fusion mode is a two-parameter translational motion vector, while the motion information in the candidate motion information list of the Affine fusion mode is four-parameter Affine motion information or six-parameter Affine motion information.

[0027] The subblock-based temporal motion vector prediction (TMVP) mode directly reuses the motion information of a block in a temporal reference picture to generate a prediction value for the current block, and the motion information of each subblock within the block may not be the same.

[0028] TPM mode: A block is divided into two triangular sub-blocks (45-degree and 135-degree triangular sub-blocks), and these two triangular sub-blocks have different unidirectional motion information. TPM mode is only used in the prediction process and does not affect the subsequent transformation and quantization processes. The unidirectional motion information here is also directly obtained from the candidate motion information list.

[0029] GEO mode: GEO mode is similar to TPM mode, but the division shape is different. In GEO mode, one quadrilateral block is divided into two sub-blocks of any shape (any other shape except the shape of two triangular sub-blocks of TPM, for example, one triangular sub-block and one pentagonal sub-block, or one triangular sub-block and one quadrilateral sub-block, or two trapezoidal sub-blocks, etc.), and the division shape is not limited. The two sub-blocks divided in GEO mode have different unidirectional motion information.

[0030] As can be seen from the above examples, the fusion mode and skip mode in this embodiment are prediction modes that directly select one motion information from a candidate motion information list and generate a predicted value for the current block. These prediction modes do not require a motion search process on the encoding side, and modes other than the MMVD mode do not require encoding of motion information differences.

[0031] Video coding framework: As shown in FIG. 1B, the encoding-side processing process of an embodiment of the present invention can be realized using a video coding framework. A schematic diagram of the video decoding framework is similar to that of FIG. 1B and is therefore omitted here. The decoding-side processing process of an embodiment of the present invention can be realized using a video decoding framework. Specifically, the video coding framework and the video decoding framework include modules such as intra prediction, motion estimation / motion compensation, a reference picture buffer, loop filtering, reconstruction, transform, quantization, inverse transform, inverse quantization, and an entropy encoder. On the encoding side, the encoding-side processing process can be realized through cooperation between these modules, and on the decoding side, the decoding-side processing process can be realized through cooperation between these modules.

[0032] In the related art, when the current block is a bidirectional block, after obtaining the first original motion vector and the second original motion vector of the current block, there is no reasonable solution for how to adjust the first original motion vector and the second original motion vector.

[0033] In an embodiment of the present invention, when the current block is a bidirectional block, considering that the motion vectors from two different directions often have a mirror-symmetric relationship, redundancy can be further removed based on this characteristic. For example, a motion vector adjustment mode can be provided, in which a predicted value is obtained based on the original motion vector, and the motion vector is fine-tuned by a local search method on the decoding side to obtain a better motion vector so as to generate a predicted value with less distortion.

[0034] For example, when it is determined to enable the motion vector adjustment mode for the current block, for each sub-block of the current block, a first reference block corresponding to the sub-block is determined based on a first original motion vector of the sub-block, a second reference block corresponding to the sub-block is determined based on a second original motion vector of the sub-block, the first original motion vector and the second original motion vector are adjusted based on a first pixel value of the first reference block and a second pixel value of the second reference block to obtain a first target motion vector and a second target motion vector, and a predicted value of the sub-block is determined based on the first target motion vector and the second target motion vector. This method solves problems such as low prediction quality and prediction error, and improves coding performance and coding efficiency.

[0035] The encoding and decoding method of the present invention will be described in detail below in connection with several specific embodiments.

[0036] Example 1: As shown in Figure 2, this is a flowchart of the encoding and decoding method provided in an embodiment of the present invention, where the encoding and decoding method can be applied to the decoding side or the encoding side, and the encoding and decoding method can include steps 201 and 202.

[0037] In step 201, As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting the reference blocks from two reference pictures, the display order of the two reference pictures is before and after the current picture, respectively, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. The method may include determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are met.

[0038] In one possible embodiment, As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting the reference blocks from two reference pictures, the display order of the two reference pictures is before and after the current picture, respectively, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. If any of the conditions that the sizes of the two reference pictures of the current block are both the same as the size of the current picture is not met, it is determined not to activate the motion vector adjustment mode for the current block.

[0039] In the above embodiment, seven conditions are provided, and whether to activate the motion vector adjustment mode for the current block is determined based on the seven conditions. In practical applications, some of the seven conditions may be selected, and whether to activate the motion vector adjustment mode for the current block may be determined based on the selected some of the conditions. For example, five of the seven conditions may be selected, but this selection method is not limited and any five conditions may be used. If all five selected conditions are met, it is determined that the motion vector adjustment mode for the current block is activated. If any of the five selected conditions is not met, it is determined that the motion vector adjustment mode for the current block is not activated. Of course, other numbers of conditions may be selected from the seven conditions, and this is not a limitation.

[0040] In the above embodiment, the fusion mode or skip mode includes normal fusion mode, sub-block fusion mode, MMVD mode, CIIP mode, TPM mode, and GEO mode. The prediction mode of the current block is not a mode other than normal fusion mode, which means that the prediction mode is not sub-block fusion mode, MMVD mode, CIIP mode, TPM mode, GEO mode, etc.

[0041] For example, if the prediction mode of the current block is the fusion mode or the skip mode, it is neither the MMVD mode nor the CIIP mode.

[0042] If it is determined that the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not the MMVD mode, the CIIP mode, the sub-block fusion mode, the TPM mode, or the GEO mode, it may be determined that the prediction mode of the current block is not a mode other than the normal fusion mode. That is, it is determined that the prediction mode of the current block is the normal fusion mode by an elimination method.

[0043] In the above embodiment, the prediction value of the current block is obtained by weighting the reference blocks from two reference pictures, which means that the current block uses a bidirectional prediction mode, i.e., the prediction value of the current block is obtained by weighting the reference blocks from two reference pictures.

[0044] In the above embodiment, the current block may correspond to motion information of two lists, designated as first motion information and second motion information, where the first motion information includes a first reference picture and a first original motion vector, and the second motion information includes a second reference picture and a second original motion vector. The two reference pictures may be the first reference picture and the second reference picture. The two reference pictures being respectively before and after the current picture in the display order means that the first reference picture is before the current picture in which the current block is located, and the second reference picture is after the current picture. Illustratively, the first reference picture is also referred to as a forward reference picture in the first list (e.g., list0), and the second reference picture is also referred to as a backward reference picture in the second list (e.g., list1).

[0045] In the above embodiment, the width, height, and area of ​​the current block being all within the limited ranges includes the width being equal to or greater than a first threshold, the height being equal to or greater than a second threshold, and the area being equal to or greater than a third threshold, or the width being equal to or greater than the first threshold, the height being equal to or greater than the second threshold, and the area being greater than a fourth threshold. Exemplarily, the third threshold may be greater than the fourth threshold. For example, the first threshold may be 8, the second threshold may be 8, the third threshold may be 128, and the fourth threshold may be 64. Of course, the above values ​​are merely examples and are not limiting.

[0046] In the above embodiment, the control information allowing the current block to use the motion vector adjustment mode may include, but is not limited to, sequence-level control information (e.g., multi-picture control information) allowing the current block to use the motion vector adjustment mode, and / or picture-level control information (e.g., single-picture control information) allowing the current block to use the motion vector adjustment mode.

[0047] In step 202, if it is determined to activate the motion vector adjustment mode for the current block, motion compensation is performed for the current block.

[0048] In one possible embodiment, when it is determined to activate the motion vector adjustment mode for the current block, for each sub-block among at least one sub-block included in the current block, a first reference block corresponding to the sub-block is determined based on a first original motion vector of the sub-block, a second reference block corresponding to the sub-block is determined based on a second original motion vector of the sub-block, the first original motion vector and the second original motion vector are adjusted based on a first pixel value of the first reference block and a second pixel value of the second reference block, a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector are obtained, and a predicted value of the sub-block is determined based on the first target motion vector and the second target motion vector. After the predicted value of each sub-block is obtained, a predicted value of the current block can be determined based on the predicted value of each sub-block.

[0049] Illustratively, the step of determining a first reference block corresponding to the sub-block based on a first original motion vector of the sub-block, and determining a second reference block corresponding to the sub-block based on a second original motion vector of the sub-block, includes: determining a first reference block corresponding to the sub-block from a first reference picture based on a first original motion vector of the sub-block, wherein a pixel value of each pixel point in the first reference block is obtained by interpolating pixel values ​​of neighboring pixel points in the first reference block or by copying pixel values ​​of neighboring pixel points in the first reference block; The method may include, but is not limited to, a step of determining a second reference block corresponding to the sub-block from a second reference picture based on a second original motion vector of the sub-block, wherein the pixel value of each pixel point in the second reference block is obtained by interpolating pixel values ​​of neighboring pixel points in the second reference block or by copying pixel values ​​of neighboring pixel points in the second reference block.

[0050] Illustratively, the size of the first reference block is the same as the size of the second reference block, the width of the first reference block is determined based on the width and search range of the sub-block, and the height value of the first reference block is determined based on the height and search range of the sub-block.

[0051] For example, for each sub-block included in the current block, the first original motion vector of the sub-block and the second original motion vector of the sub-block are adjusted based on the first pixel value of the first reference block corresponding to the sub-block and the second pixel value of the second reference block corresponding to the sub-block, to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, i.e., the first target motion vector and the second target motion vector of the sub-block.

[0052] In one possible embodiment, some or all of the motion vectors are selected from the motion vectors around and including an initial motion vector, and the selected motion vectors are determined as candidate motion vectors, where the initial motion vector is a first original motion vector or a second original motion vector. Next, one motion vector is selected from the initial motion vector and each candidate motion vector as an optimal motion vector based on a first pixel value of a first reference block and a second pixel value of a second reference block. Next, the first original motion vector is adjusted based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector, and the second original motion vector is adjusted based on the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector.

[0053] Illustratively, the steps of adjusting a first original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector and adjusting a second original motion vector based on the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector may include the steps of determining a first integer-pel motion vector adjustment value, a second integer-pel motion vector adjustment value, a first sub-pel motion vector adjustment value, and a second sub-pel motion vector adjustment value for the sub-block based on the optimal motion vector; adjusting the first original motion vector based on the first integer-pel motion vector adjustment value and the first sub-pel motion vector adjustment value to obtain a first target motion vector for the sub-block; and adjusting the second original motion vector based on the second integer-pel motion vector adjustment value and the second sub-pel motion vector adjustment value to obtain a second target motion vector for the sub-block.

[0054] Illustratively, for each sub-block among at least one sub-block included in the current block, a predicted value of the sub-block can be determined based on the first target motion vector of the sub-block and the second target motion vector of the sub-block, and this process will not be described in detail.

[0055] In one possible embodiment, if the optimal motion vector is the same as the initial motion vector, a third reference block corresponding to the sub-block is determined from the first reference picture based on the first target motion vector of the sub-block, and a fourth reference block corresponding to the sub-block is determined from the second reference picture based on the second target motion vector of the sub-block, and then pixel values ​​of the third reference block and pixel values ​​of the fourth reference block are weighted to obtain a predicted value of the sub-block.

[0056] In another possible embodiment, if the optimal motion vector is not different from the initial motion vector, a fifth reference block is determined from the first reference picture, the fifth reference block is expanded to obtain a sixth reference block, and a third reference block corresponding to the sub-block is selected from the sixth reference block based on the first target motion vector of the sub-block. A seventh reference block is determined from the second reference picture, the seventh reference block is expanded to obtain an eighth reference block, and a fourth reference block corresponding to the sub-block is selected from the eighth reference block based on the second target motion vector of the sub-block. Then, pixel values ​​of the third reference block and pixel values ​​of the fourth reference block are weighted to obtain a predicted value of the sub-block.

[0057] In the above embodiment, weighting pixel values ​​of the third reference block and pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block may include, but is not limited to, performing a weighting process on pixel values ​​of the third reference block, a first weight corresponding to the pixel values ​​of the third reference block, pixel values ​​of the fourth reference block, and a second weight corresponding to the pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block. For example, the first weight and the second weight may be the same.

[0058] For example, after obtaining the predicted value of each sub-block, the predicted value of each sub-block may be combined to obtain the predicted value of the current block, but the process of determining the predicted value of the current block is not limited.

[0059] As can be seen from the above technical solutions, in the embodiment of the present invention, when it is determined to activate the motion vector adjustment mode for the current block, instead of determining a predicted value based on the first original motion vector and the second original motion vector, the first target motion vector and the second target motion vector are obtained based on the first original motion vector and the second original motion vector, and the predicted value is determined based on the first target motion vector and the second target motion vector, thereby solving problems such as low prediction quality and prediction error, and improving coding performance and coding efficiency.

[0060] Embodiment 2: Based on the same idea as the above method, as shown in FIG. 3, is a flowchart of another encoding and decoding method provided in an embodiment of the present invention, which can be applied to the encoding side, and the method can include steps 301 to 305.

[0061] In step 301, the encoding side determines whether to activate the motion vector adjustment mode for the current block. If yes, perform step 302; if no, there is no need to use the motion vector adjustment method provided in the present invention, and the processing of this situation is not limited.

[0062] In one example, when the encoding side decides to activate the motion vector adjustment mode for the current block, it indicates that the motion information of the current block is not accurate enough, so it activates the motion vector adjustment mode for the current block (i.e., the technical solution of the present invention) and performs step 302.

[0063] If the encoding side decides not to activate the motion vector adjustment mode for the current block, it indicates that the motion information of the current block is sufficiently accurate, so the motion vector adjustment mode is not activated for the current block and the motion vector adjustment method provided in the present invention does not need to be used.

[0064] In step 302, for each sub-block among the at least one sub-block included in the current block, the encoding side determines a first reference block corresponding to the sub-block from the first reference picture based on the first original motion vector of the sub-block, and determines a second reference block corresponding to the sub-block from the second reference picture based on the second original motion vector of the sub-block. For ease of distinction, the pixel value of each pixel point in the first reference block is referred to as the first pixel value, and the pixel value of each pixel point in the second reference block is referred to as the second pixel value.

[0065] In one example, if the current block is a block using bidirectional prediction, there may be bidirectional motion information for each sub-block of the current block, which may include two reference pictures and two original motion vectors, and the bidirectional motion information may include a first reference picture, a first original motion vector, a second reference picture, and a second original motion vector.

[0066] Based on the first original motion vector, the encoding side determines a first reference block from the first reference picture corresponding to the sub-block, and the pixel value of each pixel point in the first reference block is called the first pixel value. Based on the second original motion vector, the encoding side determines a second reference block from the second reference picture corresponding to the sub-block, and the pixel value of each pixel point in the second reference block is called the second pixel value.

[0067] In one example, the distance between the current picture in which the current block is located and the first reference picture may be the same as the distance between the second reference picture and the current picture in which the current block is located, for example, the first reference picture is the first frame, the current picture is the fifth frame, and the second reference picture is the ninth frame.

[0068] In one example, the first original motion vector and the second original motion vector may be mirror symmetric, for example, the first original motion vector is (4, 4) and the second original motion vector is (-4, -4). The first original motion vector is (2.5, 3.5) and the second original motion vector is (-2.5, -3.5). Of course, the above are merely examples and are not limiting.

[0069] The method for determining the first and second reference blocks can be referred to in the subsequent embodiments, and will not be described here.

[0070] In step 303, the encoding side adjusts the first original motion vector based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain a first target motion vector of the sub-block, and adjusts the second original motion vector based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain a second target motion vector of the sub-block.

[0071] In one example, when activating the motion vector adjustment mode for the current block, the encoding side fine-tunes the first original motion vector and the second original motion vector using a local search method based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain better first target motion vectors and second target motion vectors, and then generates predicted values ​​with low distortion using the first target motion vector and the second target motion vector.

[0072] In one example, the current block may include at least one sub-block. If the current block includes only one sub-block, the sub-block is the current block itself. Each sub-block of the current block corresponds to a first original motion vector and a second original motion vector, and after adjustment, the sub-block corresponds to a first target motion vector and a second target motion vector.

[0073] For example, if the current block includes sub-block A and sub-block B, sub-block A corresponds to a first original motion vector A1 and a second original motion vector A2, and after adjustment, sub-block A corresponds to a first target motion vector A3 and a second target motion vector A4. Sub-block B corresponds to a first original motion vector B1 and a second original motion vector B2, and after adjustment, sub-block B corresponds to a first target motion vector B3 and a second target motion vector B4.

[0074] For example, the first original motion vector A1 corresponding to sub-block A and the first original motion vector B1 corresponding to sub-block B may be the same, and both are the first original motion vectors of the current block. The second original motion vector A2 corresponding to sub-block A and the second original motion vector B2 corresponding to sub-block B may be the same, and both are the second original motion vectors of the current block.

[0075] The first original motion vector of each sub-block is adjusted respectively, so that the first target motion vector A3 corresponding to sub-block A and the first target motion vector B3 corresponding to sub-block B may be the same or different.

[0076] The second original motion vector of each sub-block is adjusted respectively, so that the second target motion vector A4 corresponding to sub-block A and the second target motion vector B4 corresponding to sub-block B may be the same or different.

[0077] The method for adjusting the original motion vector can be referred to in the later embodiments, and will not be described here.

[0078] In step 304, the encoding side determines a prediction value for the sub-block based on the first target motion vector and the second target motion vector.

[0079] In step 305, the encoding side determines a predicted value for the current block based on the predicted values ​​for each sub-block.

[0080] For example, if the current block includes sub-block A and sub-block B, the predicted value of sub-block A is determined using the first target motion vector and the second target motion vector of sub-block A, and the predicted value of sub-block B is determined using the first target motion vector and the second target motion vector of sub-block B, and the predicted value of sub-block A and the predicted value of sub-block B are the predicted values ​​of the current block.

[0081] For example, the encoding side stores the first target motion vector and the second target motion vector of each sub-block of the current block, or stores the first original motion vector and the second original motion vector of each sub-block of the current block, or stores the first original motion vector, the second original motion vector, the first target motion vector and the second target motion vector of each sub-block of the current block.

[0082] Embodiment 3: Based on the same idea as the above method, as shown in FIG. 4, is a flowchart of another encoding and decoding method provided in an embodiment of the present invention, which can be applied to the decoding side, and the method includes steps 401 to 405.

[0083] In step 401, the decoding side determines whether to activate the motion vector adjustment mode for the current block. If yes, perform step 402; if no, there is no need to adopt the motion vector adjustment method provided in the present invention, and the processing in this case is not limited.

[0084] In one example, when the decoding side decides to activate the motion vector adjustment mode for the current block, it indicates that the motion information of the current block is inaccurate, so it activates the motion vector adjustment mode for the current block (i.e., the technical solution of the present invention) and performs step 402.

[0085] If the decoding side decides not to activate the motion vector adjustment mode for the current block, it indicates that the motion information of the current block is sufficiently accurate, so the motion vector adjustment mode for the current block is not activated and the motion vector adjustment method provided in the present invention does not need to be used.

[0086] In step 402, for each sub-block among the at least one sub-block included in the current block, the decoding side determines a first reference block corresponding to the sub-block from the first reference picture based on the first original motion vector of the sub-block, and determines a second reference block corresponding to the sub-block from the second reference picture based on the second original motion vector of the sub-block. For ease of distinction, the pixel value of each pixel point in the first reference block is referred to as the first pixel value, and the pixel value of each pixel point in the second reference block is referred to as the second pixel value.

[0087] In step 403, the decoding side adjusts the first original motion vector based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain a first target motion vector of the sub-block, and adjusts the second original motion vector based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain a second target motion vector of the sub-block.

[0088] In step 404, the decoding side determines a prediction value of the sub-block based on the first target motion vector and the second target motion vector.

[0089] In step 405, the decoding side determines a predicted value for the current block based on the predicted values ​​for each sub-block.

[0090] Illustratively, the decoding side stores the first target motion vector and the second target motion vector of each sub-block of the current block, or stores the first original motion vector and the second original motion vector of each sub-block of the current block, or stores the first original motion vector, the second original motion vector, the first target motion vector and the second target motion vector of each sub-block of the current block.

[0091] Illustratively, steps 401 to 405 can refer to steps 301 to 305, which are omitted here.

[0092] Embodiment 4: The above embodiment relates to whether to activate the motion vector adjustment mode for the current block, and will be described below.

[0093] In one possible embodiment, the following activation conditions can be provided: Of course, the following activation conditions are only examples, and in actual applications, the following activation conditions can be arbitrarily combined, and this is not limited thereto. Illustratively, if all of the following activation conditions are met, it is determined to activate the motion vector adjustment mode for the current block:

[0094] 1. The control information allows the current block to use the motion vector adjustment mode.

[0095] Exemplarily, the control information may include, but is not limited to, sequence level control information and / or picture level control information.

[0096] In one possible embodiment, sequence level (e.g., multi-frame image) control information may include a control flag (e.g., sps_cur_tool_enabled_flag), and picture level (e.g., single-frame image) control information may include a control flag (e.g., pic_cur_tool_disabled_flag). When sps_cur_tool_enabled_flag is a first value and pic_cur_tool_disabled_flag is a second value, it indicates that the current block is allowed to use the motion vector adjustment mode.

[0097] Illustratively, sps_cur_tool_enabled_flag indicates whether all pictures in the sequence are allowed to use the motion vector adjustment mode. pic_cur_tool_disabled_flag indicates whether each block in the current picture is not allowed to use the motion vector adjustment mode. A first value for sps_cur_tool_enabled_flag indicates that all pictures in the sequence are allowed to use the motion vector adjustment mode. A second value for pic_cur_tool_disabled_flag indicates that each block in the current picture is allowed to use the motion vector adjustment mode.

[0098] Illustratively, when sps_cur_tool_enabled_flag is the second value and / or pic_cur_tool_disabled_flag is the first value, it indicates that the current block is not allowed to use the motion vector adjustment mode, i.e., the control information indicates that the current block is not allowed to use the motion vector adjustment mode.

[0099] In another possible embodiment, the sequence level (e.g., multi-frame image) control information may include a control flag (e.g., sps_cur_tool_disabled_flag), and the picture level (e.g., one-frame image) control information may include a control flag bit (e.g., pic_cur_tool_disabled_flag), where sps_cur_tool_disabled_flag is a second value, and pic_cur_tool_disabled_flag is a second value, indicating that the current block is allowed to use the motion vector adjustment mode.

[0100] Illustratively, sps_cur_tool_disabled_flag indicates whether all pictures in the sequence are not allowed to use the motion vector adjustment mode. pic_cur_tool_disabled_flag indicates whether each block in the current picture is not allowed to use the motion vector adjustment mode. A second value for sps_cur_tool_disabled_flag indicates that all pictures in the sequence are allowed to use the motion vector adjustment mode. A second value for pic_cur_tool_disabled_flag indicates that each block in the current picture is allowed to use the motion vector adjustment mode.

[0101] Illustratively, when sps_cur_tool_disabled_flag is a first value and / or pic_cur_tool_disabled_flag is a first value, it indicates that the current block is not allowed to use the motion vector adjustment mode, i.e., as control information, the current block is not allowed to use the motion vector adjustment mode.

[0102] In another possible embodiment, the sequence level (e.g., multi-frame image) control information may include a control flag bit (e.g., sps_cur_tool_enabled_flag), and the picture level (e.g., single-frame image) control information may include a control flag bit (e.g., pic_cur_tool_enabled_flag). When sps_cur_tool_enabled_flag is a first value, and when pic_cur_tool_enabled_flag is a first value, it indicates that the current block is allowed to use the motion vector adjustment mode.

[0103] Illustratively, sps_cur_tool_enabled_flag indicates whether all pictures in the sequence are allowed to use the motion vector adjustment mode. pic_cur_tool_enabled_flag indicates whether each block in the current picture is allowed to use the motion vector adjustment mode. When sps_cur_tool_enabled_flag is set to the first value, it indicates that all pictures in the sequence are allowed to use the motion vector adjustment mode. When pic_cur_tool_enabled_flag is set to the first value, it indicates that each block in the current picture is allowed to use the motion vector adjustment mode.

[0104] Illustratively, when sps_cur_tool_enabled_flag is a second value and / or pic_cur_tool_enabled_flag is a second value, it indicates that the current block is not allowed to use the motion vector adjustment mode, i.e., as control information, the current block is not allowed to use the motion vector adjustment mode.

[0105] In another possible embodiment, the sequence level (e.g., multi-frame image) control information may include a control flag (e.g., sps_cur_tool_disabled_flag), and the picture level (e.g., one-frame image) control information may include a control flag (e.g., pic_cur_tool_enabled_flag). When sps_cur_tool_disabled_flag is the second value and pic_cur_tool_enabled_flag is the first value, it indicates that the current block is allowed to use the motion vector adjustment mode.

[0106] Illustratively, sps_cur_tool_disabled_flag indicates whether all pictures in the sequence are not allowed to use the motion vector adjustment mode. pic_cur_tool_enabled_flag indicates whether each block in the current picture is allowed to use the motion vector adjustment mode. When sps_cur_tool_disabled_flag has a second value, it indicates that all pictures in the sequence are allowed to use the motion vector adjustment mode. When pic_cur_tool_enabled_flag has a first value, it indicates that each block in the current picture is allowed to use the motion vector adjustment mode.

[0107] Illustratively, when sps_cur_tool_disabled_flag is a first value and / or pic_cur_tool_enabled_flag is a second value, it indicates that the current block is not allowed to use the motion vector adjustment mode, i.e., as control information, the current block is not allowed to use the motion vector adjustment mode.

[0108] In the above embodiment, the first value may be 1 and the second value may be 0, or the first value may be 0 and the second value may be 1. Of course, the above is just an example and is not limiting.

[0109] Illustratively, a frame or a picture herein corresponds to an image, and a current picture represents a current image, and a reference picture represents a reference image.

[0110] 2. The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not other modes than the normal fusion mode.

[0111] In one possible embodiment, when the prediction mode of the current block (e.g., inter prediction mode) is fusion mode or skip mode, and the prediction mode of the current block is not a mode other than normal fusion mode (e.g., sub-block fusion mode, MMVD mode, CIIP mode, TPM mode, GEO mode, etc.), it is indicated that the current block is allowed to use the motion vector adjustment mode. For example, when the prediction mode of the current block is fusion mode or skip mode, if the prediction mode of the current block is not MMVD mode and the prediction mode of the current block is not CIIP mode, it is indicated that the current block is allowed to use the motion vector adjustment mode.

[0112] For example, if the prediction mode of the current block is not the fusion mode and the prediction mode of the current block is not the skip mode, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 2 is not met.

[0113] For example, if the prediction mode of the current block is fusion mode or skip mode, and the prediction mode of the current block is any mode other than normal fusion mode (e.g., sub-block fusion mode, MMVD mode, CIIP mode, TPM mode, GEO mode, etc.), the current block is not allowed to use motion vector adjustment mode, i.e., activation condition 2 is not met.

[0114] In another possible embodiment, when the prediction mode of the current block is a normal merge mode (e.g., a regular merge mode), it is indicated that the current block is allowed to use the motion vector adjustment mode. Illustratively, the normal merge mode reuses some motion information in the current block motion information list as the motion information of the current block to generate a predicted value of the current block.

[0115] For example, if the prediction mode of the current block is not the normal fusion mode, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that the activation condition 2 is not met.

[0116] 3. The predicted value of the current block is obtained by weighting reference blocks from two reference pictures, where the two reference pictures are respectively before and after the current picture in display order and are the same distance from the two reference pictures to the current picture. Obtaining the predicted value of the current block by weighting reference blocks from two reference pictures means that the current block uses a bidirectional prediction mode, i.e., the predicted value of the current block is obtained by weighting reference blocks from the two reference pictures. Exemplarily, the current block may correspond to two lists of motion information, designated as first motion information and second motion information, where the first motion information includes a first reference picture and a first original motion vector, and the second motion information includes a second reference picture and a second original motion vector. Having the two reference pictures before and after the current picture in display order means that the first reference picture is before the current picture in which the current block is located, and the second reference picture is after the current picture.

[0117] In one possible embodiment, if the current block has motion information (e.g., two reference pictures and two motion vectors) from two lists (e.g., list0 and list1), the display order of the two reference pictures is before and after the current picture, respectively, and the distances from the two reference pictures to the current picture are the same, it is indicated that the current block is allowed to use the motion vector adjustment mode.

[0118] If two reference pictures are located before and after the current picture in the display order and are the same distance from the current picture, the display order number POC_Cur of the current picture can be expressed relative to the display order number POC_0 of the reference picture in list 0 and the display order number POC_1 of the reference picture in list 1. That is, (POC_0 - POC_Cur) is exactly equal to (POC_Cur - POC_0).

[0119] Illustratively, the current block uses bidirectional prediction, and the two reference pictures corresponding to the current block are from different directions, i.e., one reference picture corresponding to the current block is before the current picture, and the other reference picture corresponding to the current block is after the current picture.

[0120] For example, the above condition that "the current block has two reference pictures, the display order of the two reference pictures is before and after the current picture, respectively, and the distances from the two reference pictures to the current picture are the same" can be expressed as follows:

[0121] For example, if the current block has only one reference picture, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 3 is not satisfied. Alternatively, if the current block has two reference pictures, but the display order of the two reference pictures is both before the current picture, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 3 is not satisfied. Alternatively, if the current block has two reference pictures, but the display order of the two reference pictures is both after the current picture, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 3 is not satisfied. Alternatively, if the current block has two reference pictures, and the display order of the two reference pictures is before and after the current picture, respectively, but the distances from the two reference pictures to the current picture are different, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 3 is not satisfied.

[0122] 4. The weighting weights of the two reference pictures of the current block are the same.

[0123] In one possible embodiment, if the weighting weights of the two reference pictures of the current block are the same, it indicates that the current block is allowed to use the motion vector adjustment mode. Illustratively, if the picture-level weighting weights of the two reference pictures are the same, for example, if the luma weighting weight (luma_weight_l0_flag[refIdxL0]) of the reference picture refIdxL1 is equal to the luma weighting weight (luma_weight_l1_flag[refIdxL1]) of the reference picture refIdxL1, it indicates that the weighting weights of the two reference pictures of the current block are the same. Or, if the block-level weighting weights of the two reference pictures are the same, for example, if the block-level weighting value index BcwIdx[xCb][yCb] of the current block is 0, it indicates that the weighting weights of the two reference pictures of the current block are the same. Alternatively, if the picture-level weighting weights of the two reference pictures are the same and the block-level weighting weights of the two reference pictures are the same, it is indicated that the weighting weights of the two reference pictures of the current block are the same.

[0124] Exemplarily, if the weighting weights of the two reference pictures of the current block are different, it indicates that the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 4 is not met. For example, if the picture-level weighting weights of the two reference pictures are different, it indicates that the weighting weights of the two reference pictures of the current block are different. Or, if the block-level weighting weights of the two reference pictures are different, it indicates that the weighting weights of the two reference pictures of the current block are different. Or, if the picture-level weighting weights of the two reference pictures are different and the block-level weighting weights of the two reference pictures are different, it indicates that the weighting weights of the two reference pictures of the current block are different.

[0125] Illustratively, the weighting weight of the two reference pictures of the current block is the weight used in bidirectional weight compensation.For example, for each sub-block of the current block, after obtaining the two predicted values ​​of each sub-block (see the following embodiment for the obtaining process), need to weight these two predicted values ​​to obtain the final predicted value of this sub-block.When weighting these two predicted values, the weights corresponding to these two predicted values ​​are the weighting weights of the two reference pictures of the current block, that is, the weights corresponding to these two predicted values ​​are the same.

[0126] 5. The two reference pictures of the current block are both short-term reference pictures, or the two reference pictures of the current block are not both long-term reference pictures.

[0127] In one possible embodiment, it is shown that if the two reference pictures of the current block are both short-term reference pictures, the current block is allowed to use the motion vector adjustment mode. A short-term reference picture means a reference picture close to the current picture, which is generally an actual image frame.

[0128] Illustratively, if two reference pictures of the current block are not both short-term reference pictures, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that starting condition 5 is not met. Alternatively, if one reference picture of the current block is not a short-term reference picture, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that starting condition 5 is not met. Alternatively, if two reference pictures of the current block are not both short-term reference pictures, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that starting condition 5 is not met.

[0129] In another possible embodiment, it is indicated that if the two reference pictures of the current block are not both long-term reference pictures, the current block is allowed to use the motion vector adjustment mode. The indication number POC of the long-term reference picture has no actual meaning, and the long-term reference picture means a reference picture that is far from the current picture, or an image frame that is synthesized from several frames of actual images.

[0130] Illustratively, if one reference picture of the current block is a long-term reference picture, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 5 is not met. Alternatively, if two reference pictures of the current block are both long-term reference pictures, the current block is not allowed to use the motion vector adjustment mode, that is, it indicates that activation condition 5 is not met.

[0131] 6. The width, height and area of ​​the current block are all within the limited range.

[0132] In one possible embodiment, if the width cbWidth of the current block is greater than or equal to a first threshold (e.g., 8), the height cbHeight of the current block is greater than or equal to a second threshold (e.g., 8), and the area of ​​the current block (cbHeight*cbWidth) is greater than or equal to a third threshold (e.g., 128), it is indicated that the current block is allowed to use the motion vector adjustment mode.

[0133] For example, if the width cbWidth of the current block is less than a first threshold, the current block is not allowed to use the motion vector adjustment mode, i.e., it indicates that activation condition 6 is not met. Alternatively, if the height cbHeight of the current block is less than a second threshold, the current block is not allowed to use the motion vector adjustment mode, i.e., it indicates that activation condition 6 is not met. Alternatively, if the area of ​​the current block is less than a third threshold, the current block is not allowed to use the motion vector adjustment mode, i.e., it indicates that activation condition 6 is not met.

[0134] In another possible embodiment, if the width cbWidth of the current block is greater than or equal to a first threshold (e.g., 8), the height cbHeight of the current block is greater than or equal to a second threshold (e.g., 8), and the area of ​​the current block (cbHeight*cbWidth) is greater than a fourth threshold (e.g., 64), it is indicated that the current block is allowed to use the motion vector adjustment mode.

[0135] For example, if the width cbWidth of the current block is less than a first threshold, the current block is not allowed to use the motion vector adjustment mode, i.e., it indicates that activation condition 6 is not satisfied. Alternatively, if the height cbHeight of the current block is less than a second threshold, the current block is not allowed to use the motion vector adjustment mode, i.e., it indicates that activation condition 6 is not satisfied. Alternatively, if the area of ​​the current block is equal to or less than a fourth threshold, the current block is not allowed to use the motion vector adjustment mode, i.e., it indicates that activation condition 6 is not satisfied.

[0136] 7. The size of the two reference pictures of the current block is the same as the size of the current picture.

[0137] In one possible embodiment, if the size of the reference picture in list0 is the same as the size of the current picture, for example, the width of the reference picture in list0 is the same as the width of the current picture, the height of the reference picture in list0 is the same as the height of the current picture, and the size of the reference picture in list1 is the same as the size of the current picture, for example, the width of the reference picture in list1 is the same as the width of the current picture, and the height of the reference picture in list1 is the same as the height of the current picture, it indicates that the current block is allowed to use the motion vector adjustment mode.

[0138] For example, if the size of at least one of the two reference pictures of the current block is different from the size of the current picture, it indicates that the current block is not allowed to use the motion vector adjustment mode, i.e., activation condition 7 is not satisfied. For example, if the width of the reference picture in list0 is different from the width of the current picture, it indicates that the current block is not allowed to use the motion vector adjustment mode. Or, if the height of the reference picture in list0 is different from the height of the current picture, it indicates that the current block is not allowed to use the motion vector adjustment mode. Or, if the width of the reference picture in list1 is different from the width of the current picture, it indicates that the current block is not allowed to use the motion vector adjustment mode. Or, if the height of the reference picture in list1 is different from the height of the current picture, it indicates that the current block is not allowed to use the motion vector adjustment mode.

[0139] Embodiment 5: In the above embodiment, for each sub-block of the current block, a first reference block corresponding to the sub-block is determined from a first reference picture according to a first original motion vector of the sub-block, and the pixel value of each pixel point in the first reference block is called the first pixel value; and a second reference block corresponding to the sub-block is determined from a second reference picture according to a second original motion vector of the sub-block, and the pixel value of each pixel point in the second reference block is called the second pixel value. The following is a description:

[0140] The first pixel value of each pixel point in the first reference block is obtained by interpolating the pixel values ​​of neighboring pixel points in the first reference block, or by copying the pixel values ​​of neighboring pixel points in the first reference block.

[0141] The second pixel value of each pixel point in the second reference block is obtained by interpolating the pixel values ​​of neighboring pixel points in the second reference block, or by copying the pixel values ​​of neighboring pixel points in the second reference block.

[0142] The size of the first reference block is the same as the size of the second reference block, the width of the first reference block / second reference block is determined based on the width of the sub-block and the search range, and the height of the first reference block / second reference block is determined based on the height of the sub-block and the search range.

[0143] For example, for each of the dx*dy sub-blocks of the current block (e.g., a 16*16 sub-block, or a smaller sub-block, or a larger sub-block. The smaller sub-block may be 8*8, and the larger sub-block may be 32*32, but this is not limited thereto. Illustratively, the size of the sub-block may be the same as the size of the current block, i.e., the sub-block is the current block. For example, if the current block is 8*16, it includes only one sub-block of size 8*16. On the other hand, the size of the sub-block may be different from the size of the current block. For example, if the current block is 8*32, it may include two sub-blocks of 8*16. Of course, the above is only an example, and for convenience of explanation, the following description will be given using a 16*16 sub-block as an example), the width of the sub-block is dx, the height of the sub-block is dy, the first original motion vector is MV0, and the second original motion vector is MV1.

[0144] Based on the corresponding position of the first original motion vector MV0 in the first reference picture, an integer pixel block with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) can be obtained, and this integer pixel block can be defined as integer pixel block A.

[0145] Based on the corresponding position of the second original motion vector MV1 in the second reference picture, an integer pixel block with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) can be obtained, and this integer pixel block can be defined as integer pixel block B.

[0146] In one possible embodiment, integer pixel block A having an area of ​​(dx+filtersize-1)*(dy+filtersize-1) is used as a base to obtain an initial reference pixel block having a size of (dx+2*IterNum)*(dy+2*IterNum) through bilinear interpolation, and this initial reference pixel block can be used as the first reference block. Also, integer pixel block B having an area of ​​(dx+filtersize-1)*(dy+filtersize-1) is used as a base to obtain an initial reference pixel block having a size of (dx+2*IterNum)*(dy+2*IterNum), and this initial reference pixel block can be used as the second reference block.

[0147] In another possible embodiment, integer pixel block A with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) is used as a base, and an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) is obtained by direct copying (no interpolation required) and this initial reference pixel block is used as the first reference block.Integer pixel block B with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) is used as a base, and an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) is used as the second reference block.

[0148] Illustratively, for the luminance component only (complexity is reduced in the subsequent search process by calculating the cost value using only the luminance component), based on integer pixel blocks (e.g., integer pixel block A and integer pixel block B) with an area of ​​(dx+filtersize-1)*(dy+filtersize-1), initial reference pixel blocks with a size of (dx+2*IterNum)*(dy+2*IterNum) are obtained, and the initial reference pixel blocks are a first reference block (e.g., Pred_Inter0) and a second reference block (e.g., Pred_Inter1).

[0149] In one example, filtersize may be the number of taps of the interpolation filter, such as 8, but is not limited in this respect.

[0150] In one example, obtaining the first reference block / second reference block by bilinear interpolation means that the pixel value of each pixel point in the first reference block / second reference block is obtained by interpolating pixel values ​​of neighboring pixel points in the first reference block / second reference block. Obtaining the first reference block / second reference block by copying means that the pixel value of each pixel point in the first reference block / second reference block is obtained by copying pixel values ​​of neighboring pixel points in the first reference block / second reference block.

[0151] Referring to the above embodiment, the area of ​​the first reference block is (dx+2*IterNum)*(dy+2*IterNum), and the area of ​​the second reference block is (dx+2*IterNum)*(dy+2*IterNum). For example, the width value of the first reference block / second reference block is dx+2*IterNum, and the height value of the first reference block / second reference block is dy+2*IterNum. dx is the width of the sub-block, dy is the height of the sub-block, IterNum may be a search range SR such as the number of iterations in subsequent embodiments, and IterNum may be the maximum horizontal / vertical component interpolation between the target motion vector and the original motion vector, for example, IterNum may be 2.

[0152] As shown in FIG. 5, for a 16*16 sub-block, an integer pixel block A with an area of ​​23 (i.e., 16+8-1)*23 is obtained based on the corresponding position of the first original motion vector MV0 in the first reference picture. Based on the integer pixel block A with an area of ​​23*23, a first reference block with a size of 20 (i.e., 16+2*2)*20 can be obtained through bilinear interpolation. Similarly, for a 16*16 sub-block, an integer pixel block B with an area of ​​23*23 is obtained based on the corresponding position of the second original motion vector MV1 in the second reference picture. Based on the integer pixel block B with an area of ​​23*23, a second reference block with a size of 20*20 is obtained.

[0153] The first and second reference blocks are used to adjust the motion vectors in subsequent processes.

[0154] Example 6: In the above example, for each sub-block of the current block, the first original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the first target motion vector of the sub-block, and the second original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the second target motion vector of the sub-block.The original motion vector adjustment process is described by taking the processing process of one sub-block (for example, each sub-block of the current block with a size of dx*dy) as an example.

[0155] In step a1, the first original motion vector or the second original motion vector is determined as the central motion vector.

[0156] For example, the first original motion vector is (4, 4) and the second original motion vector is (-4, -4), and the first original motion vector (4, 4) or the second original motion vector (-4, -4) is determined as the central motion vector.

[0157] For convenience of explanation, hereinafter, we will take the example of determining the first original motion vector (4,4) as the central motion vector, and the process of determining the second original motion vector (-4,-4) as the central motion vector is similar, so we will not explain it in detail here.

[0158] In step a2, an edge motion vector corresponding to the central motion vector is determined.

[0159] For example, by offsetting the central motion vector (x, y) by S in different directions, edge motion vectors (x, y+S), (x, yS), (x+S, y), (xS, y), and (x+right, y+down) in different directions are obtained. Exemplarily, right may be S or -S, and down may be S or -S. For the method of determining right and down, see the subsequent examples. As shown in FIG. 6, taking the central motion vector (x, y) as the center, i.e., the central motion vector is (0, 0), S is 1, and right and down are both 1, the edge motion vectors corresponding to the central motion vector (0, 0) include the edge motion vector (0, 1), the edge motion vector (0, -1), the edge motion vector (1, 0), the edge motion vector (-1, 0), and the edge motion vector (1, 1).

[0160] In step a3, based on the first pixel value of the first reference block and the second pixel value of the second reference block, a first cost value corresponding to the center motion vector and a second cost value corresponding to each edge motion vector are obtained.

[0161] For example, a sub-reference block A1 corresponding to the central motion vector (0,0) is obtained by copying from a first reference block, and the sub-reference block A1 is a sub-reference block in the first reference block with the central motion vector (0,0). A sub-reference block B1 corresponding to the central motion vector (0,0) is obtained by copying from a second reference block, and the sub-reference block B1 is a sub-reference block in the second reference block with the central motion vector (0,0). Next, a cost value 1 corresponding to the central motion vector (0,0) is obtained using the first pixel value of the sub-reference block A1 and the second pixel value of the sub-reference block B1. The method for determining the cost value can refer to the subsequent embodiments.

[0162] A sub-reference block A2 corresponding to the edge motion vector (0,1) is obtained by copying from the first reference block, where the sub-reference block A2 is a sub-reference block in the first reference block with the edge motion vector (0,1). A sub-reference block B2 corresponding to the symmetric motion vector (0,-1) of the edge motion vector (0,1) is obtained by copying from the second reference block, where the sub-reference block B2 is a sub-reference block in the second reference block with the symmetric motion vector (0,-1). A cost value 2 corresponding to the edge motion vector (0,1) is obtained using the first pixel value of the sub-reference block A2 and the second pixel value of the sub-reference block B2. Refer to the subsequent examples for the method of determining the cost value.

[0163] According to the method for determining cost value 2 corresponding to edge motion vector (0,1), cost value 3 corresponding to edge motion vector (0,-1), cost value 4 corresponding to edge motion vector (1,0), cost value 5 corresponding to edge motion vector (-1,0), and cost value 6 corresponding to edge motion vector (1,1) can be determined, but this will not be described in detail here.

[0164] In step a4, one of the center motion vector and the edge motion vector is selected as the optimum motion vector based on the first cost value and the second cost value, for example, the motion vector with the smallest cost value can be selected as the optimum motion vector.

[0165] For example, if the cost value 2 corresponding to the edge motion vector (0,1) is the smallest, the edge motion vector (0,1) corresponding to the cost value 2 can be determined as the optimal motion vector. Of course, this is just an example and is not limiting.

[0166] In step a5, it is determined whether the termination condition is met. If not, the optimum motion vector is determined as the central motion vector, and the process can return to step a2. If yes, step a6 can be performed.

[0167] In one example, the termination condition is met when the number of iterations / search range reaches a threshold, whereas the termination condition is not met when the number of iterations / search range does not reach the threshold. For example, if SR is 2, i.e., the threshold is 2, and the number of iterations / search range reaches 2, i.e., steps a2 to a4 are performed twice, the termination condition is met. Otherwise, the termination condition is not met.

[0168] In another example, after selecting one motion vector from the central motion vector and the edge motion vector as the optimum motion vector, the termination condition can be satisfied by selecting the central motion vector as the optimum motion vector.

[0169] In step a6, based on the optimal motion vector, a first integer-pel motion vector adjustment value (used to adjust the first original motion vector) and a second integer-pel motion vector adjustment value (used to adjust the second original motion vector) are determined.

[0170] In one example, a first integer pixel motion vector adjustment value is determined based on the optimal motion vector and the first original motion vector, and a second integer pixel motion vector adjustment value is determined based on the first integer pixel motion vector adjustment value, and illustratively the second integer pixel motion vector adjustment value may be symmetrical to the first integer pixel motion vector adjustment value.

[0171] For example, in the first iteration, the optimal motion vector is the edge motion vector (0,1). The second iteration is performed around the edge motion vector (0,1). The optimal motion vector is also the edge motion vector (0,1). When the iteration is completed, the first integer-pixel motion vector adjustment value is (0,2), i.e., the sum of the edge motion vector (0,1) and the edge motion vector (0,1). Based on this, if the first original motion vector is (4,4), the optimal motion vector in the first iteration is the edge motion vector (0,1), i.e., the optimal motion vector corresponds to the optimal motion vector (4,5). The second iteration is performed around the edge motion vector (0,1), and the optimal motion vector in the second iteration is the edge motion vector (0,1), i.e., the optimal motion vector corresponds to the optimal motion vector (4,6). As described above, the first integer-pel motion vector adjustment value is determined based on the optimal motion vector (4,6) and the first original motion vector (4,4), and the first integer-pel motion vector adjustment value is the difference between the optimal motion vector (4,6) and the first original motion vector (4,4), i.e., the first integer-pel motion vector adjustment value is (0,2).The second integer-pel motion vector adjustment value may be determined based on the first integer-pel motion vector adjustment value (0,2), and the second integer-pel motion vector adjustment value may be (0,-2), i.e., the symmetric value of (0,2).

[0172] In step a7, a first sub-pel motion vector adjustment value (used to adjust the first original motion vector) and a second sub-pel motion vector adjustment value (used to adjust the second original motion vector) are determined based on the optimal motion vector.

[0173] In one example, a first sub-pel motion vector adjustment value is determined based on a cost value corresponding to the optimal motion vector and a cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and then a second sub-pel motion vector adjustment value is determined based on the first sub-pel motion vector adjustment value. For example, x0 = N * (E(-1,0) - E(1,0)) / (E(-1,0) + E(1,0) - 2 * E(0,0)), and y0 = N * (E(0,-1) - E(0,1)) / (E(0,-1) + E(0,1) - 2 * E(0,0)). For 1 / 2, 1 / 4, 1 / 8, and 1 / 16 motion vector pixel precisions, N is 1, 2, 4, and 8, respectively. Next, the value of (x0, y0) is assigned to deltaMv, resulting in SPMV = deltaMv / 2N. Currently, for a motion vector pixel precision of 1 / 16, the SPMV is (x0 / 16, y0 / 16).

[0174] In the above formula, SPMV may be the first sub-pel motion vector adjustment value, and N may be related to the motion vector pixel precision, for example, the motion vector pixel precision is ½, N is 1; the motion vector pixel precision is ¼, N is 2; the motion vector pixel precision is ⅛, N is 4; the motion vector pixel precision is 1 / 16, N is 8.

[0175] In the above formula, E(0,0) represents the cost value of the optimal motion vector. E(-1,0) is the cost value of the edge motion vector (-1,0) of the optimal motion vector (0,0) centered around the optimal motion vector. E(1,0) is the cost value of the edge motion vector (1,0) of the optimal motion vector (0,0) centered around the optimal motion vector. E(0,-1) is the cost value of the edge motion vector (0,-1) of the optimal motion vector (0,0) centered around the optimal motion vector. E(0,1) is the cost value of the edge motion vector (0,1) of the optimal motion vector (0,0) centered around the optimal motion vector. The method for determining the cost values ​​of each motion vector refers to the example above and will not be described in detail here.

[0176] After determining the first sub-pel motion vector adjustment value using the above method, a second sub-pel motion vector adjustment value that is the symmetric value of the first sub-pel motion vector adjustment value can be determined based on the first sub-pel motion vector adjustment value. For example, if the first sub-pel motion vector adjustment value is (1,0), the second sub-pel motion vector adjustment value can be (-1,0), i.e., the symmetric value of the first sub-pel motion vector adjustment value (1,0).

[0177] In step a8, the first original motion vector is adjusted based on the first integer-pel motion vector adjustment value and / or the first sub-pel motion vector adjustment value to obtain a first target motion vector, for example, the first target motion vector = the first original motion vector + the first integer-pel motion vector adjustment value + the first sub-pel motion vector adjustment value.

[0178] In step a9, the second original motion vector is adjusted based on the second integer-pel motion vector adjustment value and / or the second sub-pel motion vector adjustment value to obtain a second target motion vector, for example, the second target motion vector = the second original motion vector + the second integer-pel motion vector adjustment value + the second sub-pel motion vector adjustment value.

[0179] Example 7: In the above example, for each sub-block of the current block, the first original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the first target motion vector of the sub-block, and the second original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the second target motion vector of the sub-block.The original motion vector adjustment process is described by taking the processing process of one sub-block (for example, each of the sub-blocks of the current block with a size of dx*dy) as an example.

[0180] In this embodiment, the first original motion vector is Org_MV0, the second original motion vector is Org_MV1, and after adjusting the first original motion vector Org_MV0, the obtained first target motion vector is Refined_MV0, and after adjusting the second original motion vector Org_MV1, the obtained second target motion vector is Refined_MV1.

[0181] In step b1, SR iterations are performed to obtain the integer pixel offset of the optimal integer pixel MV point, which is designated as IntegerDeltaMV, where IntegerDeltaMV is the first integer pixel motion vector adjustment value in the above embodiment. For example, first, IntegerDeltaMV is initialized to (0,0), and in each iteration, the following process is performed:

[0182] In step b11, deltaMV is set to (0,0). In the first iteration, based on the reference pixels of the first reference block of the first original motion vector, a predicted block A1 (i.e., the block of dx*dy at the center of the first reference block) is obtained by copying, and based on the reference pixels of the second reference block of the second original motion vector, a predicted block B1 (i.e., the block of dx*dy at the center of the second reference block) is obtained by copying. Based on the predicted block A1 and the predicted block B1, an initial cost value cost is obtained (the initial cost value is the sum of absolute differences (SAD) based on the predicted block A1 and the predicted block B1, and the determination method is described in the following examples). If the initial cost value cost is less than dx*dy (dx and dy are the width and height of the current sub-block), the subsequent search process is directly skipped, and step b2 is performed, and notZeroCost is set to false.

[0183] In step b12, for example, as shown in Fig. 6, five offset MVs (all five offset MVs are called MVOffset) are obtained in the order of {Mv(0,1), Mv(0,-1), Mv(1,0), Mv(-1,0), Mv(right, down)} with the initial point as the center, and cost values ​​of these five offset MVs are calculated and compared. For example, based on a certain MVOffset (e.g., Mv(0,1)), two predicted value blocks (e.g., a dx*dy block with a center position offset MVOffset in the first reference block and a dx*dy block with a center position offset -MVOffset (the inverse of MVOffset) in the second reference block) are obtained by this MVOffset in the first reference block and the second reference block, and the downsampling SAD of the two predicted value blocks is calculated as the cost value of MVOffset.

[0184] Next, the MVOffset with the smallest cost value is kept, and the MVOffset with the smallest cost value is updated to the value of deltaMV, and the MVOffset with the smallest cost value is set as the new center offset point for the next iteration.

[0185] The value of IntegerDeltaMV is updated based on deltaMV, so that IntegerDeltaMV after update = IntegerDeltaMV before update + deltaMV, that is, deltaMV is added to the current IntegerDeltaMV.

[0186] In step b13, after the iteration, if the optimal MV is still the initial MV (i.e., not MVOffset) or the minimum cost value is 0, do not perform the next iterative search process, and perform step b2, setting notZeroCost as false.

[0187] Otherwise, if the number of iterations reaches SR, perform step b2; if the number of iterations does not reach SR, center on the optimal MV and perform the next iterative search process, that is, return to step b11.

[0188] After the iterative search process is completed, the value of IntegerDeltaMV is obtained, that is, the final value of IntegerDeltaMV, which is the first integer-pel motion vector adjustment value, and is thereafter referred to as IntegerDeltaMV.

[0189] In step b2, the optimum sub-pel offset MV is obtained with the optimum integer-pel MV point of step b1 as the center, and is set as the SPMV, which is the first sub-pel motion vector adjustment value in the above embodiment.

[0190] For example, first, initialize the SPMV to (0,0), then perform the following process:

[0191] In step b21, subsequent processing can be performed (i.e., SPMV needs to be obtained) only if notZeroCost is not false and deltaMV is (0,0); otherwise, instead of adjusting the original motion vector using IntegerDeltaMV and SPMV, the original motion vector is adjusted directly using IntegerDeltaMV.

[0192] In step b22, E(x,y) is expressed as the cost value (cost value calculated in step b1) corresponding to the MV obtained by offsetting the optimal MV point obtained in step b1 by (x,y). Based on E(x,y) of the center and five points above, below, left, and right, the offset (x0,y0) of the point with the smallest E(x,y) can be obtained: x0=N*(E(-1,0)-E(1,0)) / (E(-1,0)+E(1,0)-2*E(0,0)), y0=N*(E(0,-1)-E(0,1)) / (E(0,-1)+E(0,1)-2*E(0,0)). In one example, N is 1, 2, 4, and 8 for motion vector pixel precisions of 1 / 2, 1 / 4, 1 / 8, and 1 / 16. Next, the value of (x0, y0) is given to deltaMv, so that SPMV = deltaMv / 2N. Now, for a motion vector pixel precision of 1 / 16, SPMV may be (x0 / 16, y0 / 16).

[0193] If E(-1,0)=E(0,0), then offset horizontally to the left by half a pixel (deltaMv[0]=-N).

[0194] If E(1,0)=E(0,0), then offset horizontally to the right by half a pixel (deltaMv[0]=N).

[0195] If E(0,-1)=E(0,0), then offset vertically upwards by half a pixel (deltaMv[1]=-N).

[0196] If E(0,1)=E(0,0), then offset vertically downward by half a pixel (deltaMv[1]=N).

[0197] Through the above process, the SPMV value, that is, the first sub-pel motion vector adjustment value, can be obtained.

[0198] In step b3, an optimal offset MV is obtained based on the integer pixel offset IntegerDeltaMV in step b1 and the sub-pixel offset SPMV in step b2, and this optimal offset MV can be set as BestMVoffset. Also, BestMVoffset=IntegerDeltaMV+SPMV. Based on BestMVoffset, target motion vectors in two directions can be obtained: Refined_MV0=Org_MV0+BestMVoffset; Refined_MV1=Org_MV1-BestMVoffset.

[0199] Obviously, BestMVoffset=IntegerDeltaMV+SPMV, i.e., the sum of the first integer-pel motion vector adjustment value and the first sub-pel motion vector adjustment value. Also, −IntegerDeltaMV is the symmetric value of IntegerDeltaMV, i.e., the second integer-pel motion vector adjustment value, and −SPMV is the symmetric value of SPMV, i.e., the second sub-pel motion vector adjustment value. Therefore, −BestMVoffset=(−IntegerDeltaMV)+(−SPMV), i.e., the sum of the second integer-pel motion vector adjustment value and the second sub-pel motion vector adjustment value.

[0200] Example 8: In one example, to adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 7, but the differences are as follows: Step b11, "if the initial cost value cost is less than dx*dy, directly skip the subsequent search process", is removed, that is, even if the initial cost value cost is less than dx*dy, the subsequent search process is continued without "directly skip the subsequent search process", that is, step b12 needs to be performed.

[0201] Example 9: To adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 7, but the differences are as follows: Step b11, “if the initial cost value cost is less than dx*dy, directly skip the subsequent search process,” is removed, that is, even if the initial cost value cost is less than dx*dy, the subsequent search process is continued without “directly skipping the subsequent search process,” that is, step b12 needs to be performed; Step b13, “if the optimal MV is still the initial MV (i.e., not MVOffset) or the minimum cost value is 0, the next iterative search process is not performed,” is removed, that is, even if the optimal MV is still the initial MV or the minimum cost value is 0, the next iterative search process is performed.

[0202] Example 10: In one example, to adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 7, with the following differences: The related process of "notZeroCost" is removed, that is, the value of notZeroCost is not set and stored in step b11 and step b13. In step b21, instead of performing the sub-pel offset calculation process only if notZeroCost is not false and deltaMV is (0,0), the sub-pel offset calculation process (i.e., step b22) can be performed as long as deltaMV is (0,0).

[0203] Example 11: In one example, to adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to that of Example 7, but differs as follows: "Only if notZeroCost is not false and deltaMV is (0,0), perform subsequent processing; otherwise, adjust the original motion vector directly using IntegerDeltaMV" in step b21 is changed to "Only if notZeroCost is not false and the cost values ​​of four points separated by one integer pixel above, below, left, and right of the current optimal integer pixel are calculated and obtained in step b1, perform subsequent processing; otherwise, adjust the original motion vector directly using IntegerDeltaMV." In one example, the "subsequent processing" refers to the fractional pixel offset calculation process in step b22.

[0204] In one example, in the fractional pixel offset calculation process in step b22, it is necessary to use the cost values ​​of four points that are separated by one integer pixel above, below, left, and right of the optimal integer pixel. Therefore, it may be a necessary condition that the "cost values ​​of four points that are separated by one integer pixel above, below, left, and right of the optimal integer pixel" are calculated and obtained in step b1.

[0205] Example 12: To adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 7, but the differences are as follows: In step b21, "Only if notZeroCost is not false and deltaMV is (0,0), perform subsequent processing; otherwise, adjust the original motion vector directly using IntegerDeltaMV" is changed to "Only if the cost values ​​of the four points separated by one integer pixel above, below, left, and right of the current optimal integer pixel are calculated and obtained in step b1, perform subsequent processing (i.e., fractional pixel offset calculation process); otherwise, adjust the original motion vector using IntegerDeltaMV."

[0206] Example 13: To adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 7, but the differences are as follows: In step b21, "Only if notZeroCost is not false and deltaMV is (0,0), perform subsequent processing; otherwise, adjust the original motion vector directly using IntegerDeltaMV" is changed to "If the cost values ​​of the four points separated by one integer pixel above, below, left, and right of the current optimal integer pixel are calculated and obtained in step b1, perform subsequent processing (the fractional pixel offset calculation process in step b22); otherwise, process using step b23."

[0207] In step b23, the current optimal integer pixel point MV_inter_org is set to the integer pixel point MV_inter_nearest, which is the closest integer pixel point and whose cost values ​​are calculated in step b1 for the four points spaced one integer pixel above, below, left, and right around it. Next, the fractional pixel offset calculation process in step b22 is performed with MV_inter_nearest as the center, that is, an SPMV is obtained with MV_inter_nearest as the center. For example, if the cost values ​​of the four points spaced one integer pixel above, below, left, and right from the current optimal integer pixel point MV_inter_org are not all calculated in step b1, an integer pixel point MV_inter_nearest is selected from around the optimal integer pixel point MV_inter_org, and the cost values ​​of the four points spaced one integer pixel above, below, left, and right from the integer pixel point MV_inter_nearest are all calculated in step b1.

[0208] Next, the integer pixel point MV_inter_nearest is set as the current optimal integer pixel point, and SPMV is obtained centered on the integer pixel point MV_inter_nearest. For specific methods, see step b22. When SPMV is obtained centered on the integer pixel point MV_inter_nearest, see step b22. When calculating x0 and y0, x0 and y0 can be limited to the range of [-2N, 2N]. If x0 / y0 is greater than 2N, the value of 2N is assigned to x0 / y0. If x0 / y0 is less than -2N, the value of -2N is assigned to x0 / y0. For 1 / 2, 1 / 4, 1 / 8, and 1 / 16 motion vector pixel precisions, N is 1, 2, 4, and 8, respectively.

[0209] Example 14: In the above examples, it is necessary to determine the edge motion vector corresponding to the central motion vector. For example, the central motion vector (x, y) is offset by S in different directions to sequentially obtain edge motion vectors (x, y+S), (x, yS), (x+S, y), (xS, y), and (x+right, y+down) in different directions. Or, the central motion vector (x, y) is offset by S in different directions to sequentially obtain edge motion vectors (x, yS), (x, y+S), (xS, y), (x+S, y), and (x+right, y+down) in different directions. For example, if (x, y) is (0, 0) and S is 1, five edge motion vectors are obtained in the order of (0, 1), (0, -1), (1, 0), (-1, 0), and (right, down). Alternatively, five edge motion vectors are obtained in the order (0,-1), (0,1), (-1,0), (1,0), (right,down).

[0210] Example 15: In the above example, the default value of the edge motion vector (x+right, y+down) is (xS, yS). If the cost value of the edge motion vector (x+S, y) is less than the cost value of the edge motion vector (xS, y), then right is S (changes from -S to S). If the cost value of the edge motion vector (x, y+S) is less than the cost value of the edge motion vector (x, yS), then down is S (changes from -S to S). Alternatively, if the cost value of the edge motion vector (x+S, y) is less than or equal to the cost value of the edge motion vector (xS, y), then right is S (changes from -S to S). If the cost value of the edge motion vector (x, y+S) is less than or equal to the cost value of the edge motion vector (x, yS), then down is S (changes from -S to S).

[0211] Five edge motion vectors are obtained in the order of (0,1), (0,-1), (1,0), (-1,0), and (right,down), with the default value of (right,down) being (-1,-1). If the cost value of edge motion vector (1,0) is less than the cost value of edge motion vector (-1,0), then right is 1. If the cost value of edge motion vector (0,1) is less than the cost value of edge motion vector (0,-1), then down is 1. Or, if the cost value of edge motion vector (1,0) is less than or equal to the cost value of edge motion vector (-1,0), then right is 1. If the cost value of edge motion vector (0,1) is less than or equal to the cost value of edge motion vector (0,-1), then down is 1. For example, five edge motion vectors are obtained in the order of (0,-1), (0,1), (-1,0), (1,0), (right,down), and the default value of (right,down) is (-1,-1). If the cost value of edge motion vector (1,0) is less than the cost value of edge motion vector (-1,0), then right is 1. If the cost value of edge motion vector (0,1) is less than the cost value of edge motion vector (0,-1), then down is 1. Or, if the cost value of edge motion vector (1,0) is less than or equal to the cost value of edge motion vector (-1,0), then right is 1. If the cost value of edge motion vector (0,1) is less than or equal to the cost value of edge motion vector (0,-1), then down is 1.

[0212] Example 16: In the above example, for each sub-block of the current block, the first original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the first target motion vector of the sub-block, and the second original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the second target motion vector of the sub-block.The adjustment process of the original motion vector is described by taking the processing process of one sub-block (for example, each of the sub-blocks of the current block with a size of dx*dy) as an example.

[0213] In step c1, some or all of the motion vectors are selected from the motion vectors around the initial motion vector, including the initial motion vector, with the initial motion vector at the center, and the selected motion vectors are set as candidate motion vectors. Exemplarily, the initial motion vector may be the first original motion vector or the second original motion vector. For example, some or all of the motion vectors around the first original motion vector, including the first original motion vector, are selected as candidate motion vectors. For this selection method, see the following examples. Alternatively, some or all of the motion vectors around the second original motion vector, including the second original motion vector, may be selected as candidate motion vectors. For this selection method, see the following examples. For convenience of explanation, the following examples will be hereinafter exemplified by assuming that the first original motion vector is the center, i.e., the initial motion vector is the first original motion vector.

[0214] For example, a part or all of the motion vectors are selected from (2*SR+1)*(2*SR+1) motion vectors around and including the initial motion vector, with the initial motion vector at the center, and the selected motion vectors are determined as candidate motion vectors, where SR is a search range. When a part or all of the motion vectors are selected from (2*SR+1)*(2*SR+1) motion vectors around and including the initial motion vector, and the selected motion vectors are determined as candidate motion vectors, the search order of the motion vectors may include a left-to-right order or a top-to-bottom order.

[0215] When SR is 2, all motion vectors are selected from the 25 motion vectors around the initial motion vector, including the initial motion vector, and the selected motion vectors are determined as candidate motion vectors. The search order of motion vectors is {Mv(-2,-2),Mv(-1,-2),Mv(0,-2),Mv(1,-2),Mv(2,-2),Mv(-2,-1),Mv(-1,-1),Mv(0,-1),Mv(1,-1),Mv(2,-1),Mv(-2,0),Mv(-1,0),Mv(0,0),Mv(1,0),Mv(2,0),Mv(-2,1),Mv(-1,1),Mv(0,1),Mv(1,1),Mv(2,1),Mv(-2,2),Mv(-1,2),Mv(0,2),Mv(1,2),Mv(2,2)}. or {Mv(0,0),Mv(-2,-2),Mv(-1,-2),Mv(0,-2),Mv(1,-2),Mv(2,-2 ),Mv(-2,-1),Mv(-1,-1),Mv(0,-1),Mv(1,-1),Mv(2,-1),Mv(-2,0),Mv (-1,0),Mv(0,0),Mv(1,0),Mv(2,0),Mv(-2,1),Mv(-1,1),Mv(0,1),Mv (1,1),Mv(2,1),Mv(-2,2),Mv(-1,2),Mv(0,2),Mv(1,2),Mv(2,2)}.

[0216] When SR is 2, some motion vectors are selected from the 21 motion vectors around the initial motion vector, including the initial motion vector, and the selected motion vectors are determined as candidate motion vectors. The search order of motion vectors is {Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), Mv(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-1,2), Mv(0,2), Mv(1,2)}. or {Mv(0,0),Mv(-1,-2),Mv(0,-2),Mv(1,-2),Mv(-2,-1),Mv(-1,-1),Mv(0,-1),Mv(1,-1),Mv(2,-1),Mv(-2,0),Mv( -1,0),Mv(0,0),Mv(1,0),Mv(2,0),Mv(-2,1),Mv(-1,1),Mv(0,1),Mv(1,1),Mv(2,1),Mv(-1,2),Mv(0,2),Mv(1,2)}.

[0217] In step c2, based on the first pixel value of the first reference block and the second pixel value of the second reference block, a third cost value corresponding to the first original motion vector (i.e., the initial motion vector) and a fourth cost value corresponding to each candidate motion vector are obtained.

[0218] For example, a sub-reference block A1 corresponding to a first original motion vector can be obtained by copying from a first reference block, and the sub-reference block A1 may be a sub-reference block of the first reference block of the first original motion vector. Next, a sub-reference block B1 corresponding to a second original motion vector can be obtained by copying from a second reference block, and the sub-reference block B1 is a sub-reference block of the second reference block of the second original motion vector. Next, a third cost value corresponding to the first original motion vector can be obtained using a first pixel value of the sub-reference block A1 and a second pixel value of the sub-reference block B1. For each candidate motion vector, a sub-reference block A2 corresponding to the candidate motion vector can be obtained by copying from the first reference block, and the sub-reference block A2 is a sub-reference block of the first reference block of the candidate motion vector. Next, a sub-reference block B2 corresponding to a symmetric motion vector of the candidate motion vector can be obtained by copying from a second reference block, and the sub-reference block B2 is a sub-reference block of the second reference block of the symmetric motion vector. A fourth cost value corresponding to the candidate motion vector is obtained using the first pixel value of the sub-reference block A2 and the second pixel value of the sub-reference block B2.

[0219] In step c3, one motion vector is selected from the first original motion vector and each candidate motion vector based on the third cost value and the fourth cost value, and the selected motion vector is determined as the optimal motion vector. For example, the motion vector with the smallest cost value (e.g., the first original motion vector or any of the candidate motion vectors) can be determined as the optimal motion vector.

[0220] In step c4, a first integer-pel motion vector adjustment value (used to adjust the first original motion vector) and a second integer-pel motion vector adjustment value (used to adjust the second original motion vector) are determined based on the optimal motion vector. For example, the first integer-pel motion vector adjustment value is determined based on the optimal motion vector and the first original motion vector, and the second integer-pel motion vector adjustment value is determined based on the first integer-pel motion vector adjustment value, where the second integer-pel motion vector adjustment value and the first integer-pel motion vector adjustment value are symmetrical.

[0221] For example, if the optimal motion vector is (4,6) and the first original motion vector is (4,4), a first integer-pel motion vector adjustment value is determined based on the optimal motion vector (4,6) and the first original motion vector (4,4), where the first integer-pel motion vector adjustment value is the difference between the optimal motion vector (4,6) and the first original motion vector (4,4), i.e., the first integer-pel motion vector adjustment value is (0,2). Next, a second integer-pel motion vector adjustment value is determined based on the first integer-pel motion vector adjustment value (0,2), where the second integer-pel motion vector adjustment value may be (0,-2), i.e., the symmetric value of (0,2).

[0222] In step c5, a first sub-pel motion vector adjustment value (used to adjust the first original motion vector) and a second sub-pel motion vector adjustment value (used to adjust the second original motion vector) are determined based on the optimal motion vector. For example, the first sub-pel motion vector adjustment value is determined based on a cost value corresponding to the optimal motion vector and a cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and then the second sub-pel motion vector adjustment value is determined based on the first sub-pel motion vector adjustment value.

[0223] For example, x0 = N*(E(-1,0)-E(1,0)) / (E(-1,0)+E(1,0)-2*E(0,0)), and y0 = N*(E(0,-1)-E(0,1)) / (E(0,-1)+E(0,1)-2*E(0,0)). For 1 / 2, 1 / 4, 1 / 8, and 1 / 16 motion vector pixel precision, N is 1, 2, 4, and 8. Next, the value of (x0, y0) is given to deltaMv, so SPMV = deltaMv / 2N. Now, for 1 / 16 motion vector pixel precision, SPMV is (x0 / 16, y0 / 16). SPMV is the first sub-pel motion vector adjustment value. E(0,0) represents the cost value of the optimal motion vector, E(-1,0) represents the cost value of the edge motion vector (-1,0) of the optimal motion vector (0,0) centered around the optimal motion vector, E(1,0) represents the cost value of the edge motion vector (1,0) of the optimal motion vector (0,0) centered around the optimal motion vector, E(0,-1) represents the cost value of the edge motion vector (0,-1) of the optimal motion vector (0,0) centered around the optimal motion vector, and E(0,1) represents the cost value of the edge motion vector (0,1) of the optimal motion vector (0,0) centered around the optimal motion vector. For the method of determining the cost values ​​of each motion vector, refer to the above-mentioned embodiment. After determining the first sub-pel motion vector adjustment value using the above-mentioned method, a second sub-pel motion vector adjustment value, which is the symmetric value of the first sub-pel motion vector adjustment value, can be determined based on the first sub-pel motion vector adjustment value. For example, if the first sub-pel motion vector adjustment value is (1,0), the second sub-pel motion vector adjustment value is (-1,0), ie, the symmetric value of (1,0).

[0224] In step c6, the first original motion vector is adjusted based on the first integer-pel motion vector adjustment value and / or the first sub-pel motion vector adjustment value to obtain a first target motion vector corresponding to the first original motion vector, for example, the first target motion vector = the first original motion vector + the first integer-pel motion vector adjustment value + the first sub-pel motion vector adjustment value.

[0225] In step c7, the second original motion vector is adjusted based on the second integer-pel motion vector adjustment value and / or the second fractional-pel motion vector adjustment value to obtain a second target motion vector corresponding to the second original motion vector, for example, the second target motion vector = the second original motion vector + the second integer-pel motion vector adjustment value + the second fractional-pel motion vector adjustment value.

[0226] Example 17: In the above example, for each sub-block of the current block, the first original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the first target motion vector of the sub-block, and the second original motion vector is adjusted based on the first pixel value of the first reference block and the second pixel value of the second reference block to obtain the second target motion vector of the sub-block.The original motion vector adjustment process is described by taking the processing process of one sub-block (for example, each of the sub-blocks of the current block with a size of dx*dy) as an example.

[0227] The first original motion vector may be Org_MV0, the second original motion vector may be Org_MV1, the first target motion vector may be Refined_MV0, and the second target motion vector may be Refined_MV1.

[0228] In step d1, some or all of the motion vectors are selected from (2*SR+1)*(2*SR+1) points around the first original motion vector, including the first original motion vector. For example, when SR=2, some or all of the motion vectors are selected from 25 points around the first original motion vector, including the first original motion vector, and these selected motion vectors are designated as candidate motion vectors. A cost value for the first original motion vector is determined, and a cost value for each candidate motion vector is determined. The motion vector with the smallest cost value is designated as the optimal motion vector. Compared with step b1 in the above embodiment, step d1 does not require an iterative process, i.e., it does not require an iterative process of selecting some motion vectors in the first iteration and selecting other motion vectors in the second iteration. This allows all of the candidate motion vectors to be processed to be selected in one go, and then these candidate motion vectors are processed in parallel to obtain a cost value for each candidate motion vector, thereby reducing computational complexity and improving coding performance.

[0229] In step d2, the value of IntegerDeltaMV is determined based on the optimal motion vector, and the final value of IntegerDeltaMV is the first integer pixel motion vector adjustment value. The determination method is not described in detail, and reference can be made to the above embodiment.

[0230] In step d3, the optimum sub-pel offset MV is obtained with the optimum motion vector as the center, and the optimum sub-pel offset is set as SPMV, and the value of SPMV is the first sub-pel motion vector adjustment value.

[0231] The implementation process of step d3 can refer to step b2 above, and will not be described in detail here.

[0232] In step d4, BestMVoffset is obtained based on IntegerDeltaMV and SPMV. For example, BestMVoffset=IntegerDeltaMV+SPMV. Then, target motion vectors: Refined_MV0=Org_MV0+BestMVoffset, Refined_MV1=Org_MV1-BestMVoffset can be obtained based on BestMVoffset.

[0233] Example 18: To adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 16 and Example 17. In this example, all motion vectors can be selected from a total of (2*SR+1)*(2*SR+1) points around and including the original motion vector, with the original motion vector as the center. For example, when SR=2, all motion vectors are selected from 25 points around and including the original motion vector, and the cost values ​​of these motion vectors are determined, and the cost value of each motion vector is determined. The motion vector with the smallest cost value is determined as the optimal motion vector.

[0234] Example 19: To adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 16 and Example 17. In this example, all candidate motion vectors to be processed are selected only once, and therefore these candidate motion vectors can be processed in parallel to obtain cost values ​​for each candidate motion vector, thereby reducing calculation complexity and improving coding performance. In this example, based on the original motion vector, some motion vectors whose offset does not exceed the SR range are selected from a total of (2*SR+1)*(2*SR+1) points around and including the original motion vector.

[0235] For example, N candidate points (N is 1 or more and (2*SR+1)*(2*SR+1) or less) are selected from the (2*SR+1)*(2*SR+1) points including the original motion vector. Next, cost values ​​of the motion vectors corresponding to these N points are determined. Illustratively, the cost values ​​of these N points are scanned in a certain order, and the motion vector with the smallest cost value is selected as the optimal motion vector. If the cost values ​​are the same, the candidate point that comes first in the order is selected first. Illustratively, the cost value is determined based on the downsampling SAD of two predicted values ​​obtained by the candidate motion vectors.

[0236] In one example, when SR=2, there may be 25 candidate points, and the order of these candidate points may be from left to right or from top to bottom. As shown in FIG. 7A, the order of these candidate points may be {Mv(-2,-2), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(2,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), Mv(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-2,2), Mv(-1,2), Mv(0,2), Mv(1,2), Mv(2,2)}. Alternatively, as shown in FIG. 7B, the order of these candidate points may be {Mv(0,0), Mv(-2,-2), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(2,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), Mv(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-2,2), Mv(-1,2), Mv(0,2), Mv(1,2), Mv(2,2)}.

[0237] The cost values ​​corresponding to the motion vectors of these 25 points are determined, and then scanned in the above order. The motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV can then be used to determine the integer pixel motion vector adjustment value and the fractional pixel motion vector adjustment value. The determination method refers to the above embodiment and will not be described in detail here.

[0238] In another example, when SR=2, there may be 21 candidate points, and the candidate points may be ordered from left to right or top to bottom. As shown in Figure 7C, the candidate points may be ordered {Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), Mv(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-1,2), Mv(0,2), Mv(1,2)}. Alternatively, as shown in FIG. 7D, the order of these candidate points may be {Mv(0,0), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), Mv(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-1,2), Mv(0,2), Mv(1,2)}.

[0239] The cost values ​​corresponding to the motion vectors of these 21 points are determined, and then scanned in the above order. The motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV can then be used to determine the integer pixel motion vector adjustment value and the fractional pixel motion vector adjustment value. The determination method refers to the above embodiment and will not be described in detail here.

[0240] In another example, when SR=2, the number of candidate points may be 25, and the candidate points are ordered in descending order of proximity to the center, with the motion vector (0,0) at the center. As shown in FIG. 7E, the order of these candidate points may be {Mv(0,0), Mv(-1,0), Mv(0,-1), Mv(1,0), Mv(0,1), Mv(-1,1), Mv(-1,-1), Mv(1,-1), Mv(1,1), Mv(0,2), Mv(-2,0), Mv(0,-2), Mv(2,0), Mv(1,2), Mv(-1,2), Mv(-2,1), Mv(-2,-1), Mv(-1,-2), Mv(1,-2), Mv(2,-1), Mv(2,1), Mv(-2,2), Mv(-2,-2), Mv(2,-2), Mv(2,2)}. The cost values ​​corresponding to the motion vectors of these 25 points are determined, scanned in the above order, and the motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV can then be used to determine the integer pixel motion vector adjustment value and the fractional pixel motion vector adjustment value. For the determination method, please refer to the above embodiment and will not be described in detail here.

[0241] In another example, when SR=2, there may be 21 candidate points, and the candidate points are ordered from closest to the motion vector (0,0) as the center. As shown in Figure 7F, the candidate points are ordered as follows: {Mv(0,0), Mv(-1,0), Mv(0,-1), Mv(1,0), Mv(0,1), Mv(-1,1), Mv(-1,-1), Mv(1,-1), Mv(1,1), Mv(0,2), Mv(-2,0), Mv(0,-2), Mv(2,0), Mv(1,2), Mv(-1,2), Mv(-2,1), Mv(-2,-1), Mv(-1,-2), Mv(1,-2), Mv(2,-1), Mv(2,1)}. The cost values ​​corresponding to the motion vectors of these 21 points are determined, scanned in the above order, and the motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV is then used to determine the integer pixel motion vector adjustment value and the fractional pixel motion vector adjustment value. For the determination method, refer to the above example.

[0242] In another example, when SR=2, there may be 13 candidate points, and these candidate points are ordered from closest to the motion vector (0,0) as the center. As shown in FIG. 7G, the candidate points are ordered as follows: {Mv(0,0), Mv(-1,0), Mv(0,-1), Mv(1,0), Mv(0,1), Mv(-1,1), Mv(-1,-1), Mv(1,-1), Mv(1,1), Mv(0,2), Mv(-2,0), Mv(0,-2), Mv(2,0)}. The cost values ​​corresponding to the motion vectors of these 13 points are determined and scanned in the above order. The motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV can then be used to determine integer pixel motion vector adjustment values ​​and sub-pel motion vector adjustment values. For the determination method, refer to the above-mentioned embodiment.

[0243] In the above embodiment, if the first candidate motion vector is Mv(0,0), the cost SAD(0,0) of the first candidate motion vector Mv(0,0) is subjected to the process SAD(0,0) = SAD(0,0) - SAD(0,0) / 4, i.e., it is forcibly reduced by 1 / 4, and the above process is not performed on the costs SAD of other candidate motion vectors.

[0244] In one possible embodiment, in the candidate motion vector checking process, there is the following early stopping scheme:

[0245] If the cost SAD(0,0) of the first candidate motion vector (Mv(0,0)) is less than the threshold dx*dy, then no further candidate motion vectors are examined, i.e., the optimal integer pixel offset for the subblock is Mv(0,0).

[0246] If a candidate motion vector has a cost of 0, subsequent candidate motion vectors are not examined and the current candidate motion vector is taken as the best integer pixel offset.

[0247] In the candidate motion vector checking process, if any of the above premature termination situations occurs, the subsequent sub-pixel offset calculation process is skipped, that is, the target motion vector of the sub-block is directly obtained by integer pixel offset.

[0248] Example 20: To adjust the first original motion vector Org_MV0 and the second original motion vector Org_MV1 to the first target motion vector Refined_MV0 and the second target motion vector Refined_MV1, the implementation is similar to Example 16 and Example 17. In this example, all candidate motion vectors to be processed are selected only once, and therefore these candidate motion vectors are processed in parallel to obtain cost values ​​for each candidate motion vector, thereby reducing calculation complexity and improving coding performance. In this example, centered on the original motion vector, some motion vectors whose offsets do not exceed the SR range are selected from (2*SR+1)*(2*SR+1) points. For example, from (2*SR+1)*(2*SR+1) points including the original motion vector, N candidate points (N is 1 or more and (2*SR+1)*(2*SR+1) or less) are selected. Cost values ​​of the motion vectors corresponding to these N points are determined. The cost values ​​of these N points are scanned in a fixed order, and the motion vector with the smallest cost value is selected as the optimal motion vector. If the cost values ​​are the same, the candidate point that comes first in the order is selected first.

[0249] Unlike Example 19, the positions of the candidate points in Example 19 are all fixed, i.e., regardless of the original motion vector, the positions of the candidate points in Example 20 are relative to the original motion vector. Hereinafter, several specific examples will be described.

[0250] For example, when SR=2, there may be 13 candidate points, and these candidate points are ordered in descending order of proximity to the motion vector (0,0) at the center. The order of the candidate points from the center to the first layer is independent of the magnitude of the original motion vector, but the order of the candidate points from the center to the second layer is related to the magnitude of the original motion vector. The order of these candidate points is {Mv(0,0), Mv(-1,0), Mv(0,-1), Mv(1,0), Mv(0,1), Mv(-1,1), Mv(-1,-1), Mv(1,-1), Mv(1,1), Mv(sign_H*2,0), Mv(sign_H*2,sign_V*1), Mv(0,sign_V*2), Mv(0,sign_V*2)}. The first original motion vector is designated MV0, its horizontal component is designated MV0_Hor, and its vertical component is designated MV0_Ver. If MV0_Hor is greater than or equal to 0, then sign_H=1. Otherwise, sign_H=-1. If MV0_Ver is greater than or equal to 0, then sign_V=1. Otherwise, sign_V=-1. The cost values ​​corresponding to the motion vectors of these 13 points are determined, and scanned in the above order. The motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV can then be used to determine integer pixel motion vector adjustment values ​​and sub-pixel motion vector adjustment values. For the determination method, refer to the above embodiment.

[0251] In another example, when SR=2, there may be 13 candidate points, and these candidate points are ordered from closest to the center, with the motion vector (0,0) at the center. The order of the candidate points from the center to the first layer is independent of the magnitude of the original motion vector, but the order of the candidate points from the center to the second layer is related to the magnitude of the original motion vector. The order of these candidate points is {Mv(0,0), Mv(-1,0), Mv(0,-1), Mv(1,0), Mv(0,1), Mv(-1,1), Mv(-1,-1), Mv(1,-1), Mv(1,1), Mv(sign_H*2,0), Mv(sign_H*2,sign_V*1), Mv(0,sign_V*2), Mv(0,sign_V*2)}. The first original motion vector is designated MV0, its horizontal component is designated MV0_Hor, and its vertical component is designated MV0_Ver. If MV0_Hor is greater than 0, then sign_H=1; otherwise, sign_H=-1. If MV0_Ver is greater than 0, then sign_V=1; otherwise, sign_V=-1. The cost values ​​corresponding to the motion vectors of these 13 points are determined, and scanned in the above order. The motion vector with the smallest cost value is obtained as the optimal offset MV. The optimal offset MV can then be used to determine integer pixel motion vector adjustment values ​​and sub-pixel motion vector adjustment values. For the determination method, refer to the above embodiment.

[0252] Example 21: The above example relates to obtaining a first cost value corresponding to a central motion vector and a second cost value corresponding to an edge motion vector based on a first pixel value of a first reference block and a second pixel value of a second reference block, and obtaining a third cost value corresponding to a first original motion vector and a fourth cost value corresponding to a candidate motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block. In one example, the first cost value corresponding to the central motion vector, the second cost value corresponding to an edge motion vector, the third cost value corresponding to the first original motion vector, and the fourth cost value corresponding to a candidate motion vector are obtained based on a first pixel value that has not been downsampled and a second pixel value that has not been downsampled. Alternatively, a downsampling operation is performed on the first pixel value, and a downsampling operation is performed on the second pixel value, and a first cost value corresponding to the central motion vector, a second cost value corresponding to the edge motion vector, a third cost value corresponding to the first original motion vector, and a fourth cost value corresponding to the candidate motion vector are obtained based on the downsampled first pixel value and the downsampled second pixel value. Alternatively, a shift and downsampling operation is performed on the first pixel value, and a shift and downsampling operation is performed on the second pixel value, and then a first cost value corresponding to the central motion vector, a second cost value corresponding to the edge motion vector, a third cost value corresponding to the first original motion vector, and a fourth cost value corresponding to the candidate motion vector are obtained based on the operated first pixel value and the operated second pixel value.

[0253] In other cases, the cost value determination method is the same. For example, to obtain a cost value corresponding to a central motion vector, a sub-reference block A1 corresponding to the central motion vector is obtained by copying from a first reference block, a sub-reference block B1 corresponding to a symmetric motion vector of the central motion vector is obtained by copying from a second reference block, and a cost value corresponding to the central motion vector is obtained by using a first pixel value of the sub-reference block A1 and a second pixel value of the sub-reference block B1. To obtain a cost value corresponding to an edge motion vector, a sub-reference block A2 corresponding to the edge motion vector is obtained by copying from a first reference block, a sub-reference block B2 corresponding to a symmetric motion vector of the edge motion vector is obtained by copying from a second reference block, and a cost value corresponding to the edge motion vector is obtained by using a first pixel value of the sub-reference block A2 and a second pixel value of the sub-reference block B2, and so on.

[0254] As described above, to obtain a cost value corresponding to a motion vector, a sub-reference block corresponding to the motion vector is obtained from the first reference block, and a sub-reference block corresponding to the symmetric motion vector of the motion vector is obtained from the second reference block. Then, the pixel values ​​of the two sub-reference blocks can be used to obtain the cost value corresponding to the motion vector. This process will not be described in detail.

[0255] Example 22: Based on Example 21, a cost value corresponding to a motion vector is obtained based on a first pixel value that is not downsampled (i.e., a pixel value that is not downsampled of a sub-reference block in the first reference block) and a second pixel value that is not downsampled (i.e., a pixel value that is not downsampled of a sub-reference block in the second reference block). For example, if the sub-reference block in the first reference block is pred0 and the sub-reference block in the second reference block is pred1, the cost value is determined based on the SAD of all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1 without performing vertical downsampling on the pixels of the sub-reference block pred0 and the sub-reference block pred1.

[0256] Based on all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1, the cost value is calculated as follows:

[0257]

number

[0258] In the above formula, cost may represent a cost value, W may be the width value of the sub-reference block, H may be the height value of the sub-reference block, pred0(i,j) may represent the pixel value of the i-th column and j-th row of the sub-reference block pred0, pred1(i,j) may represent the pixel value of the i-th column and j-th row of the sub-reference block pred1, and abs(x) may represent the absolute value of x.

[0259] Example 23: Based on Example 21, a downsampling operation is performed on a first pixel value, and a downsampling operation is performed on a second pixel value. A cost value corresponding to a motion vector can be obtained based on the downsampled first pixel value (i.e., the downsampled pixel value of the sub-reference block in the first reference block) and the downsampled second pixel value (i.e., the downsampled pixel value of the sub-reference block in the second reference block). For example, if the sub-reference block in the first reference block is pred0 and the sub-reference block in the second reference block is pred1, the cost value is determined based on the SAD of all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1. When the cost value is determined using the SAD of all pixel values, the pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1 are downsampled vertically by N times (N is an integer greater than 0, and may be 2).

[0260] Based on all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1, the cost value is calculated as follows:

[0261]

number

[0262] In the above formula, cost may represent a cost value, W may be the width value of the sub-reference block, H may be the height value of the sub-reference block, N may represent a downsampling parameter, and may be an integer greater than 0, and may be 2, pred0(1+N(i-1),j) may represent the pixel value of the 1st+N(i-1)th column and jth row of the sub-reference block pred0, pred1(1+N(i-1),j) may represent the pixel value of the 1st+N(i-1)th column and jth row of the sub-reference block pred1, and abs(x) may represent the absolute value of x.

[0263] Example 24: Based on Example 21, a shift and down-sampling operation is performed on a first pixel value, and a shift and down-sampling operation is performed on a second pixel value. According to the first pixel value after the operation (the pixel value of the sub-reference block in the first reference block that is shifted and down-sampled) and the second pixel value after the operation (the pixel value of the sub-reference block in the second reference block that is shifted and down-sampled), a cost value corresponding to a motion vector is obtained. For example, if the sub-reference block in the first reference block is pred0 and the sub-reference block in the second reference block is pred1, pred0 and pred1 are both stored in D bits, that is, each pixel value in pred0 is stored in D bits, and each pixel value in pred1 is stored in D bits.

[0264] If D is 8 or less, the cost value is determined based on the SAD of all pixel values ​​in the sub-reference block pred0 and the sub-reference block pred1. When the cost value is determined using the SAD of all pixel values, the pixel values ​​in the sub-reference block pred0 and the sub-reference block pred1 are vertically downsampled by N times (N is an integer greater than 0, and may be 2). The calculation formula for the cost value based on all pixel values ​​in the sub-reference block pred0 and the sub-reference block pred1 is as follows:

[0265]

number

[0266] In the above formula, cost represents the cost value, W represents the width value of the sub-reference block, H represents the height value of the sub-reference block, N represents the downsampling parameter and is an integer greater than 0, which may be 2, pred0(1+N(i-1),j) represents the pixel value of the 1+N(i-1)th column and jth row of the sub-reference block pred0, pred1(1+N(i-1),j) represents the pixel value of the 1+N(i-1)th column and jth row of the sub-reference block pred1, and abs(x) represents the absolute value of x. Therefore, it can be seen that the sum of the absolute values ​​of the differences between the 1st row, the N+1th row, the 2N+1th row, etc. is calculated.

[0267] If D is greater than 8, first, all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1 are shifted to 8 bits to obtain 8-bit pred0 and 8-bit pred1, and then pred 0-8bit(i,j) and pred 1-8bit(i,j) The purpose is to save the memory cost of SAD calculation and realize higher parallelism with 8-bit memory.

[0268]

number

[0269] Next, the pixel values ​​of 8-bit pred0 and 8-bit pred1 are vertically downsampled by N times (N is an integer greater than 0, which may be 2), and thus the calculation formula for the cost value may be the following formula:

[0270]

number

[0271] In the above formula, the meaning of each expression is not explained in detail here, and reference is made to the above examples.

[0272] Example 25: In the above example, for each sub-block of the current block, a predicted value of the sub-block is determined based on the first target motion vector and the second target motion vector of the sub-block, and a predicted value of the current block is determined based on the predicted value of each sub-block. For example, based on the first target motion vector and the second target motion vector of the sub-block, two reference blocks (i.e., a third reference block and a fourth reference block containing predicted values ​​of three components, and the target motion vector may be a sub-pixel, so interpolation is required) are obtained by interpolation (for example, 8-tap interpolation). Then, weighting is performed based on the third pixel value of the third reference block and the fourth pixel value of the fourth reference block to obtain a final predicted value (for example, a predicted value of three components).

[0273] In one possible embodiment, if the optimal motion vector is the same as the initial motion vector (i.e., the first original motion vector or the second original motion vector), a third reference block corresponding to the sub-block is determined from the first reference picture based on the first target motion vector of the sub-block, and a fourth reference block corresponding to the sub-block is determined from the second reference picture based on the second target motion vector of the sub-block. Pixel values ​​of the third reference block and pixel values ​​of the fourth reference block are weighted to obtain a predicted value of the sub-block.

[0274] For example, if the size of a sub-block is dx*dy, a third reference block having a size of dx*dy is determined from a first reference picture based on a first target motion vector. For example, a reference block having a size of A*B is determined from the first reference picture, where the size of A*B is related to an interpolation method, e.g., A is greater than dx and B is greater than dy, but this is not limited thereto. The third reference block having a size of dx*dy can be obtained by interpolating pixel values ​​in the reference block, but this interpolation method is not limited thereto. A fourth reference block having a size of dx*dy is determined from a second reference picture based on a second target motion vector. For example, a reference block having a size of A*B is determined from the second reference picture, where the size of A*B is related to an interpolation method, e.g., A is greater than dx and B is greater than dy, but this is not limited thereto. The fourth reference block having a size of dx*dy can be obtained by interpolating pixel values ​​in the reference block, but this interpolation method is not limited thereto.

[0275] In another possible embodiment, if the optimal motion vector is different from the initial motion vector, a fifth reference block is determined from the first reference picture, the fifth reference block is expanded to obtain a sixth reference block, and a third reference block corresponding to the sub-block is selected from the sixth reference block based on the first target motion vector of the sub-block. A seventh reference block is determined from the second reference picture, the seventh reference block is expanded to obtain an eighth reference block, and a fourth reference block corresponding to the sub-block is selected from the eighth reference block based on the second target motion vector of the sub-block. Next, pixel values ​​of the third reference block and pixel values ​​of the fourth reference block are weighted to obtain a predicted value of the sub-block.

[0276] For example, if the size of the sub-block is dx*dy, a fifth reference block having a size of dx*dy is determined from the first reference picture based on the first original motion vector. For example, a reference block having a size of A*B is determined from the first reference picture, where A*B is related to the interpolation method, for example, A is greater than dx and B is greater than dy, but this is not limited thereto. The fifth reference block having a size of dx*dy can be obtained by interpolating pixel values ​​in the reference block, but the interpolation method is not limited thereto. Next, the fifth reference block is expanded to obtain a sixth reference block, and the fifth reference block is filled, for example, by copying neighboring values, to the top, bottom, left, and right of the fifth reference block, and the filled reference block is the sixth reference block having a size greater than dx*dy. Next, a third reference block having a size of dx*dy corresponding to the sub-block is selected from the sixth reference block based on the first target motion vector of the sub-block.

[0277] If the size of the sub-block is dx*dy, a seventh reference block having a size of dx*dy is determined from the second reference picture based on the second original motion vector. For example, a reference block having a size of A*B is determined from the second reference picture, where A*B is related to the interpolation method, for example, A is greater than dx and B is greater than dy, but this is not limited thereto. The seventh reference block having a size of dx*dy can be obtained by interpolating pixel values ​​in the reference block, but the interpolation method is not limited thereto. Next, the seventh reference block is expanded to obtain an eighth reference block, and the seventh reference block is filled above, below, left, and right by, for example, copying neighboring values, and the filled reference block is designated as the eighth reference block having a size greater than dx*dy. Next, a fourth reference block having a size of dx*dy corresponding to the sub-block is selected from the eighth reference block based on the second target motion vector of the sub-block.

[0278] Example 26: After obtaining the target motion vector, based on the target motion vector of each sub-block, obtain two-direction predicted values ​​(i.e., three components of YUV, i.e., the predicted value of the third reference block and the predicted value of the fourth reference block) by an 8-tap interpolation filter, and weight them to obtain a final predicted value. Or, based on the target motion vector of each sub-block, obtain two-direction predicted values ​​(i.e., three components of YUV, i.e., the predicted value of the third reference block and the predicted value of the fourth reference block) by a bilinear interpolation filter (not an 8-tap interpolation filter here), and weight them to obtain a final predicted value.

[0279] Example 27: After obtaining predicted values ​​in two directions, the final predicted value is obtained by weighted averaging the average values ​​(i.e., the weights of the predicted values ​​in the two directions are the same). Alternatively, after obtaining predicted values ​​in two directions, the final predicted value is obtained by weighted averaging, and the weights of the two predicted values ​​may be different. For example, the weight ratio of the two predicted values ​​may be 1:2, 1:3, 2:1, etc. For the encoding side, the weight table may include weight ratios such as 1:2, 1:3, 2:1, etc., and the encoding side may determine a cost value for each weight ratio and determine the weight ratio with the smallest cost value. In this way, the encoding side obtains the final predicted value by weighted averaging based on the weight ratio with the smallest cost value. When the encoding side transmits an encoded bitstream to the decoding side, the encoded bitstream includes an index value in the weight table of the weight ratio. In this way, the decoding side analyzes the index value of the encoded bitstream to obtain the weight ratio corresponding to the index value from the weight table, and obtains the final predicted value by weighted averaging based on the weight ratio.

[0280] In one example, the weight table may include, but is not limited to, {-2, 3, 4, 5, 10}. Illustratively, the sum of two weights may be 8. Each weight may be a negative value, as long as the sum of the two weights is 8.

[0281] For example, a weight of "-2" is a negative value, and when one predictor has a weight of -2, the other predictor has a weight of 10, i.e., the sum of the two weights is 8. In this case, the final predicted value = (predicted value 1 * (-2) + predicted value 2 * (8 - (-2))).

[0282] For example, a weight of "10" indicates that one predicted value has a weight of 10, while the other has a weight of -2, i.e., the sum of the two weights is 8, and in this case, the final predicted value = (predicted value 1 * (10) + predicted value 2 * (-2)).

[0283] For example, a weight of "3" indicates that one predicted value has a weight of 3, while the other has a weight of 5, i.e., the sum of the two weights is 8, and in this case, the final predicted value = (predicted value 1 * (3) + predicted value 2 * (5)).

[0284] For example, a weight of "5" indicates that one predicted value has a weight of 5, while the other predicted value has a weight of 3, i.e., the sum of the two weights is 8, and in this case, the final predicted value = (predicted value 1 * (5) + predicted value 2 * (3)).

[0285] For example, a weight of "4" indicates that one predicted value has a weight of 4, but the other predicted value has a weight of 4, i.e., the sum of the two weights is 8, and in this case, the final predicted value = (predicted value 1 * (4) + predicted value 2 * (4)).

[0286] In one possible embodiment, for each sub-block of the current block, referring to the above example, the third pixel value of the third reference block and the fourth pixel value of the fourth reference block are obtained, and then weighted based on the third pixel value of the third reference block and the fourth pixel value of the fourth reference block to obtain a final predicted value. For example, the third pixel value, the first weight corresponding to the third pixel value, the fourth pixel value, and the second weight corresponding to the fourth pixel value are weighted to obtain a predicted value of the sub-block. When the final predicted value is obtained by weighted averaging the average values ​​(i.e., the two weights are the same), the first weight is the same as the second weight.

[0287] Embodiment 28: In the above embodiment, the first target motion vector and the second target motion vector of each sub-block of the current block are stored, or the first original motion vector and the second original motion vector of each sub-block of the current block are stored, or the first original motion vector, the second original motion vector, the first target motion vector and the second target motion vector of each sub-block of the current block are stored. The stored motion vectors are used as reference for encoding / decoding subsequent blocks.

[0288] For example, the first and second target motion vectors of each sub-block of a current block are stored, and the first and second target motion vectors are used for loop filtering of the current picture, the first and second target motion vectors are used for temporal domain reference of a subsequent frame, and / or the first and second target motion vectors are used for spatial domain reference of the current picture. For example, the first and second target motion vectors of each sub-block of the current block may be used for motion compensation of the current block or for temporal domain reference of a subsequent frame. Also, for example, the first and second target motion vectors of each sub-block of the current block may be used for motion compensation of the current block, for the loop filtering process of the current block, or for temporal domain reference of a subsequent frame. For example, the first target motion vector and the second target motion vector of each sub-block of the current block may be used for motion compensation of the current block, may be used for loop filtering process of the current block, may be used for temporal domain reference of a subsequent frame, or may be used for spatial domain reference of the current picture, as will be described below.

[0289] The first and second target motion vectors of each subblock of the current block may be used for spatial domain reference of blocks within a certain LCU (Largest Coding Unit) in the spatial domain. The encoding and decoding order is top-to-bottom and left-to-right, so the motion vector of the current block may be referenced by other blocks within the current LCU or by blocks in subsequent neighboring LCUs. Because the amount of calculation required to obtain the target motion vector is large, a long wait is required when a subsequent block references the target motion vector of the current block. To avoid delays due to excessive waiting, only a small number of spatially neighboring blocks may reference the target motion vector of the current block, and other blocks reference the original motion vector of the current block.

[0290] Illustratively, these few blocks include sub-blocks located in the lower LCU and lower right LCU located below the current LCU, while sub-blocks located in the right LCU and left LCU cannot reference the target motion vector of the current block.

[0291] Example 29: The following describes the adjustment process of a motion vector with reference to a specific example. The specific steps of adjusting a motion vector may be as follows: According to the following "copy", it is indicated that it can be obtained without interpolation, and if the MV (i.e., the motion vector) is an integer pixel offset, it can be directly copied from the reference picture; otherwise, it needs to be interpolated.

[0292] In step e1, when the motion vector adjustment mode is activated for the current block, the following process is carried out.

[0293] In step e2, a reference pixel value is prepared (the width of the current block is W and the height is H).

[0294] 8, based on the original motion vectors (the original motion vector of list0 is Org_MV0, and the original motion vector of list1 is Org_MV1), two integer pixel blocks each having an area of ​​(W+FS-1)*(H+FS-1) and three components are copied from the corresponding positions of the corresponding reference pictures. Also, integer pixel blocks for step e4 are prepared: based on the (W+FS-1)*(H+FS-1) integer pixel block, the integer pixel block having an area of ​​(W+FS-1)*(H+FS-1) and three components is expanded by SR rows / columns in the vertical and horizontal directions, respectively. After the expansion, integer pixel blocks having an area of ​​(W+FS-1+2*SR)*(H+FS-1+2*SR) and three components are obtained, and these are designated as Pred_Inter0 and Pred_Inter1. Illustratively, the size of the inner black region is the size of the current block, the outer extended white region is the additional reference pixels required to interpolate the original motion vector with an 8-tap filter, and the outer black region is the additional reference pixels required to interpolate the target motion vector with an 8-tap filter.

[0295] While the pixel values ​​of the black and white regions of the inner layer W*H are obtained from a reference picture, the pixel values ​​of the outer black region do not need to be obtained from a reference picture and can be obtained by copying neighboring pixel values. In one example, the W+FS-1 pixel values ​​of the first row of the white region are copied to the pixel values ​​of the first SR rows of the outer black region. The W+FS-1 pixel values ​​of the last row of the white region are copied to the pixel values ​​of the last SR rows of the outer black region. Next, the H+FS-1 pixel values ​​of the first column of the white region and the pixel values ​​of the SR acquired outer black regions above and below are copied to the pixel values ​​of the first SR columns of the outer black region. The H+FS-1 pixel values ​​of the last column of the white region and the pixel values ​​of the SR acquired outer black regions above and below are copied to the pixel values ​​of the last SR columns of the outer black region. In another example, the H+FS-1 pixel values ​​of the first column of the white region are copied to the pixel values ​​of the first SR columns of the outer black region. The H+FS-1 pixel values ​​in the last column of the white region are copied to the pixel values ​​of the last SR column of the outer black region. Next, the W+FS-1 pixel values ​​in the first row of the white region and the SR pixel values ​​of the acquired outer black regions on each side are copied to the pixel values ​​of the first SR row of the outer black region. The W+FS-1 pixel values ​​in the last row of the white region and the SR pixel values ​​of the acquired outer black regions on each side are copied to the pixel values ​​of the last SR row of the outer black region.

[0296] First, motion compensation is performed based on motion information in two different directions. For example, for the luminance component (which is used to calculate the cost value in the subsequent search process), two integer pixel reference blocks with an area of ​​(W+FS-1)*(H+FS-1) are used as the basis, and two initial reference prediction blocks with a size of (W+2*SR)*(H+2*SR) are obtained by bilinear interpolation (Pred_Bilinear0 and Pred_Bilinear1), where FS is the number of filter taps and is set to 8 by default, and SR is the search range, i.e., the maximum horizontal / vertical component interpolation between the target motion vector and the original motion vector and is set to 2 by default. Pred_Bilinear0 / 1 are used in step e3.

[0297] In step e3, a target motion vector is obtained for each of the dx*dy sub-blocks of the current block (the target motion vectors in the two directions are designated as Refined_MV0 and Refined_MV1, respectively).

[0298] In step e31, SR iterations are performed, the integer pixel offset of the optimal integer pixel MV point is obtained, and set as IntegerDeltaMV, and IntegerDeltaMV is initialized to (0,0), and the following process is performed in each iteration.

[0299] In step e311, deltaMV is set to (0,0). In the first iteration process, based on the original motion vector, copy the reference pixel Pred_Bilinear0 / 1 to obtain two predicted blocks (the W*H block at the center of Pred_Bilinear0 / 1), and based on these two predicted blocks, obtain an initial cost value, that is, SAD obtained by vertically downsampling the predicted blocks in two directions by 2 times. If the initial cost value is less than dx*dy (dx and dy are the width and height of the current sub-block), skip the subsequent search process directly and perform step e32, setting notZeroCost to false.

[0300] In step e312, 24 offset MVs (all of these 24 offset MVs are called MVOffset) are obtained in the order of {Mv(-2,-2), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(2,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-2,2), Mv(-1,2), Mv(0,2), Mv(1,2), Mv(2,2)}, with the initial point as the center, and a calculation and comparison process of the cost values ​​of these offset MVs is performed. For example, based on a certain MVOffset, two predicted value blocks are obtained at the reference pixel Pred_Bilinear0 / 1 using MVOffset (i.e., a block of W*H obtained by applying the center position offset MVOffset in Pred_Bilinear0, and a block of W*H obtained by applying the center position offset -MVOffset (the opposite of list0) in Pred_Bilinear1), and the downsampling SAD of these two blocks is calculated as the cost value of MVOffset. The MVOffset with the smallest cost value is retained (stored in deltaMV).

[0301] Update IntegerDeltaMV:IntegerDeltaMV=deltaMV based on deltaMV value.

[0302] In step e313, if after one iteration, the optimal MV is still the initial MV or the minimum cost value is 0, the next iterative search process is not performed, and step e32 is performed to set notZeroCost as false.

[0303] In step e32, the optimal sub-pel offset MV is obtained centered on the optimal integer-pel MV point of step e31, and is designated as the SPMV (ie, subMV), and the SPMV is initialized to (0,0), and then the following process is performed.

[0304] In step e321, only if notZeroCost is not false and deltaMV is (0,0), the subsequent processing is carried out; otherwise, the original motion vector is adjusted directly using IntegerDeltaMV.

[0305] In step e322, E(x,y) is expressed as the cost value (cost value calculated in step e31) corresponding to the MV obtained by offsetting the optimal MV point obtained in step e31 by (x,y). Based on E(x,y) of the center and five points above, below, left, and right, the offset (x0,y0) of the point with the smallest E(x,y) can be obtained: x0 = N*(E(-1,0) - E(1,0)) / (E(-1,0) + E(1,0) - 2*E(0,0)), y0 = N*(E(0,-1) - E(0,1)) / (E(0,-1) + E(0,1) - 2*E(0,0)). In one example, N is 1, 2, 4, and 8 for motion vector pixel precisions of 1 / 2, 1 / 4, 1 / 8, and 1 / 16. Next, the value of (x0, y0) is given to deltaMv, so that SPMV = deltaMv / 2N. Now, for a motion vector pixel precision of 1 / 16, SPMV may be (x0 / 16, y0 / 16).

[0306] If E(-1,0)=E(0,0), then offset horizontally to the left by half a pixel (deltaMv[0]=-N).

[0307] If E(1,0)=E(0,0), then offset horizontally to the right by half a pixel (deltaMv[0]=N).

[0308] If E(0,-1)=E(0,0), then offset vertically upwards by half a pixel (deltaMv[1]=-N).

[0309] If E(0,1)=E(0,0), then offset vertically downward by half a pixel (deltaMv[1]=N).

[0310] In step e33, an optimal offset MV is obtained based on the integer pixel offset IntegerDeltaMV obtained in step e31 and the sub-pixel offset SPMV obtained in step e32. The optimal offset MV is designated BestMVoffset. BestMVoffset=IntegerDeltaMV+SPMV. Based on BestMVoffset, target motion vectors in two directions are obtained: Refined_MV0=Org_MV0+BestMVoffset, Refined_MV1=Org_MV1-BestMVoffset.

[0311] In step e4, based on the target motion vector of each sub-block, 8-tap interpolation is performed to obtain predicted values ​​of three components in two directions, and weighted to obtain a final predicted value (e.g., predicted value of three components). For example, based on the target motion vectors Refined_MV0 and Refined_MV1 of each sub-block, the corresponding predicted block is obtained in Pred_Inter0 / 1 prepared in step e2 by interpolation (because the motion vector may be a fractional pixel, interpolation is required to obtain the corresponding pixel block).

[0312] In step e5, the target motion vector is used for motion compensation of the current block (i.e., obtaining the predicted values ​​of each sub-block and the predicted value of the current block) and temporal domain referencing of the subsequent frame, but is not used for loop filtering of the current picture and spatial domain referencing.

[0313] Example 30: The difference from Example 29 is that the reference pixel preparation process is transferred to each dx*dy sub-block. When preparing the reference pixels, only the (dx+(filtersize-1))*(dy+(filtersize-1)) pixel block is prepared. If the optimal motion vector obtained by searching is not the original motion vector, the reference pixels are extended. Otherwise, they are not extended. For each dx*dy sub-block of the current block, a target motion vector is obtained, and motion compensation is performed according to the target motion vector, and weighted to obtain the final predicted value. The following process is performed for each dx*dy sub-block of the current block.

[0314] In step f1, when the motion vector adjustment mode is activated for the current block, the following process is performed.

[0315] In step f2, integer pixel blocks are prepared for step f3: for example, for the luminance component only, based on the original motion vectors (the original motion vector of list0 is Org_MV0, and the original motion vector of list1 is Org_MV1), two integer pixel blocks with an area of ​​(dx+(filtersize-1))*(dy+(filtersize-1)) are obtained from the corresponding positions of the corresponding reference picture.

[0316] Illustratively, filtersize may be the number of filter taps, which is 8 by default.

[0317] In step f3, a target motion vector (the target motion vectors in two directions are designated as Refined_MV0 and Refined_MV1) is obtained for each of the dx*dy sub-blocks of the current block.

[0318] Illustratively, the implementation process of step f3 can refer to step e3, and will not be repeated here.

[0319] For example, the first motion vector compensation is performed based on the original motion vector. For the luminance component only, an initial predicted value with a size of (dx+2*IterNum)*(dy+2*IterNum) is obtained by bilinear interpolation, where IterNum is 2 by default. IterNum may be the search range SR, which may be the maximum horizontal / vertical component interpolation of the target motion vector and the original motion vector. The initial predicted value of the original motion vector obtained above is stored in m_cYuvPredTempL0 / 1.

[0320] Calculate the cost values ​​of 25 points and obtain the integer pixel offset of the optimal integer pixel MV point. If it is the first point (MV offset is (0,0)), obtain the initial cost (cost is the SAD of the predicted values ​​in two directions downsampled by 2 times vertically). If the cost is less than dx*dy, directly skip the subsequent search process (set notZeroCost as false). Centered on the initial point, calculate and compare the costs of 24 points, and leave the point with the smallest cost as the new center point for the next step. Centered on the optimal integer pixel MV point, obtain the optimal 1 / 16-pixel sub-pixel offset. Based on the integer pixel offset and sub-pixel offset, obtain the optimal offset MV, which is defined as BestMVoffset. BestMVoffset=IntegerDeltaMV+SPMV. Based on BestMVoffset, obtain target motion vectors in two directions: Refined_MV0=Org_MV0+BestMVoffset, Refined_MV1=Org_MV1-BestMVoffset.

[0321] In step f4, if the optimal offset MV is (0,0), the following steps are not performed (i.e., if the original motion vector is used, no further extension is performed). If the optimal offset MV is not (0,0), integer pixels are reacquired (since the reference pixels were not extended in the above step, the reference pixels required after the offset exceed the range of the reference pixels acquired in the above step), and the following steps are performed.

[0322] For the reference pictures in list0 and the reference pictures in list1, for each U / V component (since the luminance component was obtained in step f2): obtain an integer pixel value of (dxc+(filtersizeC-1))*(dyc+(filtersizeC-1)) from the reference picture, where dxc and dyc are related to the sampling rate. If YUV has a sampling rate of 420, then dxc=dx / 2 and dyc=dy / 2. Of course, this is just an example, and dxc and dyc are not limited. filtersizeC may be 4, but of course, this is just an example, and filtersizeC is not limited. Also, for example, an integer pixel value of dx*dy may be obtained directly from the reference picture, but this is not limited.

[0323] For the reference pictures in list0 and list1, three components are filled in. For example, by copying neighboring values, the integer pixel values ​​obtained in the above step (for example, the integer pixel value of (dxc+(filtersizeC-1))*(dyc+(filtersizeC-1))) are used as a base to fill in the top, bottom, left, and right directions (for example, the fill width and luminance component are 2, and the chroma component of 420 is 1). Illustratively, available integer pixel values ​​around the current sub-block (within the current CU block) are not used here.

[0324] In step f5, based on the target motion vector of each sub-block and the two reference pixel blocks (obtained in step f4), 8-tap interpolation is performed to obtain predicted values ​​of three components in two directions, and then weighted to obtain a final predicted value (e.g., predicted value of three components).

[0325] Example 31: The above examples may be carried out alone or in any combination, and there is no limitation thereon.

[0326] For example, Example 4 may be implemented in combination with Example 2, and Example 4 may be implemented in combination with Example 3.

[0327] Example 5 may be implemented in combination with Example 2, Example 5 may be implemented in combination with Example 2 and Example 4, Example 5 may be implemented in combination with Example 3, and Example 5 may be implemented in combination with Example 3 and Example 4.

[0328] Example 6 may be performed alone, Example 7 may be performed alone, Example 8 may be performed in combination with Example 7, Example 9 may be performed in combination with Example 7, Example 10 may be performed in combination with Example 7, Example 11 may be performed in combination with Example 7, Example 12 may be performed in combination with Example 7, Example 13 may be performed in combination with Example 7, Example 14 may be performed in combination with Example 7, and Example 15 may be performed in combination with Example 7.

[0329] Example 16 may be performed alone, Example 17 may be performed alone, Example 18 may be performed in combination with Example 17, Example 19 may be performed in combination with Example 17, and Example 20 may be performed in combination with Example 17.

[0330] Example 21 may be performed in combination with Example 6, Example 21 may be performed in combination with Example 16, Example 21 may be performed in combination with Example 7, Example 21 may be performed in combination with Example 17, Example 22 may be performed in combination with Example 21, Example 23 may be performed in combination with Example 21, and Example 24 may be performed in combination with Example 21.

[0331] Example 25 may be performed in combination with Example 2, Example 25 may be performed in combination with Example 2 and Example 4, Example 25 may be performed in combination with Example 3, and Example 25 may be performed in combination with Example 3 and Example 4.

[0332] Example 26 may be performed in combination with Example 25, and Example 27 may be performed in combination with Example 25.

[0333] Example 28 may be performed in combination with Example 2, Example 28 may be performed in combination with Example 2 and Example 4, Example 28 may be performed in combination with Example 3, and Example 28 may be performed in combination with Example 3 and Example 4.

[0334] Example 29 may be carried out alone, or may be combined with Example 4. Example 30 may be carried out alone, or may be combined with Example 4. Of course, the above are only some examples of the present application, but the present application is not limited thereto, and all examples of the present application may be carried out alone or in combination, which will not be described in detail.

[0335] Example 32, Based on the same inventive concept as the above method, an embodiment of the present invention further provides an encoding and decoding device, which is applied to the encoding side or the decoding side, for example, as shown in Figure 9A, which is a structural diagram of the device, and the device comprises: As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. a determining module 911 for determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are satisfied; and a motion compensation module 912 for performing motion compensation on the current block if it determines to activate the motion vector adjustment mode for the current block.

[0336] Specifically, the motion compensation module 912 performs the following for each sub-block of the at least one sub-block included in the current block: determining a first reference block corresponding to the sub-block based on a first original motion vector of the sub-block, determining a second reference block corresponding to the sub-block based on a second original motion vector of the sub-block, adjusting the first original motion vector and the second original motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block, obtaining a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, and determining a predicted value of the sub-block based on the first target motion vector and the second target motion vector; It is used to determine the predicted value of the current block based on the predicted value of each sub-block.

[0337] The determination module 911 further comprises: As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. It is used to determine that if any of the conditions that the sizes of the two reference pictures of the current block are both the same as the size of the current picture is not met, the motion vector adjustment mode is not activated for the current block.

[0338] The control information allowing the current block to use the motion vector adjustment mode includes sequence level control information allowing the current block to use the motion vector adjustment mode and / or picture level control information allowing the current block to use the motion vector adjustment mode.

[0339] The width, height, and area of ​​the current block are all within the limited ranges, including the width being equal to or greater than a first threshold, the height being equal to or greater than a second threshold, and the area being equal to or greater than a third threshold, or the width being equal to or greater than the first threshold, the height being equal to or greater than the second threshold, and the area being greater than a fourth threshold, and the third threshold being greater than the fourth threshold.

[0340] The first threshold is 8, the second threshold is 8, the third threshold is 128, and the fourth threshold is 64.

[0341] When the motion compensation module 912 determines a first reference block corresponding to the sub-block based on the first original motion vector of the sub-block and determines a second reference block corresponding to the sub-block based on the second original motion vector of the sub-block, specifically: determining a first reference block corresponding to the sub-block from a first reference picture according to a first original motion vector of the sub-block, wherein a pixel value of each pixel point in the first reference block is obtained by interpolating pixel values ​​of neighboring pixel points in the first reference block or by copying pixel values ​​of neighboring pixel points in the first reference block; Based on the second original motion vector of the sub-block, a second reference block corresponding to the sub-block is determined from a second reference picture, and the pixel value of each pixel point in the second reference block is obtained by interpolating the pixel values ​​of neighboring pixel points in the second reference block, or by copying the pixel values ​​of neighboring pixel points in the second reference block.

[0342] When the motion compensation module 912 adjusts the first original motion vector and the second original motion vector according to a first pixel value of the first reference block and a second pixel value of the second reference block to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, specifically: Selecting some or all of the motion vectors from the motion vectors around an initial motion vector, including the initial motion vector, and determining the selected motion vectors as candidate motion vectors, wherein the initial motion vector is the first original motion vector or the second original motion vector; selecting one motion vector from the initial motion vector and each candidate motion vector as an optimal motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block; It is used to adjust the first original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector, and to adjust the second original motion vector based on the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector.

[0343] Specifically, when the motion compensation module 912 adjusts the first original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector, and adjusts the second original motion vector based on the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector, determining a first integer-pel motion vector adjustment value, a second integer-pel motion vector adjustment value, a first sub-pel motion vector adjustment value, and a second sub-pel motion vector adjustment value for the sub-block based on the optimal motion vector; adjusting the first original motion vector based on the first integer-pel motion vector adjustment value and the first sub-pel motion vector adjustment value to obtain a first target motion vector for the sub-block; The second original motion vector is adjusted based on the second integer-pel motion vector adjustment value and the second sub-pel motion vector adjustment value to obtain a second target motion vector for the sub-block.

[0344] If the optimal motion vector is the same as the initial motion vector, when the motion compensation module 912 determines the predicted value of the sub-block based on the first target motion vector and the second target motion vector, specifically: determining a third reference block corresponding to the sub-block from a first reference picture based on the first target motion vector of the sub-block; determining a fourth reference block corresponding to the sub-block from a second reference picture based on a second target motion vector of the sub-block; The pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block are weighted and used to obtain a prediction value for the sub-block.

[0345] If the optimal motion vector is different from the initial motion vector, when the motion compensation module 912 determines the predicted value of the sub-block based on the first target motion vector and the second target motion vector, specifically: determining a fifth reference block from a first reference picture, extending the fifth reference block to obtain a sixth reference block, and selecting a third reference block from the sixth reference block corresponding to the sub-block according to a first target motion vector of the sub-block; determining a seventh reference block from a second reference picture, extending the seventh reference block to obtain an eighth reference block, and selecting a fourth reference block corresponding to the sub-block from the eighth reference block according to a second target motion vector of the sub-block; The pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block are weighted and used to obtain a prediction value for the sub-block.

[0346] When the motion compensation module 912 weights the pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block, specifically, it performs a weighting process on the pixel values ​​of the third reference block, a first weight corresponding to the pixel values ​​of the third reference block, the pixel values ​​of the fourth reference block, and a second weight corresponding to the pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block, and the first weight and the second weight are the same.

[0347] From a hardware perspective, a schematic diagram of the hardware architecture of a decoding device according to an embodiment of the present invention can be specifically referred to in Figure 9B. The decoding device includes a processor 921 and a machine-readable storage medium 922, in which machine-executable instructions executable by the processor 921 are stored, and the processor 921 is used to implement the methods disclosed in the above embodiments of the present invention by executing the machine-executable instructions. For example, the processor is used to realize the following steps by executing the machine-executable instructions:

[0348] As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are satisfied; performing motion compensation on the current block if it is determined to activate the motion vector adjustment mode for the current block;

[0349] From a hardware perspective, a schematic diagram of the hardware architecture of an encoding device according to an embodiment of the present invention can be specifically referred to in Figure 9C. The encoding device includes a processor 931 and a machine-readable storage medium 932, in which machine-executable instructions executable by the processor 931 are stored. The processor 931 is used to implement the methods disclosed in the above embodiments of the present invention by executing the machine-executable instructions. For example, the processor is used to realize the following steps by executing the machine-executable instructions:

[0350] As control information, a condition that allows the current block to use the motion vector adjustment mode; The prediction mode of the current block is the normal fusion mode, or the prediction mode of the current block is the fusion mode or the skip mode, and the prediction mode of the current block is not a mode other than the normal fusion mode; The prediction value of the current block is obtained by weighting reference blocks from two reference pictures, the two reference pictures are respectively before and after the current picture in display order, and the distances from the two reference pictures to the current picture are the same; The condition that the weighting weights of the two reference pictures of the current block are the same; The condition that the two reference pictures of the current block are both short-term reference pictures; The width, height, and area of ​​the current block must all be within the specified range. determining to activate a motion vector adjustment mode for the current block if all the conditions that the sizes of the two reference pictures of the current block are the same as the size of the current picture are satisfied; performing motion compensation on the current block if it is determined to activate the motion vector adjustment mode for the current block;

[0351] Based on the same inventive concept as the above method, an embodiment of the present invention further provides a machine-readable storage medium on which a plurality of computer instructions are stored, which, when executed by a processor, can implement the encoding and decoding method disclosed in the above example of the present invention. The machine-readable storage medium may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable commands, data, etc. For example, the machine-readable storage medium may be a random access memory (RAM), a volatile memory, a non-volatile memory, a flash memory, a storage drive (e.g., a hard disk drive), a solid-state drive, any type of storage disk (e.g., an optical disk, a DVD, etc.), or a similar storage medium, or a combination thereof.

[0352] Based on the same inventive concept as the above method, an embodiment of the present invention further provides a computer program product including computer instructions, which, when executed by a processor, can implement the encoding and decoding methods disclosed in the above examples of the present invention.

[0353] Based on the same inventive concept as the above method, an embodiment of the present invention further provides an encoding and decoding system, including a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions executable by the processor, which, when executed by the processor, can implement the encoding and decoding method disclosed in the above example of the present invention.

[0354] The systems, devices, modules, or units described in the above embodiments may be specifically implemented by computer chips or entities, or may be implemented by products having certain functions. A typical implementation device is a computer, and the specific form of the computer may be a personal computer, laptop computer, mobile phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email sending / receiving device, game console, tablet computer, wearable device, or a combination of any two or more of these devices. For ease of explanation, the above devices will be described by dividing them into various units based on their functions. It should be understood that when implementing the present invention, the functions of each unit may be implemented by the same or multiple pieces of software and / or hardware.

[0355] As will be appreciated by those skilled in the art, embodiments of the present invention may be provided as a method, a system, or a computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Embodiments of the present invention may take the form of a computer program product embodied in one or more computer-usable storage media (including, but not limited to, disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code. This application will be described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that computer program instructions can implement each flow and / or block in the flowcharts and / or block diagrams, and combinations of flows and / or blocks in the flowcharts and / or block diagrams. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, and the instructions, executed by the processor of the computer or other programmable data processing device, generate an apparatus for implementing the functions specified in one or more flows and / or one or more blocks in the flowcharts and / or block diagrams.

[0356] These computer program instructions may be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable memory create an article of manufacture that includes an instruction apparatus that implements the functions specified in one or more flows of the flowcharts and / or one or more blocks of the block diagrams. These computer program instructions may be loaded into a computer or other programmable data processing device that causes the computer or other programmable device to perform a series of operational steps to create a computer-implemented process, such that the instructions executed on the computer or other programmable device provide the steps for implementing the functions specified in one or more flows of the flowcharts and / or one or more blocks of the block diagrams.

[0357] The above is merely an example of the present application and is not intended to limit the present application. Those skilled in the art can make various modifications and variations to the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of the claims of the present invention.

Claims

1. A coding / decoding method, comprising: if it is determined that the motion vector adjustment mode is used for the current block, performing motion compensation on the current block to obtain a predicted value of the current block; The step of performing motion compensation on the current block to obtain a predicted value of the current block includes: For each sub-block of the at least one sub-block included in the current block, determining a first reference block corresponding to the sub-block based on a first original motion vector of the sub-block, and determining a second reference block corresponding to the sub-block based on a second original motion vector of the sub-block; adjusting the first original motion vector and the second original motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector; determining a prediction value for the sub-block based on the first target motion vector and the second target motion vector; determining a predicted value of the current block based on the predicted values ​​of all sub-blocks; adjusting the first original motion vector and the second original motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, selecting all motion vectors as candidate motion vectors from (2*SR+1)*(2*SR+1) motion vectors around an initial motion vector and including the initial motion vector; determining a cost value of the candidate motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block, regardless of whether a cost value corresponding to the initial motion vector is less than a predetermined threshold, and determining the motion vector with the smallest cost value as an optimal motion vector; adjusting the first original motion vector and the second original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector; the initial motion vector is the first original motion vector or the second original motion vector; SR represents the search range, and when the value of SR is 2, the search order of the 25 candidate motion vectors is {Mv(0,0), Mv(-2,-2), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(2,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), M v(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-2,2), Mv(-1,2), Mv(0,2), Mv(1,2), Mv(2,2)}, Mv(0,0) is the initial motion vector, and the other candidate motion vectors except Mv(0,0) are offset motion vectors of the initial motion vector, adjusting the first original motion vector and the second original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, determining a first integer-pel motion vector adjustment value based on the optimal motion vector, and determining a second integer-pel motion vector adjustment value based on the first integer-pel motion vector adjustment value; adjusting the first original motion vector based on the first integer-pel motion vector adjustment value to obtain a first target motion vector corresponding to the first original motion vector, and adjusting the second original motion vector based on the second integer-pel motion vector adjustment value to obtain a second target motion vector corresponding to the second original motion vector.

2. The step of determining a first reference block corresponding to the sub-block based on a first original motion vector of the sub-block and determining a second reference block corresponding to the sub-block based on a second original motion vector of the sub-block includes: determining a first reference block corresponding to the sub-block from a first reference picture based on a first original motion vector of the sub-block, wherein a pixel value of each pixel point in the first reference block is obtained by interpolating pixel values ​​of neighboring pixel points in the first reference block or by copying pixel values ​​of neighboring pixel points in the first reference block; 2. The method of claim 1, further comprising: a step of determining a second reference block corresponding to the sub-block from a second reference picture based on a second original motion vector of the sub-block, wherein pixel values ​​of each pixel point in the second reference block are obtained by interpolating pixel values ​​of neighboring pixel points in the second reference block or by copying pixel values ​​of neighboring pixel points in the second reference block.

3. If the optimal motion vector is the same as the original motion vector, determining a predicted value of the sub-block based on the first target motion vector and the second target motion vector includes: determining a third reference block corresponding to the sub-block from a first reference picture based on a first target motion vector of the sub-block; determining a fourth reference block corresponding to the sub-block from a second reference picture based on a second target motion vector of the sub-block; and weighting pixel values ​​of the third reference block and pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block.

4. If the optimal motion vector is different from the original motion vector, determining a predicted value of the sub-block based on the first target motion vector and the second target motion vector includes: determining a fifth reference block from a first reference picture, extending the fifth reference block to obtain a sixth reference block, and selecting a third reference block from the sixth reference block corresponding to the sub-block based on a first target motion vector of the sub-block; determining a seventh reference block from a second reference picture, extending the seventh reference block to obtain an eighth reference block, and selecting a fourth reference block from the eighth reference block corresponding to the sub-block based on a second target motion vector of the sub-block; and weighting pixel values ​​of the third reference block and pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block.

5. The step of weighting pixel values ​​of the third reference block and pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block includes: a step of performing a weighting process on pixel values ​​of the third reference block, first weights corresponding to pixel values ​​of the third reference block, pixel values ​​of the fourth reference block, and second weights corresponding to pixel values ​​of the fourth reference block to obtain a predicted value of the sub-block; 5. The method of claim 3, wherein the first weight and the second weight are the same.

6. A coding / decoding device, a motion compensation module for performing motion compensation on the current block to obtain a predicted value of the current block when determining to use a motion vector adjustment mode for the current block; The motion compensation module performs motion compensation on the current block to obtain a predicted value of the current block, For each sub-block of the at least one sub-block included in the current block, determining a first reference block corresponding to the sub-block based on a first original motion vector of the sub-block, and determining a second reference block corresponding to the sub-block based on a second original motion vector of the sub-block; adjusting the first original motion vector and the second original motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector; determining a prediction value for the sub-block based on the first target motion vector and the second target motion vector; used to determine a predicted value of the current block based on the predicted values ​​of all sub-blocks; the motion compensation module adjusts the first original motion vector and the second original motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, Selecting all motion vectors as candidate motion vectors from (2*SR+1)*(2*SR+1) motion vectors around and including the initial motion vector; determining a cost value of the candidate motion vector based on a first pixel value of the first reference block and a second pixel value of the second reference block, regardless of whether a cost value corresponding to the initial motion vector is less than a predetermined threshold, and determining the motion vector with the smallest cost value as an optimal motion vector; adjusting the first original motion vector and the second original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector; the initial motion vector is the first original motion vector or the second original motion vector; SR represents the search range, and when the value of SR is 2, the search order of the 25 candidate motion vectors is {Mv(0,0), Mv(-2,-2), Mv(-1,-2), Mv(0,-2), Mv(1,-2), Mv(2,-2), Mv(-2,-1), Mv(-1,-1), Mv(0,-1), Mv(1,-1), Mv(2,-1), Mv(-2,0), Mv(-1,0), Mv(0,0), M v(1,0), Mv(2,0), Mv(-2,1), Mv(-1,1), Mv(0,1), Mv(1,1), Mv(2,1), Mv(-2,2), Mv(-1,2), Mv(0,2), Mv(1,2), Mv(2,2)}, Mv(0,0) is the initial motion vector, and the other candidate motion vectors except Mv(0,0) are offset motion vectors of the initial motion vector, when the motion compensation module adjusts the first original motion vector and the second original motion vector based on the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, determining a first integer-pel motion vector adjustment value based on the optimal motion vector; and determining a second integer-pel motion vector adjustment value based on the first integer-pel motion vector adjustment value; a first integer-pel motion vector adjustment value for adjusting the first original motion vector to obtain a first target motion vector corresponding to the first original motion vector, and a second integer-pel motion vector adjustment value for adjusting the second original motion vector to obtain a second target motion vector corresponding to the second original motion vector.

7. a coding device including a processor and a machine-readable storage medium; the machine-readable storage medium stores machine-executable instructions executable by the processor; 10. An encoding device, wherein the processor is adapted to perform the method of claim 1 by executing machine-executable instructions.

8. a decoding device including a processor and a machine-readable storage medium; the machine-readable storage medium stores machine-executable instructions executable by the processor; 10. A decoding device, wherein the processor is adapted to perform the method of claim 1 by executing machine-executable instructions.

Citation Information

Patent Citations

  • Motion vector refinement for multi-reference prediction

    WO2019001786A1

  • Partial cost calculation

    WO2019234672A1

  • Block size restrictions for dmvr

    WO2020008343A1

  • Sub-region based determination of motion information refinement

    WO2020228836A1

  • Methods and apparatuses for decoder-side motion vector refinement in video coding

    WO2020257365A1