A coding and decoding method, device and equipment thereof

By adjusting the motion vector in the bidirectional block, a more accurate target motion vector is generated, which solves the problem of poor coding performance in the prior art and improves coding efficiency and prediction quality.

CN112770113BActive Publication Date: 2024-08-23HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN201911072766.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-11-05
Publication Date
2024-08-23
Estimated Expiration
2039-11-05

AI Technical Summary

Technical Problem

In bidirectional block encoding, existing technologies lack effective motion vector adjustment schemes, resulting in poor coding performance, low prediction quality, and prediction errors.

Method used

A motion vector adjustment mode is provided, which fine-tunes the original motion vector through a local search method to generate a more accurate target motion vector for motion compensation of bidirectional blocks.

Benefits of technology

It improves coding performance and efficiency, and solves the problems of low prediction quality and prediction errors in bidirectional blocks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112770113B
    Figure CN112770113B
Patent Text Reader

Abstract

The present application provides a coding and decoding method, device and equipment thereof, including: if the following conditions are met, determining to start the motion vector adjustment mode for the current block: the control information is to allow 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 other modes except the normal fusion mode; the prediction value of the current block is obtained by weighting the reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distance between the two reference frames and the current frame is the same; the weighted weights of the two reference frames are the same; both reference frames are short-term reference frames; the width, height and area of ​​the current block are within a limited range; the sizes of the two reference frames are the same as the size of the current frame; if the motion vector adjustment mode is started for the current block, motion compensation is performed on the current block. The present application can improve coding performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of coding and decoding technology, and in particular to a coding and decoding method, device and equipment thereof. Background Art

[0002] In order to save space, video images are transmitted after being encoded. The complete video encoding method may include prediction, transformation, quantization, entropy coding, filtering and other processes. Among them, predictive coding includes intra-frame coding and inter-frame coding. Inter-frame coding uses the correlation of the video time domain to predict the pixels of the current image using the pixels of the adjacent encoded images to effectively remove the temporal redundancy of the video. In inter-frame coding, a motion vector (MV) can be used to represent the relative displacement between the current block of the current frame and the reference block of the reference frame. For example, there is a strong temporal correlation between the current frame A and the reference frame B. When the current block A1 of the current frame A needs to be transmitted, a motion search can be performed in the reference frame B to find the block B1 (i.e., the reference block) that best matches the current block A1, and determine the relative displacement between the current block A1 and the reference block B1, which is the motion vector of the current block A1. The encoder can send the motion vector to the decoder instead of sending the current block A1 to the decoder. The decoder can obtain the current block A1 based on the motion vector and the reference block B1. Obviously, since the number of bits occupied by the motion vector is smaller than the number of bits occupied by the current block A1, a large number of bits can be saved.

[0003] In the related art, when the current block is a unidirectional block, after obtaining the motion vector of the current block (hereinafter referred to as the original motion vector), the original motion vector can be adjusted, and encoding / decoding can be performed based on the adjusted motion vector, thereby improving the encoding performance. However, 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 currently no reasonable solution for how to adjust the first original motion vector and the second original motion vector. In other words, for the scenario of bidirectional blocks, there are problems such as low prediction quality and prediction errors, which lead to poor encoding performance. Summary of the invention

[0004] The present application provides a coding and decoding method, apparatus and device thereof, which can improve coding performance.

[0005] The present application provides a coding and decoding method, the method comprising:

[0006] If the following conditions are met, it is determined to start the motion vector adjustment mode for the current block:

[0007] The control information is to allow the current block to use the motion vector adjustment mode;

[0008] 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;

[0009] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0010] The two reference frames of the current block have the same weighting;

[0011] Both reference frames of the current block are short-term reference frames;

[0012] The width, height and area of ​​the current block are all within the specified range;

[0013] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0014] If it is determined that the motion vector adjustment mode is started for the current block, motion compensation is performed on the current block.

[0015] The present application provides a coding and decoding device, the device comprising:

[0016] The determination module is used to determine whether to start the motion vector adjustment mode for the current block if the following conditions are met:

[0017] The control information is to allow the current block to use the motion vector adjustment mode;

[0018] 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;

[0019] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0020] The two reference frames of the current block have the same weighting;

[0021] Both reference frames of the current block are short-term reference frames;

[0022] The width, height and area of ​​the current block are all within the specified range;

[0023] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0024] The motion compensation module is used to perform motion compensation on the current block if it is determined that the motion vector adjustment mode is started for the current block.

[0025] The present application provides an encoding end device, comprising: a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor;

[0026] The processor is used to execute machine executable instructions to implement the following steps:

[0027] If the following conditions are met, it is determined to start the motion vector adjustment mode for the current block:

[0028] The control information is to allow the current block to use the motion vector adjustment mode;

[0029] 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;

[0030] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0031] The two reference frames of the current block have the same weighting;

[0032] Both reference frames of the current block are short-term reference frames;

[0033] The width, height and area of ​​the current block are all within the specified range;

[0034] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0035] If it is determined that the motion vector adjustment mode is started for the current block, motion compensation is performed on the current block.

[0036] The present application provides a decoding end device, comprising: a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor;

[0037] The processor is used to execute machine executable instructions to implement the following steps:

[0038] If the following conditions are met, it is determined to start the motion vector adjustment mode for the current block:

[0039] The control information is to allow the current block to use the motion vector adjustment mode;

[0040] 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;

[0041] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0042] The two reference frames of the current block have the same weighting;

[0043] Both reference frames of the current block are short-term reference frames;

[0044] The width, height and area of ​​the current block are all within the specified range;

[0045] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0046] If it is determined that the motion vector adjustment mode is started for the current block, motion compensation is performed on the current block.

[0047] It can be seen from the above technical solution that in the embodiment of the present application, if it is determined to start the motion vector adjustment mode for the current block, the first target motion vector and the second target motion vector are obtained according to the first original motion vector and the second original motion vector, and the prediction value is determined according to the first target motion vector and the second target motion vector, rather than determining the prediction value according to the first original motion vector and the second original motion vector, thereby solving the problems of low prediction quality, prediction errors, etc. and improving the coding performance and coding efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1A is a schematic diagram of interpolation in one embodiment of the present application;

[0049] Figure 1B is a schematic diagram of a video coding framework in one implementation of the present application;

[0050] Figure 2 is a flowchart of a coding and decoding method in one embodiment of the present application;

[0051] Figure 3 is a flowchart of a coding and decoding method in one embodiment of the present application;

[0052] Figure 4 is a flowchart of a coding and decoding method in one embodiment of the present application;

[0053] Figure 5 is a schematic diagram of a reference block obtained in one embodiment of the present application;

[0054] Figure 6 is a schematic diagram of motion vector iteration in one implementation manner of the present application;

[0055] Figure 7A-7G is a schematic diagram of the sequence of candidate points in one embodiment of the present application;

[0056] Figure 8 is a schematic diagram of expanding a reference block in one implementation of the present application;

[0057] Fig.9A is a structural diagram of a coding and decoding device in one embodiment of the present application;

[0058] Fig. 9B is a hardware structure diagram of a decoding end device in one embodiment of the present application;

[0059] Fig. 9C It is a hardware structure diagram of an encoding end device in one implementation of the present application. DETAILED DESCRIPTION

[0060] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, rather than limiting the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to any or all possible combinations of one or more associated listed items. It should be understood that, although the terms first, second, third, etc. may be used to describe various information in the embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, in addition, the word "if" used can be interpreted as "at the time of..." or "when..." or "in response to determination".

[0061] In the embodiments of the present application, a coding and decoding method, apparatus and device thereof are proposed, which may involve the following concepts:

[0062] Intra prediction and inter prediction technology: Intra prediction refers to the use of the correlation in the video spatial domain to predict the current pixel using the pixels of the coded block of the current image, so as to achieve the purpose of removing the spatial redundancy of the video. Inter prediction refers to the use of the correlation in the video time domain. Since video sequences usually contain strong time domain correlation, the pixels of the adjacent coded images are used to predict the pixels of the current image, which can effectively remove the temporal redundancy of the video. The inter prediction part of the main video coding standards all adopts block-based motion compensation technology. The main principle is to find a best matching block in the previously coded image for each pixel block of the current image. This process is called motion estimation.

[0063] Motion Vector (MV): In inter-frame coding, motion vectors are used to represent the relative displacement between the current block and the best matching block in its reference image. Each divided block has a corresponding motion vector transmitted to the decoding end. If the motion vector of each block is independently encoded and transmitted, especially when it is divided into small-sized blocks, it will consume a considerable number of bits. In order to reduce the number of bits used to encode the motion vector, the spatial correlation between adjacent image blocks is used to predict the motion vector of the current block based on the motion vector of the adjacent encoded block, and then the prediction difference is encoded, thereby effectively reducing the number of bits representing the motion vector. When encoding the motion vector of the current block, the motion vector of the current block is predicted using the motion vector of the adjacent encoded block, and the difference between the predicted value of the motion vector (MVP, Motion Vector Prediction) and the true estimate of the motion vector (MVD, Motion Vector Difference) is encoded, effectively reducing the number of encoding bits.

[0064] Motion Information: Since the motion vector indicates the position offset between the current block and a reference block, in order to accurately obtain the information pointing to the image block, in addition to the motion vector, the index information of the reference frame image is also required to indicate which reference frame image to use. For the current frame image, a reference frame image list can be established, and the reference frame image index information indicates which reference frame image in the reference frame image list is used by the current block. Many encoding technologies also support multiple reference image lists, so an index value can be used to indicate which reference image list to use. This index value is called the reference direction. Motion-related information such as motion vectors, reference frame indexes, and reference directions can be collectively referred to as motion information.

[0065] Interpolation: If the current motion vector is not an integer pixel, the existing pixel value cannot be directly copied from the reference frame corresponding to the current block. The required pixel value of the current block can only be obtained through interpolation. Figure 1A As shown, if you need to obtain the pixel value Y with an offset of 1 / 2 pixel 1 / 2 , then it can be obtained by interpolating the surrounding existing pixel values ​​X. For example, if an interpolation filter with a tap number of N is used, it needs to be obtained by interpolating the surrounding N integer pixels.

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

[0067] Merge mode: including normal fusion mode (i.e. Normal Merge mode, also called regular Merge mode), sub-block fusion mode (fusion mode using sub-block motion information, also called Subblock fusion mode), MMVD mode (fusion mode for coding motion difference, also called merge with MVD mode), CIIP mode (fusion mode for jointly generating new prediction values ​​by inter-frame and intra-frame prediction, also called combine inter intra prediction mode), TPM mode (fusion mode for triangular prediction), GEO mode (fusion mode based on arbitrary geometric partitioning shapes).

[0068] 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 residual. If the current block is in skip mode, CIIP mode is disabled by default, while normal fusion mode, sub-block fusion mode, MMVD mode, TPM mode, and GEO mode can still be applied.

[0069] Exemplarily, how to generate the prediction value can be determined based on the common fusion mode, sub-block fusion mode, MMVD mode, CIIP mode, TPM mode, GEO mode, etc. After the prediction value is generated, for the fusion mode, the prediction value and the residual value can be used to obtain the reconstruction value; for the skip mode, there is no residual value, and the prediction value is directly used to obtain the reconstruction value.

[0070] Sequence parameter set (SPS): In the sequence parameter set, there is a flag that determines whether certain tool switches are allowed in the entire sequence. If the flag is 1, the tool corresponding to the flag is allowed to be enabled in the video sequence; if the flag is 0, the tool corresponding to the flag is not allowed to be enabled in the encoding process in the video sequence.

[0071] Normal fusion mode: select one motion information from the candidate motion information list, and generate a prediction value of the current block based on the motion information. The candidate motion information list includes: candidate motion information of spatially adjacent blocks, candidate motion information of temporally adjacent blocks, candidate motion information of spatially non-adjacent blocks, motion information obtained by combining existing motion information, default motion information, etc.

[0072] MMVD mode: Based on the candidate motion information list of the common fusion mode, select one motion information from the candidate motion information list of the common fusion mode as the reference motion information, and obtain the motion information difference by table lookup. The final motion information is obtained based on the reference motion information and the motion information difference, and the prediction value of the current block is generated based on the final motion information.

[0073] CIIP mode: obtains a new prediction value for the current block by combining the intra-frame prediction value and the inter-frame prediction value.

[0074] Sub-block fusion mode: The sub-block fusion mode includes Affine fusion mode and sub-block TMVP mode.

[0075] Affine fusion mode is similar to normal fusion mode. It also selects a motion information from the candidate motion information list and generates the prediction value of the current block based on the motion information. Unlike normal fusion mode, the motion information in the candidate motion information list of normal fusion mode is a 2-parameter translation motion vector, while the motion information in the candidate motion information list of Affine fusion mode is 4-parameter Affine motion information, or 6-parameter Affine motion information.

[0076] In the subblock TMVP (subblock-based temporal motion vector prediction) mode, in the temporal reference frame, the motion information of a block is directly reused to generate the prediction value of the current block. The motion information of each subblock in the block may be different.

[0077] TPM mode: Divide a block into two triangular sub-blocks (there are two triangular sub-blocks of 45 degrees and 135 degrees). These two triangular sub-blocks have different unidirectional motion information. The TPM mode is only used for 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.

[0078] GEO mode: GEO mode is similar to TPM mode, except for the different division shapes. GEO mode divides a square block into two sub-blocks of any shape (any other shape except the two triangular sub-blocks of TPM), such as a triangular sub-block and a pentagonal sub-block; or, a triangular sub-block and a quadrilateral sub-block; or, two trapezoidal sub-blocks, etc., without any restrictions on the division shape. The two sub-blocks divided by TPM mode have different unidirectional motion information.

[0079] It can be seen from the above examples that the fusion mode and skip mode involved in this embodiment refer to a type of prediction mode that directly selects a motion information from a candidate motion information list to generate a prediction value of the current block. These prediction modes do not require a motion search process at the encoding end. Except for the MMVD mode, other modes do not require encoding motion information differences.

[0080] Video Coding Framework: See Figure 1B As shown, the video encoding framework can be used to implement the encoding end processing flow of the embodiment of the present application. In addition, the schematic diagram of the video decoding framework is similar to Figure 1B Similarly, no further description is given here, and the decoding end processing flow of the embodiment of the present application can be implemented using the video decoding framework. Specifically, in the video encoding framework and the video decoding framework, modules such as intra-frame prediction, motion estimation / motion compensation, reference image buffer, in-loop filtering, reconstruction, transformation, quantization, inverse transformation, inverse quantization, and entropy encoder are included. At the encoding end, the encoding end processing flow can be implemented through the cooperation between these modules, and at the decoding end, the decoding end processing flow can be implemented through the cooperation between these modules.

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

[0082] In an embodiment of the present application, when the current block is a bidirectional block, considering that 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 the motion vector adjustment mode, the motion vector is fine-tuned based on the prediction value obtained based on the original motion vector through a local search method at the decoding end to obtain a better motion vector to generate a prediction value with less distortion.

[0083] Exemplarily, if it is determined to start the motion vector adjustment mode for the current block, then for each sub-block of the current block, the first reference block corresponding to the sub-block can be determined according to the first original motion vector of the sub-block, and the second reference block corresponding to the sub-block can be determined according to the second original motion vector of the sub-block, and the first original motion vector and the second original motion vector are adjusted according to 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 and the second target motion vector, and then the predicted value of the sub-block can be determined according to the first target motion vector and the second target motion vector. The above method can solve the problems of low prediction quality and prediction errors, and improve the coding performance and coding efficiency.

[0084] The encoding and decoding method of the present application is described in detail below in conjunction with several specific embodiments.

[0085] Example 1: See Figure 2 As shown, it is a schematic diagram of the flow of the encoding and decoding method proposed in the embodiment of the present application. The encoding and decoding method can be applied to the decoding end or the encoding end. The encoding and decoding method may include the following steps:

[0086] Step 201: If the following conditions are met, it is determined to start the motion vector adjustment mode for the current block:

[0087] The control information is to allow the current block to use the motion vector adjustment mode;

[0088] 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;

[0089] The prediction value of the current block is obtained by weighting the reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0090] The two reference frames of the current block have the same weighting;

[0091] Both reference frames of the current block are short-term reference frames;

[0092] The width, height and area of ​​the current block are all within the specified range;

[0093] The sizes of the two reference frames of the current block are the same as the size of the current frame.

[0094] In a possible implementation manner, if any one of the following conditions is not satisfied, it is determined not to start the motion vector adjustment mode for the current block: the control information is to allow the current block to use the motion vector adjustment mode;

[0095] 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;

[0096] The prediction value of the current block is obtained by weighting the reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0097] The two reference frames of the current block have the same weighting;

[0098] Both reference frames of the current block are short-term reference frames;

[0099] The width, height and area of ​​the current block are all within the specified range;

[0100] The sizes of the two reference frames of the current block are the same as the size of the current frame.

[0101] In the above embodiment, 7 conditions are given, and whether to start the motion vector adjustment mode for the current block is determined based on the 7 conditions. In practical applications, some conditions can also be selected from the 7 conditions, and whether to start the motion vector adjustment mode for the current block is determined based on the selected partial conditions. For example, 5 conditions are selected from the 7 conditions, and there is no restriction on this selection method. It can be any 5 conditions. If all the selected 5 conditions are met, it is determined that the motion vector adjustment mode is started for the current block; if any one of the selected 5 conditions is not met, it is determined not to start the motion vector adjustment mode for the current block. Of course, other numbers of conditions can also be selected from the 7 conditions, and there is no restriction on this.

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

[0103] For example, when the prediction mode of the current block is the merge mode or the skip mode, the prediction mode of the current block is not the MMVD mode, and the prediction mode of the current block is not the CIIP mode.

[0104] In the above embodiment, the prediction value of the current block is obtained by weighting the reference blocks from two reference frames, which means that the current block adopts a bidirectional prediction mode, that is, the prediction value of the current block is obtained by weighting the reference blocks from two reference frames.

[0105] In the above embodiment, the current block may correspond to motion information of two lists, recorded as the first motion information and the second motion information, the first motion information includes the first reference frame and the first original motion vector, and the second motion information includes the second reference frame and the second original motion vector. The above two reference frames may be the first reference frame and the second reference frame. The display order of the two reference frames is located one before and one after the current frame, which means that the first reference frame is located in front of the current frame where the current block is located, and the second reference frame is located behind the current frame. Exemplarily, the first reference frame may also be called a forward reference frame, which is located in the first list (such as list0), and the second reference frame may also be called a backward reference frame, which is located in the second list (such as list1).

[0106] In the above embodiment, the width, height and area of ​​the current block are all within the limited range: the width is greater than or equal to the first threshold, the height is greater than or equal to the second threshold, and the area is greater than or equal to the third threshold. Alternatively, the width is greater than or equal to the first threshold, the height is greater than or equal to the second threshold, and the area is greater than the 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 just a few examples and are not limited thereto.

[0107] In the above embodiment, the control information for allowing the current block to use the motion vector adjustment mode may include but is not limited to: sequence-level control information (such as control information of multiple frames of images) for allowing the current block to use the motion vector adjustment mode; and / or, frame-level control information (such as control information of one frame of image) for allowing the current block to use the motion vector adjustment mode.

[0108] Step 202: If it is determined that the motion vector adjustment mode is to be started for the current block, motion compensation is performed on the current block.

[0109] In a possible implementation, if it is determined to start the motion vector adjustment mode for the current block, then for each sub-block in at least one sub-block included in the current block: determine the first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determine the second reference block corresponding to the sub-block according to the second original motion vector of the sub-block; adjust the first original motion vector and the second original motion vector according to 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 corresponding to the first original motion vector and the second target motion vector corresponding to the second original motion vector; determine the predicted value of the sub-block according to the first target motion vector and the second target motion vector. After obtaining the predicted value of each sub-block, the predicted value of the current block can be determined according to the predicted value of each sub-block.

[0110] Exemplarily, determining a first reference block corresponding to the sub-block according to a first original motion vector of the sub-block, and determining a second reference block corresponding to the sub-block according to a second original motion vector of the sub-block may include but is not limited to:

[0111] Based on the first original motion vector of the sub-block, a first reference block corresponding to the sub-block is determined from a first reference frame; a pixel value of each pixel in the first reference block is obtained by interpolating pixel values ​​of adjacent pixels in the first reference block, or by copying pixel values ​​of adjacent pixels in the first reference block.

[0112] 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 frame; a pixel value of each pixel in the second reference block is obtained by interpolating pixel values ​​of adjacent pixels in the second reference block, or by copying pixel values ​​of adjacent pixels in the second reference block.

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

[0114] Exemplarily, for each sub-block included in the current block: according to 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, the first original motion vector of the sub-block and the second original motion vector of the sub-block are adjusted to obtain the first target motion vector corresponding to the first original motion vector and the second target motion vector corresponding to the second original motion vector, that is, the first target motion vector and the second target motion vector of the sub-block.

[0115] In a possible implementation, the initial motion vector may be taken as the center, and some or all motion vectors may be selected from the motion vectors around the initial motion vector including the initial motion vector, and the selected motion vectors may be determined as candidate motion vectors; the initial motion vector may be the first original motion vector or the second original motion vector. Then, according to the first pixel value of the first reference block and the second pixel value of the second reference block, a motion vector may be selected from the initial motion vector and the candidate motion vectors as the optimal motion vector. Then, according to the optimal motion vector, the first original motion vector may be adjusted to obtain a first target motion vector corresponding to the first original motion vector, and according to the optimal motion vector, the second original motion vector may be adjusted to obtain a second target motion vector corresponding to the second original motion vector.

[0116] Exemplarily, adjusting the first original motion vector according to the optimal motion vector to obtain a first target motion vector corresponding to the first original motion vector, and adjusting the second original motion vector according to the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector may include: determining a first integer pixel motion vector adjustment value, a second integer pixel motion vector adjustment value, a first sub-pixel motion vector adjustment value, and a second sub-pixel motion vector adjustment value of the sub-block according to the optimal motion vector; adjusting the first original motion vector according to the first integer pixel motion vector adjustment value and the first sub-pixel motion vector adjustment value to obtain the first target motion vector of the sub-block; adjusting the second original motion vector according to the second integer pixel motion vector adjustment value and the second sub-pixel motion vector adjustment value to obtain the second target motion vector of the sub-block.

[0117] Exemplarily, for each sub-block of at least one sub-block included in the current block: the prediction value of the sub-block can be determined according to the first target motion vector of the sub-block and the second target motion vector of the sub-block, and this process is not described in detail.

[0118] In a possible implementation, if the optimal motion vector is the same as the initial motion vector, a third reference block corresponding to the sub-block can be determined from the first reference frame based on the first target motion vector of the sub-block; a fourth reference block corresponding to the sub-block can be determined from the second reference frame based on the second target motion vector of the sub-block. Then, the pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block can be weighted to obtain the prediction value of the sub-block.

[0119] In another possible implementation, if the optimal motion vector is different from the initial motion vector, a fifth reference block may be determined from the first reference frame, and the fifth reference block may be expanded to obtain a sixth reference block; then, based on the first target motion vector of the sub-block, a third reference block corresponding to the sub-block may be selected from the sixth reference block. Also, a seventh reference block may be determined from the second reference frame, and the seventh reference block may be expanded to obtain an eighth reference block; based on the second target motion vector of the sub-block, a fourth reference block corresponding to the sub-block may be selected from the eighth reference block. Then, the pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block may be weighted to obtain a predicted value of the sub-block.

[0120] In the above embodiment, the pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block are weighted to obtain the predicted value of the sub-block, which may include but is not limited to: weighting the pixel values ​​of the third reference block, the first weight corresponding to the pixel values ​​of the third reference block, the pixel values ​​of the fourth reference block, and the second weight corresponding to the pixel values ​​of the fourth reference block to obtain the predicted value of the sub-block; exemplarily, the first weight and the second weight may be the same.

[0121] Exemplarily, after obtaining the prediction value of each sub-block, the prediction value of each sub-block may be combined together to obtain the prediction value of the current block, and the process of determining the prediction value of the current block is not limited.

[0122] It can be seen from the above technical solution that in the embodiment of the present application, if it is determined to start the motion vector adjustment mode for the current block, the first target motion vector and the second target motion vector are obtained according to the first original motion vector and the second original motion vector, and the prediction value is determined according to the first target motion vector and the second target motion vector, rather than determining the prediction value according to the first original motion vector and the second original motion vector, thereby solving the problems of low prediction quality, prediction errors, etc. and improving the coding performance and coding efficiency.

[0123] Example 2: Based on the same concept as the above method, see Figure 3 FIG. 1 is a flow chart of another encoding and decoding method proposed in an embodiment of the present application. The method can be applied to an encoding end. The method can include the following steps:

[0124] Step 301, the encoder determines whether to start the motion vector adjustment mode for the current block. If yes, step 302 is executed. If no, the motion vector adjustment method proposed in the present application does not need to be adopted, and the processing of this situation is not limited.

[0125] In one example, if the encoder determines to start the motion vector adjustment mode for the current block, it means that the motion information of the current block is not accurate enough. Therefore, the motion vector adjustment mode (ie, the technical solution of the present application) is started for the current block, and step 302 is executed.

[0126] If the encoder determines not to start the motion vector adjustment mode for the current block, it means that the motion information of the current block is accurate enough. Therefore, the motion vector adjustment mode may not be started for the current block, and the motion vector adjustment method proposed in this application may not be adopted.

[0127] Step 302: for each sub-block in at least one sub-block included in the current block: the encoder determines a first reference block corresponding to the sub-block from a first reference frame according to a first original motion vector of the sub-block; and determines a second reference block corresponding to the sub-block from a second reference frame according to a second original motion vector of the sub-block. For the sake of distinction, the pixel value of each pixel in the first reference block is referred to as a first pixel value, and the pixel value of each pixel in the second reference block is referred to as a second pixel value.

[0128] In one example, if the current block is a block using bidirectional prediction, there may be bidirectional motion information for each subblock of the current block. This bidirectional motion information may include two reference frames and two original motion vectors. The bidirectional motion information may include a first reference frame and a first original motion vector, a second reference frame and a second original motion vector.

[0129] Based on the first original motion vector, the encoder determines a first reference block corresponding to the sub-block from the first reference frame, and refers to the pixel value of each pixel in the first reference block as a first pixel value. Based on the second original motion vector, the encoder determines a second reference block corresponding to the sub-block from the second reference frame, and refers to the pixel value of each pixel in the second reference block as a second pixel value.

[0130] In one example, the distance between the current frame where the current block is located and the first reference frame and the distance between the second reference frame and the current frame where the current block is located may be the same. For example, the first reference frame is the 1st frame, the current frame is the 5th frame, and the second reference frame is the 9th frame.

[0131] In one example, the first original motion vector and the second original motion vector may have a mirror symmetry relationship, 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 is only an example and is not limited to this.

[0132] For the method of determining the first reference block and the second reference block, please refer to the subsequent embodiments, which will not be described again here.

[0133] In step 303, the encoding end adjusts the first original motion vector according to 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 adjusts the second original motion vector according to 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.

[0134] In one example, if the motion vector adjustment mode is started for the current block, the encoding end can fine-tune the first original motion vector and 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 through a local search method to obtain better first target motion vector and second target motion vector, and then use the first target motion vector and the second target motion vector to generate a prediction value with less distortion.

[0135] In one example, the current block may include at least one sub-block, and if the current block includes only one sub-block, the sub-block is the current block itself. For each sub-block of the current block, the sub-block may correspond to a first original motion vector and a second original motion vector, and after adjustment, the sub-block may correspond to a first target motion vector and a second target motion vector.

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

[0137] Exemplarily, 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, both being the first original motion vector 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, both being the second original motion vector of the current block.

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

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

[0140] For the adjustment method of the original motion vector, please refer to the subsequent embodiments, which will not be described in detail here.

[0141] Step 304: The encoder determines a prediction value of the sub-block according to the first target motion vector and the second target motion vector.

[0142] Step 305: The encoder determines the prediction value of the current block according to the prediction value of each sub-block.

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

[0144] Exemplarily, the encoding end saves the first target motion vector and the second target motion vector of each sub-block of the current block, or saves the first original motion vector and the second original motion vector of each sub-block of the current block, or saves 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.

[0145] Example 3: Based on the same concept as the above method, see Figure 4 FIG. 1 is a flow chart of another encoding and decoding method proposed in an embodiment of the present application. The method can be applied to a decoding end. The method can include the following steps:

[0146] Step 401, the decoding end determines whether to start the motion vector adjustment mode for the current block. If yes, step 402 is executed. If no, the motion vector adjustment method proposed in the present application does not need to be adopted, and the processing of this situation is not limited.

[0147] In one example, if the decoding end determines to start the motion vector adjustment mode for the current block, it means that the motion information of the current block is not accurate enough. Therefore, the motion vector adjustment mode (ie, the technical solution of the present application) is started for the current block, and step 402 is executed.

[0148] If the decoding end determines not to start the motion vector adjustment mode for the current block, it means that the motion information of the current block is accurate enough. Therefore, the motion vector adjustment mode may not be started for the current block, and the motion vector adjustment method proposed in this application may not be adopted.

[0149] Step 402: for each sub-block in at least one sub-block included in the current block: the decoding end determines a first reference block corresponding to the sub-block from a first reference frame according to a first original motion vector of the sub-block; and determines a second reference block corresponding to the sub-block from a second reference frame according to a second original motion vector of the sub-block. For the sake of distinction, the pixel value of each pixel in the first reference block is referred to as a first pixel value, and the pixel value of each pixel in the second reference block is referred to as a second pixel value.

[0150] In step 403, the decoding end adjusts the first original motion vector according to 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 adjusts the second original motion vector according to 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.

[0151] Step 404: The decoding end determines a prediction value of the sub-block according to the first target motion vector and the second target motion vector.

[0152] Step 405: The decoding end determines the prediction value of the current block according to the prediction value of each sub-block.

[0153] Exemplarily, the decoding end saves the first target motion vector and the second target motion vector of each sub-block of the current block, or saves the first original motion vector and the second original motion vector of each sub-block of the current block, or saves 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.

[0154] Illustratively, steps 401 to 405 may refer to steps 301 to 305 and are not described in detail here.

[0155] Embodiment 4: In the above embodiment, whether to start the motion vector adjustment mode for the current block is described below.

[0156] In a possible implementation, the following starting conditions may be given. Of course, the following starting conditions are only examples. In practical applications, the following starting conditions may be combined arbitrarily without limitation. Exemplarily, when all the starting conditions in the following starting conditions are met, it is determined to start the motion vector adjustment mode for the current block.

[0157] 1. The control information is to allow the current block to use the motion vector adjustment mode.

[0158] Exemplarily, the control information may include, but is not limited to: sequence-level control information and / or frame-level control information.

[0159] In a possible implementation, the sequence level (such as multiple frames of images) control information may include a control flag (such as sps_cur_tool_enabled_flag), and the frame level (such as one frame of image) control information may include a control flag (such as 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.

[0160] Exemplarily, sps_cur_tool_enabled_flag indicates whether all images in the sequence are allowed to use the motion vector adjustment mode. pic_cur_tool_disabled_flag indicates whether each block in the current image is not allowed to use the motion vector adjustment mode. When sps_cur_tool_enabled_flag is the first value, it indicates that all images in the sequence are allowed to use the motion vector adjustment mode. When pic_cur_tool_disabled_flag is the second value, it indicates that each block in the current image is allowed to use the motion vector adjustment mode.

[0161] Exemplarily, 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, that is, the control information indicates that the current block is not allowed to use the motion vector adjustment mode.

[0162] In another possible implementation, the sequence level (such as multiple frames of images) control information may include a control flag (such as sps_cur_tool_disabled_flag), and the frame level (such as one frame of image) control information may include a control flag (such as pic_cur_tool_disabled_flag). When sps_cur_tool_disabled_flag is the second value and pic_cur_tool_disabled_flag is the second value, it indicates that the current block is allowed to use the motion vector adjustment mode.

[0163] Exemplarily, sps_cur_tool_disabled_flag indicates whether all images 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 image is not allowed to use the motion vector adjustment mode. When sps_cur_tool_disabled_flag is the second value, it indicates that all images in the sequence are allowed to use the motion vector adjustment mode. When pic_cur_tool_disabled_flag is the second value, it indicates that each block in the current image is allowed to use the motion vector adjustment mode.

[0164] Exemplarily, when sps_cur_tool_disabled_flag is the first 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, that is, the control information indicates that the current block is not allowed to use the motion vector adjustment mode.

[0165] In another possible implementation, the sequence level (such as multiple frames of images) control information may include a control flag (such as sps_cur_tool_enabled_flag), and the frame level (such as one frame of image) control information may include a control flag (such as pic_cur_tool_enabled_flag). When sps_cur_tool_enabled_flag is the first 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.

[0166] Exemplarily, sps_cur_tool_enabled_flag indicates whether all images in the sequence are allowed to use the motion vector adjustment mode. pic_cur_tool_enabled_flag indicates whether each block in the current image is allowed to use the motion vector adjustment mode. When sps_cur_tool_enabled_flag is the first value, it indicates that all images in the sequence are allowed to use the motion vector adjustment mode. When pic_cur_tool_enabled_flag is the first value, it indicates that each block in the current image is allowed to use the motion vector adjustment mode.

[0167] Exemplarily, when sps_cur_tool_enabled_flag is the second value and / or pic_cur_tool_enabled_flag is the second value, it indicates that the current block is not allowed to use the motion vector adjustment mode, that is, the control information indicates that the current block is not allowed to use the motion vector adjustment mode.

[0168] In another possible implementation, the sequence level (such as multiple frames of images) control information may include a control flag (such as sps_cur_tool_disabled_flag), and the frame level (such as one frame of image) control information may include a control flag (such as 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.

[0169] Exemplarily, sps_cur_tool_disabled_flag indicates whether all images 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 image is allowed to use the motion vector adjustment mode. When sps_cur_tool_disabled_flag is the second value, it indicates that all images in the sequence are allowed to use the motion vector adjustment mode. When pic_cur_tool_enabled_flag is the first value, it indicates that each block in the current image is allowed to use the motion vector adjustment mode.

[0170] Exemplarily, when sps_cur_tool_disabled_flag is the first value and / or pic_cur_tool_enabled_flag is the second value, it indicates that the current block is not allowed to use the motion vector adjustment mode, that is, the control information indicates that the current block is not allowed to use the motion vector adjustment mode.

[0171] 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 only an example and no limitation is imposed on this.

[0172] Exemplarily, the frame in this article is equivalent to an image, such as the current frame represents the current image, and the reference frame represents the reference image.

[0173] 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 except the normal fusion mode.

[0174] In a possible implementation, if the prediction mode of the current block (such as the inter-frame prediction mode) is a fusion mode or a skip mode, and the prediction mode of the current block is not other modes (such as sub-block fusion mode, MMVD mode, CIIP mode, TPM mode, GEO mode, etc.) except the common fusion mode, it indicates that the current block is allowed to use the motion vector adjustment mode. For example, when the prediction mode of the current block is the fusion mode or the skip mode, the prediction mode of the current block is not the MMVD mode, and the prediction mode of the current block is not the CIIP mode, it indicates that the current block is allowed to use the motion vector adjustment mode.

[0175] Exemplarily, if the prediction mode of the current block is not the merge mode, and the prediction mode of the current block is not the skip mode, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 2 is not satisfied.

[0176] Exemplarily, if the prediction mode of the current block is a fusion mode or a skip mode, and the prediction mode of the current block is a mode other than the normal fusion mode (such as a sub-block fusion mode, an MMVD mode, a CIIP mode, a TPM mode, a GEO mode, etc.), it means that the current block is not allowed to use the motion vector adjustment mode, that is, start condition 2 is not met.

[0177] In another possible implementation, if the prediction mode of the current block is a normal fusion mode (such as a regularmerge mode), it means that the current block is allowed to use a motion vector adjustment mode. Exemplarily, the normal fusion mode is: reusing a certain motion information in the motion information list of the current block as the motion information of the current block to generate a prediction value of the current block.

[0178] Exemplarily, if the prediction mode of the current block is not the normal fusion mode, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 2 is not met.

[0179] 3. The prediction value of the current block is obtained by weighting the reference blocks from the two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same. The prediction value of the current block is obtained by weighting the reference blocks from the two reference frames, which means that the current block adopts a bidirectional prediction mode, that is, the prediction value of the current block is obtained by weighting the reference blocks from the two reference frames. Exemplarily, the current block can correspond to two lists of motion information, recorded as the first motion information and the second motion information, the first motion information includes the first reference frame and the first original motion vector, and the second motion information includes the second reference frame and the second original motion vector. The display order of the two reference frames is respectively located before and after the current frame, which means that the first reference frame is located in front of the current frame where the current block is located, and the second reference frame is located behind the current frame.

[0180] In a possible implementation, if the current block has two lists (such as list0 and list1) of motion information (such as two reference frames and two motion vectors), and the display order of the two reference frames is respectively located before and after the current frame, and the distances from the two reference frames to the current frame are the same, it means that the current block is allowed to use the motion vector adjustment mode.

[0181] The display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same, which can be expressed by the relative relationship among the display order number POC_Cur of the current frame, the display order number POC_0 of the reference frame of list0, and the display order number POC_1 of the reference frame of list1: that is, (POC_0-POC_Cur) is completely equal to (POC_Cur-POC_0).

[0182] Exemplarily, the current block adopts bidirectional prediction, and the two reference frames corresponding to the current block are from different directions, that is, one reference frame corresponding to the current block is located before the current frame, and the other reference frame corresponding to the current block is located after the current frame.

[0183] For example, the above condition “there are two reference frames in the current block, and the display order of the two reference frames is located before and after the current frame respectively, and the distances between the two reference frames and the current frame are the same” can be expressed as follows:

[0184] Exemplarily, if there is only one reference frame for the current block, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 3 is not met. Alternatively, if there are two reference frames for the current block, but the display order of the two reference frames is both in front of the current frame, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 3 is not met. Alternatively, if there are two reference frames for the current block, but the display order of the two reference frames is both behind the current frame, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 3 is not met. Alternatively, if there are two reference frames for the current block, and the display order of the two reference frames is respectively located before and after the current frame, but the distances between the two reference frames and the current frame are different, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 3 is not met.

[0185] 4. The weights of the two reference frames of the current block are the same.

[0186] In a possible implementation, if the weighted weights of the two reference frames of the current block are the same, it means that the current block is allowed to use the motion vector adjustment mode. Exemplarily, if the frame-level weighted weights of the two reference frames are the same, such as the luminance weighted weight (luma_weight_l0_flag[refIdxL0]) of the reference frame refIdxL0, which can be equal to the luminance weighted weight (luma_weight_l1_flag[refIdxL1]) of the reference frame refIdxL1, it means that the weighted weights of the two reference frames of the current block are the same. Alternatively, if the block-level weighted weights of the two reference frames are the same, such as the index BcwIdx[xCb][yCb] of the block-level weighted value of the current block is 0, it means that the weighted weights of the two reference frames of the current block are the same. Alternatively, if the frame-level weighted weights of the two reference frames are the same, and the block-level weighted weights of the two reference frames are the same, it means that the weighted weights of the two reference frames of the current block are the same.

[0187] Exemplarily, if the weighted weights of the two reference frames of the current block are different, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 4 is not satisfied. For example, if the frame-level weighted weights of the two reference frames are different, it means that the weighted weights of the two reference frames of the current block are different. Alternatively, if the block-level weighted weights of the two reference frames are different, it means that the weighted weights of the two reference frames of the current block are different. Alternatively, if the frame-level weighted weights of the two reference frames are different, and the block-level weighted weights of the two reference frames are different, it means that the weighted weights of the two reference frames of the current block are different.

[0188] Exemplarily, the weighted weights of the two reference frames of the current block refer to the weights used in bidirectional weighted compensation. For example, for each sub-block of the current block, after obtaining two prediction values ​​of the sub-block (see the subsequent embodiments for the acquisition process), the two prediction values ​​need to be weighted to obtain the final prediction value of the sub-block. When weighting the two prediction values, the weights corresponding to the two prediction values ​​are the weighted weights of the two reference frames of the current block, that is, the weights corresponding to the two prediction values ​​are the same.

[0189] 5. Both reference frames of the current block are short-term reference frames. In other words, both reference frames of the current block are not long-term reference frames.

[0190] In a possible implementation, if both reference frames of the current block are short-term reference frames, it means that the current block is allowed to use the motion vector adjustment mode. The short-term reference frame refers to a reference frame closer to the current frame, generally an actual image frame.

[0191] Exemplarily, if both reference frames of the current block are not short-term reference frames, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 5 is not satisfied. Alternatively, if one reference frame of the current block is not a short-term reference frame, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 5 is not satisfied. Alternatively, if both reference frames of the current block are not short-term reference frames, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 5 is not satisfied.

[0192] In another possible implementation, if neither of the two reference frames of the current block is a long-term reference frame, it indicates that the current block is allowed to use the motion vector adjustment mode. The display sequence number POC of the long-term reference frame has no actual meaning. The long-term reference frame indicates a reference frame far from the current frame, or an image frame synthesized from several frames of actual images.

[0193] Exemplarily, if one reference frame of the current block is a long-term reference frame, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 5 is not satisfied. Alternatively, if both reference frames of the current block are long-term reference frames, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 5 is not satisfied.

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

[0195] In a possible implementation, if the width cbWidth of the current block is greater than or equal to a first threshold (such as 8), the height cbHeight of the current block is greater than or equal to a second threshold (such as 8), and the area of ​​the current block (cbHeight*cbWidth) is greater than or equal to a third threshold (such as 128), it means that the current block is allowed to use the motion vector adjustment mode.

[0196] Exemplarily, if the width cbWidth of the current block is less than the first threshold, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 6 is not met. Alternatively, if the height cbHeight of the current block is less than the second threshold, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 6 is not met. Alternatively, and the area of ​​the current block is less than the third threshold, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 6 is not met.

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

[0198] Exemplarily, if the width cbWidth of the current block is less than the first threshold, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 6 is not met. Alternatively, if the height cbHeight of the current block is less than the second threshold, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 6 is not met. Alternatively, and the area of ​​the current block is less than or equal to the fourth threshold, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 6 is not met.

[0199] 7. The sizes of the two reference frames of the current block are the same as the size of the current frame.

[0200] In a possible implementation, if the size of the reference frame of list0 is the same as the size of the current frame, for example, the width of the reference frame of list0 is the same as the width of the current frame, and the height of the reference frame of list0 is the same as the height of the current frame, and the size of the reference frame of list1 is the same as the size of the current frame, for example, the width of the reference frame of list1 is the same as the width of the current frame, and the height of the reference frame of list1 is the same as the height of the current frame, then it means that the current block is allowed to use the motion vector adjustment mode.

[0201] Exemplarily, if the size of at least one of the two reference frames of the current block is different from the size of the current frame, it means that the current block is not allowed to use the motion vector adjustment mode, that is, the start condition 7 is not satisfied. For example, if the width of the reference frame of list0 is different from the width of the current frame, it means that the current block is not allowed to use the motion vector adjustment mode. Alternatively, if the height of the reference frame of list0 is different from the height of the current frame, it means that the current block is not allowed to use the motion vector adjustment mode. Alternatively, if the width of the reference frame of list1 is different from the width of the current frame, it means that the current block is not allowed to use the motion vector adjustment mode. Alternatively, if the height of the reference frame of list1 is different from the height of the current frame, it means that the current block is not allowed to use the motion vector adjustment mode.

[0202] Embodiment 5: In the above embodiment, for each sub-block of the current block, according to the first original motion vector of the sub-block, the first reference block corresponding to the sub-block is determined from the first reference frame, and the pixel value of each pixel in the first reference block is called the first pixel value; according to the second original motion vector of the sub-block, the second reference block corresponding to the sub-block is determined from the second reference frame, and the pixel value of each pixel in the second reference block is called the second pixel value, which is explained below.

[0203] The first pixel value of each pixel in the first reference block is obtained by interpolating pixel values ​​of adjacent pixels in the first reference block, or by copying pixel values ​​of adjacent pixels in the first reference block.

[0204] The second pixel value of each pixel in the second reference block is obtained by interpolating pixel values ​​of adjacent pixels in the second reference block, or by copying pixel values ​​of adjacent pixels in the second reference block.

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

[0206] For example, for each dx*dy sub-block of the current block (such as a 16*16 sub-block, or a smaller sub-block, or a larger sub-block, the smaller sub-block can be 8*8, and the larger sub-block can be 32*32, and there is no limitation on this. Exemplarily, the size of the sub-block can be the same as the size of the current block, that is, the sub-block is the current block. For example, when the current block is 8*16, the current block only includes one sub-block, and the size of the sub-block is 8*16. The size of the sub-block may also be different from the size of the current block. For example, when the current block is 8*32, the current block may include two 8*16 sub-blocks. Of course, the above is just an example. For the convenience of description, the 16*16 sub-block will be used as an example in the following description), the width of the sub-block is dx, the height of the sub-block is dy, the first original motion vector is recorded as MV0, and the second original motion vector is recorded as MV1.

[0207] From the corresponding position of the first original motion vector MV0 in the first reference frame, an integer pixel block with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) is obtained, and this integer pixel block can be recorded as integer pixel block A.

[0208] From the corresponding position of the second original motion vector MV1 in the second reference frame, an integer pixel block with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) is obtained, and this integer pixel block can be recorded as integer pixel block B.

[0209] In a possible implementation, based on an integer pixel block A with an area of ​​(dx+filtersize-1)*(dy+filtersize-1), an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) can be obtained by bilinear interpolation, and this initial reference pixel block can be recorded as a first reference block. Based on an integer pixel block B with an area of ​​(dx+filtersize-1)*(dy+filtersize-1), an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) can be obtained by bilinear interpolation, and this initial reference pixel block can be recorded as a second reference block.

[0210] In another possible implementation, based on the integer pixel block A with an area of ​​(dx+filtersize-1)*(dy+filtersize-1), an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) is obtained by direct copying (without interpolation), and this initial reference pixel block is recorded as the first reference block. Based on the integer pixel block B with an area of ​​(dx+filtersize-1)*(dy+filtersize-1), an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) is obtained by direct copying, and this initial reference pixel block is recorded as the second reference block.

[0211] Exemplarily, only for the brightness component (because the subsequent search process only uses the brightness component to calculate the cost value to reduce complexity), based on the integer pixel blocks with an area of ​​(dx+filtersize-1)*(dy+filtersize-1) (such as integer pixel block A and integer pixel block B), an initial reference pixel block with a size of (dx+2*IterNum)*(dy+2*IterNum) can be obtained, and the initial reference pixel blocks are the first reference block (such as Pred_Inter0) and the second reference block (such as Pred_Inter1).

[0212] In an example, filtersize may be the number of taps of the interpolation filter, such as 8, and there is no limitation on this.

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

[0214] 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 / the second reference block is dx+2*IterNum, and the height value of the first reference block / the second reference block is dy+2*IterNum. dx is the width of the sub-block, dy is the height of the sub-block, IterNum can be the search range SR, for example, the number of iterations in the subsequent embodiments, IterNum can be the maximum horizontal / vertical component interpolation of the target motion vector and the original motion vector, such as IterNum can be 2, etc.

[0215] See also Figure 5 As shown, for the 16*16 sub-block, based on the first original motion vector MV0 at the corresponding position of the first reference frame, an integer pixel block A with an area of ​​23 (i.e., 16+8-1)*23 is obtained. 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 by bilinear interpolation. Similarly, for the 16*16 sub-block, based on the second original motion vector MV1 at the corresponding position of the second reference frame, an integer pixel block B with an area of ​​23*23 is obtained. 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.

[0216] The first reference block and the second reference block are used for motion vector adjustment in subsequent processes.

[0217] Embodiment 6: In the above embodiment, for each sub-block of the current block, the first original motion vector is adjusted according to 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; the second original motion vector is adjusted according to 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. Taking the processing process of a sub-block (such as each sub-block of the size of dx*dy of the current block) as an example, the adjustment process of the original motion vector is introduced.

[0218] Step a1: determine the first original motion vector or the second original motion vector as the central motion vector.

[0219] For example, assuming that the first original motion vector is (4, 4) and the second original motion vector is (-4, -4), the first original motion vector (4, 4) or the second original motion vector (-4, -4) is determined as the center motion vector.

[0220] For the convenience of description, the following takes the determination of the first original motion vector (4, 4) as the center motion vector as an example. The process of determining the second original motion vector (-4, -4) as the center motion vector is similar and will not be repeated here.

[0221] Step a2: determine the edge motion vector corresponding to the center motion vector.

[0222] For example, the center motion vector (x, y) may be offset by S in different directions to obtain edge motion vectors (x, y+S), edge motion vectors (x, yS), edge motion vectors (x+S, y), edge motion vectors (xS, y), and edge motion vectors (x+right, y+down). For example, right may be S or -S, and down may be S or -S. For the determination method of right and down, please refer to the subsequent embodiments. Figure 6 As shown, taking the central motion vector (x, y) as the center, that is, the central motion vector is (0, 0), taking S as 1, right and down as 1 as an example, the edge motion vectors corresponding to the central motion vector (0, 0) include: edge motion vector (0, 1), edge motion vector (0, -1), edge motion vector (1, 0), edge motion vector (-1, 0), and edge motion vector (1, 1).

[0223] Step a3: Obtain a first generation value corresponding to the center motion vector and a second generation value corresponding to each edge motion vector according to the first pixel value of the first reference block and the second pixel value of the second reference block.

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

[0225] The sub-reference block A2 corresponding to the edge motion vector (0, 1) is obtained by copying from the first reference block. The sub-reference block A2 is the sub-reference block of the edge motion vector (0, 1) in the first reference block. The 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. The sub-reference block B2 is the sub-reference block of the symmetric motion vector (0, -1) in the second reference block. The cost value 2 corresponding to the edge motion vector (0, 1) is obtained by using the first pixel value of the sub-reference block A2 and the second pixel value of the sub-reference block B2. For the method of determining the cost value, please refer to the subsequent embodiments.

[0226] Based on the method of determining the cost value 2 corresponding to the edge motion vector (0, 1), the cost value 3 corresponding to the edge motion vector (0, -1), the cost value 4 corresponding to the edge motion vector (1, 0), the cost value 5 corresponding to the edge motion vector (-1, 0), and the cost value 6 corresponding to the edge motion vector (1, 1) can be determined, which will not be repeated here.

[0227] Step a4: According to the first generation value and the second generation value, a motion vector is selected from the center motion vector and the edge motion vector as the optimal motion vector. For example, the motion vector with the smallest cost value can be selected as the optimal motion vector.

[0228] For example, assuming that 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 used as the optimal motion vector. Of course, this is just an example and is not limited to this.

[0229] Step a5: Determine whether the end condition is met. If not, the optimal motion vector can be determined as the central motion vector, and the process returns to step a2. If yes, step a6 can be executed.

[0230] In one example, if the number of iterations / search range reaches a threshold, the end condition is met; if the number of iterations / search range does not reach the threshold, the end condition is not met. For example, assuming that SR is 2, that is, the threshold is 2, if the number of iterations / search range has reached 2 times, that is, step a2-step a4 has been executed twice, then the end condition is met; otherwise, the end condition is not met.

[0231] In another example, after selecting a motion vector from the center motion vector and the edge motion vector as the optimal motion vector, if the center motion vector is selected as the optimal motion vector, the end condition may be satisfied.

[0232] Step a6: Determine a first integer-pixel motion vector adjustment value (used to adjust the first original motion vector) and a second integer-pixel motion vector adjustment value (used to adjust the second original motion vector) according to the optimal motion vector.

[0233] In an example, a first integer-pixel motion vector adjustment value may be determined based on the optimal motion vector and the first original motion vector, and a second integer-pixel motion vector adjustment value may be determined based on the first integer-pixel motion vector adjustment value. Exemplarily, the second integer-pixel motion vector adjustment value may be symmetrical with the first integer-pixel motion vector adjustment value.

[0234] For example, in the first iteration, the optimal motion vector is the edge motion vector (0, 1), and the second iteration is performed with the edge motion vector (0, 1) as the center. In the second iteration, the optimal motion vector is the edge motion vector (0, 1). Assuming that the iteration process is completed, the first integer pixel motion vector adjustment value is (0, 2), which is the sum of the edge motion vector (0, 1) and the edge motion vector (0, 1). Based on this, assuming that the first original motion vector is (4, 4), in the first iteration, the optimal motion vector is the edge motion vector (0, 1), that is, the optimal motion vector can correspond to the optimal motion vector (4, 5). The second iteration is performed with the edge motion vector (0, 1) as the center. In the second iteration, the optimal motion vector is the edge motion vector (0, 1), that is, the optimal motion vector can correspond to the optimal motion vector (4, 6). In summary, the first integer pixel motion vector adjustment value is determined according to the optimal motion vector (4, 6) and the first original motion vector (4, 4), and the first integer pixel motion vector adjustment value is the difference between the optimal motion vector (4, 6) and the first original motion vector (4, 4), that is, the first integer pixel motion vector adjustment value is (0, 2). The second integer pixel motion vector adjustment value is determined according to the first integer pixel motion vector adjustment value (0, 2), and the second integer pixel motion vector adjustment value can be (0, -2), that is, a symmetric value of (0, 2).

[0235] Step a7: determine a first sub-pixel motion vector adjustment value (used to adjust the first original motion vector) and a second sub-pixel motion vector adjustment value (used to adjust the second original motion vector) according to the optimal motion vector.

[0236] In one example, a first sub-pixel motion vector adjustment value may be determined according to a cost value corresponding to an optimal motion vector and a cost value corresponding to an edge motion vector corresponding to the optimal motion vector, and then a second sub-pixel motion vector adjustment value may be determined according to the first sub-pixel motion vector adjustment value. For example, 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)), for motion vector pixel precisions of 1 / 2, 1 / 4, 1 / 8, and 1 / 16, N = 1, 2, 4, and 8. Then, (x0, y0) is assigned to deltaMv, SPMV = deltaMv / 2N, and if the current motion vector pixel precision is 1 / 16, the SPMV is (x0 / 16, y0 / 16).

[0237] In the above formula, SPMV can be the first sub-pixel motion vector adjustment value, and N can be related to the motion vector pixel accuracy. For example, the motion vector pixel accuracy can be 1 / 2, N is 1, the motion vector pixel accuracy can be 1 / 4, N is 2, the motion vector pixel accuracy can be 1 / 8, N is 4, and the motion vector pixel accuracy can be 1 / 16, N is 8.

[0238] 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) with the optimal motion vector as the center; E(1,0) is the cost value of the edge motion vector (1,0) of the optimal motion vector (0,0) with the optimal motion vector as the center; E(0,-1) is the cost value of the edge motion vector (0,-1) of the optimal motion vector (0,0) with the optimal motion vector as the center; E(0,1) is the cost value of the edge motion vector (0,1) of the optimal motion vector (0,0) with the optimal motion vector as the center. For the cost value of each motion vector, the determination method is shown in the above example and will not be repeated here.

[0239] After the first sub-pixel motion vector adjustment value is determined in the above manner, a second sub-pixel motion vector adjustment value may be determined according to the first sub-pixel motion vector adjustment value, and the second sub-pixel motion vector adjustment value is a symmetric value of the first sub-pixel motion vector adjustment value. For example, if the first sub-pixel motion vector adjustment value is (1, 0), the second sub-pixel motion vector adjustment value may be (-1, 0), that is, a symmetric value of the first sub-pixel motion vector adjustment value (1, 0).

[0240] Step a8: adjust the first original motion vector according to the first integer pixel motion vector adjustment value and / or the first sub-pixel 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 pixel motion vector adjustment value + the first sub-pixel motion vector adjustment value.

[0241] Step a9: adjust the second original motion vector according to the second integer pixel motion vector adjustment value and / or the second sub-pixel 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 pixel motion vector adjustment value + the second sub-pixel motion vector adjustment value.

[0242] Embodiment 7: In the above embodiment, for each sub-block of the current block, the first original motion vector is adjusted according to 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; the second original motion vector is adjusted according to 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. Taking the processing process of a sub-block (such as each sub-block of the size of dx*dy of the current block) as an example, the adjustment process of the original motion vector is introduced.

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

[0244] Step b1, perform SR iterations to obtain the optimal integer pixel offset of the integer pixel MV point, which is recorded as IntegerDeltaMV. IntegerDeltaMV is the first integer pixel motion vector adjustment value in the above embodiment. For example, first initialize IntegerDeltaMV to (0, 0), and perform the following process in each iteration:

[0245] Step b11, set deltaMV to (0, 0). If it is the first iteration, based on the reference pixels of the first original motion vector in the first reference block, copy and obtain the prediction value block A1 (i.e., the block of dx*dy at the center of the first reference block); based on the reference pixels of the second original motion vector in the second reference block, copy and obtain the prediction value block B1 (i.e., the block of dx*dy at the center of the second reference block). Based on the prediction value block A1 and the prediction value block B1, obtain the initial cost value cost (the initial cost value is the SAD (sum of abstract distortion) based on the prediction value block A1 and the prediction value block B1, and the determination method refers to the subsequent embodiments). If the initial cost value cost is less than dx*dy, dx and dy are the width and height of the current sub-block, then directly skip the subsequent search process, execute step b2, and set notZeroCost to false.

[0246] Step b12: Figure 6 As shown, with the above initial point as the center, five offset MVs are obtained in the order of {Mv(0,1), Mv(0,-1), Mv(1,0), Mv(-1,0), Mv(right,down)} (these five offset MVs are all called MVOffset), and the cost values ​​of these five offset MVs are calculated and compared. For example, based on a certain MVOffset (such as Mv(0,1), etc.), in the first reference block and the second reference block, two blocks of prediction value blocks are obtained through this MVOffset (such as 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 opposite of MVOffset) in the second reference block), and the downsampled SAD of the two prediction value blocks is calculated as the cost value of MVOffset.

[0247] Then, the MVOffset with the smallest cost value is retained, and the MVOffset with the smallest cost value is updated to the value of deltaMV, and the MVOffset with the smallest cost value is used as the new center offset point for the next iteration.

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

[0249] Step b13: After iteration, if the optimal MV is still the initial MV (ie, not MVOffset) or the minimum cost value is 0, the next iterative search process is not performed, and step b2 is executed, and notZeroCost is set to false.

[0250] Otherwise, if the number of iterations reaches SR, step b2 is executed. If the number of iterations does not reach SR, the optimal MV can be used as the center to perform the next iterative search process, that is, return to step b11.

[0251] 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-pixel motion vector adjustment value, which is subsequently recorded as IntegerDeltaMV.

[0252] Step b2: Taking the optimal whole pixel MV point of step b1 as the center, the optimal sub-pixel offset MV can be obtained, which is recorded as SPMV. The SPMV is the first sub-pixel motion vector adjustment value in the above embodiment.

[0253] For example, you can first initialize the SPMV to (0, 0), and then perform the following process:

[0254] Step b21, only when notZeroCost is not false and deltaMV is (0, 0), can subsequent processing be performed (that is, SPMV needs to be obtained); otherwise, the original motion vector can be adjusted directly using IntegerDeltaMV instead of using IntegerDeltaMV and SPMV to adjust the original motion vector.

[0255] Step b22, E(x, y) is expressed as the MV corresponding cost value of the optimal MV point offset (x, y) obtained in step b1 (the cost value calculated in step b1). Based on the E(x, y) of the center and the five points above, below, left and right, the offset (x0, y0) of the point with the smallest E(x, y) is: 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, for motion vector pixel accuracy of 1 / 2, 1 / 4, 1 / 8 and 1 / 16, N = 1, 2, 4 and 8. Then, (x0, y0) can be assigned to deltaMv, SPMV=deltaMv / 2N. If the current motion vector pixel accuracy is 1 / 16, the SPMV can be (x0 / 16, y0 / 16).

[0256] If E(-1,0)=E(0,0), then the horizontal shift is half a pixel to the left (deltaMv[0]=-N).

[0257] If E(1,0)=E(0,0), then the horizontal shift is half a pixel to the right (deltaMv[0]=N).

[0258] If E(0,-1)=E(0,0), then the vertical shift is half a pixel upward (deltaMv[1]=-N).

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

[0260] Based on the above processing, the value of SPMV, ie, the first sub-pixel motion vector adjustment value, can be obtained.

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

[0262] Obviously, BestMVoffset=IntegerDeltaMV+SPMV, which is the sum of the first integer pixel motion vector adjustment value and the first sub-pixel motion vector adjustment value. Moreover, -IntegerDeltaMV is the symmetric value of IntegerDeltaMV, which is the second integer pixel motion vector adjustment value, and -SPMV is the symmetric value of SPMV, which is the second sub-pixel motion vector adjustment value. Therefore, when -BestMVoffset=(-IntegerDeltaMV)+(-SPMV), it is the sum of the second integer pixel motion vector adjustment value and the second sub-pixel motion vector adjustment value.

[0263] Example 8: In an example, in order 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 method is similar to Example 7, except that: the "if the initial cost value cost is less than dx*dy, then directly skip the subsequent search process" in step b11 is removed, that is, even if the initial cost value cost is less than dx*dy, it will not "directly skip the subsequent search process", but continue the subsequent search process, that is, it is necessary to execute step b12.

[0264] Embodiment 9: In order 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 method is similar to that of Embodiment 7, except that: the "if the initial cost value cost is less than dx*dy, then directly skip the subsequent search process" in step b11 is removed, that is, even if the initial cost value cost is less than dx*dy, it will not "directly skip the subsequent search process", but continue the subsequent search process, that is, it is necessary to execute step b12. The "if the optimal MV is still the initial MV (that is, not MVOffset) or the minimum cost value is 0, then do not perform the next iterative search process" in step b13 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 can be performed.

[0265] Embodiment 10: In one example, in order 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 Embodiment 7, except that: the related process of "notZeroCost" is removed, that is, in step b11 and step b13, the value of notZeroCost is not set and saved. In step b21, as long as deltaMV is (0, 0), the sub-pixel offset calculation process (i.e., step b22) can be performed, instead of only when notZeroCost is not false and deltaMV is (0, 0), the sub-pixel offset calculation process can be performed.

[0266] Embodiment 11: In one example, in order 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 method is similar to that of Embodiment 7, except that: the "subsequent processing is performed only when notZeroCost is not false and deltaMV is (0, 0), otherwise, the original motion vector is adjusted directly using IntegerDeltaMV" in step b21 is modified to "subsequent processing is performed only when notZeroCost is not false and the cost values ​​of four points above, below, left and right of the current optimal integer pixel separated by 1 integer pixel have been calculated in step b1, otherwise, the original motion vector is adjusted directly using IntegerDeltaMV". In one example, "subsequent processing" refers to the sub-pixel offset calculation process of step b22.

[0267] In an example, the pixel offset calculation process of step b22 needs to use the cost values ​​of four points that are 1 whole pixel apart from each other above, below, left, and right of the optimal integer pixel. Therefore, the "cost values ​​of four points that are 1 whole pixel apart from each other above, below, left, and right of the optimal integer pixel" calculated in step b1 may be a necessary condition.

[0268] Example 12: In order 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 method is similar to Example 7, except that: the "subsequent processing is performed only when notZeroCost is not false and deltaMV is (0, 0), otherwise the original motion vector is directly adjusted using IntegerDeltaMV" in step b21 is modified to "subsequent processing (i.e., the sub-pixel offset calculation process) is performed only when the cost values ​​of the four points above, below, left and right of the current optimal integer pixel, which are separated by 1 integer pixel, have been calculated in step b1, otherwise the original motion vector is adjusted using IntegerDeltaMV".

[0269] Example 13: In order 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 method is similar to Example 7, except that: the "subsequent processing is performed only when notZeroCost is not false and deltaMV is (0, 0), otherwise, the original motion vector is directly adjusted using IntegerDeltaMV" in step b21 is modified to "if the cost values ​​of the four points of the current optimal integer pixel separated by 1 integer pixel above, below, left and right have been calculated in step b1, subsequent processing (the sub-pixel offset calculation process of step b22) is performed, otherwise step b23 is used for processing".

[0270] Step b23, set the current optimal integer pixel point MV_inter_org as the integer pixel point MV_inter_nearest that is closest to it and the cost values ​​of the four points around it that are separated by an integer pixel in the upper, lower, left, and right directions have been calculated in step b1. Then, with MV_inter_nearest as the center, perform the sub-pixel offset calculation process of step b22, that is, obtain the SPMV with MV_inter_nearest as the center. For example, if the cost values ​​of the four points separated by an integer pixel in the upper, lower, left, and right directions of the current optimal integer pixel point MV_inter_org are not all calculated in step b1, then select an integer pixel point MV_inter_nearest from the surrounding of the optimal integer pixel point MV_inter_org, and the cost values ​​of the four points separated by an integer pixel in the upper, lower, left, and right directions of the integer pixel point MV_inter_nearest have all been calculated in step b1.

[0271] Then, the integer pixel point MV_inter_nearest can be used as the current optimal integer pixel point, and the SPMV can be obtained with the integer pixel point MV_inter_nearest as the center. For the specific acquisition method, see step b22. When obtaining the SPMV with the integer pixel point MV_inter_nearest as the center, refer to 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, x0 / y0 can be assigned to 2N; if x0 / y0 is less than -2N, x0 / y0 can be assigned to -2N. For motion vector pixel accuracy of 1 / 2, 1 / 4, 1 / 8 and 1 / 16, N=1, 2, 4 and 8.

[0272] Embodiment 14: In the above embodiment, it is necessary to determine the edge motion vector corresponding to the center motion vector. For example, if the center motion vector (x, y) is offset by S in different directions, edge motion vectors (x, y+S), edge motion vector (x, yS), edge motion vector (x+S, y), edge motion vector (xS, y), and edge motion vector (x+right, y+down) in different directions are obtained in sequence. Alternatively, if the center motion vector (x, y) is offset by S in different directions, edge motion vectors (x, yS), edge motion vector (x, y+S), edge motion vector (xS, y), edge motion vector (x+S, y), and edge motion vector (x+right, y+down) in different directions are obtained in sequence. For example, assuming that (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 of (0, -1), (0, 1), (-1, 0), (1, 0), and (right, down).

[0273] Embodiment 15: In the above embodiment, 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), right is S (modified 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), down is S (modified 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), right is S (modified 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), down is S (modified from -S to S).

[0274] 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), 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), 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), 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), 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), 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), 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), 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), down is 1.

[0275] Embodiment 16: In the above embodiment, for each sub-block of the current block, the first original motion vector is adjusted according to 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 according to 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. Taking the processing process of a sub-block (such as each sub-block of the size of dx*dy of the current block) as an example, the adjustment process of the original motion vector is introduced.

[0276] Step c1, taking the initial motion vector as the center, select some or all motion vectors from the motion vectors including the initial motion vector around the initial motion vector, and use the selected motion vectors as candidate motion vectors. Exemplarily, the initial motion vector may be the first original motion vector or the second original motion vector. For example, taking the first original motion vector as the center, select some or all motion vectors from the motion vectors including the first original motion vector around the first original motion vector as candidate motion vectors, and refer to the subsequent embodiments for this selection method. Alternatively, taking the second original motion vector as the center, select some or all motion vectors from the motion vectors including the second original motion vector around the second original motion vector as candidate motion vectors, and refer to the subsequent embodiments for this selection method. For the convenience of description, in the subsequent embodiments, the first original motion vector is taken as the center as an example, that is, the initial motion vector is the first original motion vector.

[0277] Exemplarily, the initial motion vector may be taken as the center, and some or all motion vectors may be selected from (2*SR+1)*(2*SR+1) motion vectors around the initial motion vector including the initial motion vector, and the selected motion vectors may be determined as candidate motion vectors; wherein SR is the search range. When some or all motion vectors are selected from (2*SR+1)*(2*SR+1) 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 the motion vectors may include from left to right and from top to bottom.

[0278] 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 vector is determined as the candidate motion vector; the search order of the motion vector 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), M v(-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), M v(-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)}.

[0279] When SR is 2, some 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(-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)}.

[0280] Step c2: Obtain a third generation value corresponding to the first original motion vector (ie, initial motion vector) and a fourth generation value corresponding to each candidate motion vector according to the first pixel value of the first reference block and the second pixel value of the second reference block.

[0281] For example, the sub-reference block A1 corresponding to the first original motion vector can be copied from the first reference block, and the sub-reference block A1 can be the sub-reference block of the first original motion vector in the first reference block. Then, the sub-reference block B1 corresponding to the second original motion vector can be copied from the second reference block, and the sub-reference block B1 is the sub-reference block of the second original motion vector in the second reference block. Then, the third generation value corresponding to the first original motion vector can be obtained by using the first pixel value of the sub-reference block A1 and the second pixel value of the sub-reference block B1. For each candidate motion vector, the sub-reference block A2 corresponding to the candidate motion vector can be copied from the first reference block, and the sub-reference block A2 is the sub-reference block of the candidate motion vector in the first reference block. Then, the sub-reference block B2 corresponding to the symmetric motion vector of the candidate motion vector can be copied from the second reference block, and the sub-reference block B2 is the sub-reference block of the symmetric motion vector in the second reference block. The fourth generation value corresponding to the candidate motion vector is obtained by using the first pixel value of the sub-reference block A2 and the second pixel value of the sub-reference block B2.

[0282] Step c3: Select a motion vector from the first original motion vector and each candidate motion vector according to the third generation value and the fourth generation value, and determine the selected motion vector as the optimal motion vector. For example, the motion vector with the smallest cost value (such as the first original motion vector or any candidate motion vector) can be used as the optimal motion vector.

[0283] Step c4: determining a first integer-pixel motion vector adjustment value (used to adjust the first original motion vector) and a second integer-pixel motion vector adjustment value (used to adjust the second original motion vector) according to the optimal motion vector. For example, the first integer-pixel motion vector adjustment value is determined according to the optimal motion vector and the first original motion vector, and the second integer-pixel motion vector adjustment value is determined according to the first integer-pixel motion vector adjustment value, and the second integer-pixel motion vector adjustment value is symmetrical to the first integer-pixel motion vector adjustment value.

[0284] For example, assuming that the optimal motion vector is (4, 6) and the first original motion vector is (4, 4), the first integer pixel motion vector adjustment value is determined according to the optimal motion vector (4, 6) and the first original motion vector (4, 4), and the first integer pixel motion vector adjustment value is the difference between the optimal motion vector (4, 6) and the first original motion vector (4, 4), that is, the first integer pixel motion vector adjustment value is (0, 2). Then, the second integer pixel motion vector adjustment value is determined according to the first integer pixel motion vector adjustment value (0, 2), and the second integer pixel motion vector adjustment value can be (0, -2), that is, a symmetric value of (0, 2).

[0285] Step c5: determining a first sub-pixel motion vector adjustment value (used to adjust the first original motion vector) and a second sub-pixel motion vector adjustment value (used to adjust the second original motion vector) according to the optimal motion vector. For example, determining the first sub-pixel motion vector adjustment value according to a cost value corresponding to the optimal motion vector and a cost value corresponding to an edge motion vector corresponding to the optimal motion vector, and then determining the second sub-pixel motion vector adjustment value according to the first sub-pixel motion vector adjustment value.

[0286] For example, 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)), for motion vector pixel precisions of 1 / 2, 1 / 4, 1 / 8, and 1 / 16, N = 1, 2, 4, and 8. Then, (x0, y0) is assigned to deltaMv, SPMV = deltaMv / 2N, and if the current motion vector pixel precision is 1 / 16, the SPMV is (x0 / 16, y0 / 16). SPMV is the first sub-pixel motion vector adjustment value. 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) with the optimal motion vector as the center; E(1,0) is the cost value of the edge motion vector (1,0) of the optimal motion vector (0,0) with the optimal motion vector as the center; E(0,-1) is the cost value of the edge motion vector (0,-1) of the optimal motion vector (0,0) with the optimal motion vector as the center; E(0,1) is the cost value of the edge motion vector (0,1) of the optimal motion vector (0,0) with the optimal motion vector as the center. For the cost value of each motion vector, the determination method refers to the above embodiment. After determining the first sub-pixel motion vector adjustment value in the above manner, the second sub-pixel motion vector adjustment value can be determined according to the first sub-pixel motion vector adjustment value, and the second sub-pixel motion vector adjustment value is a symmetric value of the first sub-pixel motion vector adjustment value. For example, if the first sub-pixel motion vector adjustment value is (1, 0), then the second sub-pixel motion vector adjustment value is (-1, 0), which is a symmetric value of (1, 0).

[0287] Step c6: adjust the first original motion vector according to the first integer pixel motion vector adjustment value and / or the first sub-pixel 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 pixel motion vector adjustment value + the first sub-pixel motion vector adjustment value.

[0288] Step c7: adjust the second original motion vector according to the second integer pixel motion vector adjustment value and / or the second sub-pixel 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 pixel motion vector adjustment value + the second sub-pixel motion vector adjustment value.

[0289] Embodiment 17: In the above embodiment, for each sub-block of the current block, the first original motion vector is adjusted according to 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 according to 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. Taking the processing process of a sub-block (such as each dx*dy sub-block of the current block) as an example, the adjustment process of the original motion vector is introduced.

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

[0291] Step d1, taking the first original motion vector as the center, select part or all of the motion vectors from the (2*SR+1)*(2*SR+1) points around the first original motion vector including the first original motion vector. For example, if SR=2, select part or all of the motion vectors from the 25 points around the first original motion vector including the first original motion vector, and use the selected motion vectors as candidate motion vectors. Determine the cost value of the first original motion vector, and determine the cost value of each candidate motion vector. Use the motion vector with the smallest cost value as the optimal motion vector. Compared with step b1 of the above embodiment, in step d1, there is no need to perform an iterative process, that is, all candidate motion vectors to be processed can be selected at one time, instead of selecting part of the motion vectors in the first iteration and selecting part of the motion vectors in the second iteration through an iterative process. Based on this, since all candidate motion vectors to be processed can be selected at one time, these candidate motion vectors can be processed in parallel to obtain the cost value of each candidate motion vector, thereby reducing the computational complexity and improving the coding performance.

[0292] Step d2, determine the value of IntegerDeltaMV according to the optimal motion vector. The final value of IntegerDeltaMV is the first integer-pixel motion vector adjustment value. The determination method will not be described in detail, and reference may be made to the above embodiment.

[0293] Step d3, taking the optimal motion vector as the center, obtaining the optimal sub-pixel offset MV, and recording the optimal sub-pixel offset as SPMV, and the value of SPMV is the first sub-pixel motion vector adjustment value.

[0294] The implementation process of step d3 can refer to the above step b2, which will not be repeated here.

[0295] Step d4: Based on IntegerDeltaMV and SPMV, obtain BestMVoffset. For example, BestMVoffset=IntegerDeltaMV+SPMV. Then, the target motion vector can be obtained based on BestMVoffset: Refined_MV0=Org_MV0+BestMVoffset; Refined_MV1=Org_MV1-BestMVoffset.

[0296] Embodiment 18: In order 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 method is similar to Embodiment 16 and Embodiment 17. In this embodiment, with the original motion vector as the center, all motion vectors can be selected from a total of (2*SR+1)*(2*SR+1) points around the original motion vector including the original motion vector. For example, if SR=2, all motion vectors can be selected from 25 points around the original motion vector 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 taken as the optimal motion vector.

[0297] Embodiment 19: In order 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 method is similar to Embodiment 16 and Embodiment 17. In this embodiment, since all candidate motion vectors to be processed are selected at one time, these candidate motion vectors can be processed in parallel to obtain the cost value of each candidate motion vector, thereby reducing the computational complexity and improving the encoding performance. In this embodiment, with the original motion vector as the center, 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 the original motion vector including the original motion vector.

[0298] For example, from the (2*SR+1)*(2*SR+1) points including the original motion vector, select N (N is greater than or equal to 1 and less than or equal to (2*SR+1)*(2*SR+1)) candidate points. Then, determine the cost values ​​of the motion vectors corresponding to these N points. Exemplarily, the cost values ​​of these N points can be scanned in a certain order, and the motion vector with the smallest cost value can be selected as the optimal motion vector. If the cost values ​​are equal, the candidate point with a higher order is preferentially selected. Exemplarily, the cost value can be determined by determining the cost value based on the downsampled SAD of the two predicted values ​​obtained from the candidate motion vector.

[0299] In one example, assuming SR=2, there may be 25 candidate points, and the order of these candidate points may be from left to right and from top to bottom. Fig. 7A As shown, the order of these candidate points can 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)}. Or, see Figure 7B As shown, the order of these candidate points can 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)}.

[0300] Determine the cost values ​​corresponding to the motion vectors of these 25 points, and scan them in the above order to obtain the motion vector with the smallest cost value as the optimal offset MV. The optimal offset MV can be used to determine the integer-pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method refers to the above embodiment and will not be repeated here.

[0301] In another example, assuming SR=2, there may be 21 candidate points, and the order of these candidate points may be from left to right and from top to bottom. Figure 7CAs shown, the order of these candidate points 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)}. Alternatively, see Fig.7D As shown, the order of these candidate points is: {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)}.

[0302] Determine the cost values ​​corresponding to the motion vectors of these 21 points, and scan them in the above order to obtain the motion vector with the smallest cost value as the optimal offset MV. The optimal offset MV can be used to determine the integer-pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method refers to the above embodiment and will not be repeated here.

[0303] In another example, assuming SR = 2, there may be 25 candidate points. The order of these candidate points is based on the motion vector (0,0) as the center and the order from near to far from the center. Fig. 7EAs shown, the order of these candidate points can 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)}. Determine the cost values ​​corresponding to the motion vectors of these 25 points, and scan them in the above order to obtain the motion vector with the smallest cost value as the optimal offset MV. The optimal offset MV can be used to determine the integer-pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method refers to the above embodiment and will not be repeated here.

[0304] In another example, assuming SR = 2, there may be 21 candidate points. The order of these candidate points is based on the motion vector (0,0) as the center and the order from near to far from the center. Figure 7F As shown, 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(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)}. Determine the cost values ​​corresponding to the motion vectors of these 21 points, and scan them in the above order to obtain the motion vector with the smallest cost value as the optimal offset MV. Use the optimal offset MV to determine the integer-pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method refers to the above embodiment.

[0305] In another example, assuming SR = 2, there are 13 candidate points. The order of these candidate points is based on the motion vector (0,0) as the center and the order from near to far from the center. Figure 7GAs shown, 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(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 to obtain the motion vector with the smallest cost value as the optimal offset MV. The optimal offset MV can be used to determine the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method is shown in the above embodiment.

[0306] In the above embodiment, when the first candidate motion vector is Mv(0,0), the cost SAD(0,0) of the first candidate motion vector Mv(0,0) is processed as follows: SAD(0,0)=SAD(0,0)-SAD(0,0) / 4, that is, it is forcibly reduced by 1 / 4, and the above processing is not performed on the cost SAD of other candidate motion vectors.

[0307] In a possible implementation manner, during the above candidate motion vector checking process, there is the following early termination mechanism:

[0308] If the cost SAD(0,0) of the first candidate motion vector (Mv(0,0)) is less than the threshold dx*dy, no subsequent candidate motion vectors are checked, that is, the optimal integer pixel offset of the sub-block is Mv(0,0).

[0309] If the cost of a candidate motion vector is 0, the subsequent candidate motion vectors are not checked, and the current candidate motion vector is used as the optimal integer pixel offset.

[0310] If any of the above situations ends early during the candidate motion vector checking process, the subsequent sub-pixel offset calculation process is not performed, that is, the target motion vector of the sub-block is directly obtained by integer pixel offset.

[0311] Embodiment 20: In order 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 method is similar to that of Embodiment 16 and Embodiment 17. In this embodiment, since all candidate motion vectors to be processed are selected at one time, these candidate motion vectors can be processed in parallel to obtain the cost value of each candidate motion vector, thereby reducing the computational complexity and improving the coding performance. In this embodiment, with the original motion vector as the center, some motion vectors whose offset does not exceed the SR range are selected from (2*SR+1)*(2*SR+1) points. For example, N (N is greater than or equal to 1 and less than or equal to (2*SR+1)*(2*SR+1)) candidate points are selected from (2*SR+1)*(2*SR+1) points including the original motion vector. Determine the cost value of the motion vector corresponding to these N points. Scan the cost values ​​of these N points in a certain order, and select the motion vector with the smallest cost value as the optimal motion vector. If the cost values ​​are equal, the candidate points with the highest order will be selected first.

[0312] The difference from Example 19 is that the positions of the candidate points in Example 19 are all fixed, that is, they are independent of the original motion vector.

[0313] The positions of the candidate points in Example 20 are related to the original motion vector, which is explained below with reference to several specific examples.

[0314] In one example, assuming SR = 2, there can be 13 candidate points. The order of these candidate points is based on the motion vector (0,0) as the center and the order from near to far from the center. Moreover, in the first layer of candidate points from the center, the order is independent of the size of the original motion vector, while the order of the second layer of candidate points from the center is related to the size 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 denoted as MV0, the horizontal component is MV0_Hor, and the vertical component is 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. Determine the cost values ​​corresponding to the motion vectors of the 13 points, and scan them in the above order to obtain the motion vector with the smallest cost value as the optimal offset MV. The optimal offset MV can be used to determine the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method is shown in the above embodiment.

[0315] In another example, assuming SR = 2, there can be 13 candidate points. The order of these candidate points is based on the motion vector (0,0) as the center and the order from near to far from the center is adopted. Moreover, in the first layer of candidate points from the center, the order is independent of the size of the original motion vector, while the order of the second layer of candidate points from the center is related to the size 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 denoted as MV0, the horizontal component is MV0_Hor, and the vertical component is 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. Determine the cost values ​​corresponding to the motion vectors of the 13 points, and scan them in the above order to obtain the motion vector with the smallest cost value as the optimal offset MV. The optimal offset MV can be used to determine the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value. The determination method is shown in the above embodiment.

[0316] Embodiment 21: In the above embodiment, it involves obtaining a first generation value corresponding to the center motion vector and a second generation value corresponding to the edge motion vector according to the first pixel value of the first reference block and the second pixel value of the second reference block. According to the first pixel value of the first reference block and the second pixel value of the second reference block, obtain a third generation value corresponding to the first original motion vector and a fourth generation value corresponding to the candidate motion vector. In one example, according to the un-downsampled first pixel value and the un-downsampled second pixel value, obtain the first generation value corresponding to the center motion vector, the second generation value corresponding to the edge motion vector, the third generation value corresponding to the first original motion vector, and the fourth generation value corresponding to the candidate motion vector. Alternatively, downsample the first pixel value and downsample the second pixel value; according to the downsampled first pixel value and the downsampled second pixel value, obtain the first generation value corresponding to the center motion vector, the second generation value corresponding to the edge motion vector, the third generation value corresponding to the first original motion vector, and the fourth generation value corresponding to the candidate motion vector. Alternatively, shift and down-sample operations are performed on the first pixel value, and shift and down-sample operations are performed on the second pixel value; then, based on the operated first pixel value and the operated second pixel value, a first-generation value corresponding to the center motion vector, a second-generation value corresponding to the edge motion vector, a third-generation value corresponding to the first original motion vector, and a fourth-generation value corresponding to the candidate motion vector are obtained.

[0317] The method of determining the cost value is similar for different situations. For example, in order to obtain the cost value corresponding to the center motion vector, the sub-reference block A1 corresponding to the center motion vector can be copied from the first reference block, and the sub-reference block B1 corresponding to the symmetric motion vector of the center motion vector can be copied from the second reference block. The first pixel value of the sub-reference block A1 and the second pixel value of the sub-reference block B1 are used to obtain the cost value corresponding to the center motion vector. In order to obtain the cost value corresponding to the edge motion vector, the sub-reference block A2 corresponding to the edge motion vector can be copied from the first reference block, and the sub-reference block B2 corresponding to the symmetric motion vector of the edge motion vector can be copied from the second reference block. The first pixel value of the sub-reference block A2 and the second pixel value of the sub-reference block B2 are used to obtain the cost value corresponding to the edge motion vector, and so on.

[0318] To summarize, in order to obtain the cost value corresponding to a motion vector, a sub-reference block corresponding to the motion vector can be obtained from the first reference block, and a sub-reference block corresponding to the symmetric motion vector of the motion vector can be obtained from the second reference block, and 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.

[0319] Embodiment 22: Based on Embodiment 21, a cost value corresponding to a motion vector is obtained according to an un-downsampled first pixel value (i.e., an un-downsampled pixel value of a sub-reference block in a first reference block) and an un-downsampled second pixel value (i.e., an un-downsampled pixel value of a sub-reference block in a second reference block). For example, assuming that 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 according to the SAD of all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1, and there is no need to vertically downsample the pixels of the sub-reference block pred0 and the sub-reference block pred1.

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

[0321]

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

[0323] Embodiment 23: Based on Embodiment 21, the first pixel value may be downsampled, and the second pixel value may be downsampled; the cost value corresponding to the motion vector may be obtained according to 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, assuming that 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 according to 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 vertically downsampled N times (N is an integer greater than 0, which may be 2).

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

[0325]

[0326] In the above formula, cost can represent the cost value, W can be the width value of the sub-reference block, H can be the height value of the sub-reference block, N can represent the downsampling parameter, which is an integer greater than 0, which can be 2, pred0(1+N(i-1), j) can represent 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) can represent the pixel value of the 1+N(i-1)th column and jth row of the sub-reference block pred1, and abs(x) can represent the absolute value of x.

[0327] Embodiment 24: Based on Embodiment 21, 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; a cost value corresponding to the motion vector is obtained according to the first pixel value after the operation (the pixel value after the shift and downsampling of the sub-reference block in the first reference block) and the second pixel value after the operation (the pixel value after the shift and downsampling of the sub-reference block in the second reference block). For example, assuming that the sub-reference block in the first reference block is pred0, and the sub-reference block in the second reference block is pred1, both pred0 and pred1 are stored in a D-bit manner, that is, each pixel value in pred0 is stored in D bits, and each pixel value in pred1 is stored in D bits.

[0328] If D is less than or equal to 8, the cost value is determined according to 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 vertically downsampled by N times (N is an integer greater than 0, which can be 2). Based on all pixel values ​​of the sub-reference block pred0 and the sub-reference block pred1, the cost value calculation formula is:

[0329]

[0330] 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, which is an integer greater than 0, and can be 2, pred0(1+N(i-1), j) represents the pixel value of the 1+N(i-1)th column and the 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 the jth row of the sub-reference block pred1, abs(x) represents the absolute value of x. From the above, it can be seen that only the absolute value and difference of the 1st row, the N+1th row, the 2N+1th row, etc. are calculated.

[0331] If D is greater than 8, first shift all pixel values ​​of sub-reference block pred0 and sub-reference block pred1 to 8 bits to obtain 8-bit pred0 and 8-bit pred1, recorded as pred 0-8bit(i,j) and pred 1-8bit(i,j) The purpose is to save the storage cost of SAD calculation, and 8-bit storage can achieve higher parallelism.

[0332] pred 0_8bit (i,j)=pred0(i,j)>>(D-8),pred 1_8bit (i,j)=pred1(i,j)>>(D-8)

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

[0334]

[0335] In the above formula, the meaning of each expression refers to the above embodiment and will not be repeated here.

[0336] Embodiment 25: In the above embodiment, for each sub-block of the current block, the prediction value of the sub-block is determined according to the first target motion vector and the second target motion vector of the sub-block, and the prediction value of the current block is determined according to the prediction value of each sub-block. For example, based on the first target motion vector and the second target motion vector of the sub-block, reference blocks in two directions (i.e., the third reference block and the fourth reference block may include prediction values ​​of three components, and interpolation is required because the target motion vector may be pixel-by-pixel). Then, weighting is performed according to the third pixel value of the third reference block and the fourth pixel value of the fourth reference block to obtain the final prediction value (such as the prediction value of three components).

[0337] In a possible implementation, 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 frame based on the first target motion vector of the sub-block; a fourth reference block corresponding to the sub-block is determined from the second reference frame based on the 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 to obtain a prediction value of the sub-block.

[0338] For example, assuming that the size of the sub-block is dx*dy, a third reference block of size dx*dy is determined from the first reference frame based on the first target motion vector. For example, a reference block of size A*B is determined from the first reference frame, and the size of A*B is related to the interpolation method, such as A is greater than dx and B is greater than dy, and there is no restriction on this. By interpolating the pixel values ​​in the reference block, a third reference block of size dx*dy can be obtained, and there is no restriction on this interpolation method. Based on the second target motion vector, a fourth reference block of size dx*dy is determined from the second reference frame. For example, a reference block of size A*B is determined from the second reference frame, and the size of A*B is related to the interpolation method, such as A is greater than dx and B is greater than dy, and there is no restriction on this. By interpolating the pixel values ​​in the reference block, a fourth reference block of size dx*dy can be obtained, and there is no restriction on this interpolation method.

[0339] In another possible implementation, if the optimal motion vector is different from the initial motion vector, a fifth reference block may be determined from the first reference frame, and the fifth reference block may be expanded to obtain a sixth reference block; then, based on the first target motion vector of the sub-block, a third reference block corresponding to the sub-block may be selected from the sixth reference block. Also, a seventh reference block may be determined from the second reference frame, and the seventh reference block may be expanded to obtain an eighth reference block; based on the second target motion vector of the sub-block, a fourth reference block corresponding to the sub-block may be selected from the eighth reference block. Then, the pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block may be weighted to obtain a predicted value of the sub-block.

[0340] For example, assuming that the size of the sub-block is dx*dy, a fifth reference block of size dx*dy is determined from the first reference frame based on the first original motion vector. For example, a reference block of size A*B is determined from the first reference frame, and the size of A*B is related to the interpolation method, such as A is greater than dx, and B is greater than dy, and there is no restriction on this. By interpolating the pixel values ​​in the reference block, a fifth reference block of size dx*dy can be obtained, and there is no restriction on this interpolation method. Then, the fifth reference block is expanded to obtain a sixth reference block. For example, the fifth reference block is padded up, down, left, and right by copying adjacent values, and the padded reference block is used as the sixth reference block. The size of the sixth reference block can be greater than dx*dy. Then, based on the first target motion vector of the sub-block, a third reference block of size dx*dy corresponding to the sub-block is selected from the sixth reference block.

[0341] Assuming that the size of the sub-block is dx*dy, determine the seventh reference block of size dx*dy from the second reference frame based on the second original motion vector. For example, determine a reference block of size A*B from the second reference frame, and the size of A*B is related to the interpolation method, such as A is greater than dx, and B is greater than dy, and there is no restriction on this. By interpolating the pixel values ​​in the reference block, a seventh reference block of size dx*dy can be obtained, and there is no restriction on this interpolation method. Then, the seventh reference block can be expanded to obtain the eighth reference block. For example, the seventh reference block can be padded up, down, left, and right by copying adjacent values, and the padded reference block is used as the eighth reference block. The size of the eighth reference block can be greater than dx*dy. Then, based on the second target motion vector of the sub-block, select the fourth reference block of size dx*dy corresponding to the sub-block from the eighth reference block.

[0342] Embodiment 26: After obtaining the target motion vector, based on the target motion vector of each sub-block, the prediction values ​​in two directions (i.e., the three components of YUV, i.e., the prediction value of the third reference block and the prediction value of the fourth reference block) are obtained through an 8-tap interpolation filter, and the final prediction value is obtained by weighting. Alternatively, based on the target motion vector of each sub-block, the prediction values ​​in two directions (i.e., the three components of YUV, i.e., the prediction value of the third reference block and the prediction value of the fourth reference block) are obtained through a bilinear interpolation filter (here it is no longer an 8-tap interpolation filter), and the final prediction value is obtained by weighting.

[0343] Embodiment 27: After obtaining the prediction values ​​in two directions, the final prediction value is obtained by weighted averaging the mean values ​​(that is, the weights of the prediction values ​​in the two directions are the same). Alternatively, after obtaining the prediction values ​​in the two directions, the final prediction value is obtained by weighted averaging, and the weights of the two prediction values ​​may be different. For example, the weight ratio of the two prediction values ​​may be 1:2, 1:3, 2:1, etc. For the encoding end, the weight table may include weight ratios such as 1:2, 1:3, 2:1, and the encoding end may determine the cost of each weight ratio and determine the weight ratio with the smallest cost value. In this way, the encoding end may obtain the final prediction value by weighted averaging based on the weight ratio with the smallest cost value. When the encoding end sends the encoded bit stream to the decoding end, the encoded bit stream carries the index value of the weight ratio in the weight table. In this way, the decoding end obtains the weight ratio corresponding to the index value from the weight table by parsing the index value of the encoded bit stream, and obtains the final prediction value by weighted averaging based on the weight ratio.

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

[0345] For example, the weight "-2" is a negative value. When the weight of one predicted value is -2, the weight of the other predicted value is 10, that is, the sum of the two weights is 8. In this case, the final predicted value = (predicted value 1*(-2)+predicted value 2*(8-(-2))).

[0346] For example, the weight "10" means that the weight of one prediction value is 10, and the weight of the other prediction value is -2, that is, the sum of the two weights is 8. In this case, the final prediction value = (prediction value 1*(10)+prediction value 2*(-2)).

[0347] For example, the weight "3" means that the weight of one prediction value is 3, and the weight of another prediction value is 5, that is, the sum of the two weights is 8. In this case, the final prediction value = (prediction value 1*(3)+prediction value 2*(5)).

[0348] For example, the weight "5" means that the weight of one prediction value is 5, and the weight of another prediction value is 3, that is, the sum of the two weights is 8. In this case, the final prediction value = (prediction value 1*(5)+prediction value 2*(3)).

[0349] For example, the weight "4" means that the weight of one prediction value is 4, and the weight of another prediction value is 4, that is, the sum of the two weights is 8. In this case, the final prediction value = (prediction value 1*(4)+prediction value 2*(4)).

[0350] In a possible implementation, for each sub-block of the current block, referring to the above embodiment, the third pixel value of the third reference block and the fourth pixel value of the fourth reference block can be obtained, and then, the third pixel value of the third reference block and the fourth pixel value of the fourth reference block are weighted to obtain the final prediction 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 the prediction value of the sub-block. If the final prediction value is obtained by weighted averaging of the mean (i.e., the two weights are the same), the first weight is the same as the second weight.

[0351] 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 may be saved, or the first original motion vector and the second original motion vector of each sub-block of the current block may be saved, 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 may be saved. For the saved motion vectors, these motion vectors may be used as references for encoding / decoding of subsequent blocks.

[0352] For example, taking the first target motion vector and the second target motion vector of each sub-block of the current block as an example, the first target motion vector and the second target motion vector are used for loop filtering of the current frame; the first target motion vector and the second target motion vector are used for temporal reference of subsequent frames; and / or, the first target motion vector and the second target motion vector are used for spatial reference of the current frame. For example, the first target motion vector and the second target motion vector of each sub-block of the current block can be used for motion compensation of the current block, or for temporal reference of subsequent frames. For another example, the first target motion vector and the second target motion vector of each sub-block of the current block can be used for motion compensation of the current block, or for the loop filtering process of the current block, or for temporal reference of subsequent frames. For another example, the first target motion vector and the second target motion vector of each sub-block of the current block can be used for motion compensation of the current block, or for the loop filtering process of the current block, or for temporal reference of subsequent frames, or for spatial reference of the current frame, which is explained below.

[0353] The first target motion vector and the second target motion vector of each sub-block of the current block can be used for spatial reference of blocks in certain LCUs (Largest Coding Unit) in the spatial domain. Since the encoding and decoding order is from top to bottom and from left to right, the motion vector of the current block can be referenced by other blocks in the current LCU, and can also be referenced by blocks in subsequent adjacent LCUs. Since the amount of calculation required to obtain the target motion vector is large, if subsequent blocks refer to the target motion vector of the current block, it will take a long time to wait. In order to avoid delays caused by excessive waiting, only a few spatially adjacent blocks are allowed to refer to the target motion vector of the current block, and other blocks refer to the original motion vector of the current block.

[0354] Exemplarily, these few blocks include sub-blocks in the lower LCU and the lower right LCU located below the current LCU, while sub-blocks located in the right LCU and the left LCU cannot refer to the target motion vector of the current block.

[0355] Embodiment 29: The following is a specific example to illustrate the process of adjusting the motion vector. The specific steps of adjusting the motion vector can be as follows, where the "copy" in the following description does not require interpolation to obtain, and if the MV (i.e., the motion vector) is an integer pixel offset, it can be directly copied from the reference frame, otherwise it needs to be interpolated.

[0356] Step e1: If the motion vector adjustment mode is enabled for the current block, the following process is performed.

[0357] Step e2: prepare reference pixel values ​​(assuming the width of the current block is W and the height is H).

[0358] Prepare the integer pixel blocks for step e3: Based on the original motion vector (the original motion vector of list0 is denoted as Org_MV0, and the original motion vector of list1 is denoted as Org_MV1), copy two integer pixel blocks of three components with an area of ​​(W+FS-1)*(H+FS-1) at the corresponding position of the corresponding reference frame. In addition, prepare the integer pixel blocks for step e4: On the basis of the above-mentioned integer pixel blocks of (W+FS-1)*(H+FS-1), the integer pixel blocks of three components of (W+FS-1)*(H+FS-1) are expanded in the upper, lower, left and right SR rows / columns, and after expansion, the integer pixel blocks of three components with an area of ​​(W+FS-1+2*SR)*(H+FS-1+2*SR) are obtained, which are denoted as Pred_Inter0 and Pred_Inter1, reference Figure 8 As shown. Exemplarily, the size of the inner black area is the size of the current block, the outer white area is the additional reference pixels required for the original motion vector to perform an 8-tap filter interpolation, and the outer black area is the additional reference pixels required for the target motion vector to perform an 8-tap filter interpolation.

[0359] For the black and white areas of the inner layer W*H, the pixel values ​​are obtained from the reference frame. For the pixel values ​​of the outer black area, it is not necessary to obtain them from the reference frame, but they can be obtained by copying adjacent pixel values. In one example, the W+FS-1 pixel values ​​of the first row of the white area are copied to the pixel values ​​of the first SR rows of the outer black area. The W+FS-1 pixel values ​​of the last row of the white area are copied to the pixel values ​​of the last SR rows of the outer black area. Then, the H+FS-1 pixel values ​​of the first column of the white area and the upper and lower SR pixel values ​​of the outer black area that have been obtained are copied to the pixel values ​​of the first SR columns of the outer black area. The H+FS-1 pixel values ​​of the last column of the white area and the upper and lower SR pixel values ​​of the outer black area that have been obtained are copied to the pixel values ​​of the last SR columns of the outer black. In another example, the H+FS-1 pixel values ​​of the first column of the white area are copied to the pixel values ​​of the first SR columns of the outer black area. The last column H+FS-1 pixel values ​​of the white area are copied to the last SR column pixel values ​​of the outer black area. Then, the first row W+FS-1 pixel values ​​of the white area and the left and right SR pixel values ​​of the outer black area are copied to the first SR row pixel values ​​of the outer black area. The last row W+FS-1 pixel values ​​of the white area and the left and right SR pixel values ​​of the outer black area are copied to the last SR row pixel values ​​of the outer black area.

[0360] The first motion compensation is performed based on motion information in two different directions. For example, for the luminance component (because the subsequent search process uses the luminance component to calculate the cost value), based on two integer pixel reference blocks with an area of ​​(W+FS-1)*(H+FS-1), two initial reference prediction values ​​(denoted as Pred_Bilinear0 and Pred_Bilinear1) with a size of (W+2*SR)*(H+2*SR) are obtained through bilinear interpolation. FS is the number of filter taps, which defaults to 8, and SR is the search range, that is, the maximum horizontal / vertical component interpolation of the target motion vector and the original motion vector, which defaults to 2. Pred_Bilinear0 / 1 is used in step e3.

[0361] Step e3: For each dx*dy sub-block of the current block, obtain the target motion vector (the target motion vectors in two directions are respectively denoted as Refined_MV0 and Refined_MV1).

[0362] Step e31, perform SR iterations to obtain the optimal integer pixel offset of the integer pixel MV point, recorded as IntegerDeltaMV, initialize IntegerDeltaMV to (0, 0), and perform the following process for each iteration:

[0363] Step e311, set deltaMV to (0, 0). If it is the first iteration process, based on the original motion vector in the reference pixel Pred_Bilinear0 / 1, copy two prediction value blocks (actually the W*H block at the center of Pred_Bilinear0 / 1), and based on these two prediction value blocks, obtain the initial cost value, that is, the SAD of the prediction value blocks in two directions after vertical 2 times downsampling. If the initial cost value is less than dx*dy, dx and dy are the width and height of the current sub-block, then directly skip the subsequent search process, execute step e32, and set notZeroCost to false.

[0364] Step e312, taking the above initial point as the center, obtain 24 offset MVs (these 24 offset MVs are all called MVOffset) 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)}, and perform the cost value calculation and comparison process of these offset MVs. For example, based on a certain MVOffset, in the reference pixel Pred_Bilinear0 / 1, two blocks of prediction value are obtained through MVOffset (i.e., a W*H block with a center position offset of MVOffset in Pred_Bilinear0, and a W*H block with a center position offset of -MVOffset (the opposite of list0) in Pred_Bilinear1), and the downsampled SAD of the two blocks is calculated as the cost value of MVOffset. The MVOffset with the smallest cost value is retained (stored in deltaMV).

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

[0366] Step e313: After one iteration, if 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 executed, and notZeroCost is set to false.

[0367] Step e32: Taking the optimal whole pixel MV point of step e31 as the center, the optimal sub-pixel offset MV can be obtained, which is recorded as SPMV (i.e., subMV), and the SPMV is initialized to (0, 0), and then the following process is performed:

[0368] Step e321: Only when notZeroCost is not false and deltaMV is (0, 0), subsequent processing is performed; otherwise, the original motion vector is adjusted directly using IntegerDeltaMV.

[0369] Step e322: E(x, y) is expressed as the MV corresponding cost value of the optimal MV point offset (x, y) obtained in step e31 (the cost value calculated in step e31). Based on the 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) is: 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, for motion vector pixel accuracy of 1 / 2, 1 / 4, 1 / 8, and 1 / 16, N = 1, 2, 4, and 8. Then, (x0, y0) can be assigned to deltaMv, SPMV=deltaMv / 2N. If the current motion vector pixel accuracy is 1 / 16, the SPMV can be (x0 / 16, y0 / 16).

[0370] If E(-1,0)=E(0,0), then the horizontal shift is half a pixel to the left (deltaMv[0]=-N).

[0371] If E(1,0)=E(0,0), then the horizontal shift is half a pixel to the right (deltaMv[0]=N).

[0372] If E(0,-1)=E(0,0), then the vertical shift is half a pixel upward (deltaMv[1]=-N).

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

[0374] Step e33: Based on the integer pixel offset IntegerDeltaMV of step e31 and the sub-pixel offset SPMV of step e32, the optimal offset MV is obtained, and the optimal offset MV is recorded as BestMVoffset. BestMVoffset = IntegerDeltaMV + SPMV. Based on BestMVoffset, the target motion vectors in two directions can be obtained: Refined_MV0 = Org_MV0 + BestMVoffset; Refined_MV1 = Org_MV1 - BestMVoffset.

[0375] Step e4: Based on the target motion vector of each sub-block, 8-tap interpolation is performed to obtain the prediction values ​​of the three components in two directions, and the final prediction values ​​(such as the prediction values ​​of the three components) are obtained by weighting. For example, based on the target motion vectors Refined_MV0 and Refined_MV1 of each sub-block, the corresponding prediction block is obtained by interpolation in Pred_Inter0 / 1 prepared in step e2 (the motion vector may be pixel-by-pixel, and interpolation is required to obtain the corresponding pixel block).

[0376] Step e5: The target motion vector is used for motion compensation of the current block (ie, obtaining the prediction value of each sub-block and the prediction value of the current block) and temporal reference of subsequent frames, but is not used for loop filtering of the current frame and spatial reference.

[0377] Embodiment 30: Different from Embodiment 29, the reference pixel preparation process is moved to each dx*dy sub-block. When preparing reference pixels, only (dx+(filtersize-1))*(dy+(filtersize-1)) pixel blocks are prepared. If the optimal motion vector obtained by the search is not the original motion vector, the reference pixels are expanded, otherwise no expansion is performed. For each dx*dy sub-block of the current block, the target motion vector is obtained respectively, motion compensation is performed based on the target motion vector, and the final prediction value is obtained by weighting. The following process is for each dx*dy sub-block of the current block:

[0378] Step f1: If the motion vector adjustment mode is enabled for the current block, the following process is performed.

[0379] Step f2, prepare integer pixel blocks for step f3: for example, only perform the following on the luminance component: based on the original motion vector (the original motion vector of list0 is denoted as Org_MV0, and the original motion vector of list1 is denoted as Org_MV1), obtain two integer pixel blocks with an area of ​​(dx+(filtersize-1))*(dy+(filtersize-1)) from the corresponding positions of the corresponding reference frames.

[0380] Exemplarily, filtersize may be the number of filter taps, which defaults to 8.

[0381] Step f3: For each dx*dy sub-block of the current block, obtain the target motion vector (the target motion vectors in two directions are respectively denoted as Refined_MV0 and Refined_MV1).

[0382] Exemplarily, the implementation process of step f3 can refer to step e3, which will not be described in detail here.

[0383] For example, the first motion vector compensation is performed based on the original motion vector. For the luminance component only, an initial prediction value of size (dx+2*IterNum)*(dy+2*IterNum) is obtained based on bilinear interpolation. IterNum defaults to 2, IterNum can be the search range SR, and IterNum can be the maximum horizontal / vertical component interpolation of the target motion vector and the original motion vector. The initial prediction value of the original motion vector obtained above is stored in m_cYuvPredTempL0 / 1.

[0384] Perform cost calculations for 25 points to obtain the optimal integer pixel offset of the integer pixel MV point. If it is the first point (MV offset (0, 0)), obtain the initial cost (cost is the SAD of the vertical 2-fold downsampling of the predicted values ​​in both directions. If the cost is less than dx*dy, skip the subsequent search process directly (notZeroCost is set to false). With the above initial point as the center, perform cost calculation and comparison for 24 points, and retain the point with the smallest cost as the new center point for the next step. With the optimal integer pixel MV point as the center, obtain the optimal 1 / 16 pixel sub-pixel offset. Based on the integer pixel offset and sub-pixel offset, obtain the optimal offset MV, and record the optimal offset MV as BestMVoffset. BestMVoffset = IntegerDeltaMV + SPMV. Based on BestMVoffset, the target motion vectors in two directions can be obtained: Refined_MV0 = Org_MV0 + BestMVoffset; Refined_MV1 = Org_MV1-BestMVoffset.

[0385] Step f4: If the optimal offset MV is (0, 0), the following steps are not performed (i.e., no additional expansion is performed when the original motion vector is used). If the optimal offset MV is not (0, 0), the integer pixels are reacquired (since the above steps do not perform reference pixel expansion, the reference pixels required after the offset exceed the range of the reference pixels obtained in the above steps), and the following steps are performed:

[0386] For the reference frames of list0 and list1, respectively perform the following operations on the U / V components (because the brightness component is obtained in step f2): obtain the integer pixel value of (dxc+(filtersizeC-1))*(dyc+(filtersizeC-1)) from the reference frame. dxc and dyc are related to the sampling rate. When the YUV sampling rate is 420, dxc=dx / 2, dyc=dy / 2. Of course, this is just an example, and there is no limit on dxc and dyc. filtersizeC can be 4. Of course, this is just an example, and there is no limit on filtersizeC. For another example, the integer pixel value of dx*dy can be directly obtained from the reference frame, and there is no limit on this.

[0387] For the reference frames of list0 and list1, the three components are filled respectively. For example, by copying the adjacent value edge, on the basis of the integer pixel value obtained in the above steps (such as the integer pixel value of (dxc+(filtersizeC-1))*(dyc+(filtersizeC-1)), fill up, down, left and right (such as filling width brightness component is 2, 420 chroma component is 1). Exemplarily, the integer pixel values ​​that can be used around the current sub-block (in the current CU block) are not used here.

[0388] Step f5: Based on the target motion vector of each sub-block and two reference pixel blocks (obtained in step f4), 8-tap interpolation is performed to obtain prediction values ​​of the three components in two directions, and the final prediction values ​​(such as the prediction values ​​of the three components) are obtained by weighting.

[0389] Embodiment 31: The above embodiments can be implemented individually or in any combination without limitation.

[0390] For example, embodiment 4 can be implemented in combination with embodiment 2; embodiment 4 can be implemented in combination with embodiment 3.

[0391] Embodiment 5 can be implemented in combination with Embodiment 2; Embodiment 5 can be implemented in combination with Embodiment 2 and Embodiment 4; Embodiment 5 can be implemented in combination with Embodiment 3; Embodiment 5 can be implemented in combination with Embodiment 3 and Embodiment 4.

[0392] Example 6 can be implemented alone, Example 7 can be implemented alone, Example 8 can be implemented in combination with Example 7; Example 9 can be implemented in combination with Example 7; Example 10 can be implemented in combination with Example 7; Example 11 can be implemented in combination with Example 7; Example 12 can be implemented in combination with Example 7; Example 13 can be implemented in combination with Example 7; Example 14 can be implemented in combination with Example 7; Example 15 can be implemented in combination with Example 7.

[0393] Example 16 can be implemented alone, Example 17 can be implemented alone, Example 18 can be implemented in combination with Example 17; Example 19 can be implemented in combination with Example 17; Example 20 can be implemented in combination with Example 17.

[0394] Example 21 can be implemented in combination with Example 6, Example 21 can be implemented in combination with Example 16, Example 21 can be implemented in combination with Example 7, Example 21 can be implemented in combination with Example 17, Example 22 can be implemented in combination with Example 21, Example 23 can be implemented in combination with Example 21, and Example 24 can be implemented in combination with Example 21.

[0395] Example 25 can be implemented in combination with Example 2; Example 25 can be implemented in combination with Example 2 and Example 4; Example 25 can be implemented in combination with Example 3; Example 25 can be implemented in combination with Example 3 and Example 4.

[0396] Example 26 can be implemented in combination with Example 25; Example 27 can be implemented in combination with Example 25.

[0397] Example 28 can be implemented in combination with Example 2; Example 28 can be implemented in combination with Example 2 and Example 4; Example 28 can be implemented in combination with Example 3; Example 28 can be implemented in combination with Example 3 and Example 4.

[0398] Embodiment 29 can be implemented alone, or in combination with Embodiment 4. Embodiment 30 can be implemented alone, or in combination with Embodiment 4. Of course, the above are only a few examples of the present application, and there is no limitation to this. All embodiments involved in the present application can be implemented alone or in combination, and no further details will be given for this.

[0399] Embodiment 32:

[0400] Based on the same application concept as the above method, the embodiment of the present application also proposes a coding and decoding device, which is applied to the coding end or the decoding end, such as Fig.9A As shown, it is a structural diagram of the device, and the device includes:

[0401] The determination module 911 is used to determine whether to start the motion vector adjustment mode for the current block if the following conditions are met:

[0402] The control information is to allow the current block to use the motion vector adjustment mode;

[0403] 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;

[0404] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0405] The two reference frames of the current block have the same weighting;

[0406] Both reference frames of the current block are short-term reference frames;

[0407] The width, height and area of ​​the current block are all within the specified range;

[0408] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0409] The motion compensation module 912 is configured to perform motion compensation on the current block if it is determined that the motion vector adjustment mode is enabled for the current block.

[0410] The motion compensation module 912 is specifically configured to: for each sub-block of at least one sub-block included in the current block:

[0411] Determine a first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determine a second reference block corresponding to the sub-block according to the second original motion vector of the sub-block; adjust 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; determine a prediction value of the sub-block according to the first target motion vector and the second target motion vector;

[0412] The prediction value of the current block is determined according to the prediction value of each sub-block.

[0413] The determination module 911 is further used to: determine not to start the motion vector adjustment mode for the current block if any one of the following conditions is not satisfied: the control information is to allow the current block to use the motion vector adjustment mode;

[0414] 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;

[0415] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0416] The two reference frames of the current block have the same weighting;

[0417] Both reference frames of the current block are short-term reference frames;

[0418] The width, height and area of ​​the current block are all within the specified range;

[0419] The sizes of the two reference frames of the current block are the same as the size of the current frame.

[0420] The control information for allowing the current block to use the motion vector adjustment mode includes: sequence-level control information for allowing the current block to use the motion vector adjustment mode; and / or frame-level control information for allowing the current block to use the motion vector adjustment mode.

[0421] The width, height and area of ​​the current block are all within a limited range: the width is greater than or equal to a first threshold, the height is greater than or equal to a second threshold, and the area is greater than or equal to a third threshold; or, the width is greater than or equal to the first threshold, the height is greater than or equal to the second threshold, and the area is greater than a fourth threshold; wherein the third threshold is greater than the fourth threshold.

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

[0423] The motion compensation module 912 determines the first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determines the second reference block corresponding to the sub-block according to the second original motion vector of the sub-block, specifically for:

[0424] Based on the first original motion vector of the sub-block, determine a first reference block corresponding to the sub-block from a first reference frame; a pixel value of each pixel in the first reference block is obtained by interpolating pixel values ​​of adjacent pixels in the first reference block, or by copying pixel values ​​of adjacent pixels in the first reference block;

[0425] 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 frame; a pixel value of each pixel in the second reference block is obtained by interpolating pixel values ​​of adjacent pixels in the second reference block, or by copying pixel values ​​of adjacent pixels in the second reference block.

[0426] The motion compensation module 912 adjusts the first original motion vector and the second original motion vector according to 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 corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, specifically for:

[0427] Taking an initial motion vector as the center, selecting part or all of the motion vectors from the motion vectors around the 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;

[0428] Selecting a motion vector from the initial motion vector and each candidate motion vector as an optimal motion vector according to a first pixel value of the first reference block and a second pixel value of the second reference block;

[0429] The first original motion vector is adjusted according to 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 according to the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector.

[0430] The motion compensation module 912 adjusts the first original motion vector according to 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 according to the optimal motion vector to obtain a second target motion vector corresponding to the second original motion vector, which is specifically used for:

[0431] Determine a first integer-pixel motion vector adjustment value, a second integer-pixel motion vector adjustment value, a first sub-pixel motion vector adjustment value, and a second sub-pixel motion vector adjustment value of the sub-block according to the optimal motion vector;

[0432] Adjusting the first original motion vector according to the first integer-pixel motion vector adjustment value and the first sub-pixel motion vector adjustment value to obtain a first target motion vector of the sub-block;

[0433] The second original motion vector is adjusted according to the second integer-pixel motion vector adjustment value and the second sub-pixel motion vector adjustment value to obtain a second target motion vector of the sub-block.

[0434] If the optimal motion vector is the same as the initial motion vector, the motion compensation module 912 determines the prediction value of the sub-block according to the first target motion vector and the second target motion vector by:

[0435] Based on the first target motion vector of the sub-block, determining a third reference block corresponding to the sub-block from the first reference frame;

[0436] Based on the second target motion vector of the sub-block, determining a fourth reference block corresponding to the sub-block from a second reference frame;

[0437] The pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block are weighted to obtain the prediction value of the sub-block.

[0438] If the optimal motion vector is different from the initial motion vector, the motion compensation module 912 determines the prediction value of the sub-block according to the first target motion vector and the second target motion vector by:

[0439] Determine a fifth reference block from the first reference frame, and expand the fifth reference block to obtain a sixth reference block; select a third reference block corresponding to the sub-block from the sixth reference block based on the first target motion vector of the sub-block;

[0440] Determine a seventh reference block from the second reference frame, and expand the seventh reference block to obtain an eighth reference block; select a fourth reference block corresponding to the sub-block from the eighth reference block based on the second target motion vector of the sub-block;

[0441] The pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block are weighted to obtain the prediction value of the sub-block.

[0442] 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 the predicted value of the sub-block by: weighting the pixel values ​​of the third reference block, the first weight corresponding to the pixel values ​​of the third reference block, the pixel values ​​of the fourth reference block, and the second weight corresponding to the pixel values ​​of the fourth reference block to obtain the predicted value of the sub-block; wherein the first weight is the same as the second weight.

[0443] The decoding end device provided in the embodiment of the present application, from the hardware level, its hardware architecture diagram can be specifically referred to Fig. 9B As shown. It includes: a processor 921 and a machine-readable storage medium 922, wherein the machine-readable storage medium 922 stores machine-executable instructions that can be executed by the processor 921; the processor 921 is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application. For example, the processor is used to execute the machine-executable instructions to implement the following steps:

[0444] If the following conditions are met, it is determined to start the motion vector adjustment mode for the current block:

[0445] The control information is to allow the current block to use the motion vector adjustment mode;

[0446] 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;

[0447] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0448] The two reference frames of the current block have the same weighting;

[0449] Both reference frames of the current block are short-term reference frames;

[0450] The width, height and area of ​​the current block are all within the specified range;

[0451] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0452] If it is determined that the motion vector adjustment mode is started for the current block, motion compensation is performed on the current block.

[0453] The encoding end device provided in the embodiment of the present application, from the hardware level, its hardware architecture diagram can be specifically referred to Fig. 9C As shown. It includes: a processor 931 and a machine-readable storage medium 932, wherein the machine-readable storage medium 932 stores machine-executable instructions that can be executed by the processor 931; the processor 931 is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application. For example, the processor is used to execute the machine-executable instructions to implement the following steps:

[0454] If the following conditions are met, it is determined to start the motion vector adjustment mode for the current block:

[0455] The control information is to allow the current block to use the motion vector adjustment mode;

[0456] 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;

[0457] The prediction value of the current block is obtained by weighting reference blocks from two reference frames, and the display order of the two reference frames is respectively located before and after the current frame, and the distances between the two reference frames and the current frame are the same;

[0458] The two reference frames of the current block have the same weighting;

[0459] Both reference frames of the current block are short-term reference frames;

[0460] The width, height and area of ​​the current block are all within the specified range;

[0461] The sizes of the two reference frames of the current block are the same as the size of the current frame;

[0462] If it is determined that the motion vector adjustment mode is started for the current block, motion compensation is performed on the current block.

[0463] Based on the same application concept as the above method, the embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by the processor, the encoding and decoding method disclosed in the above example of the present application can be implemented. Among them, the above-mentioned machine-readable storage medium can be any electronic, magnetic, optical or other physical storage device, which can contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium can be: RAM (Radom Access Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state hard disk, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.

[0464] The systems, devices, modules or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email transceiver device, a game console, a tablet computer, a wearable device, or a combination of any of these devices. For the convenience of description, the above devices are described separately by function into various units. Of course, when implementing this application, the functions of each unit can be implemented in the same one or more software and / or hardware.

[0465] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the embodiments of the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each flow and / or box in the flow chart and / or block diagram and the combination of the flow chart and / or box in the flow chart and / or block diagram can be realized by computer program instructions. 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 produce a machine, so that the instructions executed by the processor of a computer or other programmable data processing device produce a device for realizing the function specified in one flow chart or multiple flows and / or one box or multiple boxes of a block chart.

[0466] Moreover, these computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes of the flowchart and / or one or more boxes of the block diagram. These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operating steps are performed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes of the flowchart and / or one or more boxes of the block diagram.

[0467] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A coding and decoding method, characterized in that: The method comprises: If it is determined to start the motion vector adjustment mode for the current block, motion compensation is performed on the current block to obtain a prediction value of the current block; wherein the step of performing motion compensation on the current block to obtain a prediction value of the current block includes: For each sub-block in at least one sub-block included in the current block: Determine a first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determine a second reference block corresponding to the sub-block according to the second original motion vector of the sub-block; adjust 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; determine a prediction value of the sub-block according to the first target motion vector and the second target motion vector; Determine the prediction value of the current block according to the prediction value of each sub-block; The first original motion vector and the second original motion vector are adjusted according to 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 corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, including: Select all (2*SR+1)*(2*SR+1) points around the original motion vector including the original motion vector as candidate motion vectors, determine the cost values ​​of the candidate motion vectors according to the first pixel value of the first reference block and the second pixel value of the second reference block, and take the motion vector with the smallest cost value as the optimal motion vector, and adjust the first original motion vector and the second original motion vector according to 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 original motion vector is the first original motion vector or the second original motion vector; Where SR is the search range. If the value of SR is 2, the scanning 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), 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)}; wherein, Mv(0, 0) is the original motion vector, and other candidate motion vectors except Mv(0, 0) are offset motion vectors of the original motion vector; Among them, the adjusting the first original motion vector and the second original motion vector according to 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 includes: determining a first integer pixel motion vector adjustment value according to the optimal motion vector, and determining a second integer pixel motion vector adjustment value according to the first integer pixel motion vector adjustment value; and adjusting the first original motion vector according to the first integer pixel 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 according to the second integer pixel motion vector adjustment value to obtain a second target motion vector corresponding to the second original motion vector.

2. The method according to claim 1, characterized in that The determining a first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determining a second reference block corresponding to the sub-block according to the second original motion vector of the sub-block comprises: Based on the first original motion vector of the sub-block, determine a first reference block corresponding to the sub-block from a first reference frame; a pixel value of each pixel in the first reference block is obtained by interpolating pixel values ​​of adjacent pixels in the first reference block, or by copying pixel values ​​of adjacent pixels 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 frame; a pixel value of each pixel in the second reference block is obtained by interpolating pixel values ​​of adjacent pixels in the second reference block, or by copying pixel values ​​of adjacent pixels in the second reference block.

3. The method according to claim 1, characterized in that If the optimal motion vector is the same as the original motion vector, determining the prediction value of the sub-block according to the first target motion vector and the second target motion vector includes: Based on the first target motion vector of the sub-block, determining a third reference block corresponding to the sub-block from the first reference frame; Based on the second target motion vector of the sub-block, determining a fourth reference block corresponding to the sub-block from a second reference frame; The pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block are weighted to obtain the prediction value of the sub-block.

4. The method according to claim 1, characterized in that If the optimal motion vector is different from the original motion vector, determining the prediction value of the sub-block according to the first target motion vector and the second target motion vector includes: Determine a fifth reference block from the first reference frame, and expand the fifth reference block to obtain a sixth reference block; select a third reference block corresponding to the sub-block from the sixth reference block based on the first target motion vector of the sub-block; Determine a seventh reference block from the second reference frame, and expand the seventh reference block to obtain an eighth reference block; select a fourth reference block corresponding to the sub-block from the eighth reference block based on the 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 to obtain the prediction value of the sub-block.

5. The method according to claim 3 or 4, characterized in that: The step of weighting the pixel values ​​of the third reference block and the pixel values ​​of the fourth reference block to obtain the prediction value of the sub-block includes: The pixel values ​​of the third reference block, the first weight corresponding to the pixel values ​​of the third reference block, the pixel values ​​of the fourth reference block, and the second weight corresponding to the pixel values ​​of the fourth reference block are weighted to obtain the predicted value of the sub-block; wherein the first weight is the same as the second weight.

6. A coding and decoding device, characterized in that: The device comprises: A motion compensation module, configured to, if it is determined that a motion vector adjustment mode is started for a current block, perform motion compensation on the current block to obtain a prediction value of the current block; wherein, when the motion compensation module performs motion compensation on the current block to obtain the prediction value of the current block, specifically for: for each sub-block of at least one sub-block included in the current block: Determine a first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determine a second reference block corresponding to the sub-block according to the second original motion vector of the sub-block; adjust 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; determine a prediction value of the sub-block according to the first target motion vector and the second target motion vector; Determine the prediction value of the current block according to the prediction value of each sub-block; The motion compensation module adjusts the first original motion vector and the second original motion vector according to 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 corresponding to the first original motion vector and the second target motion vector corresponding to the second original motion vector, and is specifically used to: select all of the (2*SR+1)*(2*SR+1) points around the original motion vector including the original motion vector as candidate motion vectors, and determine the cost values ​​of these candidate motion vectors according to the first pixel value of the first reference block and the second pixel value of the second reference block regardless of whether the cost value corresponding to the original motion vector is less than a preset threshold, and take the motion vector with the smallest cost value as the optimal motion vector; adjust the first original motion vector and the second original motion vector according to the optimal motion vector to obtain the first target motion vector corresponding to the first original motion vector and the second target motion vector corresponding to the second original motion vector; The original motion vector is the first original motion vector or the second original motion vector; Where SR is the search range. If the value of SR is 2, the scanning 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), 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)}; wherein, Mv(0, 0) is the original motion vector, and other candidate motion vectors except Mv(0, 0) are offset motion vectors of the original motion vector; Among them, the motion compensation module adjusts the first original motion vector and the second original motion vector according to the optimal motion vector to obtain the first target motion vector corresponding to the first original motion vector and the second target motion vector corresponding to the second original motion vector, and is specifically used to: determine a first integer pixel motion vector adjustment value according to the optimal motion vector, and determine a second integer pixel motion vector adjustment value according to the first integer pixel motion vector adjustment value; and adjust the first original motion vector according to the first integer pixel motion vector adjustment value to obtain the first target motion vector corresponding to the first original motion vector, and adjust the second original motion vector according to the second integer pixel motion vector adjustment value to obtain the second target motion vector corresponding to the second original motion vector.

7. A coding end device, characterized in that: include: a processor and a 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: If it is determined to start the motion vector adjustment mode for the current block, motion compensation is performed on the current block to obtain a prediction value of the current block; wherein the step of performing motion compensation on the current block to obtain a prediction value of the current block includes: For each sub-block in at least one sub-block included in the current block: Determine a first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determine a second reference block corresponding to the sub-block according to the second original motion vector of the sub-block; adjust 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; determine a prediction value of the sub-block according to the first target motion vector and the second target motion vector; Determine the prediction value of the current block according to the prediction value of each sub-block; The first original motion vector and the second original motion vector are adjusted according to 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 corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, including: Select all (2*SR+1)*(2*SR+1) points around the original motion vector including the original motion vector as candidate motion vectors, determine the cost values ​​of the candidate motion vectors according to the first pixel value of the first reference block and the second pixel value of the second reference block, and take the motion vector with the smallest cost value as the optimal motion vector, and adjust the first original motion vector and the second original motion vector according to 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 original motion vector is the first original motion vector or the second original motion vector; Where SR is the search range. If the value of SR is 2, the scanning 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), 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)}; wherein, Mv(0, 0) is the original motion vector, and other candidate motion vectors except Mv(0, 0) are offset motion vectors of the original motion vector; Among them, the adjusting the first original motion vector and the second original motion vector according to 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 includes: determining a first integer pixel motion vector adjustment value according to the optimal motion vector, and determining a second integer pixel motion vector adjustment value according to the first integer pixel motion vector adjustment value; and adjusting the first original motion vector according to the first integer pixel 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 according to the second integer pixel motion vector adjustment value to obtain a second target motion vector corresponding to the second original motion vector.

8. A decoding end device, characterized in that: include: a processor and a 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: If it is determined to start the motion vector adjustment mode for the current block, motion compensation is performed on the current block to obtain a prediction value of the current block; wherein the step of performing motion compensation on the current block to obtain a prediction value of the current block includes: For each sub-block in at least one sub-block included in the current block: Determine a first reference block corresponding to the sub-block according to the first original motion vector of the sub-block, and determine a second reference block corresponding to the sub-block according to the second original motion vector of the sub-block; adjust 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; determine a prediction value of the sub-block according to the first target motion vector and the second target motion vector; Determine the prediction value of the current block according to the prediction value of each sub-block; The first original motion vector and the second original motion vector are adjusted according to 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 corresponding to the first original motion vector and a second target motion vector corresponding to the second original motion vector, including: Select all (2*SR+1)*(2*SR+1) points around the original motion vector including the original motion vector as candidate motion vectors, determine the cost values ​​of the candidate motion vectors according to the first pixel value of the first reference block and the second pixel value of the second reference block, and take the motion vector with the smallest cost value as the optimal motion vector, and adjust the first original motion vector and the second original motion vector according to 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 original motion vector is the first original motion vector or the second original motion vector; Where SR is the search range. If the value of SR is 2, the scanning 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), 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)}; wherein, Mv(0, 0) is the original motion vector, and other candidate motion vectors except Mv(0, 0) are offset motion vectors of the original motion vector; Among them, the adjusting the first original motion vector and the second original motion vector according to 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 includes: determining a first integer pixel motion vector adjustment value according to the optimal motion vector, and determining a second integer pixel motion vector adjustment value according to the first integer pixel motion vector adjustment value; and adjusting the first original motion vector according to the first integer pixel 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 according to the second integer pixel motion vector adjustment value to obtain a second target motion vector corresponding to the second original motion vector.

Citation Information

Patent Citations

  • Coding and decoding method, device and equipment thereof

    CN110312132A

  • Methods and devices for coding motion vectors in video compression

    CN110383841A

  • Efficient motion vector field estimation

    US20120075535A1

  • Method and apparatus of video coding with affine motion compensation

    WO2017148345A1

  • Memory access window and padding for motion vector refinement

    WO2019072370A1