Video decoding method, video coding method and device

By dividing and sorting the template region of the current block in video encoding, the first template cost of the sub-block prediction mode is determined, which solves the problem of low encoding and decoding efficiency in the existing technology and achieves more efficient video encoding and decoding.

CN121531131APending Publication Date: 2026-02-13ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411070314.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-05
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing video coding methods have limitations in encoding and decoding efficiency, especially in sub-block prediction mode, where they fail to fully utilize template mining performance.

Method used

When the prediction mode of the current block is sub-block prediction mode, the first template cost of the sub-block prediction mode is determined by dividing the template region and sorting them to improve encoding and decoding efficiency.

Benefits of technology

By using a template-based candidate ranking method, the performance of template mining is fully utilized, thereby improving the efficiency of video encoding and decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121531131A_ABST
    Figure CN121531131A_ABST
Patent Text Reader

Abstract

The invention discloses a video decoding method and device and a video coding method and device. The video decoding method comprises the following steps of: dividing a template region of a current block to obtain at least one template sub-block in response to a condition that a prediction mode of the current block is a sub-block prediction mode; determining a first template cost of at least a part of sub-modes in the sub-block prediction mode, the first template cost of the sub-mode being calculated based on a predicted value of a template region, the predicted value of the template region in the sub-mode being formed by combining predicted values of at least one template sub-block in the sub-mode, the predicted value of the at least one template sub-block in the sub-mode is obtained by predicting the motion information of the at least one template sub-block in the sub-mode; sorting the at least part of sub-modes based on the first template cost of the at least part of sub-modes; and decoding the current block based on the at least part of the sorted sub-modes. According to the invention, the coding and decoding efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

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] In response to the prediction mode of the current block being a sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block;

[0007] A first template cost is determined for at least a portion of the sub-patterns in the sub-block prediction pattern. The first template cost of the sub-pattern is calculated based on the predicted value of the template region. The predicted value of the template region in the sub-pattern is composed of the predicted values ​​of at least one template sub-block in the sub-pattern. The predicted value of at least one template sub-block in the sub-pattern is predicted based on the motion information of at least one template sub-block in the sub-pattern.

[0008] Based on the first template cost of the at least some sub-patterns, the at least some sub-patterns are sorted;

[0009] The current block is decoded based on the sorted at least some of the sub-patterns.

[0010] To achieve the above objectives, this application provides a video coding method, which includes:

[0011] In response to the prediction mode of the current block being a sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block;

[0012] A first template cost is determined for at least a portion of the sub-patterns in the sub-block prediction pattern. The first template cost of the sub-pattern is calculated based on the predicted value of the template region. The predicted value of the template region in the sub-pattern is composed of the predicted values ​​of at least one template sub-block in the sub-pattern. The predicted value of at least one template sub-block in the sub-pattern is predicted based on the motion information of at least one template sub-block in the sub-pattern.

[0013] Based on the first template cost of the at least some sub-patterns, the at least some sub-patterns are sorted;

[0014] The current block is encoded based on the sorted at least some of the sub-patterns.

[0015] To achieve the above objectives, this application provides a video decoding method, which includes:

[0016] Construct a candidate list for the current block;

[0017] The candidate list is grouped to obtain at least two candidate groups;

[0018] According to the second template cost of the candidate, all candidates in each candidate group in at least one candidate group are sorted within the group, and / or, at least two candidate groups are reordered between groups to obtain a sorted candidate list; wherein, the second template cost of the candidate is calculated based on the predicted value of the template region of the current block, and the predicted value of the template region is obtained based on the candidate's prediction of the template region;

[0019] The current block is decoded based on the sorted candidate list.

[0020] To achieve the above objectives, this application provides a video coding method, which includes:

[0021] Construct a candidate list for the current block;

[0022] Group the candidate list to obtain at least two candidate groups;

[0023] According to the second template cost of the candidate, all candidates in each candidate group in at least one candidate group are sorted within the group, and / or, at least two candidate groups are reordered between groups to obtain a sorted candidate list; wherein, the second template cost of the candidate is calculated based on the predicted value of the template region of the current block, and the predicted value of the template region is obtained based on the candidate's prediction of the template region;

[0024] The current block is encoded based on the sorted candidate list.

[0025] To achieve the above objectives, this application provides a video decoding method, which includes:

[0026] Construct a candidate list for the current block, which includes motion information candidates based on historical information, high-level motion vector representation candidates, extended temporal motion vector prediction candidates, and / or motion vector adaptive prediction candidates;

[0027] Adjust the candidate list based on the template region of the current block;

[0028] The current block is decoded based on the adjusted candidate list.

[0029] To achieve the above objectives, this application provides a video coding method, which includes:

[0030] Construct a candidate list for the current block, which includes motion information candidates based on historical information, high-level motion vector representation candidates, extended temporal motion vector prediction candidates, and / or motion vector adaptive prediction candidates;

[0031] Adjust the candidate list based on the template region of the current block;

[0032] The current block is encoded based on the adjusted candidate list.

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

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

[0035] The video decoding method of this application applies a template-based candidate sorting method when the prediction mode of the current block is the sub-block prediction mode, so as to make full use of the template mining performance and thus improve the video encoding and decoding efficiency. Attached Figure Description

[0036] 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:

[0037] Figure 1 This is a schematic diagram of the template area for this application;

[0038] Figure 2 This is a schematic diagram of the search position based on the template region correction motion information in this application;

[0039] Figure 3 This is a flowchart illustrating one embodiment of the video decoding method of this application;

[0040] Figure 4 This is a schematic diagram of template region division in one embodiment of the video decoding method of this application;

[0041] Figure 5 This is a schematic diagram illustrating the method for determining sub-block motion information in one embodiment of the video decoding method of this application;

[0042] Figure 6 This is a schematic diagram illustrating another method for determining sub-block motion information in one embodiment of the video decoding method of this application;

[0043] Figure 7 This is a schematic diagram illustrating another method for determining sub-block motion information in one embodiment of the video decoding method of this application;

[0044] Figure 8 This is a flowchart illustrating one embodiment of the video encoding method of this application;

[0045] Figure 9 This is a flowchart illustrating one embodiment of the video decoding method of this application;

[0046] Figure 10 This is a flowchart illustrating one embodiment of the video encoding method of this application;

[0047] Figure 11 This is a flowchart illustrating one embodiment of the video decoding method of this application;

[0048] Figure 12 This is a flowchart illustrating one embodiment of the video encoding method of this application;

[0049] Figure 13 This is a schematic diagram of the structure of one embodiment of the electronic device of this application;

[0050] Figure 14 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation

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

[0052] In related technologies, predictions are made for the current block based on a template. Specifically, this technology first constructs a candidate list of motion information, and then uses its template region cost for sorting and searching.

[0053] The specific process of sorting and searching using the template region cost of the current block is as follows:

[0054] The existing method for generating the MVP (Motion Vector Prediction) list is adopted. The top 4 are selected as candidate MVPs for TM (Temporal Motion). The MVPs are then deduplicated. At the same time, the MVP list is sorted using a template (the smaller the template cost, the shorter the codeword is assigned), and the MVPs are adjusted to integer pixel positions by rounding down.

[0055] like Figure 1 As shown, based on the current block ( Figure 1 The template (template width 4) is constructed around the reconstructed pixels in the unfilled area of ​​the MVP, and template matching search is performed for each available direction. The template region for the current block is... Figure 1 Medium gray filled area.

[0056] In the template matching process, first use Figure 2 The hexagonal search is performed 30 times (using the SAD method to calculate the template cost; the point with the minimum template cost in each search is used as the center point for the next search; if the center point is optimal, the current hexagonal search is terminated), and then... Figure 2 The optimal MV is obtained by performing a square search once. The MV optimized by template matching is used as the final MV of the current block, and the prediction block of the current block is generated.

[0057] The index of the best MVP after template sorting is encoded in the bitstream using variable-length codes.

[0058] In this related technology, the template-based candidate ranking method is limited to the case of non-block prediction. For some block prediction techniques, the template mining performance can be further fully utilized.

[0059] Based on this, this application proposes a video decoding method that, when the prediction mode of the current block is the sub-block prediction mode, applies a template-based candidate sorting method to fully utilize the template mining performance.

[0060] Specifically, such as Figure 3 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.

[0061] S101: In response to the prediction mode of the current block being the sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block.

[0062] When the prediction mode of the current block is the sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block, so that the first template cost of at least some sub-modes in the sub-block prediction mode can be determined based on at least one template sub-block. This facilitates the subsequent sorting of at least some sub-modes using the first template cost of at least some sub-modes, thus allowing the application of a template-based candidate sorting method in the sub-block prediction mode.

[0063] The current block refers to the image block in the image frame that is currently being decoded or is currently to be decoded.

[0064] Optionally, sub-block prediction mode is a technique used in video coding to improve compression efficiency. It allows for the segmentation of large codec blocks to provide finer control over how each sub-block is predicted. Sub-block prediction modes may include ETMVP (Extended Temporal Motion Vector Prediction) mode and / or MVAP (Motion Vector Adaptive Prediction) mode, etc.

[0065] 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. In one embodiment, only the template pixels obtainable from the region above the current block can be used as the template region of 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, only the template pixels obtainable from the region to the left of the current block can be used as the template region of the current block; that is, only a few columns of pixels to the left of the current block can be selected as the template region of the current block. In yet another embodiment, template pixels obtainable from both the region above and the region to the left of the current block can be used as the template region 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 region of the current block. In another embodiment, 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. That is, several rows of pixels above the current block, several columns of pixels to the left of the current block, and pixels in the upper left corner region can be selected as the template region of the current block. The size of the template region is not limited. For example, the height of the template region in the first direction of the current block can be 2, 4, 6, or 9, 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, and the second direction can be left and / or right.

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

[0067] Optionally, although the current block is in sub-block prediction mode, under certain conditions, such as when the cost of partitioning is higher than the cost of not partitioning, the current block may not be partitioned during prediction; that is, it may be predicted as a whole block. When the current block is not partitioned into sub-blocks, the template region of the current block may also not be partitioned into sub-blocks. When the current block is partitioned into sub-blocks, the template region of the current block may also be partitioned into sub-blocks, or it may not be partitioned into sub-blocks, depending on the situation. Thus, the way the template region is partitioned into sub-blocks may include, but is not limited to: the template region not being partitioned into sub-blocks; or, the template region being partitioned into sub-blocks, where the template region in the first direction (which may be called the first template region) can be partitioned into sub-blocks according to the width of the current block's sub-blocks, the template region in the second direction (which may be called the second template region) can be partitioned into sub-blocks according to the height of the current block's sub-blocks, and the template region located between adjacent first and second directions may not be partitioned into sub-blocks. The first direction can be upward and / or downward, and the second direction can be left and / or right. In one embodiment, the first direction is upward and the second direction is left. The template area located between the adjacent first and second directions refers to the template area located between the top and left, that is, the template area in the upper left corner.

[0068] As shown above, in one embodiment, the pixel regions in the template region of the current block located in the first direction of the current block can be divided into sub-blocks according to their width, and / or, the pixel regions in the template region of the current block located in the second direction of the current block can be divided into sub-blocks according to their height. In one example, the pixel regions in the template region of the current block located in the first direction of the current block can be divided into sub-blocks according to the width of the current block, and / or, the pixel regions in the template region of the current block located in the second direction of the current block can be divided into sub-blocks according to the height of the current block. In another example, the pixel regions in the template region of the current block located in the first direction of the current block can be divided into sub-blocks at equal intervals along the width direction, and / or, the pixel regions in the template region of the current block located in the second direction of the current block can be divided into sub-blocks at equal intervals along the height direction.

[0069] In another embodiment, the template region of the current block can be divided based on the current block's partitioning method. For example, Figure 4 As shown, the sub-block dividing lines in the current block can be extended to the template area to divide the template area into sub-blocks using the extension lines of the sub-block dividing lines of the current block.

[0070] After dividing the template region of the current block into sub-blocks using the above-described template region division method, the template region of the current block can be divided into at least one template sub-block, thus obtaining at least one template sub-block.

[0071] Different sub-block acquisition schemes can be used as different sub-schemes. This allows the sub-block acquisition syntax to be set in the bitstream; that is, the encoder can set the sub-block acquisition syntax in the bitstream of an image block, using the values ​​of the sub-block acquisition syntax to represent the sub-block division method of the template region of the image block. Correspondingly, the decoder can interpret the values ​​of the sub-block acquisition syntax of the current block in the bitstream to determine the sub-block division method of the template region of the current block based on these values. Alternatively, the encoder and decoder can agree on a sub-block division scheme; in this case, the encoder may not need to transmit the sub-block acquisition syntax.

[0072] S102: Determine the first template cost of at least some of the sub-patterns in the sub-block prediction pattern.

[0073] After dividing the template region of the current block to obtain at least one template sub-block, the first template cost of at least some sub-modes in the sub-block prediction mode can be determined based on at least one template sub-block. This facilitates the subsequent sorting of at least some sub-modes using the first template cost of at least some sub-modes, thus enabling the application of a template-based candidate sorting method in the sub-block prediction mode.

[0074] The first template cost of the sub-mode can be calculated based on the predicted value of the template region. The predicted value of the template region in the sub-mode is composed of the predicted values ​​of at least one template sub-block in the sub-mode. The predicted value of at least one template sub-block in the sub-mode is predicted based on the motion information of at least one template sub-block in the sub-mode.

[0075] As described above, the motion information of at least one template sub-block in the sub-pattern can be determined first. Optionally, the motion information of the template sub-block can be determined based on the motion information of the current block sub-block that is closest to the template sub-block, the method of obtaining the motion information of the current block sub-block that is closest to the template sub-block, or the motion information of the template sub-block at the corresponding position of the reference block template of the current block.

[0076] In one embodiment, the motion information of the current block that is closest to the template sub-block can be used as the motion information of the template sub-block. For example, such as Figure 5As shown, if the sub-block prediction mode is MVAP, the current block includes sub-blocks ①, ②, ③, and ④. Assuming the sub-mode of the current block is specifically the horizontal mode of MVAP, sub-blocks ① and ② use motion information at position A1, and sub-blocks ③ and ④ use motion information at position A3. The template region of the current block includes template sub-blocks D1+D2, E1+E2, A1+A2, and A3+A4. The motion information of sub-block ① can be used as the motion information of template sub-blocks A1+A2 and D1+D2, meaning that template sub-blocks A1+A2 and D1+D2 use motion information at position A1. The motion information of sub-block ② can be used as the motion information of template sub-block E1+E2, meaning that template sub-block E1+E2 also uses motion information at position A1. The motion information of sub-block ③ can be used as the motion information of template sub-block A3+A4, meaning that template sub-block A3+A4 uses motion information at position A3.

[0077] In another embodiment, the motion information of the template sub-block can be obtained using a method that acquires the motion information of the current sub-block that is closest to the template sub-block. For example, such as... Figure 5As shown, if the sub-block prediction mode is MVAP, the current block includes sub-blocks ①, ②, ③ and ④. Assume that the sub-mode of the current block is specifically the horizontal mode of MVAP, that is, sub-blocks ① and ② use the motion information of A1, and sub-blocks ③ and ④ use the motion information of position A3; the template region of the current block includes template sub-blocks D1+D2, E1+E2, A1+A2 and A3+A4. The template sub-blocks can also obtain motion information through the horizontal mode of MVAP. In a specific example, without further expanding the motion information reference area—that is, the motion information reference list still includes the motion information of sub-blocks A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, and E4—if the motion information of the current sub-block closest to the template sub-block can be obtained from the motion information of these sub-blocks, then the obtained motion information is used as the motion information of the template sub-block. For example, template sub-blocks D1+D2 and E1+E2 can obtain the motion information at position C from the motion information of sub-blocks A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, and E4 using MVAP's horizontal mode. Thus, the motion information at position C can be used as the motion information of template sub-blocks D1+D2 and E1+E2. Motion information of 1+E2; If motion information cannot be obtained from the motion information of sub-blocks A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, and E4 using the motion information acquisition method of the current sub-block closest to the template sub-block, then the motion information of the current sub-block closest to the template sub-block or the preset motion information can be used as the motion information of the template sub-block. For example, if the motion information of template sub-blocks A1+A2 and A3+A4 cannot be obtained through the horizontal mode of MVAP, the motion information of the current sub-block ① closest to template sub-block A1+A2 can be used as the motion information of template sub-block A1+A2, that is, template sub-block A1+A2 uses the motion information of position A1. Similarly, the motion information of the current sub-block ③ closest to template sub-block A3+A4 can be used as the motion information of template sub-block A3+A4, that is, template sub-block A3+A4 uses the motion information of position A3. In another specific example, such as Figure 6As shown, the motion information reference area can be further expanded. That is, in addition to the motion information of sub-blocks A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, and E4, the motion information reference list can also include the motion information of sub-blocks F, G1, G2, G3, G4, G5, and G6. If the motion information of the current block closest to the template sub-block is used, it can be obtained from A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, E4, F, G1, G2, G3, G4, G... Motion information is obtained from the motion information of sub-blocks 5 and G6. This obtained motion information is then used as the motion information for template sub-blocks. For example, template sub-blocks D1+D2 and E1+E2 can obtain the motion information at position C from the motion information of sub-blocks A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, E4, F, G1, G2, G3, G4, G5, and G6 using MVAP's horizontal mode. Thus, the motion information at position C can be used as the motion information for template sub-blocks D1+D2 and E1+E2. For example, template sub-block A1+A2 obtains the motion information of position G1 from the motion information of sub-blocks A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, E4, F, G1, G2, G3, G4, G5, and G6 using MVAP horizontal mode. Thus, the motion information of position G1 can be used as the motion information of template sub-block A1+A2. Alternatively, if the motion information of the current sub-block closest to the template sub-block is used to obtain the motion information from A1, A2, A3, A4, B1, B2, C, D1, D2, E1, E2, E3, E4, ... If motion information cannot be obtained from the motion information of sub-blocks F, G1, G2, G3, G4, G5, and G6, then the motion information of the current sub-block closest to the template sub-block, or the preset motion information, can be used as the motion information of the template sub-block. For example, if the motion information of G3 is unavailable, then the template sub-block A3+A4 cannot obtain motion information through the horizontal mode of MVAP. In this case, the motion information of the current sub-block ③ closest to the template sub-block A3+A4 can be used as the motion information of the template sub-block A3+A4, that is, the template sub-block A3+A4 uses the motion information of position A3. In summary, in this embodiment, the motion information of the template sub-block can be obtained using the motion information acquisition method of the current sub-block closest to the template sub-block; if it cannot be obtained, the motion information of the current sub-block closest to the template sub-block, or the preset motion information, can be used as the motion information of the template sub-block.

[0078] In another embodiment, the motion information of the template sub-block at its corresponding position in the reference block template can be used as the motion information of the template sub-block. For example, as... Figure 7 As shown, Figure 7 The left-middle image shows the ETMVP reference block (the unfilled area in the image) and its corresponding template (the area filled with diagonal lines). Figure 7 The middle right image shows the current ETMVP block (the unfilled area in the image) and its corresponding template (the diagonally filled area). In this example, the reference block is located at the position of the corresponding block after being offset downwards. The current block's sub-blocks use the motion information of the corresponding sub-blocks in the reference block. The template area is set to the template pixels obtainable from the top, left, and top-left corners of the block. The top template area is divided into sub-blocks according to the width of the current block's sub-blocks, and the left template area is divided into sub-blocks according to the height of the current block's sub-blocks, i.e., as shown below. Figure 7 The template region shown is divided into 9 sub-blocks. Similar to the method used to obtain motion information for the current sub-block, each template sub-block uses the motion information of the corresponding sub-block in the reference template. Furthermore, if the motion information of the template sub-block at its corresponding position in the reference template cannot be obtained due to reasons such as the template sub-block's position exceeding the image boundary or the maximum coding unit boundary, or the motion information of the template sub-block at its corresponding position in the reference template being unavailable, the motion information of the current sub-block or preset motion information that is closest to the template sub-block can be used as the motion information of the template sub-block. The positional relationship between the aforementioned reference template and the current block's reference block is equivalent to the positional relationship between the template region and the current block.

[0079] The motion information of each template sub-block in the template area of ​​each sub-pattern in at least some sub-patterns can be determined based on the above method.

[0080] Different sub-block motion information acquisition schemes can be used as different sub-schemes. This allows the sub-block motion information acquisition syntax to be set in the bitstream; that is, the encoder can set the sub-block motion information acquisition syntax in the bitstream of an image block, so that the value of the sub-block motion information acquisition syntax represents the selected sub-block motion information acquisition scheme for the image block. Correspondingly, the decoder can interpret the value of the sub-block motion information acquisition syntax of the current block in the bitstream to determine the selected sub-block motion information acquisition scheme for the current block based on the value of the sub-block motion information acquisition syntax. Alternatively, the encoder and decoder can agree on a sub-block motion information acquisition scheme, so that the agreed sub-block motion information acquisition scheme can be used as the sub-block motion information acquisition scheme for the current block. In this case, the encoder may not need to transmit the sub-block motion information acquisition syntax.

[0081] Among these, at least some of the sub-patterns can be different sub-patterns under a single sub-block prediction technique. For example, the at least some of the sub-patterns mentioned above could be horizontal and vertical patterns under the MVAP prediction technique. As another example, the at least some of the sub-patterns mentioned above could be vertical upward offset, horizontal right offset, vertical downward offset, and horizontal left offset patterns under the ETMVP prediction technique.

[0082] In other implementations, at least some of the sub-modes mentioned above can be different sub-modes under at least two sub-block prediction techniques. For example, at least some of the sub-modes mentioned above can be horizontal and / or vertical modes under MVAP prediction technique, and vertical upward offset mode, horizontal right offset mode, vertical downward offset mode and / or horizontal left offset mode under ETMVP prediction technique, etc.

[0083] After determining the motion information of the template sub-blocks in the template region under the sub-mode based on the above method, the template sub-blocks can be predicted based on the motion information to obtain the predicted value of the template sub-blocks, thereby obtaining the predicted value of the template region under the sub-mode; then, the cost value of the template region under the sub-mode can be determined based on the predicted value of the template region under the sub-mode, that is, the first template cost of the sub-mode can be obtained.

[0084] Optionally, the first template cost of the sub-mode can be calculated based on the reconstructed value of the template region and the predicted value of the template region under the sub-mode. The formula for calculating the template cost is not limited; for example, the SAD calculation formula or the SATD calculation 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 sub-mode can be calculated to obtain the first template cost of the sub-mode. In another embodiment, the SATD of the reconstructed value of the template region and the predicted value of the template region under the sub-mode can be calculated to obtain the first template cost of the sub-mode.

[0085] S103: Sort at least some of the sub-patterns based on the first template cost of at least some of the sub-patterns.

[0086] Optionally, after determining the first template cost of at least some of the sub-patterns, the at least some of the sub-patterns can be sorted.

[0087] Optionally, at least some sub-patterns can be sorted in ascending order of the first template cost, that is, the sub-patterns with lower template costs are placed first to reduce the number of bits transmitted in the bitstream. Of course, in other embodiments, at least some sub-patterns can also be sorted in descending order of the first template cost.

[0088] When at least some sub-patterns include different sub-patterns under at least two sub-block prediction techniques, the sub-patterns under different sub-block prediction techniques can be sorted separately, that is, the sub-patterns under each sub-block prediction technique are sorted independently. For example, if at least some sub-patterns include two seed patterns of MVAP and four sub-patterns of ETMVP, then the two seed patterns of MVAP can be sorted independently based on the first template cost of the two seed patterns of MVAP, and the four sub-patterns of ETMVP can be sorted independently based on the first template cost of the four sub-patterns of ETMVP.

[0089] Of course, in other embodiments, when at least some sub-patterns include different sub-patterns under at least two sub-block prediction techniques, the sub-patterns under at least two sub-block prediction techniques can be sorted. For example, if at least some sub-patterns include two seed patterns of MVAP and four sub-patterns of ETMVP, then the two seed patterns of MVAP and the four sub-patterns of ETMVP can be sorted based on the first template cost of the two seed patterns of MVAP and the first template cost of the four sub-patterns of ETMVP.

[0090] Furthermore, in this video decoding method, a candidate list for the current block can be constructed, and the constructed candidate list includes at least some of the aforementioned sub-patterns; the candidate list can also be grouped to obtain at least two candidate groups; thus, in step S103, all candidates in the candidate groups can be sorted within the group based on the first template cost of at least some sub-patterns to obtain a sorted candidate list; so that the current block can be decoded subsequently based on the sorted candidate list. Specifically, the candidates in the candidate groups containing sub-patterns can be sorted within the group based on the first template cost of at least some sub-patterns. For candidates that are not sub-patterns but need to be sorted, their second template cost can be calculated; thus, the second template cost of the candidates that are not sub-patterns but need to be sorted, and the first template cost of the sub-patterns, can be used to sort all candidates in each candidate group within at least one candidate group.

[0091] S104: Decode the current block based on at least some of the sorted sub-patterns.

[0092] Alternatively, the current block can be decoded based on at least some of the reordered sub-patterns.

[0093] In one embodiment, in step S103, at least some sub-patterns are sorted based on the first template cost of at least some sub-patterns to redetermine the index of at least some sub-patterns; thus, step S104 can find sub-patterns from the at least some sub-patterns that have the same sub-pattern index value as the current block; the current block is decoded based on the sub-patterns with the same index value. Corresponding to the decoding end performing step S104, the encoding end can encode the index of the best mode of the current block based on the index redetermined by at least some sub-patterns. Generally, the prediction cost of the current block is relatively small for sub-patterns with a smaller first template cost. Thus, by reordering at least some sub-patterns based on the template cost, sub-patterns with smaller prediction costs of the current block can be placed first, thereby reducing the encoding bits of the index of the best mode of the current block when the best mode of the current block comes from at least some sub-patterns.

[0094] In another embodiment, the sub-pattern with the lowest first template cost among at least some sub-patterns can be directly selected to decode the current block. In a specific example, if the at least some sub-patterns are sorted in ascending order of first template cost, the first sub-pattern in the reordered at least some sub-patterns can be selected to decode the current block. In another specific example, if the at least some sub-patterns are sorted in descending order of first template cost, the last sub-pattern in the reordered at least some sub-patterns can be selected to decode the current block.

[0095] Optionally, decoding the current block based on the sub-mode may include: determining the predicted value of the current block under the sub-mode, i.e., obtaining the predicted value of the current block by predicting the current block based on the sub-mode; decoding to obtain the residual value of the current block, optionally, the bitstream may be processed by entropy decoding, inverse quantization and inverse transform to obtain the residual value of the current block; and obtaining the decoding result of the current block based on the residual value and the predicted value of the current block.

[0096] Corresponding to the video decoding method of the first embodiment, this application provides a video encoding method of the first embodiment. Specifically, as... Figure 8 As 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.

[0097] S201: In response to the prediction mode of the current block being a sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block.

[0098] For specific steps, please refer to step S101, which will not be repeated here.

[0099] S202: Determine the first template cost of at least some of the sub-patterns in the sub-block prediction pattern.

[0100] For specific steps, please refer to step S102, which will not be repeated here.

[0101] S203: Sort at least some of the sub-patterns based on the first template cost of at least some of the sub-patterns.

[0102] For specific steps, please refer to step S103, which will not be repeated here.

[0103] S204: Encode the current block based on at least some of the sorted sub-patterns.

[0104] Alternatively, the current block can be encoded based on at least some of the reordered sub-patterns.

[0105] In one embodiment, in step S203, at least some sub-patterns are sorted based on the first template cost of at least some sub-patterns to redetermine the index of at least some sub-patterns; thus, step S204 can determine the best prediction pattern for the current block based on at least some sub-patterns, and since the best prediction pattern for the current block comes from at least some sub-patterns, the redetermined index of the best prediction pattern can be encoded.

[0106] In another embodiment, the sub-pattern with the lowest first template cost among at least some sub-patterns can be directly selected to encode the current block. In a specific example, if the at least some sub-patterns are sorted in ascending order of first template cost, the first sub-pattern in the reordered at least some sub-patterns can be selected to encode the current block. In another specific example, if the at least some sub-patterns are sorted in descending order of first template cost, the last sub-pattern in the reordered at least some sub-patterns can be selected to encode the current block. In this embodiment, the encoding and decoding ends can agree to directly select the sub-pattern with the lowest first template cost among the at least some sub-patterns. In this case, the index of the selected sub-pattern does not need to be transmitted. Of course, the encoding end can also transmit the index of the selected sub-pattern.

[0107] Among the aforementioned related technologies, the template-based candidate sorting method only includes one approach that constructs, sorts, and searches candidates based on existing MVP candidate generation methods. Other candidates are also very valuable, and further template-based sorting can unlock more coding performance and save more coding bits. Therefore, there is still room for performance improvement in existing technologies.

[0108] Based on this, this application proposes a video decoding method that, when the prediction modes of the current block include MVAP, UMVE, ETMVP, and HMVP candidates, applies a template-based candidate sorting method to fully utilize template mining performance.

[0109] Specifically, such as Figure 9 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.

[0110] S301: Construct a candidate list for the current block.

[0111] During the decoding of the current block, a candidate list for the current block can be constructed so that the current block can be decoded subsequently based on the candidate list.

[0112] Optionally, the candidate list for the current block may include a candidate list of motion information for the current block. For example, the candidate list for the current block may include HMVP (History-based Motion Vector Prediction) candidates and / or UMVE (Ultimate Motion Vector Expression) candidates for the current block. As another example, the candidate list for the current block may include spatial candidates, temporal candidates, spatially derived candidates, temporally derived candidates, and / or history-based candidates; wherein, spatial candidates are motion information of reconstructed image units in the current image, temporal candidates are motion information of image units in other decoded images, spatially derived candidates are motion information obtained by scaling, offsetting, and / or weighted averaging of the motion information of reconstructed image units in the current image, and temporally derived candidates are motion information obtained by scaling, offsetting, weighted averaging, and other methods of motion information of image units in other decoded images. Spatial candidates may include adjacent spatial candidates and non-adjacent spatial candidates, wherein non-adjacent spatial candidates may include candidates obtained based on location, etc. In addition, spatial derivation candidates can include candidates based on spatial candidate offsets.

[0113] Optionally, the candidate list for the current block may include a list of sub-pattern candidates under at least one prediction technique for the current block. For example, the candidate list for the current block may include MVAP sub-pattern candidates and / or ETMVP sub-pattern candidates for the current block.

[0114] In one implementation, the candidate list constructed using traditional prediction techniques can be used as the candidate list to be adjusted. For example, the MVAP list of the current block can be directly used as the candidate list to be adjusted. Another example is the skip / direct mode (also known as the merge mode), which can be directly used as the candidate list to be adjusted. In this implementation, the scheme of adjusting the candidate list constructed using traditional prediction techniques based on template cost can be considered a mode of traditional prediction techniques. In a specific example, the skip / direct mode is used as the candidate list to be sorted. The encoder and decoder default to adjusting the skip / direct candidate list using template regions (e.g., sorting), so the skip / direct prediction technique will use template regions to adjust the candidate list by default. In another specific example, assuming the skip / direct mode is used as the candidate list to be adjusted, adjusting the candidates based on template regions can be considered a new method in the skip / direct prediction technique, with both the no-adjustment method and the skip / direct prediction technique being optional modes. Thus, the two modes compete for selection at the encoder end, and at the decoder end, based on the syntax, if the adjusted mode is selected, it is adjusted according to the template region in the same way as at the encoder end, and finally, the corresponding mode is selected according to the index of the selected mode transmitted. When the scheme of adjusting the candidate list constructed by the traditional prediction technique based on template cost is taken as a mode of the traditional prediction technique, and the scheme of adjusting based on template cost is taken as an optional mode, a first switch syntax can be set in the bitstream of the current block. That is, the encoder can write the first switch syntax into the bitstream of the current block to indicate whether to apply the template-based adjustment method to the candidate list of the traditional prediction technique. In this way, the decoder can interpret the first switch syntax in the bitstream of the current block to confirm whether to apply the template-based adjustment method to the candidate list of the traditional prediction technique, that is, to confirm whether to execute step S302 after constructing the candidate list of the traditional prediction technique.

[0115] In another implementation, a new candidate list can be reconstructed based on the aforementioned candidates to serve as the candidate list requiring adjustment. In this implementation, the scheme of adjusting the reconstructed list based on template cost can be considered a new mode, independent of traditional prediction techniques. In a specific example, a new candidate list can be reconstructed using skip / direct mode, UMVE, or ETMVP as the candidate list requiring adjustment; this scheme serves as a new mode. At the encoding end, this mode competes with other skip / direct modes for selection. At the decoding end, based on the syntax, if this mode is selected, the candidate list is constructed using the same method as at the encoding end and adjusted according to template cost. Finally, the corresponding mode is selected according to the index of the selected mode in the transmission. In this implementation, a second switch syntax can be set in the current block's bitstream. That is, the encoder can write the second switch syntax into the current block's bitstream to indicate whether a new prediction mode should be adopted. This mode requires constructing a candidate list and adjusting at least some of the candidates in that list. The decoder can then interpret the second switch syntax in the current block's bitstream to confirm whether to reconstruct a candidate list and adjust at least some of the candidates in that list, i.e., to confirm whether to execute steps S301 and S302. The candidate acquisition method for the reconstructed candidate list can be executed according to the convention between the encoder and decoder, or it can be based on the candidate acquisition method transmitted through syntax.

[0116] In this step, multiple existing candidate construction methods can be integrated, and adjusting the richer list can further explore the performance of template-based methods.

[0117] S302: Adjust the candidate list based on the template region of the current block.

[0118] After constructing the candidate list for the current block, the candidate list can be adjusted based on the template region of the current block so that the current block can be decoded subsequently based on the adjusted candidate list.

[0119] A preferred approach is to adjust the candidate list based on the template region of the current block when the candidate list includes MVAP, UMVE, ETMVP and / or HMVP candidates, so as to make full use of template mining performance.

[0120] In one implementation, the candidate list for the current block can be sorted based on the template region of the current block.

[0121] In this implementation, a second template cost for at least a portion of the candidates in the candidate list can be determined. The second template cost of the candidate is calculated based on the predicted value of the template region, which is obtained by predicting the template region based on the candidate. Based on the second template costs of the at least a portion of the candidates, the at least a portion of the candidates are reordered. It is understood that the candidates here may include sub-pattern candidates and / or motion information candidates.

[0122] In a specific example, reordering the at least some candidates based on their second template costs can include: reordering the at least some candidates based on their second template costs to redetermine their indices. Subsequently, candidates with the same index value as the current block are identified from the at least some candidates; the current block is then decoded based on these candidates with the same index value. Corresponding to the decoding step, the encoding end can encode the index of the best mode for the current block based on the redetermined indices of the at least some candidates. Generally, candidates with smaller second template costs have relatively smaller prediction costs for the current block. Reordering the at least some candidates based on template costs allows candidates with smaller prediction costs to be prioritized, thus reducing the number of encoded bits for the index of the best mode / motion information of the current block when the best mode / motion information comes from at least some candidates. Alternatively, a candidate in a predetermined position from the reordered sequence can be directly selected for decoding the current block. For example, the first candidate in the reordered sequence can be selected for decoding the current block. Another example is the second candidate in the reordered sequence.

[0123] In another specific example, the candidate with the lowest second template cost among at least some of the candidates can be directly selected to decode the current block. In one specific example, if at least some of the candidates are sorted in ascending order of second template cost, the first candidate in the reordered at least some candidates can be selected to decode the current block. In another specific example, if at least some of the candidates are sorted in descending order of second template cost, the last candidate in the reordered at least some candidates can be selected to decode the current block.

[0124] In the above implementation, it is necessary to determine the second template cost of the candidates so as to sort the candidate list based on the second template cost of the candidates.

[0125] When the candidate is a sub-pattern candidate, the second template cost of the candidate can be calculated based on the predicted value of the template region, and the predicted value of the template region under the candidate can be predicted based on the motion information of the template region under the candidate.

[0126] As described above, the motion information of the candidate template region can be determined first. Optionally, the motion information of the template region can be determined based on the motion information of the current block, the method of obtaining the motion information of the current block, or the motion information of the template region at the corresponding position of the reference block template of the current block.

[0127] Among them, determining the motion information of the template region based on the motion information of the current block can mean: using the motion information of the current block as the motion information of the template region, or calculating the motion information of the template region using the motion information of the current block.

[0128] Determining the motion information of the template region based on the method of acquiring the motion information of the current block can mean: acquiring the motion information of the template region using the method of acquiring the motion information of the current block. If the motion information of the template region cannot be acquired using the method of acquiring the motion information of the current block, the motion information of the template region can be calculated from the motion information of the current block, or the motion information of the current block or preset motion information can be used as the motion information of the template region.

[0129] Determining the motion information of a template region based on its motion information at the corresponding position of the template region in the reference block template of the current block can mean either using the motion information of the template region at the corresponding position of the template region in the current block as the motion information of the template region, or calculating the motion information of the template region using the motion information of the template region at the corresponding position of the template region in the reference block template of the current block. For example, if there are multiple motion information points for the template region at the corresponding position of the template region in the current block, the average or median of these motion information points can be used as the motion information of the template region. If the motion information of the template region at the corresponding position of the template region in the current block cannot be obtained, the motion information of the template region can be calculated using the motion information of the current block, or the motion information of the current block or preset motion information can be used as the motion information of the template region.

[0130] Furthermore, the candidate can be a sub-pattern candidate of the sub-block prediction technique. In this case, the motion information of the template sub-block can be determined based on the motion information of the current block sub-block that is closest to the template sub-block, the method of obtaining the motion information of the current block sub-block that is closest to the template sub-block, or the motion information of the template sub-block at the corresponding position of the reference block template of the current block. The specific steps can be found in step S102, which will not be elaborated here.

[0131] When the candidate is a motion information candidate, the second template cost of the candidate can be calculated based on the predicted value of the template region, and the predicted value of the template region under the candidate is obtained based on the prediction of the motion information candidate.

[0132] The process of obtaining the predicted value of the template region based on motion information candidate prediction can include: deriving the motion information of the template region using motion information candidates; and predicting the template region using the motion information of the template region to obtain the predicted value of the template region. Specifically, deriving the motion information of the template region using motion information candidates can be achieved by processing the motion information candidates through scaling, offsetting, weighted averaging, or other methods to obtain the motion information.

[0133] The predicted value of the candidate template region obtained based on motion information candidate prediction can also be expressed as: directly using motion information candidates to predict the template region to obtain the predicted value of the template region.

[0134] After determining the motion information of the candidate lower template region based on the above method, the template region can be predicted based on the motion information of the template region to obtain the predicted value of the candidate lower template region. Then, the cost of the candidate lower template region can be determined based on the predicted value of the candidate lower template region, that is, the cost of the candidate second template is obtained.

[0135] Optionally, the candidate second template cost can be calculated based on the reconstructed value of the template region and the predicted value of the candidate lower template region. The calculation formula for the second template cost is not limited; for example, the SAD calculation formula or the SATD calculation formula can be used. In one embodiment, the SAD of the reconstructed value of the template region and the predicted value of the candidate lower template region can be calculated to obtain the candidate second template cost. In another embodiment, the SATD of the reconstructed value of the template region and the predicted value of the candidate lower template region can be calculated to obtain the candidate second template cost.

[0136] In one embodiment, all candidates in the candidate list can be sorted according to the second template cost.

[0137] In another embodiment, the first preset number of candidates in the candidate list can be sorted according to the second template cost.

[0138] In another embodiment, the candidate list can be grouped to obtain at least two candidate groups; all candidates in each candidate group within the at least one candidate group can be sorted within the group according to a second template cost; and / or, the at least two candidate groups can be reordered between groups according to the second template cost. That is, after grouping, intra-group sorting and / or inter-group sorting can be performed.

[0139] This can be achieved by ranking all candidates within each candidate group according to the second template cost, or by ranking all candidates within each candidate group of a subset of candidate groups according to the second template cost.

[0140] In this embodiment, candidates can be grouped according to their order in the candidate list. If two candidates are in the same candidate group, then all candidates between those two candidates are also in that same candidate group. A predetermined number of candidates can be selected sequentially according to their order in the candidate list to form a candidate group. Alternatively, candidates can be grouped based on the method of obtaining them from the candidate list. Generally, candidates obtained using the same method are adjacent, which is equivalent to grouping them according to their order in the candidate list.

[0141] During sorting, the order between different groups can remain unchanged, i.e., only intra-group sorting is performed. In other implementations, the order of different groups can also be reordered based on template cost, i.e., both intra-group and inter-group sorting are performed. Alternatively, inter-group sorting can be performed without intra-group sorting. Different groups can be sorted according to the sum of their second template costs. Preferably, multiple groups can be sorted in ascending order of their second template cost sums. Alternatively, different groups can be sorted according to the average of their second template costs. Preferably, multiple groups can be sorted in ascending order of their second template cost averages.

[0142] In a specific example, the temporal and spatial domain candidates and MVAP candidates in skip / direct mode are sorted using templates. The entire list is divided into four groups: temporal domain candidates, spatial domain candidates, MVAP candidates, and HMVP candidates. The spatial domain candidates and MVAP candidates are then sorted using templates. The spatial domain candidates are obtained by predicting the entire template region using standard MV prediction, while the MVAP candidates can obtain the template region prediction value according to step S101. The cost of the template region prediction value and the reconstructed value is calculated using a SAD-based cost calculation method to achieve grouping and sorting of the candidate list.

[0143] In another specific example, consider sorting UMVE candidates in skip / direct mode using a template. Set up 64 UMVE candidates, meaning 32 candidates for each of the two base MVs, consisting of 4 directions and 8 distances. Group the UMVE candidates by different base MVs and different directions, resulting in 8 groups. Each group contains candidates with the same offset direction based on the same base MV. Sort the candidates within each group according to the template cost to obtain the sorted UMVE candidate list.

[0144] In another implementation, the candidates in the candidate list of the current block can be adjusted based on the template region of the current block.

[0145] For example, when the candidate is a motion information candidate, the motion information candidate in the candidate list can be modified based on the template region.

[0146] The step of modifying the motion information candidates in the candidate list based on the template region may include:

[0147] The motion information candidates are corrected using a search method. The corrected motion information candidates are determined based on the third template cost in the search process. The third template cost is calculated based on the predicted value of the template region determined in the search process. For details of the search process, please refer to the description of the search in related technologies.

[0148] S303: Decode the current block based on the adjusted candidate list.

[0149] Optionally, a candidate can be selected from the adjusted candidate list as the current block for decoding. Specifically, when the candidate list is sorted based on the template region in step S302, the details of the candidate selection can be found in the description of step S302, and will not be repeated here.

[0150] In addition, if the candidate list is modified and adjusted based on the template region in step S302, a candidate with the same candidate index value as the current block can be found from the candidate list; the current block is then decoded based on the candidate with the same index value.

[0151] Corresponding to the video decoding method of the second embodiment, this application provides a video encoding method of the second embodiment. Specifically, as... Figure 10 As shown, the video encoding method of the second 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.

[0152] S401: Construct a candidate list for the current block.

[0153] For specific steps, please refer to step S301, which will not be repeated here.

[0154] S402: Adjust the candidate list based on the template region of the current block.

[0155] For specific steps, please refer to step S302, which will not be repeated here.

[0156] S403: Encode the current block based on the adjusted candidate list.

[0157] Alternatively, the current block can be encoded based on the adjusted candidate list.

[0158] In one embodiment, the encoder can determine the best candidate for the current block based on the adjusted candidate list. The best candidate for the current block comes from the adjusted candidate list. The index of the best candidate in the adjusted candidate list can be encoded to transmit the candidate (i.e., sub-mode / motion information) used in the current block to the decoder.

[0159] In another embodiment, the encoder and decoder may agree to use candidates at preset positions in the adjusted candidate list simultaneously. In this case, the encoder may not transmit the candidate index.

[0160] Among the aforementioned related technologies, the template-based candidate sorting method sorts all candidates, which is relatively rigid and inflexible. Therefore, there is still room for performance improvement in existing technologies.

[0161] Based on this, this application proposes a video decoding method that groups and sorts the candidate list to make full use of template mining performance.

[0162] Specifically, such as Figure 11 As shown, the video decoding method of the third 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.

[0163] S501: Construct a candidate list for the current block.

[0164] For details, please refer to step S301, which will not be repeated here.

[0165] Furthermore, if it is confirmed that a template region-based candidate list adjustment scheme is applied to the candidate list under the traditional prediction technique, it can also be confirmed whether a grouping and sorting scheme is applied. That is, the decoding end confirms whether steps S502, S503, and S504 are executed, and the encoding end confirms whether steps S602, S603, and S604 are executed. For the decoding end, if it is confirmed that a template region-based candidate list adjustment scheme is applied to the candidate list under the traditional prediction technique based on the value of the first switch syntax, the third switch syntax of the current block can be interpreted; based on the value of the third switch syntax, it is confirmed whether the following steps are performed: grouping the candidate list to obtain at least two candidate groups; sorting all candidates in each candidate group according to the second template cost to obtain a sorted candidate list; and decoding the current block based on the sorted candidate list. For the encoding end, if it is confirmed that a candidate list adjustment scheme based on template region is to be performed on the candidate list under the traditional prediction technique, the grouped scheme and the ungrouped scheme can be compared to determine whether the current block needs to be grouped and sorted. For example, the best candidate of the current block can be compared with the grouped scheme and the ungrouped scheme. For example, the scheme with the smallest best candidate index of the current block can be taken as the final selected scheme of the current block. Based on the confirmation result of whether the current block needs to be grouped and sorted, the third switch syntax is encoded. The third switch syntax is used to indicate whether to execute the grouped sorting scheme.

[0166] S502: Group the candidate list to obtain at least two candidate groups.

[0167] After constructing the candidate list for the current block, the candidate list can be grouped to obtain at least two candidate groups, so that at least one candidate group can be sorted within the group in the future, thereby making full use of the template mining performance and further balancing complexity and performance.

[0168] Candidates can be grouped according to their order in the candidate list. If two candidates are in the same candidate group, then all candidates between those two candidates will also be in that same candidate group. For example, a preset number of candidates can be selected sequentially from the candidate list to form a candidate group.

[0169] In other embodiments, candidates can be grouped based on the acquisition method of the candidates in the candidate list. For example, if a candidate list is constructed using three acquisition methods, candidates obtained using two acquisition methods can be grouped into one candidate group, and candidates obtained using the remaining acquisition method can be grouped into another candidate group.

[0170] Different grouping schemes can serve as different sub-schemes. This allows grouping syntax to be set within the bitstream; that is, the encoder can set the grouping syntax within the bitstream of an image block, using the values ​​of the grouping syntax to represent the selected grouping scheme for that image block. Correspondingly, the decoder can interpret the values ​​of the grouping syntax for the current block in the bitstream to determine the selected grouping scheme for that current block based on these values.

[0171] For the current block, the grouping scheme of the candidate list can be determined based on multiple grouping schemes. In one embodiment, a preset grouping scheme can be selected from multiple grouping schemes as the grouping scheme for the candidate list of the current block. In another embodiment, the grouping scheme of the candidate list of the current block can be determined based on the construction method of the candidate list. For example, if the candidate list includes candidates obtained using multiple acquisition methods, the candidate list can be grouped based on the acquisition method of the candidates in the candidate list. As another example, if the candidate list only includes candidates obtained using one acquisition method, the candidate list can be grouped according to the order in which the candidates are acquired.

[0172] S503: According to the second template cost of the candidates, sort all candidates in each candidate group in at least one candidate group within the group, and / or reorder at least two of the candidate groups between groups to obtain a sorted candidate list.

[0173] This can be achieved by ranking all candidates within each candidate group according to the second template cost, or by ranking all candidates within each candidate group of a subset of candidate groups according to the second template cost.

[0174] During sorting, the order between different groups can remain unchanged, i.e., only intra-group sorting is performed. In other implementations, the order of different groups can also be reordered based on template cost, i.e., both intra-group and inter-group sorting are performed. Alternatively, the order between groups changes, but the order of multiple candidates within each group remains unchanged, i.e., only inter-group sorting is performed, without intra-group sorting. At least two candidate groups can be reordered between groups based on the statistical value of the second template cost of each group to obtain a reordered candidate list. Different groups can be sorted according to the sum of the second template costs of each group. Preferably, multiple groups can be sorted in ascending order of the sum of the second template costs. Alternatively, different groups can be sorted according to the mean of the second template costs of each group. Preferably, multiple groups can be sorted in ascending order of the mean of the second template costs.

[0175] S504: Decode the current block based on the sorted candidate list.

[0176] For details, please refer to step S303, which will not be repeated here.

[0177] Corresponding to the video decoding method of the third embodiment, this application provides a video encoding method of the third embodiment. Specifically, as... Figure 12 As shown, the video coding method of the third 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 coding method of this embodiment can be combined with the video coding methods of other embodiments.

[0178] S601: Construct a candidate list for the current block.

[0179] For details, please refer to step S501, which will not be repeated here.

[0180] S602: Group the candidate list to obtain at least two candidate groups.

[0181] For details, please refer to step S502, which will not be repeated here.

[0182] S603: According to the second template cost of the candidates, sort all candidates in each candidate group in at least one candidate group within the group, and / or reorder at least two of the candidate groups between groups to obtain a sorted candidate list.

[0183] For details, please refer to step S503, which will not be repeated here.

[0184] S604: Decode the current block based on the sorted candidate list.

[0185] For details, please refer to step S403, which will not be repeated here.

[0186] In the above scheme, the corresponding grammatical expressions include, but are not limited to, one or more of the following:

[0187] The first switch syntax indicates whether to apply a template-based sorting method to the existing list;

[0188] The second switch syntax expresses whether to adopt a new prediction mode, which requires building a candidate list and sorting at least some of the candidates in the list;

[0189] Includes one or more sub-pattern syntaxes, expressing multiple sub-schemes to choose from when applying a template-based sorting method. Specific sub-schemes include, but are not limited to:

[0190] Template area selection;

[0191] The method of obtaining sub-blocks.

[0192] The following content presents two examples of grammatical expressions.

[0193] Example 1

[0194] The skip / direct modes are used as a candidate list for sorting. Template-based sorting of candidates can be added as a new method, and both the no-sorting method and the template-based sorting method are optional modes. At the encoding end, the two modes compete for selection. At the decoding end, based on the syntax, if a sorting mode is selected, it is sorted according to the template cost in the same way as at the encoding end. Finally, the corresponding mode is selected according to the index of the selected mode transmitted.

[0195] For the scheme of Implementation Example 1, the corresponding grammatical expression can be set with a second switch grammar, which expresses whether to adopt a new prediction mode. In this mode, a candidate list needs to be constructed and at least some of the candidates in the list need to be sorted.

[0196]

[0197] The syntax template_adjustment_flag (i.e., the second switch syntax) indicates whether to apply the method based on Example 1 to construct and sort candidates, where a value of 0 indicates that this method is not used, and a value of 1 indicates that this method is used.

[0198] Example 2

[0199] The skip / direct modes are used as the candidate list to be sorted. By default, the codec uses template regions to sort the skip / direct candidate list.

[0200] Based on the implementation example, the method for sorting skip / direct candidates includes multiple sub-schemes for grouping and sorting. This example includes two methods: one divides the list into three groups—spatial domain + temporal domain, MVAP, and HMVP—and sorts only the candidates within the MVAP group; the other divides the list into three groups—spatial domain + temporal domain, MVAP, and HMVP—and sorts the candidates within the spatial domain + temporal domain group and the MVAP group based on a template, then sorts the two groups according to their total cost.

[0201] Among them, three template area selection methods are set as sub-schemes: using the top template and the left template, using only the top template, and using only the left template.

[0202] The following is a corresponding example of a syntax expression, which may include a grouping syntax to indicate which grouping sorting method to choose.

[0203]

[0204] The syntax template_adjustment_type (i.e., grouping syntax) indicates whether the first or second grouping method is used when sorting skip / direct candidates. A value of 0 indicates the first grouping method, and a value of 1 indicates the second grouping method.

[0205] The syntax template_adjustment_type (i.e., region selection syntax) represents the template region selection scheme. When the value of this syntax is 0, it is the first seed scheme; when the value of this syntax is 1, it is the second seed scheme; and when the value of this syntax is 2, it is the third seed scheme.

[0206] Please see Figure 13 , Figure 13 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.

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

[0208] The electronic device 20 may further include a memory 21 for storing instructions and data required for the processor 22 to run.

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

[0210] The electronic device in this application may be an encoder or a decoder.

[0211] Please see Figure 14 , Figure 14This 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.

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

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

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

[0215] 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: In response to the prediction mode of the current block being a sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block; A first template cost is determined for at least a portion of the sub-patterns in the sub-block prediction pattern. The first template cost of the sub-pattern is calculated based on the predicted value of the template region. The predicted value of the template region in the sub-pattern is composed of the predicted values ​​of at least one template sub-block in the sub-pattern. The predicted value of at least one template sub-block in the sub-pattern is predicted based on the motion information of at least one template sub-block in the sub-pattern. Based on the first template cost of the at least some sub-patterns, the at least some sub-patterns are sorted; The current block is decoded based on the sorted at least some of the sub-patterns.

2. The video decoding method according to claim 1, characterized in that, The steps for determining the template region include: Decipher the region selection syntax of the current block, and select the template region from the reconstructed pixel regions in the first and / or second directions of the current block based on the values ​​of the region selection syntax; or, The reconstructed pixel region at a preset position surrounding the current block is used as the template region; The first direction includes above and / or below, and the second direction includes left and / or right.

3. The video decoding method according to claim 1, characterized in that, The sorting of the at least some sub-patterns based on the first template cost of the at least some sub-patterns includes: Based on the first template cost of the at least some sub-patterns, the at least some sub-patterns are sorted to redetermine the index of the at least some sub-patterns; Decoding the current block based on the sorted at least some sub-patterns includes: finding sub-patterns from the at least some sub-patterns that have the same sub-pattern index value as the current block; and decoding the current block based on the sub-patterns with the same index value.

4. The video decoding method according to claim 1, characterized in that, The method further includes: Construct a candidate list for the current block, the candidate list including at least some of the sub-patterns; The candidate list is grouped to obtain at least two candidate groups; The sorting of the at least some sub-patterns based on the first template cost of the at least some sub-patterns includes: Based on the first template cost of at least some sub-patterns, all candidates in the candidate group are sorted within the group, and / or, at least two candidate groups are reordered between groups to obtain a sorted candidate list; Decoding the current block based on the sorted at least some sub-patterns includes: decoding the current block based on the sorted candidate list.

5. A video encoding method, characterized in that, The method includes: In response to the prediction mode of the current block being a sub-block prediction mode, the template region of the current block is divided to obtain at least one template sub-block; A first template cost is determined for at least a portion of the sub-patterns in the sub-block prediction pattern. The first template cost of the sub-pattern is calculated based on the predicted value of the template region. The predicted value of the template region in the sub-pattern is composed of the predicted values ​​of at least one template sub-block in the sub-pattern. The predicted value of at least one template sub-block in the sub-pattern is predicted based on the motion information of at least one template sub-block in the sub-pattern. Based on the first template cost of the at least some sub-patterns, the at least some sub-patterns are sorted; The current block is encoded based on the sorted at least some of the sub-patterns.

6. The method according to any one of claims 1-5, characterized in that, The first template cost for determining at least some of the sub-patterns in the sub-block prediction pattern includes: Based on the motion information of the current block that is closest to the template sub-block in the sub-mode, the method of obtaining the motion information of the current block that is closest to the template sub-block in the sub-mode, or the motion information of the template sub-block at the corresponding position of the reference block template of the current block in the sub-mode, the motion information of the template sub-block in the sub-mode is determined. The positional relationship between the reference block template and the reference block of the current block is equivalent to the positional relationship between the template region and the current block.

7. The method according to claim 6, characterized in that, The determination of the motion information of the template sub-block in the sub-mode based on the motion information of the current block sub-block closest to the template sub-block in the sub-mode, the method for obtaining the motion information of the current block sub-block closest to the template sub-block in the sub-mode, or the motion information of the template sub-block in the sub-mode at the corresponding position of the reference block template of the current block, includes: The motion information of the current sub-block that is closest to the template sub-block is used as the motion information of the template sub-block; or... The motion information of the template sub-block is obtained using the motion information acquisition method of the current sub-block closest to the template sub-block; if it cannot be obtained, the motion information of the current sub-block closest to the template sub-block or preset motion information is used as the motion information of the template sub-block; or, The motion information of the template sub-block is determined based on the motion information of the corresponding position of the template sub-block in the reference block template; if it cannot be obtained, the motion information of the current sub-block or the preset motion information that is closest to the template sub-block is used as the motion information of the template sub-block.

8. The method according to any one of claims 1-5, characterized in that, The step of dividing the template region of the current block to obtain at least one template sub-block includes: The template area includes a first template area located in a first direction of the current block and / or a second template area located in a second direction of the current block. The first template area is divided into sub-blocks according to its width to obtain at least one template sub-block; and / or, the second template area is divided into sub-blocks according to its height to obtain at least one template sub-block; wherein the first direction includes above and / or below, and the second direction includes left and / or right; or, The template area is divided into sub-blocks by extending the sub-block dividing line of the current block, resulting in at least one template sub-block.

9. The video encoding method according to claim 5, characterized in that, The steps for determining the template region include: Based on multiple template region selection methods, the template region selection method for the current block is determined, and the template region of the current block determined by the template region selection method of the current block is determined. The region selection syntax of the current block is written into the bitstream to indicate the template region selection method used for the current block; or, The reconstructed pixel region at a preset position surrounding the current block is used as the template region.

10. The video encoding method according to claim 5, characterized in that, The sorting of the at least some sub-patterns based on the first template cost of the at least some sub-patterns includes: Based on the first template cost of the at least some sub-patterns, the at least some sub-patterns are sorted to redetermine the index of the at least some sub-patterns; Encoding the current block based on the sorted at least some sub-patterns includes: determining the best prediction pattern for the current block based on the at least some sub-patterns; and encoding the index of the re-determined best prediction pattern if the best prediction pattern for the current block comes from the at least some sub-patterns.

11. The method according to claim 3 or 10, characterized in that, The sorting of the at least some sub-patterns based on the first template cost of the at least some sub-patterns includes: The at least some sub-patterns are sorted in ascending order of the cost of the first template.

12. The video encoding method according to claim 5, characterized in that, The method further includes: Construct a candidate list for the current block, the candidate list including at least some of the sub-patterns; The candidate list is grouped to obtain at least two candidate groups; The sorting of the at least some sub-patterns based on the first template cost of the at least some sub-patterns includes: Based on the first template cost of at least some sub-patterns, all candidates in the candidate group are sorted within the group, and / or, at least two candidate groups are reordered between groups to obtain a sorted candidate list; Encoding the current block based on the sorted at least some sub-patterns includes: encoding the current block based on the sorted candidate list.

13. The method according to claim 4 or 12, characterized in that, The candidate list also includes motion information candidates based on historical information, high-level motion vector representation candidates, spatial candidates, temporal candidates, spatial derivation candidates, and / or temporal derivation candidates.

14. A video decoding method, characterized in that, The method described: Construct a candidate list for the current block; The candidate list is grouped to obtain at least two candidate groups; According to the second template cost of the candidate, all candidates in each candidate group in at least one candidate group are sorted within the group, and / or, at least two candidate groups are reordered between groups to obtain a sorted candidate list; wherein, the second template cost of the candidate is calculated based on the predicted value of the template region of the current block, and the predicted value of the template region is obtained based on the candidate predicting the template region; The current block is decoded based on the sorted candidate list.

15. The video decoding method according to claim 14, characterized in that, Decoding the current block based on the sorted candidate list includes: finding a candidate from the sorted candidate list that has the same best candidate index value as the current block; and decoding the current block based on the candidate with the same index value.

16. The video decoding method according to claim 14, characterized in that, The process of grouping the candidate list to obtain at least two candidate groups includes: The grouping syntax of the current block is interpreted, and the grouping scheme of the candidate list is determined based on the value of the grouping syntax; The candidate list is grouped using the grouping scheme to obtain at least two candidate groups.

17. The video decoding method according to claim 14, characterized in that, The candidate list for constructing the current block includes: Construct a first candidate list for the current block using traditional prediction techniques; The method includes: interpreting the first switch syntax of the current block; and determining whether to sort the first candidate list based on the value of the first switch syntax.

18. The video decoding method according to claim 17, characterized in that, The method includes: If it is determined that the first candidate list is to be sorted, the third switch syntax of the current block is interpreted; based on the value of the third switch syntax, it is determined whether to perform the step of grouping the candidate list to obtain at least two candidate groups, the step of sorting all candidates in each candidate group in at least one of the candidate groups within the group according to the second template cost to obtain a sorted candidate list, and the step of decoding the current block based on the sorted candidate list.

19. The video decoding method according to claim 14, characterized in that, The method includes: interpreting the second switch syntax of the current block; determining whether to construct a second candidate list based on the value of the second switch syntax; and sorting the second candidate list based on the template region. In response to confirming the construction of a second candidate list and sorting the second candidate list based on the template region, the steps of constructing a candidate list for the current block are performed sequentially; grouping the candidate list to obtain at least two candidate groups; sorting all candidates in each candidate group in at least one of the candidate groups within the group according to the second template cost to obtain a sorted candidate list; and decoding the current block based on the sorted candidate list.

20. The video decoding method according to claim 14, characterized in that, The steps for determining the template region include: Decipher the region selection syntax of the current block, and select the template region from the reconstructed pixel regions in the first and / or second directions of the current block based on the values ​​of the region selection syntax; or, The reconstructed pixel region at a preset position surrounding the current block is used as the template region; The first direction includes above and / or below, and the second direction includes left and / or right.

21. A video encoding method, characterized in that, The method includes: Construct a candidate list for the current block; Group the candidate list to obtain at least two candidate groups; According to the second template cost of the candidate, all candidates in each candidate group in at least one candidate group are sorted within the group, and / or, at least two candidate groups are reordered between groups to obtain a sorted candidate list; wherein, the second template cost of the candidate is calculated based on the predicted value of the template region of the current block, and the predicted value of the template region is obtained based on the candidate's prediction of the template region; The current block is encoded based on the sorted candidate list.

22. The video encoding method according to claim 21, characterized in that, Encoding the current block based on the sorted candidate list includes: determining the best candidate for the current block based on the sorted candidate list; and encoding the re-determined index of the best candidate if the best candidate for the current block comes from the sorted candidate list.

23. The video encoding method according to claim 21, characterized in that, The method further includes: Based on multiple grouping schemes, the grouping scheme of the candidate list is determined; Write the block syntax of the current block into the bitstream to indicate the block scheme selected for the current block; The step of grouping the candidate list to obtain at least two candidate groups includes: grouping the candidate list using the grouping scheme of the candidate list.

24. The method according to claim 14 or 21, characterized in that, The reordering of at least two candidate groups and between groups includes: Based on the statistical value of the second template cost of each group, at least two of the candidate groups are reordered between groups to obtain a sorted candidate list.

25. The method according to claim 14 or 21, characterized in that, The process of grouping the candidate list to obtain at least two candidate groups includes: The candidate list is grouped according to the order in which the candidates are listed; or, The candidate list is grouped based on the method of obtaining the candidates in the candidate list.

26. The method according to claim 14 or 21, characterized in that, The candidate list includes motion information candidates and / or sub-pattern candidates for sub-block prediction techniques; The motion information candidates include motion information candidates based on historical information, high-level motion vector representation candidates, spatial candidates, temporal candidates, spatial derivation candidates, and / or temporal derivation candidates.

27. The video encoding method according to claim 21, characterized in that, The steps for determining the template region include: Based on multiple template region selection methods, the template region selection method for the current block is determined, and the template region of the current block determined by the template region selection method of the current block is determined. The region selection syntax of the current block is written into the bitstream to indicate the template region selection method used for the current block; or, The reconstructed pixel region at a preset position surrounding the current block is used as the template region.

28. A video decoding method, characterized in that, The method includes: Construct a candidate list for the current block, which includes motion information candidates based on historical information, high-level motion vector representation candidates, extended temporal motion vector prediction candidates, and / or motion vector adaptive prediction candidates; Adjust the candidate list based on the template region of the current block; The current block is decoded based on the adjusted candidate list.

29. The video decoding method according to claim 28, characterized in that, The candidate list for constructing the current block includes: Construct a first candidate list for the current block using traditional prediction techniques; The method includes: interpreting a first switch syntax of the current block; determining, based on the value of the first switch syntax, whether to perform the template region based on the current block to adjust the candidate list; and decoding the current block based on the adjusted candidate list.

30. The video decoding method according to claim 28, characterized in that, The method includes: interpreting the second switch syntax of the current block; determining whether to construct a second candidate list based on the value of the second switch syntax; and adjusting the second candidate list based on the template region. In response to confirming the construction of a second candidate list and adjusting the second candidate list based on the template region, the steps of adjusting the candidate list based on the template region of the current block and decoding the current block based on the adjusted candidate list are executed sequentially.

31. The video decoding method according to claim 28, characterized in that, The adjustment of the candidate list based on the template region of the current block includes: Based on the second template cost of at least some candidates in the candidate list, at least some candidates are sorted to redetermine the index of at least some candidates, wherein the second template cost of the candidate is calculated based on the predicted value of the template region, and the predicted value of the template region is obtained based on the candidate's prediction of the template region; Decoding the current block based on the adjusted candidate list includes: finding candidates with the same candidate index value as the current block from at least a portion of the candidates; and decoding the current block based on the candidates with the same index value.

32. The video decoding method according to claim 28, characterized in that, The steps for determining the template region include: Decipher the region selection syntax of the current block, and select the template region from the reconstructed pixel regions in the first and / or second directions of the current block based on the values ​​of the region selection syntax; or, The reconstructed pixel region at a preset position surrounding the current block is used as the template region; The first direction includes above and / or below, and the second direction includes left and / or right.

33. A video encoding method, characterized in that, The method includes: Construct a candidate list for the current block, which includes motion information candidates based on historical information, high-level motion vector representation candidates, extended temporal motion vector prediction candidates, and / or motion vector adaptive prediction candidates; Adjust the candidate list based on the template region of the current block; The current block is encoded based on the adjusted candidate list.

34. The video encoding method according to claim 33, characterized in that, The candidate list for constructing the current block includes: Construct a first candidate list for the current block using traditional prediction techniques; The method further includes: writing the first switch syntax into the bitstream; Wherein, the value of the first switch syntax is used to indicate whether to perform the steps of adjusting the candidate list based on the template region of the current block and decoding the current block based on the adjusted candidate list.

35. The video encoding method according to claim 33, characterized in that, The construction of the candidate list for the current block includes: constructing a second candidate list for the current block, wherein the second candidate list for the current block is independent of the first candidate list for the current block under traditional prediction techniques; The method further includes: writing the second switch syntax into the bitstream; Wherein, the value of the second switch syntax is used to indicate: whether to sequentially execute the steps of constructing the second candidate list of the current block; adjusting the candidate list based on the template region of the current block; and decoding the current block based on the adjusted candidate list.

36. The video encoding method according to claim 33, characterized in that, The adjustment of the candidate list based on the template region of the current block includes: Based on the second template cost of at least some candidates in the candidate list, at least some candidates are sorted to redetermine the index of at least some candidates, wherein the second template cost of the candidate is calculated based on the predicted value of the template region, and the predicted value of the template region is obtained based on the candidate's prediction of the template region; Encoding the current block based on the adjusted candidate list includes: encoding the redefined index of the best candidate if the best candidate of the current block comes from the at least part of the candidates.

37. The video encoding method according to claim 33, characterized in that, The steps for determining the template region include: Based on multiple template region selection methods, the template region selection method for the current block is determined, and the template region of the current block determined by the template region selection method of the current block is determined. The region selection syntax of the current block is written into the bitstream to indicate the template region selection method used for the current block; or, The reconstructed pixel region at a preset position surrounding the current block is used as the template region.

38. The method according to any one of claims 33-37, characterized in that, The candidate list also includes spatial candidates, temporal candidates, spatial derivation candidates, and / or temporal derivation candidates.

39. 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-38.

40. 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-38.