Video decoding method, video encoding method and apparatus
Patent Information
- Application Number
- CN202510281471.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2026-09-18
AI Technical Summary
[0003]本申请的发明人在长期的研发过程中,发现基于编码方法还存在一定的局限性,也在一定程度上影响了编解码的效率
[0019] The video decoding method of this application improves upon advanced motion vector prediction technology, thereby increasing the efficiency of video encoding and decoding using advanced motion vector prediction technology.
Smart Images

Figure CN122783641A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video processing technology, and in particular to a video decoding method, a video encoding method, and an apparatus. Background Technology
[0002] Because video image data is relatively large, it usually needs to be encoded and compressed. The compressed data is called a video stream, which is transmitted to the user's end via wired or wireless network for decoding and viewing. The entire video encoding process includes prediction, transform, quantization, and entropy coding. Among them, prediction is divided into intra-frame prediction and inter-frame prediction.
[0003] During the long-term research and development process, the inventors of this application discovered that there are certain limitations in the encoding method, which also affect the efficiency of encoding and decoding to a certain extent. Summary of the Invention
[0004] This application provides a video decoding method, a video encoding method, and an apparatus, which can improve the efficiency of encoding and decoding.
[0005] To achieve the above objectives, this application provides a video decoding method, which includes:
[0006] Analyze the motion vector difference of the current block in the current frame of the video;
[0007] Construct a candidate list for motion vector prediction of the current block;
[0008] Based on the template region of the current block, the motion vector prediction candidate list is adjusted to determine the motion vector prediction value of the current block;
[0009] Based on the motion vector difference and the motion vector prediction value, the actual motion vector of the current block is calculated;
[0010] Based on the actual motion vector, the decoding result of the current block is determined.
[0011] To achieve the above objectives, this application provides a video coding method, which includes:
[0012] Construct a candidate list for motion vector prediction of the current block;
[0013] Based on the template region of the current block, the motion vector prediction candidate list is adjusted to determine the motion vector prediction value of the current block;
[0014] A search is performed in the reference frame of the current block to determine the actual motion vector of the current block;
[0015] Calculate the difference between the actual motion vector and the predicted motion vector value to obtain the motion vector difference of the current block;
[0016] The motion vector difference is written into the bitstream to obtain the encoding result of the current block.
[0017] To achieve the above objectives, this application also provides an electronic device including a processor; the processor is configured to execute instructions to implement the steps of the method described above.
[0018] To achieve the above objectives, this application also provides a computer-readable storage medium for storing instruction / program data that can be executed to implement the above methods.
[0019] The video decoding method of this application improves upon advanced motion vector prediction technology, thereby increasing the efficiency of video encoding and decoding using advanced motion vector prediction technology. Attached Figure Description
[0020] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0021] Figure 1 This is a flowchart illustrating one embodiment of the video decoding method of this application;
[0022] Figure 2 This is a schematic diagram of adjacent airspace candidates for this application;
[0023] Figure 3 This is a schematic diagram of the template area of the current block in this application;
[0024] Figure 4 This is a schematic diagram of the search positions for motion vector prediction candidates in this application;
[0025] Figure 5 This is a flowchart illustrating one embodiment of the video encoding method of this application;
[0026] Figure 6 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;
[0027] Figure 7 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application. In addition, unless otherwise specified (e.g., "or additionally" or "or in alternatives"), the term "or" as used herein refers to a non-exclusive "or" (i.e., "and / or"). Furthermore, the various embodiments described herein are not necessarily mutually exclusive, as some embodiments can be combined with one or more other embodiments to form new embodiments.
[0029] In relevant advanced motion vector prediction techniques, no template-based method for adjusting the candidate list of motion vector prediction is applied. The template-based method for inter-frame prediction does not maximize the gain. For advanced motion vector prediction techniques, templates can be further used to reduce the syntactic expression of motion information and improve compression performance.
[0030] Based on this, this application proposes a video decoding method. This method parses the motion vector difference of the current block in the current frame of a video; constructs a motion vector prediction candidate list for the current block; adjusts the motion vector prediction candidate list based on the template region of the current block to determine the motion vector prediction value of the current block; calculates the actual motion vector of the current block based on the motion vector difference and the motion vector prediction value; and obtains the decoding result of the current block based on the actual motion vector. This method applies a template-based motion information prediction candidate adjustment method in advanced motion vector prediction techniques, enabling template-based inter-frame prediction to achieve significant gains and allowing for flexible adjustment of the motion vector prediction candidate list to improve video encoding and decoding efficiency.
[0031] Specifically, such as Figure 1 As shown, the video decoding method of the first embodiment proposed in this application specifically includes the following steps. It should be noted that the step numbers are for simplification only and are not intended to limit the execution order of the steps. The execution order of each step in this embodiment can be arbitrarily changed without departing from the technical concept of this application. Furthermore, the relevant content of the video decoding method of this embodiment can be combined with the video decoding methods of other embodiments.
[0032] S11: Analyze the motion vector difference of the current block in the current frame of the video.
[0033] In advanced motion vector prediction techniques, the actual motion vector (MV) can be divided into two parts: MVP (Motion Vector Prediction) and MVD (Motion Vector Difference). MVP can be predicted using methods such as spatially adjacent MVs, temporally co-located MVs, and history-based MVs, while MVD is transmitted via the bitstream. At the encoding and decoding ends, MVP is constructed in the same manner. At the encoding end, the optimal MV is determined through motion search, and MVD = MV - MVP is encoded into the bitstream. At the decoding end, MVD is decoded from the bitstream, and MV = MVD + MVP is obtained. Motion compensation is then performed based on MV to obtain the predicted value. Thus, in the video decoding method of this application, the motion vector difference of the current block in the current frame can be parsed. When constructing the motion vector prediction value of the current block, the actual motion vector of the current block can be calculated using the motion vector difference and the motion vector prediction value, thereby facilitating the subsequent decoding result of the current block based on its actual motion vector.
[0034] S12: Construct a candidate list of motion vector predictions for the current block.
[0035] A candidate list of motion vector predictions for the current block can be constructed first, so that the candidate list of motion vector predictions for the current block can be adjusted later to obtain the motion vector prediction value for the current block.
[0036] Optionally, the motion vector prediction candidates in the motion vector prediction candidate list can be derived from at least one of the following: motion information based on historical information, temporal motion information, spatial motion information, preset motion information, and processed motion information. This application designs a richer set of motion vector prediction candidates, thereby increasing the range of motion vector prediction values that can be selected, potentially leading to more accurate motion vector prediction values.
[0037] The spatial motion information can be the motion information of reconstructed image units within the CTU to which the current block belongs. The spatial motion information may include adjacent spatial motion information and / or non-adjacent spatial motion information, where non-adjacent spatial motion information may include location-based candidates, etc.
[0038] Temporal motion information refers to the motion information of image units in other decoded images. Temporal motion information may include the motion information of at least one encoded unit in the temporal co-block of the current block and / or the motion information of surrounding encoded units in the temporal co-block. At least one encoded unit in the temporal co-block may include encoded units at the center position and / or encoded units at corner positions, etc.
[0039] The preset motion information can be a zero vector or a vector of other specified size, such as vector (1,1).
[0040] The processed motion information may include motion information obtained by processing at least one of the following basic motion information: motion information based on historical information, temporal motion information, spatial motion information, and preset motion information. The motion information processing methods include at least one of scaling, weighted processing, preset position refinement, template region-based motion information refinement, and pixel precision processing.
[0041] In one implementation, a processing method can be used to process the basic motion information to obtain processed motion information. For example, a template region-based motion information refinement method can be used to process the basic motion information to obtain processed motion information. Another example is scaling (i.e., scaling) the basic motion information to obtain processed motion information.
[0042] In other implementations, the basic motion information can be processed using at least two methods to obtain the processed motion information.
[0043] In the first application, at least two basic motion information can be scaled (i.e., scaled) to obtain at least two first motion information; then, the at least two first motion information can be weighted and averaged to obtain at least one second motion information; and the second motion information can be pixel-precision processed to obtain the processed motion information.
[0044] In a specific example, the steps of processing motion information to obtain processed motion information may include:
[0045] S121: As Figure 2 As shown, the motion vectors mvX of the adjacent blocks X = A, B, and C of the current block can be scanned sequentially to see if they are available. If C is not available, then D is used as C. Here, MV is available if the coded block is available, it is not intra-frame coded, and the adjacent block X has the same prediction direction as the current block.
[0046] S122: Vector scaling. If mvX is available, scale mvX to obtain the first motion information MVX; otherwise, MVX is a zero vector. The scaling process is as follows:
[0047] The process can be simply expressed as:
[0048] MVX = mvX * current block distance / adjacent block distance
[0049] The distance between adjacent blocks is the difference between the ptr of the adjacent block and the ptr of its reference block, and the distance between the current block and the ptr of its reference block is the difference between the ptr of the current block and the ptr of its reference block.
[0050] wherein, the first motion information may be scaled by the following formula:
[0051] MVA->x=Clip3(-32768,32767,Sign(mvA->x*BlockDistanceE*BlockDistanceA)*((Abs(mvA->x*BlockDistanceE*(16384 / BlockDistanceA))+8192)>>14));
[0052] MVA->y=Clip3(-32768,32767,Sign(mvA->y*BlockDistanceE*BlockDistanceA)*((Abs(mvA->y*BlockDistanceE*(16384 / BlockDistanceA))+8192)>>14));
[0053] MVB->x=Clip3(-32768,32767,Sign(mvB->x*BlockDistanceE*BlockDistanceB)*((Abs(mvB->x*BlockDistanceE*(16384 / BlockDistanceB))+8192)>>14));
[0054] MVB->y=Clip3(-32768,32767,Sign(mvB->y*BlockDistanceE*BlockDistanceB)*((Abs(mvB->y*BlockDistanceE*(16384 / BlockDistanceB))+8192)>>14));
[0055] MVC->x=Clip3(-32768,32767,Sign(mvC->x*BlockDistanceE*BlockDistanceC)*((Abs(mvC->x*BlockDistanceE*(16384 / BlockDistanceC))+8192)>>14));
[0056] MVC->y=Clip3(-32768,32767,Sign(mvC->y*BlockDistanceE*BlockDistanceC)*((Abs(mvC->y*BlockDistanceE*(16384 / BlockDistanceC))+8192)>>14)).
[0057] S123: MVP Derivation. If only one MVX can be obtained, then MVP = MVX; otherwise, process MVX as follows:
[0058] Horizontal component: If the horizontal motion vector components MVX->x of adjacent blocks A, B, and C are all non-zero, and the three have different signs (directions of the components), then the two MVX->x with the same sign are averaged to obtain MVP->x; otherwise, the two MVX->x with the smallest absolute difference are averaged to obtain MVP->x.
[0059] Vertical component: If the horizontal motion vector components MVX->y of adjacent blocks A, B, and C are all non-zero, and the three components have different signs (directions of the components), then the two MVX->y components with the same sign are averaged to obtain MVP->y; otherwise, the two MVX->y components with the smallest absolute difference in MVX->y are averaged to obtain MVP->y.
[0060] Specifically, it can be seen as follows:
[0061] if(((MVA->x<0)&&(MVB->x>0)&&(MVC->x>0))||((MVA->x>0)&&(MVB->x<0)&&(MVC->x<0))){
[0062] MVEPred->x=(MVB->x+MVC->x) / 2
[0063] }
[0064] else if(((MVB->x<0)&&(MVA->x>0)&&(MVC->x>0))||((MVB->x>0)&&(MVA->x<0)&&(MVC->x<0))){
[0065] MVEPred->x=(MVA->x+MVC->x) / 2
[0066] }
[0067] else if(((MVC->x<0)&&(MVA->x>0)&&(MVB->x>0))||((MVC->x>0)&&(MVA->x<0)&&(MVB->x<0))){
[0068] MVEPred->x=(MVA->x+MVB->x) / 2
[0069] }
[0070] else if((Abs(MVA->x-MVB->x)<=Abs(MVB->x-MVC->x))&&(Abs(MVA->x-MVB->x)<=Abs(MVC->x-MVA->x))){
[0071] MVEPred->x=(MVA->x+MVB->x) / 2
[0072] }
[0073] else if((Abs(MVB->x-MVC->x)<=Abs(MVA->x-MVB->x))&&(Abs(MVB->x-MVC->x)<=Abs(MVC->x-MVA->x))){
[0074] MVEPred->x=(MVB->x+MVC->x) / 2
[0075] }
[0076] else{
[0077] MVEPred->x=(MVA->x+MVC->x) / 2
[0078] }
[0079] if(((MVA->y<0)&&(MVB->y>0)&&(MVC->y>0))||((MVA->y>0)&&(MVB->y<0)&&(MVC->y<0))){
[0080] MVEPred->y=(MVB->y+MVC->y) / 2
[0081] }
[0082] else if(((MVB->y<0)&&(MVA->y>0)&&(MVC->y>0))||((MVB->y>0)&&(MVA->y<0)&&(MVC->y<0))){
[0083] MVEPred->y=(MVA->y+MVC->y) / 2
[0084] }
[0085] else if(((MVC->y<0)&&(MVA->y>0)&&(MVB->y>0))||((MVC->y>0)&&(MVA->y<0)&&(MVB->y<0))){
[0086] MVEPred->y=(MVA->y+MVB->y) / 2
[0087] }
[0088] else if((Abs(MVA->y-MVB->y)<=Abs(MVB->y-MVC->y))&&(Abs(MVA->y-MVB->y)<=Abs(MVC->y-MVA->y))){
[0089] MVEPred->y=(MVA->y+MVB->y) / 2
[0090] }
[0091] else if((Abs(MVB->y-MVC->y)<=Abs(MVA->y-MVB->y))&&(Abs(MVB->y-MVC->y)<=Abs(MVC->y-MVA->y))){
[0092] MVEPred->y=(MVB->y+MVC->y) / 2
[0093] }
[0094] else}
[0095] MVEPred->y=(MVA->y+MVC->y) / 2
[0096] }
[0097] S124: AMVR adjustments (AMVR scaling, rounding, range clipping).
[0098] The calculation formula for AMVR adjustment (i.e., pixel precision processing) can be shown below:
[0099] MvEPred->x=Clip3(-32768,32767,Rounding(MvEPred->x,AmvrIndex)< <AmvrIndex);
[0100] MvEPred->y=Clip3(-32768,32767,Rounding(MvEPred->y,AmvrIndex)< <AmvrIndex)。
[0101] As shown above, Amvr technology is used to express the precision of MV. Different amvrIndex values represent different MV precisions. amvrIndex = 0, 1, 2, 3, 4 respectively represent MV precision of 1 / 4, 1 / 2, 1, 2, 4 pixels.
[0102] In the second application, the basic motion information can be scaled (i.e., scaled) to obtain the first motion information; then the first motion information is processed with pixel precision to obtain the processed motion information.
[0103] In a specific example, the steps of processing motion information to obtain processed motion information may include:
[0104] S125: Obtain Hmvp candidates.
[0105] If the number of candidates in Hmvp is greater than AmvrIdx, then the candidate from the end of the Hmvp table, which is amvrIdx, is taken as the candidate vector mvH.
[0106] Otherwise, if the number of candidates in Hmvp is greater than 0 but less than or equal to AmvrIdx, then the last candidate in the Hmvp table is used as the candidate vector mvH;
[0107] Otherwise, mvH is a zero vector.
[0108] S126: Vector scaling. Scale mvH to obtain MVP. The scaling process is similar to the adjacent block vector scaling process of AMVP, see step S122.
[0109] S127: AMVR adjustments (AMVR scaling, rounding, range clipping).
[0110] In the third application, the basic motion information can be scaled (i.e., scaled) to obtain the first motion information; then, the first motion information is refined using a template region-based motion information refinement method to obtain the third motion information; and the third motion information is processed with pixel precision to obtain the processed motion information.
[0111] In the fourth application, the basic motion information can be scaled (i.e., scaled) to obtain the first motion information; the first motion information can be processed with pixel precision to obtain the fourth motion information; then, the fourth motion information can be refined using a template region-based motion information refinement method to obtain the processed motion information.
[0112] In the fifth application, at least two basic motion information can be scaled (i.e., scaled) to obtain at least two first motion information; then, the at least two first motion information can be weighted and averaged to obtain at least one second motion information; then, the second motion information can be refined using a template region-based motion information refinement method to obtain the fifth motion information; finally, the fifth motion information can be pixel-precision processed to obtain the processed motion information.
[0113] In the sixth application, at least two basic motion information can be scaled (i.e., scaled) to obtain at least two first motion information; then, the at least two first motion information can be weighted and averaged to obtain at least one second motion information; the second motion information can be pixel-precision processed to obtain the sixth motion information; then, the sixth motion information can be refined using a template region-based motion information refinement method to obtain the processed motion information.
[0114] The above-mentioned method for refining motion information based on template regions can refer to the refining scheme for motion vector prediction candidates in this application. The difference is that the motion vector prediction candidates to be refined are replaced with the motion information to be refined during the refining process. The detailed steps are described in step S13 and will not be repeated here.
[0115] Furthermore, processed motion information obtained through different processes can be added to the same motion vector prediction candidate list. For example, motion information processed by the fourth application and motion information processed by the fifth application can both be added to the same motion vector prediction candidate list. Moreover, if the processing of motion information involves refining it using template regions, multiple template regions can be used to refine the motion information separately, and the results of these refinements can be added to the same motion vector prediction candidate list. Similarly, if the processing of motion information involves refining it using template regions, multiple cost calculation methods can be used to refine the motion information separately, and the results of these refinements can be added to the same motion vector prediction candidate list.
[0116] S13: Based on the template region of the current block, adjust the motion vector prediction candidate list to determine the motion vector prediction value of the current block.
[0117] After constructing the motion vector prediction candidate list for the current block, the motion vector prediction candidate list can be adjusted based on the template region of the current block. This allows the template-based motion information adjustment method to be applied under the advanced motion vector prediction scheme, enabling the template-based inter-frame prediction method to obtain a significant gain.
[0118] The template region of the current block can be a reconstructed region surrounding the current block, that is, a reconstructed region adjacent to the current block, or a reconstructed region not closely adjacent to the current block. Preferably, the template region of the current block is a reconstructed region adjacent to the current block. When the video decoding order is from top to bottom and from left to right, the template region of the current block can include the reconstructed region above the current block, the reconstructed region at the top left corner of the current block, and / or the reconstructed region to the left of the current block. That is, in one embodiment, as... Figure 3As shown in the second figure, the template region of the current block can be selected only from the available template pixels in the area above the current block; that is, only a few rows of pixels above the current block can be selected as the template region of the current block. In another embodiment, as... Figure 3 As shown in the first figure, the template region of the current block can be determined by using only the template pixels obtainable from the left side of the current block; that is, only a few columns of pixels on the left side of the current block can be selected as the template region of the current block. In another embodiment, as... Figure 3 As shown in the third figure, the template pixels obtainable from the area above and to the left of the current block can be used as the template area of the current block; that is, several rows of pixels above the current block and several columns of pixels to the left of the current block can be selected as the template area of the current block. In another embodiment, as... Figure 3 As shown in the fourth image, the template pixels obtainable from the upper, left, and upper left corner regions of the current block can be used as the template region of the current block (i.e., an L-shaped template). Specifically, several rows of pixels above the current block, several columns of pixels to the left, and pixels in the upper left corner region can be selected as the template region. The size of the template region is unrestricted. For example, the height of the template region in the first direction of the current block can be 2, 4, 6, or 9 pixels, and the first direction can be above and / or below. The width of the template region in the second direction of the current block can be 2, 4, 6, or 9 pixels, and the second direction can be left and / or right.
[0119] Different template region selection schemes can serve as different sub-schemes. This allows region selection syntax to be set in the bitstream; that is, the encoder can set region selection syntax in the bitstream of an image block, using the values of the region selection syntax to represent the selected template region of the image block. Correspondingly, the decoder can interpret the values of the region selection syntax for the current block in the bitstream to determine the selected template region for the current block based on these values. Alternatively, the encoder and decoder can agree on a template region selection scheme, allowing the reconstructed pixel regions at preset positions surrounding the current block to be used as the template region. In this case, the encoder does not need to transmit the region selection syntax.
[0120] In one implementation, the candidate list for motion vector prediction of the current block can be reordered based on the template region of the current block.
[0121] In this implementation, a first template cost for at least a portion of the motion vector prediction candidates in the motion vector prediction candidate list can be determined. The first template cost of the motion vector prediction candidate is calculated based on the predicted value of the template region, and the predicted value of the template region is obtained by the motion vector prediction candidate predicting the template region. Based on the first template cost of at least a portion of the motion vector prediction candidates, the motion vector prediction candidates are reordered.
[0122] Optionally, at least some motion vector prediction candidates can be sorted in ascending order of the first template cost, that is, candidates with lower template costs are placed first. This can be achieved by using template region costs to place more likely motion vector prediction candidates at the top of the list, further reducing the number of bits in the bitstream of selected motion vector prediction candidates and improving coding performance. Of course, in other embodiments, at least some motion vector prediction candidates can also be sorted in descending order of the first template cost.
[0123] In a specific example, reordering at least a portion of the motion vector prediction candidates based on the first template cost of at least a portion of the motion vector prediction candidates can include: reordering the at least a portion of the motion vector prediction candidates based on the first template cost of at least a portion of the motion vector prediction candidates to redetermine the indices of at least a portion of the motion vector prediction candidates. The decoder can then find motion vector prediction candidates from the at least a portion of the motion vector prediction candidates that have the same candidate index value as the current block; and decode the current block based on the motion vector prediction candidates with the same index value. Corresponding to the steps performed by the decoder, the encoder can encode the index of the best motion vector prediction candidate for the current block based on the redetermined index of the at least a portion of the motion vector prediction candidates. Generally, the prediction cost of the current block for motion vector prediction candidates with smaller first template costs is also relatively smaller. Therefore, reordering the at least a portion of the motion vector prediction candidates based on the first template cost allows motion vector prediction candidates with smaller prediction costs to be placed at the top, thus reducing the number of encoded bits for the index of the best candidate for the current block when the best candidate for the current block comes from at least a portion of the motion vector prediction candidates. Alternatively, the encoder can directly select a preset position of the motion vector prediction candidate from the reordered sequence to decode the current block. For example, the first candidate in the reordered sequence can be used to decode the current block. Or, for another example, the second candidate in the reordered sequence can be used to decode the current block.
[0124] In another specific example, the motion vector prediction candidate with the lowest first template cost among at least some motion vector prediction candidates can be directly selected to decode the current block. In one specific example, if the motion vector prediction candidates are sorted in ascending order of first template cost, the first candidate in the reordered motion vector prediction candidates can be selected to decode the current block. In another specific example, if the motion vector prediction candidates are sorted in descending order of first template cost, the last candidate in the reordered motion vector prediction candidates can be selected to decode the current block.
[0125] In another specific example, all motion vector prediction candidates can be sorted based on the first template cost of at least some of the motion vector prediction candidates; a preset number of motion vector prediction candidates with high importance are retained to form a rearranged list. The preset number is less than or equal to the number of motion vector prediction candidates in the motion vector prediction candidate list; the specific value can be set according to the actual situation and is not limited here. In a special example, the preset number can be equal to the number of motion vector prediction candidates to be selected to determine the motion vector prediction value. In this way, after reordering the motion vector prediction candidate list to obtain the rearranged list, all motion vector prediction candidates in the rearranged list can be directly used to determine the motion vector prediction value, without needing to determine the selected motion vector prediction candidate based on its index. Thus, the encoder and decoder do not need to involve the transmission operation of the index of the selected motion vector prediction candidate.
[0126] After rearranging the list as described above, the decoder can select at least one motion vector prediction candidate from the rearranged list by means of index or position, and then determine the motion vector prediction value of the current block based on at least one motion vector prediction candidate.
[0127] In one implementation, a motion vector prediction candidate is selected from the rearrangement list by means of index or position, and the selected motion vector prediction candidate can be used as the motion vector prediction value of the current block.
[0128] In another implementation, a motion vector prediction candidate is selected from the rearranged list by index or position. The selected candidate can then be processed to obtain the motion vector prediction value for the current block. For example, at least one of the following processes can be applied: pixel-level precision processing (e.g., AMVR (Adaptive Motion Vector Resolution) adjustment) and template region-based thinning. In one specific example, the selected candidate can be thinned based on a template region to obtain a thinned prediction value; then, pixel-level precision processing can be applied to the thinned prediction value to obtain the motion vector prediction value for the current block. In yet another specific example, the selected candidate can be pixel-level precision processing to obtain an intermediate prediction value; then, template region-based thinning can be applied to the intermediate prediction value to obtain the motion vector prediction value for the current block.
[0129] In another implementation, at least two motion vector prediction candidates are selected from the rearranged list by means of indexing or position. These candidates are then preprocessed to obtain preprocessed prediction values. Finally, the two preprocessed prediction values are weighted to obtain the motion vector prediction value for the current block. For example, the selected motion vector prediction candidates can undergo at least one of the following processing methods: pixel-precision processing (e.g., AMVR adjustment) and template region-based thinning processing to obtain the preprocessed prediction values. In a specific example, the selected motion vector prediction candidates can undergo template region-based thinning processing to obtain thinned prediction values; the thinned prediction values can then undergo pixel-precision processing to obtain the preprocessed prediction values.
[0130] In another implementation, at least two motion vector prediction candidates are selected from the rearrangement list by means of index or position, and the motion vector prediction value of the current block is obtained by weighting the at least two motion vector prediction candidates.
[0131] In the above implementation, it is necessary to determine the first template cost of the candidates so as to sort the motion vector prediction candidate list based on the first template cost of the candidates.
[0132] Optionally, the template region can be predicted using motion vector prediction candidates to obtain the predicted value of the template region; then, the cost of the template region under the motion vector prediction candidates can be determined based on the predicted value of the template region under the motion vector prediction candidates, that is, the first template cost of the motion vector prediction candidates is obtained.
[0133] Optionally, the first template cost of a motion vector prediction candidate can be calculated based on the reconstructed value of the template region and the predicted value of the template region under the motion vector prediction candidate. The formula for calculating the template cost is not limited; for example, the SAD (Sum of Absolute Differences), SSD (Sum of Squared Differences), or SATD (Sum of Absolute Transform Residuals) formula can be used. In one embodiment, the SAD of the reconstructed value of the template region and the predicted value of the template region under the motion vector prediction candidate can be calculated to obtain the first template cost of the motion vector prediction candidate. In another embodiment, the SATD of the reconstructed value of the template region and the predicted value of the template region under the motion vector prediction candidate can be calculated to obtain the first template cost of the motion vector prediction candidate.
[0134] Different template cost calculation schemes can be used as different sub-schemes. This allows cost calculation syntax to be set in the bitstream; that is, the encoder can set the cost calculation syntax in the bitstream of an image block, so that the value of the cost calculation syntax represents the selected template cost calculation scheme for that image block. Correspondingly, the decoder can interpret the value of the cost calculation syntax of the current block in the bitstream to determine the selected template cost calculation scheme for that block based on the value of the cost calculation syntax. Alternatively, the encoder and decoder can agree on a template cost calculation scheme, so that the cost value of the template region can be calculated using a preset cost calculation formula. In this case, the encoder does not need to transmit the cost calculation syntax. Optionally, corresponding to the sorting process of the motion vector prediction candidate list, a first cost calculation syntax can be set to characterize the calculation formula of the first template cost during the sorting process of the motion vector prediction candidate list. That is, the cost calculation syntax may include a first cost calculation syntax.
[0135] When the scheme of sorting the candidate list constructed by Advanced Motion Vector Prediction (APMP) based on template cost is taken as a sub-scheme of APMP, and the scheme of sorting based on template cost is taken as an optional scheme, the first scheme syntax can be set in the bitstream of the current block. That is, the encoder can write the first scheme syntax into the bitstream of the current block to indicate whether the template-based sorting method is applied to the candidate list of APMP. In this way, the decoder can interpret the first scheme syntax in the bitstream of the current block to confirm whether the template-based sorting method is applied to the candidate list of APMP, that is, to confirm whether the sorting scheme in step S13 is executed after constructing the candidate list of APMP.
[0136] The encoding end can determine the syntax of the first scheme through rate-distortion optimization techniques.
[0137] Among them, the relevant advanced motion vector prediction technology includes two schemes, A and B. Scheme A constructs a candidate list of motion vector predictions based on spatial motion information and calculates the MVP. Scheme B constructs a candidate list of motion vector predictions based on historical motion information and calculates the MVP. When the scheme of ranking the candidate list constructed by the advanced motion vector prediction technology based on template cost is considered a sub-scheme of the advanced motion vector prediction technology, Scheme A or Scheme B can be replaced by the scheme of ranking the candidate list based on template cost. That is, one of Scheme A and Scheme B, along with the scheme of ranking the candidate list based on template cost, can be considered as two schemes of the advanced motion vector prediction technology. Alternatively, the scheme of ranking the candidate list based on template cost can coexist with Schemes A and B, that is, Schemes A and B, along with the scheme of ranking the candidate list based on template cost, can be considered as three sub-schemes of the advanced motion vector prediction technology.
[0138] In other embodiments, the scheme of sorting the candidate list constructed by the advanced motion vector prediction technique based on template cost can be used as the default execution scheme. This allows the scheme of sorting the candidate list based on template cost to be executed by default, meaning the syntax of the first scheme does not need to be transmitted. This adds a designed candidate list reordering method to the related art, and this method can be executed by default or determined based on syntactic expression.
[0139] In one specific embodiment, it is assumed that the length of the initial candidate list is N = 8, and the length of the rearranged candidate list is M = 4.
[0140] The template area uses an L-shaped template area, and the difference calculation method uses SAD.
[0141] Assuming the candidates in the initial candidate list are numbered {0,1,2,3,4,5,6,7} in order of position, and the calculated corresponding SAD costs are {100,80,75,150,200,180,90,120}, then after sorting the template costs from low to high, the four candidates in the rearranged candidate list should correspond to the numbers {2,1,6,0} in the original candidate list. Therefore, the four candidates in the rearranged candidate list are the {2,1,6,0}th candidates in the initial list.
[0142] In another implementation, the candidates in the motion vector prediction candidate list of the current block can be adjusted based on the template region of the current block.
[0143] For example, the motion vector prediction candidates in the candidate list can be refined based on the template region. That is, the candidates in the candidate list of motion vector prediction for the current block can be refined based on the template region, which can provide a more flexible refinement scheme and greatly improve the accuracy of the predicted vector.
[0144] For the decoding end, the motion vector prediction candidates to be refined can be selected motion vector prediction candidates used to determine the motion vector prediction values. After refining the selected motion vector prediction candidates, the motion vector prediction value of the current block can be determined based on the refined motion vector prediction candidates. The motion vector prediction value of the current block can be obtained by referring to the relevant descriptions in the candidate list sorting scheme. For example, it can be obtained by weighting multiple refined motion vector prediction candidates, or by using the refined motion vector prediction candidates as the motion vector prediction value, or by performing post-processing such as pixel precision processing on the refined motion vector prediction candidates. These details will not be elaborated upon here.
[0145] In one embodiment, motion vector prediction candidates to be refined can be found from the motion vector prediction candidate list based on their index; the refined motion vector prediction candidates can be further refined based on a template region to obtain refined motion vector prediction candidates. In another specific embodiment, the motion vector prediction candidate list can be sorted based on a template region to obtain a rearranged list; the refined motion vector prediction candidates can be found from the rearranged list based on their index; the refined motion vector prediction candidates can be further refined based on a template region to obtain refined motion vector prediction candidates. In yet another specific embodiment, the refined motion vector prediction candidates can be found from the motion vector prediction candidate list based on their index; the refined motion vector prediction candidates can be further refined based on a refinement angle and refinement direction to obtain initially refined motion vector prediction candidates; the initially refined motion vector prediction candidates can be further refined based on a template region to obtain refined motion vector prediction candidates. In another specific embodiment, the motion vector prediction candidate list can be sorted based on the template region to obtain a rearranged list; the motion vector prediction candidate to be refined can be found from the rearranged list based on the index of the motion vector prediction candidate; the motion vector prediction candidate to be refined can be refined based on the refinement angle and refinement direction to obtain a preliminary refined motion vector prediction candidate; the preliminary refined motion vector prediction candidate can be refined based on the template region to obtain a refined motion vector prediction candidate.
[0146] For the encoder, the motion vector prediction candidate to be refined can be a selected motion vector prediction candidate used to determine the motion vector prediction value. Accordingly, after refining the selected motion vector prediction candidate, the motion vector prediction value of the current block can be determined based on the refined motion vector prediction candidate. In other embodiments, the motion vector prediction candidate to be refined can be all motion vector prediction candidates in the motion vector prediction candidate list. Then, based on cost comparison or other methods, a refined motion vector prediction candidate for determining the motion vector prediction value is determined from multiple refined motion vector prediction candidates. Finally, the motion vector prediction value of the current block is determined based on the selected refined motion vector prediction candidate.
[0147] Among these, refining the motion vector prediction candidates in the motion vector prediction candidate list based on the template region may include:
[0148] The motion vector prediction candidates are refined using a search method. The refined candidates are determined based on the second template cost during the search process. This second template cost is calculated from the predicted values of the template regions determined during the search. By utilizing template regions for the motion vector prediction candidate search, the accuracy of the candidates is improved, thereby reducing the number of bits used in the MVD representation and resulting in more accurate predictions. The motion vector prediction candidates in the list serve as the starting points for the template-based search, allowing for further refinement of the candidates using this starting point.
[0149] As shown above, during the search, template costs can be calculated for several preset locations around the search starting point, and the results of the current search can be determined based on the second template costs of the preset locations, so as to determine the refined results of the motion vector prediction candidates.
[0150] In the process of calculating template costs at several preset locations around the search starting point, the current template cost calculation location can be used as a reference location for the motion vector prediction candidate to predict the template region of the current block and obtain the current prediction block of the template region. Based on the current prediction block of the template region, the second template cost of the current template cost calculation location is calculated. Then, the second template costs of several preset locations are compared to determine the search result and obtain the refined result of the motion vector prediction candidate (i.e., the refined motion vector prediction candidate).
[0151] The process of calculating the second template cost based on the predicted value of the template region is similar to the calculation process of the first template cost during the sorting process. Specifically, the second template cost for each position can be calculated based on the reconstructed value of the template region and the predicted value of the template region at each position. Preferably, to achieve a better refinement effect, the position with the smallest second template cost among several preset positions can be used as the current search result. Optionally, corresponding to the refinement process of motion vector prediction candidates in the motion vector prediction candidate list, a second cost calculation syntax can be set to characterize the calculation formula of the second template cost during the refinement process of motion vector prediction candidates. That is, the cost calculation syntax can include a second cost calculation syntax. The first cost calculation syntax and the second cost calculation syntax can be the same, that is, the first cost calculation syntax and the second cost calculation syntax can be represented by the same syntax, i.e., the first cost calculation syntax and the second cost calculation syntax are the same syntax in the bitstream. Of course, in other embodiments, the first cost calculation syntax and the second cost calculation syntax can also be represented by different syntaxes in the bitstream.
[0152] Optionally, at least one round of search can be performed, i.e., only one round of search or multiple rounds of search. When performing multiple rounds of search, the starting point of the search is first determined based on the current motion vector prediction candidate to be refined, so as to perform the first round of search and obtain the first round of search results; then in the second round and subsequent rounds of search, the search results of the previous round are used as the starting point of the current round of search, and then the current round of search is performed based on the starting point of the current round of search to obtain the current round of search results, until the termination condition is reached, and the search results of the last round are used as the refined result of the motion vector prediction candidate (i.e., the refined motion vector prediction candidate).
[0153] In one embodiment, when the current search round of the motion vector prediction candidate is equal to 1, the position pointed to by the current motion vector prediction candidate to be refined can be directly used as the search starting point of the current round. Alternatively, in another embodiment, when the current search round of the motion vector prediction candidate is equal to 1, the current motion vector prediction candidate to be refined can be preprocessed, and then the position pointed to by the preprocessed motion vector prediction candidate can be used as the search starting point of the current round. The preprocessing can be integer pixelation; that is, when the current search round of the motion vector prediction candidate is equal to 1, the current motion vector prediction candidate to be refined can be integer pixelated, and then the position pointed to by the integer pixelated motion vector prediction candidate can be used as the search starting point of the current round.
[0154] As shown above, when performing multiple rounds of searching for motion vector prediction candidates, if the current round does not meet the search termination condition, the search will continue; otherwise, if the current round meets the search termination condition, the search will end. In this way, the motion vector prediction candidate corresponding to the search start point or search result of the current round can be used as the refined motion vector prediction candidate.
[0155] The search termination condition can be a search round condition. For example, if the search round of a motion vector prediction candidate is greater than or equal to a first threshold, the search termination condition is met, and the search ends. That is, the step of searching for motion vector prediction candidates is no longer executed. In this way, the motion vector prediction candidate corresponding to the search result position of the last search round can be used as the refined motion vector prediction candidate.
[0156] Alternatively, the search termination condition can also be a search position condition. For example, if the search result position in the current round is the same as the search starting point position in the current round, the search termination condition is met, the search ends, and the step of searching for motion vector prediction candidates is no longer executed.
[0157] The preset locations surrounding the search starting point can be set according to actual conditions and are not limited here. For example, they include, but are not limited to, the following shapes, such as... Figure 4 As shown, Figure 4 The central pentagram represents the starting point of the search, and the diamond-shaped dots represent the search positions (where, Figure 4 The midpoint search location is for illustrative purposes only and does not represent that the search shape only includes the positions at these points.
[0158] (1) Hexagonal search: Several positions forming a hexagon around the starting point;
[0159] (2) Rectangular search: Several positions forming a square around the starting point;
[0160] (3) Rhombus search: Taking the starting point as the center, several positions forming a rhombus around it...
[0161] Furthermore, during multiple rounds of searching, the search shapes in different rounds can be the same or different, and there are no restrictions on this.
[0162] in addition, Figure 4 The distance between positions (i.e., search precision) is not limited and can be any distance, such as 1 / 4, 1 / 2, 1, 2 pixels, etc. Furthermore, during multiple rounds of searching, the search precision in different rounds can be the same or different; there are no restrictions on this.
[0163] When performing multiple rounds of search, the starting points of the search in different rounds can be the same or different; there is no restriction on this. For example, a candidate motion vector prediction can be searched in two rounds, both of which use hexagonal search. Another example is a candidate motion vector prediction can be searched in three rounds: the first round uses a hexagonal search, the second a rectangular search, and the third a rhombus search. Yet another example is a refinement process using an L-shaped template and a difference calculation method using SAD. The refinement process uses R=31 rounds of search, with the first 30 rounds using a hexagonal search (as illustrated in the previous hexagonal search diagram). Figure 4 The positions are the same, and each grid represents 1 / 4 of a pixel. The final round uses a rectangular search (similar to the aforementioned square search). Figure 4 The positions are the same, and each grid represents 1 / 4 of a pixel.
[0164] Furthermore, during the refinement search process, the refinement vector can be range-clipping. This means the search position is limited to a certain range from the initial search starting point. If the search exceeds this range, the position is either invalidated or replaced by the nearest available position within the allowed range. In other words, if the search position exceeds a preset range around the predicted candidate position of the motion vector to be refined, the search position is invalidated, or replaced by the nearest available position within the allowed range.
[0165] Optionally, the motion vector prediction candidate refinement in step S13 can refine and adjust the original motion vector prediction candidates and / or the vectors refined based on a preset method.
[0166] Optionally, the motion vector prediction candidate list is first sorted based on the template region to obtain a rearranged list; at least some of the motion vector prediction candidates in the rearranged list are then refined based on the template region to obtain a refined motion vector prediction candidate list.
[0167] In one example, a candidate MVP list of length 2 can be constructed in step S12, denoted as {MV0, MV1}. The template cost of each MVP candidate is calculated using an L-shaped template region and the SAD calculation method, and the MVP candidate list is then reordered based on this template cost. Assuming the cost of MV0 is 60 and the cost of MV1 is 30, the sorted list is {MV1, MV0}. Only a portion of the reordered MVP candidates can be retained after sorting; for example, only one MVP candidate can be retained, so the reordered list is {MV1}. After obtaining the reordered list, the motion vector prediction candidates in the reordered list can be refined. The refinement steps may include: template cost calculation using an L-shaped template and the SAD cost calculation method; and refining the search method by performing 31 rounds of search, with the first 30 rounds using a hexagonal search shape and the 31st round using a rectangular search, with a search precision of 1 / 4 pixel distance.
[0168] When the scheme of refining the candidate list of advanced motion vector prediction technology based on template cost is taken as a sub-scheme of advanced motion vector prediction technology, and the scheme of refining based on template cost is taken as an optional scheme, a second scheme syntax can be set in the bitstream of the current block. That is, the encoder can write the second scheme syntax into the bitstream of the current block to indicate whether the template-based refinement method is applied to the candidate list of advanced motion vector prediction technology. In this way, the decoder can interpret the second scheme syntax in the bitstream of the current block to confirm whether the template-based refinement method is applied to the candidate list of advanced motion vector prediction technology, that is, to confirm whether the refinement scheme in step S13 is executed after the candidate list of advanced motion vector prediction technology is constructed.
[0169] In other embodiments, the scheme of refining the candidate list constructed by the advanced motion vector prediction technique based on template cost can be used as the default execution scheme. This allows the scheme of refining the candidate list constructed by the advanced motion vector prediction technique based on template cost to be executed by default, meaning the syntax of the second scheme does not need to be transmitted. This allows adding a designed candidate vector refinement method to the related art, and this method can be executed by default or its execution can be determined based on syntactic expression.
[0170] Since step S13 involves both the reordering scheme and the refinement scheme of the motion vector prediction candidate list, if the current block simultaneously enables both schemes, the template regions for these two schemes can be different or the same; no restriction is placed here. For example, the candidate reordering uses the left template, while the refinement process based on the template region uses the top template.
[0171] To facilitate the implementation of methods with different template regions in the two schemes, in the reordering scheme of the motion vector prediction candidate list, the template region of the current block can be called the first template region of the current block, and in the refinement scheme of the motion vector prediction candidate list, the template region of the current block can be called the second template region of the current block. As mentioned above, the first template region can be determined by selecting according to the default settings or by setting it through syntax, and the second template region can be determined by selecting according to the default settings or by setting it through syntax.
[0172] To facilitate setting the first template region and the second template region through syntax, the syntax for setting the first template region can select the syntax for the first region, and the syntax for setting the second template region can select the syntax for the second region.
[0173] In the bitstream, the first region selection syntax and the second region selection syntax can be the same syntax or different syntaxes.
[0174] S14: Calculate the actual motion vector of the current block based on the motion vector difference and the motion vector prediction value.
[0175] After obtaining the motion vector difference and motion vector prediction value of the current block based on the above steps, the actual motion vector of the current block can be calculated based on the motion vector difference and the motion vector prediction value.
[0176] Optionally, the motion vector difference of the current block and the predicted motion vector value can be added together to obtain the actual motion vector of the current block.
[0177] S15: Determine the decoding result of the current block based on the actual motion vector.
[0178] After obtaining the actual motion vector of the current block based on the above steps, the decoding result of the current block can be determined based on the actual motion vector.
[0179] Optionally, this step may include: using the actual motion vector of the current block to predict the predicted value of the current block; decoding to obtain the residual value of the current block; optionally, the bitstream may be processed by entropy decoding, inverse quantization and inverse transformation to obtain the residual value of the current block; and based on the residual value and the predicted value of the current block, obtaining the decoding result of the current block.
[0180] Corresponding to the video decoding method of the first embodiment, this application provides a video encoding method of the first embodiment. Specifically, as... Figure 5As shown, the video encoding method of the first embodiment proposed in this application specifically includes the following steps. It should be noted that the step numbers are for simplification only and are not intended to limit the execution order of the steps. The execution order of each step in this embodiment can be arbitrarily changed without departing from the technical concept of this application. Furthermore, the relevant content of the video encoding method of this embodiment can be combined with the video encoding methods of other embodiments.
[0181] S21: Construct a candidate list of motion vector predictions for the current block in the current frame of the video.
[0182] For specific steps, please refer to step S11, which will not be repeated here.
[0183] S22: Based on the template region of the current block, adjust the candidate list of motion vector predictions to determine the motion vector prediction value of the current block.
[0184] For specific steps, please refer to step S13, which will not be repeated here.
[0185] In one implementation, the motion vector prediction candidate list can be reordered based on the template region of the current block to obtain a rearranged list; each motion vector prediction candidate in the motion vector prediction candidate list can be traversed to calculate its cost; the costs of the motion vector prediction candidates are compared to determine the motion vector prediction value of the current block.
[0186] During the traversal, the currently traversed motion vector prediction candidates can be refined based on template regions to obtain refined prediction vectors. The cost of each refined prediction vector is then determined. For comparison, the costs of the refined prediction vectors of all motion vector prediction candidates in the candidate list are compared to determine the final motion vector prediction candidate and its refined prediction vector. For example, the refined prediction vector with the lowest cost and its corresponding motion vector prediction candidate are selected as the final motion vector prediction candidate and its refined prediction vector. The motion vector prediction value for the current block is then determined based on the final refined prediction vector. This refined prediction vector can be used as the motion vector prediction value for the current block. Alternatively, the refined prediction vector can be further processed to obtain the motion vector prediction value for the current block. For example, pixel-precision processing can be applied to the refined prediction vector to obtain the motion vector prediction value for the current block. If multiple pixel precisions are available, each pixel precision can be used to directly process the refined prediction vector, and the final pixel precision can be determined based on the processing results of multiple pixel precisions. This final pixel precision can then be transmitted to the decoding end.
[0187] Of course, in another embodiment, the costs of motion vector prediction candidates can be directly determined and compared to determine the final motion vector prediction candidate. For example, the motion vector prediction candidate with the lowest cost can be used as the final motion vector prediction candidate. The motion vector prediction value of the current block can then be determined based on the final motion vector prediction candidate. The final motion vector prediction candidate can be used as the motion vector prediction value of the current block. Alternatively, the final motion vector prediction candidate can be further processed to obtain the motion vector prediction value of the current block. For example, pixel-precision processing can be performed on the final motion vector prediction candidate to obtain the motion vector prediction value of the current block. Assuming there are multiple pixel precisions, each pixel precision can be used to directly process the final motion vector prediction candidate, and the final pixel precision can be determined based on the processing results of multiple pixel precisions. The final pixel precision can then be transmitted to the decoding end.
[0188] In another implementation, the motion vector prediction candidate list can be reordered based on the template region of the current block to obtain a rearranged list. The motion vector prediction value of the current block can be determined based on the motion vector prediction candidates at preset positions in the rearranged list. If the encoding and decoding ends agree on this, the index of the motion vector prediction value does not need to be encoded. The decoding end can directly select the motion vector prediction candidate at the preset position according to the agreement, which can reduce the number of indexes of motion vector prediction candidates that need to be encoded, and thus reduce the bit rate of encoding the current block.
[0189] In one embodiment, motion vector prediction candidates at preset positions can be refined based on template regions to obtain refined prediction vectors; the motion vector prediction value of the current block is then determined based on the refined prediction vectors. The refined prediction vectors can be used as the motion vector prediction value of the current block. Alternatively, the refined prediction vectors can be further processed to obtain the motion vector prediction value of the current block; for example, pixel-precision processing can be performed on the refined prediction vectors to obtain the motion vector prediction value of the current block. Assuming there are multiple pixel precisions, the refined prediction vectors can be directly processed using each of the multiple pixel precisions, and the final pixel precision can be determined based on the processing results of the multiple pixel precisions. The final pixel precision can then be transmitted to the decoding end.
[0190] In another embodiment, the motion vector prediction candidate at the preset position may not be refined based on the template region; that is, the motion vector prediction value of the current block can be directly determined based on the motion vector prediction candidate at the preset position. Here, the motion vector prediction candidate at the preset position can be used as the motion vector prediction value of the current block. Alternatively, the motion vector prediction candidate at the preset position can be further processed to obtain the motion vector prediction value of the current block. For example, pixel-precision processing can be performed on the motion vector prediction candidate at the preset position to obtain the motion vector prediction value of the current block. Assuming there are multiple pixel precisions, the motion vector prediction candidate at the preset position can be directly processed using each of the multiple pixel precisions, and the final pixel precision can be determined based on the processing results of the multiple pixel precisions. The final pixel precision can then be transmitted to the decoding end.
[0191] In another implementation, the motion vector prediction candidate list can be traversed to calculate its cost; the costs of the motion vector prediction candidates are compared to determine the motion vector prediction value for the current block. During the traversal, the currently traversed motion vector prediction candidate can be refined based on the template region to obtain a refined prediction vector, and the cost of the refined prediction vector can be determined. During comparison, the costs of the refined prediction vectors of all motion vector prediction candidates in the list can be compared to determine the final motion vector prediction candidate and its refined prediction vector. For example, the refined prediction vector with the lowest cost and its corresponding motion vector prediction candidate can be used as the final motion vector prediction candidate and its refined prediction vector. The motion vector prediction value for the current block is determined based on the final refined prediction vector. The refined prediction vector can be used as the motion vector prediction value for the current block. Alternatively, the refined prediction vector can be further processed to obtain the motion vector prediction value for the current block; for example, pixel-precision processing can be performed on the refined prediction vector to obtain the motion vector prediction value for the current block. Assuming there are multiple pixel accuracies, the thinning prediction vector can be processed directly using each pixel accuracies, and the final pixel accuracies can be determined based on the processing results of multiple pixel accuracies. The final pixel accuracies can then be transmitted to the decoding end.
[0192] In another implementation, motion vector prediction candidates at preset positions in the motion vector prediction candidate list can be refined based on template regions to obtain refined prediction vectors. The motion vector prediction value for the current block is then determined based on these refined prediction vectors. If agreed upon by the encoder and decoder, the index of the motion vector prediction value does not need to be encoded; the decoder can directly select the motion vector prediction candidate at the preset position according to the agreement. This reduces the number of motion vector prediction candidate indices that need to be encoded, thereby reducing the bit rate for encoding the current block. The refined prediction vector can be used as the motion vector prediction value for the current block. Alternatively, the refined prediction vector can be further processed to obtain the motion vector prediction value for the current block. For example, pixel-precision processing can be performed on the refined prediction vector to obtain the motion vector prediction value for the current block. Assuming multiple pixel precisions are available, each pixel precision can be used to directly process the refined prediction vector, and the final pixel precision can be determined based on the processing results of multiple pixel precisions. This final pixel precision can then be transmitted to the decoder.
[0193] In video coding, techniques such as rate-distortion optimization can be used to determine whether to use step S22 or other refinement methods to adjust the motion vector prediction candidate list, and to determine the details in the adjustment process (such as template region selection, template cost calculation formula, optimal refinement distance index and / or optimal refinement direction index, and accuracy in pixel precision processing).
[0194] S23: Search within the reference frame of the current block to determine the actual motion vector of the current block.
[0195] In one implementation, step S23 may refer to the steps for determining the actual motion vector in a relevant advanced motion vector prediction technique.
[0196] In another implementation, step S23 may include: setting the predicted motion vector value of the current block as the starting point of the search, and defining a search window (e.g., a range of ±57 pixels) centered on this point; based on the starting point, the encoder performs an integer-pixel search to find the preliminary optimal MV; the integer-pixel search results need to be further improved in accuracy through sub-pixel interpolation, wherein a sixth-order filter can be used to interpolate the 1 / 2 and 1 / 4 pixel positions, and the refinement strategy can be to perform a sub-pixel-level search around the optimal integer-pixel point (e.g., a rhombus or hexagonal template), calculate the interpolated SAD (sum of absolute differences) or SATD (similar difference in the transform domain), and select the optimal sub-pixel position as the final MV. The integer pixel search algorithm can include: TZSearch (TestZone Search), which uses a diamond search template and expands the search step size step by step (e.g., power-law increases of step size 1, 2, etc.). If the best matching point appears near the starting point, the search is terminated early; otherwise, the full search is refined. Two-stage parallel search is also used. Some algorithms (such as the FHS method) first limit the search range of large blocks through a full search of 4x4 sub-blocks, and then use an adaptive rectangular window for a secondary search, which significantly reduces the amount of computation.
[0197] S24: Calculate the difference between the actual motion vector and the predicted motion vector value to obtain the motion vector difference of the current block.
[0198] After obtaining the actual motion vector and predicted motion vector value of the current block based on the above steps, the motion vector difference of the current block can be calculated based on the actual motion vector and the predicted motion vector value.
[0199] Optionally, the difference between the actual motion vector and the predicted motion vector of the current block can be calculated to obtain the motion vector difference of the current block.
[0200] S25: Write the motion vector difference into the bitstream to obtain the encoding result of the current block.
[0201] After calculating the motion vector difference of the current block through the above steps, the motion vector difference of the current block can be written into the bitstream to obtain the encoding result of the current block.
[0202] Optionally, if the current block is in bidirectional prediction mode, and the forward reference frame (denoted as POC_list0) and backward reference frame (denoted as POC_list1) of the current frame satisfy a mirror relationship with the current frame (denoted as POC_Cur), that is, satisfy the formula: POC_Cur – POC_list0 = POC_list1 – POC_Cur, and the forward prediction mvd0 is the opposite of the backward prediction mvd1, then in step S25, SMVD technology can be used, that is, only the motion vector difference between forward prediction and backward transmission can be transmitted. For example, only the motion vector difference between forward prediction and backward transmission can be transmitted to the decoding end. The decoding end determines the motion vector difference between backward prediction of the current block based on the relationship that the motion vector differences between forward prediction and backward transmission are opposites and the motion vector difference between forward prediction, that is, the motion vector difference between backward prediction is -mvd1 = -mvd0. In other embodiments, under the above circumstances, SMVD can also be disabled, that is, the motion vector difference between forward prediction and backward transmission can be transmitted normally.
[0203] The smvd_flag flag can be used to indicate whether SMVD is enabled.
[0204] As described above, in the aforementioned video encoding and decoding, the adjustment of the motion vector prediction candidate list includes a reordering scheme and / or a refinement scheme for the motion vector prediction candidate list. The application of these two schemes can meet certain restrictions; that is, the reordering scheme and / or refinement scheme for the motion vector prediction candidate list can only be enabled if preset conditions are met. Specifically, if the preset conditions are not met, the prohibited adjustment schemes (i.e., reordering and / or refinement schemes) are not enabled; if the preset conditions are met, the enabled adjustment schemes (i.e., reordering and / or refinement schemes) can be selected based on the actual situation, or the enabled adjustment schemes (i.e., reordering and / or refinement schemes) can be used by default.
[0205] The preset conditions may include a first preset condition, a second preset condition, a third preset condition, a fourth preset condition, a fifth preset condition, and / or a sixth preset condition. Specifically, the reordering scheme of the motion vector prediction candidate list may be enabled only if the current block satisfies the first preset condition and / or the second preset condition. The first preset condition is that the AMVR accuracy of the current block is a first pixel accuracy, and the second preset condition is that the prediction direction of the current block is a first prediction direction. And / or, the refinement scheme of the motion vector prediction candidates may be enabled only if the current block satisfies at least one of the third, fourth, fifth, and sixth preset conditions. The third preset condition is that the AMVR accuracy of the current block is a second pixel accuracy, the fourth preset condition is that the prediction direction of the current block is a second prediction direction, the fifth preset condition is whether the reordering scheme of the motion vector prediction candidate list is enabled or disabled for the current block, and the sixth preset condition is whether SMVD is performed or not for the current block. The first pixel accuracy and the second pixel accuracy may be the same or different, and this is not limited. The first preset direction and the second preset direction may also be the same or different, and this is not limited.
[0206] The preset conditions may include the construction method of the motion vector prediction candidate list and / or whether the motion vector prediction candidate list has been reordered. For example, the refinement scheme of the motion vector prediction candidate list is applied only in the case of regular AMVP or EMVR or the method of reordering the MVP base list based on template region.
[0207] In other words, the preset conditions can include restrictions on pixel precision processing (i.e., AMVR processing). This means that the motion vector prediction candidate list reordering scheme and / or the motion vector prediction candidate list refinement scheme can be applied only under partial AMVR refinement. For example, when the AMVR precision is 1 / 4 pixel precision, the default reordering scheme and the default refinement scheme of the motion vector prediction candidate list are enabled. When the AMVR precision is {1 / 2, 1, 2} pixel precision, the MVP construction selection scheme + the default MVP refinement scheme + MVP refinement restrictions are enabled. That is, the MVP construction methods include {conventional AMVP method, EMVR method, and template region-based MVP reordering method}, and MVP refinement is performed by default only under the conventional AMVP method; MVP refinement is not performed under the other two MVP construction methods. When the AMVR accuracy is {4} pixels, the MVP construction replacement scheme, MVP refinement selection scheme, and MVP refinement restrictions are enabled. Specifically, the EMVR construction method is replaced with a template region-based MVP reordering method. At this time, the MVP construction methods include {the regular AMVP method and the template region-based MVP reordering method}. Whether to perform MVP refinement is determined based on the selected method, and this TM_AMVP scheme is only used in unidirectional prediction; therefore, the original technique is still used in bidirectional prediction. It is understandable that a template region-based adjustment scheme can be introduced at all AMVR accuracies, or it can be introduced at some accuracies while not using the template region-based motion vector prediction candidate list adjustment scheme at other accuracies.
[0208] Preset conditions may include SMVD conditions. For example, if the current AMVP mode executes the refinement scheme of the motion vector prediction candidate list, SMVD cannot be performed. In a specific example, whether to perform MVP refinement can be determined by selection, and if MVP refinement is performed, SMVD cannot be performed.
[0209] The preset conditions may include prediction direction conditions, such as applying a reordering scheme for the motion vector prediction candidate list and / or a refinement scheme for the motion vector prediction candidate list only when forward prediction and / or backward prediction and / or unidirectional prediction and / or bidirectional prediction is performed.
[0210] In other embodiments, the above adjustment scheme may also be without limitations, that is, the reordering scheme of the motion vector prediction candidate list and / or the refinement scheme of the motion vector prediction candidate list may be enabled under any conditions.
[0211] The refinement scheme for the motion vector prediction candidate list mentioned here refers to a scheme that refines the motion vector prediction candidates in the candidate list based on the template region. The reordering of the motion vector prediction candidate list refers to a scheme that reorders the motion vector prediction candidate list based on the template region.
[0212] Furthermore, in bidirectional prediction, the motion vector prediction candidate list adjustment method can be applied independently or simultaneously to each prediction direction. For example, regarding the MVP construction method, when applied independently, the forward and backward MVP construction methods can be the same or different, depending on the selection result; however, when applied simultaneously to each prediction direction, the forward and candidate MVP construction methods should be the same.
[0213] In the above scheme, the corresponding grammatical expressions include, but are not limited to, one or more of the following:
[0214] (1) Switch syntax: Used to express whether the scheme proposed in this proposal is enabled in the codec. Switch syntax can be transmitted in syntax structures including but not limited to Video Parameter Set (VPS), Sequence Parameter Set (SPS), Picture Parameter Set (PPS), Picture Header (PH), and coding unit.
[0215] (2) Scheme syntax: Scheme syntax is used to describe whether and how to execute a scheme, including but not limited to MVP construction selection syntax, MVP candidate index syntax, MVP refinement selection syntax, etc.
[0216] MVP Builder Selection Syntax: In the AMVP model, when multiple MVP build methods exist, this syntax indicates which MVP build method to execute. Specifically, building MVPs using different templates or different computational cost methods are also different MVP build methods. Therefore, the MVP Builder Selection Syntax can also include MVP Builder Template Selection (i.e., First Region Selection Syntax), MVP Builder Template Cost Computation Method (i.e., First Cost Computation Syntax), and Reordering Usage Syntax (i.e., First Solution Syntax), etc.
[0217] MVP Candidate Index Syntax: In the AMVP model, for a given MVP construction method, if the included candidates are not unique, then MVP candidate index syntax is needed to express which candidate to use. In particular, MVP candidates refined through different templates or different computational cost methods can be placed in the same candidate list.
[0218] MVP Refinement Selection Syntax: In the AMVP model, the second-scheme syntax can be used to express whether MVP refinement is performed. If multiple refinement schemes exist, it can be further used to indicate which refinement scheme was selected. In particular, MVP refinement using different templates or different cost calculation methods are also different MVP refinement methods. Therefore, the MVP refinement selection syntax can also include refinement template selection (corresponding to the second region selection syntax), refinement template cost calculation method (corresponding to the second cost calculation syntax), etc.
[0219] (3) Syntactic coding: Syntactic binarization methods include, but are not limited to, unary codes, truncated unary codes, truncated Rice codes, signed fixed-length codes, unsigned fixed-length codes, exponential Golomb codes, etc. Syntactic coding methods include, but are not limited to, high-entropy coding, bypass coding, etc. The coding methods are described in the standard text as descriptors. For specific meanings, please refer to the corresponding standard text.
[0220] The following content presents two examples of grammatical expressions.
[0221] Example 1
[0222] In this embodiment, the decision to perform MVP refinement is made by selection, and if MVP refinement is performed, SMVD cannot be performed.
[0223] In this embodiment, the switch syntax `sps_tm_amvp_enable` is used to express whether to adjust the candidate list for motion vector prediction based on the template region, as shown in Table 1. When `sps_tm_amvp_enable = 0`, it means that the scheme is not enabled; when `sps_tm_amvp_enable = 1`, it means that the scheme is enabled. The specific syntax is described as follows:
[0224] Table 1. Schematic diagram of sequence header definition
[0225] sequence_header(){ … sps_tm_amvp_enable u(1) … }
[0226] When `sps_tm_amvp_enable` = 1, the MVP refinement selection syntax `amvp_refine_flag` is used to indicate whether MVP refinement is performed. `amvp_refine_flag` = 1 indicates MVP refinement is performed; `amvp_refine_flag` = 0 indicates MVP refinement is not performed. The specific syntax description is shown in Table 2, where the variable `SpsTmAmvpEnable` is the value of the syntax element `sps_tm_amvp_enable`, and the variable `AmvpRefineFlag` is the syntax element `amvp_refine_flag`.
[0227] Table 2. Schematic diagram of coding unit definition
[0228]
[0229]
[0230] Example 2
[0231] In this embodiment, the MVP build selection scheme and the default MVP refinement scheme are enabled, and the default MVP refinement scheme is restricted to only the designed MVP build method. That is, the MVP build methods include {conventional AMVP method, EMVR method, and MVP reordering method based on template region}, and MVP refinement is only performed by default in the MVP reordering method based on template region.
[0232] Understandably, for bidirectional prediction, the above scheme can be applied independently to each prediction direction, or simultaneously to each prediction direction. For example, regarding the MVP construction method, when applied independently, the forward and backward MVP construction methods can be the same or different, and the specific construction method can be based on the selection result; while when applied simultaneously to each prediction direction, the forward and candidate MVP construction methods should be the same.
[0233] In this embodiment, the switch syntax sps_tm_amvp_enable can also be used to express whether to enable the adjustment scheme of the candidate list for motion vector prediction based on template region in this embodiment.
[0234] When `sps_tm_amvp_enable` = 1, the MVP construction syntax `amvp_method_flag` is used to express whether the designed template region-based MVP reordering method is adopted. `amvp_method_flag` = 1 indicates adoption; `amvp_method_flag` = 0 indicates disadvantage. Furthermore, assuming that the candidate list length after reordering is only 1 under the template region-based MVP reordering method, a candidate index syntax is not needed. The specific syntax description is shown in Table 3, where the variable `AmvpMethodFlag` is the syntax element `amvp_method_flag`.
[0235] Table 3. Schematic diagram of coding unit definition
[0236]
[0237]
[0238] or
[0239] If an advanced motion vector prediction scheme is applied independently for each prediction direction, the syntax `amvp_method_flagL0 / amvp_method_flagL1` can be constructed based on MVP to express whether the forward and backward predictions adopt the designed template region-based MVP reordering method. When `amvp_method_flagL0 / amvp_method_flagL1 = 1`, it indicates that the method is adopted; when `amvp_method_flagL0 / amvp_method_flagL1 = 0`, it indicates that the method is not adopted. The specific syntax description is shown in Table 4:
[0240] Table 4. Schematic diagram of coding unit definition
[0241]
[0242]
[0243] Example 3
[0244] In this embodiment, when the AMVR precision is 1 / 4 pixel precision, the MVP construction replacement scheme is enabled and the MVP default refinement scheme is enabled. Even if the MVP only adapts to the template-based MVP construction scheme designed in this proposal, the constructed MVP is refined by default.
[0245] When the AMVR precision is {1 / 2, 1, 2} pixel precision, the MVP construction selection scheme is enabled + the MVP default refinement scheme is enabled + MVP refinement limitation is enabled. That is, the MVP construction methods include {regular AMVP method, EMVR method, and MVP reordering method based on template region}, and MVP refinement is only performed by default in the regular AMVP method. MVP refinement is not performed in the other two MVP construction methods.
[0246] When the AMVR accuracy is {4} pixels, the MVP construction replacement scheme is enabled, the MVP refinement selection scheme is enabled, and the MVP refinement is restricted. Specifically, the EMVR construction method is replaced by the designed template region-based MVP reordering method. At this time, the MVP construction method includes {the regular AMVP method and the template region-based MVP reordering method}. The selection method determines whether to perform MVP refinement, and the TM_AMVP scheme is only performed in unidirectional prediction. Therefore, the original technology is still used in bidirectional prediction.
[0247] Since AMVR replaces the existing MVP construction method when the precision is 1 / 4, the extend_mvr_flag syntax (which is used to indicate whether the MVP construction method is regular AMVP or EMVR) is not needed when the AMVR precision is 1 / 4 (i.e., AmvrIndex != 0). At the same time, the amvr_index syntax can be moved before the extend_mvr_flag syntax.
[0248] When AMVR precision is 1 / 2, 1, or 2, it is necessary to select an MVP construction method from {regular AMVP method, EMVR method, and template region-based MVP reordering method}. Therefore, at these precisions, the syntax amvp_method_flag is needed to express the selected MVP construction method.
[0249] When AMVR accuracy is 4, the template region-based MVP reordering method replaces the EMVR method. Therefore, it is necessary to select the MVP construction method from {conventional AMVP method and template region-based MVP reordering method}. Thus, when AMVR accuracy is 4, the semantics of `extend_mvr_flag` needs to change. Originally, `extend_mvr_flag = 1` represented the EMVR construction method; under this scheme, when AMVR accuracy is 4, `extend_mvr_flag = 1` represents the template region-based MVP reordering method. Additionally, for unidirectional prediction, the syntax `amvp_refine_flag` is needed to express whether MVP refinement is performed.
[0250] The specific syntax description is shown in Table 5. The variable `AffineFlag` is assigned the value of the affine prediction mode flag in the syntax `affine_flag`, where the values {0, 1} represent {non-affine prediction mode, affine prediction mode} respectively. `amvr_index` is the AMVR precision index syntax, with values {0, 1, 2, 3, 4} representing {1 / 4, 1 / 2, 1, 2, 4} pixel precision respectively. The variable `AmvrIndex` is assigned the value of this syntax. `inter_pred_ref_mode_index` is a syntax element representing the prediction direction, with values {0, 1, 2} representing {forward prediction, backward prediction, bidirectional prediction} respectively. `InterPredRefModeIndex` is assigned the value of this syntax element.
[0251] Table 5. Schematic diagram of coding unit definition
[0252]
[0253]
[0254] Please see Figure 6 , Figure 6 This is a schematic diagram of one embodiment of the electronic device of this application. The electronic device 20 includes a processor 22, which executes instructions to implement the above-described method. For detailed implementation processes, please refer to the description of the above embodiment; further details will not be repeated here.
[0255] Processor 22 can also be referred to as CPU (Central Processing Unit). Processor 22 may be an integrated circuit chip with signal processing capabilities. Processor 22 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. A general-purpose processor can be a microprocessor, or processor 22 can be any conventional processor.
[0256] The electronic device 20 may further include a memory 21 for storing instructions and data required for the processor 22 to run.
[0257] The processor 22 is used to execute instructions to implement the methods provided by any embodiment of the method of this application and any non-conflicting combination thereof.
[0258] The electronic device in this application may be an encoder or a decoder.
[0259] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a computer-readable storage medium in an embodiment of this application. The computer-readable storage medium 30 in this embodiment stores instruction / program data 31. When executed, this instruction / program data 31 implements the methods provided by any embodiment of the intra-frame decoding method and video decoding method, as well as any non-conflicting combination thereof. In one embodiment, the instruction / program data 31 can be formed into a program file and stored in the storage medium 30 in the form of a software product, so that a computer device (which may be a personal computer, server, or network device, etc.) or processor can execute all or part of the steps of the methods in various embodiments of this application. The aforementioned storage medium 30 includes various media capable of storing program code, such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or terminal devices such as computers, servers, mobile phones, and tablets.
[0260] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0261] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0262] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0263] The above are merely embodiments of this application and do not limit the scope of this patent application. Any equivalent structural or procedural changes made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of this application.
Claims
1. A video decoding method, characterized in that, The method includes: Analyze the motion vector difference of the current block in the current frame of the video; Construct a candidate list for motion vector prediction of the current block; Based on the template region of the current block, the motion vector prediction candidate list is adjusted to determine the motion vector prediction value of the current block; Based on the motion vector difference and the motion vector prediction value, the actual motion vector of the current block is calculated; Based on the actual motion vector, the decoding result of the current block is determined.
2. The method according to claim 1, characterized in that, The template region includes a first template region of the current block. Adjusting the motion vector prediction candidate list based on the template region of the current block to determine the motion vector prediction value of the current block includes: The motion vector prediction candidate list is reordered based on the first template region to obtain a rearranged list; The motion vector prediction value is determined based on at least one motion vector prediction candidate in the rearranged list.
3. The method according to claim 2, characterized in that, The template region includes the second template region of the current block, and the step of determining the motion vector prediction value based on at least one motion vector prediction candidate in the rearrangement list includes: Based on the second template region, at least one motion vector prediction candidate in the rearrangement list is refined to determine the motion vector prediction value of the current block.
4. The method according to claim 2 or 3, characterized in that, When the total number of motion vector prediction candidates in the rearranged list is greater than the number of motion vector prediction candidates in the at least one motion vector prediction candidate list. The step of determining the motion vector prediction value based on at least one motion vector prediction candidate from the rearranged list includes: The motion vector prediction candidate with the same motion vector prediction index value as the current block in the rearrangement list is selected as the at least one motion vector prediction candidate.
5. The video decoding method according to claim 2 or 3, characterized in that, The method further includes: Based on the first scheme syntax of the current block in the bitstream, determine whether to perform a reordering step of the motion vector prediction candidate list.
6. The video decoding method according to claim 2 or 3, characterized in that, The process of reordering the candidate list for motion vector prediction includes: Determine the first template cost of at least a portion of the motion vector prediction candidates in the motion vector prediction candidate list. The first template cost of the motion vector prediction candidate is calculated based on the predicted value of the first template region. The predicted value of the first template region is obtained by the motion vector prediction candidate predicting the first template region. The motion vector prediction candidates are reordered based on the first template cost of the at least some motion vector prediction candidates.
7. The video decoding method according to claim 6, characterized in that, The reordering of the at least partial motion vector prediction candidates based on the first template cost of the at least partial motion vector prediction candidates includes: A preset number of motion vector prediction candidates with low cost from the first template are retained to form the rearrangement list.
8. The method according to claim 6, characterized in that, The first template cost for determining at least a portion of the motion vector prediction candidates in the motion vector prediction candidate list includes: The motion vector prediction candidate is used to predict the first template region to obtain the predicted value of the first template region; Based on the predicted and reconstructed values of the first template region, the first template cost of the motion vector prediction candidate is calculated.
9. The method according to claim 8, characterized in that, The method further includes: The first cost calculation syntax of the current block is interpreted, and the calculation formula of the first template cost is determined based on the value of the first cost calculation syntax; the predicted value of the first template region predicted using the motion vector prediction candidate and the reconstructed value of the first template region are substituted into the calculation formula of the first template cost to calculate the first template cost of the motion vector prediction candidate; and / or, The first region selection syntax of the current block is interpreted, and the first template region is selected from the reconstructed pixel regions in the first direction and / or the second direction of the current block based on the value of the first region selection syntax; or, the reconstructed pixel regions at preset positions around the current block are used as the first template region; wherein, the first direction includes above and / or below, and the second direction includes left and / or right.
10. The method according to claim 1, characterized in that, The motion vector prediction candidate list includes at least one of the following: candidate motion information based on historical information, temporal candidate motion information, spatial candidate motion information, preset motion information, and processed motion information. The processed motion information includes motion information obtained by processing at least one of the following: candidate motion information based on historical information, temporal candidate motion information, spatial candidate motion information, and preset motion information. The motion information processing methods include at least one of scaling processing, weighted processing, preset position refinement processing, motion information refinement processing based on template region, and pixel precision processing.
11. The method according to claim 1, characterized in that, The template region includes a second template region of the current block. Adjusting the motion vector prediction candidate list based on the template region of the current block to determine the motion vector prediction value of the current block includes: Based on the second template region, at least one motion vector prediction candidate in the motion vector prediction candidate list is refined to determine the motion vector prediction value of the current block.
12. The method according to claim 11, characterized in that, The method further includes: Based on the second scheme syntax of the current block in the bitstream, determine whether to perform a refinement step for motion vector prediction candidates.
13. The video decoding method according to any one of claims 11-12, characterized in that, The refinement process for motion vector prediction candidates includes: The motion vector prediction candidates to be refined are refined by a search method. The refined motion vector prediction candidates are determined based on the second template cost in the search process. The second template cost in the search process is calculated based on the prediction value of the second template region determined in the search process.
14. The video decoding method according to claim 13, characterized in that, The refinement process for motion vector prediction candidates includes: Based on the second template region, several rounds of searching are performed on the motion vector prediction candidates to be refined to obtain the refined motion vector prediction candidates. Specifically, if the current search round of the motion vector prediction candidate is equal to 1, the search starting point of the current round is determined based on the motion vector prediction candidate to be refined; if the current search round is greater than 1, the search result of the previous round is used as the search starting point of the current round; in each round of the motion vector prediction candidate search, a second template cost is calculated for a number of preset positions around the search starting point, and the result of the current round search is determined based on the second template cost of the preset positions.
15. The video decoding method according to claim 14, characterized in that, The step of calculating the second template cost for a predetermined number of locations around the search starting point, and determining the result of the current round of search based on the second template cost of the predetermined number of locations, includes: If the search location is outside a preset range around the location pointed to by the motion vector prediction candidate to be refined, the search location is set to invalid, or the search location is replaced by the location closest to the search location within the preset range.
16. The video decoding method according to claim 14, characterized in that, In a single search round, the search shape formed by a predetermined number of locations surrounding the starting point is one of a hexagon, a rhombus, or a rectangle; and / or, The search precision for one round of search is one of the following: 1 / 4, 1 / 2, 1, 2, and 4 pixel distances.
17. The video decoding method according to claim 13, characterized in that, The method further includes: The second cost calculation syntax of the current block is interpreted, and the calculation formula for the second template cost is determined based on the value of the second cost calculation syntax; the predicted value of the second template region predicted using the motion vector prediction candidate and the reconstructed value of the second template region are substituted into the calculation formula for the second template cost to calculate the second template cost of the motion vector prediction candidate; and / or, The second region selection syntax of the current block is interpreted, and the second template region is selected from the reconstructed pixel regions in the first direction and / or the second direction of the current block based on the value of the second region selection syntax; or, the reconstructed pixel regions at preset positions around the current block are used as the second template region; wherein, the first direction includes above and / or below, and the second direction includes left and / or right.
18. The video decoding method according to claim 1, characterized in that, The adjustment scheme for the motion vector prediction candidate list includes a reordering scheme for the motion vector prediction candidate list and / or a refinement scheme for the motion vector prediction candidate list. The step of adjusting the motion vector prediction candidate list based on the template region of the current block to determine the motion vector prediction value of the current block includes: The reordering scheme of the motion vector prediction candidate list is enabled only if the current block meets the first preset condition and / or the second preset condition, wherein the first preset condition is that the adaptive motion vector resolution accuracy of the current block is a first pixel accuracy, and the second preset condition is that the prediction direction of the current block is a first prediction direction; and / or, The refinement scheme of the motion vector prediction candidate is enabled only if the current block satisfies at least one of the following conditions: the third preset condition is that the adaptive motion vector resolution accuracy of the current block is the second pixel accuracy; the fourth preset condition is that the prediction direction of the current block is the second prediction direction; the fifth preset condition is that the current block enables or disables the reordering scheme of the motion vector prediction candidate list; and the sixth preset condition is that the current block performs or does not perform symmetric motion vector difference.
19. A video coding method, characterized in that, The method includes: Construct a candidate list for motion vector prediction of the current block in the current frame of the video; Based on the template region of the current block, the motion vector prediction candidate list is adjusted to determine the motion vector prediction value of the current block; A search is performed in the reference frame of the current block to determine the actual motion vector of the current block; Calculate the difference between the actual motion vector and the predicted motion vector value to obtain the motion vector difference of the current block; The motion vector difference is written into the bitstream to obtain the encoding result of the current block.
20. An electronic device, characterized in that, The electronic device includes a processor; the processor is configured to execute instructions to implement the steps of the method as described in any one of claims 1-19.
21. A computer-readable storage medium having a program and / or instructions stored thereon, characterized in that, When the program and / or instructions are executed, they implement the steps of the method according to any one of claims 1-19.