Encoding method, decoding method, code stream, encoder, decoder, and storage medium
By using a weighted matrix prediction method to determine the template prediction value of the current block in video coding, the problem of inaccurate template error when combining SGPM and PDP prediction is solved, thus improving encoding and decoding efficiency and performance.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
- Filing Date
- 2024-12-12
- Publication Date
- 2026-06-18
AI Technical Summary
In video coding standards, when SGPM and PDP prediction are combined, template prediction is still implemented by the traditional process, resulting in inaccurate template errors and reduced coding efficiency.
When using the geometric partitioning mode for prediction in the current block, a prediction method based on the weight matrix is adopted to determine the template prediction value, thereby improving the prediction accuracy.
This improves the prediction accuracy and encoding/decoding efficiency of the current block, thereby enhancing encoding/decoding performance.
Smart Images

Figure CN2024138958_18062026_PF_FP_ABST
Abstract
Description
Encoding / decoding methods, bitstreams, encoders, decoders, and storage media Technical Field
[0001] This application relates to the field of video encoding and decoding technology, and in particular to an encoding and decoding method, a bitstream, an encoder, a decoder, and a storage medium. Background Technology
[0002] In video coding standards, matrix-based position-dependent intra-prediction (PDP) technology can replace the traditional intra-prediction process by using a weight matrix-based prediction method. The weight matrix is obtained through offline training and has higher accuracy than the traditional prediction process.
[0003] In related technologies, PDP technology can be used in intra-frame prediction modes such as Geometric Partitioning Mode (GPM) and Spatial Geometric Partitioning Mode (SGPM), replacing the corresponding prediction process with PDP prediction. However, when SGPM and PDP prediction are combined, due to incomplete considerations, such as template prediction still being implemented by the traditional prediction process, the template error may be inaccurate, thus reducing coding efficiency. Summary of the Invention
[0004] This application provides an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium, which can improve encoding / decoding efficiency.
[0005] The technical solution of this application embodiment can be implemented as follows:
[0006] In a first aspect, embodiments of this application provide a decoding method applied to a decoder, the method comprising:
[0007] Parse the first syntax element in the bitstream;
[0008] When the first syntax element indicates that the current block is predicted using a geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix;
[0009] Based on the prediction information, a prediction sample for the current block is determined.
[0010] Secondly, embodiments of this application provide an encoding method applied to an encoder, the method comprising:
[0011] When using the geometric partitioning mode for prediction of the current block, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix;
[0012] Based on the prediction information, a prediction sample for the current block is determined.
[0013] Thirdly, embodiments of this application provide an encoder, which includes a first determining unit and a first predicting unit, wherein:
[0014] The first determining unit is configured to determine the prediction information of the current block based on the template prediction value of the current block when the current block is predicted using a geometric partitioning mode; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0015] The first prediction unit is configured to predict the current block based on the prediction information and determine the prediction sample for the current block.
[0016] Fourthly, embodiments of this application provide an encoder, which includes a first memory and a first processor, wherein:
[0017] A first memory for storing computer programs that can run on a first processor;
[0018] A first processor is configured to execute the encoding method as described in the second aspect when running a computer program.
[0019] Fifthly, embodiments of this application provide a decoder, which includes a decoding unit, a second determining unit, and a second predicting unit, wherein:
[0020] The decoding unit is configured to parse the first syntax element in the bitstream;
[0021] The second determining unit is configured to determine the prediction information of the current block based on the template prediction value of the current block when the first syntax element indicates that the current block uses a geometric partitioning mode for prediction; wherein the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0022] The second prediction unit is configured to predict the current block based on the prediction information and determine the prediction sample for the current block.
[0023] Sixthly, embodiments of this application provide a decoder, which includes a second memory and a second processor, wherein:
[0024] The second memory is used to store computer programs that can run on the second processor;
[0025] The second processor is used to execute the decoding method as described in the first aspect when running a computer program.
[0026] In a seventh aspect, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the decoding method as described in the first aspect or the encoding method as described in the second aspect.
[0027] Eighthly, embodiments of this application provide a computer-readable storage medium having a bitstream stored thereon, the bitstream being generated by performing the steps of the encoding method as described in the second aspect.
[0028] In a ninth aspect, embodiments of this application provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the decoding method as described in the first aspect or the encoding method as described in the second aspect.
[0029] This application provides an encoding / decoding method, a bitstream, an encoder, a decoder, and a storage medium. Whether at the encoding or decoding end, when it is determined that the current block uses a geometric partitioning mode for prediction, the prediction information of the current block is determined based on the template prediction value of the current block. Specifically, the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on a weight matrix prediction method. The current block is then predicted based on the prediction information to determine the prediction sample of the current block. Thus, when the current block uses geometric partitioning modes such as GPM or SGPM, not only can a weight matrix-based prediction method be used during the prediction process, but also in determining the prediction information of the current block, the same weight matrix-based prediction method can be used to determine the template prediction value of the current block for steps such as calculating the template error and deriving weight information. This makes the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, increasing encoding / decoding efficiency, and ultimately improving encoding / decoding performance. Attached Figure Description
[0030] Figure 1 is a schematic diagram of the reference sample for the current block;
[0031] Figure 2 illustrates nine modes for intra-frame prediction in the current block;
[0032] Figure 3 shows a schematic diagram of the intra-frame prediction angle mode and the wide-angle mode;
[0033] Figure 4 is a schematic diagram of the GPM dividing line;
[0034] Figure 5 shows the template and reference sample diagram of the current block;
[0035] Figure 6 shows a schematic diagram of the three candidate modes for SGPM;
[0036] Figure 7 is a schematic diagram of the SGPM template;
[0037] Figure 8 illustrates two scenarios for SGPM candidates;
[0038] Figure 9 is a schematic diagram illustrating the principle of PDP prediction;
[0039] Figure 10 is a schematic diagram of a video encoding and decoding network architecture provided in an embodiment of this application;
[0040] Figure 11 is a schematic block diagram of an encoder provided in an embodiment of this application;
[0041] Figure 12 is a schematic block diagram of a decoder provided in an embodiment of this application;
[0042] Figure 13 is a schematic flowchart of a decoding method provided in an embodiment of this application;
[0043] Figure 14 is a schematic flowchart of a decoding method provided in an embodiment of this application;
[0044] Figure 15A is a schematic diagram of obtaining the predicted value of the template on the current block based on the weight matrix;
[0045] Figure 15B is a schematic diagram of obtaining the predicted value of the left template of the current block based on the weight matrix;
[0046] Figure 16 is a schematic flowchart of a decoding method provided in an embodiment of this application;
[0047] Figure 17 is a flowchart illustrating an encoding method provided in an embodiment of this application;
[0048] Figure 18 is a schematic diagram of the composition structure of an encoder provided in an embodiment of this application;
[0049] Figure 19 is a schematic diagram of the hardware structure of an encoder provided in an embodiment of this application;
[0050] Figure 20 is a schematic diagram of the composition structure of a decoder provided in an embodiment of this application;
[0051] Figure 21 is a schematic diagram of the hardware structure of a decoder provided in an embodiment of this application;
[0052] Figure 22 is a schematic diagram of the composition structure of an encoding / decoding system provided in an embodiment of this application. Detailed Implementation
[0053] In order to gain a more detailed understanding of the features and technical content of the embodiments of this application, the implementation of the embodiments of this application will be described in detail below with reference to the accompanying drawings. The accompanying drawings are for reference and illustration only and are not intended to limit the embodiments of this application.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0055] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0056] It should also be noted that the terms "first, second, and third" used in the embodiments of this application are only used to distinguish similar objects and do not represent a specific order of objects. It is understood that "first, second, and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0057] Before providing a further detailed description of the embodiments of this application, the nouns and terms used in the embodiments of this application will be explained. The nouns and terms used in the embodiments of this application shall be interpreted as follows:
[0058] H.266 / Versatile Video Coding (VVC);
[0059] Joint Video Experts Team (JVET);
[0060] Enhanced Compression Model (ECM) is a reference software test platform for enhanced compression.
[0061] Intra-template matching prediction (IntraTMP);
[0062] Coding Unit (CU);
[0063] Coding Tree Unit (CTU);
[0064] Largest Coding Unit (LCU);
[0065] Prediction Unit (PU);
[0066] Transform Unit (TU);
[0067] Block Vector (BV);
[0068] Mean-square error (MSE);
[0069] Sum of Absolute Difference (SAD);
[0070] Sum of Absolute Transformed Difference (SATD)
[0071] Sequence Parameter Set (SPS);
[0072] Intra Block Copy (IBC);
[0073] Geometric Partitioning Mode (GPM);
[0074] Spatial Geometric Partitioning Mode (SGPM);
[0075] Template-based Intra Mode Derivation (TIMD);
[0076] Decoder-side Intra Mode Derivation (DIMD).
[0077] It is understandable that video codec standards can adopt a block-based hybrid coding framework. For example, each image in a video is divided into a maximum coding unit (MCU) or coding tree unit of the same size (e.g., 128×128, 64×64, etc.). Each MCU or coding tree unit can be further divided into rectangular coding units according to rules. Coding units may also be divided into prediction units, transform units, etc. The hybrid coding framework includes modules such as prediction, transform, quantization, entropy coding, inv.quantization, inv.transform, and in-loop filtering. The prediction module can include intra-prediction and inter-prediction, with inter-prediction including motion estimation and motion compensation. In video codec technology, intra-prediction methods can be used to eliminate spatial redundancy between adjacent samples, and inter-prediction methods can be used to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency. Transformation converts the predicted image patch to the frequency domain, redistributing energy. Combined with quantization, it removes information insensitive to the human eye, thus eliminating visual redundancy. Entropy coding can eliminate character redundancy based on the current context model and the probability information of the binary bitstream.
[0078] In this embodiment, after reading a black-and-white or color image, the encoding end divides it into blocks and uses intra-frame prediction or inter-frame prediction to generate a prediction block for the current block. The original block is subtracted from the prediction block to obtain a residual block. The residual block is transformed and quantized to obtain a quantization coefficient matrix. The quantization coefficient matrix is then entropy-encoded and output to the bitstream. The decoding end uses intra-frame prediction or inter-frame prediction to generate a prediction block for the current block, decodes the bitstream to obtain a quantization coefficient matrix, and performs inverse quantization and inverse transform on the quantization coefficient matrix to obtain a residual block. The prediction block and the residual block are added together to obtain a reconstructed block. The reconstructed block can be used to compose a reconstructed image. The decoding end performs loop filtering on the reconstructed image based on the image or based on the blocks to obtain a decoded image. Furthermore, the block division information, prediction, transform, quantization, entropy coding, loop filtering, and other mode or parameter information determined by the encoding end may be written into the bitstream if necessary. The decoding end determines the same block partitioning information, prediction, transform, quantization, entropy coding, loop filtering, and other mode or parameter information as the encoding end by parsing and analyzing existing information. This ensures that the decoded image obtained by the encoding end is identical to the decoded image obtained by the decoding end. The encoding end also needs similar operations to the decoding end to obtain the decoded image. The decoded image can be used as a reference image for subsequent inter-frame prediction.
[0079] The above describes the basic flow of a video codec under a block-based hybrid coding framework. With technological advancements, some modules or steps of the framework may be optimized. The embodiments in this application apply to the basic flow of this block-based hybrid coding framework for video codecs, but are not limited to this framework and flow.
[0080] In this embodiment, the current block (CB) can be the current coding unit, the current prediction unit, or the current transform unit, etc. Due to the need for parallel processing, an image can be divided into slices, etc. Slices within the same image can be processed in parallel, meaning they have no data dependency. A "frame" is a common term, generally understood as an image. In this embodiment, the term "frame" can also be replaced with an image or a slice, etc. Furthermore, samples in this document can also be called pixels, and samples include both location information and values.
[0081] The following section provides a detailed introduction to several prediction techniques.
[0082] (1) Intra-frame prediction mode.
[0083] There is a strong spatial correlation between adjacent samples in an image. Intra-frame prediction is a prediction method that utilizes the spatial correlation between the already encoded / decoded samples around the current block and the samples within the current block. An example is shown in Figure 1. The white-filled 4×4 block is the current block. The grid-filled samples in the left column and top row of the current block are the reference samples for the current block. Intra-frame prediction uses these reference samples to predict the current block. These reference samples may all be available, i.e., all have been encoded / decoded. Some may also be unavailable. For example, if the current block is at the far left of the frame, then the reference samples to the left of the current block are unavailable. Or, if the lower left part of the current block has not yet been encoded / decoded, then the reference samples to the lower left are also unavailable. In cases where reference samples are unavailable, available reference samples, certain values, or certain methods can be used to fill the gaps, or no filling can be performed.
[0084] Intra-frame prediction has multiple prediction modes, as shown in Figure 2. Here are nine modes for intra-frame prediction of a 4×4 current block in H.264. Mode 0 (Vertical Mode) copies the samples above the current block vertically as the predicted values. Mode 1 (Horizontal Mode) copies the reference samples from the left side horizontally as the predicted values. Mode 2 (DC Mode) uses the average of points A-D and I-L as the predicted values for all points. Modes 3-8 copy the reference samples to the corresponding positions in the current block at a specific angle. Because some positions in the current block may not perfectly correspond to the reference samples, a weighted average of the reference samples, or interpolated subsamples of the reference samples, may be needed.
[0085] In addition to these, there are Plane and Planar modes, and with the development of technology and the expansion of blocks, angle prediction modes are becoming increasingly common. In the reference software ECM, traditional intra-prediction modes (here referred to as "traditional intra-prediction modes" to distinguish them from newly introduced intra-prediction modes such as DIMD and IntraTMP, which will be discussed later) include:
[0086] • Planar mode: Intra-prediction mode index is 0;
[0087] • DC mode: Intra-prediction mode index is 1;
[0088] • Angle mode: Intra-frame prediction mode index is 2 to 66.
[0089] As shown in Figure 3, the arrows in Figure 3 point to the angle pattern prediction directions that exist in VVC. The prediction mode index used during encoding and decoding is the angle pattern 2 to 66. When the current block is a non-square block, some angle directions will be replaced with wide angles (such as -1 to -14 and 67 to 80 in Figure 3).
[0090] (2) Geometric Partitioning Mode (GPM).
[0091] In existing video encoding and decoding frameworks, images are divided into rectangular coding blocks of different sizes through a multi-level coding tree structure to match different video content. However, in real-world video content, moving objects may have non-horizontal or non-vertical edges. GPM technology proposes dividing the coding blocks so that each sub-region can use different motion information for motion supplementation, thereby improving prediction accuracy.
[0092] As shown in Figure 4, a dividing line can be used to divide the coded block into two irregular sub-regions. The dividing line can be an angle. And the offset ρ represents the angle. The angle between the normal vector of the dividing line and the counterclockwise direction of the horizontal x-axis is denoted by ρ, and the offset ρ represents the distance from the center of the coding block to the dividing line.
[0093] In VVC, the GPM mode supports 64 partitioning methods, which can be identified by the CU-level syntax element ---- geometric partition index merge_gpm_partition_idx, as shown in Table 1.
[0094] Table 1
[0095] Where angleIdx represents the angle. co-expression The 20 corresponding angles are detailed in Table 1. The tilt angle corresponds to a width-to-height ratio or a height-to-width ratio of 1:4, 1:2, 1:1, or 2:1 for straight lines. The distance index `distanceIdx` represents the offset ρ, corresponding to the distance ρ between the dividing line and the center of the CU in both the horizontal and vertical directions. x,j ρ y,j As shown below:
[0096] Where i and j are angleIdx and distanceIdx respectively, and w and h are the width and height of CU respectively. When i < 16, the signs in equations (1) and (2) above are positive, otherwise they are negative.
[0097] The motion vector (MV) in GPM mode can be obtained by constructing a merge list and a transmission index. After determining the two motion vectors mvA and mvB, angleIdx and distanceIdx of the GPM coded block, the prediction block pbSamples[x][y] of the current coded block can be generated, where x = 0..w-1 and y = 0..h-1. First, based on mvA and mvB, two inter-frame prediction blocks predSamplesLA and predSamplesLB are obtained through motion compensation, with a size of w×h, defined as follows:
[0098] shift1 = max(5, 17 - BitDepth), where BitDepth is the number of bits in the sample;
[0099] offset1 = 1 << (shift1 - 1);
[0100] displacementX = angleIdx;
[0101] displacementY=(angleIdx+8)%32;
[0102] partFlip=(angleIdx>=13&&angleIdx<=17)? 0:1;
[0103] shiftHor=(angle%16==8||(angle%16!=0&&h>=w))? 0:1;
[0104] If shiftHor == 0, then
[0105] offsetX = (-w) >> 1,
[0106] offsetY=((-h)>>1)+(angleIdx<16?(distanceIdx*h)>>3:-((distanceIdx*h)>>3));
[0107] otherwise,
[0108] offsetX=((-w)>>1)+(angleIdx<16?(distanceIdx*w)>>3:-((distanceIdx*w)>>3)),
[0109] offsetY = (-h) >> 1).
[0110] Here, the definition of the list disLut is shown in Table 2.
[0111] Table 2
[0112] The weight value wValue corresponding to each predicted sample can be obtained:
[0113] weightIdx=(((x+offsetX)<<1)+1)*disLut[displacementX]+(((y+offsetY)<<1)+1)*disLut[displacementY];
[0114] weightIdxL=partFlip? 32+weightIdx:32-weightIdx;
[0115] wValue=Clip3(0,8,(weightIdxL+4)>>3) (3)
[0116] GPM prediction value:
[0117] pbSamples[x][y] = Clip3(0, (1< <BitDepth)-1,
[0118] (predSamplesLA[x][y]*wValue+predSamplesLB[x][y]*(8-wValue)+offset1)>>shift1) (4)
[0119] (3) Template-based Intra Mode Derivation (TIMD).
[0120] TIMD technology proposes comparing the errors of different intra-prediction modes in the current coding block template region to select the optimal intra-prediction mode. This method avoids the complex mode index transmission, thus achieving coding gain. The intra-prediction modes can include traditional intra-angle prediction modes, DC mode, Planar mode, block copy mode, etc. By generating the predicted value of this mode in the template region and comparing it with the reconstructed value of the template region, the template error of this mode is obtained (using error calculation methods such as SAD and SATD).
[0121] Taking the template error calculation of the traditional intra-frame angle prediction mode as an example, as shown in Figure 5, let the coordinates of the top left corner of the current block be (0,0), and the width and height of the current block be W and H respectively. Then, the size of the upper template of the current block is W×TemplateHeight, and the size of the left template of the current block is TemplateWidth×H. The template prediction process is similar to the actual traditional intra-frame angle prediction process. First, obtain the reference sample ref[x][y], x=-TemplateWidth-1..N, y=-TemplateHeight-1, and x=-TemplateWidth-1, y=-TemplateHeight…M, N>=W, M>=H. Referring to the angle prediction process, predict the current block containing the template (position and size are (-TemplateWidth, -TemplateHeight, W+TemplateWidth, H+TemplateHeight)) based on the reference sample. Only the upper template region and the left template region can be predicted. Thus, the predicted values p[x][y] of the template are obtained, where x = 0…W-1, y = -TemplateHeight…-1 and x = -TemplateWidth…-1, y = 0…H-1. Further, the predicted values p[x][y] of the template are compared with the reconstructed sample values reco[x][y] at the corresponding positions to obtain the template error, which can be represented by SAD or SATD, etc.
[0122] (4) Spatial Geometric Partitioning Mode (SGPM).
[0123] SGPM (Single Frame Prediction Mode) is an intra-frame prediction method similar to GPM (Gateway Frame Prediction). It proposes dividing the coded block into two parts using a partition line. Unlike GPM, both parts in SGPM are obtained through intra-frame prediction, as shown in Figure 6. In its implementation, an SGPM coded block constructs a candidate list. Each candidate in this list contains one partition mode and two intra-frame prediction modes. First, the n partition modes available for the current block are determined (e.g., n=26). For each partition mode `splitDir`, m intra-frame prediction modes are determined through TIMD derivation, DIMD derivation, and inheritance from adjacent coded blocks (e.g., m=9). Two intra-frame prediction modes, `predMode0` and `predMode1`, are selected from these m modes, where `predMode0` != `predMode1`. Combined with `splitDir`, these forms an SGPM candidate.
[0124] It should be noted that, since one partition mode and two intra-prediction modes are used, the general logic would be to write the syntax elements indicating these three modes into the bitstream, as shown in Table 3, namely partition_mode_idx, intra_pred_mode0_idx, and intra_pred_mode1_idx. However, to reduce the overhead of this information, SGPM uses the template of the current block to sort the combination of the three modes, obtaining a candidate list of combined modes. In the bitstream, only the candidate index of SGPM needs to be written. At the decoding end, SGPM can construct the SGPM candidate list. Based on the candidate index of SGPM, such as sgpm_cand_idx in Table 4, it can derive one partition mode and two intra-prediction modes: partition_mode_idx, intra_pred_mode0_idx, and intra_pred_mode1_idx.
[0125] Table 3
[0126] Table 4
[0127] Here, for sgpm_cand_idx, In other words, only one sgpm_cand_idx syntax element is encoded here, instead of encoding three syntax elements: partition_mode_idx, intra_pred_mode0_idx, and intra_pred_mode1_idx.
[0128] To further improve coding efficiency, the SGPM candidate list can be reordered based on template error, allowing candidates with smaller template errors to have shorter codewords, while discarding candidates with larger template errors. For example, if the current block has n partitioning modes, and each partitioning mode has m intra-prediction mode candidates, a total of n*m*(m-1) SGPM candidates can be obtained. The template error values of these SGPM candidates can be calculated, and then the SGPM candidate list can be reordered, retaining only the best k SGPM candidates, for example, k=16. Correspondingly, the value range of sgpm_cand_idx is 0…k-1.
[0129] The SGPM technique uses a method similar to TIMD to calculate the template error for each SGPM candidate. Unlike TIMD, when predicting the template of an SGPM coding block (e.g., the upper and left templates), it is necessary to consider the weight values of the two predicted blocks corresponding to its partitioning pattern, as shown in Figure 7. Here, the width of the left template and the height of the upper template are both the template size.
[0130] For the extension of the SGPM model:
[0131] SGPM and Block Copy Prediction: An SGPM prediction block is a combination of two intra-prediction blocks. In addition to traditional intra-angle prediction modes, DC mode, or Planar mode, intra-prediction blocks can also be implemented through block vector-based prediction. For example, by inheriting the block vectors of adjacent and non-adjacent coded blocks, a candidate list of block vectors for the current block is constructed, thereby determining the candidate block vectors for the current block. This can be combined with the process of constructing the SGPM candidate list to determine the final SGPM candidates. That is, n partitioning modes are determined, each partitioning mode has m1 traditional intra-prediction mode candidates (e.g., traditional intra-angle prediction mode, DC mode, or Planar mode) and m2 block vector candidates, resulting in a total of n*(m1+m2)*(m1+m2-1) SGPM candidates.
[0132] Regression-based SGPM (RSGPM) prediction: Unlike geometric partitioning based on predefined weights chosen according to the partitioning pattern, GPM models can determine the weight values when combining two prediction blocks through derivation. For two prediction patterns, predMode0 and predMode1, let their weights be w0[x][y] = 1 - w1[x][y] and w1[x][y] = ax + by + c, respectively. Based on this weight expression and the predicted values p0[x][y] and p1[x][y] of the two prediction patterns on the template, the values of a, b, and c are derived, thus determining the expressions for w0 and w1. In one possible implementation, the derivation process is as follows: traverse the templates x = -TemplateWidth…-1, y = 0…H-1 and x = 0…W-1, y = -TemplateHeight…-1. At each position, a training sample can be obtained: (p1[x][y]-p0[x][y])*x*a+(p1[x][y]-p0[x][y])*y*b+(p1[x][y]-p0[x][y])*c = reco[x][y]-p0[x][y]. After obtaining all training samples, a, b, and c are calculated using the MSE minimization method. Based on this weight model (i.e., the expressions for w0 and w1), the combination of predMode0 and predMode1 prediction blocks can be realized. Here, this weight model can be used as information contained in the SGPM candidate and incorporated into the existing SGPM model.
[0133] As shown in Figure 8, for the syntax element sgpm_cand_idx, in the SGPM candidate, it can indicate: partition_mode_idx, intra_pred_mode0_idx, intra_pred_mode1_idx; in the RSGPM candidate (Regression-based SGPM candidate), it can indicate: intra_pred_mode0_idx, intra_pred_mode1_idx, derived blending matrix.
[0134] (5) Matrix-based Position Dependent Intra Prediction (PDP).
[0135] PDP is an intra-frame prediction technique based on a predefined weight matrix. One implementation involves determining a predefined weight matrix (which can be obtained through pre-training) for a specific block shape and intra-frame prediction angle. The predicted block is obtained by multiplying this weight matrix with a reference sample of the current block template region. This weight matrix-based PDP prediction process replaces the traditional intra-frame angle prediction process for the corresponding angle. As shown in Figure 9, the weight matrix is applied to the L-shaped neighborhood samples filled with a grid.
[0136] Suppose we denote the reference samples in the neighborhood as r, and F(x,y) is the weight matrix. Then the predicted value P(x,y) can be expressed as: P(x,y)=∑ k F(x,y,k)×r(k) (5)
[0137] Here, k represents the index of the reference sample in the L-shaped neighborhood. In existing implementations, the PDP mode is only applied to blocks of a certain size to control complexity. For example, it is applied to blocks with a width and height no greater than 32 (except for 4x32, 32x4, 8x32, and 32x8). Furthermore, different sized templates can be set for blocks of different sizes, and different angle predictions can be used. For example:
[0138] For blocks with a width and height of no more than 16, the width of the template (e.g., T1, T2) is set to 2 samples, and the original intra-frame angle prediction mode replaced by the PDP mode is 0, 1, (2+2k), k = 0..32;
[0139] For other block sizes (i.e., 32x16, 16x32, 32x32), the template width (e.g., T1, T2) is set to 1 sample, and the original intra-frame angle prediction mode replaced by the PDP mode is 0, 1, (2+4k), k = 0..16;
[0140] PDP uses the weight matrix to predict only the 16×16 size position; the remaining sample values are generated through bilinear interpolation. For all block sizes, the symmetry between block shape and mode is utilized.
[0141] For traditional angle prediction models in the range of 18–50, the reference length (i.e., the side length of the L-shaped neighborhood) is set to W and H, otherwise it is set to 2W and 2H.
[0142] In one possible implementation, for the combination of PDP and existing intra-prediction modes, the encoder / decoder can use the aforementioned weight matrix-based method instead of the traditional intra-prediction process (calculating the predicted value based on the position of the sample to be predicted, the reference sample value in the corresponding direction, etc.) when performing intra-prediction (e.g., intra-angle prediction mode, DC mode, or Planar mode). Different modes can choose whether to replace the intra-prediction process with PDP prediction. For example, the SGPM mode requires two parts of intra-prediction and can use the traditional prediction method; intra-prediction encoded by the Most Probable Mode (MPM) can use PDP prediction when the conditions are met.
[0143] In simple terms, in related technologies, PDP prediction can replace the traditional intra-frame prediction process by using a weight matrix-based prediction method. This weight matrix can be obtained through offline training and offers higher accuracy compared to traditional prediction methods. This technique can be used in modes such as GPM and SGPM that employ intra-frame prediction; that is, when the required intra-frame prediction mode meets the conditions for PDP prediction, the corresponding prediction process can be replaced with PDP prediction. However, combining SGPM and PDP prediction still has some drawbacks. For example, when constructing and reordering the SGPM candidate list, it is necessary to obtain the predicted values of the candidate intra-frame modes in the template region. This template prediction process is still implemented using the traditional prediction process. This leads to potentially inaccurate template errors for the corresponding prediction mode if PDP prediction is used, thus reducing coding efficiency.
[0144] Based on this, embodiments of this application provide an encoding method. When the current block is predicted using a geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block. The template prediction value under at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on a weight matrix prediction method. The current block is then predicted based on the prediction information to determine the prediction sample of the current block. Embodiments of this application also provide a decoding method. A first syntax element in the bitstream is parsed. When the first syntax element indicates that the current block is predicted using a geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block. The template prediction value under at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on a weight matrix prediction method. The current block is then predicted based on the prediction information to determine the prediction sample of the current block.
[0145] In this way, when the current block uses geometric partitioning modes such as GPM and SGPM, not only can the prediction method based on the weight matrix be used during the prediction process, but also in the process of determining the prediction information of the current block, the same prediction method based on the weight matrix can be used to determine the template prediction value of the current block for steps such as calculating the template error of the current block and deriving the weight information. This makes the template error and the derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, improving the encoding and decoding efficiency, and thus improving the encoding and decoding performance.
[0146] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0147] Figure 10 is a schematic diagram of a video encoding and decoding network architecture provided in an embodiment of this application. As shown in Figure 10, the network architecture includes one or more electronic devices 13 to 1N and a communication network 01, wherein the electronic devices 13 to 1N can perform video interaction through the communication network 01. During implementation, the electronic devices can be various types of devices with video encoding and decoding capabilities. For example, the electronic devices may include mobile phones, tablet computers, personal computers, personal digital assistants, navigators, digital phones, video phones, televisions, sensing devices, servers, etc., and this embodiment of the application does not limit the scope of the application.
[0148] This application provides a network architecture for a video encoding / decoding system that includes decoding and encoding methods. The decoder or encoder in this application can be the aforementioned electronic device. That is, the electronic device in this application has video encoding / decoding capabilities and generally includes a video / image encoder (referred to as an encoder) and a video / image decoder (referred to as a decoder).
[0149] Figure 11 is a schematic block diagram of an encoder provided in an embodiment of this application. As shown in Figure 11, the encoder 100 may include a transform and quantization unit 101, an intra-frame estimation unit 102, an intra-frame prediction unit 103, a motion compensation unit 104, a motion estimation unit 105, an inverse transform and inverse quantization unit 106, a filter control and analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoded image buffer unit 110, etc. Among them, the filtering unit 108 can implement deblocking filtering and sample adaptive offset (SAO) filtering, and the encoding unit 109 can implement header information encoding and context-based adaptive binary arithmetic coding (CABAC).For the input raw video signal, a video coding block can be obtained by partitioning it through a Coding Tree Unit (CTU). Then, the residual sample information obtained after intra-frame or inter-frame prediction is transformed by the transform and quantization unit 101, including transforming the residual information from the sample domain to the transform domain and quantizing the resulting transform coefficients to further reduce the bit rate. The intra-frame estimation unit 102 and the intra-frame prediction unit 103 are used to perform intra-frame prediction on the video coding block. Specifically, the intra-frame estimation unit 102 and the intra-frame prediction unit 103 are used to determine the intra-frame prediction mode to be used to encode the video coding block. The motion compensation unit 104 and the motion estimation unit 105 are used to perform inter-frame prediction coding of the received video coding block relative to one or more blocks in one or more reference frames to provide time prediction information. The motion estimation performed by the motion estimation unit 105 is a process of generating motion vectors, which can estimate the motion of the video coding block. Then, the motion compensation unit 104 is used to perform the motion estimation based on the motion vectors determined by the motion estimation unit 105. The motion compensation is performed. After determining the intra-prediction mode, the intra-prediction unit 103 is also used to provide the selected intra-prediction data to the coding unit 109, and the motion estimation unit 105 also sends the calculated motion vector data to the coding unit 109. In addition, the inverse transform and inverse quantization unit 106 is used to reconstruct the video coding block, reconstruct the residual block in the sample domain, and remove the block artifacts by the filter control analysis unit 107 and the filtering unit 108. Then, the reconstructed residual block is added to a predictive block in the frame of the decoding image buffer unit 110 to generate the reconstructed video coding block. The coding unit 109 is used to encode various coding parameters and quantized transform coefficients. In the CABAC-based coding algorithm, the context content can be based on adjacent coding blocks and can be used to encode information indicating the determined intra-prediction mode and output the bitstream of the video signal. The decoding image buffer unit 110 is used to store the reconstructed video coding block for prediction reference. As video image encoding proceeds, new reconstructed video encoding blocks are continuously generated, and these reconstructed video encoding blocks are stored in the decoding image buffer unit 110.
[0150] Figure 12 is a schematic block diagram of a decoder provided in an embodiment of this application. As shown in Figure 12, the decoder 200 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra-frame prediction unit 203, a motion compensation unit 204, a filtering unit 205, and a decoded image buffer unit 206, etc. The decoding unit 201 can perform header information decoding and CABAC decoding, and the filtering unit 205 can perform deblocking filtering and SAO filtering. After the input video signal is encoded as shown in Figure 11, the bitstream of the video signal is output. This bitstream is input into the decoder 200, first passing through the decoding unit 201 to obtain the decoded transform coefficients. The transform coefficients are then processed by the inverse transform and inverse quantization unit 202 to generate residual blocks in the sample domain. The intra-frame prediction unit 203 can be used to generate prediction data for the current video decoding block based on the determined intra-frame prediction mode and data from previously decoded blocks in the current frame or image. The motion compensation unit 204 determines the prediction information for the video decoding block by analyzing motion vectors and other associated syntax elements, and uses... The prediction information is used to generate a predictive block of the video block being decoded; the decoded video block is formed by summing the residual block from the inverse transform and inverse quantization unit 202 with the corresponding predictive block generated by the intra-prediction unit 203 or the motion compensation unit 204; the decoded video signal is passed through the filtering unit 205 to remove block artifacts, which can improve video quality; then the decoded video block is stored in the decoding image buffer unit 206, which stores reference images for subsequent intra-prediction or motion compensation, and is also used for the output of the video signal, thus obtaining the recovered original video signal.
[0151] It should be noted that the method in this application's embodiments affects the intra-frame prediction part of the video coding hybrid framework, for example, mainly acting on the intra-frame estimation unit 102 and intra-frame prediction unit 103 parts shown in FIG11 and the intra-frame prediction unit 203 part shown in FIG12. That is to say, the embodiments of this application can be applied to the encoder, the decoder, or even to both the encoder and the decoder, but no limitation is made here.
[0152] It should also be noted that when the embodiments of this application are applied to the encoder 100, the "current block" can refer to the block to be encoded in the video image (also known as the "encoded block"); when the embodiments of this application are applied to the decoder 200, the "current block" can refer to the block to be decoded in the video image (also known as the "decoded block").
[0153] In one embodiment of this application, Figure 13 is a schematic flowchart of a decoding method provided in this application. As shown in Figure 13, the method may include:
[0154] S1301, parse the first syntax element in the bitstream.
[0155] It should be noted that in this embodiment, the method is applied to the decoder, mainly to the intra-prediction part in Figure 12 (marked with a bold box). Specifically, when intra-prediction is used in the current block, this mainly refers to the optimization scheme proposed for the geometric partitioning mode based on matrix prediction, which can improve decoding efficiency.
[0156] It should also be noted that, in this embodiment, some indication information in the form of syntax elements, or flags, can be written into the bitstream. Thus, by parsing the values of the syntax elements in the bitstream, the prediction mode used by the current block can be determined. For example, the first syntax element can be used to indicate whether the current block uses a geometric partitioning mode for prediction.
[0157] In some embodiments, if the value of the first syntax element is a first value, then it can be determined that the first syntax element indicates that the current block uses a geometric partitioning pattern for prediction; if the value of the first syntax element is a second value, then it can be determined that the first syntax element indicates that the current block does not use a geometric partitioning pattern for prediction.
[0158] In the embodiments of this application, the first value and the second value are different. In one possible implementation, the first value can be true and the second value can be false; or, the first value can be 1 and the second value can be 0; no limitation is made here.
[0159] In this embodiment, the first syntax element is a block-level syntax element (or "CU-level syntax element"), and the geometric partitioning mode can refer to GPM, SGPM, etc. In one possible implementation, the first syntax element can be represented by cu_gpm_flag, which indicates whether the current block uses GPM for prediction. Alternatively, the first syntax element can also be represented by cu_sgpm_flag, which indicates whether the current block uses SGPM for prediction.
[0160] S1302, when the first syntax element indicates that the current block is predicted using the geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0161] In this embodiment, if the value of the first syntax element is true, then it is determined that the current block is predicted using a geometric partitioning mode. Here, the current block can be divided into at least two parts according to the geometric partitioning mode, and each part corresponds to a prediction mode; therefore, the prediction information obtained under the geometric partitioning mode may include at least two prediction modes, and the template prediction value under at least some of the prediction modes is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0162] In one possible implementation, to determine the prediction information for the current block, a candidate list can be constructed first, and then the prediction information for the current block can be determined from it. In some embodiments, referring to FIG14, after step S1301, the method may include:
[0163] S1401, when the first syntax element indicates that the current block is predicted using a geometric partitioning mode, parse the prediction mode index in the bitstream.
[0164] S1402, Determine the candidate list for the current block based on the template prediction value of the current block.
[0165] S1403, Determine the prediction information for the current block based on the prediction mode index and the candidate list of the current block.
[0166] It should be noted that, in this embodiment of the application, a candidate list for the current block can be determined based on the template prediction value of the current block; then, the prediction information for the current block can be determined based on the candidate list. The candidate list includes at least one set of candidate prediction information.
[0167] It should also be noted that, in the embodiments of this application, the prediction mode index is used to indicate the index number of the prediction information of the current block in the candidate list of the current block. Thus, after parsing the prediction mode index in the bitstream, the prediction information of the current block can be determined based on the prediction mode index and the candidate list of the current block.
[0168] It should also be noted that, in this embodiment, the prediction mode index in the bitstream can be a single syntax element or multiple syntax elements, all used to obtain the prediction information of the current block. For example, as shown in Table 3, the prediction mode index can be composed of multiple syntax elements, such as `partition_mode_idx`, `intra_pred_mode0_idx`, and `intra_pred_mode1_idx`. To reduce the overhead of this information, these mode indices can be combined into a single syntax element, as shown in Table 4. Here, the prediction mode index can be just a single syntax element, such as `sgpm_cand_idx`. Here, by decoding this single syntax element `sgpm_cand_idx`, the values of syntax elements such as `partition_mode_idx`, `intra_pred_mode0_idx`, and `intra_pred_mode1_idx` can also be obtained.
[0169] In one possible implementation, if the current block is predicted using SGPM, the prediction mode index can be represented by cu_sgpm_idx, and the candidate list of the current block can be represented by sgpmList'; then, based on the prediction mode index cu_sgpm_idx in the bitstream, the prediction information of the current block obtained is sgpmList'[cu_sgpm_idx].
[0170] In other words, in this embodiment, the first syntax element cu_sgpm_flag in the bitstream is first parsed. If the value of the first syntax element cu_sgpm_flag is true, it indicates that the current block uses SGPM for prediction. Then, the prediction mode index cu_sgpm_idx in the bitstream needs to be further parsed. Then, the candidate list sgpmList' of the current block is constructed. Combined with the prediction mode index cu_sgpm_idx, the prediction information of the current block can be determined as sgpmList'[cu_sgpm_idx].
[0171] The following description uses SGPM prediction for the current block as an example to illustrate the construction of the candidate list.
[0172] In one possible implementation, determining the candidate list of the current block includes: determining at least one set of prediction mode combinations, wherein each set of prediction mode combinations includes at least two candidate prediction modes; determining a first candidate list of the current block based on the at least one set of prediction mode combinations and at least one candidate partitioning method; and determining the candidate list of the current block based on the first candidate list.
[0173] In this embodiment, when using SGPM for prediction of the current block, a first candidate list sgpmList for the current block can be constructed; then, based on the first candidate list sgpmList, the candidate list for the current block is determined. In this implementation, each set of candidate prediction information may include: at least two candidate prediction modes included in the prediction mode combination and a candidate partitioning method. For example, assuming the prediction mode combination includes two candidate prediction modes, then for each set of candidate prediction information, it may include: partition_mode_idx, intra_pred_mode0_idx, and intra_pred_mode1_idx.
[0174] In another possible implementation, determining the candidate list for the current block includes: determining at least one set of prediction mode combinations, each set of prediction mode combinations including at least two candidate prediction modes; determining a second candidate list for the current block based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations; and determining the candidate list for the current block based on the second candidate list.
[0175] In this embodiment, when the current block is predicted using derived SGPM (i.e., RSGPM), a second candidate list rsgpmList for the current block can be constructed; then, based on the second candidate list rsgpmList, the candidate list for the current block is determined. In this implementation, each set of candidate prediction information may include: at least two candidate prediction modes included in the prediction mode combination and derived candidate weight information. For example, assuming the prediction mode combination includes two candidate prediction modes, then for each set of candidate prediction information, it may include: intra_pred_mode0_idx, intra_pred_mode1_idx, and a derived blending matrix.
[0176] In another possible implementation, determining the candidate list of the current block includes: determining at least one set of prediction mode combinations, wherein each set of prediction mode combinations includes at least two candidate prediction modes; determining a first candidate list of the current block based on at least one set of prediction mode combinations and at least one candidate partitioning method; determining a second candidate list of the current block based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode groups; and determining the candidate list of the current block based on the first candidate list and the second candidate list.
[0177] In this embodiment, the candidate list for the current block can be obtained by combining a first candidate list sgpmList and a second candidate list rsgpmList. In one possible implementation, in the candidate list sgpmList' of the current block, the candidate prediction information in the second candidate list rsgpmList precedes the candidate prediction information in the first candidate list sgpmList.
[0178] For example, assuming the first candidate list sgpmList includes N1 sets of candidate prediction information and the second candidate list rsgpmList includes N2 sets of candidate prediction information, then the first N2 sets of candidate prediction information in the candidate list sgpmList' of the current block correspond to the second candidate list rsgpmList, and the last N1 sets of candidate prediction information correspond to the first candidate list sgpmList.
[0179] Understandably, when using SGPM for prediction in the current block, a first candidate list (sgpmList) can be constructed. In some embodiments, determining the first candidate list for the current block based on at least one combination of prediction modes and at least one candidate partitioning method may include: determining at least one set of first candidate prediction information based on at least one combination of prediction modes and at least one candidate partitioning method; calculating template error for the template region of the current block based on the at least one set of first candidate prediction information to determine the template error value corresponding to each of the at least one set of first candidate prediction information; sorting the at least one set of first candidate prediction information in ascending order based on the template error value, and forming the first candidate list for the current block from the top N1 sets of first candidate prediction information; where N1 is a positive integer.
[0180] It should be noted that, in the embodiments of this application, at least one set of first candidate prediction information can be obtained by combining the candidate intra-prediction modes, candidate vector parameters (including BV, MV, etc.) and candidate partitioning methods; based on this at least one set of first candidate prediction information, a first initial list for the current block, i.e., the initial SGPM candidate list sgpmCandidateList, can be constructed. The first candidate prediction information may include at least two candidate prediction modes and one candidate partitioning method contained in a set of prediction mode combinations. The at least two candidate prediction modes can be determined based on traditional intra-prediction modes, block copying prediction modes, etc.
[0181] It should also be noted that, in the embodiments of this application, a template error value can be calculated for each group of first candidate prediction information, and then at least one group of first candidate prediction information in the first initial list is reordered according to the template error value, and the N1 groups of first candidate prediction information that are ranked first are used to form the first candidate list sgpmList of the current block.
[0182] In some embodiments, performing template error calculation on the template region of the current block based on at least one set of first candidate prediction information, and determining the template error value corresponding to each of the at least one set of first candidate prediction information, may include:
[0183] The template region of the current block is predicted based on at least two candidate prediction modes in the first candidate prediction information, and the template prediction value corresponding to each of the at least two candidate prediction modes is determined. The template error is calculated based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region, and the template error value corresponding to the first candidate prediction information is determined.
[0184] It should be noted that, in this embodiment, for at least two candidate prediction modes in the first candidate prediction information, the corresponding template error value can be calculated based on the prediction method of the weight matrix. Specifically, the template prediction value of at least some of these at least two candidate prediction modes is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0185] In some embodiments, predicting the template region of the current block based on at least two candidate prediction patterns in the first candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, may include:
[0186] When the first candidate prediction mode among at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value corresponding to the first candidate prediction mode.
[0187] If the second candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second candidate prediction mode to determine the template prediction value corresponding to the second candidate prediction mode.
[0188] It should be noted that, in the embodiments of this application, the first candidate prediction mode can be a candidate prediction mode that meets the preset conditions among at least two candidate prediction modes of the first candidate prediction information, and the second candidate prediction mode is a candidate prediction mode that does not meet the preset conditions among at least two candidate prediction modes of the first candidate prediction information.
[0189] It should also be noted that, in the embodiments of this application, the first candidate prediction mode meeting preset conditions may include: the first candidate prediction mode is an intra-frame prediction mode and meets the PDP prediction usage conditions. In one possible implementation, the PDP prediction usage conditions may include: the size of the current block meets the size requirements. For example, PDP prediction is only applied to blocks of a certain size, such as blocks whose width and height are both no greater than 32, or blocks whose width and height are both no greater than 32 except for 4x32, 32x4, 8x32, and 32x8. In this case, the template prediction value in the first candidate prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0190] In one possible implementation, assuming the current block is divided into two parts, prediction is performed using prediction mode A and prediction mode B respectively, resulting in a first prediction block PredA and a second prediction block PredB. The final predicted sample can be a weighted combination of PredA and PredB. If the first prediction block PredA (or the second prediction block PredB) is obtained by a prediction method based on the weight matrix, its template prediction value in the template region can also be obtained by a prediction method based on the weight matrix. For example, assuming the top-left corner coordinate of the current block is (0,0), then the first prediction block PredA can be: PredA(x,y)=∑ k F(x,y,k)×τ(k) (6)
[0191] Where x and y represent the coordinates of the predicted pixel relative to the top-left corner of the current block, τ represents the reference template composed of pixels p[x][y], x=-T2..(2*W-1), y=-T1..-1 and x=-T2..-1, y=0..(2*H-1), k represents the index of the reference sample in the reference template, W represents the width of the current block, H represents the height of the current block, T1 represents the height of the upper part of the reference template, and T2 represents the width of the left part of the reference template.
[0192] In one possible implementation, taking a first candidate prediction pattern that meets preset conditions as an example, the first reference template of the current block may include a reference sample of the first left template and a reference sample of the first upper template. Correspondingly, in some embodiments, predicting the template region of the current block based on a weight matrix to determine the template prediction value corresponding to the first candidate prediction pattern may include:
[0193] Determine the first weight matrix of the current block; determine the predicted value of the first left template based on the first weight matrix and the reference sample of the first left template; determine the predicted value of the first upper template based on the first weight matrix and the reference sample of the first upper template; determine the template predicted value corresponding to the first candidate prediction mode based on the predicted value of the first left template and / or the predicted value of the first upper template.
[0194] In the embodiments of this application, the first reference template of the current block may only include the reference sample of the first left template, in which case the template prediction value corresponds only to the prediction value of the first left template; or it may only include the reference sample of the first top template, in which case the template prediction value corresponds only to the prediction value of the first top template; or it may simultaneously include the reference sample of the first left template and the reference sample of the first top template, in which case the template prediction value may be composed of the prediction value of the first left template and the prediction value of the first top template; no limitations are made here.
[0195] For example, suppose that at least two candidate prediction modes in the first candidate prediction information may include prediction mode A and prediction mode B, and prediction mode A uses a template prediction method based on a weight matrix. Here, the prediction value PredA_temp of prediction mode A in the template can be expressed as: PredA_temp(x,y)=∑ k F(x,(y+tempH),k)×τ_top(k) (7)
[0196] Where x = 0..(W-1), y = -tempH..-1, tempH represents the height of the upper template, τ_top represents the reference template composed of pixels p[x][y], x = -T2..(2*W-1), y = -T1-tempH..-1-tempH and x = -T2..-1, y = -tempH..(2*H-1)-tempH, and k represents the index of the reference sample in the reference template (the index order is the same as τ), as shown in Figure 15A.
[0197] Similarly, the predicted value PredA_temp of prediction mode A in the left template can be expressed as: PredA_temp(x,y)=∑ k F(x+tempW,y,k)×τ_left(k) (8)
[0198] Where x = -tempW..-1, y = 0..(H-1), tempW represents the width of the left template, τ_left represents the reference template composed of pixels p[x][y], x = -T2-tempW..(2*W-1)-tempW, y = -T1..-1 and x = -T2-tempW..-1-tempW, y = 0..(2*H-1), and k represents the index of the reference sample in the reference template (the index order is the same as τ), as shown in Figure 15B.
[0199] Based on the above process, the predicted values PredA_top and PredA_left of prediction mode A in the upper and left templates can be obtained. These values can be combined with the predicted values PredB_top and PredB_left of prediction mode B in the upper and left templates, and the splitDir partitioning method, to obtain the template error value under the first candidate prediction information (prediction mode A, prediction mode B, and splitDir partitioning method). It should be noted that if prediction mode B also uses the prediction method based on the weight matrix for template prediction, then PredB_top and PredB_left can be calculated based on formulas (7) and (8); if prediction mode B does not use the prediction method based on the weight matrix for template prediction, then PredB_top and PredB_left can be obtained by predicting the template region of the current block based on prediction mode B.
[0200] In some embodiments, calculating the template error based on the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction values of the template region, and determining the template error value corresponding to the first candidate prediction information, may include:
[0201] Based on the candidate division method in the first candidate prediction information, determine the weight values corresponding to at least two candidate prediction modes; based on the template prediction values and template reconstruction values of the template regions corresponding to at least two candidate prediction modes, determine the error values corresponding to at least two candidate prediction modes; perform weighted calculation based on the error values and weight values corresponding to at least two candidate prediction modes to obtain the template error value corresponding to the first candidate prediction information.
[0202] In this embodiment, the template error value can be calculated using methods such as MSE, SAD, and SATD. In one possible implementation, SAD is used as an example to calculate the error value of the prediction pattern A in the upper and left templates. First, the error value wholeSadA of the prediction pattern A under the complete upper and left templates is calculated: wholeSadA=∑abs(PredA_temp(x,y)-reco(x,y)) (9)
[0203] Where x = 0..(W-1), y = -tempH..-1 and x = -tempW..-1, y = 0..(H-1); PredA_temp(x,y) represents the template predicted value, and reco(x,y) represents the template reconstructed value.
[0204] Calculate the template error of prediction mode A after combining the first part of the weights: partSadA=∑w0[x][y]*abs(PredA_temp(x,y)-reco(x,y)) (10)
[0205] Where x = 0..(W-1), y = -tempH..-1 and x = -tempW..-1, y = 0..(H-1); w0[x][y] represents the first weight value. It should be noted that w0[x][y], like the GPM and SGPM prediction processes in related techniques, can be determined by the shape, size, and partitioning method splitDir of the current block.
[0206] Similarly, we can obtain the error value wholeSadB of prediction mode B under the complete upper and left templates and the template error partSadB after combining prediction mode B with the first part weight. Then, when the first part uses prediction mode A and the second part uses prediction mode B, the template error value corresponding to the first candidate prediction information is expressed as: SadA_B_splitDir= partSadA+wholeSadB-partSadB (11)
[0207] Thus, based on the template error calculation process described above, template error values corresponding to at least one set of first candidate prediction information can be obtained. Then, these at least one set of first candidate prediction information are sorted from smallest to largest according to their template error values, and the top N1 sets of first candidate prediction information form the first candidate list for the current block. In other words, by calculating the template error value in the above manner, the processes of calculating the template error corresponding to each first candidate prediction information and reordering the candidate list are realized in both GPM and SGPM modes. Since the prediction method based on the weight matrix can be used not only in the prediction process of the current block but also in the template error calculation to determine the template prediction value, prediction accuracy is improved.
[0208] It is also understandable that when the current block is predicted using inference-based SGPM, a second candidate list rsgpmList can be constructed, and candidate weight information can be inferred based on the prediction method of the weight matrix.
[0209] In some embodiments, the method may further include: predicting the template region of the current block according to a first prediction mode combination, and determining the template prediction values corresponding to at least two candidate prediction modes included in the first prediction mode combination; determining at least one set of training samples according to the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction value of the template region; determining first candidate model parameters of a preset weight model according to the at least one set of training samples; and determining candidate weight information corresponding to the first prediction mode combination according to the first candidate model parameters; wherein the first prediction mode combination is any one of the at least one set of prediction mode combinations.
[0210] It should be noted that, in the embodiments of this application, taking the at least two candidate prediction modes included in the first prediction mode combination as an example, the template prediction value of at least some of the candidate prediction modes in these at least two candidate prediction modes is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0211] In some embodiments, predicting the template region of the current block based on a first prediction mode combination, and determining the template prediction values corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination, may include:
[0212] When the third candidate prediction mode among at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value corresponding to the third candidate prediction mode.
[0213] When the fourth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the fourth candidate prediction mode to determine the template prediction value corresponding to the fourth candidate prediction mode.
[0214] It should be noted that, in the embodiments of this application, the third candidate prediction mode can be a candidate prediction mode that meets a preset condition from at least two candidate prediction modes in the combination of the first prediction modes, and the fourth candidate prediction mode can be a candidate prediction mode that does not meet the preset condition from at least two candidate prediction modes in the combination of the first prediction modes. The third candidate prediction mode meeting the preset condition may include: the third candidate prediction mode being an intra-frame prediction mode and meeting the conditions for using PDP prediction. In this case, the template prediction value in the third candidate prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0215] In one possible implementation, taking a third candidate prediction mode that meets preset conditions as an example, the second reference template of the current block may include a reference sample of the second left template and a reference sample of the second upper template. Correspondingly, in some embodiments, predicting the template region of the current block based on a weight matrix to determine the template prediction value corresponding to the third candidate prediction mode may include:
[0216] Determine the second weight matrix of the current block; determine the predicted value of the second left template based on the second weight matrix and the reference sample of the second left template; determine the predicted value of the second upper template based on the second weight matrix and the reference sample of the second upper template; determine the template predicted value corresponding to the third candidate prediction mode based on the predicted value of the second left template and / or the predicted value of the second upper template.
[0217] In the embodiments of this application, the second reference template of the current block may only include the reference sample of the second left template, in which case the template prediction value corresponds only to the prediction value of the second left template; or it may only include the reference sample of the second top template, in which case the template prediction value corresponds only to the prediction value of the second top template; or it may simultaneously include the reference sample of the second left template and the reference sample of the second top template, in which case the template prediction value may be composed of the prediction value of the second left template and the prediction value of the second top template; no limitations are imposed here.
[0218] It should also be noted that, in the embodiments of this application, both the first weight matrix and the second weight matrix are pre-trained based on specific block shapes and intra-frame prediction modes. Specifically, if the first candidate prediction mode and the second candidate prediction mode belong to different intra-frame prediction modes, then the obtained first weight matrix and second weight matrix can be different; if the first candidate prediction mode and the second candidate prediction mode belong to the same intra-frame prediction mode and have the same block shape, then the obtained first weight matrix and second weight matrix can also be the same.
[0219] In one possible implementation, taking the first prediction mode combination as an example, which includes two candidate prediction modes (i.e., prediction mode A and prediction mode B), it is assumed that the current block is divided into two parts, and prediction mode A and prediction mode B are used for prediction respectively. Furthermore, the weight values of these two parts can be calculated by minimizing the MSE (Mean Sequence Equation) using the template prediction values and template reconstruction values corresponding to prediction mode A and prediction mode B in the template region. If the first prediction block PredA is obtained by a prediction method based on the weight matrix, the aforementioned method can be used to calculate the prediction value of prediction mode A in the template region and derive the weights.
[0220] Exemplarily, the template regions for deriving weights are defined as x = 0..(W - 1), y = -tempH..-1 and x = -tempW..-1, y = 0..(H - 1), and the predicted value PredA_temp of the prediction mode A in the template region can be obtained:
[0221] The predicted value PredB_temp of the prediction mode B in the template region can be obtained according to the prediction mode B.
[0222] In this way, after determining the template prediction values corresponding to each of the at least two candidate prediction modes, at least one set of training samples can be determined according to the template prediction values corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region, and the corresponding first candidate model parameters can be derived therefrom. Exemplarily, for any position x = i, y = j within the template region, an equation (or it can also be called a training sample) can be established as follows: α*diff(i,j)*i + β*diff(i,j)*j + C*diff(i,j) = reco(i,j) - PredA_temp(i,j) (13)
[0223] Where diff(x,y) = PredB_temp(i,j) - PredA_temp(i,j). According to all the training samples within the template region, the first candidate model parameters, such as α, β, and C, can be obtained by solving based on the MSE method.
[0224] After deriving the corresponding first candidate model parameters α, β, and C, the candidate weight information corresponding to the first prediction mode combination can be determined according to the first candidate model parameters α, β, and C. Exemplarily, the weight information w0(x,y) and w1(x,y) corresponding to the first prediction block PredA and the second prediction block PredB can be expressed as: w0(x,y) = (1<<shift) - w1(x,y); w1(x,y) = α*x + β*y + C. Where shift is a predefined integer value representing the precision of the weight (the precision is 1 / (1<<shift)).
[0225] It can also be understood that when the SGPM based on derivation is used for prediction in the current block, the above weight derivation process can be combined with the template error calculation process. In one possible implementation, the weight information is first derived, and then the template error value is calculated based on the weight.
[0226] In some embodiments, determining a second candidate list for the current block based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations may include: determining at least one set of second candidate prediction information based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations, wherein the second candidate prediction information includes at least two candidate prediction modes contained in a prediction mode combination and candidate weight information derived from the prediction mode combination; calculating template error for the template region of the current block based on at least one set of second candidate prediction information to determine the template error value corresponding to each of the at least one set of second candidate prediction information; sorting the at least one set of second candidate prediction information in ascending order based on the template error value, and forming a second candidate list for the current block from the top N2 sets of second candidate prediction information; wherein N2 is a positive integer.
[0227] It should be noted that, in this embodiment, at least one set of second candidate prediction information can be obtained by combining the candidate intra-prediction modes, candidate vector parameters (including BV, MV, etc.), and candidate weight information. Based on this at least one set of second candidate prediction information, a second initial list for the current block, i.e., the initial RSGPM candidate list rsgpmCandidateList, can be constructed. The second candidate prediction information may include at least two candidate prediction modes and corresponding candidate weight information contained in a prediction mode combination. These at least two candidate prediction modes can be determined based on traditional intra-prediction modes, block copy prediction modes, etc.
[0228] It should also be noted that, in the embodiments of this application, a template error value can be calculated for each group of second candidate prediction information, and then at least one group of second candidate prediction information in the second initial list is reordered according to the template error value, and the N2 groups of second candidate prediction information that are ranked first are used to form the second candidate list rsgpmList of the current block.
[0229] In some embodiments, performing template error calculation on the template region of the current block based on at least one set of second candidate prediction information, and determining the template error value corresponding to each of the at least one set of second candidate prediction information, may include:
[0230] The template region of the current block is predicted based on at least two candidate prediction modes in the second candidate prediction information, and the template prediction value corresponding to each of the at least two candidate prediction modes is determined. The template error is calculated based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region, and the template error value corresponding to the second candidate prediction information is determined.
[0231] It should be noted that, in the embodiments of this application, for at least two candidate prediction modes in the second candidate prediction information, the corresponding template error value can be calculated based on the prediction method of the weight matrix. Furthermore, the template prediction value of at least some of these at least two candidate prediction modes can also be obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0232] In some embodiments, predicting the template region of the current block based on at least two candidate prediction patterns in the second candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, may include:
[0233] When the fifth candidate prediction mode among at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value corresponding to the fifth candidate prediction mode.
[0234] When the sixth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the sixth candidate prediction mode, and the template prediction value corresponding to the sixth candidate prediction mode is determined.
[0235] It should be noted that, in the embodiments of this application, the fifth candidate prediction mode can be a candidate prediction mode that meets preset conditions from at least two candidate prediction modes of the second candidate prediction information, and the sixth candidate prediction mode can be a candidate prediction mode that does not meet preset conditions from at least two candidate prediction modes of the second candidate prediction information. The fifth candidate prediction mode meeting preset conditions may include: the fifth candidate prediction mode being an intra-frame prediction mode and meeting the conditions for using PDP prediction. In this case, the template prediction value under the fifth candidate prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0236] In one possible implementation, taking the second candidate prediction information as including two candidate prediction modes (i.e., prediction mode A and prediction mode B) as an example, assuming the current block is divided into two parts, prediction mode A and prediction mode B are used respectively to obtain the first prediction block PredA and the second prediction block PredB. The final prediction sample can be a weighted combination of PredA and PredB. If the first prediction block PredA (or the second prediction block PredB) is obtained by a prediction method based on the weight matrix, its template prediction value in the template region can also be obtained by a prediction method based on the weight matrix. For example, the prediction value PredA_temp of prediction mode A in the template region can be as shown in the aforementioned formula (12).
[0237] In some embodiments, calculating the template error based on the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction values of the template region, and determining the template error value corresponding to the second candidate prediction information, may include:
[0238] Based on the candidate weight information in the second candidate prediction information, determine the weight values corresponding to at least two candidate prediction modes; based on the template prediction values and template reconstruction values of the template regions corresponding to at least two candidate prediction modes, determine the error values corresponding to at least two candidate prediction modes; perform weighted calculations based on the error values and weight values corresponding to at least two candidate prediction modes to obtain the template error value corresponding to the second candidate prediction information.
[0239] In this embodiment, the template error value can be calculated using methods such as MSE, SAD, and SATD. In one possible implementation, taking SAD as an example, the template error value corresponding to the second candidate prediction information can be calculated by combining the aforementioned formulas (9) to (11). Thus, according to the aforementioned template error calculation process, at least one set of template error values corresponding to each of the second candidate prediction information can be obtained; then, these at least one set of second candidate prediction information are sorted from smallest to largest according to the template error values, and the top N2 sets of second candidate prediction information are used to form the second candidate list of the current block.
[0240] In other words, in this embodiment, by calculating candidate weight information and template error values according to the above-mentioned PDP prediction method, the processes of candidate weight information, template error calculation, and candidate list reordering corresponding to each second candidate prediction information under GPM and SGPM modes are realized. Since the prediction method based on the weight matrix can be used not only in the prediction process of the current block, but also for candidate weight information and template error calculation, the template prediction value can be determined by the prediction method based on the weight matrix, the prediction accuracy is further improved.
[0241] It is also understandable that, in the embodiments of this application, considering computational complexity, a prediction method based on a weight matrix can be used for simplification. Here, using PDP prediction instead of the traditional prediction mode to predict the template region of the current block maintains consistency with the prediction process of the current block, thereby improving prediction accuracy. In addition, the complexity of PDP prediction is higher than that of the traditional prediction mode, which leads to an increase in decoding time. Therefore, the embodiments of this application can conditionally use PDP prediction.
[0242] In one possible implementation, at least one set of candidate prediction information can be initially screened based on the template error obtained from the traditional prediction model, and then the template error value under PDP prediction can be calculated only for the candidates with smaller template error values.
[0243] In some embodiments, the method for determining the first candidate list may further include: predicting the template region of the current block based on a first prediction method to determine a first template error value corresponding to each of at least one set of first candidate prediction information; sorting the at least one set of first candidate prediction information in ascending order according to the first template error value to determine at least two sets of candidate prediction information that are ranked first; predicting the template region of the current block based on a prediction method of a weight matrix to determine a second template error value corresponding to each of at least two sets of candidate prediction information; and sorting the at least two sets of candidate prediction information in ascending order according to the second template error value to form the first candidate list of the current block from the N1 sets of candidate prediction information that are ranked first.
[0244] In some embodiments, the method for determining the second candidate list may further include: predicting the template region of the current block based on a first prediction method to determine a first template error value corresponding to each of at least one set of second candidate prediction information; sorting the at least one set of second candidate prediction information from smallest to largest according to the first template error value to determine at least two sets of candidate prediction information that are ranked first; predicting the template region of the current block based on a prediction method of a weight matrix to determine a second template error value corresponding to each of at least two sets of candidate prediction information; sorting the at least two sets of candidate prediction information from smallest to largest according to the second template error value to form the second candidate list of the current block from the top N2 sets of candidate prediction information.
[0245] In this embodiment, the first prediction method does not include a prediction method based on a weight matrix. For example, the first prediction method can be a traditional prediction mode. That is, after obtaining at least one set of candidate prediction information (first candidate prediction information or second candidate prediction information), this embodiment can first calculate the corresponding first template error value according to the traditional prediction mode, retain at least two sets of candidate prediction information with the smallest template error, for example, retaining Q sets of candidate prediction information with the smallest template error; then, for the retained Q sets of candidate prediction information, calculate the corresponding second template error value according to the PDP prediction method, and finally reorder according to the second template error value. Here, the value of Q is greater than or equal to N1 (or N2), without any limitation.
[0246] In one possible implementation, predicting the template region of the current block based on the weight matrix prediction method and determining the second template error value corresponding to each of at least two sets of candidate prediction information may include: predicting the template region of the current block based on the weight matrix prediction method and determining the third template error value corresponding to each of K sets of candidate prediction information from at least two sets of candidate prediction information; where K is a positive integer; updating the first template error value corresponding to each of at least two sets of candidate prediction information according to the third template error value corresponding to each of the K sets of candidate prediction information, and determining the second template error value corresponding to each of at least two sets of candidate prediction information.
[0247] In this embodiment, for K groups of candidate prediction information, the first m groups of candidate prediction information among at least two groups of candidate prediction information may be determined as K groups of candidate prediction information when they meet a preset condition. Alternatively, any group of candidate prediction information among the first m groups among at least two groups of candidate prediction information may be determined as K groups of candidate prediction information when it meets the preset condition.
[0248] For example, taking the current block as an example of prediction using SGPM, a first initial list, namely the SGPM candidate list sgpmCandidateList, with a length of L1, can be constructed based on the candidate intra-prediction modes, candidate block vectors, and candidate partitioning methods. Each candidate prediction information includes (prediction mode A, prediction mode B, and partitioning method splitDir). The template error value corresponding to each candidate prediction information can be calculated based on traditional prediction modes such as traditional intra-prediction modes and block copy prediction modes (if prediction mode A or prediction mode B corresponds to block copy prediction). From this, Q groups of candidate prediction information with the smallest template error can be retained. Wherein, if the value of Q is equal to N1, the retained Q groups of candidate prediction information can be used to form the first candidate list sgpmList for the current block. Then, based on the PDP prediction method, the template error value of K groups of candidate prediction information in the first candidate list is recalculated, and the reordering is performed according to the recalculated template error value. Alternatively, if the value of Q is greater than N1, then the template error value is recalculated for K groups of candidate prediction information in these Q groups of candidate prediction information based on the PDP prediction method, and the reordering is performed according to the recalculated template error value. Finally, the top N1 groups of candidate prediction information are used to form the first candidate list sgpmList of the current block.
[0249] In one possible implementation, assuming Q equals N1, the template error values calculated using the traditional prediction model are reordered, and the remaining Q groups of candidate prediction information can form the first candidate list sgpmList for the current block. One approach to template prediction using PDP prediction is to recalculate the template error values for the first m candidates in the first candidate list sgpmList using PDP prediction. Another possible option is to perform the aforementioned PDP prediction and recalculate the template error values for the first m candidates in the first candidate list sgpmList whose prediction models satisfy the conditions for using PDP prediction.
[0250] It should also be noted that, in some embodiments of this application, when recalculating the third template error value corresponding to each of the K groups of candidate prediction information based on the PDP prediction method, the method may further include: determining the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information.
[0251] For example, taking the i-th candidate prediction information as an example, the first template error value predicted based on the traditional prediction mode is sgpmCost[i]. If any of its prediction modes meets the conditions for using PDP prediction, then based on the PDP prediction method, the corresponding third template error value SadA_B_splitDir is predicted. Then, the final second template error value can be set to be equal to the third template error value SadA_B_splitDir, that is, sgpmCost[i]=SadA_B_splitDir.
[0252] In some embodiments, the method may further include: determining the minimum value of the first template error value and the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information, based on the first template error value and the third template error value corresponding to each of the K groups of candidate prediction information.
[0253] For example, taking the i-th candidate prediction information as an example, the first template error value predicted based on the traditional prediction mode is sgpmCost[i]. If any prediction mode satisfies the PDP prediction usage conditions, then based on the PDP prediction method, the corresponding third template error value SadA_B_splitDir is predicted. Then, the final second template error value can be set to the minimum of the first template error value sgpmCost[i] and the third template error value SadA_B_splitDir, i.e., sgpmCost[i] = min(sgpmCost[i], SadA_B_splitDir). In other words, the original template error value is only replaced when the template error value predicted by PDP is smaller.
[0254] In another possible implementation, instead of performing initial screening on at least one set of candidate prediction information, PDP prediction can be performed on only a portion of the candidate prediction information from this at least one set of candidate prediction information, and the template error value can be updated.
[0255] In some embodiments, the method may further include: predicting the template region of the current block based on a prediction method using a weight matrix, and determining the third template error value corresponding to each of the top K1 groups of first candidate prediction information in at least one group of first candidate prediction information; wherein K1 is a positive integer; updating the first template error value corresponding to each of the at least one group of first candidate prediction information according to the third template error value corresponding to each of the K1 groups of first candidate prediction information, and determining the second template error value corresponding to each of the at least one group of first candidate prediction information; sorting the at least one group of first candidate prediction information in ascending order according to the second template error value, and forming the first candidate list of the current block from the top N1 groups of first candidate prediction information.
[0256] In this embodiment, a first initial list, namely the SGPM candidate list sgpmCandidateList, can be constructed based on the candidate intra-prediction modes, candidate block vectors, and candidate partitioning methods. Here, PDP prediction can be performed on a subset of the candidate prediction information in the first initial list. For example, the process of performing PDP prediction and updating the template error value can be performed only on the first candidate prediction information in the first K1 groups of sgpmCandidateList whose prediction modes meet the PDP prediction usage conditions.
[0257] In some embodiments, the method may further include: predicting the template region of the current block based on a prediction method using a weight matrix, and determining the third template error value corresponding to each of the top K2 groups of second candidate prediction information in at least one group of second candidate prediction information; wherein K2 is a positive integer; updating the first template error value corresponding to each of the at least one group of second candidate prediction information according to the third template error value corresponding to each of the K2 groups of second candidate prediction information, and determining the second template error value corresponding to each of the at least one group of second candidate prediction information; sorting the at least one group of second candidate prediction information in ascending order according to the second template error value, and forming the second candidate list of the current block from the top N2 groups of second candidate prediction information.
[0258] In this embodiment, a second initial list, namely the RSGPM candidate list rsgpmCandidateList, can be constructed based on the candidate intra-prediction modes, candidate block vectors, and derived candidate weight information. Here, PDP prediction can be performed on a subset of the candidate prediction information in the second initial list. For example, the process of performing PDP prediction and updating the template error value can be performed only on the second candidate prediction information in the first K2 groups of rsgpmCandidateList where any prediction mode meets the PDP prediction usage conditions.
[0259] For example, in related technologies, SGPM can construct an SGPM candidate list sgpmCandidateList with a length of L1 based on the candidate intra-prediction mode, candidate block vector, and candidate partitioning method. Each candidate prediction information includes (prediction mode A, prediction mode B, and partitioning method splitDir). The template error value corresponding to each candidate prediction information can be calculated based on traditional prediction modes such as traditional intra-prediction mode and block copy prediction mode (if prediction mode A or prediction mode B corresponds to block copy prediction). From this, N1 sets of candidate prediction information with the smallest template error can be retained to form the first candidate list sgpmList for the current block. SGPM in related technologies can also use derivation-based SGPM prediction. Based on the candidate intra-prediction mode and candidate block vector, an RSGPM candidate list rsgpmCandidateList with a length of L2 can be constructed. Each candidate prediction information includes (prediction mode A, prediction mode B, and derivational weight information w0 (or w1)). Similar to the above process, the template error value corresponding to each candidate prediction information can be calculated based on traditional intra-frame prediction mode, block copy prediction mode, etc. From this, the N2 groups of candidate prediction information with the smallest template error can be retained to form the second candidate list RSGPM list rsgpmList for the current block. rsgpmList and sgpmList can be merged to obtain the final candidate list sgpmList'. In sgpmList', the first N2 groups of candidate prediction information correspond to rsgpmList, and the last N1 groups of candidate prediction information correspond to sgpmList.
[0260] It is also understood that, in the embodiments of this application, the prediction information of the current block may include weight information in addition to at least two prediction modes. In another possible implementation, determining the prediction information of the current block based on the template prediction value of the current block may include: determining the weight information of the current block based on the template prediction value of the current block.
[0261] In some embodiments, referring to FIG16, after step S1301, the method may further include:
[0262] S1601, when the first syntax element indicates that the current block uses a geometric partitioning mode for prediction, determine the template prediction values of the current block in at least two prediction modes corresponding to the geometric partitioning mode.
[0263] S1602, determine at least one set of training samples based on the template prediction values and template reconstruction values of the template regions in at least two prediction modes.
[0264] S1603, determine the model parameters of the preset weight model based on at least one set of training samples.
[0265] S1604, determine the weight information of the current block according to the model parameters of the preset weight model.
[0266] It should be noted that, in the embodiments of this application, for at least two prediction modes corresponding to the geometric partitioning pattern, or in other words, at least two prediction modes used by the current block, the template prediction values of at least some of the candidate prediction modes in these at least two prediction modes are obtained by predicting the template region of the current block based on the prediction method of the weight matrix. In some embodiments, the method may further include:
[0267] When the first prediction mode in at least two prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value under the first prediction mode.
[0268] When the second prediction mode in at least two prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second prediction mode to determine the template prediction value under the second prediction mode.
[0269] It should be noted that, in the embodiments of this application, the first prediction mode can be a prediction mode that meets preset conditions among at least two prediction modes, and the second prediction mode can be a prediction mode that does not meet preset conditions among at least two prediction modes. The first prediction mode meeting preset conditions may include: the first prediction mode being an intra-frame prediction mode and meeting the conditions for using PDP prediction. In this case, the template prediction value in the first prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0270] It should also be noted that, in one possible implementation, the conditions for using PDP prediction may include: the size of the current block meets the size requirements. For example, PDP prediction is only applied to blocks of a certain size, such as blocks whose width and height are both no greater than 32, or blocks whose width and height are both no greater than 32 except for 4x32, 32x4, 8x32, and 32x8.
[0271] In this way, after determining the template prediction values corresponding to each of the at least two prediction patterns, at least one set of training samples can be determined based on the template prediction values corresponding to each of the at least two prediction patterns and the template reconstruction value of the template region, thereby deriving the model parameters of the current block. Exemplarily, for any position x = i, y = j within the template region, an equation (or which can also be referred to as a training sample) can be established, as shown in the aforementioned formula (13). Among them, diff(x,y) = PredB_temp(i,j) - PredA_temp(i,j). Based on all the training samples within the template region, the model parameters of the current block, such as α, β, and C, can be obtained by solving using the MSE method.
[0272] After deriving the model parameters α, β, and C of the current block, the weight information of the current block can be determined according to the model parameters α, β, and C. Exemplarily, the weight information w0(x,y) and w1(x,y) corresponding to the first prediction block PredA and the second prediction block PredB can be expressed as: w0(x,y) = (1 << shift) - w1(x,y); w1(x,y) = α * x + β * y + C. Among them, shift is a predefined integer value representing the precision of the weight (the precision is 1 / (1 << shift)).
[0273] S1303, perform prediction on the current block according to the prediction information to determine the prediction sample of the current block.
[0274] It should be noted that in the embodiments of this application, the prediction information of the current block can at least include: at least two prediction patterns corresponding to the geometric partitioning pattern. In some embodiments, performing prediction on the current block according to the prediction information to determine the prediction sample of the current block can include: when at least some of the at least two prediction patterns meet the preset conditions, determining the prediction samples corresponding to at least some of the prediction patterns based on the prediction method of the weight matrix; determining the prediction sample of the current block according to the prediction samples corresponding to at least some of the prediction patterns.
[0275] It should also be noted that in the embodiments of this application, the at least two prediction patterns can be divided into at least some prediction patterns that meet the preset conditions and the remaining part of the prediction patterns that do not meet the preset conditions. In some embodiments, the method can further include: when the remaining part of the prediction patterns among the at least two prediction patterns do not meet the preset conditions, performing prediction on the current block according to the remaining part of the prediction patterns to determine the prediction samples corresponding to the remaining part of the prediction patterns. Here, since the remaining part of the prediction patterns does not meet the preset conditions, that is, the remaining part of the prediction patterns cannot use PDP prediction, the prediction method of the related technology is still used to determine the prediction samples corresponding to the remaining part of the prediction patterns.
[0276] In some embodiments, for determining the prediction samples of the current block, it may include: determining the prediction samples of the previous block according to the prediction samples corresponding to at least part of the prediction modes and the prediction samples corresponding to the remaining part of the prediction modes.
[0277] In some embodiments, the prediction information of the current block may further include weight information. Determining the prediction samples of the previous block according to the prediction samples corresponding to at least part of the prediction modes and the prediction samples corresponding to the remaining part of the prediction modes may include: determining the weight values corresponding to at least two prediction modes according to the weight information; performing a weighted operation on the prediction samples corresponding to at least part of the prediction modes and the prediction samples corresponding to the remaining part of the prediction modes according to these weight values to determine the prediction samples of the current block.
[0278] It should be noted that in the embodiments of the present application, if the weight information is the partitioning method used for the current block, then the weight values corresponding to at least two prediction modes can be determined according to the partitioning method used for the current block; if the weight information is the weight information derived for the current block, the weight values corresponding to at least two prediction modes are determined according to the weight information derived for the current block.
[0279] In a possible implementation manner, if w0(x, y) = (1 << shift) - w1(x, y); w1(x, y) = α * x + β * y + C; then the prediction samples of the current block can be expressed as: Pred(x, y) = (w0(x, y) * PredA(x, y) + w1(x, y) * PredB(x, y) + (1 << (shift - 1))) >> shift (14)
[0280] It should also be noted that in the embodiments of the present application, after obtaining the prediction samples of the current block, the method may further include: parsing the residual samples of the current block in the code stream; determining the reconstructed samples of the current block according to the prediction samples of the current block and the residual samples of the current block. Here, by performing an addition operation on the prediction samples of the current block and the residual samples of the current block, the reconstructed samples of the current block can be obtained, thereby implementing the reconstruction process of the current block.
[0281] It should also be noted that in the embodiments of the present application, the current block is predicted through multiple prediction modes to obtain multiple first prediction values, and then the final prediction value of the current block is obtained by performing a weighted calculation on the obtained multiple first prediction values. As long as any one of these multiple prediction modes is an intra prediction mode and meets the PDP prediction usage conditions, the method of the embodiments of the present application can be applied.
[0282] This application provides a decoding method that parses a first syntax element in a bitstream; when the first syntax element indicates that the current block is predicted using a geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on a weight matrix prediction method; the current block is predicted based on the prediction information to determine the prediction sample of the current block. Thus, when the current block uses geometric partitioning modes such as GPM or SGPM, not only can a weight matrix-based prediction method be used during the prediction process, but also in determining the prediction information of the current block, the same weight matrix-based prediction method can be used to determine the template prediction value of the current block for steps such as calculating the template error and deriving weight information. This makes the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, increasing decoding efficiency, and ultimately improving decoding performance.
[0283] In another embodiment of this application, FIG17 is a flowchart illustrating an encoding method provided by an embodiment of this application. As shown in FIG17, the method may include:
[0284] S1701, when the current block is predicted using the geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0285] It should be noted that in this embodiment, the method is applied to the encoder, mainly to the intra-prediction part in Figure 11 (marked with a bold box). Specifically, when intra-prediction is used in the current block, this mainly refers to the optimization scheme proposed for the geometric partitioning mode based on matrix prediction, which can improve coding efficiency.
[0286] It should also be noted that, in this embodiment, whether the current block is predicted using a geometric partitioning mode can be indicated by syntax elements or flags in the bitstream. For example, a first syntax element can be used to indicate whether the current block is predicted using a geometric partitioning mode. In some embodiments, the method may further include: determining the value of the first syntax element; encoding the value of the first syntax element; and writing the obtained encoded bits into the bitstream.
[0287] In this embodiment, if the current block is predicted using a geometric partitioning pattern, then the value of the first syntax element can be determined to be a first value; if the current block is not predicted using a geometric partitioning pattern, then the value of the first syntax element can be a second value. Here, the first value and the second value are different. In one possible implementation, the first value can be true and the second value can be false; or, the first value can be 1 and the second value can be 0; no limitations are imposed here.
[0288] In one possible implementation, the current block has at least two candidate prediction modes, and the at least two candidate prediction modes include a geometric partitioning mode. The method may further include: calculating the encoding cost for the at least two candidate prediction modes to determine the cost result corresponding to the at least two candidate prediction modes; when the cost result corresponding to the geometric partitioning mode is the minimum cost result, determining that the current block uses the geometric partitioning mode for prediction, in which case the value of the first syntax element is a first value; when the cost result corresponding to the geometric partitioning mode is not the minimum cost result, determining that the current block does not use the geometric partitioning mode for prediction, in which case the value of the first syntax element is a second value.
[0289] In other words, in this embodiment, some indication information in the form of syntax elements can be written into the bitstream. Thus, the subsequent decoding end can determine the prediction mode used by the current block by parsing the value of the first syntax element in the bitstream.
[0290] It should also be noted that, in the embodiments of this application, the first syntax element is a block-level syntax element (or "CU-level syntax element"), and the geometric partitioning mode can refer to GPM, SGPM, etc. In one possible implementation, the first syntax element can be represented by cu_gpm_flag, which indicates whether the current block uses GPM for prediction. Alternatively, the first syntax element can also be represented by cu_sgpm_flag, which indicates whether the current block uses SGPM for prediction.
[0291] Understandably, in the embodiments of this application, if the current block is predicted using a geometric partitioning mode, then the current block can be divided into at least two parts according to the geometric partitioning mode, and each part corresponds to a prediction mode; therefore, the prediction information obtained under the geometric partitioning mode may include at least two prediction modes, and the template prediction value under at least some of the prediction modes is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0292] In one possible implementation, to determine the prediction information for the current block, a candidate list can be constructed first, and then the prediction information for the current block can be determined from it. In some embodiments, determining the prediction information for the current block based on the template prediction value of the current block may include: determining a candidate list for the current block based on the template prediction value of the current block; and determining the prediction information for the current block based on the candidate list.
[0293] In embodiments of this application, the candidate list includes at least one set of candidate prediction information. In some embodiments, determining the prediction information of the current block based on the candidate list of the current block may include: calculating the encoding cost of the current block using at least one set of candidate prediction information in the candidate list, and determining the cost result corresponding to at least one set of candidate prediction information; determining the minimum cost result from the cost results corresponding to at least one set of candidate prediction information, and determining the candidate prediction information corresponding to the minimum cost result as the prediction information of the current block.
[0294] It should be noted that, in the embodiments of this application, for at least one set of candidate prediction information in the candidate list, after calculating the encoding cost of the current block for the at least one set of candidate prediction information, the minimum cost result can be determined from the cost results corresponding to the at least one set of candidate prediction information, and the candidate prediction information corresponding to the minimum cost result can be determined as the prediction information of the current block.
[0295] It should also be noted that, in the embodiments of this application, the encoding cost calculation can be rate-distortion cost calculation, or it can be other distortion cost calculation, such as mean absolute error (MAE), mean square error (MSE), etc., and no limitation is made here.
[0296] In some embodiments, after determining the prediction information of the current block, the method may further include: determining the prediction mode index of the current block; encoding the prediction mode index of the current block; and writing the obtained encoded bits into the bitstream.
[0297] In this embodiment, the prediction mode index is used to indicate the index number of the prediction information of the current block in the candidate list. Thus, after the prediction mode index is written into the bitstream, the subsequent decoding end can directly obtain the prediction mode index by parsing the bitstream. Based on the prediction mode index and the candidate list of the current block, the prediction information of the current block can be determined.
[0298] It should also be noted that, in this embodiment, the prediction mode index can be a single syntax element or multiple syntax elements, based on the prediction information of the current block. For example, as shown in Table 3, the prediction mode index can be composed of multiple syntax elements, such as `partition_mode_idx`, `intra_pred_mode0_idx`, and `intra_pred_mode1_idx`. To reduce the overhead of this information, these mode indices can be combined into a single syntax element. As shown in Table 4, the prediction mode index can be just one syntax element, such as `sgpm_cand_idx`. In this case, only this single syntax element `sgpm_cand_idx` is written into the bitstream, and the decoder can still obtain the values of syntax elements such as `partition_mode_idx`, `intra_pred_mode0_idx`, and `intra_pred_mode1_idx`.
[0299] In one possible implementation, if the current block is predicted using SGPM, the prediction mode index can be represented by cu_sgpm_idx, and the candidate list of the current block can be represented by sgpmList'; then, based on the prediction mode index cu_sgpm_idx in the bitstream, the prediction information of the current block obtained is sgpmList'[cu_sgpm_idx].
[0300] In other words, in this embodiment, after determining the value of the first syntax element cu_sgpm_flag, the value of the first syntax element cu_sgpm_flag can be written into the bitstream. If the value of the first syntax element cu_sgpm_flag is true, that is, the current block uses the geometric partitioning mode for prediction, then the prediction mode index cu_sgpm_idx of the current block can also be determined, and the prediction mode index cu_sgpm_idx of the current block can be written into the bitstream. In this way, after the subsequent decoding end obtains the prediction mode index cu_sgpm_idx of the current block through decoding, it can combine it with the constructed candidate list sgpmList' to determine the prediction information of the current block as sgpmList'[cu_sgpm_idx].
[0301] The following description uses SGPM prediction for the current block as an example to illustrate the construction of the candidate list.
[0302] In one possible implementation, determining the candidate list of the current block includes: determining at least one set of prediction mode combinations, wherein each set of prediction mode combinations includes at least two candidate prediction modes; determining a first candidate list of the current block based on the at least one set of prediction mode combinations and at least one candidate partitioning method; and determining the candidate list of the current block based on the first candidate list.
[0303] In this embodiment, when using SGPM for prediction of the current block, a first candidate list sgpmList for the current block can be constructed; then, based on the first candidate list sgpmList, the candidate list for the current block is determined. In this implementation, each set of candidate prediction information may include: at least two candidate prediction modes included in the prediction mode combination and a candidate partitioning method. For example, assuming the prediction mode combination includes two candidate prediction modes, then for each set of candidate prediction information, it may include: partition_mode_idx, intra_pred_mode0_idx, and intra_pred_mode1_idx.
[0304] In another possible implementation, determining the candidate list for the current block includes: determining at least one set of prediction mode combinations, each set of prediction mode combinations including at least two candidate prediction modes; determining a second candidate list for the current block based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations; and determining the candidate list for the current block based on the second candidate list.
[0305] In this embodiment, when the current block is predicted using derived SGPM (i.e., RSGPM), a second candidate list rsgpmList for the current block can be constructed; then, based on the second candidate list rsgpmList, the candidate list for the current block is determined. In this implementation, each set of candidate prediction information may include: at least two candidate prediction modes included in the prediction mode combination and derived candidate weight information. For example, assuming the prediction mode combination includes two candidate prediction modes, then for each set of candidate prediction information, it may include: intra_pred_mode0_idx, intra_pred_mode1_idx, and a derived blending matrix.
[0306] In another possible implementation, determining the candidate list of the current block includes: determining at least one set of prediction mode combinations, wherein each set of prediction mode combinations includes at least two candidate prediction modes; determining a first candidate list of the current block based on at least one set of prediction mode combinations and at least one candidate partitioning method; determining a second candidate list of the current block based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode groups; and determining the candidate list of the current block based on the first candidate list and the second candidate list.
[0307] In this embodiment, the candidate list for the current block can be obtained by combining a first candidate list sgpmList and a second candidate list rsgpmList. In one possible implementation, in the candidate list sgpmList' of the current block, the candidate prediction information in the second candidate list rsgpmList precedes the candidate prediction information in the first candidate list sgpmList.
[0308] For example, assuming the first candidate list sgpmList includes N1 sets of candidate prediction information and the second candidate list rsgpmList includes N2 sets of candidate prediction information, then the first N2 sets of candidate prediction information in the candidate list sgpmList' of the current block correspond to the second candidate list rsgpmList, and the last N1 sets of candidate prediction information correspond to the first candidate list sgpmList.
[0309] Understandably, when using SGPM for prediction in the current block, a first candidate list (sgpmList) can be constructed. In some embodiments, determining the first candidate list for the current block based on at least one combination of prediction modes and at least one candidate partitioning method may include: determining at least one set of first candidate prediction information based on at least one combination of prediction modes and at least one candidate partitioning method; calculating template error for the template region of the current block based on the at least one set of first candidate prediction information to determine the template error value corresponding to each of the at least one set of first candidate prediction information; sorting the at least one set of first candidate prediction information in ascending order based on the template error value, and forming the first candidate list for the current block from the top N1 sets of first candidate prediction information; where N1 is a positive integer.
[0310] It should be noted that, in the embodiments of this application, at least one set of first candidate prediction information can be obtained by combining the candidate intra-prediction modes, candidate vector parameters (including BV, MV, etc.) and candidate partitioning methods; based on this at least one set of first candidate prediction information, a first initial list for the current block, i.e., the initial SGPM candidate list sgpmCandidateList, can be constructed. The first candidate prediction information may include at least two candidate prediction modes and one candidate partitioning method contained in a set of prediction mode combinations. The at least two candidate prediction modes can be determined based on traditional intra-prediction modes, block copying prediction modes, etc.
[0311] It should also be noted that, in the embodiments of this application, a template error value can be calculated for each group of first candidate prediction information, and then at least one group of first candidate prediction information in the first initial list is reordered according to the template error value, and the N1 groups of first candidate prediction information that are ranked first are used to form the first candidate list sgpmList of the current block.
[0312] In some embodiments, performing template error calculation on the template region of the current block based on at least one set of first candidate prediction information, and determining the template error value corresponding to each of the at least one set of first candidate prediction information, may include:
[0313] The template region of the current block is predicted based on at least two candidate prediction modes in the first candidate prediction information, and the template prediction value corresponding to each of the at least two candidate prediction modes is determined. The template error is calculated based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region, and the template error value corresponding to the first candidate prediction information is determined.
[0314] It should be noted that, in this embodiment, for at least two candidate prediction modes in the first candidate prediction information, the corresponding template error value can be calculated based on the prediction method of the weight matrix. Specifically, the template prediction value of at least some of these at least two candidate prediction modes is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0315] In some embodiments, predicting the template region of the current block based on at least two candidate prediction patterns in the first candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, may include:
[0316] When the first candidate prediction mode among at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value corresponding to the first candidate prediction mode.
[0317] If the second candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second candidate prediction mode to determine the template prediction value corresponding to the second candidate prediction mode.
[0318] It should be noted that, in the embodiments of this application, the first candidate prediction mode can be a candidate prediction mode that meets the preset conditions among at least two candidate prediction modes of the first candidate prediction information, and the second candidate prediction mode is a candidate prediction mode that does not meet the preset conditions among at least two candidate prediction modes of the first candidate prediction information.
[0319] It should also be noted that, in the embodiments of this application, the first candidate prediction mode meeting preset conditions may include: the first candidate prediction mode is an intra-frame prediction mode and meets the PDP prediction usage conditions. In one possible implementation, the PDP prediction usage conditions may include: the size of the current block meets the size requirements. For example, PDP prediction is only applied to blocks of a certain size, such as blocks whose width and height are both no greater than 32, or blocks whose width and height are both no greater than 32 except for 4x32, 32x4, 8x32, and 32x8. In this case, the template prediction value in the first candidate prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0320] In one possible implementation, assuming the current block is divided into two parts, prediction is performed using prediction mode A and prediction mode B respectively, resulting in a first prediction block PredA and a second prediction block PredB. The final prediction sample can be a weighted combination of PredA and PredB. If the first prediction block PredA (or the second prediction block PredB) is obtained by a prediction method based on the weight matrix, its template prediction value in the template region can also be obtained by a prediction method based on the weight matrix. For example, assuming the top-left corner coordinate of the current block is (0,0), then the first prediction block PredA can be represented as shown in the aforementioned formula (6).
[0321] In one possible implementation, taking a first candidate prediction pattern that meets preset conditions as an example, the first reference template of the current block may include a reference sample of the first left template and a reference sample of the first upper template. Correspondingly, in some embodiments, predicting the template region of the current block based on a weight matrix to determine the template prediction value corresponding to the first candidate prediction pattern may include:
[0322] Determine the first weight matrix of the current block; determine the predicted value of the first left template based on the first weight matrix and the reference sample of the first left template; determine the predicted value of the first upper template based on the first weight matrix and the reference sample of the first upper template; determine the template predicted value corresponding to the first candidate prediction mode based on the predicted value of the first left template and / or the predicted value of the first upper template.
[0323] In the embodiments of this application, the first reference template of the current block may only include the reference sample of the first left template, in which case the template prediction value corresponds only to the prediction value of the first left template; or it may only include the reference sample of the first top template, in which case the template prediction value corresponds only to the prediction value of the first top template; or it may simultaneously include the reference sample of the first left template and the reference sample of the first top template, in which case the template prediction value may be composed of the prediction value of the first left template and the prediction value of the first top template; no limitations are made here.
[0324] For example, suppose that at least two candidate prediction modes in the first candidate prediction information may include prediction mode A and prediction mode B, and prediction mode A uses a prediction method based on the weight matrix for template prediction. Here, the prediction value PredA_temp of prediction mode A in the upper template can be expressed as shown in the aforementioned formula (7). Similarly, the prediction value PredA_temp of prediction mode A in the left template can be expressed as shown in the aforementioned formula (8).
[0325] Based on the above process, the predicted values PredA_top and PredA_left of prediction mode A in the upper and left templates can be obtained. These values can be combined with the predicted values PredB_top and PredB_left of prediction mode B in the upper and left templates, and the splitDir partitioning method, to obtain the template error value under the first candidate prediction information (prediction mode A, prediction mode B, and splitDir partitioning method). It should be noted that if prediction mode B also uses the prediction method based on the weight matrix for template prediction, then PredB_top and PredB_left can be calculated based on formulas (7) and (8); if prediction mode B does not use the prediction method based on the weight matrix for template prediction, then PredB_top and PredB_left can be obtained by predicting the template region of the current block based on prediction mode B.
[0326] In some embodiments, calculating the template error based on the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction values of the template region, and determining the template error value corresponding to the first candidate prediction information, may include:
[0327] Based on the candidate division method in the first candidate prediction information, determine the weight values corresponding to at least two candidate prediction modes; based on the template prediction values and template reconstruction values of the template regions corresponding to at least two candidate prediction modes, determine the error values corresponding to at least two candidate prediction modes; perform weighted calculation based on the error values and weight values corresponding to at least two candidate prediction modes to obtain the template error value corresponding to the first candidate prediction information.
[0328] In this embodiment, the template error value can be calculated using methods such as MSE, SAD, and SATD. In one possible implementation, SAD is used as an example to calculate the error value of the prediction pattern A in the upper and left templates. First, the error value wholeSadA of the prediction pattern A under the complete upper and left templates can be expressed as shown in the aforementioned formula (9). The template error of the prediction pattern A combined with the first part of the weights can be expressed as shown in the aforementioned formula (10).
[0329] Similarly, we can obtain the error value wholeSadB of prediction mode B under the complete upper and left templates and the template error partSadB after combining prediction mode B with the first part weight. Then, when the first part uses prediction mode A and the second part uses prediction mode B, the template error value corresponding to the first candidate prediction information can be expressed as shown in the aforementioned formula (11).
[0330] Thus, based on the template error calculation process described above, template error values corresponding to at least one set of first candidate prediction information can be obtained. Then, these at least one set of first candidate prediction information are sorted from smallest to largest according to their template error values, and the top N1 sets of first candidate prediction information form the first candidate list for the current block. In other words, by calculating the template error value in the above manner, the processes of calculating the template error corresponding to each first candidate prediction information and reordering the candidate list are realized in both GPM and SGPM modes. Since the prediction method based on the weight matrix can be used not only in the prediction process of the current block but also in the template error calculation to determine the template prediction value, prediction accuracy is improved.
[0331] It is also understandable that when the current block is predicted using inference-based SGPM, a second candidate list rsgpmList can be constructed, and candidate weight information can be inferred based on the prediction method of the weight matrix.
[0332] In some embodiments, the method may further include: predicting the template region of the current block according to a first prediction mode combination, and determining the template prediction values corresponding to at least two candidate prediction modes included in the first prediction mode combination; determining at least one set of training samples according to the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction value of the template region; determining first candidate model parameters of a preset weight model according to the at least one set of training samples; and determining candidate weight information corresponding to the first prediction mode combination according to the first candidate model parameters; wherein the first prediction mode combination is any one of the at least one set of prediction mode combinations.
[0333] It should be noted that, in the embodiments of this application, taking the at least two candidate prediction modes included in the first prediction mode combination as an example, the template prediction value of at least some of the candidate prediction modes in these at least two candidate prediction modes is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0334] In some embodiments, predicting the template region of the current block based on a first prediction mode combination, and determining the template prediction values corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination, may include:
[0335] When the third candidate prediction mode among at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value corresponding to the third candidate prediction mode.
[0336] When the fourth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the fourth candidate prediction mode to determine the template prediction value corresponding to the fourth candidate prediction mode.
[0337] It should be noted that, in the embodiments of this application, the third candidate prediction mode can be a candidate prediction mode that meets a preset condition from at least two candidate prediction modes in the combination of the first prediction modes, and the fourth candidate prediction mode can be a candidate prediction mode that does not meet the preset condition from at least two candidate prediction modes in the combination of the first prediction modes. The third candidate prediction mode meeting the preset condition may include: the third candidate prediction mode being an intra-frame prediction mode and meeting the conditions for using PDP prediction. In this case, the template prediction value in the third candidate prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0338] In one possible implementation, taking a third candidate prediction mode that meets preset conditions as an example, the second reference template of the current block may include a reference sample of the second left template and a reference sample of the second upper template. Correspondingly, in some embodiments, predicting the template region of the current block based on a weight matrix to determine the template prediction value corresponding to the third candidate prediction mode may include:
[0339] Determine the second weight matrix of the current block; determine the predicted value of the second left template based on the second weight matrix and the reference sample of the second left template; determine the predicted value of the second upper template based on the second weight matrix and the reference sample of the second upper template; determine the template predicted value corresponding to the third candidate prediction mode based on the predicted value of the second left template and / or the predicted value of the second upper template.
[0340] In the embodiments of this application, the second reference template of the current block may only include the reference sample of the second left template, in which case the template prediction value corresponds only to the prediction value of the second left template; or it may only include the reference sample of the second top template, in which case the template prediction value corresponds only to the prediction value of the second top template; or it may simultaneously include the reference sample of the second left template and the reference sample of the second top template, in which case the template prediction value may be composed of the prediction value of the second left template and the prediction value of the second top template; no limitations are imposed here.
[0341] It should also be noted that, in the embodiments of this application, both the first weight matrix and the second weight matrix are pre-trained based on specific block shapes and intra-frame prediction modes. Specifically, if the first candidate prediction mode and the second candidate prediction mode belong to different intra-frame prediction modes, then the obtained first weight matrix and second weight matrix can be different; if the first candidate prediction mode and the second candidate prediction mode belong to the same intra-frame prediction mode and have the same block shape, then the obtained first weight matrix and second weight matrix can also be the same.
[0342] In one possible implementation, taking the first prediction mode combination as an example, which includes two candidate prediction modes (i.e., prediction mode A and prediction mode B), it is assumed that the current block is divided into two parts, and prediction mode A and prediction mode B are used for prediction respectively. Furthermore, the weight values of these two parts can be calculated by minimizing the MSE (Mean Sequence Equation) using the template prediction values and template reconstruction values corresponding to prediction mode A and prediction mode B in the template region. If the first prediction block PredA is obtained by a prediction method based on the weight matrix, the aforementioned method can be used to calculate the prediction value of prediction mode A in the template region and derive the weights.
[0343] Exemplarily, the template regions for defining the derivation weights are x = 0..(W - 1), y = -tempH..-1 and x = -tempW..-1, y = 0..(H - 1). The predicted value PredA_temp of the prediction pattern A in the template region can be expressed as shown in the aforementioned formula (12).
[0344] According to the prediction pattern B, its predicted value PredB_temp in the template region can be obtained.
[0345] In this way, after determining the template predicted values corresponding to each of the at least two candidate prediction patterns, at least one set of training samples can be determined based on the template predicted values corresponding to each of the at least two candidate prediction patterns and the template reconstruction value of the template region, and the corresponding first candidate model parameters can be derived therefrom. Exemplarily, for any position x = i, y = j within the template region, an equation (or which can also be referred to as a training sample) can be established, as shown in the aforementioned formula (13). Among them, diff(x, y) = PredB_temp(i, j) - PredA_temp(i, j). Based on all the training samples within the template region, the first candidate model parameters, such as α, β, and C, can be obtained by solving using the MSE method.
[0346] After deriving the corresponding first candidate model parameters α, β, and C, based on the first candidate model parameters α, β, and C, the candidate weight information corresponding to the first prediction pattern combination can be determined. Exemplarily, the weight information w0(x, y) and w1(x, y) corresponding to the first prediction block PredA and the second prediction block PredB can be expressed as: w0(x, y) = (1 << shift) - w1(x, y); w1(x, y) = α * x + β * y + C. Among them, shift is a predefined integer value representing the precision of the weight (the precision is 1 / (1 << shift)).
[0347] It can also be understood that when using the derivation-based SGPM for prediction in the current block, the above weight derivation process can be combined with the template error calculation process. In one possible implementation, the weight information is first derived, and then the template error value is calculated based on this weight.
[0348] In some embodiments, determining a second candidate list for the current block based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations may include: determining at least one set of second candidate prediction information based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations, wherein the second candidate prediction information includes at least two candidate prediction modes contained in a prediction mode combination and candidate weight information derived from the prediction mode combination; calculating template error for the template region of the current block based on at least one set of second candidate prediction information to determine the template error value corresponding to each of the at least one set of second candidate prediction information; sorting the at least one set of second candidate prediction information in ascending order based on the template error value, and forming a second candidate list for the current block from the top N2 sets of second candidate prediction information; wherein N2 is a positive integer.
[0349] It should be noted that, in this embodiment, at least one set of second candidate prediction information can be obtained by combining the candidate intra-prediction modes, candidate vector parameters (including BV, MV, etc.), and candidate weight information. Based on this at least one set of second candidate prediction information, a second initial list for the current block, i.e., the initial RSGPM candidate list rsgpmCandidateList, can be constructed. The second candidate prediction information may include at least two candidate prediction modes and corresponding candidate weight information contained in a prediction mode combination. These at least two candidate prediction modes can be determined based on traditional intra-prediction modes, block copy prediction modes, etc.
[0350] It should also be noted that, in the embodiments of this application, a template error value can be calculated for each group of second candidate prediction information, and then at least one group of second candidate prediction information in the second initial list is reordered according to the template error value, and the N2 groups of second candidate prediction information that are ranked first are used to form the second candidate list rsgpmList of the current block.
[0351] In some embodiments, performing template error calculation on the template region of the current block based on at least one set of second candidate prediction information, and determining the template error value corresponding to each of the at least one set of second candidate prediction information, may include:
[0352] The template region of the current block is predicted based on at least two candidate prediction modes in the second candidate prediction information, and the template prediction value corresponding to each of the at least two candidate prediction modes is determined. The template error is calculated based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region, and the template error value corresponding to the second candidate prediction information is determined.
[0353] It should be noted that, in the embodiments of this application, for at least two candidate prediction modes in the second candidate prediction information, the corresponding template error value can be calculated based on the prediction method of the weight matrix. Furthermore, the template prediction value of at least some of these at least two candidate prediction modes can also be obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0354] In some embodiments, predicting the template region of the current block based on at least two candidate prediction patterns in the second candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, may include:
[0355] When the fifth candidate prediction mode among at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value corresponding to the fifth candidate prediction mode.
[0356] When the sixth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the sixth candidate prediction mode, and the template prediction value corresponding to the sixth candidate prediction mode is determined.
[0357] It should be noted that, in the embodiments of this application, the fifth candidate prediction mode can be a candidate prediction mode that meets preset conditions from at least two candidate prediction modes of the second candidate prediction information, and the sixth candidate prediction mode can be a candidate prediction mode that does not meet preset conditions from at least two candidate prediction modes of the second candidate prediction information. The fifth candidate prediction mode meeting preset conditions may include: the fifth candidate prediction mode being an intra-frame prediction mode and meeting the conditions for using PDP prediction. In this case, the template prediction value under the fifth candidate prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0358] In one possible implementation, taking the second candidate prediction information as including two candidate prediction modes (i.e., prediction mode A and prediction mode B) as an example, assuming the current block is divided into two parts, prediction mode A and prediction mode B are used respectively to obtain the first prediction block PredA and the second prediction block PredB. The final prediction sample can be a weighted combination of PredA and PredB. If the first prediction block PredA (or the second prediction block PredB) is obtained by a prediction method based on the weight matrix, its template prediction value in the template region can also be obtained by a prediction method based on the weight matrix. For example, the prediction value PredA_temp of prediction mode A in the template region can be as shown in the aforementioned formula (12).
[0359] In some embodiments, calculating the template error based on the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction values of the template region, and determining the template error value corresponding to the second candidate prediction information, may include:
[0360] Based on the candidate weight information in the second candidate prediction information, determine the weight values corresponding to at least two candidate prediction modes; based on the template prediction values and template reconstruction values of the template regions corresponding to at least two candidate prediction modes, determine the error values corresponding to at least two candidate prediction modes; perform weighted calculations based on the error values and weight values corresponding to at least two candidate prediction modes to obtain the template error value corresponding to the second candidate prediction information.
[0361] In this embodiment, the template error value can be calculated using methods such as MSE, SAD, and SATD. In one possible implementation, taking SAD as an example, the template error value corresponding to the second candidate prediction information can be calculated by combining the aforementioned formulas (9) to (11). Thus, according to the aforementioned template error calculation process, at least one set of template error values corresponding to each of the second candidate prediction information can be obtained; then, these at least one set of second candidate prediction information are sorted from smallest to largest according to the template error values, and the top N2 sets of second candidate prediction information are used to form the second candidate list of the current block.
[0362] In other words, in this embodiment, by calculating candidate weight information and template error values according to the above-mentioned PDP prediction method, the processes of candidate weight information, template error calculation, and candidate list reordering corresponding to each second candidate prediction information under GPM and SGPM modes are realized. Since the prediction method based on the weight matrix can be used not only in the prediction process of the current block, but also for candidate weight information and template error calculation, the template prediction value can be determined by the prediction method based on the weight matrix, the prediction accuracy is further improved.
[0363] It is also understandable that, considering computational complexity, a weight matrix-based prediction method can be used in this embodiment for simplification. Here, using PDP prediction instead of the traditional prediction mode to predict the template region of the current block maintains consistency with the prediction process of the current block, thereby improving prediction accuracy. Furthermore, PDP prediction is more complex than the traditional prediction mode, leading to increased encoding time. Therefore, this embodiment can conditionally use PDP prediction.
[0364] In one possible implementation, at least one set of candidate prediction information can be initially screened based on the template error obtained from the traditional prediction model, and then the template error value under PDP prediction can be calculated only for the candidates with smaller template error values.
[0365] In some embodiments, the method for determining the first candidate list may further include: predicting the template region of the current block based on a first prediction method to determine a first template error value corresponding to each of at least one set of first candidate prediction information; sorting the at least one set of first candidate prediction information in ascending order according to the first template error value to determine at least two sets of candidate prediction information that are ranked first; predicting the template region of the current block based on a prediction method of a weight matrix to determine a second template error value corresponding to each of at least two sets of candidate prediction information; and sorting the at least two sets of candidate prediction information in ascending order according to the second template error value to form the first candidate list of the current block from the N1 sets of candidate prediction information that are ranked first.
[0366] In some embodiments, the method for determining the second candidate list may further include: predicting the template region of the current block based on a first prediction method to determine a first template error value corresponding to each of at least one set of second candidate prediction information; sorting the at least one set of second candidate prediction information from smallest to largest according to the first template error value to determine at least two sets of candidate prediction information that are ranked first; predicting the template region of the current block based on a prediction method of a weight matrix to determine a second template error value corresponding to each of at least two sets of candidate prediction information; sorting the at least two sets of candidate prediction information from smallest to largest according to the second template error value to form the second candidate list of the current block from the top N2 sets of candidate prediction information.
[0367] In this embodiment, the first prediction method does not include a prediction method based on a weight matrix. For example, the first prediction method can be a traditional prediction mode. That is, after obtaining at least one set of candidate prediction information (first candidate prediction information or second candidate prediction information), this embodiment can first calculate the corresponding first template error value according to the traditional prediction mode, retain at least two sets of candidate prediction information with the smallest template error, for example, retaining Q sets of candidate prediction information with the smallest template error; then, for the retained Q sets of candidate prediction information, calculate the corresponding second template error value according to the PDP prediction method, and finally reorder according to the second template error value. Here, the value of Q is greater than or equal to N1 (or N2), without any limitation.
[0368] In one possible implementation, predicting the template region of the current block based on the weight matrix prediction method and determining the second template error value corresponding to each of at least two sets of candidate prediction information may include: predicting the template region of the current block based on the weight matrix prediction method and determining the third template error value corresponding to each of K sets of candidate prediction information from at least two sets of candidate prediction information; where K is a positive integer; updating the first template error value corresponding to each of at least two sets of candidate prediction information according to the third template error value corresponding to each of the K sets of candidate prediction information, and determining the second template error value corresponding to each of at least two sets of candidate prediction information.
[0369] In this embodiment, for K groups of candidate prediction information, the first m groups of candidate prediction information among at least two groups of candidate prediction information may be determined as K groups of candidate prediction information when they meet a preset condition. Alternatively, any group of candidate prediction information among the first m groups among at least two groups of candidate prediction information may be determined as K groups of candidate prediction information when it meets the preset condition.
[0370] For example, taking the current block as an example of prediction using SGPM, a first initial list, namely the SGPM candidate list sgpmCandidateList, with a length of L1, can be constructed based on the candidate intra-prediction modes, candidate block vectors, and candidate partitioning methods. Each candidate prediction information includes (prediction mode A, prediction mode B, and partitioning method splitDir). The template error value corresponding to each candidate prediction information can be calculated based on traditional prediction modes such as traditional intra-prediction modes and block copy prediction modes (if prediction mode A or prediction mode B corresponds to block copy prediction). From this, Q groups of candidate prediction information with the smallest template error can be retained. Wherein, if the value of Q is equal to N1, the retained Q groups of candidate prediction information can be used to form the first candidate list sgpmList for the current block. Then, based on the PDP prediction method, the template error value of K groups of candidate prediction information in the first candidate list is recalculated, and the reordering is performed according to the recalculated template error value. Alternatively, if the value of Q is greater than N1, then the template error value is recalculated for K groups of candidate prediction information in these Q groups of candidate prediction information based on the PDP prediction method, and the reordering is performed according to the recalculated template error value. Finally, the top N1 groups of candidate prediction information are used to form the first candidate list sgpmList of the current block.
[0371] In one possible implementation, assuming Q equals N1, the template error values calculated using the traditional prediction model are reordered, and the remaining Q groups of candidate prediction information can form the first candidate list sgpmList for the current block. One approach to template prediction using PDP prediction is to recalculate the template error values for the first m candidates in the first candidate list sgpmList using PDP prediction. Another possible option is to perform the aforementioned PDP prediction and recalculate the template error values for the first m candidates in the first candidate list sgpmList whose prediction models satisfy the conditions for using PDP prediction.
[0372] It should also be noted that, in some embodiments of this application, when recalculating the third template error value corresponding to each of the K groups of candidate prediction information based on the PDP prediction method, the method may further include: determining the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information.
[0373] For example, taking the i-th candidate prediction information as an example, the first template error value obtained based on the traditional prediction model is sgpmCost[i]. If any of its prediction models meets the conditions for using PDP prediction, then based on
[0374] The PDP prediction method predicts the corresponding third template error value SadA_B_splitDir. Then, the final second template error value can be set to be equal to the third template error value SadA_B_splitDir, i.e., sgpmCost[i]=SadA_B_splitDir.
[0375] In some embodiments, the method may further include: determining the minimum value of the first template error value and the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information, based on the first template error value and the third template error value corresponding to each of the K groups of candidate prediction information.
[0376] For example, taking the i-th candidate prediction information as an example, the first template error value predicted based on the traditional prediction mode is sgpmCost[i]. If any prediction mode satisfies the PDP prediction usage conditions, then based on the PDP prediction method, the corresponding third template error value SadA_B_splitDir is predicted. Then, the final second template error value can be set to the minimum of the first template error value sgpmCost[i] and the third template error value SadA_B_splitDir, i.e., sgpmCost[i] = min(sgpmCost[i], SadA_B_splitDir). In other words, the original template error value is only replaced when the template error value predicted by PDP is smaller.
[0377] In another possible implementation, instead of performing initial screening on at least one set of candidate prediction information, PDP prediction can be performed on only a portion of the candidate prediction information from this at least one set of candidate prediction information, and the template error value can be updated.
[0378] In some embodiments, the method may further include: predicting the template region of the current block based on a prediction method using a weight matrix, and determining the third template error value corresponding to each of the top K1 groups of first candidate prediction information in at least one group of first candidate prediction information; wherein K1 is a positive integer; updating the first template error value corresponding to each of the at least one group of first candidate prediction information according to the third template error value corresponding to each of the K1 groups of first candidate prediction information, and determining the second template error value corresponding to each of the at least one group of first candidate prediction information; sorting the at least one group of first candidate prediction information in ascending order according to the second template error value, and forming the first candidate list of the current block from the top N1 groups of first candidate prediction information.
[0379] In this embodiment, a first initial list, namely the SGPM candidate list sgpmCandidateList, can be constructed based on the candidate intra-prediction modes, candidate block vectors, and candidate partitioning methods. Here, PDP prediction can be performed on a subset of the candidate prediction information in the first initial list. For example, the process of performing PDP prediction and updating the template error value can be performed only on the first candidate prediction information in the first K1 groups of sgpmCandidateList whose prediction modes meet the PDP prediction usage conditions.
[0380] In some embodiments, the method may further include: predicting the template region of the current block based on a prediction method using a weight matrix, and determining the third template error value corresponding to each of the top K2 groups of second candidate prediction information in at least one group of second candidate prediction information; wherein K2 is a positive integer; updating the first template error value corresponding to each of the at least one group of second candidate prediction information according to the third template error value corresponding to each of the K2 groups of second candidate prediction information, and determining the second template error value corresponding to each of the at least one group of second candidate prediction information; sorting the at least one group of second candidate prediction information in ascending order according to the second template error value, and forming the second candidate list of the current block from the top N2 groups of second candidate prediction information.
[0381] In this embodiment, a second initial list, namely the RSGPM candidate list rsgpmCandidateList, can be constructed based on the candidate intra-prediction modes, candidate block vectors, and derived candidate weight information. Here, PDP prediction can be performed on a subset of the candidate prediction information in the second initial list. For example, the process of performing PDP prediction and updating the template error value can be performed only on the second candidate prediction information in the first K2 groups of rsgpmCandidateList where any prediction mode meets the PDP prediction usage conditions.
[0382] For example, in related technologies, SGPM can construct an SGPM candidate list sgpmCandidateList with a length of L1 based on the candidate intra-prediction mode, candidate block vector, and candidate partitioning method. Each candidate prediction information includes (prediction mode A, prediction mode B, and partitioning method splitDir). The template error value corresponding to each candidate prediction information can be calculated based on traditional prediction modes such as traditional intra-prediction mode and block copy prediction mode (if prediction mode A or prediction mode B corresponds to block copy prediction). From this, N1 sets of candidate prediction information with the smallest template error can be retained to form the first candidate list sgpmList for the current block. SGPM in related technologies can also use derivation-based SGPM prediction. Based on the candidate intra-prediction mode and candidate block vector, an RSGPM candidate list rsgpmCandidateList with a length of L2 can be constructed. Each candidate prediction information includes (prediction mode A, prediction mode B, and derivational weight information w0 (or w1)). Similar to the above process, the template error value corresponding to each candidate prediction information can be calculated based on traditional intra-frame prediction mode, block copy prediction mode, etc. From this, the N2 groups of candidate prediction information with the smallest template error can be retained to form the second candidate list RSGPM list rsgpmList for the current block. rsgpmList and sgpmList can be merged to obtain the final candidate list sgpmList'. In sgpmList', the first N2 groups of candidate prediction information correspond to rsgpmList, and the last N1 groups of candidate prediction information correspond to sgpmList.
[0383] It is also understood that, in the embodiments of this application, the prediction information of the current block may include weight information in addition to at least two prediction modes. In another possible implementation, determining the prediction information of the current block based on the template prediction value of the current block may include: determining the weight information of the current block based on the template prediction value of the current block.
[0384] In some embodiments, determining the weight information of the current block based on the template prediction value of the current block may include: determining the template prediction value of the current block in at least two prediction modes corresponding to the geometric partitioning mode; determining at least one set of training samples based on the template prediction value in at least two prediction modes and the template reconstruction value of the template region; determining the model parameters of a preset weight model based on the at least one set of training samples; and determining the weight information of the current block based on the model parameters of the preset weight model.
[0385] It should be noted that, in the embodiments of this application, for at least two prediction modes corresponding to the geometric partitioning pattern, or in other words, at least two prediction modes used by the current block, the template prediction values of at least some of the candidate prediction modes in these at least two prediction modes are obtained by predicting the template region of the current block based on the prediction method of the weight matrix. In some embodiments, the method may further include:
[0386] When the first prediction mode in at least two prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value under the first prediction mode.
[0387] When the second prediction mode in at least two prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second prediction mode to determine the template prediction value under the second prediction mode.
[0388] It should be noted that, in the embodiments of this application, the first prediction mode can be a prediction mode that meets preset conditions among at least two prediction modes, and the second prediction mode can be a prediction mode that does not meet preset conditions among at least two prediction modes. The first prediction mode meeting preset conditions may include: the first prediction mode being an intra-frame prediction mode and meeting the conditions for using PDP prediction. In this case, the template prediction value in the first prediction mode can be replaced with the template prediction value obtained based on PDP prediction.
[0389] It should also be noted that, in one possible implementation, the conditions for using PDP prediction may include: the size of the current block meets the size requirements. For example, PDP prediction is only applied to blocks of a certain size, such as blocks whose width and height are both no greater than 32, or blocks whose width and height are both no greater than 32 except for 4x32, 32x4, 8x32, and 32x8.
[0390] In this way, after determining the template prediction values corresponding to the at least two prediction patterns respectively, at least one set of training samples can be determined according to the template prediction values corresponding to the at least two prediction patterns and the template reconstruction value of the template region, so as to derive the model parameters of the current block. Exemplarily, for any position x = i, y = j within the template region, an equation (or it can also be called a training sample) can be established, as shown in the aforementioned formula (13). Among them, diff(x,y)=PredB_temp(i,j)-PredA_temp(i,j). According to all the training samples within the template region, the model parameters of the current block, such as α, β, and C, can be obtained by solving based on the MSE method.
[0391] After deriving the model parameters α, β, and C of the current block, the weight information of the current block can be determined according to the model parameters α, β, and C. Exemplarily, the weight information w0(x,y) and w1(x,y) corresponding to the first prediction block PredA and the second prediction block PredB can be expressed as: w0(x,y)=(1<<shift)-w1(x,y); w1(x,y)=α*x+β*y+C. Among them, shift is a predefined integer value representing the precision of the weight (the precision is 1 / (1<<shift)).
[0392] S1702. Predict the current block according to the prediction information to determine the prediction sample of the current block.
[0393] It should be noted that in the embodiments of the present application, the prediction information of the current block can at least include: at least two prediction patterns corresponding to the geometric partitioning mode. In some embodiments, predicting the current block according to the prediction information to determine the prediction sample of the current block can include: when at least some of the at least two prediction patterns meet the preset conditions, determining the prediction samples corresponding to at least some of the prediction patterns based on the prediction method of the weight matrix; determining the prediction sample of the current block according to the prediction samples corresponding to at least some of the prediction patterns.
[0394] It should also be noted that in the embodiments of the present application, the at least two prediction patterns can be divided into at least some prediction patterns that meet the preset conditions and the remaining prediction patterns that do not meet the preset conditions. In some embodiments, the method can further include: when the remaining prediction patterns among the at least two prediction patterns do not meet the preset conditions, predicting the current block according to the remaining prediction patterns to determine the prediction samples corresponding to the remaining prediction patterns. Here, since the remaining prediction patterns do not meet the preset conditions, that is, the remaining prediction patterns cannot use PDP prediction, the prediction method of the related technology is still used to determine the prediction samples corresponding to the remaining prediction patterns.
[0395] In some embodiments, for determining the prediction samples of the current block, it may include: determining the prediction samples of the previous block according to the prediction samples corresponding to at least part of the prediction modes and the prediction samples corresponding to the remaining part of the prediction modes.
[0396] In some embodiments, the prediction information of the current block may further include weight information. Determining the prediction samples of the previous block according to the prediction samples corresponding to at least part of the prediction modes and the prediction samples corresponding to the remaining part of the prediction modes may include: determining the weight values corresponding to at least two prediction modes respectively according to the weight information; performing a weighted operation on the prediction samples corresponding to at least part of the prediction modes and the prediction samples corresponding to the remaining part of the prediction modes according to these weight values to determine the prediction samples of the current block.
[0397] It should be noted that in the embodiments of the present application, if the weight information is the partitioning method used for the current block, then the weight values corresponding to at least two prediction modes can be determined according to the partitioning method used for the current block; if the weight information is the weight information derived for the current block, the weight values corresponding to at least two prediction modes are determined according to the weight information derived for the current block.
[0398] In a possible implementation, if w0(x,y) = (1 << shift) - w1(x,y); w1(x,y) = α * x + β * y + C; then the prediction samples of the current block can be expressed as shown in the foregoing formula (14).
[0399] It should also be noted that in the embodiments of the present application, after obtaining the prediction samples of the current block, the method may further include: determining the residual samples of the current block according to the prediction samples of the current block. Here, determining the residual samples of the current block according to the prediction samples of the current block may be to perform a subtraction operation on the initial samples of the current block and the prediction samples of the current block to determine the residual samples of the current block.
[0400] It should also be noted that in the embodiments of the present application, the method may further include: performing encoding processing on the residual samples of the current block and writing the obtained encoded bits into the code stream. In this way, by encoding the corresponding information, the encoding process of the current block is completed.
[0401] It should also be noted that in the embodiments of the present application, the current block is predicted through multiple prediction modes to obtain multiple first prediction values, and then the final prediction value of the current block is obtained by performing a weighted calculation on the obtained multiple first prediction values. As long as any one of these multiple prediction modes is an intra prediction mode and meets the PDP prediction usage conditions, the method of the embodiments of the present application can be applied.
[0402] This application provides an encoding method that, when predicting a current block using a geometric partitioning mode, determines the prediction information of the current block based on the template prediction value of the current block. The template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block using a weight matrix-based prediction method. The current block is then predicted based on the prediction information to determine the prediction sample for the current block. Thus, when the current block uses geometric partitioning modes such as GPM or SGPM, not only can a weight matrix-based prediction method be used during the prediction process, but also in determining the prediction information of the current block, the same weight matrix-based prediction method can be used to determine the template prediction value of the current block for steps such as calculating the template error and deriving weight information. This makes the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, increasing encoding efficiency, and ultimately improving encoding performance.
[0403] In another embodiment of this application, based on the encoding / decoding method described in the foregoing embodiments, this application proposes using a weight matrix-based prediction method (hereinafter referred to as PDP prediction) to calculate the template error of geometric partitioning modes (e.g., GPM, SGPM). That is, when a certain part of the current block uses an intra-frame prediction mode, and the intra-frame prediction mode meets predefined conditions, then PDP prediction can be used to obtain its predicted value in the template region. Furthermore, the optimal weight value between the two parts can be derived based on this template prediction value.
[0404] The first part calculates the template error of the GPM method using a prediction method based on the weight matrix.
[0405] If the current block has two parts, prediction is performed using prediction mode A and prediction mode B respectively, resulting in a first prediction block PredA and a second prediction block PredB. The final predicted sample is a weighted combination of PredA and PredB, expressed as Pred = (w0 * PredA + w1 * PredB + offset) >> shift. Here, the values of w0 and w1 are related to the sample coordinates x and y, which can be described as the current block being predicted using a geometric partitioning mode.
[0406] If the first prediction block PredA (or the second prediction block PredB) is obtained by a prediction method based on the weight matrix, its predicted value in the template region can also be predicted by the weight matrix. For example, if the top left corner of the current block is (0,0), the first prediction block PredA can be represented as shown in the aforementioned formula (6).
[0407] Where x and y represent the coordinates of the predicted pixel relative to the top-left corner of the current block, τ represents the reference template composed of pixels p[x][y], x=-T2..(2*W-1), y=-T1..-1 and x=-T2..-1, y=0..(2*H-1), k represents the index of the reference sample in the reference template, W represents the width of the current block, H represents the height of the current block, T1 represents the height of the upper part of the reference template, and T2 represents the width of the left part of the reference template. Then the predicted value PredA_temp of the prediction mode A in the upper template can be expressed as shown in the aforementioned formula (7).
[0408] Where x = 0..(W-1), y = -tempH..-1, tempH represents the height of the upper template, τ_top represents the reference template composed of pixels p[x][y], x = -T2..(2*W-1), y = -T1-tempH..-1-tempH and x = -T2..-1, y = -tempH..(2*H-1)-tempH, and k represents the index of the reference sample in the reference template (the index order is the same as τ), as shown in Figure 15A.
[0409] Similarly, the predicted value PredA_temp of prediction mode A in the left template can be expressed as shown in the aforementioned formula (8).
[0410] Where x = -tempW..-1, y = 0..(H-1), tempW represents the width of the left template, τ_left represents the reference template composed of pixels p[x][y], x = -T2-tempW..(2*W-1)-tempW, y = -T1..-1 and x = -T2-tempW..-1-tempW, y = 0..(2*H-1), and k represents the index of the reference sample in the reference template (the index order is the same as τ), as shown in Figure 15B.
[0411] Based on the above process, the predicted values PredA_top and PredA_left of prediction mode A in the upper and left templates can be obtained. These can be combined with the predicted values PredB_top and PredB_left of prediction mode B in the upper and left templates, and the splitting method splitDir, to obtain the template error value under this candidate prediction mode (prediction mode A, prediction mode B, splitting method splitDir). One possible calculation method is:
[0412] The errors of the upper and left templates of prediction pattern A can be represented by SAD. First, the error value wholeSadA of prediction pattern A under the complete upper and left templates can be calculated and expressed as shown in the aforementioned formula (9).
[0413] The template error of prediction model A combined with the first part of the weights can be expressed as shown in the aforementioned formula (10).
[0414] Similarly, we can obtain the upper and left template errors wholeSadB of prediction pattern B and the template error partSadB after combining the first part of the weights of prediction pattern B.
[0415] When the first part is prediction mode A and the second part is prediction mode B, the template error value corresponding to the candidate prediction information is expressed as shown in the aforementioned formula (11). Here, the weight w0[x][y] is determined by the current block shape, size, partitioning method splitDir, etc., in the GPM and SGPM methods of related technologies.
[0416] Based on the above calculation of the template error values under prediction mode A, prediction mode B, and the splitDir partitioning method, it is possible to realize the template error calculation of candidate prediction modes and the reordering of candidate lists under the GPM and SGPM methods.
[0417] The second part derives the weights for GPM prediction using a weight matrix-based prediction method.
[0418] If the current block is predicted using a geometric partitioning model (e.g., GPM, SGPM), the weight values of its two parts can be calculated using methods such as minimum mean square error (MSE) from the predicted values of prediction models A and B in the template region and the reconstructed value of the template region. If the first prediction block PredA is obtained by a prediction method based on the weight matrix, the predicted value of prediction model A in the template region can be calculated and the weight information derived using the same method described in the first part.
[0419] Define the template region for deriving the weight information as x = 0..(W-1), y = -tempH..-1 and x = -tempW..-1, y = 0..(H-1). As described in Part 1, the predicted value PredA_temp of the prediction pattern A in the template region can be expressed as shown in the aforementioned formula (12).
[0420] Based on the prediction pattern B, its predicted value PredB_temp in the template region is obtained. For any position x = i, y = j in the template region, we can have the equation (or a training sample): α*diff(i,j)*i + β*diff(i,j)*j + C*diff(i,j) = reco(i,j) - PredA_temp(i,j).
[0421] Among them, diff(x, y) = PredB_temp(i, j) - PredA_temp(i, j). Based on all training samples within the template region, α, β, and C can be obtained by solving using the MSE method. The weights w0(x, y) and w1(x, y) corresponding to PredA and PredB can be expressed as: w0(x, y) = (1 << shift) - w1(x, y); w1(x, y) = α * x + β * y + C. Here, shift is a predefined integer value representing the precision of the weight (the precision is 1 / (1 << shift)). The predicted value of the current block can be expressed as shown in the aforementioned formula (14).
[0422] It should be noted that the weight derivation process described in this part can be combined with the template error calculation process described in the first part, that is, first derive the weights, and then calculate the template error based on these weights.
[0423] In the third part, a prediction method based on the weight matrix is simply used.
[0424] The first part and the second part give the template error of the geometric partitioning pattern prediction using PDP prediction calculation and the weight information for deriving the geometric partitioning pattern prediction. On the one hand, using PDP prediction instead of traditional intra-frame prediction to predict the template is consistent with the process of predicting the current block, improving the accuracy. On the other hand, the complexity of PDP prediction is higher than that of traditional intra-frame prediction, which will lead to an increase in the encoding and decoding time. Therefore, the embodiments of this application propose to use PDP prediction conditionally. Specifically, the candidate prediction information is initially screened according to the template error obtained by traditional intra-frame prediction, and only the candidates with smaller template errors are used to calculate the template error under PDP prediction.
[0425] Exemplarily, the SGPM method in the related art constructs an SGPM candidate list sgpmCandidateList with a length of L1 according to the candidate intra-frame prediction mode, candidate block vector, and candidate partitioning method. Each candidate prediction information includes (prediction mode A, prediction mode B, partitioning method splitDir). The template error of each candidate can be calculated according to the traditional intra-frame prediction method, block copy prediction method (if prediction mode A or B corresponds to block copy prediction), etc. N1 candidates with the smallest template errors can be retained to form the final SGPM list sgpmList. The finally selected SGPM prediction method sgpmList[idx] is determined by transmitting the prediction mode index idx.
[0426] One approach to template prediction using PDP prediction is to recalculate the template error value for the first m candidates in sgpmList using PDP prediction. For example, the template error corresponding to the i-th candidate in sgpmList is sgpmCost[i]. If any prediction mode of this candidate satisfies the conditions for using PDP prediction, then according to the processes described in the first and second parts above, the corresponding template error SadA_B_splitDir is predicted, and sgpmCost[i] = SadA_B_splitDir is set. A possible alternative is to set sgpmCost[i] = min(sgpmCost[i], SadA_B_splitDir), meaning that the original template error is only replaced when the template error obtained from PDP prediction is smaller.
[0427] Another possible alternative is to perform the above-mentioned PDP prediction and update the template error for the first m prediction patterns of any candidate that meet the PDP prediction conditions in sgpmList.
[0428] Another possible alternative is to perform the above-mentioned PDP prediction and update the template error for the first m prediction patterns of any candidate in sgpmCandidateList that meet the conditions for using PDP prediction.
[0429] Furthermore, the SGPM method of related technologies can use derivation-based SGPM prediction (hereinafter referred to as RSGPM). Based on the candidate intra-prediction modes and candidate block vectors, an RSGPM candidate list rsgpmCandidateList of length L2 can be constructed. Each candidate contains (prediction mode A, prediction mode B, and derivational weight information w0 (or w1)). Similar to the above process, the template error of each candidate can be calculated using traditional intra-prediction methods, block copy prediction methods, etc. The N2 candidates with the smallest template errors can be retained to form the final RSGPM list rsgpmList. rsgpmList and sgpmList can be merged to obtain the final sgpmList', where the first N2 candidates correspond to rsgpmList, and the last N1 candidates correspond to sgpmList.
[0430] Similar to the method described above, PDP can be used conditionally to predict and update the template error of RSGPM candidates.
[0431] In one possible embodiment, the SGPM method of the related art is improved according to the method described in the embodiments of this application. If the current block is predicted using the SGPM method, an SGPM candidate list can be constructed. Wherein, if any prediction mode in the current RSGPM and SGPM candidates meets the PDP prediction usage conditions, then, as described in the first part, the template error of the candidate is calculated using PDP prediction. If any prediction mode in the current RSGPM candidates meets the PDP prediction usage conditions, then, as described in the second part, the weight of the candidate is derived using PDP prediction.
[0432] In one possible implementation, taking SGPM as an example, the syntax element definitions are shown in Table 5.
[0433] Table 5
[0434] Here, `cu_sgpm_flag` is the enable flag for the SGPM method at the coding block level. A value of true indicates that the SGPM method is used for the current luma block, while a value of false indicates that the SGPM method is not used. If this syntax element does not exist in the bitstream, it defaults to false. `cu_sgpm_idx` is the SGPM prediction mode index at the coding block level, representing the index number of the selected prediction information in the SGPM candidate list for the current block. If this syntax element does not exist in the bitstream, it defaults to 0.
[0435] In one possible implementation, the decoding process at the decoding end is as follows:
[0436] Step 1: Decode the syntax element. If the cu_sgpm_flag of the current block is true, then the current block is predicted using the SGPM method, and cu_sgpm_idx is further decoded.
[0437] Step 2: Construct the SGPM list for the current block. Based on the candidate intra-prediction modes, candidate block vectors, and candidate partitioning methods, construct the SGPM candidate list sgpmCandidateList. Calculate the template error for each SGPM candidate (containing prediction mode A, prediction mode B, and partitioning method splitDir). If prediction mode A or prediction mode B contained in an SGPM candidate satisfies the PDP prediction usage conditions, then predict the template region for that mode according to the process described in Part 1 and calculate the template error. Based on the template errors of all SGPM candidates, obtain the first candidate list sgpmList consisting of N1 SGPM candidates with the smallest template errors.
[0438] Step 3: Construct the RSGPM list for the current block. Based on the candidate intra-prediction modes and candidate block vectors, construct the RSGPM candidate list rsgpmCandidateList, and derive the weight of each RSGPM candidate. If the prediction mode A or prediction mode B included in the RSGPM candidate meets the PDP prediction usage conditions, then derive the weight information of the candidate according to the process described in Part 2. Further, perform template region prediction for the mode according to the process described in Part 1 and calculate the template error. Based on the template errors of all RSGPM candidates, obtain a second candidate list rsgpmList consisting of N2 RSGPM candidates with the smallest template errors;
[0439] Step 4: Combine the sgpmList and rsgpmList obtained in Steps 2 and 3 to obtain the final SGPM candidate list sgpmList'. The first N2 candidates of sgpmList' correspond to rsgpmList, and the last N1 candidates correspond to sgpmList.
[0440] Step 5: Determine the SGPM prediction method sgpmList'[cu_sgpm_idx] used for the current block based on cu_sgpm_idx. If the prediction mode A or prediction mode B of the current block meets the conditions for using PDP prediction, then the corresponding prediction block PredA or PredB is obtained using the PDP-based prediction method. Combining PredA and PredB, the final prediction sample Pred = (w0*PredA + w1*PredB + (1<<(shift-1)))>>shift) is obtained. Here, shift represents the precision of the weighted operation, and w0 and w1 are obtained from the partitioning method of the current SGPM prediction method or the derivation process in Step 3.
[0441] Step 6: Obtain the predicted block for the current block based on the steps described above. Then, following existing techniques, complete the coefficient decoding and transformation processes for the current block. The decoding of the current block is then complete.
[0442] In one possible implementation, the encoding process at the encoding end is as follows:
[0443] Step 1: Based on the high-level mode enable flag, the size and position of the current block, determine whether the current block can be encoded using the SGPM method. If it is determined that the current block uses SGPM mode, set cu_sgpm_flag to true;
[0444] Step 2, similar to steps 2-4 on the decoding end, derive the SGPM candidate list sgpmList' for the current block, determine the selected SGPM prediction method for the current block, and encode the prediction mode index cu_sgpm_idx corresponding to the selected candidate;
[0445] Step 3, similar to step 5 at the decoding end, obtains the predicted sample for the current block. This completes the residual encoding and reconstruction process for the current block. The corresponding information is then encoded to complete the encoding of the current block.
[0446] Step 4: After traversing all coding units, the bitstream is output after passing through techniques such as loop filtering and entropy coding.
[0447] In other words, in the embodiments of this application, it is proposed that the GPM and SGPM methods can use a prediction method based on the weight matrix to obtain the predicted value of the template region; it is also proposed that the GPM and SGPM methods can use a prediction method based on the weight matrix to calculate the template error of the candidate mode and derive the weight information of the weighted combination; furthermore, it is proposed that the GPM and SGPM methods can conditionally use a prediction method based on the weight matrix to obtain the predicted value of the template region.
[0448] In the embodiments of this application, the specific implementation of the foregoing embodiments is described in detail through the above embodiments. It can be seen from the technical solutions of the foregoing embodiments that, for methods such as GPM and SGPM, if a prediction method based on a weight matrix is used in the prediction process, then when calculating the template error and deriving the weights, the same prediction method based on a weight matrix can be used to obtain the predicted value of the template region, making the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block and improving the encoding and decoding efficiency.
[0449] In another embodiment of this application, based on the same inventive concept as the foregoing embodiments, FIG18 is a schematic diagram of the composition structure of an encoder provided in an embodiment of this application. As shown in FIG18, the encoder 180 may include a first determining unit 1801 and a first predicting unit 1802, wherein:
[0450] The first determining unit 1801 is configured to determine the prediction information of the current block based on the template prediction value of the current block when the current block is predicted using a geometric partitioning mode; wherein, the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0451] The first prediction unit 1802 is configured to predict the current block based on the prediction information and determine the prediction sample of the current block.
[0452] In some embodiments, the prediction information includes weight information, and the first determining unit 1801 is further configured to determine the weight information of the current block based on the template prediction value of the current block.
[0453] In some embodiments, the first determining unit 1801 is further configured to determine the template prediction values of the current block in at least two prediction modes corresponding to the geometric partitioning mode; determine at least one set of training samples based on the template prediction values in the at least two prediction modes and the template reconstruction values of the template region; determine the model parameters of the preset weight model based on the at least one set of training samples; and determine the weight information of the current block based on the model parameters of the preset weight model.
[0454] In some embodiments, the first determining unit 1801 is further configured to, when the first prediction mode in at least two prediction modes meets a preset condition, predict the template region of the current block based on the prediction method of the weight matrix to determine the template prediction value under the first prediction mode; and when the second prediction mode in at least two prediction modes does not meet the preset condition, predict the template region of the current block according to the second prediction mode to determine the template prediction value under the second prediction mode.
[0455] In some embodiments, the first determining unit 1801 is further configured to determine a candidate list for the current block based on the template prediction value of the current block; wherein the candidate list includes at least one set of candidate prediction information; and to determine the prediction information of the current block based on the candidate list.
[0456] In some embodiments, the first determining unit 1801 is further configured to perform encoding cost calculation on the current block for at least one set of candidate prediction information in the candidate list, determine the cost result corresponding to at least one set of candidate prediction information; and determine the minimum cost result from the cost results corresponding to at least one set of candidate prediction information, and determine the candidate prediction information corresponding to the minimum cost result as the prediction information of the current block.
[0457] In some embodiments, referring to FIG18, the encoder 180 may further include an encoding unit 1803; a first determining unit 1801, further configured to determine the prediction mode index of the current block, wherein the prediction mode index is used to indicate the index number of the prediction information of the current block in the candidate list; and the encoding unit 1803, configured to encode the prediction mode index of the current block and write the obtained encoded bits into the bit stream.
[0458] In some embodiments, the first determining unit 1801 is further configured to determine at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; determine a first candidate list for the current block based on at least one set of prediction mode combinations and at least one candidate partitioning method; and determine a candidate list for the current block based on the first candidate list.
[0459] In some embodiments, the first determining unit 1801 is further configured to determine at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; determine a second candidate list for the current block based on the at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations; and determine a candidate list for the current block based on the second candidate list.
[0460] In some embodiments, the first determining unit 1801 is further configured to determine at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; determine a first candidate list for the current block based on at least one set of prediction mode combinations and at least one candidate partitioning method; determine a second candidate list for the current block based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode groups; and determine a candidate list for the current block based on the first candidate list and the second candidate list.
[0461] In some embodiments, the first determining unit 1801 is further configured to: determine at least one set of first candidate prediction information based on at least one set of prediction mode combinations and at least one candidate partitioning method, wherein the first candidate prediction information includes at least two candidate prediction modes and one candidate partitioning method contained in a set of prediction mode combinations; calculate the template error of the template region of the current block based on the at least one set of first candidate prediction information to determine the template error value corresponding to each of the at least one set of first candidate prediction information; and sort the at least one set of first candidate prediction information in ascending order based on the template error value, and form the first candidate list of the current block by the N1 sets of first candidate prediction information that are ranked first; wherein N1 is a positive integer.
[0462] In some embodiments, the first determining unit 1801 is further configured to predict the template region of the current block according to at least two candidate prediction modes in the first candidate prediction information, and determine the template prediction value corresponding to each of the at least two candidate prediction modes; and to perform template error calculation based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region, and determine the template error value corresponding to the first candidate prediction information.
[0463] In some embodiments, the first determining unit 1801 is further configured to, when the first candidate prediction mode among at least two candidate prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix to determine the template prediction value corresponding to the first candidate prediction mode; and when the second candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, predict the template region of the current block according to the second candidate prediction mode to determine the template prediction value corresponding to the second candidate prediction mode.
[0464] In some embodiments, the first reference template of the current block includes a reference sample of the first left template and a reference sample of the first top template; the first determining unit 1801 is further configured to determine a first weight matrix of the current block; determine the predicted value of the first left template based on the first weight matrix and the reference sample of the first left template; determine the predicted value of the first top template based on the first weight matrix and the reference sample of the first top template; and determine the template predicted value corresponding to the first candidate prediction mode based on the predicted value of the first left template and / or the predicted value of the first top template.
[0465] In some embodiments, the first determining unit 1801 is further configured to predict the template region of the current block according to the first prediction mode combination, determine the template prediction value corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination; determine at least one set of training samples according to the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region; determine the first candidate model parameters of the preset weight model according to the at least one set of training samples; and determine the candidate weight information corresponding to the first prediction mode combination according to the first candidate model parameters; wherein the first prediction mode combination is any one of the at least one set of prediction mode combinations.
[0466] In some embodiments, the first determining unit 1801 is further configured to, when the third candidate prediction mode among at least two candidate prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix to determine the template prediction value corresponding to the third candidate prediction mode; and when the fourth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, predict the template region of the current block according to the fourth candidate prediction mode to determine the template prediction value corresponding to the fourth candidate prediction mode.
[0467] In some embodiments, the second reference template of the current block includes a reference sample of the second left template and a reference sample of the second top template; the first determining unit 1801 is further configured to determine a second weight matrix of the current block; determine a predicted value of the second left template based on the second weight matrix and the reference sample of the second left template; determine a predicted value of the second top template based on the second weight matrix and the reference sample of the second top template; and determine a template predicted value corresponding to the third candidate prediction mode based on the predicted value of the second left template and / or the predicted value of the second top template.
[0468] In some embodiments, the first determining unit 1801 is further configured to: determine at least one set of second candidate prediction information based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations; wherein the second candidate prediction information includes at least two candidate prediction modes contained in a set of prediction mode combinations and candidate weight information derived from the prediction mode combinations; calculate template error for the template region of the current block based on the at least one set of second candidate prediction information to determine the template error value corresponding to each of the at least one set of second candidate prediction information; and sort the at least one set of second candidate prediction information in ascending order based on the template error value, and form a second candidate list for the current block from the top N2 sets of second candidate prediction information; wherein N2 is a positive integer.
[0469] In some embodiments, the first determining unit 1801 is further configured to predict the template region of the current block according to at least two candidate prediction modes in the second candidate prediction information, and determine the template prediction value corresponding to each of the at least two candidate prediction modes; and to calculate the template error value corresponding to the second candidate prediction information according to the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
[0470] In some embodiments, the first determining unit 1801 is further configured to, when the fifth candidate prediction mode among at least two candidate prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix and determine the template prediction value corresponding to the fifth candidate prediction mode; and when the sixth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, predict the template region of the current block according to the sixth candidate prediction mode and determine the template prediction value corresponding to the sixth candidate prediction mode.
[0471] In some embodiments, the first determining unit 1801 is further configured to: predict the template region of the current block based on a first prediction method; determine a first template error value corresponding to each of at least one set of first candidate prediction information; sort the at least one set of first candidate prediction information in ascending order according to the first template error value; determine at least two sets of candidate prediction information that are ranked first; predict the template region of the current block based on a prediction method using a weight matrix; determine a second template error value corresponding to each of at least two sets of candidate prediction information; and sort the at least two sets of candidate prediction information in ascending order according to the second template error value; and form a first candidate list of the current block by the N1 sets of candidate prediction information that are ranked first; wherein the first prediction method does not include a prediction method based on a weight matrix.
[0472] In some embodiments, the first determining unit 1801 is further configured to: predict the template region of the current block based on a first prediction method; determine the first template error value corresponding to each of at least one set of second candidate prediction information; sort the at least one set of second candidate prediction information from smallest to largest according to the first template error value; determine at least two sets of candidate prediction information that are ranked first; predict the template region of the current block based on a prediction method using a weight matrix; determine the second template error value corresponding to each of at least two sets of candidate prediction information; and sort the at least two sets of candidate prediction information from smallest to largest according to the second template error value, forming a second candidate list of the current block from the N2 sets of candidate prediction information that are ranked first; wherein the first prediction method does not include the prediction method based on a weight matrix.
[0473] In some embodiments, the first determining unit 1801 is further configured to predict the template region of the current block based on the prediction method of the weight matrix, determine the third template error value corresponding to each of the K sets of candidate prediction information in at least two sets of candidate prediction information; wherein K is a positive integer; and update the first template error value corresponding to each of the at least two sets of candidate prediction information according to the third template error value corresponding to each of the K sets of candidate prediction information, and determine the second template error value corresponding to each of the at least two sets of candidate prediction information.
[0474] In some embodiments, the first determining unit 1801 is further configured to determine the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information.
[0475] In some embodiments, the first determining unit 1801 is further configured to determine the minimum value of the first template error value and the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information, based on the first template error value and the third template error value corresponding to each of the K groups of candidate prediction information.
[0476] In some embodiments, the first determining unit 1801 is further configured to determine the first m groups of candidate prediction information as K groups of candidate prediction information when the first m groups of candidate prediction information in at least two groups of candidate prediction information meet the preset conditions; or, when any one group of candidate prediction information in the first m groups of at least two groups of candidate prediction information meets the preset conditions, determine the candidate prediction information in the first m groups that meets the preset conditions as K groups of candidate prediction information.
[0477] In some embodiments, the first determining unit 1801 is further configured to predict the template region of the current block based on a prediction method using a weight matrix, determine the third template error value corresponding to each of the top K1 groups of first candidate prediction information in at least one group of first candidate prediction information; wherein K1 is a positive integer; update the first template error value corresponding to each of the at least one group of first candidate prediction information according to the third template error value corresponding to each of the K1 groups of first candidate prediction information, determine the second template error value corresponding to each of the at least one group of first candidate prediction information; and sort the at least one group of first candidate prediction information from smallest to largest according to the second template error value, and form the first candidate list of the current block by the N1 groups of first candidate prediction information that are ranked first.
[0478] In some embodiments, the first determining unit 1801 is further configured to predict the template region of the current block based on a prediction method using a weight matrix, and determine the third template error value corresponding to each of the top K2 groups of second candidate prediction information in at least one group of second candidate prediction information; wherein K2 is a positive integer; update the first template error value corresponding to each of the at least one group of second candidate prediction information according to the third template error value corresponding to each of the K2 groups of second candidate prediction information, and determine the second template error value corresponding to each of the at least one group of second candidate prediction information; and sort the at least one group of second candidate prediction information from smallest to largest according to the second template error value, and form the second candidate list of the current block by the N2 groups of second candidate prediction information that are ranked first.
[0479] In some embodiments, the prediction information of the current block includes at least two prediction modes corresponding to the geometric partitioning pattern; the first prediction unit 1802 is further configured to determine the prediction samples corresponding to at least some prediction modes based on the prediction method of the weight matrix when at least some prediction modes among the at least two prediction modes meet the preset conditions; and to determine the prediction samples of the current block based on the prediction samples corresponding to at least some prediction modes.
[0480] In some embodiments, the first determining unit 1801 is further configured to determine the value of a first syntax element; wherein the first syntax element is used to indicate whether the current block uses a geometric partitioning mode for prediction; the encoding unit 1803 is further configured to encode the value of the first syntax element and write the obtained encoded bits into the bitstream.
[0481] Understandably, in the embodiments of this application, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular one. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit described above can be implemented in hardware or as a software functional module.
[0482] In another embodiment of this application, FIG19 is a schematic diagram of the hardware structure of an encoder provided in an embodiment of this application. As shown in FIG19, the encoder 180 may include: a first communication interface 1901, a first memory 1902, and a first processor 1903; the various components are coupled together through a first bus system 1904. It is understood that the first bus system 1904 is used to realize the connection and communication between these components. In addition to a data bus, the first bus system 1904 also includes a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as the first bus system 1904 in FIG19.
[0483] The first communication interface 1901 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0484] The first memory 1902 is used to store computer programs that can run on the first processor 1903;
[0485] The first processor 1903 is configured to, when running the computer program, perform the following: when the current block is predicted using a geometric partitioning mode, determine the prediction information of the current block based on the template prediction value of the current block; wherein the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix; and predict the current block based on the prediction information to determine the prediction sample of the current block.
[0486] It is understood that the first memory 1902 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The first memory 1902 of the system and method described in this application is intended to include, but is not limited to, these and any other suitable types of memory.
[0487] The first processor 1903 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the first processor 1903 or by instructions in software form. The first processor 1903 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in the first memory 1902. The first processor 1903 reads the information in the first memory 1902 and, in conjunction with its hardware, completes the steps of the above method.
[0488] It is understood that the embodiments described in this application can be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application, or combinations thereof. For software implementation, the technology described in this application can be implemented through modules (e.g., procedures, functions, etc.) that perform the functions described in this application. Software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0489] Alternatively, as another embodiment, the first processor 1903 is also configured to perform the method described in any of the foregoing embodiments when running the computer program.
[0490] This embodiment provides an encoder that, when the current block uses geometric partitioning modes such as GPM or SGPM, can not only use a prediction method based on the weight matrix during the prediction process, but also use the same method to determine the template prediction value of the current block for steps such as calculating the template error and deriving weight information. This makes the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, increasing coding efficiency, and ultimately improving coding performance.
[0491] In another embodiment of this application, based on the same inventive concept as the foregoing embodiments, FIG20 is a schematic diagram of the composition structure of a decoder provided in an embodiment of this application. As shown in FIG20, the decoder 200 may include a decoding unit 2001, a second determining unit 2002, and a second predicting unit 2003, wherein:
[0492] Decoding unit 2001 is configured to parse the first syntax element in the bitstream;
[0493] The second determining unit 2002 is configured to determine the prediction information of the current block based on the template prediction value of the current block when the first syntax element indicates that the current block uses a geometric partitioning mode for prediction; wherein the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix.
[0494] The second prediction unit 2003 is configured to predict the current block based on the prediction information and determine the prediction sample of the current block.
[0495] In some embodiments, the prediction information includes weight information, and the second determining unit 2002 is further configured to determine the weight information of the current block based on the template prediction value of the current block.
[0496] In some embodiments, the second determining unit 2002 is further configured to: determine template prediction values of the current block in at least two prediction modes corresponding to the geometric partitioning mode; determine at least one set of training samples based on the template prediction values in the at least two prediction modes and the template reconstruction values of the template region; determine model parameters of a preset weight model based on the at least one set of training samples; and determine weight information of the current block based on the model parameters of the preset weight model.
[0497] In some embodiments, the second determining unit 2002 is further configured to, when the first prediction mode in at least two prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix to determine the template prediction value under the first prediction mode; and when the second prediction mode in at least two prediction modes does not meet the preset conditions, predict the template region of the current block according to the second prediction mode to determine the template prediction value under the second prediction mode.
[0498] In some embodiments, the second determining unit 2002 is further configured to determine a candidate list for the current block based on the template prediction value of the current block; wherein the candidate list includes at least one set of candidate prediction information; and to determine the prediction information of the current block based on the candidate list.
[0499] In some embodiments, the decoding unit 2001 is further configured to parse the prediction mode index in the bitstream; the second determining unit 2002 is further configured to determine the prediction information of the current block based on the prediction mode index and the candidate list of the current block.
[0500] In some embodiments, the second determining unit 2002 is further configured to determine at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; determine a first candidate list for the current block based on at least one set of prediction mode combinations and at least one candidate partitioning method; and determine a candidate list for the current block based on the first candidate list.
[0501] In some embodiments, the second determining unit 2002 is further configured to determine at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; determine a second candidate list for the current block based on the at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations; and determine a candidate list for the current block based on the second candidate list.
[0502] In some embodiments, the second determining unit 2002 is further configured to determine at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; determine a first candidate list for the current block based on at least one set of prediction mode combinations and at least one candidate partitioning method; determine a second candidate list for the current block based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode groups; and determine a candidate list for the current block based on the first candidate list and the second candidate list.
[0503] In some embodiments, the second determining unit 2002 is further configured to: determine at least one set of first candidate prediction information based on at least one set of prediction mode combinations and at least one candidate partitioning method, wherein the first candidate prediction information includes at least two candidate prediction modes and one candidate partitioning method contained in a set of prediction mode combinations; calculate the template error of the template region of the current block based on the at least one set of first candidate prediction information to determine the template error value corresponding to each of the at least one set of first candidate prediction information; and sort the at least one set of first candidate prediction information in ascending order based on the template error value, and form the first candidate list of the current block by the N1 sets of first candidate prediction information that are ranked first; wherein N1 is a positive integer.
[0504] In some embodiments, the second determining unit 2002 is further configured to predict the template region of the current block according to at least two candidate prediction modes in the first candidate prediction information, and determine the template prediction value corresponding to each of the at least two candidate prediction modes; and to calculate the template error value corresponding to the first candidate prediction information according to the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
[0505] In some embodiments, the second determining unit 2002 is further configured to: when the first candidate prediction mode among at least two candidate prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix to determine the template prediction value corresponding to the first candidate prediction mode; and when the second candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, predict the template region of the current block according to the second candidate prediction mode to determine the template prediction value corresponding to the second candidate prediction mode.
[0506] In some embodiments, the first reference template of the current block includes a reference sample of the first left template and a reference sample of the first top template; the second determining unit 2002 is further configured to determine a first weight matrix of the current block; determine the predicted value of the first left template based on the first weight matrix and the reference sample of the first left template; determine the predicted value of the first top template based on the first weight matrix and the reference sample of the first top template; and determine the template predicted value corresponding to the first candidate prediction mode based on the predicted value of the first left template and / or the predicted value of the first top template.
[0507] In some embodiments, the second determining unit 2002 is further configured to predict the template region of the current block according to the first prediction mode combination, determine the template prediction value corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination; determine at least one set of training samples according to the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region; determine the first candidate model parameters of the preset weight model according to the at least one set of training samples; and determine the candidate weight information corresponding to the first prediction mode combination according to the first candidate model parameters; wherein the first prediction mode combination is any one of the at least one set of prediction mode combinations.
[0508] In some embodiments, the second determining unit 2002 is further configured to, when the third candidate prediction mode among at least two candidate prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix and determine the template prediction value corresponding to the third candidate prediction mode; and when the fourth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, predict the template region of the current block according to the fourth candidate prediction mode and determine the template prediction value corresponding to the fourth candidate prediction mode.
[0509] In some embodiments, the second reference template of the current block includes a reference sample of the second left template and a reference sample of the second top template; the second determining unit 2002 is further configured to determine a second weight matrix of the current block; determine a predicted value of the second left template based on the second weight matrix and the reference sample of the second left template; determine a predicted value of the second top template based on the second weight matrix and the reference sample of the second top template; and determine a template predicted value corresponding to the third candidate prediction mode based on the predicted value of the second left template and / or the predicted value of the second top template.
[0510] In some embodiments, the second determining unit 2002 is further configured to: determine at least one set of second candidate prediction information based on at least one set of prediction mode combinations and candidate weight information derived from each of the at least one set of prediction mode combinations; wherein the second candidate prediction information includes at least two candidate prediction modes contained in a set of prediction mode combinations and candidate weight information derived from the prediction mode combinations; calculate template error for the template region of the current block based on the at least one set of second candidate prediction information to determine the template error value corresponding to each of the at least one set of second candidate prediction information; and sort the at least one set of second candidate prediction information in ascending order based on the template error value, and form a second candidate list for the current block from the top N2 sets of second candidate prediction information; wherein N2 is a positive integer.
[0511] In some embodiments, the second determining unit 2002 is further configured to predict the template region of the current block according to at least two candidate prediction modes in the second candidate prediction information, and determine the template prediction value corresponding to each of the at least two candidate prediction modes; and to calculate the template error value corresponding to the second candidate prediction information according to the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
[0512] In some embodiments, the second determining unit 2002 is further configured to, when the fifth candidate prediction mode among at least two candidate prediction modes meets the preset conditions, predict the template region of the current block based on the prediction method of the weight matrix and determine the template prediction value corresponding to the fifth candidate prediction mode; and when the sixth candidate prediction mode among at least two candidate prediction modes does not meet the preset conditions, predict the template region of the current block according to the sixth candidate prediction mode and determine the template prediction value corresponding to the sixth candidate prediction mode.
[0513] In some embodiments, the second determining unit 2002 is further configured to: predict the template region of the current block based on a first prediction method; determine a first template error value corresponding to each of at least one set of first candidate prediction information; sort the at least one set of first candidate prediction information from smallest to largest according to the first template error value; determine at least two sets of candidate prediction information that are ranked first; predict the template region of the current block based on a prediction method using a weight matrix; determine a second template error value corresponding to each of at least two sets of candidate prediction information; and sort the at least two sets of candidate prediction information from smallest to largest according to the second template error value, forming a first candidate list of the current block from the N1 sets of candidate prediction information that are ranked first; wherein the first prediction method does not include a prediction method based on a weight matrix.
[0514] In some embodiments, the second determining unit 2002 is further configured to: predict the template region of the current block based on a first prediction method; determine the first template error value corresponding to each of at least one set of second candidate prediction information; sort the at least one set of second candidate prediction information from smallest to largest according to the first template error value; determine at least two sets of candidate prediction information that are ranked first; predict the template region of the current block based on a prediction method using a weight matrix; determine the second template error value corresponding to each of at least two sets of candidate prediction information; and sort the at least two sets of candidate prediction information from smallest to largest according to the second template error value, forming a second candidate list of the current block from the top N2 sets of candidate prediction information; wherein the first prediction method does not include a prediction method based on a weight matrix.
[0515] In some embodiments, the second determining unit 2002 is further configured to predict the template region of the current block based on the prediction method of the weight matrix, determine the third template error value corresponding to each of K sets of candidate prediction information in at least two sets of candidate prediction information; wherein K is a positive integer; and update the first template error value corresponding to each of the at least two sets of candidate prediction information according to the third template error value corresponding to each of the K sets of candidate prediction information, and determine the second template error value corresponding to each of the at least two sets of candidate prediction information.
[0516] In some embodiments, the second determining unit 2002 is further configured to determine the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information.
[0517] In some embodiments, the second determining unit 2002 is further configured to determine the minimum value of the first template error value and the third template error value as the second template error value corresponding to each of the K groups of candidate prediction information, based on the first template error value and the third template error value corresponding to each of the K groups of candidate prediction information.
[0518] In some embodiments, the second determining unit 2002 is further configured to determine the first m groups of candidate prediction information as K groups of candidate prediction information when the first m groups of candidate prediction information in at least two groups of candidate prediction information meet the preset conditions; or, when any one group of candidate prediction information in the first m groups of at least two groups of candidate prediction information meets the preset conditions, determine the candidate prediction information in the first m groups that meets the preset conditions as K groups of candidate prediction information.
[0519] In some embodiments, the second determining unit 2002 is further configured to predict the template region of the current block based on the prediction method of the weight matrix, determine the third template error value corresponding to the first K1 groups of first candidate prediction information in at least one group of first candidate prediction information; wherein K1 is a positive integer; update the first template error value corresponding to the first group of first candidate prediction information according to the third template error value corresponding to the first group of first candidate prediction information, determine the second template error value corresponding to the first group of first candidate prediction information; and sort the at least one group of first candidate prediction information from smallest to largest according to the second template error value, and form the first candidate list of the current block by the N1 groups of first candidate prediction information that are ranked first.
[0520] In some embodiments, the second determining unit 2002 is further configured to predict the template region of the current block based on the prediction method of the weight matrix, and determine the third template error value corresponding to the first K2 groups of second candidate prediction information in at least one group of second candidate prediction information; wherein K2 is a positive integer; update the first template error value corresponding to the at least one group of second candidate prediction information according to the third template error value corresponding to the K2 groups of second candidate prediction information, and determine the second template error value corresponding to the at least one group of second candidate prediction information; and sort the at least one group of second candidate prediction information from smallest to largest according to the second template error value, and form the second candidate list of the current block by the N2 groups of second candidate prediction information that are ranked first.
[0521] In some embodiments, the prediction information of the current block includes at least two prediction modes corresponding to the geometric partitioning pattern; the second prediction unit 2003 is further configured to determine the prediction samples corresponding to at least some prediction modes based on the prediction method of the weight matrix when at least some prediction modes among the at least two prediction modes meet the preset conditions; and to determine the prediction samples of the current block based on the prediction samples corresponding to at least some prediction modes.
[0522] Understandably, in this embodiment, a "unit" can be a portion of a circuit, a portion of a processor, a portion of a program or software, etc., and can also be a module or a non-modular component. Furthermore, the components in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional module.
[0523] In another embodiment of this application, FIG21 is a schematic diagram of the hardware structure of a decoder provided in an embodiment of this application. As shown in FIG21, the decoder 200 may include: a second communication interface 2101, a second memory 2102, and a second processor 2103; the various components are coupled together through a second bus system 2104. It is understood that the second bus system 2104 is used to realize the connection and communication between these components. In addition to a data bus, the second bus system 2104 also includes a power bus, a control bus, and a status signal bus. However, for clarity, all buses are labeled as the second bus system 2104 in FIG21.
[0524] The second communication interface 2101 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0525] The second memory 2102 is used to store computer programs that can run on the second processor 2103;
[0526] The second processor 2103 is configured to, when running the computer program, perform the following: parse a first syntax element in the code stream; when the first syntax element indicates that the current block is predicted using a geometric partitioning mode, determine the prediction information of the current block based on the template prediction value of the current block; wherein the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix; and predict the current block based on the prediction information to determine the prediction sample of the current block.
[0527] Alternatively, as another embodiment, the second processor 2103 is also configured to perform the method described in any of the foregoing embodiments when running the computer program.
[0528] It is understood that the second memory 2102 has similar hardware functions to the first memory 1902, and the second processor 2103 has similar hardware functions to the first processor 1903; these will not be described in detail here.
[0529] This embodiment provides a decoder that, when the current block uses geometric partitioning modes such as GPM or SGPM, can not only use a prediction method based on the weight matrix during the prediction process, but also use the same method to determine the template prediction value of the current block for steps such as calculating the template error and deriving weight information. This makes the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, enhancing decoding efficiency, and ultimately improving decoding performance.
[0530] In another embodiment of this application, FIG22 is a schematic diagram of the composition structure of an encoding and decoding system provided in an embodiment of this application. As shown in FIG22, the encoding and decoding system 220 may include an encoder 2201 and a decoder 2202.
[0531] In this embodiment, encoder 2201 can be any of the encoders described in the foregoing embodiments, and decoder 2202 can be any of the decoders described in the foregoing embodiments.
[0532] In some embodiments, this application also provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the method as described in any of the foregoing embodiments. Specifically, when executed by a first processor, the computer program implements the encoding method as described in any of the foregoing embodiments, or when executed by a second processor, it implements the decoding method as described in any of the foregoing embodiments.
[0533] In some embodiments, this application also provides a computer program product, including a computer program or instructions. When executed by a processor, the computer program or instructions implement the method as described in any of the foregoing embodiments. Specifically, when executed by a first processor, the computer program or instructions implement the encoding method as described in any of the foregoing embodiments, or when executed by a second processor, they implement the decoding method as described in any of the foregoing embodiments.
[0534] In some embodiments, this application also provides a computer program that, when executed by a processor, implements the method as described in any of the foregoing embodiments. Specifically, when executed by a first processor, the computer program or instructions implement the encoding method as described in any of the foregoing embodiments, or when executed by a second processor, implement the decoding method as described in any of the foregoing embodiments.
[0535] In some embodiments, this application also provides a computer-readable storage medium storing a bitstream thereon. The bitstream is generated by performing the steps of the encoding method as described in any of the foregoing embodiments.
[0536] In this embodiment of the application, the information to be encoded in the encoding method includes at least one of the following: the value of the first syntax element, the prediction mode index of the current block, and the residual sample of the current block. Here, this information to be encoded is encoded to write it into the bitstream.
[0537] Those skilled in the art will recognize that the units and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art 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.
[0538] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described apparatus and unit can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0539] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0540] The units described as separate components may or may not be physically separate. 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 can be selected to achieve the purpose of this embodiment according to actual needs.
[0541] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0542] It should be noted that, in this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0543] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0544] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0545] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0546] The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method or device embodiments.
[0547] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims. Industrial applicability
[0548] In this embodiment, whether at the encoding or decoding end, when it is determined that the current block uses a geometric partitioning mode for prediction, the prediction information of the current block is determined based on the template prediction value of the current block. Specifically, the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on a weight matrix prediction method. The current block is then predicted based on the prediction information to determine the prediction sample of the current block. Thus, when the current block uses geometric partitioning modes such as GPM or SGPM, not only can a weight matrix-based prediction method be used during the prediction process, but also in determining the prediction information of the current block, the same weight matrix-based prediction method can be used to determine the template prediction value of the current block for steps such as calculating the template error and deriving weight information. This makes the template error and derived weight information of the current block more accurate, thereby improving the prediction accuracy of the current block, increasing encoding and decoding efficiency, and ultimately improving encoding and decoding performance.
Claims
1. A decoding method applied to a decoder, the method comprising: Parse the first syntax element in the bitstream; When the first syntax element instructs the current block to use a geometric partitioning mode for prediction, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix; Based on the prediction information, a prediction sample for the current block is determined.
2. The method according to claim 1, wherein, The prediction information includes weight information. Determining the prediction information for the current block based on the template prediction value of the current block includes: The weight information of the current block is determined based on the template prediction value of the current block.
3. The method according to claim 2, wherein, Determining the weight information of the current block based on the template prediction value of the current block includes: Determine the template prediction value of the current block under at least two prediction modes corresponding to the geometric partitioning mode; Based on the template prediction values under the at least two prediction modes and the template reconstruction values of the template region, at least one set of training samples is determined; The model parameters of the preset weight model are determined based on the at least one set of training samples; The weight information of the current block is determined based on the model parameters of the preset weight model.
4. The method according to claim 3, wherein, The method further includes: When the first prediction mode in the at least two prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value under the first prediction mode. When the second prediction mode in the at least two prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second prediction mode to determine the template prediction value under the second prediction mode.
5. The method according to claim 1, wherein, Determining the prediction information of the current block based on the template prediction value of the current block includes: Based on the template prediction value of the current block, a candidate list for the current block is determined; wherein the candidate list includes at least one set of candidate prediction information; Based on the candidate list, the prediction information for the current block is determined.
6. The method according to claim 5, wherein, Determining the prediction information of the current block based on the candidate list of the current block includes: Parse the prediction mode index in the bitstream; The prediction information for the current block is determined based on the prediction mode index and the candidate list of the current block.
7. The method according to claim 5, wherein, Determining the candidate list for the current block includes: Identify at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; The first candidate list of the current block is determined based on the at least one set of prediction mode combinations and at least one candidate partitioning method; Based on the first candidate list, a candidate list for the current block is determined.
8. The method according to claim 5, wherein, Determining the candidate list for the current block includes: Identify at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; A second candidate list for the current block is determined based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations. The candidate list for the current block is determined based on the second candidate list.
9. The method according to claim 5, wherein, Determining the candidate list for the current block includes: Identify at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; The first candidate list of the current block is determined based on the at least one set of prediction mode combinations and at least one candidate partitioning method; The second candidate list of the current block is determined based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations. The candidate list for the current block is determined based on the first candidate list and the second candidate list.
10. The method according to claim 7 or 9, wherein, Determining the first candidate list of the current block based on the at least one set of prediction mode combinations and at least one candidate partitioning method includes: Based on the at least one set of prediction mode combinations and the at least one candidate partitioning method, at least one set of first candidate prediction information is determined, and the first candidate prediction information includes at least two candidate prediction modes contained in the prediction mode combinations and one candidate partitioning method. Based on the at least one set of first candidate prediction information, the template error of the template region of the current block is calculated, and the template error value corresponding to each of the at least one set of first candidate prediction information is determined. The at least one set of first candidate prediction information is sorted from smallest to largest according to the template error value, and the top N1 sets of first candidate prediction information are used to form the first candidate list of the current block; where N1 is a positive integer.
11. The method according to claim 10, wherein, The step of calculating the template error of the template region of the current block based on the at least one set of first candidate prediction information, and determining the template error value corresponding to each of the at least one set of first candidate prediction information, includes: Based on at least two candidate prediction patterns in the first candidate prediction information, the template region of the current block is predicted, and the template prediction value corresponding to each of the at least two candidate prediction patterns is determined. The template error value corresponding to the first candidate prediction information is determined by calculating the template error based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
12. The method according to claim 11, wherein, The step of predicting the template region of the current block based on at least two candidate prediction patterns in the first candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, includes: When the first candidate prediction mode among the at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix, and the template prediction value corresponding to the first candidate prediction mode is determined. When the second candidate prediction mode among the at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second candidate prediction mode to determine the template prediction value corresponding to the second candidate prediction mode.
13. The method according to claim 12, wherein, The first reference template of the current block includes a reference sample of the first left template and a reference sample of the first upper template; The prediction method based on the weight matrix predicts the template region of the current block and determines the template prediction value corresponding to the first candidate prediction mode, including: Determine the first weight matrix of the current block; Based on the first weight matrix and the reference sample of the first left template, the predicted value of the first left template is determined; Based on the first weight matrix and the reference sample of the first upper template, the predicted value of the first upper template is determined; Based on the predicted value of the first left template and / or the predicted value of the first upper template, determine the template prediction value corresponding to the first candidate prediction mode.
14. The method according to claim 8 or 9, wherein, The method further includes: The template region of the current block is predicted according to the first prediction mode combination, and the template prediction value corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination is determined. Based on the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction values of the template region, at least one set of training samples is determined; and based on the at least one set of training samples, the first candidate model parameters of the preset weight model are determined. Based on the parameters of the first candidate model, determine the candidate weight information corresponding to the first prediction mode combination; Wherein, the first prediction mode combination is any one of the at least one prediction mode combination.
15. The method according to claim 14, wherein, The step of predicting the template region of the current block according to the first prediction mode combination, and determining the template prediction value corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination, includes: When the third candidate prediction mode among the at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix, and the template prediction value corresponding to the third candidate prediction mode is determined. When the fourth candidate prediction mode among the at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the fourth candidate prediction mode to determine the template prediction value corresponding to the fourth candidate prediction mode.
16. The method according to claim 15, wherein, The second reference template of the current block includes a reference sample of the second left template and a reference sample of the second top template; The prediction method based on the weight matrix predicts the template region of the current block and determines the template prediction value corresponding to the third candidate prediction mode, including: Determine the second weight matrix of the current block; Based on the second weight matrix and the reference sample of the second left template, the predicted value of the second left template is determined; Based on the second weight matrix and the reference sample of the second upper template, the predicted value of the second upper template is determined; Based on the predicted value of the second left template and / or the predicted value of the second upper template, the template prediction value corresponding to the third candidate prediction mode is determined.
17. The method according to claim 8, 9, 14, 15 or 16, wherein, The step of determining the second candidate list for the current block based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations includes: Based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations, at least one set of second candidate prediction information is determined, and the second candidate prediction information includes at least two candidate prediction modes contained in the prediction mode combination and the candidate weight information derived from the prediction mode combination. Based on the at least one set of second candidate prediction information, the template error of the template region of the current block is calculated, and the template error value corresponding to each of the at least one set of second candidate prediction information is determined. The at least one set of second candidate prediction information is sorted from smallest to largest according to the template error value, and the top N2 sets of second candidate prediction information are used to form the second candidate list of the current block; where N2 is a positive integer.
18. The method according to claim 17, wherein, The step of calculating the template error of the template region of the current block based on the at least one set of second candidate prediction information, and determining the template error value corresponding to each of the at least one set of second candidate prediction information, includes: Based on at least two candidate prediction patterns in the second candidate prediction information, the template region of the current block is predicted, and the template prediction value corresponding to each of the at least two candidate prediction patterns is determined. The template error value corresponding to the second candidate prediction information is determined by calculating the template error based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
19. The method according to claim 18, wherein, The step of predicting the template region of the current block based on at least two candidate prediction patterns in the second candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, includes: When the fifth candidate prediction mode among the at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix, and the template prediction value corresponding to the fifth candidate prediction mode is determined. When the sixth candidate prediction mode among the at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the sixth candidate prediction mode to determine the template prediction value corresponding to the sixth candidate prediction mode.
20. The method of claim 10, wherein, The method further includes: Based on the first prediction method, the template region of the current block is predicted, and the first template error value corresponding to each of the at least one set of first candidate prediction information is determined; Based on the first template error value, sort the at least one set of first candidate prediction information from smallest to largest, and determine at least two sets of candidate prediction information that rank first. The template region of the current block is predicted based on the weight matrix prediction method, and the second template error value corresponding to each of the at least two sets of candidate prediction information is determined. Based on the second template error value, sort the at least two sets of candidate prediction information from smallest to largest, and form the first candidate list of the current block by the N1 sets of candidate prediction information that are ranked first. The first prediction method does not include prediction methods based on weight matrices.
21. The method according to claim 17, wherein, The method further includes: Based on the first prediction method, the template region of the current block is predicted, and the first template error value corresponding to each of the at least one set of second candidate prediction information is determined; Based on the first template error value, sort the at least one set of second candidate prediction information from smallest to largest, and determine at least two sets of candidate prediction information that rank first. The template region of the current block is predicted based on the weight matrix prediction method, and the second template error value corresponding to each of the at least two sets of candidate prediction information is determined. Based on the second template error value, sort the at least two sets of candidate prediction information from smallest to largest, and form the second candidate list of the current block by the N2 sets of candidate prediction information that are ranked first. The first prediction method does not include prediction methods based on weight matrices.
22. The method according to claim 20 or 21, wherein, The prediction method based on the weight matrix predicts the template region of the current block and determines the second template error value corresponding to each of the at least two sets of candidate prediction information, including: The template region of the current block is predicted based on the weight matrix prediction method, and the third template error value corresponding to each of the K sets of candidate prediction information in the at least two sets of candidate prediction information is determined; where K is a positive integer. The first template error values corresponding to each of the at least two groups of candidate prediction information are updated based on the third template error values corresponding to each of the K groups of candidate prediction information, and the second template error values corresponding to each of the at least two groups of candidate prediction information are determined.
23. The method according to claim 22, wherein, The method further includes: The third template error value is determined as the second template error value corresponding to each of the K groups of candidate prediction information.
24. The method according to claim 22, wherein, The method further includes: Based on the first template error value and the third template error value corresponding to each of the K groups of candidate prediction information, the minimum value among the first template error value and the third template error value is determined as the second template error value corresponding to each of the K groups of candidate prediction information.
25. The method according to claim 22, wherein, The method further includes: When the first m groups of candidate prediction information among the at least two groups of candidate prediction information meet preset conditions, the first m groups of candidate prediction information are determined as the K groups of candidate prediction information; or, When any one of the first m groups of candidate prediction information in the at least two groups of candidate prediction information meets the preset conditions, the candidate prediction information in the first m groups that meets the preset conditions is determined as the K group of candidate prediction information.
26. The method of claim 20, wherein, The method further includes: The template region of the current block is predicted based on the weight matrix prediction method, and the third template error value corresponding to the first K1 groups of first candidate prediction information in the at least one group of first candidate prediction information is determined; where K1 is a positive integer; The first template error value corresponding to each of the at least one group of first candidate prediction information is updated according to the third template error value corresponding to each of the first candidate prediction information in the K1 group, and the second template error value corresponding to each of the at least one group of first candidate prediction information is determined. The first candidate prediction information is sorted from smallest to largest according to the second template error value, and the first candidate prediction information of the top N1 groups is used to form the first candidate list of the current block.
27. The method according to claim 21, wherein, The method further includes: The template region of the current block is predicted based on the weight matrix prediction method, and the third template error value corresponding to the first K2 groups of second candidate prediction information in the at least one group of second candidate prediction information is determined; where K2 is a positive integer; The first template error value corresponding to each of the at least one group of second candidate prediction information is updated according to the third template error value corresponding to each of the K2 groups of second candidate prediction information, and the second template error value corresponding to each of the at least one group of second candidate prediction information is determined. The at least one set of second candidate prediction information is sorted from smallest to largest according to the second template error value, and the top N2 sets of second candidate prediction information are used to form the second candidate list of the current block.
28. The method according to any one of claims 1 to 27, wherein, The prediction information of the current block includes at least two prediction modes corresponding to the geometric partitioning mode; the step of predicting the current block based on the prediction information to determine the prediction sample of the current block includes: When at least some of the prediction modes among the at least two prediction modes meet the preset conditions, the prediction samples corresponding to the at least some prediction modes are determined based on the prediction method of the weight matrix. The prediction sample for the current block is determined based on the prediction samples corresponding to at least some of the prediction modes.
29. An encoding method applied to an encoder, the method comprising: When the current block is predicted using a geometric partitioning mode, the prediction information of the current block is determined based on the template prediction value of the current block; wherein, the template prediction value of at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix; Based on the prediction information, a prediction sample for the current block is determined.
30. The method according to claim 29, wherein, The prediction information includes weight information. Determining the prediction information for the current block based on the template prediction value of the current block includes: The weight information of the current block is determined based on the template prediction value of the current block.
31. The method according to claim 30, wherein, Determining the weight information of the current block based on the template prediction value of the current block includes: Determine the template prediction value of the current block under at least two prediction modes corresponding to the geometric partitioning mode; Based on the template prediction values under the at least two prediction modes and the template reconstruction values of the template region, at least one set of training samples is determined; The model parameters of the preset weight model are determined based on the at least one set of training samples; The weight information of the current block is determined based on the model parameters of the preset weight model.
32. The method according to claim 31, wherein, The method further includes: When the first prediction mode in the at least two prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix to determine the template prediction value under the first prediction mode. When the second prediction mode in the at least two prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second prediction mode to determine the template prediction value under the second prediction mode.
33. The method according to claim 29, wherein, Determining the prediction information of the current block based on the template prediction value of the current block includes: Based on the template prediction value of the current block, a candidate list for the current block is determined; wherein the candidate list includes at least one set of candidate prediction information; Based on the candidate list, the prediction information for the current block is determined.
34. The method according to claim 33, wherein, Determining the prediction information of the current block based on the candidate list of the current block includes: The encoding cost of the current block is calculated for at least one set of candidate prediction information in the candidate list, and the cost result corresponding to the at least one set of candidate prediction information is determined. The minimum cost result is determined from the cost results corresponding to the at least one set of candidate prediction information, and the candidate prediction information corresponding to the minimum cost result is determined as the prediction information of the current block.
35. The method according to claim 33 or 34, wherein, The method further includes: Determine the prediction mode index of the current block, wherein the prediction mode index is used to indicate the index number of the prediction information of the current block in the candidate list; The prediction mode index of the current block is encoded, and the resulting encoded bits are written into the bitstream.
36. The method according to claim 33, wherein, Determining the candidate list for the current block includes: Identify at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; The first candidate list of the current block is determined based on the at least one set of prediction mode combinations and at least one candidate partitioning method; Based on the first candidate list, a candidate list for the current block is determined.
37. The method according to claim 33, wherein, Determining the candidate list for the current block includes: Identify at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; A second candidate list for the current block is determined based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations. The candidate list for the current block is determined based on the second candidate list.
38. The method according to claim 33, wherein, Determining the candidate list for the current block includes: Identify at least one set of prediction mode combinations, and each set of prediction mode combinations includes at least two candidate prediction modes; The first candidate list of the current block is determined based on the at least one set of prediction mode combinations and at least one candidate partitioning method; The second candidate list of the current block is determined based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations. The candidate list for the current block is determined based on the first candidate list and the second candidate list.
39. The method according to claim 36 or 38, wherein, Determining the first candidate list of the current block based on the at least one set of prediction mode combinations and at least one candidate partitioning method includes: Based on the at least one set of prediction mode combinations and the at least one candidate partitioning method, at least one set of first candidate prediction information is determined, and the first candidate prediction information includes at least two candidate prediction modes contained in the prediction mode combinations and one candidate partitioning method. Based on the at least one set of first candidate prediction information, the template error of the template region of the current block is calculated, and the template error value corresponding to each of the at least one set of first candidate prediction information is determined. The at least one set of first candidate prediction information is sorted from smallest to largest according to the template error value, and the top N1 sets of first candidate prediction information are used to form the first candidate list of the current block; where N1 is a positive integer.
40. The method according to claim 39, wherein, The step of calculating the template error of the template region of the current block based on the at least one set of first candidate prediction information, and determining the template error value corresponding to each of the at least one set of first candidate prediction information, includes: Based on at least two candidate prediction patterns in the first candidate prediction information, the template region of the current block is predicted, and the template prediction value corresponding to each of the at least two candidate prediction patterns is determined. The template error value corresponding to the first candidate prediction information is determined by calculating the template error based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
41. The method according to claim 40, wherein, The step of predicting the template region of the current block based on at least two candidate prediction patterns in the first candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, includes: When the first candidate prediction mode among the at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix, and the template prediction value corresponding to the first candidate prediction mode is determined. When the second candidate prediction mode among the at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the second candidate prediction mode to determine the template prediction value corresponding to the second candidate prediction mode.
42. The method according to claim 41, wherein, The first reference template of the current block includes a reference sample of the first left template and a reference sample of the first upper template; The prediction method based on the weight matrix predicts the template region of the current block and determines the template prediction value corresponding to the first candidate prediction mode, including: Determine the first weight matrix of the current block; Based on the first weight matrix and the reference sample of the first left template, the predicted value of the first left template is determined; Based on the first weight matrix and the reference sample of the first upper template, the predicted value of the first upper template is determined; Based on the predicted value of the first left template and / or the predicted value of the first upper template, determine the template prediction value corresponding to the first candidate prediction mode.
43. The method of claim 37 or 38, wherein, The method further includes: The template region of the current block is predicted according to the first prediction mode combination, and the template prediction value corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination is determined. Based on the template prediction values corresponding to at least two candidate prediction modes and the template reconstruction values of the template region, at least one set of training samples is determined; and based on the at least one set of training samples, the first candidate model parameters of the preset weight model are determined. Based on the parameters of the first candidate model, determine the candidate weight information corresponding to the first prediction mode combination; Wherein, the first prediction mode combination is any one of the at least one prediction mode combination.
44. The method of claim 43, wherein, The step of predicting the template region of the current block according to the first prediction mode combination, and determining the template prediction value corresponding to each of the at least two candidate prediction modes included in the first prediction mode combination, includes: When the third candidate prediction mode among the at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix, and the template prediction value corresponding to the third candidate prediction mode is determined. When the fourth candidate prediction mode among the at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the fourth candidate prediction mode to determine the template prediction value corresponding to the fourth candidate prediction mode.
45. The method of claim 44, wherein, The second reference template of the current block includes a reference sample of the second left template and a reference sample of the second top template; The prediction method based on the weight matrix predicts the template region of the current block and determines the template prediction value corresponding to the third candidate prediction mode, including: Determine the second weight matrix of the current block; Based on the second weight matrix and the reference sample of the second left template, the predicted value of the second left template is determined; Based on the second weight matrix and the reference sample of the second upper template, the predicted value of the second upper template is determined; Based on the predicted value of the second left template and / or the predicted value of the second upper template, the template prediction value corresponding to the third candidate prediction mode is determined.
46. The method of claim 37, 38, 43, 44, or 45, wherein, The step of determining the second candidate list for the current block based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations includes: Based on the at least one set of prediction mode combinations and the candidate weight information derived from each of the at least one set of prediction mode combinations, at least one set of second candidate prediction information is determined, and the second candidate prediction information includes at least two candidate prediction modes contained in the prediction mode combination and the candidate weight information derived from the prediction mode combination. Based on the at least one set of second candidate prediction information, the template error of the template region of the current block is calculated, and the template error value corresponding to each of the at least one set of second candidate prediction information is determined. The at least one set of second candidate prediction information is sorted from smallest to largest according to the template error value, and the top N2 sets of second candidate prediction information are used to form the second candidate list of the current block; where N2 is a positive integer.
47. The method of claim 46, wherein, The step of calculating the template error of the template region of the current block based on the at least one set of second candidate prediction information, and determining the template error value corresponding to each of the at least one set of second candidate prediction information, includes: Based on at least two candidate prediction patterns in the second candidate prediction information, the template region of the current block is predicted, and the template prediction value corresponding to each of the at least two candidate prediction patterns is determined. The template error value corresponding to the second candidate prediction information is determined by calculating the template error based on the template prediction value corresponding to each of the at least two candidate prediction modes and the template reconstruction value of the template region.
48. The method of claim 47, wherein, The step of predicting the template region of the current block based on at least two candidate prediction patterns in the second candidate prediction information, and determining the template prediction value corresponding to each of the at least two candidate prediction patterns, includes: When the fifth candidate prediction mode among the at least two candidate prediction modes meets the preset conditions, the template region of the current block is predicted based on the prediction method of the weight matrix, and the template prediction value corresponding to the fifth candidate prediction mode is determined. When the sixth candidate prediction mode among the at least two candidate prediction modes does not meet the preset conditions, the template region of the current block is predicted according to the sixth candidate prediction mode to determine the template prediction value corresponding to the sixth candidate prediction mode.
49. The method of claim 39, wherein, The method further includes: Based on the first prediction method, the template region of the current block is predicted, and the first template error value corresponding to each of the at least one set of first candidate prediction information is determined; Based on the first template error value, sort the at least one set of first candidate prediction information from smallest to largest, and determine at least two sets of candidate prediction information that rank first. The template region of the current block is predicted based on the weight matrix prediction method, and the second template error value corresponding to each of the at least two sets of candidate prediction information is determined. Based on the second template error value, sort the at least two sets of candidate prediction information from smallest to largest, and form the first candidate list of the current block by the N1 sets of candidate prediction information that are ranked first. The first prediction method does not include prediction methods based on weight matrices.
50. The method of claim 46, wherein, The method further includes: Based on the first prediction method, the template region of the current block is predicted, and the first template error value corresponding to each of the at least one set of second candidate prediction information is determined; Based on the first template error value, sort the at least one set of second candidate prediction information from smallest to largest, and determine at least two sets of candidate prediction information that rank first. The template region of the current block is predicted based on the weight matrix prediction method, and the second template error value corresponding to each of the at least two sets of candidate prediction information is determined. Based on the second template error value, sort the at least two sets of candidate prediction information from smallest to largest, and form the second candidate list of the current block by the N2 sets of candidate prediction information that are ranked first. The first prediction method does not include prediction methods based on weight matrices.
51. The method of claim 49 or 50, wherein, The prediction method based on the weight matrix predicts the template region of the current block and determines the second template error value corresponding to each of the at least two sets of candidate prediction information, including: The template region of the current block is predicted based on the weight matrix prediction method, and the third template error value corresponding to each of the K sets of candidate prediction information in the at least two sets of candidate prediction information is determined; where K is a positive integer. The first template error values corresponding to each of the at least two groups of candidate prediction information are updated based on the third template error values corresponding to each of the K groups of candidate prediction information, and the second template error values corresponding to each of the at least two groups of candidate prediction information are determined.
52. The method according to claim 51, wherein, The method further includes: The third template error value is determined as the second template error value corresponding to each of the K groups of candidate prediction information.
53. The method according to claim 51, wherein, The method further includes: Based on the first template error value and the third template error value corresponding to each of the K groups of candidate prediction information, the minimum value among the first template error value and the third template error value is determined as the second template error value corresponding to each of the K groups of candidate prediction information.
54. The method according to claim 51, wherein, The method further includes: When the first m groups of candidate prediction information among the at least two groups of candidate prediction information meet preset conditions, the first m groups of candidate prediction information are determined as the K groups of candidate prediction information; or, When any one of the first m groups of candidate prediction information in the at least two groups of candidate prediction information meets the preset conditions, the candidate prediction information in the first m groups that meets the preset conditions is determined as the K group of candidate prediction information.
55. The method according to claim 49, wherein, The method further includes: The template region of the current block is predicted based on the weight matrix prediction method, and the third template error value corresponding to the first K1 groups of first candidate prediction information in the at least one group of first candidate prediction information is determined; where K1 is a positive integer; The first template error value corresponding to each of the at least one group of first candidate prediction information is updated according to the third template error value corresponding to each of the first candidate prediction information in the K1 group, and the second template error value corresponding to each of the at least one group of first candidate prediction information is determined. The first candidate prediction information is sorted from smallest to largest according to the second template error value, and the first candidate prediction information of the top N1 groups is used to form the first candidate list of the current block.
56. The method of claim 50, wherein, The method further includes: The template region of the current block is predicted based on the weight matrix prediction method, and the third template error value corresponding to the first K2 groups of second candidate prediction information in the at least one group of second candidate prediction information is determined; where K2 is a positive integer; The first template error value corresponding to each of the at least one group of second candidate prediction information is updated according to the third template error value corresponding to each of the K2 groups of second candidate prediction information, and the second template error value corresponding to each of the at least one group of second candidate prediction information is determined. The at least one set of second candidate prediction information is sorted from smallest to largest according to the second template error value, and the top N2 sets of second candidate prediction information are used to form the second candidate list of the current block.
57. The method according to any one of claims 29 to 56, wherein, The prediction information for the current block includes at least two prediction modes corresponding to the geometric partitioning mode; The step of predicting the current block based on the prediction information and determining the prediction sample for the current block includes: When at least some of the prediction modes among the at least two prediction modes meet the preset conditions, the prediction samples corresponding to the at least some prediction modes are determined based on the prediction method of the weight matrix. The prediction sample for the current block is determined based on the prediction samples corresponding to at least some of the prediction modes.
58. The method according to any one of claims 29 to 57, wherein, The method further includes: Determine the value of the first syntax element; wherein the first syntax element is used to indicate whether the current block uses a geometric partitioning pattern for prediction; The value of the first syntax element is encoded, and the resulting encoded bits are written into the bitstream.
59. An encoder, the encoder comprising a first determining unit and a first predicting unit, wherein: The first determining unit is configured to determine the prediction information of the current block based on the template prediction value of the current block when the current block is predicted using a geometric partitioning mode; wherein, the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix; The first prediction unit is configured to predict the current block based on the prediction information and determine the prediction sample of the current block.
60. An encoder, the encoder comprising a first memory and a first processor, wherein: The first memory is used to store computer programs that can run on the first processor; The first processor is configured to perform the method as described in any one of claims 29 to 58 when running the computer program.
61. A decoder, the decoder comprising a decoding unit, a second determining unit, and a second predicting unit, wherein: The decoding unit is configured to parse the first syntax element in the code stream; The second determining unit is configured to determine the prediction information of the current block based on the template prediction value of the current block when the first syntax element indicates that the current block is predicted using a geometric partitioning mode; wherein the template prediction value in at least some prediction modes corresponding to the geometric partitioning mode is obtained by predicting the template region of the current block based on the prediction method of the weight matrix. The second prediction unit is configured to predict the current block based on the prediction information and determine the prediction sample of the current block.
62. A decoder, the decoder comprising a second memory and a second processor, wherein: The second memory is used to store computer programs that can run on the second processor; The second processor is configured to perform the method as described in any one of claims 1 to 28 when running the computer program.
63. A computer-readable storage medium having a computer program stored thereon, wherein, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 28, or the method as described in any one of claims 29 to 58.
64. A computer-readable storage medium having a bitstream stored thereon, wherein, The bitstream is generated by performing the steps of the encoding method as described in any one of claims 29 to 58.