Pseudo contour optimization method, video coding method and electronic equipment

By downsampling and judging the coding tree unit of the video to be encoded, marking the brightness gradient area block and implementing optimization strategies, the problem that pseudo-contour optimization cannot be deployed on the encoding end in the prior art is solved, and the effect of optimizing the pseudo-contour during the encoding process is realized and the user experience is improved.

CN119603449APending Publication Date: 2025-03-11SHANGHAI FULLHAN MICROELECTRONICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411818927.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-11

AI Technical Summary

Technical Problem

In the prior art, the pseudo-contour optimization scheme is usually carried out after decoding, and cannot be deployed on the encoding end, and a pixel-by-pixel processing method is adopted, resulting in high computational complexity and difficult to apply on the encoding end.

Method used

By downsampling all encoding tree units in the video to be encoded, their pseudo-contour features are obtained, they are judged whether they meet the preset conditions, marked as brightness gradient area blocks, and optimization strategies are implemented during the encoding process, such as limiting the encoding mode to the directionless mode or reducing the quantization step.

Benefits of technology

During the encoding process, the pseudo-contour is optimized, the generation of pseudo-contours is reduced, the user's viewing experience can be improved, and it can be deployed on the encoding side, avoiding the increase in computing complexity caused by pixel-by-pixel processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603449A_ABST
    Figure CN119603449A_ABST
Patent Text Reader

Abstract

The invention provides a pseudo contour optimization method, a video coding method and an electronic device, and the method comprises the steps: carrying out the down-sampling of all coding tree units in a to-be-coded video, and obtaining an image block with the corresponding size of N * N; for each coding tree unit, acquiring a false contour feature of the image block of the coding tree unit, judging whether the false contour feature of the image block of the coding tree unit meets a false contour preset condition, and if so, marking the coding tree unit as a brightness gradient region block; wherein the pseudo contour features comprise a horizontal gradient of brightness, a vertical gradient of brightness, a gradient amplitude of brightness, a high-frequency coefficient average value, a brightness extreme value and brightness uniformity; and implementing an optimization strategy on all the coding tree units marked as the brightness gradient region blocks in the video to be coded so as to optimize the false contour generated in the coding process. According to the invention, the pseudo contour generated in the coding process can be optimized, the watching experience of a user is improved, and the pseudo contour optimization method can be deployed at a coding end.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of video encoding, and in particular to a pseudo contour optimization method, a video encoding method and an electronic device. Background Art

[0002] The high-efficiency video coding standard H.265 / HEVC uses spatial correlation and temporal correlation to generate predicted pixels during the encoding process, then subtracts the original pixels from the predicted pixels to obtain residual pixels, and finally encodes the residual pixels. In order to minimize the amount of data that needs to be transmitted and stored, the video encoder quantizes the frequency domain coefficients of these residual data to reduce the transmission cost. However, quantization inevitably introduces image distortion. In particular, in some specific areas, due to the loss of high-frequency information, encoding pseudo-contours may occur, that is, artificial contours that do not originally exist appear in the encoded image, which will reduce the visual experience of the human eye.

[0003] The existing solutions generally analyze the characteristics of pseudo contours, use a series of features to detect the pseudo contour areas in the decoded video, and then process them pixel by pixel. Specifically, first remove the smooth areas where the gradient changes are negligible according to the degree of gradient change of each pixel. At the same time, in order to ensure that the detected area does not include real textures and edge areas, areas with large gradient amplitudes are also eliminated, so that the pseudo contour areas in the video can be determined. Then, for each pixel point judged as a pseudo contour, the pixel values ​​on both sides of the pseudo contour are jittered, that is, a window is set around each pixel point judged as a pseudo contour, and within the window, a pixel value is randomly selected by a random seed to replace the original pixel value of the point. Finally, the average filtering technology is used to make the improved pseudo contour smoother, so as to further improve the visual experience of the human eye.

[0004] However, existing solutions often perform pseudo contour optimization on decoded videos, that is, pseudo contour detection and improvement are performed only after the video has been decoded. This pseudo contour optimization solution is more suitable for deployment at the decoding end, but cannot be deployed at the encoding end. In addition, the existing pseudo contour optimization solution adopts a pixel-by-pixel processing method, that is, firstly judging whether it is a pseudo contour area pixel by pixel, and then modifying the pixels in the pseudo contour area pixel by pixel according to the judgment result. The pixel-by-pixel processing method is difficult to be directly transplanted to the encoding end for application. Summary of the invention

[0005] The purpose of the present invention is to provide a pseudo contour optimization method, a video encoding method and an electronic device to solve one or more problems existing in the prior art, such as pseudo contour optimization schemes often perform pseudo contour optimization on decoded videos and adopt a pixel-by-pixel processing method, which makes it impossible to be deployed on the encoding end.

[0006] To achieve the above object, the present invention is implemented by the following technical scheme: a pseudo contour optimization method, comprising:

[0007] All coding tree units in the video to be coded are downsampled to obtain image blocks of corresponding size N×N;

[0008] For each of the coding tree units, a pseudo contour feature of the image block of the coding tree unit is obtained, and it is determined whether the pseudo contour feature of the image block of the coding tree unit meets a pseudo contour preset condition. If so, the coding tree unit is marked as a brightness gradient area block; wherein the pseudo contour feature includes a horizontal gradient of brightness, a vertical gradient of brightness, a gradient amplitude of brightness, an average value of high-frequency coefficients, a brightness extreme value, and a brightness uniformity;

[0009] An optimization strategy is implemented for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, so as to optimize the pseudo contours generated in the encoding process.

[0010] Optionally, the brightness extreme values ​​include a maximum brightness value, a minimum brightness value, and a brightness extreme difference value; the pseudo-contour optimization method also includes determining whether the pseudo-contour feature of the image block meets the pseudo-contour preset condition in the following manner: if the maximum value of the horizontal gradient of the brightness is greater than a first preset detection value, or the maximum value of the vertical gradient of the brightness is greater than a second preset detection value, or the maximum value of the gradient amplitude of the brightness is greater than a third preset detection value, or the average value of the high-frequency coefficient is less than a fourth preset detection value or greater than a fifth preset detection value, or the maximum brightness value is less than a sixth preset detection value, or the minimum brightness value is greater than a seventh preset detection value, or the brightness extreme difference value is less than an eighth preset detection value, or the uniformity of the brightness is greater than a ninth preset detection value, then it is determined that the pseudo-contour feature of the image block does not meet the pseudo-contour preset condition; otherwise, it is determined that the pseudo-contour feature of the image block meets the pseudo-contour preset condition.

[0011] Optionally, the maximum value of the horizontal gradient / vertical gradient of the brightness of the image block is obtained by: calculating the square of the difference in brightness values ​​of adjacent pixels in the horizontal / vertical direction in the current image block, and taking the maximum value in the calculation result as the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block; or, if there is an image block on the adjacent right / lower side of the current image block, calculating the square of the difference in brightness values ​​of adjacent pixels in the horizontal / vertical direction in the current image block and calculating the square of the difference in brightness values ​​between the last column / row of pixels of the current image block and the first column / row of pixels of the image block on its adjacent right / lower side in the horizontal / vertical direction, and taking the maximum value in the calculation result as the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block.

[0012] Optionally, the maximum value of the gradient amplitude of the brightness of the image block is obtained in the following manner: calculating the square of the difference in brightness values ​​of adjacent pixels in the horizontal direction in the current image block to obtain a gradient matrix in the horizontal direction; calculating the square of the difference in brightness values ​​of adjacent pixels in the vertical direction in the current image block to obtain a gradient matrix in the vertical direction; respectively calculating the arithmetic square root of the sum of data at corresponding positions in the gradient matrix in the horizontal direction and the gradient matrix in the vertical direction, and taking the maximum value of the calculation results as the maximum value of the gradient amplitude of the brightness of the current image block.

[0013] Optionally, the average value of the high-frequency coefficients of the image block is obtained in the following manner: performing discrete cosine transform on the current image block to obtain a frequency domain coefficient matrix; and taking the average value of the high-frequency coefficients in the frequency domain coefficient matrix as the average value of the high-frequency coefficients of the current image block.

[0014] Optionally, the maximum brightness value, the minimum brightness value and the extreme brightness difference value of the image block are obtained in the following manner: the brightness values ​​of all pixels in the current image block are obtained, the maximum brightness value is used as the maximum brightness value of the current image block, the minimum brightness value is used as the minimum brightness value of the current image block, and the difference between the maximum brightness value and the minimum brightness value is used as the extreme brightness difference value of the current image block.

[0015] Optionally, the uniformity of the brightness of the image block is obtained in the following manner: obtaining the brightness values ​​of all pixels in the current image block, calculating the probability of each brightness value in the range of 0-255 appearing in the current image block, and taking the sum of the squares of each obtained probability as the uniformity of the brightness of the current image block.

[0016] Optionally, the optimization strategy is implemented for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, including: limiting the coding mode of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded to a non-directional mode; or, reducing the quantization step size of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded; or, limiting the coding mode of a part of the coding tree units in the video to be encoded that are marked as the brightness gradient area blocks to a non-directional mode, and reducing the quantization step size of the coding tree units in the remaining part of the video to be encoded that are marked as the brightness gradient area blocks.

[0017] To achieve the above object, the present invention further provides a video encoding method, comprising: executing any one of the above-mentioned pseudo contour optimization methods when encoding a video to be encoded.

[0018] To achieve the above-mentioned objectives, the present invention also provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the pseudo-contour optimization method described in any one of the above-mentioned items is implemented or the video encoding method described in any one of the above-mentioned items is implemented.

[0019] Compared with the prior art, the pseudo contour optimization method, video encoding method and electronic device provided by the present invention have the following beneficial effects:

[0020] The pseudo contour optimization method provided by the present invention comprises: first, downsampling all coding tree units in the video to be encoded to obtain an image block of a corresponding size of N×N; then, for each coding tree unit, obtaining the pseudo contour feature of the image block of the coding tree unit, judging whether the pseudo contour feature of the image block of the coding tree unit meets the pseudo contour preset condition, and if so, marking the coding tree unit as a brightness gradient area block; wherein the pseudo contour feature includes the horizontal gradient of brightness, the vertical gradient of brightness, the gradient amplitude of brightness, the average value of high-frequency coefficients, the extreme value of brightness, and the uniformity of brightness; finally, implementing an optimization strategy for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded to optimize the pseudo contours generated by the encoding process. Therefore, the pseudo contour optimization method provided by the present invention, by first downsampling each coding tree unit in the video to be encoded to obtain an image block, and obtaining the pseudo contour feature of the image block of each coding tree unit, lays a good foundation for marking the coding tree units as brightness gradient area blocks in the video to be encoded. Next, by judging whether the pseudo contour feature of the image block of each coding tree unit meets the pseudo contour preset condition, the coding tree unit marked as the brightness gradient area block in the video to be encoded can be obtained. Finally, by implementing the optimization strategy for all coding tree units marked as brightness gradient area blocks in the video to be encoded, the pseudo contour generated by the encoding process can be optimized, thereby improving the user viewing experience. By adopting the pseudo contour optimization method provided by the present invention, the pseudo contour is optimized during the encoding process, so that the pseudo contour problem of the encoded code stream has been improved after decoding. The pseudo contour optimization method provided by the present invention can be deployed at the encoding end.

[0021] Further, the optimization strategy is implemented for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, including: limiting the coding mode of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded to the non-directional mode; or reducing the quantization step size of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded; or, limiting the coding mode of the coding tree units of a part of the video to be encoded marked as the brightness gradient area blocks to the non-directional mode, and reducing the quantization step size of the coding tree units of the remaining part of the video to be encoded marked as the brightness gradient area blocks. Therefore, the pseudo contour optimization method provided by the present invention can reduce the high-frequency information loss of the coding tree units marked as the brightness gradient area blocks in the video to be encoded, thereby reducing the generation of pseudo contours. In addition, compared with the pixel-by-pixel processing method in the prior art, the pseudo contour optimization method provided by the present invention can optimize in units of coding tree units by limiting the coding mode of the coding tree units marked as brightness gradient area blocks to the non-directional mode, thereby avoiding the problem of increased computational complexity caused by pixel-by-pixel processing. It can also accelerate the coding mode decision process of the coding tree units marked as brightness gradient area blocks, thereby improving coding efficiency.

[0022] Since the video encoding method provided by the present invention and the electronic device provided by the present invention belong to the same inventive concept as the pseudo-contour optimization method provided by the present invention, the video encoding method provided by the present invention and the electronic device provided by the present invention at least have all the advantages of the pseudo-contour optimization method provided by the present invention. For the advantages of the video encoding method provided by the present invention and the electronic device provided by the present invention, please refer to the relevant description of the beneficial effects of the pseudo-contour optimization method provided by the present invention, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 The original video image corresponding to a frame of pseudo contour generation area in the prior art;

[0024] Figure 2 for Figure 1 The encoded video image corresponding to the original video image shown;

[0025] Figure 3 for Figure 1 The brightness variation diagram of the original video image in the horizontal direction is shown;

[0026] Figure 4 for Figure 2 The brightness variation diagram of the video image in the horizontal direction after encoding is shown;

[0027] Figure 5 A schematic diagram of the overall steps of a pseudo contour optimization method provided in the first embodiment of the present invention;

[0028] Figure 6 A schematic diagram of a specific process of a pseudo contour optimization method provided in Embodiment 1 of the present invention. DETAILED DESCRIPTION

[0029] The pseudo contour optimization method, video encoding method and electronic device proposed in the present invention are further described in detail below in conjunction with the accompanying drawings and specific embodiments. According to the following description, the advantages and features of the present invention will be clearer. It should be noted that the drawings are all in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention. In order to make the purposes, features and advantages of the present invention more obvious and easy to understand, please refer to the accompanying drawings. It should be noted that the structures, proportions, sizes, etc. illustrated in the drawings of this specification are only used to match the contents disclosed in the specification for people familiar with this technology to understand and read, and are not used to limit the limiting conditions for the implementation of the present invention. Any modification of the structure, change of the proportional relationship or adjustment of the size, in the case of the same or similar effects and purposes that can be achieved by the present invention, should still fall within the scope of the technical content disclosed by the present invention. The specific design features of the present invention disclosed herein include, for example, specific dimensions, directions, positions and shapes, which will be determined in part by the specific environment to be applied and used. And, in the implementations described below, sometimes the same figure mark is used to represent the same part or part with the same function between different drawings, and its repeated description is omitted.

[0030] In order to make it easier to understand and explain the present invention, before describing the specific implementation methods of the pseudo contour optimization method, video encoding method and electronic device provided by the present invention, the research process of proposing the present invention is briefly described as follows.

[0031] First, the inventors analyzed the causes of pseudo contours. By observing the coding mode of the pseudo contour generating area during the coding process, it was found that the coding tree units in the area would eventually use the directional mode for intra-frame prediction. Using the directional mode for intra-frame prediction can maximize the use of spatial correlation. However, by observing the residual frequency domain coefficients after encoding the coding tree units in the area, it was found that with the increase of the quantization step size, the high-frequency coefficients in the transformed residual frequency domain coefficients are more likely to be quantized to 0, resulting in the loss of high-frequency information in the reconstructed video in this area, thus generating the pseudo contour phenomenon.

[0032] In order to further understand the relationship between high-frequency information loss and the generation of pseudo contours, the inventors used a simple statistical analysis chart to observe the pseudo contour generation area. Figures 1 to 4 , Figure 1The original video image corresponding to a frame of pseudo contour generation area in the prior art is schematically given; Figure 2 for Figure 1 The encoded video image corresponding to the original video image shown; Figure 3 for Figure 1 The brightness variation diagram of the original video image in the horizontal direction is shown; Figure 4 for Figure 2 The diagram shows the brightness change of the encoded video image in the horizontal direction. Figure 3 and Figure 4 In the figure, the horizontal axis Y Position represents the horizontal position, and the vertical axis Intensity Value represents the brightness value.

[0033] Furthermore, after in-depth research, the inventors found that the brightness change of the original video image in the horizontal direction has more frequent fluctuations, while the brightness change of the encoded video image in the horizontal direction presents a step-by-step characteristic. The reason for this is that during the encoding process, due to the large quantization step size of the coding tree unit, the high-frequency coefficients are more easily quantized to 0, resulting in the loss of high-frequency information.

[0034] Based on the above research, the core idea of ​​the present invention is to solve technical problems such as the pseudo contour optimization solutions in the prior art often perform pseudo contour optimization on decoded videos and adopt a pixel-by-pixel processing method, which makes it impossible to be deployed on the encoding end.

[0035] In order to realize the above idea, the present invention provides a pseudo-contour optimization method, a video encoding method and an electronic device, which optimizes the pseudo-contours generated by the encoding process by marking the coding tree units that are brightness gradient area blocks in the video to be encoded, and implementing optimization strategies on these coding tree units during the encoding process, thereby solving one or more problems of existing pseudo-contour optimization schemes, such as often performing pseudo-contour optimization on decoded videos and adopting pixel-by-pixel processing methods that make it impossible to be deployed on the encoding end.

[0036] Next, the specific implementations of the pseudo contour optimization method, video encoding method and electronic device provided by the present invention are described in detail as follows.

[0037] Embodiment 1

[0038] This embodiment provides a pseudo contour optimization method. Figure 5 and Figure 6 , Figure 5 A schematic diagram of the overall steps of the pseudo contour optimization method provided in this embodiment; Figure 6 A specific flow chart of the pseudo contour optimization method provided in this embodiment. Figure 5 and Figure 6 It can be seen that the pseudo contour optimization method includes:

[0039] S1000: down-sampling all coding tree units in the video to be coded to obtain image blocks of a corresponding size of N×N;

[0040] S2000: For each of the coding tree units, obtain a pseudo contour feature of the image block of the coding tree unit, determine whether the pseudo contour feature of the image block of the coding tree unit meets a pseudo contour preset condition, and if so, mark the coding tree unit as a brightness gradient area block; wherein the pseudo contour feature includes a horizontal gradient of brightness, a vertical gradient of brightness, a gradient amplitude of brightness, an average value of high-frequency coefficients, a brightness extreme value, and a brightness uniformity;

[0041] S3000: Implementing an optimization strategy on all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, so as to optimize the pseudo contours generated in the encoding process.

[0042] Therefore, the pseudo contour optimization method provided by the present embodiment, by first downsampling each coding tree unit in the video to be encoded to obtain an image block, and obtaining the pseudo contour features of the image block of each coding tree unit, lays a good foundation for marking the coding tree unit as a brightness gradient area block in the video to be encoded. Then, by judging whether the pseudo contour features of the image block of each coding tree unit meet the pseudo contour preset conditions, the coding tree unit marked as a brightness gradient area block in the video to be encoded can be obtained. Finally, by implementing an optimization strategy for all coding tree units marked as brightness gradient area blocks in the video to be encoded, the pseudo contour generated by the encoding process can be optimized, thereby improving the user viewing experience. Using the pseudo contour optimization method provided by the present embodiment, the pseudo contour is optimized during the encoding process, so that the pseudo contour problem has been improved after the encoded code stream is decoded. The pseudo contour optimization method provided by the present embodiment can be deployed at the encoding end.

[0043] It should be noted that, as can be understood by those skilled in the art, in the N×N image blocks of the present invention, N≥4, and N is preferably 4, 8, or 16. In addition, the present invention does not impose too many restrictions on the downsampling method and size of each coding tree unit in the video to be encoded. Exemplarily, in some of the embodiments, all coding tree units in the video to be encoded are downsampled using the average pooling method, and all are downsampled to obtain image blocks of size 8×8; in other embodiments, a part of the coding tree units in the video to be encoded are downsampled using the average pooling method to obtain image blocks of size 8×8, another part of the coding tree units in the video to be encoded are downsampled using the bilinear interpolation method to obtain image blocks of size 4×4, and the remaining part of the coding tree units in the video to be encoded are downsampled using the bicubic interpolation method to obtain image blocks of size 16×16.

[0044] Preferably, in step S2000, the brightness extreme value includes a brightness maximum value, a brightness minimum value, and a brightness extreme difference value; and the pseudo contour optimization method further includes determining whether the pseudo contour feature of the image block meets a pseudo contour preset condition by the following method:

[0045] S2100: If the maximum value of the horizontal gradient of the brightness is greater than the first preset detection value, or the maximum value of the vertical gradient of the brightness is greater than the second preset detection value, or the maximum value of the gradient amplitude of the brightness is greater than the third preset detection value, or the average value of the high-frequency coefficient is less than the fourth preset detection value or greater than the fifth preset detection value, or the maximum value of the brightness is less than the sixth preset detection value, or the minimum value of the brightness is greater than the seventh preset detection value, or the extreme difference value of the brightness is less than the eighth preset detection value, or the uniformity of the brightness is greater than the ninth preset detection value, it is determined that the pseudo contour feature of the image block does not meet the pseudo contour preset condition;

[0046] S2200: Otherwise, determining that the pseudo contour feature of the image block meets a pseudo contour preset condition.

[0047] Thus, by determining the pseudo contour feature of the image block whose maximum value of the horizontal gradient of the brightness is greater than the first preset detection value as not meeting the pseudo contour preset condition, the vertical texture in the video to be encoded can be removed; by determining the pseudo contour feature of the image block whose maximum value of the vertical gradient of the brightness is greater than the second preset detection value as not meeting the pseudo contour preset condition, the horizontal texture in the video to be encoded can be removed; by determining the pseudo contour feature of the image block whose maximum value of the gradient amplitude of the brightness is greater than the third preset detection value as not meeting the pseudo contour preset condition, the area with excessively large gradient amplitude of the brightness in the video to be encoded can be removed; by determining the pseudo contour feature of the image block whose average value of the high-frequency coefficient is less than the fourth preset detection value as not meeting the pseudo contour preset condition, the area with low texture complexity in the video to be encoded can be removed; By judging the pseudo-contour feature of the image block as not meeting the pseudo-contour preset condition, the area with high texture complexity in the video to be encoded can be removed; by judging the pseudo-contour feature of the image block whose maximum brightness is less than the sixth preset detection value as not meeting the pseudo-contour preset condition, the overly dark area in the video to be encoded can be removed; by judging the pseudo-contour feature of the image block whose minimum brightness is greater than the seventh preset detection value as not meeting the pseudo-contour preset condition, the overly bright area in the video to be encoded can be removed; by judging the pseudo-contour feature of the image block whose brightness extreme difference value is less than the eighth preset detection value as not meeting the pseudo-contour preset condition, the area in the video to be encoded where the brightness change is not large can be removed; by judging the pseudo-contour feature of the image block whose brightness uniformity is greater than the ninth preset detection value as not meeting the pseudo-contour preset condition, the area in the video to be encoded where the brightness distribution is concentrated (i.e., the area with high flatness) can be removed. The above judgment method can detect the coding tree units in the video to be encoded that can be marked as brightness gradient area blocks.

[0048] It should be noted that, as those skilled in the art can understand, the specific values ​​of the first preset detection value to the ninth preset detection value can be reasonably set according to the actual application scenario. For example, in some embodiments, the first preset detection value and the second preset detection value can both be 500, the third preset detection value can be 20, the fourth preset detection value can be 5, the fifth preset detection value can be 50, the sixth preset detection value can be 80, the seventh preset detection value can be 130, the eighth preset detection value can be 20, and the ninth preset detection value can be 0.04.

[0049] Further, in step S2100, the maximum value of the horizontal gradient / vertical gradient of the brightness of the image block is obtained by:

[0050] S2111: Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the horizontal / vertical direction, and use the maximum value in the calculation results as the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block; or, S2112: If there is an image block on the adjacent right / lower side of the current image block, calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the horizontal / vertical direction and calculate the square of the difference in brightness values ​​of the last column / row of pixels in the current image block and the first column / row of pixels in the image block on its adjacent right / lower side in the horizontal / vertical direction, and use the maximum value in the calculation results as the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block.

[0051] Exemplarily, the maximum value of the horizontal gradient of the brightness in step S2111 can be calculated by the following formula (1):

[0052]

[0053] Exemplarily, the maximum value of the vertical gradient of the brightness in step S2111 can be calculated by the following formula (2):

[0054]

[0055] In formula (1) and formula (2), Y 8×8 represents the current image block of size 8×8, and Ii,j represents the brightness value of the pixel in the i-th row and j-th column in the current image block.

[0056] It should be noted that, as those skilled in the art can understand, regardless of whether there is an image block on the adjacent right side / below the current image block, the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block can be obtained according to step S2111; if there is an image block on the adjacent right side / below the current image block, the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block can also be obtained according to step S2112; if the size of the current image block is different from the size of the image block on the adjacent right side or adjacent bottom side of the current image block, the maximum value of the horizontal gradient and the vertical gradient of the brightness of the current image block are obtained according to step S2111. Exemplarily, in some embodiments, there is an image block of size 4×4 on the right side of the current image block of size 8×8, and an image block of size 16×16 on the bottom side, and the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block can be obtained according to step S2111; in other embodiments, there is no image block on the right side of the current image block of size 4×4, and there is an image block of size 16×16 on the bottom side, and the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block can also be obtained according to step S2111.

[0057] Preferably, in step S2100, the maximum value of the gradient amplitude of the brightness of the image block is obtained by:

[0058] S2121: Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the horizontal direction to obtain a gradient matrix in the horizontal direction;

[0059] S2122: Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the vertical direction to obtain a gradient matrix in the vertical direction;

[0060] S2123: Calculate the arithmetic square root of the sum of the data at corresponding positions in the horizontal gradient matrix and the vertical gradient matrix respectively, and use the maximum value of the calculation results as the maximum value of the gradient amplitude of the brightness of the current image block.

[0061] Exemplarily, the maximum value of the gradient amplitude of the brightness in step S2100 can be calculated by the following formula (3):

[0062]

[0063] In formula (3), Y 8×8 represents the current image block of size 8×8, and Ii,j represents the brightness value of the pixel in the i-th row and j-th column in the current image block.

[0064] It should be noted that, as can be understood by those skilled in the art, regardless of whether there is an image block on the adjacent right side / below the current image block, the maximum value of the gradient amplitude of the brightness of the current image block can be obtained according to steps S2121 to S2123. In addition, if the size of the current image block is different from the size of the image block on the adjacent right side or the adjacent lower side of the current image block, the maximum value of the gradient amplitude of the brightness of the current image block is obtained according to steps S2121 to S2123. Exemplarily, in some embodiments, there is an image block of size 4×4 on the right side of the current image block of size 8×8, and an image block of size 16×16 on the lower side. The maximum value of the gradient amplitude of the brightness of the current image block can be obtained according to steps S2121 to S2123, and the sizes of the gradient matrices in the horizontal direction and the gradient matrices in the vertical direction are both 7×7.

[0065] It should be noted that the above is merely an exemplary description of a method for obtaining the maximum value of the gradient amplitude of the brightness of the image block, and is not a limitation of the present invention.

[0066] Exemplarily, in some other implementations, if there is an image block of the same size as the current image block on the adjacent right side of the current image block, and there is no image block on the adjacent lower side of the current image block, the maximum value of the gradient amplitude of the brightness of the current image block can also be obtained in the following manner:

[0067] S2124: Calculate the square of the difference in brightness values ​​between adjacent pixels in the current image block in the horizontal direction and calculate the square of the difference in brightness values ​​between the last column of pixels in the current image block and the first column of pixels in the image block adjacent to the right thereof in the horizontal direction to obtain a gradient matrix in the horizontal direction;

[0068] S2125: Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the vertical direction to obtain a gradient matrix in the vertical direction, and add a row of elements with all zeros at the bottom of the matrix by zero padding the matrix to obtain an expanded gradient matrix in the vertical direction;

[0069] S2126: Calculate the arithmetic square root of the sum of the data at corresponding positions in the horizontal gradient matrix and the expanded vertical gradient matrix respectively, and use the maximum value of the calculation results as the maximum value of the gradient amplitude of the brightness of the current image block.

[0070] Exemplarily, in some other implementations, if there are image blocks with the same size as the current image block on both the adjacent right side and the adjacent bottom side of the current image block, the maximum value of the gradient amplitude of the brightness of the current image block can also be obtained in the following manner:

[0071] S2127: Calculate the square of the difference in brightness values ​​between adjacent pixels in the current image block in the horizontal direction and calculate the square of the difference in brightness values ​​between the last column of pixels in the current image block and the first column of pixels in the image block adjacent to the right thereof in the horizontal direction to obtain a gradient matrix in the horizontal direction;

[0072] S2128: Calculate the square of the difference in brightness values ​​between adjacent pixels in the current image block in the vertical direction and calculate the square of the difference in brightness values ​​between the last row of pixels in the current image block and the first row of pixels in the image block adjacent to it in the vertical direction to obtain a gradient matrix in the vertical direction;

[0073] S2129: Calculate the arithmetic square root of the sum of the data at corresponding positions in the horizontal gradient matrix and the vertical gradient matrix respectively, and use the maximum value of the calculation results as the maximum value of the gradient amplitude of the brightness of the current image block.

[0074] Further, in step S2100, the average value of the high frequency coefficients of the image block is obtained by:

[0075] S2131: Performing discrete cosine transform on the current image block to obtain a frequency domain coefficient matrix;

[0076] S2132: Taking the average value of the high-frequency coefficients in the frequency domain coefficient matrix as the average value of the high-frequency coefficients of the current image block.

[0077] Exemplarily, the high frequency coefficient average value in step S2100 can be calculated by the following formula (4):

[0078]

[0079] In formula (4), the size of the current image block is 4×4, It represents the sum of all coefficients in the frequency domain coefficient matrix obtained after DCT transformation of the current image block. 0,0 Represents the first coefficient in the upper left corner of the frequency domain coefficient matrix obtained after DCT transformation of the current image block.

[0080] It should be noted that discrete cosine transform (i.e. DCT transform) can transform image blocks from spatial domain to frequency domain. DCT coefficients can reflect the low-frequency information and high-frequency information of image blocks. The smoother the image block, the more concentrated the frequency domain energy is in the low-frequency coefficients (i.e. DC coefficients). The more complex the texture of the image block, the more concentrated the frequency domain energy is in the high-frequency coefficients (i.e. AC coefficients).

[0081] Exemplarily, in some embodiments, a DCT transform is performed on an image block of size 8×8 to obtain a frequency domain coefficient matrix of size 8×8, wherein the first coefficient in the upper left corner of the frequency domain coefficient matrix is ​​a low-frequency coefficient, and the remaining coefficients in the frequency domain coefficient matrix are high-frequency coefficients. All high-frequency coefficients can be summed and then divided by 63 to obtain the average value of the high-frequency coefficients of the current image block.

[0082] Preferably, in step S2100, the maximum brightness value, the minimum brightness value and the extreme brightness difference value of the image block are obtained by:

[0083] S2141: Obtain the brightness values ​​of all pixels in the current image block, take the maximum brightness value as the maximum brightness value of the current image block, take the minimum brightness value as the minimum brightness value of the current image block, and take the difference between the maximum brightness value and the minimum brightness value as the brightness extreme difference value of the current image block.

[0084] Further, in step S2100, the uniformity of the brightness of the image block is obtained by:

[0085] S2151: Obtain the brightness values ​​of all pixels in the current image block, calculate the probability of each brightness value in the range of 0-255 appearing in the current image block, and use the sum of the squares of each obtained probability as the brightness uniformity of the current image block.

[0086] Exemplarily, the brightness uniformity in step S2100 can be calculated by the following formula (5):

[0087]

[0088] In formula (5), p(I) represents the probability that the brightness value I appears in the current image block.

[0089] It should be noted that the uniformity represents the similarity of pixel values ​​within an image block, and the larger the characteristic value, the smoother the corresponding area. In addition, the above is only an exemplary description, and the present invention does not impose too many restrictions on the method for obtaining the uniformity of the brightness of the image block.

[0090] Preferably, in step S3000, the optimizing strategy is implemented on all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, including:

[0091] S3110: limit the coding mode of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded to the non-directional mode; or, S3120: reduce the quantization step size of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded; or, S3130: limit the coding mode of a part of the coding tree units marked as the brightness gradient area blocks in the video to be encoded to the non-directional mode, and reduce the quantization step size of the coding tree units marked as the brightness gradient area blocks in the remaining part of the video to be encoded.

[0092] Therefore, by implementing the optimization strategy for all coding tree units marked as brightness gradient area blocks in the coded video, the high-frequency information loss of the coding tree units marked as brightness gradient area blocks can be reduced, thereby reducing the generation of pseudo contours. In addition, compared with the pixel-by-pixel processing method in the prior art, the pseudo contour optimization method provided in this embodiment can optimize in units of coding tree units by limiting the coding mode of the coding tree units marked as brightness gradient area blocks to a non-directional mode, thereby avoiding the problem of increased computational complexity caused by pixel-by-pixel processing. It can also accelerate the coding mode decision process of the coding tree units marked as brightness gradient area blocks and improve coding efficiency.

[0093] Preferably, the non-directional mode includes a direct current mode (DC mode) and a planar prediction mode (i.e., Planar mode). Thus, by limiting the coding mode of the coding tree unit marked as a brightness gradient area block to the DC mode or the Planar mode, all directional angle modes can be eliminated. When the coding tree unit marked as a brightness gradient area block is encoded using the DC mode or the Planar mode, the generation of pseudo contours can be well suppressed despite the large quantization step size.

[0094] It should be noted that the above is only an exemplary description of the optimization strategy implemented for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded. The present invention does not impose too many restrictions on the optimization strategy, and it is only necessary to retain as much high-frequency information of the coding tree units marked as the brightness gradient area blocks as possible.

[0095] In order to better understand the present invention, please continue to refer to Figure 6 , by way of example, one specific process of the pseudo contour optimization method provided in this embodiment is described.

[0096] SA1: All coding tree units in the coded video are downsampled to 8×8 size using the same downsampling method to obtain the corresponding image blocks;

[0097] For each of the coding tree units, the following steps SA2 to SA4 are performed:

[0098] SA2: Obtain pseudo contour features of the image block of the coding tree unit, including horizontal gradient of brightness, vertical gradient of brightness, gradient amplitude of brightness, average value of high-frequency coefficients, maximum brightness, minimum brightness, extreme difference of brightness, and uniformity of brightness;

[0099] SA3: Determine whether the pseudo contour feature of the image block meets the pseudo contour preset condition: if the maximum value of the horizontal gradient of the brightness is greater than 500, or the maximum value of the vertical gradient of the brightness is greater than 500, or the maximum value of the gradient amplitude of the brightness is greater than 20, or the average value of the high-frequency coefficient is less than 5 or greater than 50, or the maximum brightness is less than 80, or the minimum brightness is greater than 130, or the extreme brightness difference is less than 20, or the uniformity of the brightness is greater than 0.04, then it is determined that the pseudo contour feature of the image block does not meet the pseudo contour preset condition; otherwise, it is determined that the pseudo contour feature of the image block meets the pseudo contour preset condition;

[0100] SA4: marking the coding tree unit of the image block whose pseudo contour feature meets the pseudo contour preset condition as a brightness gradient area block;

[0101] SA5: restricting the coding modes of all the coding tree units marked as the brightness gradient area blocks in the to-be-encoded video to the DC mode or the Planar mode.

[0102] Embodiment 2

[0103] This embodiment provides a video encoding method, comprising: performing the pseudo contour optimization method described in any of the above embodiments when encoding a video to be encoded.

[0104] Therefore, the video encoding method provided by the present embodiment is used for encoding, which can reduce the probability of pseudo contours appearing in the encoded video, and make the pseudo contours appearing more mild, which can reduce the subjective experience impact caused by the pseudo contours. In addition, since the video encoding method provided by the present embodiment and the pseudo contour optimization method described in any of the above embodiments belong to the same inventive concept, the video encoding method provided by the present embodiment at least has all the advantages of the pseudo contour optimization method provided by the above embodiments. For the advantages of the video encoding method provided by the present embodiment, please refer to the relevant description of the beneficial effects of the pseudo contour optimization method provided by the above embodiments, which will not be repeated here.

[0105] Embodiment 3

[0106] This embodiment provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the pseudo-contour optimization method described in any one of the above embodiments or the video encoding method described in any one of the above embodiments is implemented.

[0107] Since the electronic device provided by this embodiment and the pseudo-contour optimization method described in any of the above-mentioned embodiments or the video encoding method described in any of the above-mentioned embodiments belong to the same inventive concept, the electronic device provided by this embodiment has at least all the advantages of the pseudo-contour optimization method provided by the above-mentioned embodiments or the video encoding method provided by the above-mentioned embodiments. For the advantages of the electronic device provided by this embodiment, please refer to the relevant description of the beneficial effects of the pseudo-contour optimization method provided by the above-mentioned embodiments or the video encoding method provided by the above-mentioned embodiments, which will not be repeated here.

[0108] In summary, the pseudo contour optimization method, video encoding method and electronic device provided by the present invention have the following advantages: the pseudo contour optimization method provided by the present invention comprises: first, downsampling all coding tree units in the video to be encoded to obtain an image block of a corresponding size of N×N; then, for each of the coding tree units, obtaining the pseudo contour feature of the image block of the coding tree unit, judging whether the pseudo contour feature of the image block of the coding tree unit meets the pseudo contour preset condition, and if so, marking the coding tree unit as a brightness gradient area block; wherein the pseudo contour feature includes the horizontal gradient of brightness, the vertical gradient of brightness, the gradient amplitude of brightness, the average value of high-frequency coefficients, the extreme value of brightness and the uniformity of brightness; finally, implementing an optimization strategy for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded to optimize the pseudo contours generated by the encoding process. Therefore, the pseudo contour optimization method provided by the present invention, by first downsampling each coding tree unit in the video to be encoded to obtain an image block, and obtaining the pseudo contour feature of the image block of each coding tree unit, lays a good foundation for marking the coding tree units as brightness gradient area blocks in the video to be encoded. Next, by judging whether the pseudo contour feature of the image block of each coding tree unit meets the pseudo contour preset condition, the coding tree unit marked as the brightness gradient area block in the video to be encoded can be obtained. Finally, by implementing the optimization strategy for all coding tree units marked as brightness gradient area blocks in the video to be encoded, the pseudo contour generated by the encoding process can be optimized, thereby improving the user viewing experience. By adopting the pseudo contour optimization method provided by the present invention, the pseudo contour is optimized during the encoding process, so that the pseudo contour problem of the encoded code stream has been improved after decoding. The pseudo contour optimization method provided by the present invention can be deployed at the encoding end.

[0109] Further, the optimization strategy is implemented for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, including: limiting the coding mode of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded to the non-directional mode; or reducing the quantization step size of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded; or, limiting the coding mode of the coding tree units of a part of the video to be encoded marked as the brightness gradient area blocks to the non-directional mode, and reducing the quantization step size of the coding tree units of the remaining part of the video to be encoded marked as the brightness gradient area blocks. Therefore, the pseudo contour optimization method provided by the present invention can reduce the high-frequency information loss of the coding tree units marked as the brightness gradient area blocks in the video to be encoded, thereby reducing the generation of pseudo contours. In addition, compared with the pixel-by-pixel processing method in the prior art, the pseudo contour optimization method provided by the present invention can optimize in units of coding tree units by limiting the coding mode of the coding tree units marked as brightness gradient area blocks to the non-directional mode, thereby avoiding the problem of increased computational complexity caused by pixel-by-pixel processing. It can also accelerate the coding mode decision process of the coding tree units marked as brightness gradient area blocks, thereby improving coding efficiency.

[0110] Since the video encoding method provided by the present invention and the electronic device provided by the present invention belong to the same inventive concept as the pseudo-contour optimization method provided by the present invention, the video encoding method provided by the present invention and the electronic device provided by the present invention at least have all the advantages of the pseudo-contour optimization method provided by the present invention. For the advantages of the video encoding method provided by the present invention and the electronic device provided by the present invention, please refer to the relevant description of the beneficial effects of the pseudo-contour optimization method provided by the present invention, which will not be repeated here.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.

Claims

1. A pseudo contour optimization method, characterized in that: include: All coding tree units in the video to be coded are downsampled to obtain image blocks of corresponding size N×N; For each of the coding tree units, a pseudo contour feature of the image block of the coding tree unit is obtained, and it is determined whether the pseudo contour feature of the image block of the coding tree unit meets a pseudo contour preset condition. If so, the coding tree unit is marked as a brightness gradient area block; wherein the pseudo contour feature includes a horizontal gradient of brightness, a vertical gradient of brightness, a gradient amplitude of brightness, an average value of high-frequency coefficients, a brightness extreme value, and a brightness uniformity; An optimization strategy is implemented for all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, so as to optimize the pseudo contours generated in the encoding process.

2. The pseudo contour optimization method according to claim 1, characterized in that: The brightness extreme value includes a brightness maximum value, a brightness minimum value, and a brightness extreme difference value; the pseudo contour optimization method further includes determining whether the pseudo contour feature of the image block meets the pseudo contour preset condition in the following manner: If the maximum value of the horizontal gradient of the brightness is greater than the first preset detection value, or the maximum value of the vertical gradient of the brightness is greater than the second preset detection value, or the maximum value of the gradient amplitude of the brightness is greater than the third preset detection value, or the average value of the high-frequency coefficient is less than the fourth preset detection value or greater than the fifth preset detection value, or the maximum value of the brightness is less than the sixth preset detection value, or the minimum value of the brightness is greater than the seventh preset detection value, or the extreme difference value of the brightness is less than the eighth preset detection value, or the uniformity of the brightness is greater than the ninth preset detection value, it is determined that the pseudo contour feature of the image block does not meet the pseudo contour preset condition; Otherwise, it is determined that the pseudo contour feature of the image block meets a pseudo contour preset condition.

3. The pseudo contour optimization method according to claim 2, characterized in that: The maximum value of the horizontal gradient / vertical gradient of the brightness of the image block is obtained by: Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the horizontal / vertical direction, and use the maximum value in the calculation results as the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block; or, if there is an image block on the adjacent right / lower side of the current image block, calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the horizontal / vertical direction and calculate the square of the difference in brightness values ​​of the last column / row of pixels of the current image block and the first column / row of pixels of the image block on its adjacent right / lower side in the horizontal / vertical direction, and use the maximum value in the calculation results as the maximum value of the horizontal gradient / vertical gradient of the brightness of the current image block.

4. The pseudo contour optimization method according to claim 2, characterized in that: The maximum value of the gradient amplitude of the brightness of the image block is obtained by: Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the horizontal direction to obtain a gradient matrix in the horizontal direction; Calculate the square of the difference in brightness values ​​of adjacent pixels in the current image block in the vertical direction to obtain a gradient matrix in the vertical direction; The arithmetic square root of the sum of the data at corresponding positions in the gradient matrix in the horizontal direction and the gradient matrix in the vertical direction is calculated respectively, and the maximum value of the calculation results is used as the maximum value of the gradient amplitude of the brightness of the current image block.

5. The pseudo contour optimization method according to claim 2, characterized in that: The average value of the high frequency coefficients of the image block is obtained by: Performing discrete cosine transform on the current image block to obtain a frequency domain coefficient matrix; and taking an average value of high frequency coefficients in the frequency domain coefficient matrix as the average value of high frequency coefficients of the current image block.

6. The pseudo contour optimization method according to claim 2, characterized in that: The maximum brightness value, the minimum brightness value and the extreme brightness difference value of the image block are obtained in the following manner: The brightness values ​​of all pixels in the current image block are obtained, the maximum brightness value is used as the maximum brightness value of the current image block, the minimum brightness value is used as the minimum brightness value of the current image block, and the difference between the maximum brightness value and the minimum brightness value is used as the extreme brightness difference value of the current image block.

7. The pseudo contour optimization method according to claim 2, characterized in that: The uniformity of the brightness of the image block is obtained in the following manner: The brightness values ​​of all pixels in the current image block are obtained, the probability of each brightness value in the range of 0-255 appearing in the current image block is calculated, and the sum of the squares of each obtained probability is used as the brightness uniformity of the current image block.

8. The pseudo contour optimization method according to claim 1, characterized in that: The optimizing strategy is implemented on all the coding tree units marked as the brightness gradient area blocks in the video to be encoded, including: The coding mode of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded is limited to a non-directional mode; or, the quantization step size of all the coding tree units marked as the brightness gradient area blocks in the video to be encoded is reduced; or, the coding mode of a part of the coding tree units marked as the brightness gradient area blocks in the video to be encoded is limited to a non-directional mode, and the quantization step size of the coding tree units marked as the brightness gradient area blocks in the remaining part of the video to be encoded is reduced.

9. A video encoding method, characterized in that: include: The pseudo contour optimization method according to any one of claims 1 to 8 is performed when encoding a video to be encoded.

10. An electronic device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the pseudo contour optimization method according to any one of claims 1 to 8 or the video encoding method according to claim 9 is implemented.