Encoding and decoding method and device, encoder, decoder and storage medium

CN119817095APending Publication Date: 2025-04-11GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280099854.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-09-13
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

In video coding, the edges of moving objects are not necessarily horizontal or vertical. As a result, traditional rectangular block division cannot accurately divide the edges of objects, resulting in large motion prediction errors and low coding efficiency.

Method used

Geometric Partition Mode (GPM) is used to determine the optimal transition width parameters through template matching, and the weight matrix is ​​dynamically adjusted to improve prediction accuracy.

Benefits of technology

By dynamically adjusting the weight matrix, prediction errors are reduced, coding efficiency is improved, and the accuracy of GPM in weighted prediction is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119817095A_ABST
    Figure CN119817095A_ABST
Patent Text Reader

Abstract

The invention discloses a coding and decoding method and device, a coder, a decoder and a storage medium. The method comprises the following steps: acquiring a geometric partition mode prediction parameter of a current block; determining a plurality of candidate transition width parameters according to the prediction parameters; determining a first transition width parameter actually used by the weight matrix of the current block based on template matching; obtaining a weight value of the pixel point of the current block according to the first transition width parameter; and performing pixel-by-pixel weighting on the first predicted value and the second predicted value of the current block according to the weight value to obtain the predicted value of the current block. According to the method, the candidate transition width parameters are sorted by applying template matching, the optimal transition width parameter is selected for the current block from the sorting result, and then the optimal weight matrix of the current block is determined, so that compared with a fixed transition width, the prediction accuracy of the GPM during weighted prediction can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

A coding and decoding method, device, encoder, decoder and storage medium Technical Field

[0001] The present application relates to the field of video image processing technology, and in particular to a coding and decoding method, device, encoder, decoder and storage medium. Background Art

[0002] In hybrid video coding frameworks, coding techniques such as prediction, transform, and quantization are typically implemented using square and rectangular blocks. However, in reality, the edges of moving objects are not always horizontal or vertical, and the motion vectors on either side of the moving edge often differ. Therefore, the dividing line may not accurately identify the edge of the object. Therefore, when performing motion prediction and compensation on an entire block during the coding process, large prediction errors can occur, limiting coding efficiency.

[0003] At the Joint Video Experts Team (JVET) meeting, a more flexible inter-frame geometric partitioning prediction mode (GPM) was introduced. GPM allows the coding block to be divided into two non-rectangular sub-partitions, which are then weightedly fused to obtain the final prediction value after performing unidirectional prediction on each sub-partition.

[0004] During the GPM prediction process, the weight transition width of the GPM weight matrix at the segmentation line is fixed. Considering the influence of the moving object's movement speed and sequence resolution, the fixed weight transition width at the segmentation line is not the optimal solution.

[0005] Summary of the Invention

[0006] The embodiments of the present application provide a coding and decoding method, apparatus, encoder, decoder, and storage medium.

[0007] In a first aspect, an embodiment of the present application provides a decoding method, comprising:

[0008] Get the geometric partitioning mode prediction parameters of the current block;

[0009] Determining, based on the prediction parameters, a plurality of candidate transition width parameters of a weight matrix of the current block;

[0010] Determining, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0011] Obtaining a weight value of a pixel point of the current block according to the first transition width parameter;

[0012] The first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

[0013] In a second aspect, an embodiment of the present application provides an encoding method, including:

[0014] Get the geometric partitioning mode prediction parameters of the current block;

[0015] Determining, based on the prediction parameters, a plurality of candidate transition width parameters of a weight matrix of the current block;

[0016] Determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching;

[0017] sorting the plurality of candidate transition width parameters according to the template matching cost parameter to obtain index parameters of the plurality of candidate transition width parameters;

[0018] Determine a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0019] Determining an index parameter of the first transition width parameter from index parameters of the plurality of candidate transition width parameters;

[0020] The index parameter of the first transition width parameter is encoded to obtain a code stream.

[0021] In a third aspect, an embodiment of the present application provides an encoding method, including:

[0022] Get the geometric partitioning mode prediction parameters of the current block;

[0023] Determining, based on the prediction parameters, a plurality of candidate transition width parameters of a weight matrix of the current block;

[0024] Determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching;

[0025] sorting the plurality of candidate transition width parameters according to the template matching cost parameter, and selecting the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter;

[0026] Obtaining a weight value of a pixel point of the current block according to the first transition width parameter;

[0027] The first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

[0028] In a fourth aspect, an embodiment of the present application provides a decoding device, including:

[0029] An acquisition unit, used to acquire the geometric partitioning mode prediction parameters of the current block;

[0030] a determining unit, configured to determine a plurality of candidate transition width parameters of the weight matrix of the current block according to the prediction parameter;

[0031] A first processing unit is configured to determine, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0032] A prediction unit is used to obtain a weight value of the pixel point of the current block according to the first transition width parameter; and to weight the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel point of the current block to obtain a prediction value of the current block.

[0033] In a fifth aspect, an embodiment of the present application provides an encoding device, including:

[0034] An acquisition unit, used to acquire the geometric partitioning mode prediction parameters of the current block;

[0035] a determining unit, configured to determine a plurality of candidate transition width parameters of the weight matrix of the current block according to the prediction parameter;

[0036] A first processing unit is configured to determine, based on template matching, template matching cost parameters of the plurality of candidate transition width parameters; sort the plurality of candidate transition width parameters according to the template matching cost parameters to obtain index parameters of the plurality of candidate transition width parameters;

[0037] a second processing unit, configured to determine a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0038] The first processing unit is further configured to determine an index parameter of the first transition width parameter from index parameters of the plurality of candidate transition width parameters;

[0039] The encoding unit is configured to encode the index parameter of the first transition width parameter to obtain a code stream.

[0040] In a sixth aspect, an embodiment of the present application provides an encoding device, including:

[0041] An acquisition unit, used to acquire the geometric partitioning mode prediction parameters of the current block;

[0042] a determining unit, configured to determine a plurality of candidate transition width parameters of the weight matrix of the current block according to the prediction parameter;

[0043] a first processing unit, configured to determine, based on template matching, template matching cost parameters of the plurality of candidate transition width parameters; sort the plurality of candidate transition width parameters according to the template matching cost parameters, and select the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter;

[0044] A prediction unit is used to obtain a weight value of the pixel point of the current block according to the first transition width parameter; and to weight the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel point of the current block to obtain a prediction value of the current block.

[0045] In a seventh aspect, a decoder is provided, comprising a first memory and a first processor; the first memory stores a computer program that can be run on the first processor to execute the method in the above-mentioned first aspect or its various implementations.

[0046] In an eighth aspect, an encoder is provided, comprising a second memory and a second processor; the second memory stores a computer program that can be run on the second processor to execute the method in the above-mentioned second aspect, third aspect or their respective implementations.

[0047] In a ninth aspect, a coding and decoding system is provided, comprising an encoder and a decoder. The encoder is configured to execute the method of the second aspect, the third aspect, or their respective implementations, and the decoder is configured to execute the method of the first aspect, or their respective implementations.

[0048] In a tenth aspect, a chip is provided for implementing the method described in any one of the first to third aspects or their respective implementations. Specifically, the chip includes a processor configured to load and execute a computer program from a memory, causing a device equipped with the chip to perform the method described in any one of the first to third aspects or their respective implementations.

[0049] In the eleventh aspect, a computer-readable storage medium is provided for storing a computer program, which enables a computer to execute the method of any one of the first to second aspects or their respective implementations.

[0050] In a twelfth aspect, a computer program product is provided, comprising computer program instructions, which enable a computer to execute the method in any one of the above-mentioned first to second aspects or their respective implementations.

[0051] In a thirteenth aspect, a computer program is provided, which, when executed on a computer, enables the computer to execute the method in any one of the first to second aspects or their respective implementations.

[0052] In a fourteenth aspect, a code stream is provided, comprising an index parameter of a first transition width parameter actually used by a weight matrix of a current block.

[0053] The technical solution of the embodiment of the present application uses template matching to sort multiple candidate transition width parameters, selects the optimal transition width parameter for the current block from the sorting results, and then determines the optimal weight matrix of the current block. Compared with using a fixed transition width, it can improve the prediction accuracy of GPM in weighted prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] FIG1 is a block diagram of an encoder according to an embodiment of the present application;

[0055] FIG2 is a block diagram of a decoder according to an embodiment of the present application;

[0056] FIG3 is a schematic diagram of a first flow chart of an encoding method provided in an embodiment of the present application;

[0057] FIG4 is a schematic flow chart of a method for determining a first transition width parameter in an embodiment of the present application;

[0058] FIG5 is a schematic diagram showing the correspondence between the distance from a pixel point to a dividing line and the weight value in an embodiment of the present application;

[0059] FIG6 is a schematic diagram of a flow chart of a template matching method in an embodiment of the present application;

[0060] FIG7 a is a schematic diagram of a first position relationship of related areas of a current block in an embodiment of the present application;

[0061] FIG7 b is a schematic diagram of a second positional relationship of related areas of the current block in an embodiment of the present application;

[0062] FIG8 is a schematic diagram of a second flow chart of the encoding method provided in an embodiment of the present application;

[0063] FIG9 is a schematic diagram of a first flow chart of a decoding method provided in an embodiment of the present application;

[0064] FIG10 is a schematic diagram of GPM division at different angles and offsets in an embodiment of the present application;

[0065] FIG11a is a first schematic diagram of a GPM with inter and intra modes in an embodiment of the present application;

[0066] FIG11 b is a second schematic diagram of the GPM with inter and intra mode in an embodiment of the present application;

[0067] FIG11c is a third schematic diagram of the GPM with inter and intra modes in an embodiment of the present application;

[0068] FIG12a is a fourth schematic diagram of a GPM with inter and intra modes according to an embodiment of the present application;

[0069] FIG12 b is a fifth schematic diagram of the GPM with inter and intra modes according to an embodiment of the present application;

[0070] FIG13 is a schematic block diagram 1 of an encoding device provided in an embodiment of the present application;

[0071] FIG14 is a second schematic block diagram of an encoding device provided in an embodiment of the present application;

[0072] FIG15 is a schematic block diagram of a decoding device provided in an embodiment of the present application;

[0073] FIG16 is a schematic block diagram of an encoder provided in an embodiment of the present application;

[0074] FIG17 is a schematic block diagram of a decoder provided in accordance with an embodiment of the present application;

[0075] FIG18 is a schematic diagram of the composition structure of a coding and decoding system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0076] In order to enable a more detailed understanding of the features and technical contents of the embodiments of the present application, the implementation of the embodiments of the present application is described in detail below with reference to the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present application.

[0077] The embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0078] Currently, common video codec standards (such as VVC) all use block-based hybrid coding and decoding. Each frame in the video is divided into square largest coding units (LCUs) or coding tree units (CTUs) of the same size (such as 128x128, 64x64, etc.). Each largest coding unit can be divided into rectangular coding units (CUs) according to rules. Coding units may also be divided into prediction units (PUs) and transform units (TUs).

[0079] At the encoding end, a frame of image is divided into blocks, and intra-frame prediction or inter-frame prediction is used for the current block (CU) to generate a predicted block of the current block. The original block of the current block is subtracted from the predicted block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix, and the quantization coefficient matrix is ​​entropy coded and output to the bitstream.

[0080] FIG1 is an exemplary video coding system. As shown in FIG1 , the video coding system 11 includes a transform unit 111, a quantization unit 112, a mode selection and coding control logic unit 113, an intra-frame prediction unit 114, an inter-frame prediction unit 115 (including motion compensation and motion estimation), an inverse quantization unit 116, an inverse transform unit 117, a loop filter unit 118, a coding unit 119, and a decoded image buffer unit 110. For an input original video signal, a frame of an image is divided into blocks. The mode selection and coding control logic unit 113 determines a coding mode. Intra-frame prediction or inter-frame prediction is used for the current block to generate a prediction block for the current block. Due to the strong correlation between adjacent pixels in a video frame, intra-frame prediction is used in video coding and decoding technology to eliminate spatial redundancy between adjacent pixels. Due to the strong similarity between adjacent frames in a video, inter-frame prediction is used in video coding and decoding technology to eliminate temporal redundancy between adjacent frames, thereby improving coding efficiency. The original block of the current block is subtracted from the predicted block to obtain a residual block. The residual block is then passed through the transform unit 111 and the quantization unit 112 to obtain a quantization coefficient matrix. The quantization coefficient matrix is ​​entropy-encoded by the encoding unit 119 and output to the bitstream. In addition, the quantization coefficient matrix is ​​passed through the inverse quantization unit 116 and the inverse transform unit 117 to obtain a reconstructed residual block. The reconstructed residual block is then removed from the block effect artifacts by the loop filter unit 118. This reconstructed residual block is then added to a prediction block in the frame of the decoded image buffer unit 111 to generate a reconstructed video reconstructed block. The decoded image buffer unit 110 is used to store the reconstructed video reconstructed block for prediction reference. As the video image encoding progresses, new reconstructed video reconstructed blocks are continuously generated, and these reconstructed video reconstructed blocks are all stored in the decoded image buffer unit 110.

[0081] The decoding end determines the same block division information, prediction, transformation, quantization, entropy coding, loop filtering and other mode information or parameter information as the encoding end by parsing and analyzing the existing information, thereby ensuring that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end.

[0082] Exemplarily, FIG2 is a video decoding system, FIG2 is a schematic diagram of the composition structure of the video encoding system of an embodiment of the present application, as shown in FIG2, the video encoding system 21 includes: a decoding unit 211, an inverse transform unit 212, an inverse quantization unit 213, an intra-frame prediction unit 214, a motion compensation unit 215, a loop filter unit 216 and a decoded image cache unit 217; after the input video signal is encoded by the video encoding system 11, the code stream of the video signal is output; the code stream is input to the video decoding system 21, and first passes through the decoding unit 211 to obtain a decoded quantization coefficient matrix; the quantization coefficient matrix is ​​processed by the inverse transform unit 212 and the inverse quantization unit 213 to generate a residual block in the pixel domain; the intra-frame prediction unit 214 can be used to generate a residual block based on the determined intra-frame prediction direction and the A prediction block for the current visual block is generated from data of a previously decoded block of the current frame or picture; the motion compensation unit 215 determines prediction information for the current block by parsing the motion vector and other associated syntax elements, and uses the prediction information to generate a prediction block for the current block; a decoded reconstructed block is formed by summing the residual block from the inverse transform unit 212 and the inverse quantization unit 213 with the corresponding prediction block generated by the intra-frame prediction unit 214 or the motion compensation unit 215; the decoded reconstructed block passes through the loop filter unit 216 to remove blocking artifacts, thereby improving video quality; the decoded reconstructed block is then stored in the decoded image cache unit 217, which stores reference images for subsequent intra-frame prediction or motion compensation, and is also used for outputting the video signal to obtain the restored original video signal.

[0083] It should be noted that the method of the embodiment of the present application is mainly applied to the inter-frame prediction unit 115 shown in Figure 1 and the motion compensation unit 215 shown in Figure 2. In other words, the embodiment of the present application can be applied to both the encoder and the decoder, or even to both the encoder and the decoder at the same time, but the embodiment of the present application is not specifically limited thereto.

[0084] Based on this, the technical solution of this application is further described in detail below with reference to the accompanying drawings and embodiments. Before proceeding with the detailed description, it should be noted that the terms "first", "second", "third", etc. mentioned throughout the specification are only used to distinguish different features and do not have the function of defining priority, sequence, size relationship, etc.

[0085] The present application provides an encoding method, which is applied to a video encoding device, i.e., an encoder. The functions implemented by the method can be implemented by a processor in the video encoding device calling program code. Of course, the program code can be stored in a computer storage medium. Therefore, the video encoding device includes at least a processor and a storage medium.

[0086] FIG3 is a schematic diagram of a first flow chart of an encoding method provided in an embodiment of the present application. As shown in FIG3 , the method includes:

[0087] Step 301: Obtaining geometric partitioning mode prediction parameters of the current block;

[0088] Step 302: Determine multiple candidate transition width parameters of the weight matrix of the current block according to the prediction parameters;

[0089] It should be noted that the prediction parameters at least include parameters for indicating the optional range of the candidate transition width parameters.

[0090] The transition width parameter (weightTransitionWidthIdx) is a parameter that characterizes the transition width (weightTransitionWidth) of the weight matrix. The transition width is expressed in pixels to represent the transition pixel width of the weight matrix at the dividing line. The transition width parameter can be the transition width itself or a control variable for the transition width. In some embodiments, the optional range of transition widths can include 1, 2, 4, 8, 16, 32, 64, and other powers of 2. For example, the transition width selection range is 2, 4, and 8. The transition width selection range is 1, 2, 4, 8, 16, and 32. In some embodiments, the optional range of transition widths can also include 0, 3, 5, 7, and other non-powers of 2.

[0091] In some embodiments, the transition width parameter is a logarithmic value of the transition width with base 2. When the selection range of the transition width is 1, 2, 4, 8, 16, 32, the selection range of the candidate transition width parameter is 0, 1, 2, 3, 4, 5 accordingly.

[0092] Exemplarily, in some embodiments, the prediction parameter includes a first syntax element for indicating the plurality of candidate transition width parameters.

[0093] Exemplarily, the first syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit. That is, the selection range of the weight matrix transition width can be controlled in a high-level syntax such as a sequence parameter set (SPS) or a picture parameter set (SPS). Or the selection range of the weight matrix transition width is indicated in a picture header data unit (PH), a slice header data unit (SH) or a current block data unit (CU layer). For example, the selection range of controlling the weight matrix transition width is 4 to 16.

[0094] Exemplarily, in some embodiments, the prediction parameters include the size of the current block, the resolution of the current block, the quantization parameter of the current block, and the motion vector difference between two partitions of the current block.

[0095] The larger the size of the current block, the larger the transition width, and the smaller the size of the current block, the smaller the transition width; the higher the resolution of the current block, the larger the transition width, and the lower the resolution of the current block, the smaller the transition width; the smaller the quantization parameter of the current block, the larger the transition width, and the larger the size of the current block, the smaller the transition width; the larger the difference between the motion vectors of the two partitions, the larger the transition width, and the smaller the difference between the motion vectors of the two partitions, the smaller the transition width.

[0096] In some embodiments, the upper limit and / or lower limit of the transition width selection range can be determined based on these prediction parameters, that is, the upper limit and / or lower limit of the candidate transition width parameter selection range can be determined, and multiple candidate transition width parameters can be selected from the selection range.

[0097] Step 303: Determine a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0098] Here, the first transition width parameter represents the optimal transition width that minimizes the error between the predicted value and the original value of the current block. The encoding end calculates the error parameters between the weighted predicted value and the original value of the current block when different transition width weight matrices are selected based on the preset matching criteria, and selects the transition width parameter that minimizes the error parameter as the first transition width parameter.

[0099] For example, FIG4 is a flow chart of a method for determining a first transition width parameter in an embodiment of the present application. As shown in FIG4 , determining the first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters includes:

[0100] Step 401: Obtaining weight values ​​of pixels of the current block according to the candidate transition width parameters;

[0101] Geometric Partitioning Mode (GPM) technology has a total of 64 partitioning modes, each corresponding to an angle α and a step size ρ, for a total of 20 angles and 4 step sizes. GPM allows the coding block to be divided into two non-rectangular sub-partitions, each of which is unidirectionally predicted and then weightedly merged to obtain the final prediction value. In H.266 / VVC, when the current block is in GPM mode, the corresponding angle angleIdx and step size distanceIdx are obtained by looking up the table based on the partitioning mode index merge_gpm_partition_idx selected by the current block.

[0102] In some embodiments, the prediction parameters include geometric partitioning mode parameters of the current block, which are used to locate the partitioning line of the current block. Exemplarily, the geometric partitioning mode parameters include at least the size of the current block and partitioning information, where the partitioning information includes the angle angleIdx and the step length distanceIdx of the partitioning line.

[0103] The method of obtaining the weight value of the current block pixel point based on the candidate transition width parameter includes: determining the distance parameter from the current block pixel point to the current block dividing line based on the geometric division mode parameter; and determining the weight value of the current block pixel point based on the distance parameter and the candidate transition width parameter.

[0104] During the GPM hybrid weighted prediction calculation process, the prediction values ​​corresponding to both partitions are used for all pixels in the current block that are farther from the dividing line. The prediction values ​​near the dividing line are obtained by mixing the prediction values ​​of both partitions according to a certain weight, and the weight is related to the distance between the pixel and the dividing line. In other words, the weight of each pixel in the current block is calculated based on the distance between the pixel and the dividing line. In this embodiment of the application, the correspondence between distance and weight value is a linear relationship.

[0105] In some embodiments, obtaining the weight value of the current block pixel point based on the candidate transition width parameter includes: when the candidate transition width parameter represents a transition width that is not a zero pixel width, adding the distance parameter to half the transition width to obtain the translated distance parameter; dividing the translated distance parameter by the ratio of the transition width and the maximum weight value to obtain a first intermediate weight value; when the first intermediate weight value is less than or equal to the minimum weight value, using the minimum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, using the intermediate weight value as the weight value of the current block pixel point.

[0106] Exemplarily, the current block size is W×H. First, the distance parameter (weightIdx) from the pixel in the current block to the dividing line is calculated, and then the distance parameter is translated upward by half the transition width to obtain the translated distance parameter (weightIdxL). Finally, within the transition width, the translated distance parameter is divided by the ratio of the transition width to the maximum weight to obtain the first intermediate weight value, which is then clamped to the weight range to obtain the weight value (wValue) of the pixel in the current block.

[0107]

[0108]

[0109]

[0110] Among them, (xL, yL) is the coordinate of the pixel point of the current block, offsetX and offsetY are the offset values ​​of the current block, weightIdxL is the distance parameter after translation, weightTransitionWidthIdx is the transition width parameter, weightTransitionWidthIdx is the logarithm of the transition width with 2 as the lower limit, 1<<(3+weightTransitionWidthIdx) represents half the transition width, and >>(weightTransitionWidthIdx-log2wMax+3+1) represents the ratio of the transition width to the maximum weight value.

[0111] In some embodiments, determining the weight value of the current block pixel point based on the distance parameter and the candidate transition width parameter includes: when the candidate transition width parameter represents a transition width of non-zero pixel width, dividing the distance parameter by the ratio of the transition width and the maximum weight value to obtain a scaled distance parameter; adding the scaled distance parameter to half of the maximum weight value to obtain a second intermediate weight value; when the second intermediate weight value is less than or equal to the minimum weight value, using the minimum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, using the intermediate weight value as the weight value of the second pixel point.

[0112] Accordingly, the calculation formula for the above weight value can be changed to:

[0113]

[0114] wValue=Clip3(0,wMax,(partFlip?(weightIdxS+wMax>>1):(weightIdxS-wMax>>1))) (5)

[0115] Among them, weightIdxS is the scaled distance parameter, >>(weightTransitionWidthIdx-log2wMax+3+1) represents the ratio of the transition width to the maximum weight value, and wMax>>1 represents half of the maximum weight value.

[0116] In some embodiments, determining the weight value of the current block pixel point based on the distance parameter and the candidate transition width parameter also includes: when the candidate transition width parameter represents a transition width of 0 pixel width, when the distance parameter is greater than 0, using the maximum weight value as the weight value of the current block pixel point; when the distance parameter is less than or equal to 0, using the minimum weight value as the weight value of the current block pixel point.

[0117] When the transition width is 0 pixel width, it can be understood that the weight matrix of the current block has no transition width, and the predicted value of the pixel point in the current block is the predicted value of the first partition or the predicted value of the second partition. The weight value is not controlled by the transition width parameter, and the weight value can be determined according to the positive or negative distance from the pixel point to the dividing line.

[0118]

[0119] For example, when weightTransitionWidthIdx=0, the transition width is 1; when weightTransitionWidthIdx=1, the transition width is 2; when weightTransitionWidthIdx=2, the transition width is 4; and when weightTransitionWidthIdx=3, the transition width is 8. When weightTransitionWidthIdx=2, the transition width is 4, which corresponds to the case in the H.266 / VVC standard. In some embodiments, weightTransitionWidthIdx=-1 can be defined to indicate a transition width of 0.

[0120] It is understandable that in order to visualize the transition width, the embodiment of the present application introduces a control parameter weightTransitionWidthIdx. WeightIdx is used to represent the distance from the pixel point in the current block to the dividing line. WeightTransitionWidthIdx can control the speed of change of the weight wValue with weightIdx (i.e., slope k). Figure 5 is a schematic diagram of the correspondence between the distance from the pixel point to the dividing line and the weight value in the embodiment of the present application. As shown in Figure 5, the horizontal axis is the distance in pixels, and the vertical axis is the weight value. WeightTransitionWidthIdx affects the slope of the straight line within the transition width range. When weightTransitionWidthIdx is smaller, the slope is larger, and the weight wValue changes faster with weightIdx, that is, fewer pixels are required to transition from the maximum value to the minimum value. It is intuitively manifested as the "width" of the weighted matrix (also called "weight matrix") in the non-maximum value and non-zero value area "near the dividing line" is narrower. When weightTransitionWidthIdx is larger, the slope is smaller, and the weight wValue changes more slowly with weightIdx, that is, more pixels are required to transition from the maximum value to the minimum value, which is intuitively manifested as the "width" of the weight matrix in the non-maximum and non-zero areas "near the dividing line" is wider. The transition width can be 0, 1, 2, 4, 8, 16, 32. When the transition width is 0, it means that the maximum weight value and the minimum weight value suddenly change. When the transition width is non-zero, it is necessary to ensure that the weight value of the pixel point on the dividing line is half of the maximum weight value (wMax). The farther the distance between the pixel point and the dividing line, the larger or smaller the weight value. That is, the area where the pixel point in the current block is far from the dividing line uses the prediction values ​​corresponding to the two partitions, while the prediction value near the dividing line (that is, within the transition width range) is a mixed weighted prediction of the prediction values ​​of the two partitions according to the actual weight value, and the weight value is related to the distance between the pixel point and the dividing line.

[0121] In practical applications, the correspondence between distance and weight value can be obtained by rotating, translating, and clamping the line y = x. For example, y = (x + width / 2) k can be obtained by translating first and then rotating, or y = kx + (wMax - wMin) / 2 can be obtained by rotating first and then translating, where k is the slope, which controls how quickly the weight value wValue changes with distance, width is the transition width, and (wMax - wMin) is the weight range. In practical applications, when wMin is generally 0, the weight range is wMax.

[0122] Step 402: weighting the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel of the current block to obtain the prediction value of the current block;

[0123] In a hybrid video coding framework, coding techniques such as prediction, transformation, and quantization are typically implemented using square and rectangular blocks as units. However, in reality, the edges of moving objects are not always horizontal or vertical, and the motion vectors on either side of the moving edge are often different. The dividing line may not be accurately drawn on the edge of the object. Therefore, using a whole block for motion prediction and compensation during the encoding process can easily result in large prediction errors, which limits coding efficiency. The Geometric Partitioning Mode (GPM) allows the coding block to be divided into two non-rectangular sub-partitions, which are then weighted and fused to obtain the final prediction value after performing unidirectional prediction on each.

[0124] That is, the first prediction value is the unidirectional prediction value of the first partition (part0) of the current block, and the second prediction value is the unidirectional prediction value of the second partition (part1) of the current block. To balance the coding performance and complexity of GPM, three coding options are added to the conventional GPM: GPM with MMVD, GPM with TM, and GPM with intra and inter.

[0125] Exemplarily, the first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight value of the pixel point of the current block to obtain the prediction value of the current block, including: when the weight value is the minimum weight value, the prediction value of the current block is equal to the first prediction value; when the weight value is the maximum weight value, the prediction value of the current block is equal to the second prediction value; when the weight value is greater than the minimum weight value and less than the maximum weight value, the weight value is used as the weight value of the first prediction value, and the difference between the maximum weight value and the weight value is used as the weight value of the second prediction value for weighted operation to obtain the prediction value of the current block.

[0126] The unidirectional prediction values ​​of the two partitions part0 and part1 are weighted pixel by pixel to obtain the final GPM prediction block. The specific weighted calculation is shown in the following formula:

[0127]

[0128] Among them, offset1 is used for rounding, and shift1 is used to restore the weighted average prediction value to the same bit depth as the input video. Offset1 and shift1 are calculated as follows:

[0129]

[0130] Exemplarily, based on the current block size of W×H, the division information of the angle angleIdx and the step size distanceIdx, and the transition width corresponding to the candidate transition width parameter, a weight matrix W×H with the same size as the current block is obtained, and the unidirectional prediction values ​​of the two partitions part0 and part1 are weighted pixel by pixel using this matrix.

[0131] Step 403: determining an error parameter between the original value of the current block and the predicted value of the current block based on a preset matching criterion;

[0132] Illustratively, the matching criterion includes one of the following: Sum of Absolute Difference (SAD) criterion, Sum of Squared Difference (SSD) criterion, Mean Absolute Deviation (MAD) criterion, Mean Sum of Squared Error (MSD) criterion, and Mean Squared Error (MSE) criterion. Accordingly, the error parameter includes one of the following: Sum of Absolute Difference, Sum of Squared Error, Mean Absolute Deviation, Mean Sum of Squared Error, and Mean Squared Error.

[0133] Step 404: Sort the multiple candidate transition width parameters according to the error parameter, and select the candidate transition width parameter corresponding to the minimum error parameter as the first transition width parameter.

[0134] Exemplarily, the matching criterion is applied to calculate the error parameters between the weighted prediction value and the original value of the current coding unit when different transition width weight matrices are selected, and the errors of each transition width parameter are sorted in ascending order to obtain the error list curBlockSadList of the current block, and the candidate transition width parameter corresponding to the minimum error parameter is selected as the first transition width parameter weightTransitionWidthIdx.

[0135] Step 304: determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching;

[0136] FIG6 is a flow chart of a template matching method in an embodiment of the present application. As shown in FIG6 , the template matching method includes:

[0137] Step 601: Obtain the actual template of the current block;

[0138] In some embodiments, reconstruction information of a related area of ​​the current block is obtained as an actual template of the current block. The actual template of the current block is a template actually used when predicting the current block.

[0139] The relevant region can be understood as a region that is relevant to the current block, and the adjacent region is a reconstructed region that has been reconstructed. In some embodiments, the relevant region includes at least one of the following: an upper adjacent region, a left adjacent region, an upper-left adjacent region, a lower-left adjacent region, and an upper-right adjacent region. In some embodiments, the relevant region can also be a non-adjacent region of the current block.

[0140] The size of the relevant area can be a preset size w×h. As shown in FIG7a , the relevant area can be a square block adjacent to the current block. As shown in FIG7b , the relevant area can be a rectangular block adjacent to the current block.

[0141] Exemplarily, as shown in Figure 7b, the relevant areas include the upper adjacent area (CUAbove) and the left adjacent area (CULeft). If the upper adjacent area exists and the current block uses CUAbove in the corresponding partitioning mode, the upper adjacent area is determined to be available, which is recorded as TopTemplateAvailable and true, otherwise it is recorded as false.

[0142] If the left adjacent area exists and the current block uses CULeft in the corresponding partitioning mode, the left adjacent area is determined to be available, and LeftTemplateAvailable is recorded as true, otherwise it is recorded as false.

[0143] If TopTemplateAvailable=true, the reconstruction information of the four adjacent rows on the current block is obtained as the adjacent template on the current block, which is recorded as CurTopTemplate.

[0144] If LeftTemplateAvailable=true, obtain the reconstructed samples of the four columns adjacent to the left of the current block as the left adjacent template of the current block, recorded as CurLeftTemplate.

[0145] Step 602: Obtain a reference template for the first partition of the current block and a reference template for the second partition of the current block;

[0146] The reference template of the first partition is the template of the reference block corresponding to the first partition, and the reference template of the second partition is the template of the reference block corresponding to the second partition.

[0147] In some embodiments, obtaining a reference template for a first partition of the current block includes: when the first partition is non-intra-prediction, obtaining first motion information of the first partition; determining a first reference block of the first partition based on the first motion information; obtaining reconstruction information of a relevant area of ​​the first reference block as a reference template for the first partition; when the first partition is intra-prediction, obtaining reconstruction information of a relevant area of ​​the current block as a reference template for the first partition;

[0148] The obtaining of the reference template of the second partition of the current block includes: when the second partition is non-intra-frame prediction, obtaining second motion information of the second partition; determining a second reference block of the second partition based on the second motion information; obtaining reconstruction information of a related area of ​​the second reference block as a reference template of the second partition; when the second partition is intra-frame prediction, obtaining reconstruction information of the related area of ​​the current block as a reference template of the second partition.

[0149] Exemplarily, as shown in FIG5 b , the relevant region includes an upper adjacent region (CUAbove) and a left adjacent region (CULeft).

[0150] If the first partition (part0) is not intra-frame predicted, the motion information of part0 is obtained, and the corresponding motion vector is recorded as MV part0 .

[0151] If TopTemplateAvailable=true, apply the existing motion compensation technology to obtain the reference block of part0, and obtain the reconstruction information of the four adjacent rows of pixels on the reference block as the upper adjacent reference template of part0. part0 Offset four pixels upward to obtain the MV pointing to the upper left corner of the adjacent template on part0 part0_top , apply the existing motion compensation technology to obtain the reconstruction information of the four adjacent rows of pixels on part0 as the upper adjacent reference template of part0, and the upper adjacent reference template of part0 is recorded as Part0TopTemplate.

[0152] If LeftTemplateAvailable=true, apply the existing motion compensation technology to obtain the reference block of part0, and obtain the reconstruction information of the four rows of pixels adjacent to the left of the reference block as the left adjacent reference template of part0. part0 Shift four pixels to the left to obtain the MV pointing to the upper left corner of the left adjacent template of part0 part0_left, apply the existing motion compensation technology to obtain the reconstruction information of the four left adjacent columns of pixels of part0 as the left adjacent template of part0, and the left adjacent template of part0 is recorded as Part0LeftTemplate.

[0153] If part0 is intra-frame prediction, the reconstructed sample information of the four adjacent rows of pixels on the current block is used as the upper adjacent template of part0, and the reconstructed sample information of the four adjacent columns of pixels on the left of the current block is used as the left adjacent template of part0.

[0154] If the second partition (part1) is not intra-frame predicted, the motion information of part1 is obtained and the corresponding motion vector is recorded as MV part1 .

[0155] If TopTemplateAvailable=true, apply the existing motion compensation technology to obtain the reference block of part1, and obtain the reconstruction information of the four adjacent rows of pixels on the reference block as the upper adjacent reference template of part1. part1 Offset four pixels upward to obtain the MV pointing to the upper left corner of the adjacent template on part1 part1_top , apply the existing motion compensation technology to obtain the reconstruction information of the four adjacent rows of pixels on part1 as the upper adjacent template of part1, and the upper adjacent template of part1 is recorded as Part1TopTemplate.

[0156] If LeftTemplateAvailable=true, apply the existing motion compensation technology to obtain the reference block of part1, and obtain the reconstruction information of the four rows of pixels adjacent to the left of the reference block as the left adjacent reference template of part0. part1 Shift four pixels to the left to obtain the MV pointing to the upper left corner of the left adjacent template of part1 part1_left , apply the existing motion compensation technology to obtain the reconstruction information of the four left adjacent columns of pixels of part1 as the left adjacent template of part1, and the left adjacent template of part1 is recorded as Part1LeftTemplate.

[0157] If part1 is intra prediction, the reconstruction information of the four adjacent rows of pixels on the current block is used as the upper adjacent template of part1, and the reconstruction information of the four adjacent columns of pixels on the left of the current block is used as the left adjacent template of part1.

[0158] Step 603: Obtaining weight values ​​of reference template pixels according to the candidate transition width parameters;

[0159] In some embodiments, the prediction parameters include geometric partitioning mode parameters of the current block; exemplarily, the geometric partitioning mode parameters include at least the size and partitioning information of the current block, and the partitioning information includes the angle angleIdx and the step length distanceIdx of the positioning partitioning line.

[0160] The method of obtaining the weight value of the reference template pixel point based on the candidate transition width parameter includes: determining the distance parameter from the reference template pixel point to the extension line of the current block dividing line based on the geometric division mode parameter; and determining the weight value of the reference template pixel point based on the distance parameter and the candidate transition width parameter.

[0161] During the GPM hybrid weighted prediction calculation process, the prediction values ​​corresponding to both partitions are used for all pixels in the current block that are farther from the dividing line. The prediction values ​​near the dividing line are obtained by mixing the prediction values ​​of both partitions according to a certain weight, and the weight is related to the distance between the pixel and the dividing line. In other words, the weight of each pixel in the current block is calculated based on the distance between the pixel and the dividing line. In this embodiment of the application, the correspondence between distance and weight value is a linear relationship.

[0162] In some embodiments, the weight value of the reference template pixel point is determined based on the distance parameter and the candidate transition width parameter, including: when the candidate transition width parameter represents a transition width of non-zero pixel width, adding the distance parameter to half the transition width to obtain the translated distance parameter; dividing the translated distance parameter by the ratio of the transition width and the maximum weight value to obtain a first intermediate weight value; when the first intermediate weight value is less than or equal to the minimum weight value, using the minimum weight value as the weight value of the reference template pixel point; when the first intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the reference template pixel point; when the first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, using the intermediate weight value as the weight value of the reference template pixel point.

[0163] Exemplarily, the current block size is W×H, the upper adjacent template size is W×4, and the left adjacent template size is 4×H. When TopTemplateAvailable=true, the adjacent templates on the first partition and the adjacent templates on the second partition are weighted by weight matrices with different transition widths. The point for calculating the weight is offset upward by four pixels, and the distance parameter (weightIdx) from each pixel to the extension line of the dividing line is first calculated. The distance parameter is then translated upward by half the transition width to obtain the translated distance parameter (weightIdxL). Finally, the translated distance parameter is divided by the ratio of the transition width to the maximum weight within the transition width to obtain the first intermediate weight value, which is then clamped within the weight range to obtain the weight value (wValue) of the pixel point in the upper adjacent template.

[0164]

[0165]

[0166]

[0167] Among them, (xL, yL) is the coordinate of the pixel point of the current block, offsetX and offsetY are the offsets of the current block, weightIdxL is the distance parameter after translation, weightTransitionWidthIdx is the transition width parameter, weightTransitionWidthIdx is the logarithm of the transition width with 2 as the lower limit, 1<<(3+weightTransitionWidthIdx) represents half the transition width, and >>(weightTransitionWidthIdx-log2wMax+3+1) represents the ratio of the transition width to the maximum weight value.

[0168] If LeftTemplateAvailable = true, weight the left adjacent template of the first partition and the left adjacent template of the second partition using weight matrices with different transition widths. The weight calculation point is offset upward by four pixels. First, the distance parameter (weightIdx) from each pixel to the extension of the dividing line is calculated. Then, the distance parameter is translated upward by half the transition width to obtain the translated distance parameter (weightIdxL). Finally, within the transition width, the translated distance parameter is divided by the ratio of the transition width to the maximum weight to obtain the first intermediate weight value. This value is then clamped to the weight range to obtain the weight value (wValue) of the pixel in the lower adjacent template.

[0169]

[0170]

[0171]

[0172] In some embodiments, determining the weight value of the reference template pixel point based on the distance parameter and the candidate transition width parameter includes: when the candidate transition width parameter represents a transition width of non-zero pixel width, dividing the distance parameter by the ratio of the transition width and the maximum weight value to obtain a scaled distance parameter; adding the scaled distance parameter to half of the maximum weight value to obtain a second intermediate weight value; when the second intermediate weight value is less than or equal to the minimum weight value, using the minimum weight value as the weight value of the reference template pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the reference template pixel point; when the second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, using the intermediate weight value as the weight value of the reference template pixel point.

[0173] Accordingly, the calculation formulas (10)(11), and (13)(14) for the above weight values ​​can be changed to:

[0174]

[0175] wValue=Clip3(0,wMax,(partFlip?(weightIdxS+wMax>>1):(weightIdxS-wMax>>1))) (16)

[0176] Among them, weightIdxS is the scaled distance parameter, >>(weightTransitionWidthIdx-log2wMax+3+1) represents the ratio of the transition width to the maximum weight value, and wMax>>1 represents half of the maximum weight value.

[0177] In some embodiments, determining the weight value of the reference template pixel point based on the distance parameter and the candidate transition width parameter also includes: when the candidate transition width parameter represents a transition width of 0 pixel width, when the distance parameter is greater than 0, using the maximum weight value as the weight value of the current block pixel point; when the distance parameter is less than or equal to 0, using the minimum weight value as the weight value of the current block pixel point.

[0178] When the transition width is 0 pixel width, it can be understood that the weight matrix of the current block and the weight matrix of the reference template have no transition width, and the pixel value of the pixel point in the reference template is the pixel value of the reference template of the first partition or the pixel value of the reference template of the second partition. The weight value is not controlled by the transition width parameter, and the weight value can be determined according to the positive or negative distance from the pixel point to the extension line of the dividing line.

[0179]

[0180] For example, when weightTransitionWidthIdx=0, the transition width is 1; when weightTransitionWidthIdx=1, the transition width is 2; when weightTransitionWidthIdx=2, the transition width is 4; and when weightTransitionWidthIdx=3, the transition width is 8. When weightTransitionWidthIdx=2, the transition width is 4, which corresponds to the case in the H.266 / VVC standard. In some embodiments, weightTransitionWidthIdx=-1 can be defined to indicate a transition width of 0.

[0181] It is understandable that in order to visually represent the transition width, the embodiment of the present application introduces a control parameter weightTransitionWidthIdx. WeightIdx is used to represent the distance from the pixel point in the current block to the dividing line, and weightTransitionWidthIdx can control how fast the weight wValue changes with weightIdx. Figure 5 is a schematic diagram of the correspondence between the distance from the pixel point in the current block to the dividing line and the weight value in the embodiment of the present application. As shown in Figure 5, the horizontal axis is the distance in pixels, and the vertical axis is the weight value. When weightTransitionWidthIdx is relatively small, the weight wValue changes faster with weightIdx, that is, fewer pixels are required to transition from the maximum value to the minimum value, which is intuitively manifested as the "width" of the weighted matrix in the non-maximum and non-zero value areas "near the dividing line" is smaller. The transition width can be 0, 1, 2, 4, 8, 16, 32. When the transition width is 0, it indicates a sudden change between the maximum weight value and the minimum weight value. When the transition width is non-zero, it is necessary to ensure that the weight value of the pixel points on the dividing line is half of the maximum weight value (wMax). The greater the distance from the pixel point to the dividing line, the greater or smaller the weight value. That is, the areas in the current block where the pixel points are far from the dividing line all use the prediction values ​​corresponding to the two partitions, while the prediction values ​​near the dividing line (that is, within the transition width range) are obtained by mixing the prediction values ​​of the two partitions according to the actual weight values, and the weight value is related to the distance between the pixel point and the dividing line.

[0182] In practical applications, the correspondence between distance and weight value can be obtained by rotating, translating, and clamping the line y = x. For example, y = (x + width / 2) k can be obtained by translating first and then rotating, or y = kx + (wMax - wMin) / 2 can be obtained by rotating first and then translating, where k is the slope, which controls how quickly the weight value wValue changes with distance, width is the transition width, and (wMax - wMin) is the weight range. In practical applications, when wMin is generally 0, the weight range is wMax.

[0183] Step 604: performing pixel-by-pixel weighting on the reference template of the first partition and the reference template of the second partition according to the weight values ​​of the pixels of the reference template to obtain the reference template of the current block;

[0184] Here, the reference template of the first partition and the reference template of the second partition refer to the reference templates of the same related area. For example, the upper adjacent reference template of the first partition and the upper adjacent reference template of the second partition are weighted pixel by pixel to obtain the upper adjacent reference template of the current block, the left adjacent reference template of the first partition and the left adjacent reference template of the second partition are weighted pixel by pixel to obtain the left adjacent reference template of the current block, and so on.

[0185] Exemplarily, the reference template of the first partition and the reference template of the second partition are weighted pixel by pixel according to the weight value of the pixel point of the reference template to obtain the reference template of the current block, including: when the weight value is the minimum weight value, the reference value of the reference template is equal to the first reference value; when the weight value is the maximum weight value, the reference value of the reference template is equal to the second reference value; the weight value is greater than the minimum weight value and less than the maximum weight value, the weight value is used as the weight value of the first reference value, and the difference between the maximum weight value and the weight value is used as the weight value of the second reference value for weighted operation to obtain the reference value of the reference template. Among them, the first reference value is the pixel value of the reference template of the first partition, and the second reference value is the pixel value of the reference template of the second partition. Specifically, the upper adjacent reference template of the current block is recorded as RefTopTemplate, which is specifically obtained by the following formula.

[0186]

[0187] The left adjacent reference template of the current block is recorded as RefLeftTemplate, which is specifically obtained by the following formula.

[0188]

[0189] The reference template obtained by different weightTransitionWidthIdx is recorded as:

[0190] RefTopTemplateweightTransitionWidthIdx=1, RefLeftTemplateweightTransitionWidthIdx=1

[0191] RefTopTemplateweightTransitionWidthIdx=2, RefLeftTemplateweightTransitionWidthIdx=2

[0192] RefTopTemplateweightTransitionWidthIdx=3, RefLeftTemplateweightTransitionWidthIdx=3.

[0193] Exemplarily, based on the current block size of W×H, the division information is the angle angleIdx and the step size distanceIdx, and the transition width corresponding to the candidate transition width parameter, a weight matrix W×H with the same size as the current block is obtained. In order to obtain the weight matrix of the template, the original weight matrix W×H is expanded by 4 pixels up, down, left and right to obtain a weight matrix of (W+4)×(H+4). In the same way, the offsetX' and offsetY' corresponding to the template are used to obtain the template weight matrix of Wx4 (upper template) and / or 4xH (left template) size corresponding to the upper adjacent template and / or left adjacent template of the current block.

[0194] Figuratively speaking, the weight matrix for the current block is a W×H weight matrix "cut out" from the (W+4)×(H+4) weight matrix using the offsetX and offsetY corresponding to the current block. The weight matrix for the template is a Wx4 (top template) and / or 4xH (left template) weight matrix "cut out" from the (W+4)×(H+4) weight matrix using the offsetX' and offsetY' corresponding to the template. The weight matrix used by the template and the weight matrix of the current block are related in that the corresponding dividing lines are located at the same position, that is, the dividing line corresponding to the weight matrix used by the template is an extension of the dividing line of the current block.

[0195] Step 605: Perform template matching on the actual template of the current block and the reference template of the current block to obtain the template matching cost parameter.

[0196] Based on a preset matching criterion, a template matching cost parameter is calculated for the actual template and the reference template in the same relevant area of ​​the current block. Exemplarily, the matching criterion includes one of the following: Sum of Absolute Difference (SAD) criterion, Sum of Squared Difference (SSD) criterion, Mean Absolute Deviation (MAD) criterion, Mean Sum of Squared Error (MSD) criterion, or Mean Squared Error (MSE) criterion. Accordingly, the template matching cost parameter includes one of the following: Sum of Absolute Difference, Sum of Squared Error, Mean Absolute Deviation, Mean Sum of Squared Error, or Mean Squared Error.

[0197] Exemplarily, the SAD criterion is applied to calculate the SAD of each relevant region template respectively, and then the SADs of each relevant region template are added together to obtain the SAD corresponding to the candidate transition width parameter.

[0198] When TopTemplateAvailable=true, calculate the SAD between the upper adjacent template CurTopTemplate of the current block and the upper adjacent reference template RefTopTemplate, denoted as SAD Top .

[0199] When LeftTemplateAvailable=true, calculate the SAD between the left adjacent template CurLeftTemplate of the current block and the left adjacent reference template RefLeftTemplate, denoted as SAD Left .

[0200] SAD Top and SAD Left The sum is added to obtain the SAD of the corresponding candidate transition width parameter.

[0201] Step 305: Sort the multiple candidate transition width parameters according to the template matching cost parameter to obtain index parameters of the multiple candidate transition width parameters;

[0202] Exemplarily, the plurality of candidate transition width parameters are sorted according to the template matching cost parameter, and the sorting sequence number is used as an index parameter. For example, the SADs of all candidate transition width parameters are sorted in ascending order to obtain a re-sorted candidate transition width parameter cost list tmSadList, where the template matching cost of the transition width parameter ranked first in tmSadList is the smallest, and the template matching costs of the subsequent transition width parameters are larger. The index parameter (index) in tmSadList can be 0, 1, 2, 3, etc.

[0203] Step 306: Determine the index parameter of the first transition width parameter from the index parameters of the plurality of candidate transition width parameters;

[0204] Exemplarily, the first transition width parameter weightTransitionWidthIdx is determined from the error list curBlockSadList of the current block, and the index parameter h of weightTransitionWidthIdx in the cost list tmSadList of the candidate transition width parameters is determined:

[0205] weightTransitionWidthIdx=curBlockSadList[0] (20)

[0206] tmSadList[h]=weightTransitionWidthIdx (21)

[0207] Step 307: Encode the index parameter of the first transition width parameter to obtain a code stream.

[0208] Exemplarily, in some embodiments, the index parameter of the first transition width parameter includes a first index parameter of a transition width group to which the first transition width parameter belongs, and a second index parameter of the first transition width parameter within the transition width group to which it belongs.

[0209] For example, in some embodiments, Golmb-Rice encoding is used to group the encoded index parameters. First, the grouping parameter divisor is set to indicate the number of index parameters in each group. For example, if divisor=1, one index parameter is grouped together; if divisor=2, two index parameters are grouped together; if divisor=4, four index parameters are grouped together; and if divisor=8, eight index parameters are grouped together. When there are fewer candidate transition width parameters, a Golmb-Rice encoding index parameter with divisor=1 can be used. When there are more candidate transition width parameters, a Golmb-Rice encoding index parameter with a divisor greater than 1 can save bit rate.

[0210] For example, taking divisor=2 as an example, the index parameter h is divided into two parts for encoding, one part is the group number Prefix (first index parameter), and the other part is the offset Suffix within the group after grouping (second index parameter):

[0211] Prefix=h / divisor (22)

[0212] Suffix=h&(divisor-1) (23)

[0213] The context model is used to encode the group number Prefix into a unary code, and the lower bit of the remainder Suffix is ​​taken as the codeword of Suffix, which is then truncated into a binary code. Table 1 below shows the codewords of Prefix and Suffix in Golmb-Rice and their corresponding CodeNum.

[0214] Table 1 Golmb-Rice codewords and their corresponding CodeNum

[0215] prefix codewordSuffix codewordCodeNum0110001111101021011311004110151110611117

[0216] It should be noted that the encoding method of the index parameter is not limited to Golmb-Rice encoding, and Exponential Golomb encoding can also be used.

[0217] Exemplarily, in some embodiments, the index parameter of the first transition width parameter is used to index a portion of candidate transition width parameters that are located in the first N positions in the order of the template matching cost parameters, where N is a positive integer. It is understood that when there are a large number of candidate transition width parameters, after sorting the template cost parameters in ascending order, since the first transition width parameter is likely to be located in the first N positions, the first N candidate transition width parameters can be marked as available transition width parameters, and only one of the first N index parameters can be encoded. In this way, a shorter bit can be used to index the first transition width parameter from many candidate transition width parameters, thereby reducing the bit rate.

[0218] In the embodiments of the present application, the weight range also affects the prediction accuracy. A larger weight range indicates higher prediction accuracy, while a smaller weight range indicates lower prediction accuracy. In practical applications, the minimum weight value is generally 0. Therefore, the maximum weight value can be pre-configured or flexibly configured based on actual prediction accuracy requirements.

[0219] Exemplarily, in some embodiments, the method further includes: determining the maximum weight value according to the first transition width parameter.

[0220] Exemplarily, in some embodiments, determining the maximum weight value based on the first transition width parameter includes: determining the maximum weight value corresponding to the first transition width parameter based on a preset mapping relationship between the transition width parameter and the maximum weight value. For example, when the transition width is 2, the weight range is (0, 4); when the transition pixel width is 4, the weight range is (0, 8); and when the transition pixel width is 8, the weight range is (0, 16).

[0221] Exemplarily, in some embodiments, the method further includes: determining, according to a second syntax element, whether to determine the first transition width parameter based on template matching. Exemplarily, in some embodiments, the second syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit, or a current block data unit.

[0222] By adopting the above technical solution, the encoding end determines the first transition width parameter from multiple candidate transition width parameters, applies template matching to sort the multiple candidate transition width parameters, determines the index parameter of the first transition width parameter from the sorting result, and encodes the index parameter, so that the decoding end also applies template matching to sort the multiple candidate transition width parameters, determines the first transition width parameter from the sorting result according to the index parameter, selects the optimal transition width for the current block, and then determines the optimal weight matrix of the current block. Compared with using a fixed transition width, the prediction accuracy of GPM in weighted prediction can be improved.

[0223] The embodiment of the present application further provides another encoding method. FIG8 is a schematic diagram of a second flow chart of the encoding method provided in the embodiment of the present application. As shown in FIG8 , the method includes:

[0224] Step 801: Obtain the geometric partitioning mode prediction parameters of the current block;

[0225] Step 802: Determine multiple candidate transition width parameters of the weight matrix of the current block according to the prediction parameters;

[0226] Step 803: Determine template matching cost parameters of the multiple candidate transition width parameters based on template matching;

[0227] Step 804: sorting the multiple candidate transition width parameters according to the template matching cost parameter, and selecting the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter;

[0228] In other words, the different candidate transition width parameters are sorted by the template matching cost parameter. In this case, the candidate with the smallest cost parameter value is ranked first, and the candidate transition width parameter corresponding to the smallest template matching cost parameter is selected as the first transition width parameter actually used for the current block. This method eliminates the need to transmit the transition width parameter in the bitstream. In this case, the transition width parameter corresponding to the smallest template matching cost parameter is the same as the transition width parameter of the current block.

[0229] Step 805: Obtaining a weight value of the pixel point of the current block according to the first transition width parameter;

[0230] Step 806: weighting the first prediction value and the second prediction value of the current block pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

[0231] Using the above encoding method, template matching is applied to sort multiple candidate transition width parameters, and the candidate transition width parameter corresponding to the minimum template matching cost parameter is obtained from the sorting result as the first transition width parameter, and then the optimal weight matrix of the current block is determined. Compared with using a fixed transition width, the prediction accuracy of GPM in weighted prediction can be improved.

[0232] The present application also provides a decoding method. FIG9 is a schematic diagram of a first flow chart of the decoding method provided in the present application. As shown in FIG9 , the method includes:

[0233] Step 901: Obtain the geometric partitioning mode prediction parameters of the current block;

[0234] Step 902: Determine multiple candidate transition width parameters of the weight matrix of the current block according to the prediction parameters;

[0235] It should be noted that the prediction parameters at least include parameters for indicating the optional range of the candidate transition width parameters.

[0236] The transition width parameter (weightTransitionWidthIdx) is a parameter that characterizes the transition width (weightTransitionWidth) of the weight matrix. The transition width is expressed in pixels to represent the transition pixel width of the weight matrix at the dividing line. The transition width parameter can be the transition width itself or a control variable for the transition width. In some embodiments, the optional range of transition width can include 1, 2, 4, 8, 16, 32, 64, and other powers of 2. For example, the range of transition width is 2, 4, and 8. The range of transition width is 1, 2, 4, 8, 16, and 32. In some embodiments, the optional range of transition width can also include 0, 3, 5, 7, and other non-powers of 2.

[0237] In some embodiments, the transition width parameter is a logarithmic value of the transition width with base 2. When the selection range of the transition width is 1, 2, 4, 8, 16, 32, the selection range of the candidate transition width parameter is 0, 1, 2, 3, 4, 5 accordingly.

[0238] Exemplarily, in some embodiments, the prediction parameter includes a first syntax element for indicating the plurality of candidate transition width parameters.

[0239] Exemplarily, the first syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit. That is, the selection range of the weight matrix transition width can be controlled in a high-level syntax such as a sequence parameter set (SPS) or a picture parameter set (SPS). Or the selection range of the weight matrix transition width is indicated in a picture header data unit (PH), a slice header data unit (SH) or a current block data unit (CU layer). For example, the selection range of controlling the weight matrix transition width is 4 to 16.

[0240] Exemplarily, in some embodiments, the prediction parameters include the size of the current block, the resolution of the current block, the quantization parameter of the current block, and the motion vector difference between two partitions of the current block.

[0241] The larger the size of the current block, the larger the transition width, and the smaller the size of the current block, the smaller the transition width; the higher the resolution of the current block, the larger the transition width, and the lower the resolution of the current block, the smaller the transition width; the smaller the quantization parameter of the current block, the larger the transition width, and the larger the size of the current block, the smaller the transition width; the larger the difference between the motion vectors of the two partitions, the larger the transition width, and the smaller the difference between the motion vectors of the two partitions, the smaller the transition width.

[0242] In some embodiments, the upper limit and / or lower limit of the transition width selection range may be determined based on these prediction parameters, that is, the upper limit and / or lower limit of the candidate transition width parameter selection range may be determined.

[0243] Step 903: determining a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters based on template matching;

[0244] In some embodiments, the method further includes: decoding the code stream to determine the index parameter of the first transition width parameter; determining the first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters based on template matching, including: determining the template matching cost parameters of the multiple candidate transition width parameters based on template matching; sorting the multiple candidate transition width parameters according to the template matching cost parameters to obtain the index parameters of the multiple candidate transition width parameters; and determining the first transition width parameter from the multiple candidate transition width parameters according to the index parameter of the first transition width parameter.

[0245] In other words, the transition width parameter index parameter for the current block is determined by the decoded bitstream. The template matching cost parameter is used to sort the different candidate transition width parameters, thereby determining the index parameters corresponding to the different candidate transition width parameters and thereby determining the first transition width parameter actually used for the current block. In this case, the transition width parameter corresponding to the minimum template matching cost parameter may be different from the first transition width parameter of the current block.

[0246] In some embodiments, the method of determining the first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters based on template matching includes: determining the template matching cost parameters of the multiple candidate transition width parameters based on template matching; sorting the multiple candidate transition width parameters according to the template matching cost parameters, and selecting the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter.

[0247] In other words, the different candidate transition width parameters are sorted by the template matching cost parameter. In this case, the candidate with the smallest cost parameter value is ranked first, and the candidate transition width parameter corresponding to the smallest template matching cost parameter can be selected as the first transition width parameter actually used for the current block, thus eliminating the need to transmit the transition width parameter in the bitstream. In this case, the transition width parameter corresponding to the smallest template matching cost parameter is the same as the transition width parameter of the current block.

[0248] For example, in some embodiments, the multiple candidate transition width parameters are sorted according to the template matching cost parameter to obtain a template matching cost list, the bitstream is decoded to obtain an index parameter of the first transition width parameter, and the template matching cost list is searched based on the index parameter of the first transition width parameter to determine the first transition width parameter; or the transition width parameter ranked first in the template matching cost list is directly used as the first transition width parameter. Template matching is applied to select the optimal transition width for the current block from the multiple candidate transition widths, thereby determining the optimal weight matrix for the current block. This can improve the prediction accuracy of GPM during weighted prediction compared to using a fixed transition width.

[0249] Exemplarily, in some embodiments, the template matching cost parameters of the multiple candidate transition width parameters are determined based on template matching, including: obtaining the actual template of the current block; obtaining the reference template of the first partition of the current block, and the reference template of the second partition of the current block; obtaining the weight values ​​of the reference template pixels according to the candidate transition width parameters; weighting the reference template of the first partition and the reference template of the second partition pixel by pixel according to the weight values ​​of the reference template pixels to obtain the reference template of the current block; template matching the actual template of the current block with the reference template of the current block to obtain the template matching cost parameters.

[0250] Exemplarily, in some embodiments, obtaining the actual template of the current block includes: obtaining reconstruction information of a related area of ​​the current block as the actual template of the current block.

[0251] Exemplarily, in some embodiments, obtaining a reference template for the first partition of the current block includes: when the first partition is non-intra prediction, obtaining first motion information of the first partition; determining a first reference block of the first partition based on the first motion information; obtaining reconstruction information of a related area of ​​the first reference block as a reference template for the first partition; when the first partition is intra prediction, obtaining reconstruction information of a related area of ​​the current block as a reference template for the first partition;

[0252] The obtaining of the reference template of the second partition of the current block includes: when the second partition is non-intra-frame prediction, obtaining second motion information of the second partition; determining a second reference block of the second partition based on the second motion information; obtaining reconstruction information of a related area of ​​the second reference block as a reference template of the second partition; when the second partition is intra-frame prediction, obtaining reconstruction information of the related area of ​​the current block as a reference template of the second partition.

[0253] Exemplarily, in some embodiments, the related area includes at least one of the following: an upper adjacent area, a left adjacent area, an upper left adjacent area, a lower left adjacent area, and an upper right adjacent area.

[0254] Exemplarily, in some embodiments, the position and size information of the relevant area can be pre-set or configured through syntax elements. For example, the relevant area includes an upper adjacent area and a left adjacent area, and can further include one or more of an upper left adjacent area, a lower left adjacent area, and an upper right adjacent area. The current block size is W×H, and the relevant area size is w×h, where w and h are equal or unequal. In some embodiments, the relevant area includes an upper adjacent area of ​​size W×4 and a left adjacent area of ​​size 4×H. The number of rows and columns of the upper adjacent area and the left adjacent area is not limited to 4 rows / columns, and there are more options, such as: 1, 2, 3, 5, etc.

[0255] Exemplarily, in some embodiments, the template matching cost parameter includes one of the following: sum of absolute errors, sum of squared errors, mean absolute deviation error, mean sum of squared errors, and mean squared error.

[0256] For a more detailed template matching method, please refer to steps 601 to 605 on the encoding side.

[0257] At a decoding end, the code stream is decoded to determine an index parameter of the first transition width parameter. Exemplarily, in some embodiments, the index parameter of the first transition width parameter includes a first index parameter of a transition width group to which the first transition width parameter belongs, and a second index parameter of the first transition width parameter within the transition width group to which the first transition width parameter belongs.

[0258] The first index parameter Prefix and the second index parameter Suffix are decoded, and the first transition width parameter weightTransitionWidthIdx is obtained as follows:

[0259] merge_gpm_weightedmatrix_idx[x0][y0]=Prefix*divisor+Suffix (24)

[0260] h=merge_gpm_weightedmatrix_idx[x0][y0] (25)

[0261] weightTransitionWidthIdx=tmSadList[h] (26)

[0262] Among them, h is the index of the weight matrix in the template matching distortion list tmSadList, and weightTransitionWidthIdx is the optimal transition width parameter obtained by decoding, that is, the first transition width parameter.

[0263] Step 904: Obtaining a weight value of the pixel point of the current block according to the first transition width parameter;

[0264] Exemplarily, in some embodiments, the prediction parameters include geometric partitioning mode parameters of the current block, used to locate the partitioning line of the current block. Exemplarily, the geometric partitioning mode parameters include at least the size of the current block and partitioning information, where the partitioning information includes an angle angleIdx and a step length distanceIdx for locating the partitioning line.

[0265] The method of obtaining the weight value of the current block pixel point based on the candidate transition width parameter includes: determining the distance parameter from the current block pixel point to the dividing line based on the geometric division mode parameter; and determining the weight value of the current block pixel point based on the distance parameter and the first transition width parameter.

[0266] In some embodiments, obtaining the weight value of the current block pixel point based on the candidate transition width parameter includes: when the candidate transition width parameter represents a transition width that is not a zero pixel width, adding the distance parameter to half the transition width to obtain the translated distance parameter; dividing the translated distance parameter by the ratio of the transition width and the maximum weight value to obtain a first intermediate weight value; when the first intermediate weight value is less than or equal to the minimum weight value, using the minimum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, using the intermediate weight value as the weight value of the current block pixel point.

[0267] In some embodiments, determining the weight value of the current block pixel point based on the distance parameter and the candidate transition width parameter includes: when the candidate transition width parameter represents a transition width of non-zero pixel width, dividing the distance parameter by the ratio of the transition width and the maximum weight value to obtain a scaled distance parameter; adding the scaled distance parameter to half of the maximum weight value to obtain a second intermediate weight value; when the second intermediate weight value is less than or equal to the minimum weight value, using the minimum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, using the maximum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, using the intermediate weight value as the weight value of the second pixel point.

[0268] In some embodiments, determining the weight value of the current block pixel point based on the distance parameter and the candidate transition width parameter also includes: when the candidate transition width parameter represents a transition width of 0 pixel width, when the distance parameter is greater than 0, using the maximum weight value as the weight value of the current block pixel point; when the distance parameter is less than or equal to 0, using the minimum weight value as the weight value of the current block pixel point.

[0269] When the transition width is 0 pixel width, it can be understood as no transition width of the current block. The predicted value of the pixel point in the current block is the predicted value of the first partition or the predicted value of the second partition. The weight value is not controlled by the transition width parameter. The weight value can be determined according to the positive or negative distance from the pixel point to the dividing line.

[0270] Step 905: weighting the first prediction value and the second prediction value of the current block pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

[0271] In a hybrid video coding framework, coding techniques such as prediction, transformation, and quantization are typically implemented using square and rectangular blocks as units. However, in reality, the edges of moving objects are not always horizontal or vertical, and the motion vectors on either side of the moving edge are often different. The dividing line may not be accurately drawn on the edge of the object. Therefore, using a whole block for motion prediction and compensation during the encoding process can easily result in large prediction errors, which limits coding efficiency. The Geometric Partitioning Mode (GPM) allows the coding block to be divided into two non-rectangular sub-partitions, which are then weighted and fused to obtain the final prediction value after performing unidirectional prediction on each.

[0272] That is, the first prediction value is the unidirectional prediction value of the first partition (part0) of the current block, and the second prediction value is the unidirectional prediction value of the second partition (part1) of the current block. To balance the coding performance and complexity of GPM, three coding options are added to the conventional GPM: GPM with MMVD, GPM with TM, and GPM with intra and inter.

[0273] Exemplarily, the first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight value of the pixel point of the current block to obtain the prediction value of the current block, including: when the weight value is the minimum weight value, the prediction value of the current block is equal to the first prediction value; when the weight value is the maximum weight value, the prediction value of the current block is equal to the second prediction value; when the weight value is greater than the minimum weight value and less than the maximum weight value, the weight value is used as the weight value of the first prediction value, and the difference between the maximum weight value and the weight value is used as the weight value of the second prediction value for weighted operation to obtain the prediction value of the current block.

[0274] Exemplarily, in some embodiments, the index parameter of the first transition width parameter is used to index a portion of candidate transition width parameters that are located in the first N positions in the order of the template matching cost parameters, where N is a positive integer. It is understood that when there are a large number of candidate transition width parameters, after sorting the template cost parameters in ascending order, since the first transition width parameter is likely to be located in the first N positions, the first N candidate transition width parameters can be marked as available transition width parameters, and only one of the first N index parameters can be encoded. In this way, a shorter bit can be used to index the first transition width parameter from many candidate transition width parameters, thereby reducing the bit rate.

[0275] In the embodiments of the present application, the weight range also affects the prediction accuracy. A larger weight range indicates higher prediction accuracy, while a smaller weight range indicates lower prediction accuracy. In practical applications, the minimum weight value is generally 0. Therefore, the maximum weight value can be pre-configured or flexibly configured based on actual prediction accuracy requirements.

[0276] Exemplarily, in some embodiments, the method further includes: determining the maximum weight value according to the first transition width parameter.

[0277] Exemplarily, in some embodiments, determining the maximum weight value based on the first transition width parameter includes: determining the maximum weight value corresponding to the first transition width parameter based on a preset mapping relationship between the transition width parameter and the maximum weight value. For example, when the transition width is 2, the weight range is (0, 4); when the transition pixel width is 4, the weight range is (0, 8); and when the transition pixel width is 8, the weight range is (0, 16).

[0278] Exemplarily, in some embodiments, the method further includes: determining, according to a second syntax element, whether to determine the first transition width parameter based on template matching. Exemplarily, in some embodiments, the second syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit, or a current block data unit.

[0279] Using the above technical solution, the encoding end applies template matching to sort multiple candidate transition width parameters, selects the optimal transition width parameter for the current block from the sorting result, and then determines the optimal weight matrix of the current block. Compared with using a fixed transition width, the prediction accuracy of GPM in weighted prediction can be improved. The optimal transition width can be selected for the current block, and then the optimal weight matrix of the current block can be determined. Compared with using a fixed transition width, the prediction accuracy of GPM in weighted prediction can be improved. Specifically, the index parameter of the first transition width parameter is obtained by decoding the code stream, and the first transition width parameter is determined from the sorting result according to the index parameter; or the candidate transition width parameter corresponding to the minimum template matching cost parameter is directly obtained from the sorting result as the first transition width parameter. This makes the selection of the weight matrix more accurate. Using the Golmb-Rice encoding index parameter can further save bit rate.

[0280] The following further illustrates the application of the coding and decoding method provided in the embodiment of the present application. It should be noted that the geometric partitioning mode is located in the inter-frame prediction unit 115 shown in FIG1 and the motion compensation unit 215 shown in FIG2 in the hybrid video coding framework.

[0281] In a hybrid video coding framework, coding techniques such as prediction, transformation, and quantization are typically implemented using square and rectangular blocks as units. However, in reality, the edges of moving objects are not always horizontal or vertical, and the motion vectors on either side of the moving edge are often different. The dividing line may not be accurately drawn on the edge of the object. Therefore, using a whole block for motion prediction and compensation during the encoding process can easily result in large prediction errors, which limits coding efficiency. The Geometric Partitioning Mode (GPM) allows the coding block to be divided into two non-rectangular sub-partitions, which are then weighted and fused to obtain the final prediction value after performing unidirectional prediction on each.

[0282] The GPM mode was introduced in H.266 / VVC, and the ECM model established during the exploration of the next-generation video coding standard also used this technology. In addition, ECM4.0 further added optional sub-coding modes based on H.266 / VVC.

[0283] Currently, GPM includes 64 partitioning methods, as shown in Figure 10. These methods include 20 angles, with each angle corresponding to up to four offsets. The solid lines in Figure 10 represent the corresponding partitioning methods. A geometric line is located based on the selected angle and offset parameters, dividing the current block into two sub-partitions. Unidirectional motion compensation is performed on each sub-partition to produce a unidirectional prediction value. Finally, the unidirectional prediction values ​​of the two sub-partitions are weighted and fused using a weight matrix to produce the final GPM prediction value.

[0284] The conditions for using GPM are as follows:

[0285] ① The sequence parameter set (SPS) allows the use of GPM prediction method;

[0286] ②The current coded image area belongs to a bidirectional prediction slice (B slice);

[0287] ③Block size limit: The width and height must both be greater than or equal to 8 and less than 128, and the aspect ratio and height-to-width ratio of the current block must both be less than 8.

[0288] ④ The current block is not general merge prediction, merge_subblock prediction, affine prediction, or composed intra inter prediction (CIIP).

[0289] In order to balance the coding performance and complexity of GPM, three coding options, GPM with MMVD, GPM with TM, and GPM with intra and inter, are added to the conventional GPM.

[0290] GPM_MMVD applies MMVD technology to the GPM mode. In the latest Beyond VVC version, ECM4.0, the process of MMVD technology is as follows:

[0291] (1) First, reuse the unidirectional Merge candidates of the normal GPM mode and use these candidates as the initial motion vectors.

[0292] (2) An offset is added to the initial MV. The offset is selected from a set of fixed optional amplitude and direction combinations (identified by amplitude index and direction symbol in the code stream) to obtain the offset motion vector for motion compensation.

[0293] The GPM_TM technique uses template matching for GPM mode to refine the partition motion vector by minimizing the difference between the template of the current coding unit / block and the template of the corresponding coding unit / block in the reference picture.

[0294] The GPM with intra and inter technology applies intra mode and inter mode to the two partitions of GPM to obtain partition prediction values, and finally performs weighted mixing on the prediction values ​​of the two partitions.

[0295] Currently, only one of GPM-MMVD and GPM-TM is enabled for the GPM CU, and the two are in a competitive relationship. When the GPM-MMVD flags gpm_mmvd_flag[x0][y0] of both partitions are equal to false (that is, both partitions of the GPM have disabled GPM-MMVD mode), the GPM-TM flag tmMergeFlag[x0][y0] is parsed to indicate whether template matching is applied to the two GPM partitions. When tmMergeFlag is true, both partitions correct the motion vectors in GPM_TM mode.

[0296] The syntax elements of the four GPM modes are shown in Table 2 below.

[0297] Table 2. Syntactic element analysis of the four GPM modes

[0298]

[0299]

[0300] Note: gpm_merge_idx() and gpm_merge_idx1() are both used to parse the GPM partitioning method and the candidate indexes of the two partitions, but the parsing method of the second partition candidate is different.

[0301] gpm_merge_idx()

[0302] merge_gpm_partition_idx[x0][y0]ae(v)merge_gpm_idx0[x0][y0]=unary_max_eqprob(numCandminus2)+1ae(v)if(numCandminus2>0) merge_gpm_idx1[x0][y0]=unary_max_eqprob(numCandminus2-1)+1ae(v)

[0303] gpm_merge_idx1()

[0304] merge_gpm_partition_idx[x0][y0]ae(v)merge_gpm_idx0[x0][y0]=unary_max_eqprob(numCandminus2)+1ae(v)if(numCandminus2>0) merge_gpm_idx1[x0][y0]=unary_max_eqprob(numCandminus2)+1ae(v)

[0305] (1) Construction of GPM one-way candidate list. The GPM one-way candidate list is derived from the regular Merge list.

[0306] Because each partition in a CU using GPM uses only unidirectional prediction, and each item in the merge list could contain bidirectionally predicted MV information, the unidirectionally predicted MV must be extracted for GPM use. The maximum length of the GPM candidate list is specified by the MaxNumGpmMergeCand syntax element in the SPS layer. In the ECM 4.0 to 5.0 implementation, duplicate checking and deduplication are performed when adding each of the following candidate items to the candidate list:

[0307] First, using a parity check, let X == (m & 0x01). This means extracting the last bit of m, where & is a bitwise AND operation, m represents the index of each candidate in the GPM unidirectional candidate list (m = 0…9), and X represents whether the prediction direction of the GPM candidate at position m is forward or backward. This ensures that the GPM candidate at position m prioritizes the MV information corresponding to the reference image in the reference list corresponding to X in the regular merge list, and then uses it for prediction of the GPM partition, as shown in the options corresponding to the "×" area in Table 3. If the corresponding MV is unavailable (or the candidate in the regular merge list at position m itself may be unidirectional), the opposite MV (the MV represented by the blank area corresponding to the "×" area) is used, in which case X = 1-X. Each candidate is then checked for duplicates and added to the GPM candidate list. Specifically, each entry is compared with existing entries in the candidate list. Entries with identical reference images and MV values ​​are not added, and only those with different values ​​are added.

[0308] Table 3. GPM candidate list constructed by the first parity pruning

[0309]

[0310] If the length of the GPM one-way candidate list after filling in the above process is less than MaxNumGpmMergeCand, new alternatives are obtained in the opposite odd-even pruning order shown in Table 4, and these alternatives are filled in after checking for duplicates and removing duplicates based on the current GPM candidate list.

[0311] Table 4. GPM candidate list constructed by the second parity pruning

[0312]

[0313] If the number of GPM candidate lists is still less than MaxNumGpmMergeCand, then based on the existing GPM candidate list, after checking for duplicates, add up to two average candidates. Average the first two available L0 candidates in the GPM candidate list and add a forward L0 candidate. Average the first two available backward L1 candidates in the GPM candidate list and add an L1 candidate. If the list length still does not meet the requirements, perform parity pruning on the bidirectional zero candidates and fill in the unidirectional zero candidates in turn.

[0314] 2) GPM prediction process

[0315] 2) GPM prediction process

[0316] 2.1) Obtaining the one-way prediction value of two partitions

[0317] 2.1.1) Conventional GPM Mode

[0318] In conventional GPM mode, the motion vectors of the two partitions of the CU are directly derived from the corresponding options in the previously constructed GPM candidate list.

[0319] Let merge_gpm_idx0[xCb][yCb] represent the index of the actual entropy coded partition A's mv in the one-way merge list, and merge_gpm_idx1[xCb][yCb] represent the index of the actual entropy coded partition B's mv in the merge list. Let m and n be the one-way merge indices of the two partitions respectively.

[0320] Take the mth candidate M from the merge list for the mv construction of partition A. The acquisition of the one-way candidate of partition A is shown in (27)

[0321]

[0322] The nth candidate N is taken from the merge list and used to construct the mv of partition B. Since the position of the mv of the second partition in the merge list may be due to the fact that the first partition selected the option at the front, the index of the second partition needs to be reduced by 1 for entropy coding. The acquisition of the unidirectional candidate of partition B is shown in (28).

[0323]

[0324] X represents the prediction direction of the GPM motion vector candidate at position m. X = 0 indicates that the motion vector candidate of the GPM partition comes from the forward reference frame, and X = 1 indicates that the motion vector candidate of the GPM partition comes from the backward reference frame. According to the rule of odd-even clipping, X == (m & 0x01). If the corresponding mv is not available, the opposite mv is used, in which case X = 1-X. mvA and mvB represent the motion vectors of the two partitions, refIdxA and refIdxB represent the reference indices of the two partitions, and predListFlagA and predListFlagB represent the prediction list flags of the two partitions. The motion vector information of partition A is obtained as shown in the following formula.

[0325]

[0326] Similarly, for the B partition, X==(n&0x01). If the corresponding mv is not available, the opposite mv is used. At this time, X=1-X, and the motion vector information of the B partition is obtained as shown in the following formula.

[0327]

[0328] The obtained motion vector information of the two partitions is used to perform unidirectional motion compensation prediction respectively to obtain unidirectional prediction values ​​of the two partitions.

[0329] 2.1.2) GPM_MMVD mode

[0330] In GPM_MMVD mode, the motion vector values ​​of the CU's A and / or B partitions are calculated by adding an offset to the previously constructed GPM candidate list options. This offset is derived from a finite set specified by the GPM_MMVD mode. Specifically, in GPM_MMVD mode, the GPM unidirectional merge candidate list is first used to obtain the candidate list for the current block as the initial MV candidate. The encoder then searches eight candidate directions (four horizontal / vertical directions and four diagonal directions) using nine step sizes (1 / 4 pixel, 1 / 2 pixel, 1 pixel, 2 pixel, 3 pixel, 4 pixel, 6 pixel, 8 pixel, and 16 pixel) (a total of 72 MMVD search modes) to obtain the motion vector offset mvOffset. Note that when pic_fpel_mmvd_enabled_flag is 0, the MVD step size is shifted left by two bits, i.e., amplified by a factor of 4.

[0331] In the bitstream, the flags gpm_mmvd_flag0[x0][y0] and gpm_mmvd_flag1[x0][y0] are used to indicate whether GPM_MMVD is used for motion vector refinement in the A and B geometric partitions, respectively. If gpm_mmvd_flag0[x0][y0] = 1, the motion vector of partition A is obtained by adding a motion vector offset mvOffsetA to the motion vector in the GPM candidate list. If gpm_mmvd_flag1[x0][y0] = 1, the motion vector of partition B is obtained by adding a motion vector offset mvOffsetB to the motion vector in the GPM candidate list. Both flags gpm_mmvd_flag0[x0][y0] and gpm_mmvd_flag1[x0][y0] can be 1 at the same time, in which case the two geometric partitions refine the motion vector candidates using the motion vector offsets offsetA and offsetB, respectively.

[0332] Taking partition A as an example, when partition A is predicted using the GPM_MMVD mode, first, the lth candidate L is taken from the constructed GPM unidirectional merge list to construct the initial motion vector mvA of partition A, where l is the GPM unidirectional merge index of partition A, and merge_gpm_idx0[xCb][yCb] represents the index of the actual entropy-coded mv of partition A in the unidirectional merge list. Then, mvA is obtained as follows:

[0333]

[0334] Let mmvdIdx be the MMVD mode index used by partition A. From mmvdIdx, we can deduce the MMVD step index geo_mmvd_distance_idx[x0][y0] and search direction index geo_mmvd_direction_idx[x0][y0]. Using the step index and direction index, we can parse the corresponding offset direction and step. Based on the offset direction and step, we can get the motion vector offset value mvOffsetA of partition A in GPM_MMVD mode:

[0335]

[0336] Where geo_mmvd_idx[xCb][yCb] represents the candidate index value of the actual entropy coding of the partition using the GPM_MMVD mode.

[0337] The final motion vector after adding the offset in MMVD mode is represented by dstmv. The motion vector information of partition A is obtained as shown in the following formula.

[0338]

[0339] Among them, refIdxA represents the reference index of the initial motion vector of partition A in the GPM unidirectional merge candidate list using the GPM_MMVD mode, and predListFlagA represents the prediction list flag of partition A.

[0340] The refined dstmv is used to perform unidirectional motion compensation prediction to obtain the unidirectional prediction value of the A partition.

[0341] 2.1.3) GPM_TM Mode

[0342] In the GPM_TM mode, both partitions of the current block use this mode, and the motion vectors of the two partitions are motion information refined using the template matching (TM) method based on the corresponding options in the previously constructed GPM candidate list.

[0343] Specifically, first, the initial MVs of the two geometric partitions of the current block, mvA and mvB, are obtained from the corresponding items in the GPM Merge candidate list. Then, the reference templates of the two geometric partitions under the current segmentation angle Partition_angle are obtained by looking up the table, as shown in Table 5, where A indicates the use of upper adjacent samples, L indicates the use of left adjacent samples, and L+A indicates the use of both left and upper adjacent samples. Finally, based on mvA and mvB, within a certain offset range, the MV is refined by minimizing the difference between the template of the current coding unit / block and the template of the corresponding coding unit / block in the reference picture (half-pixel interpolation is disabled). That is, the motion vector is further refined by the matching cost between the current block template and the reference template to obtain the refined motion vectors mvA' and mvB'.

[0344] Table 5 Templates used by two partitions at different partitioning angles

[0345] Partition angle023458111213141 st partitionAAAAL+AL+AL+AL+AAA2 nd partitionL+AL+AL+ALLLLL+AL+AL+A

[0346] The motion vector information mvA' and mvB' of the two partitions are used to perform unidirectional motion compensation prediction respectively to obtain unidirectional prediction values ​​of the two partitions in the GPM mode.

[0347] 2.1.4) GPM with inter and intra modes

[0348] In GPM with inter and intra coding mode, one partition is allowed to use intra mode (as shown in Figure 11a-c). When only one partition uses intra prediction mode (intra mode), the other partition uses regular GPM mode or GPM_MMVD mode in inter prediction mode (inter mode).

[0349] The two geometric partitions are marked with a GPMIntraFlag to indicate whether they use intra or inter prediction mode. When GPMIntraFlag=1, the current partition uses the intra prediction mode, and an IPM intra candidate mode list IPMCandList with a length of 3 needs to be adaptively constructed. Specifically, the sources of the options in the list include the angle mode parallel to the dividing line (as shown in Figure 11a), the angle mode perpendicular to the dividing line (as shown in Figure 11b), the planar intra prediction mode (as shown in Figure 11c), and can also be derived from DIMD / TIMD and / or the IPM information of adjacent blocks. These Intra modes from different sources are filled into the IPM candidates after duplicate checking and deduplication.

[0350] If GPMIntraFlag=0, the prediction value of the current partition comes from the inter-frame prediction pixel. When using the inter-frame prediction mode partition in the conventional GPM mode, the motion vector information mvA or mvB can be obtained from the already constructed GPM unidirectional candidate list, as shown in Figure 12a. When using the inter-frame prediction mode partition in the GPM_MMVD mode, the motion vector information mvA or mvB is obtained by adding an offset to the already constructed GPM candidate list option, as shown in Figure 12b. The process of obtaining the partition motion vector under GPM and GPM_MMVD has been introduced in 2.1.1 and 2.1.2 and will not be repeated here. The motion vector mvA or mvB is used for unidirectional motion compensation to obtain the prediction value of the partition using the inter-frame prediction mode.

[0351] When a partition uses intra prediction mode for prediction, it is necessary to obtain the intra prediction mode IntraMode from the adaptively derived intra prediction mode IPM list. Specifically, let intra_gpm_idx[xCb][yCb] represent the index of the intra prediction mode selected by the partition using the GPM_Intra mode in the IPM list IPMCandList. k is the index of the intra prediction mode used by the partition in GPM_Intra mode in the IPM list. This index can be used to obtain the intra prediction mode IntraMode used by the partition in GPM_Intra mode.

[0352]

[0353] Using the selected intra prediction mode IntraMode, the predicted pixel values ​​of the partition using intra mode are obtained. In this way, the two GPM partitions using intra and inter modes respectively obtain the corresponding intra prediction values ​​and inter prediction values ​​for weighted prediction of luma and chroma samples.

[0354] 2.2) Obtaining GPM angle and step length

[0355] In H.266 / VVC, when the current prediction block is in GPM mode, the corresponding angle angleIdx and step length distanceIdx are obtained by looking up the table according to the partition mode index merge_gpm_partition_idx selected by the current block. The mapping table of the partition mode is shown in Table 6:

[0356] Table 6 Mapping table of angle and step size based on wedge_partition_idx

[0357] merge_gpm_partition_idx0123456789101112131415angleIdx0022223333444455distanceIdx1301230123012301merge_gpm_partitio n_idx16171819202122232425262728293031angleIdx5588111111111212121213131313distanceIdx2313012301230123merge_gpm_parti tion_idx32333435363738394041424344454647angleIdx14141414161618181819191920202021distanceIdx0123131231231231merge_g pm_partition_idx48495051525354555657585960616263angleIdx21212424272727282828292929303030distanceIdx2313123123123123

[0358] In ECM5.0, a template matching-based GPM partitioning rearrangement mode is introduced. In this mode, the GPM partitioning mode is rearranged based on the TM, so that the Idx transmitted in the final bitstream becomes the index value of the selected partitioning mode in the template matching cost list. The specific operation is as follows:

[0359] For the current block, given its motion information, first, for each possible partitioning mode, extend its segmentation line to the surrounding template composed of reconstructed pixels, and calculate the template cost of each of the 64 partitions;

[0360] Then, these 64 partitioning modes are arranged from large to small according to the template cost, and the first 32 are used as optional modes.

[0361] The incoming code stream is divided into one of 32 modes and the mode index is encoded with a Golomb-Rice code.

[0362] Note that when calculating the template cost, the edge hybrid weighted prediction introduced in the next section is not used. Instead, the prediction values ​​corresponding to the two partitions are directly weighted with a weight of 1 or 0.

[0363] 2.3) GPM Hybrid Weighted Prediction

[0364] During the GPM hybrid weighted prediction calculation process, areas farther from the dividing line use the prediction values ​​corresponding to both partitions. Areas near the dividing line use a weighted hybrid prediction of the two partitions' prediction values, weighted according to their distance from the dividing line. In other words, the weight of each pixel in the current block is calculated based on its distance from the dividing line.

[0365] A specific implementation method is currently used in VVC and ECM:

[0366] Let nCbW and nCbH represent the width and height of the current block. When cIdx = 0, it indicates the luma component; otherwise, it indicates the chroma component. SubWidthC and SubHeightC represent the downsampling rate. For a 4:2:0 format, both SubWidthC and SubHeightC are 2. nW and nH are used for the following split line displacement directions.

[0367]

[0368] Because the distance from the point (x1, y1) to the line cosαx-sinαy=0 is d=cosαx1-sinαy1.

[0369] The index number displacementX of α in cos(α) corresponding to the angle angleIdx obtained for the current block, and the index number displacementY of (α+π / 2) corresponding to -sin(α)=cos(α+π / 2) are obtained.

[0370] displacementX=angleIdx (36)

[0371] displacementY=(angleIdx+8)%32 (37)

[0372] The transmission of the relevant information of the first partition (part0) and the second partition (part1) in the code stream is in a certain order. Therefore, the order of the two partitions must follow certain principles. The partFlip is calculated by the following formula:

[0373] partFlip=(angleIdx>=13&&angleIdx<=27)? 0:1 (38)

[0374] If partFlip is 0, it means that the side of the point with a negative distance from the dividing line to weightIdx is partition A, and the side opposite to the dividing line is partition B. When the value is 1, the opposite is true. The side with a positive distance from weightIdx is partition A, and the negative side corresponds to partition B.

[0375] shiftHor=(angleIdx%16==8||(angleIdx%16!=0&&nH>=nW))? 0:1 (39)

[0376] The purpose of shiftHor is to determine the displacement direction of different dividing lines at the same angle. When shiftHor is 0, the dividing line will be offset on the Y axis; when shiftHor is 1, the dividing line will be offset on the X axis.

[0377] According to the size and partition information of the current block, the offset values ​​offsetX and offsetY of the current block are calculated as follows:

[0378] When shiftHor=0:

[0379]

[0380] When shiftHor=1:

[0381]

[0382] The weight index weightIdx at the current pixel is calculated by the position of the pixel, and then the weight value at the current pixel is obtained.

[0383]

[0384] weightIdxL=partFlip? 32+weightIdx:32-weightIdx (43)

[0385] wValue=Clip3(0,8,(weightIdxL+4)>>3) (44)

[0386] Where disLut[] is shown in Table 7.

[0387] xL, yL can be calculated by the following formula.

[0388]

[0389] Table 7 Geometric partition distance lookup table

[0390] idx02345681011121314disLut[idx]8884420-2-4-4-8-8idx161819202122242627282930disLut[idx]-8-8-8-4-4-2024488

[0391] So far, the weight value wValue at each pixel point of the current block is obtained, where weightTransitionWidthIdx=2, the transition width is 4, wMax=8, the weight range of wValue is {0,1,2,3,4,5,6,7,8}, and the weight value around the dividing line is between 0 and 8.

[0392] The unidirectional prediction values ​​of the two partitions part0 and part1 are weighted pixel by pixel to obtain the final GPM prediction block. The specific weighted calculation is shown in the following formula:

[0393]

[0394] The offset1 and shift1 are calculated as follows. The offset1 is used for rounding, and the shift1 is used to restore the weighted average prediction value to the same bit depth as the input video, as shown in the following formula:

[0395]

[0396] 2.4) Storage of motion information

[0397] 2.4.1) Storage of GPM mode motion information

[0398] Motion information is stored in 4x4 units. The storage process of GPM motion information is implemented based on the motion mask matrix of the brightness component of the current block. If the prediction value comes entirely from part0, the motion vector of part0 is stored. If it comes entirely from part1, the motion vector of part1 is recorded; otherwise, the motion vectors of both partitions are recorded at the same time.

[0399] Let cbWidth and cbHeight be the width and height of the luma component of the current block.

[0400] displacementX=angleIdx (48)

[0401] displacementY=(angleIdx+8)%32 (49)

[0402] isFlip=(angleIdx>=13&&angleIdx<=27)? 1:0 (50)

[0403]

[0404] When shiftHor=0:

[0405]

[0406] When shiftHor=1:

[0407]

[0408] Let the index of the 4x4 sub-block be (xSbIdx, ySbIdx), xSbIdx = 0...numSbX-1,

[0409] ySbIdx=0...numSbY-1, where numSbX and numSbY represent the number of 4×4 blocks in the horizontal and vertical directions of the current block, respectively, numSbX=cbWidth>>2, and numSbY=cbHeight>>2.

[0410] The motionIdx of each position is as follows:

[0411]

[0412] sType is used to store the motion information of which partition. If sType = 0, the motion information of part0 is stored; if sType = 1, the motion information of part1 is stored; if sType = 2, the combined motion information of part0 and part1 is stored.

[0413] sType=Abs(motionIdx)<32?2:(motionIdx<=0?(1-isFlip):isFlip) (55)

[0414] When sType=0:

[0415]

[0416] When sType = 1:

[0417]

[0418] When sType = 2:

[0419]

[0420] Where mvA, mvB represent the motion vectors of the two partitions, refIdxA, refIdxB represent the reference indexes of the two partitions, and predListFlagA, predListFlagB represent the prediction list flags of the two partitions. The final motion information of the current block is stored as shown in the following formula:

[0421]

[0422] Wherein x=xCb...xCb+3, y=yCb...yCb+3, xCb, yCb represent the upper left corner position of the luminance component of the current block.

[0423] in:

[0424] sType=(motionIdx<=0?(1-isFlip):isFlip) (60)

[0425] 2.4.2) Storage of GPM_MMVD mode motion information

[0426] In GPM_MMVD mode, motion information is also stored in 4x4 units.

[0427] Specifically, in GPM_MMVD mode, the GPM Merge candidate list construction process is first used to obtain a candidate list for the current block as the initial MV candidate; starting from the position pointed to by the initial candidate MV in the reference image (forward or backward), nine step sizes (1 / 4-pixel, 1 / 2-pixel, 1-pixel, 2-pixel, 3-pixel, 4-pixel, 6-pixel, 8-pixel, 16-pixel) are searched in eight candidate directions (four horizontal / vertical directions and four diagonal directions) (a total of 72 MMVD search modes) to obtain the motion vector offset mvOffset. Using the GPM_MMVD mode index mmvdIdx used by the current partition, the candidate distance index is fPosStep and the candidate direction index fPosPosition, the motion vector offset deltaMv can be obtained:

[0428]

[0429] In different candidate directions, deltaMv is shown in Table 8. Note that when pic_fpel_mmvd_enabled_flag is equal to 0, the MVD step size here will be shifted left by two bits, that is, it will be amplified by 4 times.

[0430] Table 8 Motion vector offsets in different candidate directions

[0431] fPosPositiondeltaMv0Mv(refMvdCands[fPosStep],0)1Mv(-refMvdCands[fPosStep],0)2Mv(0,refMvdCands[fPosStep])3Mv(0,-refMvdCands[fPosStep])4Mv(refMvdCands[fPosStep],refMv dCands[fPosStep])5Mv(refMvdCands[fPosStep],-refMvdCands[fPosStep])6Mv(-refMvdCands[fPosStep],refMvdCands[fPosStep])7Mv(-refMvdCands[fPosStep],-refMvdCands[fPosStep])

[0432] geoMMVDFlagA and geoMMVDFlagB represent the GPM-MMVD mode flags of the two partitions, and predListFlagA and predListFlagB represent the prediction list flags of the two partitions.

[0433] When geoMMVDFlagA=1, the first partition uses GPM_MMVD mode.

[0434] predFlagL0=1:

[0435]

[0436] predFlagL1=1:

[0437]

[0438] When geoMMVDFlagB=1, the second partition uses GPM_MMVD mode.

[0439] predFlagL0=1:

[0440]

[0441] predFlagL1=1:

[0442]

[0443]

[0444] 2.4.3) Storage of GPM_TM mode motion information

[0445] When tmMergeFlag[x0][y0] is 1, GPM_TM mode is used for inter-frame prediction. In this case, both partitions use template matching for unidirectional prediction. Specifically, the two partitions use geoTmMrgCtx0 and geoTmMrgCtx1 to obtain the two-partition unidirectional candidate mergeCtx0 and mergeCtx1 obtained by template matching cost filtering. The specific storage process of motion vectors is the same as that of conventional GPM mode.

[0446] 2.4.4) GPM with storage of intra and inter mode motion information

[0447] When a partition is predicted using the intra mode, in addition to storing the motion information of the partition (represented by a zero-valued MV), it is also necessary to store the intra prediction mode information of the partition, ie, the IPM candidate.

[0448] When the partition uses inter-frame prediction, the conventional GPM mode or GPM_MMVD technology can be selected. The storage of the current block motion information in these two modes has been described in detail in 2.4.1 and 2.4.2 and will not be repeated here.

[0449] The partition information predicted using intra mode is stored in 4x4 units.

[0450] Let cbWidth and cbHeight be the width and height of the luma component of the current block.

[0451] displacementX=angleIdx (67)

[0452] displacementY=(angleIdx+8)%32 (68)

[0453] isFlip=(angleIdx>=13&&angleIdx<=27)? 1:0 (69)

[0454]

[0455] When shiftHor=0:

[0456]

[0457] When shiftHor=1:

[0458]

[0459] Let the index of the 4x4 sub-block be (xSbIdx, ySbIdx), xSbIdx = 0...numSbX-1, ySbIdx = 0...numSbY-1. Where numSbX and numSbY represent the number of 4x4 blocks in the horizontal and vertical directions of the current block, respectively, numSbX = cbWidth>>2, numSbY = cbHeight>>2.

[0460] The motionIdx of each position is as follows:

[0461]

[0462] tmpMask is used to indicate which partition's motion information is stored. If tmpMask = 0, the information of part0 is stored; if tmpMask = 1, the information of part1 is stored.

[0463] tmpMask=motionIdx<=0? (1-isFlip):isFlip (74)

[0464] When (tmpMask==0&&isIntra0=1):

[0465]

[0466] At this time, in addition to storing the motion vector information, the intra prediction mode IPM information of the current block also needs to be stored. If the IPM information of the partition is available, it is stored directly. If the IPM information of the current partition is not available, the IPM information of the corresponding position of the reference block needs to be found based on the position index of the current sub-block and the motion vector information, and stored as the IPM information of the corresponding position of the current sub-block.

[0467] When (tmpMask==0&&isIntra1=1):

[0468]

[0469] The IPM information of the current block is stored as follows:

[0470] When geoIPM[0]>=0, Ipm=geoIPM[0], otherwise, the IPM information of the current partition is unavailable.

[0471] interDir!=3:

[0472]

[0473] interDir=3:

[0474]

[0475] Where xCb and yCb represent the top-left corner of the luminance component of the current block. (xSbIdx and ySbIdx) represent the indices of each 4×4 sub-block. cMv0 and cMv1 represent the forward and backward motion vectors for the current block, respectively. PosY0 and PosY1 represent the forward and backward reference pixel positions of the current pixel. ipm0 and ipm1 represent the IPM information obtained from the two prediction directions.

[0476] Use Table 9 to select the final IPM information of the current block from ipm0 and ipm1 for storage.

[0477] Table 9 IPM storage

[0478] conditionIPM! mi0.isInter&&mi1.isInteripm0! mi1.isInter&&mi0.isInteripm1ipm0>DC_IDX&&ipm0ipm0<=DC_IDX&&ipm1pocDiff0 <pocDiff1ipm0pocDiff1 <pocdiff0ipm1prefpic0->m_prevQP[0]>pRefPiipm1elseipm0

[0479] To implement the encoding method of the embodiment of the present application, based on the same inventive concept, the embodiment of the present application further provides an encoding device, as shown in FIG13 , the encoding device 130 includes:

[0480] An acquiring unit 1301 is configured to acquire geometric partitioning mode prediction parameters of a current block;

[0481] A determining unit 1302 is configured to determine a plurality of candidate transition width parameters of a weight matrix of the current block according to the prediction parameter;

[0482] The first processing unit 1303 is configured to determine template matching cost parameters of the multiple candidate transition width parameters based on template matching; sort the multiple candidate transition width parameters according to the template matching cost parameters to obtain index parameters of the multiple candidate transition width parameters;

[0483] A second processing unit 1304 is configured to determine a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0484] The first processing unit 1303 is further configured to determine an index parameter of the first transition width parameter from index parameters of the plurality of candidate transition width parameters;

[0485] The encoding unit 1305 is configured to encode the index parameter of the first transition width parameter to obtain a code stream.

[0486] In some embodiments, the first processing unit 1303 is used to obtain the actual template of the current block; obtain the reference template of the first partition of the current block, and the reference template of the second partition of the current block; obtain the weight value of the reference template pixel point according to the candidate transition width parameter; weight the reference template of the first partition and the reference template of the second partition pixel by pixel according to the weight value of the reference template pixel point to obtain the reference template of the current block; perform template matching on the actual template of the current block and the reference template of the current block to obtain the template matching cost parameter.

[0487] In some embodiments, the first processing unit 1303 is configured to obtain reconstruction information of a related area of ​​the current block as an actual template of the current block.

[0488] In some embodiments, the first processing unit 1303 is configured to, when the first partition is non-intra prediction, obtain first motion information of the first partition; determine a first reference block of the first partition based on the first motion information; obtain reconstruction information of a related area of ​​the first reference block as a reference template for the first partition; and, when the first partition is intra prediction, obtain reconstruction information of a related area of ​​the current block as a reference template for the first partition;

[0489] In some embodiments, the first processing unit 1303 is used to obtain second motion information of the second partition when the second partition is non-intra-frame prediction; determine a second reference block of the second partition based on the second motion information; obtain reconstruction information of a related area of ​​the second reference block as a reference template for the second partition; and obtain reconstruction information of a related area of ​​the current block as a reference template for the second partition when the second partition is intra-frame prediction.

[0490] In some embodiments, the related area includes at least one of the following: an upper adjacent area, a left adjacent area, an upper left adjacent area, a lower left adjacent area, and an upper right adjacent area.

[0491] In some embodiments, the template matching cost parameter includes one of the following: sum of absolute errors, sum of squared errors, mean absolute deviation error, mean sum of squared errors, and mean squared error.

[0492] In some embodiments, the prediction parameters include the geometric division mode parameters of the current block; the first processing unit 1303 is used to determine the distance parameter from the reference template pixel point to the extension line of the current block dividing line based on the geometric division mode parameters; and determine the weight value of the reference template pixel point based on the distance parameter and the candidate transition width parameter.

[0493] In some embodiments, the second processing unit 1304 is used to obtain the weight value of the pixel point of the current block according to the candidate transition width parameter; weight the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel point of the current block to obtain the prediction value of the current block; determine the error parameter between the original value of the current block and the prediction value of the current block based on a preset matching criterion; sort the multiple candidate transition width parameters according to the error parameter, and select the candidate transition width parameter corresponding to the minimum error parameter as the first transition width parameter.

[0494] In some embodiments, the prediction parameters include the geometric division mode parameters of the current block; the second processing unit 1304 is used to determine the distance parameter from the current block pixel point to the current block dividing line based on the geometric division mode parameters; and determine the weight value of the current block pixel point based on the distance parameter and the candidate transition width parameter.

[0495] In some embodiments, the second processing unit 1304 is used to add the distance parameter to half the transition width to obtain the translated distance parameter when the candidate transition width parameter represents a transition width that is not a zero pixel width; divide the translated distance parameter by the ratio of the transition width and the maximum weight value to obtain a first intermediate weight value; when the first intermediate weight value is less than or equal to the minimum weight value, use the minimum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than or equal to the maximum weight value, use the maximum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, use the intermediate weight value as the weight value of the current block pixel point.

[0496] In some embodiments, the second processing unit 1304 is used to divide the distance parameter by the ratio of the transition width and the maximum weight value to obtain a scaled distance parameter when the candidate transition width parameter represents a transition width that is not a zero pixel width; add the scaled distance parameter to half of the maximum weight value to obtain a second intermediate weight value; when the second intermediate weight value is less than or equal to the minimum weight value, use the minimum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, use the maximum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, use the intermediate weight value as the weight value of the second pixel point.

[0497] In some embodiments, the second processing unit 1304 is also used to use the maximum weight value as the weight value of the current block pixel point when the candidate transition width parameter represents a transition width of 0 pixel width and the distance parameter is greater than 0; and use the minimum weight value as the weight value of the current block pixel point when the distance parameter is less than or equal to 0.

[0498] In some embodiments, the transition width is a number of pixels, and the candidate transition width parameter is a base-2 logarithmic value of the transition width.

[0499] In some embodiments, the error parameter comprises one of the following: sum of absolute errors, sum of squared errors, mean absolute bias error, mean sum of squared errors, and mean squared error.

[0500] In some embodiments, the second processing unit 1304 is used to: when the weight value is the minimum weight value, the predicted value of the current block is equal to the first predicted value; when the weight value is the maximum weight value, the predicted value of the current block is equal to the second predicted value; when the weight value is greater than the minimum weight value and less than the maximum weight value, the weight value is used as the weight value of the first predicted value, and the difference between the maximum weight value and the weight value is used as the weight value of the second predicted value for weighted operation to obtain the predicted value of the current block.

[0501] In some embodiments, the determining unit 1302 is further configured to determine the maximum weight value according to the candidate transition width parameter.

[0502] In some embodiments, the determining unit 1302 is further configured to determine the maximum weight value corresponding to the candidate transition width parameter according to a preset mapping relationship between the transition width parameter and the maximum weight value.

[0503] In some embodiments, the prediction parameters comprise a first syntax element for indicating the plurality of candidate transition width parameters.

[0504] In some embodiments, the first syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit, or a current block data unit.

[0505] In some embodiments, the prediction parameters include at least the size of the current block, the resolution of the current block, the quantization parameter of the current block, and a motion vector difference between two partitions of the current block.

[0506] In some embodiments, the determining unit 1302 is further configured to determine, according to the second syntax element, whether to determine the first transition width parameter based on template matching.

[0507] In some embodiments, the second syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit.

[0508] In some embodiments, the index parameter of the first transition width parameter includes a first index parameter of a transition width group to which the first transition width parameter belongs, and a second index parameter of the first transition width parameter within the transition width group to which the first transition width parameter belongs.

[0509] In some embodiments, the index parameter of the first transition width parameter is used to index some candidate transition width parameters that are located in the first N positions in the arrangement order of the template matching cost parameters, where N is a positive integer.

[0510] To implement the encoding method of the embodiment of the present application, based on the same inventive concept, the embodiment of the present application also provides another encoding device, as shown in FIG14 , the encoding device 140 includes:

[0511] An acquiring unit 1401 is configured to acquire geometric partitioning mode prediction parameters of a current block;

[0512] A determining unit 1402 is configured to determine a plurality of candidate transition width parameters of a weight matrix of the current block according to the prediction parameter;

[0513] The first processing unit 1403 is configured to determine, based on template matching, template matching cost parameters of the multiple candidate transition width parameters; sort the multiple candidate transition width parameters according to the template matching cost parameters, and select the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter;

[0514] The prediction unit 1404 is used to obtain the weight value of the pixel point of the current block according to the first transition width parameter; and weight the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel point of the current block to obtain the prediction value of the current block.

[0515] To implement the decoding method of the embodiment of the present application, based on the same inventive concept, the embodiment of the present application further provides a decoding device, as shown in FIG15 , the decoding device 150 includes:

[0516] An acquiring unit 1501 is configured to acquire geometric partitioning mode prediction parameters of a current block;

[0517] A determining unit 1502 is configured to determine a plurality of candidate transition width parameters of a weight matrix of the current block according to the prediction parameter;

[0518] A first processing unit 1503 is configured to determine, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters;

[0519] The prediction unit 1504 is used to obtain the weight value of the pixel point of the current block according to the first transition width parameter; and weight the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel point of the current block to obtain the prediction value of the current block.

[0520] In some embodiments, the decoding device 150 further includes: a decoding unit (not shown in FIG15 ), configured to decode the code stream and determine an index parameter of the first transition width parameter;

[0521] The first processing unit 1503 is used to determine the template matching cost parameters of the multiple candidate transition width parameters based on template matching; sort the multiple candidate transition width parameters according to the template matching cost parameters to obtain the index parameters of the multiple candidate transition width parameters; and determine the first transition width parameter from the multiple candidate transition width parameters according to the index parameter of the first transition width parameter.

[0522] In some embodiments, a decoding unit is used to decode a code stream, determine a first index parameter of a transition width group to which the first transition width parameter belongs, and a second index parameter of the first transition width parameter within the transition width group to which the first transition width parameter belongs; and obtain an index parameter of the first transition width parameter based on the first index parameter and the second index parameter.

[0523] In some embodiments, the index parameter of the first transition width parameter is used to index some candidate transition width parameters that are located in the first N positions in the arrangement order of the template matching cost parameters, where N is a positive integer.

[0524] In some embodiments, the first processing unit 1503 is used to determine the template matching cost parameters of the multiple candidate transition width parameters based on template matching; sort the multiple candidate transition width parameters according to the template matching cost parameters, and select the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter.

[0525] In some embodiments, the first processing unit 1503 is used to obtain the actual template of the current block; obtain the reference template of the first partition of the current block, and the reference template of the second partition of the current block; obtain the weight value of the reference template pixel point according to the candidate transition width parameter; weight the reference template of the first partition and the reference template of the second partition pixel by pixel according to the weight value of the reference template pixel point to obtain the reference template of the current block; perform template matching on the actual template of the current block and the reference template of the current block to obtain the template matching cost parameter.

[0526] In some embodiments, the first processing unit 1503 is configured to obtain reconstruction information of a related area of ​​the current block as an actual template of the current block.

[0527] In some embodiments, the first processing unit 1503 is configured to, when the first partition is non-intra prediction, obtain first motion information of the first partition; determine a first reference block of the first partition based on the first motion information; obtain reconstruction information of a related area of ​​the first reference block as a reference template for the first partition; and, when the first partition is intra prediction, obtain reconstruction information of a related area of ​​the current block as a reference template for the first partition;

[0528] In some embodiments, the first processing unit 1503 is used to obtain second motion information of the second partition when the second partition is non-intra-frame prediction; determine a second reference block of the second partition based on the second motion information; obtain reconstruction information of a related area of ​​the second reference block as a reference template of the second partition; and obtain reconstruction information of a related area of ​​the current block as a reference template of the second partition when the second partition is intra-frame prediction.

[0529] In some embodiments, the related area includes at least one of the following: an upper adjacent area, a left adjacent area, an upper left adjacent area, a lower left adjacent area, and an upper right adjacent area.

[0530] In some embodiments, the template matching cost parameter includes one of the following: sum of absolute errors, sum of squared errors, mean absolute deviation error, mean sum of squared errors, and mean squared error.

[0531] In some embodiments, the prediction parameters include geometric partitioning mode parameters of the current block;

[0532] The first processing unit 1503 is used to determine the distance parameter from the reference template pixel point to the extension line of the current block segmentation line according to the geometric partitioning mode parameter; and determine the weight value of the reference template pixel point according to the distance parameter and the candidate transition width parameter.

[0533] In some embodiments, the prediction parameters include the geometric division mode parameters of the current block; the prediction unit 1504 is used to determine the distance parameter from the current block pixel point to the dividing line based on the geometric division mode parameters; and determine the weight value of the current block pixel point based on the distance parameter and the first transition width parameter.

[0534] In some embodiments, the prediction unit 1504 is used to add the distance parameter to half the transition width to obtain the distance parameter after translation when the first transition width parameter represents a transition width that is not a zero pixel width; divide the distance parameter after translation by the ratio of the transition width and the maximum weight value to obtain a first intermediate weight value; when the first intermediate weight value is less than or equal to the minimum weight value, use the minimum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than or equal to the maximum weight value, use the maximum weight value as the weight value of the current block pixel point; when the first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, use the intermediate weight value as the weight value of the current block pixel point.

[0535] In some embodiments, the prediction unit 1504 is used to divide the distance parameter by the ratio of the transition width and the maximum weight value to obtain a scaled distance parameter when the first transition width parameter represents a transition width that is not a zero pixel width; add the scaled distance parameter to half the maximum weight value to obtain a second intermediate weight value; when the second intermediate weight value is less than or equal to the minimum weight value, use the minimum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than or equal to the maximum weight value, use the maximum weight value as the weight value of the current block pixel point; when the second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, use the intermediate weight value as the weight value of the second pixel point.

[0536] In some embodiments, the prediction unit 1504 is also used to: when the first transition width parameter represents a transition width of 0 pixel width, and when the distance parameter is greater than 0, use the maximum weight value as the weight value of the current block pixel point; when the distance parameter is less than or equal to 0, use the minimum weight value as the weight value of the current block pixel point.

[0537] In some embodiments, the transition width is a number of pixels, and the first transition width parameter is a base-2 logarithmic value of the transition width.

[0538] In some embodiments, the prediction unit 1504 is configured to weight the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel of the current block to obtain the prediction value of the current block, including:

[0539] When the weight value is the minimum weight value, the prediction value of the current block is equal to the first prediction value;

[0540] When the weight value is the maximum weight value, the prediction value of the current block is equal to the second prediction value;

[0541] The weight value is greater than the minimum weight value and less than the maximum weight value. The weight value is used as the weight value of the first prediction value, and the difference between the maximum weight value and the weight value is used as the weight value of the second prediction value to perform weighted operation to obtain the prediction value of the current block.

[0542] In some embodiments, the prediction unit 1504 is configured to determine the maximum weight value according to the first transition width parameter.

[0543] In some embodiments, the prediction unit 1504 is configured to determine the maximum weight value corresponding to the first transition width parameter according to a preset mapping relationship between the transition width parameter and the maximum weight value.

[0544] It should be noted that the first processing unit 1503 can refer to the process of determining the weight value of the current block pixel point and the weighted operation process of the prediction unit 1504 based on the process of determining the weight value of the reference template pixel point and the weighted operation process, and only needs to replace the first transition width parameter with the candidate transition width parameter.

[0545] In some embodiments, the prediction parameters include a first syntax element for indicating the plurality of candidate transition width parameters. In some embodiments, the first syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit, or a current block data unit.

[0546] In some embodiments, the prediction parameters include the size of the current block, the resolution of the current block, the quantization parameter of the current block, and a motion vector difference between two partitions of the current block.

[0547] In some embodiments, the determining unit 1502 is further configured to determine, based on a second syntax element, whether to determine the first transition width parameter based on template matching. In some embodiments, the second syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit, or a current block data unit.

[0548] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here.

[0549] The above describes the apparatus and system of the embodiment of the present application from the perspective of functional units in conjunction with the accompanying drawings. It should be understood that the functional unit can be implemented in the form of hardware, can be implemented by instructions in the form of software, or can be implemented by a combination of hardware and software units. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software units in the decoding processor. Optionally, the software unit can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps in the above method embodiment in conjunction with its hardware.

[0550] In practical applications, an embodiment of the present application further provides an encoder. FIG16 is a schematic block diagram of an encoder provided in an embodiment of the present application. As shown in FIG16 , the encoder 1610 includes:

[0551] The second memory 1620 and the second processor 1630; the second memory 1620 stores a computer program that can be run on the second processor 1630, and the second processor 1630 executes the program when the encoding method on the encoder side is executed.

[0552] In practical applications, an embodiment of the present application further provides a decoder. FIG17 is a schematic block diagram of a decoder provided in an embodiment of the present application. As shown in FIG17 , a decoder 1710 includes:

[0553] The first memory 1720 and the first processor 1730; the first memory 1720 stores a computer program that can be run on the first processor 1730, and the first processor 1730 executes the decoding method on the decoder side when executing the program.

[0554] In some embodiments of the present application, the processor may include but is not limited to: a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0555] In some embodiments of the present application, the memory includes, but is not limited to, volatile memory and / or non-volatile memory. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).

[0556] In addition, the functional modules in this embodiment may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional modules.

[0557] In yet another embodiment of the present application, see Figure 18 , which shows a schematic diagram of the structure of a coding and decoding system provided in an embodiment of the present application. As shown in Figure 18 , the coding and decoding system 180 may include an encoder 1801 and a decoder 1802. The encoder 1801 may be a device integrated with the encoding device described in the previous embodiment; the decoder 1802 may be a device integrated with the decoding device described in the previous embodiment.

[0558] In an embodiment of the present application, in the encoding and decoding system 180, both the encoder 1801 and the decoder 1802 can use the color component information of adjacent reference pixels and the pixels to be predicted to calculate the corresponding weighting coefficients of the pixels to be predicted; and different reference pixels can have different weighting coefficients. Applying this weighting coefficient to the chrominance prediction of the pixels to be predicted in the current block can not only improve the accuracy of the chrominance prediction and save bit rate, but also improve the encoding and decoding performance.

[0559] The embodiment of the present application also provides a chip for implementing the above-mentioned encoding and decoding method. Specifically, the chip includes: a processor for calling and running a computer program from a memory, so that an electronic device equipped with the chip performs the above-mentioned encoding and decoding method. The embodiment of the present application also provides a computer storage medium, which stores a computer program, and when the computer program is executed by a second processor, it implements the encoding method of the encoder; or, when the computer program is executed by a first processor, it implements the decoding method of the decoder. In other words, the embodiment of the present application also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer executes the method of the above-mentioned method embodiment. The present application also provides a code stream, which is generated according to the above-mentioned encoding method. Optionally, the code stream includes an index parameter of the first transition width parameter actually used by the weight matrix of the current block.

[0560] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid state drive (SSD)).

[0561] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0562] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the unit is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0563] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment. For example, the functional units in the various embodiments of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0564] The above content is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims. Industrial Applicability

[0565] The present application provides a coding and decoding method, apparatus, encoder, decoder, and storage medium, the method comprising: obtaining geometric partitioning pattern prediction parameters for a current block; determining multiple candidate transition width parameters based on the prediction parameters; determining a first transition width parameter actually used by a weight matrix for the current block based on template matching; obtaining weight values ​​for pixels of the current block based on the first transition width parameter; and weighting the first and second prediction values ​​of the current block pixel by pixel based on the weight values ​​to obtain a prediction value for the current block. Template matching is applied to sort the multiple candidate transition width parameters, and the optimal transition width parameter is selected for the current block from the sorted results, thereby determining the optimal weight matrix for the current block. This improves the prediction accuracy of GPM during weighted prediction compared to using a fixed transition width.

Claims

1. A decoding method, wherein: include: Get the geometric partitioning mode prediction parameters of the current block; Determining, based on the prediction parameters, a plurality of candidate transition width parameters of a weight matrix of the current block; Determining, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters; Obtaining a weight value of a pixel point of the current block according to the first transition width parameter; The first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

2. The method according to claim 1, wherein The method further comprises: Decoding the bitstream, and determining an index parameter of the first transition width parameter; The determining, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters includes: Determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching; sorting the plurality of candidate transition width parameters according to the template matching cost parameter to obtain index parameters of the plurality of candidate transition width parameters; The first transition width parameter is determined from the plurality of candidate transition width parameters according to an index parameter of the first transition width parameter.

3. The method according to claim 2, wherein: The decoding code stream and determining the index parameter of the first transition width parameter include: Decoding a code stream, determining a first index parameter of a transition width group to which the first transition width parameter belongs, and a second index parameter of the first transition width parameter within the transition width group to which the first transition width parameter belongs; An index parameter of the first transition width parameter is obtained according to the first index parameter and the second index parameter.

4. The method according to claim 2 or 3, wherein: The index parameter of the first transition width parameter is used to index some candidate transition width parameters that are located in the first N positions in the arrangement order of the template matching cost parameters, where N is a positive integer.

5. The method according to claim 1, wherein The determining, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters includes: Determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching; The multiple candidate transition width parameters are sorted according to the template matching cost parameter, and the candidate transition width parameter corresponding to the minimum template matching cost parameter is selected as the first transition width parameter.

6. The method according to claim 2 or 5, wherein The step of determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching includes: Get the actual template of the current block; Obtaining a reference template for a first partition of the current block and a reference template for a second partition of the current block; Obtaining weight values ​​of reference template pixels according to the candidate transition width parameters; Perform pixel-by-pixel weighting on the reference template of the first partition and the reference template of the second partition according to the weight values ​​of the pixels of the reference template to obtain the reference template of the current block; Template matching is performed on the actual template of the current block and the reference template of the current block to obtain the template matching cost parameter.

7. The method according to claim 6, wherein: The obtaining of the actual template of the current block includes: Reconstruction information of a related area of ​​the current block is obtained as an actual template of the current block.

8. The method according to claim 6, wherein: The obtaining of the reference template of the first partition of the current block includes: When the first partition is non-intra prediction, obtaining first motion information of the first partition; determining a first reference block of the first partition based on the first motion information; Obtaining reconstruction information of a related area of ​​the first reference block as a reference template for the first partition; When the first partition is intra-frame prediction, obtaining reconstruction information of a related area of ​​the current block as a reference template of the first partition; The obtaining of the reference template of the second partition of the current block includes: When the second partition is non-intra prediction, obtaining second motion information of the second partition; determining a second reference block of the second partition based on the second motion information; Acquire reconstruction information of a related area of ​​the second reference block as a reference template for the second partition; When the second partition is intra-frame prediction, reconstruction information of a related area of ​​the current block is obtained as a reference template of the second partition.

9. The method according to claim 7 or 8, wherein The related area includes at least one of the following: an upper adjacent area, a left adjacent area, an upper left adjacent area, a lower left adjacent area, and an upper right adjacent area.

10. The method according to any one of claims 2 to 6, wherein: The template matching cost parameter includes one of the following: the sum of absolute errors, the sum of squared errors, the mean absolute deviation error, the mean sum of squared errors, and the mean square error.

11. The method according to claim 6, wherein: The prediction parameters include geometric partitioning mode parameters of the current block; The step of obtaining the weight value of the reference template pixel point according to the candidate transition width parameter includes: Determining a distance parameter from the reference template pixel to an extension line of the current block segmentation line according to the geometric partitioning mode parameter; The weight value of the reference template pixel is determined according to the distance parameter and the candidate transition width parameter.

12. The method according to claim 1, wherein The prediction parameters include geometric partitioning mode parameters of the current block; The obtaining the weight value of the pixel point of the current block according to the first transition width parameter includes: Determining a distance parameter from a pixel point of the current block to a dividing line according to the geometric division mode parameter; Determine a weight value of the pixel point of the current block according to the distance parameter and the first transition width parameter.

13. The method according to claim 12, wherein: The determining, according to the distance parameter and the first transition width parameter, the weight value of the pixel point of the current block includes: When the first transition width parameter represents a transition width that is not 0 pixel width, the distance parameter is added to half the transition width to obtain a distance parameter after translation; Dividing the translated distance parameter by the ratio of the transition width to the maximum weight value to obtain a first intermediate weight value; When the first intermediate weight value is less than or equal to the minimum weight value, the minimum weight value is used as the weight value of the pixel point of the current block; When the first intermediate weight value is greater than or equal to the maximum weight value, the maximum weight value is used as the weight value of the pixel point of the current block; The first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, and the intermediate weight value is used as the weight value of the pixel point of the current block.

14. The method according to claim 12, wherein: The determining, according to the distance parameter and the first transition width parameter, the weight value of the pixel point of the current block includes: When the first transition width parameter represents that the transition width is a non-zero pixel width, the distance parameter is divided by the ratio of the transition width to the maximum weight value to obtain a scaled distance parameter; Adding the scaled distance parameter to half the maximum weight value to obtain a second intermediate weight value; When the second intermediate weight value is less than or equal to the minimum weight value, the minimum weight value is used as the weight value of the pixel point of the current block; When the second intermediate weight value is greater than or equal to the maximum weight value, the maximum weight value is used as the weight value of the pixel point of the current block; The second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, and the intermediate weight value is used as the weight value of the second pixel point.

15. The method according to claim 13 or 14, wherein: The determining the weight value of the pixel point of the current block according to the distance parameter and the first transition width parameter further includes: When the first transition width parameter represents a transition width of 0 pixel width and the distance parameter is greater than 0, the maximum weight value is used as the weight value of the pixel point of the current block; When the distance parameter is less than or equal to 0, the minimum weight value is used as the weight value of the pixel point of the current block.

16. The method according to any one of claims 13 to 15, wherein: The transition width is the number of pixels, and the first transition width parameter is the logarithmic value of the transition width with base 2.

17. The method according to claim 1, wherein The step of weighting the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel of the current block to obtain the prediction value of the current block includes: When the weight value is the minimum weight value, the prediction value of the current block is equal to the first prediction value; When the weight value is the maximum weight value, the prediction value of the current block is equal to the second prediction value; The weight value is greater than the minimum weight value and less than the maximum weight value. The weight value is used as the weight value of the first prediction value, and the difference between the maximum weight value and the weight value is used as the weight value of the second prediction value to perform weighted operation to obtain the prediction value of the current block.

18. The method according to any one of claims 13 to 17, wherein: The method further comprises: The maximum weight value is determined according to the first transition width parameter.

19. The method according to claim 18, wherein The determining the maximum weight value according to the first transition width parameter includes: According to a preset mapping relationship between the transition width parameter and the maximum weight value, the maximum weight value corresponding to the first transition width parameter is determined.

20. The method according to claim 1, wherein The prediction parameters include a first syntax element for indicating the plurality of candidate transition width parameters.

21. The method according to claim 20, wherein The first syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit.

22. The method according to claim 1, wherein The prediction parameters include the size of the current block, the resolution of the current block, the quantization parameter of the current block, and a motion vector difference between two partitions of the current block.

23. The method according to claim 1, wherein The method further comprises: It is determined according to the second syntax element whether to determine the first transition width parameter based on template matching.

24. The method according to claim 23, wherein The second syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit.

25. A coding method, wherein: include: Get the geometric partitioning mode prediction parameters of the current block; Determining, based on the prediction parameters, a plurality of candidate transition width parameters of a weight matrix of the current block; Determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching; sorting the plurality of candidate transition width parameters according to the template matching cost parameter to obtain index parameters of the plurality of candidate transition width parameters; Determine a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters; Determining an index parameter of the first transition width parameter from index parameters of the plurality of candidate transition width parameters; The index parameter of the first transition width parameter is encoded to obtain a code stream.

26. The method of claim 25, wherein: The step of determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching includes: Get the actual template of the current block; Obtaining a reference template for a first partition of the current block and a reference template for a second partition of the current block; Obtaining weight values ​​of reference template pixels according to the candidate transition width parameters; Perform pixel-by-pixel weighting on the reference template of the first partition and the reference template of the second partition according to the weight values ​​of the pixels of the reference template to obtain the reference template of the current block; Template matching is performed on the actual template of the current block and the reference template of the current block to obtain the template matching cost parameter.

27. The method according to claim 26, wherein The obtaining of the actual template of the current block includes: Reconstruction information of a related area of ​​the current block is obtained as an actual template of the current block.

28. The method according to claim 27, wherein The obtaining of a reference template for the first partition of the current block includes: When the first partition is non-intra prediction, obtaining first motion information of the first partition; determining a first reference block of the first partition based on the first motion information; Obtaining reconstruction information of a related area of ​​the first reference block as a reference template for the first partition; When the first partition is intra-frame prediction, obtaining reconstruction information of a related area of ​​the current block as a reference template of the first partition; The obtaining of the reference template of the second partition of the current block includes: When the second partition is non-intra prediction, obtaining second motion information of the second partition; determining a second reference block of the second partition based on the second motion information; Acquire reconstruction information of a related area of ​​the second reference block as a reference template for the second partition; When the second partition is intra-frame prediction, reconstruction information of a related area of ​​the current block is obtained as a reference template of the second partition.

29. The method according to claim 27 or 28, wherein The related area includes at least one of the following: an upper adjacent area, a left adjacent area, an upper left adjacent area, a lower left adjacent area, and an upper right adjacent area.

30. The method according to claim 25 or 26, wherein The template matching cost parameter includes one of the following: the sum of absolute errors, the sum of squared errors, the mean absolute deviation error, the mean sum of squared errors, and the mean square error.

31. The method of claim 26, wherein: The prediction parameters include geometric partitioning mode parameters of the current block; The step of obtaining the weight value of the reference template pixel point according to the candidate transition width parameter includes: Determining a distance parameter from the reference template pixel to an extension line of the current block segmentation line according to the geometric partitioning mode parameter; The weight value of the reference template pixel is determined according to the distance parameter and the candidate transition width parameter.

32. The method of claim 26, wherein: The determining, from the plurality of candidate transition width parameters, a first transition width parameter actually used by the weight matrix of the current block comprises: Obtaining a weight value of a pixel point of the current block according to the candidate transition width parameter; Weighting the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel of the current block to obtain the prediction value of the current block; Determining an error parameter between the original value of the current block and the predicted value of the current block based on a preset matching criterion; The multiple candidate transition width parameters are sorted according to the error parameter, and the candidate transition width parameter corresponding to the minimum error parameter is selected as the first transition width parameter.

33. The method according to claim 32, wherein The prediction parameters include geometric partitioning mode parameters of the current block; The obtaining the weight value of the pixel point of the current block according to the candidate transition width parameter includes: Determining a distance parameter from a pixel point of the current block to a dividing line of the current block according to the geometric partitioning mode parameter; Determine a weight value of the pixel point of the current block according to the distance parameter and the candidate transition width parameter.

34. The method according to claim 33, wherein The determining, according to the distance parameter and the candidate transition width parameter, the weight value of the pixel point of the current block includes: When the candidate transition width parameter represents a transition width that is not 0 pixel width, the distance parameter is added to half the transition width to obtain a distance parameter after translation; Dividing the translated distance parameter by the ratio of the transition width to the maximum weight value to obtain a first intermediate weight value; When the first intermediate weight value is less than or equal to the minimum weight value, the minimum weight value is used as the weight value of the pixel point of the current block; When the first intermediate weight value is greater than or equal to the maximum weight value, the maximum weight value is used as the weight value of the pixel point of the current block; The first intermediate weight value is greater than the minimum weight value and less than the maximum weight value, and the intermediate weight value is used as the weight value of the pixel point of the current block.

35. The method of claim 33, wherein: The determining, according to the distance parameter and the candidate transition width parameter, the weight value of the pixel point of the current block includes: When the candidate transition width parameter represents a transition width that is non-zero pixel width, the distance parameter is divided by the ratio of the transition width to the maximum weight value to obtain a scaled distance parameter; Adding the scaled distance parameter to half the maximum weight value to obtain a second intermediate weight value; When the second intermediate weight value is less than or equal to the minimum weight value, the minimum weight value is used as the weight value of the pixel point of the current block; When the second intermediate weight value is greater than or equal to the maximum weight value, the maximum weight value is used as the weight value of the pixel point of the current block; The second intermediate weight value is greater than the minimum weight value and less than the maximum weight value, and the intermediate weight value is used as the weight value of the second pixel point.

36. The method according to claim 34 or 35, wherein The step of determining the weight value of the pixel point of the current block according to the distance parameter and the candidate transition width parameter further includes: When the candidate transition width parameter represents a transition width of 0 pixel width and the distance parameter is greater than 0, the maximum weight value is used as the weight value of the pixel point of the current block; When the distance parameter is less than or equal to 0, the minimum weight value is used as the weight value of the pixel point of the current block.

37. The method according to any one of claims 34 to 36, wherein: The transition width is the number of pixels, and the candidate transition width parameter is the logarithmic value of the transition width with base 2 as the base.

38. The method of claim 32, wherein: The error parameter includes one of the following: absolute error sum, square error sum, mean absolute deviation error, mean square error sum, and mean square error.

39. The method according to claim 32, wherein: The step of weighting the first prediction value and the second prediction value of the current block pixel by pixel according to the weight value of the pixel of the current block to obtain the prediction value of the current block includes: When the weight value is the minimum weight value, the prediction value of the current block is equal to the first prediction value; When the weight value is the maximum weight value, the prediction value of the current block is equal to the second prediction value; The weight value is greater than the minimum weight value and less than the maximum weight value. The weight value is used as the weight value of the first prediction value, and the difference between the maximum weight value and the weight value is used as the weight value of the second prediction value to perform weighted operation to obtain the prediction value of the current block.

40. The method according to any one of claims 34 to 39, wherein: The method further comprises: The maximum weight value is determined according to the candidate transition width parameters.

41. The method according to claim 40, wherein The determining the maximum weight value according to the candidate transition width parameter includes: The maximum weight value corresponding to the candidate transition width parameter is determined according to a preset mapping relationship between the transition width parameter and the maximum weight value.

42. The method of claim 25, wherein: The index parameter of the first transition width parameter includes a first index parameter of a transition width group to which the first transition width parameter belongs, and a second index parameter of the first transition width parameter within the transition width group to which the first transition width parameter belongs.

43. The method according to claim 25 or 42, wherein The index parameter of the first transition width parameter is used to index some candidate transition width parameters that are located in the first N positions in the arrangement order of the template matching cost parameters, where N is a positive integer.

44. The method of claim 25, wherein The prediction parameters include a first syntax element for indicating the plurality of candidate transition width parameters.

45. The method of claim 25, wherein The first syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit.

46. ​​The method of claim 25, wherein The prediction parameters include at least the size of the current block, the resolution of the current block, the quantization parameter of the current block, and a motion vector difference between two partitions of the current block.

47. The method of claim 25, wherein: The method further comprises: It is determined according to the second syntax element whether to determine the first transition width parameter based on template matching.

48. The method of claim 47, wherein The second syntax element is located in a sequence parameter set, a picture parameter set, a picture header data unit, a slice header data unit or a current block data unit.

49. A coding method, wherein include: Get the geometric partitioning mode prediction parameters of the current block; Determining, based on the prediction parameters, a plurality of candidate transition width parameters of a weight matrix of the current block; Determining template matching cost parameters of the plurality of candidate transition width parameters based on template matching; sorting the plurality of candidate transition width parameters according to the template matching cost parameter, and selecting the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter; Obtaining a weight value of a pixel point of the current block according to the first transition width parameter; The first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

50. A decoding device, wherein: include: An acquisition unit, used to acquire the geometric partitioning mode prediction parameters of the current block; a determining unit, configured to determine a plurality of candidate transition width parameters of the weight matrix of the current block according to the prediction parameter; A first processing unit is configured to determine, based on template matching, a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters; A prediction unit, configured to obtain a weight value of a pixel point of the current block according to the first transition width parameter; The first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

51. An encoding device, wherein: include: An acquisition unit, used to acquire the geometric partitioning mode prediction parameters of the current block; a determining unit, configured to determine a plurality of candidate transition width parameters of the weight matrix of the current block according to the prediction parameter; A first processing unit is configured to determine, based on template matching, template matching cost parameters of the plurality of candidate transition width parameters; sort the plurality of candidate transition width parameters according to the template matching cost parameters to obtain index parameters of the plurality of candidate transition width parameters; a second processing unit, configured to determine a first transition width parameter actually used by the weight matrix of the current block from the multiple candidate transition width parameters; The first processing unit is further configured to determine an index parameter of the first transition width parameter from index parameters of the plurality of candidate transition width parameters; The encoding unit is configured to encode the index parameter of the first transition width parameter to obtain a code stream.

52. An encoding device, wherein: include: An acquisition unit, used to acquire the geometric partitioning mode prediction parameters of the current block; a determining unit, configured to determine a plurality of candidate transition width parameters of the weight matrix of the current block according to the prediction parameter; A first processing unit, configured to determine template matching cost parameters of the plurality of candidate transition width parameters based on template matching; sorting the plurality of candidate transition width parameters according to the template matching cost parameter, and selecting the candidate transition width parameter corresponding to the minimum template matching cost parameter as the first transition width parameter; A prediction unit, configured to obtain a weight value of a pixel point of the current block according to the first transition width parameter; The first prediction value and the second prediction value of the current block are weighted pixel by pixel according to the weight values ​​of the pixels of the current block to obtain the prediction value of the current block.

53. A decoder, wherein The decoder comprises: a first memory and a first processor; The first memory stores a computer program that can be run on the first processor, and when the first processor executes the program, the decoding method according to any one of claims 1 to 24 is implemented.

54. An encoder, wherein The encoder comprises: a second memory and a second processor; The second memory stores a computer program that can be run on the second processor, and when the second processor executes the program, the encoding method according to any one of claims 25 to 49 is implemented.

55. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed by a first processor, it implements the decoding method described in any one of claims 1 to 24; or, when the computer program is executed by a second processor, it implements the encoding method described in any one of claims 25 to 49.

56. A code stream, wherein The code stream includes an index parameter of a first transition width parameter actually used by a weight matrix of a current block.