Encoding and decoding method, device and equipment

文档序号:1893558 发布日期:2021-11-26 浏览:11次 中文

阅读说明:本技术 一种编解码方法、装置及其设备 (Encoding and decoding method, device and equipment ) 是由 陈方栋 于 2019-03-11 设计创作,主要内容包括:本申请提供一种编解码方法、装置及其设备,该方法包括:若当前块的特征信息满足特定条件,则根据所述当前块的第一原始运动矢量确定所述当前块对应的第一参考块,根据所述当前块的第二原始运动矢量确定所述当前块对应的第二参考块;根据所述第一参考块的第一像素值和所述第二参考块的第二像素值,对第一原始运动矢量和第二原始运动矢量进行调整,得到所述第一原始运动矢量对应的第一目标运动矢量和所述第二原始运动矢量对应的第二目标运动矢量;根据所述第一目标运动矢量和所述第二目标运动矢量对所述当前块进行编码或者解码。通过本申请的技术方案,可以提高编码性能。(The application provides a coding and decoding method, a device and equipment thereof, wherein the method comprises the following steps: if the characteristic information of the current block meets a specific condition, determining a first reference block corresponding to the current block according to a first original motion vector of the current block, and determining a second reference block corresponding to the current block according to a second original motion vector of the current block; adjusting a first original motion vector and a 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; encoding or decoding the current block according to the first target motion vector and the second target motion vector. By the technical scheme, the coding performance can be improved.)

1. A method of decoding, the method comprising:

if the characteristic information of the current block meets a specific condition, wherein the characteristic information comprises a motion information prediction mode corresponding to the current block, a motion information attribute corresponding to the current block and size information of the current block, determining a first reference block corresponding to at least one sub-block included in the current 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;

selecting all motion vectors from the motion vectors surrounding the initial motion vector and including the initial motion vector by taking the initial motion vector as a center, and determining the selected motion vector as a candidate motion vector; wherein the initial motion vector is the first original motion vector or the second original motion vector;

obtaining a cost value corresponding to the initial motion vector and a cost value corresponding to each candidate motion vector according to a first pixel value of the first reference block and a second pixel value of the second reference block; selecting a motion vector from the initial motion vector and each candidate motion vector as an optimal motion vector according to the cost value corresponding to the initial motion vector and the cost value corresponding to each candidate motion vector;

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, which specifically 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; determining a first sub-pixel motion vector adjustment value according to the cost value corresponding to the optimal motion vector and the cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and determining a second sub-pixel motion vector adjustment value according to the first sub-pixel motion vector adjustment value; 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 corresponding to the first original motion vector; 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 a second target motion vector corresponding to the second original motion vector; wherein the first integer pixel motion vector adjustment value is equal to a difference between the optimal motion vector and the initial motion vector; the second integer pixel motion vector adjustment value and the first integer pixel motion vector adjustment value are opposite numbers; the second sub-pixel motion vector adjustment value and the first sub-pixel motion vector adjustment value are opposite numbers; the first target motion vector is equal to a sum of the first original motion vector, the first integer pixel motion vector adjustment value, and the first sub-pixel motion vector adjustment value; the second target motion vector is equal to a sum of the second original motion vector, the second integer motion vector adjustment value, and the second sub-pixel motion vector adjustment value;

decoding the sub-block according to the first target motion vector and the second target motion vector; wherein the decoding the sub-block according to the first target motion vector and the second target motion vector comprises: determining a third reference block corresponding to the sub-block according to the first target motion vector, and determining a fourth reference block corresponding to the sub-block according to the second target motion vector; weighting according to the pixel value of the third reference block and the pixel value of the fourth reference block to obtain a predicted value of the sub-block;

the method further comprises the following steps: and determining the prediction value of the current block according to the prediction value of each sub-block included by the current block.

2. The method of claim 1, wherein when the current block comprises a sub-block, the sub-block is the current block itself, and the motion information of the current block comprises the first original motion vector and a first reference frame corresponding to the first original motion vector, and the second original motion vector and a second reference frame corresponding to the second original motion vector.

3. The method of claim 1, wherein when the current block comprises a plurality of sub-blocks, each of the plurality of sub-blocks shares motion information of the current block, and wherein the motion information of the current block comprises a first reference frame corresponding to the first original motion vector and the first original motion vector, and a second reference frame corresponding to the second original motion vector and the second original motion vector.

4. The method of claim 1, wherein the first reference block and the second reference block are luma blocks.

5. The method of claim 1, wherein the optimal motion vector is a motion vector with a smallest cost value selected from the initial motion vector and each candidate motion vector.

6. The method of claim 1, wherein the weighting weight is the same when the pixel values of the third reference block and the pixel values of the fourth reference block are weighted.

7. A decoding device, characterized by comprising: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute the machine-executable instructions to implement the method of any of claims 1-6.

8. A decoder, characterized in that the decoder is configured to implement the method of any of claims 1-6.

9. Decoding device, characterized in that it comprises means for implementing the method of any one of claims 1 to 6.

10. A machine-readable storage medium having stored thereon machine-executable instructions executable by a processor; the processor is configured to execute the machine-executable instructions to implement the method of any of claims 1-6.

Technical Field

The present application relates to the field of encoding and decoding technologies, and in particular, to an encoding and decoding method, apparatus, and device.

Background

In order to achieve the purpose of saving space, video images are transmitted after being coded, and the complete video coding method can comprise the processes of prediction, transformation, quantization, entropy coding, filtering and the like. The predictive coding comprises intra-frame coding and inter-frame coding, wherein the inter-frame coding is to use the correlation of a video time domain and use the pixels adjacent to a coded image to predict the pixels of a current image so as to achieve the aim of effectively removing the video time domain redundancy.

In inter-frame coding, a Motion Vector (MV) may be used to represent a relative displacement between a current image block of a current frame video image and a reference image block of a reference frame video image. For example, when a video image a of the current frame has a strong temporal correlation with a video image B of the reference frame, and an image block a1 (current image block) of the video image a needs to be transmitted, a motion search may be performed in the video image B to find an image block B1 (i.e., reference image block) that best matches image block a1, and determine a relative displacement between image block a1 and image block B1, which is also a motion vector of image block a 1.

The encoding side may send the motion vector to the decoding side, instead of sending the image block a1 to the decoding side, and the decoding side may obtain the image block a1 according to the motion vector and the image block B1. Obviously, this can save a lot of bits, since the motion vector occupies a smaller number of bits than the image block a 1.

In a conventional manner, when a current block is a unidirectional block, after a motion vector of the current block (hereinafter, referred to as an original motion vector) is obtained, the original motion vector may be adjusted and encoded/decoded based on the adjusted motion vector, thereby improving encoding performance. However, when the current block is a bidirectional block, how to adjust the first original motion vector and the second original motion vector after obtaining the first original motion vector and the second original motion vector of the current block does not have a reasonable solution at present, that is, for a scene of the bidirectional block, there are problems of low prediction quality, wrong prediction, and the like, thereby resulting in poor coding performance.

Disclosure of Invention

The application provides a coding and decoding method, device and equipment thereof, which can improve coding performance.

The application provides a coding and decoding method, which comprises the following steps: if the characteristic information of the current block meets a specific condition, determining a first reference block corresponding to the current block according to a first original motion vector of the current block, and determining a second reference block corresponding to the current block according to a second original motion vector of the current block; adjusting a first original motion vector and a 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; encoding or decoding the current block according to the first target motion vector and the second target motion vector.

The present application provides a coding and decoding device, the device includes: a determining module, configured to determine, if feature information of a current block meets a specific condition, a first reference block corresponding to the current block according to a first original motion vector of the current block, and determine, according to a second original motion vector of the current block, a second reference block corresponding to the current block; a processing module, configured to adjust a first original motion vector and a 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, so as 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; and the coding and decoding module is used for coding or decoding the current block according to the first target motion vector and the second target motion vector.

The application provides a coding end device, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute machine executable instructions to perform the steps of: if the characteristic information of the current block meets a specific condition, determining a first reference block corresponding to the current block according to a first original motion vector of the current block, and determining a second reference block corresponding to the current block according to a second original motion vector of the current block; adjusting a first original motion vector and a 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; encoding the current block according to the first target motion vector and the second target motion vector.

The application provides a decoding side device, including: a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute machine executable instructions to perform the steps of: if the characteristic information of the current block meets a specific condition, determining a first reference block corresponding to the current block according to a first original motion vector of the current block, and determining a second reference block corresponding to the current block according to a second original motion vector of the current block; adjusting a first original motion vector and a 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; decoding the current block according to the first target motion vector and the second target motion vector.

As can be seen from the foregoing technical solutions, in the embodiment of the present application, a first target motion vector and a second target motion vector of a current block may be determined according to a first original motion vector and a second original motion vector, and the current block may be encoded or decoded according to the first target motion vector and the second target motion vector, instead of being encoded or decoded directly according to the first original motion vector and the second original motion vector, so as to solve the problems of low prediction quality, prediction error, and the like, and improve encoding performance and encoding efficiency.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments of the present application or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments described in the present application, and other drawings can be obtained by those skilled in the art according to the drawings of the embodiments of the present application.

FIG. 1A is a schematic illustration of interpolation in one embodiment of the present application;

FIG. 1B is a schematic diagram of a video coding framework in one embodiment of the present application;

FIG. 2 is a flow chart of a coding and decoding method according to an embodiment of the present application;

FIG. 3 is a flow chart of a method of encoding and decoding in one embodiment of the present application;

FIG. 4 is a flow chart of a method of encoding and decoding in one embodiment of the present application;

FIG. 5 is a schematic diagram of a reference pixel in one embodiment of the present application;

FIG. 6 is a diagram illustrating motion vector iteration in one embodiment of the present application;

FIGS. 7A-7E are schematic diagrams illustrating a sequence of candidate points in one embodiment of the present application;

FIG. 8 is a schematic diagram of spatial referencing of a current block in one embodiment of the present application;

fig. 9 is a block diagram of a codec device according to an embodiment of the present application;

fig. 10 is a hardware configuration diagram of a decoding-side device according to an embodiment of the present application;

fig. 11 is a hardware configuration diagram of an encoding-side device according to an embodiment of the present application.

Detailed Description

The terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein is meant to encompass any and all possible combinations of one or more of the associated listed items.

It should be understood that although the terms first, second, third, etc. may be used in the embodiments of the present application to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. Depending on the context, moreover, the word "if" as used may be interpreted as "at … …" or "when … …" or "in response to a determination".

The embodiment of the application provides a coding and decoding method, which can relate to the following concepts:

intra and inter prediction (intra and inter) techniques: the intra-frame prediction means that the current pixel is predicted by using the pixel of the current image coded block by utilizing the correlation of a video spatial domain so as to achieve the purpose of removing the video spatial domain redundancy. In intra prediction, a plurality of prediction modes are defined, each of which corresponds to one texture direction (except for the DC mode), and a current block predicted pixel is generated from a boundary reconstructed pixel value of a block adjacent to the current block in the prediction direction. For example, if the texture of the image is horizontally arranged, the image information can be better predicted by selecting the horizontal prediction mode. Inter-frame prediction refers to using the correlation of the video time domain, and because a video sequence usually contains strong time domain correlation, the purpose of effectively removing the video time domain redundancy can be achieved by using the pixels of the adjacent coded images to predict the pixels of the current image. The main principle of Motion compensation is to find a best matching block in a previously coded picture for each pixel block of a current picture, which is called Motion Estimation (ME).

Motion Vector (MV): in inter-coding, motion vectors are used to represent the relative displacement between the current coding block and the best matching block in its reference picture. Each divided block has a corresponding motion vector transmitted to a decoding side, and if the motion vector of each block is independently encoded and transmitted, particularly divided into small-sized blocks, a considerable amount of bits are consumed. In order to reduce the bit number for coding the motion vector, the spatial correlation between adjacent image blocks is utilized to predict the motion vector of the current block to be coded according to the motion vector of the adjacent coded block, and then the prediction difference is coded. Thus, the number of bits representing a motion vector can be effectively reduced. In the process of encoding the Motion Vector of the current block, the Motion Vector of the current block is predicted by using the Motion Vector of the adjacent encoded block, and then the Difference value (MVD) between the predicted value (MVP) of the Motion Vector and the real estimated value of the Motion Vector is encoded, so that the encoding bit number of the MV is effectively reduced.

Motion Information (Motion Information): since the motion vector indicates the position offset of the current image block from a certain reference image block, in order to accurately acquire information pointing to the image block, index information of the reference frame image is required in addition to the motion vector to indicate which reference frame image is used. In the video coding technology, for a current frame image, a reference frame image list may be generally established, and the reference frame image index information indicates that the current image block adopts the several reference frame images in the reference frame image list. In addition, many coding techniques also support multiple reference picture lists, and therefore, an index value, which may be referred to as a reference direction, may also be used to indicate which reference picture list is used. In the video encoding technology, motion-related information such as a motion vector, a reference frame index, and a reference direction may be collectively referred to as motion information.

Prediction pixel (Prediction Signal): the prediction pixel is a pixel value derived from a pixel which is coded and decoded, a residual is obtained through the difference between an original pixel and the prediction pixel, and then residual transformation quantization and coefficient coding are carried out. Specifically, the inter prediction pixel refers to a pixel value derived from a reference frame (reconstructed pixel frame) of the current block, and a final prediction pixel needs to be obtained through an interpolation operation due to the pixel position dispersion. The closer the predicted pixel is to the original pixel, the smaller the residual energy obtained by subtracting the predicted pixel and the original pixel is, and the higher the coding compression performance is.

Interpolation (Interpolation): if the current MV is not integer pixel precision, the existing pixel values cannot be directly copied from the corresponding reference frame, and the required pixel values can only be obtained through interpolation. As shown in FIG. 1A, if one wants to obtain a pixel value Y with an offset of 1/2 pixels1/2Then it needs to be obtained by interpolating the X values of the surrounding pixels. If an interpolation filter with the number of taps being N is used, it needs to be obtained by interpolation of N surrounding integer pixels.

And motion compensation: motion compensation is the process of obtaining all the pixel values of the current block by interpolation or copying.

The video coding framework comprises the following steps: referring to fig. 1B, a video encoding frame may be used to implement the processing flow at the encoding end in the embodiment of the present application, and in addition, the schematic diagram of the video decoding frame is similar to that in fig. 1B, which is not described herein again, and a video decoding frame may be used to implement the processing flow at the decoding end in the embodiment of the present application. Specifically, the video encoding framework and the video decoding framework include intra prediction, motion estimation/motion compensation, reference image buffer, in-loop filtering, reconstruction, transformation, quantization, inverse transformation, inverse quantization, entropy encoder and other modules. At the encoding end, the processing flow at the encoding end can be realized through the matching among the modules, and at the decoding end, the processing flow at the decoding end can be realized through the matching among the modules.

In the conventional method, when the current block is a bidirectional block, how to adjust the first original motion vector and the second original motion vector after obtaining the first original motion vector and the second original motion vector of the current block does not have a reasonable solution. In the embodiment of the application, when a current block is a bidirectional block, whether characteristic information of the current block meets a specific condition is judged, if yes, a first reference block corresponding to the current block is determined according to a first original motion vector, a second reference block is determined according to a second original motion vector of the current block, and the first original motion vector and the second original motion vector are adjusted 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 and a second target motion vector.

In this way, the first target motion vector and the second target motion vector are obtained by adjusting the first original motion vector and the second original motion vector, so that the current block can be encoded or decoded according to the first target motion vector and the second target motion vector, and the encoding performance and the encoding efficiency can be improved.

The encoding and decoding method of the present application will be described in detail below with reference to several specific embodiments.

Example 1: referring to fig. 2, a schematic flow chart of the encoding and decoding method provided in the embodiment of the present application is shown, where the method may be applied to a decoding end or an encoding end, and the method may include the following steps:

in step 201, if the feature information of the current block satisfies a specific condition, a first reference block corresponding to the current block is determined according to a first original motion vector of the current block, and a second reference block corresponding to the current block is determined according to a second original motion vector of the current block. The characteristic information includes, but is not limited to, one or more of the following: the motion information prediction mode corresponding to the current block; the motion information attribute corresponding to the current block; size information of the current block.

In an example, if the feature information is a motion information prediction mode corresponding to the current block, the feature information of the current block satisfies a specific condition, which may include but is not limited to: if the motion information prediction mode corresponding to the current block is a common fusion mode, determining that the motion information prediction mode corresponding to the current block meets a specific condition; or, if the motion information prediction mode corresponding to the current block is a fusion mode for generating a new prediction value by combining the inter prediction value and the intra prediction value, it may be determined that the motion information prediction mode corresponding to the current block satisfies a specific condition.

In one example, if the feature information is a motion information attribute corresponding to the current block, the feature information of the current block satisfies a specific condition, including but not limited to: if the motion information attribute corresponding to the current block is that the motion information of the current block comprises motion information in two different directions, determining that the motion information attribute corresponding to the current block meets a specific condition; or if the motion information attribute corresponding to the current block is that the motion information of the current block comprises motion information in two different directions, and the distances between two reference frames corresponding to the motion information in the two different directions and the current frame are the same, determining that the motion information attribute corresponding to the current block meets a specific condition; or if the motion information attribute corresponding to the current block is the motion information of the current block multiplexing surrounding blocks, determining that the motion information attribute corresponding to the current block meets a specific condition; or, if the motion information attribute corresponding to the current block is that the motion information of each sub-block of the current block is the same, determining that the motion information attribute corresponding to the current block meets the specific condition.

Exemplarily, the motion information of the current block includes motion information of two different directions, which means that: the motion information of the current block in two different directions respectively corresponds to a first reference frame and a second reference frame, the first reference frame is positioned in front of the current frame where the current block is positioned, and the second reference frame is positioned behind the current frame where the current block is positioned.

In one example, if the feature information is size information of the current block, and the size information of the current block may include a width value of the current block and a height value of the current block, the feature information of the current block satisfies a specific condition, which may include but is not limited to: if the width value of the current block is within the range of a first interval [ a first threshold value, a second threshold value ], it can be determined that the size information of the current block satisfies a specific condition; or, if the height value of the current block is within the range of the second interval [ the third threshold, the fourth threshold ], it may be determined that the size information of the current block satisfies the specific condition; or, if the area of the width value of the current block and the area of the height value of the current block are located within a third interval [ a fifth threshold, a sixth threshold ], it may be determined that the size information of the current block satisfies a specific condition; or, if the width value is located within a first interval [ first threshold, second threshold ], the height value is located within a second interval [ third threshold, fourth threshold ], and the area is located within a third interval [ fifth threshold, sixth threshold ], it may be determined that the size information of the current block satisfies a specific condition.

For example, the first threshold may be smaller than the second threshold, and neither of the first threshold and the second threshold is limited, for example, the first threshold may be 4, and the second threshold may be 128. The third threshold may be smaller than the fourth threshold, and neither the fourth threshold nor the fourth threshold is limited, for example, the third threshold may be 8, and the fourth threshold may be 128. The fifth threshold may be smaller than the sixth threshold, and neither the fifth threshold nor the sixth threshold is limited, for example, the fifth threshold may be 64, and the sixth threshold may be 128 × 128

In one example, determining a first reference block corresponding to the current block according to the first original motion vector of the current block and determining a second reference block corresponding to the current block according to the second original motion vector of the current block may include, but is not limited to: determining a first reference block corresponding to the current block from a first reference frame based on a first original motion vector of the current block; and determining a second reference block corresponding to the current block from the second reference frame based on the second original motion vector of the current block. The first pixel value of each pixel point in the first reference block is obtained by interpolating the pixel values of the adjacent pixel points in the first reference block, or is obtained by copying the pixel values of the adjacent pixel points in the first reference block; the second pixel value of each pixel point in the second reference block is obtained by interpolating the pixel values of the adjacent pixel points in the second reference block, or by copying the pixel values of the adjacent pixel points in the second reference block. The size of the first reference block is the same as the size of the second reference block, the width value of the first reference block is determined based on the width value of the current block and the search range, and the height value of the first reference block is determined based on the height value of the current block and the search range.

Step 202, according to a first pixel value of the first reference block and a second pixel value of the second reference block, the first original motion vector and the second original motion vector are adjusted 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.

In one example, if the current block includes at least one sub-block, for each sub-block of the current block, the first original motion vector and the second original motion vector may be adjusted according to the first pixel value and the second pixel value, so as to obtain a first target motion vector and a second target motion vector of the sub-block.

In one example, adjusting the first original motion vector and the second original motion vector according to the first pixel value and the second pixel value to obtain a first target motion vector and a second target motion vector of the sub-block may include: and determining a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-block and/or a first sub-pixel motion vector adjustment value and a second sub-pixel motion vector adjustment value of the sub-block according to the first pixel value and the second pixel value. Then, the first original motion vector may be adjusted according to the first integer-pixel motion vector adjustment value and/or the first sub-pixel motion vector adjustment value, so as to obtain a first target motion vector of the sub-block. And adjusting 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 of the sub-block.

In one example, determining the first and second integer pixel motion vector adjustment values of the sub-block, the first and second sub-pixel motion vector adjustment values of the sub-block according to the first and second pixel values may include: determining the first original motion vector or the second original motion vector as a central motion vector; determining an edge motion vector corresponding to the center motion vector; according to the first pixel value and the second pixel value, a first cost value corresponding to the central motion vector and a second cost value corresponding to the edge motion vector are obtained; then, according to the first generation value and the second generation value, selecting one motion vector from the central motion vector and the edge motion vector as an optimal motion vector, and judging whether an end condition is met; if not, determining the optimal motion vector as a central motion vector, and returning to execute the determination of the edge motion vector corresponding to the central motion vector; if yes, determining a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-blocks according to the optimal motion vector; and determining 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.

In one example, determining an edge motion vector corresponding to the center motion vector comprises: shifting the central motion vector (x, y) to different directions by S, and sequentially obtaining edge motion vectors (x, y + S), edge motion vectors (x, y-S), edge motion vectors (x + S, y), edge motion vectors (x-S, y) and edge motion vectors (x + right, y + down) in different directions; or, shifting the central motion vector (x, y) to different directions by S, and sequentially obtaining edge motion vectors (x, y-S), edge motion vectors (x, y + S), edge motion vectors (x-S, y), edge motion vectors (x + S, y), and edge motion vectors (x + right, y + down) in different directions. The default value of the edge motion vector (x + right, y + down) is (x-S, y-S); if the cost value of the edge motion vector (x + S, y) is smaller than the cost value of the edge motion vector (x-S, y), right is S; if the cost value of the edge motion vector (x, y + S) is smaller than that of the edge motion vector (x, y-S), then down is S; or, 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 (x-S, y), right is 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, y-S), then down is S.

In one example, obtaining the first cost value corresponding to the center motion vector and the second cost value corresponding to the edge motion vector according to the first pixel value and the second pixel value may include, but is not limited to: and acquiring a first cost value corresponding to the central motion vector and a second cost value corresponding to the edge motion vector according to the first pixel value without down-sampling and the second pixel value without down-sampling. Or, performing downsampling operation on the first pixel value and performing downsampling operation on the second pixel value; then, a first cost value corresponding to the center motion vector and a second cost value corresponding to the edge motion vector are obtained according to the first pixel value after down-sampling and the second pixel value after down-sampling. Or, shift and downsample the first pixel value, and shift and downsample the second pixel value; and then, acquiring a first generation value corresponding to the central motion vector and a second generation value corresponding to the edge motion vector according to the operated first pixel value and the operated second pixel value.

In one example, determining the first and second integer pixel motion vector adjustment values of the sub-block, the first and second sub-pixel motion vector adjustment values of the sub-block according to the first and second pixel values may include: selecting a part of or all motion vectors from surrounding motion vectors by taking the first original motion vector or the second original motion vector as a center, and taking the selected motion vector as a candidate motion vector; according to the first pixel value and the second pixel value, acquiring a third cost value corresponding to the first original motion vector or the second original motion vector and a fourth cost value corresponding to the candidate motion vector; according to the third cost value and the fourth cost value, selecting one motion vector from the first original motion vector or the second original motion vector and the candidate motion vector as an optimal motion vector; determining a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-blocks according to the optimal motion vector; and determining 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.

Determining the first integer pixel motion vector adjustment value and the second integer pixel motion vector adjustment value of the sub-block according to the optimal motion vector may include, but is not limited to: and determining a first integer pixel motion vector adjustment value of the sub-block according to the optimal motion vector and the first original motion vector, and determining a second integer pixel motion vector adjustment value of the sub-block according to the first integer pixel motion vector adjustment value.

Determining 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, comprising: and determining a first sub-pixel motion vector adjustment value of the sub-block according to the cost value corresponding to the optimal motion vector and the cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and determining a second sub-pixel motion vector adjustment value of the sub-block according to the first sub-pixel motion vector adjustment value.

Step 203, encoding or decoding the current block according to the first target motion vector and the second target motion vector. For example, for the encoding end, the encoding end may perform encoding processing on the current block according to the first target motion vector and the second target motion vector; for the decoding end, the decoding end may perform decoding processing on the current block according to the first target motion vector and the second target motion vector.

In one example, for each sub-block of the current block, determining a third reference block corresponding to the sub-block according to the first target motion vector of the sub-block, and determining a fourth reference block corresponding to the sub-block according to the second target motion vector of the sub-block; weighting according to a third pixel value of the third reference block and a fourth pixel value of the fourth reference block to obtain a predicted value of the sub-block; and determining the prediction value of the current block according to the prediction value of each sub-block.

In one example, determining a third reference block corresponding to the sub-block according to the first target motion vector of the sub-block, and determining a fourth reference block corresponding to the sub-block according to the second target motion vector of the sub-block may include:

in the first mode, a fifth 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, and a pixel value in the fifth reference block is interpolated to obtain a third reference block. And determining a sixth reference block corresponding to the sub-block from the second reference frame based on the second target motion vector of the sub-block, and interpolating a pixel value in the sixth reference block to obtain a fourth reference block.

Determining a seventh reference block corresponding to the sub-block from the first reference frame based on the first target motion vector of the sub-block, constructing an eighth reference block by using pixel values in the seventh reference block, and interpolating the pixel values in the eighth reference block to obtain a third reference block; and determining a ninth reference block corresponding to the sub-block from the second reference frame based on the second target motion vector of the sub-block, constructing a tenth reference block by using pixel values in the ninth reference block, and interpolating the pixel values in the tenth reference block to obtain a fourth reference block.

In one example, after encoding or decoding the current block according to the first target motion vector and the second target motion vector, the first target motion vector and the second target motion vector may be further stored for the current block. Thus, 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 a subsequent frame, and/or the first target motion vector and the second target motion vector are used for spatial reference of the current frame.

As can be seen from the foregoing technical solutions, in the embodiment of the present application, a first target motion vector and a second target motion vector of a current block may be determined according to a first original motion vector and a second original motion vector, and the current block may be encoded or decoded according to the first target motion vector and the second target motion vector, instead of being encoded or decoded directly according to the first original motion vector and the second original motion vector, so as to solve the problems of low prediction quality, prediction error, and the like, and improve encoding performance and encoding efficiency.

Example 2: referring to fig. 3, a schematic flow chart of a coding and decoding method proposed in the embodiment of the present application is shown, where the coding and decoding method can be applied to a coding end, and the coding and decoding method can include the following steps:

step 301, the encoding end determines whether the feature information of the current block satisfies a specific condition. If yes, step 302 is executed, and if no, the motion vector adjustment method proposed by the present application is not required to be adopted, and the processing method is not limited.

In one example, the encoding side may determine whether the feature information of the current block satisfies a certain condition based on the encoded information. If the feature information of the current block meets a specific condition, it indicates that the motion information of the current block is not accurate enough, and therefore, the motion vector adjustment mode is enabled (i.e., the present embodiment), and step 302 is performed.

If the characteristic information of the current block does not meet the specific condition, the motion information of the current block is accurate enough, so that a motion vector adjusting mode can be not started, and a motion vector adjusting mode provided by the application is not needed.

In one example, the characteristic information of the current block includes, but is not limited to, one or more of the following: the motion information prediction mode corresponding to the current block; the motion information attribute corresponding to the current block; size information of the current block.

For the way of determining whether the feature information of the current block satisfies the specific condition, refer to the following embodiments.

Step 302, determining a first reference block corresponding to the current block from a first reference frame based on a first original motion vector of the current block; and determining a second reference block corresponding to the current block from the second reference frame based on the second original motion vector of the current block. For the sake of convenience of distinction, the pixel value of each pixel point in the first reference block is referred to as a first pixel value, and the pixel value of each pixel point in the second reference block is referred to as a second pixel value.

In one example, if the current block is a block using bi-directional prediction, bi-directional motion information exists for the current block, and the bi-directional motion information includes two reference frames and two original motion vectors. For example, the encoding end may acquire the bidirectional motion information in a conventional manner, and the acquisition manner is not limited. The bi-directional motion information includes a first reference frame and a first original motion vector, a second reference frame and a second original motion vector.

Based on the first original motion vector, the encoding side may determine a first reference block corresponding to the current block from the first reference frame, and may refer to a pixel value of each pixel point in the first reference block as a first pixel value.

Based on the second original motion vector, the encoding end may determine a second reference block corresponding to the current block from the second reference frame, and may refer to a pixel value of each pixel point in the second reference block as a second pixel value.

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 1 st frame, the current frame is the 5 th frame, and the second reference frame is the 9 th frame. Of course, the above is only an example, and the distance between the two may be different.

The first original motion vector and the second original motion vector may have a mirror symmetry relationship, e.g., the first original motion vector is (4, 4), 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 the first original motion vector and the second original motion vector may not have a mirror symmetry relationship.

For the way of determining the first reference block and the second reference block, reference may be made to the subsequent embodiments.

Step 303, for each sub-block of the current block, 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 a first target motion vector of the sub-block; and the encoding end 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 a second target motion vector of the sub-block.

In one example, if the motion vector adjustment mode is enabled for the current block, the encoding end may perform fine adjustment on the first original motion vector and the second original motion vector by using a local search method based on the first pixel value and the second pixel value to obtain a better first target motion vector and a better second target motion vector, and then generate a prediction value with less distortion by using the first target motion vector and the second target motion vector.

In one example, the current block may include at least one sub-block, and if only one sub-block is included, the sub-block is the current block itself. And aiming at the sub-block, the sub-block corresponds to a first original motion vector and a second original motion vector, and after adjustment, the sub-block corresponds to a first target motion vector and a second target motion vector.

If the current block includes a sub-block a and a sub-block B, for the sub-block a, the sub-block a corresponds to the first original motion vector a1 and the second original motion vector a2, and after adjustment, the sub-block a corresponds to the first target motion vector A3 and the second target motion vector a 4. For the sub-block B, the sub-block B corresponds to the first original motion vector B1 and the second original motion vector B2, and after adjustment, the sub-block B corresponds to the first target motion vector B3 and the second target motion vector B4.

The first original motion vector a1 corresponding to the sub-block a and the first original motion vector B1 corresponding to the sub-block B may be the same and are both the first original motion vector of the current block; the second original motion vector a2 corresponding to the sub-block a and the second original motion vector B2 corresponding to the sub-block B may be the same and are both the second original motion vector of the current block.

Since the first original motion vector for each sub-block is adjusted separately, the first target motion vector a3 corresponding to the sub-block a may be the same as or different from the first target motion vector B3 corresponding to the sub-block B. Since the second original motion vector for each sub-block is adjusted separately, the second target motion vector a4 corresponding to the sub-block a may be the same as or different from the second target motion vector B4 corresponding to the sub-block B.

For the adjustment method of the original motion vector, refer to the following embodiments, which are not described herein again.

And step 304, the encoding end performs motion compensation on each sub-block of the current block according to the first target motion vector and the second target motion vector. For example, if the current block includes a sub-block a and a sub-block B, the sub-block a may be motion-compensated using the first target motion vector and the second target motion vector of the sub-block a, and the sub-block B may be motion-compensated using the first target motion vector and the second target motion vector of the sub-block B.

For the motion compensation method, reference may be made to the following embodiments, which are not described herein again.

Step 305, the encoding end stores the first target motion vector and the second target motion vector of each sub-block of the current block, and the first target motion vector and the second target motion vector are used for encoding reference of the subsequent block.

For the implementation of the coding reference, reference may be made to the following embodiments, which are not described herein again.

Example 3: referring to fig. 4, a schematic flow chart of an encoding and decoding method provided in the embodiment of the present application is shown, where the encoding and decoding method may be applied to a decoding end, and the encoding and decoding method may include the following steps:

in step 401, the decoding end determines whether the feature information of the current block satisfies a specific condition. If yes, step 402 is executed, otherwise, the motion vector adjustment method proposed by the present application is not required to be adopted, and the processing method is not limited.

In one example, the decoding end may receive the encoded bitstream transmitted by the encoding end and determine whether the characteristic information of the current block satisfies a specific condition based on the decoded information. If the feature information of the current block satisfies a specific condition, it indicates that the motion information of the current block is not accurate enough, and therefore, the motion vector adjustment mode is enabled, and step 402 is performed. If the characteristic information of the current block does not meet the specific condition, the motion information of the current block is accurate enough, so that a motion vector adjusting mode is not started, and a motion vector adjusting mode provided by the application is not needed.

Step 402, decoding a first original motion vector based on a current block, and determining a first reference block corresponding to the current block from a first reference frame; and determining a second reference block corresponding to the current block from the second reference frame based on the second original motion vector of the current block. For the sake of convenience of distinction, the pixel value of each pixel point in the first reference block is referred to as a first pixel value, and the pixel value of each pixel point in the second reference block is referred to as a second pixel value.

Step 403, for each sub-block of the current block, 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, so as to obtain a first target motion vector of the sub-block; and the decoding end 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 a second target motion vector of the sub-block.

Step 404, for each sub-block of the current block, the decoding end performs motion compensation on the sub-block according to the first target motion vector of the sub-block and the second target motion vector of the sub-block.

Step 405, the decoding end stores the first target motion vector and the second target motion vector of each sub-block of the current block, and the first target motion vector and the second target motion vector are used for decoding reference of the subsequent block.

Example 4: in steps 301 and 401, it is involved in determining whether the feature information of the current block satisfies a certain condition. In this embodiment, when the feature information satisfies all the following conditions, it is determined that the feature information of the current block satisfies a specific condition, and the motion vector adjustment mode is enabled. Otherwise, the motion vector adjustment mode is not enabled.

The motion information attribute corresponding to the current block includes: the current block directly multiplexes motion information of surrounding blocks without encoding a motion information difference. The motion information attribute corresponding to the current block includes: the motion information of each sub-block of the current block is the same, i.e., the sub-block motion information prediction mode is not employed. The motion information attribute corresponding to the current block includes: the motion information of the current block includes motion information of two different directions. The size information of the current block includes: the size of the current block is within a defined range, for which the size is within a defined range, as described in the following embodiments.

Example 5: in steps 301 and 401, it is involved in determining whether the feature information of the current block satisfies a certain condition. In this embodiment, when the feature information satisfies all the following conditions, it is determined that the feature information of the current block satisfies a specific condition, and the motion vector adjustment mode is enabled. Otherwise, the motion vector adjustment mode is not enabled.

The motion information prediction mode corresponding to the current block adopts a Normal Merge mode (namely a common fusion mode) or a CIIP mode (namely a fusion mode for generating a new prediction value by combining an interframe prediction value and an intraframe prediction value); alternatively, the motion information prediction mode corresponding to the current block does not adopt an MMVD mode (i.e., a fusion mode for encoding motion information difference values), an SB Merge mode (i.e., a fusion mode using sub-block motion information), or a TPM mode (i.e., a fusion mode for triangle prediction).

The motion information attribute corresponding to the current block includes: the motion information of the current block comprises motion information in two different directions, and the distances between two reference frames corresponding to the motion information in the two different directions and the current frame are the same. The size information of the current block includes: the size of the current block is within a defined range.

It should be noted that the fusion mode (i.e. Merge mode) includes, but is not limited to, the following types of fusion modes: a Normal fusion mode (referred to as Normal Merge mode); a fused mode for triangulation (referred to as TPM mode); a fusion mode (referred to as MMVD mode) for encoding motion information difference; a fusion mode (called SB Merge mode) using sub-block motion information; and a fusion mode (called CIIP mode) for generating a new predicted value by combining the inter predicted value and the intra predicted value.

In one example, the Normal Merge mode includes a Normal Merge mode (i.e., skip mode) in which no residual is encoded and a Normal Merge mode in which a residual is encoded. The MMVD patterns include MMVD patterns that do not encode a residual.

Example 6: in steps 301 and 401, it is involved in determining whether the feature information of the current block satisfies a certain condition. In this embodiment, when the feature information satisfies all the following conditions, it is determined that the feature information of the current block satisfies a specific condition, and the motion vector adjustment mode is enabled. Otherwise, the motion vector adjustment mode is not enabled.

The motion information prediction mode corresponding to the current block adopts a Normal Merge mode (namely a common fusion mode), a CIIP mode (namely a fusion mode for generating a new predicted value by combining an inter-frame predicted value and an intra-frame predicted value), or a TPM mode (namely a fusion mode for triangular prediction); alternatively, the motion information prediction mode corresponding to the current block does not adopt the MMVD mode (i.e., the fusion mode for encoding the motion information difference value) or the SB Merge mode (i.e., the fusion mode using the sub-block motion information).

The motion information attribute corresponding to the current block includes: the motion information of the current block comprises motion information in two different directions, and the distances between two reference frames corresponding to the motion information in the two different directions and the current frame are the same. The size information of the current block includes: the size of the current block is within a defined range.

Example 7: in steps 301 and 401, it is involved in determining whether the feature information of the current block satisfies a certain condition. In this embodiment, when the feature information satisfies all the following conditions, it is determined that the feature information of the current block satisfies a specific condition, and the motion vector adjustment mode is enabled. Otherwise, the motion vector adjustment mode is not enabled.

The motion information prediction mode corresponding to the current block adopts a Normal Merge mode (namely a common fusion mode), a CIIP mode (namely a fusion mode for generating a new predicted value by combining an inter-frame predicted value and an intra-frame predicted value), a TPM mode (namely a fusion mode for triangular prediction), or an MMVD mode (namely a fusion mode for coding a motion information difference value); or, the motion information prediction mode corresponding to the current block does not adopt the SB Merge mode (i.e., adopts the fusion mode of the sub-block motion information).

The motion information attribute corresponding to the current block includes: the motion information of the current block comprises motion information in two different directions, and the distances between two reference frames corresponding to the motion information in the two different directions and the current frame are the same. The size information of the current block includes: the size of the current block is within a defined range.

Example 8: in steps 301 and 401, it is involved in determining whether the feature information of the current block satisfies a certain condition. In this embodiment, when the feature information satisfies all the following conditions, it is determined that the feature information of the current block satisfies a specific condition, and the motion vector adjustment mode is enabled. Otherwise, the motion vector adjustment mode is not enabled.

The motion information prediction mode corresponding to the current block adopts a Normal Merge mode or a CIIP mode; the motion information prediction mode corresponding to the current block does not adopt an MMVD mode, an SB Merge mode or a TPM mode; or the motion information prediction mode corresponding to the current block adopts a Normal Merge mode, a CIIP mode or a TPM mode; the motion information prediction mode corresponding to the current block does not adopt an MMVD mode or an SB Merge mode; or the motion information prediction mode corresponding to the current block adopts a Normal Merge mode, a CIIP mode, a TPM mode or an MMVD mode; the motion information prediction mode corresponding to the current block does not adopt the SB large mode.

The motion information attribute corresponding to the current block includes: the motion information of the current block includes motion information in two different directions, and it is not necessary to restrict the distances between the two reference frames corresponding to the motion information in the two different directions and the current frame to be the same, i.e. remove this restriction. The size information of the current block includes: the size of the current block is within a defined range.

Example 9: regarding the "size of the current block is within the limited range" in the above-mentioned embodiments 4 to 8, if the size of the current block satisfies the following condition, it is determined that the size of the current block is within the limited range.

The width of the current block is within a range of [ first threshold, second threshold ], the first threshold may be 4, and the second threshold may be 128. The height of the current block is in the range of [ third threshold, fourth threshold ], the third threshold may be 8, and the fourth threshold may be 128. For example, the first threshold, the second threshold, the third threshold, and the fourth threshold may be an nth power of 2, where n is an integer greater than or equal to 1. The area of the current block is within the range of [ fifth threshold, sixth threshold ], the fifth threshold may be 64, and the sixth threshold may be 128 × 128 — 16384. For example, the fifth threshold and the sixth threshold may both be 4 to the power of m, where m is an integer greater than or equal to 1. In the above example, the expression [ a, b ] may represent a being equal to or greater than a and b being equal to or less than b.

Example 10: in steps 302 and 402, determining a first reference block corresponding to the current block from a first reference frame based on the first original motion vector, wherein a pixel value of each pixel point in the first reference block is referred to as a first pixel value; a second reference block corresponding to the current block is determined from the second reference frame based on the second original motion vector, and a pixel value of each pixel point in the second reference block is referred to as a second pixel value, which is described below.

The first pixel value of each pixel point in the first reference block is obtained by interpolating the pixel values of the adjacent pixel points in the first reference block, or is obtained by copying the pixel values of the adjacent pixel points in the first reference block; the second pixel value of each pixel point in the second reference block is obtained by interpolating the pixel values of the adjacent pixel points in the second reference block, or by copying the pixel values of the adjacent pixel points in the second reference block. The size of the first reference block is the same as the size of the second reference block, the width value of the first reference block/the second reference block is determined based on the width value of the current block and the search range, and the height value of the first reference block/the second reference block is determined based on the height value of the current block and the search range.

Referring to FIG. 5, assuming that the width of the current block is W and the height is H, the first original motion vector is denoted as MV0 and the second original motion vector is denoted as MV 1. And obtaining the whole pixel block with the area of (W + FS-1) × (H + FS-1) from the corresponding position of the first original motion vector MV0 in the first reference frame, and marking the whole pixel block as a whole pixel block A. And obtaining the whole pixel block with the area of (W + FS-1) × (H + FS-1) from the corresponding position of the second original motion vector MV1 in the second reference frame, and marking the whole pixel block as a whole pixel block B.

In one example, based on the whole pixel block a with an area of (W + FS-1) × (H + FS-1), an initial reference pixel block with a size of (W +2 × SR) × (H +2 × SR) may be obtained by means of bilinear interpolation, and this initial reference pixel block may be referred to as a first reference block. Based on the whole pixel block B with the area of (W + FS-1) × (H + FS-1), an initial reference pixel block with the size of (W +2 × SR) × (H +2 × SR) can be obtained by a bilinear interpolation, and this initial reference pixel block can be marked as a second reference block.

In another example, an initial reference pixel block with size of (W +2 SR) × (H +2 SR) is obtained by direct copy (without interpolation) based on the entire pixel block a with area of (W + FS-1) × (H + FS-1), and this initial reference pixel block is denoted as the first reference block. Based on the whole pixel block B with the area of (W + FS-1) × (H + FS-1), an initial reference pixel block with the size of (W +2 × SR) × (H +2 × SR) can be obtained by means of direct copying, and this initial reference pixel block is marked as a second reference block.

For example, the initial reference pixel blocks with size of (W +2 SR) × (H +2 SR), i.e., the first reference block (e.g., Pred _ Inter0) and the second reference block (e.g., Pred _ Inter1), may be obtained based on the whole pixel blocks (e.g., whole pixel block a and whole pixel block B) with area of (W + FS-1) × (H + FS-1) for only the luminance component (because the subsequent search process only calculates the cost value with the luminance component to reduce complexity).

In one example, FS may be the number of taps of the interpolation filter, such as 8.

Obtaining the first reference block/the second reference block by bilinear interpolation means: the pixel value of each pixel point in the first reference block/the second reference block is obtained by interpolating the pixel values of the adjacent pixel points in the first reference block/the second reference block, and the method is not limited to this. Obtaining the first reference block/the second reference block by copying means: the pixel value of each pixel point in the first reference block/the second reference block is obtained by copying the pixel values of the adjacent pixel points in the first reference block/the second reference block, which is not limited to this.

Referring to the above embodiment, the area of the first reference block is (W +2 × SR) × (H +2 × SR), the area of the second reference block is (W +2 × SR) × (H +2 × SR), that is, the width value of the first reference block/the second reference block is W +2 × SR, and the height value of the first reference block/the second reference block is H +2 × SR. W is the width of the current block, H is the height of the current block, SR is the search range, i.e. the number of iterations in the subsequent embodiments, SR, i.e. the maximum horizontal/vertical component interpolation of the target motion vector and the original motion vector, e.g. SR can be 2, etc.

And aiming at the first reference block and the second reference block, the motion vector is adjusted in the subsequent process.

Example 11: in steps 303 and 403, for each sub-block of the current block, adjusting 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 a first target motion vector of the sub-block; and adjusting 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 second target motion vector of the sub-block.

Taking the processing procedure of a sub-block (e.g. each dx × dy sized sub-block of the current block, e.g. a 16 × 16 sized sub-block, or a smaller whole block) as an example, the adjustment procedure of the original motion vector is introduced.

Step a1, determining the first original motion vector or the second original motion vector as the center motion vector.

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) may be determined as the center motion vector. For convenience of description, the procedure of determining the first original motion vector (4, 4) as the center motion vector and the second original motion vector (-4, -4) as the center motion vector is similar.

Step a2, an edge motion vector corresponding to the center motion vector is determined.

For example, the center motion vector (x, y) may be shifted by S in different directions to obtain an edge motion vector (x, y + S), an edge motion vector (x, y-S), an edge motion vector (x + S, y), an edge motion vector (x-S, y), and an edge motion vector (x + right, y + down) in different directions. Right can be S or-S, down can be S or-S, right and down are determined, see the following examples.

Referring to fig. 6, taking the central motion vector (x, y) as the center, that is, the central motion vector is (0,0), S is 1, and both right and down are 1 as examples, the edge motion vector corresponding to the central motion vector (0,0) includes: edge motion vector (0,1), edge motion vector (0, -1), edge motion vector (1,0), edge motion vector (-1,0), edge motion vector (1, 1).

Step a3, obtaining a first cost value corresponding to the central motion vector and a second cost 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.

For example, the sub-reference block a1 corresponding to the central motion vector (0,0) is copied from the first reference block, and the sub-reference block a1 is a sub-reference block in which the central motion vector (0,0) is in the first reference block. The size of the sub-reference block a1 is the size of the current block, and the sub-reference block a1 is the most central W × H block in the first reference block.

The sub-reference block B1 corresponding to the central motion vector (0,0) is copied from the second reference block, and the sub-reference block B1 is a sub-reference block of the central motion vector (0,0) in the second reference block. The size of the sub-reference block B1 is the size of the current block, and the sub-reference block B1 is the most central W × H block in the second reference block.

Then, using the first pixel value of the sub-reference block a1 and the second pixel value of the sub-reference block B1, the cost value 1 corresponding to the central motion vector (0,0) is obtained, and the determination manner of the cost value is as follows in the following embodiments.

A sub-reference block a2 corresponding to the edge motion vector (0,1) is copied from the first reference block, and the sub-reference block a2 is a sub-reference block of the edge motion vector (0,1) in the first reference block. The size of the sub-reference block a2 is the size of the current block, and the sub-reference block a2 is a block of W × H in the first reference block.

The sub-reference block B2 corresponding to the symmetric motion vector (0, -1) that obtains the edge motion vector (0,1) is copied from the second reference block, and the sub-reference block B2 is a sub-reference block of the symmetric motion vector (0, -1) in the second reference block. The sub-reference block B2 has a size equal to the size of the current block and is a block of W × H in the second reference block.

Then, 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 2 corresponding to the edge motion vector (0,1), and the cost value is determined in the following embodiments.

Based on the determination manner of 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.

And a step a4 of selecting one motion vector from the central motion vector and the edge motion vector as an optimal motion vector according to the first cost value and the second cost value. For example, the motion vector having the smallest cost value may be used as the optimal motion vector. 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 may be used as the optimal motion vector.

And a step a5, judging whether the ending condition is met. If not, the optimal motion vector may be determined as the center motion vector and returned to step a 2. If so, step a6 may be performed.

In one example, if the number of iterations/search range reaches a threshold, then an end condition is met; if the iteration times/search range does not reach the threshold value, the end condition is not met. For example, assume that SR is 2, i.e., the threshold is 2, i.e., two iterations are allowed. If the iteration number/search range has reached 2 times, i.e. step a 2-step a4 have been performed twice, the end condition is met; otherwise, the end condition is not satisfied.

In another example, after selecting one 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 termination condition is satisfied.

Step a6, determining a first integer pixel motion vector adjustment value (for adjusting the first original motion vector) and a second integer pixel motion vector adjustment value (for adjusting the second original motion vector) based on the optimal motion vector.

In one example, a first integer motion vector adjustment value may be determined based on the optimal motion vector and the first original motion vector, and a second integer motion vector adjustment value may be determined based on the first integer motion vector adjustment value, the second integer motion vector adjustment value being symmetric to the first integer motion vector adjustment value.

For example, in the first iteration process, the optimal motion vector is the edge motion vector (0,1), the second iteration is performed with the edge motion vector (0,1) as the center, and in the second iteration process, the optimal motion vector is the edge motion vector (0,1), and assuming that the iteration process is completed up to this point, the adjustment value of the first integer pixel motion vector is (0,2), that 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), the first iteration process, the optimal motion vector is the edge motion vector (0,1), i.e. the optimal motion vector may correspond to the optimal motion vector (4, 5). And performing second iteration by taking the edge motion vector (0,1) as a center, wherein the optimal motion vector is the edge motion vector (0,1) in the second iteration process, namely the optimal motion vector can correspond to the optimal motion vector (4, 6).

In summary, a first integer pixel motion vector adjustment value is determined based on the optimal motion vector (4, 6) and the first original motion vector (4, 4), and the first integer pixel motion vector adjustment value is the difference between the optimal motion vector (4, 6) and the first original motion vector (4, 4), i.e. the first integer pixel motion vector adjustment value is (0, 2).

Then, a second integer motion vector adjustment value is determined based on the first integer motion vector adjustment value (0,2), which may be (0, -2), i.e. a symmetric value of (0, 2).

Step a7, determining a first sub-pixel motion vector adjustment value (for adjusting the first original motion vector) and a second sub-pixel motion vector adjustment value (for adjusting the second original motion vector) based on the optimal motion vector.

In one example, a first sub-pixel motion vector adjustment value may be determined according to a cost value corresponding to the optimal motion vector and a cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and then a second sub-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)),y0N (E (0, -1) -E (0,1))/(E (0, -1) + E (0,1) -2E (0,0)), and N is 1,2, 4, and 8 for motion vector pixel accuracies of 1/2, 1/4, 1/8, and 1/16. Then, (x0, y0) is assigned to deltaMv, SPMV is deltaMv/2N, and if the current motion vector pixel precision is 1/16, SPMV is (x)0/16,y0/16)。

In the above equation, the SPMV is the first sub-pel motion vector adjustment value, and N is related to the motion vector pixel precision, e.g., 1/2 for motion vector pixel precision, 1 for N, 1/4 for motion vector pixel precision, 2 for N, 1/8 for motion vector pixel precision, 4 for N, 1/16 for N, 8 for N.

In the above formula, E (0,0) represents a cost value of the optimal motion vector; e (-1,0) is the cost value of the edge motion vector (-1,0) of the optimal motion vector (0,0) centered on the optimal motion vector; e (1,0) is the cost value of the edge motion vector (1,0) of the optimal motion vector (0,0) centered on the optimal motion vector; e (0, -1) is a cost value of an edge motion vector (0, -1) of the optimal motion vector (0,0) centered on the optimal motion vector; e (0,1) is a cost value of the edge motion vector (0,1) of the optimal motion vector (0,0) centered on the optimal motion vector. For the cost value of each motion vector, the determination method thereof may refer to the above embodiment, and is not described herein again.

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, where 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 is (-1,0), i.e., a symmetric value of (1, 0).

Step a8, adjusting 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 is equal to the first original motion vector + the first integer-pel motion vector adjustment value + the first sub-pel motion vector adjustment value. Of course, the above is merely an example, and no limitation is made thereto.

Step a9, adjusting 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 is the second original motion vector + the second integer pixel motion vector adjustment value + the second sub-pixel motion vector adjustment value. Of course, the above is merely an example, and no limitation is made thereto.

Example 12: in steps 303 and 403, for each sub-block of the current block, adjusting 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 a first target motion vector of the sub-block; and adjusting 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 second target motion vector of the sub-block.

Taking the processing procedure of a sub-block (e.g. each dx × dy sized sub-block of the current block, such as a 16 × 16 sized sub-block or smaller whole block) as an example, the adjustment procedure of the original motion vector is introduced. The first original motion vector is recorded as Org _ MV0, the second original motion vector is recorded as Org _ MV1, the first original motion vector Org _ MV0 is adjusted to obtain a first target motion vector which is recorded as referred _ MV0, and the second original motion vector Org _ MV1 is adjusted to obtain a second target motion vector which is recorded as referred _ MV 1.

Step b1, perform SR iterations to obtain the optimal integer pixel offset of the integer pixel MV point, which is denoted as integer delta MV, which is the first integer pixel motion vector adjustment value in the above embodiments. For example, IntegerDeltaMV is initialized to (0,0), and the following process is performed for each iteration:

step b11, deltaMV is set to (0, 0). If the first iteration is performed, copying to obtain a predictive value block A1 (namely the block of W x H at the center of the first reference block) based on the reference pixels of the first original motion vector in the first reference block; the block of prediction values B1 (i.e. the centremost W × H block of the second reference block) is obtained by copying based on the reference pixels of the second original motion vector in the second reference block. An initial cost value cost is obtained based on the prediction value block a1 and the prediction value block B1 (the initial cost value is SAD (sum of absolute differences) based on the prediction value block a1 and the prediction value block B1), and the determination is made in a manner as described in the following embodiments). If the initial cost value cost is less than 4 × dx dy/2, and dx and dy are the width and height of the current subblock, the subsequent search process is directly skipped, step b2 is executed, and notZeroCost is set to false.

Step b12, as shown in fig. 6, obtains five offset MVs (these five offset MVs are all referred to as MVOffset) in the order of { Mv (0,1), Mv (0, -1), Mv (1,0), Mv (-1,0), Mv (right, down) }, with the above-mentioned initial point as the center, and performs the calculation and comparison process of the cost values of these five offset MVs.

For example, based on a certain MVOffset (e.g., Mv (0,1), etc.), two blocks of prediction values (e.g., a W × H block in the first reference block for center position shift MVOffset and a W × H block in the second reference block for center position shift-MVOffset (opposite to MVOffset)) are obtained from this MVOffset in the first reference block and the second reference block, and downsampling of the two blocks of prediction values is calculated as a cost value of MVOffset.

Then, the MVOffset with the minimum cost value is reserved, the MVOffset with the minimum cost value is updated to the value of deltaMV, and the MVOffset with the minimum cost value is used as a new center offset point of the next iteration.

Updating the value of IntegerDeltaMV based on deltaMV, wherein the updated IntegerDeltaMV is the IntegerDeltaMV + deltaMV before updating, namely adding deltaMV on the basis of the current IntegerDeltaMV.

After iteration in step b13, if the optimal MV is still the initial MV (i.e. not the MVOffset) or the minimum cost value is 0, the next iterative search process is not performed, step b2 is executed, and notZeroCost is set to false. Otherwise, if the iteration number reaches SR, executing step b2, and if the iteration number does not reach SR, taking the optimal MV as the center to perform the next iterative search process, i.e., returning to step b 11.

After the iterative search process is finished, obtaining the value of IntegerDeltaMV, namely the final value of IntegerDeltaMV, namely the first integer pixel motion vector adjustment value, and then marking as IntegerDeltaMV.

Step b2, taking the optimal integer pixel MV point of step b1 as the center, obtains the optimal sub-pixel offset MV, which is denoted as SPMV, and the SPMV is the first sub-pixel motion vector adjustment value in the above embodiment. For example, the SPMV may be initialized to (0,0) first, and then the following process is performed:

and b21, performing subsequent processing (namely acquiring the SPMV) only when notZeroCost is not false and deltaMV is (0,0), otherwise, directly adjusting the original motion vector by using IntegerDeltaMV instead of adjusting the original motion vector by using IntegerDeltaMV and SPMV.

And b22, representing E (x, y) as the MV corresponding cost value of the optimal MV point offset (x, y) obtained in the step b1 (the cost value calculated in the step b 1). Based on the center and the E (x, y) of the five upper, lower, left, and right points, the deviation (x0, y0) of the point at which the E (x, y) is the smallest can be found as: x is the number of0=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, then N is 1,2, 4, and 8. Then, (x0, y0) may be assigned to deltaMv, SPMV/2N, and if the current motion vector pixel precision is 1/16, then SPMV may be (x0, y0)0/16,y0/16)。

If E (-1,0) ═ E (0,0), then the horizontal is shifted to the left by half a pixel (deltaMv [0] ═ N).

If E (1,0) is equal to E (0,0), the horizontal is shifted to the right by half a pixel (deltaMv [0] ═ N).

If E (0, -1) ═ E (0,0), then half a pixel is shifted vertically upward (deltaMv [1] ═ N).

If E (0,1) is equal to E (0,0), then a half pixel is shifted vertically downward (deltaMv [1] ═ N).

Based on the above processing, the value of the SPMV, i.e. the first sub-pixel motion vector adjustment value, can be obtained.

Step b3, obtaining an optimal offset MV based on the integer pixel offset integrarteltamv of step b1 and the sub-pixel offset SPMV of step b2, and marking the optimal offset MV as bestmvaffset. Moreover, bestmvamfset is IntegerDeltaMV + SPMV.

Based on bestmveffset, target motion vectors in two directions can be obtained: referred _ MV0 Org _ MV0+ bestmvffset; referred _ MV1 Org _ MV 1-bestmvffset.

Obviously, bestmvamfset is the integral deltamv + SPMV, i.e., the sum of the first integer-pel motion vector adjustment value and the first sub-pel motion vector adjustment value. Furthermore, -integrarteltaMV is the symmetric value of integrarteltaMV, i.e. the second integer motion vector adjustment value, -SPMV is the symmetric value of SPMV, i.e. the second sub-pixel motion vector adjustment value, so that-BestMVoffset ═ integrarteltaMV) + (-SPMV), i.e. the sum of the second integer motion vector adjustment value and the second sub-pixel motion vector adjustment value.

Example 13: with respect to steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to that of embodiment 12, except that:

in step b11, "if the initial cost value cost is less than 4 × dx dy/2, then directly skip the subsequent search process" is removed, that is, even if the initial cost value cost is less than 4 × dx dy/2, the subsequent search process is not "directly skipped" but is continued, that is, step b12 needs to be performed.

Example 14: with respect to steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to that of embodiment 12, except that:

in step b11, "if the initial cost value cost is less than 4 × dx dy/2, then directly skip the subsequent search process" is removed, that is, even if the initial cost value cost is less than 4 × dx dy/2, the subsequent search process is not "directly skipped" but is continued, that is, step b12 needs to be performed.

The "if the optimal MV is still the initial MV (i.e. not the MVOffset) or the minimum cost value is 0, then the next iterative search process is not performed" in step b13 is removed, that is, the next iterative search process can be performed even if the optimal MV is still the initial MV or the minimum cost value is 0.

Example 15: with respect to steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to that of embodiment 12, except that:

the correlation process of "notZeroCost" is removed, that is, the value of notZeroCost is not set and saved in step b11 and step b 13. In step b21, the fractional-pixel offset calculation process (i.e., step b22) may be performed as long as deltaMV is (0,0), instead of only when notZeroCost is not false and deltaMV is (0, 0).

Example 16: with respect to steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to that of embodiment 12, except that:

and c, performing subsequent processing only when the notZeroCost is not false and the deltaMV is (0,0) in the step b21, otherwise, directly adjusting the original motion vector by using the IntegerDeltaMV, modifying to be that only the notZeroCost is not false and cost values of four points which are 1 integer pixel apart from the top, the bottom, the left and the right of the current optimal integer pixel are obtained by calculation in the step b1, and otherwise, directly adjusting the original motion vector by using the IntegerDeltaMV.

In one example, "post-processing" refers to the fractional-pixel offset calculation process of step b 22.

In one example, the fractional-pixel shift calculation process of step b22 needs to use cost values of four points spaced by 1 integer pixel up, down, left and right of the optimal integer pixel, so that it is a necessary condition that "cost values of four points spaced by 1 integer pixel up, down, left and right of the optimal integer pixel" are obtained by calculation in step b 1.

Example 17: with respect to steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to that of embodiment 12, except that:

the "subsequent processing is performed only if notZeroCost is not false and deltaMV is (0, 0)" in step b21, otherwise, the original motion vector is adjusted directly by using integrarteltaMV ", and the" subsequent processing (i.e. the sub-pixel offset calculation process) is performed only if the cost values of four points, which are spaced by 1 whole pixel from the top, bottom, left and right of the current optimal whole pixel, are obtained by calculation in step b1, otherwise, the original motion vector is adjusted directly by using integrarteltaMV ".

Example 18: with respect to steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to that of embodiment 12, except that:

performing subsequent processing only when notZeroCost is not false and deltaMV is (0,0) in the step b21, otherwise, directly adjusting the original motion vector by using IntegerDeltaMV, and modifying to perform subsequent processing only when cost values of four points which are separated by 1 whole pixel from the top, bottom, left and right of the current optimal whole pixel are obtained by calculation in the step b1 (the pixel division offset calculation process in the step b22), otherwise, performing processing by using the step b 23.

Step b23, setting the current optimal whole pixel MV _ inter _ org as the nearest whole pixel, and calculating the cost values of four points which are spaced by 1 whole pixel up, down, left and right around the current optimal whole pixel MV _ inter _ org in step b1 to obtain the whole pixel MV _ inter _ nearest. Then, the sub-pixel offset calculation process of step b22 is performed centering on MV _ inter _ nearest, that is, obtaining the SPMV centering on MV _ inter _ nearest.

For example, if the cost values of the four points, which are separated by 1 whole pixel, above, below, left, and right, of the current optimal whole pixel point MV _ inter _ org are not all obtained through calculation in step b1, one whole pixel point MV _ inter _ nearest is selected from the periphery of the optimal whole pixel point MV _ inter _ org, and the cost values of the four points, which are separated by 1 whole pixel, above, below, left, and right, of the whole pixel point MV _ inter _ nearest are all obtained through calculation in step b 1.

Then, the whole pixel point MV _ inter _ nearest is used as the current optimal whole pixel point, and the whole pixel point MV _ inter _ nearest is used as the center to obtain the SPMV, and the specific obtaining mode refers to step b 22.

When obtaining the SPMV with the whole pixel MV _ inter _ nearest as the center, see step b22, countingCalculate x0And y0When x0And y0Can be limited to [ -2N, 2N]Within the range of (1). If x0/y0Greater than 2N, x may be0/y0The value is assigned to 2N; if x0/y0Less than-2N, then x may be0/y0The value is assigned-2N. For motion vector pixel accuracy of 1/2, 1/4, 1/8, and 1/16, then N is 1,2, 4, and 8.

Example 19: in the above embodiment, it is necessary to determine an edge motion vector corresponding to the center motion vector, such as 5 edge motion vectors. For example, the center motion vector (x, y) may be shifted by S in different directions, and the edge motion vector (x, y + S), the edge motion vector (x, y-S), the edge motion vector (x + S, y), the edge motion vector (x-S, y), and the edge motion vector (x + right, y + down) in different directions may be obtained sequentially. Alternatively, the central motion vector (x, y) may be shifted by S in different directions, and the edge motion vector (x, y-S), the edge motion vector (x, y + S), the edge motion vector (x-S, y), the edge motion vector (x + S, y), and the edge motion vector (x + right, y + down) in different directions may be obtained sequentially.

For example, assuming that (x, y) is (0,0) and S is 1, 5 edge motion vectors can be obtained in the order of (0,1), (0, -1), (1,0), (-1,0), and (right, down). Alternatively, 5 edge motion vectors can be obtained in the order of (0, -1), (0,1), (-1,0), (right, down).

Example 20: in the above embodiment, the default value of the edge motion vector (x + right, y + down) is (x-S, y-S). If the cost value of the edge motion vector (x + S, y) is smaller than the cost value of the edge motion vector (x-S, y), right is S (modified from-S to S); if the cost value of the edge motion vector (x, y + S) is smaller than that of the edge motion vector (x, y-S), then down is S (modified from-S to S). Or 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 (x-S, 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, y-S), then down is S (modified from-S to S).

For example, 5 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 the edge motion vector (1,0) is smaller than the cost value of the edge motion vector (-1,0), right is 1; if the cost value of the edge motion vector (0,1) is less than the cost value of the edge motion vector (0, -1), then down is 1. Alternatively, if the cost value of the edge motion vector (1,0) is less than or equal to the cost value of the edge motion vector (-1,0), then right is 1; if the cost value of the edge motion vector (0,1) is less than or equal to the cost value of the edge motion vector (0, -1), then down is 1.

For example, 5 edge motion vectors are obtained in the order of (0, -1), (0,1), (-1,0), (right, down), and the default value of (right, down) is (-1, -1). If the cost value of the edge motion vector (1,0) is smaller than the cost value of the edge motion vector (-1,0), right is 1; if the cost value of the edge motion vector (0,1) is less than the cost value of the edge motion vector (0, -1), then down is 1. Alternatively, if the cost value of the edge motion vector (1,0) is less than or equal to the cost value of the edge motion vector (-1,0), then right is 1; if the cost value of the edge motion vector (0,1) is less than or equal to the cost value of the edge motion vector (0, -1), then down is 1.

Example 21: in steps 303 and 403, for each sub-block of the current block, adjusting 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 a first target motion vector of the sub-block; and adjusting 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 second target motion vector of the sub-block.

Taking the processing procedure of a sub-block (e.g. each dx × dy sized sub-block of the current block, e.g. a 16 × 16 sized sub-block, or a smaller whole block) as an example, the adjustment procedure of the original motion vector is introduced.

Step c1 selects a part or all of the motion vectors from the surrounding motion vectors with the first original motion vector or the second original motion vector as the center, and uses the selected motion vector as a candidate motion vector.

For example, a part or all of the motion vectors may be selected from the surrounding motion vectors as candidate motion vectors, centered on the first original motion vector, for which selection is referred to in the subsequent embodiments.

For convenience of description, in the following embodiments, the first original motion vector is taken as a center.

And c2, obtaining a third cost value corresponding to the first original motion vector and a fourth cost value corresponding to each candidate motion vector by the first pixel value of the first reference block and the second pixel value of the second reference block.

For example, a sub-reference block a1 corresponding to the first original motion vector is copied from the first reference block, the sub-reference block a1 is a sub-reference block of the first original motion vector in the first reference block, and the size of the sub-reference block a1 is the size of the current block. And copying a sub-reference block B1 corresponding to the second original motion vector from the second reference block, wherein the sub-reference block B1 is a sub-reference block of the second original motion vector in the second reference block, and the size of the sub-reference block B1 is the size of the current block. Then, a third generation value corresponding to the first original motion vector is obtained 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, copying a sub-reference block A2 corresponding to the obtained candidate motion vector from the first reference block, wherein the sub-reference block A2 is a sub-reference block of the candidate motion vector in the first reference block, and the size of the sub-reference block A2 is the size of the current block. And copying a sub-reference block B2 corresponding to the symmetric motion vector for obtaining the candidate motion vector from the second reference block, wherein the sub-reference block B2 is a sub-reference block of the symmetric motion vector in the second reference block, and the size of the sub-reference block B2 is the size of the current block. And acquiring a fourth cost value corresponding to the candidate motion vector by using the first pixel value of the sub-reference block A2 and the second pixel value of the sub-reference block B2.

And c3, selecting one motion vector from the first original motion vector and the candidate motion vector as the optimal motion vector according to the third cost value and the fourth cost value. For example, the motion vector with the smallest cost value (such as the first original motion vector or any one of the candidate motion vectors) is used as the optimal motion vector.

Step c4, determining a first integer pixel motion vector adjustment value (for adjusting the first original motion vector) and a second integer pixel motion vector adjustment value (for adjusting the second original motion vector) based on the optimal motion vector. In one example, a first integer motion vector adjustment value may be determined based on the optimal motion vector and the first original motion vector, and a second integer motion vector adjustment value may be determined based on the first integer motion vector adjustment value, the second integer motion vector adjustment value being symmetric to the first integer motion vector adjustment value.

For example, assuming that the optimal motion vector is (4, 6) and the first original motion vector is (4, 4), a first integer motion vector adjustment value is determined from the optimal motion vector (4, 6) and the first original motion vector (4, 4), the first integer motion vector adjustment value being the difference between the optimal motion vector (4, 6) and the first original motion vector (4, 4), i.e. the first integer motion vector adjustment value is (0, 2).

Then, a second integer motion vector adjustment value is determined based on the first integer motion vector adjustment value (0,2), which may be (0, -2), i.e. a symmetric value of (0, 2).

Step c5, determining a first sub-pixel motion vector adjustment value (for adjusting the first original motion vector) and a second sub-pixel motion vector adjustment value (for adjusting the second original motion vector) based on the optimal motion vector.

In one example, a first sub-pixel motion vector adjustment value may be determined according to a cost value corresponding to the optimal motion vector and a cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and then a second sub-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)),y0N (E (0, -1) -E (0,1))/(E (0, -1) + E (0,1) -2E (0,0)), and N is 1,2, 4, and 8 for motion vector pixel accuracies of 1/2, 1/4, 1/8, and 1/16. Then, (x0, y0) is assigned to deltaMv, SPMV/2N,if the current motion vector pixel precision is 1/16, then SPMV is (x)0/16,y0/16)。

The SPMV is the first sub-pixel motion vector adjustment value. E (0,0) represents a cost value of the optimal motion vector; e (-1,0) is the cost value of the edge motion vector (-1,0) of the optimal motion vector (0,0) centered on the optimal motion vector; e (1,0) is the cost value of the edge motion vector (1,0) of the optimal motion vector (0,0) centered on the optimal motion vector; e (0, -1) is a cost value of an edge motion vector (0, -1) of the optimal motion vector (0,0) centered on the optimal motion vector; e (0,1) is a cost value of the edge motion vector (0,1) of the optimal motion vector (0,0) centered on the optimal motion vector. For the cost value of each motion vector, see the above embodiment.

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, where 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 is (-1,0), i.e., a symmetric value of (1, 0).

And c6, adjusting 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 is equal to the first original motion vector + the first integer-pel motion vector adjustment value + the first sub-pel motion vector adjustment value. Of course, the above is merely an example, and no limitation is made thereto.

And c7, adjusting 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 is the second original motion vector + the second integer pixel motion vector adjustment value + the second sub-pixel motion vector adjustment value. Of course, the above is merely an example, and no limitation is made thereto.

Example 22: in steps 303 and 403, for each sub-block of the current block, adjusting 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 a first target motion vector of the sub-block; and adjusting 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 second target motion vector of the sub-block.

Taking the processing procedure of a sub-block (e.g. each dx × dy sized sub-block of the current block, such as a 16 × 16 sized sub-block or smaller whole block) as an example, the adjustment procedure of the original motion vector is introduced. The first original motion vector may be denoted Org _ MV0, the second original motion vector may be denoted Org _ MV1, the first target motion vector may be denoted referred to as referred _ MV0, and the second target motion vector may be denoted referred to as referred _ MV 1.

Step d1, selecting some or all of the motion vectors from (2 × SR +1) × (2 × SR +1) points around the first original motion vector, centered on the first original motion vector. For example, when SR is 2, a part or all of the motion vectors are selected from 25 points around the first original motion vector, and the selected motion vectors are used as candidate motion vectors. Then, a cost value for the first original motion vector is determined, and a cost value for each candidate motion vector is determined. Then, the motion vector with the minimum cost value is used as the optimal motion vector.

Compared with the step b1 of the above embodiment, in the step d1, all the candidate motion vectors to be processed can be selected at one time without performing an iterative process, instead of selecting a partial motion vector in the first iteration and selecting a partial motion vector in the second iteration through an iterative process. Based on this, all the candidate motion vectors to be processed are selected at one time, so that the 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.

And d2, determining the value of IntegerDeltaMV according to the optimal motion vector, wherein the final value of IntegerDeltaMV is the first integer pixel motion vector adjustment value, and the determination method is not repeated.

And d3, taking the optimal motion vector as the center, obtaining the optimal sub-pixel offset MV, and marking the optimal sub-pixel offset MV as SPMV, wherein the value of the SPMV is the first sub-pixel motion vector adjustment value.

The implementation process of step d3 can be referred to as step b2, and will not be repeated here.

And d4, obtaining BestMVoffset based on IntegerDeltaMV and SPMV. For example, bestmvamfset ═ IntegerDeltaMV + SPMV.

Obtaining a target motion vector based on BestMVoffset: referred _ MV0 Org _ MV0+ bestmvffset; referred _ MV1 Org _ MV 1-bestmvffset.

Example 23: for steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to embodiments 21 and 22.

In this embodiment, all the motion vectors are selected from a total of (2 × SR +1) × (2 × SR +1) points around the original motion vector, with the original motion vector as the center. For example, if SR is 2, all motion vectors are selected from 25 points around the original motion vector, the cost values of these motion vectors are determined, and the cost value of each motion vector is determined. Then, the motion vector with the minimum cost value is used as the optimal motion vector.

Example 24: for steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to embodiments 21 and 22. In this embodiment, all the candidate motion vectors to be processed are selected at one time, so that the candidate motion vectors can be processed in parallel to obtain a cost value of each candidate motion vector, thereby reducing the computational complexity and improving the coding performance.

In this embodiment, a partial motion vector having a deviation not exceeding the SR range is selected from a total of (2 × SR +1) × (2 × SR +1) points around the original motion vector, centering on the original motion vector. For example, from (2 × SR +1) × (2 × SR +1) points including the original motion vector, N (N is equal to or greater than 1, and equal to or less than (2 × SR +1) × (2 × SR +1)) candidate points are selected. And determining the cost value of the motion vector corresponding to the N points. The cost values of the N points are scanned in a certain sequence, and the motion vector with the minimum cost value is selected as the optimal motion vector. If the cost values are equal, the candidate points in the front order are preferentially selected.

In one example, assuming that SR is 2, the number of candidate points may be 25, and the order of the candidate points may be from left to right and from top to bottom. Referring to fig. 7A, the order of these candidate points may be: { Mv (-2, -2), Mv (-1, -2), Mv (0, -2), Mv (1, -2), Mv (2, -2), Mv (-2, -1), Mv (-1, -1), Mv (0, -1), Mv (1, -1), Mv (2, -1), Mv (-2,0), Mv (-1,0), Mv (0,0), Mv (1,0), Mv (2,0), Mv (-2,1), Mv (-1,1), Mv (0,1), Mv (1,1), Mv (2,1), Mv (-2,2), Mv (-1,2), Mv (0,2), Mv (1,2), Mv (2,2) }.

The cost values corresponding to the motion vectors of the 25 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

In another example, assuming that SR is 2, the number of candidate points may be 21, and the order of these candidate points may be from left to right and from top to bottom. Referring to fig. 7B, 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) }. The cost values corresponding to the motion vectors of the 21 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

In another example, assuming that SR is 2, the number of candidate points may be 25, and the order of these candidate points is in the order from near to far from the center with motion vector (0,0) as the center. Referring to fig. 7C, the order of these candidate points may be: { Mv (0,0), Mv (-1,0), Mv (0, -1), Mv (1,0), Mv (0,1), Mv (-1,1), Mv (-1, -1), Mv (1, -1), Mv (1,1), Mv (0,2), Mv (-2,0), Mv (0, -2), Mv (2,0), Mv (1,2), Mv (-1,2), Mv (-2,1), Mv (-2, -1), Mv (-1, -2), Mv (1, -2), Mv (2, -1), Mv (2,1), Mv (-2,2), Mv (-2, -2), Mv (2, -2), Mv (2, 2). The cost values corresponding to the motion vectors of the 25 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

In another example, assuming that SR is 2, the number of candidate points may be 21, and the order of these candidate points is in the order from near to far from the center with the motion vector (0,0) as the center. Referring to fig. 7D, 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) }.

The cost values corresponding to the motion vectors of the 21 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

In another example, assuming that SR is 2, the number of candidate points may be 13, and the order of these candidate points is in the order from near to far from the center with motion vector (0,0) as the center. Referring to fig. 7E, 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 the 13 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

Example 25: for steps 303 and 403, 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 referred _ MV0 and the second target motion vector referred _ MV1, the implementation is similar to embodiments 21 and 22. In this embodiment, all the candidate motion vectors to be processed are selected at one time, so that the candidate motion vectors can be processed in parallel to obtain a cost value of each candidate motion vector, thereby reducing the computational complexity and improving the coding performance.

In this embodiment, a partial motion vector having a deviation not exceeding the SR range is selected from a total of (2 × SR +1) × (2 × SR +1) points around the original motion vector, centering on the original motion vector. For example, from (2 × SR +1) × (2 × SR +1) points including the original motion vector, N (N is equal to or greater than 1, and equal to or less than (2 × SR +1) × (2 × SR +1)) candidate points are selected. And determining the cost value of the motion vector corresponding to the N points. The cost values of the N points are scanned in a certain sequence, and the motion vector with the minimum cost value is selected as the optimal motion vector. If the cost values are equal, the candidate points in the front order are preferentially selected.

Unlike embodiment 24, the positions of the candidate points in embodiment 24 are all fixed, i.e., independent of the original motion vector, and the positions of the candidate points in embodiment 25 are related to the original motion vector, and the following description will be made with reference to several specific examples.

In one example, assuming that SR is 2, the number of candidate points may be 13, and the order of these candidate points is in order from near to far from the center with motion vector (0,0) as the center. Furthermore, the order of the first layer candidate points from the center is independent of the size of the original motion vector, while the order of the second layer candidate points from the center is dependent on 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 x 2,0), Mv (sign _ H x 2, sign _ V x 1), Mv (0, sign _ V x 2) }. The first original motion vector is denoted as MV0, the horizontal component is MV0_ Hor, and the vertical component is MV0_ Ver. If the MV0_ Hor is greater than or equal to 0, sign _ H is equal to 1; otherwise sign _ H ═ 1; if MV0_ Ver is greater than or equal to 0, sign _ V is equal to 1; otherwise sign _ V is-1.

The cost values corresponding to the motion vectors of the 13 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

In another example, assuming that SR is 2, the number of candidate points may be 13, and the order of these candidate points is in the order from near to far from the center with motion vector (0,0) as the center. Furthermore, the order of the first layer candidate points from the center is independent of the size of the original motion vector, while the order of the second layer candidate points from the center is dependent on the size of the original motion vector, and these candidate points are in the order: { 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 x 2,0), Mv (sign _ H x 2, sign _ V x 1), Mv (0, sign _ V x 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, sign _ H is 1; otherwise sign _ H ═ 1; if MV0_ Ver is greater than 0, sign _ V is 1; otherwise sign _ V is-1.

The cost values corresponding to the motion vectors of the 13 points are determined, scanning is performed according to the sequence, the motion vector with the minimum cost value is obtained as the optimal offset MV, the integer pixel motion vector adjustment value and the sub-pixel motion vector adjustment value can be determined by using the optimal offset MV, and the determination method refers to the above embodiment.

Example 26: in the above embodiment, the first cost value corresponding to the center motion vector and the second cost value corresponding to the edge motion vector are obtained according to the first pixel value of the first reference block and the second pixel value of the second reference block. And acquiring a third cost value corresponding to the first original motion vector and a fourth cost value corresponding to the candidate motion vector according to the first pixel value of the first reference block and the second pixel value of the second reference block.

In one example, a first cost value corresponding to the center motion vector, a second cost value corresponding to the edge motion vector, a third cost value corresponding to the first original motion vector, and a fourth cost value corresponding to the candidate motion vector may be obtained according to the first pixel value without down-sampling and the second pixel value without down-sampling.

In another example, a downsampling operation may be performed on a first pixel value and a downsampling operation may be performed on a second pixel value; then, according to the first pixel value after down-sampling and the second pixel value after down-sampling, a first cost value corresponding to the central motion vector, a second cost value corresponding to the edge motion vector, a third cost value corresponding to the first original motion vector and a fourth cost value corresponding to the candidate motion vector are obtained.

In another example, a shift and downsample operation may be performed on a first pixel value, and a shift and downsample operation may be performed on a second pixel value; and then, according to the operated first pixel value and the operated second pixel value, acquiring a first cost value corresponding to the central motion vector, a second cost value corresponding to the edge motion vector, a third cost value corresponding to the first original motion vector and a fourth cost value corresponding to the candidate motion vector.

The manner in which the cost value is determined is similar for different situations. For example, in order to obtain a cost value corresponding to the central motion vector, the sub-reference block a1 corresponding to the central motion vector may be copied from the first reference block, the sub-reference block B1 corresponding to the symmetric motion vector for obtaining the central motion vector may be copied from the second reference block, and the cost value corresponding to the central motion vector may be obtained using the first pixel values of the sub-reference block a1 and the second pixel values of the sub-reference block B1. In order to obtain the cost value corresponding to the edge motion vector, the sub-reference block a2 corresponding to the edge motion vector may be obtained by copying from the first reference block, the sub-reference block B2 corresponding to the symmetric motion vector of the edge motion vector may be obtained by copying from the second reference block, and the cost value corresponding to the edge motion vector may be obtained by using the first pixel value of the sub-reference block a2 and the second pixel value of the sub-reference block B2, and so on.

In summary, in order to obtain the cost value corresponding to the motion vector, the sub-reference block corresponding to the motion vector is obtained from the first reference block, the sub-reference block corresponding to the symmetric motion vector of the motion vector is obtained from the second reference block, and then the pixel values of the two sub-reference blocks are used to obtain the cost value corresponding to the motion vector.

Example 27: on the basis of embodiment 26, the cost value corresponding to the motion vector is obtained based on the non-downsampled first pixel value (i.e., the non-downsampled pixel value of the sub-reference block in the first reference block) and the non-downsampled second pixel value (i.e., the non-downsampled pixel value of the sub-reference block in the second reference block).

In one example, assume that a sub-reference block in a first reference block is pred0The sub-reference block in the second reference block is pred1According to the sub-reference block pred0And sub-reference block pred1Without the need for sub-reference block pred0And sub-reference block pred1The pixel of (a) is vertically down sampled.

Based on sub-reference block pred0And sub-reference block pred1The cost value calculation formula is:

in the above formula, cost represents the cost value, W is the width value of the sub-reference block, H is the height value of the sub-reference block, pred0(i, j) denotes a sub-reference block pred0Of the ith column and the jth row of (2)1(i, j) denotes a sub-reference block pred1And abs (x) represents the absolute value of x.

Example 28: on the basis of embodiment 26, a downsampling operation may be performed on the first pixel value and the second pixel value; 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).

In one example, assume that a sub-reference block in a first reference block is pred0The sub-reference block in the second reference block is pred1According to the sub-reference block pred0And sub-reference block pred1The SAD of all pixel values of (a) determines the cost value. In determining a cost value using SADs of all pixel values, a sub-reference block pred0And sub-reference block pred1Is down-sampled by a factor of N (N is an integer greater than 0, and may be 2) vertically.

Based on sub-reference block pred0And sub-reference block pred1The cost value calculation formula is:

in the above formula, cost represents the cost value, W is the width value of the sub-reference block, H is the height value of the sub-reference block, N represents the down-sampling parameter, is an integer greater than 0, and may be 2, pred0(1+ N (i-1), j) denotes a sub-reference block pred0Column 1+ N (i-1), row j, the pixel value pred1(1+ N (i-1), j) denotes a sub-reference block pred1Column 1+ N (i-1), row j, abs (x) represents the absolute value of x.

Example 29: on the basis of embodiment 26, shift and downsample operations are performed on the first pixel value, and shift and downsample operations are performed on the second pixel value; and acquiring a cost value corresponding to the motion vector according to the operated first pixel value (the pixel value after the shifting and downsampling of the sub-reference block in the first reference block) and the operated second pixel value (the pixel value after the shifting and downsampling of the sub-reference block in the second reference block).

In one example, assume that a sub-reference block in a first reference block is pred0The sub-reference block in the second reference block is pred1,pred0And pred1All using a D-bit storage scheme, i.e. pred0Each image ofThe prime values are all stored using D bits, pred1Each pixel value in (a) is stored using D bits.

If D is less than or equal to 8, pred is determined according to the sub-reference block0And sub-reference block pred1The SAD of all pixel values of (a) determines the cost value. In determining a cost value using SADs of all pixel values, a sub-reference block pred0And sub-reference block pred1Is down-sampled by a factor of N (N is an integer greater than 0, and may be 2) vertically. Based on sub-reference block pred0And sub-reference block pred1The cost value calculation formula is:

in the above formula, cost represents the cost value, W is the width value of the sub-reference block, H is the height value of the sub-reference block, N represents the down-sampling parameter, is an integer greater than 0, and may be 2, pred0(1+ N (i-1), j) denotes a sub-reference block pred0Column 1+ N (i-1), row j, the pixel value pred1(1+ N (i-1), j) denotes a sub-reference block pred1Column 1+ N (i-1), and abs (x) denotes the absolute value of x, and as can be seen from the above, the sum of the absolute values of the differences of row 1, row N +1, and row 2N +1 … is calculated.

If D is greater than 8, the sub-reference block pred is first determined0And sub-reference block pred1Is shifted to 8 bits to obtain an 8-bit pred0And 8 bit pred1Is denoted by pred0-8bit(i,j)And pred1-8bit(i,j). The purpose is to save the storage cost of SAD computation, and the storage of 8 bits can realize higher parallelism.

pred0_8bit(i,j)=pred0(i,j)>>(D-8),pred1_8bit(i,j)=pred1(i,j)>>(D-8)

Then, for 8-bit pred0And 8 bit pred1Is down-sampled by a factor of N (N is an integer greater than 0, and may be 2) vertically, so that the cost value can be calculated by:

In the above formula, the meaning of each expression is referred to the above embodiment, and is not repeated here.

Example 30: in step 304 and step 404, for each sub-block of the current block, motion compensation is performed on the sub-block according to the first target motion vector of the sub-block and the second target motion vector of the sub-block. Specifically, a third reference block corresponding to the sub-block is determined according to the first target motion vector of the sub-block, and a fourth reference block corresponding to the sub-block is determined according to the second target motion vector of the sub-block. And weighting according to the third pixel value of the third reference block and the fourth pixel value of the fourth reference block to obtain the predicted value of the sub-block.

For example, two directional reference blocks (i.e., a third reference block and a fourth reference block including predicted values of three components, which are obtained by interpolation (e.g., 8-tap interpolation) based on two target motion vectors of the sub-blocks, interpolation is required since the target motion vectors may be sub-pixels. And weighting according to the third pixel value of the third reference block and the fourth pixel value of the fourth reference block to obtain a final predicted value (three components).

In one example, a fifth reference block corresponding to the sub-block may be determined from the first reference frame based on the first target motion vector of the sub-block, and a third reference block may be obtained by interpolating pixel values in the fifth reference block. A sixth reference block corresponding to the sub-block may be determined from the second reference frame based on the second target motion vector of the sub-block, and a fourth reference block may be obtained by interpolating pixel values in the sixth reference block.

For example, assuming that the size of the current block is W × H, a fifth reference block with a size a × B may be determined from the first reference frame based on the first target motion vector, where the size a × B of the fifth reference block is related to the interpolation method, a is greater than W, and B is greater than H, which is not limited herein. By interpolating the pixel values in the fifth reference block, the third reference block with the size of W × H can be obtained, and the interpolation method is not limited. A sixth reference block of size a B may be determined from the second reference frame based on the second target motion vector, the size a B of the sixth reference block being related to the manner of interpolation, a being greater than W and B being greater than H. By interpolating the pixel values in the sixth reference block, the fourth reference block with the size of W × H can be obtained, and the interpolation method is not limited.

In another example, a seventh 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, an eighth reference block is constructed by using pixel values in the seventh reference block, and the third reference block is obtained by interpolating the pixel values in the eighth reference block. And determining a ninth reference block corresponding to the sub-block from the second reference frame based on the second target motion vector of the sub-block, constructing a tenth reference block by using pixel values in the ninth reference block, and interpolating the pixel values in the tenth reference block to obtain a fourth reference block.

For example, assuming that the size of the current block is W × H, a seventh reference block of size W × H may be determined from the first reference frame based on the first target motion vector. The eighth reference block with a size of a × B is constructed based on the pixel values in the seventh reference block, and this construction method is not limited. The size a × B of the eighth reference block is related to the interpolation method, where a is greater than W and B is greater than H, which is not limited. By interpolating the pixel values in the eighth reference block, the third reference block with the size of W × H can be obtained, and the interpolation method is not limited.

For another example, assuming that the size of the current block is W × H, a ninth reference block of size W × H may be determined from the second reference frame based on the second target motion vector. The tenth reference block with a size a × B is constructed based on the pixel values in the ninth reference block, and this construction method is not limited. The size a × B of the tenth reference block is related to the interpolation method, where a is greater than W and B is greater than H, which is not limited. By interpolating the pixel values in the tenth reference block, the fourth reference block with the size of W × H can be obtained, and the interpolation method is not limited.

Example 31: after obtaining the target motion vector, based on the target motion vector of each sub-block, two-direction prediction values (i.e., YUV three components, 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 a final prediction value is obtained by weighting. Referring to fig. 5, the black area and the white area are pixel values obtained from the reference frame, and the pixel values for the gray area are not necessarily obtained from the reference frame, but may be obtained by copying adjacent pixel values.

In one example, first, the first row of W + FS-1 pixel values of the white area may be copied to the pixel values of the first SR row of the gray area. The last row W + FS-1 pixel values of the white area are copied to the pixel values of the last SR row of the gray area. Then, the pixel values of the first column of the white region, H + FS-1, and the pixel values of the upper and lower SR obtained gray regions may be copied to the pixel values of the first SR columns of the gray region. And copying the H + FS-1 pixel values of the last column of the white area and the pixel values of the upper SR obtained gray areas and the lower SR obtained gray areas to the pixel values of the last SR column of the gray area.

In another example, first, the first column of H + FS-1 pixel values of the white area may be copied to the first SR column of pixel values of the gray area. The last column H + FS-1 pixel values of the white area are copied to the pixel values of the last SR column of the gray area. Then, the W + FS-1 pixel values of the first row of the white area and the SR pixel values of the obtained gray areas on the left and right sides are copied to the pixel values of the previous SR row of the gray area. And copying W + FS-1 pixel values of the last line of the white area and SR obtained pixel values of the gray area to the pixel values of the last SR line of the gray area.

Example 32: after the target motion vector is obtained, based on the target motion vector of each sub-block, prediction values in two directions (namely YUV three components, namely, a prediction value of the third reference block and a prediction value of the fourth reference block) are obtained through an 8-tap interpolation filter, and a final prediction value is obtained through weighting. Referring to fig. 5, the black area and the white area are pixel values obtained from the reference frame, and the pixel values for the gray area are obtained by copying directly from the corresponding area of the reference frame, rather than by copying adjacent pixel values. This approach is simple and may perform better, but increases the amount of access data to the reference frame.

Example 33: after obtaining the target motion vector, based on the target motion vector of each sub-block, two-directional prediction values (i.e., YUV three components, i.e., the prediction value of the third reference block and the prediction value of the fourth reference block described above) are obtained through a bilinear interpolation filter (here, no longer an 8-tap interpolation filter), and a final prediction value is obtained by weighting. Referring to fig. 5, the black and white regions may be pixel values obtained from a reference frame. Since the number of taps is relatively small, the pixel values of the gray area are not required.

Example 34: in example 30 to example 33, after obtaining the predicted values in the two directions, the final predicted value is obtained by mean weighted average (i.e., the predicted values in the two directions have the same weight). Or after obtaining the predicted values in two directions, obtaining the final predicted value by weighted average, wherein the weights of the two predicted values may be different. For example, the weight ratio of two predicted values may be 1: 2,1: 3,2: 1, etc.

For the encoding end, the weight table may include 1: 2,1: 3,2: 1, the coding end can determine the cost value of each weight value proportion and determine the weight value proportion with the minimum cost value, so that the coding end can obtain the final predicted value through weighted average based on the weight value proportion with the minimum 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 proportion in the weight table. In this way, the decoding end analyzes the index value of the coded bit stream, obtains the weight ratio corresponding to the index value from the weight table, and obtains the final predicted value through weighted average based on the weight ratio.

In one example, the weight table may include, but is not limited to { -2, 3, 4, 5, 10 }. The weight "-2" indicates that the final predicted value is (predicted value 1 × (-2) + predicted value 2 × (8- (-2))), that is (-2 × predicted value 1+10 × (2))/8. The weight "10" indicates that the weight ratio is 10: -2, i.e. the final predicted value (predicted value 1 x (10) + predicted value 2 x (-2)), i.e. (10 x predicted values 1-2 x predicted values 2)/8. The weight "3" indicates a weight ratio of 3: 5. the weight "5" indicates a weight ratio of 5: 3. weight "4" indicates a weight ratio of 4: 4, i.e., weight "4" means the same weight.

Example 35: in steps 305 and 405, it is necessary to save the first target motion vector and the second target motion vector of each sub-block of the current block, which are used for encoding/decoding reference of the subsequent block. For 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 a subsequent frame; 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 may be used for motion compensation of the current block, and may also be used for temporal reference of a subsequent frame. For another example, the first target motion vector and the second target motion vector of each sub-block of the current block may be used for motion compensation of the current block, may also be used for a loop filtering process of the current block, and may also be used for temporal reference of a subsequent frame.

For another example, the first target motion vector and the second target motion vector of each sub-block of the current block may be used for motion compensation of the current block, may also be used for a loop filtering process of the current block, may also be used for a temporal reference of a subsequent frame, and may also be used for a spatial reference of the current frame, which will be described below.

The first and second target motion vectors of each sub-block of the current block may be used for spatial reference of blocks within certain LCUs (Largest Coding units) in spatial domain. Since the coding order is from top to bottom and from left to right, the motion vector of the current block can be referenced by other blocks within the current LCU, as well as by blocks within subsequent neighboring LCUs. Since the amount of calculation required for the obtained target motion vector is large, if the subsequent block refers to the target motion vector of the current block, it takes a long time to wait. In order to avoid the time delay caused by excessive waiting, only a few spatial 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. Referring to fig. 8, the minority blocks include sub-blocks located in a lower LCU and a lower right LCU on the lower side of the current LCU, and sub-blocks located in a right LCU and a left LCU, the target motion vector of the current block may not be referenced.

Example 36: the following describes an adjustment process of a motion vector with reference to a specific example. The specific steps of motion vector adjustment can be as follows, the following "copy" indicates that interpolation is not needed to obtain, the MV is the integer pixel offset and can be directly copied from the reference frame, otherwise interpolation is needed.

Step e1, if the current block adopts merge or skip mode, the following procedure is performed.

Step e2, prepare the reference pixel values (assuming the width of the current block is W and the height is H).

Preparing the whole pixel block for step e 3: based on the original motion vector (the original motion vector of list0 is denoted as Org _ MV0, the original motion vector of list1 is denoted as Org _ MV1), two whole pixel blocks of three components with the area of (W + FS-1) × (H + FS-1) are copied at the corresponding positions of the corresponding reference frames.

Preparing the whole pixel block for step e 4: in addition to the above-described whole pixel block of (W + FS-1) × (H + FS-1), the whole pixel block of three components of (W + FS-1) × (H + FS-1) is expanded in the upper, lower, left, right, and SR rows/columns, and the expanded pixel block of three components of (W + FS-1+2 SR) × (H + FS-1+2 × SR) area is denoted as Pred _ Inter0 and Pred _ Inter1, as shown in fig. 5.

A first motion compensation is performed based on motion information in two different directions. For example, for the luminance component (since the subsequent search process calculates the cost value by using the luminance component, thereby reducing the complexity), two initial reference prediction values (denoted as Pred _ Bilinear0 and Pred _ Bilinear1) with the size of (W +2 SR) (H +2 SR)) are obtained by Bilinear interpolation based on two integer pixel reference blocks with the area of (W + FS-1) ((H + FS-1), FS is the number of filter taps, and is default to 8, and SR is the search range, i.e., the target motion vector and the maximum horizontal/vertical component interpolation of the original motion vector, and is default to 2. Pred _ Biliner 0/1 is used for the use of step e 3.

Step e3, for each dx _ dy sub-block (16 × 16 or smaller whole block) of the current block, a target motion vector is obtained, respectively (the two target motion vectors are denoted as referred _ MV0 and referred _ MV1, respectively).

Step e31, performing SR iterations to obtain the optimal integer pixel offset of the integer pixel MV point, which is denoted as integer delta MV, initializing the integer delta MV to (0,0), and performing the following process in each iteration:

in step e311, deltaMV is set to (0, 0). If the process is the first iteration, two prediction value blocks (namely, the most central W × H block of Pred _ Bilinear 0/1) are obtained by copying in the reference pixel Pred _ Bilinear0/1 based on the original motion vector, and an initial cost value, namely SAD after vertical 2-time down-sampling of the two directional prediction value blocks, is obtained based on the two prediction value blocks.

If the initial cost value is less than 4 × dx dy/2, and dx and dy are the width and height of the current subblock, the subsequent search process is directly skipped, step e32 is executed, and notZeroCost is set to false.

Step e312, as shown in fig. 6, obtains five offset MVs (these five offset MVs are all referred to as MVOffset) in the order of { Mv (0,1), Mv (0, -1), Mv (1,0), Mv (-1,0), Mv (right, down) }, with the above-mentioned initial point as the center, and performs the calculation and comparison process of the cost values of these five offset MVs.

For example, based on a certain MVOffset, two blocks of prediction values (that is, a block of W × H subjected to center position shift MVOffset in Pred _ binlinar 0 and a block of W × H subjected to center position shift MVOffset (opposite to list 0) in Pred _ binlinar 1) are obtained by MVOffset in reference pixel Pred _ binlinar 0/1, and downsampled SAD of the two blocks is calculated as a cost value of MVOffset. The MVOffset (stored in deltaMV) with the smallest cost value is retained as the new center offset point for the next iteration.

The default value of Mv (right, down) is (-1, -1), if the cost value of Mv (1,0) is less than that of Mv (-1,0), right is 1; if the cost value of Mv (0,1) is less than that of Mv (0, -1), down is 1.

Updating IntegerDeltaMV based on the deltaMV value: IntegerDeltaMV + deltaMV.

And e313, after 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 e32 is executed, and notZeroCost is set to false. Otherwise, if the iteration number reaches SR, executing step e32, and if the iteration number does not reach SR, taking the optimal MV as the center, and performing the next iterative search process, i.e., returning to step e 311.

Step e32, taking the optimal integer pixel MV point of step e31 as the center, obtaining the optimal sub-pixel offset MV, which is denoted as SPMV, initializing the SPMV to (0,0), and then performing the following processes:

and e321, performing subsequent processing only when notZeroCost is not false and deltaMV is (0,0), otherwise, directly adjusting the original motion vector by using IntegerDeltaMV.

And E322, representing E (x, y) as the MV corresponding cost value of the optimal MV point offset (x, y) obtained in the step E31 (the cost value calculated in the step E31). Based on the center and the E (x, y) of the five upper, lower, left, and right points, the deviation (x0, y0) of the point at which the E (x, y) is the smallest can be found as: x is the number of0=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, then N is 1,2, 4, and 8. Then, (x0, y0) may be assigned to deltaMv, SPMV/2N, and if the current motion vector pixel precision is 1/16, then SPMV may be (x0, y0)0/16,y0/16)。

If E (-1,0) ═ E (0,0), then the horizontal is shifted to the left by half a pixel (deltaMv [0] ═ N).

If E (1,0) is equal to E (0,0), the horizontal is shifted to the right by half a pixel (deltaMv [0] ═ N).

If E (0, -1) ═ E (0,0), then half a pixel is shifted vertically upward (deltaMv [1] ═ N).

If E (0,1) is equal to E (0,0), then a half pixel is shifted vertically downward (deltaMv [1] ═ N).

And e33, obtaining an optimal offset MV, which is marked as BestMVoffset, based on the integer pixel offset IntegerDeltaMV of the step e31 and the sub-pixel offset SPMV of the step e 32. Bestmvamfset ═ IntegerDeltaMV + SPMV. Based on bestmveffset, target motion vectors in two directions can be obtained: referred _ MV0 Org _ MV0+ bestmvffset; referred _ MV1 Org _ MV 1-bestmvffset.

And e4, performing 8-tap interpolation based on the target motion vector of each sub-block to obtain predicted values in two directions, and weighting to obtain final predicted values (three components). For example, based on the target motion vectors referred _ MV0 and referred _ MV1 of each sub-block, in Pred _ Inter0/1 prepared in step e2, the corresponding prediction block is obtained by interpolation (the motion vectors may be divided into pixels, and interpolation is required to obtain the corresponding pixel block).

Step e5, target motion vector, for motion compensation of the current block and temporal reference of the subsequent frame.

Example 37: the above embodiments may be implemented individually or in any combination. For example, embodiment 13 may be implemented alone, embodiment 15 may be implemented alone, embodiment 24 may be implemented alone, and embodiment 29 may be implemented alone. Embodiment 13 and embodiment 15 are implemented in combination, embodiment 13 and embodiment 24 are implemented in combination, embodiment 13 and embodiment 29 are implemented in combination, embodiment 15 and embodiment 24 are implemented in combination, embodiment 15 and embodiment 29 are implemented in combination, embodiment 24 and embodiment 29 are implemented in combination, embodiment 13, embodiment 15 and embodiment 24 are implemented in combination, embodiment 13, embodiment 15 and embodiment 29 are implemented in combination, embodiment 15, embodiment 24 and embodiment 29 are implemented in combination, embodiment 13, embodiment 15, embodiment 24 and embodiment 29 are implemented in combination, and embodiment 13, embodiment 15, embodiment 24 and embodiment 29 are implemented in combination.

Example 38:

based on the same application concept as the method, an embodiment of the present application further provides a coding and decoding apparatus applied to a coding end or a decoding end, as shown in fig. 9, which is a structural diagram of the apparatus, and the apparatus includes:

a determining module 91, configured to determine, if the feature information of the current block meets a specific condition, a first reference block corresponding to the current block according to a first original motion vector of the current block, and determine, according to a second original motion vector of the current block, a second reference block corresponding to the current block; a processing module 92, configured to adjust a first original motion vector and a 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, so as 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; and an encoding/decoding module 93, configured to encode or decode the current block according to the first target motion vector and the second target motion vector.

The characteristic information comprises one or more of the following: the motion information prediction mode corresponding to the current block; the motion information attribute corresponding to the current block; size information of the current block.

If the feature information is the motion information prediction mode corresponding to the current block, the determining module 91 is further configured to: if the motion information prediction mode corresponding to the current block is a common fusion mode, determining that the motion information prediction mode corresponding to the current block meets a specific condition; or, if the motion information prediction mode corresponding to the current block is a fusion mode used for generating a new prediction value by combining the inter prediction value and the intra prediction value, determining that the motion information prediction mode corresponding to the current block meets a specific condition.

If the feature information is the motion information attribute corresponding to the current block, the determining module 91 is further configured to: if the motion information attribute corresponding to the current block is that the motion information of the current block comprises motion information in two different directions, determining that the motion information attribute corresponding to the current block meets a specific condition; or if the motion information attribute corresponding to the current block is that the motion information of the current block comprises motion information in two different directions, and the distances between two reference frames corresponding to the motion information in the two different directions and the current frame are the same, determining that the motion information attribute corresponding to the current block meets a specific condition; or if the motion information attribute corresponding to the current block is the motion information of the current block multiplexing surrounding blocks, determining that the motion information attribute corresponding to the current block meets a specific condition; or if the motion information attribute corresponding to the current block is that the motion information of each sub-block of the current block is the same, determining that the motion information attribute corresponding to the current block meets a specific condition.

If the feature information is the size information of the current block, and the size information of the current block includes the width value of the current block and the height value of the current block, the determining module 91 is further configured to: if the width value of the current block is located in the range of a first interval [ a first threshold value, a second threshold value ], determining that the size information of the current block meets a specific condition; or if the height value of the current block is located in the range of a second interval [ a third threshold value, a fourth threshold value ], determining that the size information of the current block meets a specific condition; or if the area of the width value and the area of the height value of the current block are located in a third interval [ a fifth threshold value, a sixth threshold value ], determining that the size information of the current block meets a specific condition; or, if the width value is located within a first interval [ first threshold, second threshold ], the height value is located within a second interval [ third threshold, fourth threshold ], and the area is located within a third interval [ fifth threshold, sixth threshold ], determining that the size information of the current block satisfies a specific condition.

The determining module 91 determines the first reference block corresponding to the current block according to the first original motion vector of the current block, and when determining the second reference block corresponding to the current block according to the second original motion vector of the current block, is specifically configured to: determining a first reference block corresponding to the current block from a first reference frame based on a first original motion vector of the current block; determining a second reference block corresponding to the current block from a second reference frame based on a second original motion vector of the current block; the first pixel value of each pixel point in the first reference block is obtained by interpolating the pixel values of the adjacent pixel points in the first reference block, or is obtained by copying the pixel values of the adjacent pixel points in the first reference block; the second pixel value of each pixel point in the second reference block is obtained by interpolating the pixel values of the adjacent pixel points in the second reference block, or by copying the pixel values of the adjacent pixel points in the second reference block.

The processing module 92 is specifically configured to, when adjusting 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:

if the current block comprises at least one sub-block, aiming at each sub-block of the current block, adjusting the first original motion vector and the second original motion vector according to the first pixel value and the second pixel value to obtain a first target motion vector and a second target motion vector of the sub-blocks.

For example, a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-block, and/or a first sub-pixel motion vector adjustment value and a second sub-pixel motion vector adjustment value of the sub-block may be determined according to the first pixel value and the second pixel value; adjusting 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 of the sub-block; and adjusting 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 of the sub-block.

The processing module 92 is specifically configured to determine, according to the first pixel value and the second pixel value, a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-block, and a first sub-pixel motion vector adjustment value and a second sub-pixel motion vector adjustment value of the sub-block:

determining the first original motion vector or the second original motion vector as a central motion vector;

determining an edge motion vector corresponding to the center motion vector;

according to the first pixel value and the second pixel value, a first cost value corresponding to the central motion vector and a second cost value corresponding to the edge motion vector are obtained;

selecting one motion vector from the center motion vector and the edge motion vector as an optimal motion vector according to the first cost value and the second cost value;

judging whether an end condition is met; if not, determining the optimal motion vector as a central motion vector, and returning to execute the determination of the edge motion vector corresponding to the central motion vector;

if yes, determining a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-block according to the optimal motion vector; and determining 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.

When the processing module 92 determines the edge motion vector corresponding to the center motion vector, it is specifically configured to:

shifting the central motion vector (x, y) to different directions by S, and sequentially obtaining edge motion vectors (x, y + S), edge motion vectors (x, y-S), edge motion vectors (x + S, y), edge motion vectors (x-S, y) and edge motion vectors (x + right, y + down) in different directions; alternatively, the first and second electrodes may be,

shifting the central motion vector (x, y) to different directions by S, and sequentially obtaining edge motion vectors (x, y-S), edge motion vectors (x, y + S), edge motion vectors (x-S, y), edge motion vectors (x + S, y) and edge motion vectors (x + right, y + down) in different directions;

wherein the default value of the edge motion vector (x + right, y + down) is (x-S, y-S);

if the cost value of the edge motion vector (x + S, y) is smaller than the cost value of the edge motion vector (x-S, y), right is S; if the cost value of the edge motion vector (x, y + S) is smaller than that of the edge motion vector (x, y-S), then down is S; or, 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 (x-S, y), right is 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, y-S), then down is S.

The processing module 92 is specifically configured to, when obtaining the first cost value corresponding to the center motion vector and the second cost value corresponding to the edge motion vector according to the first pixel value and the second pixel value:

according to the first pixel value without down-sampling and the second pixel value without down-sampling, acquiring a first cost value corresponding to the central motion vector and a second cost value corresponding to the edge motion vector; alternatively, the first and second electrodes may be,

performing downsampling operation on the first pixel value and performing downsampling operation on the second pixel value; according to the first pixel value after down sampling and the second pixel value after down sampling, a first cost value corresponding to the central motion vector and a second cost value corresponding to the edge motion vector are obtained; alternatively, the first and second electrodes may be,

performing shifting and downsampling operations on the first pixel value, and performing shifting and downsampling operations on the second pixel value; and acquiring a first generation value corresponding to the central motion vector and a second generation value corresponding to the edge motion vector according to the operated first pixel value and the operated second pixel value.

The processing module 92 is specifically configured to determine, according to the first pixel value and the second pixel value, a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-block, and a first sub-pixel motion vector adjustment value and a second sub-pixel motion vector adjustment value of the sub-block:

selecting a part of or all of the motion vectors from the surrounding motion vectors by taking the first original motion vector or the second original motion vector as a center, and taking the selected motion vector as a candidate motion vector;

according to the first pixel value and the second pixel value, acquiring a third cost value corresponding to the first original motion vector or the second original motion vector and a fourth cost value corresponding to the candidate motion vector;

according to the third cost value and the fourth cost value, selecting one motion vector from the first original motion vector or the second original motion vector and the candidate motion vector as an optimal motion vector;

determining a first integer pixel motion vector adjustment value and a second integer pixel motion vector adjustment value of the sub-block according to the optimal motion vector; and determining 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.

When the processing module 92 determines the first integer pixel motion vector adjustment value and the second integer pixel motion vector adjustment value of the sub-block according to the optimal motion vector, it is specifically configured to: and determining a first integer pixel motion vector adjustment value of the sub-block according to the optimal motion vector and the first original motion vector, and determining a second integer pixel motion vector adjustment value of the sub-block according to the first integer pixel motion vector adjustment value.

When the processing module 92 determines the first sub-pixel motion vector adjustment value and the second sub-pixel motion vector adjustment value of the sub-block according to the optimal motion vector, it is configured to: and determining a first sub-pixel motion vector adjustment value of the sub-block according to the cost value corresponding to the optimal motion vector and the cost value corresponding to the edge motion vector corresponding to the optimal motion vector, and determining a second sub-pixel motion vector adjustment value of the sub-block according to the first sub-pixel motion vector adjustment value.

The encoding and decoding module 93 is specifically configured to, when encoding or decoding the current block according to the first target motion vector and the second target motion vector: if the current block comprises at least one sub-block, aiming at each sub-block of the current block, determining a third reference block corresponding to the sub-block according to a first target motion vector of the sub-block, and determining a fourth reference block corresponding to the sub-block according to a second target motion vector of the sub-block; weighting according to a third pixel value of the third reference block and a fourth pixel value of the fourth reference block to obtain a predicted value of the sub-block; and determining the prediction value of the current block according to the prediction value of each sub-block.

The encoding and decoding module 93 is specifically configured to determine, according to the first target motion vector of the sub-block, a third reference block corresponding to the sub-block, and determine, according to the second target motion vector of the sub-block, a fourth reference block corresponding to the sub-block: determining a fifth reference block corresponding to the sub-block from a first reference frame based on the first target motion vector of the sub-block, and interpolating pixel values in the fifth reference block to obtain a third reference block;

and determining a sixth reference block corresponding to the sub-block from a second reference frame based on the second target motion vector of the sub-block, and interpolating pixel values in the sixth reference block to obtain the fourth reference block.

The encoding and decoding module 93 is specifically configured to determine, according to the first target motion vector of the sub-block, a third reference block corresponding to the sub-block, and determine, according to the second target motion vector of the sub-block, a fourth reference block corresponding to the sub-block: determining a seventh reference block corresponding to the sub-block from a first reference frame based on the first target motion vector of the sub-block, constructing an eighth reference block by using pixel values in the seventh reference block, and interpolating the pixel values in the eighth reference block to obtain a third reference block; and determining a ninth reference block corresponding to the sub-block from a second reference frame based on the second target motion vector of the sub-block, constructing a tenth reference block by using pixel values in the ninth reference block, and interpolating the pixel values in the tenth reference block to obtain the fourth reference block.

The device further comprises: a storage module for storing the first target motion vector and the second target motion vector for the current block; wherein, 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 a subsequent frame, and/or the first target motion vector and the second target motion vector are used for spatial reference of the current frame.

Example 39:

in terms of hardware, the hardware architecture diagram of the decoding-side device provided in the embodiment of the present application may specifically refer to fig. 10. The method comprises the following steps: a processor 101 and a machine-readable storage medium 102, the machine-readable storage medium 102 storing machine-executable instructions executable by the processor 101; the processor 101 is configured to execute machine-executable instructions to implement the methods disclosed in the above examples of the present application. For example, a processor is used to execute machine executable instructions to implement the steps of:

if the characteristic information of the current block meets a specific condition, determining a first reference block corresponding to the current block according to a first original motion vector of the current block, and determining a second reference block corresponding to the current block according to a second original motion vector of the current block; adjusting a first original motion vector and a 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; decoding the current block according to the first target motion vector and the second target motion vector.

In terms of hardware, the hardware architecture diagram of the encoding end device provided in the embodiment of the present application may specifically refer to fig. 11. The method comprises the following steps: a processor 111 and a machine-readable storage medium 112, the machine-readable storage medium 112 storing machine-executable instructions executable by the processor 111; the processor 111 is configured to execute machine-executable instructions to implement the methods disclosed in the above examples of the present application. For example, a processor is used to execute machine executable instructions to implement the steps of:

if the characteristic information of the current block meets a specific condition, determining a first reference block corresponding to the current block according to a first original motion vector of the current block, and determining a second reference block corresponding to the current block according to a second original motion vector of the current block; adjusting a first original motion vector and a 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; encoding the current block according to the first target motion vector and the second target motion vector.

Based on the same application concept as the method, embodiments of the present application further provide a machine-readable storage medium, where a plurality of computer instructions are stored on the machine-readable storage medium, and when the computer instructions are executed by a processor, the encoding and decoding methods disclosed in the above examples of the present application can be implemented. The machine-readable storage medium may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium may be: a RAM (random Access Memory), a volatile Memory, a non-volatile Memory, a flash Memory, a storage drive (e.g., a hard drive), a solid state drive, any type of storage disk (e.g., an optical disk, a dvd, etc.), or similar storage medium, or a combination thereof.

The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.

For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.

As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.

The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

Furthermore, these computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.

These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.

The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. 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.

45页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种编解码方法、装置及其设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类