Nothing Special   »   [go: up one dir, main page]

WO2024207136A1 - 编解码方法、码流、编码器、解码器以及存储介质 - Google Patents

编解码方法、码流、编码器、解码器以及存储介质 Download PDF

Info

Publication number
WO2024207136A1
WO2024207136A1 PCT/CN2023/085870 CN2023085870W WO2024207136A1 WO 2024207136 A1 WO2024207136 A1 WO 2024207136A1 CN 2023085870 W CN2023085870 W CN 2023085870W WO 2024207136 A1 WO2024207136 A1 WO 2024207136A1
Authority
WO
WIPO (PCT)
Prior art keywords
template
current block
value
intra
candidate
Prior art date
Application number
PCT/CN2023/085870
Other languages
English (en)
French (fr)
Inventor
王凡
Original Assignee
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Oppo广东移动通信有限公司 filed Critical Oppo广东移动通信有限公司
Priority to PCT/CN2023/085870 priority Critical patent/WO2024207136A1/zh
Publication of WO2024207136A1 publication Critical patent/WO2024207136A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode

Definitions

  • 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, a bit stream, an encoder, a decoder, and a storage medium.
  • the coding block prediction can be performed through template matching technology or template analysis technology.
  • the prediction technology involving the use of templates can be collectively referred to as template-based prediction technology.
  • template-based prediction techniques include but are not limited to inter-frame template matching, intra-frame block copy (Intra Block Copy, IBC) template matching, intra-frame template matching prediction (Intra Template Matching Prediction, Intra TMP), template based intra-frame mode derivation (Template based intra mode derivation, TIMD), decoder-side Intra Mode Derivation (Decoder-side Intra Mode Derivation, DIMD), etc.
  • the embodiments of the present application provide a coding and decoding method, a bit stream, an encoder, a decoder, and a storage medium, which can reduce unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and improving coding and decoding performance.
  • an embodiment of the present application provides a decoding method, which is applied to a decoder, and the method includes:
  • the prediction mode corresponding to the current block is a preset prediction mode, determining a first template corresponding to the current block in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode;
  • an embodiment of the present application provides an encoding method, which is applied to an encoder, and the method includes:
  • the prediction mode corresponding to the current block is a preset prediction mode, determining a first template corresponding to the current block in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode;
  • an embodiment of the present application provides a code stream, wherein the code stream is generated by bit encoding according to information to be encoded; wherein the information to be encoded includes at least one of the following:
  • Prediction mode identification information first template indication information, second template indication information, prediction difference.
  • an encoder comprising a first determining unit; wherein:
  • the first determination unit is configured to determine a first template corresponding to the current block in at least one candidate template according to size information of the current block if the prediction mode corresponding to the current block is a preset prediction mode; wherein the preset prediction mode includes a template-based prediction mode; and determine a prediction value corresponding to the current block according to the first template.
  • an encoder 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 used to execute the method as described in the second aspect when running the computer program.
  • an embodiment of the present application provides a decoder, comprising a second determining unit; wherein:
  • the second determination unit is configured to determine a first template corresponding to the current block in at least one candidate template according to size information of the current block if the prediction mode corresponding to the current block is a preset prediction mode; wherein the preset prediction mode includes a template-based prediction mode; and determine a prediction value corresponding to the current block according to the first template.
  • an embodiment of the present application provides a decoder, including 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 used to execute the method as described in the first aspect when running the computer program.
  • an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the method as described in the first aspect is implemented, or the method as described in the second aspect is implemented.
  • the embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder and a storage medium. If the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using a preset prediction mode of a template-based prediction mode
  • at least one candidate template can be selected to be determined according to the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain a first template used in the subsequent prediction process, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing through the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and improving coding and decoding performance.
  • FIG1 is a schematic diagram of the basic flow of a video codec
  • FIG2 is a schematic diagram showing the positional relationship between the current block and the reference sample
  • FIG3 is a schematic diagram of using four reference rows/columns in an intra-frame prediction method
  • FIG4 is a schematic diagram of nine modes of intra-frame prediction for a 4 ⁇ 4 block in H.264;
  • FIG5 is a schematic diagram of 35 intra-frame prediction modes used by HEVC.
  • FIG6 is a schematic diagram of 67 intra-frame modes used by VVC
  • FIG7 is a schematic diagram of a wide angle mode
  • FIG8 is a schematic diagram of 66 prediction modes used by AVS3;
  • FIG9 is a schematic diagram of screen content
  • FIG10 is a schematic diagram of inter-frame prediction
  • Figure 11 is a schematic diagram of intra TMP
  • FIG12 is a schematic diagram of a MIP
  • FIG13 is a schematic diagram of a TIMD
  • FIG14 is a schematic diagram of a DIMD
  • FIG15 is a schematic diagram of weights of different intra prediction modes
  • FIG16 is a schematic diagram of a template type 1
  • FIG17 is a schematic block diagram of the encoder
  • FIG18 is a schematic block diagram of the encoder
  • FIG19 is a schematic diagram of a network architecture of a coding and decoding system
  • FIG20 is a schematic diagram of a flow chart of a decoding method proposed in an embodiment of the present application.
  • FIG. 21 is a schematic diagram of a second template type
  • FIG22 is a schematic diagram of a candidate template
  • FIG23 is a schematic diagram of a flow chart of an encoding method proposed in an embodiment of the present application.
  • FIG24 is a schematic diagram of the composition structure of the encoder
  • FIG25 is a schematic diagram of the encoder hardware structure
  • FIG26 is a schematic diagram of the structure of a decoder
  • FIG27 is a schematic diagram of the decoder hardware structure
  • FIG28 is a schematic diagram of the composition structure of the encoding and decoding system.
  • CU Coding Unit
  • MSE Mean Square Error
  • MSD Mean Square Differences
  • VVC Versatile Video Coding
  • VVC reference software test platform
  • VTM VVC Test Model
  • ECM Enhanced Compression Model
  • MIP Matrix-based Intra Prediction
  • TDD Template based intra mode derivation
  • DIMD Decoder-side Intra Mode Derivation
  • a first color component, a second color component, and a third color component are generally used to represent a coding block.
  • the three color components are a brightness component, a blue chroma component, and a red chroma component.
  • the brightness component is usually represented by the symbol Y
  • the blue chroma component is usually represented by the symbol Cb or U
  • the red chroma component is usually represented by the symbol Cr or V; in this way, the video image can be represented in the YCbCr format or the YUV format.
  • Each image or sub-image or frame in the video is divided into square largest coding units (LCU) or coding tree units (CTU) of the same size (such as 128x128 or 64x64, etc.).
  • Each largest coding unit or coding tree unit can be divided into rectangular coding units (CU) according to rules.
  • Coding units may also be divided into prediction units (PU) and/or transform units (TU).
  • the hybrid coding framework includes modules such as prediction, transform, quantization, entropy coding and in-loop filter.
  • the prediction module includes intra prediction and inter prediction.
  • Inter prediction includes motion estimation and motion compensation.
  • the intra-frame prediction method is used in video coding and decoding technology to eliminate the spatial redundancy between adjacent samples. Since there is a strong similarity between adjacent frames in a video, the inter-frame prediction method is used in video coding and decoding technology to eliminate the temporal redundancy between adjacent frames, thereby improving coding and decoding efficiency.
  • the basic process of the video codec is shown in FIG1.
  • a frame of image 101 is divided into blocks, and intra-frame prediction or inter-frame prediction is used for the current block to generate a prediction block of the current block.
  • the original block of the current block is subtracted from the prediction block to obtain a residual block.
  • the residual block is transformed and quantized to obtain a quantization coefficient matrix.
  • the quantization coefficient matrix is entropy encoded and output to the bitstream.
  • intra-frame prediction or inter-frame prediction is used for the current block to generate a prediction block of the current block.
  • the bitstream is parsed to obtain a quantization coefficient matrix.
  • the quantization coefficient matrix is inversely quantized and inversely transformed to obtain a residual block.
  • the prediction block and the residual block are added to obtain a reconstructed block.
  • the reconstructed blocks constitute a reconstructed image, and the reconstructed image is loop-filtered based on the image or block to obtain a decoded image.
  • the encoding end also requires similar operations as the decoding end to obtain a decoded image.
  • the decoded image obtained can be used as a reference image for inter-frame prediction for subsequent frames.
  • the decoding end determines the same block division information, prediction, transformation, quantization, entropy coding and loop filtering mode information or parameter information as the encoding end by parsing and analyzing the existing information, so as to ensure that the decoded image obtained by the encoding end is the same as the decoded image obtained by the decoding end.
  • the decoded image obtained by the encoding end is also usually called the reconstructed image.
  • the above is the basic process of the video codec under the block-based hybrid coding framework. With the development of technology, some modules or steps of the framework or process may be optimized.
  • the coding and decoding method provided in the embodiment of the present application is applicable to the basic process of the video codec under the block-based hybrid coding framework, but is not limited to the framework and process. It is known to those skilled in the art that with the evolution of encoders and decoders and the emergence of new business scenarios, the method provided in the embodiment of the present application is also applicable to similar technical problems.
  • the current block can be the current coding unit (CU) or the current prediction unit (PU), etc.
  • Intra-frame prediction is a method of prediction using the spatial correlation between the samples that have been encoded and decoded around the current block and the samples within the current block.
  • the white 4x4 block is the current block
  • the gray samples in the left column and the upper row of the current block are the reference samples of the current block.
  • Intra-frame prediction uses these reference samples to predict the current block.
  • These reference samples may all be available, that is, all have been encoded and decoded. Some may also be unavailable, for example, the current block is the leftmost of the entire frame, then the reference sample on the left side of the current block is unavailable.
  • the reference sample on the lower left is also unavailable.
  • available reference samples or certain values or certain methods can be used for filling, or no filling can be performed.
  • the intra prediction method of multiple reference lines can use more reference samples to improve coding efficiency.
  • Figure 3 shows an example of using 4 reference rows/columns.
  • Mode 4 There are multiple prediction modes for intra-frame prediction. As shown in Figure 4, there are 9 modes for intra-frame prediction of 4x4 blocks in H.264. Mode 0 is to copy the samples above the current block vertically to the current block as the prediction value, mode 1 is to copy the reference samples on the left side horizontally to the current block as the prediction value, mode 2 (i.e. DC mode) is to use the average value of the 8 points A ⁇ D and I ⁇ L as the prediction value of all points, and modes 3 ⁇ 8 copy the reference samples to the corresponding positions of the current block at a certain angle (therefore, modes 3 ⁇ 8 are also called angle prediction modes). Because some positions of the current block cannot correspond exactly to the reference samples, it may be necessary to use the weighted average of the reference samples, or the sub-samples (sub-pixels) of the interpolated reference samples.
  • the intra-frame prediction modes used by HEVC include Planar, DC and 33 angle modes, a total of 35 prediction modes.
  • the intra-frame modes used by VVC include Planar, DC and 65 angle modes, a total of 67 prediction modes.
  • VVC also provides wide-angle modes for some rectangular blocks with large differences in length and width, such as the modes indicated by the dotted lines in Figure 7, which are -14 to -1 and 67 to 80 intervals, which will replace some conventional modes.
  • AVS3 uses DC, Plane, Bilinear, PCM and 62 angle modes, a total of 66 prediction modes.
  • Inter-frame prediction uses motion information to represent "motion".
  • Basic motion information includes information about the reference frame (or reference picture) and information about the motion vector (MV).
  • the codec determines the reference image based on the information about the reference image, and determines the coordinates of the reference block based on the information about the motion vector and the coordinates of the current block.
  • the reference block is determined by the coordinates of the reference block in the reference image. Using the determined reference block as the prediction block is the most basic prediction method of inter-frame prediction.
  • More than one reference block can be used to predict the current block to achieve better prediction results.
  • two reference blocks are used to predict the current block.
  • the two reference blocks can use a forward reference block and a backward reference block. It is also allowed that both reference blocks are forward or backward.
  • the so-called forward means that the time corresponding to the reference image is before the current frame
  • the backward means that the time corresponding to the reference image is after the current frame.
  • forward means that the position of the reference image in the video is before the current frame
  • backward means that the position of the reference image in the video is after the current frame.
  • forward means that the POC (picture order count) of the reference image is less than the POC of the current frame
  • backward means that the POC of the reference image is greater than the POC of the current frame.
  • Future video codec standards may support the prediction of multiple reference blocks.
  • a simple way to generate a prediction block using two reference blocks is to average the pixel values at corresponding positions of the two reference blocks to obtain a prediction block.
  • weighted averaging can also be used, such as the BCW (Bi-prediction with CU-level weight) used by VVC.
  • the GPM (Geometric partitioning mode) in VVC can also be understood as a special bidirectional prediction. In order to use bidirectional prediction, it is naturally necessary to find two reference blocks, so two sets of reference image information and motion vector information are required.
  • the motion in the video is not just simple translation, but also scaling, rotation, distortion and various complex motions.
  • VVC uses affine to simulate some of these simple motions.
  • the affine model in VVC uses two or three control points, and uses a linear model to derive the motion vector of each sub-block in the current block based on these control points.
  • the reason why only motion vectors are mentioned here instead of motion information is because they all point to the same reference image. It can be understood that ordinary translational motion is to find a "whole block" from the reference image, while affine is to find a group of "sub-blocks" that are not adjacent to each other from the reference image.
  • the above are all in the scope of unidirectional prediction, and affine can also realize bidirectional prediction or prediction of more "reference blocks”.
  • a unidirectional motion information in the data structure of affine motion information can include information of a reference image and two to three motion vectors. Or two to three groups of reference image information and motion vector information, but the information of these reference images is the same.
  • Intra Block Copy can significantly improve the compression efficiency of screen content coding, so IBC is used for screen content coding from HEVC to VVC.
  • Screen content is different from camera captured content. It is generated by computer. Screen content has no noise, contains text and computer graphics, etc., and has clear boundaries. There are a lot of repeated contents in the screen content. As shown in Figure 9, the contents in the two boxes in the first row are repeated, and the contents in the third and fourth boxes are repeated.
  • inter-frame prediction uses the reference block on the reference image as the prediction block of the current block, and the reference image is not the current image.
  • IBC finds a block from the encoded and decoded part of the current image (called the reconstructed part) as the prediction block of the current block.
  • IBC is also called intra picture block compensation or current picture referencing (CPR).
  • CPR current picture referencing
  • IBC uses a block vector (BV) to represent the position difference between the current block and the reference block.
  • the encoder determines the best matching block of the current block within the search range through block matching and encodes the BV.
  • BV block vector
  • IBC can be considered as an intra-frame prediction method, or as another type of prediction method independent of intra-frame prediction and inter-frame prediction.
  • the Template Matching (TM) method was first used in inter-frame prediction. This method uses the correlation between adjacent samples and takes some areas around the current block as templates.
  • the current block is encoded and decoded, its left and upper sides have been encoded and decoded according to the encoding order.
  • the hardware decoder is implemented, it is not necessarily guaranteed that the left and upper sides of the current block have been decoded when the current block starts decoding.
  • this refers to inter-frame blocks.
  • the inter-frame coded block when the inter-frame coded block generates a prediction block, the surrounding reconstructed samples are not required, so the prediction process of the inter-frame block can be carried out in parallel.
  • the intra-frame coded block requires the reconstructed samples on the left and upper sides as reference samples.
  • the left and upper sides of the current block are available, that is, it can be achieved by making corresponding adjustments to the hardware design.
  • the right and lower sides of the current block are not available under the encoding order in the video standard (such as VVC).
  • the rectangular areas on the left and upper sides of the current block 1001 are set as templates.
  • the height of the left template part is generally the same as the height of the current block 1001
  • the width of the upper template part is generally the same as the width of the current block 1001, but of course they can be different.
  • the best matching position of the template is found in the reference frame 1003 of the current frame 1002 to determine the motion information or motion vector of the current block 1001. This process can be roughly described as starting from a starting position in a certain reference frame and searching within a certain range around.
  • the search rules such as the search range and search step length, can be pre-set. Each time it moves to a position, the matching degree of the template corresponding to the position and the template around the current block is calculated.
  • the so-called matching degree can be measured by some distortion costs, such as SAD (sum of absolute difference), SATD (sum of absolute transformed difference) or MSE (mean-square error), etc.
  • SAD sum of absolute difference
  • SATD sum of absolute transformed difference
  • MSE mean-square error
  • the transform used by SATD may be Hadamard transform.
  • the cost is calculated using the prediction block of the template corresponding to the position and the reconstructed block of the template around the current block.
  • the sub-pixel position can also be searched, and the motion information of the current block is determined based on the position with the highest matching degree.
  • the motion information suitable for the template may also be the motion information suitable for the current block.
  • the template matching method may not necessarily be applicable to all blocks, so some methods can be used to determine whether the current block uses the above template matching method, such as using a control switch in the current block to indicate whether the template matching method is used.
  • Template matching technology such as DMVD (decoder side motion vector derivation). Both the encoder and the decoder can use the template to search to derive motion information or find better motion information based on the original motion information. It does not need to transmit specific motion vectors or motion vector differences, but the encoder and the decoder perform the same regular search to ensure the consistency of encoding and decoding.
  • the template matching method can improve compression performance, but it also requires “searching" in the decoder, which brings a certain degree of decoder complexity.
  • Intra template matching prediction is also a prediction technology.
  • TM can reduce the overhead of encoding MV, that is, TM can reduce the overhead of encoding BV.
  • An example is that there is no need to encode BV, and the matching block found by TM is directly used as the prediction block of the intra TMP mode of the current block.
  • FIG11 An example of intra TMP is shown in FIG11 .
  • the inverted L-shaped area 111 at the upper left corner of the current block 110 is used as a template and searched within the search range 112.
  • the search range is the reconstructed area.
  • the illustrated area 112 includes the current CTU of R1, the CTU on the upper left side of R2, the CTU on the upper side of R3, and the CTU on the left side of R4. This is an example.
  • the search range is different in actual applications.
  • the example shown in FIG11 finds the best matching block 113 (Matching block) in R2.
  • intra TMP will use the best matching block found by template matching as its final prediction block. That is to say, in the related art, when decoding the current block, there will be a flag to determine whether the current block uses intra TMP. If the current block uses intra TMP, the decoder will use the template matching method to find a best matching block and use the value of the best matching block as the prediction value of the current block. It can be seen that although the template has a strong correlation with the current block, the template is not the current block after all. The best matching block found by the template (actually the position of the current block corresponding to the best matching block of the template) may not necessarily be the best matching block of the current block. However, the decoder does not have a current block when searching, so it can only use the best matching block found by the template as the best matching block found by intra TMP.
  • intra TMP multi-candidate method can be used.
  • intra TMP can also use template matching to build a candidate list. Compared with directly determining the best matching block found by template matching, building a candidate list can provide the encoder with more choices. In some cases, it is difficult to find a perfect match block, especially for content captured by the camera. Template matching is used to select a small number of candidates with high matching degree from a large number of possible BVs, and then the encoder decides which candidate to select, which helps improve compression efficiency.
  • Matrix weighted intra prediction MIP also known as Matrix weighted Intra Prediction, is a special intra prediction mode.
  • Figure 12 is a schematic diagram of MIP. As shown in Figure 12, in order to predict a block with a width of W and a height of H, MIP needs to take H reconstructed samples in a column on the left side of the current block and W reconstructed samples in a row on the upper side of the current block as input. MIP generates a prediction block in the following three steps: reference sample averaging (Averaging), matrix multiplication (Matrix Vector Multiplication) and interpolation (Interpolation). Among them, it can be considered that the core of MIP is matrix multiplication. In other words, MIP can be considered to be a process of generating a prediction block using input samples (reference samples) in a matrix multiplication manner.
  • MIP provides a variety of matrices. Different prediction methods are reflected in the difference in matrices. The same input sample will get different results using different matrices.
  • the process of reference sample averaging and interpolation is a design that compromises performance and complexity. For larger blocks, an effect similar to downsampling can be achieved by averaging the reference samples, so that the input can be adapted to a smaller matrix, while interpolation achieves an upsampling effect. In this way, there is no need to provide MIP matrices for blocks of every size, but only one or several matrices of specific sizes can be provided.
  • MIP is somewhat similar to planar, but it is obviously more complex and more flexible than planar.
  • Template-based intra-frame mode derivation TIMD uses templates to analyze and select intra-frame prediction modes. It does not use MV or BV in the "search" space used by inter-frame and IBC, but “searches" intra-frame prediction modes from another level. Therefore, it does not need to involve the template around the current block and the reconstructed samples other than the reference samples of the template.
  • FIG13 is a schematic diagram of TIMD.
  • TIMD uses the template area shown in the figure as a template, and the Reference of the template in the figure is the reference sample of the template.
  • the decoder can use a certain intra-frame prediction mode to predict on the template, and compare the predicted value with the reconstructed value to obtain the cost of the intra-frame prediction mode on the template. For example, SAD, SATD, SSE, etc.
  • TIMD predicts some candidate intra-frame prediction modes on the template, obtains their costs on the template, and replaces one or two intra-frame prediction modes with the lowest cost as the intra-frame prediction value of the current block.
  • weighted averaging of the prediction values of the two intra prediction modes can improve the compression performance.
  • the weights of the prediction values of the two prediction modes are related to the above-mentioned cost, for example, the weights can be set to be inversely proportional to the cost.
  • TIMD uses the prediction effect of the intra-frame prediction mode on the template to screen the intra-frame prediction mode, and can weight the two intra-frame prediction modes according to the cost on the template.
  • the two intra-frame prediction modes may also be expanded to multiple in the later technological evolution.
  • the advantage of TIMD is that if the current block selects the TIMD mode, it does not need to indicate which specific intra-frame prediction mode is used, but is derived by the decoder itself through the above process, which saves overhead to a certain extent.
  • Intra-mode derivation DIMD also uses the reconstructed samples on the left and top of the current block to derive the prediction mode, but it does not make predictions on the template, but analyzes the gradient of the reconstructed samples.
  • FIG14 is a schematic diagram of DIMD.
  • DIMD analyzes the gradient of a dark point and adapts an intra-frame prediction mode according to its gradient.
  • the analysis of all points that need to be checked can obtain a result similar to the histogram below.
  • the so-called histogram is only to help understanding. It can be implemented in a variety of simple forms.
  • the current DIMD selects the highest two intra-frame prediction modes in the histogram, plus the planar mode, and the prediction values of the three intra-frame prediction modes are weighted. The weight is related to the analysis result.
  • FIG15 is a schematic diagram of the weights of different intra-frame prediction modes.
  • DIMD selects the two highest intra-frame prediction modes in the histogram, such as M1 and M2, plus the planar mode.
  • the weights ⁇ 1, ⁇ 2, and ⁇ 3 corresponding to these three intra-frame prediction modes can refer to the analysis results of the dark point.
  • the prediction value can be obtained by weighted prediction of the prediction values of these three intra-frame prediction modes.
  • DIMD uses the gradient analysis of the reconstructed samples to select the intra prediction mode, and can weight the two intra prediction modes plus planar according to the analysis results.
  • the advantage of DIMD is that if the current block selects the DIMD mode, it does not need to indicate which specific intra prediction mode is used, but the decoder itself derives it through the above process, which saves overhead to a certain extent.
  • the two intra prediction modes may also be expanded to multiple in the later technical evolution.
  • TIMD and DIMD have many similarities, and even in previous literature, their names are sometimes reversed. They both support weighting of prediction values of two or more intra-frame prediction modes.
  • DIMD does not make predictions on the template, it also uses the area of the template.
  • DIMD can also be classified as a template-based prediction technology.
  • Figure 16 is a schematic diagram of the first template type.
  • the template currently used in intra TMP in ECM is an inverted L-shaped template that includes left-side adjacent reconstructed samples, upper-side adjacent reconstructed samples, and upper-left adjacent reconstructed samples. In some other technologies that use template matching, some templates do not use upper-left adjacent samples.
  • a part of the area can also be used as a template, such as the upper template and the left template shown in Figure 16.
  • the complete template inverted L or T+L
  • the TL template the upper template
  • the left template is called the L template.
  • Template matching can be used to estimate the current block using a template, assuming that the block with a high template match degree also has a high match degree in the current block.
  • video content is diverse, especially the images collected by the camera. Assuming that the texture changes on both sides near the left edge of the current block, then using only the T template may be more appropriate than the TL template. Similarly, assuming that the texture changes on both sides near the upper edge of the current block, then using only the L template may be more appropriate than the TL template. It can be seen that the use of template analysis technology can also provide more options using a variety of different templates.
  • the template can also include reconstruction samples on the upper right side and the lower left side.
  • the T template extends to the right by a certain distance in addition to the part shown in the figure
  • the L template extends downward by a certain distance in addition to the part shown in the figure.
  • an upper right template and a lower left template are added.
  • Template-based prediction technology includes but is not limited to template matching between frames (inter-frame template matching prediction), template matching of IBC, intra TMP, TIMD, DIMD, etc.
  • intra TMP can use TL template, T template, and L template to perform template matching to determine BV.
  • Inter-frame template matching technology can use The TL template, T template, and L template are used for template matching to determine the MV.
  • TIMD can use the TL template, T template, and L template to derive the intra-frame prediction mode, and DIMD can use the TL template, T template, and L template to derive the intra-frame prediction mode.
  • T templates and L templates can provide more options, but they are not applicable to all situations. Considering the situation where the width and height are very different, or the template pixels on one side are too few, the use of T templates and/or L templates can be limited, thereby reducing unnecessary overhead or reducing the interference of unreasonable results.
  • the embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder and a storage medium. If the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using a preset prediction mode of a template-based prediction mode
  • at least one candidate template can be determined according to the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain a first template used in the subsequent prediction process, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing through the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and coding and decoding performance.
  • the encoder 100 may include a transform and quantization unit 101, an intra-frame estimation unit 102, an intra-frame prediction unit 103, a motion compensation unit 104, a motion estimation unit 105, an inverse transform and inverse quantization unit 106, a filter control analysis unit 107, a filtering unit 108, an encoding unit 109, and a decoded image cache unit 110, etc.
  • the filtering unit 108 may implement deblocking filtering and sample adaptive offset (Sample Adaptive Offset, SAO) filtering
  • the encoding unit 109 may implement header information encoding and context-based adaptive binary arithmetic coding (Context-based Adaptive Binary Arithmetic Coding, CABAC).
  • a video coding block can be obtained by dividing the coding tree unit (CTU), and then the residual pixel information obtained after intra-frame or inter-frame prediction is transformed by the transformation and quantization unit 101 to transform the video coding block, 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 of 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 a process of generating a motion vector, and the motion vector can estimate the motion of the video coding block, and then
  • the motion vector determined by the motion estimation unit 105 performs motion compensation; after determining the intra-frame prediction mode, the intra-frame prediction unit 103 is also used to provide the selected intra-frame prediction data to the encoding unit 109, and the motion estimation unit 105 also sends the calculated and determined motion vector data to the encoding unit 109; in addition, the inverse transform and inverse quantization unit 106 is used to reconstruct the video coding block, reconstruct the residual block in the pixel domain, and the reconstructed residual block is removed by the filter control analysis unit 107 and the filtering unit 108.
  • the encoding unit 109 is used to encode various coding parameters and quantized transform coefficients.
  • 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; and the decoded image buffer unit 110 is used 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 .
  • the decoder 200 includes a decoding unit 201, an inverse transform and inverse quantization unit 202, an intra-frame prediction unit 203, a motion compensation unit 204, a filtering unit 205, and a decoded image cache unit 206, etc., wherein the decoding unit 201 can implement header information decoding and CABAC decoding, and the filtering unit 205 can implement deblocking filtering and SAO filtering.
  • the decoding unit 201 can implement header information decoding and CABAC decoding
  • the filtering unit 205 can implement deblocking filtering and SAO filtering.
  • 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 the decoded transform coefficients; the transform coefficients are processed by the inverse transform and inverse quantization unit 202 to generate residual blocks in the pixel domain; the intra-frame prediction unit 203 can be used to generate prediction data for the current video decoding block based on the determined intra-frame prediction mode and the data from the previously decoded block of the current frame or picture; the motion compensation unit 204 is to determine the prediction information for the video decoding block by analyzing the motion vector and other associated syntax elements, and use The prediction information is used to generate a predictive block of 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 and 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 the block effect artifacts,
  • the embodiment of the present application also provides a network architecture of a codec system including an encoder and a decoder, wherein Figure 19 shows a schematic diagram of the network architecture of a codec system provided by the embodiment of the present application.
  • the network architecture includes one or more electronic devices 13 to 1N and a communication network 01, wherein the electronic devices 13 to 1N can perform video interaction through the communication network 01.
  • the electronic device can be various types of devices with video codec functions during implementation, for example, the electronic device can include a smart phone, a tablet computer, a personal computer, a personal digital assistant, a navigator, a digital phone, a video phone, a television, a sensor device, a server, etc., and the embodiment of the present application is not specifically limited.
  • the decoder or encoder described in the embodiment of the present application can be the above-mentioned electronic device.
  • the method of the embodiment of the present application is mainly applied to the intra-frame prediction unit 103 part shown in Figure 17 and the intra-frame prediction unit 203 part shown in Figure 18.
  • the embodiment of the present application can be applied to both the encoder and the decoder, and can even be applied to both the encoder and the decoder at the same time, but the embodiment of the present application is not specifically limited.
  • 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.
  • FIG20 is a flowchart of the decoding method proposed in the embodiment of the present application.
  • the method for the decoder to perform decoding processing may include the following steps:
  • Step 101 If the prediction mode corresponding to the current block is a preset prediction mode, determine a first template corresponding to the current block in at least one candidate template according to size information of the current block; wherein the preset prediction mode includes a template-based prediction mode.
  • the first template corresponding to the current block can be determined first, wherein if the prediction mode corresponding to the current block is a preset prediction mode, then Then, a first template corresponding to the current block can be determined from at least one candidate template according to the size information of the current block.
  • the decoding method of the embodiment of the present application is applied to a decoder.
  • the decoding method may include an intra-frame prediction method, more specifically, a color component prediction method.
  • the video image can be divided into a plurality of decoding blocks, each decoding block may include a first color component, a second color component and a third color component, and the current block in the embodiment of the present application refers to a decoding block in the video image that is currently to be intra-frame predicted.
  • the component to be predicted is the first color component
  • the component to be predicted is the second color component
  • the component to be predicted is the second color component
  • the component to be predicted is the third color component.
  • the current block predicts the first color component
  • the first color component is the brightness component
  • the current block can also be called a brightness block
  • the current block predicts the second color component
  • the second color component is the chrominance component, that is, the component to be predicted is the chrominance component
  • the current block can also be called a chrominance block.
  • the first template corresponding to the current block may be a candidate template in the template set corresponding to the current block, wherein the candidate templates corresponding to the current block include candidate templates of multiple different template types.
  • a template set corresponding to the current block can be constructed based on different template types, and then the first template corresponding to the current block can be determined from the candidate templates in the template set.
  • Figure 21 is a second schematic diagram of the template type.
  • the template shape is as shown in (a); when only the left reference sample is available, the template shape is as shown in (b); when only the upper reference sample is available, the template shape is as shown in (c); when only the left reference sample and the upper left reference sample are available, the template shape is as shown in (d); when only the left reference sample and the lower left reference sample are available, the template shape is as shown in (e); when only the upper reference sample and the upper right reference sample are available, the template shape is as shown in (f).
  • the template reference sample of the current block can be determined first according to the template type and the template size corresponding to the template type, and then the candidate template of the current block can be determined according to the template reference sample, and finally the construction of the template set is completed.
  • the first candidate template in the template set may be a template including the left adjacent reconstructed samples and the upper adjacent reconstructed samples of the current block, such as the TL template;
  • the second candidate template in the template set may be a template including the upper adjacent reconstructed samples of the current block, such as the T template;
  • the third candidate template in the template set may be a template including the left adjacent reconstructed samples of the current block, such as the L template.
  • At least one candidate template corresponding to the current block may include a TL template, a T template, and an L template.
  • Figure 22 is a schematic diagram of candidate templates.
  • the candidate templates of the current block finally generated may also include four types, such as candidate template 1 (TL template), candidate template 2 (TL template), candidate template 3 (T template) and candidate template 4 (L template).
  • the first template corresponding to the current block may be the first candidate template in the template set corresponding to the current block, such as candidate template 1.
  • the first template corresponding to the current block may be the second candidate template in the template set corresponding to the current block, such as candidate template 3.
  • the first template corresponding to the current block may be the third candidate template in the template set corresponding to the current block, such as candidate template 4.
  • the preset prediction mode may include a prediction mode based on a template. That is, in the present application, the prediction mode involving the use of a template in the prediction process may be uniformly determined as a preset prediction mode.
  • the preset prediction mode may include any one of template-based prediction modes such as intra-frame template matching prediction, intra-frame block copying, inter-frame template matching prediction, template-based intra-frame mode derivation, and intra-frame mode derivation.
  • template-based prediction modes such as intra-frame template matching prediction, intra-frame block copying, inter-frame template matching prediction, template-based intra-frame mode derivation, and intra-frame mode derivation.
  • the intra-frame template matching prediction intraTMP can use the best matching block found by template matching as its final prediction block, that is, intraTMP can be a template-based prediction mode, and thus can be used as a preset prediction mode.
  • the template matching of the intra-block copy IBC can determine the best matching block of the current block within the search range by the template matching method, that is, the template matching of IBC can be a template-based prediction mode, and therefore can be used as a preset prediction mode.
  • the inter-frame template matching prediction can determine the best matching block of the current block by the template matching method within the reference frame, that is, the inter-frame template matching prediction can be a template-based prediction mode, and therefore can be used as a preset prediction mode.
  • the template-based intra-frame mode derivation TIMD predicts some candidate intra-frame prediction modes on the template, and replaces one or two intra-frame prediction modes with the lowest cost as the intra-frame prediction value of the current block, that is, TIMD can be a template-based prediction mode, and therefore can be used as a preset prediction mode.
  • the intra-frame mode derivation DIMD is similar to the TIMD processing process. Although DIMD does not make predictions on the template, it also uses the area of the template. Therefore, DIMD can be a template-based prediction mode, and can then be used as a preset prediction mode.
  • the size information of the current block can be used to select and restrict the candidate templates.
  • the first template corresponding to the current block can be determined from at least one candidate template according to the size information corresponding to the current block.
  • the first template is a template used when the current block is predicted based on a preset prediction mode.
  • the size information corresponding to the current block may include information related to the height and/or width corresponding to the current block.
  • the size information corresponding to the current block may be a height value and a width value of the current block, wherein the height value and the width value of the current block may be absolute values of the height and the width of the current block.
  • the prediction mode identification information corresponding to the current block can be determined; if the value of the prediction mode identification information is a first value, then it can be determined that the prediction mode corresponding to the current block is a preset prediction mode; if the value of the prediction mode identification information is a second value, then it can be determined that the prediction mode corresponding to the current block is not a preset prediction mode.
  • the prediction mode identification information can be used to determine whether the current block uses a template-based prediction mode, that is, to determine whether the prediction mode of the current block is a preset prediction mode, and then the prediction mode identification information can be used to determine whether the current block uses the preset prediction mode for prediction processing.
  • the decoded code stream may determine a variable as the prediction mode identification information, so that the prediction mode identification information may be determined by taking a value of the variable.
  • the value of the prediction mode identification information may be the first value or the second value. Different values of the prediction mode identification information may lead to different ways of determining the prediction value of the current block. Specifically, based on the value of the prediction mode identification information, when determining the prediction value of the current block, you may choose to use a preset prediction mode, or choose not to use a preset prediction mode.
  • the prediction mode identification information can be understood as a flag indicating whether intra TMP is performed. If the value of the prediction mode identification information is a first value, then the prediction value of the current block can be determined by using intra TMP; if the value of the prediction mode identification information is a second value, then the prediction value of the current block can be determined without using intra TMP.
  • the first value may be set to 1 and the second value may be set to 0; the first value may also be set to true and the second value may be set to false.
  • This application does not make any limitation.
  • the flag intra_tmp_flag can be used to represent the prediction mode identification information, that is, intra_tmp_flag is used as the flag of intra TMP.
  • intra_tmp_flag 1
  • intra_tmp_flag 0
  • the first template corresponding to the current block can be further determined in at least one candidate template according to the size information corresponding to the current block.
  • the code stream when determining the first template corresponding to the current block in at least one candidate template based on the size information of the current block, the code stream is decoded to determine the first template indication information corresponding to the current block; if the value of the first template indication information is the third value, then it can be determined that the first template is the first candidate template.
  • the first candidate template may be one of the at least one candidate template corresponding to the current block.
  • the first candidate template may be a TL template in the at least one candidate template.
  • the first template indication information can be used to determine whether the current block uses the first candidate template, that is, the first template indication information can indicate whether the current block uses the first candidate template to perform prediction processing of the preset prediction mode.
  • the decoded code stream may determine a variable as the first template indication information, so that the first template indication information may be determined by taking a value of the variable.
  • the value of the first template indication information may be the third value or the fourth value.
  • the first candidate template when performing the preset prediction mode, may be selected for use, or the first candidate template may not be used, and other templates may be used, such as other templates other than the first candidate template in at least one candidate template.
  • the third value may be set to 0 and the fourth value may be set to 1; the third value may also be set to false and the fourth value may be set to true.
  • This application does not make any limitation.
  • the flag intra_tmp_alternative_template_flag can be used to indicate the first template indication information. For example, if the value of intra_tmp_alternative_template_flag is 0, it can be indicated that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_alternative_template_flag is 1, it can be indicated that the first candidate template is not determined as the first template corresponding to the current block, but other templates are continuously selected as the first template corresponding to the current block.
  • the value of the first template indication information is the fourth value, then it can be determined that the first template is not the first candidate template.
  • the size information of the current block meets the preset size condition, then it is necessary to further determine the second template indication information corresponding to the current block, so as to determine the first template according to the second template indication information.
  • the value of the first template indication information is a fourth value and the size information of the current block meets the preset size condition, then it is necessary to further decode the code stream to determine the second template indication information corresponding to the current block, and determine the first template based on the second template indication information.
  • the present application if it is determined not to use the first candidate template according to the first template indication information, then it is necessary to further determine whether to use other candidate templates other than the first candidate template according to the size information corresponding to the current block. Specifically, if the size information corresponding to the current block meets the preset size condition, then it is determined that other candidate templates other than the first candidate template can be used, and then the second template indication information can be determined to determine the first template according to the second template indication information.
  • the preset size condition can be used to restrict the use of candidate templates based on the size of the current block.
  • the first template when determining the first template based on the second template indication information, if the value of the second template indication information is the fifth value, then the first template can be determined as the second candidate template; if the value of the second template indication information is the sixth value, then the first template can be determined as the third candidate template.
  • the second candidate template and the third candidate template may be one of the at least one candidate template corresponding to the current block, for example, the second candidate template may be a T template in the at least one candidate template, and the third candidate template may be an L template in the at least one candidate template.
  • the second template indication information can be used to determine whether the current block uses the second candidate template and/or the third candidate template, that is, the second template indication information can indicate whether the current block uses the second candidate template and/or the third candidate template to perform prediction processing of the preset prediction mode.
  • the decoded code stream may determine a variable as the second template indication information, so that the second template indication information may be determined by taking a value of the variable.
  • the value of the second template indication information may be the fifth value or the sixth value.
  • the second candidate template or the third candidate template may be selected for use when performing the preset prediction mode.
  • the fifth value can be set to 0 and the sixth value can be set to 1; the fifth value can also be set to false and the sixth value can be set to true. No restrictions.
  • the flag intra_tmp_template_idx can be used to indicate the second template indication information. For example, if the value of intra_tmp_template_idx is 0, it can indicate that the second candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it can indicate that the third candidate template is determined as the first template corresponding to the current block.
  • the value of the first template indication information is a fourth value and the size information of the current block does not meet a preset size condition, then it is possible to choose to skip determining the second template indication information and directly determine the longest side of the current block based on the size information of the current block, and then determine the first template in at least one candidate template based on the longest side of the current block.
  • the present application if it is determined not to use the first candidate template according to the first template indication information, then it is necessary to further determine whether to use other candidate templates other than the first candidate template according to the size information corresponding to the current block. Specifically, if the size information corresponding to the current block does not meet the preset size condition, then it is no longer necessary to determine the first template according to the second template indication information, but the first template can be directly indicated according to the longest side of the current block.
  • the side corresponding to the width can be determined as the longest side of the current block; if the height value of the current block is greater than the width value of the current block, then the side corresponding to the width can be determined as the longest side of the current block.
  • the longest side of the current block is the side corresponding to the height height, which can also be understood as the height of the current block is greater than the width; the longest side of the current block is the side corresponding to the width width, which can also be understood as the width of the current block is greater than the height.
  • the value of the first template indication information is the fourth value and the size information of the current block does not meet the preset size condition
  • the width value of the current block is greater than the height value of the current block, that is, the longest side of the current block is the side corresponding to the width width
  • the L template containing more left adjacent samples can be used as the first template, that is, the third candidate template (L template) including the left adjacent reconstructed samples of the current block is determined as the first template.
  • the value of the first template indication information is the fourth value and the size information of the current block does not meet the preset size condition
  • the height value of the current block is greater than the width value of the current block, that is, the longest side of the current block is the side corresponding to the height height
  • the T template containing more upper adjacent samples can be used as the first template, that is, the second candidate template (T template) including the upper adjacent reconstructed samples of the current block is determined as the first template.
  • the longest side of the current block is the side corresponding to the height height, and therefore the L template corresponding to the longest side can be used as the first template.
  • the longest side of the current block is the side corresponding to the width width, and therefore the T template corresponding to the longest side can be used as the first template.
  • the code stream when determining a first template corresponding to a current block in at least one candidate template based on the size information of the current block, if the size information of the current block satisfies a preset size condition, the code stream can be decoded to determine the first template indication information corresponding to the current block; if the value of the first template indication information is a third value, the first template can be determined to be a first candidate template.
  • the first candidate template may be one of the at least one candidate template corresponding to the current block.
  • the first candidate template may be a TL template in the at least one candidate template.
  • the first template corresponding to the current block when determining the first template corresponding to the current block in at least one candidate template according to the size information of the current block, whether to use the first candidate template can be determined according to the size information corresponding to the current block. Specifically, if the size information corresponding to the current block meets the preset size condition, then it is determined that the first candidate template can be used, and then the determination of the first template indication information can be continued.
  • the preset size condition can be used to restrict the use of candidate templates based on the size of the current block.
  • the first template when determining the first template corresponding to the current block in at least one candidate template according to the size information of the current block, if the size information of the current block does not meet the preset size condition, then at this time, it is not necessary to determine the first template according to the first template indication information, but the first template can be directly indicated.
  • the first candidate template can be determined as the first template.
  • the first template indication information can be used to determine whether the current block uses the first candidate template, that is, the first template indication information can indicate whether the current block uses the first candidate template to perform prediction processing of the preset prediction mode.
  • the decoded code stream may determine a variable as the first template indication information, so that the first template indication information may be determined by taking a value of the variable.
  • the value of the first template indication information may be the third value or the fourth value.
  • the first candidate template when performing the preset prediction mode, may be selected for use, or the first candidate template may not be used, and other templates may be used, such as other templates other than the first candidate template in at least one candidate template.
  • the third value may be set to 0 and the fourth value may be set to 1; the third value may also be set to false and the fourth value may be set to true.
  • This application does not make any limitation.
  • the flag intra_tmp_alternative_template_flag can be used to indicate the first template indication information. For example, if the value of intra_tmp_alternative_template_flag is 0, it can be indicated that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_alternative_template_flag is 1, it can be indicated that the first candidate template is not determined as the first template corresponding to the current block, but other templates are continuously selected as the first template corresponding to the current block.
  • the value of the first template indication information is the fourth value, then it can be determined that the first template is not the first candidate template. At this time, it is necessary to further decode the code stream to determine the second template indication information corresponding to the current block, so as to determine the first template according to the second template indication information.
  • the first template when determining the first template based on the second template indication information, if the value of the second template indication information is the fifth value, then the first template can be determined as the second candidate template; if the value of the second template indication information is the sixth value, then the first template can be determined as the third candidate template.
  • the second candidate template and the third candidate template may be one of the at least one candidate template corresponding to the current block, for example, the second candidate template may be a T template in the at least one candidate template, and the third candidate template may be an L template in the at least one candidate template.
  • the second template indication information can be used to determine whether the current block uses the second candidate template and/or the third candidate template, that is, the second template indication information can indicate whether the current block uses the second candidate template and/or the third candidate template to perform prediction processing of the preset prediction mode.
  • the decoded code stream may determine a variable as the second template indication information, so that the second template indication information may be determined by taking a value of the variable.
  • the value of the second template indication information may be the fifth value or the sixth value.
  • the second candidate template or the third candidate template may be selected for use when performing the preset prediction mode.
  • the fifth value may be set to 0 and the sixth value may be set to 1; the fifth value may also be set to false and the sixth value may be set to true.
  • This application does not make any limitation.
  • the flag intra_tmp_template_idx can be used to indicate the second template indication information. For example, if the value of intra_tmp_template_idx is 0, it can indicate that the second candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it can indicate that the third candidate template is determined as the first template corresponding to the current block.
  • the first template indication information and/or the second template indication information are used to indicate the first template.
  • the size information corresponding to the current block needs to be used to restrict the candidate templates.
  • the use of the candidate template can be restricted according to the size of the current block. Specifically, when the meaning included in the size information corresponding to the current block is different, the corresponding preset size condition can also be different.
  • the preset size condition includes: the width value is less than a first numerical multiple of the height value and the height value is less than a second numerical multiple of the width value.
  • the first numerical multiple and the second numerical multiple can be used to limit the ratio between the width and the height of the current block.
  • the first numerical multiple and the second numerical multiple can be any numerical value greater than 0, wherein the first numerical multiple and the second numerical multiple can be the same or different, and the present application does not make specific limitations.
  • the first numerical value multiple may be 4, and the second numerical value multiple may be 8.
  • the first numerical multiple and the second numerical multiple may both be 4.
  • the width value of the current block is less than the first numerical value times the height value and the height value of the current block is less than the second numerical value times the width value, then it can be determined that the size information of the current block meets the preset size condition.
  • the width value of the current block is greater than or equal to the first numerical value times the height value, or the height value of the current block is greater than or equal to the second numerical value times the width value, then it can be determined that the size information of the current block does not meet the preset size condition.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template, as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the aspect ratio is less than the second ratio threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the decoded bitstream is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • Intra_tmp_template_idx indicates that the current block uses the T template or the L template.
  • the value of intra_tmp_template_idx is 0, which means that the current block uses the T template.
  • the value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side can be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template, as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the aspect ratio is less than the second ratio threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the decoded bitstream is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the current block satisfies both the width value less than four times the height value and the height value less than four times the width value, that is, whether the height value and the width value satisfy the conditions of width ⁇ height ⁇ 4 and height ⁇ width ⁇ 4. If not, then skip the parsing of intra_tmp_alternative_template_flag and directly select the TL template by default; if satisfied, the decoder parses intra_tmp_alternative_template_flag and intra_tmp_alternative_template_flag. ve_template_flag indicates whether the current block uses other templates.
  • intra_tmp_alternative_template_flag If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, the decoder parses intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the preset size condition includes: the height value is greater than a first size threshold and the width value is greater than a second size threshold.
  • the first size threshold can be used to limit the height value (absolute value of the height) of the current block; correspondingly, the second size threshold can be used to limit the width value (absolute value of the width) of the current block.
  • the first size threshold and the second size threshold may be any numerical value greater than 0, wherein the first size threshold and the second size threshold may be the same or different, and the present application does not make any specific limitation.
  • the first size threshold may be 8, and the second size threshold may be 4.
  • the first size threshold and the second size threshold may both be 8.
  • the size information of the current block when determining whether the size information of the current block meets the preset size condition, if the height value of the current block is greater than the first size threshold and the width value of the current block is greater than the second size threshold, then it can be determined that the size information of the current block meets the preset size condition. Correspondingly, if the height value of the current block is less than or equal to the first size threshold, or the width value of the current block is less than or equal to the second size threshold, then it can be determined that the size information of the current block does not meet the preset size condition.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first size threshold and the second size threshold are both 4, the preset size condition is that the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the decoded bitstream is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1 and the width value and height value of the current block both meet the conditions of width>4 and height>4, the decoder parses intra_tmp_template_idx.
  • Intra_tmp_template_idx indicates that the current block uses the T template or the L template.
  • the value of intra_tmp_template_idx is 0, which means that the current block uses the T template.
  • the value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side may be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template, as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first size threshold and the second size threshold are both 4, the preset size condition is that the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the decoded bitstream is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the width and height values of the current block meet the conditions of width>4 and height>4. If not, then skip the parsing of intra_tmp_alternative_template_flag and directly select the TL template by default; if it is satisfied, the decoder parses intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates that the current block Whether to use other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • intra_tmp_alternative_template_flag the decoder parses intra_tmp_template_idx.
  • intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the preset size conditions include: the width value is less than a first numerical multiple of the height value and the height value is less than a second numerical multiple of the width value, and the height value is greater than a first size threshold and the width value is greater than a second size threshold.
  • the first value multiple and the second value multiple can be used to limit the ratio between the width and height of the current block.
  • the first size threshold can be used to limit the height value (absolute value of the height) of the current block; the second size threshold can be used to limit the width value (absolute value of the width) of the current block.
  • the first numerical multiple and the second numerical multiple can be any numerical value greater than 0, wherein the first numerical multiple and the second numerical multiple can be the same or different, and the present application does not make specific limitations.
  • the first size threshold and the second size threshold may be any numerical value greater than 0, wherein the first size threshold and the second size threshold may be the same or different, and the present application does not make any specific limitation.
  • the first numerical multiple and the second numerical multiple may both be 4, and the first size threshold and the second size threshold may both be 8.
  • the width value of the current block is less than the first numerical value times the height value and the height value of the current block is less than the second numerical value times the width value, and at the same time, the height value of the current block is greater than the first size threshold and the width value of the current block is greater than the second size threshold, then it can be determined that the size information of the current block meets the preset size condition.
  • the width value of the current block is greater than or equal to the first numerical value times the height value, or the height value of the current block is greater than or equal to the second numerical value times the width value, or the height value of the current block is less than or equal to the first size threshold, or the width value of the current block is less than or equal to the second size threshold, then it can be determined that the size information of the current block does not meet the preset size condition.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the first size threshold and the second size threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the aspect ratio is less than the second ratio threshold, and at the same time, the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4&&width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the decoded
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses TL template.
  • intra_tmp_alternative_template_flag 1
  • the width value is less than four times the height value and the height value is less than four times the width value, that is, the height value and the width value satisfy width ⁇ height ⁇ 4 and height ⁇ width ⁇ 4, and the height value and the width value ratio of the current block simultaneously satisfy the conditions of width>4 and height>4.
  • the decoder parses intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side can be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the first size threshold and the second size threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the aspect ratio is less than the second ratio threshold, and at the same time, the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4&&width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the decoded
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the current block satisfies the conditions that the width value is less than four times the height value and the height value is less than four times the width value, that is, whether the height value and the width value satisfy width ⁇ height ⁇ 4 and height ⁇ width ⁇ 4, and whether the height value and the width value of the current block satisfy the conditions that width>4 and height>4 at the same time.
  • Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, the decoder parses intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the above examples use an explicit method to select different candidate templates, that is, the information for selecting different templates is written into the bitstream.
  • the method of limiting the candidate templates by the size information of the current block can reduce unnecessary overhead.
  • some template-based prediction techniques such as TIMD, DIMD, etc.
  • TIMD can derive an intra-frame prediction mode according to the TL template, T template, and L template respectively.
  • different processing can be performed according to threshold condition analysis.
  • DIMD uses the gradients of the reconstructed samples around the current block to construct a histogram of intra-frame prediction modes, selects the two highest intra-frame prediction modes in the histogram as mode0 and mode1, and adds the planar mode, and the prediction values of the three intra-frame prediction modes are weighted.
  • H_T a histogram of the T template
  • H_L a histogram of the L template
  • H_L a histogram of the L template
  • the above-mentioned DIMD position-dependent weight derivation method can directly determine whether to use position-dependent weights based on the data, without adding flags and other information.
  • the size information can also be used to restrict the weight derivation method. For example, if the block size meets the conditions, such as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4 or width>4&&height>4, it can be executed according to the DIMD position-dependent weight derivation method, otherwise, it can be directly executed according to the method that does not use position-dependent weights.
  • Step 102 Determine a prediction value corresponding to the current block according to the first template.
  • the prediction mode corresponding to the current block is a preset prediction mode
  • the prediction value corresponding to the current block can be further determined based on the first template.
  • the determined first template in the process of performing prediction processing on the current block using a preset prediction mode, can be used to complete the template-based prediction processing process of the current block, that is, the prediction block corresponding to the current block is obtained using the first template, and then the prediction value corresponding to the current block is determined.
  • the best matching block corresponding to the current block when determining the prediction value corresponding to the current block according to the first template, can be determined based on the first template, and then the prediction value corresponding to the current block can be determined according to the best matching block. For example, the reconstructed value corresponding to the best matching block can be determined as the prediction value of the current block.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the best matching block is used as the prediction block of the current block, and then the prediction value corresponding to the current block is determined.
  • the above method for determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is intra-frame template matching prediction intraTMP.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the first template is used to determine the best matching block of the current block within the search range, and then the best matching block is used as the prediction block of the current block, and then the prediction value corresponding to the current block is determined.
  • the above method for determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is template matching of intra-frame block copy IBC.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the first template can be used to determine the best matching block of the current block by template matching in the reference frame, and then the best matching block is used as the prediction block of the current block to determine the prediction value corresponding to the current block.
  • the above method of determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is the inter-frame template matching prediction.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • some candidate intra-frame prediction modes can be predicted on the first template, and one or two intra-frame prediction modes with the lowest value can be replaced as the intra-frame prediction value of the current block, thereby determining the prediction value corresponding to the current block.
  • the above-mentioned method of determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is a template-based intra-frame mode derivation TIMD.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the area of the first template can be used to determine one or two intra-frame prediction modes with the lowest cost as the intra-frame prediction value of the current block, and then determine the prediction value corresponding to the current block.
  • the above method of determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is the intra-frame mode to derive DIMD.
  • the reconstruction value of the current block may be further determined according to the prediction value of the current block.
  • the code stream may be decoded first to determine the prediction residual corresponding to the current block; and then the reconstructed value of the current block may be further determined based on the prediction residual and the prediction value.
  • the size information of the current block can be used to screen and limit the candidate templates, so as to determine the first template for prediction processing.
  • the candidate templates that are not suitable for the current block can be eliminated based on the size information of the current block, thereby reducing unnecessary overhead or reducing the interference of unreasonable results.
  • the encoding and decoding method proposed in the embodiment of the present application can limit the candidate templates through the size information corresponding to the current block to solve the problem that the derived results may be unreasonable when the template proportion is too small or the template size is too small, so that the first template used in the prediction process is suitable for the current block, thereby reducing the interference of unreasonable results.
  • the embodiment of the present application provides a decoding method, if the prediction mode corresponding to the current block is a preset prediction mode, then the first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using the preset prediction mode of the template-based prediction mode
  • at least one candidate template can be selected to be determined according to the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain the first template used in the subsequent prediction process, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing through the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and encoding and decoding performance.
  • FIG. 23 is a flow chart of the encoding method proposed in the embodiment of the present application. As shown in FIG. 23, the encoding method of the encoder may include the following steps:
  • Step 201 If the prediction mode corresponding to the current block is a preset prediction mode, determine a first template corresponding to the current block in at least one candidate template according to size information of the current block; wherein the preset prediction mode includes a template-based prediction mode.
  • the first template corresponding to the current block can be determined first, wherein, if the prediction mode corresponding to the current block is a preset prediction mode, the first template corresponding to the current block can be determined from at least one candidate template based on the size information of the current block.
  • the encoding method of the embodiment of the present application is applied to an encoder.
  • the encoding method may include an intra-frame prediction method, more specifically, a color component prediction method.
  • the video image can be divided into multiple coding blocks, each coding block may include a first color component, a second color component and a third color component, and the current block in the embodiment of the present application refers to the coding block in the video image that is currently to be intra-frame predicted.
  • the component to be predicted is the first color component
  • the component to be predicted is the second color component
  • the component to be predicted is the second color component
  • the component to be predicted is the third color component.
  • the current block predicts the first color component
  • the first color component is the brightness component
  • the current block can also be called a brightness block
  • the current block predicts the second color component
  • the second color component is the chrominance component, that is, the component to be predicted is the chrominance component
  • the current block can also be called a chrominance block.
  • the first template corresponding to the current block may be a candidate template in the template set corresponding to the current block, wherein the candidate templates corresponding to the current block include candidate templates of multiple different template types.
  • a template set corresponding to the current block can be constructed based on different template types, and then the first template corresponding to the current block can be determined from the candidate templates in the template set.
  • the template shape is as shown in (a); when only the left reference sample is available, the template shape is as shown in (b); when only the upper reference sample is available, the template shape is as shown in (c); when only the left reference sample and the upper left reference sample are available, the template shape is as shown in (d); when only the left reference sample and the lower left reference sample are available, the template shape is as shown in (e); when only the upper reference sample and the upper right reference sample are available, the template shape is as shown in (f).
  • the template reference sample of the current block can be determined first according to the template type and the template size corresponding to the template type, and then the candidate template of the current block can be determined according to the template reference sample, and finally the construction of the template set is completed.
  • the first candidate template in the template set may be a template including the left adjacent reconstructed samples and the upper adjacent reconstructed samples of the current block, such as the TL template;
  • the second candidate template in the template set may be a template including the upper adjacent reconstructed samples of the current block, such as the T template;
  • the third candidate template in the template set may be a template including the left adjacent reconstructed samples of the current block, such as the L template.
  • At least one candidate template corresponding to the current block may include a TL template, a T template, and an L template.
  • the candidate templates of the current block finally generated may also include four types, such as candidate template 1 (TL template), candidate template 2 (TL template), candidate template 3 (T template) and candidate template 4 (L template).
  • the first template corresponding to the current block may be the first candidate template in the template set corresponding to the current block, such as candidate template 1.
  • the first template corresponding to the current block may be the second candidate template in the template set corresponding to the current block, such as candidate template 3.
  • the first template corresponding to the current block may be the third candidate template in the template set corresponding to the current block, such as candidate template 4.
  • the preset prediction mode may include a prediction mode based on a template. That is, in the present application, the prediction mode involving the use of a template in the prediction process may be uniformly determined as a preset prediction mode.
  • the preset prediction mode may include any one of template-based prediction modes such as intra-frame template matching prediction, intra-frame block copying, inter-frame template matching prediction, template-based intra-frame mode derivation, and intra-frame mode derivation.
  • template-based prediction modes such as intra-frame template matching prediction, intra-frame block copying, inter-frame template matching prediction, template-based intra-frame mode derivation, and intra-frame mode derivation.
  • the intra-frame template matching prediction intraTMP can use the best matching block found by template matching as its final prediction block, that is, intraTMP can be a template-based prediction mode, and thus can be used as a preset prediction mode.
  • the template matching of the intra-block copy IBC can determine the best matching block of the current block within the search range by the template matching method, that is, the template matching of IBC can be a template-based prediction mode, and therefore can be used as a preset prediction mode.
  • the inter-frame template matching prediction can determine the best matching block of the current block by the template matching method within the reference frame, that is, the inter-frame template matching prediction can be a template-based prediction mode, and therefore can be used as a preset prediction mode.
  • the template-based intra-frame mode derivation TIMD predicts some candidate intra-frame prediction modes on the template, and replaces one or two intra-frame prediction modes with the lowest cost as the intra-frame prediction value of the current block, that is, TIMD can be a template-based prediction mode, and therefore can be used as a preset prediction mode.
  • the intra-frame mode derivation DIMD is similar to the TIMD processing process. Although DIMD does not make predictions on the template, it also uses the area of the template. Therefore, DIMD can be a template-based prediction mode, and can then be used as a preset prediction mode.
  • the size information of the current block can be used to select and restrict the candidate templates.
  • the first template corresponding to the current block can be determined from at least one candidate template according to the size information corresponding to the current block.
  • the first template is a template used when the current block is predicted based on a preset prediction mode.
  • the size information corresponding to the current block may include information related to the height and/or width corresponding to the current block.
  • the size information corresponding to the current block may be a height value and a width value of the current block, wherein the height value and the width value of the current block may be absolute values of the height and the width of the current block.
  • the prediction mode identification information corresponding to the current block can be determined; if the value of the prediction mode identification information is a first value, then it can be determined that the prediction mode corresponding to the current block is a preset prediction mode; if the value of the prediction mode identification information is a second value, then it can be determined that the prediction mode corresponding to the current block is a preset prediction mode.
  • the prediction mode is not the preset prediction mode.
  • the prediction mode identification information can be used to determine whether the current block uses a template-based prediction mode, that is, to determine whether the prediction mode of the current block is a preset prediction mode, and then the prediction mode identification information can be used to determine whether the current block uses the preset prediction mode for prediction processing.
  • a variable may be determined as the prediction mode identification information, so that the prediction mode identification information may be determined by taking a value of the variable.
  • the value of the prediction mode identification information may be the first value or the second value. Different values of the prediction mode identification information may lead to different ways of determining the prediction value of the current block. Specifically, based on the value of the prediction mode identification information, when determining the prediction value of the current block, you may choose to use a preset prediction mode, or choose not to use a preset prediction mode.
  • the prediction mode identification information can be understood as a flag indicating whether intra TMP is performed. If the value of the prediction mode identification information is a first value, then the prediction value of the current block can be determined by using intra TMP; if the value of the prediction mode identification information is a second value, then the prediction value of the current block can be determined without using intra TMP.
  • the first value may be set to 1 and the second value may be set to 0; the first value may also be set to true and the second value may be set to false.
  • This application does not make any limitation.
  • the flag intra_tmp_flag can be used to represent the prediction mode identification information, that is, intra_tmp_flag is used as the flag of intra TMP.
  • intra_tmp_flag 1
  • intra_tmp_flag 0
  • the first template corresponding to the current block can be further determined in at least one candidate template according to the size information corresponding to the current block.
  • the first template indication information corresponding to the current block is determined; if the value of the first template indication information is a third value, then the first template can be determined to be the first candidate template.
  • the first candidate template may be one of the at least one candidate template corresponding to the current block.
  • the first candidate template may be a TL template in the at least one candidate template.
  • the first template indication information can be used to determine whether the current block uses the first candidate template, that is, the first template indication information can indicate whether the current block uses the first candidate template to perform prediction processing of the preset prediction mode.
  • a variable may be determined as the first template indication information, so that the first template indication information may be determined by taking a value of the variable.
  • the value of the first template indication information may be the third value or the fourth value.
  • the first candidate template when performing the preset prediction mode, may be selected for use, or the first candidate template may not be used, and other templates may be used, such as other templates other than the first candidate template in at least one candidate template.
  • the third value may be set to 0 and the fourth value may be set to 1; the third value may also be set to false and the fourth value may be set to true.
  • This application does not make any limitation.
  • the flag intra_tmp_alternative_template_flag can be used to indicate the first template indication information. For example, if the value of intra_tmp_alternative_template_flag is 0, it can be indicated that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_alternative_template_flag is 1, it can be indicated that the first candidate template is not determined as the first template corresponding to the current block, but other templates are continuously selected as the first template corresponding to the current block.
  • the value of the first template indication information is the fourth value, then it can be determined that the first template is not the first candidate template.
  • the size information of the current block meets the preset size condition, then it is necessary to further determine the second template indication information corresponding to the current block, so as to determine the first template according to the second template indication information.
  • the first template indication information is the fourth value, and the size information of the current block satisfies the preset size condition, then it is necessary to further determine the second template indication information corresponding to the current block, and determine the first template based on the second template indication information.
  • the present application if it is determined not to use the first candidate template according to the first template indication information, then it is necessary to further determine whether to use other candidate templates other than the first candidate template according to the size information corresponding to the current block. Specifically, if the size information corresponding to the current block meets the preset size condition, then it is determined that other candidate templates other than the first candidate template can be used, and then the second template indication information can be determined to determine the first template according to the second template indication information.
  • the preset size condition can be used to restrict the use of candidate templates based on the size of the current block.
  • the first template when determining the first template based on the second template indication information, if the value of the second template indication information is the fifth value, then the first template can be determined as the second candidate template; if the value of the second template indication information is the sixth value, then the first template can be determined as the third candidate template.
  • the second candidate template and the third candidate template may be one of the at least one candidate template corresponding to the current block, for example, the second candidate template may be a T template in the at least one candidate template, and the third candidate template may be an L template in the at least one candidate template.
  • the second template indication information can be used to determine whether the current block uses the second candidate template and/or the third candidate template, that is, the second template indication information can indicate whether the current block uses the second candidate template and/or the third candidate template to perform prediction processing of the preset prediction mode.
  • a variable may be determined as the second template indication information, so that the second template indication information may be determined by taking a value of the variable.
  • the value of the second template indication information may be the fifth value or the sixth value.
  • the second candidate template or the third candidate template may be selected for use when performing the preset prediction mode.
  • the fifth value can be set to 0 and the sixth value can be set to 1; the fifth value can also be set to false and the sixth value can be set to true. No restrictions.
  • the flag intra_tmp_template_idx can be used to indicate the second template indication information. For example, if the value of intra_tmp_template_idx is 0, it can indicate that the second candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it can indicate that the third candidate template is determined as the first template corresponding to the current block.
  • the value of the first template indication information is a fourth value and the size information of the current block does not meet a preset size condition, then it is possible to choose to skip determining the second template indication information and directly determine the longest side of the current block based on the size information of the current block, and then determine the first template in at least one candidate template based on the longest side of the current block.
  • the present application if it is determined not to use the first candidate template according to the first template indication information, then it is necessary to further determine whether to use other candidate templates other than the first candidate template according to the size information corresponding to the current block. Specifically, if the size information corresponding to the current block does not meet the preset size condition, then it is no longer necessary to determine the first template according to the second template indication information, but the first template can be directly indicated according to the longest side of the current block.
  • the side corresponding to the width can be determined as the longest side of the current block; if the height value of the current block is greater than the width value of the current block, then the side corresponding to the width can be determined as the longest side of the current block.
  • the longest side of the current block is the side corresponding to the height height, which can also be understood as the height of the current block is greater than the width; the longest side of the current block is the side corresponding to the width width, which can also be understood as the width of the current block is greater than the height.
  • the value of the first template indication information is the fourth value and the size information of the current block does not meet the preset size condition
  • the width value of the current block is greater than the height value of the current block, that is, the longest side of the current block is the side corresponding to the width width
  • the L template containing more left adjacent samples can be used as the first template, that is, the third candidate template (L template) including the left adjacent reconstructed samples of the current block is determined as the first template.
  • the value of the first template indication information is the fourth value and the size information of the current block does not meet the preset size condition
  • the height value of the current block is greater than the width value of the current block, that is, the longest side of the current block is the side corresponding to the height height
  • the T template containing more upper adjacent samples can be used as the first template, that is, the second candidate template (T template) including the upper adjacent reconstructed samples of the current block is determined as the first template.
  • the longest side of the current block is the side corresponding to the height height, and therefore the L template corresponding to the longest side can be used as the first template.
  • the longest side of the current block is the side corresponding to the width width, and therefore the T template corresponding to the longest side can be used as the first template.
  • the first template indication information corresponding to the current block can be determined; if the value of the first template indication information is the third value, then the first template can be determined to be the first candidate template.
  • the first candidate template may be one of the at least one candidate template corresponding to the current block.
  • the first candidate template may be a TL template in the at least one candidate template.
  • the first template corresponding to the current block when determining the first template corresponding to the current block in at least one candidate template according to the size information of the current block, whether to use the first candidate template can be determined according to the size information corresponding to the current block. Specifically, if the size information corresponding to the current block meets the preset size condition, then it is determined that the first candidate template can be used, and then the determination of the first template indication information can be continued.
  • the preset size condition can be used to restrict the use of candidate templates based on the size of the current block.
  • the first template when determining the first template corresponding to the current block in at least one candidate template according to the size information of the current block, if the size information of the current block does not meet the preset size condition, then at this time, it is not necessary to determine the first template according to the first template indication information, but the first template can be directly indicated.
  • the first candidate template can be determined as the first template.
  • the first template indication information can be used to determine whether the current block uses the first candidate template, that is, the first template indication information can indicate whether the current block uses the first candidate template to perform prediction processing of the preset prediction mode.
  • a variable may be determined as the first template indication information, so that the first template indication information may be determined by taking a value of the variable.
  • the value of the first template indication information may be the third value or the fourth value.
  • the first candidate template when performing the preset prediction mode, may be selected for use, or the first candidate template may not be used, and other templates may be used, such as other templates other than the first candidate template in at least one candidate template.
  • the third value may be set to 0 and the fourth value may be set to 1; the third value may also be set to false and the fourth value may be set to true.
  • This application does not make any limitation.
  • the flag intra_tmp_alternative_template_flag can be used to indicate the first template indication information. For example, if the value of intra_tmp_alternative_template_flag is 0, it can be indicated that the first candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_alternative_template_flag is 1, it can be indicated that the first candidate template is not determined as the first template corresponding to the current block, but other templates are continuously selected as the first template corresponding to the current block.
  • the value of the first template indication information is the fourth value, then it can be determined that the first template is not the first candidate template. At this time, it is necessary to further determine the second template indication information corresponding to the current block, so as to determine the first template based on the second template indication information.
  • the first template when determining the first template based on the second template indication information, if the value of the second template indication information is the fifth value, then the first template can be determined as the second candidate template; if the value of the second template indication information is the sixth value, then the first template can be determined as the third candidate template.
  • the second candidate template and the third candidate template may be one of the at least one candidate template corresponding to the current block, for example, the second candidate template may be a T template in the at least one candidate template, and the third candidate template may be an L template in the at least one candidate template.
  • the second template indication information can be used to determine whether the current block uses the second candidate template and/or the third candidate template, that is, the second template indication information can indicate whether the current block uses the second candidate template and/or the third candidate template to perform prediction processing of the preset prediction mode.
  • a variable may be determined as the second template indication information, so that the second template indication information may be determined by taking a value of the variable.
  • the value of the second template indication information may be the fifth value or the sixth value.
  • the second candidate template or the third candidate template may be selected for use when performing the preset prediction mode.
  • the fifth value may be set to 0 and the sixth value may be set to 1; the fifth value may also be set to false and the sixth value may be set to true.
  • This application does not make any limitation.
  • the flag intra_tmp_template_idx can be used to indicate the second template indication information. For example, if the value of intra_tmp_template_idx is 0, it can indicate that the second candidate template is determined as the first template corresponding to the current block; if the value of intra_tmp_template_idx is 1, it can indicate that the third candidate template is determined as the first template corresponding to the current block.
  • the first template indication information and/or the second template indication information are used to indicate the first template.
  • the size information corresponding to the current block needs to be used to restrict the candidate templates.
  • the use of the candidate template can be restricted according to the size of the current block. Specifically, when the meaning included in the size information corresponding to the current block is different, the corresponding preset size condition can also be different.
  • the preset size condition includes: the width value is less than a first numerical multiple of the height value and the height value is less than a second numerical multiple of the width value.
  • the first numerical multiple and the second numerical multiple can be used to limit the ratio between the width and the height of the current block.
  • the first numerical multiple and the second numerical multiple can be any numerical value greater than 0, wherein the first numerical multiple and the second numerical multiple can be the same or different, and the present application does not make specific limitations.
  • the first numerical value multiple may be 4, and the second numerical value multiple may be 8.
  • the first numerical multiple and the second numerical multiple may both be 4.
  • the width value of the current block is less than the first numerical value times the height value and the height value of the current block is less than the second numerical value times the width value, then it can be determined that the size information of the current block meets the preset size condition.
  • the width value of the current block is greater than or equal to the first numerical value times the height value, or the height value of the current block is greater than or equal to the second numerical value times the width value, then it can be determined that the size information of the current block does not meet the preset size condition.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template, as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the width-to-height ratio is less than the second ratio threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the bitstream is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, intra_tmp_alternative_template_flag is determined. intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • intra_tmp_template_idx indicates that the current block uses the T template or the L template.
  • the value of intra_tmp_template_idx is 0, which means that the current block uses the T template.
  • the value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side can be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template, as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the width-to-height ratio is less than the second ratio threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the bitstream is as follows:
  • ve_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, determine intra_tmp_template_idx. intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the first size threshold can be used to limit the height value (absolute value of the height) of the current block; correspondingly, the second size threshold can be used to limit the width value (absolute value of the width) of the current block.
  • the first size threshold and the second size threshold may be any numerical value greater than 0, wherein the first size threshold and the second size threshold may be the same or different, and the present application does not make any specific limitation.
  • the first size threshold may be 8, and the second size threshold may be 4.
  • the first size threshold and the second size threshold may both be 8.
  • the size information of the current block when determining whether the size information of the current block meets the preset size condition, if the height value of the current block is greater than the first size threshold and the width value of the current block is greater than the second size threshold, then it can be determined that the size information of the current block meets the preset size condition. Correspondingly, if the height value of the current block is less than or equal to the first size threshold, or the width value of the current block is less than or equal to the second size threshold, then it can be determined that the size information of the current block does not meet the preset size condition.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template, as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first size threshold and the second size threshold are both 4, the preset size condition is that the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the code stream is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, intra_tmp_alternative_template_flag is determined. intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1 and the width value and height value of the current block both meet the conditions of width>4 and height>4, intra_tmp_template_idx is determined. intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side may be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the preset prediction mode is intra TMP, taking three candidate templates of TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first size threshold and the second size threshold are both 4, the preset size condition is that the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the code stream can be as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the width and height values of the current block meet the conditions of width>4 and height>4. If not, then skip the parsing of intra_tmp_alternative_template_flag and directly select the TL template by default; if it meets the conditions, determine intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates that the current block Whether to use other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • intra_tmp_alternative_template_flag determines intra_tmp_template_idx.
  • intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the preset size conditions include: the width value is less than a first numerical multiple of the height value and the height value is less than a second numerical multiple of the width value, and the height value is greater than a first size threshold and the width value is greater than a second size threshold.
  • the first value multiple and the second value multiple can be used to limit the ratio between the width and height of the current block.
  • the first size threshold can be used to limit the height value (absolute value of the height) of the current block; the second size threshold can be used to limit the width value (absolute value of the width) of the current block.
  • the first numerical multiple and the second numerical multiple can be any numerical value greater than 0, wherein the first numerical multiple and the second numerical multiple can be the same or different, and the present application does not make specific limitations.
  • the first size threshold and the second size threshold may be any numerical value greater than 0, wherein the first size threshold and the second size threshold may be the same or different, and the present application does not make any specific limitation.
  • the first numerical multiple and the second numerical multiple may both be 4, and the first size threshold and the second size threshold may both be 8.
  • the width value of the current block is less than the first numerical value times the height value and the height value of the current block is less than the second numerical value times the width value, and at the same time, the height value of the current block is greater than the first size threshold and the width value of the current block is greater than the second size threshold, then it can be determined that the size information of the current block meets the preset size condition.
  • the width value of the current block is greater than or equal to the first numerical value times the height value, or the height value of the current block is greater than or equal to the second numerical value times the width value, or the height value of the current block is less than or equal to the first size threshold, or the width value of the current block is less than or equal to the second size threshold, then it can be determined that the size information of the current block does not meet the preset size condition.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the first size threshold and the second size threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the aspect ratio is less than the second ratio threshold, and at the same time, the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4&&width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the code stream is
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, determine intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • intra_tmp_alternative_template_flag is 1, and the current block also uses the TL template
  • width value is less than four times the height value and the height value is less than four times the width value, that is, the height value and the width value satisfy width ⁇ height ⁇ 4 and height ⁇ width ⁇ 4, and the height value and the width value ratio of the current block simultaneously satisfy the conditions of width>4 and height>4
  • intra_tmp_template_idx is determined, and intra_tmp_template_idx indicates that the current block uses the T template or the L template.
  • the value of intra_tmp_template_idx is 0, which represents that the current block uses the T template
  • the value of intra_tmp_template_idx is 1, which represents that the current block uses the L template.
  • the candidate template corresponding to the long side can be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the preset prediction mode is intra TMP, taking three candidate templates, TL template, T template, and L template as examples, the first candidate template is the TL template, the second candidate template is the T template, the third candidate template is the L template, the first ratio threshold and the second ratio threshold are both 4, the first size threshold and the second size threshold are both 4, the preset size condition is that the aspect ratio is less than the first ratio threshold and the aspect ratio is less than the second ratio threshold, and at the same time, the height value is greater than the first size threshold and the width value is greater than the second size threshold, that is, the preset size condition can be expressed as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4&&width>4&&height>4, the flag intra_tmp_flag indicates the prediction mode identification information, the flag intra_tmp_alternative_template_flag indicates the first template indication information, and the flag intra_tmp_template_idx indicates the second template indication information, then the information in the code stream is
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the current block satisfies the conditions that the width value is less than four times the height value and the height value is less than four times the width value, that is, whether the height value and the width value satisfy width ⁇ height ⁇ 4 and height ⁇ width ⁇ 4, and whether the height value and the width value of the current block satisfy the conditions that width>4 and height>4 at the same time.
  • intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, intra_tmp_template_idx is determined. intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the above examples use an explicit method to select different candidate templates, that is, the information for selecting different templates is written into the bitstream.
  • the method of limiting the candidate templates by the size information of the current block can reduce unnecessary overhead.
  • some template-based prediction techniques such as TIMD, DIMD, etc.
  • TIMD can derive an intra-frame prediction mode according to the TL template, T template, and L template respectively.
  • different processing can be performed according to threshold condition analysis.
  • DIMD uses the gradients of the reconstructed samples around the current block to construct a histogram of intra-frame prediction modes, selects the two highest intra-frame prediction modes in the histogram as mode0 and mode1, and adds the planar mode, and the prediction values of the three intra-frame prediction modes are weighted.
  • H_T a histogram of the T template
  • H_L a histogram of the L template
  • H_L a histogram of the L template
  • the above-mentioned DIMD position-dependent weight derivation method can directly determine whether to use position-dependent weights based on the data, without adding flags and other information.
  • the size information can also be used to restrict the weight derivation method. For example, if the block size meets the conditions, such as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4 or width>4&&height>4, it can be executed according to the DIMD position-dependent weight derivation method, otherwise, it can be directly executed according to the method that does not use position-dependent weights.
  • Step 202 Determine a prediction value corresponding to the current block according to the first template.
  • the prediction mode corresponding to the current block is a preset prediction mode
  • the prediction value corresponding to the current block can be further determined based on the first template.
  • the determined first template in the process of performing prediction processing on the current block using a preset prediction mode, can be used to complete the template-based prediction processing process of the current block, that is, the prediction block corresponding to the current block is obtained using the first template, and then the prediction value corresponding to the current block is determined.
  • the best matching block corresponding to the current block when determining the prediction value corresponding to the current block according to the first template, can be determined based on the first template, and then the prediction value corresponding to the current block can be determined according to the best matching block. For example, the reconstructed value corresponding to the best matching block can be determined as the prediction value of the current block.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the best matching block is used as the prediction block of the current block, and then the prediction value corresponding to the current block is determined.
  • the above method for determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is intra-frame template matching prediction intraTMP.
  • the first template can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the best matching block of the current block is determined within the search range using the first template, and then the best matching block is used as the prediction block of the current block, thereby determining the prediction value corresponding to the current block.
  • the above method for determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is template matching of intra-frame block copy IBC.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the first template can be used to determine the best matching block of the current block by template matching in the reference frame, and then the best matching block is used as the prediction block of the current block, thereby determining the prediction value corresponding to the current block.
  • the above method of determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is the inter-frame template matching prediction.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • some candidate intra-frame prediction modes can be predicted on the first template, and one or two intra-frame prediction modes with the lowest cost can be replaced as the intra-frame prediction value of the current block, thereby determining the prediction value corresponding to the current block.
  • the above-mentioned method of determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is a template-based intra-frame mode derivation TIMD.
  • the first template after determining the first template of the current block, can be used to search for the best matching block corresponding to the current block, and finally the prediction value of the current block can be determined based on the obtained best matching block.
  • the area of the first template can be used to determine one or two intra-frame prediction modes with the lowest cost as the intra-frame prediction value of the current block, and then determine the prediction value corresponding to the current block.
  • the above method of determining the prediction value of the current block based on the first template can be applicable to the case where the preset prediction mode is the intra-frame mode to derive DIMD.
  • the reconstruction value of the current block may be further determined according to the prediction value of the current block.
  • the prediction residual corresponding to the current block may be determined first; and then the reconstructed value of the current block may be further determined based on the prediction residual and the prediction value.
  • the prediction difference after determining the prediction difference (residual) of the current block according to the prediction value of the current block, the prediction difference can be written into the bitstream.
  • the decoder can determine the prediction difference (residual) corresponding to the current block by decoding the bitstream; and then the reconstruction value of the current block can be further determined according to the prediction difference and the prediction value.
  • the size information of the current block can be used to screen and limit the candidate templates, so as to determine the first template for prediction processing.
  • the candidate templates that are not suitable for the current block can be eliminated based on the size information of the current block, thereby reducing unnecessary overhead or reducing the interference of unreasonable results.
  • the encoding and decoding method proposed in the embodiment of the present application can limit the candidate templates through the size information corresponding to the current block to solve the problem that the derived results may be unreasonable when the template proportion is too small or the template size is too small, so that the first template used in the prediction process is suitable for the current block, thereby reducing the interference of unreasonable results.
  • An embodiment of the present application provides an encoding method, if the prediction mode corresponding to the current block is a preset prediction mode, then a first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using a preset prediction mode of a template-based prediction mode
  • at least one candidate template can be determined based on the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain a first template used in subsequent prediction processing, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing using the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or unreasonable
  • the interference of the results can improve the compression efficiency and the encoding and decoding performance.
  • the coding method can control and limit the use of candidate templates according to the size of the current block.
  • the use of T templates and/or L templates can be limited according to the aspect ratio of the current block; in another case, the use of T templates and/or L templates can be limited according to the absolute value of the size of the current block (i.e., the absolute value of the width and height, such as the height value and the width value).
  • the L template corresponding to the width does not have an obvious effect, so it can be specified that the L template is not used for blocks of this size.
  • the L template corresponding to the width does not have an obvious effect.
  • an example of decoding syntax without any restriction on T template and L template is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, the decoder parses intra_tmp_template_idx. Intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the condition &&width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4 can be added on the basis of the above example.
  • the ratio threshold (first value times or second value times) 4 can be replaced by other values, such as 2 or 8. In other words, it is necessary to parse intra_tmp_template_idx only when the above aspect ratio restriction is met. Otherwise, if the value of intra_tmp_alternative_template_flag is 1, the candidate template corresponding to the long side is selected by default.
  • an example of decoding syntax for restricting the T template and the L template according to the aspect ratio of the current block is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • Intra_tmp_template_idx indicates that the current block uses the T template or the L template.
  • the value of intra_tmp_template_idx is 0, which means that the current block uses the T template.
  • the value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side can be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the condition width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4 can be added on the basis of the above example.
  • the ratio threshold 4 can be replaced with other values, such as 2 or 8. That is to say, it is necessary to parse intra_tmp_alternative_template_flag only when the above aspect ratio restriction is met. Otherwise, the TL template is selected by default.
  • an example of decoding syntax for restricting the T template and the L template according to the aspect ratio of the current block is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the current block satisfies both the width value less than four times the height value and the height value less than four times the width value, that is, whether the height value and the width value satisfy the conditions of width ⁇ height ⁇ 4 and height ⁇ width ⁇ 4. If not, then skip the parsing of intra_tmp_alternative_template_flag and directly select the TL template by default; if satisfied, the decoder parses intra_tmp_alternative_template_flag and intra_tmp_alternative_template_flag. ve_template_flag indicates whether the current block uses other templates.
  • intra_tmp_alternative_template_flag If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1, the decoder parses intra_tmp_template_idx, and intra_tmp_template_idx indicates that the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the absolute value of the size of the current block that is, the absolute value of the width and height of the current block can also be taken as a factor to be considered.
  • the corresponding T template or L template can be used.
  • the condition width>4&&height>4 can be added on the basis of the above example.
  • the size threshold 4 can be replaced with other values, such as 2 or 8. In other words, it is necessary to parse intra_tmp_template_idx only when the above size restriction conditions are met. Otherwise, if the value of intra_tmp_alternative_template_flag is 1, the candidate template corresponding to the long edge is selected by default.
  • an example of decoding syntax for limiting the T template and the L template according to the absolute value of the width and/or height of the current block is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, the decoder parses intra_tmp_alternative_template_flag. Intra_tmp_alternative_template_flag indicates whether the current block uses other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template. If the value of intra_tmp_alternative_template_flag is 1 and the width value and height value of the current block both meet the conditions of width>4 and height>4, the decoder parses intra_tmp_template_idx.
  • Intra_tmp_template_idx indicates that the current block uses the T template or the L template.
  • the value of intra_tmp_template_idx is 0, which means that the current block uses the T template.
  • the value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the candidate template corresponding to the long side may be selected by default. For example, if the long side is the height side, the L template is selected; if the long side is the width side, the T template is selected.
  • the condition width>4&&height>4 can be added on the basis of the above example.
  • the size threshold 4 can be replaced with other values, such as 2 or 8. That is to say, it is necessary to parse intra_tmp_alternative_template_flag only when the above size restriction conditions are met. Otherwise, the TL template is selected by default.
  • an example of decoding syntax for limiting the T template and the L template according to the absolute value of the width and/or height of the current block is as follows:
  • intra_tmp_flag indicates whether the current block uses intra TMP. If the current block uses intra TMP, it is necessary to first determine whether the width and height of the current block meet the conditions of width>4 and height>4. If not, then skip the parsing of intra_tmp_alternative_template_flag and directly select the TL template by default; if it meets the conditions, the decoder parses intra_tmp_alternative_template_flag, and intra_tmp_alternative_template_flag indicates that the current block is Whether to use other templates. If the value of intra_tmp_alternative_template_flag is 0, it means that the current block uses the TL template.
  • intra_tmp_alternative_template_flag the decoder parses intra_tmp_template_idx.
  • intra_tmp_template_idx indicates whether the current block uses the T template or the L template. For example, the value of intra_tmp_template_idx is 0, which means that the current block uses the T template. The value of intra_tmp_template_idx is 1, which means that the current block uses the L template.
  • the above examples use an explicit method to select different candidate templates, that is, the information for selecting different templates is written into the bitstream.
  • the method of limiting the candidate templates by the size information of the current block can reduce unnecessary overhead.
  • some template-based prediction techniques such as TIMD, DIMD, etc.
  • TIMD can derive an intra-frame prediction mode according to the TL template, T template, and L template respectively.
  • different processing can be performed according to threshold condition analysis.
  • DIMD uses the gradients of the reconstructed samples around the current block to construct a histogram of intra-frame prediction modes, selects the two highest intra-frame prediction modes in the histogram as mode0 and mode1, and adds the planar mode, and the prediction values of the three intra-frame prediction modes are weighted.
  • H_T a histogram of the T template
  • H_L a histogram of the L template
  • H_L a histogram of the L template
  • the above-mentioned DIMD position-dependent weight derivation method can directly determine whether to use position-dependent weights based on the data, without adding flags and other information.
  • the size information can also be used to restrict the weight derivation method. For example, if the block size meets the conditions, such as width ⁇ height ⁇ 4&&height ⁇ width ⁇ 4 or width>4&&height>4, it can be executed according to the DIMD position-dependent weight derivation method, otherwise, it can be directly executed according to the method that does not use position-dependent weights.
  • the encoding and decoding method proposed in the embodiment of the present application can use the size information of the current block to screen and limit the candidate templates in the process of using the template-based prediction technology to predict the current block, so as to determine the first template for prediction.
  • the candidate templates that are not suitable for the current block can be eliminated based on the size information of the current block, thereby reducing unnecessary overhead or reducing the interference of unreasonable results.
  • the encoding and decoding method proposed in the embodiment of the present application can limit the candidate templates through the size information corresponding to the current block to solve the problem that the derived results may be unreasonable when the template proportion is too small or the template size is too small, so that the first template used in the prediction process is suitable for the current block, thereby reducing the interference of unreasonable results.
  • the embodiment of the present application provides a coding and decoding method, if the prediction mode corresponding to the current block is a preset prediction mode, then the first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using the preset prediction mode of the template-based prediction mode
  • at least one candidate template can be selected to be determined according to the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain the first template used in the subsequent prediction processing process, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing through the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and improving coding and decoding performance.
  • FIG. 24 shows a schematic diagram of the composition structure of an encoder provided in an embodiment of the present application.
  • the encoder 180 may include: a first determining unit 1801; wherein,
  • the first determination unit 1801 is configured to determine a first template corresponding to the current block in at least one candidate template according to size information of the current block if the prediction mode corresponding to the current block is a preset prediction mode; wherein the preset prediction mode includes a template-based prediction mode; and determine a prediction value corresponding to the current block according to the first template.
  • a "unit” may be a part of a circuit, a part of a processor, a part of a program or software, etc., and of course, it may be a module, or it may be non-modular.
  • the components in the present embodiment may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software functional module.
  • the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • the technical solution of this embodiment is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product.
  • the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in this embodiment.
  • the aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., which can store program code.
  • an embodiment of the present application provides a computer-readable storage medium, which is applied to the encoder 180.
  • the computer-readable storage medium stores a computer program, and when the computer program is executed by the first processor, the method described in any one of the aforementioned embodiments is implemented.
  • the encoder 180 may include: a first communication interface 1901, a first memory 1902 and a first processor 1903; each component is coupled together through a first bus system 1904. It can be understood that the first bus system 1904 is used to realize the connection and communication between these components.
  • the first bus system 1904 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 1904. Among them,
  • the first communication interface 1901 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
  • a first memory 1902 used for storing a computer program that can be run on the first processor 1903;
  • the first processor 1903 is used to perform the following processing when running the computer program: if the prediction mode corresponding to the current block is a preset prediction mode, determine the first template corresponding to the current block in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and determine the prediction value corresponding to the current block according to the first template.
  • the first memory 1902 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.
  • 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.
  • RAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate synchronous DRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous link DRAM
  • DRRAM direct RAM bus RAM
  • the first processor 1903 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the first processor 1903 or an instruction in the form of software.
  • the above first processor 1903 may be a general-purpose processor, a digital Signal processor (Digital Signal Processor, DSP), Application Specific Integrated Circuit (Application Specific Integrated Circuit, ASIC), Field Programmable Gate Array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field Programmable Gate Array
  • the methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed.
  • the general processor can be a microprocessor or the processor can also be any conventional processor, etc.
  • the steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be combined and executed.
  • the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc.
  • the storage medium is located in the first memory 1902, and the first processor 1903 reads the information in the first memory 1902, and completes the steps of the above method in combination with its hardware.
  • the processing unit can be implemented in one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processors (Digital Signal Processing, DSP), digital signal processing devices (DSP Device, DSPD), programmable logic devices (Programmable Logic Device, PLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA), general processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application or a combination thereof.
  • ASIC Application Specific Integrated Circuits
  • DSP Digital Signal Processing
  • DSP Device digital signal processing devices
  • PLD programmable logic devices
  • FPGA field programmable gate array
  • general processors controllers, microcontrollers, microprocessors, other electronic units for performing the functions described in this application or a combination thereof.
  • the technology described in this application can be implemented by a module (such as a process, function, etc.) that performs the functions described in this 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.
  • the first processor 1903 is further configured to execute the method described in any one of the aforementioned embodiments when running the computer program.
  • FIG26 shows a schematic diagram of the structure of a decoder provided in an embodiment of the present application.
  • the decoder 200 may include: a second determining unit 2001; wherein,
  • the second determination unit 2001 is configured to determine a first template corresponding to the current block in at least one candidate template according to size information of the current block if the prediction mode corresponding to the current block is a preset prediction mode; wherein the preset prediction mode includes a template-based prediction mode; and determine a prediction value corresponding to the current block according to the first template.
  • a "unit" can be a part of a circuit, a part of a processor, a part of a program or software, etc., and of course it can also be a module, or it can be non-modular.
  • the components in this embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional module.
  • the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • this embodiment provides a computer-readable storage medium, which is applied to the decoder 200, and the computer-readable storage medium stores a computer program. When the computer program is executed by the second processor, the method described in any one of the above embodiments is implemented.
  • the decoder 200 may include: a second communication interface 2201, a second memory 2202 and a second processor 2203; each component is coupled together through a second bus system 2204. It can be understood that the second bus system 2204 is used to achieve connection and communication between these components.
  • the second bus system 2204 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 2204. Among them,
  • the second communication interface 2201 is used for receiving and sending signals during the process of sending and receiving information with other external network elements;
  • the second memory 2202 is used to store a computer program that can be run on the second processor 2203;
  • the second processor 2203 is used to perform the following processing when running the computer program: if the prediction mode corresponding to the current block is a preset prediction mode, determining a first template corresponding to the current block in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and determining a prediction value corresponding to the current block according to the first template.
  • the second processor 2203 is further configured to execute any one of the methods described in the foregoing embodiments when running the computer program.
  • the present embodiment provides a codec, if the prediction mode corresponding to the current block is a preset prediction mode, then the first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using the preset prediction mode of the template-based prediction mode
  • at least one candidate template can be selected to be determined according to the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain the first template used in the subsequent prediction process, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing through the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and improving codec performance.
  • FIG28 shows a schematic diagram of the composition structure of a coding and decoding system provided in an embodiment of the present application.
  • the coding and decoding system 230 may include an encoder 2301 and a decoder 2302 .
  • the encoder 2301 may be the encoder described in any one of the aforementioned embodiments
  • the decoder 2302 may be the decoder described in any one of the aforementioned embodiments.
  • an embodiment of the present application also provides a code stream, wherein the code stream is generated by bit encoding based on information to be encoded; wherein the information to be encoded includes at least one of the following: prediction mode identification information, first template indication information, second template indication information, and prediction difference.
  • the embodiment of the present application provides a coding and decoding method, a code stream, an encoder, a decoder and a storage medium. If the prediction mode corresponding to the current block is a preset prediction mode, a first template corresponding to the current block is determined in at least one candidate template according to the size information of the current block; wherein the preset prediction mode includes a template-based prediction mode; and the prediction value corresponding to the current block is determined according to the first template.
  • the current block is predicted using a preset prediction mode of a template-based prediction mode
  • at least one candidate template can be determined according to the size information of the current block
  • the use of candidate templates that do not meet the size information of the current block can be restricted to obtain a first template used in the subsequent prediction process, wherein the first template is obtained based on the size information of the current block, so that in the process of prediction processing through the template-based prediction mode, the first template can be applicable to the scene corresponding to the current block, thereby reducing unnecessary overhead or interference from unreasonable results, thereby improving compression efficiency and coding and decoding performance.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本申请实施例公开了一种编解码方法、码流、编码器、解码器以及存储介质,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。

Description

编解码方法、码流、编码器、解码器以及存储介质 技术领域
本申请实施例涉及视频编解码技术领域,尤其涉及一种编解码方法、码流、编码器、解码器以及存储介质。
背景技术
在一些图像信息的预测处理过程中,可以通过模板匹配的技术或者利用模板分析的技术来进行编码快的预测,其中,可以将涉及到模板的使用的预测技术统称为基于模板的预测技术。
相关技术中,基于模板的预测技术包括但不限于帧间的模板匹配,帧内块复制(Intra Block Copy,IBC)的模板匹配,帧内模板匹配预测(Intra Template Matching Prediction,Intra TMP),基于模板的帧内模式推导(Template based intra mode derivation,TIMD),帧内模式推导(Decoder-side Intra Mode Derivation,DIMD)等。
然而,在基于模板的预测技术的实际使用过程中,部分模板在一些场景中并不适用,例如宽和高差别较大,或某一边模板像素过少的情况,部分模板的使用会增加不必要的开销或增大不合理的结果的干扰。
发明内容
本申请实施例提供一种编解码方法、码流、编码器、解码器以及存储介质,可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。
本申请实施例的技术方案可以如下实现:
第一方面,本申请实施例提供了一种解码方法,应用于解码器,所述方法包括:
若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;
根据所述第一模板确定所述当前块对应的预测值。
第二方面,本申请实施例提供了一种编码方法,应用于编码器,所述方法包括:
若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;
根据所述第一模板确定所述当前块对应的预测值。
第三方面,本申请实施例提供了一种码流,其中,所述码流是根据待编码信息进行比特编码生成的;其中,待编码信息包括下述至少一项:
预测模式标识信息,第一模板指示信息,第二模板指示信息,预测差值。
第四方面,本申请实施例提供了一种编码器,包括第一确定单元;其中,
所述第一确定单元,配置为若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
第五方面,本申请实施例提供了一种编码器,包括第一存储器和第一处理器;其中,
所述第一存储器,用于存储能够在所述第一处理器上运行的计算机程序;
所述第一处理器,用于在运行所述计算机程序时,执行如第二方面所述的方法。
第六方面,本申请实施例提供了一种解码器,包括第二确定单元;其中,
所述第二确定单元,配置为若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
第七方面,本申请实施例提供了一种解码器,包括第二存储器和第二处理器;其中,
所述第二存储器,用于存储能够在所述第二处理器上运行的计算机程序;
所述第二处理器,用于在运行所述计算机程序时,执行如第一方面所述的方法。
第八方面,本申请实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被执行时实现如第一方面所述的方法、或者实现如第二方面所述的方法。
本申请实施例提供了一种编解码方法、码流、编码器、解码器以及存储介质,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。
附图说明
图1为视频编解码器的基本流程示意图;
图2为当前块与参考样本的位置关系示意图;
图3为帧内预测方法中使用4个参考行/列的示意图;
图4为H.264中对4x4的块进行帧内预测的9种模式示意图;
图5为HEVC使用的35种帧内预测模式示意图;
图6为VVC使用的67种帧内模式示意图;
图7为宽角度模式示意图;
图8为AVS3使用的66种预测模式示意图;
图9为屏幕内容示意图;
图10为帧间预测示意图;
图11为intra TMP示意图;
图12为MIP的示意图;
图13为TIMD的示意图;
图14为DIMD的示意图;
图15为不同的帧内预测模式的权重的示意图;
图16为模板类型的示意图一;
图17为编码器的组成框图示意图;
图18为编码器的组成框图示意图;
图19为编解码系统的网络架构示意图;
图20为本申请实施例提出的解码方法的流程示意图;
图21为模板类型的示意图二;
图22为候选模板的示意图;
图23为本申请实施例提出的编码方法的流程示意图;
图24为编码器的组成结构示意图;
图25为编码器硬件结构示意图;
图26为解码器的组成结构示意图;
图27为解码器硬件结构示意图;
图28为编解码系统的组成结构示意图。
具体实施方式
为了能够更加详尽地了解本申请实施例的特点与技术内容,下面结合附图对本申请实施例的实现进行详细阐述,所附附图仅供参考说明之用,并非用来限定本申请实施例。
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。还需要指出,本申请实施例所涉及的术语“第一\第二\第三”仅是用于区别类似的对象,不代表针对对象的特定排序,可以理解地,“第一\第二\第三”在允许的情况下可以互换特定的顺序或先后次序,以使这里描述的本申请实施例能够以除了在这里图示或描述的以外的顺序实施。
对本申请实施例进行进一步详细说明之前,先对本申请实施例中涉及的名词和术语进行说明,本申请实施例中涉及的名词和术语适用于如下的解释:
编码块(Coding Block,CB);
块匹配(Block Maching,BM);
编码单元(Coding Unit,CU);
块矢量(Block Vector,BV);
绝对误差和(Sum of Absolute Difference,SAD);
绝对变换差和(Sum of Absolute Transformed Difference,SATD);
均方误差(Mean Square Error,MSE);
误差平方和(Sum of Squared Differences,SSD);
平均绝对差(Mean Absolute Deviation,MAD);
平均误差平方和(Mean Square Differences,MSD);
归一化相关系数(Normalized Correlation Coefficient,NCC);
H.266/多功能视频编码(Versatile Video Coding,VVC);
VVC的参考软件测试平台(VVC Test Model,VTM);
帧内模板匹配预测(Intra Template Matching Prediction,Intra TMP);
Beyond VVC的参考软件测试平台(Enhanced Compression Model,ECM);
矩阵加权帧内预测(Matrix-based Intra Prediction,MIP);
基于模板的帧内模式推导(Template based intra mode derivation,TIMD);
帧内模式推导(Decoder-side Intra Mode Derivation,DIMD)。
可以理解,在视频图像中,一般采用第一颜色分量、第二颜色分量和第三颜色分量来表征编码块。其中,这三个颜色分量分别为一个亮度分量、一个蓝色色度分量和一个红色色度分量,具体地,亮度分量通常使用符号Y表示,蓝色色度分量通常使用符号Cb或者U表示,红色色度分量通常使用符号Cr或者V表示;这样,视频图像可以用YCbCr格式表示,也可以用YUV格式表示。
视频编解码标准大多采用基于块的混合编码框架。视频中的每一个图像或子图像或一帧(frame)被分割成相同大小(如128x128或64x64等)的正方形的最大编码单元(Largest Coding Unit,LCU)或编码树单元(Coding Tree Unit,CTU)。每个最大编码单元或编码树单元可根据规则划分成矩形的编码单元(Coding Unit,CU)。编码单元可能还会划分预测单元(Prediction Unit PU)和/或变换单元(Transform Unit,TU)等。混合编码框架包括预测(prediction)、变换(transform)、量化(quantization)、熵编码(entropy coding)和环路滤波(in loop filter)等模块。预测模块包括帧内预测(intra prediction)和帧间预测(inter prediction)。帧间预测包括运动估计(motion estimation)和运动补偿(motion compensation)。由于视频的一个帧中的相邻样本之间存在较强的相关性,在视频编解码技术中使用帧内预测的方法消除相邻样本之间的空间冗余。由于视频中的相邻帧之间存在较强的相似性,在视频编解码技术中使用帧间预测方法消除相邻帧之间的时间冗余,从而提高编解码效率。
视频编解码器的基本流程如图1所示。在编码端,将一帧图像101划分成块,对当前块使用帧内预测或帧间预测产生当前块的预测块,当前块的原始块减去预测块得到残差块,对残差块进行变换和量化得到量化系数矩阵,对量化系数矩阵进行熵编码输出到码流中。在解码端(图中未示出),对当前块使用帧内预测或帧间预测产生当前块的预测块,另一方面解析码流得到量化系数矩阵,对量化系数矩阵进行反量化、反变换得到残差块,将预测块和残差块相加得到重建块。重建块组成重建图像,基于图像或基于块对重建图像进行环路滤波得到解码图像。编码端同样需要和解码端类似的操作获得解码图像。在编码端,得到的解码图像可以为后续的帧作为帧间预测的参考图像。编码端确定的块划分信息,预测、变换、量化、熵编码和环路滤波等模式信息或者参数信息如果有必要需要在输出的码流中。解码端通过解析及根据已有信息进行分析确定与编码端相同的块划分信息,预测、变换、量化、熵编码和环路滤波等模式信息或者参数信息,从而保证编码端获得的解码图像和解码端获得的解码图像相同。编码端获得的解码图像通常也叫做重建图像。在预测时可以将当前块划分成预测单元,在变换时可以将当前块划分成变换单元,预测单元和变换单元的划分可以不同。
上述是基于块的混合编码框架下的视频编解码器的基本流程,随着技术的发展,该框架或流程的一些模块或步骤可能会被优化,本申请实施例提供的编解码方法适用于该基于块的混合编码框架下的视频编解码器的基本流程,但不限于该框架及流程。本领域普通技术人员可知,随着编码器、解码器的演变以及新业务场景的出现,本申请实施例提供的方法对于类似的技术问题,同样适用。
当前块(current block)可以是当前编码单元(CU)或当前预测单元(PU)等。
可以理解地,图像内部相邻的部分或相邻样本之间存在较强的空间相关性,帧内预测就是利用当前块周边已编解码的样本与当前块内部的样本的空间相关性进行预测的方法。举例来说,如图2所示,白色的4x4块是当前块,当前块左侧一列和上侧一行的灰色的样本为当前块的参考样本,帧内预测使用这些参考样本对当前块进行预测。这些参考样本可能已经全部可得,即全部已经编解码。也可能有部分不可得,比如当前块是整帧的最左边,那么当前块的左侧的参考样本不可得。或者编解码当前块时,当前块左下方的部分还没有编解码,那么左下方的参考样本也不可得。对于参考样本不可得的情况,可以使用可得的参考样本或某些值或某些方法进行填充,或者不进行填充。
多参考行的帧内预测方法(Multiple Reference Line,MRL)可以使用更多的参考样本,从而提高编码效率。如图3所示是使用4个参考行/列的例子。
帧内预测有多种预测模式,如图4所示是H.264中对4x4的块进行帧内预测的9种模式。其中模式0是将当前块上面的样本按竖直方向复制到当前块作为预测值,模式1是将左侧的参考样本按水平方向复制到当前块作为预测值,模式2(即DC模式)是将A~D和I~L这8个点的平均值作为所有点的预测值,模式3~8分别按某一个角度将参考样本复制到当前块的对应位置(因此模式3~8也称为角度预测模式),因为当前块某些位置不能正好对应到参考样本,可能需要使用参考样本的加权平均值,或者说是插值的参考样本的分样本(分像素)。
除此之外,还有Plane和Planar等模式,而随着技术的发展以及块的扩大,角度预测模式也越来越多。如图5所示,HEVC使用的帧内预测模式有Planar、DC和33种角度模式共35种预测模式。如图6所示,VVC使用的帧内模式有Planar、DC和65种角度模式共67种预测模式。当然,除了上述67种模式,VVC对一些长和宽差距较大的长方形的块还提供了宽角度模式,如图7中的虚线所指的模式即-14~-1和67~80两个区间,它们会替换掉一些常规的模式。如图8所示,AVS3使用DC、Plane、Bilinear、PCM和62种角度模式共66种预测模式。
视频由多个图像组成。为了使视频看起来流畅,每一秒钟的视频包含几十甚至上百帧的图像,如24帧每秒、30帧每秒、50帧每秒、60帧每秒或120帧每秒等。于是,视频中存在非常明显的时间冗余。或者换句话说,视频中存在较多的时间相关性。帧间预测利用这种时间相关性来提升压缩效率。帧间预测常用“运动”来利用时间相关性。一个非常简单的“运动”模型是,一个物体在某一时刻对应的图像上处于某一个位置,经过一定的时间,在这一时刻对应的图像上,它平移到了另外一个位置。这就是视频编解码中较基本也较常用的平移运动。帧间预测使用运动信息(motion information)来表示“运动”。基本的运动信息包含参考帧(reference frame)(或者称为参考图像(reference picture))的信息和运动矢量(Motion Vector,MV)的信息。编解码器根据参考图像的信息来确定参考图像,根据运动矢量的信息以及当前块的坐标来确定参考块的坐标。在参考图像中用参考块的坐标来确定参考块。把确定的参考块作为预测块是帧间预测最基本的预测方法。
视频中的运动并不都是如此简单的运动,即使是可以视为平移的运动,随着时间的变化也会有细微的变化,包括细微的形变、亮度的变化和噪声的变化等。对当前块可以使用不止一个参考块来预测,从而达到更好的预测效果。如双向预测,使用两个参考块对当前块进行预测。两个参考块可以使用一个前向的参考块和一个后向的参考块。也允许两个参考块都是前向的或都是后向的。所谓前向是指参考图像对应的时刻在当前帧之前,后向是指参考图像对应的时刻在当前帧之后。或者说前向是指参考图像在视频中的位置位于当前帧之前,后向是指参考图像在视频中的位置位于当前帧之后。 或者说,前向是指参考图像的POC(picture order count)小于当前帧的POC,后向是指参考图像的POC大于当前帧的POC。未来的视频编解码标准可能支持多个参考块的预测。利用两个参考块生成预测块的一种简单的方法是将两个参考块对应位置的像素值进行平均得到预测块。为了获得更好的预测效果,还可以使用加权平均,如VVC使用的BCW(Bi-prediction with CU-level weight)。VVC中的GPM(Geometric partitioning mode)也可以理解为一种特殊的双向预测。为了能使用双向预测,自然需要能找到两个参考块,那么就需要2组参考图像的信息和运动矢量的信息。
视频中的运动并非只有简单的平移,还有缩放、旋转和扭曲变形以及各种复杂的运动。VVC中使用仿射(affine)来模拟其中一些简单的运动。VVC中的仿射模型使用两个或三个控制点,根据这些控制点利用线性模型来推导出当前块中的每一个子块的运动矢量。这里之所以只说运动矢量而不是运动信息,因为它们都指向同一个参考图像。可以理解为普通的平移运动是从参考图像找到一个“整块”,而仿射是从参考图像找到一组不是一个挨一个的“子块”。上述都是单向预测的范畴,仿射也可以实现双向预测或更多“参考块”的预测。这里说的参考块是由子块组合成的。在具体实现时,仿射运动信息的数据结构中的一个单向运动信息可以包括一个参考图像的信息和二到三个运动矢量的信息。或二到三组参考图像的信息和运动矢量的信息,但是这些参考图像的信息是相同的。
帧内块复制(Intra Block Copy,IBC)能够明显提升屏幕内容编码(screen content coding)的压缩效率,因而IBC从HEVC到VVC都被用于屏幕内容编码。屏幕内容区别于相机采集的内容(camera captured content),它是由计算机生成的,屏幕内容没有噪声,包含文字和计算机图形等,边界清晰。屏幕内容中存在大量重复的内容,如图9所示,第一行的两个框内的内容是重复的,第三行框内的内容与第四行框内的内容是重复的。
上文提到,帧间预测把参考图像上的参考块作为当前块的预测块,参考图像不是当前图像。而IBC是从当前图像中已编解码的部分(称已重建部分)找一个块作为当前块的预测块。IBC也有的地方称为intra picture block compensation或current picture referencing(CPR)。本实施例中对IBC的名称不做限定,上述名称在未进行特殊说明之外,均可同等或替换。
IBC用块矢量(Block Vector,BV)来表示当前块和参考块之间的位置差别。编码器在搜索范围内通过块匹配的方法确定当前块的最佳的匹配块,并对BV进行编码,对BV的编码有多种方法,这里不再赘述。IBC可以认为是一种帧内预测方法,也可以认为是独立于帧内预测和帧间预测的另一类预测方法。
模板匹配(Template Matching,TM)的方法最早用在帧间预测中,该方法利用相邻样本之间的相关性,把当前块周边的一些区域作为模板。在当前块进行编解码时,按照编码顺序其左侧及上侧已经编解码完成。当然在硬件解码器实现时,不一定能保证当前块开始解码时,其左侧和上侧已经解码完成,当然这里说的是帧间块,比如在HEVC中帧间编码的块产生预测块时是不需要周边的重建样本的,因而帧间块的预测过程可以并行进行。但是帧内编码的块是需要左侧和上侧的重建样本作为参考样本的。理论上当前块的左侧和上侧是可得的,也就是说,硬件设计做相应的调整是可以实现的。相对来说,当前块的右侧和下侧在视频标准(如VVC)中的编码顺序下是不可得的。
如图10所示,把当前块1001的左侧和上侧的矩形区域设为模板(Template),左侧的模板部分的高度一般和当前块1001的高度相同,上侧的模板的部分的宽度一般和当前块1001的宽度相同,当然也可以不同。在当前帧1002的参考帧1003中寻找模板的最佳匹配位置从而确定当前块1001的运动信息或者说运动矢量。这个过程大致可以描述为,在某一个参考帧中,从一个起始位置开始,在周边一定范围内进行搜索。可以预先设定好搜索的规则,如搜索范围搜索步长等。每移动到一个位置,计算该位置对应的模板和当前块周边的模板的匹配程度,所谓匹配程度可以用一些失真代价来衡量,比如SAD(sum of absolute difference)、SATD(sum of absolute transformed difference)或MSE(mean-square error)等,SAD、SATD或MSE等的值越小代表匹配程度越高。其中,SATD使用的变换可以是Hadamard变换。用该位置对应的模板的预测块和当前块周边的模板的重建块计算代价。除了整像素位置的搜索还可以进行分像素位置的搜索,根据搜索到的匹配程度最高的位置来确定当前块的运动信息。利用相邻样本之间的相关性,对模板合适的运动信息可能也是当前块合适的运动信息。当然模板匹配的方法可能并不一定对所有的块都适用,因而可以使用一些方法确定当前块是否使用上述模板匹配的方法,比如在当前块用一个控制开关表示是否使用模板匹配的方法。模板匹配的技术例如DMVD(decoder side motion vector derivation)。编码器和解码器都可以利用模板进行搜索从而导出运动信息或者在原有的运动信息的基础上找到更好的运动信息。而它不需要传输具体的运动矢量或运动矢量差,而是由编码器和解码器都进行同样规则的搜索从而保证编码和解码的一致。模板匹配的方法可以提高压缩性能,但是它需要在解码器中也进行“搜索”,从而带来了一定的解码器复杂度。
帧内模板匹配预测(intra template matching prediction,intra TMP)也是一种预测技术。上面已经提到TM可以减少编码MV的开销,即TM可以减少编码BV的开销。一个例子是不需要编码BV,直接把TM找到的匹配块作为当前块的intra TMP模式的预测块。
一个intra TMP的例子如图11所示,当前块110左上角的倒L形区域111作为模板,在搜索范围内112进行搜索,搜索范围为已重建区域,图示112区域包括R1当前CTU、R2左上侧的CTU、R3上侧的CTU和R4为左侧CTU。这是一个例子,实际应用时搜索范围不一样。图11所示的示例在R2中找到了最佳匹配块113(Matching block)。
由前文介绍可知,IBC能够显著提升屏幕内容编码的压缩效率的一个重要原因是在屏幕内容中能够找到很多重复的块,而且屏幕内容通常有锐利的边界,从颜色(亮度和色度)上来说,会存在成片的区域为相同的颜色(亮度和色度)的情况。相机拍摄的内容也存在近似重复的块,即使考虑噪声和亮度的细微变化以及透视角度等原因的影响,不可否认的是重复的纹理在相机拍摄的内容中是存在的。
intra TMP会将模板匹配找到的最佳匹配块作为其最终确定的预测块。也就是说,在相关技术中,解码当前块时,会有一个flag确定当前块是否使用intra TMP。如果当前块使用intra TMP,解码器就会用模板匹配的方法找到一个最佳匹配块,将最佳匹配块的值作为当前块的预测值。可以知道模板虽然和当前块存在很强的相关性,但是模板毕竟不是当前块,用模板找到的最佳匹配块(实际上是模板的最佳匹配块对应的当前块的位置)未必一定是当前块的最佳匹配块。但是解码器在搜索的时候并没有当前块,因而只能将模板找到的最佳匹配块作为intra TMP找到的最佳匹配块。
为了进一步提高预测的准确性,可以选择采用intra TMP多候选方法。具体地,intra TMP也可以利用模板匹配来构建一个候选列表,相较于直接确定模板匹配找到的最佳匹配块,构建一个候选列表可以给编码器提供更多选择,在一些 情况下,特别是针对相机采集的内容,很难找到完美的匹配块。通过模板匹配从大量的可能的BV中筛选出少数的匹配度高的候选,再用编码器决策选择哪一个候选,这样有助于压缩效率的提高。
矩阵加权帧内预测MIP,也可以称为Matrix weighted Intra Prediction,是一种特殊的帧内预测模式。图12为MIP的示意图,如图12所示,为了对一个宽度为W高度为H的块进行预测,MIP需要将当前块左侧一列的H个重建样本和当前块上侧一行的W个重建样本作为输入。MIP按如下三个步骤生成预测块:参考样本平均(Averaging),矩阵乘法(Matrix Vector Multiplication)和插值(Interpolation)。其中,可以认为MIP的核心是矩阵乘法。也就是说,可以认为MIP是用一种矩阵乘法的方式用输入样本(参考样本)生成预测块的过程。
MIP提供了多种矩阵,预测方式的不同就体现在矩阵的不同上,相同的输入样本使用不同的矩阵会得到不同的结果。而参考样本平均和插值的过程是一种性能和复杂度折中的设计。对于尺寸较大的块,可以通过参考样本平均来实现一种近似于降采样的效果,使输入能适配到比较小的矩阵,而插值则实现一种上采样的效果。这样就不需要对每一种尺寸的块都提供MIP的矩阵,而是只提供一种或几种特定的尺寸的矩阵即可。
随着对压缩性能的需求的提高,以及硬件能力的提高,下一代的标准中也许会出现复杂度更高的MIP。
MIP有些类似于planar,但显然MIP比planar更复杂,灵活性也更强。
基于模板的帧内模式推导TIMD通过使用模板来分析筛选帧内预测模式,它没有用到帧间、IBC所使用的“搜索”空间上的MV或BV,而是从另一个层面“搜索”了帧内预测模式。所以它不需要涉及当前块周边的模板和模板的参考样本以外的重建样本。
图13为TIMD的示意图,如图13所示,对当前块,把它左侧和上侧的一个区域作为模板。除了边界情况,在编解码当前块时,当前块的左侧和上侧理论上是可以得到重建值的。这也是众多模板匹配方法的基础。TIMD把如图所示的模板(Template)区域作为模板,而图中Reference of the template就是模板的参考样本。解码器可以使用某一个帧内预测模式在模板上进行预测,并且将预测值和重建值进行比较,得到该帧内预测模式在模板上的代价。比如说SAD,SATD,SSE等。由于模板和当前块是相邻的,它们有相关性,所以可以用一个预测模式在模板上的表现来估计它在当前块上的表现。TIMD将一些候选的帧内预测模式在模板上进行预测,得到它们在模板上的代价,取代价最低的一个或两个帧内预测模式作为当前块的帧内预测值。
需要说明的是,如果两个帧内预测模式在模板上的代价差距不大,将两个帧内预测模式的预测值进行加权平均可以得到压缩性能的提升。两个预测模式的预测值的权重跟上述的代价有关,例如,可以设置权重跟代价成反比。
也就是说,TIMD利用帧内预测模式在模板上的预测效果来筛选帧内预测模式,而且可以将两个帧内预测模式根据模板上的代价进行加权。而两个帧内预测模式在后期的技术演进中也可能扩展到多个。TIMD的好处在于如果当前块选择了TIMD模式,那么它不需要再去指示具体使用了哪种帧内预测模式,而是由解码器自己通过上述流程导出,一定程度上节省了开销。
帧内模式推导DIMD也是利用当前块左侧和上侧的重建样本导出预测模式,但是它不是在模板上进行预测,而是分析重建样本的梯度。
图14为DIMD的示意图,如图14所示,DIMD分析深色点的梯度,根据它的梯度适配一种帧内预测模式,对所有需要检查的点分析可以得到一个类似于下面的直方图的结果。当然所谓直方图只是帮助理解,具体实现时可以用多种简单的形式实现。现在的DIMD选出直方图里最高的两帧内预测模式,再加上planar模式,共三个帧内预测模式的预测值进行加权,权重和分析的结果有关。
示例性的,图15为不同的帧内预测模式的权重的示意图,如图15所示,DIMD选出直方图里最高的两帧内预测模式,如M1和M2,再加上planar模式,这三种帧内预测模式对应的权重ω1、ω2、ω3可以参考深色点的分析解结果,最终可以通过对这三个帧内预测模式的预测值进行加权预测,获得预测值。
也就是说,DIMD利用重建样本的梯度分析来筛选帧内预测模式,而且可以将两个帧内预测模式再加上planar根据分析结果进行加权。DIMD的好处在于如果当前块选择了DIMD模式,那么它不需要再去指示具体使用了哪种帧内预测模式,而是由解码器自己通过上述流程导出,一定程度上节省了开销。而两个帧内预测模式在后期的技术演进中也可能扩展到多个。
TIMD和DIMD有很多相似之处,甚至在以前的文献中,它们的名称有些都是颠倒的。它们都支持两个或更多帧内预测模式的预测值进行加权。另一方面,DIMD虽然没有在模板上做预测,但它也使用了模板的区域,后面为了描述上的方便,可以把DIMD也归为基于模板的预测技术。
在进行intra TMP时,图16为模板类型的示意图一,如图16所示,目前ECM中的intra TMP使用的模板是包含左侧相邻重建样本和上侧相邻重建样本以及左上侧相邻重建样本的倒L型模板,在某些其他使用模板匹配的技术中,也有的模板不使用左上侧相邻的样本。
除了完整的模板,也可以把其中一部分区域当成模板来使用,如图16所示的上侧模板和左侧模板。这里为了表述方便,把完整的模板(倒L或T+L)统称为TL模板,把上侧模板成为T模板,把左侧模板成为L模板。多种不同的模板可以提供更多的选择。可以利用模板匹配是利用模板来估计当前块,假设模板匹配度高的块在当前块的匹配度也高。但是视频内容多种多样,特别是相机采集的图像。假设纹理在当前块的左边缘附近左右两边发生了变化,那么只用T模板可能比TL模板更合适。类似地,假设纹理在当前块的上边缘附近上下两边发生了变化,那么只用L模板可能比TL模板更合适。由此可见,利用模板分析的技术等也可以利用多种不同的模板提供更多的选择。
当然模板中也可以加入右上侧的重建样本,左下侧的重建样本等。例如T模板除了图中所示的部分又向右延申了一定距离,L模板除了图中所示的部分又向下延申了一定距离。或者说除了T模板和L模板,又增加一个右上侧模板,左下侧模板等。
需要说明的是,可以选择把模板匹配的技术,利用模板分析的技术等需要使用模板的技术统称为基于模板的预测技术。基于模板的预测技术包括但不限于帧间的模板匹配(帧间模板匹配预测),IBC的模板匹配,intra TMP,TIMD,DIMD等。
例如,intra TMP可以分别利用TL模板,T模板,L模板进行模板匹配确定BV。帧间的模板匹配技术可以分别利用 TL模板,T模板,L模板进行模板匹配确定MV。TIMD可以分别利用TL模板,T模板,L模板导出帧内预测模式,DIMD可以分别利用TL模板,T模板,L模板导出帧内预测模式。
可以理解的是,对于常见的基于模板的预测技术,部分模板并不是适用于任何场景的,例如,T模板和L模板可以提供更多的选择,但并不是所有情况都适用。考虑宽和高差别较大的情况,或某一边模板像素过少的情况,可以限制T模板和或L模板的使用,从而可以减少不必要的开销或减少不合理的结果的干扰。
本申请实施例提供了一种编解码方法、码流、编码器、解码器以及存储介质,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。
下面将结合附图对本申请各实施例进行详细说明。
参见图17,其示出了本申请实施例提供的一种编码器的组成框图示意图。如图17所示,编码器(具体为“视频编码器”)100可以包括变换与量化单元101、帧内估计单元102、帧内预测单元103、运动补偿单元104、运动估计单元105、反变换与反量化单元106、滤波器控制分析单元107、滤波单元108、编码单元109和解码图像缓存单元110等,其中,滤波单元108可以实现去方块滤波及样本自适应缩进(Sample Adaptive 0ffset,SAO)滤波,编码单元109可以实现头信息编码及基于上下文的自适应二进制算术编码(Context-based Adaptive Binary Arithmetic Coding,CABAC)。针对输入的原始视频信号,通过编码树单元(Coding Tree Unit,CTU)的划分可以得到一个视频编码块,然后对经过帧内或帧间预测后得到的残差像素信息通过变换与量化单元101对该视频编码块进行变换,包括将残差信息从像素域变换到变换域,并对所得的变换系数进行量化,用以进一步减少比特率;帧内估计单元102和帧内预测单元103是用于对该视频编码块进行帧内预测;明确地说,帧内估计单元102和帧内预测单元103用于确定待用以编码该视频编码块的帧内预测模式;运动补偿单元104和运动估计单元105用于执行所接收的视频编码块相对于一或多个参考帧中的一或多个块的帧间预测编码以提供时间预测信息;由运动估计单元105执行的运动估计为产生运动向量的过程,所述运动向量可以估计该视频编码块的运动,然后由运动补偿单元104基于由运动估计单元105所确定的运动向量执行运动补偿;在确定帧内预测模式之后,帧内预测单元103还用于将所选择的帧内预测数据提供到编码单元109,而且运动估计单元105将所计算确定的运动向量数据也发送到编码单元109;此外,反变换与反量化单元106是用于该视频编码块的重构建,在像素域中重构建残差块,该重构建残差块通过滤波器控制分析单元107和滤波单元108去除方块效应伪影,然后将该重构残差块添加到解码图像缓存单元110的帧中的一个预测性块,用以产生经重构建的视频编码块;编码单元109是用于编码各种编码参数及量化后的变换系数,在基于CABAC的编码算法中,上下文内容可基于相邻编码块,可用于编码指示所确定的帧内预测模式的信息,输出该视频信号的码流;而解码图像缓存单元110是用于存放重构建的视频编码块,用于预测参考。随着视频图像编码的进行,会不断生成新的重构建的视频编码块,这些重构建的视频编码块都会被存放在解码图像缓存单元110中。
参见图18,其示出了本申请实施例提供的一种解码器的组成框图示意图。如图18所示,解码器(具体为“视频解码器”)200包括解码单元201、反变换与反量化单元202、帧内预测单元203、运动补偿单元204、滤波单元205和解码图像缓存单元206等,其中,解码单元201可以实现头信息解码以及CABAC解码,滤波单元205可以实现去方块滤波以及SAO滤波。输入的视频信号经过图15的编码处理之后,输出该视频信号的码流;该码流输入解码器200中,首先经过解码单元201,用于得到解码后的变换系数;针对该变换系数通过反变换与反量化单元202进行处理,以便在像素域中产生残差块;帧内预测单元203可用于基于所确定的帧内预测模式和来自当前帧或图片的先前经解码块的数据而产生当前视频解码块的预测数据;运动补偿单元204是通过剖析运动向量和其他关联语法元素来确定用于视频解码块的预测信息,并使用该预测信息以产生正被解码的视频解码块的预测性块;通过对来自反变换与反量化单元202的残差块与由帧内预测单元203或运动补偿单元204产生的对应预测性块进行求和,而形成解码的视频块;该解码的视频信号通过滤波单元205以便去除方块效应伪影,可以改善视频质量;然后将经解码的视频块存储于解码图像缓存单元206中,解码图像缓存单元206存储用于后续帧内预测或运动补偿的参考图像,同时也用于视频信号的输出,即得到了所恢复的原始视频信号。
进一步地,本申请实施例还提供了一种包含编码器和解码器的编解码系统的网络架构,其中,图19示出了本申请实施例提供的一种编解码系统的网络架构示意图。如图19所示,该网络架构包括一个或多个电子设备13至1N和通信网络01,其中,电子设备13至1N可以通过通信网络01进行视频交互。电子设备在实施的过程中可以为各种类型的具有视频编解码功能的设备,例如,所述电子设备可以包括智能手机、平板电脑、个人计算机、个人数字助理、导航仪、数字电话、视频电话、电视机、传感设备、服务器等,本申请实施例不作具体限定。在这里,本申请实施例所述的解码器或编码器就可以为上述电子设备。
需要说明的是,本申请实施例的方法主要应用在如图17所示的帧内预测单元103部分和如图18所示的帧内预测单元203部分。也就是说,本申请实施例既可以应用于编码器,也可以应用于解码器,甚至还可以同时应用于编码器和解码器,但是本申请实施例不作具体限定。
还需要说明的是,当应用于帧内预测单元103部分时,“当前块”具体是指当前待进行帧内预测的编码块;当应用于帧内预测单元203部分时,“当前块”具体是指当前待进行帧内预测的解码块。
本申请的一实施例提出了一种解码方法,该解码方法应用于解码器,图20为本申请实施例提出的解码方法的流程示意图,如图20所示,解码器进行解码处理的方法可以包括以下步骤:
步骤101、若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式。
在本申请的实施例中,可以先确定当前块对应的第一模板,其中,如果当前块对应的预测模式为预设预测模式,那 么可以根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板。
需要说明的是,本申请实施例的解码方法应用于解码器。另外,该解码方法可以包括一种帧内预测方法,更具体地,是一种颜色分量预测方法。其中,视频图像可以划分为多个解码块,每个解码块可以包括第一颜色分量、第二颜色分量和第三颜色分量,而本申请实施例中的当前块是指视频图像中当前待进行帧内预测的解码块。
在这里,当需要对第一颜色分量进行预测时,待预测分量为第一颜色分量;当需要对第二颜色分量进行预测时,待预测分量为第二颜色分量;当需要对第三颜色分量进行预测时,待预测分量为第三颜色分量。另外,假定当前块进行第一颜色分量的预测,而且第一颜色分量为亮度分量,即待预测分量为亮度分量,那么当前块也可以称为亮度块;或者,假定当前块进行第二颜色分量的预测,而且第二颜色分量为色度分量,即待预测分量为色度分量,那么当前块也可以称为色度块。
需要说明的是,在本申请的实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的候选模板。其中,当前块对应的候选模板中包括多种不同模板类型的候选模板。
可以理解的是,在本申请的实施例中,可以先基于不同的模板类型,构建当前块对应的模板集合,进而可以在该模板集合中的候选模板中确定当前块对应的第一模板。
示例性的,在本申请的实施例中,图21为模板类型的示意图二,如图21所示,当左上侧参考样本、上侧参考样本和左侧参考样本均可用时,模板形状如(a)所示;当只有左侧参考样本可用时,模板形状如(b)所示;当只有上侧参考样本可用时,模板形状如(c)所示;当只有左侧参考样本和左上侧参考样本可用时,模板形状如(d)所示;当只有左侧参考样本和左下侧参考样本可用,模板形状如(e)所示;当只有上侧参考样本和右上侧参考样本可用时,模板形状如(f)所示。
进一步地,在本申请的实施例中,在根据模板类型构建当前块对应的模板集合时,可以先根据模板类型,以及模板类型对应的模板尺寸,确定当前块的模板参考样本,然后可以根据模板参考样本确定当前块的候选模板,最终完成模板集合的构建。
需要说明的是,在本申请的实施例中,模板集合中的第一候选模板可以为包括当前块的左侧相邻重建样本和上侧相邻重建样本的模板,例如TL模板;模板集合中的第二候选模板可以为包括当前块的上侧相邻重建样本的模板,例如T模板;模板集合中的第三候选模板可以为包括当前块的左侧相邻重建样本的模板,例如L模板。
也就是说,在本申请的实施例中,当前块对应的至少一个候选模板可以包括TL模板,T模板,L模板。
示例性的,在本申请的实施例中,图22为候选模板的示意图,如图22所示,对应于4种不同的模板类型,最终生成的当前块的候选模板也可以包括4种,如候选模板1(TL模板)、候选模板2(TL模板)、候选模板3(T模板)以及候选模板4(L模板)。
示例性的,在一些实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的第一候选模板,如候选模板1。
示例性的,在一些实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的第二候选模板,如候选模板3。
示例性的,在一些实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的第三候选模板,如候选模板4。
进一步地,在本申请的实施例中,预设预测模式可以包括基于模板的预测模式。也就是说,在本申请中,可以将预测处理过程中涉及到模板的使用的预测方式统一确定为预设预测模式。
示例性的,在一些实施例中,预设预测模式可以包括帧内模板匹配预测,帧内块复制,帧间模板匹配预测,基于模板的帧内模式推导,帧内模式推导等基于模板的预测模式中的任意一种。
可以理解的是,在本申请的实施例中,帧内模板匹配预测intraTMP可以将模板匹配找到的最佳匹配块作为其最终确定的预测块,即intraTMP可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,帧内块复制IBC的模板匹配可以在搜索范围内通过模板匹配的方法确定当前块的最佳的匹配块,即IBC的模板匹配可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,帧间模板匹配预测可以在参考帧内通过模板匹配的方法确定当前块的最佳的匹配块,即帧间模板匹配预测可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,基于模板的帧内模式推导TIMD将一些候选的帧内预测模式在模板上进行预测,取代价最低的一个或两个帧内预测模式作为当前块的帧内预测值,即TIMD可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,帧内模式推导DIMD与TIMD处理过程类似,DIMD虽然没有在模板上做预测,但它也使用了模板的区域,因此DIMD可以为基于模板的预测模式,进而可以作为预设预测模式。
可以理解的是,在本申请的实施例中,除了帧内模板匹配预测,帧内块复制,帧间模板匹配预测,基于模板的帧内模式推导,帧内模式推导以外,其他基于模板的预测模式均可以作为预设预测模式。本申请不进行具体限定。
可以理解的是,在本申请的实施例中,如果确定当前块对应的预测模式为预设预测模式,那么便可以使用当前块的尺寸信息来对候选模板进行选择和限制。具体地,可以根据当前块对应的尺寸信息在至少一个候选模板中确定出当前块对应的第一模板。
需要说明的是,在本申请的实施例中,第一模板为当前块基于预设预测模式进行预测处理时所使用的模板。
需要说明的是,在本申请的实施例中,当前块对应的尺寸信息可以包括与当前块对应的高度和/或宽度相关的信息。
示例性的,在一些实施例中,当前块对应的尺寸信息可以为当前块的高度值和宽度值,其中,当前块的高度值和宽度值可以为当前块的高度和宽度的绝对值。
进一步地,在本申请的实施例中,解码码流,可以确定当前块对应的预测模式标识信息;若预测模式标识信息的取值为第一值,那么可以确定当前块对应的预测模式为预设预测模式;若预测模式标识信息的取值为第二值,那么可以确定当前块对应的预测模式不为预设预测模式。
可以理解的是,在本申请的实施例中,预测模式标识信息可以用来确定当前块是否使用基于模板的预测模式,即确定当前块的预测模式是否为预设预测模式,进而通过预测模式标识信息可以确定当前块是否使用预设预测模式来进行预测处理。
示例性的,在一些实施例中,解码码流,可以确定作为预测模式标识信息的一个变量,从而可以通过该变量的取值来实现预测模式标识信息的确定。
需要说明的是,在本申请中,预测模式标识信息的取值可以为第一值或第二值。其中,预测模式标识信息的取值不同,确定当前块的预测值的方式也不同。具体地,基于预测模式标识信息的取值,在确定当前块的预测值时,可以选择使用预设预测模式,或者选择不使用预设预测模式。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以将预测模式标识信息理解为一个表明是否进行intra TMP的标志位。其中,如果预测模式标识信息的取值为第一值,那么可以选择使用intra TMP确定当前块的预测值;如果预测模式标识信息的取值为第二值,那么可以选择不使用intra TMP确定当前块的预测值。
示例性的,在一些实施例中,可以设置第一值为1,第二值为0;也可以设置第一值为true,第二值为false。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_flag来表示预测模式标识信息,即使用intra_tmp_flag为intra TMP的flag。
示例性的,在一些实施例中,如果intra_tmp_flag的取值为1,那么可以表示选择使用intra TMP确定当前块的预测值;如果intra_tmp_flag的取值为0,那么可以表示不选择使用intra TMP确定当前块的预测值。
可以理解的是,在本申请的实施例中,在预测模式标识信息的取值为第一值,即确定在基于预测模式标识信息的取值确定使用预设预测模式确定当前块的预测值之后,便可以进一步根据当前块对应的尺寸信息在至少一个候选模板中确定当前块对应的第一模板。
进一步地,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,解码码流,确定当前块对应的第一模板指示信息;若第一模板指示信息的取值为第三值,那么可以确定第一模板为第一候选模板。
需要说明的是,在本申请的实施例中,第一候选模板可以为当前块对应的至少一个候选模板中的一个候选模板。例如,第一候选模板可以为至少一个候选模板中的TL模板。
可以理解的是,在本申请的实施例中,第一模板指示信息可以用来确定当前块是否使用第一候选模板,即第一模板指示信息可以指示当前块是否利用第一候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,解码码流,可以确定作为第一模板指示信息的一个变量,从而可以通过该变量的取值来实现第一模板指示信息的确定。
需要说明的是,在本申请中,第一模板指示信息的取值可以为第三值或第四值。具体地,基于第一模板指示信息的取值,在进行预设预测模式时可以选择使用第一候选模板,也可以选择不使用第一候选模板,而使用其他模板,例如至少一个候选模板中的、第一候选模板以外的其他模板。
示例性的,在一些实施例中,可以设置第三值为0,第四值为1;也可以设置第三值为false,第四值为true。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_alternative_template_flag来表示第一模板指示信息。例如,如果intra_tmp_alternative_template_flag的取值为0,那么可以表示将第一候选模板确定为当前块对应的第一模板;如果intra_tmp_alternative_template_flag的取值为1,那么可以表示不将第一候选模板确定为当前块对应的第一模板,而是继续选择其他模板作为当前块对应的第一模板。
相应的,在本申请的实施例中,在确定当前块对应的第一模板指示信息之后,如果第一模板指示信息的取值为第四值,那么可以确定第一模板并不是第一候选模板,此时,如果当前块的尺寸信息满足预设尺寸条件,那么需要进一步确定当前块对应的第二模板指示信息,从而根据第二模板指示信息确定第一模板。
也就是说,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果第一模板指示信息的取值为第四值,且当前块的尺寸信息满足预设尺寸条件,那么需要进一步解码码流,确定当前块对应的第二模板指示信息,并根据第二模板指示信息确定第一模板。
可以理解的是,在本申请的实施例中,如果根据第一模板指示信息确定不使用第一候选模板,那么需要进一步根据当前块对应的尺寸信息来确定是否使用第一候选模板以外的其他候选模板。具体地,如果当前块对应的尺寸信息满足预设尺寸条件,那么便确定可以使用第一候选模板以外的其他候选模板,进而可以继续进行第二模板指示信息的确定,以根据第二模板指示信息确定第一模板。
需要说明的是,在本申请的实施例中,预设尺寸条件可以用于基于当前块的尺寸对候选模板的使用进行限制。
进一步地,在本申请的实施例中,在根据第二模板指示信息确定第一模板时,若第二模板指示信息的取值为第五值,那么可以确定第一模板为第二候选模板;若第二模板指示信息的取值为第六值,那么可以确定第一模板为第三候选模板。
需要说明的是,在本申请的实施例中,第二候选模板和第三候选模板可以分别为当前块对应的至少一个候选模板中的一个候选模板。例如,第二候选模板可以为至少一个候选模板中的T模板,第三候选模板可以为至少一个候选模板中的L模板。
可以理解的是,在本申请的实施例中,第二模板指示信息可以用来确定当前块是否使用第二候选模板和/或第三候选模板,即第二模板指示信息可以指示当前块是否利用第二候选模板和/或第三候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,解码码流,可以确定作为第二模板指示信息的一个变量,从而可以通过该变量的取值来实现第二模板指示信息的确定。
需要说明的是,在本申请中,第二模板指示信息的取值可以为第五值或第六值。具体地,基于第二模板指示信息的取值,在进行预设预测模式时可以选择使用第二候选模板,也可以选择使用第三候选模板。
示例性的,在一些实施例中,可以设置第五值为0,第六值为1;也可以设置第五值为false,第六值为true。本申请 不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_template_idx来表示第二模板指示信息。例如,如果intra_tmp_template_idx的取值为0,那么可以表示将第二候选模板确定为当前块对应的第一模板;如果intra_tmp_template_idx的取值为1,那么可以表示将第三候选模板确定为当前块对应的第一模板。
进一步地,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果第一模板指示信息的取值为第四值,且当前块的尺寸信息不满足预设尺寸条件,那么可以选择跳过对第二模板指示信息的确定,而是直接根据当前块的尺寸信息确定当前块的最长边,然后再根据当前块的最长边在至少一个候选模板中确定第一模板。
可以理解的是,在本申请的实施例中,如果根据第一模板指示信息确定不使用第一候选模板,那么需要进一步根据当前块对应的尺寸信息来确定是否使用第一候选模板以外的其他候选模板。具体地,如果当前块对应的尺寸信息不满足预设尺寸条件,那么此时不需要再根据第二模板指示信息确定第一模板,而是可以直接按照当前块的最长边对第一模板进行指示。
可以理解的是,在本申请的实施例中,如果当前块的宽度值大于当前块的高度值,那么可以将宽度对应的一边确定为当前块的最长边;如果当前块的高度值大于当前块的宽度值,那么可以将宽度对应的一边确定为当前块的最长边。
也就是说,在本申请的实施例中,当前块的最长边为高度height对应的一边,也可以理解为当前块的高度大于宽度;当前块的最长边为宽度width对应的一边,也可以理解为当前块的宽度大于高度。
相应的,在本申请的实施例中,在第一模板指示信息的取值为第四值,且当前块的尺寸信息不满足预设尺寸条件的情况下,如果当前块的宽度值大于当前块的高度值,即当前块的最长边为宽度width对应的一边,那么可以认为当前块的左相邻区域包含比上相邻区域更多的相邻样本,因此可以将包含较多左相邻样本的L模板作为第一模板,即将包括当前块的左侧相邻重建样本的第三候选模板(L模板)确定为第一模板。
相应的,在本申请的实施例中,在第一模板指示信息的取值为第四值,且当前块的尺寸信息不满足预设尺寸条件的情况下,如果当前块的高度值大于当前块的宽度值,即当前块的最长边为高度height对应的一边,那么可以认为当前块的上相邻区域包含比左相邻区域更多的相邻样本,因此可以将包含较多上相邻样本的T模板作为第一模板,即将包括当前块的上侧相邻重建样本的第二候选模板(T模板)确定为第一模板。
示例性的,在一些实施例中,假设当前块的高度height为4,宽度width为1,那么可以确定当前块的最长边为高度height对应的一边,因此可以将该最长边对应的L模板作为第一模板。
示例性的,在一些实施例中,假设当前块的高度height为1,宽度width为8,那么可以确定当前块的最长边为宽度width对应的一边,因此可以将该最长边对应的T模板作为第一模板。
进一步地,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果当前块的尺寸信息满足预设尺寸条件,那么可以解码码流,确定当前块对应的第一模板指示信息;若第一模板指示信息的取值为第三值,那么可以确定第一模板为第一候选模板。
需要说明的是,在本申请的实施例中,第一候选模板可以为当前块对应的至少一个候选模板中的一个候选模板。例如,第一候选模板可以为至少一个候选模板中的TL模板。
也就是说,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,可以先根据当前块对应的尺寸信息来确定是否使用第一候选模板。具体地,如果当前块对应的尺寸信息满足预设尺寸条件,那么便确定可以使用第一候选模板,进而可以继续进行第一模板指示信息的确定。
需要说明的是,在本申请的实施例中,预设尺寸条件可以用于基于当前块的尺寸对候选模板的使用进行限制。
相应的,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果当前块的尺寸信息不满足预设尺寸条件,那么此时不需要再根据第一模板指示信息确定第一模板,而是可以直接对第一模板进行指示。例如,可以将第一候选模板确定为第一模板。
可以理解的是,在本申请的实施例中,第一模板指示信息可以用来确定当前块是否使用第一候选模板,即第一模板指示信息可以指示当前块是否利用第一候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,解码码流,可以确定作为第一模板指示信息的一个变量,从而可以通过该变量的取值来实现第一模板指示信息的确定。
需要说明的是,在本申请中,第一模板指示信息的取值可以为第三值或第四值。具体地,基于第一模板指示信息的取值,在进行预设预测模式时可以选择使用第一候选模板,也可以选择不使用第一候选模板,而使用其他模板,例如至少一个候选模板中的、第一候选模板以外的其他模板。
示例性的,在一些实施例中,可以设置第三值为0,第四值为1;也可以设置第三值为false,第四值为true。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_alternative_template_flag来表示第一模板指示信息。例如,如果intra_tmp_alternative_template_flag的取值为0,那么可以表示将第一候选模板确定为当前块对应的第一模板;如果intra_tmp_alternative_template_flag的取值为1,那么可以表示不将第一候选模板确定为当前块对应的第一模板,而是继续选择其他模板作为当前块对应的第一模板。
相应的,在本申请的实施例中,在确定当前块对应的第一模板指示信息之后,如果第一模板指示信息的取值为第四值,那么可以确定第一模板并不是第一候选模板,此时,需要进一步解码码流,确定当前块对应的第二模板指示信息,从而根据第二模板指示信息确定第一模板。
进一步地,在本申请的实施例中,在根据第二模板指示信息确定第一模板时,若第二模板指示信息的取值为第五值,那么可以确定第一模板为第二候选模板;若第二模板指示信息的取值为第六值,那么可以确定第一模板为第三候选模板。
需要说明的是,在本申请的实施例中,第二候选模板和第三候选模板可以分别为当前块对应的至少一个候选模板中的一个候选模板。例如,第二候选模板可以为至少一个候选模板中的T模板,第三候选模板可以为至少一个候选模板中的L模板。
可以理解的是,在本申请的实施例中,第二模板指示信息可以用来确定当前块是否使用第二候选模板和/或第三候选模板,即第二模板指示信息可以指示当前块是否利用第二候选模板和/或第三候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,解码码流,可以确定作为第二模板指示信息的一个变量,从而可以通过该变量的取值来实现第二模板指示信息的确定。
需要说明的是,在本申请中,第二模板指示信息的取值可以为第五值或第六值。具体地,基于第二模板指示信息的取值,在进行预设预测模式时可以选择使用第二候选模板,也可以选择使用第三候选模板。
示例性的,在一些实施例中,可以设置第五值为0,第六值为1;也可以设置第五值为false,第六值为true。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_template_idx来表示第二模板指示信息。例如,如果intra_tmp_template_idx的取值为0,那么可以表示将第二候选模板确定为当前块对应的第一模板;如果intra_tmp_template_idx的取值为1,那么可以表示将第三候选模板确定为当前块对应的第一模板。
也就是说,在本申请的实施例中,可以选择在码流中指示当前块对应的第一模板为至少一个候选模板中的哪一个候选模板。例如,使用第一模板指示信息和/或第二模板指示信息来对第一模板进行指示。而在第一模板的确定过程中,需要使用当前块对应的尺寸信息对候选模板进行限制。
可以理解的是,在本申请的实施例中,基于预设尺寸条件,可以根据当前块的尺寸对候选模板的使用进行限制。具体地,当当前块对应的尺寸信息所包括的含义不同时,对应的预设尺寸条件也可以是不同的。
进一步地,在本申请的实施例中,如果尺寸信息包括当前块的高度值和宽度值;相应的,预设尺寸条件包括:宽度值小于高度值的第一数值倍且高度值小于宽度值的第二数值倍。
可以理解的是,在本申请的实施例中,第一数值倍和第二数值倍可以用于对当前块的宽度和高度之间的比例进行限制。
需要说明的是,在本申请的实施例中,第一数值倍和第二数值倍可以为大于0的任意数值,其中,第一数值倍和第二数值倍可以相同,也可以不同,本申请不进行具体限定。
示例性的,在本申请的实施例中,第一数值倍可以为4,第二数值倍可以为8。
示例性的,在本申请的实施例中,第一数值倍和第二数值倍可以均为4。
可以理解的是,在本申请的实施例中,在确定当前块的尺寸信息是否满足预设尺寸条件时,如果当前块的宽度值小于高度值的第一数值倍且当前块的高度值小于宽度值的第二数值倍,那么可以确定当前块的尺寸信息满足预设尺寸条件。相应的,如果当前块的宽度值大于或者等于高度值的第一数值倍,或者,当前块的高度值大于或者等于宽度值的第二数值倍,那么可以确定当前块的尺寸信息不满足预设尺寸条件。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以解码码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1且当前块同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值满足width<height×4且height<width×4的条件,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的高度值和宽度值不同时满足width<height×4且height<width×4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以解码码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块是否同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值是否满足width<height×4且height<width×4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
进一步地,在本申请的实施例中,如果尺寸信息包括当前块的高度值和宽度值;相应的,预设尺寸条件包括:高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值。
可以理解的是,在本申请的实施例中,第一尺寸阈值可以用于对当前块的高度值(高度的绝对值)进行限制;相应的,第二尺寸阈值可以用于对当前块的宽度值(宽度的绝对值)进行限制。
需要说明的是,在本申请的实施例中,第一尺寸阈值和第二尺寸阈值可以为大于0的任意数值,其中,第一尺寸阈值和第二尺寸阈值可以相同,也可以不同,本申请不进行具体限定。
示例性的,在本申请的实施例中,第一尺寸阈值可以为8,第二尺寸阈值可以为4。
示例性的,在本申请的实施例中,第一尺寸阈值和第二尺寸阈值可以均为8。
可以理解的是,在本申请的实施例中,在确定当前块的尺寸信息是否满足预设尺寸条件时,如果当前块的高度值大于第一尺寸阈值且当前块的宽度值大于第二尺寸阈值,那么可以确定当前块的尺寸信息满足预设尺寸条件。相应的,如果当前块的高度值小于或者等于第一尺寸阈值,或者,当前块的宽度值小于或者等于第二尺寸阈值,那么可以确定当前块的尺寸信息不满足预设尺寸条件。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以解码码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1且当前块的宽度值和高度值同时满足width>4且height>4的条件,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的宽度值和高度值不满足width>4且height>4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以解码码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块的宽度值和高度值是否满足width>4且height>4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
进一步地,在本申请的实施例中,如果尺寸信息包括当前块的高度值和宽度值;相应的,预设尺寸条件包括:宽度值小于高度值的第一数值倍且高度值小于宽度值的第二数值倍,且高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值。
可以理解的是,在本申请的实施例中,第一数值倍和第二数值倍可以用于对当前块的宽度和高度之间的比例进行限 制;第一尺寸阈值可以用于对当前块的高度值(高度的绝对值)进行限制;第二尺寸阈值可以用于对当前块的宽度值(宽度的绝对值)进行限制。
需要说明的是,在本申请的实施例中,第一数值倍和第二数值倍可以为大于0的任意数值,其中,第一数值倍和第二数值倍可以相同,也可以不同,本申请不进行具体限定。
需要说明的是,在本申请的实施例中,第一尺寸阈值和第二尺寸阈值可以为大于0的任意数值,其中,第一尺寸阈值和第二尺寸阈值可以相同,也可以不同,本申请不进行具体限定。
示例性的,在本申请的实施例中,第一数值倍和第二数值倍可以均为4,第一尺寸阈值和第二尺寸阈值可以均为8。
可以理解的是,在本申请的实施例中,在确定当前块的尺寸信息是否满足预设尺寸条件时,如果当前块的宽度值小于高度值的第一数值倍且当前块的高度值小于宽度值的第二数值倍,同时,当前块的高度值大于第一尺寸阈值且当前块的宽度值大于第二尺寸阈值,那么可以确定当前块的尺寸信息满足预设尺寸条件。相应的,如果当前块的宽度值大于或者等于高度值的第一数值倍,或者,当前块的高度值大于或者等于宽度值的第二数值倍,或者,当前块的高度值小于或者等于第一尺寸阈值,或者,当前块的宽度值小于或者等于第二尺寸阈值,那么可以确定当前块的尺寸信息不满足预设尺寸条件。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,同时,高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4&&width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以解码码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,且当前块同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值满足width<height×4且height<width×4,以及当前块的高度值和宽度值比同时满足且width>4且height>4的条件,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的高度值和宽度值不同时满足width<height×4且height<width×4且width>4且height>4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,同时,高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4&&width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以解码码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块是否同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值是否满足width<height×4且height<width×4,以及当前块的高度值和宽度值是否同时满足width>4且height>4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
可以理解的是,在本申请的实施例中,上述的示例为使用显式的方式来选择不同的候选模板,也就是说,要将选择不同模板的信息写进码流,通过当前块的尺寸信息对候选模板进行限制的方法可以减少不必要的开销。
进一步地,在本申请的实施例中,一些基于模板的预测技术,如TIMD,DIMD等,可以分别根据TL模板,T模板,L模板各导出一种帧内预测模式,为了不增加额外的开销,可以根据阈值条件分析来进行不同的处理。
可以理解的是,在本申请的实施例中,DIMD利用当前块周边已重建样本的梯度构建一个帧内预测模式的直方图,选出直方图里最高的两个帧内预测模式记为mode0和mode1,再加上planar模式,共三个帧内预测模式的预测值进行加权。
需要说明的是,在本申请的实施例中,在实现DIMD的一种位置相关的权重导出方法时,可以选择在构建TL模板的直方图时,分别构建T模板的直方图,记为H_T,和L模板的直方图,记为H_L。分别对X为0或1,如果H_T[modeX]>H_L[modeX]×2,则modeX主要依赖于T模板,则modeX在接近于上侧的位置上权重更大。否则如果H_L[modeX]>H_T[modeX]×2,则modeX主要依赖于L模板,则modeX在接近于左侧的位置上权重更大。否则,modeX不使用位置相关的权重。
可以理解的是,上述DIMD的一种位置相关的权重导出方法,可以直接根据数据判断是否使用位置相关的权重,没有新增标志位flag等信息。这种情况下也可以应用尺寸信息对权重导出方法进行限制。例如,如果块尺寸符合条件,如满足width<height×4&&height<width×4或width>4&&height>4的条件,可以按照DIMD的一种位置相关的权重导出方法执行,否则,直接按不使用位置相关的权重的方法执行。
步骤102、根据第一模板确定当前块对应的预测值。
在本申请的实施例中,如果当前块对应的预测模式为预设预测模式,那么在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板在确定当前块对应的第一模板之后,可以进一步根据第一模板确定当前块对应的预测值。
需要说明的是,在本申请的实施例中,对当前块使用预设预测模式进行预测处理的过程中,可以利用确定的第一模板完成对当前块的基于模板的预测处理过程,即利用第一模板获得当前块对应的预测块,进而确定当前块对应的预测值。
进一步地,在本申请的实施例中,在根据第一模板确定当前块对应的预测值时,可以先基于第一模板确定当前块对应的最佳匹配块;然后再根据该最佳匹配块确定当前块对应的预测值。例如,可以将最佳匹配块对应的重建值确定为当前块的预测值。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,将该最佳匹配块作为当前块的预测块,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧内模板匹配预测intraTMP的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,使用第一模板在搜索范围内确定当前块的最佳的匹配块,然后将该最佳匹配块作为当前块的预测块,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧内块复制IBC的模板匹配的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,可以使用第一模板在参考帧内通过模板匹配的方法确定当前块的最佳的匹配块,然后将该最佳匹配块作为当前块的预测块,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧间模板匹配预测的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,可以将一些候选的帧内预测模式在第一模板上进行预测,取代价最低的一个或两个帧内预测模式作为当前块的帧内预测值,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为基于模板的帧内模式推导TIMD的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,可以使用第一模板的区域来确定代价最低的一个或两个帧内预测模式作为当前块的帧内预测值,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧内模式推导DIMD的情况。
进一步地,在本申请的实施例中,在根据当前块对应的第一模板确定当前块的预测值之后,可以进一步根据当前块的预测值,确定当前块的重建值。
需要说明的是,在本申请的实施例中,可以先解码码流,确定当前块对应的预测差值(residual);然后可以进一步根据预测差值和预测值,确定当前块的重建值。
综上所述,通过上述步骤101至步骤102所提出的解码方法,在使用基于模板的预测技术对当前块进行预测处理的过程中,可以使用当前块的尺寸信息对候选模板进行筛选和限制,从而确定出用于进行预测处理的第一模板。其中,在对候选模板筛选和限制的过程中,可以基于当前块的尺寸信息剔除掉不适用于当前块的候选模板,从而可以减少不必要的开销或减少不合理的结果的干扰。
也就是说,本申请实施例提出的编解码方法,针对模板占比太小或模板尺寸太小时,推导出来的结果可能不合理的问题,能够通过当前块对应的尺寸信息对候选模板进行限制,使得预测过程中使用的第一模板适用于当前块,从而可以减少不合理的结果的干扰。
本申请实施例提供了一种解码方法,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。
本申请的一实施例提出了一种编码方法,该编码方法应用于编码器,图23为本申请实施例提出的编码方法的流程示意图,如图23所示,编码器进行编码处理的方法可以包括以下步骤:
步骤201、若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式。
在本申请的实施例中,可以先确定当前块对应的第一模板,其中,如果当前块对应的预测模式为预设预测模式,那么可以根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板。
需要说明的是,本申请实施例的编码方法应用于编码器。另外,该编码方法可以包括一种帧内预测方法,更具体地,是一种颜色分量预测方法。其中,视频图像可以划分为多个编码块,每个编码块可以包括第一颜色分量、第二颜色分量和第三颜色分量,而本申请实施例中的当前块是指视频图像中当前待进行帧内预测的编码块。
在这里,当需要对第一颜色分量进行预测时,待预测分量为第一颜色分量;当需要对第二颜色分量进行预测时,待预测分量为第二颜色分量;当需要对第三颜色分量进行预测时,待预测分量为第三颜色分量。另外,假定当前块进行第一颜色分量的预测,而且第一颜色分量为亮度分量,即待预测分量为亮度分量,那么当前块也可以称为亮度块;或者,假定当前块进行第二颜色分量的预测,而且第二颜色分量为色度分量,即待预测分量为色度分量,那么当前块也可以称为色度块。
需要说明的是,在本申请的实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的候选模板。其中,当前块对应的候选模板中包括多种不同模板类型的候选模板。
可以理解的是,在本申请的实施例中,可以先基于不同的模板类型,构建当前块对应的模板集合,进而可以在该模板集合中的候选模板中确定当前块对应的第一模板。
示例性的,在本申请的实施例中,如图21所示,当左上侧参考样本、上侧参考样本和左侧参考样本均可用时,模板形状如(a)所示;当只有左侧参考样本可用时,模板形状如(b)所示;当只有上侧参考样本可用时,模板形状如(c)所示;当只有左侧参考样本和左上侧参考样本可用时,模板形状如(d)所示;当只有左侧参考样本和左下侧参考样本可用,模板形状如(e)所示;当只有上侧参考样本和右上侧参考样本可用时,模板形状如(f)所示。
进一步地,在本申请的实施例中,在根据模板类型构建当前块对应的模板集合时,可以先根据模板类型,以及模板类型对应的模板尺寸,确定当前块的模板参考样本,然后可以根据模板参考样本确定当前块的候选模板,最终完成模板集合的构建。
需要说明的是,在本申请的实施例中,模板集合中的第一候选模板可以为包括当前块的左侧相邻重建样本和上侧相邻重建样本的模板,例如TL模板;模板集合中的第二候选模板可以为包括当前块的上侧相邻重建样本的模板,例如T模板;模板集合中的第三候选模板可以为包括当前块的左侧相邻重建样本的模板,例如L模板。
也就是说,在本申请的实施例中,当前块对应的至少一个候选模板可以包括TL模板,T模板,L模板。
示例性的,在本申请的实施例中,如图22所示,对应于4种不同的模板类型,最终生成的当前块的候选模板也可以包括4种,如候选模板1(TL模板)、候选模板2(TL模板)、候选模板3(T模板)以及候选模板4(L模板)。
示例性的,在一些实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的第一候选模板,如候选模板1。
示例性的,在一些实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的第二候选模板,如候选模板3。
示例性的,在一些实施例中,当前块对应的第一模板可以为当前块对应的模板集合中的第三候选模板,如候选模板4。
进一步地,在本申请的实施例中,预设预测模式可以包括基于模板的预测模式。也就是说,在本申请中,可以将预测处理过程中涉及到模板的使用的预测方式统一确定为预设预测模式。
示例性的,在一些实施例中,预设预测模式可以包括帧内模板匹配预测,帧内块复制,帧间模板匹配预测,基于模板的帧内模式推导,帧内模式推导等基于模板的预测模式中的任意一种。
可以理解的是,在本申请的实施例中,帧内模板匹配预测intraTMP可以将模板匹配找到的最佳匹配块作为其最终确定的预测块,即intraTMP可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,帧内块复制IBC的模板匹配可以在搜索范围内通过模板匹配的方法确定当前块的最佳的匹配块,即IBC的模板匹配可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,帧间模板匹配预测可以在参考帧内通过模板匹配的方法确定当前块的最佳的匹配块,即帧间模板匹配预测可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,基于模板的帧内模式推导TIMD将一些候选的帧内预测模式在模板上进行预测,取代价最低的一个或两个帧内预测模式作为当前块的帧内预测值,即TIMD可以为基于模板的预测模式,因此可以作为预设预测模式。
可以理解的是,在本申请的实施例中,帧内模式推导DIMD与TIMD处理过程类似,DIMD虽然没有在模板上做预测,但它也使用了模板的区域,因此DIMD可以为基于模板的预测模式,进而可以作为预设预测模式。
可以理解的是,在本申请的实施例中,除了帧内模板匹配预测,帧内块复制,帧间模板匹配预测,基于模板的帧内模式推导,帧内模式推导以外,其他基于模板的预测模式均可以作为预设预测模式。本申请不进行具体限定。
可以理解的是,在本申请的实施例中,如果确定当前块对应的预测模式为预设预测模式,那么便可以使用当前块的尺寸信息来对候选模板进行选择和限制。具体地,可以根据当前块对应的尺寸信息在至少一个候选模板中确定出当前块对应的第一模板。
需要说明的是,在本申请的实施例中,第一模板为当前块基于预设预测模式进行预测处理时所使用的模板。
需要说明的是,在本申请的实施例中,当前块对应的尺寸信息可以包括与当前块对应的高度和/或宽度相关的信息。
示例性的,在一些实施例中,当前块对应的尺寸信息可以为当前块的高度值和宽度值,其中,当前块的高度值和宽度值可以为当前块的高度和宽度的绝对值。
进一步地,在本申请的实施例中,可以确定当前块对应的预测模式标识信息;若预测模式标识信息的取值为第一值,那么可以确定当前块对应的预测模式为预设预测模式;若预测模式标识信息的取值为第二值,那么可以确定当前块对应 的预测模式不为预设预测模式。
可以理解的是,在本申请的实施例中,预测模式标识信息可以用来确定当前块是否使用基于模板的预测模式,即确定当前块的预测模式是否为预设预测模式,进而通过预测模式标识信息可以确定当前块是否使用预设预测模式来进行预测处理。
示例性的,在一些实施例中,可以确定作为预测模式标识信息的一个变量,从而可以通过该变量的取值来实现预测模式标识信息的确定。
需要说明的是,在本申请中,预测模式标识信息的取值可以为第一值或第二值。其中,预测模式标识信息的取值不同,确定当前块的预测值的方式也不同。具体地,基于预测模式标识信息的取值,在确定当前块的预测值时,可以选择使用预设预测模式,或者选择不使用预设预测模式。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以将预测模式标识信息理解为一个表明是否进行intra TMP的标志位。其中,如果预测模式标识信息的取值为第一值,那么可以选择使用intra TMP确定当前块的预测值;如果预测模式标识信息的取值为第二值,那么可以选择不使用intra TMP确定当前块的预测值。
示例性的,在一些实施例中,可以设置第一值为1,第二值为0;也可以设置第一值为true,第二值为false。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_flag来表示预测模式标识信息,即使用intra_tmp_flag为intra TMP的flag。
示例性的,在一些实施例中,如果intra_tmp_flag的取值为1,那么可以表示选择使用intra TMP确定当前块的预测值;如果intra_tmp_flag的取值为0,那么可以表示不选择使用intra TMP确定当前块的预测值。
可以理解的是,在本申请的实施例中,在预测模式标识信息的取值为第一值,即确定在基于预测模式标识信息的取值确定使用预设预测模式确定当前块的预测值之后,便可以进一步根据当前块对应的尺寸信息在至少一个候选模板中确定当前块对应的第一模板。
进一步地,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,确定当前块对应的第一模板指示信息;若第一模板指示信息的取值为第三值,那么可以确定第一模板为第一候选模板。
需要说明的是,在本申请的实施例中,第一候选模板可以为当前块对应的至少一个候选模板中的一个候选模板。例如,第一候选模板可以为至少一个候选模板中的TL模板。
可以理解的是,在本申请的实施例中,第一模板指示信息可以用来确定当前块是否使用第一候选模板,即第一模板指示信息可以指示当前块是否利用第一候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,可以确定作为第一模板指示信息的一个变量,从而可以通过该变量的取值来实现第一模板指示信息的确定。
需要说明的是,在本申请中,第一模板指示信息的取值可以为第三值或第四值。具体地,基于第一模板指示信息的取值,在进行预设预测模式时可以选择使用第一候选模板,也可以选择不使用第一候选模板,而使用其他模板,例如至少一个候选模板中的、第一候选模板以外的其他模板。
示例性的,在一些实施例中,可以设置第三值为0,第四值为1;也可以设置第三值为false,第四值为true。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_alternative_template_flag来表示第一模板指示信息。例如,如果intra_tmp_alternative_template_flag的取值为0,那么可以表示将第一候选模板确定为当前块对应的第一模板;如果intra_tmp_alternative_template_flag的取值为1,那么可以表示不将第一候选模板确定为当前块对应的第一模板,而是继续选择其他模板作为当前块对应的第一模板。
相应的,在本申请的实施例中,在确定当前块对应的第一模板指示信息之后,如果第一模板指示信息的取值为第四值,那么可以确定第一模板并不是第一候选模板,此时,如果当前块的尺寸信息满足预设尺寸条件,那么需要进一步确定当前块对应的第二模板指示信息,从而根据第二模板指示信息确定第一模板。
也就是说,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果第一模板指示信息的取值为第四值,且当前块的尺寸信息满足预设尺寸条件,那么需要进一步确定当前块对应的第二模板指示信息,并根据第二模板指示信息确定第一模板。
可以理解的是,在本申请的实施例中,如果根据第一模板指示信息确定不使用第一候选模板,那么需要进一步根据当前块对应的尺寸信息来确定是否使用第一候选模板以外的其他候选模板。具体地,如果当前块对应的尺寸信息满足预设尺寸条件,那么便确定可以使用第一候选模板以外的其他候选模板,进而可以继续进行第二模板指示信息的确定,以根据第二模板指示信息确定第一模板。
需要说明的是,在本申请的实施例中,预设尺寸条件可以用于基于当前块的尺寸对候选模板的使用进行限制。
进一步地,在本申请的实施例中,在根据第二模板指示信息确定第一模板时,若第二模板指示信息的取值为第五值,那么可以确定第一模板为第二候选模板;若第二模板指示信息的取值为第六值,那么可以确定第一模板为第三候选模板。
需要说明的是,在本申请的实施例中,第二候选模板和第三候选模板可以分别为当前块对应的至少一个候选模板中的一个候选模板。例如,第二候选模板可以为至少一个候选模板中的T模板,第三候选模板可以为至少一个候选模板中的L模板。
可以理解的是,在本申请的实施例中,第二模板指示信息可以用来确定当前块是否使用第二候选模板和/或第三候选模板,即第二模板指示信息可以指示当前块是否利用第二候选模板和/或第三候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,可以确定作为第二模板指示信息的一个变量,从而可以通过该变量的取值来实现第二模板指示信息的确定。
需要说明的是,在本申请中,第二模板指示信息的取值可以为第五值或第六值。具体地,基于第二模板指示信息的取值,在进行预设预测模式时可以选择使用第二候选模板,也可以选择使用第三候选模板。
示例性的,在一些实施例中,可以设置第五值为0,第六值为1;也可以设置第五值为false,第六值为true。本申请 不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_template_idx来表示第二模板指示信息。例如,如果intra_tmp_template_idx的取值为0,那么可以表示将第二候选模板确定为当前块对应的第一模板;如果intra_tmp_template_idx的取值为1,那么可以表示将第三候选模板确定为当前块对应的第一模板。
进一步地,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果第一模板指示信息的取值为第四值,且当前块的尺寸信息不满足预设尺寸条件,那么可以选择跳过对第二模板指示信息的确定,而是直接根据当前块的尺寸信息确定当前块的最长边,然后再根据当前块的最长边在至少一个候选模板中确定第一模板。
可以理解的是,在本申请的实施例中,如果根据第一模板指示信息确定不使用第一候选模板,那么需要进一步根据当前块对应的尺寸信息来确定是否使用第一候选模板以外的其他候选模板。具体地,如果当前块对应的尺寸信息不满足预设尺寸条件,那么此时不需要再根据第二模板指示信息确定第一模板,而是可以直接按照当前块的最长边对第一模板进行指示。
可以理解的是,在本申请的实施例中,如果当前块的宽度值大于当前块的高度值,那么可以将宽度对应的一边确定为当前块的最长边;如果当前块的高度值大于当前块的宽度值,那么可以将宽度对应的一边确定为当前块的最长边。
也就是说,在本申请的实施例中,当前块的最长边为高度height对应的一边,也可以理解为当前块的高度大于宽度;当前块的最长边为宽度width对应的一边,也可以理解为当前块的宽度大于高度。
相应的,在本申请的实施例中,在第一模板指示信息的取值为第四值,且当前块的尺寸信息不满足预设尺寸条件的情况下,如果当前块的宽度值大于当前块的高度值,即当前块的最长边为宽度width对应的一边,那么可以认为当前块的左相邻区域包含比上相邻区域更多的相邻样本,因此可以将包含较多左相邻样本的L模板作为第一模板,即将包括当前块的左侧相邻重建样本的第三候选模板(L模板)确定为第一模板。
相应的,在本申请的实施例中,在第一模板指示信息的取值为第四值,且当前块的尺寸信息不满足预设尺寸条件的情况下,如果当前块的高度值大于当前块的宽度值,即当前块的最长边为高度height对应的一边,那么可以认为当前块的上相邻区域包含比左相邻区域更多的相邻样本,因此可以将包含较多上相邻样本的T模板作为第一模板,即将包括当前块的上侧相邻重建样本的第二候选模板(T模板)确定为第一模板。
示例性的,在一些实施例中,假设当前块的高度height为4,宽度width为1,那么可以确定当前块的最长边为高度height对应的一边,因此可以将该最长边对应的L模板作为第一模板。
示例性的,在一些实施例中,假设当前块的高度height为1,宽度width为8,那么可以确定当前块的最长边为宽度width对应的一边,因此可以将该最长边对应的T模板作为第一模板。
进一步地,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果当前块的尺寸信息满足预设尺寸条件,那么可以确定当前块对应的第一模板指示信息;若第一模板指示信息的取值为第三值,那么可以确定第一模板为第一候选模板。
需要说明的是,在本申请的实施例中,第一候选模板可以为当前块对应的至少一个候选模板中的一个候选模板。例如,第一候选模板可以为至少一个候选模板中的TL模板。
也就是说,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,可以先根据当前块对应的尺寸信息来确定是否使用第一候选模板。具体地,如果当前块对应的尺寸信息满足预设尺寸条件,那么便确定可以使用第一候选模板,进而可以继续进行第一模板指示信息的确定。
需要说明的是,在本申请的实施例中,预设尺寸条件可以用于基于当前块的尺寸对候选模板的使用进行限制。
相应的,在本申请的实施例中,在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板时,如果当前块的尺寸信息不满足预设尺寸条件,那么此时不需要再根据第一模板指示信息确定第一模板,而是可以直接对第一模板进行指示。例如,可以将第一候选模板确定为第一模板。
可以理解的是,在本申请的实施例中,第一模板指示信息可以用来确定当前块是否使用第一候选模板,即第一模板指示信息可以指示当前块是否利用第一候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,可以确定作为第一模板指示信息的一个变量,从而可以通过该变量的取值来实现第一模板指示信息的确定。
需要说明的是,在本申请中,第一模板指示信息的取值可以为第三值或第四值。具体地,基于第一模板指示信息的取值,在进行预设预测模式时可以选择使用第一候选模板,也可以选择不使用第一候选模板,而使用其他模板,例如至少一个候选模板中的、第一候选模板以外的其他模板。
示例性的,在一些实施例中,可以设置第三值为0,第四值为1;也可以设置第三值为false,第四值为true。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_alternative_template_flag来表示第一模板指示信息。例如,如果intra_tmp_alternative_template_flag的取值为0,那么可以表示将第一候选模板确定为当前块对应的第一模板;如果intra_tmp_alternative_template_flag的取值为1,那么可以表示不将第一候选模板确定为当前块对应的第一模板,而是继续选择其他模板作为当前块对应的第一模板。
相应的,在本申请的实施例中,在确定当前块对应的第一模板指示信息之后,如果第一模板指示信息的取值为第四值,那么可以确定第一模板并不是第一候选模板,此时,需要进一确定当前块对应的第二模板指示信息,从而根据第二模板指示信息确定第一模板。
进一步地,在本申请的实施例中,在根据第二模板指示信息确定第一模板时,若第二模板指示信息的取值为第五值,那么可以确定第一模板为第二候选模板;若第二模板指示信息的取值为第六值,那么可以确定第一模板为第三候选模板。
需要说明的是,在本申请的实施例中,第二候选模板和第三候选模板可以分别为当前块对应的至少一个候选模板中的一个候选模板。例如,第二候选模板可以为至少一个候选模板中的T模板,第三候选模板可以为至少一个候选模板中的L模板。
可以理解的是,在本申请的实施例中,第二模板指示信息可以用来确定当前块是否使用第二候选模板和/或第三候选模板,即第二模板指示信息可以指示当前块是否利用第二候选模板和/或第三候选模板来执行预设预测模式的预测处理。
示例性的,在一些实施例中,可以确定作为第二模板指示信息的一个变量,从而可以通过该变量的取值来实现第二模板指示信息的确定。
需要说明的是,在本申请中,第二模板指示信息的取值可以为第五值或第六值。具体地,基于第二模板指示信息的取值,在进行预设预测模式时可以选择使用第二候选模板,也可以选择使用第三候选模板。
示例性的,在一些实施例中,可以设置第五值为0,第六值为1;也可以设置第五值为false,第六值为true。本申请不作任何限定。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,可以使用标志intra_tmp_template_idx来表示第二模板指示信息。例如,如果intra_tmp_template_idx的取值为0,那么可以表示将第二候选模板确定为当前块对应的第一模板;如果intra_tmp_template_idx的取值为1,那么可以表示将第三候选模板确定为当前块对应的第一模板。
也就是说,在本申请的实施例中,可以选择在码流中指示当前块对应的第一模板为至少一个候选模板中的哪一个候选模板。例如,使用第一模板指示信息和/或第二模板指示信息来对第一模板进行指示。而在第一模板的确定过程中,需要使用当前块对应的尺寸信息对候选模板进行限制。
可以理解的是,在本申请的实施例中,基于预设尺寸条件,可以根据当前块的尺寸对候选模板的使用进行限制。具体地,当当前块对应的尺寸信息所包括的含义不同时,对应的预设尺寸条件也可以是不同的。
进一步地,在本申请的实施例中,如果尺寸信息包括当前块的高度值和宽度值;相应的,预设尺寸条件包括:宽度值小于高度值的第一数值倍且高度值小于宽度值的第二数值倍。
可以理解的是,在本申请的实施例中,第一数值倍和第二数值倍可以用于对当前块的宽度和高度之间的比例进行限制。
需要说明的是,在本申请的实施例中,第一数值倍和第二数值倍可以为大于0的任意数值,其中,第一数值倍和第二数值倍可以相同,也可以不同,本申请不进行具体限定。
示例性的,在本申请的实施例中,第一数值倍可以为4,第二数值倍可以为8。
示例性的,在本申请的实施例中,第一数值倍和第二数值倍可以均为4。
可以理解的是,在本申请的实施例中,在确定当前块的尺寸信息是否满足预设尺寸条件时,如果当前块的宽度值小于高度值的第一数值倍且当前块的高度值小于宽度值的第二数值倍,那么可以确定当前块的尺寸信息满足预设尺寸条件。相应的,如果当前块的宽度值大于或者等于高度值的第一数值倍,或者,当前块的高度值大于或者等于宽度值的第二数值倍,那么可以确定当前块的尺寸信息不满足预设尺寸条件。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,确定intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1且当前块同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值满足width<height×4且height<width×4的条件,确定intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的高度值和宽度值不同时满足width<height×4且height<width×4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块是否同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值是否满足width<height×4且height<width×4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则确定intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,确定intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
进一步地,在本申请的实施例中,如果尺寸信息包括当前块的高度值和宽度值;相应的,预设尺寸条件包括:高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值。
可以理解的是,在本申请的实施例中,第一尺寸阈值可以用于对当前块的高度值(高度的绝对值)进行限制;相应的,第二尺寸阈值可以用于对当前块的宽度值(宽度的绝对值)进行限制。
需要说明的是,在本申请的实施例中,第一尺寸阈值和第二尺寸阈值可以为大于0的任意数值,其中,第一尺寸阈值和第二尺寸阈值可以相同,也可以不同,本申请不进行具体限定。
示例性的,在本申请的实施例中,第一尺寸阈值可以为8,第二尺寸阈值可以为4。
示例性的,在本申请的实施例中,第一尺寸阈值和第二尺寸阈值可以均为8。
可以理解的是,在本申请的实施例中,在确定当前块的尺寸信息是否满足预设尺寸条件时,如果当前块的高度值大于第一尺寸阈值且当前块的宽度值大于第二尺寸阈值,那么可以确定当前块的尺寸信息满足预设尺寸条件。相应的,如果当前块的高度值小于或者等于第一尺寸阈值,或者,当前块的宽度值小于或者等于第二尺寸阈值,那么可以确定当前块的尺寸信息不满足预设尺寸条件。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,确定intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1且当前块的宽度值和高度值同时满足width>4且height>4的条件,确定intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的宽度值和高度值不满足width>4且height>4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么可以码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块的宽度值和高度值是否满足width>4且height>4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则确定intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,确定intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
进一步地,在本申请的实施例中,如果尺寸信息包括当前块的高度值和宽度值;相应的,预设尺寸条件包括:宽度值小于高度值的第一数值倍且高度值小于宽度值的第二数值倍,且高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值。
可以理解的是,在本申请的实施例中,第一数值倍和第二数值倍可以用于对当前块的宽度和高度之间的比例进行限 制;第一尺寸阈值可以用于对当前块的高度值(高度的绝对值)进行限制;第二尺寸阈值可以用于对当前块的宽度值(宽度的绝对值)进行限制。
需要说明的是,在本申请的实施例中,第一数值倍和第二数值倍可以为大于0的任意数值,其中,第一数值倍和第二数值倍可以相同,也可以不同,本申请不进行具体限定。
需要说明的是,在本申请的实施例中,第一尺寸阈值和第二尺寸阈值可以为大于0的任意数值,其中,第一尺寸阈值和第二尺寸阈值可以相同,也可以不同,本申请不进行具体限定。
示例性的,在本申请的实施例中,第一数值倍和第二数值倍可以均为4,第一尺寸阈值和第二尺寸阈值可以均为8。
可以理解的是,在本申请的实施例中,在确定当前块的尺寸信息是否满足预设尺寸条件时,如果当前块的宽度值小于高度值的第一数值倍且当前块的高度值小于宽度值的第二数值倍,同时,当前块的高度值大于第一尺寸阈值且当前块的宽度值大于第二尺寸阈值,那么可以确定当前块的尺寸信息满足预设尺寸条件。相应的,如果当前块的宽度值大于或者等于高度值的第一数值倍,或者,当前块的高度值大于或者等于宽度值的第二数值倍,或者,当前块的高度值小于或者等于第一尺寸阈值,或者,当前块的宽度值小于或者等于第二尺寸阈值,那么可以确定当前块的尺寸信息不满足预设尺寸条件。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,同时,高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4&&width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,确定intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,且当前块同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值满足width<height×4且height<width×4,以及当前块的高度值和宽度值比同时满足width>4且height>4的条件,确定intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的高度值和宽度值不同时满足width<height×4且height<width×4且width>4且height>4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
示例性的,在一些实施例中,假设预设预测模式为intra TMP,以TL模板,T模板,L模板三种候选模板为例,第一候选模板为TL模板,第二候选模板为T模板,第三候选模板为L模板,第一比例阈值和第二比例阈值均为4,第一尺寸阈值和第二尺寸阈值均为4,预设尺寸条件为高宽比小于第一比例阈值且宽高比小于第二比例阈值,同时,高度值大于第一尺寸阈值且宽度值大于第二尺寸阈值,即预设尺寸条件可以表示为width<height×4&&height<width×4&&width>4&&height>4,标志intra_tmp_flag表示预测模式标识信息,标志intra_tmp_alternative_template_flag表示第一模板指示信息,标志intra_tmp_template_idx表示第二模板指示信息,那么码流中的信息如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块是否同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值是否满足width<height×4且height<width×4,以及当前块的高度值和宽度值是否同时满足width>4且height>4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则确定intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,确定intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
可以理解的是,在本申请的实施例中,上述的示例为使用显式的方式来选择不同的候选模板,也就是说,要将选择不同模板的信息写进码流,通过当前块的尺寸信息对候选模板进行限制的方法可以减少不必要的开销。
进一步地,在本申请的实施例中,一些基于模板的预测技术,如TIMD,DIMD等,可以分别根据TL模板,T模板,L模板各导出一种帧内预测模式,为了不增加额外的开销,可以根据阈值条件分析来进行不同的处理。
可以理解的是,在本申请的实施例中,DIMD利用当前块周边已重建样本的梯度构建一个帧内预测模式的直方图,选出直方图里最高的两个帧内预测模式记为mode0和mode1,再加上planar模式,共三个帧内预测模式的预测值进行加权。
需要说明的是,在本申请的实施例中,在实现DIMD的一种位置相关的权重导出方法时,可以选择在构建TL模板的直方图时,分别构建T模板的直方图,记为H_T,和L模板的直方图,记为H_L。分别对X为0或1,如果H_T[modeX]>H_L[modeX]×2,则modeX主要依赖于T模板,则modeX在接近于上侧的位置上权重更大。否则如果H_L[modeX]>H_T[modeX]×2,则modeX主要依赖于L模板,则modeX在接近于左侧的位置上权重更大。否则,modeX不使用位置相关的权重。
可以理解的是,上述DIMD的一种位置相关的权重导出方法,可以直接根据数据判断是否使用位置相关的权重,没有新增标志位flag等信息。这种情况下也可以应用尺寸信息对权重导出方法进行限制。例如,如果块尺寸符合条件,如满足width<height×4&&height<width×4或width>4&&height>4的条件,可以按照DIMD的一种位置相关的权重导出方法执行,否则,直接按不使用位置相关的权重的方法执行。
步骤202、根据第一模板确定当前块对应的预测值。
在本申请的实施例中,如果当前块对应的预测模式为预设预测模式,那么在根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板在确定当前块对应的第一模板之后,可以进一步根据第一模板确定当前块对应的预测值。
需要说明的是,在本申请的实施例中,对当前块使用预设预测模式进行预测处理的过程中,可以利用确定的第一模板完成对当前块的基于模板的预测处理过程,即利用第一模板获得当前块对应的预测块,进而确定当前块对应的预测值。
进一步地,在本申请的实施例中,在根据第一模板确定当前块对应的预测值时,可以先基于第一模板确定当前块对应的最佳匹配块;然后再根据该最佳匹配块确定当前块对应的预测值。例如,可以将最佳匹配块对应的重建值确定为当前块的预测值。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,将该最佳匹配块作为当前块的预测块,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧内模板匹配预测intraTMP的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,使用第一模板在搜索范围内确定当前块的最佳的匹配块,然后将该最佳匹配块作为当前块的预测块,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧内块复制IBC的模板匹配的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,可以使用第一模板在参考帧内通过模板匹配的方法确定当前块的最佳的匹配块,然后将该最佳匹配块作为当前块的预测块,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧间模板匹配预测的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,可以将一些候选的帧内预测模式在第一模板上进行预测,取代价最低的一个或两个帧内预测模式作为当前块的帧内预测值,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为基于模板的帧内模式推导TIMD的情况。
可以理解的是,在本申请的实施例中,在确定当前块的第一模板之后,便可以使用第一模板对当前块对应的最佳匹配块进行搜索,最终可以根据获得的最佳匹配块来确定当前块的预测值。例如,可以使用第一模板的区域来确定代价最低的一个或两个帧内预测模式作为当前块的帧内预测值,进而确定出当前块对应的预测值。其中,上述基于第一模板确定当前块的预测值的方法可以适用于预设预测模式为帧内模式推导DIMD的情况。
进一步地,在本申请的实施例中,在根据当前块对应的第一模板确定当前块的预测值之后,可以进一步根据当前块的预测值,确定当前块的重建值。
需要说明的是,在本申请的实施例中,可以先确定当前块对应的预测差值(residual);然后可以进一步根据预测差值和预测值,确定当前块的重建值。
可以理解的是,在本申请的实施例中,在根据当前块的预测值,确定当前块的预测差值(residual)之后,可以将预测差值写入码流。从而可以使得解码器通过解码码流,确定当前块对应的预测差值(residual);然后可以进一步根据预测差值和预测值,确定当前块的重建值。
综上所述,通过上述步骤201至步骤202所提出的编码方法,在使用基于模板的预测技术对当前块进行预测处理的过程中,可以使用当前块的尺寸信息对候选模板进行筛选和限制,从而确定出用于进行预测处理的第一模板。其中,在对候选模板筛选和限制的过程中,可以基于当前块的尺寸信息剔除掉不适用于当前块的候选模板,从而可以减少不必要的开销或减少不合理的结果的干扰。
也就是说,本申请实施例提出的编解码方法,针对模板占比太小或模板尺寸太小时,推导出来的结果可能不合理的问题,能够通过当前块对应的尺寸信息对候选模板进行限制,使得预测过程中使用的第一模板适用于当前块,从而可以减少不合理的结果的干扰。
本申请实施例提供了一种编码方法,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的 结果的干扰,进而能够提升压缩效率,提高编解码性能。
基于上述实施例,本申请的另一实施例提出了一种编解码方法,该编解码方法应用于编解码器。其中,该编解码方法可以根据当前块的尺寸来对候选模板的使用进行限控制和限制。例如,一种情况下,可以根据当前块的宽高比限制T模板和/或L模板的使用;另一种情况下,可以根据当前块的尺寸的绝对值(即宽度和高度的绝对值,如高度值和宽度值)限制T模板和/或L模板的使用。
可以理解的是,常见的视频编解码技术支持正方形块和长方形的块。其中,正方形块的宽高比是1:1,而长方形的宽高比可以达到4:1或1:4,甚至8:1或1:8,当然也可能差别更多。如果当前块的宽width和当前块的高height差得比较多,那么可以理解短边对应的候选模板作用并不明显。
示例性的,在一些实施例中,一个width为4,height为16的块,这种情况下,width对应的L模板作用不明显,那么可以规定这种尺寸的块不使用L模板。
示例性的,在一些实施例中,一个width为4,height为16的块,这种情况下,width对应的L模板作用不明显,那么可以规定这种形状的块只能使用TL模板,这是因为L模板相比于T模板足够小时,TL模板和T模板差别不大。
示例性的,在一些实施例中,以intra TMP为例,一个对T模板和L模板不加任何限制的解码语法例子如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
需要说明的是,在本申请的实施例中,以intra TMP为例,在根据当前块的宽高比和高宽比(高度值和宽度值)对T模板和L模板设置限制时,可以在上面例子的基础上增加条件&&width<height×4&&height<width×4。其中,比例阈值(第一数值倍或第二数值倍)4可以换成其他的数值,例如2或8等。也就是说,只有在符合上述宽高比的限制条件的情况下才需要解析intra_tmp_template_idx。否则,如果intra_tmp_alternative_template_flag的值为1,默认选择长边对应的候选模板。
示例性的,在一些实施例中,以intra TMP为例,根据当前块的宽高比对T模板和L模板进行限制的解码语法例子如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1且当前块同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值满足width<height×4且height<width×4的条件,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的高度值和宽度值不同时满足width<height×4且height<width×4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
需要说明的是,在本申请的实施例中,以intra TMP为例,在根据当前块的宽高比对T模板和L模板设置限制时,可以在上面例子的基础上增加条件width<height×4&&height<width×4。其中,比例阈值4可以换成其他的数值,例如2或8等。也就是说,只有在符合上述宽高比的限制条件的情况下才需要解析intra_tmp_alternative_template_flag。否则,默认选择TL模板。
示例性的,在一些实施例中,以intra TMP为例,根据当前块的宽高比对T模板和L模板进行限制的解码语法例子如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块是否同时满足宽度值小于高度值的四倍且高度值小于宽度值的四倍,即高度值和宽度值是否满足width<height×4且height<width×4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
可以理解的是,在本申请的实施例中,还可以将当前块的尺寸的绝对值,即当前块的宽度和高度的绝对值作为要考虑的因素。
示例性的,在一些实施例中,当当前块的宽度和/或高度的绝对值大于或者等于一个尺寸阈值时,才可以使用对应的T模板或L模板。
需要说明的是,在本申请的实施例中,以intra TMP为例,在根据当前块的尺寸的绝对值对T模板和L模板设置限制时,可以在上面例子的基础上增加条件width>4&&height>4。其中,尺寸阈值4可以换成其他的数值,例如2或8等。也就是说,只有在符合上述尺寸的限制条件的情况下才需要解析intra_tmp_template_idx。否则,如果intra_tmp_alternative_template_flag的值为1,默认选择长边对应的候选模板。
示例性的,在一些实施例中,以intra TMP为例,根据当前块的宽度和/或高度的绝对值对T模板和L模板进行限制的解码语法例子如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1且当前块的宽度值和高度值同时满足width>4且height>4的条件,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
相应的,在本申请的实施例中,如果当前块的宽度值和高度值不满足width>4且height>4的条件,那么可以默认选择长边对应的候选模板。例如,如果长边为高度那一边,则选择L模板;如果长边为宽度那一边,则选择T模板。
需要说明的是,在本申请的实施例中,以intra TMP为例,在根据当前块的尺寸的绝对值对T模板和L模板设置限制时,可以在上面例子的基础上增加条件width>4&&height>4。其中,尺寸阈值4可以换成其他的数值,例如2或8等。也就是说,只有在符合上述尺寸的限制条件的情况下才需要解析intra_tmp_alternative_template_flag。否则,默认选择TL模板。
示例性的,在一些实施例中,以intra TMP为例,根据当前块的宽度和/或高度的绝对值对T模板和L模板进行限制的解码语法例子如下:
其中,intra_tmp_flag指示当前块是否使用intra TMP,如果当前块使用intra TMP,那么需要先确定当前块的宽度和高度是否满足width>4且height>4的条件,如果不满足,那么就跳过对intra_tmp_alternative_template_flag的解析,而是直接默认选择TL模板;如果满足,则解码器解析intra_tmp_alternative_template_flag,intra_tmp_alternative_template_flag指示当前块是否使用其他模板,如果intra_tmp_alternative_template_flag的值为0,代表当前块使用TL模板,如果intra_tmp_alternative_template_flag的值为1,解码器解析intra_tmp_template_idx,intra_tmp_template_idx指示当前块使用T模板或L模板,例如,intra_tmp_template_idx的值为0代表当前块使用T模板,intra_tmp_template_idx的值为1代表当前块使用L模板。
可以理解的是,在本申请的实施例中,在对候选模板的使用进行限制时,也可以对宽高比和尺寸的绝对值这两方面的因素进行组合使用。本申请不进行具体限定。
可以理解的是,在本申请的实施例中,上述的示例为使用显式的方式来选择不同的候选模板,也就是说,要将选择不同模板的信息写进码流,通过当前块的尺寸信息对候选模板进行限制的方法可以减少不必要的开销。
进一步地,在本申请的实施例中,一些基于模板的预测技术,如TIMD,DIMD等,可以分别根据TL模板,T模板,L模板各导出一种帧内预测模式,为了不增加额外的开销,可以根据阈值条件分析来进行不同的处理。
可以理解的是,在本申请的实施例中,DIMD利用当前块周边已重建样本的梯度构建一个帧内预测模式的直方图,选出直方图里最高的两个帧内预测模式记为mode0和mode1,再加上planar模式,共三个帧内预测模式的预测值进行加权。
需要说明的是,在本申请的实施例中,在实现DIMD的一种位置相关的权重导出方法时,可以选择在构建TL模板的直方图时,分别构建T模板的直方图,记为H_T,和L模板的直方图,记为H_L。分别对X为0或1,如果H_T[modeX]>H_L[modeX]×2,则modeX主要依赖于T模板,则modeX在接近于上侧的位置上权重更大。否则如果H_L[modeX]>H_T[modeX]×2,则modeX主要依赖于L模板,则modeX在接近于左侧的位置上权重更大。否则,modeX不使用位置相关的权重。
可以理解的是,上述DIMD的一种位置相关的权重导出方法,可以直接根据数据判断是否使用位置相关的权重,没有新增标志位flag等信息。这种情况下也可以应用尺寸信息对权重导出方法进行限制。例如,如果块尺寸符合条件,如满足width<height×4&&height<width×4或width>4&&height>4的条件,可以按照DIMD的一种位置相关的权重导出方法执行,否则,直接按不使用位置相关的权重的方法执行。
综上所述,本申请实施例提出的编解码方法,在使用基于模板的预测技术对当前块进行预测处理的过程中,可以使用当前块的尺寸信息对候选模板进行筛选和限制,从而确定出用于进行预测处理的第一模板。其中,在对候选模板筛选和限制的过程中,可以基于当前块的尺寸信息剔除掉不适用于当前块的候选模板,从而可以减少不必要的开销或减少不合理的结果的干扰。
也就是说,本申请实施例提出的编解码方法,针对模板占比太小或模板尺寸太小时,推导出来的结果可能不合理的问题,能够通过当前块对应的尺寸信息对候选模板进行限制,使得预测过程中使用的第一模板适用于当前块,从而可以减少不合理的结果的干扰。
本申请实施例提供了一种编解码方法,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。
本申请的再一实施例中,参见图24,其示出了本申请实施例提供的一种编码器的组成结构示意图。如图24所示,该编码器180可以包括:第一确定单元1801;其中,
第一确定单元1801,配置为若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
可以理解地,在本申请实施例中,“单元”可以是部分电路、部分处理器、部分程序或软件等等,当然也可以是模块,还可以是非模块化的。而且在本实施例中的各组成部分可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
所述集成的单元如果以软件功能模块的形式实现并非作为独立的产品进行销售或使用时,可以存储在一个计算机可读取存储介质中,基于这样的理解,本实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或processor(处理器)执行本实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
因此,本申请实施例提供了一种计算机可读存储介质,应用于编码器180,该计算机可读存储介质存储有计算机程序,所述计算机程序被第一处理器执行时实现前述实施例中任一项所述的方法。
基于编码器180的组成以及计算机可读存储介质,参见图25,其示出了本申请实施例提供的编码器180的具体硬件结构示意图。如图25所示,编码器180可以包括:第一通信接口1901、第一存储器1902和第一处理器1903;各个组件通过第一总线系统1904耦合在一起。可理解,第一总线系统1904用于实现这些组件之间的连接通信。第一总线系统1904除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,将各种总线都标为第一总线系统1904。其中,
第一通信接口1901,用于在与其他外部网元之间进行收发信息过程中,信号的接收和发送;
第一存储器1902,用于存储能够在第一处理器1903上运行的计算机程序;
第一处理器1903,用于在运行所述计算机程序时,执行如下处理:若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
可以理解,本申请实施例中的第一存储器1902可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDRSDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DRRAM)。本申请描述的系统和方法的第一存储器1902旨在包括但不限于这些和任意其它适合类型的存储器。
而第一处理器1903可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过第一处理器1903中的硬件的集成逻辑电路或者软件形式的指令完成。上述的第一处理器1903可以是通用处理器、数字 信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于第一存储器1902,第一处理器1903读取第一存储器1902中的信息,结合其硬件完成上述方法的步骤。
可以理解的是,本申请描述的这些实施例可以用硬件、软件、固件、中间件、微码或其组合来实现。对于硬件实现,处理单元可以实现在一个或多个专用集成电路(Application Specific Integrated Circuits,ASIC)、数字信号处理器(Digital Signal Processing,DSP)、数字信号处理设备(DSP Device,DSPD)、可编程逻辑设备(Programmable Logic Device,PLD)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、通用处理器、控制器、微控制器、微处理器、用于执行本申请所述功能的其它电子单元或其组合中。对于软件实现,可通过执行本申请所述功能的模块(例如过程、函数等)来实现本申请所述的技术。软件代码可存储在存储器中并通过处理器执行。存储器可以在处理器中或在处理器外部实现。
可选地,作为另一个实施例,第一处理器1903还配置为在运行所述计算机程序时,执行前述实施例中任一项所述的方法。
在本申请的再一实施例中,参见图26,其示出了本申请实施例提供的一种解码器的组成结构示意图。如图26所示,该解码器200可以包括:第二确定单元2001;其中,
第二确定单元2001,配置为若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
可以理解地,在本实施例中,“单元”可以是部分电路、部分处理器、部分程序或软件等等,当然也可以是模块,还可以是非模块化的。而且在本实施例中的各组成部分可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
所述集成的单元如果以软件功能模块的形式实现并非作为独立的产品进行销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本实施例提供了一种计算机可读存储介质,应用于解码器200,该计算机可读存储介质存储有计算机程序,所述计算机程序被第二处理器执行时实现前述实施例中任一项所述的方法。
基于解码器200的组成以及计算机可读存储介质,参见图27,其示出了本申请实施例提供的解码器200的具体硬件结构示意图。如图27所示,解码器200可以包括:第二通信接口2201、第二存储器2202和第二处理器2203;各个组件通过第二总线系统2204耦合在一起。可理解,第二总线系统2204用于实现这些组件之间的连接通信。第二总线系统2204除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,将各种总线都标为第二总线系统2204。其中,
第二通信接口2201,用于在与其他外部网元之间进行收发信息过程中,信号的接收和发送;
第二存储器2202,用于存储能够在第二处理器2203上运行的计算机程序;
第二处理器2203,用于在运行所述计算机程序时,执行如下处理:若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
可选地,作为另一个实施例,第二处理器2203还配置为在运行所述计算机程序时,执行前述实施例中任一项所述的方法。
可以理解,第二存储器2202与第一存储器1902的硬件功能类似,第二处理器2203与第一处理器1903的硬件功能类似;这里不再详述。
本实施例提供了一种编解码器,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。
在本申请的再一实施例中,参见图28,其示出了本申请实施例提供的一种编解码系统的组成结构示意图。如图28所示,编解码系统230可以包括编码器2301和解码器2302。
在本申请实施例中,编码器2301可以为前述实施例中任一项所述的编码器,解码器2302可以为前述实施例中任一项所述的解码器。
进一步地,本申请实施例还提供了一种码流,其中,码流是根据待编码信息进行比特编码生成的;其中,待编码信息包括下述至少一项:预测模式标识信息,第一模板指示信息,第二模板指示信息,预测差值。
需要说明的是,在本申请中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
本申请所提供的几个方法实施例中所揭露的方法,在不冲突的情况下可以任意组合,得到新的方法实施例。
本申请所提供的几个产品实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的产品实施例。
本申请所提供的几个方法或设备实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的方法实施例或设备实施例。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。
工业实用性
本申请实施例提供了一种编解码方法、码流、编码器、解码器以及存储介质,若当前块对应的预测模式为预设预测模式,则根据当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板;其中,预设预测模式包括基于模板的预测模式;根据第一模板确定当前块对应的预测值。由此可见,在本申请的实施例中,如果对当前块使用基于模板的预测模式的预设预测模式来进行预测处理,那么可以选择根据当前块的尺寸信息来对至少一个候选模板进行确定,限制不符合当前块的尺寸信息的候选模板的使用,以获得后续预测处理过程所使用的第一模板,其中,该第一模板是基于当前块的尺寸信息获得的,因此在通过基于模板的预测模式进行预测处理的过程中,第一模板能够适用于当前块所对应的场景,从而可以减少不必要的开销或不合理的结果的干扰,进而能够提升压缩效率,提高编解码性能。

Claims (38)

  1. 一种解码方法,应用于解码器,所述方法包括:
    若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;
    根据所述第一模板确定所述当前块对应的预测值。
  2. 根据权利要求1所述的方法,其中,所述方法还包括:
    解码码流,确定所述当前块对应的预测模式标识信息;
    若所述预测模式标识信息的取值为第一值,则确定当前块对应的预测模式为所述预设预测模式;
    若所述预测模式标识信息的取值为第二值,则确定当前块对应的预测模式不为所述预设预测模式。
  3. 根据权利要求1所述的方法,其中,所述预设预测模式包括以下预测模式中的任意一种:帧内模板匹配预测,帧内块复制,帧间模板匹配预测,基于模板的帧内模式推导,帧内模式推导。
  4. 根据权利要求2所述的方法,其中,所述根据所述当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板,包括:
    解码码流,确定所述当前块对应的第一模板指示信息;
    若所述第一模板指示信息的取值为第三值,则确定所述第一模板为第一候选模板;
    若所述第一模板指示信息的取值为第四值,且所述当前块的尺寸信息满足预设尺寸条件,则解码码流,确定所述当前块对应的第二模板指示信息,并根据所述第二模板指示信息确定所述第一模板。
  5. 根据权利要求4所述的方法,其中,所述根据所述第二模板指示信息确定所述第一模板,包括:
    若所述第二模板指示信息的取值为第五值,则确定所述第一模板为第二候选模板;
    若所述第二模板指示信息的取值为第六值,则确定所述第一模板为第三候选模板。
  6. 根据权利要求5所述的方法,其中,所述方法还包括:
    在所述第一模板指示信息的取值为第四值,且所述当前块的尺寸信息不满足所述预设尺寸条件的情况下,若所述当前块的宽度值大于所述当前块的高度值,则确定所述第一模板为所述第二候选模板;若所述当前块的高度值大于所述当前块的宽度值,则确定所述第一模板为所述第三候选模板。
  7. 根据权利要求2所述的方法,其中,所述根据所述当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板,包括:
    若所述当前块的尺寸信息满足预设尺寸条件,则解码码流,确定所述当前块对应的第一模板指示信息;
    若所述第一模板指示信息的取值为第三值,则确定所述第一模板为第一候选模板;
    若所述第一模板指示信息的取值为第四值,则解码码流,确定所述当前块对应的第二模板指示信息,并根据所述第二模板指示信息确定所述第一模板。
  8. 根据权利要求7所述的方法,其中,所述根据所述第二模板指示信息确定所述第一模板,包括:
    若所述第二模板指示信息的取值为第五值,则确定所述第一模板为第二候选模板;
    若所述第二模板指示信息的取值为第六值,则确定所述第一模板为第三候选模板。
  9. 根据权利要求5,6,8任一项所述的方法,其中,
    所述第一候选模板为包括所述当前块的左侧相邻重建样本和上侧相邻重建样本的模板;
    所述第二候选模板为包括所述当前块的上侧相邻重建样本的模板;
    所述第三候选模板为包括所述当前块的左侧相邻重建样本的模板。
  10. 根据权利要求7所述的方法,其中,所述方法还包括:
    若所述当前块的尺寸信息不满足所述预设尺寸条件,则确定所述第一模板为所述第一候选模板。
  11. 根据权利要求4至10任一项所述的方法,其中,所述尺寸信息包括所述当前块的高度值和宽度值;相应的,
    所述预设尺寸条件包括:所述宽度值小于所述高度值的第一数值倍且所述高度值小于所述宽度值的第二数值倍。
  12. 根据权利要求4至10任一项所述的方法,其中,所述尺寸信息包括所述当前块的高度值和宽度值;相应的,
    所述预设尺寸条件包括:所述高度值大于第一尺寸阈值且所述宽度值大于第二尺寸阈值。
  13. 根据权利要求4至10任一项所述的方法,其中,所述尺寸信息包括所述当前块的高度值和宽度值;相应的,
    所述预设尺寸条件包括:所述宽度值小于所述高度值的第一数值倍且所述高度值小于所述宽度值的第二数值倍,且所述高度值大于第一尺寸阈值且所述宽度值大于第二尺寸阈值。
  14. 根据权利要求1所述的方法,其中,所述至少一种候选模板包括:TL模板,T模板,L模板。
  15. 根据权利要求1所述的方法,其中,所述方法还包括:
    解码码流,确定所述当前块对应的预测差值;
    根据所述预测差值和所述预测值,确定所述当前块的重建值。
  16. 根据权利要求1所述的方法,其中,所述根据所述第一模板确定所述当前块对应的预测值,包括:
    基于所述第一模板确定所述当前块对应的最佳匹配块;
    根据所述最佳匹配块确定所述当前块对应的预测值。
  17. 一种编码方法,应用于编码器,所述方法包括:
    若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;
    根据所述第一模板确定所述当前块对应的预测值。
  18. 根据权利要求17所述的方法,其中,所述方法还包括:
    确定所述当前块对应的预测模式标识信息;
    若所述预测模式标识信息的取值为第一值,则确定当前块对应的预测模式为所述预设预测模式;
    若所述预测模式标识信息的取值为第二值,则确定当前块对应的预测模式不为所述预设预测模式。
  19. 根据权利要求17所述的方法,其中,所述预设预测模式包括以下预测模式中的任意一种:帧内模板匹配预测,帧内块复制,帧间模板匹配预测,基于模板的帧内模式推导,帧内模式推导。
  20. 根据权利要求18所述的方法,其中,所述根据所述当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板,包括:
    确定所述当前块对应的第一模板指示信息;
    若所述第一模板指示信息的取值为第三值,则确定所述第一模板为第一候选模板;
    若所述第一模板指示信息的取值为第四值,且所述当前块的尺寸信息满足预设尺寸条件,则确定所述当前块对应的第二模板指示信息,并根据所述第二模板指示信息确定所述第一模板。
  21. 根据权利要求20所述的方法,其中,所述根据所述第二模板指示信息确定所述第一模板,包括:
    若所述第二模板指示信息的取值为第五值,则确定所述第一模板为第二候选模板;
    若所述第二模板指示信息的取值为第六值,则确定所述第一模板为第三候选模板。
  22. 根据权利要求21所述的方法,其中,所述方法还包括:
    在所述第一模板指示信息的取值为第四值,且所述当前块的尺寸信息不满足所述预设尺寸条件的情况下,若所述当前块的宽度值大于所述当前块的高度值,则确定所述第一模板为所述第二候选模板;若所述当前块的高度值大于所述当前块的宽度值,则确定所述第一模板为所述第三候选模板。
  23. 根据权利要求18所述的方法,其中,所述根据所述当前块的尺寸信息在至少一个候选模板中确定当前块对应的第一模板,包括:
    若所述当前块的尺寸信息满足预设尺寸条件,则确定所述当前块对应的第一模板指示信息;
    若所述第一模板指示信息的取值为第三值,则确定所述第一模板为第一候选模板;
    若所述第一模板指示信息的取值为第四值,则确定所述当前块对应的第二模板指示信息,并根据所述第二模板指示信息确定所述第一模板。
  24. 根据权利要求23所述的方法,其中,所述根据所述第二模板指示信息确定所述第一模板,包括:
    若所述第二模板指示信息的取值为第五值,则确定所述第一模板为第二候选模板;
    若所述第二模板指示信息的取值为第六值,则确定所述第一模板为第三候选模板。
  25. 根据权利要求21,22,24任一项所述的方法,其中,
    所述第一候选模板为包括所述当前块的左侧相邻重建样本和上侧相邻重建样本的模板;
    所述第二候选模板为包括所述当前块的上侧相邻重建样本的模板;
    所述第三候选模板为包括所述当前块的左侧相邻重建样本的模板。
  26. 根据权利要求23所述的方法,其中,所述方法还包括:
    若所述当前块的尺寸信息不满足所述预设尺寸条件,则确定所述第一模板为所述第一候选模板。
  27. 根据权利要求20至26任一项所述的方法,其中,所述尺寸信息包括所述当前块的高度值和宽度值;相应的,
    所述预设尺寸条件包括:所述宽度值小于所述高度值的第一数值倍且所述高度值小于所述宽度值的第二数值倍。
  28. 根据权利要求20至26任一项所述的方法,其中,所述尺寸信息包括所述当前块的高度值和宽度值;相应的,
    所述预设尺寸条件包括:所述高度值大于第一尺寸阈值且所述宽度值大于第二尺寸阈值。
  29. 根据权利要求20至26任一项所述的方法,其中,所述尺寸信息包括所述当前块的高度值和宽度值;相应的,
    所述预设尺寸条件包括:所述宽度值小于所述高度值的第一数值倍且所述高度值小于所述宽度值的第二数值倍,且所述高度值大于第一尺寸阈值且所述宽度值大于第二尺寸阈值。
  30. 根据权利要求17所述的方法,其中,所述至少一种候选模板包括:TL模板,T模板,L模板。
  31. 根据权利要求17所述的方法,其中,所述方法还包括:
    确定所述当前块对应的预测差值;
    根据所述预测差值和所述预测值,确定所述当前块的重建值。
  32. 根据权利要求17所述的方法,其中,所述根据所述第一模板确定所述当前块对应的预测值,包括:
    基于所述第一模板确定所述当前块对应的最佳匹配块;
    根据所述最佳匹配块确定所述当前块对应的预测值。
  33. 一种码流,其中,所述码流是根据待编码信息进行比特编码生成的;其中,待编码信息包括下述至少一项:
    预测模式标识信息,第一模板指示信息,第二模板指示信息,预测差值。
  34. 一种编码器,包括第一确定单元;其中,
    所述第一确定单元,配置为若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
  35. 一种编码器,包括第一存储器和第一处理器;其中,
    所述第一存储器,用于存储能够在所述第一处理器上运行的计算机程序;
    所述第一处理器,用于在运行所述计算机程序时,执行如权利要求17至32中任一项所述的方法。
  36. 一种解码器,包括第二确定单元;其中,
    所述第二确定单元,配置为若当前块对应的预测模式为预设预测模式,则根据所述当前块的尺寸信息在至少一个候选模板中确定所述当前块对应的第一模板;其中,所述预设预测模式包括基于模板的预测模式;根据所述第一模板确定所述当前块对应的预测值。
  37. 一种解码器,所述解码器包括第二存储器和第二处理器;其中,
    所述第二存储器,用于存储能够在所述第二处理器上运行的计算机程序;
    所述第二处理器,用于在运行所述计算机程序时,执行如权利要求1至16中任一项所述的方法。
  38. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序被执行时实现如权利要求1至16中任一项所述的方法、或者实现如权利要求17至32中任一项所述的方法。
PCT/CN2023/085870 2023-04-03 2023-04-03 编解码方法、码流、编码器、解码器以及存储介质 WO2024207136A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2023/085870 WO2024207136A1 (zh) 2023-04-03 2023-04-03 编解码方法、码流、编码器、解码器以及存储介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2023/085870 WO2024207136A1 (zh) 2023-04-03 2023-04-03 编解码方法、码流、编码器、解码器以及存储介质

Publications (1)

Publication Number Publication Date
WO2024207136A1 true WO2024207136A1 (zh) 2024-10-10

Family

ID=92970755

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/085870 WO2024207136A1 (zh) 2023-04-03 2023-04-03 编解码方法、码流、编码器、解码器以及存储介质

Country Status (1)

Country Link
WO (1) WO2024207136A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101222641A (zh) * 2007-01-11 2008-07-16 华为技术有限公司 帧内预测编解码方法及其装置
CN102067601A (zh) * 2008-04-11 2011-05-18 汤姆森特许公司 视频编码和解码中模板匹配预测(tmp)的方法和装置
CN106464870A (zh) * 2014-03-31 2017-02-22 英迪股份有限公司 用于对帧内画面进行编码和解码的基于模板匹配的方法和装置
TW201804805A (zh) * 2016-06-03 2018-02-01 聯發科技股份有限公司 用於圖像和視訊編碼的基於模板的圖框內預測的方法和裝置
CN112106367A (zh) * 2018-03-30 2020-12-18 Vid拓展公司 基于编码和解码时延减少的基于模板的帧间预测技术

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101222641A (zh) * 2007-01-11 2008-07-16 华为技术有限公司 帧内预测编解码方法及其装置
CN102067601A (zh) * 2008-04-11 2011-05-18 汤姆森特许公司 视频编码和解码中模板匹配预测(tmp)的方法和装置
CN106464870A (zh) * 2014-03-31 2017-02-22 英迪股份有限公司 用于对帧内画面进行编码和解码的基于模板匹配的方法和装置
TW201804805A (zh) * 2016-06-03 2018-02-01 聯發科技股份有限公司 用於圖像和視訊編碼的基於模板的圖框內預測的方法和裝置
CN112106367A (zh) * 2018-03-30 2020-12-18 Vid拓展公司 基于编码和解码时延减少的基于模板的帧间预测技术

Similar Documents

Publication Publication Date Title
JP7303325B2 (ja) ビデオ処理方法、装置、記憶媒体、及び記憶方法
JP7612795B2 (ja) イントラコーディングモードにおけるマトリクスの導出
JP2024003124A (ja) 行列ベースイントラ予測における制約されたアップサンプリングプロセス
CN113068028B (zh) 视频图像分量的预测方法、装置及计算机存储介质
WO2022067805A1 (zh) 图像预测方法、编码器、解码器以及计算机存储介质
WO2022266971A1 (zh) 编解码方法、编码器、解码器以及计算机存储介质
TW202145794A (zh) 幀間預測方法、編碼器、解碼器以及電腦儲存媒介
JPWO2020211807A5 (zh)
CN114175653B (zh) 用于视频编解码中的无损编解码模式的方法和装置
WO2023193253A1 (zh) 解码方法、编码方法、解码器以及编码器
WO2024207136A1 (zh) 编解码方法、码流、编码器、解码器以及存储介质
CN113395520B (zh) 解码预测方法、装置及计算机存储介质
CN117730533A (zh) 超分辨率上采样和下采样
CN112313950B (zh) 视频图像分量的预测方法、装置及计算机存储介质
WO2024077562A1 (zh) 编解码方法及装置、编解码器、码流、存储介质
WO2024207132A1 (zh) 编解码方法、码流、编码器、解码器以及存储介质
WO2024119521A1 (zh) 编解码方法、码流、编码器、解码器以及存储介质
WO2024152383A1 (zh) 编解码方法、码流、编码器、解码器以及存储介质
WO2024113311A1 (zh) 编解码方法、编解码器、码流以及存储介质
RU2815175C2 (ru) Составление списка наиболее вероятных режимов для матричного внутрикадрового предсказания
WO2024077553A1 (zh) 视频编解码方法、装置、设备、系统、及存储介质
WO2024108391A1 (zh) 视频编解码方法、装置、设备、系统、及存储介质
WO2025007272A1 (zh) 编解码方法、码流、编码器、解码器以及存储介质
TW202502041A (zh) 編解碼方法及裝置、編解碼器、碼流、電子設備、儲存媒介
TW202431839A (zh) 編解碼方法、碼流、編碼器、解碼器以及儲存媒介

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23931214

Country of ref document: EP

Kind code of ref document: A1