Video encoding, decoding method and decoder
A video encoding, decoding method and a decoder are disclosed. The method includes: decoding a bitstream to determine a first-type intra prediction mode parameter of a current block; determining first prediction values of the current block according to the first-type intra prediction mode parameter; determining a first transform parameter of the current block based on the first prediction values of the current block or the first-type intra prediction mode parameter of the current block; determining, based on the first transform parameter, a second transform parameter for transforming the current block; transforming, based on the second transform parameter, transform coefficients of the current block to determine residuals of the current block; and determining reconstructed values of the current block based on the residuals and the first prediction values.
1 . A method for decoding a video, applied to a decoder and comprising:
decoding a bitstream to determine a first-type intra prediction mode of a current block;
determining first prediction values of the current block according to the first-type intra prediction mode;
determining a first transform parameter of the current block based on the first prediction values of the current block or the first-type intra prediction mode of the current block;
determining, based on the first transform parameter, a second transform parameter for transforming the current block, wherein the second transform parameter comprises an index parameter of a transform kernel candidate set;
transforming, based on the second transform parameter, transform coefficients of the current block to determine residuals of the current block; and
determining reconstructed values of the current block based on the residuals and the first prediction values,
wherein determining the first transform parameter of the current block based on the first prediction values of the current block or the first-type intra prediction mode of the current block comprises:
determining a first index of a second-type intra prediction mode of the current block based on the first prediction values of the current block; and
determining the first transform parameter of the current block based on the first index of the second-type intra prediction mode of the current block,
wherein the method further comprises:
setting the first transform parameter of the current block to be equal to the first index of the second-type intra prediction mode of the current block.
2 . The method of claim 1 , wherein determining the first transform parameter of the current block based on the first prediction values of the current block or the first-type intra prediction mode of the current block comprises:
determining a first index of a second-type intra prediction mode of the current block based on the first-type intra prediction mode; and
determining the first transform parameter of the current block based on the first index of the second-type intra prediction mode,
wherein the second-type intra prediction mode comprises at least one of: a planar mode, a direct current mode, or an angular intra prediction mode.
3 . The method of claim 1 , wherein determining, based on the first transform parameter, the second transform parameter for transforming the current block comprises:
determining the second transform parameter corresponding to the first transform parameter according to a preset first mapping table between first transform parameters and second transform parameters,
wherein the second transform parameter further comprises at least one of: a transform kernel index parameter, or a scanning sequence parameter of transform parameters, wherein the transform kernel index parameter indicates a transform kernel to be used in decoding the transform parameters of the current block, the scanning sequence parameter indicates a scanning sequence of the transform parameters, and the scanning sequence comprises a horizontal sequence and a vertical sequence.
4 . The method of claim 1 , wherein determining the first index of the second-type intra prediction mode of the current block based on the first prediction values of the current block comprises:
determining, based on the first prediction values, an index set of second-type intra prediction modes of the first prediction values; and
determining, based on the index set of the second-type intra prediction modes of the first prediction values, the first index of the second-type intra prediction mode of the current block, wherein the index set of the second-type intra prediction modes stores accumulative weight values corresponding to a portion or all of admissible values of indexes of the second-type intra prediction modes,
wherein determining, based on the first prediction values of the current block, the index set of the second-type intra prediction modes of the first prediction values comprises:
for each of a portion or all of the first prediction values, determining a gradient value in a horizontal direction and a gradient value in a vertical direction of a sample point corresponding to the first prediction value; and
determining the index set of the second-type intra prediction modes of the first prediction values based on gradient values in the horizontal direction and gradient values in the vertical direction of sample points.
5 . The method of claim 4 , wherein determining the index set of the second-type intra prediction modes of the first prediction values based on gradient values in the horizontal direction and gradient values in the vertical direction of the sample points comprises:
determining a gradient angle value of the sample point according to the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point;
determining a second index of a second-type intra prediction mode corresponding to the gradient angle value according to the gradient angle value of the sample point; and
updating an accumulative weight value corresponding to the determined second index of the second-type intra prediction mode in the index set of the second-type intra prediction modes,
wherein determining the gradient angle value of the sample point according to the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point comprises:
determining the gradient angle value of the sample point based on the gradient value in the horizontal direction, the gradient value in the vertical direction of the sample point, and a preset function.
6 . The method of claim 5 , wherein the preset function is an arc-tangent function, and the arc-tangent function is a ratio of the gradient value in the horizontal direction of the sample point to the gradient value in the vertical direction of the sample point; and determining the gradient angle value of the sample point based on the gradient value in the horizontal direction, the gradient value in the vertical direction of the sample point, and the preset function comprises: processing, based on the arc-tangent function, the ratio of the gradient value in the horizontal direction of the sample point to the gradient value in the vertical direction of the sample point, to determine the gradient angle value of the sample point, or
wherein the preset function is a second mapping table of the gradient angle value of the sample point and the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point; and determining the gradient angle value of the sample point based on the gradient value in the horizontal direction, the gradient value in the vertical direction of the sample point, and the preset function comprises: inputting, into the second mapping table, the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point, or a ratio of the gradient value in the horizontal direction of the sample point to the gradient value in the vertical direction of the sample point, to output the gradient angle value of the sample point.
7 . The method of claim 5 , wherein determining the second index of the second-type intra prediction mode corresponding to the gradient angle value of the sample point according to the gradient angle value of the sample point comprises: determining a second-type intra prediction mode index value corresponding to an angular intra prediction direction having a minimum included angle with a direction indicated by the gradient angle value among angular intra prediction directions indicated by the portion or all of admissible values of the indexes of the second-type intra prediction modes; and setting the second index of the second-type intra prediction mode corresponding to the gradient angle value to be the second-type intra prediction mode index value or
wherein determining the second index of the second-type intra prediction mode corresponding to the gradient angle value of the sample point according to the gradient angle value of the sample point comprises: determining the second index of the second-type intra prediction mode corresponding to the gradient angle value according to a preset third mapping table between gradient angle values and second-type intra prediction mode indexes, wherein the third mapping table represents correspondences between gradient angle values of different values or in different value ranges and the second-type intra prediction mode indexes.
8 . The method of claim 5 , wherein updating the accumulative weight value corresponding to the determined second index of the second-type intra prediction mode in the index set of the second-type intra prediction modes comprises: incrementing, by a set numeric value, the accumulative weight value corresponding to the determined second index of the second-type intra prediction mode in the index set of the second-type intra prediction modes,
wherein the set numeric value equals 1 or the set numeric value equals a sum of an absolute value of the gradient value in the horizontal direction and an absolute value of the gradient value in the vertical direction.
9 . The method of claim 4 , wherein determining, based on the index set of the second-type intra prediction modes of the first prediction values, the first index of the second-type intra prediction mode of the current block comprises:
setting the first index of the second-type intra prediction mode of the current block to be a second index of a second-type intra prediction mode corresponding to a maximum accumulative weight value in the index set of the second-type intra prediction modes corresponding to the first prediction values,
wherein determining the first index of the second-type intra prediction mode of the current block based on the first prediction values of the current block comprises:
determining second-type intra prediction values of the current block according to a candidate second-type intra prediction mode; and
determining the first index of the second-type intra prediction mode of the current block based on the first intra prediction values and the second-type intra prediction values.
10 . The method of claim 9 , wherein the candidate second-type intra prediction mode comprises one or more of: a planar mode, a direct current mode, or an angular intra prediction mode, or
wherein determining, based on the first intra prediction values and the second-type intra prediction values, the first index of the second-type intra prediction mode of the current block comprises: determining a first prediction error of the first intra prediction values and the second-type intra prediction values; determining an index value corresponding to the candidate second-type intra prediction mode corresponding to a case where the first prediction error satisfies a first preset condition as the first index of the second-type intra prediction mode of the current block.
11 . A method for encoding a video, applied to an encoder and comprising:
determining a first-type intra prediction mode;
determining first prediction values of a current block according to the first-type intra prediction mode, and calculating residuals between original values of the current block and the first prediction values;
determining a first transform parameter of the current block based on the first prediction values of the current block or the first-type intra prediction mode of the current block;
determining, based on the first transform parameter, a second transform parameter for transforming the current block, wherein the second transform parameter comprises an index parameter of a transform kernel candidate set; and
transforming, based on the second transform parameter, the residuals to obtain transform coefficients of the current block,
wherein determining the first transform parameter of the current block according to the first prediction values of the current block or the first-type intra prediction mode of the current block comprises:
determining a first index of a second-type intra prediction mode of the current block based on the first prediction values of the current block; and
determining the first transform parameter of the current block based on the first index of the second-type intra prediction mode of the current block,
wherein the method further comprises:
setting the first transform parameter of the current block to be equal to the first index of the second-type intra prediction mode of the current block.
12 . The method of claim 11 , wherein determining the first transform parameter of the current block based on the first prediction values of the current block or the first-type intra prediction mode of the current block comprises:
determining a first index of a second-type intra prediction mode of the current block based on the first-type intra prediction mode; and
determining the first transform parameter of the current block based on the first index of the second-type intra prediction mode.
13 . The method of claim 11 , wherein
the second-type intra prediction mode comprises at least one of: a planar mode, a direct current mode, or an angular intra prediction mode.
14 . The method of claim 11 , wherein determining, based on the first transform parameter, the second transform parameter for transforming the current block comprises: determining the second transform parameter corresponding to the first transform parameter according to a preset first mapping table between first transform parameters and second transform parameters, or
wherein the second transform parameter further comprises at least one of: a transform kernel index parameter, or a scanning sequence parameter of transform parameters, wherein the transform kernel index parameter indicates a transform kernel to be used in decoding the transform parameters of the current block, the scanning sequence parameter indicates a scanning sequence of the transform parameters, and the scanning sequence comprises a horizontal sequence and a vertical sequence.
15 . The method of claim 11 , wherein determining the first index of the second-type intra prediction mode of the current block based on the first prediction values of the current block comprises:
determining, based on the first prediction values, an index set of second-type intra prediction modes corresponding to the first prediction values; and
determining, based on the index set of the second-type intra prediction modes of the first prediction values, the first index of the second-type intra prediction mode of the current block, wherein the index set of the second-type intra prediction modes stores accumulative weight values corresponding to a portion or all of admissible values of indexes of the second-type intra prediction modes,
wherein determining, based on the first prediction values of the current block, the index set of the second-type intra prediction modes of the first prediction values comprises:
for each of a portion or all of the first prediction values, determining a gradient value in a horizontal direction and a gradient value in a vertical direction of a sample point corresponding to the first prediction value; and
determining the index set of the second-type intra prediction modes of the first prediction values based on gradient values in the horizontal direction and gradient values in the vertical direction of sample points.
16 . The method of claim 15 , wherein determining the index set of the second-type intra prediction modes of the first prediction values based on gradient values in the horizontal direction and gradient values in the vertical direction of sample points comprises:
determining a gradient angle value of the sample point according to the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point;
determining a second index of a second-type intra prediction mode corresponding to the gradient angle value according to the gradient angle value of the sample point; and
updating an accumulative weight value corresponding to the determined second index of the second-type intra prediction mode in the index set of the second-type intra prediction modes,
wherein determining the gradient angle value of the sample point according to the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point comprises:
determining the gradient angle value of the sample point based on the gradient value in the horizontal direction, the gradient value in the vertical direction of the sample point, and a preset function.
17 . The method of claim 16 , wherein the preset function is an arc-tangent function, and the arc-tangent function is a ratio of the gradient value in the horizontal direction of the sample point to the gradient value in the vertical direction of the sample point; and
determining the gradient angle value of the sample point based on the gradient value in the horizontal direction, the gradient value in the vertical direction of the sample point, and the preset function comprises:
processing, based on the arc-tangent function, the ratio of the gradient value in the horizontal direction of the sample point to the gradient value in the vertical direction of the sample point, to determine the gradient angle value of the sample point,
or wherein the preset function is a second mapping table of the gradient angle value of the sample point and the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point; and
determining the gradient angle value of the sample point based on the gradient value in the horizontal direction, the gradient value in the vertical direction of the sample point, and the preset function comprises:
inputting, into the second mapping table, the gradient value in the horizontal direction and the gradient value in the vertical direction of the sample point or a ratio of the gradient value in the horizontal direction of the sample point to the gradient value in the vertical direction of the sample point, to output the gradient angle value of the sample point.
18 . A non-transitory computer-readable storage medium, having a computer program and a bitstream stored thereon, wherein the computer program, when executed by a processor, enables the processor to perform the steps of the encoding method of claim 11 to generate the bitstream.