ENCRYPTION METHODS, DECODING METHODS, AND COMPUTER-READABLE INVARIABLE RECORDING MATERIALS
Patent Information
- Authority / Receiving Office
- VN · VN
- Patent Type
- Applications
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2023-09-28
- Publication Date
- 2026-06-15
AI Technical Summary
The inter-frame prediction performance in existing video encoding and codec standards is poor, making it difficult to effectively improve video encoding and codec efficiency.
During the motion estimation process, multiple candidate motion vectors are determined by combining the difference between the template of the current block and the template of the multiple reference blocks, and motion compensation is performed to improve the accuracy of inter prediction.
Improves the accuracy of motion estimation and inter prediction accuracy of the current block, thereby enhancing the video encoding and decoding performance.
Smart Images

Figure VN1202603251_0
Abstract
Description
Coding and decoding method and device, codec, code stream, device, storage medium Technical Field
[0001] The embodiments of the present application relate to video coding and decoding technology, including but not limited to coding and decoding methods and devices, codecs, bit streams, devices, and storage media. Background Art
[0002] In the field of video coding and decoding, improving video compression efficiency is crucial. The digitization of images and videos generates a significant amount of data redundancy, which makes video compression technology possible. Since adjacent images in a video are highly similar, inter-image prediction methods are used in video coding and decoding to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency. However, inter-frame prediction in existing video coding and decoding standards suffers from poor video coding and decoding performance. Therefore, research on how to further improve the accuracy of inter-frame prediction and thus enhance video coding and decoding performance remains of particular interest.
[0003] Summary of the Invention
[0004] In view of this, the coding and decoding methods and apparatuses, codecs, bit streams, devices, and storage media provided in the embodiments of the present application can improve the accuracy of inter-frame prediction, thereby enhancing video coding and decoding performance. The coding and decoding methods and apparatuses, codecs, bit streams, devices, and storage media provided in the embodiments of the present application are implemented as follows:
[0005] According to one aspect of an embodiment of the present application, a decoding method is provided, which is applied to a decoder, and the method includes: determining a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; determining a second difference in sample values between a template of the current block and a template of the first reference block; determining a third difference in sample values between the template of the current block and a template of the second reference block; performing motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block; and performing motion compensation on the current block based on the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
[0006] According to one aspect of an embodiment of the present application, a coding method is provided, which is applied to an encoder, and the method includes: determining a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; determining a second difference in sample values between a template of the current block and a template of the first reference block; determining a third difference in sample values between the template of the current block and a template of the second reference block; performing motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block; and performing motion compensation on the current block based on the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
[0007] According to one aspect of an embodiment of the present application, a decoding device is provided, which is applied to a decoder, and includes: a first determination module, configured to determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; a second determination module, configured to determine a second difference in sample values between a template of the current block and a template of the first reference block; a third determination module, configured to determine a third difference in sample values between the template of the current block and the template of the second reference block; a first motion estimation module, configured to perform motion estimation on the current block based on at least the first difference, the second difference, and the third difference, to obtain a first predicted MV and a second predicted MV of the current block; and a first motion compensation module, configured to perform motion compensation on the current block based on the first predicted MV and the second predicted MV, to obtain a predicted block of the current block.
[0008] According to one aspect of an embodiment of the present application, a decoder is provided, comprising a first memory and a first processor; wherein the first memory is used to store a computer program that can be run on the first processor; and the first processor is used to execute the decoding method described in the embodiment of the present application when running the computer program.
[0009] According to one aspect of an embodiment of the present application, there is provided an encoding device, applied to an encoder, the device comprising: a fourth determination module, configured to determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; a fifth determination module, configured to determine a second difference in sample values between a template of the current block and a template of the first reference block; a sixth determination module, configured to determine a third difference in sample values between the template of the current block and the template of the second reference block; a second motion estimation module, configured to perform motion estimation on the current block based on at least the first difference, the second difference, and the third difference, to obtain a first predicted MV and a second predicted MV of the current block; and a second motion compensation module, configured to perform motion compensation on the current block based on the first predicted MV and the second predicted MV, to obtain a predicted block of the current block.
[0010] According to one aspect of an embodiment of the present application, an encoder is provided, comprising a second memory and a second processor; wherein the second memory is used to store a computer program that can be run on the second processor; and the second processor is used to execute the encoding method described in the embodiment of the present application when running the computer program.
[0011] According to one aspect of an embodiment of the present application, a code stream is provided, where the code stream is obtained using the encoding method described in the embodiment of the present application.
[0012] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor adapted to execute a computer program; and a computer-readable storage medium storing a computer program, wherein when the computer program is executed by the processor, the encoding method as described in the embodiment of the present application is implemented, or when the computer program is executed by the processor, the decoding method as described in the embodiment of the present application is implemented.
[0013] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the encoding method as described in the embodiment of the present application is implemented, or when the computer program is executed, the decoding method as described in the embodiment of the present application is implemented.
[0014] In an embodiment of the present application, when motion estimation is performed on the current block, not only the second difference in sample values between the template of the current block and the template of the first reference block pointed to by the first candidate MV and the third difference in sample values between the template of the current block and the template of the second reference block pointed to by the second candidate MV are used, but also the first difference in sample values between the first reference block pointed to by the first candidate MV of the current block and the second reference block pointed to by the second candidate MV of the current block are combined; this is beneficial to improving the accuracy of motion estimation of the current block, that is, improving the accuracy of the first predicted MV and the second predicted MV of the current block, thereby improving the inter-frame prediction accuracy of the current block and enhancing video encoding and decoding performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The accompanying drawings herein are incorporated into and constitute a part of this specification. These drawings illustrate embodiments consistent with the present application and, together with the specification, serve to illustrate the technical solutions of the present application. Obviously, the drawings described below are merely some embodiments of the present application. Those skilled in the art can, without inventive effort, derive other drawings from these drawings.
[0016] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0017] FIG1 is a schematic diagram of the basic flow of a video codec;
[0018] FIG2 is a schematic diagram of a classic GOP (group of pictures) structure of RA (Random Access);
[0019] Figure 3 shows an example from HEVC;
[0020] FIG4 is a schematic diagram showing the positions of motion information that can be added to the merge candidate list in the Merge mode;
[0021] FIG5 is a schematic diagram showing the relationship between motion vectors of a collocated reference image col_pic, a reference image col_ref of a collocated block, a current image curr_pic and a reference image curr_ref of a current block;
[0022] FIG6 is a schematic diagram of MVD distributed in a single horizontal direction or a single vertical direction;
[0023] FIG7 is a schematic diagram of the MVs of two reference images moving in a mirror image manner;
[0024] FIG8 is a schematic diagram of the inter-frame prediction principle based on template matching;
[0025] FIG9 is a schematic diagram of an implementation flow of the encoding method provided in an embodiment of the present application;
[0026] FIG10 is a schematic diagram of a first flow chart of a method for determining a first predicted MV and a second predicted MV according to an embodiment of the present application;
[0027] FIG11 is a second schematic diagram of a flow chart of a method for determining a first predicted MV and a second predicted MV according to an embodiment of the present application;
[0028] FIG12 is a third flowchart of a method for determining a first predicted MV and a second predicted MV according to an embodiment of the present application;
[0029] FIG13 is a schematic diagram of an implementation flow of a decoding method provided in an embodiment of the present application;
[0030] FIG14 is a schematic structural diagram of a decoding device provided in an embodiment of the present application;
[0031] FIG15 is a schematic diagram of the structure of an encoding device provided in an embodiment of the present application;
[0032] FIG16 is a schematic diagram of the structure of an encoder provided in an embodiment of the present application;
[0033] FIG17 is a schematic diagram of the structure of the decoder provided in an embodiment of the present application. DETAILED DESCRIPTION
[0034] To make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the specific technical solutions of the present application will be further described in detail below in conjunction with the drawings in the embodiments of the present application. The following embodiments are used to illustrate the present application but are not intended to limit the scope of the present application.
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0036] In the following description, references to “some embodiments,” “this embodiment,” “embodiments of the present application,” and examples, etc., describe a subset of all possible embodiments. However, it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict.
[0037] The descriptions such as "first, second, third" appearing in the embodiments of this application are only for illustration and distinction of the described objects. There is no order, nor does it indicate any special limitation on the number of devices in the embodiments of this application, and cannot constitute any limitation on the embodiments of this application.
[0038] The codec architecture and service scenarios described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that, with the evolution of codec architectures and the emergence of new service scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0039] Most video codec standards use a block-based hybrid coding framework. Each image, sub-image, or frame in a video is divided into square Largest Coding Units (LCUs) or Coding Tree Units (CTUs) of the same size (e.g., 256x256, 128x128, 64x64, etc.). Each LCU or CTU can be divided into rectangular Coding Units (CUs) according to a rule. Coding Units may also be divided into Prediction Units (PUs) and Transform Units (TUs). The hybrid coding framework includes modules such as prediction, transform, quantization, entropy coding, and in-loop filtering. The prediction module includes intra-frame prediction and inter-frame prediction. Inter-frame prediction includes motion estimation and motion compensation. Because adjacent pixels in a video image have strong correlations, intra-frame prediction is used in video codecs to eliminate spatial redundancy between adjacent pixels. Since there is a strong similarity between adjacent images in a video, the inter-image prediction method is used in video coding and decoding technology to eliminate the temporal redundancy between adjacent images, thereby improving coding efficiency.
[0040] The basic process of a video codec is shown in Figure 1. At the encoder, an input image 101 is divided into blocks. Intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block for the current block. The prediction block is subtracted from the original block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. This quantization coefficient matrix is entropy-encoded and output to the bitstream. At the decoder, intra-frame prediction or inter-frame prediction is used on the current block to generate a prediction block for the current block. The bitstream is then parsed to obtain a quantization coefficient matrix. This quantization coefficient matrix is inversely quantized and inversely transformed to obtain a residual block. The prediction block and residual block are added together to obtain a reconstructed block. The reconstructed blocks form a reconstructed image, which is then subjected to image-based or block-based loop filtering to obtain a decoded image. The encoder also performs similar operations as the decoder to obtain a decoded image. The decoded image can serve as a reference image for inter-frame prediction of subsequent images. The block division information determined by the encoder, as well as information about the prediction, transform, quantization, entropy coding, loop filtering, and other modes or parameters, may be output to the bitstream if necessary. The decoding end determines the same block division information as the encoding end by parsing and analyzing the existing information, as well as the mode information or parameter information such as prediction, transformation, quantization, entropy coding, and loop filtering, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end. The decoded image obtained by the encoding end is also usually called a reconstructed image. The current block can be divided into prediction units during prediction, and can be divided into transformation units during transformation. The division of prediction units and transformation units can be different. The above is the basic process of the video codec under the block-based hybrid coding framework. With the development of technology, some modules or steps of the framework or process may be optimized. The embodiment of the present application is applicable to the basic process of the video codec under the block-based hybrid coding framework, but is not limited to the framework and process.
[0041] The current block can be the current coding unit (CU) or the current prediction unit (PU), etc. Due to the need for parallel processing, the image can be divided into slices, etc. Slices in the same image can be processed in parallel, that is, there is no data dependency between them. "Frame" is a commonly used term, and it can generally be understood that a frame is an image. In the embodiments of the present application, the frame can also be understood as an image or a slice, etc.
[0042] Inter-frame prediction uses temporal correlation to eliminate redundancy. To minimize visual lag, typical video frame rates range from 30, 50, 60, or even 120 frames per second. In such videos, adjacent frames within the same scene are highly correlated. Inter-frame prediction leverages this correlation to predict the current encoding content, referencing the content of previously encoded and decoded frames. Inter-frame prediction can significantly improve encoding performance.
[0043] The most basic inter-frame prediction method is translational prediction. Translational prediction assumes that the content being predicted translates between the current image and a reference image. For example, if the content of the current block (coding unit or prediction unit) translates between the current image and the reference image, a motion vector (MV) can be used to find this content in the reference image and use it as the prediction block for the current block. Translational motion is a common feature of video. Static backgrounds, objects that move in a completely translational manner, and camera pans can all be handled using translational prediction. However, some content in natural video does not simply translate; for example, translation involves subtle changes in shape and color. Bidirectional prediction uses two reference blocks from the reference image and performs a weighted average of these two blocks to produce a prediction block that is as similar as possible to the current block. For example, in certain scenes, a weighted average of two reference blocks from both the front and back of the current frame may produce a prediction block that is more similar to the current block than a single reference block. This improves compression performance over unidirectional prediction.
[0044] The POC (picture order count) can be used as an image identifier. In a video sequence, each image has a unique POC. In this article, the order of the POCs is considered to be the same as the playback order. A P-frame is an image that can only be predicted using reference images whose POCs precede the current image. The current reference image has only one reference picture list, denoted as RPL0. Here, RPL can be understood as the abbreviation for Reference Picture List. Reference picture list RPL0 contains all reference pictures whose POCs precede the current image. A B-frame is an image that can be predicted using both reference pictures whose POCs precede the current image and reference pictures whose POCs follow the current image. B-frames have two reference picture lists, denoted as RPL0 and RPL1. One configuration method is to have RPL0 contain all reference pictures whose POCs precede the current image, and RPL1 contain all reference pictures whose POCs follow the current image. For a current block, one can reference only the reference block of a certain image in RPL0 (also known as forward prediction); only the reference block of a certain image in RPL1 (also known as backward prediction); or simultaneously reference the reference block of a certain image in RPL0 and a reference block of a certain image in RPL1 (also known as bidirectional prediction). A simple method for simultaneously referencing two reference blocks is to average the pixels at each corresponding position in the two reference blocks to obtain the prediction block for the current block. Later, B-pictures no longer require that RPL0 only contain reference images with a Point of Occurrence (POC) before the current image, and RPL1 only contain reference images with a Point of Occurrence (POC) after the current image. Therefore, RPL0 can also contain reference images with a Point of Occurrence (POC) after the current image, and RPL1 can also contain reference images with a Point of Occurrence (POC) before the current image. The current block can then reference both reference images with a Point of Occurrence (POC) before the current image and reference images with a Point of Occurrence (POC) after the current image. This type of B-picture is also called a generalized B-picture.
[0045] The encoding and decoding order of the RA configuration differs from the POC order. This allows B-pictures to reference information before and after the current picture, significantly improving encoding performance. A classic RA GOP structure is shown in Figure 2.
[0046] The arrows in Figure 2 indicate reference relationships. An I-picture does not require a reference picture. After an I-picture with a POC of 0 is decoded, a P-picture with a POC of 4 is decoded. The P-picture with a POC of 4 can refer to the I-picture with a POC of 0. Then, a B-picture with a POC of 2 is decoded. The B-picture with a POC of 2 can refer to the I-picture with a POC of 0 and the P-picture with a POC of 4. ...
[0047] The encoding and decoding order of the LD (Low Delay) configuration is the same as the POC order. Therefore, the current image can only reference information before the current image. The Low Delay configuration is divided into Low Delay P and Low Delay B. Low Delay P is the traditional Low Delay configuration. Its typical structure is IPPP..., that is, an I picture is encoded and decoded first, and subsequent pictures are all P pictures. The typical structure of Low Delay B is IBBB..., which differs from Low Delay P in that each inter-frame picture is a B picture. In other words, two reference picture lists are used, and the current block can simultaneously reference the reference block of a picture in RPL0 and the reference block of a picture in RPL1.
[0048] Generally speaking, the compression efficiency of the RA configuration is higher than that of the LD configuration, and the compression efficiency of the LDB configuration is higher than that of the LDP configuration. This is partly because bidirectional prediction can refer to backward information and partly because bidirectional prediction can reduce prediction errors through some technologies, such as weighted averaging.
[0049] A reference picture list for a current image can contain a maximum of several reference pictures, such as two, three, or four. When encoding a current image, the number of reference pictures in RPL0 and RPL1 is determined by a specific configuration or algorithm and is not the focus of this disclosure. However, the same reference picture may appear in both RPL0 and RPL1. This means that the codec allows the current block to simultaneously reference two reference blocks from the same reference picture.
[0050] Codecs typically use the index value in the reference picture list to correspond to the reference picture. If a reference picture list is 4 in length, then index has four values: 0, 1, 2, and 3. For example, RPL0 of the current frame has four reference pictures with POCs 5, 4, 3, and 0. Then RPL0 index 0 is the reference picture with POC 5, RPL0 index 1 is the reference picture with POC 4, RPL0 index 2 is the reference picture with POC 3, and RPL0 index 3 is the reference picture with POC 0.
[0051] Inter-frame prediction uses motion information to represent "motion". Basic motion information includes reference picture information and motion vector (MV) information. In order for a block to use bidirectional prediction, it is naturally necessary to find two reference blocks, so two sets of reference image information and motion vector information are needed. Each of these sets can be understood as a unidirectional motion information, and combining these two sets together forms a bidirectional motion information. In specific implementation, unidirectional motion information and bidirectional motion information can use the same data structure, but the two sets of reference frame information and motion vector information of the bidirectional motion information are both valid, while one set of reference frame information and motion vector information of the unidirectional motion information is invalid. The valid can also be understood as "used", and the invalid can also be understood as "not used".
[0052] VVC supports two reference picture lists, denoted as RPL0 and RPL1. For the bidirectional motion information described above, VVC uses the reference picture index refIdxL0 corresponding to RPL0, the motion vector mvL0 corresponding to RPL0, the reference picture index refIdxL1 corresponding to RPL1, and the motion vector mvL0 corresponding to RPL1. The reference picture index corresponding to RPL0 and the reference picture index corresponding to RPL1 can be understood as the reference picture information described above. VVC uses two flags, denoted as predFlagL0 and predFlagL1, to indicate whether the motion information corresponding to RPL0 and RPL1 is used, respectively. It can also be understood that predFlagL0 and predFlagL1 indicate whether the unidirectional motion information described above is "valid." Therefore, although VVC does not explicitly mention the data structure of motion information, it uses the reference picture index, motion vector, and "validity" flag corresponding to each reference picture list to represent motion information. The VVC standard does not mention motion information, but instead uses motion vectors. The reference image index and the flag indicating whether to use the corresponding motion information can also be considered as appendages of the motion vector. In this embodiment, "motion information" is still used for ease of description, but it should be understood that "motion vectors" can also be used. "Motion information" can also be called "motion parameters."
[0053] For a two-dimensional image, a motion vector can be represented by (x, y), with a horizontal component and a vertical component. Since videos are represented in pixels, there are distances between pixels. The motion of an object in adjacent images may not always correspond to a whole-pixel distance. For example, in a distant video, the distance between two pixels is 1 meter for the distant object, while the object moves 0.5 meters between two frames. This scenario cannot be well represented using a whole-pixel motion vector. Therefore, motion vectors can be expressed at the sub-pixel level, with precision of 1 / 2, 1 / 4, 1 / 8, or 1 / 16 pixels, to represent motion more precisely. Interpolation is then used to obtain the pixel value at the sub-pixel position in the reference image.
[0054] Both the unidirectional and bidirectional predictions in the aforementioned translation prediction are block-based, such as coding units (CUs) or prediction units (PUs). This means that prediction is performed using a pixel matrix as the unit. The most basic block is a rectangular block, such as a square or rectangle. Video codec standards such as HEVC and VVC allow the encoder to determine the size and division of CUs and PUs based on the video content. Regions with simple textures or motion tend to use larger blocks, while regions with complex textures or motion tend to use smaller blocks. The deeper the block division level, the more complex the blocks that more closely resemble the actual texture or motion, but the corresponding overhead for representing these divisions increases. Motion information may also need to be transmitted in the bitstream. Furthermore, generally, the finer the block division, the greater the motion information overhead.
[0055] The most primitive method of representing motion information directly writes the complete motion information. Later, experts discovered that motion vectors can be represented using motion vector prediction (MVP) and motion vector difference (MVD), where MV = MVP + MVD. The more accurate the MVP, the smaller the MVD, which in turn reduces the bitstream overhead.
[0056] It's understandable that every inter-coded block requires motion information. To simplify matters, we assume that CU division equals PU division equals TU division, meaning that each coding unit has a prediction unit (PU) and a transform unit (TU) of the same size and position. In reality, with more flexible CU division, VVC tends to decouple PU and TU from HEVC. Differences in any of the steps involved in prediction, transform, quantization, and entropy coding can lead to CU division. For example, if two regions have different motion information, the encoder may divide them into different CUs. Alternatively, if two regions have identical or similar motion information but significantly different residual characteristics, the encoder may also divide them into different CUs. The division method is determined based on overall compression efficiency, not solely on a single factor. Consequently, the same object or regions with identical or similar motion may be divided into different CUs.
[0057] Figure 3 is an example in HEVC. Figure a is the original image, in which an iron rod moves in the direction indicated by the arrow, and the background area moves less. Figure b shows the block division of HEVC, and Figure c removes the boundaries of the blocks with the same motion information in Figure b. It can be seen that many adjacent blocks use the same motion information. In this case, if the motion information is encoded separately for each block, it will result in obvious waste. The complete motion information of VVC mentioned above includes the reference image index, MV and the flag of whether it is used for RPL0, and the reference image index, MV and the flag of whether it is used for RPL1. The basic principle of the merge mode is that the current block can inherit the motion information of the adjacent blocks, including the reference image information and motion vector information.
[0058] Merge mode can build a merge candidate list. If the current block uses merge mode, an index can be used to indicate which motion information to merge with the current block, eliminating the need to encode the complete motion information. When building the merge candidate list, motion information of spatially adjacent blocks of the current block, motion information in the temporal domain, motion information of non-adjacent blocks in the spatial domain, motion information of non-adjacent blocks in the temporal domain, historical motion information, and synthesized motion information can be included.
[0059] The spatially adjacent blocks refer to blocks adjacent to the current block in the same image, and the spatially non-adjacent blocks refer to blocks not adjacent to the current block in the same image. The temporal motion information and the temporal non-adjacent blocks motion information refer to motion information at a specified position on the collocated reference image. An example is shown in FIG4 , where the gray block is the current block, and positions 1, 2, 3, 4, and 5 are the positions of the spatially adjacent blocks used in the Merge mode, and the others are The position of non-adjacent blocks in the spatial domain used by the Merge mode. Position 6 is the position used for motion information in the temporal domain. If the corresponding position of the lower right corner of the current block is not available, the position corresponding to the center of the current block is used. Other The position is the position used for the motion information of non-adjacent blocks in the time domain. The temporal motion information is derived based on the motion information at the corresponding position of the co-located reference image. The specific derivation method is described below.
[0060] Historical motion information is independent of position. The codec maintains a first-in, first-out list of motion information. Each time a block is encoded or decoded, the codec updates the list with the motion information of that block, ensuring that there is no duplication with existing motion information in the list. Historical motion information is obtained from this list.
[0061] Temporal motion information (vector) prediction is used to complement spatial motion information prediction. Generally speaking, the correlation between adjacent regions within the same image is stronger than that between regions in different images. However, there are also cases where temporal motion information is more useful. For example, if the current block and its neighboring blocks in the current image belong to different objects and have distinct motions, the motion of a block in a reference image that belongs to the same object as the current block can provide a better motion prediction for the current block.
[0062] As shown in Figure 5, the motion vector of the co-located block in the co-located reference image (here we call the block that obtains temporal motion information the co-located block) is the vector from the co-located reference image col_pic to the co-located block's reference image col_ref. For the current block, the required motion vector is the vector from the current image curr_pic to the current block's reference image curr_ref. Let the POC distance between col_pic and col_ref be td, and the POC distance between curr_pic and curr_ref be tb. Assuming that the motion from the co-located block to the current block is constant, the scaling factor can be determined based on td and tb. Let the motion vector of the co-located block be (col_mv_x, col_mv_y). Then, the temporal motion vector prediction (tmvp_x, tmvp_y) can be derived as follows: tmvp_x = col_mv_x * tb / td, and tmvp_y = col_mv_y * tb / td.
[0063] In VVC, the smallest unit for storing motion information in a co-located reference image is 4x4. This means that each 4x4 sub-block stores a set of motion information. It's understandable that, if hardware implementation costs are not considered, a co-located reference image can also store a set of motion information per pixel.
[0064] Merge mode directly uses the motion information in the merge candidate list selected as the motion information of the current block. In actual videos, there may be some differences between the actual motion vector of the current block and the motion vector in the selected merge candidate list. MMVD (Merge mode with MVD) is a special merge mode in VVC, which uses an efficient method to encode the MVD in this case. Ordinary Merge does not require encoding and decoding MVD (motion vector difference). Ordinary inter mode requires direct encoding and decoding of MVD. MMVD takes advantage of the fact that MVD is more distributed in a single horizontal direction or a single vertical direction, with more MVD for smaller values and fewer MVD for larger values, as shown in Figure 6.
[0065] MMVD can only represent MVDs of specific values in certain directions, and it cannot represent any MVD. It uses mmvd_direction_idx to represent the direction of the MVD, which can also be understood as whether the x and y values of the MVD are non-zero and their positive and negative signs. mmvd_distance_idx represents the absolute value of the non-zero x and y values of the MVD, MmvdDistance. The relationship between mmvd_distance_idx[x0][y0] and MmvdDistance[x0][y0] is shown in the following table:
[0066] Among them, ph_mmvd_fullpel_only_flag is an image header flag that can set 2 different combinations of MMVD.
[0067] The relationship between mmvd_direction_idx[x0][y0] and MmvdSign[x0][y0] is shown in the following table:
[0068] The MVD of MMVD is obtained as follows: MmvdOffset[x0][y0][0] = (MmvdDistance[x0][y0] << 2) * MmvdSign[x0][y0][0] MmvdOffset[x0][y0][1] = (MmvdDistance[x0][y0] << 2) * MmvdSign[x0][y0][1]
[0069] The bitrate of general consumer video is limited, so video compression typically seeks a compromise between bitrate overhead and distortion. Taking block partitioning as an example, for the same content, within a certain range, finer the partitioning, the higher the overhead and lower the distortion; coarser the partitioning, the lower the overhead and higher the distortion. Taking motion information encoding as an example, for the same content, within a certain range, more precise motion information leads to higher overhead and lower distortion; coarser motion information leads to lower overhead and higher distortion. Some decoder-side methods utilize decoder-side information for processing and calculation without incurring overhead, thereby improving motion information, enhancing prediction, and reducing distortion. This overhead-free approach means that the encoder does not need to provide instructions based on the original image; processing is performed automatically based on available information. Two typical decoder-side methods in VVC are decoder-side motion vector refinement (DMVR) and bi-directional optical flow (BDOF).
[0070] One condition for starting DMVR in VVC is that the two reference images of the current block come from the front and back of the current image respectively, and the distance between the two reference images and the current image is equal. Another starting condition is that the current CU uses the whole-block merge mode (including skip), which does not include sub-block-based merges such as SbTMVP and affine merge, because the motion vector in the merge mode is prone to inaccuracy. There are some other conditions that are not repeated here. DMVR in VVC uses bilateral matching BM (bilateral matching), which is to calculate the matching cost for the reference blocks on both sides, such as calculating the SAD (sum of absolute difference) or SATD (sum of absolute transformed difference) between the two reference blocks. DMVR searches for the matching cost of the MVs around the original MV. When moving, the MVs of the two reference images are moved in a mirrored manner, that is, the MVs are moved on the basis of their respective original MVs. diff , move the other side - MV diff , as shown in Figure 7. Assume that the motion vector of the original MV corresponding to RPL0 is MV0, the motion vector corresponding to RPL1 is MV1, and the motion vectors after search or improvement are MV′0 and MV′1 respectively. This search method is later called the mirror search method. MV′0=MV0+MV diff MV′1=MV1-MV diff
[0071] The search also supports sub-pixel search, so DMVR may find an MV with higher accuracy than the original MV. The search is performed according to certain rules. Generally, the integer pixel MV within a certain range is searched first to find the integer pixel MV with the lowest matching cost, and then the sub-pixel MV is searched based on the integer pixel MV. If an MV with a lower matching cost than the original MV is found, the MV with the lower matching cost is used for motion compensation prediction. It is also possible to search the integer pixel MVD first to find the integer pixel MVD with the lowest matching cost, and then search the sub-pixel MVD based on the integer pixel MVD. If an MV with a lower matching cost than the original MV is found, the MV with the lower matching cost is used for motion compensation prediction. If the original MV is sub-pixel, then the new MV when searching the integer pixel MVD is also sub-pixel.
[0072] In theory, the MV improved by DMVR can be used to store MV and surrounding blocks. For example, when building a merge candidate list for the current block, if the surrounding blocks have improved the MV using DMVR, using the improved MV to build the merge candidate list can achieve better compression effect. However, due to hardware implementation considerations, VVC does not do this.
[0073] DMVR can be processed on a sub-block basis. In fact, in VVC, if the horizontal or vertical size of a block is larger than 16 pixels, it will be divided into sub-blocks of 16 pixels. This is partly due to the complexity of hardware implementation, because DMVR needs to be searched at the decoding end, and limiting the size of sub-blocks can reduce the cost of caching. On the other hand, dividing the processing into sub-blocks provides better flexibility. Each sub-block can independently improve the MV, which to a certain extent achieves the effect of improving the division accuracy, which also improves the compression efficiency.
[0074] Bidirectional optical flow (BDOF) is also a typical decoder-side method. As its name suggests, BDOF improves MV and prediction based on the principles of optical flow. Optical flow is the instantaneous velocity of pixels moving across the observation imaging plane for a moving object. Optical flow has some basic assumptions, such as constant brightness, meaning that the brightness of the same target does not change when it moves between different images. It also assumes that the target's position is constant, or that the target's motion is small. This means that changes in time do not cause drastic changes in the target's position.
[0075] A condition for starting BDOF in VVC is that the two reference images of the current block come from the previous and next images respectively, and the distance between the two reference images and the current image is equal. For each 4x4 sub-block, VVC will derive a motion vector deviation (v x ,v y), which is calculated by minimizing the difference between the predicted values in the two directions. This motion vector deviation is also used to adjust the predicted value in the corresponding sub-block. The derivation process is as follows:
[0076] First, calculate the horizontal and vertical gradients of the two prediction blocks and
[0077] Among them I (k) (i, j) is the predicted value of the coordinate (i, j) in the reference image list k, k = 0, 1, and shift1 is calculated according to the bit depth bitDepth of the brightness, shift1 = max(6, bitDepth-6).
[0078] S1, S2, S3, S5 and S6 are calculated as follows:
[0079] S1=∑ (i,j)∈Ω ABs(ψ x (i,j)),S3=∑ (i,j)∈Ω θ(i,j)·Sign(ψ x (i,j))
[0080] S5=∑ (i,j)∈Ω Abs(ψ y (i,j)),S6=∑ (i,j)∈Ω θ(i,j)·Sign(ψ y (i,j))
[0081] in θ(i,j)=(I (1) (i,j)>>n b )-(I (0) (i,j)>>n b )
[0082] Where Ω is a 6x6 window around the current 4x4 sub-block, n a is min(1,bitDepth-11), n b is min(4,bitDepth-8).
[0083] Motion vector deviation (v x ,v y ) is calculated as follows:
[0084] in th′ BIO=2max(5,BD-7). is rounded down,
[0085] Based on the motion vector deviation and gradient, each prediction value within the 4x4 sub-block is adjusted as follows:
[0086] The final predicted value of BDOF is calculated as follows: pred BDOF (x,y)=(I (0) (x,y)+I (1) (x,y)+b(x,y)+o offset )>>shift
[0087] Where Ooffset and shift are calculated based on the bit depth of brightness. a , n b Both scalar and shift are processed to reduce the bit width during the calculation process.
[0088] The motion vector deviation of BDOF can achieve high precision, making the prediction more accurate, and the sub-block-based processing also improves flexibility. These two aspects are similar to DMVR.
[0089] Multi-pass decoder-side motion vector refinement (DMVR) and BDOF both improve motion vectors. DMVR is based on block matching, while BDOF is based on optical flow. They can be used in combination. An example is shown below, which can be called multi-pass decoder-side motion vector refinement (MDMVR).
[0090] The first step is motion vector improvement based on bidirectional matching of the entire block.
[0091] The second step is to improve the motion vector based on bidirectional matching of sub-blocks. The block size of this step can be 16x16.
[0092] The third step is to improve the motion vector based on the bidirectional optical flow of the sub-block. The sub-block size in this step can be 8x8.
[0093] Of course, we can further enrich the steps on this basis, such as a fourth step, motion vector improvement based on bidirectional optical flow of 4x4 sub-blocks, or a motion vector improvement based on bidirectional optical flow of points.
[0094] The subsequent steps use the MV improved in the previous step as the initial MV for improvement.
[0095] The template matching (TM) method was first used in inter-frame prediction. As shown in Figure 8, it leverages the correlation between adjacent pixels and uses areas surrounding the current block as templates. When the current block is encoded or decoded, its left and upper sides have already been encoded and decoded according to the coding order. However, hardware decoder implementations cannot guarantee that the left and upper sides have already been decoded when decoding begins. This refers to inter-frame blocks. For example, in HEVC, the prediction process for inter-frame coded blocks does not require surrounding reconstructed pixels, allowing the prediction process for inter-frame blocks to proceed in parallel. However, intra-frame coded blocks must use reconstructed pixels on the left and upper sides as reference pixels. Theoretically, the left and upper sides are available, meaning that they can be implemented with appropriate hardware design adjustments. However, the right and lower sides are unavailable under the VVC coding order.
[0096] As shown in Figure 8, the rectangular areas to the left and above the current block are used as templates. The height of the left template portion is generally the same as the height of the current block, and the width of the upper template portion is generally the same as the width of the current block, but they can also be different. The best matching position of the template is found in the reference image to determine the motion information, or motion vector, of the current block. This process can be roughly described as starting from a starting position in a reference image and searching within a certain range around it. Search rules, such as the search range and search step size, can be predefined. At each position, the degree of match between the template corresponding to that position and the templates surrounding the current block is calculated. The degree of match can be measured using distortion costs, such as SAD (sum of absolute difference) or SATD (sum of absolute transformed difference). SATD generally uses transforms such as the Hadamard transform and MSE (mean-square error). Smaller values of SAD, SATD, and MSE indicate a higher degree of match. The cost is calculated using the predicted block of the template corresponding to that position and the reconstructed blocks of the templates surrounding the current block. In addition to searching at whole-pixel positions, sub-pixel positions can also be searched. The motion information for the current block is determined based on the position with the highest degree of match. By leveraging the correlation between adjacent pixels, motion information that is appropriate for the template may also be appropriate for the current block. Of course, template matching may not be applicable to all blocks. Therefore, methods can be used to determine whether to use the template matching method for the current block, such as using a control switch to indicate whether template matching is used for the current block. This template matching method is called DMVD (decoder-side motion vector derivation). Both the encoder and decoder can use the template to search to derive motion information or find better motion information based on the existing motion information. This method does not require the transmission of specific motion vectors or motion vector differences. Instead, both the encoder and decoder perform the same search rules to ensure consistent encoding and decoding. Template matching can improve compression performance, but it requires a "search" on the decoder side, which introduces a certain degree of decoding complexity.
[0097] TM can be used to improve the motion vectors of bidirectionally predicted blocks. This means improving bidirectional motion information. TM in ECM uses the following process to improve bidirectional motion information:
[0098] The first step is to use TM to improve MV0 corresponding to RPL0. When calculating the matching cost, the template of the reference block located by MV0 is compared with the template of the current block. The minimum cost minCost0 is recorded during this process.
[0099] In the second step, TM is used to improve MV1 corresponding to RPL1. When calculating the matching cost, the template of the reference block located by MV1 is compared with the template of the current block. The minimum cost minCost1 is recorded during this process.
[0100] The third step is to compare minCost0 and minCost1. The reference direction of the larger one is X, where X is 0 or 1. The reference direction of the smaller one is 1-X. TM is used again to improve the MV corresponding to RPLX. x , this time the improvement is to use MV when calculating the matching cost x The template of the reference block is compared with the template of the modified current block. One possible method is to modify the value of each position in the template of the current block to be equal to 2 times the value of the corresponding position of the template of the current block minus the latest MV 1-x The value of the corresponding position of the template of the located reference block.
[0101] That is to say, TM first improves the MV of the two reference directions separately, corresponding to the first and second steps above. Then it uses the modified template to improve the direction with poor matching again. The first and second steps are independent of each other and the order is not important. The third step improves the MV corresponding to RPLX. x After that, one method is to have a fourth step to improve the MV corresponding to RPL(1-X) 1-x The improvement in the fourth step is similar to that in the third step, except that X and 1-X are swapped.
[0102] Each search step can have a specified search range and order. For example, the entire search range can be searched from the starting MV inward and outward. Alternatively, a 3x3 MV region can be searched from the starting MV inward, followed by another 3x3 MV region from the MV with the lowest cost, and this can be repeated several times. Step 3 can also be repeated after step 4, and so on.
[0103] This search method is referred to as a one-way plus iterative search method. Each search step focuses on a single reference direction, making it a one-way search method. After optimizing two one-way directions, at least one of them must be optimized again, making it an iterative search method.
[0104] Both BM and TM improve MV through block matching, that is, they rely on the degree of matching of pixel values to judge the quality of MV, but when the degree of matching is the same or very close, they usually tend to choose MV that is closer to the original MV. Therefore, the matching cost can also be replaced by a comprehensive matching cost, which includes both the SAD or SATD of pixel matching and the cost of motion vector (difference). For example, let the comprehensive matching cost be cost, cost = SAD + costMV. All the matching costs or costs used in the above search process can be replaced by the comprehensive matching cost. Among them, costMV can be calculated using a linear function, piecewise function or nonlinear function of the motion vector difference.
[0105] However, when DMVR applies BM to perform MV search, the MVs of the two prediction directions are moved simultaneously, and the MVs of the two reference images are moved in a mirrored manner, that is, the MVs are moved on the basis of their respective original MVs. diff , move the other side - MV diff . This operation is based on the assumption that the content of the current block is moving in a straight line at a uniform speed during the period between the two reference images. Of course, this assumption is applicable in many cases. However, the motion in nature is complex, and if the interval between the two reference images is relatively long, it cannot be simply attributed to an instant. Data shows that a certain proportion of the motion between the two reference images is not a uniform linear motion. Both the speed and direction of the motion may change. When the motion vector is not accurate enough, DMVR can compensate for small motion vector differences through BM. If the object moves in a straight line at a uniform speed between the two reference images, then the improved matching block is theoretically the block where the current block wants to be. However, if the object does not move in a straight line at a uniform speed between the two reference images, then the improved matching block is theoretically the ideal position of the current block, which is deviated. One of the drawbacks of DMVR is that it cannot accurately "locate" the reference block.
[0106] TM can be said to have a certain "positioning" function, improving the MV based on the degree of template matching. The template is not the current block, so it actually "locates" the current block based on information surrounding the current block. However, TM's limitation is that it lacks information about the current block's interior and can only determine that the best template match position should be the best position of the reference block.
[0107] Based on the above analysis, an embodiment of the present application provides an encoding method, which is applied to an encoder. FIG9 is a schematic diagram of an implementation flow of the encoding method provided in an embodiment of the present application. As shown in FIG9 , the method includes the following steps 901 to 905:
[0108] Step 901, determining a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block;
[0109] Step 902: determining a second difference in sample values between the template of the current block and the template of the first reference block;
[0110] Step 903: determining a third difference in sample values between the template of the current block and the template of the second reference block;
[0111] Step 904: Perform motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block;
[0112] Step 905: Perform motion compensation on the current block according to the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
[0113] For example, in some embodiments, based on the first prediction MV, a reference block corresponding to the current block is found from the reference image pointed to, and based on the second prediction MV, a reference block corresponding to the current block is found from the executed reference image; the reconstructed value of the reference block pointed to by the first prediction MV and the reconstructed value of the reference block pointed to by the second prediction MV are weighted averaged to obtain the predicted block of the current block, that is, the predicted value of the current block. Compared with unidirectional inter-frame prediction, this bidirectional inter-frame prediction method further improves video compression performance, that is, improves the inter-frame prediction accuracy of the current block, which is beneficial to saving codeword overhead.
[0114] It should be noted that the encoder and decoder use the same operation to obtain the prediction block of the current block, so both the encoder and decoder need to perform the operation shown in FIG9 .
[0115] It can be understood that in the embodiment of the present application, when performing motion estimation on the current block, not only the second difference in sample values between the template of the current block and the template of the first reference block pointed to by the first candidate MV and the third difference in sample values between the template of the current block and the template of the second reference block pointed to by the second candidate MV are used, but also the first difference in sample values between the first reference block pointed to by the first candidate MV of the current block and the second reference block pointed to by the second candidate MV of the current block are combined; this is beneficial to improving the accuracy of motion estimation of the current block, that is, improving the accuracy of the first predicted MV and the second predicted MV of the current block, thereby improving the inter-frame prediction accuracy of the current block and enhancing video encoding and decoding performance.
[0116] In some embodiments, the encoding method further includes: determining a residual block of the current block according to an original block of the current block and a predicted block of the current block; and generating a code stream according to the residual block of the current block.
[0117] The following describes further optional implementations and related terms of each of the above steps.
[0118] In step 901 , a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block is determined.
[0119] In some embodiments, the codec may determine a first difference between a reconstructed value of a first reference block and a reconstructed value of a second reference block.
[0120] Exemplarily, in some embodiments, the first difference can be determined based on SAD (sum of absolute difference), SSE (Sum of Squares due to Error), SATD (sum of absolute transformed difference) or MSE (mean-square error), etc., which are determined based on the reconstructed value of the first reference block and the reconstructed value of the second reference block.
[0121] In step 902, a second difference in sample values between the template of the current block and the template of the first reference block is determined.
[0122] In some embodiments, the codec may determine a second difference between the reconstructed value of the template of the current block and the reconstructed value of the template of the first reference block.
[0123] Exemplarily, in some embodiments, the second difference value can be determined based on SAD (sum of absolute difference), SSE (Sum of Squares due to Error), SATD (sum of absolute transformed difference) or MSE (mean-square error), etc., which are determined based on the reconstructed value of the template of the current block and the reconstructed value of the template of the first reference block.
[0124] It can be understood that when determining the second difference, the position of the template of the current block relative to the current block is consistent with the position of the template of the first reference block relative to the template of the first reference block. For example, if the template of the current block includes the left adjacent area of the current block, the template of the first reference block also includes the left adjacent area of the first reference block; for another example, if the template of the current block includes the upper adjacent area of the current block, the template of the first reference block also includes the upper adjacent area of the first reference block; for another example, if the template of the current block includes the upper adjacent area and the left adjacent area of the current block, the template of the first reference block also includes the upper adjacent area and the left adjacent area of the first reference block.
[0125] In step 903 , a third difference in sample values between the template of the current block and the template of the second reference block is determined.
[0126] In some embodiments, the codec may determine a third difference between the reconstructed values of the template of the current block and the template of the second reference block.
[0127] Exemplarily, in some embodiments, the third difference value may be determined based on SAD (sum of absolute difference), SSE (Sum of Squares due to Error), SATD (sum of absolute transformed difference) or MSE (mean-square error), etc., which are determined based on the reconstructed value of the template of the current block and the reconstructed value of the template of the second reference block.
[0128] Similarly, when determining the third difference, the position of the template of the current block relative to the current block is consistent with the position of the template of the second reference block relative to the template of the second reference block. For example, the template of the current block includes the left adjacent area of the current block, and the template of the first reference block also includes the left adjacent area of the first reference block; for another example, the template of the current block includes the upper adjacent area of the current block, and the template of the first reference block also includes the upper adjacent area of the first reference block; for another example, the template of the current block includes the upper adjacent area and the left adjacent area of the current block, and the template of the first reference block also includes the upper adjacent area and the left adjacent area of the first reference block.
[0129] In the embodiment of the present application, whether it is the template of the current block or the template of the reference block, there is no limitation on which position of the adjacent block the template of the block is, and it can include any reconstructed pixels adjacent to the block.
[0130] For example, in some embodiments, the template of a block may include at least one of the following:
[0131] The upper neighboring pixel of the block;
[0132] The upper left neighboring pixel of the block;
[0133] The upper right neighboring pixel of the block;
[0134] The left neighboring pixel of the block;
[0135] The upper left neighboring pixel of the block;
[0136] The lower left neighboring pixel of the block.
[0137] In step 904, motion estimation is performed on the current block at least based on the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block.
[0138] The codec may implement step 904 by any one of the following embodiments 1-3. These embodiments are described below.
[0139] Regarding Example 1:
[0140] In some embodiments, as shown in FIG10 , the encoder or decoder may implement step 904 through steps 1001 to 1003 as follows:
[0141] Step 1001: Determine a first matching cost based on at least the first difference, the second difference, and the third difference, where the first matching cost represents a degree of matching between the first reference block and the second reference block and the current block.
[0142] In a possible implementation, the encoder or decoder may implement step 1001 as follows: determining a first matching cost according to the first difference, the second difference, and the third difference.
[0143] For example, in some embodiments, the encoder or decoder may determine the first matching cost cost according to the following formula: cost=costBM+costTM0+costTM1
[0144] Here, costBM represents the first difference, costTM0 represents the second difference, and costTM1 represents the third difference.
[0145] For example, in some other embodiments, the encoder or decoder may also determine the first matching cost as follows: determine a first weighting coefficient of the first difference, a second weighting coefficient of the second difference, and a third weighting coefficient of the third difference; and weight the first difference, the second difference, and the third difference according to the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the first matching cost.
[0146] Exemplarily, the encoder or decoder may determine the first matching cost cost according to the following formula: cost=factorBM*costBM+factorTM0*costTM0+factorTM1*costTM1
[0147] Among them, factorBM represents the first weighting coefficient, factorTM0 represents the second weighting coefficient, and factorTM1 represents the third weighting coefficient.
[0148] Among them, the first weighting coefficient, the second weighting coefficient and the third weighting coefficient can be preset values, or values related to the size of the current block or the size of the template of the current block, that is, the encoder or decoder can determine the first weighting coefficient to the third weighting coefficient based on the size of the current block or the template of the current block.
[0149] For example, the first weighting coefficient is equal to the number of samples of the template of the current block, the second weighting coefficient is equal to the number of samples of the current block, and the third weighting coefficient is equal to the number of samples of the current block.
[0150] In another possible implementation, the encoder or decoder determines the first matching cost not only based on the first difference, the second difference, and the third difference, but also based on the first MVD of the first candidate MV and the second MVD of the second candidate MV. That is, the encoder or decoder may also implement step 1001 as follows: determine the first MVD of the first candidate MV and the second MVD of the second candidate MV; and determine the first matching cost based on the first difference, the second difference, the third difference, the first MVD, and the second MVD.
[0151] For example, in some embodiments, the encoder or decoder may determine the first matching cost cost according to the following formula: cost=costBM+costTM0+costTM1+costMV0+costMV1
[0152] Here, costBM represents the first difference, costTM0 represents the second difference, costTM1 represents the third difference, costMV0 represents the first MVD of the first candidate MV, and costMV1 represents the second MVD of the second candidate MV.
[0153] For example, in some other embodiments, the encoder or decoder may also determine the first matching cost as follows: determine the first weighting coefficient of the first difference, the second weighting coefficient of the second difference, the third weighting coefficient of the third difference, the fourth weighting coefficient of the first MVD and the fifth weighting coefficient of the second MVD; weight the first difference, the second difference, the third difference, the first MVD and the second MVD according to the first weighting coefficient, the second weighting coefficient, the third weighting coefficient, the fourth weighting coefficient and the fifth weighting coefficient to obtain the first matching cost.
[0154] Exemplarily, the encoder or decoder may determine the first matching cost cost according to the following formula: cost=factorBM*costBM+factorTM0*costTM0+factorTM1*costTM1+factorMV0*costMV0+factorMV1*costMV1
[0155] Among them, factorBM represents the first weighting coefficient, factorTM0 represents the second weighting coefficient, factorTM1 represents the third weighting coefficient, factorMV0 represents the fourth weighting coefficient, and factorMV1 represents the fifth weighting coefficient.
[0156] Step 1002: Starting from the first candidate MV and the second candidate MV, a first search process is performed to obtain a new first matching cost.
[0157] The encoder or decoder can search the first reference image pointed to by the first candidate MV and the second reference image pointed to by the second candidate MV according to the predefined MV search rule. For example, the first search process according to the predefined MV search rule includes: starting from the first candidate MV and using the first step length as the search step length, searching in the first direction to obtain a new first candidate MV; and starting from the second candidate MV and using the first step length as the search step length, searching in the second direction to obtain a new second candidate MV; and determining a new first matching cost based on the new first candidate MV and the new second candidate MV; wherein the first direction and the second direction are in a mirror image relationship.
[0158] It can be understood that determining the new first matching cost based on the new first candidate MV and the new second candidate MV means: determining a new first difference based on the sample values between the new first reference block pointed to by the new first candidate MV and the new second reference block pointed to by the new second candidate MV; and determining the new second difference by determining the sample values between the template of the current block and the template of the new first reference block pointed to by the new first candidate MV; and determining the new third difference by determining the sample values between the template of the current block and the template of the new second reference block pointed to by the new second candidate MV; and determining the new first matching cost based on at least the new first difference, the new second difference and the new third difference.
[0159] Step 1003: Determine the first predicted MV and the second predicted MV based on at least the two obtained first matching costs.
[0160] It is understandable that after the encoder or decoder performs the first search process, the new first matching cost obtained may not be the final desired matching cost. For example, in some embodiments, the encoder or decoder can implement step 1003 as follows:
[0161] When the first search cutoff condition is met, determining the first predicted MV and the second predicted MV according to the two obtained first matching costs;
[0162] When the first search cutoff condition is not met, the first search process is iterated with the new first candidate MV and the new second candidate MV as starting points until the first search cutoff condition is met, and the first predicted MV and the second predicted MV are determined based on the multiple first matching costs obtained.
[0163] Exemplarily, the first search cutoff condition may be that the number of first matching costs reaches a quantity threshold; or, the first search cutoff condition may be that the minimum value of the currently obtained first matching costs is less than or equal to the first cost threshold.
[0164] Exemplarily, in some embodiments, the first predicted MV is equal to the MV corresponding to the minimum first matching cost among the obtained first matching costs; the second predicted MV is equal to the MV corresponding to the minimum first matching cost.
[0165] Regarding Example 2:
[0166] It can be understood that in embodiment 1, the first predicted MV and the second predicted MV are determined by bidirectional synchronous search. In embodiment 2, another search method will be described, that is, determining the first predicted MV and the second predicted MV by unidirectional search.
[0167] Specifically, in some embodiments, as shown in FIG11 , the encoder or decoder may implement the step 904 of performing motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block through the following steps 1101 to 1104:
[0168] Step 1101: Determine a second matching cost based on at least the first difference and the second difference, where the second matching cost represents a degree of matching between the first reference block and the current block.
[0169] In a possible implementation, the encoder or decoder may implement step 1101 as follows: determining a second matching cost according to the first difference and the second difference.
[0170] For example, in some embodiments, the encoder or decoder may determine the second matching cost cost according to the following formula: cost=costBM+costTM0
[0171] Here, costBM represents the first difference, and costTM0 represents the second difference.
[0172] For example, in some other embodiments, the encoder or decoder may also implement step 1101 as follows: determine a first weighting coefficient for the first difference and a second weighting coefficient for the second difference; and weight the first difference and the second difference according to the first weighting coefficient and the second weighting coefficient to obtain the second matching cost.
[0173] Exemplarily, the encoder or decoder may determine the second matching cost cost according to the following formula: cost=factorBM*costBM+factorTM0*costTM0
[0174] Among them, factorBM represents the first weighting coefficient, and factorTM0 represents the second weighting coefficient.
[0175] Among them, the first weighting coefficient and the second weighting coefficient can be preset values, or values related to the size of the current block or the size of the template of the current block, that is, the encoder or decoder can determine the first weighting coefficient to the second weighting coefficient based on the size of the current block or the template of the current block.
[0176] For example, the first weighting coefficient is equal to the number of samples of the template of the current block, and the second weighting coefficient is equal to the number of samples of the current block.
[0177] In another possible implementation, the encoder or decoder determines the second matching cost not only based on the first difference and the second difference, but also based on the first MVD of the first candidate MV. That is, the encoder or decoder may also implement step 1101 as follows: determine the first MVD of the first candidate MV; and determine the second matching cost based on the first difference, the second difference, and the first MVD.
[0178] For example, in some embodiments, the encoder or decoder may determine the second matching cost cost according to the following formula: cost=costBM+costTM0+costMV0
[0179] Here, costBM represents the first difference, costTM0 represents the second difference, and costMV0 represents the first MVD of the first candidate MV.
[0180] For example, in some other embodiments, the encoder or decoder may also determine the first matching cost as follows: determine a first weighting coefficient of the first difference, a second weighting coefficient of the second difference, and a fourth weighting coefficient of the first MVD; weight the first difference, the second difference, and the first MVD according to the first weighting coefficient, the second weighting coefficient, and the fourth weighting coefficient to obtain the second matching cost.
[0181] Exemplarily, the encoder or decoder may determine the second matching cost cost according to the following formula: cost=factorBM*costBM+factorTM0*costTM0+factorMV0*costMV0
[0182] Among them, factorBM represents the first weighting coefficient, factorTM0 represents the second weighting coefficient, and factorMV0 represents the fourth weighting coefficient.
[0183] Step 1102, starting from the first candidate MV, performing a second search process to obtain a new second matching cost; wherein, the second search process includes: starting from the first candidate MV, using the second step length as the search step length, searching in the first direction to obtain a new first candidate MV; and determining a new second matching cost based on the second candidate MV and the new first candidate MV.
[0184] It can be understood that determining a new second matching cost based on the second candidate MV and the new first candidate MV includes: determining a new first difference based on sample values between the new first reference block pointed to by the new first candidate MV and the second reference block pointed to by the second candidate MV; and determining a new second difference based on sample values between the template of the current block and the template of the new first reference block pointed to by the new first candidate MV; and determining a new second matching cost based on at least the new first difference and the new second difference. In other words, determining the new second matching cost is implemented in the same manner as step 1101.
[0185] It can be understood that step 1102 describes a one-way search, that is, during a search process, one of the MVs in the two reference directions changes and the other remains unchanged, which means that during a search process, the value of one of the second difference and the third difference will not change.
[0186] Step 1103, determine whether the second search cutoff condition is met; if the second search cutoff condition is not met, take the new first candidate MV as the starting point, return to step 1102, and iterate the second search process until the second search cutoff condition is met; if the second search cutoff condition is met, execute step 1104.
[0187] Exemplarily, the second search cutoff condition may be that the number of second matching costs reaches a quantity threshold; or, the second search cutoff condition may be that the minimum value of the currently obtained second matching costs is less than or equal to the second cost threshold.
[0188] Step 1104: Determine the first predicted MV and the second predicted MV based on at least the obtained multiple second matching costs and the third difference.
[0189] Furthermore, in some embodiments, based on the search results of step 1103, a prediction MV in another direction may be further searched. That is, the encoder or decoder may implement step 1104 as follows:
[0190] The first candidate MV corresponding to the minimum second matching cost among the obtained multiple second matching costs is used as the third candidate MV;
[0191] Determine a fourth difference in sample values between a third reference block pointed to by the third candidate MV and a second reference block pointed to by the second candidate MV;
[0192] determining a third matching cost based at least on the fourth difference and the third difference, wherein the third matching cost represents a degree of matching between the second reference block and the current block;
[0193] Taking the second candidate MV as the starting point, a third search process is performed to obtain a new third matching cost; wherein, the third search process includes: taking the second candidate MV as the starting point and the third step length as the search step length, searching in the second direction to obtain a new second candidate MV; and determining a new third matching cost based on the third candidate MV and the new second candidate MV; when the third search cutoff condition is not satisfied, taking the new second candidate MV as the starting point, iteratively performing the third search process until the third search cutoff condition is satisfied; when the third search cutoff condition is satisfied, determining the first predicted MV and the second predicted MV based on the multiple third matching costs and the third candidate MV obtained.
[0194] That is, in the third search process, the third candidate MV remains unchanged, and the search is performed with the second candidate MV as the starting point.
[0195] Exemplarily, the third search cutoff condition may be that the number of third matching costs reaches a quantity threshold; or, the third search cutoff condition may be that the minimum value of the currently obtained third matching costs is less than or equal to the third cost threshold.
[0196] Exemplarily, in some embodiments, determining the first predicted MV and the second predicted MV based on the multiple third matching costs and the third candidate MV obtained includes: taking the third candidate MV as the first predicted MV; and taking the second candidate MV corresponding to the minimum third matching cost among the multiple third matching costs obtained as the second predicted MV.
[0197] In some embodiments, the second predicted MV is determined based on the multiple third matching costs and the third candidate MV obtained, including: based on determining that the second matching cost corresponding to the third candidate MV is greater than the minimum third matching cost among the multiple third matching costs obtained, the second candidate MV corresponding to the minimum third matching cost is the second predicted MV.
[0198] In some embodiments, determining the first predicted MV based on the obtained multiple third matching costs and the third candidate MV includes: determining a fifth difference in sample values between a third reference block pointed to by the third candidate MV and a fourth reference block pointed to by the second predicted MV; correcting the template of the current block based on the template of the fourth reference block to obtain a first corrected template of the current block; determining a sixth difference in sample values between the template of the third reference block and the first corrected template; determining a fourth matching cost based on at least the fifth difference and the sixth difference, the fourth matching cost representing the degree of matching between the third reference block and the current block; performing a fourth search process with the third candidate MV as the starting point to obtain a new fourth matching cost; wherein the fourth search process includes: searching in the first direction with the third candidate MV as the starting point and a fourth step size as the search step size to obtain a new third candidate MV; and determining a new fourth matching cost based on the new third candidate MV and the second predicted MV; and determining the first predicted MV based on at least the two obtained fourth matching costs.
[0199] Furthermore, in some embodiments, determining the first predicted MV based on at least the two obtained fourth matching costs includes:
[0200] When a fourth search cutoff condition is met, determining the first predicted MV according to the two obtained fourth matching costs;
[0201] When the fourth search cutoff condition is not met, the fourth search process is iterated starting from the new third candidate MV until the fourth search cutoff condition is met, and the first predicted MV is determined based on the multiple fourth matching costs obtained.
[0202] Exemplarily, the fourth search cutoff condition may be that the number of fourth matching costs reaches a quantity threshold; or, the fourth search cutoff condition may be that the minimum value of the currently obtained fourth matching costs is less than or equal to the fourth cost threshold.
[0203] Exemplarily, in some embodiments, the first predicted MV is equal to the third candidate MV corresponding to the minimum fourth matching cost among the obtained fourth matching costs.
[0204] Exemplarily, in some embodiments, the sample value at each position of the first revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the fourth reference block.
[0205] In some embodiments, determining the third matching cost based at least on the fourth difference and the third difference includes: determining a sixth weighting coefficient of the fourth difference and a third weighting coefficient of the third difference; and weighting the fourth difference and the third difference based on the sixth weighting coefficient and the third weighting coefficient to obtain the third matching cost.
[0206] In other embodiments, determining the third matching cost based on at least the fourth difference and the third difference includes: determining a second MVD of the second candidate MV; and determining the third matching cost based on the fourth difference, the third difference and the second MVD.
[0207] Further, in some embodiments, determining the third matching cost based on the fourth difference, the third difference and the second MVD includes: determining a sixth weighting coefficient of the fourth difference, a third weighting coefficient of the third difference and a fifth weighting coefficient of the second MVD; weighting the fourth difference, the third difference and the second MVD according to the sixth weighting coefficient, the third weighting coefficient and the fifth weighting coefficient to obtain the third matching cost.
[0208] In some embodiments, determining the fourth matching cost based on at least the fifth difference and the sixth difference includes: determining a third MVD of the third candidate MV; and determining the fourth matching cost based on the fifth difference, the sixth difference and the third MVD.
[0209] Further, in some embodiments, determining the fourth matching cost based on the fifth difference, the sixth difference and the third MVD includes: determining a seventh weighting coefficient of the fifth difference, an eighth weighting coefficient of the sixth difference and a ninth weighting coefficient of the third MVD; and weighting the fifth difference, the sixth difference and the third MVD according to the seventh weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient to obtain the fourth matching cost.
[0210] Regarding Example 3:
[0211] In some embodiments, as shown in FIG12 , the encoder or decoder may also implement step 904 through steps 1201 to 1204 as follows:
[0212] Step 1201: When the second difference is greater than the third difference, determine a fifth matching cost based on at least the first difference and the second difference, where the fifth matching cost represents a degree of matching between the first reference block and the current block.
[0213] In a possible implementation, the encoder or decoder may implement step 1201 as follows: determining a fifth matching cost according to the first difference and the second difference.
[0214] For example, in some embodiments, the encoder or decoder may determine the fifth matching cost cost according to the following formula: cost=costBM+costTM x
[0215] Among them, costBM represents the first difference, costTM x Indicates the larger template difference.
[0216] For example, in some other embodiments, the encoder or decoder may also implement step 1201 as follows: determine a first weighting coefficient for the first difference and a second weighting coefficient for the second difference; weight the first difference and the second difference according to the first weighting coefficient and the second weighting coefficient to obtain the fifth matching cost.
[0217] Exemplarily, the encoder or decoder may determine the fifth matching cost cost according to the following formula: cost=factorBM*costBM+factorTM x *costTM x
[0218] Among them, factorBM represents the first weighting coefficient, factorTM x represents the second weighting coefficient.
[0219] In another possible implementation, the encoder or decoder determines the fifth matching cost not only based on the first difference and the second difference, but also based on the first MVD of the first candidate MV, that is, the encoder or decoder may also implement step 1201 as follows: determine the first MVD of the first candidate MV; determine the fifth matching cost based on the first difference, the second difference and the first MVD.
[0220] For example, in some embodiments, the encoder or decoder may determine the fifth matching cost cost according to the following formula: cost=costBM+costTM x +costMV x
[0221] Among them, costBM represents the first difference, costTM x Represents the second difference, costMV x Indicates the first MVD of the first candidate MV.
[0222] For example, in some other embodiments, determining the fifth matching cost based on the first difference, the second difference and the first MVD includes: determining a first weighting coefficient of the first difference, a second weighting coefficient of the second difference and a fourth weighting coefficient of the first MVD; weighting the first difference, the second difference and the first MVD according to the first weighting coefficient, the second weighting coefficient and the fourth weighting coefficient to obtain the fifth matching cost.
[0223] Exemplarily, the encoder or decoder may determine the fifth matching cost cost according to the following formula: cost=factorBM*costBM+factorTM x *costTM x +factorMV x *costMV x
[0224] Among them, factorBM represents the first weighting coefficient, factorTM x Represents the second weighting coefficient, factorMV x represents the fourth weighting coefficient.
[0225] In some embodiments, for the first candidate MV described in step 1201, the encoder or decoder may determine it as follows: determine the seventh difference between the sample values of the template of the reference block pointed to by the first initial MV and the template of the current block; determine the sixth matching cost at least based on the seventh difference, and the sixth matching cost represents the degree of matching between the reference block pointed to by the first initial MV and the current block; perform a sixth search process with the first initial MV as the starting point to obtain a new sixth matching cost; wherein the sixth search process includes: starting from the first initial MV and using the sixth step length as the search step length, searching in the first direction to obtain a new first initial MV; and determining a new sixth matching cost based on the new first initial MV; and determining the first candidate MV based on at least the two obtained sixth matching costs.
[0226] Furthermore, in some embodiments, determining the first candidate MV based on at least the two obtained sixth matching costs includes:
[0227] When the sixth search cutoff condition is met, determining the first candidate MV according to the two obtained sixth matching costs;
[0228] When the sixth search cutoff condition is not met, the sixth search process is iterated until the sixth search cutoff condition is met, and the first candidate MV is determined based on the obtained multiple sixth matching costs.
[0229] Exemplarily, the sixth search cutoff condition may be that the number of sixth matching costs reaches a quantity threshold; or, the sixth search cutoff condition may be that the minimum value of the currently obtained sixth matching costs is less than or equal to the sixth cost threshold.
[0230] Exemplarily, in some embodiments, the first candidate MV is equal to the first initial MV corresponding to the minimum sixth matching cost among the obtained sixth matching costs.
[0231] In some embodiments, for the second difference described in step 1201, determining the second difference in sample values between the template of the current block and the template of the first reference block includes: correcting the template of the current block according to the template of the second reference block pointed to by the second candidate MV to obtain a second corrected template of the current block; and determining the second difference in sample values between the second corrected template and the template of the first reference block.
[0232] Exemplarily, in some embodiments, the sample value at each position of the second revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the second reference block.
[0233] Step 1202: Starting from the first candidate MV, a fifth search process is performed to obtain a new fifth matching cost. The fifth search process includes: starting from the first candidate MV and using the fifth step length as the search step length, searching in the first direction to obtain a new first candidate MV; and determining a new fifth matching cost based on the new first candidate MV and the second candidate MV.
[0234] Step 1203: determining the first predicted MV based on at least the two obtained fifth matching costs;
[0235] In some embodiments, the encoder or decoder may implement step 1203 as follows:
[0236] When the fifth search cutoff condition is met, determining the first predicted MV according to the two obtained fifth matching costs;
[0237] When the fifth search cutoff condition is not met, the fifth search process is iterated until the fifth search cutoff condition is met, and the first predicted MV is determined based on the obtained multiple fifth matching costs.
[0238] Exemplarily, the fifth search cutoff condition may be that the number of fifth matching costs reaches a quantity threshold; or, the fifth search cutoff condition may be that the minimum value of the currently obtained fifth matching costs is less than or equal to the fifth cost threshold.
[0239] Exemplarily, in some embodiments, the first predicted MV is equal to the first candidate MV corresponding to the minimum fifth matching cost among the obtained multiple fifth matching costs.
[0240] Step 1204: Determine the second predicted MV according to the first predicted MV and the third difference.
[0241] In some embodiments, the encoder or decoder may implement step 1204 as follows: determine the eighth difference in sample values between the fifth reference block pointed to by the first predicted MV and the second reference block pointed to by the second candidate MV; determine a seventh matching cost based at least on the eighth difference and the third difference, the seventh matching cost representing the degree of matching between the fifth reference block and the current block; perform a seventh search process starting from the second candidate MV to obtain a new seventh matching cost; wherein the seventh search process includes: starting from the second candidate MV and using the seventh step length as the search step length, searching in the second direction to obtain a new second candidate MV; and determining a new seventh matching cost based on the new second candidate MV and the first predicted MV; and determining the second predicted MV based at least on the two obtained seventh matching costs.
[0242] Furthermore, in some embodiments, determining the second predicted MV based on at least the two obtained seventh matching costs includes:
[0243] When the seventh search cutoff condition is met, determining the second predicted MV according to the two obtained seventh matching costs;
[0244] When the seventh search cutoff condition is not met, the seventh search process is iterated until the seventh search cutoff condition is met, and the second predicted MV is determined based on the obtained multiple seventh matching costs.
[0245] Exemplarily, the seventh search cutoff condition may be that the number of seventh matching costs reaches a quantity threshold; or, the seventh search cutoff condition may be that the minimum value of the currently obtained seventh matching costs is less than or equal to the seventh cost threshold.
[0246] Exemplarily, in some embodiments, the second predicted MV is equal to the second candidate MV corresponding to the minimum seventh matching cost among the obtained seventh matching costs.
[0247] In Example 3, determining a third difference in sample values between the template of the current block and the template of the second reference block includes: correcting the template of the current block according to the template of the reference block pointed to by the first predicted MV to obtain a third corrected template of the current block; and determining a third difference in sample values between the third corrected template and the template of the second reference block.
[0248] Furthermore, in some embodiments, the template of the current block is corrected according to the template of the reference block pointed to by the first prediction MV to obtain a third corrected template of the current block, including: the sample value of each position of the third corrected template is equal to 2 times the sample value of the corresponding position of the template of the current block minus the sample value of the corresponding position of the template of the reference block pointed to by the first prediction MV.
[0249] In some embodiments, determining a sixth matching cost at least based on the seventh difference includes: determining a fourth MVD of the first initial MV; and determining the sixth matching cost based on the seventh difference and the fourth MVD.
[0250] Further, in some embodiments, determining the sixth matching cost based on the seventh difference and the fourth MVD includes: determining the tenth weighting coefficient of the seventh difference and the eleventh weighting coefficient of the fourth MVD; weighting the seventh difference and the fourth MVD according to the tenth weighting coefficient and the eleventh weighting coefficient to obtain the sixth matching cost.
[0251] In some embodiments, determining the seventh matching cost based at least on the eighth difference and the third difference includes: determining a twelfth weighting coefficient of the eighth difference and a third weighting coefficient of the third difference; and weighting the eighth difference and the third difference based on the twelfth weighting coefficient and the third weighting coefficient to obtain the seventh matching cost.
[0252] In other embodiments, determining the seventh matching cost based on at least the eighth difference and the third difference includes: determining the second MVD of the second candidate MV; and determining the seventh matching cost based on the eighth difference, the third difference and the second MVD.
[0253] Further, in some embodiments, determining the seventh matching cost based on the eighth difference, the third difference and the second MVD includes: determining a twelfth weighting coefficient of the eighth difference, a third weighting coefficient of the third difference and a fifth weighting coefficient of the second MVD; weighting the eighth difference, the third difference and the second MVD according to the twelfth weighting coefficient, the third weighting coefficient and the fifth weighting coefficient to obtain the seventh matching cost.
[0254] The method for determining the above weighting coefficients is described as follows:
[0255] In some embodiments, the first to twelfth weighting coefficients are all preset values.
[0256] In some other embodiments, the method further includes: determining the first weighting coefficient, the sixth weighting coefficient, the seventh weighting coefficient and the twelfth weighting coefficient according to the size of the current block or the size of the template of the current block.
[0257] Exemplarily, in some embodiments, the first weighting coefficient is equal to the number of samples of the template of the current block; the sixth weighting coefficient is equal to the number of samples of the template of the current block; the seventh weighting coefficient is equal to the number of samples of the template of the current block; and the twelfth weighting coefficient is equal to the number of samples of the template of the current block.
[0258] In some other embodiments, the method further includes: determining the second weighting coefficient, the third weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient according to the size of the current block or the size of the template of the current block.
[0259] Exemplarily, in some embodiments, the second weighting coefficient is equal to the number of samples of the current block; the third weighting coefficient is equal to the number of samples of the current block; the eighth weighting coefficient is equal to the number of samples of the current block; and the tenth weighting coefficient is equal to the number of samples of the current block.
[0260] In some other embodiments, the method further includes: determining the fourth weighting coefficient, the fifth weighting coefficient, the ninth weighting coefficient and the eleventh weighting coefficient according to the size of the current block or the size of the template of the current block.
[0261] In some embodiments, the distances between the first reference image to which the first reference block belongs and the second reference image to which the second reference block belongs and the current image to which the current block belongs are equal or unequal.
[0262] In some embodiments, based on the relationship between the first candidate MV and the second candidate MV, it is determined whether to perform the step of performing motion estimation on the current block based on at least the first difference, the second difference and the third difference to obtain the first predicted MV and the second predicted MV of the current block.
[0263] Further, in some embodiments, when the first candidate MV is asymmetric to the second candidate MV, the step of performing motion estimation on the current block based on at least the first difference, the second difference and the third difference to obtain the first predicted MV and the second predicted MV of the current block is performed.
[0264] Exemplarily, in some embodiments, when the ratio or difference between the absolute value of the first candidate MV and the absolute value of the second candidate MV is not within the corresponding range, and / or the ratio or difference between the angle of the first candidate MV and the angle of the second candidate MV is not within the corresponding range, it is determined that the first candidate MV and the second candidate MV are asymmetric.
[0265] It should be noted that the method for determining each matching cost can be similar (the difference is that the numerical value used to calculate the matching cost may be different) or different. The matching cost can be obtained by weighted averaging the corresponding numerical values based on the weighting coefficient, or the matching cost can be obtained by directly adding up the numerical values used to calculate the matching cost.
[0266] The embodiment of the present application provides a decoding method, which is applied to a decoder. FIG13 is a schematic diagram of an implementation flow of the decoding method provided in the embodiment of the present application. As shown in FIG13 , the decoding method includes the following steps 1301 to 1305:
[0267] Step 1301, determining a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block;
[0268] Step 1302: Determine a second difference in sample values between the template of the current block and the template of the first reference block;
[0269] Step 1303: determine a third difference in sample values between the template of the current block and the template of the second reference block;
[0270] Step 1304: Perform motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block.
[0271] Step 1305: Perform motion compensation on the current block according to the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
[0272] It can be understood that the decoder and the encoder use the same operation to obtain the prediction block of the current block. Therefore, for the operations performed on the decoder side to obtain the prediction block of the current block that are not described above, refer to the operations and related features performed by the encoder to obtain the prediction block of the current block, and will not be repeated here.
[0273] In an embodiment of the present application, when performing motion estimation on the current block, not only the second difference in sample values between the template of the current block and the template of the first reference block pointed to by the first candidate MV and the third difference in sample values between the template of the current block and the template of the second reference block pointed to by the second candidate MV are used, but also the first difference in sample values between the first reference block pointed to by the first candidate MV of the current block and the second reference block pointed to by the second candidate MV of the current block are combined; this is beneficial to improving the accuracy of motion estimation of the current block, that is, improving the accuracy of the first predicted MV and the second predicted MV of the current block, thereby improving the inter-frame prediction accuracy of the current block and enhancing the video decoding quality.
[0274] In some embodiments, the decoding method further includes: parsing a bitstream to obtain a residual block of the current block; and determining a reconstructed block of the current block according to the prediction block of the current block and the residual block.
[0275] The following describes an exemplary application of the embodiments of the present application in a practical application scenario.
[0276] BM and TM each have their own shortcomings, but they are also complementary, so BM and TM can be used in combination.
[0277] A scheme combining BM and TM is as follows:
[0278] The first step is to improve the motion vector based on the whole block bidirectional matching BM.
[0279] The second step is motion vector improvement based on template matching TM of the entire block.
[0280] The third step is to improve the motion vector based on the bidirectional matching (BM) of the sub-blocks. The sub-block size in this step can be 16x16.
[0281] The fourth step is to improve the motion vector based on the bidirectional optical flow of the sub-block. The sub-block size in this step can be 8x8.
[0282] More specifically, BM refinement uses a mirrored search method, while TM refinement uses a unidirectional plus iterative search method. One approach is to use only the first two steps of the bidirectional template matching search during TM refinement, that is, to refine the MVs in the two reference directions using only a unidirectional search method, without using an iterative search method.
[0283] This scheme uses BM, TM, and optical flow. Each step is independent of the others. After the BM search of the entire block, the TM search of the entire block is performed. After the TM search of the entire block, the BM search of the sub-blocks is performed.
[0284] Another option is to substantially combine BM and TM.
[0285] For a certain set of bidirectional motion information that is searched, the motion vector corresponding to its RPL0 is MV0 (ie, the first candidate MV), and the motion vector corresponding to its RPL1 is MV1 (ie, the second candidate MV).
[0286] The matching cost of the two reference blocks in BM bidirectional matching is denoted as costBM. One method is to use costBM as the SAD or SATD (ie, an example of the first difference) of the reference block pointed to by MV0 and the reference block pointed to by MV1.
[0287] Let the matching cost of the template of the reference block corresponding to RPL0 of TM template matching and the template of the current block be costTM0. One method is that costTM0 is the SAD or SATD of the template of the reference block pointed to by MV0 and the template of the current block (i.e., an example of the second difference). Let the matching cost of the template of the reference block corresponding to RPL1 of TM template matching and the template of the current block be costTM1. One method is that costTM1 is the SAD or SATD of the template of the reference block pointed to by MV1 and the template of the current block (i.e., an example of the third difference).
[0288] The cost of the motion vector (difference) of the MVD corresponding to RPL0 is denoted as costMV0 (i.e., the first MVD). One method is to make costMV0 a piecewise function of the MVD corresponding to RPL0 (i.e., an example of the first MVD). The cost of the motion vector difference of the MVD corresponding to RPL1 is denoted as costMV1 (i.e., the second MVD). One method is to make costMV1 a piecewise function of the MVD corresponding to RPL1 (i.e., an example of the first MVD).
[0289] The matching cost of the current bidirectional motion information is calculated as follows: cost = costBM + costTM0 + costTM1 + costMV0 + costMV1
[0290] If the motion vectors in the two directions are mirror images, the above formula can also be simplified to: cost = costBM + costTM0 + costTM1 + costMV
[0291] Where cosTMV is the total motion vector (difference) cost. The absolute values of MVD in the two directions are the same and can be calculated together.
[0292] Optionally, the cost of the motion vector (difference) may not be calculated, ie, cost = costBM + costTM0 + costTM1
[0293] Furthermore, different coefficients can be set for each cost to adjust their proportions, such as cost = factorBM*costBM+factorTM0*costTM0+factorTM1*costTM1+factorMV0*costMV0+factorMV1*costMV1
[0294] Among them, factorBM, factorTM0, factorTM1, factorMV0, and factorMV1 can be preset values, such as 1, 2, 3, 4, etc., or can be values calculated according to the block size.
[0295] Example of calculating coefficients:
[0296] An example of calculating factor is as follows. Let the width of the current block be width and the height be height. Let the height of the upper template and the width of the left template be templateSize. The width of the upper template is equal to the width of the current block, and the height of the left template is equal to the height of the current block. The number of pixels of the template is numPixTemplate = (width + height) * templateSize. The number of pixels of the current block is numPixCurr = width * height. An example is to let factorBM = numPixTemplate factorTM0 = factorTM1 = numPixCurr
[0297] Another example is to set factorBM = 1 factorTM0 = factorTM1 = numPixCurr / numPixTemplate
[0298] Of course, division can be replaced by right shift or table lookup.
[0299] Variants for calculating costs:
[0300] If the MVs of the two reference directions change at the same time during a search, it also means that the values of costBM, costTM0, and costTM1 may change. Then it is appropriate to use the above formula. For example, in the current DMVR search process, the MVs of the two reference directions move in a mirrored manner. Each set of MVs may cause the values of costBM, costTM0, and costTM1 to change. Another possible search method is the one-way search mentioned above, that is, during a search, one of the MVs of the two reference directions changes, while the other remains unchanged. This means that during a search, the value of one of costTM0 and costTM1 will not change. For example, during a one-way search of the motion vector MV0 corresponding to RPL0, the motion vector MV1 corresponding to RPL1 remains unchanged. Then the value of costTM0 will change during the search, while the value of costTM1 will not change during the search.
[0301] During a search process, if the mv of a reference direction remains unchanged, the cost calculation method can be simplified as: cost = costBM + costTM x +costMV x
[0302] Or cost=factorBM*costBM+factorTM x *costTM x +factorMV x *costMV x
[0303] Where x is 0 or 1, indicating the reference direction of the change.
[0304] Optionally, the cost of the motion vector (difference) may not be calculated.
[0305] Combining BM and TM usage scenarios:
[0306] One possible scenario involves using a mirror search method. For example, during a DMVR or multi-round DMVR search, a method combining BM and TM is used instead of using only BM without TM. Specifically, the combined BM and TM method is used to calculate the set of MVs generated by the mirror movement.
[0307] One possible scenario is for one-way search. For example, when using template matching to improve the MV corresponding to RPL0 or RPL1, the TM-only approach is replaced with a combined BM and TM approach. Specifically, the BM and TM approach is used to calculate the MV generated by the MV shift in RPL0 or RPL1.
[0308] The TM can be replaced by a method combining BM and TM in all steps, or it can be replaced by a method combining BM and TM in only some steps. This can also be said to be used in the one-way plus iterative search method.
[0309] In Example 1, TM was replaced by a method combining BM and TM in all steps:
[0310] The first step is to improve MV0 corresponding to RPL0 using a combination of BM and TM. The matching cost is calculated as cost = costBM + costTM0. The minimum cost minCost0 is recorded.
[0311] The second step is to improve MV1 corresponding to RPL1 using a combination of BM and TM. The matching cost is calculated as cost = costBM + costTM1. The minimum cost minCost1 is recorded.
[0312] The third step is to compare minCost0 and minCost1. The reference direction of the larger one is X, where X is 0 or 1, and the reference direction of the smaller one is 1-X. The BM and TM methods are combined to improve the MV corresponding to RPLX. x , when calculating the matching cost, use cost = costBM + costTM x . This time, MV is used to calculate the matching cost. x The template of the reference block is compared with the template of the modified current block. One possible method is to modify the value of each position in the template of the current block to be equal to 2 times the value of the corresponding position of the template of the current block minus the latest MV 1-x The value of the corresponding position of the template of the located reference block. In Example 2, only the TM is replaced by a method combining BM and TM in the third and fourth steps:
[0313] The first step is to use TM to improve MV0 corresponding to RPL0. When calculating the matching cost, the template of the reference block located by MV0 is compared with the template of the current block. The minimum cost minCost0 is recorded during this process.
[0314] In the second step, TM is used to improve MV1 corresponding to RPL1. When calculating the matching cost, the template of the reference block located by MV1 is compared with the template of the current block. The minimum cost minCost1 is recorded during this process.
[0315] The third step is to compare minCost0 and minCost1. The reference direction of the larger one is X, where X is 0 or 1, and the reference direction of the smaller one is 1-X. The MV corresponding to RPLX is improved by combining BM and TM. x, when calculating the matching cost, use cost = costBM + costTM x . This time, MV is used to calculate the matching cost. x The template of the reference block is compared with the template of the modified current block. One possible method is to modify the value of each position in the template of the current block to be equal to 2 times the value of the corresponding position of the template of the current block minus the latest MV 1-x The value of the corresponding position of the template of the located reference block.
[0316] The fourth step is to improve the MV corresponding to RPL(1-X) by combining BM and TM. 1-x , when calculating the matching cost, use cost = costTM + costTM 1-x . This time, MV is used to calculate the matching cost. 1-x The template of the reference block is compared with the template of the modified current block. One possible method is to modify the value of each position in the template of the current block to be equal to 2 times the value of the corresponding position of the template of the current block minus the latest MV x The value of the corresponding position of the template of the located reference block.
[0317] Restrictions:
[0318] DMVR has a restriction that the two reference images are located on both sides of the current image, that is, one reference image is before the current image and the other reference image is after the current image, and the distance between the two reference images and the current image is equal. This distance can refer to the time distance or be calculated using the POC value.
[0319] A possible constraint on the combined BM and TM method is that the two reference images are located on either side of the current image, i.e., one reference image precedes the current image and the other follows it. However, the distances between the two reference images and the current image are not required to be equal. This means that the method can be used even when the distances between the two reference images and the current image are unequal. Another possible constraint is to use the existing method when the distances between the two reference images and the current image are equal, and to use the combined BM and TM method when the distances between the two reference images and the current image are unequal.
[0320] On the other hand, whether to use the method combining BM and TM can be determined based on the values of MV0 corresponding to RPL0 and MV1 corresponding to RPL1.
[0321] An example is to use the method of combining BM and TM when MV0 and MV1 are asymmetric. An example of judging whether MV0 and MV1 are symmetric is as follows:
[0322] There are two aspects: one is to determine whether the absolute values of MV0 and MV1 are similar, and the other is to determine whether the angles of MV0 and MV1 are similar.
[0323] 1. Determine whether the absolute values of MV0 and MV1 are similar:
[0324] Calculate MV x The absolute value of Where x is 0 or 1, MV x [0] is MV x The horizontal component of MV x [1] For MV x The vertical component of . If If the absolute values of MV0 and MV1 are similar, then they are considered to be dissimilar. 0.9 and 1.1 are preset thresholds, which can also be set to other values.
[0325] 2. Determine whether the angles of MV0 and MV1 are similar:
[0326] Calculate MV x Angle Where x is 0 or 1, MV x [0] is MV x The horizontal component of MV x [1] For MV x The vertical component of . If abs(angMV0 - angMV1) < 10, the angles of MV0 and MV1 are considered similar; otherwise, they are not. 10 is a preset threshold, and other values can also be set.
[0327] For the convenience of hardware implementation, the square root and division operations mentioned above can be replaced by table lookup or right shift.
[0328] By combining BM and TM, a more accurate MV is derived, thereby improving compression efficiency.
[0329] It should be noted that although the steps of the method of the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all steps must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps; or steps in different embodiments may be combined to form a new technical solution.
[0330] Based on the above embodiments, an embodiment of the present application provides a decoding device, which is applied to a decoder. FIG14 is a schematic structural diagram of the decoding device provided in an embodiment of the present application. As shown in FIG14 , the decoding device 14 includes:
[0331] A first determining module 1401 is configured to determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block;
[0332] A second determining module 1402 is configured to determine a second difference in sample values between the template of the current block and the template of the first reference block;
[0333] A third determining module 1403 is configured to determine a third difference in sample values between the template of the current block and the template of the second reference block;
[0334] A first motion estimation module 1404 is configured to perform motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block;
[0335] The first motion compensation module 1405 is configured to perform motion compensation on the current block according to the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
[0336] In some embodiments, the first motion estimation module 1404 is configured to: determine a first matching cost based on at least the first difference, the second difference and the third difference, the first matching cost representing the degree of matching between the first reference block and the second reference block and the current block; perform a first search process with the first candidate MV and the second candidate MV as starting points to obtain a new first matching cost; wherein the first search process includes: starting from the first candidate MV and taking the first step as the search step, searching in the first direction to obtain a new first candidate MV; and, starting from the second candidate MV and taking the first step as the search step, searching in the second direction to obtain a new second candidate MV; and, determining a new first matching cost based on the new first candidate MV and the new second candidate MV; wherein the first direction and the second direction are in a mirror relationship; and determining the first predicted MV and the second predicted MV based on at least the two obtained first matching costs.
[0337] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine the first predicted MV and the second predicted MV according to the two obtained first matching costs when a first search cutoff condition is satisfied.
[0338] Further, in some embodiments, the first motion estimation module 1404 is configured to: when the first search cutoff condition is not met, iteratively perform the first search process with the new first candidate MV and the new second candidate MV as the starting point until the first search cutoff condition is met, and determine the first predicted MV and the second predicted MV based on the multiple first matching costs obtained.
[0339] Exemplarily, in some embodiments, the first predicted MV is equal to the MV corresponding to the minimum first matching cost among the obtained first matching costs; the second predicted MV is equal to the MV corresponding to the minimum first matching cost.
[0340] Further, in some embodiments, the first motion estimation module 1404 is configured to: determine a first weighting coefficient of the first difference, a second weighting coefficient of the second difference, and a third weighting coefficient of the third difference; and weight the first difference, the second difference, and the third difference according to the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the first matching cost.
[0341] Furthermore, in some other embodiments, the first motion estimation module 1404 is configured to: determine a first MVD of the first candidate MV and a second MVD of the second candidate MV; and determine the first matching cost based on the first difference, the second difference, the third difference, the first MVD and the second MVD.
[0342] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine a first weighting coefficient of the first difference, a second weighting coefficient of the second difference, a third weighting coefficient of the third difference, a fourth weighting coefficient of the first MVD, and a fifth weighting coefficient of the second MVD; and weight the first difference, the second difference, the third difference, the first MVD, and the second MVD according to the first weighting coefficient, the second weighting coefficient, the third weighting coefficient, the fourth weighting coefficient, and the fifth weighting coefficient to obtain the first matching cost.
[0343] In some embodiments, the first motion estimation module 1404 is configured to: determine a second matching cost based on at least the first difference and the second difference, the second matching cost representing the degree of matching between the first reference block and the current block; perform a second search process with the first candidate MV as the starting point to obtain a new second matching cost; wherein the second search process includes: starting from the first candidate MV and using the second step size as the search step size, searching in the first direction to obtain a new first candidate MV; and determining a new second matching cost based on the second candidate MV and the new first candidate MV; if the second search cutoff condition is not met, iteratively perform the second search process with the new first candidate MV as the starting point until the second search cutoff condition is met; if the second search cutoff condition is met, determine the first predicted MV and the second predicted MV based on at least the multiple second matching costs and the third difference obtained.
[0344] Further, in some embodiments, the first motion estimation module 1404 is configured to: select the first candidate MV corresponding to the minimum second matching cost among the obtained multiple second matching costs as a third candidate MV; determine a fourth difference in sample values between a third reference block pointed to by the third candidate MV and the second reference block pointed to by the second candidate MV; determine a third matching cost based on at least the fourth difference and the third difference, wherein the third matching cost represents the degree of matching between the second reference block and the current block; perform a third search process starting from the second candidate MV to obtain a new third matching cost; wherein the third search process includes: starting from the second candidate MV and using a third step size as a search step size, searching in the second direction to obtain a new second candidate MV; and determining a new third matching cost based on the third candidate MV and the new second candidate MV; if the third search cutoff condition is not satisfied, iteratively performing the third search process starting from the new second candidate MV until the third search cutoff condition is satisfied; if the third search cutoff condition is satisfied, determining the first predicted MV and the second predicted MV based on the obtained multiple third matching costs and the third candidate MV.
[0345] Exemplarily, in some embodiments, the first motion estimation module 1404 is configured to: use the third candidate MV as the first predicted MV; and use the second candidate MV corresponding to the minimum third matching cost among the multiple third matching costs obtained as the second predicted MV.
[0346] Exemplarily, in some embodiments, the first motion estimation module 1404 is configured to: based on determining that the second matching cost corresponding to the third candidate MV is greater than the minimum third matching cost among the multiple third matching costs obtained, the second candidate MV corresponding to the minimum third matching cost is the second predicted MV.
[0347] Further, in some embodiments, the first motion estimation module 1404 is configured to: determine a fifth difference in sample values between the third reference block pointed to by the third candidate MV and the fourth reference block pointed to by the second predicted MV; correct the template of the current block according to the template of the fourth reference block to obtain a first corrected template of the current block; determine a sixth difference in sample values between the template of the third reference block and the first corrected template; determine a fourth matching cost based on at least the fifth difference and the sixth difference, the fourth matching cost representing the degree of matching between the third reference block and the current block; perform a fourth search process with the third candidate MV as the starting point to obtain a new fourth matching cost; wherein the fourth search process includes: starting from the third candidate MV and using a fourth step size as the search step size, searching in the first direction to obtain a new third candidate MV; and determining a new fourth matching cost based on the new third candidate MV and the second predicted MV; and determining the first predicted MV based on at least the two obtained fourth matching costs.
[0348] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine the first predicted MV according to the two obtained fourth matching costs when a fourth search cutoff condition is satisfied.
[0349] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: when the fourth search cutoff condition is not met, iteratively perform the fourth search process with the new third candidate MV as the starting point until the fourth search cutoff condition is met, and determine the first predicted MV based on the multiple fourth matching costs obtained.
[0350] Exemplarily, in some embodiments, the first predicted MV is equal to the third candidate MV corresponding to the minimum fourth matching cost among the obtained fourth matching costs.
[0351] Exemplarily, in some embodiments, the sample value at each position of the first revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the fourth reference block.
[0352] Further, in some embodiments, the first motion estimation module 1404 is configured to: determine a first weighting coefficient of the first difference and a second weighting coefficient of the second difference; and weight the first difference and the second difference according to the first weighting coefficient and the second weighting coefficient to obtain the second matching cost.
[0353] Furthermore, in some other embodiments, the first motion estimation module 1404 is configured to: determine a first MVD of the first candidate MV; and determine the second matching cost according to the first difference, the second difference, and the first MVD.
[0354] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine a first weighting coefficient of the first difference, a second weighting coefficient of the second difference, and a fourth weighting coefficient of the first MVD; and weight the first difference, the second difference, and the first MVD according to the first weighting coefficient, the second weighting coefficient, and the fourth weighting coefficient to obtain the second matching cost.
[0355] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine a sixth weighting coefficient of the fourth difference and a third weighting coefficient of the third difference; and weight the fourth difference and the third difference according to the sixth weighting coefficient and the third weighting coefficient to obtain the third matching cost.
[0356] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine a second MVD of the second candidate MV; and determine the third matching cost according to the fourth difference, the third difference, and the second MVD.
[0357] Exemplarily, in some embodiments, the first motion estimation module 1404 is configured to: determine a sixth weighting coefficient of the fourth difference, a third weighting coefficient of the third difference, and a fifth weighting coefficient of the second MVD; and weight the fourth difference, the third difference, and the second MVD according to the sixth weighting coefficient, the third weighting coefficient, and the fifth weighting coefficient to obtain the third matching cost.
[0358] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine a third MVD of the third candidate MV; and determine the fourth matching cost according to the fifth difference, the sixth difference, and the third MVD.
[0359] Exemplarily, in some embodiments, the first motion estimation module 1404 is configured to: determine the seventh weighting coefficient of the fifth difference, the eighth weighting coefficient of the sixth difference, and the ninth weighting coefficient of the third MVD; and weight the fifth difference, the sixth difference, and the third MVD according to the seventh weighting coefficient, the eighth weighting coefficient, and the ninth weighting coefficient to obtain the fourth matching cost.
[0360] In some embodiments, the first motion estimation module 1404 is configured to: when the second difference is greater than the third difference, determine a fifth matching cost based on at least the first difference and the second difference, the fifth matching cost representing the degree of matching between the first reference block and the current block; perform a fifth search process with the first candidate MV as the starting point to obtain a new fifth matching cost; wherein the fifth search process includes: starting from the first candidate MV and using the fifth step length as the search step length, searching in the first direction to obtain a new first candidate MV; and determining a new fifth matching cost based on the new first candidate MV and the second candidate MV; determining the first predicted MV based on at least the two obtained fifth matching costs; and determining the second predicted MV based on the first predicted MV and the third difference.
[0361] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine the first predicted MV according to the two obtained fifth matching costs when a fifth search cutoff condition is satisfied.
[0362] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: when the fifth search cutoff condition is not met, iterate the fifth search process until the fifth search cutoff condition is met, and determine the first predicted MV based on the multiple fifth matching costs obtained.
[0363] Exemplarily, in some embodiments, the first predicted MV is equal to the first candidate MV corresponding to the minimum fifth matching cost among the obtained multiple fifth matching costs.
[0364] In some embodiments, the first motion estimation module 1404 is further configured to: determine a seventh difference between sample values of a template of a reference block pointed to by the first initial MV and a template of the current block; determine a sixth matching cost based at least on the seventh difference, the sixth matching cost representing the degree of matching between the reference block pointed to by the first initial MV and the current block; perform a sixth search process with the first initial MV as the starting point to obtain a new sixth matching cost; wherein the sixth search process includes: starting from the first initial MV and using the sixth step length as the search step length, searching in the first direction to obtain a new first initial MV; and determining a new sixth matching cost based on the new first initial MV; and determining the first candidate MV based at least on the two obtained sixth matching costs.
[0365] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine the first candidate MV according to the two obtained sixth matching costs when a sixth search cutoff condition is satisfied.
[0366] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: when the sixth search cutoff condition is not met, iterate the sixth search process until the sixth search cutoff condition is met, and determine the first candidate MV based on the multiple sixth matching costs obtained.
[0367] Exemplarily, in some embodiments, the first candidate MV is equal to the first initial MV corresponding to the minimum sixth matching cost among the obtained sixth matching costs.
[0368] In some embodiments, the second determination module 1402 is configured to: correct the template of the current block according to the template of the second reference block pointed to by the second candidate MV to obtain a second corrected template of the current block; and determine a second difference in sample values between the second corrected template and the template of the first reference block.
[0369] Exemplarily, in some embodiments, the sample value at each position of the second revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the second reference block.
[0370] In some embodiments, the first motion estimation module 1404 is configured to: determine the eighth difference in sample values between the fifth reference block pointed to by the first predicted MV and the second reference block pointed to by the second candidate MV; determine a seventh matching cost based on at least the eighth difference and the third difference, wherein the seventh matching cost represents the degree of matching between the fifth reference block and the current block; perform a seventh search process with the second candidate MV as the starting point to obtain a new seventh matching cost; wherein the seventh search process includes: starting from the second candidate MV and using the seventh step length as the search step length, searching in the second direction to obtain a new second candidate MV; and determining a new seventh matching cost based on the new second candidate MV and the first predicted MV; and determining the second predicted MV based on at least the two obtained seventh matching costs.
[0371] Furthermore, in some embodiments, the first motion estimation module 1404 is configured to: determine the second predicted MV according to the two obtained seventh matching costs when a seventh search cutoff condition is satisfied.
[0372] Further, in some embodiments, the first motion estimation module 1404 is configured to: when the seventh search cutoff condition is not met, iterate the seventh search process until the seventh search cutoff condition is met, and determine the second predicted MV based on the multiple seventh matching costs obtained.
[0373] Exemplarily, in some embodiments, the second predicted MV is equal to the second candidate MV corresponding to the minimum seventh matching cost among the obtained seventh matching costs.
[0374] In some embodiments, the first motion estimation module 1404 is configured to: correct the template of the current block according to the template of the reference block pointed to by the first predicted MV to obtain a third corrected template of the current block; and determine a third difference in sample values between the third corrected template and the template of the second reference block.
[0375] Exemplarily, in some embodiments, the sample value of each position of the third revised template is equal to twice the sample value of the corresponding position of the template of the current block minus the sample value of the corresponding position of the template of the reference block pointed to by the first predicted MV.
[0376] In some embodiments, the first motion estimation module 1404 is configured to: determine a first weighting coefficient of the first difference and a second weighting coefficient of the second difference; and weight the first difference and the second difference according to the first weighting coefficient and the second weighting coefficient to obtain the fifth matching cost.
[0377] In some embodiments, the first motion estimation module 1404 is configured to: determine a first MVD of the first candidate MV; and determine the fifth matching cost according to the first difference, the second difference, and the first MVD.
[0378] In some embodiments, the first motion estimation module 1404 is configured to: determine a first weighting coefficient of the first difference, a second weighting coefficient of the second difference, and a fourth weighting coefficient of the first MVD; weight the first difference, the second difference, and the first MVD according to the first weighting coefficient, the second weighting coefficient, and the fourth weighting coefficient to obtain the fifth matching cost.
[0379] In some embodiments, the first motion estimation module 1404 is configured to: determine a fourth MVD of the first initial MV; and determine the sixth matching cost according to the seventh difference and the fourth MVD.
[0380] In some embodiments, the first motion estimation module 1404 is configured to: determine the tenth weighting coefficient of the seventh difference and the eleventh weighting coefficient of the fourth MVD; weight the seventh difference and the fourth MVD according to the tenth weighting coefficient and the eleventh weighting coefficient to obtain the sixth matching cost.
[0381] In some embodiments, the first motion estimation module 1404 is configured to: determine a twelfth weighting coefficient of the eighth difference and a third weighting coefficient of the third difference; and weight the eighth difference and the third difference according to the twelfth weighting coefficient and the third weighting coefficient to obtain the seventh matching cost.
[0382] In some embodiments, the first motion estimation module 1404 is configured to: determine a second MVD of the second candidate MV; and determine the seventh matching cost according to the eighth difference, the third difference, and the second MVD.
[0383] In some embodiments, the first motion estimation module 1404 is configured to: determine the twelfth weighting coefficient of the eighth difference, the third weighting coefficient of the third difference, and the fifth weighting coefficient of the second MVD; weight the eighth difference, the third difference, and the second MVD according to the twelfth weighting coefficient, the third weighting coefficient, and the fifth weighting coefficient to obtain the seventh matching cost.
[0384] In some embodiments, the first to twelfth weighting coefficients are all preset values.
[0385] In some embodiments, the first motion estimation module 1404 is further configured to determine the first weighting coefficient, the sixth weighting coefficient, the seventh weighting coefficient and the twelfth weighting coefficient according to the size of the current block or the size of the template of the current block.
[0386] Exemplarily, in some embodiments, the first weighting coefficient is equal to the number of samples of the template of the current block; the sixth weighting coefficient is equal to the number of samples of the template of the current block; the seventh weighting coefficient is equal to the number of samples of the template of the current block; and the twelfth weighting coefficient is equal to the number of samples of the template of the current block.
[0387] In some embodiments, the first motion estimation module 1404 is further configured to determine the second weighting coefficient, the third weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient according to the size of the current block or the size of the template of the current block.
[0388] Exemplarily, in some embodiments, the second weighting coefficient is equal to the number of samples of the current block; the third weighting coefficient is equal to the number of samples of the current block; the eighth weighting coefficient is equal to the number of samples of the current block; and the tenth weighting coefficient is equal to the number of samples of the current block.
[0389] In some embodiments, the first motion estimation module 1404 is further configured to determine the fourth weighting coefficient, the fifth weighting coefficient, the ninth weighting coefficient and the eleventh weighting coefficient according to the size of the current block or the size of the template of the current block.
[0390] In some embodiments, the distances between the first reference image to which the first reference block belongs and the second reference image to which the second reference block belongs and the current image to which the current block belongs are equal or unequal.
[0391] In some embodiments, the first motion estimation module 1404 is further configured to: determine, based on the relationship between the first candidate MV and the second candidate MV, whether to execute the step of performing motion estimation on the current block based on at least the first difference, the second difference and the third difference to obtain the first predicted MV and the second predicted MV of the current block.
[0392] In some embodiments, the first motion estimation module 1404 is further configured to: when the first candidate MV is asymmetric to the second candidate MV, perform the step of performing motion estimation on the current block based on at least the first difference, the second difference and the third difference to obtain the first predicted MV and the second predicted MV of the current block.
[0393] In some embodiments, the first motion estimation module 1404 is further configured to: determine that the first candidate MV is asymmetric to the second candidate MV when the ratio or difference between the absolute value of the first candidate MV and the absolute value of the second candidate MV is not within a corresponding range, and / or the ratio or difference between the angle of the first candidate MV and the angle of the second candidate MV is not within a corresponding range.
[0394] In some embodiments, the decoding device 14 further includes a decoding module configured to parse the code stream to obtain a residual block of the current block; and determine a reconstructed block of the current block according to the prediction block of the current block and the residual block.
[0395] The description of the above decoding device embodiment is similar to the description of the above encoding method embodiment, and has similar beneficial effects as the encoding method embodiment. For technical details not disclosed in the decoding device embodiment of this application, please refer to the description of the encoding method embodiment of this application for understanding.
[0396] An embodiment of the present application provides an encoding device, which is applied to an encoder. FIG15 is a schematic structural diagram of the encoding device provided in an embodiment of the present application. As shown in FIG15 , the encoding device 15 includes:
[0397] A fourth determining module 1501 is configured to determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block;
[0398] a fifth determining module 1502 configured to determine a second difference in sample values between the template of the current block and the template of the first reference block;
[0399] a sixth determining module 1503, configured to determine a third difference in sample values between the template of the current block and the template of the second reference block;
[0400] A second motion estimation module 1504 is configured to perform motion estimation on the current block based on at least the first difference, the second difference, and the third difference to obtain a first predicted MV and a second predicted MV of the current block;
[0401] The second motion compensation module 1505 is configured to perform motion compensation on the current block according to the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
[0402] In some embodiments, the encoding device 15 further includes a seventh determination module and a generation module; wherein the seventh determination module is configured to determine the residual block of the current block based on the original block of the current block and the predicted block of the current block; and the generation module is configured to generate a code stream based on the residual block of the current block.
[0403] It can be understood that the decoding device 14 and the encoding device 15 use the same operation to obtain the prediction block of the current block. That is, the first determination module 1401 in the decoding device 14 and the fourth determination module 1501 in the encoding device 15 perform the same operation to determine the first difference; the second determination module 1402 in the decoding device 14 and the fifth determination module 1502 in the encoding device 15 perform the same operation to determine the second difference; the third determination module 1403 in the decoding device 14 and the sixth determination module 1503 in the encoding device 15 perform the same operation to determine the third difference; and the first motion estimation module 1404 in the decoding device 14 and the second motion compensation module 1505 in the encoding device 15 perform the same operation to determine the prediction block of the current block. Therefore, in the embodiment of the encoding device, the operations and related features performed by the above modules will not be described in detail. The operations performed by the above modules are the same as those performed by the corresponding modules in the decoding device.
[0404] The description of the above encoding device embodiment is similar to the description of the above encoding / decoding method embodiment, and has similar beneficial effects as the encoding / decoding method embodiment. For technical details not disclosed in the encoding device embodiment of this application, please refer to the description of the encoding / decoding method embodiment of this application for understanding.
[0405] It should be noted that the division of modules in the encoding / decoding device described in the embodiments of the present application is schematic and is merely a logical functional division. In actual implementation, other division methods may be used. Furthermore, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units. They may also be implemented in a combination of software and hardware.
[0406] It should be noted that, in the embodiment of the present application, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling an electronic device to execute all or part of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific combination of hardware and software.
[0407] An embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the encoding method or the decoding method as described in the embodiment of the present application is implemented.
[0408] An embodiment of the present application provides an encoder, as shown in FIG16 , the encoder 16 includes: a first communication interface 161, a first memory 162, and a first processor 163; each component is coupled together via a first bus system 164. It is understood that the first bus system 164 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 164 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in FIG16 , various buses are labeled as the first bus system 164. Among them,
[0409] The first communication interface 161 is used for receiving and sending signals during the process of sending and receiving information between other external network elements;
[0410] A first memory 162 is used to store computer programs that can be run on the first processor 163;
[0411] The first processor 163 is configured to execute the encoding method described in the embodiment of the present application when running the computer program.
[0412] It is understood that the first memory 162 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The first memory 162 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0413] The first processor 163 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in the first processor 163. The above-mentioned first processor 163 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the first memory 162 , and the first processor 163 reads the information in the first memory 162 and completes the steps of the above method in combination with its hardware.
[0414] It is to be understood that these embodiments described in the present application can be implemented with hardware, software, firmware, middleware, microcode or its combination.For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing equipment (DSP Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other electronic units for performing functions described in the present application or its combination.For software implementation, the technology described in the present application can be realized by the module (such as process, function etc.) that performs functions described in the present application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0415] Optionally, as another embodiment, the first processor 163 is further configured to execute any of the aforementioned encoding method embodiments when running the computer program.
[0416] The present application provides a decoder, as shown in FIG17 , the decoder 17 includes: a second communication interface 171, a second memory 172, and a second processor 173; each component is coupled together via a second bus system 174. It is understood that the second bus system 174 is used to achieve connection and communication between these components. In addition to the data bus, the second bus system 174 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in FIG17 , various buses are labeled as the second bus system 174. Among them,
[0417] The second communication interface 171 is used for receiving and sending signals during the process of sending and receiving information between other external network elements;
[0418] The second memory 172 is used to store computer programs that can be run on the second processor 173;
[0419] The second processor 173 is configured to execute the decoding method described in the embodiment of the present application when running the computer program.
[0420] It can be understood that the hardware functions of the second memory 172 and the first memory 162 are similar, and the hardware functions of the second processor 173 and the first processor 163 are similar; they will not be described in detail here.
[0421] The embodiment of the present application further provides a code stream, which is obtained by using the aforementioned encoding method.
[0422] An embodiment of the present application provides an electronic device, comprising: a processor adapted to execute a computer program; and a computer-readable storage medium storing the computer program, wherein when the computer program is executed by the processor, the encoding method and / or decoding method described in the embodiment of the present application are implemented. The electronic device can be any type of device capable of video encoding and / or video decoding, such as a mobile phone, tablet computer, laptop computer, personal computer, television, projection device, or monitoring device.
[0423] It should be noted that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium, storage medium, and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0424] It should be understood that "one embodiment" or "an embodiment" or "some embodiments" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" or "in some embodiments" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other. For the sake of brevity, they will not be repeated here.
[0425] The term "and / or" in this article is only a description of the association relationship between associated objects, indicating that there can be three relationships. For example, object A and / or object B can mean: object A exists alone, object A and object B exist at the same time, and object B exists alone.
[0426] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0427] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The embodiments described above are merely illustrative. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be electrical, mechanical or other forms.
[0428] The modules described above as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules; they may be located in one place or distributed across multiple network units; some or all of the modules may be selected according to actual needs to achieve the purpose of this embodiment.
[0429] In addition, all functional modules in the embodiments of the present application can be integrated into one processing unit, or each module can be a separate unit, or two or more modules can be integrated into one unit; the above-mentioned integrated modules can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0430] Those skilled in the art will understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, and other media that can store program codes.
[0431] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application, or the part that contributes to the relevant technology, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a number of instructions for enabling an electronic device to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks or optical disks.
[0432] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0433] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0434] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0435] The above is merely an embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A decoding method, the decoding method being applied to a decoder, the method comprising: Determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; Determine a second difference in sample values between the template of the current block and the template of the first reference block; determining a third difference in sample values between the template of the current block and the template of the second reference block; Performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block; According to the first predicted MV and the second predicted MV, motion compensation is performed on the current block to obtain a predicted block of the current block.
2. The method according to claim 1, wherein: The performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block includes: Determine a first matching cost at least according to the first difference, the second difference and the third difference, wherein the first matching cost represents a matching degree between the first reference block and the second reference block and the current block; Taking the first candidate MV and the second candidate MV as starting points, a first search process is performed to obtain a new first matching cost; wherein the first search process includes: taking the first candidate MV as a starting point and the first step length as a search step length, searching in a first direction to obtain a new first candidate MV; and taking the second candidate MV as a starting point and the first step length as a search step length, searching in a second direction to obtain a new second candidate MV; and determining a new first matching cost according to the new first candidate MV and the new second candidate MV; wherein the first direction and the second direction are in a mirror relationship; The first predicted MV and the second predicted MV are determined based on at least the two obtained first matching costs.
3. The method according to claim 2, wherein: The determining the first predicted MV and the second predicted MV at least according to the obtained two first matching costs includes: When the first search cutoff condition is met, the first predicted MV and the second predicted MV are determined according to the two obtained first matching costs.
4. The method according to claim 2, wherein: The determining the first predicted MV and the second predicted MV at least according to the obtained two first matching costs includes: When the first search cutoff condition is not met, the first search process is iterated with the new first candidate MV and the new second candidate MV as starting points until the first search cutoff condition is met, and the first predicted MV and the second predicted MV are determined based on the multiple first matching costs obtained.
5. The method according to claim 3 or 4, wherein: The first predicted MV is equal to the MV corresponding to the minimum first matching cost among the obtained first matching costs; The second predicted MV is equal to the MV corresponding to the minimum first matching cost.
6. The method according to claim 2, wherein: The determining the first matching cost at least according to the first difference, the second difference and the third difference includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, and a third weighting coefficient for the third difference; The first difference, the second difference and the third difference are weighted according to the first weighting coefficient, the second weighting coefficient and the third weighting coefficient to obtain the first matching cost.
7. The method according to claim 2, wherein: The determining a first matching cost at least according to the first difference, the second difference and the third difference includes: Determine a first MVD of the first candidate MV and a second MVD of the second candidate MV; The first matching cost is determined according to the first difference, the second difference, the third difference, the first MVD, and the second MVD.
8. The method according to claim 7, wherein: The determining the first matching cost according to the first difference, the second difference, the third difference, the first MVD, and the second MVD includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, a third weighting coefficient for the third difference, a fourth weighting coefficient for the first MVD, and a fifth weighting coefficient for the second MVD; The first difference, the second difference, the third difference, the first MVD and the second MVD are weighted according to the first weighting coefficient, the second weighting coefficient, the third weighting coefficient, the fourth weighting coefficient and the fifth weighting coefficient to obtain the first matching cost.
9. The method according to claim 1, wherein: The performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block includes: Determine a second matching cost at least according to the first difference and the second difference, wherein the second matching cost represents a matching degree between the first reference block and the current block; Taking the first candidate MV as a starting point, performing a second search process to obtain a new second matching cost; wherein the second search process includes: taking the first candidate MV as a starting point and taking the second step length as a search step length, searching in the first direction to obtain a new first candidate MV; and determining a new second matching cost according to the second candidate MV and the new first candidate MV; In the case that the second search cut-off condition is not met, taking the new first candidate MV as a starting point, iteratively performing the second search process until the second search cut-off condition is met; When the second search cutoff condition is met, the first predicted MV and the second predicted MV are determined based at least on the obtained plurality of second matching costs and the third difference value.
10. The method according to claim 9, wherein: The determining the first predicted MV and the second predicted MV at least according to the obtained plurality of second matching costs and the third difference value comprises: Using the first candidate MV corresponding to the minimum second matching cost among the obtained plurality of second matching costs as the third candidate MV; Determine a fourth difference in sample values between a third reference block pointed to by the third candidate MV and a second reference block pointed to by the second candidate MV; Determine a third matching cost at least according to the fourth difference and the third difference, wherein the third matching cost represents a matching degree between the second reference block and the current block; Taking the second candidate MV as a starting point, performing a third search process to obtain a new third matching cost; wherein the third search process includes: taking the second candidate MV as a starting point and taking a third step length as a search step length, searching in a second direction to obtain a new second candidate MV; and determining a new third matching cost according to the third candidate MV and the new second candidate MV; In the case where the third search cutoff condition is not satisfied, taking the new second candidate MV as a starting point, iteratively performing the third search process until the third search cutoff condition is satisfied; When the third search cutoff condition is met, the first predicted MV and the second predicted MV are determined according to the obtained multiple third matching costs and the third candidate MVs.
11. The method according to claim 10, wherein: The determining the first predicted MV and the second predicted MV according to the obtained plurality of third matching costs and the third candidate MVs includes: Using the third candidate MV as the first predicted MV; The second candidate MV corresponding to the minimum third matching cost among the multiple third matching costs obtained is used as the second predicted MV.
12. The method according to claim 10, wherein: Determining the second predicted MV according to the obtained plurality of third matching costs and the third candidate MVs includes: Based on determining that the second matching cost corresponding to the third candidate MV is greater than the minimum third matching cost among the obtained multiple third matching costs, the second candidate MV corresponding to the minimum third matching cost is the second predicted MV.
13. The method according to claim 12, wherein: Determining the first predicted MV according to the obtained plurality of third matching costs and the third candidate MVs includes: Determine a fifth difference in sample values between a third reference block pointed to by the third candidate MV and a fourth reference block pointed to by the second predicted MV; Modifying the template of the current block according to the template of the fourth reference block to obtain a first modified template of the current block; determining a sixth difference in sample values between the template of the third reference block and the first revised template; Determine a fourth matching cost at least according to the fifth difference value and the sixth difference value, wherein the fourth matching cost represents a matching degree between the third reference block and the current block; Taking the third candidate MV as a starting point, performing a fourth search process to obtain a new fourth matching cost; wherein the fourth search process includes: taking the third candidate MV as a starting point and taking a fourth step length as a search step length, searching in the first direction to obtain a new third candidate MV; and determining a new fourth matching cost according to the new third candidate MV and the second predicted MV; The first predicted MV is determined based on at least the two obtained fourth matching costs.
14. The method according to claim 13, wherein: The determining the first predicted MV at least according to the obtained two fourth matching costs includes: When the fourth search cutoff condition is met, the first predicted MV is determined according to the two obtained fourth matching costs.
15. The method according to claim 13, wherein: The determining the first predicted MV at least according to the obtained two fourth matching costs includes: When the fourth search cutoff condition is not met, the fourth search process is iterated with the new third candidate MV as the starting point until the fourth search cutoff condition is met, and the first predicted MV is determined based on the multiple fourth matching costs obtained.
16. The method according to claim 14 or 15, wherein: The first predicted MV is equal to the third candidate MV corresponding to the minimum fourth matching cost among the obtained fourth matching costs.
17. The method according to claim 13, wherein: The sample value of each position of the first revised template is equal to twice the sample value of the corresponding position of the template of the current block minus the sample value of the corresponding position of the template of the fourth reference block.
18. The method according to claim 9, wherein: The determining a second matching cost at least according to the first difference and the second difference includes: determining a first weighting coefficient for the first difference and a second weighting coefficient for the second difference; The first difference and the second difference are weighted according to the first weighting coefficient and the second weighting coefficient to obtain the second matching cost.
19. The method according to claim 9, wherein: The determining a second matching cost at least according to the first difference and the second difference includes: Determine a first MVD of the first candidate MV; The second matching cost is determined according to the first difference, the second difference and the first MVD.
20. The method according to claim 19, wherein: The determining the second matching cost according to the first difference, the second difference and the first MVD includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, and a fourth weighting coefficient for the first MVD; The first difference, the second difference, and the first MVD are weighted according to the first weighting coefficient, the second weighting coefficient, and the fourth weighting coefficient to obtain the second matching cost.
21. The method according to claim 10, wherein: The determining a third matching cost at least according to the fourth difference and the third difference includes: determining a sixth weighting coefficient of the fourth difference and a third weighting coefficient of the third difference; The fourth difference and the third difference are weighted according to the sixth weighting coefficient and the third weighting coefficient to obtain the third matching cost.
22. The method according to claim 10, wherein: The determining a third matching cost at least according to the fourth difference and the third difference includes: determining a second MVD of the second candidate MV; The third matching cost is determined according to the fourth difference, the third difference and the second MVD.
23. The method according to claim 22, wherein: The determining the third matching cost according to the fourth difference, the third difference and the second MVD includes: determining a sixth weighting coefficient of the fourth difference, a third weighting coefficient of the third difference, and a fifth weighting coefficient of the second MVD; The fourth difference, the third difference and the second MVD are weighted according to the sixth weighting coefficient, the third weighting coefficient and the fifth weighting coefficient to obtain the third matching cost.
24. The method according to claim 13, wherein: The determining a fourth matching cost at least according to the fifth difference and the sixth difference includes: Determining a third MVD of the third candidate MV; The fourth matching cost is determined according to the fifth difference, the sixth difference and the third MVD.
25. The method according to claim 24, wherein: The determining the fourth matching cost according to the fifth difference, the sixth difference and the third MVD includes: determining a seventh weighting coefficient of the fifth difference, an eighth weighting coefficient of the sixth difference, and a ninth weighting coefficient of the third MVD; The fifth difference, the sixth difference and the third MVD are weighted according to the seventh weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient to obtain the fourth matching cost.
26. The method of claim 1, wherein: The performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block includes: In a case where the second difference is greater than the third difference, determining a fifth matching cost based at least on the first difference and the second difference, the fifth matching cost representing a matching degree between the first reference block and the current block; Taking the first candidate MV as a starting point, performing a fifth search process to obtain a new fifth matching cost; wherein the fifth search process includes: taking the first candidate MV as a starting point, taking the fifth step length as a search step length, searching in the first direction to obtain a new first candidate MV; and determining a new fifth matching cost according to the new first candidate MV and the second candidate MV; Determine the first predicted MV based on at least the two obtained fifth matching costs; The second predicted MV is determined according to the first predicted MV and the third difference.
27. The method according to claim 26, wherein: The determining the first predicted MV at least according to the obtained two fifth matching costs includes: When the fifth search cutoff condition is met, the first predicted MV is determined according to the two obtained fifth matching costs.
28. The method according to claim 26, wherein: The determining the first predicted MV at least according to the obtained two fifth matching costs includes: When the fifth search cutoff condition is not met, the fifth search process is iterated until the fifth search cutoff condition is met, and the first predicted MV is determined based on the obtained multiple fifth matching costs.
29. The method according to claim 28, wherein: The first predicted MV is equal to the first candidate MV corresponding to the minimum fifth matching cost among the multiple fifth matching costs obtained.
30. The method of claim 26, wherein: The method further comprises: Determine a seventh difference between sample values of a template of a reference block pointed to by the first initial MV and a template of the current block; Determine a sixth matching cost at least according to the seventh difference, wherein the sixth matching cost represents a matching degree between a reference block pointed to by the first initial MV and the current block; Taking the first initial MV as a starting point, performing a sixth search process to obtain a new sixth matching cost; wherein the sixth search process includes: taking the first initial MV as a starting point, taking the sixth step length as a search step length, searching in the first direction to obtain a new first initial MV; and determining a new sixth matching cost according to the new first initial MV; The first candidate MV is determined based on at least the two obtained sixth matching costs.
31. The method according to claim 30, wherein: The determining the first candidate MV at least according to the obtained two sixth matching costs includes: When the sixth search cutoff condition is met, the first candidate MV is determined according to the two obtained sixth matching costs.
32. The method of claim 30, wherein: The determining the first candidate MV at least according to the obtained two sixth matching costs includes: When the sixth search cutoff condition is not met, the sixth search process is iterated until the sixth search cutoff condition is met, and the first candidate MV is determined based on the obtained multiple sixth matching costs.
33. The method according to claim 31 or 32, wherein: The first candidate MV is equal to the first initial MV corresponding to the minimum sixth matching cost among the obtained sixth matching costs.
34. The method of claim 26, wherein: The determining a second difference in sample values between the template of the current block and the template of the first reference block comprises: According to the template of the second reference block pointed to by the second candidate MV, the template of the current block is modified to obtain a second modified template of the current block; A second difference in sample values between the second revised template and the template of the first reference block is determined.
35. The method of claim 34, wherein: The sample value at each position of the second revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the second reference block.
36. The method of claim 26, wherein: The determining the second predicted MV according to the first predicted MV and the third difference includes: Determine an eighth difference in sample values between a fifth reference block pointed to by the first prediction MV and a second reference block pointed to by the second candidate MV; Determine a seventh matching cost at least according to the eighth difference value and the third difference value, wherein the seventh matching cost represents a matching degree between the fifth reference block and the current block; Taking the second candidate MV as a starting point, performing a seventh search process to obtain a new seventh matching cost; wherein the seventh search process includes: taking the second candidate MV as a starting point, taking the seventh step length as a search step length, searching in a second direction to obtain a new second candidate MV; and determining a new seventh matching cost according to the new second candidate MV and the first predicted MV; The second predicted MV is determined based on at least the two obtained seventh matching costs.
37. The method of claim 36, wherein: The determining the second predicted MV at least according to the obtained two seventh matching costs includes: When the seventh search cutoff condition is met, the second predicted MV is determined according to the two obtained seventh matching costs.
38. The method of claim 36, wherein: The determining the second predicted MV at least according to the obtained two seventh matching costs includes: When the seventh search cutoff condition is not met, the seventh search process is iterated until the seventh search cutoff condition is met, and the second predicted MV is determined based on the obtained multiple seventh matching costs.
39. The method according to claim 37 or 38, wherein: The second predicted MV is equal to the second candidate MV corresponding to the minimum seventh matching cost among the obtained seventh matching costs.
40. The method of claim 36, wherein: The determining a third difference value of sample values between the template of the current block and the template of the second reference block comprises: According to the template of the reference block pointed to by the first predicted MV, the template of the current block is modified to obtain a third modified template of the current block; A third difference in sample values between the third revised template and the template of the second reference block is determined.
41. The method of claim 40, wherein: The step of correcting the template of the current block according to the template of the reference block pointed to by the first predicted MV to obtain a third corrected template of the current block includes: The sample value at each position of the third revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the reference block pointed to by the first prediction MV.
42. The method of claim 26, 34 or 35, wherein: The determining a fifth matching cost at least according to the first difference and the second difference includes: determining a first weighting coefficient for the first difference and a second weighting coefficient for the second difference; The first difference and the second difference are weighted according to the first weighting coefficient and the second weighting coefficient to obtain the fifth matching cost.
43. The method of claim 26, 34 or 35, wherein: The determining a fifth matching cost at least according to the first difference and the second difference includes: Determine a first MVD of the first candidate MV; The fifth matching cost is determined according to the first difference, the second difference and the first MVD.
44. The method of claim 43, wherein: The determining the fifth matching cost according to the first difference, the second difference and the first MVD includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, and a fourth weighting coefficient for the first MVD; The first difference, the second difference and the first MVD are weighted according to the first weighting coefficient, the second weighting coefficient and the fourth weighting coefficient to obtain the fifth matching cost.
45. The method of claim 30, wherein: The step of determining a sixth matching cost at least according to the seventh difference includes: determining a fourth MVD of the first initial MV; The sixth matching cost is determined according to the seventh difference and the fourth MVD.
46. The method of claim 45, wherein: The determining the sixth matching cost according to the seventh difference and the fourth MVD includes: determining a tenth weighting coefficient of the seventh difference and an eleventh weighting coefficient of the fourth MVD; The seventh difference and the fourth MVD are weighted according to the tenth weighting coefficient and the eleventh weighting coefficient to obtain the sixth matching cost.
47. The method of claim 36, 40 or 41, wherein: The determining a seventh matching cost at least according to the eighth difference and the third difference includes: determining a twelfth weighting coefficient of the eighth difference and a third weighting coefficient of the third difference; The eighth difference and the third difference are weighted according to the twelfth weighting coefficient and the third weighting coefficient to obtain the seventh matching cost.
48. The method of claim 36, 40 or 41, wherein: The determining a seventh matching cost at least according to the eighth difference and the third difference includes: determining a second MVD of the second candidate MV; The seventh matching cost is determined according to the eighth difference, the third difference and the second MVD.
49. The method of claim 48, wherein: The determining the seventh matching cost according to the eighth difference, the third difference and the second MVD includes: determining a twelfth weighting coefficient of the eighth difference, a third weighting coefficient of the third difference, and a fifth weighting coefficient of the second MVD; The eighth difference, the third difference and the second MVD are weighted according to the twelfth weighting coefficient, the third weighting coefficient and the fifth weighting coefficient to obtain the seventh matching cost.
50. The method of claim 6, 8, 18, 20, 21, 23, 25, 42, 44, 46, 47 or 49, wherein: The first weighting coefficient to the twelfth weighting coefficient are all preset values.
51. The method of claim 6, 8, 18, 20, 21, 23, 25, 42, 44, 46, 47 or 49, wherein: The method further comprises: The first weighting coefficient, the sixth weighting coefficient, the seventh weighting coefficient, and the twelfth weighting coefficient are determined according to a size of the current block or a size of a template of the current block.
52. The method of claim 51, wherein: The first weighting coefficient is equal to the number of samples of the template of the current block; The sixth weighting coefficient is equal to the number of samples of the template of the current block; The seventh weighting coefficient is equal to the number of samples of the template of the current block; The twelfth weighting coefficient is equal to the number of samples of the template of the current block.
53. The method of claim 6, 8, 18, 20, 21, 23, 25, 42, 44, 46, 47 or 49, wherein: The method further comprises: The second weighting coefficient, the third weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient are determined according to the size of the current block or the size of the template of the current block.
54. The method of claim 53, wherein: The second weighting coefficient is equal to the number of samples of the current block; The third weighting coefficient is equal to the number of samples of the current block; The eighth weighting coefficient is equal to the number of samples of the current block; The tenth weighting coefficient is equal to the number of samples of the current block.
55. The method of claim 8, 20, 23, 25, 46 or 49, wherein: The method further comprises: The fourth weighting coefficient, the fifth weighting coefficient, the ninth weighting coefficient, and the eleventh weighting coefficient are determined according to a size of the current block or a size of a template of the current block.
56. The method according to any one of claims 1 to 55, wherein: The distances between a first reference image to which the first reference block belongs and a second reference image to which the second reference block belongs and a current image to which the current block belongs are equal or unequal.
57. The method according to any one of claims 1 to 55, wherein: According to the relationship between the first candidate MV and the second candidate MV, determine whether to execute the step of performing motion estimation on the current block at least based on the first difference, the second difference and the third difference to obtain the first predicted MV and the second predicted MV of the current block.
58. The method of claim 57, wherein: In the case where the first candidate MV is asymmetric to the second candidate MV, the step of performing motion estimation on the current block at least based on the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block is performed.
59. The method of claim 58, wherein: When the ratio or difference of the absolute value of the first candidate MV and the absolute value of the second candidate MV is not within the corresponding range, and / or the ratio or difference of the angle of the first candidate MV and the angle of the second candidate MV is not within the corresponding range, it is determined that the first candidate MV and the second candidate MV are asymmetric.
60. The method according to any one of claims 1 to 55, wherein: The method further comprises: Parsing a bitstream to obtain a residual block of the current block; A reconstructed block of the current block is determined according to the prediction block of the current block and the residual block.
61. A coding method, the coding method being applied to an encoder, the method comprising: Determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; Determine a second difference in sample values between the template of the current block and the template of the first reference block; determining a third difference in sample values between the template of the current block and the template of the second reference block; Performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block; According to the first predicted MV and the second predicted MV, motion compensation is performed on the current block to obtain a predicted block of the current block.
62. The method of claim 61, wherein: The performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block includes: Determine a first matching cost at least according to the first difference, the second difference and the third difference, wherein the first matching cost represents a matching degree between the first reference block and the second reference block and the current block; Taking the first candidate MV and the second candidate MV as starting points, a first search process is performed to obtain a new first matching cost; wherein the first search process includes: taking the first candidate MV as a starting point and the first step length as a search step length, searching in a first direction to obtain a new first candidate MV; and taking the second candidate MV as a starting point and the first step length as a search step length, searching in a second direction to obtain a new second candidate MV; and determining a new first matching cost according to the new first candidate MV and the new second candidate MV; wherein the first direction and the second direction are in a mirror relationship; The first predicted MV and the second predicted MV are determined based on at least the two obtained first matching costs.
63. The method of claim 62, wherein: The determining the first predicted MV and the second predicted MV at least according to the obtained two first matching costs includes: When the first search cutoff condition is met, the first predicted MV and the second predicted MV are determined according to the two obtained first matching costs.
64. The method of claim 62, wherein: The determining the first predicted MV and the second predicted MV at least according to the obtained two first matching costs includes: When the first search cutoff condition is not met, the first search process is iterated with the new first candidate MV and the new second candidate MV as starting points until the first search cutoff condition is met, and the first predicted MV and the second predicted MV are determined based on the multiple first matching costs obtained.
65. The method of claim 63 or 64, wherein: The first predicted MV is equal to the MV corresponding to the minimum first matching cost among the obtained first matching costs; The second predicted MV is equal to the MV corresponding to the minimum first matching cost.
66. The method of claim 62, wherein: The determining the first matching cost at least according to the first difference, the second difference and the third difference includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, and a third weighting coefficient for the third difference; The first difference, the second difference and the third difference are weighted according to the first weighting coefficient, the second weighting coefficient and the third weighting coefficient to obtain the first matching cost.
67. The method of claim 62, wherein: The determining a first matching cost at least according to the first difference, the second difference and the third difference includes: Determine a first MVD of the first candidate MV and a second MVD of the second candidate MV; The first matching cost is determined according to the first difference, the second difference, the third difference, the first MVD, and the second MVD.
68. The method of claim 67, wherein: The determining the first matching cost according to the first difference, the second difference, the third difference, the first MVD, and the second MVD includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, a third weighting coefficient for the third difference, a fourth weighting coefficient for the first MVD, and a fifth weighting coefficient for the second MVD; The first difference, the second difference, the third difference, the first MVD and the second MVD are weighted according to the first weighting coefficient, the second weighting coefficient, the third weighting coefficient, the fourth weighting coefficient and the fifth weighting coefficient to obtain the first matching cost.
69. The method of claim 61, wherein: The performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block includes: Determine a second matching cost at least according to the first difference and the second difference, wherein the second matching cost represents a matching degree between the first reference block and the current block; Taking the first candidate MV as a starting point, performing a second search process to obtain a new second matching cost; wherein the second search process includes: taking the first candidate MV as a starting point and taking the second step length as a search step length, searching in the first direction to obtain a new first candidate MV; and determining a new second matching cost according to the second candidate MV and the new first candidate MV; In the case that the second search cut-off condition is not met, taking the new first candidate MV as a starting point, iteratively performing the second search process until the second search cut-off condition is met; When the second search cutoff condition is met, the first predicted MV and the second predicted MV are determined based at least on the obtained plurality of second matching costs and the third difference value.
70. The method of claim 69, wherein: The determining the first predicted MV and the second predicted MV at least according to the obtained plurality of second matching costs and the third difference value comprises: Using the first candidate MV corresponding to the minimum second matching cost among the obtained plurality of second matching costs as the third candidate MV; Determine a fourth difference in sample values between a third reference block pointed to by the third candidate MV and a second reference block pointed to by the second candidate MV; Determine a third matching cost at least according to the fourth difference and the third difference, wherein the third matching cost represents a matching degree between the second reference block and the current block; Taking the second candidate MV as a starting point, performing a third search process to obtain a new third matching cost; wherein the third search process includes: taking the second candidate MV as a starting point and taking a third step length as a search step length, searching in a second direction to obtain a new second candidate MV; and determining a new third matching cost according to the third candidate MV and the new second candidate MV; In the case where the third search cutoff condition is not satisfied, taking the new second candidate MV as a starting point, iteratively performing the third search process until the third search cutoff condition is satisfied; When the third search cutoff condition is met, the first predicted MV and the second predicted MV are determined according to the obtained multiple third matching costs and the third candidate MVs.
71. The method of claim 70, wherein: The determining the first predicted MV and the second predicted MV according to the obtained plurality of third matching costs and the third candidate MVs includes: Using the third candidate MV as the first predicted MV; The second candidate MV corresponding to the minimum third matching cost among the multiple third matching costs obtained is used as the second predicted MV.
72. The method of claim 70, wherein: Determining the second predicted MV according to the obtained plurality of third matching costs and the third candidate MVs includes: Based on determining that the second matching cost corresponding to the third candidate MV is greater than the minimum third matching cost among the obtained multiple third matching costs, the second candidate MV corresponding to the minimum third matching cost is the second predicted MV.
73. The method of claim 72, wherein: Determining the first predicted MV according to the obtained plurality of third matching costs and the third candidate MVs includes: Determine a fifth difference in sample values between a third reference block pointed to by the third candidate MV and a fourth reference block pointed to by the second predicted MV; Modifying the template of the current block according to the template of the fourth reference block to obtain a first modified template of the current block; determining a sixth difference in sample values between the template of the third reference block and the first revised template; Determine a fourth matching cost at least according to the fifth difference value and the sixth difference value, wherein the fourth matching cost represents a matching degree between the third reference block and the current block; Taking the third candidate MV as a starting point, performing a fourth search process to obtain a new fourth matching cost; wherein the fourth search process includes: taking the third candidate MV as a starting point and taking a fourth step length as a search step length, searching in the first direction to obtain a new third candidate MV; and determining a new fourth matching cost according to the new third candidate MV and the second predicted MV; The first predicted MV is determined based on at least the two obtained fourth matching costs.
74. The method of claim 73, wherein: The determining the first predicted MV at least according to the obtained two fourth matching costs includes: When the fourth search cutoff condition is met, the first predicted MV is determined according to the two obtained fourth matching costs.
75. The method of claim 73, wherein: The determining the first predicted MV at least according to the obtained two fourth matching costs includes: When the fourth search cutoff condition is not met, the fourth search process is iterated with the new third candidate MV as the starting point until the fourth search cutoff condition is met, and the first predicted MV is determined based on the multiple fourth matching costs obtained.
76. The method of claim 74 or 75, wherein: The first predicted MV is equal to the third candidate MV corresponding to the minimum fourth matching cost among the obtained fourth matching costs.
77. The method of claim 73, wherein: The sample value of each position of the first revised template is equal to twice the sample value of the corresponding position of the template of the current block minus the sample value of the corresponding position of the template of the fourth reference block.
78. The method of claim 69, wherein: The determining a second matching cost at least according to the first difference and the second difference includes: determining a first weighting coefficient for the first difference and a second weighting coefficient for the second difference; The first difference and the second difference are weighted according to the first weighting coefficient and the second weighting coefficient to obtain the second matching cost.
79. The method of claim 69, wherein: The determining a second matching cost at least according to the first difference and the second difference includes: Determine a first MVD of the first candidate MV; The second matching cost is determined according to the first difference, the second difference and the first MVD.
80. The method of claim 79, wherein: The determining the second matching cost according to the first difference, the second difference and the first MVD includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, and a fourth weighting coefficient for the first MVD; The first difference, the second difference, and the first MVD are weighted according to the first weighting coefficient, the second weighting coefficient, and the fourth weighting coefficient to obtain the second matching cost.
81. The method of claim 70, wherein: The determining a third matching cost at least according to the fourth difference and the third difference includes: determining a sixth weighting coefficient of the fourth difference and a third weighting coefficient of the third difference; The fourth difference and the third difference are weighted according to the sixth weighting coefficient and the third weighting coefficient to obtain the third matching cost.
82. The method of claim 70, wherein: The determining a third matching cost at least according to the fourth difference and the third difference includes: determining a second MVD of the second candidate MV; The third matching cost is determined according to the fourth difference, the third difference and the second MVD.
83. The method of claim 82, wherein: The determining the third matching cost according to the fourth difference, the third difference and the second MVD includes: determining a sixth weighting coefficient of the fourth difference, a third weighting coefficient of the third difference, and a fifth weighting coefficient of the second MVD; The fourth difference, the third difference and the second MVD are weighted according to the sixth weighting coefficient, the third weighting coefficient and the fifth weighting coefficient to obtain the third matching cost.
84. The method of claim 73, wherein: The determining a fourth matching cost at least according to the fifth difference and the sixth difference includes: Determining a third MVD of the third candidate MV; The fourth matching cost is determined according to the fifth difference, the sixth difference and the third MVD.
85. The method of claim 84, wherein: The determining the fourth matching cost according to the fifth difference, the sixth difference and the third MVD includes: determining a seventh weighting coefficient of the fifth difference, an eighth weighting coefficient of the sixth difference, and a ninth weighting coefficient of the third MVD; The fifth difference, the sixth difference and the third MVD are weighted according to the seventh weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient to obtain the fourth matching cost.
86. The method of claim 61, wherein: The performing motion estimation on the current block at least according to the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block includes: In a case where the second difference is greater than the third difference, determining a fifth matching cost based at least on the first difference and the second difference, the fifth matching cost representing a matching degree between the first reference block and the current block; Taking the first candidate MV as a starting point, performing a fifth search process to obtain a new fifth matching cost; wherein the fifth search process includes: taking the first candidate MV as a starting point, taking the fifth step length as a search step length, searching in the first direction to obtain a new first candidate MV; and determining a new fifth matching cost according to the new first candidate MV and the second candidate MV; Determine the first predicted MV based on at least the two obtained fifth matching costs; The second predicted MV is determined according to the first predicted MV and the third difference.
87. The method of claim 86, wherein: The determining the first predicted MV at least according to the obtained two fifth matching costs includes: When the fifth search cutoff condition is met, the first predicted MV is determined according to the two obtained fifth matching costs.
88. The method of claim 86, wherein: The determining the first predicted MV at least according to the obtained two fifth matching costs includes: When the fifth search cutoff condition is not met, the fifth search process is iterated until the fifth search cutoff condition is met, and the first predicted MV is determined based on the obtained multiple fifth matching costs.
89. The method of claim 88, wherein: The first predicted MV is equal to the first candidate MV corresponding to the minimum fifth matching cost among the multiple fifth matching costs obtained.
90. The method of claim 86, wherein: The method further comprises: Determine a seventh difference between sample values of a template of a reference block pointed to by the first initial MV and a template of the current block; Determine a sixth matching cost at least according to the seventh difference, wherein the sixth matching cost represents a matching degree between a reference block pointed to by the first initial MV and the current block; Taking the first initial MV as a starting point, performing a sixth search process to obtain a new sixth matching cost; wherein the sixth search process includes: taking the first initial MV as a starting point, taking the sixth step length as a search step length, searching in the first direction to obtain a new first initial MV; and determining a new sixth matching cost according to the new first initial MV; The first candidate MV is determined based on at least the two obtained sixth matching costs.
91. The method of claim 90, wherein: The determining the first candidate MV at least according to the obtained two sixth matching costs includes: When the sixth search cutoff condition is met, the first candidate MV is determined according to the two obtained sixth matching costs.
92. The method of claim 90, wherein: The determining the first candidate MV at least according to the obtained two sixth matching costs includes: When the sixth search cutoff condition is not met, the sixth search process is iterated until the sixth search cutoff condition is met, and the first candidate MV is determined based on the obtained multiple sixth matching costs.
93. The method of claim 91 or 92, wherein: The first candidate MV is equal to the first initial MV corresponding to the minimum sixth matching cost among the obtained sixth matching costs.
94. The method of claim 86, wherein: The determining a second difference in sample values between the template of the current block and the template of the first reference block comprises: According to the template of the second reference block pointed to by the second candidate MV, the template of the current block is modified to obtain a second modified template of the current block; A second difference in sample values between the second revised template and the template of the first reference block is determined.
95. The method of claim 94, wherein: The sample value at each position of the second revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the second reference block.
96. The method of claim 86, wherein: The determining the second predicted MV according to the first predicted MV and the third difference includes: Determine an eighth difference in sample values between a fifth reference block pointed to by the first prediction MV and a second reference block pointed to by the second candidate MV; Determine a seventh matching cost at least according to the eighth difference value and the third difference value, wherein the seventh matching cost represents a matching degree between the fifth reference block and the current block; Taking the second candidate MV as a starting point, performing a seventh search process to obtain a new seventh matching cost; wherein the seventh search process includes: taking the second candidate MV as a starting point, taking the seventh step length as a search step length, searching in a second direction to obtain a new second candidate MV; and determining a new seventh matching cost according to the new second candidate MV and the first predicted MV; The second predicted MV is determined based on at least the two obtained seventh matching costs.
97. The method of claim 96, wherein: The determining the second predicted MV at least according to the obtained two seventh matching costs includes: When the seventh search cutoff condition is met, the second predicted MV is determined according to the two obtained seventh matching costs.
98. The method of claim 96, wherein: The determining the second predicted MV at least according to the obtained two seventh matching costs includes: When the seventh search cutoff condition is not met, the seventh search process is iterated until the seventh search cutoff condition is met, and the second predicted MV is determined based on the obtained multiple seventh matching costs.
99. The method of claim 97 or 98, wherein: The second predicted MV is equal to the second candidate MV corresponding to the minimum seventh matching cost among the obtained seventh matching costs.
100. The method of claim 96, wherein: The determining a third difference value of sample values between the template of the current block and the template of the second reference block comprises: According to the template of the reference block pointed to by the first predicted MV, the template of the current block is modified to obtain a third modified template of the current block; A third difference in sample values between the third revised template and the template of the second reference block is determined.
101. The method according to claim 100, wherein: The step of correcting the template of the current block according to the template of the reference block pointed to by the first predicted MV to obtain a third corrected template of the current block includes: The sample value at each position of the third revised template is equal to twice the sample value at the corresponding position of the template of the current block minus the sample value at the corresponding position of the template of the reference block pointed to by the first prediction MV.
102. The method of claim 86, 94 or 95, wherein: The determining a fifth matching cost at least according to the first difference and the second difference includes: determining a first weighting coefficient for the first difference and a second weighting coefficient for the second difference; The first difference and the second difference are weighted according to the first weighting coefficient and the second weighting coefficient to obtain the fifth matching cost.
103. The method of claim 86, 94 or 95, wherein: The determining a fifth matching cost at least according to the first difference and the second difference includes: Determine a first MVD of the first candidate MV; The fifth matching cost is determined according to the first difference, the second difference and the first MVD.
104. The method of claim 103, wherein: The determining the fifth matching cost according to the first difference, the second difference and the first MVD includes: determining a first weighting coefficient for the first difference, a second weighting coefficient for the second difference, and a fourth weighting coefficient for the first MVD; The first difference, the second difference and the first MVD are weighted according to the first weighting coefficient, the second weighting coefficient and the fourth weighting coefficient to obtain the fifth matching cost.
105. The method of claim 90, wherein: The step of determining a sixth matching cost at least according to the seventh difference includes: determining a fourth MVD of the first initial MV; The sixth matching cost is determined according to the seventh difference and the fourth MVD.
106. The method of claim 105, wherein: The determining the sixth matching cost according to the seventh difference and the fourth MVD includes: determining a tenth weighting coefficient of the seventh difference and an eleventh weighting coefficient of the fourth MVD; The seventh difference and the fourth MVD are weighted according to the tenth weighting coefficient and the eleventh weighting coefficient to obtain the sixth matching cost.
107. The method of claim 96, 100 or 101, wherein: The determining a seventh matching cost at least according to the eighth difference and the third difference includes: determining a twelfth weighting coefficient of the eighth difference and a third weighting coefficient of the third difference; The eighth difference and the third difference are weighted according to the twelfth weighting coefficient and the third weighting coefficient to obtain the seventh matching cost.
108. The method of claim 96, 100 or 101, wherein: The determining a seventh matching cost at least according to the eighth difference and the third difference includes: determining a second MVD of the second candidate MV; The seventh matching cost is determined according to the eighth difference, the third difference and the second MVD.
109. The method of claim 108, wherein: The determining the seventh matching cost according to the eighth difference, the third difference and the second MVD includes: determining a twelfth weighting coefficient of the eighth difference, a third weighting coefficient of the third difference, and a fifth weighting coefficient of the second MVD; The eighth difference, the third difference and the second MVD are weighted according to the twelfth weighting coefficient, the third weighting coefficient and the fifth weighting coefficient to obtain the seventh matching cost.
110. The method of claim 66, 68, 78, 80, 81, 83, 85, 102, 104, 106, 107 or 109, wherein: The first weighting coefficient to the twelfth weighting coefficient are all preset values.
111. The method of claim 66, 68, 78, 80, 81, 83, 85, 102, 104, 106, 107 or 109, wherein: The method further comprises: The first weighting coefficient, the sixth weighting coefficient, the seventh weighting coefficient, and the twelfth weighting coefficient are determined according to a size of the current block or a size of a template of the current block.
112. The method according to claim 111, wherein: The first weighting coefficient is equal to the number of samples of the template of the current block; The sixth weighting coefficient is equal to the number of samples of the template of the current block; The seventh weighting coefficient is equal to the number of samples of the template of the current block; The twelfth weighting coefficient is equal to the number of samples of the template of the current block.
113. The method of claim 66, 68, 78, 80, 81, 83, 85, 102, 104, 106, 107 or 109, wherein: The method further comprises: The second weighting coefficient, the third weighting coefficient, the eighth weighting coefficient and the ninth weighting coefficient are determined according to the size of the current block or the size of the template of the current block.
114. The method of claim 113, wherein: The second weighting coefficient is equal to the number of samples of the current block; The third weighting coefficient is equal to the number of samples of the current block; The eighth weighting coefficient is equal to the number of samples of the current block; The tenth weighting coefficient is equal to the number of samples of the current block.
115. The method of claim 68, 80, 83, 85, 106 or 109, wherein: The method further comprises: The fourth weighting coefficient, the fifth weighting coefficient, the ninth weighting coefficient, and the eleventh weighting coefficient are determined according to a size of the current block or a size of a template of the current block.
116. The method according to any one of claims 61 to 115, wherein: The distances between a first reference image to which the first reference block belongs and a second reference image to which the second reference block belongs and a current image to which the current block belongs are equal or unequal.
117. The method according to any one of claims 61 to 115, wherein: According to the relationship between the first candidate MV and the second candidate MV, determine whether to execute the step of performing motion estimation on the current block at least based on the first difference, the second difference and the third difference to obtain the first predicted MV and the second predicted MV of the current block.
118. The method of claim 117, wherein: In the case where the first candidate MV is asymmetric to the second candidate MV, the step of performing motion estimation on the current block at least based on the first difference, the second difference and the third difference to obtain a first predicted MV and a second predicted MV of the current block is performed.
119. The method of claim 118, wherein: When the ratio or difference of the absolute value of the first candidate MV and the absolute value of the second candidate MV is not within the corresponding range, and / or the ratio or difference of the angle of the first candidate MV and the angle of the second candidate MV is not within the corresponding range, it is determined that the first candidate MV and the second candidate MV are asymmetric.
120. The method according to any one of claims 61 to 115, wherein: The method further comprises: Determine a residual block of the current block according to an original block of the current block and a predicted block of the current block; A code stream is generated according to the residual block of the current block.
121. A decoding device, the device being applied to a decoder, the device comprising: A first determining module, configured to determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; A second determination module, configured to determine a second difference in sample values between the template of the current block and the template of the first reference block; A third determination module, configured to determine a third difference in sample values between the template of the current block and the template of the second reference block; A first motion estimation module, configured to perform motion estimation on the current block at least according to the first difference, the second difference and the third difference, to obtain a first predicted MV and a second predicted MV of the current block; The first motion compensation module is configured to perform motion compensation on the current block according to the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
122. A decoder comprising a first memory and a first processor; wherein: The first memory is used to store a computer program that can be run on the first processor; The first processor is configured to execute the method according to any one of claims 1 to 60 when running the computer program.
123. A coding device, applied to an encoder, the device comprising: A fourth determination module, configured to determine a first difference in sample values between a first reference block pointed to by a first candidate MV of a current block and a second reference block pointed to by a second candidate MV of the current block; a fifth determining module, configured to determine a second difference in sample values between the template of the current block and the template of the first reference block; a sixth determining module, configured to determine a third difference in sample values between the template of the current block and the template of the second reference block; a second motion estimation module, configured to perform motion estimation on the current block at least according to the first difference, the second difference and the third difference, to obtain a first predicted MV and a second predicted MV of the current block; The second motion compensation module is configured to perform motion compensation on the current block according to the first predicted MV and the second predicted MV to obtain a predicted block of the current block.
124. An encoder comprising a second memory and a second processor; wherein, The second memory is used to store a computer program that can be run on the second processor; The second processor is used to execute the method according to any one of claims 61 to 120 when running the computer program.
125. A code stream obtained by using the encoding method as described in any one of claims 61 to 120.
126. An electronic device comprising: a processor adapted to execute a computer program; A computer-readable storage medium having a computer program stored therein, wherein when the computer program is executed by the processor, the method according to any one of claims 1 to 60 is implemented; or when the computer program is executed by the processor, the method according to any one of claims 61 to 120 is implemented.
127. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, which implements the method according to any one of claims 1 to 60 when executed, or implements the method according to any one of claims 61 to 120 when executed.