Coding method, decoding method, coder, decoder and storage medium
By introducing a new intra-frame prediction mode into the video coding standard and constructing distance and weight matrices using reference samples, the problem of inaccurate prediction for complex coding blocks in existing technologies is solved, thereby improving encoding and decoding efficiency and performance.
Patent Information
- Application Number
- PCT/CN2024/105575
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-07-15
- Publication Date
- 2026-01-22
AI Technical Summary
In existing video coding standards, intra-frame prediction mode cannot accurately predict complex coding blocks, resulting in low encoding and decoding efficiency.
A novel intra-frame prediction mode is adopted, which improves the prediction accuracy of luminance and chrominance components, reduces prediction complexity, and saves bitrate by determining the reference sample of the current block, constructing a distance matrix, and calculating a weight matrix.
It improves the prediction accuracy of luminance and chrominance components, reduces prediction complexity, saves bitrate, and improves encoding and decoding efficiency.
Smart Images

Figure CN2024105575_22012026_PF_FP_ABST
Abstract
Description
Encoding / decoding methods, 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, encoder, decoder, and storage medium. Background Technology
[0002] As people's demands for video display quality have increased, high-resolution video, such as HD and UHD, has emerged. However, high-resolution video typically contains more information, thus requiring more bandwidth. To reduce bandwidth requirements, video coding standards involving video compression have been introduced.
[0003] In video coding standards, intra-frame prediction includes luma intra-frame prediction and chroma intra-frame prediction. Both luma and chroma intra-frame prediction involve multiple prediction modes, and the choice of prediction mode determines the quality of intra-frame prediction. However, existing intra-frame prediction modes cannot accurately predict complex coded blocks, reducing encoding and decoding efficiency.
[0004] Summary of the Invention
[0005] This application provides an encoding / decoding method, encoder, decoder, and storage medium, which can improve encoding / decoding efficiency.
[0006] The technical solution of this application embodiment can be implemented as follows:
[0007] In a first aspect, embodiments of this application provide a decoding method applied to a decoder, the method comprising:
[0008] Parse the first syntax element in the bitstream;
[0009] When the first syntax element indicates that the first color component of the current block uses the first prediction mode, the reference sample of the current block is determined;
[0010] Based on the reference sample, the distance matrix of the current block is determined, wherein the distance matrix is used to represent the distance information between at least one sample in the current block and the reference sample;
[0011] The weight matrix of the current block is determined based on the distance matrix;
[0012] Based on the weight matrix and reference samples, determine the predicted value of the first color component of the current block.
[0013] Secondly, embodiments of this application provide an encoding method applied to an encoder, the method comprising:
[0014] When the first color component of the current block uses the first prediction mode, determine the reference sample of the current block;
[0015] Based on the reference sample, the distance matrix of the current block is determined, wherein the distance matrix is used to represent the distance information between at least one sample in the current block and the reference sample;
[0016] The weight matrix of the current block is determined based on the distance matrix;
[0017] Based on the weight matrix and reference samples, determine the predicted value of the first color component of the current block.
[0018] Thirdly, embodiments of this application provide a bitstream generated by bit encoding according to the encoding method of the second aspect. The information to be encoded in the encoding method includes at least one of the following: the value of a first parameter, the value of a first syntax element, and the value of a second syntax element; wherein the first syntax element is used to indicate whether the first color component of the current block uses a first prediction mode, and the second syntax element is used to indicate whether the second color component of the current block uses a DM mode.
[0019] Fourthly, embodiments of this application provide an encoder, which includes a first determining unit and a first predicting unit, wherein:
[0020] The first determining unit is configured to: determine a reference sample of the current block when the first color component of the current block uses a first prediction mode; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample; and determine a weight matrix of the current block according to the distance matrix.
[0021] The first prediction unit is configured to determine the predicted value of the first color component of the current block based on the weight matrix and the reference sample.
[0022] Fifthly, embodiments of this application provide an encoder, which includes a first memory and a first processor, wherein:
[0023] A first memory for storing computer programs that can run on a first processor;
[0024] A first processor is configured to execute the encoding method as described in the second aspect when running a computer program.
[0025] Sixthly, embodiments of this application provide a decoder, which includes a decoding unit, a second determining unit, and a second predicting unit, wherein:
[0026] The decoding unit is configured to parse the first syntax element in the bitstream;
[0027] The second determining unit is configured to: determine a reference sample of the current block when the first syntax element indicates that the first color component of the current block uses a first prediction mode; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; and determine a weight matrix of the current block according to the distance matrix.
[0028] The second prediction unit is configured to determine the predicted value of the first color component of the current block based on the weight matrix and the reference sample.
[0029] In a seventh aspect, embodiments of this application provide a decoder, which includes a second memory and a second processor, wherein:
[0030] The second memory is used to store computer programs that can run on the second processor;
[0031] The second processor is used to execute the decoding method as described in the first aspect when running a computer program.
[0032] Eighthly, 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.
[0033] In a ninth aspect, 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.
[0034] In a tenth aspect, embodiments of this application provide a computer program product, including a computer program or instructions that, 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.
[0035] This application provides an encoding / decoding method, an encoder, a decoder, and a storage medium. At the encoding end, when the first color component of the current block uses a first prediction mode, a reference sample for the current block is determined; based on the reference sample, a distance matrix for the current block is determined, wherein the distance matrix represents the distance information between at least one sample in the current block and the reference sample; a weight matrix for the current block is determined based on the distance matrix; and a predicted value for the first color component of the current block is determined based on the weight matrix and the reference sample. At the decoding end, a first syntax element in the bitstream is parsed; when the first syntax element indicates that the first color component of the current block uses the first prediction mode, a reference sample for the current block is determined; based on the reference sample, a distance matrix for the current block is determined, wherein the distance matrix represents the distance information between at least one sample in the current block and the reference sample; a weight matrix for the current block is determined based on the distance matrix; and a predicted value for the first color component of the current block is determined based on the weight matrix and the reference sample. Thus, based on the existing intra-frame prediction modes, this application embodiment adds a new intra-frame prediction mode (i.e., the first prediction mode). Specifically, it determines the distance matrix of the current block based on the reference sample, then determines the corresponding weight matrix based on the distance matrix, and finally determines the predicted value of the first color component of the current block based on the weight matrix and the reference sample. In this way, when the first prediction mode is applied to the luma component, the prediction accuracy of the luma component of the current block can be improved; when the first prediction mode is applied to the chroma component, the prediction accuracy of the chroma component of the current block can also be improved. Therefore, this process can achieve accurate prediction of the luma component of the current block and accurate prediction of the chroma component using the DM mode, while reducing prediction complexity, saving bitrate, improving encoding and decoding efficiency, and thus improving encoding and decoding performance. Attached Figure Description
[0036] Figure 1 is a schematic diagram of the coding framework based on VVC technology;
[0037] Figure 2 is a schematic diagram of the prediction process of the Planar model;
[0038] Figure 3 is a schematic diagram of a prediction block suitable for DC mode;
[0039] Figure 4 is a schematic diagram of the predicted direction of the angle prediction mode;
[0040] Figure 5 is a schematic diagram of the prediction process of the MIP model;
[0041] Figure 6 is a schematic diagram of the block partitioning structure in the DM mode;
[0042] Figure 7 is a schematic diagram of a video encoding and decoding network architecture provided in an embodiment of this application;
[0043] Figure 8 is a schematic block diagram of an encoder provided in an embodiment of this application;
[0044] Figure 9 is a schematic block diagram of a decoder provided in an embodiment of this application;
[0045] Figure 10 is a schematic flowchart of a decoding method provided in an embodiment of this application;
[0046] Figure 11 is a schematic diagram of an adjacent reference region provided in an embodiment of this application;
[0047] Figure 12 is a schematic diagram of the Softmax function under different conditions provided in an embodiment of this application;
[0048] Figure 13 is a schematic flowchart of a decoding method provided in an embodiment of this application;
[0049] Figure 14 is a schematic flowchart of a decoding method provided in an embodiment of this application;
[0050] Figure 15 is a flowchart illustrating an encoding method provided in an embodiment of this application;
[0051] Figure 16 is a schematic flowchart of an encoding method provided in an embodiment of this application;
[0052] Figure 17 is a schematic diagram of a specific prediction process based on the Softmax function provided in an embodiment of this application;
[0053] Figure 18 is a detailed flowchart of an encoding method provided in an embodiment of this application;
[0054] Figure 19 is a detailed flowchart of a decoding method provided in an embodiment of this application;
[0055] Figure 20 is a schematic diagram of the composition structure of an encoder provided in an embodiment of this application;
[0056] Figure 21 is a schematic diagram of the specific hardware structure of an encoder provided in an embodiment of this application;
[0057] Figure 22 is a schematic diagram of the composition structure of a decoder provided in an embodiment of this application;
[0058] Figure 23 is a schematic diagram of the specific hardware structure of a decoder provided in an embodiment of this application;
[0059] Figure 24 is a schematic diagram of the composition structure of an encoding and decoding system provided in an embodiment of this application. Detailed Implementation
[0060] 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.
[0061] 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.
[0062] 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.
[0063] 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.
[0064] 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:
[0065] H.266 / Versatile Video Coding (VVC);
[0066] VVC's reference software testing platform (VVC Test Model, VTM);
[0067] Joint Video Experts Team (JVET);
[0068] Coding Unit (CU);
[0069] Prediction Unit (PU);
[0070] Coding Tree Unit (CTU);
[0071] Planar mode (Planar);
[0072] Direct Current Mode (DC);
[0073] Matrix-based Intra Prediction Mode (MIP);
[0074] Luminance Derived Mode (DM);
[0075] Quantization parameters (QP);
[0076] Rate Distortion Optimization (RDO);
[0077] The weight generation function (Softmax function, Softmax);
[0078] Peak signal-to-noise ratio (PSNR);
[0079] Structural Similarity (SSIM).
[0080] It's understandable that the goal of video coding is to reduce the bitrate as much as possible within a certain acceptable range of distortion in the reconstructed video. Since there is strong spatial correlation between adjacent samples within a single video frame, eliminating this spatial correlation through intra-frame prediction is one of the key problems the VVC video coding standard aims to solve.
[0081] Figure 1 is a schematic diagram of the encoding framework based on VVC technology. As shown in Figure 1, the encoding framework 10 includes a pre-encode filtering module 11, an intra-prediction module 12, an inter-prediction module 13, a motion estimation module 14, a transform module 15, a quantization module 16, an entropy coding module 17, an inverse quantization module 18, an inverse transform module 19, a loop filter module 20, and a decoded picture buffer module 21. The predictions here include intra-prediction and inter-prediction, with inter-prediction including motion estimation and motion compensation. Because there is a strong correlation between adjacent samples within an image of a video, intra-prediction is used in video encoding and decoding technology to eliminate spatial redundancy between adjacent samples. Furthermore, due to the strong similarity between adjacent images in a video, inter-image prediction methods are used in video encoding and decoding technology to eliminate temporal redundancy between adjacent images, thereby improving coding efficiency. It should be noted that samples can also be called pixels, and samples include both location information and values.
[0082] As shown in Figure 1, the position of intra-frame prediction within this coding framework is indicated by a bold dashed box. Intra-frame prediction can be divided into luma intra-frame prediction and chroma intra-frame prediction.
[0083] In the VVC coding framework, both luma intra-frame prediction and chroma intra-frame prediction contain multiple prediction modes. For luma component prediction, there are Planar mode, DC mode, angle mode, wide-angle mode, and Matrix-based Intra Prediction (MIP) mode; for chroma component prediction, there are Planar mode, DC mode, horizontal mode, vertical mode, DM mode, and Cross-Component Linear Model Prediction (CCLM) mode, totaling eight chroma prediction modes. Among these prediction modes, the optimal luma / chroma prediction mode is determined by calculating and comparing the rate-distortion cost results. These prediction modes will be briefly introduced below.
[0084] Because the human visual system is more sensitive to brightness information in videos, researchers have conducted a series of studies on intra-frame brightness prediction technology, and ultimately incorporated several brightness prediction modes into the VVC standard, including the following:
[0085] (1) Planar mode.
[0086] The intra-frame prediction mode number for Planar mode is 0. Planar mode is suitable for regions where sample values change slowly. The predicted sample of Planar mode can be regarded as the average of the predicted values in the horizontal and vertical directions. The specific prediction process is shown in Figure 2.
[0087] As shown in Figure 2, the predicted value P(i,j) of the current sample point is obtained by weighting the predicted values in the horizontal direction and the predicted values in the vertical direction. The predicted value in the horizontal direction is obtained by weighting the reference sample b on the left side of the corresponding position and the reference sample a at the upper right corner of the current block. The predicted value in the vertical direction is obtained by weighting the reference sample d above the corresponding position and the reference sample c at the lower left corner of the current block. The specific weighting coefficients can depend on the distance between the sample to be predicted and the reference samples.
[0088] (2) DC mode.
[0089] The intra-prediction mode number in DC mode is 1, which is applicable to the large flat area within the bold box shown in Figure 3. In DC mode, for square blocks, the average value of the reference samples above and to the left of the current CU is used as the prediction value; for non-square blocks, the average value of the reference samples on the longer side of the current CU is used as the prediction value.
[0090] (3) Angle mode.
[0091] VVC introduces 65 angle prediction modes. It uses a "projected pixel method" to map the required reference samples into a one-dimensional form, and then performs targeted interpolation and filtering on the reference samples to ultimately determine the angle prediction value. The 65 angle prediction modes are shown in Figure 4. Here, 0 represents Planar mode and 1 represents DC mode.
[0092] (4) Wide-angle mode.
[0093] In VVC, both binary and ternary tree partitioning can lead to non-square control units (CUs), and the angle range of traditional prediction modes may limit the selection of reference samples for non-square CUs. Therefore, VVC introduces the Wide Angle Intra Prediction (WAIP) mode, which expands the angle range of intra-frame prediction to the angle direction from the lower left to the upper right diagonal of the current CU. For non-square CUs, although the WAIP mode is added, 65 candidate angle prediction modes are still used, meaning that the added WAIP mode replaces some traditional angle prediction modes. Specifically, when encoding the prediction modes, the added WAIP mode is transmitted according to the mode number being replaced, based on the aspect ratio of the CU to be encoded.
[0094] (5) MIP mode.
[0095] Traditional prediction modes and wide-angle prediction modes calculate predicted values using sample mapping or linear gradation, which cannot effectively predict irregular textures. To adapt to different sample distributions and image textures, H.266 / VVC uses the MIP mode. The MIP mode employs an offline neural network training method to obtain multiple fixed weight matrices, which are then used to calculate predicted values. The prediction process of the MIP mode is shown in Figure 5. The reference sample of the current block (CU to be encoded) is processed to obtain the input vector. The input vector is multiplied by the weight matrix to obtain the output vector. After further permutation and upsampling, the predicted value of the CU to be encoded can be obtained.
[0096] Here, the MIP pattern is closely related to the CU size, classifying CUs into three categories based on their size. Different sizes and numbers of weight matrices can be used for each CU category.
[0097] Furthermore, in intra-frame prediction of the chroma component, there are a total of 8 chroma prediction modes. The DM mode will be introduced in detail below. It is another mode affected by the luma component, in addition to the CCLM mode.
[0098] (1) DM mode.
[0099] For the chroma component, H.266 / VVC uses the luma-derived mode—DM mode—which directly uses the luma prediction mode information at the corresponding position. When an I-frame uses dual-tree partitioning, the luma and chroma components are allowed to use independent block partitioning structures. As shown in Figure 6, the luma component at the position corresponding to the chroma CU may contain multiple luma CUs. In H.266 / VVC, the chroma CU can inherit the intra-prediction mode of the CU at the center position of the corresponding luma block.
[0100] In other words, the prediction mode can be considered the core of intra-frame predictive coding, and its quality fundamentally determines the quality of intra-frame prediction. In lumen intra-frame prediction modes, the DC mode is suitable for large, flat areas, the Planar mode is suitable for areas with slowly changing sample values, and the Angular mode is suitable for areas describing unidirectional changes in sample values. None of these methods can describe complex texture information, accurately predict complex coding blocks, or provide relatively accurate lumen prediction for all video scenes. Furthermore, the MIP mode uses offline training of neural networks to obtain multiple fixed weight matrices, and then uses these weight matrices to calculate prediction values. While it can be applied to different sample distributions and image textures, it requires adding one or more flags to each PU to indicate whether the current PU uses the MIP mode for prediction and which size and number of weight matrices are used, making the operation complex. Therefore, existing intra-frame prediction modes cannot accurately predict complex coding blocks, reducing encoding and decoding efficiency.
[0101] Based on this, embodiments of this application provide an encoding method that, when the first color component of the current block uses a first prediction mode, determines a reference sample for the current block; based on the reference sample, determines a distance matrix for the current block, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample; determines a weight matrix for the current block based on the distance matrix; and determines the predicted value of the first color component of the current block based on the weight matrix and the reference sample. Embodiments of this application also provide a decoding method that parses a first syntax element in the bitstream; when the first syntax element indicates that the first color component of the current block uses a first prediction mode, determines a reference sample for the current block; based on the reference sample, determines a distance matrix for the current block, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample; determines a weight matrix for the current block based on the distance matrix; and determines the predicted value of the first color component of the current block based on the weight matrix and the reference sample.
[0102] Thus, based on the existing intra-frame prediction modes, a new intra-frame prediction mode (i.e., the first prediction mode) is added here. Specifically, the distance matrix of the current block is determined based on the reference sample, then the corresponding weight matrix is determined based on the distance matrix, and finally the predicted value of the first color component of the current block is determined based on the weight matrix and the reference sample. In this way, when the first prediction mode is applied to the luma component, the prediction accuracy of the luma component of the current block can be improved. When the first prediction mode is applied to the chroma component, the prediction accuracy of the chroma component of the current block can also be improved. Therefore, this process can achieve accurate prediction of the luma component of the current block and accurate prediction of the chroma component using the DM mode. Moreover, it reduces the prediction complexity, saves bitrate, improves encoding and decoding efficiency, and thus improves encoding and decoding performance.
[0103] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0104] Figure 7 is a schematic diagram of a video encoding and decoding network architecture provided in an embodiment of this application. As shown in Figure 7, the network architecture includes one or more electronic devices 31 to 3N and a communication network 01, where N is a positive integer. The electronic devices 31 to 3N 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.
[0105] 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).
[0106] Figure 8 is a schematic block diagram of an encoder provided in an embodiment of this application. As shown in Figure 8, 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 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 pixel 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 uses the motion vectors determined by the motion estimation unit 105 as a basis for the motion estimation. 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, reconstructing the residual block in the pixel domain. The reconstructed residual block is processed by the filter control analysis unit 107 and the filtering unit 108 to remove block artifacts, and 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, outputting the bitstream of the video signal; and 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.
[0107] Figure 9 is a schematic block diagram of a decoder provided in an embodiment of this application. As shown in Figure 9, 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 undergoes the encoding processing shown in Figure 8, 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 pixel 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.
[0108] It should be noted that in the embodiments of this application, 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 there is no data dependency between them. A "frame" is a commonly used term, generally understood as one image. In the embodiments of this application, the term "frame" can also be replaced with an image or a slice, etc.
[0109] It should also be noted that the method of this application embodiment is mainly applied to the intra-frame estimation unit 102 and intra-frame prediction unit 103 as shown in FIG8 and the intra-frame prediction unit 203 as shown in FIG9. That is to say, this application embodiment can be applied to the encoder, the decoder, or even to both the encoder and the decoder, but no specific limitation is made here. Wherein, when this application embodiment is applied to the encoder 100, "current block" refers to the block to be encoded in the video image (also called "encoded block"); when this application embodiment is applied to the decoder 200, "current block" refers to the block to be decoded in the video image (also called "decoded block").
[0110] In one embodiment of this application, Figure 10 is a schematic flowchart of a decoding method provided in this application. As shown in Figure 10, the method may include:
[0111] S1001, the first syntax element in the parsed code stream.
[0112] It should be noted that in this embodiment, the method is applied to the decoder. Specifically, based on the structure of the decoder 200 shown in Figure 9, the decoding method in this embodiment is mainly applied to the intra-frame prediction part. Wherein, when intra-frame prediction is used in the current block, a new intra-frame prediction mode (i.e., the first prediction mode) is provided, which can improve encoding and decoding efficiency.
[0113] It should also be noted that, in this embodiment, some mode indication information (or mode flags) in the form of syntax elements 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 is used to indicate whether the first color component of the current block uses the first prediction mode.
[0114] In some embodiments, the method may further include: if the value of the first syntax element is a first value, then determining that the first syntax element indicates that the first color component of the current block uses a first prediction mode; if the value of the first syntax element is a second value, then determining that the first syntax element indicates that the first color component of the current block does not use the first prediction mode.
[0115] It should also be noted that, in this embodiment, when the first color component is a luminance component, the first prediction mode can be a luminance intra-frame prediction mode based on a preset function. Specifically, assuming there are 67 existing intra-frame prediction modes, the newly added first prediction mode can be the 68th luminance intra-frame prediction mode, with the mode number set to 67.
[0116] It should also be noted that, in the embodiments of this application, the first value and the second value are different.
[0117] In one possible implementation, if the first syntax element is a mode flag, then the first value can be set to 1 and the second value can be set to 0; or, the first value can be set to true and the second value can be set to false, without any limitation. For example, if the parsed value of the first syntax element is true, then it can be determined that the first color component of the current block uses the first prediction mode; otherwise, if the parsed value of the first syntax element is false, then it can be determined that the first color component of the current block does not use the first prediction mode.
[0118] In another possible implementation, if the first syntax element is pattern indication information, then the first value can be set to 67, and the second value can be set to other values, such as 0, 1, 2, ..., 66, etc., without any limitation. For example, if the parsed value of the first syntax element is equal to 67, then it can be determined that the first color component of the current block uses the first prediction mode; otherwise, if the parsed value of the first syntax element is not equal to 67, then it can be determined that the first color component of the current block does not use the first prediction mode.
[0119] S1002, when the first syntax element indicates that the first color component of the current block uses the first prediction mode, determine the reference sample of the current block.
[0120] It should be noted that, in the embodiments of this application, if the first syntax element indicates that the first color component of the current block uses the first prediction mode, that is, the first color component of the current block uses the luminance intra-frame prediction mode based on a preset function, then it is necessary to determine the reference sample of the current block.
[0121] It should also be noted that, in the embodiments of this application, the reference sample refers to the reconstructed sample adjacent to the current block. In some embodiments, determining the reference sample of the current block may include: determining the adjacent reference regions of the current block; and determining the reference sample of the current block based on at least one candidate sample in the adjacent reference regions.
[0122] In this embodiment of the application, as shown in FIG11, the adjacent reference region may include: the left adjacent reference region of the current block, and / or, the upper adjacent reference region of the current block. The candidate sample in the left adjacent reference region may be referred to as the left reference sample, and the candidate sample in the upper adjacent reference region may be referred to as the upper reference sample.
[0123] In other words, in this embodiment of the application, the reference sample of the current block can be determined based on at least one candidate sample in the left adjacent reference region of the current block, or it can be determined based on at least one candidate sample in the upper adjacent reference region of the current block, or it can be determined based on at least one candidate sample in the left adjacent reference region and the upper adjacent reference region of the current block. No limitation is made here.
[0124] It should also be noted that, in the embodiments of this application, for the adjacent reference areas (i.e., "reference sample range") of the current block, the left adjacent reference area of the current block can be the reference area corresponding to the left adjacent column of the current block, or it can be the reference area corresponding to the left adjacent multiple columns (e.g., 2 columns, 3 columns, etc.); the upper adjacent reference area of the current block can be the reference area corresponding to the upper adjacent row of the current block, or it can be the reference area corresponding to the upper adjacent multiple rows (e.g., 2 rows, 3 rows, etc.). There are no limitations on the reference sample range here.
[0125] In some embodiments, determining a reference sample for the current block based on at least one candidate sample in an adjacent reference region may include: filtering at least one candidate sample in an adjacent reference region to determine a reference sample for the current block.
[0126] In this embodiment, after determining the adjacent reference regions of the current block, since there may be some unimportant candidate samples (e.g., these candidate samples have poor correlation) or some abnormal candidate samples in the adjacent reference regions, in order to ensure the accuracy of the prediction, it is necessary to filter out these candidate samples to obtain the reference samples of the current block. The number of reference samples is less than or equal to the number of candidate samples in the adjacent reference regions.
[0127] In this embodiment of the application, filtering at least one candidate sample in an adjacent reference region to determine the reference sample of the current block may include: determining the position of the candidate sample based on the sample position and / or color component intensity (e.g., luminance value, chromaticity value, etc.) corresponding to each candidate sample in the adjacent reference region; selecting the target sample corresponding to the position of the candidate sample from the adjacent reference region according to the determined position of the candidate sample, and determining the selected target sample as the reference sample of the current block.
[0128] In this embodiment of the application, the adjacent reference region of the current block can typically refer to the reference region corresponding to the column adjacent to the left of the current block and the reference region corresponding to the row adjacent to the top of the current block. In this case, at least one candidate sample in the adjacent reference region can be directly used as the reference sample of the current block, and no filtering operation is required.
[0129] It should also be noted that, in some embodiments of this application, the current block may not have a reference sample in certain situations, in which case a reference sample can be filled in. For example, the sample value filled in the reference sample can be the median of the maximum sample range (e.g., 512).
[0130] S1003, Based on the reference sample, determine the distance matrix of the current block, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample.
[0131] In this embodiment of the application, after obtaining the reference sample, the distance matrix of the current block can be determined based on the reference sample. In some embodiments, determining the distance matrix of the current block based on the reference sample may include: determining the distance information between at least one sample in the current block and the reference sample; and determining the distance matrix based on the distance information between at least one sample in the current block and the reference sample.
[0132] It should be noted that, in this embodiment, for a single video frame, samples exhibit spatial correlation. Generally, the closer the samples are, the stronger the correlation; conversely, as the distance increases, the correlation weakens. Here, by calculating the distance information between each sample in the current block and each reference sample, the dependency of the samples in the current block on the reference samples located above or to the left of the current block is illustrated, thereby quantifying the direct impact of the distance information between the samples in the current block and the reference samples on the sample values in the current block.
[0133] It should also be noted that, in the embodiments of this application, the distance information can be Euclidean distance, or it can be other distances, such as cosine distance, Manhattan distance, Chebyshev distance, Minkowski distance, etc., without any limitation.
[0134] In one possible implementation, taking Euclidean distance as an example, let's assume we use... Indicates the current block, This represents the reference sample of the current block, where W and H are the width and height of the current block, respectively. The Euclidean distance matrix D can be obtained from the following formula:
[0135] In another possible implementation, taking Manhattan distance as an example, Given the Manhattan distance matrix D, it can be obtained by the following formula: D(r,x,y)=|R r -C x, y| (2)
[0136] Here, x and y are the x and y coordinates of the current sample in the current block, respectively, and r is the non-zero x / y coordinate of the reference sample. C x,y R represents the coordinate information of the sample at position (x, y) in the current block. r This refers to the coordinate information of the r-th reference sample.
[0137] Thus, after the distance matrix is determined, it can be used to characterize the distance information between at least one sample in the current block and the reference sample, thereby indicating the dependence of the samples in the current block on the reference samples located above or to the left of the current block.
[0138] S1004, determine the weight matrix of the current block based on the distance matrix.
[0139] In this embodiment, after obtaining the distance matrix, the weight matrix (or "reference sample weighted matrix") of the current block can be obtained based on the distance matrix. In some embodiments, determining the weight matrix of the current block based on the distance matrix may include: determining a preset function, wherein the preset function includes a first parameter; and determining the weight matrix based on the distance matrix and the preset function.
[0140] It should be noted that, in this embodiment, a preset function can be used to process the distance matrix to obtain the weight matrix. The preset function includes a first parameter, which can be represented by theta. In other words, the preset function is a function relating to the first parameter theta, and the independent variable of the preset function is the distance matrix, while the dependent variable is the weight matrix.
[0141] It should also be noted that, in the embodiments of this application, the preset function can be a function with non-linear monotonically decreasing characteristics. As the independent variable increases, its dependent variable decreases slowly. For example, the preset function can be a Softmax function.
[0142] In this embodiment, the Softmax function is a commonly used mathematical function, typically used in multi-class classification problems. It transforms a set of real numbers into a form representing a probability distribution. The definition of the Softmax function is as follows:
[0143] Suppose we have a vector x = (x1, x2, ..., xn) containing N real numbers. n The Softmax function calculates each element x in this vector. i Convert to a real number σ(x) between 0 and 1 i The softmax function is defined as follows: (The result is that the sum of all transformed elements is 1.)
[0144] Where k = 1, 2, ..., N, and e is the base of the natural logarithm (or "Euler number"). express The exponential form, where the first parameter theta is a function of x. k The scaling factor.
[0145] Here, the Softmax function can transform any real vector into a probability distribution where the sum of all elements is 1. This not only normalizes the input vector but also represents the relative magnitude of each element in the input vector. Furthermore, the first parameter, theta, can be positive or negative. However, in this embodiment, to satisfy the non-linear monotonically decreasing characteristic, theta is typically negative.
[0146] For example, when the value of theta is negative, Figure 12 is a schematic diagram of the Softmax function graph under different conditions provided by an embodiment of this application. As shown in Figure 12, the different conditions here can be different values of the first parameter theta, for example, the value of theta is -0.1, -0.05, -0.01, -0.001, and 0.0. Among them, when the value of theta is -0.1, the Softmax function graph is represented by dots; when the value of theta is -0.05, the Softmax function graph is represented by dashed lines; when the value of theta is -0.01, the Softmax function graph is represented by short lines and dots; when the value of theta is -0.001, the Softmax function graph is represented by long dashes and short dashes; when the value of theta is 0.0, the Softmax function graph is represented by solid lines.
[0147] As shown in Figure 12, the Softmax function graph is non-linearly monotonically decreasing, and the decrease in the dependent variable gradually slows down as the independent variable increases. Based on this, in this embodiment, the distance matrix formed by the distance information between the current sample and each reference sample can be used as input, and the output after processing by the Softmax function can be used as the reference sample weighting matrix (i.e., the weight matrix). This weight matrix can be used to generate the predicted value for the current block.
[0148] In this embodiment, the distance matrix is processed using the Softmax function to become the weight matrix. The process is shown in the following formula:
[0149] Here, theta is the first parameter of the Softmax function.
[0150] In one possible implementation, the first parameter theta is a constant. For example, the first parameter theta is -0.01.
[0151] In another possible implementation, if the encoder uses iteration to find the optimal theta value pattern, then the value of the first parameter theta will be written into the bitstream. Accordingly, the method may also include: parsing the first parameter in the bitstream to determine the value of the first parameter theta.
[0152] In other words, in this embodiment, if the encoder uses an iterative method to find the optimal theta value, then after determining the optimal theta value, the encoder will write the optimal theta value into the bitstream so that the decoder can obtain the optimal theta value of the current block to complete the correct decoding. This implementation method will increase the number of encoded bits and the encoding complexity. Therefore, in most cases, the Softmax function (theta = -0.01) is used to complete the intra-frame prediction process of the first prediction mode.
[0153] In another possible implementation, determining the weight matrix of the current block based on the distance matrix may include: determining multiple piecewise linear functions corresponding to a preset function; and determining the weight matrix based on the distance matrix and the multiple piecewise linear functions.
[0154] For example, taking the Softmax function with the first parameter theta = -0.01 as an example, as shown in Figure 12, within a certain range of the independent variable's values, for example, when x belongs to [40, 60], the graph of this function can be approximated as a monotonic linear function. Different piecewise linear functions can be selected based on the distance information in the distance matrix. Assuming the Softmax function can be divided into multiple piecewise linear functions according to [0, 20], [20, 40], [40, 60], [60, 80], and [80, 100], if the distance information x in the distance matrix belongs to [20, 40], then the piecewise linear function corresponding to [20, 40] is selected; if the distance information x in the distance matrix belongs to [40, 60], then the piecewise linear function corresponding to [40, 60] is selected; if the distance information x in the distance matrix belongs to [80, 100], then the piecewise linear function corresponding to [80, 100] is selected, and so on. In this way, by using multiple piecewise linear functions instead of the Softmax function, the reference samples can be weighted using multiple piecewise linear functions.
[0155] S1005, Based on the weight matrix and reference samples, determine the predicted value of the first color component of the current block.
[0156] In this embodiment, after obtaining the weight matrix, a multiplication operation is performed based on the reference sample and the weight matrix to obtain the predicted value of the first color component of the current block. In some embodiments, determining the predicted value of the first color component of the current block based on the weight matrix and the reference sample may include: performing a weighted prediction based on the first color component of the weight matrix and the reference sample to determine the first predicted value of the first color component of the current block; and filtering the first predicted value of the first color component to determine the predicted value of the first color component of the current block.
[0157] It should be noted that, in the embodiments of this application, if the first color component is a luminance component, then the first predicted value of the current block can be obtained by weighting the luminance component values of the reference sample and the weighted calculation. Alternatively, if the first color component is a chrominance component, then the first predicted value of the current block can be obtained by weighting the chrominance component values of the reference sample and the weighted calculation.
[0158] It should also be noted that, in the embodiments of this application, after the weight matrix is used to calculate the weighted sample, in order to ensure the validity of the predicted value, the obtained first predicted value can also be filtered, for example, a pruning operation can be performed.
[0159] In some embodiments, filtering the first predicted value of the first color component to determine the predicted value of the first color component of the current block may include: when the first predicted value of the first color component is within a preset range, using the first predicted value of the first color component as the predicted value of the first color component of the current block; when the first predicted value of the first color component is outside the preset range, performing a trimming operation on the first predicted value of the first color component so that the predicted value of the first color component of the current block is within the preset range.
[0160] In this embodiment, the pruning operation can also be called a clipping operation, thereby obtaining the final predicted value of the current block. The process is expressed as follows: P(x,y)=min(max(W(r,x,y)·R(r),0),2 bitdepth -1) (5)
[0161] Here, bitdepth represents the bit depth, which is usually set to 10 bits. bitdepth The value of -1 is 1023, which is also the maximum value of the sample.
[0162] It should also be noted that, in the embodiments of this application, if the first predicted value (W(r,x,y)·R(r)) is less than 0, then P(x,y) can be set to equal 0; if the first predicted value (W(r,x,y)·R(r)) is greater than 2, then P(x,y) can be set to equal 0;bitdepth If -1, then P(x,y) can be set to equal 2. bitdepth -1; if 0 ≤ the first predicted value (W(r,x,y)·R(r)) ≤ 2 bitdepth If -1, then P(x,y) can be set to equal the first predicted value (W(r,x,y)·R(r)) so that the predicted value of the current block is clamped within a preset range, i.e., [0, 2]. bitdepth Within -1].
[0163] Understandably, in the embodiments of this application, a Softmax prediction mode extension can also be performed for the first prediction mode. In some embodiments, the method may further include: when the first syntax element indicates that the first color component of the current block uses the first prediction mode, copying based on the reference sample of the current block to determine the predicted value of the first color component of the current block.
[0164] In this embodiment, the reference sample may include a left reference sample and an upper reference sample. Accordingly, determining the predicted value of the first color component of the current block by copying the reference sample of the current block may include: dividing the current block according to a preset boundary line to determine a first sub-block and a second sub-block of the current block; copying the reconstructed value of the left reference sample to the predicted value of the first color component of the first sub-block, and copying the reconstructed value of the upper reference sample to the predicted value of the first color component of the second sub-block; calculating the average value of the reconstructed values of the left reference sample and the upper reference sample, and determining the calculated average value as the predicted value of the first color component of at least one sample on the preset boundary line.
[0165] In other words, in this embodiment, a direct copy mode can also be used. For example, by observing the Softmax function graph shown in Figure 12, it can be seen that when the first parameter theta is 0.0, regardless of the distribution of the input data, it can be converted into an equal probability distribution. In other words, the weight corresponding to each reference sample is the same (theta is 0, corresponding to the DC mode). When the first parameter theta is -0.001, the function graph gradually decreases, slowly approaching the function graph when theta is 0. Based on this, the Softmax prediction mode can be directly extended to a nearest-neighbor copy mode. Using the diagonal of the current block as a preset boundary, the sample at the lower left corner of the diagonal is copied to the left reference sample at the corresponding position, and the sample at the upper right corner of the diagonal is copied to the upper reference sample at the corresponding position. The samples on the diagonal are the average of the upper and left reference samples at the corresponding positions.
[0166] It is also understood that, in the embodiments of this application, for the first prediction mode, a template region can also be used to optimally select the value of theta. In some embodiments, the method may further include: determining the template region of the current block; predicting the template region based on multiple candidate values of the first parameter to determine multiple candidate prediction blocks; calculating the cost of each candidate prediction block with the reconstructed block of the template region to determine multiple cost results; determining the minimum cost result among the multiple cost results, and determining the candidate value corresponding to the minimum cost result as the value of the first parameter.
[0167] In the embodiments of this application, the cost calculation here may be determined based on the cost result of Rate-Distortion Optimization (RDO), or it may be determined based on the cost result of Sum of Absolute Difference (SAD), or even based on the cost result of Sum of Absolute Transformed Difference (SATD), etc., but no limitation is made.
[0168] In other words, in this embodiment, the determination of the value of the first parameter theta can be extended to determine the value of the Softmax function based on relevant information of the upper or left reconstruction region of the current block. For example, the template region is predicted according to multiple candidate values of the first parameter theta, i.e., the template region is used to determine the value of the first parameter theta to obtain the optimal value of theta; then the determined optimal value of theta is applied to the luminance component of the current block for prediction.
[0169] In some embodiments, predicting a template region based on multiple candidate values of a first parameter to determine multiple candidate prediction blocks may include: calculating gradient information between at least one sample in the template region and a reference sample in the template region; determining multiple candidate weight matrices of the template region based on the gradient information and multiple candidate values of the first parameter; and performing weighted prediction based on the multiple candidate weight matrices of the template region and the reference sample in the template region to determine multiple candidate prediction blocks.
[0170] In other words, in this embodiment, a weighted value for the reference sample is generated based on the distance information between the reference sample and the sample to be predicted. This can be extended to predict the brightness component of the current block based on the gradient information of the reference sample. For example, the template region of the current block and the reference sample of the template region can be determined first; then the gradient information of each sample in the template region and its corresponding reference sample can be calculated; a weight value for the reference sample of the template region can be generated based on the gradient information; a weighted prediction can be performed based on the weight value of the reference sample of the template region and the reference sample of the template region; the first parameter theta can be iterated to find the optimal value of theta in the template region, and this optimal value can be used as the value of the first parameter theta, and applied to predict the brightness component of the current block.
[0171] It can also be understood that, in the embodiments of this application, for step S1002, if the first syntax element indicates that the first color component of the current block does not use the first prediction mode, then the luminance component of the current block can be predicted according to the existing intra-frame prediction mode.
[0172] It is also understood that, in the embodiments of this application, the first prediction mode can also be extended to predict the chromaticity components of the current block. In some embodiments, referring to FIG13, the method may further include:
[0173] S1301, parse the second syntax element in the bitstream.
[0174] S1302, when the second syntax element indicates that the second color component of the current block uses the DM mode, the predicted value of the second color component of the current block is determined according to the first prediction mode used by the first color component of the current block.
[0175] In this embodiment, the second syntax element is used to indicate whether the second color component of the current block uses DM mode. Specifically, if the value of the second syntax element is a first value, it is determined that the second syntax element indicates that the second color component of the current block uses DM mode; if the value of the second syntax element is a second value, it is determined that the second syntax element indicates that the second color component of the current block does not use DM mode.
[0176] In one possible implementation, the second syntax element can be a mode flag. Here, the first value can be set to 1 and the second value can be set to 0; or, the first value can be set to true and the second value can be set to false, without any limitation. For example, if the parsed value of the second syntax element is true, then it can be determined that the second color component of the current block uses DM mode; otherwise, if the parsed value of the second syntax element is false, then it can be determined that the second color component of the current block does not use DM mode.
[0177] In this embodiment of the application, it is assumed that the first color component is the luminance component and the second color component is the chrominance component. If the chrominance component of the current block uses the DM mode, then according to the first prediction mode used by the luminance component of the current block, it can be determined that the chrominance component of the current block can also be predicted according to the first prediction mode.
[0178] In some embodiments, referring to FIG14, after step S1301, the method may further include:
[0179] S1401, when the second syntax element indicates that the second color component of the current block uses DM mode, determine the reference sample of the current block.
[0180] S1402, Based on the reference sample, determine the distance matrix of the current block, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample.
[0181] S1403, determine the weight matrix of the current block based on the distance matrix.
[0182] S1404, perform weighted prediction based on the weight matrix and the second color component of the reference sample to determine the predicted value of the second color component of the current block.
[0183] In this embodiment of the application, when the second syntax element indicates that the second color component of the current block uses the DM mode, the first prediction mode can be applied to the chromaticity component of the current block for prediction. Specifically, when the first prediction mode is applied to the chromaticity component of the current block for prediction, the value of the first parameter theta can be set to -1.
[0184] In this embodiment, the distance information here is the same as the distance information mentioned above, which can be the Euclidean distance between at least one sample in the current block and the reference sample, or it can be other distances, such as cosine distance, Manhattan distance, Chebyshev distance, Minkowski distance, etc., and no limitation is made here.
[0185] In this embodiment, determining the weight matrix of the current block based on the distance matrix still involves processing the distance matrix using a preset function to obtain the weight matrix. For example, the preset function can be the Softmax function, and the first parameter theta is set to -1. This allows for accurate prediction of the chromaticity components of the current block when the first prediction mode is applied to the chromaticity prediction process using the DM mode.
[0186] This application provides a decoding method that adds a new intra-frame prediction mode (i.e., a first prediction mode) to the existing intra-frame prediction modes. Specifically, it parses the first syntax element in the bitstream. When the first syntax element indicates that the first color component of the current block uses the first prediction mode, the distance matrix of the current block is determined based on reference samples. Then, the corresponding weight matrix is determined based on the distance matrix. Finally, the predicted value of the first color component of the current block is determined based on the weight matrix and the reference samples. Thus, when the first prediction mode is applied to the luma component, the prediction accuracy of the luma component of the current block can be improved; when the first prediction mode is applied to the chroma component, the prediction accuracy of the chroma component of the current block can also be improved. Therefore, this process can achieve accurate prediction of the luma component of the current block and accurate prediction of the chroma component using the DM mode, while reducing prediction complexity, saving bitrate, improving encoding and decoding efficiency, and thus improving encoding and decoding performance.
[0187] In another embodiment of this application, Figure 15 is a schematic flowchart of an encoding method provided by an embodiment of this application. As shown in Figure 15, the method may include:
[0188] S1501, when the first color component of the current block uses the first prediction mode, determine the reference sample of the current block.
[0189] It should be noted that in this embodiment, the method is applied to the encoder. Specifically, based on the structure of the encoder 100 shown in Figure 8, the encoding method in this embodiment is mainly applied to the intra-frame prediction part. Wherein, when intra-frame prediction is used in the current block, a new intra-frame prediction mode (i.e., the first prediction mode) is provided, which can improve encoding efficiency.
[0190] It should also be noted that, in the embodiments of this application, whether the first color component of the current block uses the first prediction mode can be determined by a cost method. In some embodiments, the method may include: determining multiple candidate prediction modes for the first color component of the current block; predicting the current block based on the multiple candidate prediction modes to determine multiple candidate blocks; calculating the cost between the multiple candidate blocks and the original block of the current block to determine multiple candidate cost results; and determining whether the first color component of the current block uses the first prediction mode based on the multiple candidate cost results.
[0191] In this embodiment, the cost calculation can be performed using rate-distortion optimization or other cost calculation methods. For example, using rate-distortion optimization, the current block is predicted for multiple candidate prediction modes (e.g., including the existing 67 intra-frame prediction modes and a first prediction mode), resulting in multiple candidate blocks. Then, rate-distortion cost calculations are performed between each of the multiple candidate blocks and the original block of the current block to determine the candidate cost results for each of the multiple candidate prediction modes. Based on the obtained multiple candidate cost results, it is determined whether the first color component of the current block uses the first prediction mode.
[0192] In some embodiments, determining whether the first color component of the current block uses the first prediction mode based on multiple candidate cost results may include: determining the minimum cost result among multiple candidate cost results; if the candidate prediction mode corresponding to the minimum cost result is the first prediction mode, then determining that the first color component of the current block uses the first prediction mode; if the candidate prediction mode corresponding to the minimum cost result is not the first prediction mode, then determining that the first color component of the current block does not use the first prediction mode.
[0193] In the embodiments of this application, the prediction mode used for the current block can typically be selected based on the principle of minimizing rate-distortion cost. For example, if the candidate prediction mode corresponding to the minimum cost result is the first prediction mode, then it can be determined that the first color component of the current block uses the first prediction mode; if the candidate prediction mode corresponding to the minimum cost result is not the first prediction mode, for example, it is one of the existing 67 intra-frame prediction modes, then it can be determined that the first color component of the current block does not use the first prediction mode, and instead, one of the existing 67 intra-frame prediction modes is used to predict the first color component of the current block.
[0194] Understandably, in this embodiment, some mode indication information (or mode flags) in the form of syntax elements can be written into the bitstream. For example, whether the first prediction mode is used for the first color component of the current block can be indicated by a syntax element. Thus, by writing the values of the syntax elements into the bitstream, the subsequent decoding end can determine the prediction mode used by the current block by parsing the values of the corresponding syntax elements in the bitstream. For example, the first syntax element is used to indicate whether the first prediction mode is used for the first color component of the current block.
[0195] In some embodiments, referring to FIG16, the method may further include:
[0196] S1601, calculates the rate-distortion cost of the current block based on multiple candidate prediction modes, and determines multiple candidate cost results.
[0197] S1602, determine the value of the first syntax element based on multiple candidate cost results.
[0198] S1603, encode the value of the first syntax element and write the resulting encoded bits into the bitstream.
[0199] In this embodiment, calculating the rate-distortion cost of the current block based on multiple candidate prediction modes to determine multiple candidate cost results may include: predicting the current block based on multiple candidate prediction modes to obtain multiple candidate blocks; and then calculating the rate-distortion cost of each candidate block with the original block of the current block to determine multiple candidate cost results.
[0200] In this embodiment, determining the value of the first syntax element based on multiple candidate cost results may include: if the candidate prediction mode corresponding to the minimum cost result is the first prediction mode, then the value of the first syntax element is determined to be a first value; if the candidate prediction mode corresponding to the minimum cost result is not the first prediction mode, then the value of the first syntax element is determined to be a second value. Alternatively, it can be said that if the first color component of the current block uses the first prediction mode, then the value of the first syntax element is determined to be a first value; if the first color component of the current block does not use the first prediction mode, then the value of the first syntax element is determined to be a second value.
[0201] It should be noted that, in this embodiment of the application, when the first color component is a luminance component, the first prediction mode can be a luminance intra-frame prediction mode based on a preset function. Specifically, assuming the existing number of intra-frame prediction modes is 67, the newly added first prediction mode here can be the 68th luminance intra-frame prediction mode, with the mode number set to 67.
[0202] It should also be noted that, in the embodiments of this application, the first value and the second value are different.
[0203] In one possible implementation, if the first syntax element is a mode flag, then the first value can be set to 1 and the second value can be set to 0; or, the first value can be set to true and the second value can be set to false, without any limitation. For example, if the first color component of the current block uses the first prediction mode, then the value of the first syntax element can be written to the bitstream as true; otherwise, if the first color component of the current block does not use the first prediction mode, then the value of the first syntax element can be written to the bitstream as false.
[0204] In another possible implementation, if the first syntax element is mode indication information, then the first value can be set to 67, and the second value can be set to other values, such as 0, 1, 2, ..., 66, etc., without any limitation. For example, if the first color component of the current block uses the first prediction mode, then the value of the first syntax element can be written into the bitstream as 67; otherwise, if the first color component of the current block does not use the first prediction mode, then the value of the first syntax element can be written into the bitstream as not equal to 67.
[0205] It can also be understood that, in the embodiments of this application, if the first color component of the current block uses the first prediction mode, that is, the first color component of the current block uses the luminance intra-frame prediction mode based on a preset function, then it is also necessary to determine the reference sample of the current block.
[0206] In some embodiments, determining a reference sample for the current block may include: determining adjacent reference regions of the current block; and determining a reference sample for the current block based on at least one candidate sample in the adjacent reference regions.
[0207] In this embodiment, a reference sample refers to a reconstructed sample adjacent to the current block. As shown in Figure 11, the adjacent reference region may include: the left adjacent reference region of the current block, and / or, the upper adjacent reference region of the current block. Candidate samples in the left adjacent reference region can be called left reference samples, and candidate samples in the upper adjacent reference region can be called upper reference samples.
[0208] In other words, in this embodiment of the application, the reference sample of the current block can be determined based on at least one candidate sample in the left adjacent reference region of the current block, or it can be determined based on at least one candidate sample in the upper adjacent reference region of the current block, or it can be determined based on at least one candidate sample in the left adjacent reference region and the upper adjacent reference region of the current block. No limitation is made here.
[0209] It should also be noted that, in the embodiments of this application, for the adjacent reference areas (i.e., "reference sample range") of the current block, the left adjacent reference area of the current block can be the reference area corresponding to the left adjacent column of the current block, or it can be the reference area corresponding to the left adjacent multiple columns (e.g., 2 columns, 3 columns, etc.); the upper adjacent reference area of the current block can be the reference area corresponding to the upper adjacent row of the current block, or it can be the reference area corresponding to the upper adjacent multiple rows (e.g., 2 rows, 3 rows, etc.). There are no limitations on the reference sample range here.
[0210] In some embodiments, determining a reference sample for the current block based on at least one candidate sample in an adjacent reference region may include: filtering at least one candidate sample in an adjacent reference region to determine a reference sample for the current block.
[0211] In this embodiment, after determining the adjacent reference regions of the current block, since there may be some unimportant candidate samples (e.g., these candidate samples have poor correlation) or some abnormal candidate samples in the adjacent reference regions, in order to ensure the accuracy of the prediction, it is necessary to filter out these candidate samples to obtain the reference samples of the current block. The number of reference samples is less than or equal to the number of candidate samples in the adjacent reference regions.
[0212] In this embodiment of the application, filtering at least one candidate sample in an adjacent reference region to determine the reference sample of the current block may include: determining the position of the candidate sample based on the sample position and / or color component intensity (e.g., luminance value, chromaticity value, etc.) corresponding to each candidate sample in the adjacent reference region; selecting the target sample corresponding to the position of the candidate sample from the adjacent reference region according to the determined position of the candidate sample, and determining the selected target sample as the reference sample of the current block.
[0213] In this embodiment of the application, the adjacent reference region of the current block can typically refer to the reference region corresponding to the column adjacent to the left of the current block and the reference region corresponding to the row adjacent to the top of the current block. In this case, at least one candidate sample in the adjacent reference region can be directly used as the reference sample of the current block, and no filtering operation is required.
[0214] It should also be noted that, in some embodiments of this application, the current block may not have a reference sample in certain situations, in which case a reference sample can be filled in. For example, the sample value filled in the reference sample can be the median of the maximum sample range (e.g., 512).
[0215] S1502, Based on the reference sample, determine the distance matrix of the current block, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample.
[0216] In this embodiment of the application, after obtaining the reference sample, the distance matrix of the current block can be determined based on the reference sample. In some embodiments, determining the distance matrix of the current block based on the reference sample may include: determining the distance information between at least one sample in the current block and the reference sample; and determining the distance matrix based on the distance information between at least one sample in the current block and the reference sample.
[0217] It should be noted that, in this embodiment, for a single video frame, samples exhibit spatial correlation. Generally, the closer the samples are, the stronger the correlation; conversely, as the distance increases, the correlation weakens. Here, by calculating the distance information between each sample in the current block and each reference sample, the dependency of the samples in the current block on the reference samples located above or to the left of the current block is illustrated, thereby quantifying the direct impact of the distance information between the samples in the current block and the reference samples on the sample values in the current block.
[0218] It should also be noted that, in the embodiments of this application, the distance information can be Euclidean distance, or it can be other distances, such as cosine distance, Manhattan distance, Chebyshev distance, Minkowski distance, etc., without any limitation.
[0219] In one possible implementation, taking Euclidean distance as an example, let's assume we use... Indicates the current block, This represents the reference sample of the current block, where W and H are the width and height of the current block, respectively. D is the Euclidean distance matrix, which can be obtained from the aforementioned equation (1).
[0220] In another possible implementation, taking Manhattan distance as an example, Let D be the Manhattan distance matrix, which can be obtained from the aforementioned equation (2).
[0221] Here, x and y are the x and y coordinates of the current sample in the current block, respectively, and r is the non-zero x / y coordinate of the reference sample. C x,y R represents the coordinate information of the sample at position (x, y) in the current block. r This refers to the coordinate information of the r-th reference sample.
[0222] Thus, after the distance matrix is determined, it can be used to characterize the distance information between at least one sample in the current block and the reference sample, thereby indicating the dependence of the samples in the current block on the reference samples located above or to the left of the current block.
[0223] S1503, determine the weight matrix of the current block based on the distance matrix.
[0224] In this embodiment, after obtaining the distance matrix, the weight matrix (or "reference sample weighted matrix") of the current block can be obtained based on the distance matrix. In some embodiments, determining the weight matrix of the current block based on the distance matrix may include: determining a preset function, wherein the preset function includes a first parameter; and determining the weight matrix based on the distance matrix and the preset function.
[0225] It should be noted that, in this embodiment, a preset function can be used to process the distance matrix to obtain the weight matrix. The preset function includes a first parameter, which can be represented by theta. In other words, the preset function is a function relating to the first parameter theta, and the independent variable of the preset function is the distance matrix, while the dependent variable is the weight matrix.
[0226] It should also be noted that, in the embodiments of this application, the preset function can be a function with non-linear monotonically decreasing characteristics. As the independent variable increases, its dependent variable decreases slowly. For example, the preset function can be a Softmax function.
[0227] In this embodiment, the Softmax function is a commonly used mathematical function, typically used in multi-class classification problems. It transforms a set of real numbers into a form representing a probability distribution. The definition of the Softmax function is as follows:
[0228] Suppose we have a vector x = (x1, x2, ..., xn) containing N real numbers. n The Softmax function calculates each element x in this vector. i Convert to a real number σ(x) between 0 and 1 i The sum of all transformed elements is 1. The definition of the Softmax function is shown in equation (3) above.
[0229] Where k = 1, 2, ..., N, and e is the base of the natural logarithm (or "Euler number"). express The exponential form, where the first parameter theta is a function of x. k The scaling factor.
[0230] Here, the Softmax function can transform any real vector into a probability distribution where the sum of all elements is 1. This not only normalizes the input vector but also represents the relative magnitude of each element in the input vector. Furthermore, the first parameter, theta, can be positive or negative. However, in this embodiment, to satisfy the non-linear monotonically decreasing characteristic, theta is typically negative.
[0231] For example, when the value of theta is negative, Figure 12 is a schematic diagram of the Softmax function graph under different conditions provided by an embodiment of this application. As shown in Figure 12, the different conditions here can be different values of the first parameter theta, for example, the value of theta is -0.1, -0.05, -0.01, -0.001, and 0.0. Among them, when the value of theta is -0.1, the Softmax function graph is represented by dots; when the value of theta is -0.05, the Softmax function graph is represented by dashed lines; when the value of theta is -0.01, the Softmax function graph is represented by short lines and dots; when the value of theta is -0.001, the Softmax function graph is represented by long dashes and short dashes; when the value of theta is 0.0, the Softmax function graph is represented by solid lines.
[0232] As shown in Figure 12, the Softmax function graph is non-linearly monotonically decreasing, and the decrease in the dependent variable gradually slows down as the independent variable increases. Based on this, in this embodiment, the distance matrix formed by the distance information between the current sample and each reference sample can be used as input, and the output after processing by the Softmax function can be used as the reference sample weighting matrix (i.e., the weight matrix). This weight matrix can be used to generate the predicted value for the current block.
[0233] In this embodiment, the distance matrix is processed using the Softmax function to become the weight matrix. The process is shown in the following formula:
[0234] Here, theta is the first parameter of the Softmax function.
[0235] In one possible implementation, the first parameter theta is a constant. For example, the first parameter theta is -0.01.
[0236] In another possible implementation, if the encoder uses iteration to find the optimal theta value pattern, then the value of the first parameter theta will be written into the bitstream. Accordingly, the method may further include: determining the value of the first parameter theta; encoding the value of the first parameter theta; and writing the obtained encoded bits into the bitstream.
[0237] In some embodiments, determining the value of the first parameter theta may include: determining multiple candidate values for the first parameter; determining multiple candidate weight matrices for the current block based on the distance matrix of the current block and the multiple candidate values of the first parameter; performing weighted prediction based on the multiple candidate weight matrices of the current block and the reference samples of the current block to determine multiple candidate prediction blocks; calculating the cost of each of the multiple candidate prediction blocks with the original block of the current block to determine multiple cost results; determining the minimum cost result among the multiple cost results, and determining the candidate value corresponding to the minimum cost result as the value of the first parameter theta.
[0238] In this embodiment of the application, after determining multiple candidate values of the first parameter, taking rate distortion optimization as an example, the rate distortion cost of the current block can be calculated based on the multiple candidate values of the first parameter to determine the minimum rate distortion cost result; the candidate value corresponding to the minimum rate distortion cost result is determined as the value of the first parameter theta.
[0239] In this embodiment, the value range of the first parameter theta can be selected from 10 candidate values: -0.001, -0.002, ..., -0.01. Based on these candidate values, the current block is predicted to determine multiple candidate blocks. Cost calculations are then performed between each of the multiple candidate blocks and the original block of the current block to determine multiple rate-distortion cost results. The minimum rate-distortion cost result is then determined, and the candidate value corresponding to the minimum rate-distortion cost result is identified as the optimal value, i.e., the value of the first parameter theta, and written into the bitstream.
[0240] In other words, in this embodiment, since the Softmax prediction mode is mainly affected by the first parameter theta of the Softmax function, the range of theta values can be preset, selecting from 10 candidate values: -0.001, -0.002, ..., -0.01. Under the constraint of rate-distortion cost, the prediction scheme with the optimal theta value is iteratively searched. When the optimal theta value is determined and the Softmax prediction mode is finally selected as the prediction mode for the current block, the prediction mode and the optimal theta value can be written into the bitstream. During the iterative search for the optimal theta value, although the optimal theta value for each luma block can be found, writing the optimal theta value into the bitstream to ensure the decoder can obtain the optimal theta value for each luma block to complete correct decoding would increase the number of encoded bits and multiply the encoding complexity. Therefore, this embodiment recommends using the Softmax mode (theta = -0.01) to complete the intra-frame prediction process.
[0241] In some embodiments, determining the value of the first parameter theta may include: determining the template region of the current block; predicting the template region based on multiple candidate values of the first parameter to determine multiple candidate prediction blocks; calculating the cost of each candidate prediction block and the reconstructed block of the template region to determine multiple cost results; determining the minimum cost result among the multiple cost results, and determining the candidate value corresponding to the minimum cost result as the value of the first parameter.
[0242] In the embodiments of this application, the cost calculation here may be determined based on the cost result of rate distortion optimization (RDO), or it may be determined based on the cost result of absolute error and SAD, or even based on the cost result of absolute transformation difference and SATD, etc., but no limitation is made.
[0243] In other words, in this embodiment, the determination of the value of the first parameter theta can be extended to determine the value of the Softmax function based on relevant information of the upper or left reconstruction region of the current block. For example, the template region is predicted according to multiple candidate values of the first parameter theta, i.e., the template region is used to determine the value of the first parameter theta to obtain the optimal value of theta; then the determined optimal value of theta is applied to the luminance component of the current block for prediction.
[0244] In some embodiments, predicting a template region based on multiple candidate values of a first parameter to determine multiple candidate prediction blocks may include: calculating gradient information between at least one sample in the template region and a reference sample in the template region; determining multiple candidate weight matrices of the template region based on the gradient information and multiple candidate values of the first parameter; and performing weighted prediction based on the multiple candidate weight matrices of the template region and the reference sample in the template region to determine multiple candidate prediction blocks.
[0245] In other words, in this embodiment, a weighted value for the reference sample is generated based on the distance information between the reference sample and the sample to be predicted. This can be extended to predict the brightness component of the current block based on the gradient information of the reference sample. For example, the template region of the current block and the reference sample of the template region can be determined first; then the gradient information of each sample in the template region and its corresponding reference sample can be calculated; a weight value for the reference sample of the template region can be generated based on the gradient information; a weighted prediction can be performed based on the weight value of the reference sample of the template region and the reference sample of the template region; the first parameter theta can be iterated to find the optimal value of theta in the template region, and this optimal value can be used as the value of the first parameter theta, and applied to predict the brightness component of the current block.
[0246] In another possible implementation, determining the weight matrix of the current block based on the distance matrix may include: determining multiple piecewise linear functions corresponding to a preset function; and determining the weight matrix based on the distance matrix and the multiple piecewise linear functions.
[0247] For example, taking the Softmax function with the first parameter theta = -0.01 as an example, as shown in Figure 12, within a certain range of the independent variable's values, for example, when x belongs to [40, 60], the graph of this function can be approximated as a monotonic linear function. Different piecewise linear functions can be selected based on the distance information in the distance matrix. Assuming the Softmax function can be divided into multiple piecewise linear functions according to [0, 20], [20, 40], [40, 60], [60, 80], and [80, 100], if the distance information x in the distance matrix belongs to [20, 40], then the piecewise linear function corresponding to [20, 40] is selected; if the distance information x in the distance matrix belongs to [40, 60], then the piecewise linear function corresponding to [40, 60] is selected; if the distance information x in the distance matrix belongs to [80, 100], then the piecewise linear function corresponding to [80, 100] is selected, and so on. In this way, by using multiple piecewise linear functions instead of the Softmax function, the reference samples can be weighted using multiple piecewise linear functions.
[0248] S1504, based on the weight matrix and reference samples, determine the predicted value of the first color component of the current block.
[0249] In this embodiment, after obtaining the weight matrix, a multiplication operation is performed based on the reference sample and the weight matrix to obtain the predicted value of the first color component of the current block. In some embodiments, determining the predicted value of the first color component of the current block based on the weight matrix and the reference sample may include: performing a weighted prediction based on the first color component of the weight matrix and the reference sample to determine the first predicted value of the first color component of the current block; and filtering the first predicted value of the first color component to determine the predicted value of the first color component of the current block.
[0250] It should be noted that, in the embodiments of this application, if the first color component is a luminance component, then the first predicted value of the current block can be obtained by weighting the luminance component values of the reference sample and the weighted calculation. Alternatively, if the first color component is a chrominance component, then the first predicted value of the current block can be obtained by weighting the chrominance component values of the reference sample and the weighted calculation.
[0251] It should also be noted that, in the embodiments of this application, after the weight matrix is used to calculate the weighted sample, in order to ensure the validity of the predicted value, the obtained first predicted value can also be filtered, for example, a pruning operation can be performed.
[0252] In some embodiments, filtering the first predicted value of the first color component to determine the predicted value of the first color component of the current block may include: when the first predicted value of the first color component is within a preset range, using the first predicted value of the first color component as the predicted value of the first color component of the current block; when the first predicted value of the first color component is outside the preset range, performing a trimming operation on the first predicted value of the first color component so that the predicted value of the first color component of the current block is within the preset range.
[0253] In this embodiment, the pruning operation can also be called a clipping operation, thereby obtaining the final predicted value of the current block. The process is expressed as follows: P(x,y)=min(max(W(r,x,y)·R(r),0),2 bitdepth -1) (5)
[0254] Here, bitdepth represents the bit depth, which is usually set to 10 bits. bitdepth The value of -1 is 1023, which is also the maximum value of the sample.
[0255] It should also be noted that, in the embodiments of this application, if the first predicted value (W(r,x,y)·R(r)) is less than 0, then P(x,y) can be set to equal 0; if the first predicted value (W(r,x,y)·R(r)) is greater than 2, then P(x,y) can be set to equal 0; bitdepth If -1, then P(x,y) can be set to equal 2. bitdepth -1; if 0 ≤ the first predicted value (W(r,x,y)·R(r)) ≤ 2 bitdepth If -1, then P(x,y) can be set to equal the first predicted value (W(r,x,y)·R(r)) so that the predicted value of the current block is clamped within a preset range, i.e., [0, 2]. bitdepth Within -1].
[0256] Understandably, in the embodiments of this application, a Softmax prediction mode extension can also be performed for the first prediction mode. In some embodiments, the method may further include: when the first syntax element indicates that the first color component of the current block uses the first prediction mode, copying based on the reference sample of the current block to determine the predicted value of the first color component of the current block.
[0257] In this embodiment, the reference sample may include a left reference sample and an upper reference sample. Accordingly, determining the predicted value of the first color component of the current block by copying the reference sample of the current block may include: dividing the current block according to a preset boundary line to determine a first sub-block and a second sub-block of the current block; copying the reconstructed value of the left reference sample to the predicted value of the first color component of the first sub-block, and copying the reconstructed value of the upper reference sample to the predicted value of the first color component of the second sub-block; calculating the average value of the reconstructed values of the left reference sample and the upper reference sample, and determining the calculated average value as the predicted value of the first color component of at least one sample on the preset boundary line.
[0258] In other words, in this embodiment, a direct copy mode can also be used. For example, by observing the Softmax function graph shown in Figure 12, it can be seen that when the first parameter theta is 0.0, regardless of the distribution of the input data, it can be converted into an equal probability distribution. In other words, the weight corresponding to each reference sample is the same (theta is 0, corresponding to the DC mode). When the first parameter theta is -0.001, the function graph gradually decreases, slowly approaching the function graph when theta is 0. Based on this, the Softmax prediction mode can be directly extended to a nearest-neighbor copy mode. Using the diagonal of the current block as a preset boundary, the sample at the lower left corner of the diagonal is copied to the left reference sample at the corresponding position, and the sample at the upper right corner of the diagonal is copied to the upper reference sample at the corresponding position. The samples on the diagonal are the average of the upper and left reference samples at the corresponding positions.
[0259] It can also be understood that, in the embodiments of this application, for step S1002, if the first syntax element indicates that the first color component of the current block does not use the first prediction mode, then the luminance component of the current block can be predicted according to the existing intra-frame prediction mode.
[0260] It is also understood that, in the embodiments of this application, the first prediction mode can also be extended to predict the chromaticity components of the current block. In some embodiments, the method may further include: when the second color component of the current block uses the DM mode, determining the predicted value of the second color component of the current block according to the first prediction mode used by the first color component of the current block.
[0261] In this embodiment of the application, the method for determining whether the second color component of the current block uses the DM mode may include: determining multiple candidate prediction modes for the second color component of the current block; predicting the second color component of the current block based on the multiple candidate prediction modes to determine multiple candidate blocks; calculating the cost of each candidate block with the original block of the current block to determine multiple candidate cost results; and determining whether the second color component of the current block uses the DM mode based on the multiple candidate cost results.
[0262] In this embodiment, it is assumed that the second color component can be a chromaticity component. The multiple candidate prediction modes include at least the DM mode and other chromaticity prediction modes. The cost calculation can be performed using rate-distortion optimization or other cost calculation methods. For example, taking rate-distortion optimization as an example, the chromaticity component of the current block is predicted for multiple candidate prediction modes to obtain multiple candidate blocks. Then, rate-distortion cost calculation is performed between each of the multiple candidate blocks and the original block of the current block to determine the candidate cost result of each of the multiple candidate prediction modes. Based on the obtained multiple candidate cost results, it is determined whether the chromaticity component of the current block uses the DM mode.
[0263] In some embodiments, determining whether the second color component of the current block uses the DM mode based on multiple candidate cost results may include: determining the minimum cost result among multiple candidate cost results; if the candidate prediction mode corresponding to the minimum cost result is the DM mode, then determining that the second color component of the current block uses the DM mode; if the candidate prediction mode corresponding to the minimum cost result is not the first prediction mode, then determining that the second color component of the current block does not use the DM mode.
[0264] In the embodiments of this application, the prediction mode used for the current block can typically be selected based on the principle of minimizing rate-distortion cost. For example, if the candidate prediction mode corresponding to the minimum cost result is the DM mode, then the chroma component of the current block is determined to use the DM mode; if the candidate prediction mode corresponding to the minimum cost result is not the DM mode, then the chroma component of the current block is determined not to use the DM mode.
[0265] In this embodiment, a second syntax element can also be written into the bitstream. The second syntax element indicates whether the second color component of the current block uses DM mode. In some embodiments, the method may further include: determining the value of the second syntax element; encoding the value of the second syntax element; and writing the obtained encoded bits into the bitstream.
[0266] In this embodiment of the application, if the second color component of the current block uses DM mode, the value of the second syntax element is determined to be a first value; if the second color component of the current block does not use DM mode, the value of the second syntax element is determined to be a second value.
[0267] In one possible implementation, the second syntax element can be a mode flag. Here, the first value can be set to 1 and the second value to 0; or, the first value can be set to true and the second value to false, without any limitation. For example, if the second color component of the current block uses DM mode, then the value of the second syntax element can be written to the bitstream as true; otherwise, if the second color component of the current block does not use DM mode, then the value of the second syntax element can be written to the bitstream as false.
[0268] In other words, in this embodiment of the application, assuming that the first color component is the luminance component and the second color component is the chrominance component, if the chrominance component of the current block uses the DM mode, then according to the first prediction mode used by the luminance component of the current block, it can be determined that the chrominance component of the current block can also be predicted according to the first prediction mode.
[0269] In some embodiments, determining the predicted value of the second color component of the current block based on the first prediction mode used by the first color component of the current block may include: determining a reference sample of the current block when the second syntax element indicates that the second color component of the current block uses the DM mode; determining a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; determining a weight matrix of the current block based on the distance matrix; and performing weighted prediction based on the weight matrix and the second color component of the reference sample to determine the predicted value of the second color component of the current block.
[0270] In this embodiment of the application, when the second syntax element indicates that the second color component of the current block uses the DM mode, the first prediction mode can be applied to the chromaticity component of the current block for prediction. Specifically, when the first prediction mode is applied to the chromaticity component of the current block for prediction, the value of the first parameter theta can be set to -1.
[0271] In this embodiment, the distance information here is the same as the distance information mentioned above, which can be the Euclidean distance between at least one sample in the current block and the reference sample, or it can be other distances, such as cosine distance, Manhattan distance, Chebyshev distance, Minkowski distance, etc., and no limitation is made here.
[0272] In this embodiment, determining the weight matrix of the current block based on the distance matrix still involves processing the distance matrix using a preset function to obtain the weight matrix. For example, the preset function can be the Softmax function, and the first parameter theta is set to -1. This allows for accurate prediction of the chromaticity components of the current block when the first prediction mode is applied to the chromaticity prediction process using the DM mode.
[0273] In another embodiment of this application, a bitstream is provided, which is generated by bit encoding according to the encoding method described in the foregoing embodiments; wherein the information to be encoded in the encoding method includes at least one of the following: the value of a first parameter, the value of a first syntax element, and the value of a second syntax element. The first syntax element is used to indicate whether the first color component of the current block uses a first prediction mode, and the second syntax element is used to indicate whether the second color component of the current block uses a DM mode.
[0274] This application provides an encoding method that, based on existing intra-frame prediction modes, adds a new intra-frame prediction mode (i.e., a first prediction mode). Specifically, when using the first prediction mode for the first color component of the current block, the distance matrix of the current block is determined based on reference samples. Then, the corresponding weight matrix is determined based on the distance matrix, and finally, the predicted value of the first color component of the current block is determined based on the weight matrix and the reference samples. Thus, when the first prediction mode is applied to the luma component, the prediction accuracy of the luma component of the current block can be improved; when the first prediction mode is applied to the chroma component, the prediction accuracy of the chroma component of the current block can also be improved. Therefore, this process can achieve accurate prediction of both the luma component of the current block and the chroma component using the DM mode, while reducing prediction complexity, saving bitrate, improving encoding efficiency, and ultimately improving encoding performance.
[0275] In another embodiment of this application, based on the encoding and decoding method described in the foregoing embodiments, taking the current block as a CU as an example, this embodiment proposes an intra-frame luminance prediction mode based on the Softmax function to accurately predict the luminance CU during intra-frame coding. First, based on the 67 existing intra-frame prediction modes in H.266 / VVC, an intra-frame luminance prediction mode based on the Softmax function is added here for accurate prediction of the CU luminance component. Second, applying this prediction mode to the chrominance prediction process using the DM mode can also accurately predict the chrominance component of the CU. Since this process is beneficial for both accurately predicting the current luminance CU and providing more accurate predictions for the chrominance CU using the DM mode, it improves coding efficiency.
[0276] In a specific embodiment, taking the Softmax function as an example, the following will provide a detailed introduction to the Softmax function, the intra-frame luminance prediction mode based on the Softmax function, the specific implementation of the prediction mode, and the position of the prediction mode in the encoding and decoding framework.
[0277] (1) Softmax function.
[0278] The Softmax function is a commonly used mathematical function, typically used in multi-class classification problems. It transforms a set of real numbers into a form representing a probability distribution. The definition of the Softmax function is as follows:
[0279] Suppose we have a vector x = (x1, x2, ..., xn) containing N real numbers. n The Softmax function calculates each element x in this vector. i Convert to a real number σ(x) between 0 and 1 i ), and the sum of all transformed elements is 1. The definition of the Softmax function is shown in equation (3) above. Where k = 1, 2, ..., N, e is the base of the natural logarithm (or "Euler number"), express The exponential form, where the first parameter theta is a function of x. k The scaling factor.
[0280] Here, the Softmax function transforms any real vector into a probability distribution where the sum of all elements is 1. This not only normalizes the input vector but also represents the relative magnitude of each element. When the first parameter, theta, is negative, its graph, as shown in Figure 12, is non-linearly monotonically decreasing, and the decrease in the dependent variable gradually slows down as the independent variable increases. Based on this, the distance matrix formed by the Euclidean distances between the current sample and each reference sample is used as input, and the output processed by the Softmax function is used as the reference sample weighting matrix (i.e., the aforementioned "weight matrix") to generate the predicted value of the current CU.
[0281] (2) Intra-frame brightness prediction mode based on the Softmax function (Softmax prediction mode).
[0282] Similar to the processing of traditional intra-frame prediction modes (i.e., the existing 67 intra-frame prediction modes), the process can be divided into two steps: reference sample acquisition and prediction value calculation. In the reference sample acquisition stage, the reference sample range needs to be determined first, followed by determining whether to filter candidate samples within the reference sample range. Since this technical solution strictly adheres to VVC smoothing filtering and non-integer pixel interpolation conditions, this embodiment ultimately uses a single reference row / column pixel and does not require filtering of the reference samples. In the prediction value calculation stage, the Euclidean distance between each reference sample and the sample to be predicted in the current block needs to be determined first. Then, based on the Euclidean distance matrix and the Softmax function, the reference sample weighting matrix is determined. Finally, the reference samples are weighted using the reference sample weighting matrix to obtain the prediction value of the current CU. The specific prediction process is shown in Figure 17. This prediction process may include: determining the distance information between the reference sample R(r) and the sample to be predicted c(x,y) in the current block; determining the Euclidean distance matrix D between each reference sample and the sample to be predicted in the current block; using the Softmax function to process and determine the reference sample weighting matrix W; using the reference sample weighting matrix W to weight the reference samples, the predicted value P(x,y) of the sample to be predicted in the current block can be obtained.
[0283] In one possible implementation, the calculation process for a specific predicted value may include:
[0284] (a) Construction of the Euclidean distance matrix.
[0285] For a single video frame, samples exhibit spatial correlation. Generally, the closer the samples are, the stronger the correlation; as the distance increases, the correlation gradually weakens. This step aims to illustrate the dependency of samples in the current CU on reference samples located above or to the left of the current CU by calculating the Euclidean distance between each sample in the current CU and each reference sample. This quantitatively represents the direct impact of the distance between samples in the current CU and reference samples on the sample values of the current CU.
[0286] Here, using Indicates the current CU; The reference sample of the current CU is represented by the upper reference sample and the left reference sample; W and H are the width and height of the current CU, respectively. Let D be the Euclidean distance matrix, as shown in equation (1) above. Here, x and y are the x and y coordinates of the current sample in the current CU, respectively, and r is the non-zero x / y coordinate of the reference sample. x,y R represents the distance information of the sample to be predicted at position (x,y) in the current CU. r This represents the distance information for the r-th reference sample.
[0287] (b) Obtaining the weighted matrix of the reference sample.
[0288] Here, the Softmax function is used to process the Euclidean distance matrix to obtain the reference sample weighting matrix. The Softmax function has the property of always being positive and summing to 1. Since the correlation between samples generally decreases with increasing distance, this is equivalent to the shorter the distance between samples, the closer they are, and the higher the influence of the reference sample on the current sample to be predicted, thus increasing the influence weight accordingly. Therefore, the Softmax function is used to process the Euclidean distance matrix to make it the reference sample weighting matrix. The process is shown in equation (4) above. Here, theta is the first parameter of the Softmax function, and its value can be -0.01.
[0289] (c) Predicted value generation.
[0290] Here, the reference samples are weighted using a reference sample weighting matrix, and then a Clip operation is performed to obtain the predicted value of the sample to be predicted in the current block. The process is shown in equation (5) above. Here, bitdepth represents the bit depth, typically set to 10 bits, where 2 bitdepth The value of -1 is 1023, which is also the maximum value of the sample.
[0291] (3) Softmax prediction mode extension.
[0292] (a) Direct Copy mode.
[0293] As observed in Figure 12, the Softmax function graph shows that when the first parameter theta is 0.0, regardless of the distribution of the input data, it will be transformed into an equal probability distribution. In other words, the weight of each reference sample is the same (theta is 0, corresponding to the DC mode). When the first parameter theta is -0.001, the function graph gradually decreases, approaching the function graph when the first parameter theta is 0. Based on this, the Softmax prediction mode can be directly extended to a nearest-neighbor copy mode. Taking the diagonal of the current CU as the preset dividing line, the sample in the lower left corner of the diagonal is copied to the left reference sample of the corresponding position, and the sample in the upper right corner of the diagonal is copied to the upper reference sample of the corresponding position. The sample on the diagonal is the average of the upper and left reference samples of the corresponding position.
[0294] (b) Iteratively find the optimal value of theta.
[0295] Since the Softmax prediction mode is mainly affected by the parameters of the Softmax function, a pre-set range of theta values is implemented, selecting from 10 candidate values: -0.001, -0.002, ..., -0.01. Then, through rate-distortion cost constraints, the prediction scheme with the optimal theta value is iteratively searched. When the optimal theta value is determined and the Softmax prediction mode is finally selected as the optimal prediction mode, the prediction mode and the optimal theta value are written into the bitstream. In the iterative search for the optimal theta value mode, although the optimal theta value for each luminance CU can be found, writing the optimal theta value into the bitstream to ensure that the decoder can obtain the optimal theta value for each luminance CU to complete the correct decoding will lead to an increase in the number of encoded bits and a multiple increase in encoding complexity. Therefore, this application embodiment recommends using the Softmax mode (theta = -0.01) to complete the intra-frame prediction process.
[0296] (c) Piecewise linear fitting.
[0297] As can be seen from the graph of the Softmax function in Figure 12, taking theta = -0.01 as an example, within a certain range of independent variable values, such as when x belongs to [40, 60], the graph of this function can be approximated as a monotonic linear function. In this case, the Softmax function can be replaced by multiple piecewise linear functions, that is, the reference sample can be weighted by multiple piecewise linear functions.
[0298] (4) The Softmax mode introduces the VVC coding framework.
[0299] In one specific embodiment, Figure 18 is a detailed flowchart of an encoding method provided in this application. As shown in Figure 18, the detailed flowchart may include:
[0300] S1801, determine the reference sample for the current CU.
[0301] S1802 calculates the rate-distortion cost for the traditional prediction model, the Softmax prediction model, and the MIP prediction model.
[0302] S1803, perform rate distortion cost result judgment.
[0303] S1804, determine the optimal brightness prediction mode.
[0304] S1805, determine the luminance residual and the optimal luminance prediction mode.
[0305] S1806, writes the luminance residual and the optimal luminance prediction mode into the bitstream.
[0306] In this embodiment, rate-distortion cost calculation is performed on the traditional prediction mode, Softmax prediction mode, and MIP prediction mode to determine the rate-distortion cost results of each mode. Then, the rate-distortion cost results are judged, and the optimal brightness prediction mode is determined based on the minimum rate-distortion cost result. The current CU is predicted according to the optimal brightness prediction mode, and the brightness residual of the current CU is determined by subtraction between the original value and the predicted value. Then, the brightness residual and the optimal brightness prediction mode are encoded, and the obtained encoded bits are written into the bitstream.
[0307] In other words, in this embodiment, a 68th intra-frame prediction mode for luma can be added at the encoding end, numbered 67. The RDO cost is calculated to determine whether to select this prediction mode. If the final luma prediction mode is this mode, it is written into the bitstream using the existing entropy encoding and truncated binary encoding algorithm in the VVC encoder. If the chroma mode is DM mode, the value of theta is set to -1, and RDO cost calculations are performed with other chroma prediction modes.
[0308] In one specific embodiment, Figure 19 is a detailed flowchart of a decoding method provided in an embodiment of this application. As shown in Figure 19, the detailed flowchart may include:
[0309] S1901, parsing the bitstream.
[0310] S1902, determine the luminance residual and the optimal luminance prediction mode.
[0311] S1903, determine the optimal prediction mode.
[0312] S1904, the optimal prediction mode is determined to be the Softmax prediction mode.
[0313] S1905, the optimal prediction model is determined to be the traditional prediction model / MIP prediction model.
[0314] S1906, determine the current luminance prediction value of the CU.
[0315] In this embodiment of the application, for step S1903, if the mode index of the optimal prediction mode is 67 (Mode = 67), then step S1904 can be executed, that is, the Softmax prediction mode is used to predict the current CU and determine the brightness prediction value of the current CU; if the mode index of the optimal prediction mode is not 67 (Mode != 67), then step S1905 can be executed, that is, the traditional prediction mode / MIP prediction mode is used to predict the current CU and determine the brightness prediction value of the current CU.
[0316] In this embodiment of the application, the decoding end first parses the intra-frame luminance prediction mode (i.e., "optimal prediction mode") of the current CU from the bitstream. If the mode index of the intra-frame luminance prediction mode is 67, the Softmax prediction mode is used to obtain the prediction value of the current CU. Otherwise, the current CU is predicted and reconstructed according to the conventional prediction mode (traditional prediction mode / MIP prediction mode).
[0317] It should also be noted that, in this embodiment, the Softmax prediction mode is represented by a syntax element in the bitstream. When the value of this syntax element is equal to 67, it indicates that the current block uses the Softmax prediction mode. Specifically, for the four methods of softmax mode (based on the Softmax function, direct copy mode, iterative search for the optimal theta value mode, piecewise fitting function, etc.), these four methods will not be enabled simultaneously. The encoder uses whichever method is enabled, and there is no need for a syntax element to indicate the specific method used.
[0318] In this embodiment, the proposed technical solution is implemented in the latest version of the VVC testing software VTM23.1, and the test sequence used is the Class C, Class D, Class E, and Class F sequence given in the general test conditions. The results in Tables 1 and 5 are obtained by encoding in AI mode using QP22, 27, 32, 37, and 42.
[0319] In one possible implementation, the first parameter theta is set to -0.01, and the reference samples are weighted using the Softmax function. Specific test results are shown in Tables 1 to 4. Table 1 shows the test results of the BD-rate of the Softmax prediction mode in VTM23.1, and Tables 2 to 4 show the test results of the BD-rate of the Softmax prediction mode at different bitrates.
[0320] Table 1
[0321] Table 2
[0322] Table 3
[0323] Table 4
[0324] In one possible implementation, the samples in the current block are based on the values of the nearest Copy reference sample. Specific test results are shown in Tables 5 to 8. Table 5 shows the test results of the BD-rate for the nearest Copy prediction mode in VTM23.1, while Tables 6 to 8 show the test results of the BD-rate for the nearest Copy prediction mode at different bitrates.
[0325] Table 5
[0326] Table 6
[0327] Table 7
[0328] Table 8
[0329] In Tables 1 to 8, Class represents the video category, Sequence represents the specific test sequence, and Y, U, and V represent the performance of the three components of video luminance and chrominance. The values in the tables are BD-rates, which are a way to measure algorithm performance. They represent the changes in bitrate and PSNR / SSIM of the encoding algorithm in this application embodiment compared to the original algorithm. A negative value indicates a performance improvement, and the larger the absolute value, the greater the performance improvement. BD-rate5 q12345 represents the BD-rate results under five bitrate conditions with QP of 22, 27, 32, 37, and 42; BD-rate4 q2345 represents the BD-rate results under low bitrate conditions with QP of 27, 32, 37, and 42; and BD-rate4 q1234 represents the BD-rate results under high bitrate conditions with QP of 22, 27, 32, and 37.
[0330] Understandably, in the embodiments of this application, the technical solution generates a reference sample weighted value based on the distance information between the reference sample and the pixel sample to be predicted, and can be extended to predict the CU brightness component based on the gradient information of the reference sample.
[0331] It can also be understood that, in the embodiments of this application, the technical solution can be extended to determine the optimal value of the Softmax function based on the relevant information of the reconstructed CU above or to the left of the current CU, so as to predict the luminance component of the CU, that is: using the template region to determine the optimal value of the CU.
[0332] It is also understood that, in the embodiments of this application, the technical solution can be extended to predict the CU chromaticity components. Furthermore, in the embodiments of this application, the technical solution can also operate in Random Access (RA), Low Delay P (LDP or LP) and Low Delay B (LDB or LP) configuration modes.
[0333] In this application, the specific implementation of the aforementioned embodiments is described in detail through the above embodiments. It can be seen that, based on the technical solutions of the aforementioned embodiments, an intra-frame luminance prediction mode based on the Softmax function is proposed to accurately predict the luminance CU during intra-frame coding. First, based on the 67 traditional intra-frame prediction modes of H.266 / VVC, an intra-frame luminance prediction mode based on the Softmax function is added for accurate prediction of the CU luminance component. Second, applying this prediction mode to the chrominance prediction process using the DM mode can also accurately predict the chrominance component of the CU. Since this process is beneficial for both accurately predicting the current luminance CU and providing more accurate predictions for the chrominance CU using the DM mode, coding efficiency can be improved.
[0334] 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 an encoder provided in an embodiment of this application. As shown in FIG20, the encoder 210 may include a first determining unit 2001 and a first predicting unit 2002; wherein,
[0335] The first determining unit 2001 is configured to: determine a reference sample of the current block when the first color component of the current block uses a first prediction mode; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample; and determine a weight matrix of the current block according to the distance matrix.
[0336] The first prediction unit 2002 is configured to determine the predicted value of the first color component of the current block based on the weight matrix and the reference sample.
[0337] In some embodiments, the first determining unit 2001 is further configured to determine multiple candidate prediction modes for the first color component of the current block; predict the current block based on the multiple candidate prediction modes to determine multiple candidate blocks; calculate the cost of the multiple candidate blocks with the original block of the current block to determine multiple candidate cost results; and determine whether the first color component of the current block uses the first prediction mode based on the multiple candidate cost results.
[0338] In some embodiments, the first determining unit 2001 is further configured to determine the minimum cost result among a plurality of candidate cost results; and if the candidate prediction mode corresponding to the minimum cost result is a first prediction mode, then determine that the first color component of the current block uses the first prediction mode; if the candidate prediction mode corresponding to the minimum cost result is not the first prediction mode, then determine that the first color component of the current block does not use the first prediction mode.
[0339] In some embodiments, referring to FIG20, the encoder 210 may further include an encoding unit 2003; wherein, the first determining unit 2001 is further configured to determine the value of a first syntax element, wherein the first syntax element is used to indicate whether the first color component of the current block uses a first prediction mode; the encoding unit 2003 is configured to encode the value of the first syntax element and write the obtained encoded bits into the bitstream.
[0340] In some embodiments, the first determining unit 2001 is further configured to determine the adjacent reference regions of the current block; and to determine the reference samples of the current block based on at least one candidate sample in the adjacent reference regions; wherein the adjacent reference regions include: the left adjacent reference region of the current block, and / or, the upper adjacent reference region of the current block.
[0341] In some embodiments, the first determining unit 2001 is further configured to filter at least one candidate sample in an adjacent reference region to determine a reference sample for the current block.
[0342] In some embodiments, the first determining unit 2001 is further configured to determine distance information between at least one sample in the current block and a reference sample; and to determine a distance matrix based on the distance information between at least one sample in the current block and the reference sample.
[0343] In some embodiments, the first determining unit 2001 is further configured to determine a preset function, wherein the preset function includes a first parameter; and to determine a weight matrix based on the distance matrix and the preset function.
[0344] In some embodiments, the first parameter takes the value of a constant.
[0345] In some embodiments, the first determining unit 2001 is further configured to determine a plurality of piecewise linear functions corresponding to a preset function; and to determine a weight matrix based on a distance matrix and the plurality of piecewise linear functions.
[0346] In some embodiments, the first prediction unit 2002 is further configured to perform weighted prediction based on the weight matrix and the first color component of the reference sample to determine a first predicted value of the first color component of the current block; and to perform filtering processing on the first predicted value of the first color component to determine a predicted value of the first color component of the current block.
[0347] In some embodiments, the first prediction unit 2002 is further configured to, when the first prediction value of the first color component is within a preset range, use the first prediction value of the first color component as the prediction value of the first color component of the current block; and when the first prediction value of the first color component is outside the preset range, perform a trimming operation on the first prediction value of the first color component so that the prediction value of the first color component of the current block is within the preset range.
[0348] In some embodiments, the first prediction unit 2002 is further configured to determine the predicted value of the first color component of the current block by copying a reference sample of the current block when the first color component of the current block uses the first prediction mode.
[0349] In some embodiments, the first prediction unit 2002 is further configured to divide the current block according to a preset boundary line, determine a first sub-block and a second sub-block of the current block; copy the reconstructed value of the left reference sample to the predicted value of the first color component of the first sub-block, copy the reconstructed value of the upper reference sample to the predicted value of the first color component of the second sub-block; and calculate the average value of the reconstructed value of the left reference sample and the reconstructed value of the upper reference sample, and determine the calculated average value as the predicted value of the first color component of at least one sample on the preset boundary line.
[0350] In some embodiments, the first determining unit 2001 is further configured to: determine multiple candidate weight matrices for the current block based on the distance matrix of the current block and multiple candidate values of the first parameter; perform weighted prediction based on the multiple candidate weight matrices of the current block and the reference sample of the current block to determine multiple candidate prediction blocks; perform cost calculations between the multiple candidate prediction blocks and the original block of the current block to determine multiple cost results; and determine the minimum cost result among the multiple cost results, and determine the candidate value corresponding to the minimum cost result as the value of the first parameter.
[0351] In some embodiments, the first determining unit 2001 is further configured to: determine the template region of the current block; predict the template region based on multiple candidate values of the first parameter to determine multiple candidate prediction blocks; calculate the cost of the multiple candidate prediction blocks and the reconstructed blocks of the template region to determine multiple cost results; and determine the minimum cost result among the multiple cost results, and determine the candidate value corresponding to the minimum cost result as the value of the first parameter.
[0352] In some embodiments, the first prediction unit 2002 is further configured to calculate gradient information between at least one sample in the template region and a reference sample in the template region; determine multiple candidate weight matrices of the template region based on the gradient information and multiple candidate values of the first parameter; and perform weighted prediction based on the multiple candidate weight matrices of the template region and the reference sample in the template region to determine multiple candidate prediction blocks.
[0353] In some embodiments, the encoding unit 2003 is further configured to encode the value of the first parameter and write the obtained encoded bits into the bit stream.
[0354] In some embodiments, the first prediction unit 2002 is further configured to determine the predicted value of the second color component of the current block according to the first prediction mode used by the first color component of the current block when the second color component of the current block uses the DM mode.
[0355] In some embodiments, the first determining unit 2001 is further configured to determine a reference sample of the current block; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; and determine a weight matrix of the current block according to the distance matrix; the first prediction unit 2002 is further configured to perform weighted prediction based on the weight matrix and the second color component of the reference sample to determine the predicted value of the second color component of the current block.
[0356] In some embodiments, the first determining unit 2001 is further configured to determine the value of the second syntax element, wherein the second syntax element is used to indicate whether the second color component of the current block uses DM mode; the encoding unit 2003 is further configured to encode the value of the second syntax element and write the obtained encoded bits into the bit stream.
[0357] 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.
[0358] In another embodiment of this application, FIG21 is a schematic diagram of the specific hardware structure of an encoder provided in an embodiment of this application. As shown in FIG21, the encoder 210 may include: a first communication interface 2101, a first memory 2102, and a first processor 2103; the various components are coupled together through a first bus system 2104. It is understood that the first bus system 2104 is used to realize the connection and communication between these components. In addition to a data bus, the first bus system 2104 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, all buses are labeled as the first bus system 2104 in FIG21.
[0359] The first communication interface 2101 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0360] The first memory 2102 is used to store computer programs that can run on the first processor 2103;
[0361] The first processor 2103 is configured to, when running the computer program, perform:
[0362] When the first color component of the current block uses the first prediction mode, a reference sample of the current block is determined; based on the reference sample, a distance matrix of the current block is determined, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; a weight matrix of the current block is determined according to the distance matrix; and the predicted value of the first color component of the current block is determined according to the weight matrix and the reference sample.
[0363] It is understood that the first memory 2102 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 2102 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.
[0364] The first processor 2103 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 2103 or by instructions in software form. The first processor 2103 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 2102. The first processor 2103 reads the information in the first memory 2102 and completes the steps of the above method in conjunction with its hardware.
[0365] 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.
[0366] Alternatively, as another embodiment, the first processor 2103 is further configured to perform the method described in any of the foregoing embodiments when running the computer program.
[0367] This embodiment provides an encoder that, based on existing intra-frame prediction modes, adds a new intra-frame prediction mode (i.e., a first prediction mode). Specifically, it determines the distance matrix of the current block based on reference samples, then determines the corresponding weight matrix based on the distance matrix, and finally determines the predicted value of the first color component of the current block based on the weight matrix and reference samples. Thus, when the first prediction mode is applied to the luma component, it can improve the prediction accuracy of the luma component of the current block; when applied to the chroma component, it can also improve the prediction accuracy of the chroma component of the current block. Therefore, this process can achieve accurate prediction of both the luma component of the current block and the chroma component using the DM mode, while reducing prediction complexity, saving bitrate, improving encoding and decoding efficiency, and ultimately enhancing encoding and decoding performance.
[0368] In another embodiment of this application, based on the same inventive concept as the foregoing embodiments, FIG22 is a schematic diagram of the composition structure of a decoder provided in an embodiment of this application. As shown in FIG22, the decoder 230 may include a decoding unit 2201, a second determining unit 2202, and a second predicting unit 2203, wherein:
[0369] Decoding unit 2201 is configured to parse the first syntax element in the bitstream;
[0370] The second determining unit 2202 is configured to: when the first syntax element indicates that the first color component of the current block uses a first prediction mode, determine a reference sample of the current block; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; and determine a weight matrix of the current block according to the distance matrix.
[0371] The second prediction unit 2203 is configured to determine the predicted value of the first color component of the current block based on the weight matrix and the reference sample.
[0372] In some embodiments, the second determining unit 2202 is further configured to determine the adjacent reference regions of the current block; and to determine the reference samples of the current block based on at least one candidate sample in the adjacent reference regions; wherein the adjacent reference regions include: the left adjacent reference region of the current block, and / or, the upper adjacent reference region of the current block.
[0373] In some embodiments, the second determining unit 2202 is further configured to filter at least one candidate sample in an adjacent reference region to determine a reference sample for the current block.
[0374] In some embodiments, the second determining unit 2202 is further configured to determine distance information between at least one sample in the current block and a reference sample; and to determine a distance matrix based on the distance information between at least one sample in the current block and the reference sample.
[0375] In some embodiments, the second determining unit 2202 is further configured to determine a preset function, wherein the preset function includes a first parameter; and to determine a weight matrix based on the distance matrix and the preset function.
[0376] In some embodiments, the preset function is a function that is non-linearly monotonically decreasing.
[0377] In some embodiments, the default function is the Softmax function.
[0378] In some embodiments, the first parameter takes the value of a constant.
[0379] In some embodiments, the decoding unit 2201 is further configured to parse the first parameter in the bitstream and determine the value of the first parameter.
[0380] In some embodiments, the second determining unit 2202 is further configured to determine a plurality of piecewise linear functions corresponding to a preset function; and to determine a weight matrix based on a distance matrix and the plurality of piecewise linear functions.
[0381] In some embodiments, the second prediction unit 2203 is further configured to perform weighted prediction based on the weight matrix and the first color component of the reference sample to determine a first predicted value of the first color component of the current block; and to perform filtering processing on the first predicted value of the first color component to determine a predicted value of the first color component of the current block.
[0382] In some embodiments, the second prediction unit 2203 is further configured to, when the first prediction value of the first color component is within a preset range, use the first prediction value of the first color component as the prediction value of the first color component of the current block; and when the first prediction value of the first color component is outside the preset range, perform a trimming operation on the first prediction value of the first color component so that the prediction value of the first color component of the current block is within the preset range.
[0383] In some embodiments, the second prediction unit 2203 is further configured to determine the predicted value of the first color component of the current block by copying a reference sample of the current block when the first syntax element indicates that the first color component of the current block uses the first prediction mode.
[0384] In some embodiments, the second prediction unit 2203 is further configured to divide the current block according to a preset boundary line, determine a first sub-block and a second sub-block of the current block; copy the reconstructed value of the left reference sample to the predicted value of the first color component of the first sub-block, copy the reconstructed value of the upper reference sample to the predicted value of the first color component of the second sub-block; and calculate the average value of the reconstructed value of the left reference sample and the reconstructed value of the upper reference sample, and determine the calculated average value as the predicted value of the first color component of at least one sample on the preset boundary line.
[0385] In some embodiments, the second determining unit 2202 is further configured to: determine the template region of the current block; predict the template region based on multiple candidate values of the first parameter to determine multiple candidate prediction blocks; calculate the cost of the multiple candidate prediction blocks and the reconstructed blocks of the template region to determine multiple cost results; and determine the minimum cost result among the multiple cost results, and determine the candidate value corresponding to the minimum cost result as the value of the first parameter.
[0386] In some embodiments, the second prediction unit 2203 is further configured to calculate gradient information between at least one sample in the template region and a reference sample in the template region; determine multiple candidate weight matrices of the template region based on the gradient information and multiple candidate values of the first parameter; and perform weighted prediction based on the multiple candidate weight matrices of the template region and the reference sample in the template region to determine multiple candidate prediction blocks.
[0387] In some embodiments, the decoding unit 2201 is further configured to parse the second syntax element in the bitstream; the second prediction unit 2203 is further configured to determine the predicted value of the second color component of the current block according to the first prediction mode used by the first color component of the current block when the second syntax element indicates that the second color component of the current block uses the DM mode.
[0388] In some embodiments, the second determining unit 2202 is further configured to determine a reference sample of the current block; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; and determine a weight matrix of the current block according to the distance matrix; the second prediction unit 2203 is further configured to perform weighted prediction based on the weight matrix and the second color component of the reference sample to determine the predicted value of the second color component of the current block.
[0389] 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.
[0390] In another embodiment of this application, FIG23 is a schematic diagram of the specific hardware structure of a decoder provided in an embodiment of this application. As shown in FIG23, the decoder 230 may include: a second communication interface 2301, a second memory 2302, and a second processor 2303; the various components are coupled together through a second bus system 2304. It is understood that the second bus system 2304 is used to realize the connection and communication between these components. In addition to a data bus, the second bus system 2304 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, all buses are labeled as the second bus system 2304 in FIG23.
[0391] The second communication interface 2301 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
[0392] The second memory 2302 is used to store computer programs that can run on the second processor 2303;
[0393] The second processor 2303 is configured to perform the following when running the computer program:
[0394] The first syntax element in the bitstream is parsed; when the first syntax element indicates that the first color component of the current block uses a first prediction mode, a reference sample of the current block is determined; based on the reference sample, a distance matrix of the current block is determined, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample respectively; a weight matrix of the current block is determined according to the distance matrix; and the predicted value of the first color component of the current block is determined according to the weight matrix and the reference sample.
[0395] Alternatively, as another embodiment, the second processor 2303 is also configured to perform the method described in any of the foregoing embodiments when running the computer program.
[0396] It is understood that the second memory 2302 has similar hardware functions to the first memory 2102, and the second processor 2303 has similar hardware functions to the first processor 2103; details will not be elaborated here.
[0397] This embodiment provides a decoder that adds a new intra-frame prediction mode (i.e., a first prediction mode) to the existing intra-frame prediction modes. Specifically, it determines the distance matrix of the current block based on reference samples, then determines the corresponding weight matrix based on the distance matrix, and finally determines the predicted value of the first color component of the current block based on the weight matrix and the reference samples. Thus, when the first prediction mode is applied to the luma component, it can improve the prediction accuracy of the luma component of the current block; when applied to the chroma component, it can also improve the prediction accuracy of the chroma component of the current block. Therefore, this process can achieve accurate prediction of both the luma component of the current block and the chroma component using the DM mode, while reducing prediction complexity, saving bitrate, improving encoding and decoding efficiency, and ultimately improving encoding and decoding performance.
[0398] In another embodiment of this application, FIG24 is a schematic diagram of the composition structure of an encoding and decoding system provided in an embodiment of this application. As shown in FIG24, the encoding and decoding system 240 may include an encoder 2401 and a decoder 2402.
[0399] In this embodiment, encoder 2401 can be any of the encoders described in the foregoing embodiments, and decoder 2402 can be any of the decoders described in the foregoing embodiments.
[0400] 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.
[0401] 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.
[0402] 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.
[0403] In some embodiments, this application also provides a computer-readable storage medium storing a bitstream thereon. This bitstream is generated by performing the steps of the encoding method as described in the foregoing embodiments.
[0404] In this embodiment of the application, the encoding method encodes the information to be encoded and writes the obtained encoded bits into the bitstream. Here, the information to be encoded includes at least one of the following: the value of a first parameter, the value of a first syntax element, and the value of a second syntax element. The first syntax element indicates whether the first color component of the current block uses a first prediction mode, and the second syntax element indicates whether the second color component of the current block uses a DM mode.
[0405] 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.
[0406] 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.
[0407] 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.
[0408] 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.
[0409] In addition, 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.
[0410] If the aforementioned 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 a portion 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 various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0411] 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.
[0412] 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.
[0413] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0414] The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0415] 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.
[0416] 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 technical scope 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
[0417] In this embodiment, at the encoding end, when the first color component of the current block uses a first prediction mode, a reference sample of the current block is determined; based on the reference sample, a distance matrix of the current block is determined, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample; a weight matrix of the current block is determined according to the distance matrix; and the predicted value of the first color component of the current block is determined according to the weight matrix and the reference sample. At the decoding end, a first syntax element in the bitstream is parsed; when the first syntax element indicates that the first color component of the current block uses the first prediction mode, a reference sample of the current block is determined; based on the reference sample, a distance matrix of the current block is determined, wherein the distance matrix is used to characterize the distance information between at least one sample in the current block and the reference sample; a weight matrix of the current block is determined according to the distance matrix; and the predicted value of the first color component of the current block is determined according to the weight matrix and the reference sample. Thus, based on the existing intra-frame prediction modes, this application embodiment adds a new intra-frame prediction mode (i.e., the first prediction mode). Specifically, it determines the distance matrix of the current block based on the reference sample, then determines the corresponding weight matrix based on the distance matrix, and finally determines the predicted value of the first color component of the current block based on the weight matrix and the reference sample. In this way, when the first prediction mode is applied to the luma component, the prediction accuracy of the luma component of the current block can be improved; when the first prediction mode is applied to the chroma component, the prediction accuracy of the chroma component of the current block can also be improved. Therefore, this process can achieve accurate prediction of the luma component of the current block and accurate prediction of the chroma component using the DM mode, while reducing prediction complexity, saving bitrate, improving encoding and decoding efficiency, and thus improving encoding and decoding performance.
Claims
1. A decoding method applied to a decoder, the method comprising: parsing a first syntax element in a bitstream; determining a reference sample of a current block when the first syntax element indicates that a first color component of the current block uses a first prediction mode; determining a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to represent distance information between at least one sample in the current block and the reference sample respectively; determining a weight matrix of the current block according to the distance matrix; and determining a prediction value of the first color component of the current block according to the weight matrix and the reference sample. The determining the reference sample of the current block comprises: determining a neighboring reference region of the current block; and determining the reference sample of the current block according to at least one candidate sample in the neighboring reference region. The determining the reference sample of the current block according to at least one candidate sample in the neighboring reference region comprises: filtering the at least one candidate sample in the neighboring reference region to determine the reference sample of the current block. The determining the distance matrix of the current block based on the reference sample comprises: determining distance information between at least one sample in the current block and the reference sample respectively; and determining the distance matrix according to the distance information between at least one sample in the current block and the reference sample respectively. The determining the weight matrix of the current block according to the distance matrix comprises: determining a preset function, wherein the preset function comprises a first parameter; and determining the weight matrix according to the distance matrix and the preset function. The preset function is a function with non-linear monotone decreasing.
2. The method of claim 1, wherein, The preset function is a Softmax function. The first parameter is a constant. The method further comprises: parsing the first parameter in the bitstream to determine a value of the first parameter. The determining the weight matrix of the current block according to the distance matrix comprises: determining a plurality of piecewise linear functions corresponding to the preset function; and determining the weight matrix according to the distance matrix and the plurality of piecewise linear functions.
3. The method of claim 2, wherein, The determining the prediction value of the first color component of the current block according to the weight matrix and the reference sample comprises: performing weighted prediction on the first color component of the current block according to the weight matrix and the first color component of the reference sample to determine a first prediction value of the first color component of the current block; and performing filtering processing on the first prediction value of the first color component to determine the prediction value of the first color component of the current block. The performing filtering processing on the first prediction value of the first color component to determine the prediction value of the first color component of the current block comprises: when the first prediction value of the first color component is within a preset range, taking the first prediction value of the first color component as the prediction value of the first color component of the current block.
4. The method of claim 1, wherein, 5. The method of claim 1, wherein, 6. The method of claim 5, wherein, 7. The method of claim 6, wherein, 8. The method of claim 5, wherein, 9. The method of claim 5, wherein, 10. The method of claim 5, wherein, 11. The method of any one of claims 1 to 10, wherein, 12. The method of claim 11, wherein, When the first prediction value of the first color component is out of a preset range, a clipping operation is performed on the first prediction value of the first color component, so that the prediction value of the first color component of the current block is within the preset range.
13. The method of claim 1, wherein, The method further comprises: When the first syntax element indicates that the first prediction mode is used for the first color component of the current block, a prediction value of the first color component of the current block is determined according to reference samples of the current block.
14. The method of claim 13, wherein, The reference samples include a left reference sample and an upper reference sample. The determination of the prediction value of the first color component of the current block according to the reference samples of the current block comprises: The current block is divided according to a preset boundary line to determine a first sub-block and a second sub-block of the current block; The reconstructed value of the left reference sample is correspondingly copied as the prediction value of the first color component of the first sub-block, and the reconstructed value of the upper reference sample is correspondingly copied as the prediction value of the first color component of the second sub-block; An average value of the reconstructed value of the left reference sample and the reconstructed value of the upper reference sample is calculated, and the calculated average value is correspondingly determined as the prediction value of the first color component of at least one sample on the preset boundary line.
15. The method of claim 5, wherein, The method further comprises: A template region of the current block is determined; A plurality of candidate prediction blocks are determined by predicting the template region based on a plurality of candidate values of the first parameter; A plurality of cost results are determined by performing cost calculation on the plurality of candidate prediction blocks and the reconstructed block of the template region respectively; A minimum cost result is determined in the plurality of cost results, and a candidate value corresponding to the minimum cost result is determined as the value of the first parameter.
16. The method of claim 15, wherein, The determination of the plurality of candidate prediction blocks by predicting the template region based on the plurality of candidate values of the first parameter comprises: Gradient information between at least one sample in the template region and a reference sample of the template region is calculated; A plurality of candidate weight matrices of the template region are determined according to the gradient information and the plurality of candidate values of the first parameter; The plurality of candidate prediction blocks are determined by performing weighted prediction on the reference sample of the template region and the plurality of candidate weight matrices of the template region.
17. The method of any one of claims 1 to 16, wherein, The method further comprises: A second syntax element in a code stream is parsed; When the second syntax element indicates that the DM mode is used for the second color component of the current block, a prediction value of the second color component of the current block is determined according to the first prediction mode used for the first color component of the current block.
18. The method of claim 17, wherein, The determination of the prediction value of the second color component of the current block according to the first prediction mode used for the first color component of the current block comprises: Reference samples of the current block are determined; A distance matrix of the current block is determined based on the reference samples, wherein the distance matrix is used to represent distance information between at least one sample in the current block and the reference samples respectively; A weight matrix of the current block is determined according to the distance matrix; The prediction value of the second color component of the current block is determined by performing weighted prediction on the second color component of the reference sample and the weight matrix.
19. An encoding method applied to an encoder, the method comprising: determining a reference sample of a current block when a first color component of the current block uses a first prediction mode; determining a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to represent distance information between at least one sample in the current block and the reference sample respectively; determining a weight matrix of the current block according to the distance matrix; determining a prediction value of the first color component of the current block according to the weight matrix and the reference sample.
20. The method of claim 19, wherein, The method further comprises: determining a plurality of candidate prediction modes of the first color component of the current block; determining a plurality of candidate blocks by predicting the current block based on the plurality of candidate prediction modes; determining a plurality of candidate cost results by performing cost calculation on the plurality of candidate blocks and an original block of the current block respectively; determining whether the first color component of the current block uses the first prediction mode according to the plurality of candidate cost results.
21. The method of claim 20, wherein, The determining whether the first color component of the current block uses the first prediction mode according to the plurality of candidate cost results comprises: determining a minimum cost result in the plurality of candidate cost results; if the candidate prediction mode corresponding to the minimum cost result is the first prediction mode, determining that the first color component of the current block uses the first prediction mode; if the candidate prediction mode corresponding to the minimum cost result is not the first prediction mode, determining that the first color component of the current block does not use the first prediction mode.
22. The method of claim 21, wherein, The method further comprises: determining a value of a first syntax element, wherein the first syntax element is used to indicate whether the first color component of the current block uses the first prediction mode; encoding the value of the first syntax element and writing the obtained encoding bits into a bitstream.
23. The method of claim 19, wherein, The determining the reference sample of the current block comprises: determining a neighboring reference region of the current block; determining the reference sample of the current block according to at least one candidate sample in the neighboring reference region; wherein the neighboring reference region comprises a left neighboring reference region of the current block and / or an upper neighboring reference region of the current block. The determining the reference sample of the current block according to at least one candidate sample in the neighboring reference region comprises:
24. The method of claim 23, wherein, filtering the at least one candidate sample in the neighboring reference region to determine the reference sample of the current block. The determining the distance matrix of the current block based on the reference sample comprises:
25. The method of claim 19, wherein, determining distance information between at least one sample in the current block and the reference sample respectively; determining the distance matrix according to the distance information between at least one sample in the current block and the reference sample respectively. The determining the weight matrix of the current block according to the distance matrix comprises:
26. The method of claim 19, wherein, determining a preset function, wherein the preset function comprises a first parameter; determining the weight matrix according to the distance matrix and the preset function. The value of the first parameter is a constant.
27. The method of claim 26, wherein, The determining the weight matrix of the current block according to the distance matrix comprises:
28. The method of claim 26, wherein, determining a plurality of piecewise linear functions corresponding to the preset function; determining the weight matrix according to the distance matrix and the plurality of piecewise linear functions.
29. The method of any one of claims 19 to 28, wherein, The determining of the prediction value of the first color component of the current block according to the weight matrix and the reference sample comprises: performing weighted prediction on the first color component of the reference sample according to the weight matrix to determine a first prediction value of the first color component of the current block; performing filtering processing on the first prediction value of the first color component to determine the prediction value of the first color component of the current block.
30. The method of claim 29, wherein, The filtering processing on the first prediction value of the first color component to determine the prediction value of the first color component of the current block comprises: when the first prediction value of the first color component is within a preset range, taking the first prediction value of the first color component as the prediction value of the first color component of the current block; when the first prediction value of the first color component is outside the preset range, performing clipping operation on the first prediction value of the first color component to make the prediction value of the first color component of the current block within the preset range.
31. The method of claim 19, wherein, The method further comprises: when the first prediction mode is used for the first color component of the current block, copying the reference sample of the current block to determine the prediction value of the first color component of the current block.
32. The method of claim 31, wherein, The reference sample comprises a left reference sample and an upper reference sample. The copying of the reference sample of the current block to determine the prediction value of the first color component of the current block comprises: dividing the current block according to a preset boundary line to determine a first sub-block and a second sub-block of the current block; correspondingly copying the reconstructed value of the left reference sample as the prediction value of the first color component of the first sub-block, and correspondingly copying the reconstructed value of the upper reference sample as the prediction value of the first color component of the second sub-block; performing average value calculation on the reconstructed value of the left reference sample and the reconstructed value of the upper reference sample, and correspondingly determining the calculated average value as the prediction value of the first color component of at least one sample on the preset boundary line.
33. The method of claim 26, wherein, The method further comprises: determining a plurality of candidate weight matrices of the current block based on the distance matrix of the current block and a plurality of candidate values of the first parameter; performing weighted prediction on the reference sample of the current block according to the plurality of candidate weight matrices of the current block to determine a plurality of candidate prediction blocks; determining a plurality of cost results according to cost calculation of the plurality of candidate prediction blocks and the original block of the current block respectively; determining a minimum cost result in the plurality of cost results, and determining the candidate value corresponding to the minimum cost result as the value of the first parameter.
34. The method of claim 26, wherein, The method further comprises: determining a template region of the current block; predicting the template region based on the plurality of candidate values of the first parameter to determine a plurality of candidate prediction blocks; determining a plurality of cost results according to cost calculation of the plurality of candidate prediction blocks and the reconstructed block of the template region respectively; determining a minimum cost result in the plurality of cost results, and determining the candidate value corresponding to the minimum cost result as the value of the first parameter.
35. The method of claim 34, wherein, The method further includes: calculating gradient information between at least one sample in the template region and a reference sample of the template region; determining a plurality of candidate weight matrices of the template region according to the gradient information and a plurality of candidate values of the first parameter; determining the plurality of candidate prediction blocks according to weighted prediction of the plurality of candidate weight matrices of the template region and the reference sample of the template region.
36. The method of any one of claims 33-35, wherein, The method further includes: encoding the value of the first parameter and writing the obtained encoding bits into a bitstream.
37. The method of any one of claims 19 to 36, wherein, The method further includes: when the second color component of the current block uses the DM mode, determining the prediction value of the second color component of the current block according to the first prediction mode used by the first color component of the current block.
38. The method of claim 37, wherein, The method further includes: determining a reference sample of the current block; determining a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to represent distance information between at least one sample in the current block and the reference sample respectively; determining a weight matrix of the current block according to the distance matrix; determining the prediction value of the second color component of the current block according to weighted prediction of the weight matrix and the second color component of the reference sample.
39. The method of claim 37, wherein, The method further includes: determining a value of a second syntax element, wherein the second syntax element is used to indicate whether the second color component of the current block uses the DM mode; encoding the value of the second syntax element and writing the obtained encoding bits into a bitstream.
40. An encoder, comprising a first determining unit and a first prediction unit, wherein: the first determining unit is configured to, when a first color component of a current block uses a first prediction mode, determine a reference sample of the current block; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to represent distance information between at least one sample in the current block and the reference sample respectively; and determine a weight matrix of the current block according to the distance matrix; the first prediction unit is configured to determine a prediction value of the first color component of the current block according to the weight matrix and the reference sample.
41. An encoder, comprising a first memory and a first processor, wherein: the first memory is configured to store a computer program capable of running on the first processor; the first processor is configured to, when running the computer program, execute the encoding method according to any one of claims 19 to 39.
42. A decoder, comprising a decoding unit, a second determining unit and a second prediction unit, wherein: the decoding unit is configured to parse a first syntax element in a bitstream; The second determining unit is configured to determine a reference sample of the current block when the first syntax element indicates that a first color component of the current block uses a first prediction mode; determine a distance matrix of the current block based on the reference sample, wherein the distance matrix is used to represent distance information between at least one sample in the current block and the reference sample respectively; and determine a weight matrix of the current block according to the distance matrix; and determine a prediction value of the first color component of the current block according to the weight matrix and the reference sample.
43. A decoder, comprising a second memory and a second processor, wherein: the second memory is configured to store a computer program capable of running on the second processor; the second processor is configured to execute the decoding method according to any one of claims 1 to 18 when running the computer program. The computer program is executed by the processor to implement the decoding method according to any one of claims 1 to 18, or the encoding method according to any one of claims 19 to 39.
44. A computer readable storage medium having stored thereon a computer program, wherein, The code stream is generated by the step of executing the encoding method according to any one of claims 19 to 39.
45. A computer-readable storage medium having a code stream stored thereon, wherein,
Citation Information
Patent Citations
Image component prediction method, encoder, decoder, and storage medium
CN113439440A
Image encoding / decoding method and apparatus using intra prediction
CN116405679A
Encoding and decoding method, code stream, encoder, decoder and storage medium
CN116803078A
Coding method and apparatus, decoding method and apparatus, and coding device, decoding device and storage medium
WO2023197189A1
Image encoding / decoding method and apparatus, and recording medium storing bitstream
WO2023200214A1