Encoding and decoding method and device, encoding equipment, decoding equipment and storage medium

CN119013990APending Publication Date: 2024-11-22GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280094515.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-04-12
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

There is a large deviation between the predicted value of the current block calculated by the inter-color component prediction technology of H.266/VVC and the original value, resulting in low prediction accuracy and affecting encoding performance.

Method used

By determining weighting coefficients that are more in line with the characteristics of the current block based on the template area, the prediction accuracy of the second color component is improved, thereby saving bit rates and improving encoding and decoding performance.

Benefits of technology

It improves the accuracy of color component prediction, reduces the bit rate, improves encoding performance, and improves video decoding quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119013990A_ABST
    Figure CN119013990A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a coding and decoding method and device, coding equipment, decoding equipment and a storage medium, and the decoding method comprises the steps: determining a first decoding parameter according to a template region; determining a reference sample value of a first color component of the current block; determining a first weighting coefficient according to a reference sample value of a first color component of the current block and the first decoding parameter; and determining a first predicted value of a second color component of the current block according to the first weighting coefficient and a reference sample value of the second color component of the current block.
Need to check novelty before this filing date? Find Prior Art

Description

Coding and decoding method, device, encoding device, decoding device and storage medium Technical Field

[0001] The embodiments of the present application relate to the field of video coding and decoding technology, and in particular to a coding and decoding method, apparatus, encoding device, decoding device, and storage medium. Background Art

[0002] As demand for video display quality increases, new video applications such as high-definition and ultra-high-definition video are emerging. The Joint Video Exploration Team (JVET) of the international standards organizations ISO / IEC and ITU-T has developed the next-generation video coding standard H.266 / Versatile Video Coding (VVC).

[0003] H.266 / VVC includes inter-color prediction technology. However, the predicted value of the current block calculated by this technology deviates significantly from the original value. This results in low prediction accuracy, degraded decoded video quality, and reduced encoding performance.

[0004] Summary of the Invention

[0005] The embodiments of the present application provide a coding and decoding method, apparatus, coding device, decoding device, and storage medium, which can improve the prediction accuracy of the second color component, thereby saving bit rate and improving coding and decoding performance.

[0006] In a first aspect, an embodiment of the present application provides a decoding method, which includes: determining a first decoding parameter based on a template area; determining a reference sample value of a first color component of a current block; determining a first weighting coefficient based on the reference sample value of the first color component of the current block and the first decoding parameter; and determining a first predicted value of the second color component of the current block based on the first weighting coefficient and the reference sample value of the second color component of the current block.

[0007] In the second aspect, an embodiment of the present application provides an encoding method, which includes: determining a first encoding parameter based on a template area; determining a reference sample value of a first color component of a current block; determining a first weighting coefficient based on the reference sample value of the first color component of the current block and the first encoding parameter; determining a first predicted value of the second color component of the current block based on the first weighting coefficient and the reference sample value of the second color component of the current block; in this way, the first encoding parameter is determined based on the template area, and based on this, a first weighting coefficient that is more in line with the characteristics of the current block can be obtained, thereby improving the prediction accuracy of the second color component of the current block, thereby saving bit rate and improving encoding performance.

[0008] In a third aspect, an embodiment of the present application provides an encoding device, comprising: a first determination module, a second determination module, a third determination module and a first prediction module; wherein the first determination module is configured to determine a first encoding parameter based on a template area; the second determination module is configured to determine a reference sample value of a first color component of a current block; the third determination module is configured to determine a first weighting coefficient based on the reference sample value of the first color component of the current block and the first encoding parameter; the first prediction module is configured to determine a first predicted value of the second color component of the current block based on the first weighting coefficient and the reference sample value of the second color component of the current block.

[0009] In a fourth aspect, an embodiment of the present application provides an encoding device comprising a first memory and a first processor; wherein the first memory is used to store a computer program that can be run on the first processor; and the first processor is used to execute the method described in the second aspect when running the computer program.

[0010] In the fifth aspect, an embodiment of the present application provides a decoding device, including: a fourth determination module, configured to determine a first decoding parameter based on a template area; a fifth determination module, configured to determine a reference sample value of a first color component of a current block; a sixth determination module, configured to determine a first weighting coefficient based on the reference sample value of the first color component of the current block and the first decoding parameter; and a second prediction module, configured to determine a first prediction value of the second color component of the current block based on the first weighting coefficient and the reference sample value of the second color component of the current block.

[0011] In a sixth aspect, an embodiment of the present application provides a decoding device, comprising a second memory and a second processor; wherein the second memory is used to store a computer program that can be run on the second processor; and the second processor is used to execute the method described in the first aspect when running the computer program.

[0012] In a seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed, it implements the method described in the first aspect or the method described in the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] FIG1 is a schematic diagram showing the distribution of effective adjacent areas;

[0014] FIG2 is a schematic diagram showing the distribution of selected areas under different prediction modes;

[0015] FIG3 is a flow chart of a model parameter derivation scheme;

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

[0017] FIG4B is a schematic block diagram of a decoder according to an embodiment of the present application;

[0018] FIG5 is a schematic diagram of an implementation flow of the encoding method provided in an embodiment of the present application;

[0019] FIG6 is a schematic diagram of the positions of adjacent areas of a current block provided by an embodiment of the present application;

[0020] FIG7 is a schematic diagram of an example of an upper template, a left template, and a current block not intersecting with each other, provided by an embodiment of the present application;

[0021] FIG8 is a schematic diagram illustrating an example of the interface between different types of templates and the current block provided by an embodiment of the present application;

[0022] FIG9 is a schematic diagram of a flow chart for implementing step 51 according to an embodiment of the present application;

[0023] FIG10 is a schematic diagram illustrating an example of overlap between a left template and a reference area provided by an embodiment of the present application;

[0024] FIG11 is another exemplary schematic diagram of reference areas of the left template and the right template provided in an embodiment of the present application;

[0025] FIG12A is another exemplary schematic diagram of reference areas of a left template and a right template provided in an embodiment of the present application;

[0026] FIG12B is a schematic diagram of a WCP prediction process provided in an embodiment of the present application;

[0027] FIG13 is a schematic diagram of an implementation flow of a decoding method provided in an embodiment of the present application;

[0028] FIG14 is a schematic diagram of the prediction process of the WCP technology provided in an embodiment of the present application;

[0029] FIG15 is a schematic diagram illustrating an example of a reference area of ​​a current block provided by an embodiment of the present application;

[0030] FIG16 is a schematic diagram of a flow chart for implementing step 143 according to an embodiment of the present application;

[0031] FIG17 is a schematic diagram of a flow chart for implementing step 144 according to an embodiment of the present application;

[0032] FIG18 is a schematic diagram of the structure of an encoding device provided in an embodiment of the present application;

[0033] FIG19 is a schematic diagram of a specific hardware structure of an encoding device provided in an embodiment of the present application;

[0034] FIG20 is a schematic diagram of the structure of a decoding device provided in an embodiment of the present application;

[0035] FIG21 is a schematic diagram of a specific hardware structure of a decoding device provided in an embodiment of the present application;

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

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

[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.

[0039] In the following description, reference is 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. It should also be noted that the terms "first, second, and third" in the embodiments of the present application are only used to distinguish similar objects and do not represent a specific ordering of the objects. It is understood that "first, second, and third" may be interchanged in a specific order or sequential order where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0040] In a video image, three color components are generally used to represent a coding block (CB); wherein the three color components are a luminance component, a blue chrominance component, and a red chrominance component. For example, the luminance component is usually represented by the symbol Y, the blue chrominance component is usually represented by the symbol Cb or U, and the red chrominance component is usually represented by the symbol Cr or V; thus, the video image can be represented in YCbCr format or YUV format. In addition, the video image can also be in RGB format or YCgCo format, etc., which is not limited in the embodiments of the present application.

[0041] It can be understood that in the current video image or video encoding and decoding process, the cross-component prediction technology mainly includes the cross-component linear model (CCLM) prediction mode and the multi-directional linear model (MDLM) prediction mode. Regardless of the model parameters derived according to the CCLM prediction mode or the model parameters derived according to the MDLM prediction mode, the corresponding prediction models can realize the prediction between color components such as the first color component to the second color component, the second color component to the first color component, the first color component to the third color component, the third color component to the first color component, the second color component to the third color component, or the third color component to the second color component.

[0042] Taking the prediction from the first color component to the second color component as an example, assuming that the first color component is the luminance component and the second color component is the chrominance component, in order to reduce the redundancy between the luminance component and the chrominance component, the CCLM prediction mode is used in VVC, that is, the predicted value of chrominance is constructed according to the reconstructed luminance value of the same coding block, such as: Pred C (i, j) = α·Rec L (i,j)+β.

[0043] Among them, i, j represent the position coordinates of the pixel to be predicted in the coding block, i represents the horizontal direction, and j represents the vertical direction; Pred C (i, j) represents the chroma prediction value corresponding to the pixel to be predicted at the position coordinate (i, j) in the coding block, Rec L (i, j) represents the reconstructed luminance value of the pixel to be predicted at position (i, j) in the same coding block (after downsampling). In addition, α and β represent model parameters, which can be derived from the reference pixels.

[0044] For a coding block, its adjacent areas can be divided into five parts: the left adjacent area, the upper adjacent area, the lower left adjacent area, the upper left adjacent area, and the upper right adjacent area. H.266 / VVC includes three cross-component linear model prediction modes, namely: the left and upper adjacent intra-frame CCLM prediction mode (which can be represented by INTRA_LT_CCLM), the left and lower left adjacent intra-frame CCLM prediction mode (which can be represented by INTRA_L_CCLM), and the upper and upper right adjacent intra-frame CCLM prediction mode (which can be represented by INTRA_T_CCLM). In these three prediction modes, each prediction mode can select a preset number (for example, 4) of reference pixels for the derivation of model parameters α and β. The biggest difference between these three prediction modes is that the selected areas corresponding to the reference pixels used to derive the model parameters α and β are different.

[0045] Specifically, for the coding block size corresponding to the chrominance component is W×H, assuming that the upper selection area corresponding to the reference pixel is W′, and the left selection area corresponding to the reference pixel is H′; thus,

[0046] For the INTRA_LT_CCLM mode, reference pixels can be selected from the upper adjacent area and the left adjacent area, that is, W′=W, H′=H; for the INTRA_L_CCLM mode, reference pixels can be selected from the left adjacent area and the lower left adjacent area, that is, H′=W+H, and W′=0 is set; for the INTRA_T_CCLM mode, reference pixels can be selected from the upper adjacent area and the upper right adjacent area, that is, W′=W+H, and H′=0 is set.

[0047] It should be noted that in VTM5.0, only pixels in the W range are stored in the upper right adjacent area, and only pixels in the H range are stored in the lower left adjacent area. Therefore, although the selection area of ​​the INTRA_L_CCLM mode and the INTRA_T_CCLM mode is defined as W+H, in actual applications, the selection area of ​​the INTRA_L_CCLM mode will be limited to H+H, and the selection area of ​​the INTRA_T_CCLM mode will be limited to W+W. In this way,

[0048] For INTRA_L_CCLM mode, the reference pixels can be selected from the left adjacent area and the lower left adjacent area, H′=min{W+H,H+H};

[0049] For the INTRA_T_CCLM mode, reference pixels can be selected from the upper adjacent area and the upper right adjacent area, where W′=min{W+H,W+W}.

[0050] See Figure 1, which shows a schematic diagram of the distribution of valid adjacent regions. In Figure 1, the left adjacent region, the lower left adjacent region, the upper adjacent region, and the upper right adjacent region are all valid; in addition, the gray-filled block is the pixel to be predicted at position (i, j) in the coding block.

[0051] Thus, based on Figure 1, the selection areas for the three prediction modes are shown in Figure 2. In Figure 2, (a) represents the selection area for the INTRA_LT_CCLM mode, including the left adjacent area and the upper adjacent area; (b) represents the selection area for the INTRA_L_CCLM mode, including the left adjacent area and the lower left adjacent area; (c) represents the selection area for the INTRA_T_CCLM mode, including the upper adjacent area and the upper right adjacent area. In this way, after determining the selection areas for the three prediction modes, pixels for model parameter derivation can be selected within the selection areas. The pixels selected in this way can be called reference pixels, and the number of reference pixels is usually 4; and for a W×H coding block of a certain size, the positions of its reference pixels are generally fixed.

[0052] After obtaining a preset number of reference pixels, chrominance prediction is currently performed according to the flow diagram of the model parameter derivation scheme shown in Figure 3. According to the process shown in Figure 3, assuming that the preset number is 4, the process may include:

[0053] S301: Acquire reference pixels in a selected area.

[0054] S302: Determine the number of valid reference pixels.

[0055] S303: If the number of valid reference pixels is 0, the model parameter α is set to 0 and β is set to a default value.

[0056] S304: The chroma prediction value is filled with a default value.

[0057] S305: If the number of valid reference pixels is 4, two reference pixels with larger values ​​and two reference pixels with smaller values ​​in the luminance component are obtained through comparison.

[0058] S306: Calculate the mean point corresponding to the larger value and the mean point corresponding to the smaller value.

[0059] S307: Derivation of model parameters α and β based on the two mean points.

[0060] S308: Perform chroma prediction using the prediction model constructed using α and β.

[0061] It should be noted that in VVC, the step of valid reference pixels being 0 is judged based on the validity of adjacent areas.

[0062] It should also be noted that the prediction model is constructed using the principle of "two points determine a straight line". The two points here can be called fitting points. In the current technical solution, after obtaining 4 reference pixels, the two reference pixels with larger values ​​and the two reference pixels with smaller values ​​in the brightness component are obtained through comparison; then, a mean point (which can be used as mean) is obtained based on the two reference pixels with larger values. max According to the two reference pixels with smaller values, another mean point is obtained (mean can be used min Represents), we can get two mean points mean max and mean min ; Then mean max and mean min As two fitting points, model parameters (represented by α and β) can be derived; finally, a prediction model is constructed based on α and β, and prediction processing of the chrominance component is performed based on the prediction model.

[0063] However, in the related art, a simple linear model Pred is used for each coding block. C (i, j) = α·Rec L (i, j) + β to predict the chrominance component, and the same model parameters α and β are used for prediction of any pixel at any position in each coding block. This will lead to the following defects: (1) Coding blocks with different content characteristics all use a simple linear model to map luminance to chrominance to achieve chrominance prediction, but not all luminance to chrominance mapping functions in any coding block can be accurately fitted by this simple linear model, which leads to inaccurate prediction of some coding blocks; (2) During the prediction process, the same model parameters α and β are used for pixels at different positions in the coding block, and there are also large differences in the prediction accuracy of different positions in the coding block. (3) In the CCLM prediction process, the characteristics of coding blocks with different contents and different sizes are not fully considered, which will lose the high correlation between the reconstructed luminance information of the current block and the reference information of the reference area, which will cause some coding blocks to be unable to be accurately predicted under this technology, thereby affecting the gain effect of this technology. In short, there is a large deviation between the predicted value and the original value of some coding blocks under the relevant schemes of CCLM technology, resulting in low prediction accuracy, quality degradation, and thus reduced encoding and decoding efficiency.

[0064] Based on this, embodiments of the present application provide a coding and decoding method. The principles of the method are the same for both the encoding and decoding ends. Taking the encoding end as an example, the method determines a first coding parameter based on a template region; determines a reference sample value for the first color component of the current block; determines a first weighting coefficient based on the reference sample value for the first color component of the current block and the first coding parameter; and determines a first predicted value for the second color component of the current block based on the first weighting coefficient and the reference sample value for the second color component of the current block. In this way, by determining the first coding parameter based on the template region, a first weighting coefficient that better matches the characteristics of the current block can be obtained, thereby improving the prediction accuracy of the second color component of the current block, thereby saving bit rate and improving coding performance.

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

[0066] Referring to FIG4A , which shows a schematic block diagram of the composition of an encoder provided in an embodiment of the present application. As shown in FIG4A , the encoder (specifically, a “video 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 analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoded image cache unit 110, etc., wherein 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 original video signal, a video coding block can be obtained by dividing it into coding tree units (CTUs). Then, the residual pixel 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 obtained 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 on the received video coding block relative to one or more blocks in one or more reference frames to provide temporal prediction information; the motion estimation performed by the motion estimation unit 105 is the process of generating a motion vector, which can estimate the motion of the video coding block, and the motion compensation unit 104 then calculates the motion vector based on the motion vector determined by the motion estimation unit 105. After determining the intra-frame prediction mode, the intra-frame prediction unit 103 is further configured to provide the selected intra-frame prediction data to the encoding unit 109, and the motion estimation unit 105 also sends the calculated motion vector data to the encoding unit 109. In addition, the inverse transform and inverse quantization unit 106 is configured to reconstruct the video coding block and reconstruct a residual block in the pixel domain. The reconstructed residual block is subjected to the filter control analysis unit 107 and the filtering unit 108 to remove the block effect artifacts. The reconstructed residual block is then added to a predictive block in the frame of the decoded image buffer unit 110 to generate a reconstructed video coding block. The encoding unit 109 is configured 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-frame prediction mode, and output the code stream of the video signal. The decoded image buffer unit 110 is configured to store the reconstructed video coding block for prediction reference. As the video image encoding proceeds, new reconstructed video encoding blocks are continuously generated, and these reconstructed video encoding blocks are stored in the decoded image buffer unit 110 .

[0067] Referring to FIG4B , which shows a block diagram of a decoder provided in an embodiment of the present application, as shown in FIG4B , the decoder (specifically, a "video 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. The decoding unit 201 can implement header information decoding and CABAC decoding, and the filtering unit 205 can implement deblocking filtering and SAO filtering. After the input video signal is encoded as shown in FIG4A , a code stream of the video signal is output; the code stream is input to the decoder 200 and first passes through the decoding unit 201 to obtain decoded transform coefficients; the transform coefficients are processed by the inverse transform and inverse quantization unit 202 to generate a residual block 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 the previously decoded block of the current frame or picture; the motion compensation unit 204 determines the prediction information for the video decoding block by analyzing the motion vector and other associated syntax elements, and uses The prediction information is used to generate a predictive block for the video decoding block being decoded; a 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-frame prediction unit 203 or the motion compensation unit 204; the decoded video signal passes through the filtering unit 205 to remove blocking artifacts, thereby improving video quality; the decoded video block is then stored in the decoded image buffer unit 206, which stores reference images used for subsequent intra-frame prediction or motion compensation, and is also used for outputting the video signal, thereby obtaining the restored original video signal.

[0068] It should be noted that the method of the embodiment of the present application is mainly applied to the intra-frame prediction unit 103 shown in Figure 4A and the intra-frame prediction unit 203 shown in Figure 4B. In other words, the embodiment of the present application can be applied to both the encoder and the decoder, or even to both the encoder and the decoder at the same time, but the embodiment of the present application is not specifically limited thereto.

[0069] It should also be noted that, when applied to the intra-frame prediction unit 103, the "current block" specifically refers to the coding block currently to be intra-frame predicted; when applied to the intra-frame prediction unit 203, the "current block" specifically refers to the decoding block currently to be intra-frame predicted.

[0070] First, the encoding method provided in the embodiment of the present application is introduced. FIG5 is a schematic diagram of the implementation flow of the encoding method provided in the embodiment of the present application. As shown in FIG5 , the method may include the following steps 51 to 54:

[0071] Step 51, determining a first encoding parameter according to the template area;

[0072] Step 52, determining a reference sample value of the first color component of the current block;

[0073] Step 53: determining a first weighting coefficient according to the reference sample value of the first color component of the current block and the first encoding parameter;

[0074] Step 54: Determine a first predicted value of the second color component of the current block according to the first weighting coefficient and the reference sample value of the second color component of the current block.

[0075] In an embodiment of the present application, the first encoding parameter is determined based on the template area rather than a preset fixed value, so the obtained first weighting coefficient is more in line with the characteristics of the current block, thereby improving the accuracy of the second color component of the current block, thereby saving bit rate and improving encoding performance.

[0076] The following describes further optional implementations and related terms of each of the above steps.

[0077] In step 51, a first encoding parameter is determined according to the template area.

[0078] In an embodiment of the present application, the template region may include a portion or all of the current block and a reference region of the current block; the template region may also not include the current block but include a reference region of the template region. In some embodiments, the template region is an encoded region.

[0079] A template area may be determined first. For example, the template area may be determined based on pixel availability in an area adjacent to the current block; wherein the adjacent area includes at least one of the following based on a relative positional relationship with the current block: an area above the current block, an area to the left of the current block, an area above and to the right of the current block, an area below and to the left of the current block, or an area above and to the left of the current block.

[0080] It is understandable that unavailable pixels are not set as pixels of the template area. In some embodiments, the pixel availability of the pixel can be determined based on the position of the pixel in the adjacent area and / or the encoding state of the pixel. For example, if the position of the pixel belongs to a defined edge area, the pixel is determined to be unavailable. For another example, if the encoding state of the pixel is uncoded, the pixel is determined to be unavailable; for another example, if the position of the pixel belongs to a defined edge area and the encoding state of the pixel is uncoded, the pixel is determined to be unavailable.

[0081] In an embodiment of the present application, the adjacent area of ​​the current block may include an area that borders the current block and / or an area that does not border the current block. Taking the area that borders the current block as an example, as shown in Figure 6, the adjacent area may include at least one of the areas in each direction shown in the figure.

[0082] For another example, the template region may be determined in this way: the template region is determined according to the template type included in the configured prediction mode.

[0083] In some embodiments, the template type includes at least one of the following: an upper template, a left template, an upper-right template, a lower-left template, and an upper-left template.

[0084] Furthermore, in some embodiments, a template included in the configured prediction mode may be used as the template area.

[0085] The template area may include areas that intersect with the current block, or areas that do not intersect with the current block. For example, Figure 7 shows a situation where the upper template, the left template, and the current block do not intersect; and Figure 8 shows a situation where the upper template, the left template, the upper-right template, the lower-left template, and the upper-left template intersect with the current block.

[0086] It should be noted that the width and height of the adjacent area can be configured according to the requirements of indicators such as bit rate. Similarly, the width and height of the template area can also be configured according to the requirements of indicators such as bit rate.

[0087] After determining the template area, in some embodiments, as shown in FIG9 , step 51 may be implemented through the following steps 511 and 512:

[0088] Step 511: Determine the reference sample value of the template area.

[0089] In some embodiments, the reference sample value of the template area includes: a reconstructed value of the first color component of the template area, a reconstructed value of the second color component of the template area, a reconstructed value of the first color component of the reference area of ​​the template area, and a reconstructed value of the second color component of the reference area of ​​the template area.

[0090] The reference area of ​​the template area varies with the type of the template area, and the template area is allowed to overlap with its reference area. In some embodiments, the reference area of ​​the template area includes at least one of the following: the upper adjacent area of ​​the template area; the lower adjacent area of ​​the template area; the left adjacent area of ​​the template area; the right adjacent area of ​​the template area; the template area; wherein, when the reference area of ​​the template area includes the template area, the area of ​​the reference area is larger than the area of ​​the template area. In the embodiment of the present application, there is no limitation on the size of the upper, lower, left and right adjacent areas of the template area, and the size of the adjacent areas can be pre-set according to the type of the template area. The left and right edges of the upper adjacent area and the lower adjacent area of ​​the template area can be aligned with the left and right edges of the upper template, or they can be misaligned. Similarly, the upper and lower edges of the left adjacent area and the right adjacent area of ​​the template area can be aligned with the upper and lower edges of the left template, or they can be misaligned.

[0091] For example, as shown in Figure 10, an example of the left template overlapping with the reference area and an example of the right template overlapping with the reference area are shown, the reference area of ​​the upper template includes the upper template, and the reference area of ​​the left template includes the left template; as shown in Figure 11, the reference areas of the left template and the right template are shown, and the reference areas include the upper adjacent area of ​​the upper template and the left adjacent area of ​​the left template; as shown in Figure 12A, the reference areas of the left template and the right template are shown, and the reference areas include the lower adjacent area of ​​the upper template and the right adjacent area of ​​the left template.

[0092] Step 512: Determine the first encoding parameter according to the reference sample value of the template area.

[0093] In some embodiments, step 512 may be implemented by steps 5121 and 5122:

[0094] Step 5121: determine a first difference value of the template area, wherein the first difference value of the template area is set equal to the absolute value of the difference between the reference value of the first color component of the template area and the reference value of the first color component of the reference area of ​​the template area.

[0095] Further, in some embodiments, the reference value of the first color component of the template area is the reconstructed value of the first color component of the template area, or the value obtained by filtering the reconstructed value of the first color component of the template area; the reference value of the first color component of the reference area of ​​the template area is the reconstructed value of the first color component of the reference area of ​​the template area, or the value obtained by filtering the reconstructed value of the first color component of the reference area of ​​the template area.

[0096] Step 5122: Determine the first encoding parameter according to the first difference value of the template area.

[0097] Furthermore, in some embodiments, the first encoding parameter can be determined by querying a pre-set mapping table of the first difference value and the first encoding parameter; wherein the mapping table records the first encoding parameters corresponding to different first difference values ​​that can maximize the bit rate. In still other embodiments, step 5122 can be implemented through steps 5122-1 to 5122-3:

[0098] Step 5122-1: Determine a second predicted value of the second color component of the template area based on the first difference and the candidate first encoding parameter.

[0099] In some embodiments, the second predicted value of the second color component of the template region is set equal to a weighted sum of a reference value of the second color component of a reference region of the template region and a second weighting coefficient.

[0100] Furthermore, in some embodiments, the second weighting coefficient is determined based on the first difference value of the template area and the candidate first encoding parameter using a preset corresponding relationship.

[0101] In some embodiments, the preset correspondence is not limited and can be any type of function model, with the candidate first coding parameter being a model parameter of the function model that affects the magnitude of the second weighting coefficient. The preset correspondence can also be obtained using a function model, for example, the preset correspondence is the first difference and the second weighting coefficient corresponding to the candidate first coding parameter.

[0102] Furthermore, in some embodiments, the preset correspondence is a softmax function; wherein the input of the softmax function is one of the following: a ratio of the first difference value to the candidate first encoding parameter; a product of the first difference value and the candidate first encoding parameter; a value obtained by bit-shifting the first difference value; wherein the number of bits of the bit shift is equal to the candidate first encoding parameter. The direction of the bit shift can be leftward or rightward.

[0103] For example, as shown in the following formula (1), it shows an example of the softmax function:

[0104]

[0105] Wherein, [i] represents the horizontal coordinate of the pixel with pixel coordinates (i, j) in the template area, and [j] represents the vertical coordinate of the pixel with pixel coordinates (i, j) in the template area. cTempWeight[i][j][k] represents the second weighting coefficient of the kth pixel in the reference area of ​​the template area corresponding to the pixel with pixel coordinates (i, j) in the template area; diffTempY[i][j][k] represents the absolute value of the difference between the reference value of the first color component of the pixel with pixel coordinates (i, j) in the template area and the reference value of the kth pixel in the reference area of ​​the template area corresponding to the pixel with pixel coordinates (i, j) in the template area; inTempSize represents the number of pixels in the reference area of ​​the template area; T represents the candidate first encoding parameter; the calculation formula of diffTempY[i][j][k] is shown in the following formula (2):

[0106] diffTempY[i][j][k]=abs(refTempY[k]-recTempY[i][j]) (2);

[0107] Wherein, refTempY[k] represents the reference value of the first color component of the kth pixel in the reference area of ​​the template area, and recTempY[i][j] represents the reference value of the first color component of the pixel with pixel coordinates (i, j) in the template area.

[0108] Based on this, the second predicted value of the second color component of the pixel with pixel coordinates (i, j) in the template area is calculated, as shown in formula (3):

[0109]

[0110] That is, the second predicted value of the second color component of the pixel with pixel coordinates (i, j) in the template area is set equal to the weighted sum of the reference value of the second color component of each pixel in the reference area of ​​the template area and the corresponding second weighting coefficient.

[0111] In some embodiments, the preset correspondence relationship may also be obtained using a softmax function. A preset correspondence relationship (e.g., a preset mapping table) may be pre-calculated using the softmax function, and then, when determining the second weighting coefficient, the preset correspondence relationship may be queried to obtain the second weighting coefficient corresponding to the first difference value of the template region and the candidate decoding parameter.

[0112] In some embodiments, the candidate first coding parameters include one or more candidate first coding parameters. For each candidate first coding parameter, a corresponding first prediction error can be calculated through steps 5122-1 and 5122-2.

[0113] Step 5122-2, determine the first prediction error of the second color component of the template area; wherein the first prediction error is the error between the reference value of the second color component of the template area and the second prediction value of the second color component of the template area, and the reference value of the second color component of the template area is the reconstructed value of the second color component of the template area, or the value obtained by filtering the reconstructed value of the second color component of the template area.

[0114] In some embodiments, the second prediction value used to determine the first prediction error is set equal to a second prediction value obtained by performing a correction operation on the second prediction value of the second color component of the template area.

[0115] Step 5122-3: Determine the first encoding parameter based on the first prediction error.

[0116] In the embodiment of the present application, there is no limitation on the implementation of step 5122-3, which can be various. For example, it can be implemented by any of the following examples 1 to 4.

[0117] In embodiment 1, step 5122-3 can be implemented as follows: the first encoding parameter is set to be equal to the value of the candidate first encoding parameter corresponding to the time when the first prediction error meets the first condition; wherein, the reference value of the second color component of the reference area of ​​the template area is the reconstructed value of the second color component of the reference area of ​​the template area, or the value obtained after filtering the reconstructed value of the second color component of the reference area of ​​the template area.

[0118] In some embodiments, the first condition includes: the first prediction error is minimum, the first prediction error is less than a first threshold, the first prediction error is maximum, or the first prediction error is greater than a third threshold.

[0119] It should be noted that the first conditions corresponding to the first prediction error of different measurement criteria are different. For example, under the measurement criterion of the sum of absolute differences (SAD), the first condition includes the first prediction error being minimized or the first prediction error being less than a first threshold. For another example, under the measurement criterion of the peak signal-to-noise ratio (PSNR), the first condition includes the first prediction error being maximized or the first prediction error being greater than a third threshold.

[0120] In Example 2, step 5122-3 (i.e., determining the first encoding parameter based on the first prediction error) can also be implemented as follows: select a parameter whose first prediction error satisfies the first condition from the various candidate first encoding parameters of the template area; and determine the first encoding parameter based on the parameter whose first prediction error corresponding to the template area satisfies the first condition.

[0121] Furthermore, the step of “determining the first encoding parameter according to the parameter of the first prediction error corresponding to the template area satisfying the first condition” can be implemented by the following Example 1, Example 2, Example 3, or Example 4:

[0122] In Example 1, a sixth weighting coefficient is determined based on the reference sample value of the first color component of the current block and the candidate first coding parameter whose first prediction error satisfies the first condition; a third prediction value of the second color component of the current block is determined based on the sixth weighting coefficient and the reference sample value of the second color component of the current block; a second prediction error of the candidate first coding parameter whose corresponding first prediction error satisfies the first condition is determined based on the third prediction value and the original value of the second color component of the current block; and the first coding parameter is determined based on the second prediction error of the candidate first coding parameter whose first prediction error satisfies the first condition.

[0123] Here, the calculation principle of the sixth weighting coefficient is consistent with that of the second weighting coefficient, and reference can be made to formulas (1) and (2), so the specific calculation method of the sixth weighting coefficient is not repeated here. In some embodiments, the reference sample value of the first color component of the current block includes the reconstructed value of the first color component of the reference area of ​​the current block (or the value obtained by filtering the reconstructed value) and the reconstructed value of the first color component of the current block (or the value obtained by filtering the reconstructed value); the reference sample value of the second color component of the current block includes the reconstructed value of the second color component of the reference area of ​​the current block, the value obtained by filtering the reconstructed value of the second color component of the reference area of ​​the current block, or the original value of the second color component of the reference area of ​​the current block, or the value obtained by filtering the original value of the second color component of the reference area of ​​the current block.

[0124] In some embodiments, a candidate first coding parameter whose second prediction error satisfies a third condition is selected from the candidate first coding parameters whose first prediction error satisfies the first condition; and the first coding parameter is determined based on the candidate first coding parameter whose second prediction error satisfies the third condition.

[0125] For example, the first coding parameter is set equal to a candidate first coding parameter for which the second prediction error satisfies a third condition. Here, the number of candidate first coding parameters for which the second prediction error satisfies the third condition may be one or more. If there are more than one candidate first coding parameter, the first coding parameter is set equal to any candidate first coding parameter for which the second prediction error satisfies the third condition.

[0126] For another example, the first coding parameter is set equal to a fused value of the candidate first coding parameter for which the second prediction error satisfies a third condition. Furthermore, in some embodiments, a weighting coefficient of the corresponding candidate first coding parameter may be determined based on the magnitude of the second prediction error. Based on this, the first coding parameter is set equal to a weighted sum of the candidate first coding parameter for which the second prediction error satisfies the third condition and the corresponding weighting coefficient.

[0127] In some embodiments, the third condition includes: the second prediction error is minimum or maximum.

[0128] It should be noted that different third conditions correspond to different metrics for the second prediction error. For example, under the Sum of Absolute Differences (SAD) metric, the third condition includes minimizing the second prediction error; and under the Peak Signal-to-Noise Ratio (PSNR) metric, the third condition includes maximizing the second prediction error.

[0129] In Example 2, the step of "determining the first coding parameter based on the parameter whose first prediction error corresponding to the template area satisfies the first condition" can also be implemented as follows: expand the candidate first coding parameter whose first prediction error satisfies the first condition to obtain the first extended parameter; determine the seventh weighting coefficient based on the reference sample value of the first color component of the current block and the candidate first coding parameter whose first prediction error satisfies the first condition and the first extended parameter; determine the fourth prediction value of the second color component of the current block based on the seventh weighting coefficient and the reference sample value of the second color component of the current block; determine the third prediction error of the corresponding parameter based on the fourth prediction value and the original value of the second color component of the current block; determine the first coding parameter based on the third prediction error of each candidate first coding parameter and the first extended parameter.

[0130] Similarly, the calculation principle of the seventh weighting coefficient is consistent with the calculation principle of the second weighting coefficient. Please refer to the above formulas (1) and (2), and will not be repeated here. One seventh weighting coefficient corresponds to one candidate first coding parameter or one first extended parameter, that is, the seventh weighting coefficient is determined based on one candidate first coding parameter or one first extended parameter and the reference sample value of the first color component of the current block.

[0131] In some embodiments, at least one first extended parameter may be extended leftward and / or rightward according to a preset step size, with the candidate first coding parameter whose first prediction error satisfies the first condition as the center.

[0132] In some embodiments, a parameter whose third prediction error satisfies a fourth condition can be selected from each of the candidate first encoding parameters and the first extended parameters; and the first encoding parameter is determined based on the parameter whose third prediction error satisfies the fourth condition.

[0133] For example, the first encoding parameter is set equal to a parameter for which the third prediction error satisfies a fourth condition. Here, the number of parameters for which the third prediction error satisfies the fourth condition may be one or more. If there are more than one parameters, the first encoding parameter is set equal to any parameter for which the third prediction error satisfies the fourth condition.

[0134] In another example, the first encoding parameter is set equal to a fused value of the parameter for which the third prediction error satisfies the fourth condition. Furthermore, in some embodiments, a weighting coefficient for the corresponding parameter may be determined based on the magnitude of the third prediction error. Based on this, the first encoding parameter is set equal to the weighted sum of the parameter for which the third prediction error satisfies the fourth condition and the corresponding weighting coefficient.

[0135] In some embodiments, the fourth condition includes: the third prediction error is minimum or maximum.

[0136] It should be noted that different metrics for the third prediction error correspond to different fourth conditions. For example, under the Sum of Absolute Differences (SAD) metric, the fourth condition includes minimizing the third prediction error; and under the Peak Signal-to-Noise Ratio (PSNR) metric, the fourth condition includes maximizing the third prediction error.

[0137] In Example 3, the step of "determining the first encoding parameter based on the parameter of the first prediction error corresponding to the template area satisfying the first condition" can also be implemented as follows: setting the first encoding parameter to be equal to the parameter of the first prediction error satisfying the first condition; or setting the first encoding parameter to be equal to the fusion value of the parameter of the first prediction error satisfying the first condition.

[0138] Furthermore, in some embodiments, the first encoding parameter is set to be equal to a weighted sum of a parameter for the first prediction error to satisfy a first condition and a third weighting coefficient.

[0139] In some embodiments, the corresponding third weighting coefficient may be determined based on the first prediction error corresponding to the parameter whose first prediction error satisfies the first condition; or, the third weighting coefficient may be set to a preset constant value.

[0140] In Example 4, the step of "determining the first encoding parameter based on the parameter of the first prediction error corresponding to the template area that meets the first condition" can also be implemented as follows: expanding the parameter of the first prediction error that meets the first condition to obtain the first extended parameter; fusing the first extended parameter and / or the parameter of the first prediction error that meets the first condition to obtain the first encoding parameter.

[0141] In some embodiments, the weighting coefficient of the corresponding parameter can be determined based on the size of the first prediction error. The weighting coefficient of the first extended parameter can be a preset constant value or the weighting coefficient of the corresponding candidate first encoding parameter. Based on this, the first extended parameter and / or the parameter whose first prediction error meets the first condition is weighted calculated to obtain the first encoding parameter.

[0142] In Example 3, step 5122-3 (i.e., determining the first coding parameter based on the first prediction error) can also be implemented as follows: the first coding parameter is set to be equal to the weighted sum of each candidate first coding parameter and a fourth weighting coefficient.

[0143] In some embodiments, a fourth weighting coefficient of the corresponding candidate first coding parameter is determined based on the first prediction error.

[0144] In Example 4, step 5122-3 (i.e., determining the first encoding parameter based on the first prediction error) can also be implemented as follows: based on the first prediction errors corresponding to the same candidate first encoding parameters in the template area, an evaluation parameter characterizing the performance of the corresponding candidate first encoding parameter is determined; and based on the evaluation parameters of each candidate first encoding parameter, the first encoding parameter is determined.

[0145] Furthermore, in some embodiments, the evaluation parameter is set to be equal to a fusion value of first prediction errors corresponding to the same candidate first coding parameter of the template region, and the fusion value may be the sum or product of the first prediction errors.

[0146] Furthermore, in some embodiments, the evaluation parameter is set to be equal to the sum of the first prediction errors corresponding to the same candidate first encoding parameter of the template region.

[0147] Furthermore, in some embodiments, the step of "determining the first encoding parameter based on the evaluation parameters of each of the candidate first encoding parameters" can be implemented as follows: selecting a parameter whose evaluation parameter satisfies the second condition from each of the candidate first encoding parameters; and determining the first encoding parameter based on the parameter whose evaluation parameter satisfies the second condition.

[0148] Furthermore, the step of “determining the first encoding parameter according to the evaluation parameter satisfying the second condition” can be implemented by the following Example 5 or Example 6:

[0149] In Example 5, the eighth weighting coefficient is determined based on the reference sample value of the first color component of the current block and the parameter whose evaluation parameter satisfies the second condition; the fifth prediction value of the second color component of the current block is determined based on the eighth weighting coefficient and the reference sample value of the second color component of the current block; the fourth prediction error of the parameter whose corresponding evaluation parameter satisfies the second condition is determined based on the fifth prediction value and the original value of the second color component of the current block; and the first coding parameter is determined based on the fourth prediction error of each candidate first coding parameter.

[0150] Furthermore, in some embodiments, the parameters whose evaluation parameters satisfy the second condition are expanded to obtain second extended parameters; a ninth weighting coefficient is determined based on the reference sample value of the first color component of the current block, the parameters whose evaluation parameters satisfy the second condition, and the second extended parameters; a sixth predicted value of the second color component of the current block is determined based on the ninth weighting coefficient and the reference sample value of the second color component of the current block; a fifth prediction error of the corresponding parameter is determined based on the sixth predicted value and the original value of the second color component of the current block; and the first coding parameter is determined based on the fifth prediction error of each candidate first coding parameter and the second extended parameter.

[0151] Similarly, the calculation principle of the eighth and ninth weighting coefficients is consistent with the calculation principle of the second weighting coefficient, and can refer to the above formulas (1) and (2), which are not repeated here. A ninth weighting coefficient corresponds to a candidate first coding parameter or a second extended parameter, that is, the ninth weighting coefficient is determined based on a candidate first coding parameter or a second extended parameter and the reference sample value of the first color component of the current block.

[0152] In Example 6, the step of "determining the first encoding parameter based on the parameter for which the evaluation parameter satisfies the second condition" can be implemented as follows: setting the first encoding parameter equal to the parameter for which the evaluation parameter satisfies the second condition; or setting the first encoding parameter equal to a blended value of the parameter for which the evaluation parameter satisfies the second condition. In some embodiments, the first encoding parameter is set equal to the weighted sum of the parameter for which the evaluation parameter satisfies the second condition and a fifth weighting coefficient.

[0153] Furthermore, the fifth weighting coefficient can be obtained through Example 7 or Example 8:

[0154] In Example 7, the fifth weighting coefficient of the corresponding parameter is determined according to the template region corresponding to the parameter whose evaluation parameter satisfies the second condition.

[0155] Furthermore, in some embodiments, a fifth weighting coefficient of the corresponding parameter is determined based on the number of pixels in the template region and / or the template type corresponding to the parameter for which the evaluation parameter satisfies the second condition.

[0156] In some embodiments, the second condition includes: the evaluation parameter is minimum, the evaluation parameter is less than the second threshold, the evaluation parameter is maximum, or the evaluation parameter is greater than a fourth threshold. It can be understood that the second condition is different for the first prediction error of different measurement criteria. For example, under the measurement criterion of the sum of absolute errors (SAD), the second condition includes the evaluation parameter being minimum or the evaluation parameter being less than the second threshold; for example, under the measurement criterion of the peak signal-to-noise ratio (PSNR), the second condition includes the evaluation parameter being maximum or the evaluation parameter being greater than the fourth threshold.

[0157] In Example 8, the fifth weighting coefficient is a preset constant value.

[0158] When performing intra-frame prediction on a current block, a template region may not exist. In some embodiments, when the template region does not exist, a default value is used as the predicted value of the second color component of the current block. In other embodiments, when the template region does not exist, another prediction method different from the above method may be used to determine the second color component of the current block for prediction. For example, the other prediction method different from the above method is a prediction method based on a cross-component linear model (CCLM).

[0159] In some embodiments, after obtaining the first encoding parameter, the first encoding parameter or the index of the first encoding parameter may be encoded, and the obtained encoding bits may be written into a bitstream.

[0160] In step 52, a reference sample value of the first color component of the current block is determined.

[0161] In some embodiments, the reference sample value of the first color component of the current block includes a reconstructed value of the first color component of the current block and a reconstructed value of the first color component of a reference area of ​​the current block.

[0162] In step 53, a first weighting coefficient is determined according to the reference sample value of the first color component of the current block and the first encoding parameter.

[0163] In some embodiments, a second difference value of the current block can be determined, wherein the second difference value of the current block is set equal to the absolute value of the difference between the reference value of the first color component of the current block and the reference value of the first color component of the reference area of ​​the current block; a first weighting coefficient is determined based on the second difference value of the current block and the first encoding parameter; wherein the reference value of the first color component of the current block is a reconstructed value of the first color component of the current block, or a value obtained by filtering the reconstructed value of the first color component of the current block; the reference value of the first color component of the reference area of ​​the current block is a reconstructed value of the first color component of the reference area of ​​the current block, or a value obtained by filtering the reconstructed value of the first color component of the reference area of ​​the current block.

[0164] Furthermore, in some embodiments, a first weighting coefficient may be determined according to a preset corresponding relationship between the second difference value of the current block and the first encoding parameter.

[0165] Furthermore, in some embodiments, the preset correspondence is a softmax function, or the preset correspondence is obtained using a softmax function; wherein the input of the softmax function is one of the following: the ratio of the second difference to the first encoding parameter; the product of the second difference and the candidate first decoding parameter; the value obtained after bit shifting of the second difference; wherein the number of bits of the bit shift is equal to the candidate first decoding parameter.

[0166] For example, as shown in the following formula (4), it shows an example of the softmax function:

[0167]

[0168] Where [i] represents the horizontal coordinate of the pixel with pixel coordinates (i, j) in the current block, and [j] represents the vertical coordinate of the pixel with pixel coordinates (i, j) in the current block. cWeight[i][j][k] represents the first weighting coefficient of the kth pixel in the reference area of ​​the current block corresponding to the pixel with pixel coordinates (i, j) in the current block; inSize represents the number of pixels in the reference area of ​​the current block; best_T represents the first encoding parameter; and the calculation formula of diffY[i][j][k] is shown in the following formula (5):

[0169] diffY[i][j][k]=abs(refY[k]-recY[i][j]) (5);

[0170] Wherein, refY[k] represents the reference value of the first color component of the k-th pixel in the reference area of ​​the current block (such as the reconstructed value, the value obtained by filtering the reconstructed value, the original value, or the value obtained by filtering the original value), and recY[i][j] represents the reference value of the first color component of the pixel with pixel coordinates (i, j) in the current block (such as the reconstructed value, the value obtained by filtering the reconstructed value, the original value, or the value obtained by filtering the original value).

[0171] In step 54, a first predicted value of the second color component of the current block is determined according to the first weighting coefficient and the reference sample value of the second color component of the current block.

[0172] In some embodiments, the reference sample value of the second color component of the current block includes the reconstructed value of the second color component of the reference area of ​​the current block, or the value obtained by filtering the reconstructed value, or the original value of the second color component of the reference area of ​​the current block, or the value obtained by filtering the original value.

[0173] Based on formula (5), the first predicted value of the second color component of the pixel with pixel coordinates (i, j) in the current block is calculated as shown in the following formula (6):

[0174]

[0175] That is, the first predicted value of the second color component of the pixel with pixel coordinates (i, j) of the current block is set to be equal to the weighted sum of the reference value of the second color component of each pixel in the reference area of ​​the current block and the corresponding first weighting coefficient; wherein, the reference value of the second color component of each pixel in the reference area of ​​the current block is the reconstructed value of the second color component of each pixel in the reference area of ​​the current block, or the value obtained by filtering the reconstructed value, or the original value of the second color component of each pixel in the reference area of ​​the current block, or the value obtained by filtering the original value.

[0176] In some embodiments, after obtaining the first predicted value of the second color component of the current block in step 54, the method further includes the following steps 55 to 57:

[0177] Step 55, obtaining the original value of the second color component of the current block;

[0178] Step 56, determining a residual value of the second color component of the current block according to the original value of the second color component of the current block and the first predicted value of the second color component;

[0179] Step 57: Encode the residual value of the second color component of the current block, and write the obtained coded bits into the bitstream.

[0180] In some other embodiments, after obtaining the first predicted value of the second color component of the current block through step 54, the method further includes the following steps 515 to 518:

[0181] Step 515: Perform a correction operation on the first predicted value of the second color component of the current block to obtain a corrected first predicted value.

[0182] The first predicted value of the second color component of the current block should be within a defined range. If it exceeds the range, a corresponding correction operation is performed. For example:

[0183] A clamping operation can be performed on the first predicted value of the second color component of the current block, specifically as follows:

[0184] ● When the value of C pred [i][j] is less than 0, set it to 0; where C pred [i][j] represents the first predicted value of the second color component of the pixel with pixel coordinates (i, j) in the current block;

[0185] ● When the value of C pred [i][j] is greater than (1 << BitDepth) – 1, set it to (1 << BitDepth) – 1.

[0186] To ensure that all predicted values in predWcp are between 0 and (1 << BitDepth) – 1.

[0187] That is:

[0188] C pred [i][j] = Clip3(0, (1 << BitDepth) - 1, C pred [i][j]) (7)

[0189] Where:

[0190] [[ID=?]]

[0191] Or combine the operations of formula (7) and formula (8) into the following formula (9) to complete:

[0192]

[0193] Step 516: Obtain the original value of the second color component of the current block;

[0194] Step 517: Determine the residual value of the second color component of the current block according to the original value of the second color component of the current block and the corrected first predicted value;

[0195] Step 518: Encode the residual value of the second color component of the current block, and write the obtained coded bits into the bitstream.

[0196] The following provides an embodiment of the decoding end. The decoding method provided in the embodiment of the present application is similar to the above-mentioned encoding method. The above-mentioned first encoding parameter is equivalent to the first decoding parameter described in the following embodiment, which is essentially the same; and the above-mentioned candidate first encoding parameter is equivalent to the candidate first decoding parameter described in the following embodiment, which is also essentially the same, and is used to control the size of the weighting coefficient. The decoding method provided in the following embodiment has similar beneficial effects as the embodiment of the above-mentioned encoding method. For technical details not disclosed in the embodiment of the decoding method of the present application, please refer to the description of the embodiment of the encoding method for understanding. Therefore, the technical details and specific embodiments not disclosed in the embodiment of the decoding method disclosed below will not be repeated.

[0197] The embodiment of the present application provides a decoding method. FIG13 is a schematic diagram of an implementation flow of the decoding method provided in the embodiment of the present application. As shown in FIG13 , the method may include the following steps 131 to 134:

[0198] Step 131, determining a first decoding parameter according to the template area;

[0199] Step 132, determining a reference sample value of the first color component of the current block;

[0200] Step 133: determining a first weighting coefficient according to the reference sample value of the first color component of the current block and the first decoding parameter;

[0201] Step 134 : Determine a first predicted value of the second color component of the current block according to the first weighting coefficient and the reference sample value of the second color component of the current block.

[0202] The following describes further optional implementations and related terms of each of the above steps.

[0203] In step 131, a first decoding parameter is determined according to the template area.

[0204] In some embodiments, a template area may be determined first. For example, the template area may be determined based on pixel availability in an area adjacent to the current block; wherein, based on a relative positional relationship with the current block, the adjacent area includes at least one of the following: an area above the current block, an area to the left of the current block, an area above and to the right of the current block, an area below and to the left of the current block, or an area above and to the left of the current block.

[0205] For another example, the template region may be determined in this way: the template region is determined according to the template type included in the configured prediction mode.

[0206] In some embodiments, the template type includes at least one of the following: an upper template, a left template, an upper-right template, a lower-left template, and an upper-left template.

[0207] Furthermore, in some embodiments, a template included in the configured prediction mode may be used as the template area.

[0208] After determining the template area, in some embodiments, step 131 may be implemented by the following steps 111 and 112:

[0209] Step 111, determining a reference sample value of the template area;

[0210] In some embodiments, the reference sample value includes: a reconstructed value of the first color component of the template area, a reconstructed value of the second color component of the template area, a reconstructed value of the first color component of the reference area of ​​the template area, and a reconstructed value of the second color component of the reference area of ​​the template area.

[0211] Further, in some embodiments, the reference area of ​​the template area includes at least one of the following: an upper adjacent area of ​​the template area; a lower adjacent area of ​​the template area; a left adjacent area of ​​the template area; a right adjacent area of ​​the template area; the template area.

[0212] Step 112: Determine the first decoding parameter according to the reference sample value of the template area.

[0213] In some embodiments, step 112 may be implemented by steps 1121 and 1122:

[0214] Step 1121: determining a first difference value of the template region, wherein the first difference value of the template region is set equal to an absolute value of a difference between a reference value of a first color component of the template region and a reference value of a first color component of a reference region of the template region;

[0215] Further, in some embodiments, the reference value of the first color component of the template area is the reconstructed value of the first color component of the template area, or the value obtained by filtering the reconstructed value of the first color component of the template area; the reference value of the first color component of the reference area of ​​the template area is the reconstructed value of the first color component of the reference area of ​​the template area, or the value obtained by filtering the reconstructed value of the first color component of the reference area of ​​the template area.

[0216] Step 1122: Determine the first decoding parameter according to the first difference value of the template area.

[0217] Furthermore, in some embodiments, step 1122 may be implemented through steps 1122-1 to 1122-3:

[0218] Step 1122-1: determining a second prediction value of a second color component of the template area according to the first difference and a candidate first decoding parameter.

[0219] In some embodiments, the candidate first encoding parameters include one or more candidate first decoding parameters.

[0220] Step 1122-2, determine the first prediction error of the second color component of the template area; wherein the first prediction error is the error between the reference value of the second color component of the template area and the second prediction value of the second color component of the template area, and the reference value of the second color component of the template area is the reconstructed value of the second color component of the template area, or the value obtained by filtering the reconstructed value of the second color component of the template area.

[0221] In some embodiments, the second prediction value used to determine the first prediction error is set equal to a second prediction value obtained by performing a correction operation on the second prediction value of the second color component of the template area.

[0222] Step 1122-3: determining the first decoding parameter according to the first prediction error;

[0223] In the embodiment of the present application, there is no limitation on the implementation of step 1122-3, which can be various. For example, it can be implemented by any of the following examples 5 to 8.

[0224] In Example 5, step 1122-3 can be implemented as follows: the second prediction value of the second color component of the template area is set to be equal to the weighted sum of the reference value of the second color component of the reference area of ​​the template area and the second weighting coefficient; the first decoding parameter is set to be equal to the value of the candidate first decoding parameter corresponding to the first prediction error meeting the first condition; wherein, the reference value of the second color component of the reference area of ​​the template area is the reconstructed value of the second color component of the reference area of ​​the template area, or the value obtained after filtering the reconstructed value of the second color component of the reference area of ​​the template area.

[0225] Furthermore, in some embodiments, the second weighting coefficient is determined based on a preset corresponding relationship according to the first difference value of the template area and the candidate first decoding parameter.

[0226] Furthermore, in some embodiments, the preset correspondence is a softmax function, or the preset correspondence is obtained using a softmax function; wherein the input of the softmax function is one of the following: the ratio of the first difference to the candidate first decoding parameter; the product of the first difference and the candidate first decoding parameter; the value obtained after bit shifting of the first difference; wherein the number of bits of the bit shift is equal to the candidate first decoding parameter.

[0227] In some embodiments, the first condition includes: the first prediction error is minimum, the first prediction error is less than a first threshold, the first prediction error is maximum, or the first prediction error is greater than a third threshold.

[0228] In Example 6, step 1122-3 (i.e., determining the first decoding parameter based on the first prediction error) can also be implemented as follows: select a parameter whose first prediction error satisfies the first condition from the various candidate first decoding parameters of the template area; and determine the first decoding parameter based on the parameter whose first prediction error corresponding to the template area satisfies the first condition.

[0229] Furthermore, the step of “determining the first decoding parameter according to the parameter of the first prediction error corresponding to the template area satisfying the first condition” can be implemented by the following Example 9 or Example 10:

[0230] In Example 9, the step of "determining the first decoding parameter based on the parameter of the first prediction error corresponding to the template area satisfying the first condition" can also be implemented as follows: setting the first decoding parameter to be equal to the parameter of the first prediction error satisfying the first condition; or setting the first decoding parameter to be equal to the fusion value of the parameter of the first prediction error satisfying the first condition.

[0231] Furthermore, in some embodiments, the first decoding parameter is set to be equal to a weighted sum of a parameter for the first prediction error to satisfy a first condition and a third weighting coefficient.

[0232] In some embodiments, the corresponding third weighting coefficient may be determined based on the first prediction error corresponding to the parameter whose first prediction error satisfies the first condition; or, the third weighting coefficient may be set to a preset constant value.

[0233] In Example 10, the step of "determining the first decoding parameter based on the parameter of the first prediction error corresponding to the template area that satisfies the first condition" can also be implemented as follows: expanding the parameter of the first prediction error that satisfies the first condition to obtain the first extended parameter; fusing the first extended parameter and / or the parameter of the first prediction error that satisfies the first condition to obtain the first decoding parameter.

[0234] In Example 7, step 1122-3 (i.e., determining the first decoding parameter based on the first prediction error) can also be implemented as follows: the first decoding parameter is set to be equal to the weighted sum of each candidate first decoding parameter and a fourth weighting coefficient.

[0235] In some embodiments, a fourth weighting coefficient of the corresponding candidate first decoding parameter is determined based on the first prediction error.

[0236] In Example 8, step 1122-3 (i.e., determining the first decoding parameter based on the first prediction error) can also be implemented as follows: based on the first prediction errors corresponding to the same candidate first decoding parameters in the template area, an evaluation parameter characterizing the performance of the corresponding candidate first decoding parameter is determined; and based on the evaluation parameters of each candidate first decoding parameter, the first decoding parameter is determined.

[0237] Furthermore, in some embodiments, the evaluation parameter is set to be equal to a fusion value of first prediction errors corresponding to the same candidate first decoding parameter of the template region.

[0238] Furthermore, in some embodiments, the evaluation parameter is set to be equal to the sum of the first prediction errors corresponding to the same candidate first decoding parameter of the template region.

[0239] Furthermore, in some embodiments, the step of "determining the first decoding parameter based on the evaluation parameters of each candidate first decoding parameter" can be implemented as follows: selecting a parameter whose evaluation parameter satisfies the second condition from each candidate first decoding parameter; and determining the first decoding parameter based on the parameter whose evaluation parameter satisfies the second condition.

[0240] Furthermore, the step of “determining the first decoding parameter according to the evaluation parameter satisfying the second condition” can be implemented by the following example 11:

[0241] In Example 11, the first decoding parameter is set to be equal to the parameter for which the evaluation parameter satisfies the second condition; or, the first decoding parameter is set to be equal to the fusion value of the parameter for which the evaluation parameter satisfies the second condition.

[0242] In some embodiments, the first decoding parameter is set equal to a weighted sum of a parameter for evaluating the parameter to satisfy a second condition and a fifth weighting coefficient.

[0243] Furthermore, the fifth weighting coefficient can be obtained through Example 12 or Example 13:

[0244] In Example 12, a fifth weighting coefficient of the corresponding parameter is determined according to the template region corresponding to the parameter whose evaluation parameter satisfies the second condition.

[0245] Furthermore, in some embodiments, a fifth weighting coefficient of the corresponding parameter is determined based on the number of pixels in the template region and / or the template type corresponding to the parameter for which the evaluation parameter satisfies the second condition.

[0246] In some embodiments, the second condition includes: the evaluation parameter is minimum, the evaluation parameter is less than a second threshold, the evaluation parameter is maximum, or the evaluation parameter is greater than a fourth threshold.

[0247] In Example 13, the fifth weighting coefficient is a preset constant value.

[0248] When performing intra-frame prediction on a current block, a template region may not exist. In some embodiments, when the template region does not exist, a default value is used as the predicted value of the second color component of the current block. In other embodiments, when the template region does not exist, another prediction method different from the above method may be used to determine the second color component of the current block for prediction.

[0249] In some embodiments, the method further includes: parsing a code stream to obtain an index of the first decoding parameter; and acquiring the first decoding parameter according to the index of the first decoding parameter.

[0250] In some embodiments, the method further includes: parsing a code stream to obtain the first decoding parameter.

[0251] In some embodiments, the method further includes: parsing the code stream to obtain the residual value of the second color component of the current block; and determining the reconstructed value of the second color component of the current block based on the residual value of the second color component and the first predicted value of the second color component of the current block.

[0252] In some embodiments, the method further includes: performing a correction operation on the first predicted value of the second color component of the current block to obtain a corrected first predicted value; and determining a reconstructed value of the second color component of the current block based on the residual value of the second color component and the corrected first predicted value.

[0253] In the embodiment of the present application, the first color component and the second color component are of different types. For example, the first color component is a brightness component, and the second color component is a chrominance component. For another example, the first color component is a chrominance component, and the second color component is a brightness component.

[0254] When performing chroma prediction on the current block, the reconstructed luminance information of the current block, the reconstructed luminance information of the adjacent reference area, and the reconstructed chroma information of the adjacent reference area are all encoded reconstruction information. Therefore, the above reconstruction information can be used to adopt a weighted chroma prediction technique (WCP). A template matching step is added before the weighted chroma prediction process to select the optimal model parameters based on current blocks of different sizes and contents. The key lies in using template matching to search for the optimal model parameters of the weight model used to calculate the weight vector within the adjacent area. For the decoding end, the optimal model parameters are an example of the first decoding parameters described in the above embodiment; for the encoding end, the optimal model parameters are an example of the first encoding parameters described in the above embodiment.

[0255] In some embodiments, the detailed steps of the chromaticity prediction process of the WCP technique are as follows:

[0256] Input of WCP: the position of the current block (xTbCmp, yTbCmp), the width of the current block nTbW and the height of the current block nTbH.

[0257] WCP output: chroma prediction value predSamples[x][y] of the current block; where x = 0, ..., nTbW-1; y = 0, ..., nTbH-1, with the upper-left pixel position within the current block as the coordinate origin. It should be noted that the chroma component is an example of the second color component described in the above embodiment, and the luma component mentioned below is an example of the first color component described in the above embodiment.

[0258] As shown in Figure 14, the WCP prediction process includes steps 141 to 145: core parameter configuration, input acquisition, weighted chrominance prediction, and post-processing. A template matching step is added between the input acquisition and weighted chrominance prediction steps. These steps yield the predicted chrominance value for the current block.

[0259] Step 141, determine WCP core parameters; these parameters can be pre-configured;

[0260] Step 142: obtaining input information according to the determined core parameters, including obtaining reference chrominance information, reference luminance information, and reconstructed luminance information of the current block;

[0261] Step 143, determining the control parameter by means of template matching; wherein, for the decoding end, the control parameter is equivalent to an example of the first decoding parameter described in the above embodiment; for the encoding end, the control parameter is equivalent to an example of the first encoding parameter described in the above embodiment.

[0262] Step 144, performing a weighted chrominance prediction calculation based on the acquired input information;

[0263] Step 145: Post-process the chrominance prediction calculation result.

[0264] The following is a detailed description of the steps shown in Figure 14:

[0265] In step 141 , WCP core parameters are determined.

[0266] Here, the core parameters involved in WCP are determined. This means that the WCP core parameters can be obtained or inferred through configuration or other channels, such as from the bitstream at the decoder. The specific application will be described in detail later.

[0267] The determination of WCP core parameters includes, but is not limited to, a control parameter (T), the number inSize of various types of input information for weighted chroma prediction, and the number of weighted chroma prediction outputs (predWcp); predWcp is arranged as predSizeW×predSizeH. The number of weighted chroma prediction outputs (predWcp) can be set to the same value (e.g., predSizeW=predSizeH=S / 4) or related to the current block size (e.g., predSizeW=nTbW, predSizeH=nTbH). The control parameter (T) can be used to adjust nonlinear functions in subsequent steps or to adjust data involved in subsequent steps.

[0268] The determination of the WCP core parameters is affected by the block size, block content, or number of pixels within the block under certain conditions. The current block can be classified according to its size, block content, or number of pixels within the block, and the same or different core parameters can be configured according to different categories. That is, the inSize or predWcp (arranged as predSizeW×predSizeH) corresponding to different categories can be the same, for example, predSizeW=predSizeH=s / 4, and predWcp can be related to the size of the current block, such as predSizeW=nTbW, predSizeH=nTbH. Note that predSizeW and predSizeH can also be the same or different. The control parameter (T) corresponding to the current block of different size, different content, or different number of pixels within the block is determined by template matching in step 143.

[0269] In step 142, input information is obtained.

[0270] When predicting the current block, the upper area, upper left area and left area of ​​the current block are all called reference areas of the current block. As shown in Figure 15, the pixels in the reference area of ​​the current block are all reconstructed pixels, called reference pixels.

[0271] Reference chromaticity information refC and reference luminance information refY are obtained from the reference area. The reference chromaticity information refC includes, but is not limited to, selecting reference reconstructed chromaticity values ​​from the area above and the area to the left of the current block. The reference luminance information refY includes, but is not limited to, obtaining corresponding reference luminance information based on the position of the reference chromaticity information.

[0272] The reconstructed luminance information recY of the current block is obtained, and the obtaining method includes but is not limited to: obtaining corresponding reconstructed luminance information according to the position of the chrominance information of the current block as the reconstructed luminance information of the current block.

[0273] It should be noted that the reference chrominance information refC is an example of a reference sample value of the second color component of the current block; the reference luminance information refY and the reconstructed luminance information recY of the current block are an example of a reference sample value of the first color component of the current block.

[0274] Obtaining input information includes: obtaining inSize amount of reference chromaticity information refC (if pre-processing is required, it is after pre-processing operation), obtaining inSize amount of reference luminance information refY (if pre-processing is required, it is after pre-processing operation) and obtaining the reconstructed luminance information recY of the current block (if pre-processing is required, it is after pre-processing operation).

[0275] In step 143, control parameters are determined by template matching.

[0276] The WCP prediction process is simulated using the reconstructed luminance pixels and chrominance pixels of the template area and the reconstructed luminance pixels and chrominance pixels of the reference area of ​​the template area, and the best control parameter (best_T) is selected from them. As shown in Figure 16, the following steps 1431 to 1433 are specifically included:

[0277] Step 1431: Determine the template area and the reference area of ​​the template.

[0278] According to the pixel availability of the neighboring area of ​​the current block, it is judged whether the pixels of the template area and the reference area of ​​the template area are available, including reconstructing the brightness information and reconstructing the chrominance information. Including but not limited to: according to the relative position relationship between the template area and the current block, the template area can be classified into template types such as upper template, left template, upper right template, lower left template and upper left template. The reference area of ​​the template area varies with different template types, and the template area is allowed to overlap with the reference area of ​​the template area. In addition, in order to meet the needs of different current blocks, the template type and the reference area corresponding to the template area can be flexibly combined, as shown in Figures 10, 11 and 12A. The template sizes of different types for different current blocks can be fixed to the same or different. For example, different template sizes can be selected according to the different sizes of the current block. Taking the template in Figure 11 as an example, the following formula describes a size setting condition for a template, where nTbW and nTbH are the width and height of the current block, and iTempW and iTempH are the width and height of the determined template:

[0279] Upper template:

[0280] Left template:

[0281]

[0282] You can also select different template sizes based on the number of pixels in the current block. Taking the template in Figure 11 as an example, the following formula illustrates a template size setting condition, where nTbW and nTbH are the width and height of the current block, nTbW×nTbH is the number of pixels in the current block, and iTempW and iTempH are the width and height of the template used:

[0283] Upper template:

[0284] Left template:

[0285] The combination type of the template type and the reference area corresponding to the template area or the size of the template may also be transmitted in the code stream of the encoding end.

[0286] Figures 10, 11 and 12A respectively show schematic diagrams of three types of template positions and their corresponding reference area positions. The templates in the following embodiments are illustrated using the upper template and left template in Figure 11 as examples. In actual application, more different template types and corresponding reference areas can be used in this step.

[0287] Step 1432: Perform WCP prediction in the template area.

[0288] Under different template types, the reconstructed luminance information of the template area, the reconstructed chrominance information of the template area, the reconstructed luminance information of the reference area of ​​the template area, and the reconstructed chrominance information are all encoded reconstruction information. Therefore, the basic process of WCP can be performed in the template area; wherein, the reconstructed luminance information of the template area and the reconstructed luminance information of the reference area of ​​the template area are examples of reference sample values ​​of the first color component of the template area; the reconstructed chrominance information of the template area and the reconstructed chrominance information of the reference area of ​​the template area are examples of reference sample values ​​of the second color component of the template area.

[0289] Here we first perform the WCP prediction of the upper template. The detailed process is as follows:

[0290] The input of the template's WCP is: the position of the upper template (xTemp, yTemp), the width of the upper template nTbW, and the height of the upper template iTempH.

[0291] The output of the WCP of the template: the chrominance prediction value predTempSamples[x][y] of the upper template, that is, an example of the second prediction value of the second color component of the template area; wherein the upper left chrominance pixel position of the above template is the coordinate origin, x=0,···,nTbW-1; y=0,···,iTempH–1.

[0292] Determine WCP core parameters, including but not limited to: a control parameter (T), the number of various inputs to weighted chroma prediction (inTempSize), and the number of outputs of weighted chroma prediction (predTempWcp) (arranged as predTempSizeW × predTempSizeH). The above parameters inTempSize, predTempSizeW, and predTempSizeH can vary with different template types and can also vary based on the WCP core parameters configured during the WCP prediction process for the current block.

[0293] Obtaining input information: Obtaining reference chromaticity information refTempC and reference luminance information refTempY from the reference area of ​​the upper template. The obtained reference chromaticity information refTempC includes but is not limited to: selecting a reference reconstructed chromaticity value of the reference area of ​​the upper template; the obtained reference luminance information refTempY includes but is not limited to: obtaining corresponding reference luminance information based on the position of the reference chromaticity information.

[0294] The reconstructed chromaticity information recTempC of the template is obtained, and the obtaining method includes but is not limited to selecting the reconstructed chromaticity information in the current template.

[0295] Obtain the reconstructed luminance information recTempY of the template. This acquisition method includes, but is not limited to, obtaining the corresponding reconstructed luminance information based on the position of the reconstructed chrominance information within the current template as the reconstructed luminance information of the current template. This process can also perform pre-processing operations based on different requirements, such as upsampling and downsampling based on different input color formats, selecting only a portion of the reference area, or selecting points in the reference area.

[0296] Next, the template chrominance prediction value C within the size specified by the configuration parameter predT [i][j], i=0...predTempSizeW-1, j=0...predTempSizeH-1, obtain them one by one. Note that predTempSizeH and predTempSizeW are the determined WCP core parameters and can be the same as or different from the height or width of the current template.

[0297] The detailed calculation process is as follows:

[0298] For i=0,..., predTempSizeW-1; for j=0,..., predTempSizeH-1

[0299] For k = 0, 1, ···, inTempSize-1

[0300] Construct each element diffTempY[i][j][k] in the brightness difference vector

[0301] Calculate each element in the weight vector cTempWeight[i][j][k] (or cTempWeightFloat[i][j][k])

[0302] Calculate the chrominance prediction value C by cTempWeight[i][j] (or cTempWeightFloat[i][j][k]) and refTempC predT [i][j];

[0303] Construct the brightness difference vector: for each chrominance pixel C to be predicted in the template within the size specified by the WCP core parameter predT [i][j], the corresponding reconstructed brightness information recTempY[i][j] is subtracted from the reference brightness information refTempY of inTempSize and the absolute value is taken to obtain the brightness difference vector diffTempY[i][j][k]. The calculation formula is shown in (10), where k = 0, 1...inTempSize-1. Similarly, the obtained brightness difference vector can also be subjected to linear or nonlinear numerical processing. Among them, the elements in the brightness difference vector are examples of the first difference value.

[0304] diffTempY[i][j][k]=abs(refTempY[k]-recTempY[i][j]) (10);

[0305] in

[0306]

[0307] Calculate the weight vector: Use a nonlinear weight model to calculate each pixel C to be predicted predT [i][j] is processed to obtain the corresponding floating-point weight vector cTempWeightFloat[i][j], where the control parameter (T) transmitted in the configuration core parameter is used as the adjustment parameter of the model. Note that the weight model here must be consistent with the weight model used in the current block in step 1442. Taking the nonlinear softmax function as an example, the weight vector calculation formula corresponding to each pixel to be predicted is shown in (11). Among them, the elements in the weight vector are an example of the second weighting coefficient.

[0308]

[0309] After the above calculations are completed, we can perform fixed-point conversion, as shown in the following formula (12):

[0310] cTempWeight[i][j][k]=round(cTempWeightFloat[i][j][k]×2 Shift ) (12);

[0311] in,

[0312] round(x)=Sign(x)×Floor(Abs(x)+0.5)

[0313]

[0314] Floor(x) represents the largest integer less than or equal to x

[0315]

[0316] Calculate the chrominance prediction value: According to each pixel to be predicted C of the template predT [i][j] corresponding weight vector cTempWeight[i][j] (or cTempWeightFloat[i][j]) and reference chrominance information refTempC, calculate the pixel to be predicted C predT The chroma prediction value of [i][j]. Specifically, each pixel to be predicted CpredT The reference chrominance information refTempC of [i][j] is multiplied one by one with the corresponding weight vector elements, subTempC[i][j] (or subTempCFloat[i][j]), and the multiplication results are accumulated to obtain the chrominance prediction value C of each pixel to be predicted. predT [i][j]. The calculation formula is as follows (13):

[0317] For k = 0, 1...inTempSize-1

[0318] subTempCFloat[i][j][k]=(cTempWeightFloat[i][j][k]×refTempC[k]) (13);

[0319] After the calculation is completed, subTempCFloat can be fixed-pointed. In order to retain a certain calculation accuracy during the fixed-pointing process, a coefficient can be multiplied, as shown in the following formulas (14) and (15):

[0320] subTempC[i][j][k]=round(subTempCFloat[i][j][k]×2 Shift ) (14);

[0321] or:

[0322] subTempC[i][j][k]=(cTempWeight[i][j][k]×refTempC[k]) (15);

[0323] For i=0...predTempSizeW-1, j=0...predTempSizeH-1

[0324]

[0325] After the calculation is completed, predT Float[i][j] is fixed-pointed, as shown in formula (17):

[0326] C predT [i][j]=round(C predT Float[i][j]) (17);

[0327] Or use the fixed-point subTempC[i][j][k] for calculation, as shown in formula (18):

[0328]

[0329] Or perform the calculation using the fixed-point subTempC[i][j][k], as shown in Equation (19):

[0330]

[0331] Where Offset = 1 << (Shift1 - 1), and Shift1 is the shift amount required in the fixed-point operation for improving accuracy when calculating cTempWeight[i][j][k] or subTempC[i][j][k] (Shift1 = Shift), or in other steps.

[0332] Separate the chrominance prediction value C predT [i][j] of each pixel to be predicted for spatial storage, which is the chrominance prediction output predTempWcp based on weights.

[0333] Correct predTempWcp: The chrominance prediction values in predTempWcp should be within a limited range. If they exceed the range, corresponding correction operations should be performed. This correction operation must be consistent with the correction operation adopted for the current block in Step 1444 mentioned below.

[0334] For example: …

[0335] The clamping operation can be performed on the chrominance prediction value in C predT [i][j] as follows:

[0336] ● When the value of C predT [i][j] is less than 0, set it to 0;

[0337] ● When the value of C predT [i][j] is greater than (1 << BitDepth) – 1, set it to (1 << BitDepth) – 1. <000…To ensure that all prediction values in predTempWcp are between 0 and (1 << BitDepth) – 1.

[0339] That is:

[0340]

[0341] So far, the WCP prediction process for the upper template is completed. Next, the WCP prediction process for the left template is carried out. The order of the WCP prediction processes for the two templates can be interchanged.

[0342] FIG12B describes the WCP process. FIG12B may be a WCP process performed on the basis of the template region and the reference region of the template region shown in FIG12A. FIG12B may also be a WCP process performed on the basis of other types of template regions and corresponding reference regions. As shown in FIG12B , for each sample recTempY[i][j] in the downsampled luminance block, first, the luminance difference vector diffTempY[i][j][k] is obtained based on the absolute value of the difference between recTempY[i][j] and the adjacent luminance vector refTempY[k]. Secondly, the normalized weight vector cTempWeight[i][j][k] is derived based on the nonlinear mapping model related to diffTempY[i][j][k]. Thirdly, the weight vector is used to perform vector multiplication on the weight vector and the adjacent chrominance vector to obtain the predicted chrominance sample C predT [i][j].

[0343] The WCP prediction process of the left template only provides special instructions for the WCP input, output, configuration core parameters, and obtaining input information of the WCP prediction process of the upper template. Other operations remain the same:

[0344] The input of the template's WCP is: the position of the left template (xTemp, yTemp), the width of the left template iTempW, and the height of the left template nTbH.

[0345] Output of the WCP of the template: the chrominance prediction value predTempSamples[x][y] of the left template, where the upper left chrominance pixel position of the left template is the coordinate origin, x=0,···,iTempW-1; y=0,···,nTbH–1.

[0346] Configure core parameters, including but not limited to: the control parameter (T), the number of various input information for weighted chroma prediction (inTempSize), and the number of weighted chroma prediction outputs (predTempWcp) (arranged as predTempSizeW × predTempSizeW). The above parameters inTempSize, predTempSizeW, and predTempSizeW can be the same as those configured in the previous template, and different parameters can be selected based on the template type.

[0347] Obtain input information: The reference area for the upper and left templates can be the same, or different reference areas can be selected for each. Pre-processing operations can also be performed according to different requirements.

[0348] After the left template completes the WCP prediction process, it also saves its own weighted chrominance prediction output.

[0349] Step 1433, select the optimal control parameter best_T.

[0350] The above text introduced the WCP prediction processes of the upper template and the left template, thus obtaining the reconstructed chrominance information recTempC[i][j] within their respective templates and the predicted chrominance information predTempWcp[i][j] corresponding to a certain control parameter (T).

[0351] By looping through the template WCP prediction processes under different control parameters (T), multiple groups of corresponding predicted chrominance information can be obtained. According to a certain evaluation criterion, an optimal control parameter (T) can be selected. For example, evaluation criteria such as the sum of absolute differences (SAD), sum of absolute transformed differences (SATD), sum of squared errors (SSE), mean absolute difference (MAD), mean absolute error (MAE), mean squared error (MSE), rate distortion function (RDO), etc. can be chosen, which is an example of the first prediction error. Any of the evaluation criteria mentioned in the following content can be selected from the above criteria. Taking the MAE evaluation criterion as an example, the calculation formula is as follows in Equation (20):

[0352]

[0353] If none of the templates can be obtained, all predicted values are filled with default values. The default value can be set to (1 << BitDepth) – 1, (BitDepth is the bit depth required for chrominance pixel values), or directly exit the WCP prediction algorithm midway (i.e., the current block does not use the WCP prediction algorithm).

[0354] If only one template can be obtained, either the upper template or the left template, then only one optimal control parameter can be selected at this time. Save this control parameter and denote it as best_T.

[0355] If both templates can be obtained, at this time, the optimal parameter above_T for the upper template and the optimal parameter left_T for the left template can be selected. Then the following processing is required for these two, including but not limited to the following methods:

[0356] The first method is to perform weighted fusion of above_T and left_T into an optimal parameter best_T, as shown in Equation (21):

[0357] best_T = w0 × above_T + w1 × left_T (21);

[0358] The weighted fusion standard can choose a fixed weighting coefficient or assign a weighting coefficient based on the mean absolute error between the reconstructed chroma of each template and the predicted chroma. The fixed weighting coefficient of the former is {0.5, 0.5}, and the formula for calculating the weighting coefficient of the latter is as shown in formula (22), MAE A is the mean absolute error of the upper template, MAE L is the mean absolute error of the left template, MAE A is the mean absolute error of the upper template; where MAE L and MAE A Each is an example of the first prediction error;

[0359]

[0360] The second method is to retain above_T and left_T and proceed to step 144 for weighted chroma prediction. At the encoder, the original chroma values ​​and the predicted chroma values ​​of the current block are processed according to a certain evaluation criterion, and the optimal control parameters are selected from the two. The index of the upper template or the left template or the parameter value can be transmitted directly in the encoded bitstream.

[0361] The third method also retains above_T and left_T. In step 144, during the weighted chroma prediction, the neighboring parameter values ​​of above_T and left_T are traversed. At the encoder, the original chroma values ​​and the predicted chroma values ​​of the current block are processed according to a certain evaluation criterion. The optimal control parameter is selected from the narrowed parameter range. The optimal control parameter is transmitted in the encoded bitstream, either as an index within the narrowed range or as the parameter value itself. In the case of multiple optimal control parameters, such as in the second and third methods, no specific explanation is given in step 144.

[0362] If more than two templates are selected for subsequent operations during the template selection process, the above situation can be followed.

[0363] In step 144, a weighted chrominance prediction calculation is performed according to the acquired input information.

[0364] The chromaticity prediction value C within the size specified by the configuration parameters pred [i][j], where i = 0, ..., predSizeW - 1; j = 0, ..., predSizeH - 1, are obtained one by one. Note that predSizeH and predSizeW are fixed WCP core parameters and can be the same as or different from the height nTbH or width nTbW of the current block. Under certain conditions, the following calculation can also be performed on only a portion of the pixels to be predicted within the current block.

[0365] As shown in FIG17 , step 144 includes the following operation steps 1441 to 1444 :

[0366] Step 1441 : For each pixel to be predicted, a brightness difference vector is constructed using the obtained reference chrominance information, reference brightness information, and reconstructed brightness information of the current block.

[0367] Step 1442: For each pixel to be predicted, calculate a weight vector using a nonlinear function according to the brightness difference vector;

[0368] Step 1443: For each pixel to be predicted, calculate a chrominance prediction value by weighting according to the weight vector and the obtained reference chrominance information;

[0369] Step 1444: For each pixel to be predicted, the calculated chrominance prediction value is corrected, including a clip operation.

[0370] That is, by obtaining weights, performing weighted prediction based on the weights to obtain weighted chrominance prediction values, and then correcting them. The weight acquisition process includes constructing a luminance difference vector and calculating a weight vector.

[0371] The detailed calculation process is as follows:

[0372] For i=0…predSizeW-1, j=0…predSizeH-1

[0373] For k = 0, 1... inSize-1

[0374] Construct each element diffY[i][j][k] in the brightness difference vector

[0375] Calculate each element in the weight vector cWeight[i][j][k] (or cWeightFloat[i][j][k])

[0376] The chrominance prediction value Cpred[i][j] is calculated by cWeight[i][j] (or cWeightFloat[i][j][k]) and refC.

[0377] In step 1441, for each pixel to be predicted, a luminance difference vector is constructed using the obtained reference chrominance information, reference luminance information, and reconstructed luminance information of the current block.

[0378] For each pixel to be predicted C within the size specified by the WCP core parameters pred[i][j], subtract the corresponding reconstructed brightness information recY[i][j] from the reference brightness information refY of inSize and take the absolute value to obtain the brightness difference vector diffY[i][j][k]. The calculation formula is shown in (23), where k = 0, 1...inSize-1.

[0379] diffY[i][j][k]=abs(refY[k]-recY[i][j]) (23);

[0380] in

[0381]

[0382] Under certain conditions, the brightness difference vector of the pixel to be predicted can be processed linearly or nonlinearly.

[0383] For example, the value of the brightness difference vector of the pixel to be predicted may be scaled according to the WCP control parameter T in the WCP core parameters.

[0384] In step 1442, for each pixel to be predicted, a weight vector is calculated using a nonlinear function according to the brightness difference vector.

[0385] According to the best control parameter (best_T) obtained in step 143, a nonlinear weight model is used to predict each pixel C pred [i][j] is processed to obtain the corresponding weight vector cWeightFloat[i][j]. The weight model includes but is not limited to a nonlinear normalization function, a nonlinear exponential normalization function, and the like.

[0386] For example:

[0387] The nonlinear Softmax function can be used as the weight model, and each pixel to be predicted C pred The brightness difference vector diffY[i][j] corresponding to [i][j] is used as the input of the weight model, and the optimal control parameter (best_T) can be used as the adjustment parameter of the model. The model outputs the weight vector cWeightFloat[i][j] corresponding to each pixel to be predicted. The calculation formula is shown in (24), where k = 0, 1, ···, inSize-1.

[0388]

[0389] After the above calculations are completed, cWeightFloat can be fixed-pointed as shown in the following formula (25):

[0390] cWeight[i][j][k]=round(cWeightFloat[i][j][k]×2 Shift ) (25);

[0391] in,

[0392] Round(x)=Sign(x)×Floor(Abs(x)+0.5)

[0393]

[0394] Floor(x) represents the largest integer less than or equal to x

[0395]

[0396] In step 1443, for each pixel to be predicted, a chrominance prediction value is calculated by weighting according to the weight vector and the obtained reference chrominance information;

[0397] The chrominance prediction value of the pixel to be predicted is calculated based on the weight vector cWeight[i][j] (or cWeightFloat[i][j]) corresponding to each pixel to be predicted and the reference chrominance information refC. Specifically, each pixel to be predicted C pred The reference chroma information refC of [i][j] is multiplied one by one with the weight vector elements corresponding to each pixel to be predicted to obtain subC[i][j] (or subCFloat[i][j]). The multiplication results are accumulated to obtain the chroma prediction value C of each pixel to be predicted. pred [i][j] (i.e. weighted prediction). The calculation formula is shown in the following formula (26):

[0398] For k = 0, 1... inSize-1

[0399] subCFloat[i][j][k]=(cWeightFloat[i][j][k]×refC[k]) (26);

[0400] After the calculation is completed, subCFloat can be fixed-pointed. In order to retain a certain calculation accuracy during the fixed-pointing process, a coefficient can be multiplied, as shown in the following formula (27):

[0401] subC[i][j][k]=round(subCFloat[i][j][k]×2 Shift ) (27);

[0402] Or as shown in the following formula (28):

[0403] subC[i][j][k] = (cWeight[i][j][k] × refC[k]) (28);

[0404] For i = 0...predSizeW - 1, j = 0...predSizeH - 1

[0405]

[0406] After the calculation, perform fixed-point conversion on C pred Float[i][j] as shown in Equation 30 below:

[0407] C pred [i][j] = round(C pred Float[i][j]) (30);

[0408] Or perform the calculation using the fixed-point subC[i][j][k] as shown in Equation (31) below:

[0409]

[0410] Where Offset = 1 << (Shift1 - 1), and Shift1 is the shift amount required in the fixed-point operation to improve accuracy when calculating cWeight[i][j][k] or subC[i][j][k] (Shift1 = Shift), or in other steps.

[0411] Spatially store the chrominance prediction value C pred [i][j] of each pixel to be predicted, which is the chrominance prediction output predWcp based on weights.

[0412] In step 1444, for each pixel to be predicted, correct the calculated chrominance prediction value, including clip operation.

[0413] The chrominance prediction value in predWcp should be within the defined range. If it exceeds, corresponding correction operations should be performed. For example:

[0414] The chrominance prediction value in C pred [i][j] can be clamped as follows:

[0415] ● When the value of C pred [i][j] is less than 0, set it to 0;

[0416] ● When the value of C pred [i][j] is greater than (1 << BitDepth) - 1, set it to (1 << BitDepth) - 1.

[0417] To ensure that all predicted values in predWcp are between 0 and (1 << BitDepth) – 1.

[0418] That is:

[0419] C pred [i][j] = Clip3(0, (1 << BitDepth) - 1, C pred [i][j]) (32);

[0420] Where

[0421]

[0422] Or the operations of formula (32) and formula (33) can be combined into the following formula (34) to complete:

[0423]

[0424] In step 145, a post - processing process is performed on the chrominance prediction calculation result.

[0425] Based on the weight, the chrominance prediction output predWcp needs to be post - processed under certain conditions as the final chrominance prediction value predSamples, otherwise the final chrominance prediction value predSamples is predWcp.

[0426] The above solution can improve the accuracy of the WCP prediction technology. By optimizing the control parameter (T) in the core parameters of WCP, in the case of different content characteristics of the current block, this technical solution can adaptively select the best control parameter, further improve the weight model in step 144, and then obtain a more accurate chrominance prediction value. Since the weight model used in the WCP prediction process better matches the content characteristics and spatial correlation of the current block, the predicted value can be made more accurate.

[0427] The key innovation point of this technical solution lies in the optimization of the configuration control parameters in the WCP prediction process:

[0428] (1) Make full use of the content characteristics of the current block to improve the accuracy of the prediction process;

[0429] (2) Make full use of the existing reconstructed pixel information in the adjacent area to improve the accuracy of the prediction model;

[0430] (3) Fully consider the characteristic information of the prediction block in different directions and design different template matching methods.

[0431] Extended Solution 1: The modification of "3. Template Matching" in the above solution is only an implementation method. The main idea is to directly select an optimal control parameter through template matching in a WCP chroma prediction mode. Multiple WCP chroma prediction modes are defined in the encoder, corresponding to the combination of different template types and different template reference areas. When the current block traverses all chroma prediction modes to optimize the rate-distortion and select the best chroma prediction mode, when it comes to a WCP chroma prediction mode that matches a certain template type, only one or relatively few template types and their corresponding template reference areas will be selected in the template selection process of step 1431.

[0432] Taking the above template and the left template as an example, three WCP chrominance prediction modes with template matching, namely WCP_L, WCP_T and WCP_LT, are added to the existing chrominance prediction mode. WCP_L means that in the template matching step of the WCP prediction process, only the left template is used to select the best control parameters as the parameters of the weight model of the WCP prediction of the current block; WCP_T means that in the template matching step of the WCP prediction process, only the upper template is used to select the best control parameters as the parameters of the weight model of the WCP prediction of the current block; WCP_LT means that in the template matching step of the WCP prediction process, only the left template and the upper template are used to select the best control parameters as the parameters of the weight model of the WCP prediction of the current block, where the selection of the best control parameters is the same as the case when there are multiple template types in the above scheme. Other operations are consistent with the scheme of the above embodiment.

[0433] Extended Solution 2: The main idea of ​​the above embodiments is to search for optimal parameters within all acquired templates, then perform subsequent operations through various weighted fusion methods or retain multiple optimal parameters. However, this implementation may not always match the optimal parameters for the current block. Here is a brief description of an alternative implementation method.

[0434] Assuming that both the above template and the left template can be obtained, in the WCP_LT mode of extended solution 1, modify "3.3, Select the best parameters" to:

[0435] Step 1432 introduces the WCP prediction process of the upper template and the left template, so that the reconstructed chrominance information in each template and the predicted chrominance information corresponding to a certain control parameter (T) are obtained. k ) The corresponding predicted chrominance information is predAboveTempWcp k , a control parameter of the left template (T k ) The corresponding predicted chrominance information is predLeftTempWcp k , taking MAE as an example, calculate the MAE of the upper template and the left template respectivelyA and MAE L , other evaluation criteria can also be used here.

[0436] MAE A and MAE L Add up the evaluation sum of the upper template and the left template to get the MAE Sum (i.e. an example of evaluation parameters), corresponding to the control parameters (T k By looping through different control parameters (T) and repeating the above operation, multiple MAEs can be obtained. Sum , select the smallest MAE from them Sum The corresponding control parameter (best_T) is used to perform weighted chrominance prediction in step 144 .

[0437] If there are multiple MAEs corresponding to the control parameters Sum In the case of equal treatment, the processing operations include but are not limited to the following methods:

[0438] The first method is to perform weighted fusion of these multiple control parameters into an optimal parameter best_T. The weighted fusion standard can select a fixed weight coefficient or allocate a weight coefficient according to the number of pixels in the template.

[0439] The second method is to retain these multiple control parameters and continue with the weighted chrominance prediction in step 144. At the encoder, the original chrominance values ​​and the predicted chrominance values ​​of the current block are processed according to a certain evaluation criterion, and the best parameters are selected from the two. The index of the upper template or the left template or the parameter value can be transmitted directly in the encoded bitstream.

[0440] A third method is to also retain these multiple control parameters, and in the weighted chrominance prediction of step 144, traverse the nearby parameter values ​​of these values, process the original chrominance value and the predicted chrominance value of the current block according to a certain evaluation criterion at the encoding end, select the best parameter from the reduced parameter interval, and transmit the index of the best control parameter in the reduced interval or directly transmit the parameter value in the encoded bit stream.

[0441] If more than two templates are selected for subsequent operations in the above solution 1, the above situation can be followed.

[0442] It should be noted that although the steps of the method of the present application are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all steps must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps; or steps in different embodiments may be combined to form a new technical solution.

[0443] The present application provides an encoding device. FIG18 is a schematic diagram of the structure of the encoding device provided in the present application. As shown in FIG18 , the encoding device 18 includes:

[0444] A first determining module 181 is configured to determine a first encoding parameter according to the template area;

[0445] A second determining module 182 is configured to determine a reference sample value of the first color component of the current block;

[0446] a third determining module 183 configured to determine a first weighting coefficient according to the reference sample value of the first color component of the current block and the first encoding parameter;

[0447] The first prediction module 184 is configured to determine a first prediction value of the second color component of the current block according to the first weighting coefficient and a reference sample value of the second color component of the current block.

[0448] In some embodiments, the first determination module 181 includes a first determination unit and a second determination unit; wherein the first determination unit is configured to determine the reference sample value of the template area; the second determination unit is configured to determine the first encoding parameter based on the reference sample value of the template area.

[0449] In some embodiments, the first determination unit is configured to determine the reconstruction value of the first color component of the template area and the reconstruction value of the second color component of the template area; determine the reconstruction value of the first color component of the reference area of ​​the template area and the reconstruction value of the second color component of the reference area of ​​the template area.

[0450] In some embodiments, the second determination unit includes a first subunit and a second subunit; wherein, the first subunit is configured to determine a first difference value of the template area, wherein the first difference value of the template area is set equal to the absolute value of the difference between the reference value of the first color component of the template area and the reference value of the first color component of the reference area of ​​the template area; the second subunit is configured to determine the first encoding parameter based on the first difference value of the template area.

[0451] In some embodiments, the second subunit is configured to: determine a second prediction value of the second color component of the template area based on the first difference and the candidate first encoding parameter; determine a first prediction error of the second color component of the template area; and determine the first encoding parameter based on the first prediction error; wherein the first prediction error is an error between a reference value of the second color component of the template area and the second prediction value of the second color component of the template area, and the reference value of the second color component of the template area is a reconstructed value of the second color component of the template area, or a value obtained by filtering the reconstructed value of the second color component of the template area.

[0452] In some embodiments, the second subunit is further configured to determine the second weighting coefficient according to the first difference value of the template area and the candidate first encoding parameter using a preset corresponding relationship.

[0453] In some embodiments, the second subunit is configured to: select a parameter whose first prediction error satisfies a first condition from each candidate first encoding parameter of the template area; and determine the first encoding parameter based on the parameter whose first prediction error corresponding to the template area satisfies the first condition.

[0454] In some embodiments, the second subunit is configured to: determine a sixth weighting coefficient based on the reference sample value of the first color component of the current block and the candidate first coding parameter whose first prediction error satisfies the first condition; determine a third prediction value of the second color component of the current block based on the sixth weighting coefficient and the reference sample value of the second color component of the current block; determine a second prediction error of the candidate first coding parameter whose corresponding first prediction error satisfies the first condition based on the third prediction value and the original value of the second color component of the current block; determine the first coding parameter based on the second prediction error of the candidate first coding parameter whose first prediction error satisfies the first condition.

[0455] In some embodiments, the second subunit is configured to: select a candidate first coding parameter whose second prediction error satisfies a third condition from the candidate first coding parameters whose first prediction error satisfies the first condition; and determine the first coding parameter based on the candidate first coding parameter whose second prediction error satisfies the third condition.

[0456] In some embodiments, the second subunit is configured to: set the first encoding parameter to be equal to the candidate first encoding parameter whose second prediction error satisfies a third condition; or set the first encoding parameter to be equal to a fusion value of the candidate first encoding parameter whose second prediction error satisfies the third condition.

[0457] In some embodiments, the second subunit is configured to: expand the candidate first coding parameter whose first prediction error satisfies the first condition to obtain the first extended parameter; determine the seventh weighting coefficient based on the reference sample value of the first color component of the current block and the candidate first coding parameter whose first prediction error satisfies the first condition and the first extended parameter; determine the fourth prediction value of the second color component of the current block based on the seventh weighting coefficient and the reference sample value of the second color component of the current block; determine the third prediction error of the corresponding parameter based on the fourth prediction value and the original value of the second color component of the current block; determine the first coding parameter based on the third prediction error of each candidate first coding parameter and the first extended parameter.

[0458] In some embodiments, the second subunit is configured to: select a parameter whose third prediction error satisfies a fourth condition from each of the candidate first encoding parameters and the first extended parameter; and determine the first encoding parameter based on the parameter whose third prediction error satisfies the fourth condition.

[0459] In some embodiments, the second subunit is configured to: set the first encoding parameter to be equal to the parameter for which the third prediction error satisfies a fourth condition; or set the first encoding parameter to be equal to a fusion value of the parameter for which the third prediction error satisfies the fourth condition.

[0460] In some embodiments, the second subunit is configured to: set the first encoding parameter to be equal to the parameter for which the first prediction error satisfies the first condition; or set the first encoding parameter to be equal to the fusion value of the parameter for which the first prediction error satisfies the first condition.

[0461] In some embodiments, the second subunit is configured to: set the first encoding parameter to be equal to a weighted sum of a parameter that the first prediction error satisfies a first condition and a third weighting coefficient.

[0462] In some embodiments, the second subunit is further configured to: determine a corresponding third weighting coefficient based on the first prediction error corresponding to the parameter whose first prediction error satisfies the first condition; or set the third weighting coefficient to a preset constant value.

[0463] In some embodiments, the second subunit is configured to expand the parameters of the first prediction error that meet the first condition to obtain the first expanded parameters; and fuse the first expanded parameters and / or the parameters of the first prediction error that meet the first condition to obtain the first encoding parameters.

[0464] In some embodiments, the second subunit is configured to set the first encoding parameter to be equal to a weighted sum of each candidate first encoding parameter and a fourth weighting coefficient.

[0465] In some embodiments, the second subunit is further configured to determine a fourth weighting coefficient of the corresponding candidate first coding parameter according to the first prediction error.

[0466] In some embodiments, the second subunit is configured to: determine an evaluation parameter characterizing the performance of the corresponding candidate first encoding parameter based on the first prediction error corresponding to each of the same candidate first encoding parameters in the template area; and determine the first encoding parameter based on the evaluation parameters of each of the candidate first encoding parameters.

[0467] In some embodiments, the second subunit is configured to: set the evaluation parameter to be equal to a fusion value of the first prediction errors corresponding to the same candidate first encoding parameter of the template region.

[0468] In some embodiments, the second subunit is configured to: set the evaluation parameter to be equal to the sum of the first prediction errors corresponding to the same candidate first encoding parameter of the template region.

[0469] In some embodiments, the second subunit is configured to: select a parameter whose evaluation parameter satisfies a second condition from each of the candidate first encoding parameters; and determine the first encoding parameter based on the parameter whose evaluation parameter satisfies the second condition.

[0470] In some embodiments, the second subunit is configured to: set the first encoding parameter to be equal to the parameter of the evaluation parameter satisfying the second condition; or set the first encoding parameter to be equal to the fusion value of the parameter of the evaluation parameter satisfying the second condition.

[0471] In some embodiments, the second subunit is configured to: set the first encoding parameter to be equal to the weighted sum of the parameter of the evaluation parameter satisfying the second condition and a fifth weighting coefficient.

[0472] In some embodiments, the second subunit is further configured to: determine a fifth weighting coefficient of the corresponding parameter according to the template area corresponding to the parameter whose evaluation parameter satisfies the second condition.

[0473] In some embodiments, the second subunit is configured to determine a fifth weighting coefficient of the corresponding parameter according to the number of pixels in the template area and / or the template type corresponding to the parameter for which the evaluation parameter satisfies the second condition.

[0474] In some embodiments, the second subunit is configured to: determine an eighth weighting coefficient based on the reference sample value of the first color component of the current block and the parameter whose evaluation parameter satisfies the second condition; determine the fifth predicted value of the second color component of the current block based on the eighth weighting coefficient and the reference sample value of the second color component of the current block; determine the fourth prediction error of the parameter whose corresponding evaluation parameter satisfies the second condition based on the fifth predicted value and the original value of the second color component of the current block; and determine the first coding parameter based on the fourth prediction error of each candidate first coding parameter.

[0475] In some embodiments, the second subunit is configured to: expand the parameters whose evaluation parameters meet the second condition to obtain second extended parameters; determine a ninth weighting coefficient based on the reference sample value of the first color component of the current block, the parameters whose evaluation parameters meet the second condition, and the second extended parameters; determine a sixth predicted value of the second color component of the current block based on the ninth weighting coefficient and the reference sample value of the second color component of the current block; determine a fifth prediction error of the corresponding parameter based on the sixth predicted value and the original value of the second color component of the current block; and determine the first coding parameter based on the fifth prediction error of each candidate first coding parameter and the second extended parameter.

[0476] In some embodiments, the first determining module 181 is further configured to determine the template area according to the template type included in the configured prediction mode.

[0477] In some embodiments, the first determining module 181 is configured to use the template included in the configured prediction mode as the template area.

[0478] In some embodiments, the first determination module 181 is further configured to determine the template area based on the pixel availability of the neighboring area of ​​the current block; wherein, based on the relative position relationship with the current block, the neighboring area includes at least one of the following: the upper area of ​​the current block, the left area of ​​the current block, the upper right area of ​​the current block, the lower left area of ​​the current block, and the upper left area of ​​the current block.

[0479] In some embodiments, the first prediction module 184 is further configured to use a default value as the predicted value of the second color component of the current block when the template region does not exist.

[0480] In some embodiments, the first prediction module 184 is further configured to, when the template area does not exist, use another prediction method different from the method to determine the second color component of the current block for prediction.

[0481] In some embodiments, the second subunit is configured to set the second prediction value used to determine the first prediction error to be equal to a second prediction value obtained by performing a correction operation on the second prediction value of the second color component of the template area.

[0482] In some embodiments, the encoding device 18 also includes: a first acquisition module, configured to obtain the original value of the second color component of the current block; a seventh determination module, configured to determine the residual value of the second color component of the current block based on the original value of the second color component of the current block and the first predicted value of the second color component; an encoding module, configured to encode the residual value of the second color component of the current block and write the obtained encoding bits into the bitstream.

[0483] In some embodiments, the encoding device 18 also includes: a first correction module, configured to perform a correction operation on the first predicted value of the second color component of the current block to obtain a corrected first predicted value; a first acquisition module, configured to obtain the original value of the second color component of the current block; an eighth determination module, configured to determine the residual value of the second color component of the current block based on the original value of the second color component of the current block and the corrected first predicted value; an encoding module, configured to encode the residual value of the second color component of the current block and write the obtained encoding bits into the bitstream.

[0484] In some embodiments, the encoding device 18 further includes an encoding module configured to encode the first encoding parameter or the index of the first encoding parameter, and write the obtained encoding bits into a bitstream.

[0485] It is understood that in the embodiments of the present application, a "module" 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 unit or a non-unitized unit. Moreover, the various components in this embodiment can be integrated into a processing unit, or each module can exist physically separately, or two or more modules can be integrated into a unit. The above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.

[0486] If the integrated module is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, or the portion that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in this embodiment. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0487] Therefore, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a first processor, the method according to any one of the aforementioned embodiments is implemented.

[0488] Based on the composition of the above-mentioned encoding device 18 and the computer-readable storage medium, refer to Figure 19, which shows a specific hardware structure diagram of the encoding device provided by the embodiment of the present application. As shown in Figure 19, the encoding device 19 may include: a first communication interface 191, a first memory 192 and a first processor 193; each component is coupled together through a first bus system 194. It can be understood that the first bus system 194 is used to achieve connection and communication between these components. In addition to the data bus, the first bus system 194 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are labeled as the first bus system 194 in Figure 19. Among them,

[0489] The first communication interface 191 is used to receive and send signals during the process of sending and receiving information with other external network elements;

[0490] A first memory 192 is used to store computer programs that can be run on the first processor 193;

[0491] The first processor 193 is configured to, when running the computer program, perform the following: determining a first encoding parameter according to the template area;

[0492] Determine a reference sample value of a first color component of the current block; determine a first weighting coefficient based on the reference sample value of the first color component of the current block and the first encoding parameter; and determine a first predicted value of the second color component of the current block based on the first weighting coefficient and the reference sample value of the second color component of the current block.

[0493] It is understood that the first memory 192 in the embodiment of the present application can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct RAM bus random access memory (DRRAM). The first memory 222 of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0494] The first processor 193 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in the first processor 193. The above-mentioned first processor 193 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 various 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 method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the first memory 192 , and the first processor 193 reads the information in the first memory 192 and completes the steps of the above method in combination with its hardware.

[0495] It is to be understood that these embodiments described in the present application can be implemented with hardware, software, firmware, middleware, microcode or its combination.For hardware implementation, the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processor (Digital Signal Processing, DSP), digital signal processing equipment (DSP Device, DSPD), programmable logic device (Programmable Logic Device, PLD), field programmable gate array (Field-Programmable Gate Array, FPGA), general-purpose processor, controller, microcontroller, microprocessor, other electronic units for performing functions described in the present application or its combination.For software implementation, the technology described in the present application can be realized by the module (such as process, function etc.) that performs functions described in the present application. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.

[0496] Optionally, as another embodiment, the first processor 193 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.

[0497] In another embodiment of the present application, based on the same inventive concept as the above embodiment, referring to FIG20 , a schematic diagram of the composition structure of a decoding device provided by an embodiment of the present application is shown. As shown in FIG20 , the decoding device 200 may include:

[0498] The fourth determining module 2001 is configured to determine a first decoding parameter according to the template area;

[0499] A fifth determining module 2002 is configured to determine a reference sample value of a first color component of the current block;

[0500] a sixth determining module 2003, configured to determine a first weighting coefficient according to the reference sample value of the first color component of the current block and the first decoding parameter;

[0501] The second prediction module 2004 is configured to determine a first prediction value of the second color component of the current block according to the first weighting coefficient and a reference sample value of the second color component of the current block.

[0502] In some embodiments, the fourth determination module 2001 includes a third determination unit and a fourth determination unit; wherein the third determination unit is configured to determine the reference sample value of the template area; and the fourth determination unit is configured to determine the first decoding parameter based on the reference sample value of the template area.

[0503] In some embodiments, the third determination unit is configured to: determine the reconstruction value of the first color component of the template area, and the reconstruction value of the second color component of the template area; determine the reconstruction value of the first color component of the reference area of ​​the template area, and the reconstruction value of the second color component of the reference area of ​​the template area.

[0504] In some embodiments, the fourth determination unit includes a third subunit and a fourth subunit; wherein the third subunit is configured to determine a first difference value of the template area, wherein the first difference value of the template area is set equal to the absolute value of the difference between the reference value of the first color component of the template area and the reference value of the first color component of the reference area of ​​the template area; and the fourth subunit is configured to determine the first decoding parameter based on the first difference value of the template area.

[0505] In some embodiments, the reference value of the first color component of the template area is the reconstructed value of the first color component of the template area, or the value obtained by filtering the reconstructed value of the first color component of the template area; the reference value of the first color component of the reference area of ​​the template area is the reconstructed value of the first color component of the reference area of ​​the template area, or the value obtained by filtering the reconstructed value of the first color component of the reference area of ​​the template area.

[0506] In some embodiments, the fourth subunit is configured to: determine the second prediction value of the second color component of the template area based on the first difference and the candidate first decoding parameter; determine the first prediction error of the second color component of the template area; determine the first decoding parameter based on the first prediction error; wherein the first prediction error is the error between the reference value of the second color component of the template area and the second prediction value of the second color component of the template area, and the reference value of the second color component of the template area is the reconstructed value of the second color component of the template area, or the value obtained by filtering the reconstructed value of the second color component of the template area.

[0507] In some embodiments, the fourth subunit is configured as follows: setting the second prediction value of the second color component of the template area to be equal to the weighted sum of the reference value of the second color component of the reference area of ​​the template area and a second weighting coefficient; setting the first decoding parameter to be equal to the value of the candidate first decoding parameter corresponding to the first prediction error meeting the first condition; wherein, the reference value of the second color component of the reference area of ​​the template area is the reconstructed value of the second color component of the reference area of ​​the template area, or the value obtained after filtering the reconstructed value of the second color component of the reference area of ​​the template area.

[0508] In some embodiments, the fourth subunit is further configured to determine the second weighting coefficient according to the first difference value of the template area and the candidate first decoding parameter using a preset corresponding relationship.

[0509] In some embodiments, the fourth subunit is configured to: select a parameter whose first prediction error satisfies a first condition from each candidate first decoding parameter of the template area; and determine the first decoding parameter based on the parameter whose first prediction error corresponding to the template area satisfies the first condition.

[0510] In some embodiments, the fourth subunit is configured to: set the first decoding parameter to be equal to the parameter for which the first prediction error satisfies the first condition; or set the first decoding parameter to be equal to the fusion value of the parameter for which the first prediction error satisfies the first condition.

[0511] In some embodiments, the fourth subunit is configured to: set the first decoding parameter to be equal to a weighted sum of a parameter that the first prediction error satisfies the first condition and a third weighting coefficient.

[0512] In some embodiments, the fourth subunit is further configured to: determine a corresponding third weighting coefficient based on the first prediction error corresponding to the parameter whose first prediction error satisfies the first condition; or set the third weighting coefficient to a preset constant value.

[0513] In some embodiments, the fourth subunit is configured to: expand the parameters of the first prediction error that meet the first condition to obtain the first extended parameters; and fuse the first extended parameters and / or the parameters of the first prediction error that meet the first condition to obtain the first decoding parameters.

[0514] In some embodiments, the fourth subunit is configured to: set the first decoding parameter to be equal to a weighted sum of each of the candidate first decoding parameters and a fourth weighting coefficient.

[0515] In some embodiments, the fourth subunit is further configured to: determine a fourth weighting coefficient of the corresponding candidate first decoding parameter according to the first prediction error.

[0516] In some embodiments, the first condition includes: the first prediction error is minimum or the first prediction error is less than a first threshold.

[0517] In some embodiments, the fourth subunit is configured to: determine an evaluation parameter characterizing the performance of the corresponding candidate first decoding parameter based on the first prediction error corresponding to each of the same candidate first decoding parameters in the template area; and determine the first decoding parameter based on the evaluation parameters of each of the candidate first decoding parameters.

[0518] In some embodiments, the fourth subunit is configured to: set the evaluation parameter to be equal to a fusion value of the first prediction errors corresponding to the same candidate first decoding parameter of the template region.

[0519] In some embodiments, the fourth subunit is configured to: set the evaluation parameter to be equal to the sum of the first prediction errors corresponding to the same candidate first decoding parameter of the template region.

[0520] In some embodiments, the fourth subunit is configured to: select a parameter whose evaluation parameter satisfies the second condition from each of the candidate first decoding parameters; and determine the first decoding parameter based on the parameter whose evaluation parameter satisfies the second condition.

[0521] In some embodiments, the fourth subunit is configured to: set the first decoding parameter to be equal to the parameter of the evaluation parameter satisfying the second condition; or set the first decoding parameter to be equal to the fusion value of the parameter of the evaluation parameter satisfying the second condition.

[0522] In some embodiments, the fourth subunit is configured to: set the first decoding parameter to be equal to a weighted sum of a parameter of the evaluation parameter satisfying the second condition and a fifth weighting coefficient.

[0523] In some embodiments, the fourth subunit is further configured to: determine a fifth weighting coefficient of the corresponding parameter according to the template area corresponding to the parameter whose evaluation parameter satisfies the second condition.

[0524] In some embodiments, the fourth subunit is configured to determine a fifth weighting coefficient of the corresponding parameter according to the number of pixels in the template area and / or the template type corresponding to the parameter whose evaluation parameter satisfies the second condition.

[0525] In some embodiments, the decoding device 200 further includes a parsing module configured to parse the code stream to obtain an index of the first decoding parameter; a second acquisition module configured to obtain the first decoding parameter based on the index of the first decoding parameter; or a parsing module configured to parse the code stream to obtain the first decoding parameter.

[0526] In some embodiments, the fourth determining module 2001 is further configured to determine the template area according to the template type included in the configured prediction mode.

[0527] In some embodiments, the template type includes at least one of the following: an upper template, a left template, an upper-right template, a lower-left template, and an upper-left template.

[0528] In some embodiments, the fourth determining module 2001 is configured to set the template region to a region corresponding to the template type included in the configured prediction mode.

[0529] In some embodiments, the fourth determination module 2001 is further configured to determine the template area based on the pixel availability of the neighboring area of ​​the current block; wherein the neighboring area includes at least one of the following: the upper area of ​​the current block, the left area of ​​the current block, the upper right area of ​​the current block, the lower left area of ​​the current block, and the upper left area of ​​the current block.

[0530] In some embodiments, the second prediction module 2004 is further configured to use a default value as the predicted value of the second color component of the current block based on determining that the template area does not exist.

[0531] In some embodiments, the second prediction module 2004 is further configured to, based on determining that the template area does not exist, use another prediction method different from the method to determine the second color component of the current block for prediction.

[0532] In some embodiments, the fourth subunit is configured to: set the second prediction value used to determine the first prediction error to be equal to a second prediction value obtained by performing a correction operation on the second prediction value of the second color component of the template area.

[0533] In some embodiments, the decoding device 200 also includes a parsing module configured to parse the code stream to obtain the residual value of the second color component of the current block; a ninth determination module configured to determine the reconstructed value of the second color component of the current block based on the residual value of the second color component and the first predicted value of the second color component of the current block.

[0534] In some embodiments, the decoding device 200 also includes a second correction module and a tenth determination module; wherein the second correction module is configured to perform a correction operation on the first prediction value of the second color component of the current block to obtain a corrected first prediction value; the tenth determination module is configured to determine the reconstructed value of the second color component of the current block based on the residual value of the second color component and the corrected first prediction value.

[0535] It is understood that in the embodiments of the present application, a "module" 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 unit or a non-unitized unit. Moreover, the various components in this embodiment can be integrated into a processing unit, or each module can exist physically separately, or two or more modules can be integrated into a unit. The above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.

[0536] If the integrated module is implemented as a software functional module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, this embodiment provides a computer-readable storage medium that stores a computer program. When the computer program is executed by a second processor, it implements any of the methods in the aforementioned embodiments.

[0537] Based on the composition of the above-mentioned decoding device 200 and the computer-readable storage medium, refer to Figure 21, which shows a specific hardware structure diagram of the decoding device provided by an embodiment of the present application. As shown in Figure 21, the decoding device 21 may include: a second communication interface 211, a second memory 212 and a second processor 213; each component is coupled together through a second bus system 214. It can be understood that the second bus system 214 is used to achieve connection and communication between these components. In addition to the data bus, the second bus system 214 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, various buses are labeled as the second bus system 214 in Figure 21. Among them,

[0538] The second communication interface 211 is used to receive and send signals during the process of sending and receiving information between other external network elements; the second memory 212 is used to store computer programs that can be run on the second processor 213; the second processor 213 is used to execute any one of the methods in the foregoing embodiments when running the computer program.

[0539] Optionally, as another embodiment, the second processor 213 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.

[0540] It can be understood that the hardware functions of the second memory 212 and the first memory 222 are similar, and the hardware functions of the second processor 213 and the first processor 223 are similar; they are not described in detail here.

[0541] In yet another embodiment of the present application, see Figure 22, which shows a schematic diagram of the structure of a coding and decoding system provided in an embodiment of the present application. As shown in Figure 22, the coding and decoding system 22 may include an encoder 221 and a decoder 222. The encoder 221 may be a device integrated with the encoding device 18 described in the previous embodiment, or may be the encoding device 19 described in the previous embodiment; the decoder 222 may be a device integrated with the decoding device 200 described in the previous embodiment, or may be the decoding device 21 described in the previous embodiment.

[0542] It should be noted that, in this application, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0543] The serial numbers of the embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments. The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments. The features disclosed in the several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments. The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments. The above is only a specific implementation method of the present application, but the scope of protection of the present application is not limited to this. Any technician familiar with this technical field can easily think of changes or replacements within the technical scope disclosed in this application, which should be covered within the scope of protection of this application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A decoding method, comprising: determining a first decoding parameter according to the template area; Determining a reference sample value of a first color component of a current block; determining a first weighting coefficient according to a reference sample value of a first color component of the current block and the first decoding parameter; A first prediction value of the second color component of the current block is determined according to the first weighting coefficient and a reference sample value of the second color component of the current block.

2. The method according to claim 1, wherein The determining of the first decoding parameter according to the template area includes: Determining a reference sample value of the template area; The first decoding parameter is determined according to the reference sample value of the template area.

3. The method according to claim 2, wherein: The determining of the reference sample value of the template area includes: Determining a reconstruction value of a first color component of the template area and a reconstruction value of a second color component of the template area; A reconstruction value of a first color component of a reference area of ​​the template area and a reconstruction value of a second color component of the reference area of ​​the template area are determined.

4. The method according to claim 3, wherein: The determining the first decoding parameter according to the reference sample value of the template area includes: determining a first difference value of the template area, wherein the first difference value of the template area is set equal to an absolute value of a difference between a reference value of the first color component of the template area and a reference value of the first color component of a reference area of ​​the template area; The first decoding parameter is determined according to the first difference value of the template area.

5. The method according to claim 4, wherein The reference value of the first color component of the template area is a reconstructed value of the first color component of the template area, or a value obtained by filtering the reconstructed value of the first color component of the template area; The reference value of the first color component of the reference area of ​​the template area is a reconstructed value of the first color component of the reference area of ​​the template area, or a value obtained by filtering the reconstructed value of the first color component of the reference area of ​​the template area.

6. The method according to claim 4, wherein: The determining the first decoding parameter according to the first difference value of the template area includes: determining a second prediction value of a second color component of the template area according to the first difference and the candidate first decoding parameter; determining a first prediction error for a second color component of the template region; determining the first decoding parameter according to the first prediction error; The first prediction error is an error between a reference value of the second color component of the template area and a second predicted value of the second color component of the template area, and the reference value of the second color component of the template area is a reconstructed value of the second color component of the template area, or a value obtained by filtering the reconstructed value of the second color component of the template area.

7. The method according to claim 6, wherein: The second predicted value of the second color component of the template area is set to be equal to the weighted sum of the reference value of the second color component of the reference area of ​​the template area and a second weighting coefficient; Setting the first decoding parameter to be equal to a value of the candidate first decoding parameter corresponding to when the first prediction error satisfies a first condition; The reference value of the second color component of the reference area of ​​the template area is a reconstructed value of the second color component of the reference area of ​​the template area, or a value obtained by filtering the reconstructed value of the second color component of the reference area of ​​the template area.

8. The method according to claim 7, wherein: The second weighting coefficient is determined according to the first difference value of the template area and the candidate first decoding parameter using a preset corresponding relationship.

9. The method according to claim 8, wherein The preset corresponding relationship is a softmax function, or the preset corresponding relationship is obtained using a softmax function; wherein the input of the softmax function is one of the following: a ratio of the first difference to the candidate first decoding parameter; a product of the first difference and the candidate first decoding parameter; The first difference is obtained by bit shifting, wherein the number of bits of the bit shift is equal to the candidate first decoding parameter.

10. The method according to claim 6, wherein: The candidate first decoding parameters include one or more candidate first decoding parameters.

11. The method according to claim 3, wherein: The reference area of ​​the template area includes at least one of the following: an upper adjacent region of the template region; a lower adjacent region of the template region; A left adjacent area of ​​the template area; a right adjacent area of ​​the template area; The template area.

12. The method according to claim 6, wherein: The determining the first decoding parameter according to the first prediction error includes: Selecting a parameter whose first prediction error satisfies a first condition from each candidate first decoding parameter of the template area; The first decoding parameter is determined according to a parameter of the first prediction error corresponding to the template area that satisfies a first condition.

13. The method according to claim 12, wherein: Setting the first decoding parameter to be equal to the parameter at which the first prediction error satisfies the first condition; or, The first decoding parameter is set to be equal to a fusion value of the parameter where the first prediction error satisfies a first condition.

14. The method according to claim 13, wherein The first decoding parameter is set to be equal to a weighted sum of a parameter that the first prediction error satisfies a first condition and a third weighting coefficient.

15. The method according to claim 14, wherein The method further comprises: Determine a corresponding third weighting coefficient based on the first prediction error corresponding to the parameter whose first prediction error satisfies the first condition; or set the third weighting coefficient to a preset constant value.

16. The method according to claim 12, wherein: The determining the first decoding parameter according to the parameter that the first prediction error corresponding to the template area satisfies the first condition includes: Expanding the parameter whose first prediction error satisfies the first condition to obtain a first expanded parameter; The first extended parameter and / or the parameter whose first prediction error satisfies the first condition are fused to obtain the first decoding parameter.

17. The method according to claim 6, wherein The first decoding parameter is set equal to a weighted sum of each of the candidate first decoding parameters and a fourth weighting coefficient.

18. The method according to claim 17, wherein The method further comprises: A fourth weighting coefficient of the corresponding candidate first decoding parameter is determined according to the first prediction error.

19. The method according to any one of claims 12 to 16, wherein: The first condition includes: the first prediction error is minimum, the first prediction error is less than a first threshold, the first prediction error is maximum, or the first prediction error is greater than a third threshold.

20. The method according to claim 6, wherein The determining the first decoding parameter according to the first prediction error includes: determining, based on first prediction errors corresponding to the same candidate first decoding parameter in the template region, an evaluation parameter representing the performance of the corresponding candidate first decoding parameter; The first decoding parameter is determined according to the evaluation parameters of each of the candidate first decoding parameters.

21. The method according to claim 20, wherein The evaluation parameter is set to be equal to a fusion value of the first prediction errors corresponding to the same candidate first decoding parameter of the template area.

22. The method according to claim 21, wherein The evaluation parameter is set to be equal to the sum of the first prediction errors corresponding to the same candidate first decoding parameter of the template area.

23. The method according to claim 20, wherein The determining the first decoding parameter according to the evaluation parameters of each candidate first decoding parameter includes: Selecting a parameter whose evaluation parameter satisfies a second condition from each of the candidate first decoding parameters; The first decoding parameter is determined according to the evaluation parameter satisfying the second condition.

24. The method according to claim 23, wherein Setting the first decoding parameter to be equal to the parameter of the evaluation parameter satisfying the second condition; or, The first decoding parameter is set to be equal to a fusion value of the parameter whose evaluation parameter satisfies the second condition.

25. The method according to claim 24, wherein The first decoding parameter is set equal to a weighted sum of a parameter for evaluating that the parameter satisfies the second condition and a fifth weighting coefficient.

26. The method according to claim 25, wherein The method further comprises: According to the template region corresponding to the parameter whose evaluation parameter satisfies the second condition, a fifth weighting coefficient of the corresponding parameter is determined.

27. The method according to claim 26, wherein The step of determining a fifth weighting coefficient of a corresponding parameter based on a template area corresponding to a parameter whose evaluation parameter satisfies the second condition includes: According to the number of pixels in the template area and / or the template type corresponding to the parameter whose evaluation parameter satisfies the second condition, a fifth weighting coefficient of the corresponding parameter is determined.

28. The method according to claim 25, wherein The fifth weighting coefficient is a preset constant value.

29. The method according to any one of claims 23 to 28, wherein The second condition includes: the evaluation parameter is minimum, the evaluation parameter is less than the second threshold, the evaluation parameter is maximum, or the evaluation parameter is greater than the fourth threshold.

30. The method of claim 1, wherein The method further comprises: Parsing the code stream to obtain the index of the first decoding parameter; and obtaining the first decoding parameter according to the index of the first decoding parameter; or, Parse the code stream to obtain the first decoding parameter.

31. The method according to claim 1, wherein The method further comprises: The template area is determined according to the template type included in the configured prediction mode.

32. The method according to claim 31, wherein The template type includes at least one of the following: upper template, left template, upper right template, lower left template, and upper left template.

33. The method according to claim 32, wherein The template area is set to an area corresponding to the template type included in the configured prediction mode.

34. The method of claim 1, wherein The method further comprises: Determining a template area based on pixel availability in a neighboring area of ​​the current block; The adjacent area includes at least one of the following: an upper area of ​​the current block, a left area of ​​the current block, an upper right area of ​​the current block, a lower left area of ​​the current block, and an upper left area of ​​the current block.

35. The method of claim 1, wherein The method further comprises: Based on determining that the template area does not exist, a default value is used as the predicted value of the second color component of the current block.

36. The method of claim 1, wherein The method further comprises: Based on determining that the template area does not exist, another prediction method different from the method is adopted to determine the second color component of the current block for prediction.

37. The method according to claim 6, wherein The second prediction value used to determine the first prediction error is set to be equal to a second prediction value obtained by performing a correction operation on the second prediction value of the second color component of the template area.

38. The method of claim 1, wherein The method further comprises: Parsing the code stream to obtain a residual value of the second color component of the current block; A reconstructed value of the second color component of the current block is determined according to the residual value of the second color component and the first predicted value of the second color component of the current block.

39. The method of claim 1, wherein The method further comprises: performing a correction operation on the first predicted value of the second color component of the current block to obtain a corrected first predicted value; A reconstructed value of the second color component of the current block is determined according to the residual value of the second color component and the modified first prediction value.

40. A coding method, the method comprising: determining a first encoding parameter according to the template area; Determining a reference sample value of a first color component of a current block; determining a first weighting coefficient according to a reference sample value of a first color component of the current block and the first encoding parameter; A first prediction value of the second color component of the current block is determined according to the first weighting coefficient and a reference sample value of the second color component of the current block.

41. The method of claim 1, wherein The determining of the first encoding parameter according to the template area includes: Determining a reference sample value of the template area; The first encoding parameter is determined according to the reference sample value of the template area.

42. The method according to claim 41, wherein The determining of the reference sample value of the template area includes: Determining a reconstruction value of a first color component of the template area and a reconstruction value of a second color component of the template area; A reconstruction value of a first color component of a reference area of ​​the template area and a reconstruction value of a second color component of the reference area of ​​the template area are determined.

43. The method according to claim 42, wherein The determining the first encoding parameter according to the reference sample value of the template area includes: determining a first difference value of the template area, wherein the first difference value of the template area is set equal to an absolute value of a difference between a reference value of the first color component of the template area and a reference value of the first color component of a reference area of ​​the template area; The first encoding parameter is determined according to the first difference value of the template area.

44. The method according to claim 43, wherein The reference value of the first color component of the template area is a reconstructed value of the first color component of the template area, or a value obtained by filtering the reconstructed value of the first color component of the template area; or the reference value of the first color component of the template area is an original value of the first color component of the template area, or a value obtained by filtering the original value of the first color component of the template area; The reference value of the first color component of the reference area of ​​the template area is a reconstructed value of the first color component of the reference area of ​​the template area, or a value obtained by filtering the reconstructed value of the first color component of the reference area of ​​the template area.

45. The method of claim 43, wherein The determining the first encoding parameter according to the first difference value of the template area includes: determining a second prediction value of a second color component of the template area according to the first difference and the candidate first encoding parameter; determining a first prediction error for a second color component of the template region; determining the first encoding parameter according to the first prediction error; The first prediction error is an error between a reference value of the second color component of the template area and a second predicted value of the second color component of the template area, and the reference value of the second color component of the template area is a reconstructed value of the second color component of the template area, or a value obtained by filtering the reconstructed value of the second color component of the template area.

46. ​​The method of claim 45, wherein The second predicted value of the second color component of the template area is set to be equal to the weighted sum of the reference value of the second color component of the reference area of ​​the template area and a second weighting coefficient; Setting the first encoding parameter to be equal to a value of the candidate first encoding parameter corresponding to when the first prediction error satisfies a first condition; The reference value of the second color component of the reference area of ​​the template area is a reconstructed value of the second color component of the reference area of ​​the template area, or a value obtained by filtering the reconstructed value of the second color component of the reference area of ​​the template area.

47. The method of claim 46, wherein The second weighting coefficient is determined according to the first difference value of the template area and the candidate first encoding parameter using a preset corresponding relationship.

48. The method of claim 47, wherein The preset corresponding relationship is a softmax function, or the preset corresponding relationship is obtained using a softmax function; wherein the input of the softmax function is one of the following: a ratio of the first difference to the candidate first encoding parameter; a product of the first difference and the candidate first encoding parameter; The first difference is obtained by bit shifting, wherein the number of bits of the bit shift is equal to the candidate first encoding parameter.

49. The method of claim 45, wherein The candidate first encoding parameters include one or more candidate first encoding parameters.

50. The method of claim 42, wherein The reference area of ​​the template area includes at least one of the following: an upper adjacent region of the template region; a lower adjacent region of the template region; A left adjacent area of ​​the template area; a right adjacent area of ​​the template area; The template area.

51. The method of claim 45, wherein The determining the first encoding parameter according to the first prediction error includes: Selecting a parameter whose first prediction error satisfies a first condition from each candidate first encoding parameter of the template area; The first encoding parameter is determined according to a parameter of the first prediction error corresponding to the template area that satisfies a first condition.

52. The method of claim 51, wherein The determining the first encoding parameter according to the parameter that the first prediction error corresponding to the template area satisfies the first condition includes: determining a sixth weighting coefficient according to a candidate first coding parameter whose reference sample value of the first color component of the current block and the first prediction error meet a first condition; determining a third predicted value of the second color component of the current block according to the sixth weighting coefficient and a reference sample value of the second color component of the current block; Determining, according to the third predicted value and the original value of the second color component of the current block, a second prediction error of the candidate first coding parameter whose corresponding first prediction error satisfies the first condition; The first coding parameter is determined according to the second prediction error of the candidate first coding parameter whose first prediction error satisfies the first condition.

53. The method of claim 52, wherein: The determining the first coding parameter according to the second prediction error of the candidate first coding parameter whose first prediction error satisfies the first condition includes: Selecting, from the candidate first coding parameters whose first prediction errors satisfy the first condition, a candidate first coding parameter whose second prediction error satisfies the third condition; The first coding parameter is determined according to the candidate first coding parameter whose second prediction error satisfies the third condition.

54. The method of claim 53, wherein: Setting the first encoding parameter to be equal to the candidate first encoding parameter whose second prediction error satisfies a third condition; or The first encoding parameter is set to be equal to a fused value of a candidate first encoding parameter whose second prediction error satisfies a third condition.

55. The method of claim 53, wherein The third condition includes: the second prediction error is minimum or maximum.

56. The method of claim 51, wherein The determining the first encoding parameter according to the parameter that the first prediction error corresponding to the template area satisfies the first condition includes: Extending the candidate first coding parameter whose first prediction error satisfies the first condition to obtain a first extended parameter; Determining a seventh weighting coefficient according to the candidate first coding parameter whose reference sample value and the first prediction error of the first color component of the current block meet the first condition and the first extended parameter; determining a fourth predicted value of the second color component of the current block according to the seventh weighting coefficient and a reference sample value of the second color component of the current block; determining a third prediction error of a corresponding parameter according to a fourth predicted value and an original value of the second color component of the current block; The first coding parameter is determined according to a third prediction error between each of the candidate first coding parameters and the first extended parameter.

57. The method of claim 56, wherein The determining the first coding parameter according to the third prediction error between each candidate first coding parameter and the first extended parameter includes: Selecting a parameter whose third prediction error satisfies a fourth condition from each of the candidate first coding parameters and the first extended parameter; The first encoding parameter is determined according to the parameter of the third prediction error satisfying the fourth condition.

58. The method of claim 57, wherein Setting the first encoding parameter to be equal to the parameter at which the third prediction error satisfies a fourth condition; or, The first encoding parameter is set to be equal to a fusion value of the parameter where the third prediction error satisfies a fourth condition.

59. The method of claim 57, wherein The fourth condition includes: the third prediction error is minimum or maximum.

60. The method of claim 51, wherein Setting the first encoding parameter to be equal to the parameter at which the first prediction error satisfies the first condition; or, The first encoding parameter is set to be equal to a fusion value of the parameter where the first prediction error satisfies a first condition.

61. The method of claim 60, wherein: The first encoding parameter is set to be equal to a weighted sum of a parameter that the first prediction error satisfies a first condition and a third weighting coefficient.

62. The method of claim 61, wherein The method further comprises: Determine a corresponding third weighting coefficient based on the first prediction error corresponding to the parameter whose first prediction error satisfies the first condition; or set the third weighting coefficient to a preset constant value.

63. The method of claim 51, wherein The determining the first encoding parameter according to the parameter that the first prediction error corresponding to the template area satisfies the first condition includes: Expanding the parameter whose first prediction error satisfies the first condition to obtain a first expanded parameter; The first extended parameter and / or the parameter whose first prediction error satisfies the first condition are fused to obtain the first encoding parameter.

64. The method of claim 45, wherein The first encoding parameter is set equal to a weighted sum of each of the candidate first encoding parameters and a fourth weighting coefficient.

65. The method of claim 64, wherein The method further comprises: According to the first prediction error, a fourth weighting coefficient of the corresponding candidate first coding parameter is determined.

66. The method of claim 46, wherein The first condition includes: the first prediction error is minimum, the first prediction error is less than a first threshold, the first prediction error is maximum, or the first prediction error is greater than a third threshold.

67. The method of claim 45, wherein The determining the first encoding parameter according to the first prediction error includes: determining, based on first prediction errors corresponding to the same candidate first coding parameter of the template region, an evaluation parameter characterizing the performance of the corresponding candidate first coding parameter; The first encoding parameter is determined according to the evaluation parameters of each candidate first encoding parameter.

68. The method of claim 67, wherein The evaluation parameter is set to be equal to a fusion value of the first prediction errors corresponding to the same candidate first encoding parameter of the template area.

69. The method of claim 68, wherein The evaluation parameter is set to be equal to the sum of the first prediction errors corresponding to the same candidate first encoding parameter of the template area.

70. The method of claim 67, wherein The determining the first encoding parameter according to the evaluation parameters of each candidate first encoding parameter includes: Selecting a parameter whose evaluation parameter satisfies a second condition from each of the candidate first encoding parameters; The first encoding parameter is determined according to the evaluation parameter satisfying the second condition.

71. The method of claim 70, wherein Setting the first encoding parameter to be equal to the parameter of the evaluation parameter satisfying the second condition; or, The first encoding parameter is set to be equal to a fusion value of the parameter whose evaluation parameter satisfies the second condition.

72. The method of claim 71, wherein The first encoding parameter is set to be equal to a weighted sum of a parameter for evaluating that the parameter satisfies the second condition and a fifth weighting coefficient.

73. The method of claim 72, wherein: The method further comprises: According to the template region corresponding to the parameter whose evaluation parameter satisfies the second condition, a fifth weighting coefficient of the corresponding parameter is determined.

74. The method of claim 73, wherein The step of determining a fifth weighting coefficient of a corresponding parameter based on a template area corresponding to a parameter whose evaluation parameter satisfies the second condition includes: According to the number of pixels in the template area and / or the template type corresponding to the parameter whose evaluation parameter satisfies the second condition, a fifth weighting coefficient of the corresponding parameter is determined.

75. The method of claim 72, wherein The fifth weighting coefficient is a preset constant value.

76. The method according to any one of claims 70 to 75, wherein The second condition includes: the evaluation parameter is minimum, the evaluation parameter is less than the second threshold, the evaluation parameter is maximum, or the evaluation parameter is greater than the fourth threshold.

77. The method of claim 70, wherein The determining the first encoding parameter according to the evaluation parameter satisfying the second condition includes: determining an eighth weighting coefficient according to the reference sample value of the first color component of the current block and a parameter of the evaluation parameter satisfying a second condition; determining a fifth predicted value of the second color component of the current block according to the eighth weighting coefficient and the reference sample value of the second color component of the current block; Determining, according to the fifth predicted value and the original value of the second color component of the current block, a parameter fourth prediction error whose corresponding evaluation parameter satisfies the second condition; The first coding parameter is determined according to the fourth prediction error of each candidate first coding parameter.

78. The method of claim 77, wherein The determining the first coding parameter according to the fourth prediction error of each candidate first coding parameter includes: Expanding the parameters whose evaluation parameters satisfy the second condition to obtain second expanded parameters; determining a ninth weighting coefficient according to the reference sample value of the first color component of the current block, the parameter of the evaluation parameter satisfying the second condition, and the second extended parameter; determining a sixth predicted value of the second color component of the current block according to the ninth weighting coefficient and the reference sample value of the second color component of the current block; determining a fifth prediction error of a corresponding parameter according to a sixth predicted value and an original value of the second color component of the current block; The first coding parameter is determined according to a fifth prediction error between each candidate first coding parameter and the second extended parameter.

79. The method of claim 40, wherein The method further comprises: The template area is determined according to the template type included in the configured prediction mode.

80. The method of claim 79, wherein The template type includes at least one of the following: upper template, left template, upper right template, lower left template, and upper left template.

81. The method of claim 80, wherein The determining the template area according to the template type included in the configured prediction mode includes: The template included in the configured prediction mode is used as the template area.

82. The method of claim 40, wherein: The method further comprises: determining the template area according to pixel availability in a neighboring area of ​​the current block; Among them, based on the relative position relationship with the current block, the adjacent area includes at least one of the following: the upper area of ​​the current block, the left area of ​​the current block, the upper right area of ​​the current block, the lower left area of ​​the current block, and the upper left area of ​​the current block.

83. The method of claim 40, wherein The method further comprises: In the absence of the template area, a default value is used as the predicted value of the second color component of the current block.

84. The method of claim 40, wherein The method further comprises: In the absence of the template area, another prediction method different from the method is adopted to determine the second color component of the current block for prediction.

85. The method of claim 45, wherein The second prediction value used to determine the first prediction error is set to be equal to a second prediction value obtained by performing a correction operation on the second prediction value of the second color component of the template area.

86. The method of claim 40, wherein The method further comprises: Obtaining the original value of the second color component of the current block; determining a residual value of the second color component of the current block according to the original value of the second color component of the current block and the first predicted value of the second color component; The residual value of the second color component of the current block is encoded, and the obtained encoding bits are written into a bitstream.

87. The method of claim 40, wherein The method further comprises: performing a correction operation on the first predicted value of the second color component of the current block to obtain a corrected first predicted value; Obtaining the original value of the second color component of the current block; determining a residual value of the second color component of the current block according to the original value of the second color component of the current block and the corrected first prediction value; The residual value of the second color component of the current block is encoded, and the obtained encoding bits are written into a bitstream.

88. The method of claim 40, wherein The method further comprises: The first coding parameter or the index of the first coding parameter is encoded, and the obtained encoding bits are written into a bitstream.

89. An encoding device comprising: A first determining module is configured to determine a first encoding parameter according to the template area; a second determining module configured to determine a reference sample value of a first color component of a current block; a third determining module configured to determine a first weighting coefficient according to a reference sample value of the first color component of the current block and the first encoding parameter; The first prediction module is configured to determine a first prediction value of the second color component of the current block according to the first weighting coefficient and a reference sample value of the second color component of the current block.

90. A coding device comprising a first memory and a first processor; wherein, The first memory is used to store a computer program that can be run on the first processor; The first processor is configured to execute the method according to any one of claims 40 to 88 when running the computer program.

91. A decoding device comprising: a fourth determining module configured to determine a first decoding parameter according to the template area; a fifth determining module configured to determine a reference sample value of a first color component of a current block; a sixth determining module, configured to determine a first weighting coefficient according to a reference sample value of the first color component of the current block and the first decoding parameter; The second prediction module is configured to determine a first prediction value of the second color component of the current block according to the first weighting coefficient and a reference sample value of the second color component of the current block.

92. A decoding device comprising a second memory and a second processor; wherein, The second memory is used to store a computer program that can be run on the second processor; The second processor is configured to execute the method according to any one of claims 1 to 39 when running the computer program.

93. A computer-readable storage medium, wherein: The computer-readable storage medium stores a computer program, and when the computer program is executed, the method according to any one of claims 1 to 39 is implemented, or the method according to any one of claims 40 to 88 is implemented.