Deblocking effect filtering method, video coding method, electronic equipment and storage medium
By determining the boundary filtering unit in the target encoding tree unit of video encoding and calculating the filter judgment feature value, filtering operations are performed on the pixels of the complex texture area, the problem of insufficient processing of the block effect of complex texture areas in the prior art is solved, effective optimization on the encoding end is achieved, and visual experience is improved.
Patent Information
- Application Number
- CN202510350417.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-06-24
AI Technical Summary
The prior art is not effective enough to process the block effect of complex texture areas during video encoding, and the existing de-blocking filtering module cannot be deployed on the encoding end.
By determining the boundary filtering unit in the target encoding tree unit of the video encoding and calculating the filter judgment feature value, it is determined whether the filtering operation is performed. For pixels in the pixel range that need to be filtered, calculate their horizontal gradient and vertical gradient, determine the filtering direction and perform the corresponding filtering operation.
Effectively optimize the block effect of complex texture areas, improve user visual experience, and be able to deploy on the coding end to make up for the limitations of the existing technology.
Smart Images

Figure CN120201197A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video coding and decoding, and particularly relates to a deblocking filtering method, a video coding method, an electronic device and a storage medium. Background Art
[0002] In the encoding process of the High Efficiency Video Coding standard H.265 / HEVC, spatial correlation and temporal correlation are utilized for prediction to generate predicted pixels, then the original pixels are subtracted from the predicted pixels to obtain residual pixels, and finally the residual pixels are encoded. In order to minimize the amount of data to be transmitted and stored as much as possible, the video encoder quantizes the frequency domain coefficients of these residual data to reduce the transmission cost. However, image distortion is inevitably introduced during quantization, and block effect distortion is usually introduced in the video after video coding. The block effect refers to the discontinuity phenomenon at the boundaries of coding blocks. The main reason for its formation is that in the block-based coding process, the processes of prediction, transformation, quantization, etc. of each block are independent of each other, resulting in different distortion magnitudes of each block, thus causing a discontinuity phenomenon at the block boundaries. In addition, motion compensation is also a cause of the block effect. During the motion compensation prediction process, the reference blocks of adjacent blocks may come from different reference images, which will cause discontinuity at the boundaries between adjacent predicted blocks; similarly, the intra-frame prediction processes of adjacent blocks are different, which will also cause discontinuity at the boundaries between adjacent predicted blocks. The existence of the block effect greatly affects the visual experience of users.
[0003] To address the problem of the degraded subjective visual experience caused by block effect distortion, existing solutions generally involve adding a deblocking filter module to the video coding standard. Specifically, the basic working principle of the deblocking filter module is as follows: First, the boundary strength is obtained, that is, based on the coding parameters of the boundary blocks, it is initially determined whether the block boundary needs to be filtered, and appropriate filtering parameters are determined accordingly. The boundary strength value reflects to a certain extent the consistency of the coding parameters between two adjacent blocks. If the coding parameters used by two adjacent blocks are relatively close, the boundary strength is small, meaning that strong filtering may not be required; conversely, if the coding parameters of two adjacent blocks differ significantly, the boundary strength is high, indicating that stronger filtering may be needed to reduce visible discontinuities. Next, the filtering switch decision is made. When making the filtering switch decision, different boundary strength requirements exist for luminance and chrominance. The filtering switch decision determines the content characteristics of the block based on the degree of change in the pixel values on both sides of the block boundary, and then determines whether the block boundary needs to be filtered according to the content characteristics of the block. Due to the spatial masking effect of the human eye, that is, the human eye is more likely to notice discontinuities in flat regions rather than in complex texture regions, the filtering switch decision can be understood as determining whether the content characteristics of the blocks on both sides of the boundary are flat enough. For regions with flat block content characteristics, if there are discontinuities, these defects will be more prominent, so it is more suitable to apply filtering operations to smooth the boundary. For regions with complex block content characteristics, on the one hand, because the internal details and textures can themselves mask some small discontinuities, and at the same time, it is not easy to distinguish whether these discontinuities are caused by the content of the image itself or by coding distortion; on the other hand, applying filtering operations in complex texture regions may weaken the original texture details, so usually no filtering treatment is selected. Finally, according to the flatness degree of the block content characteristics, different strength filtering operations are selected to filter the block boundary, thereby improving the block effect introduced in the video coding process.
[0004] However, the deblocking filter module in existing solutions tends to filter the discontinuous boundaries in flat regions, while for the discontinuous boundaries in complex texture regions, it often chooses not to filter or perform weak filtering. Therefore, when it is necessary to optimize the block effect in complex texture regions, it is very difficult to effectively reduce or eliminate the block effect using the existing deblocking filter module and its parameter settings. In addition, existing other solutions also attempt to optimize the block effect for the decoded video, that is, to detect and improve the block effect after the video has been decoded. However, this solution is more suitable for deployment at the decoding end and cannot be deployed at the encoding end. Summary of the Invention
[0005] The object of the present invention is to provide a deblocking filtering method, a video encoding method, an electronic device and a storage medium, so as to solve one or more of the problems existing in the prior art, such as the deblocking filtering module does not perform filtering or performs weak filtering on the block effect introduced in the complex texture area during the encoding process, and the existing solutions optimize the block effect for the decoded video and cannot be deployed at the encoding end.
[0006] To achieve the above object, the present invention is implemented through the following technical solutions: A deblocking filtering method, including:
[0007] According to the obtained original image block of the current target coding tree unit, determine the row boundary, column boundary and 4×4 boundary filtering unit of the current target coding tree unit;
[0008] For each of the boundary filtering units, obtain the filtering decision eigenvalue of the boundary filtering unit, and determine whether the filtering decision eigenvalue of the boundary filtering unit is within the preset range of filtering decision. If so, filter the boundary filtering unit in the following manner:
[0009] Determine the pixel range to be filtered in the boundary filtering unit, obtain the horizontal gradient and vertical gradient of each pixel in the pixel range, determine the filtering direction of the pixel according to the horizontal gradient and vertical gradient of the pixel, and perform corresponding filtering operations based on the filtering direction of the pixel.
[0010] Optionally, for each of the boundary filtering units, obtaining the filtering decision eigenvalue of the boundary filtering unit includes: determining whether there is an adjacent coding tree unit on the boundary corresponding to the boundary filtering unit of the current target coding tree unit: if so, calculate the filtering decision eigenvalue of the boundary filtering unit according to the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to the boundary filtering unit; if not, copy the original pixels in the preset expansion range of the boundary corresponding to the boundary filtering unit of the current target coding tree unit at least three times and expand them outwards in sequence to obtain an expanded image block, and calculate the filtering decision eigenvalue of the boundary filtering unit according to the original pixels of the current target coding tree unit and the pixels of the expanded image block corresponding to the boundary filtering unit; the original pixels in the preset expansion range include the pixels of the first row / last row / first column / last column of the current target coding tree unit corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located.
[0011] Optionally, for each of the boundary filtering units that need to be filtered, determining the pixel range to be filtered in the boundary filtering unit includes: using at least one row / one row / one column / one column of boundary image blocks corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located as the pixel range to be filtered.
[0012] Optionally, for each of the pixels within the pixel range to be filtered, obtaining the horizontal gradient and the vertical gradient of the pixel in the following manner: obtaining the pixel values within the 3×3 neighborhood of the current pixel; performing a convolution operation on the pixel values within the 3×3 neighborhood of the current pixel using the horizontal convolution kernel in the Sobel operator to obtain the horizontal gradient of the current pixel; performing a convolution operation on the pixel values within the 3×3 neighborhood of the current pixel using the vertical convolution kernel in the Sobel operator to obtain the vertical gradient of the current pixel.
[0013] Optionally, obtaining the pixel values within the 3×3 neighborhood of the pixel in the following manner: if all the pixels within the 3×3 neighborhood of the current pixel are within the current target coding tree unit, using the pixel values of all the pixels within the 3×3 neighborhood as the pixel values within the 3×3 neighborhood of the current pixel; if the pixels within the 3×3 neighborhood of the current pixel are incomplete, determining whether there is a coding tree unit within the 3×3 neighborhood range of the current target coding tree unit for the current pixel. If so, using the pixel values of the original pixels at the corresponding positions within the coding tree unit as the pixel values of the missing pixel points at the corresponding positions within the 3×3 neighborhood of the current pixel. If not, selecting the pixel value of the pixel closest to the missing pixel point within the 3×3 neighborhood of the current pixel as the pixel value of the missing pixel point within the 3×3 neighborhood of the current pixel.
[0014] Optionally, determining a filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and performing a corresponding filtering operation based on the filtering direction of the pixel includes: if the boundary where the boundary filtering unit to be filtered where the pixel is located is the horizontal boundary of the current target coding tree unit, determining whether the absolute value of the horizontal gradient of the pixel is not less than the absolute value of the vertical gradient of the pixel multiplied by a first preset multiple: if so, performing a first filtering operation on the pixel; if not, determining whether both the horizontal gradient and the vertical gradient of the pixel are greater than 0 or both the horizontal gradient and the vertical gradient of the pixel are less than 0: if so, performing a second filtering operation on the pixel; otherwise, performing a third filtering operation on the pixel; if the boundary where the boundary filtering unit to be filtered where the pixel is located is the vertical boundary of the current target coding tree unit, determining whether the absolute value of the vertical gradient of the pixel is not less than the absolute value of the horizontal gradient of the pixel multiplied by a second preset multiple: if so, performing a fourth filtering operation on the pixel; if not, determining whether both the horizontal gradient and the vertical gradient of the pixel are greater than 0 or both the horizontal gradient and the vertical gradient of the pixel are less than 0: if so, performing the second filtering operation on the pixel; otherwise, performing the third filtering operation on the pixel.
[0015] Optionally, the first filtering operation includes: determining whether there are adjacent pixels above / below the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel above / below the current pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, using the pixel value of the current pixel to be filtered as the current pixel value of the adjacent pixel above / below the current pixel to be filtered; taking the average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels above and below the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered; the second filtering operation includes: determining whether there are adjacent pixels in the upper left corner / lower right corner of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel in the upper left corner / lower right corner of the current pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, selecting the pixel value of the pixel closest to the missing pixel point within the 3×3 neighborhood of the current pixel to be filtered to fill in the pixel value of the missing pixel point within the 3×3 neighborhood of the current pixel to be filtered, and using the pixel value of the pixel in the upper left corner / lower right corner within the 3×3 neighborhood of the current pixel to be filtered as the current pixel value of the adjacent pixel in the upper left corner / lower right corner of the current pixel to be filtered; taking the average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels in the upper left and lower right corners of the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered; the third filtering operation includes: determining whether there are adjacent pixels in the lower left corner / upper right corner of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel in the lower left corner / upper right corner of the current pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, selecting the pixel value of the pixel closest to the missing pixel point within the 3×3 neighborhood of the current pixel to be filtered to fill in the pixel value of the missing pixel point within the 3×3 neighborhood of the current pixel to be filtered, and using the pixel value of the pixel in the lower left corner / upper right corner within the 3×3 neighborhood of the current pixel to be filtered as the current pixel value of the adjacent pixel in the lower left corner / upper right corner of the current pixel to be filtered; taking the average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels in the lower left and upper right corners of the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered; the fourth filtering operation includes: determining whether there are adjacent pixels to the left / right of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel to the left / right of the current pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel;Otherwise, use the pixel value of the current pixel to be filtered as the current pixel value of the adjacent pixel on the left / right side of the current pixel to be filtered; use the average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels on the left and right sides of the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered.
[0016] To achieve the above object, the present invention also provides a video encoding method, including:
[0017] Perform the deblocking filtering method described in any one of the above on at least one target coding tree unit in the residual calculation module of the video to be encoded, and obtain the filtered pixel values of the corresponding pixels;
[0018] Replace the original pixel values of the corresponding pixels with the obtained filtered pixel values of the corresponding pixels, and perform residual calculation to obtain residuals;
[0019] Encode and transmit the obtained residuals.
[0020] To achieve the above object, the present invention also 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, it implements the deblocking filtering method described in any one of the above or implements the video encoding method described in any one of the above.
[0021] To achieve the above object, the present invention also provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it implements the deblocking filtering method described in any one of the above or implements the video encoding method described in any one of the above.
[0022] Compared with the prior art, the deblocking filtering method, video encoding method, electronic device, and storage medium provided by the present invention have the following beneficial effects:
[0023] The deblocking filtering method provided by the present invention comprises: firstly, according to the original image block of the current target coding tree unit obtained, determining the row boundary and column boundary of the current target coding tree unit and the boundary filtering unit of size 4×4; then, for each of the boundary filtering units, obtaining the filtering decision characteristic value of the boundary filtering unit, and judging whether the filtering decision characteristic value of the boundary filtering unit is within the preset filtering decision range, if so, filtering the boundary filtering unit in the following manner: determining the pixel range that needs to be filtered in the boundary filtering unit, and obtaining the horizontal gradient and vertical gradient of each pixel in the pixel range, determining the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and performing the corresponding filtering operation based on the filtering direction of the pixel. Therefore, the deblocking filtering method provided by the present invention first determines the row boundary and column boundary of the current target coding tree unit and the boundary filtering unit of size 4×4 according to the original image block of the current target coding tree unit obtained, and obtains the filtering decision characteristic value of each boundary filtering unit, which lays a good foundation for judging whether the boundary filtering unit needs to be filtered. Next, by judging whether the filtering decision characteristic value of the boundary filtering unit is within the preset filtering decision range, the boundary filtering unit that needs to be filtered can be determined. Finally, for the boundary filtering unit that needs to be filtered, by first determining the pixel range that needs to be filtered in the boundary filtering unit, and obtaining the horizontal gradient and vertical gradient of each pixel in the pixel range, a good foundation is laid for obtaining the filtering direction of the pixel that needs to be filtered; then, according to the obtained horizontal gradient and vertical gradient of each pixel in the pixel range that needs to be filtered, the filtering direction of the pixel that needs to be filtered can be determined; finally, based on the filtering direction, the corresponding filtering operation is performed on the pixel that needs to be filtered, while maintaining the original texture information of the image as much as possible, the block effect of the complex texture area can be effectively optimized, thereby improving the user's visual experience. The deblocking effect filtering method provided by the present invention is used to optimize the block effect of the complex texture area during the encoding process, which can make up for the limitation that the existing deblocking filter module chooses not to perform filtering or weak filtering for the block effect introduced by the complex texture area during the encoding process. The deblocking effect filtering method provided by the present invention can be deployed at the encoding end.
[0024] The video encoding method provided by the present invention includes: First, perform the deblocking filtering method described in any one of the above on at least one target coding tree unit in the residual calculation module of the video to be encoded, and obtain the filtered pixel values of the corresponding pixels; then replace the original pixel values of the corresponding pixels with the obtained filtered pixel values of the corresponding pixels, and perform residual calculation to obtain the residuals; finally, encode and transmit the obtained residuals. Thus, the video encoding method provided by the present invention can change the pixel values of the original image blocks by using the deblocking filtering method provided by the present invention in the residual calculation module, thereby further changing the residuals to be encoded, and further effectively optimizing the block effect in complex texture regions during the encoding process, improving the encoding efficiency and image quality. Moreover, since the deblocking filtering method provided by the present invention is used in the residual calculation module, it can ensure that some operations based on the original pixels are not affected, thereby avoiding affecting other modules during the encoding process.
[0025] Since the electronic device provided by the present invention and the readable storage medium provided by the present invention both belong to the same inventive concept as the deblocking filtering method provided by the present invention or the video encoding method provided by the present invention, therefore, the electronic device provided by the present invention and the readable storage medium provided by the present invention at least have all the advantages of the deblocking filtering method provided by the present invention or the video encoding method provided by the present invention. For the advantages of the electronic device provided by the present invention and the readable storage medium provided by the present invention, please refer to the relevant descriptions of the beneficial effects of the deblocking filtering method provided by the present invention or the video encoding method provided by the present invention, and will not be elaborated here. Description of the Drawings
[0026] Figure 1 It is a schematic diagram of the overall steps of a deblocking filtering method provided in Embodiment 1 of the present invention;
[0027] Figure 2 It is one specific example diagram of the pixel distribution when calculating the filtering decision eigenvalue of the boundary filtering unit provided in Embodiment 1 of the present invention;
[0028] Figure 3 It is another specific example diagram of the pixel distribution when calculating the filtering decision eigenvalue of the boundary filtering unit provided in Embodiment 1 of the present invention;
[0029] Figure 4 It is yet another specific example diagram of the pixel distribution when calculating the filtering decision eigenvalue of the boundary filtering unit provided in Embodiment 1 of the present invention;
[0030] Figure 5 It is one specific example diagram of the pixel distribution when obtaining the pixel values in the 3×3 neighborhood of the pixels to be filtered provided in Embodiment 1 of the present invention;
[0031] Figure 6 Another specific example diagram of the pixel distribution when obtaining pixel values within the 3×3 neighborhood of a pixel to be filtered, provided in the first embodiment of the present invention;
[0032] Figure 7 Another specific example diagram of the pixel distribution when obtaining pixel values within the 3×3 neighborhood of a pixel to be filtered, provided in the first embodiment of the present invention;
[0033] Figure 8 Schematic flowchart of a video encoding method provided in the second embodiment of the present invention. Detailed implementation manners
[0034] The deblocking filter method, video encoding method, electronic device, and storage medium proposed by the present invention are further described in detail below with reference to 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 accompanying drawings are all in very simplified forms and use non-precise scales, only for facilitating and clearly assisting in explaining the purposes of the embodiments of the present invention. In order to make the purposes, features, and advantages of the present invention more obvious and understandable, please refer to the accompanying drawings. It should be known that the structures, ratios, sizes, etc. shown in the drawings of this specification are only used to cooperate with the content disclosed in the specification for those skilled in 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 in the ratio relationship, or adjustment of the size, in the case of being the same or similar to the effects that the present invention can produce and the purposes that can be achieved, should still fall within the scope covered by the technical content disclosed by the present invention. The specific design features of the present invention disclosed herein, including, for example, specific dimensions, directions, positions, and shapes, will be partially determined by the specific application and usage environment. Also, in the following described embodiments, sometimes the same reference numerals are used commonly between different drawings to represent the same part or parts having the same functions, and the repeated description thereof is omitted.
[0035] Embodiment 1
[0036] This embodiment provides a deblocking filter method. Specifically, please refer to Figure 1 , Figure 1 which is the overall step schematic diagram of the deblocking filter method provided in this embodiment. It can be seen from Figure 1 that the filtering method includes:
[0037] S100: According to the obtained original image block of the current target coding tree unit, determine the row boundary, column boundary, and a 4×4 boundary filtering unit of the current target coding tree unit;
[0038] S200: For each of the boundary filter units, obtain the filter decision characteristic value of the boundary filter unit, and determine whether the filter decision characteristic value of the boundary filter unit is within the preset filter decision range. If so, perform filtering on the boundary filter unit using the following steps S300:
[0039] S300: Determine the pixel range that needs to be filtered in the boundary filtering unit, and obtain the horizontal gradient and vertical gradient of each pixel in the pixel range, determine the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and perform corresponding filtering operations based on the filtering direction of the pixel.
[0040] Therefore, the deblocking filtering method provided by the present embodiment first determines the row boundary and column boundary of the current target coding tree unit and the boundary filtering unit of size 4×4 according to the original image block of the current target coding tree unit obtained, and obtains the filtering decision eigenvalue of each boundary filtering unit, which lays a good foundation for determining whether the boundary filtering unit needs to be filtered. Then, by judging whether the filtering decision eigenvalue of the boundary filtering unit is within the preset filtering decision range, the boundary filtering unit that needs to be filtered can be determined. Finally, for the boundary filtering unit that needs to be filtered, by first determining the pixel range that needs to be filtered in the boundary filtering unit, and obtaining the horizontal gradient and vertical gradient of each pixel in the pixel range, a good foundation is laid for obtaining the filtering direction of the pixel that needs to be filtered; then, according to the horizontal gradient and vertical gradient of each pixel in the pixel range that needs to be filtered, the filtering direction of the pixel that needs to be filtered can be determined; finally, based on the filtering direction, the corresponding filtering operation is performed on the pixel that needs to be filtered, while maintaining the original texture information of the image as much as possible, the block effect of the complex texture area can be effectively optimized, thereby improving the user's visual experience. By adopting the deblocking effect filtering method provided in this embodiment, the block effect of the complex texture area is optimized during the encoding process, which can make up for the limitation of the existing deblocking filtering module that chooses not to perform filtering or weak filtering on the block effect introduced by the complex texture area during the encoding process. The deblocking effect filtering method provided in this embodiment can be deployed at the encoding end.
[0041] It should be noted that, as can be understood by those skilled in the art, the present invention does not impose excessive limitations on the size of the current target coding tree unit, as long as the current target coding tree unit can be divided into a number of boundary filtering units of size 4×4 at the row boundary and the column boundary. Exemplarily, in some embodiments, the size of the current target coding tree unit can be 32×32. The current target coding tree unit can be divided into 8 boundary filtering units with a horizontal boundary of size 4×4 at the row boundaries of the first row and the last row, and the current target coding tree unit can be divided into 8 boundary filtering units with a vertical boundary of size 4×4 at the column boundaries of the first column and the last column. In other embodiments, the size of the current target coding tree unit can also be 8×16. The current target coding tree unit can be divided into 2 boundary filtering units with a horizontal boundary of size 4×4 at the row boundaries of the first row and the last row, and the current target coding tree unit can be divided into 4 boundary filtering units with a vertical boundary of size 4×4 at the column boundaries of the first column and the last column.
[0042] Preferably, in step S200, for each of the boundary filtering units, obtaining the filtering decision eigenvalue of the boundary filtering unit includes:
[0043] S210: Determine whether there is an adjacent coding tree unit at the boundary where the current target coding tree unit corresponds to the boundary filtering unit:
[0044] S211: If so, calculate the filtering decision eigenvalue of the boundary filtering unit according to the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to the boundary filtering unit;
[0045] S212: If not, at least copy the original pixels in the preset expansion range of the boundary where the current target coding tree unit corresponds to the boundary filtering unit three times and expand them outwards in sequence to obtain an expanded image block, and calculate the filtering decision eigenvalue of the boundary filtering unit according to the original pixels of the current target coding tree unit and the pixels of the expanded image block corresponding to the boundary filtering unit; the original pixels in the preset expansion range include the pixels of the first row / last row / first column / last column of the current target coding tree unit corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located.
[0046] Specifically, if the boundary filtering unit is a boundary filtering unit divided on the row boundary of the current target coding tree unit in the first row, the filtering decision eigenvalue of this boundary filtering unit is obtained in the following manner: Determine whether there is an adjacent coding tree unit on the upper boundary corresponding to this boundary filtering unit of the current target coding tree unit. If so, calculate the filtering decision eigenvalue of this boundary filtering unit based on the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to this boundary filtering unit. If not, copy the original pixels in the preset expansion range of the upper boundary corresponding to this boundary filtering unit of the current target coding tree unit at least three times and expand them outwards in sequence to obtain an expanded image block, and calculate the filtering decision eigenvalue of this boundary filtering unit based on the original pixels of the current target coding tree unit and the pixels of the expanded image block corresponding to this boundary filtering unit.
[0047] Specifically, if the boundary filtering unit is a boundary filtering unit divided on the row boundary of the current target coding tree unit in the last row, the filtering decision eigenvalue of this boundary filtering unit is obtained in the following manner: Determine whether there is an adjacent coding tree unit on the lower boundary corresponding to this boundary filtering unit of the current target coding tree unit. If so, calculate the filtering decision eigenvalue of this boundary filtering unit based on the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to this boundary filtering unit. If not, copy the original pixels in the preset expansion range of the lower boundary corresponding to this boundary filtering unit of the current target coding tree unit at least three times and expand them outwards in sequence to obtain an expanded image block, and calculate the filtering decision eigenvalue of this boundary filtering unit based on the original pixels of the current target coding tree unit and the pixels of the expanded image block corresponding to this boundary filtering unit.
[0048] Specifically, if the boundary filtering unit is a boundary filtering unit divided on the column boundary of the current target coding tree unit in the first column, the filtering decision eigenvalue of this boundary filtering unit is obtained in the following manner: Determine whether there is an adjacent coding tree unit on the left boundary corresponding to this boundary filtering unit of the current target coding tree unit. If so, calculate the filtering decision eigenvalue of this boundary filtering unit based on the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to this boundary filtering unit. If not, copy the original pixels in the preset expansion range of the left boundary corresponding to this boundary filtering unit of the current target coding tree unit at least three times and expand them outwards in sequence to obtain an expanded image block, and calculate the filtering decision eigenvalue of this boundary filtering unit based on the original pixels of the current target coding tree unit and the pixels of the expanded image block corresponding to this boundary filtering unit.
[0049] Specifically, if the boundary filtering unit is a boundary filtering unit divided on the column boundary of the last column of the current target coding tree unit, the filtering decision eigenvalue of the boundary filtering unit is obtained in the following manner: Determine whether there is an adjacent coding tree unit on the right boundary corresponding to the boundary filtering unit of the current target coding tree unit. If so, calculate the filtering decision eigenvalue of the boundary filtering unit according to the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to the boundary filtering unit. If not, copy the original pixels in the preset expansion range on the right boundary corresponding to the boundary filtering unit of the current target coding tree unit at least three times and expand them outwards in sequence to obtain an expanded image block, and calculate the filtering decision eigenvalue of the boundary filtering unit according to the original pixels of the current target coding tree unit and the pixels of the expanded image block corresponding to the boundary filtering unit.
[0050] Exemplarily, please refer to Figure 2 , Figure 2 which is a specific example diagram of the pixel distribution when calculating the filtering decision eigenvalue of the boundary filtering unit provided in this embodiment. As Figure 2 shown, the P block is a boundary filtering unit on the column boundary of the last column of the current target coding tree unit, and the pixels in the P block are the original pixels at the corresponding positions in the current target coding tree unit; the Q block is a 4×4 image block corresponding to an adjacent coding tree unit existing on the right boundary of the P block, and the pixels in the Q block are the original pixels at the corresponding positions in the adjacent coding tree unit. The filtering decision eigenvalue C B of this P block can be calculated by the following formula (1):
[0051] C B =|p(2,0)-2p(1,0)+p(0,0)|+|q(2,0)-2q(1,0)+q(0,0)|+|p(2,3)-2p(1,3)+p(0,3)|+|q(2,
[0052] 3)-2q(1,3)+q(0,3)|(1)
[0053] Exemplarily, please refer to Figure 3 , Figure 3 which is another specific example diagram of the pixel distribution when calculating the filtering decision eigenvalue of the boundary filtering unit provided in this embodiment. As Figure 3As shown in the figure, block Q is a boundary filtering unit on the row boundary of the first row of the current target coding tree unit, and the pixels in block Q are the original pixels at the corresponding positions in the current target coding tree unit; block P is a 4×4 image block corresponding to an adjacent coding tree unit existing on the upper boundary of block Q, and the pixels in block P are the original pixels at the corresponding positions in the adjacent coding tree unit. The filtering decision eigenvalue C of block Q B can be calculated by the following formula (2):
[0054] C B =|p(0, 2) - 2p(0, 1) + p(0, 0)| + |q(0, 2) - 2q(0, 1) + q(0, 0)| + |p(3, 2) - 2p(3, 1) + p(3, 0)| + |q(3,
[0055] 2) - 2q(3, 1) + q(3, 0)| (2)
[0056] Exemplarily, please refer to Figure 4 , Figure 4 which is another specific example diagram of the pixel distribution when calculating the filtering decision eigenvalue of the boundary filtering unit provided by this embodiment. As Figure 4 shown in the figure, block P is a boundary filtering unit on the column boundary of the last column of the current target coding tree unit, and the pixels in block P are the original pixels at the corresponding positions in the current target coding tree unit; there is no adjacent coding tree unit on the right boundary of block P, and block Q is an extended image block obtained by replicating the pixels in the last column of the current target coding tree unit corresponding to the right boundary of block P three times and expanding them outwards in sequence. The filtering decision eigenvalue C of block P B can be calculated by the following formula (3):
[0057] C B =|p(2, 0) - 2p(1, 0) + p(0, 0)| + |p(0, 0) - 2p(0, 0) + p(0, 0)| + |p(2, 3) - 2p(1, 3) + p(0, 3)| + |p(0,
[0058] 3) - 2p(0, 3) + p(0, 3)| (3)
[0059] Furthermore, in step S200, the value range of the filtering decision preset range may include, but is not limited to, being greater than 64 and less than 256. It should be noted that the present invention does not impose too many limitations on the value range of the filtering decision preset range, and it can be set according to the filtering requirements of different scenarios.
[0060] Preferably, in step S300, for each of the boundary filtering units to be filtered, determining the pixel range to be filtered in the boundary filtering unit includes: using at least one row / one row / one column / one column of boundary image blocks corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located as the pixel range to be filtered.
[0061] Specifically, for a boundary filtering unit located in the first row, using at least one row of image blocks of the upper boundary of the boundary filtering unit as the pixel range to be filtered; for a boundary filtering unit located in the last row, using at least one row of image blocks of the lower boundary of the boundary filtering unit as the pixel range to be filtered; for a boundary filtering unit located in the first column, using at least one column of image blocks of the left boundary of the boundary filtering unit as the pixel range to be filtered; for a boundary filtering unit located in the last column, using at least one column of image blocks of the right boundary of the boundary filtering unit as the pixel range to be filtered.
[0062] Exemplarily, in some exemplary embodiments, for each of the boundary filtering units to be filtered, determining the pixel range to be filtered in the boundary filtering unit includes: using two rows / two rows / two columns / two columns of boundary image blocks corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located as the pixel range to be filtered; in other embodiments, for each of the boundary filtering units to be filtered, determining the pixel range to be filtered in the boundary filtering unit includes: using four rows / four rows / four columns / four columns of boundary image blocks corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located as the pixel range to be filtered.
[0063] Further, in step S300, for each of the pixels in the pixel range to be filtered, obtaining the horizontal gradient and the vertical gradient of the pixel by the following method: obtaining the pixel values within the 3×3 neighborhood of the current pixel; using the horizontal convolution kernel in the Sobel operator to perform a convolution operation on the pixel values within the 3×3 neighborhood of the current pixel to obtain the horizontal gradient of the current pixel; using the vertical convolution kernel in the Sobel operator to perform a convolution operation on the pixel values within the 3×3 neighborhood of the current pixel to obtain the vertical gradient of the current pixel.
[0064] Preferably, the pixel values within the 3×3 neighborhood of the pixel are obtained by the following method:
[0065] S311: If all pixels within the 3×3 neighborhood of the current pixel are within the current target coding tree unit, using the pixel values of all pixels within the 3×3 neighborhood as the pixel values within the 3×3 neighborhood of the current pixel;
[0066] S312: If the pixels within the 3×3 neighborhood of the current pixel are incomplete, determine whether there is a coding tree unit within the 3×3 neighborhood range of the current target coding tree unit for the current pixel. If so, use the pixel value of the original pixel at the corresponding position within the coding tree unit as the pixel value of the missing pixel at the corresponding position within the 3×3 neighborhood of the current pixel. If not, select the pixel value of the pixel closest to the missing pixel within the 3×3 neighborhood of the current pixel as the pixel value of the missing pixel within the 3×3 neighborhood of the current pixel.
[0067] Exemplarily, please refer to Figure 5 , Figure 5 which is a specific example diagram of the pixel distribution when obtaining the pixel values within the 3×3 neighborhood of the pixel to be filtered provided in this embodiment. As Figure 5 shown, the P block is a boundary filtering unit to be filtered on the row boundary of the first row of the current target coding tree unit. If it is necessary to filter the pixel p(2,1) in the boundary image block corresponding to the upper boundary where this boundary filtering unit is located, when calculating the horizontal gradient and the vertical gradient of this pixel p(2,1), use the pixel values of all pixels within the 3×3 neighborhood of this pixel p(2,1) (as shown by the dashed box in Figure 5 ) as the pixel values within the 3×3 neighborhood of this pixel p(2,1).
[0068] Exemplarily, please refer to Figure 6 , Figure 6 which is another specific example diagram of the pixel distribution when obtaining the pixel values within the 3×3 neighborhood of the pixel to be filtered provided in this embodiment. As Figure 6 shown, the P block is a boundary filtering unit to be filtered on the row boundary of the first row of the current target coding tree unit, a and b are the original pixels at the corresponding positions of the adjacent coding tree units on the left side of the current target coding tree unit, c is the original pixel at the corresponding position of the coding tree unit in the upper left corner of the current target coding tree unit, and d and e are the original pixels at the corresponding positions of the adjacent coding tree units on the upper side of the current target coding tree unit. If it is necessary to filter the pixel p(3,0) in the boundary image block filtering corresponding to the upper boundary where this boundary filtering unit is located, when calculating the horizontal gradient and the vertical gradient of this pixel p(3,0), use the pixel values of a, b, c, d, and e as the pixel values of the missing pixel at the corresponding position within the 3×3 neighborhood of this pixel p(3,0).
[0069] Exemplarily, please refer to Figure 7 , Figure 7 which is yet another specific example diagram of the pixel distribution when obtaining the pixel values within the 3×3 neighborhood of the pixel to be filtered provided in this embodiment. As Figure 7As shown, the P block is a boundary filtering unit to be filtered on the row boundary of the first row of the current target coding tree unit, and there are no adjacent coding tree units on the left and upper sides of the P block. If it is necessary to filter the pixel p(3,0) in the boundary image block filtering corresponding to the two rows of the upper boundary where the boundary filtering unit is located, when calculating the horizontal gradient and the vertical gradient of the pixel p(3,0), the pixel value of the pixel closest to the missing pixel point in the 3×3 neighborhood of the pixel p(3,0) is selected as the pixel value of the missing pixel point in the 3×3 neighborhood of the pixel p(3,0).
[0070] Further, in step S300, the determining the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and performing a corresponding filtering operation based on the filtering direction of the pixel includes:
[0071] S321: If the boundary where the boundary filtering unit to be filtered where the pixel is located is the horizontal boundary of the current target coding tree unit, determine whether the absolute value of the horizontal gradient of the pixel is not less than the absolute value of the vertical gradient of the pixel multiplied by a first preset multiple: if so, perform a first filtering operation on the pixel; if not, determine whether both the horizontal gradient and the vertical gradient of the pixel are greater than 0 or whether both the horizontal gradient and the vertical gradient of the pixel are less than 0: if so, perform a second filtering operation on the pixel; otherwise, perform a third filtering operation on the pixel;
[0072] S322: If the boundary where the boundary filtering unit to be filtered where the pixel is located is the vertical boundary of the current target coding tree unit, determine whether the absolute value of the vertical gradient of the pixel is not less than the absolute value of the horizontal gradient of the pixel multiplied by a second preset multiple: if so, perform a fourth filtering operation on the pixel; if not, determine whether both the horizontal gradient and the vertical gradient of the pixel are greater than 0 or whether both the horizontal gradient and the vertical gradient of the pixel are less than 0: if so, perform the second filtering operation on the pixel; otherwise, perform the third filtering operation on the pixel.
[0073] Thus, by first determining the filtering direction of the pixel to be filtered and then filtering the pixel to be filtered according to the corresponding filtering operation, the original texture information of the image can be maintained as much as possible.
[0074] It should be noted that the present invention does not impose excessive limitations on the value ranges of the first preset multiple and the second preset multiple, as long as the value of the first preset multiple can indicate that the absolute value of the horizontal gradient of the pixel is much larger than the absolute value of the vertical gradient of the pixel, and the value of the second preset multiple can indicate that the absolute value of the vertical gradient of the pixel is much larger than the absolute value of the horizontal gradient of the pixel. Exemplarily, in some embodiments, the values of the first preset multiple and the second preset multiple can both be 3; in other embodiments, the value of the first preset multiple can be 3, and the value of the second preset multiple can be 5.
[0075] Preferably, the first filtering operation includes: determining whether there are adjacent pixels above / below the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel above / below the current pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, using the pixel value of the current pixel to be filtered as the current pixel value of the adjacent pixel above / below the current pixel to be filtered; taking the average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels above and below the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered.
[0076] It should be noted that in the present invention, the reconstructed pixel value of the adjacent pixel refers to the pixel value of the pixel obtained by decoding the original pixel of the adjacent pixel from the coded bitstream; the filtered pixel value of the adjacent pixel refers to the pixel value obtained by performing a filtering operation on the adjacent pixel.
[0077] Specifically, in the first filtering operation, if there are adjacent pixels above / below the current pixel to be filtered, when obtaining the current pixel value of the adjacent pixel above / below the current pixel to be filtered, if there is a filtered pixel value for the adjacent pixel above / below the current pixel to be filtered, using the filtered pixel value as the current pixel value of the adjacent pixel; if there is no filtered pixel value for the adjacent pixel above / below the current pixel to be filtered, using the original pixel value of the adjacent pixel as the current pixel value of the adjacent pixel; if there is no original pixel value for the adjacent pixel above / below the current pixel to be filtered, using the reconstructed pixel value of the adjacent pixel as the current pixel value of the adjacent pixel.
[0078] Preferably, the second filtering operation includes: determining whether there are adjacent pixels at the upper left corner / lower right corner of the currently pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel at the upper left corner / lower right corner of the currently pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, selecting the pixel value of the pixel closest to the missing pixel point within the 3×3 neighborhood of the currently pixel to be filtered to fill in the pixel values of the missing pixel points within the 3×3 neighborhood of the currently pixel to be filtered, and using the pixel value of the pixel at the upper left corner / lower right corner within the 3×3 neighborhood of the currently pixel to be filtered as the current pixel value of the adjacent pixel at the upper left corner / lower right corner of the currently pixel to be filtered; taking the average value of the pixel value of the currently pixel to be filtered, the current pixel values of the adjacent pixels at the upper left and lower right corners of the currently pixel to be filtered as the filtered pixel value of the currently pixel to be filtered.
[0079] Specifically, in the second filtering operation, if there are adjacent pixels at the upper left corner / lower right corner of the currently pixel to be filtered, when obtaining the current pixel value of the adjacent pixel at the upper left corner / lower right corner of the currently pixel to be filtered, if there is a filtered pixel value for the adjacent pixel at the upper left corner / lower right corner of the currently pixel to be filtered, then use this filtered pixel value as the current pixel value of the adjacent pixel; if there is no filtered pixel value for the adjacent pixel at the upper left corner / lower right corner of the currently pixel to be filtered, then use the original pixel value of the adjacent pixel as the current pixel value of the adjacent pixel; if there is no original pixel value for the adjacent pixel at the upper left corner / lower right corner of the currently pixel to be filtered, then use the reconstructed pixel value of the adjacent pixel as the current pixel value of the adjacent pixel.
[0080] Preferably, the third filtering operation includes: determining whether there are adjacent pixels at the lower left corner / upper right corner of the currently pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel at the lower left corner / upper right corner of the currently pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, selecting the pixel value of the pixel closest to the missing pixel point within the 3×3 neighborhood of the currently pixel to be filtered to fill in the pixel values of the missing pixel points within the 3×3 neighborhood of the currently pixel to be filtered, and using the pixel value of the pixel at the lower left corner / upper right corner within the 3×3 neighborhood of the currently pixel to be filtered as the current pixel value of the adjacent pixel at the lower left corner / upper right corner of the currently pixel to be filtered; taking the average value of the pixel value of the currently pixel to be filtered, the current pixel values of the adjacent pixels at the lower left and upper right corners of the currently pixel to be filtered as the filtered pixel value of the currently pixel to be filtered.
[0081] Specifically, in the third filtering operation, if there are adjacent pixels at the lower left corner / upper right corner of the current pixel to be filtered, when obtaining the current pixel value of the adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered, if there is a filtered pixel value for the adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered, then use this filtered pixel value as the current pixel value of the adjacent pixel; if there is no filtered pixel value for the adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered, then use the original pixel value of the adjacent pixel as the current pixel value of the adjacent pixel; if there is no original pixel value for the adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered, then use the reconstructed pixel value of the adjacent pixel as the current pixel value of the adjacent pixel.
[0082] Preferably, the fourth filtering operation includes: determining whether there are adjacent pixels on the left side / right side of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel on the left side / right side of the current pixel to be filtered, where the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value, and the original pixel value of the adjacent pixel; if not, then using the pixel value of the current pixel to be filtered as the current pixel value of the adjacent pixel on the left side / right side of the current pixel to be filtered; and using the average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels on the left and right sides of the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered.
[0083] Specifically, in the fourth filtering operation, if there are adjacent pixels on the left side / right side of the current pixel to be filtered, when obtaining the current pixel value of the adjacent pixel on the left side / right side of the current pixel to be filtered, if there is a filtered pixel value for the adjacent pixel on the left side / right side of the current pixel to be filtered, then use this filtered pixel value as the current pixel value of the adjacent pixel; if there is no filtered pixel value for the adjacent pixel on the left side / right side of the current pixel to be filtered, then use the original pixel value of the adjacent pixel as the current pixel value of the adjacent pixel; if there is no original pixel value for the adjacent pixel on the left side / right side of the current pixel to be filtered, then use the reconstructed pixel value of the adjacent pixel as the current pixel value of the adjacent pixel.
[0084] It should be noted that the above is only an exemplary illustration and not a limitation of the present invention. In some other embodiments, if there are no adjacent coding tree units on the upper side / lower side / left side / right side of the current target coding tree unit, it is also possible to choose not to filter the current target coding tree unit.
[0085] Embodiment 2
[0086] This embodiment provides a video coding method. Specifically, please refer to Figure 8 , Figure 8Schematic flowchart of the video encoding method provided in this embodiment. Starting from Figure 3 As can be seen, the video encoding method includes:
[0087] S400: Perform the deblocking filtering method described in any of the above embodiments on at least one target coding tree unit in the residual calculation module of the video to be encoded, and obtain the filtered pixel values of the corresponding pixels;
[0088] S500: Replace the original pixel values of the corresponding pixels with the obtained filtered pixel values of the corresponding pixels, and perform residual calculation to obtain the residuals;
[0089] S600: Encode and transmit the obtained residuals.
[0090] Thus, the video encoding method provided in this embodiment can change the pixel values of the original image blocks by using the deblocking filtering method provided in any of the above embodiments in the residual calculation module, thereby further changing the residuals to be encoded, and further effectively optimizing the block effect in complex texture regions during the encoding process, improving the encoding efficiency and image quality. Moreover, since the deblocking filtering method is used in the residual calculation module, it can ensure that some operations based on the original pixels are not affected, thereby avoiding affecting other modules in the encoding process.
[0091] It should be noted that the present invention does not overly limit the specific module for performing the deblocking filtering method described in any of the above embodiments on the video to be encoded and the number of target coding tree units. Exemplarily, in some of the embodiments, the deblocking filtering method described in any of the above embodiments can be performed on all target coding tree units of size 32×32 in the residual calculation module of the video to be encoded; in other embodiments, the deblocking filtering method described in any of the above embodiments can also be performed on all coding tree units in the pre-analysis module of the encoder of the video to be encoded.
[0092] For better understanding of the present invention, exemplarily, the process of using the video encoding method provided in this embodiment for a certain target coding tree unit in the residual calculation module of the video to be encoded is described.
[0093] First, determine the four boundaries of the target coding tree unit and all boundary filtering units of size 4×4 on the four boundaries, and obtain the filtering decision eigenvalue of each boundary filtering unit. Then, for each boundary filtering unit, determine whether the filtering decision eigenvalue of the current boundary filtering unit is within the preset range of filtering decision. If so, determine that the pixel range to be filtered in the boundary filtering unit is the two rows / two rows / two columns / two columns of the boundary image block corresponding to the upper boundary / lower boundary / left boundary / right boundary where the boundary filtering unit is located, and obtain the horizontal gradient and vertical gradient of each pixel within this pixel range. Next, determine the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and perform corresponding filtering operations based on the filtering direction of the pixel to obtain the filtered pixel value of the corresponding pixel. Finally, in the residual calculation module, replace the original pixel value of the corresponding pixel with the obtained filtered pixel value of the corresponding pixel, perform residual calculation to obtain the residual, and then encode and transmit the obtained residual.
[0094] Embodiment III
[0095] 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, it implements the deblocking filtering method described in any of the above embodiments or implements the video coding method described in any of the above embodiments.
[0096] Since the electronic device provided in this embodiment and the deblocking filtering method described in any of the above embodiments or the video coding method described in any of the above embodiments belong to the same inventive concept, therefore, the electronic device provided in this embodiment has at least all the advantages of the deblocking filtering method provided in each of the above embodiments or the video coding method provided in each of the above embodiments. For the advantages of the electronic device provided in this embodiment, please refer to the relevant descriptions of the beneficial effects of the deblocking filtering method provided in each of the above embodiments or the video coding method provided in each of the above embodiments, and will not be elaborated here.
[0097] Embodiment IV
[0098] This embodiment provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it implements the deblocking filtering method described in any of the above embodiments or implements the video coding method described in any of the above embodiments.
[0099] Since the readable storage medium provided in this embodiment and the deblocking filtering method described in any of the above embodiments or the video coding method described in any of the above embodiments belong to the same inventive concept, the readable storage medium provided in this embodiment has at least all the advantages of the deblocking filtering method provided in each of the above embodiments or the video coding method provided in each of the above embodiments. For the advantages of the readable storage medium provided in this embodiment, please refer to the relevant descriptions of the beneficial effects of the deblocking filtering method provided in each of the above embodiments or the video coding method provided in each of the above embodiments, which will not be elaborated here.
[0100] In summary, the deblocking filtering method, video encoding method, electronic device and storage medium provided by the present invention have the following advantages: The deblocking filtering method provided by the present invention comprises: first, according to the original image block of the current target coding tree unit obtained, determining the row boundary and column boundary of the current target coding tree unit and the boundary filtering unit with a size of 4×4; then, for each of the boundary filtering units, obtaining the filtering decision characteristic value of the boundary filtering unit, judging whether the filtering decision characteristic value of the boundary filtering unit is within the preset filtering decision range, and if so, filtering the boundary filtering unit in the following manner: determining the pixel range to be filtered in the boundary filtering unit, and obtaining the horizontal gradient and vertical gradient of each pixel within the pixel range, determining the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and performing corresponding filtering operations based on the filtering direction of the pixel. Therefore, the deblocking filtering method provided by the present invention first determines the row boundary and column boundary of the current target coding tree unit and the boundary filtering unit of size 4×4 according to the original image block of the current target coding tree unit obtained, and obtains the filtering decision characteristic value of each boundary filtering unit, which lays a good foundation for determining whether the boundary filtering unit needs to be filtered. Then, by judging whether the filtering decision characteristic value of the boundary filtering unit is within the preset range of the filtering decision, the boundary filtering unit that needs to be filtered can be determined. Finally, for the boundary filtering unit that needs to be filtered, by first determining the pixel range that needs to be filtered in the boundary filtering unit, and obtaining the horizontal gradient and vertical gradient of each pixel in the pixel range, a good foundation is laid for obtaining the filtering direction of the pixel that needs to be filtered; then, according to the horizontal gradient and vertical gradient of each pixel in the pixel range that needs to be filtered, the filtering direction of the pixel that needs to be filtered can be determined; finally, based on the filtering direction, the corresponding filtering operation is performed on the pixel that needs to be filtered, while maintaining the original texture information of the image as much as possible, the block effect of the complex texture area can be effectively optimized, thereby improving the user's visual experience. By adopting the deblocking effect filtering method provided by the present invention, the block effect of the complex texture area is optimized during the encoding process, which can make up for the limitation that the existing deblocking filtering module chooses not to perform filtering processing or weak filtering processing on the block effect introduced by the complex texture area during the encoding process. The deblocking effect filtering method provided by the present invention can be deployed at the encoding end.
[0101] The video encoding method provided by the present invention includes: First, perform the deblocking filter method described in any one of the above on at least one target coding tree unit in the residual calculation module of the video to be encoded, and obtain the filtered pixel values of the corresponding pixels; Then, replace the original pixel values of the corresponding pixels with the obtained filtered pixel values of the corresponding pixels, and perform residual calculation to obtain the residuals; Finally, encode and transmit the obtained residuals. Thus, in the video encoding method provided by the present invention, by using the deblocking filter method provided by the present invention in the residual calculation module, the pixel values of the original image blocks can be changed, so that the residuals to be encoded can be further changed, and thus the block effect in complex texture regions can be effectively optimized during the encoding process, improving the encoding efficiency and image quality. Moreover, since the deblocking filter method provided by the present invention is used in the residual calculation module, it can ensure that some operations based on the original pixels are not affected, thus avoiding affecting other modules in the encoding process.
[0102] Since the electronic device provided by the present invention and the readable storage medium provided by the present invention are both within the same inventive concept as the deblocking filter method provided by the present invention or the video encoding method provided by the present invention, therefore, the electronic device provided by the present invention and the readable storage medium provided by the present invention at least have all the advantages of the deblocking filter method provided by the present invention or the video encoding method provided by the present invention. For the advantages of the electronic device provided by the present invention and the readable storage medium provided by the present invention, please refer to the relevant descriptions of the beneficial effects of the deblocking filter method provided by the present invention or the video encoding method provided by the present invention, and will not be elaborated here.
[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A deblocking filtering method, characterized in that: The filtering method comprises: Determine, according to the acquired original image block of the current target coding tree unit, a row boundary and a column boundary of the current target coding tree unit and a boundary filter unit of a size of 4×4; For each of the boundary filtering units, a filtering decision characteristic value of the boundary filtering unit is obtained, and it is determined whether the filtering decision characteristic value of the boundary filtering unit is within a preset filtering decision range. If so, the boundary filtering unit is filtered in the following manner: Determine the pixel range that needs to be filtered in the boundary filtering unit, and obtain the horizontal gradient and vertical gradient of each pixel in the pixel range, determine the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and perform corresponding filtering operations based on the filtering direction of the pixel.
2. The deblocking filtering method according to claim 1, wherein: The step of obtaining, for each of the boundary filtering units, a filtering decision characteristic value of the boundary filtering unit comprises: Determine whether there is an adjacent coding tree unit at the boundary where the current target coding tree unit corresponds to the boundary filtering unit: If yes, the filtering decision feature value of the boundary filtering unit is calculated according to the original pixels of the current target coding tree unit and the original pixels of the adjacent coding tree unit corresponding to the boundary filtering unit; If not, the original pixels of the preset extension range of the boundary of the current target coding tree unit corresponding to the boundary filtering unit are copied at least three times and expanded outward in sequence to obtain an extended image block, and the filtering decision eigenvalue of the boundary filtering unit is calculated based on the original pixels of the current target coding tree unit and the pixels of the extended image block corresponding to the boundary filtering unit; the original pixels of the preset extension range include the pixels of the first row / last row / first column / last column of the current target coding tree unit corresponding to the upper boundary / lower boundary / left boundary / right boundary of the boundary filtering unit.
3. The deblocking filtering method according to claim 1, wherein: For each boundary filtering unit that needs filtering, determining a pixel range that needs filtering in the boundary filtering unit includes: At least one row / row / column / column of boundary image blocks corresponding to the upper boundary / lower boundary / left boundary / right boundary of the boundary filtering unit is used as the pixel range that needs to be filtered.
4. The deblocking filtering method according to claim 1, wherein: For each pixel within the pixel range that needs to be filtered, the horizontal gradient and the vertical gradient of the pixel are obtained in the following manner: Get the pixel values in the 3×3 neighborhood of the current pixel; Using the horizontal convolution kernel in the Sobel operator to perform a convolution operation on the pixel values in a 3×3 neighborhood of the current pixel, to obtain the horizontal gradient of the current pixel; A convolution operation is performed on pixel values within a 3×3 neighborhood of the current pixel using a vertical convolution kernel in a Sobel operator to obtain the vertical gradient of the current pixel.
5. The deblocking filtering method according to claim 4, characterized in that: Get the pixel values in the 3×3 neighborhood of the pixel in the following way: If all pixels in a 3×3 neighborhood of the current pixel are in the current target coding tree unit, the pixel values of all pixels in the 3×3 neighborhood are used as the pixel values in the 3×3 neighborhood of the current pixel; If the pixels within the 3×3 neighborhood of the current pixel are incomplete, determine whether there is a coding tree unit within the 3×3 neighborhood of the current pixel. If so, use the pixel value of the original pixel at the corresponding position in the coding tree unit as the pixel value of the missing pixel at the corresponding position in the 3×3 neighborhood of the current pixel. If not, select the pixel value of the pixel closest to the missing pixel in the 3×3 neighborhood of the current pixel as the pixel value of the missing pixel in the 3×3 neighborhood of the current pixel.
6. The deblocking filtering method according to claim 1, wherein: The determining the filtering direction of the pixel according to the horizontal gradient and the vertical gradient of the pixel, and performing a corresponding filtering operation based on the filtering direction of the pixel, comprises: If the boundary of the boundary filter unit where the pixel needs to be filtered is located is the horizontal boundary of the current target coding tree unit, then determine whether the absolute value of the horizontal gradient of the pixel is not less than the absolute value of the vertical gradient of the pixel of the first preset multiple: if so, perform a first filtering operation on the pixel; if not, determine whether the horizontal gradient and the vertical gradient of the pixel are both greater than 0 or whether the horizontal gradient and the vertical gradient of the pixel are both less than 0: if so, perform a second filtering operation on the pixel; otherwise, perform a third filtering operation on the pixel; If the boundary of the boundary filtering unit where the pixel needs to be filtered is located is the vertical boundary of the current target coding tree unit, then determine whether the absolute value of the vertical gradient of the pixel is not less than the absolute value of the horizontal gradient of the pixel at a second preset multiple: if so, perform the fourth filtering operation on the pixel; if not, determine whether the horizontal gradient and the vertical gradient of the pixel are both greater than 0 or whether the horizontal gradient and the vertical gradient of the pixel are both less than 0: if so, perform the second filtering operation on the pixel; otherwise, perform the third filtering operation on the pixel.
7. The deblocking filtering method according to claim 6, characterized in that: The first filtering operation includes: determining whether there is an adjacent pixel on the upper side / lower side of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel on the upper side / lower side of the current pixel to be filtered, the current pixel value of the adjacent pixel being one of the reconstructed pixel value, the filtered pixel value and the original pixel value of the adjacent pixel; if not, taking the pixel value of the current pixel to be filtered as the current pixel value of the adjacent pixel on the upper side / lower side of the current pixel to be filtered; Taking the average of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels above and below the current pixel to be filtered as the filtered pixel value of the current pixel to be filtered; The second filtering operation includes: determining whether there is an adjacent pixel at the upper left corner / lower right corner of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel at the upper left corner / lower right corner of the current pixel to be filtered, wherein the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value and the original pixel value of the adjacent pixel; if not, selecting the pixel value of the pixel closest to the missing pixel point in the 3×3 neighborhood of the current pixel to be filtered to fill the pixel value of the missing pixel point in the 3×3 neighborhood of the current pixel to be filtered, and taking the pixel value of the pixel at the upper left corner / lower right corner in the 3×3 neighborhood of the current pixel to be filtered as the current pixel value of the adjacent pixel at the upper left corner / lower right corner of the current pixel to be filtered; The average value of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels at the upper left corner and the lower right corner of the current pixel to be filtered is taken as the filtered pixel value of the current pixel to be filtered; The third filtering operation includes: determining whether there is an adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered, the current pixel value of the adjacent pixel being one of the reconstructed pixel value, the filtered pixel value and the original pixel value of the adjacent pixel; if not, selecting the pixel value of the pixel closest to the missing pixel point in the 3×3 neighborhood of the current pixel to be filtered to fill the pixel value of the missing pixel point in the 3×3 neighborhood of the current pixel to be filtered, and taking the pixel value of the pixel at the lower left corner / upper right corner in the 3×3 neighborhood of the current pixel to be filtered as the current pixel value of the adjacent pixel at the lower left corner / upper right corner of the current pixel to be filtered; The average of the pixel value of the current pixel to be filtered, the current pixel values of the adjacent pixels at the lower left corner and the upper right corner of the current pixel to be filtered is used as the filtered pixel value of the current pixel to be filtered; The fourth filtering operation includes: determining whether there is an adjacent pixel on the left / right side of the current pixel to be filtered: if so, obtaining the current pixel value of the adjacent pixel on the left / right side of the current pixel to be filtered, wherein the current pixel value of the adjacent pixel is one of the reconstructed pixel value, the filtered pixel value and the original pixel value of the adjacent pixel; if not, taking the pixel value of the current pixel to be filtered as the current pixel value of the adjacent pixel on the left / right side of the current pixel to be filtered; The average of the pixel value of the current pixel to be filtered and the current pixel values of the adjacent pixels on the left and right sides of the current pixel to be filtered is taken as the filtered pixel value of the current pixel to be filtered.
8. A video encoding method, characterized in that: include: Performing the deblocking filtering method according to any one of claims 1 to 7 on at least one target coding tree unit in a residual calculation module in the video to be encoded, to obtain a filtered pixel value of a corresponding pixel; The obtained filtered pixel value of the corresponding pixel is used to replace the original pixel value of the corresponding pixel, and a residual calculation is performed to obtain a residual; The obtained residual is encoded and transmitted.
9. 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 deblocking filtering method according to any one of claims 1 to 7 or the video encoding method according to claim 8 is implemented.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the deblocking effect filtering method according to any one of claims 1 to 7 or the video encoding method according to claim 8 is implemented.