Filtering method and device, electronic equipment, storage medium and product
By acquiring gradient spatial distribution data and pixel change data of coding units in video images, dual accurate classification is performed, and an appropriate filtering strategy is selected to process the coding units. This solves the problem of low adaptability between filtering strategies and coding unit features in existing technologies, and improves the filtering effect and processing efficiency of video images.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- MIGU VIDEO TECH CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-05-19
AI Technical Summary
In existing video encoding and decoding technologies, the filtering strategy has a low degree of adaptation to the actual characteristics of the coding unit, resulting in poor filtering effect of video images and an inability to effectively eliminate block artifacts.
By acquiring gradient spatial distribution data and pixel change data of coding units in video images, double accurate classification is performed based on these data to determine the gradient distribution type and pixel change type of coding units. Combining the gradient distribution type and pixel change type, a differentiated filtering strategy is selected to filter the coding units.
It achieves precise filtering of coding units, improves the filtering effect of video images, avoids the limitations of single-dimensional judgment in traditional methods, reduces computational complexity and coding latency, and stably processes fast-moving objects.
Smart Images

Figure CN122069366A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of video encoding and decoding technology, and in particular to a filtering method, apparatus, electronic device, storage medium and product. Background Technology
[0002] In the field of video encoding and decoding, to improve transmission and storage efficiency, video images are usually divided into coding units (such as macroblocks) for compression encoding. However, during the compression process, abrupt changes in pixel values between coding units can cause blockiness, resulting in a noticeable blocky and fragmented appearance in the image, which severely degrades the subjective visual quality of the video. Therefore, deblocking filter (DBF) is particularly important in the video encoding and decoding process.
[0003] In most correlation filtering schemes, a unified or single-dimensional judgment standard is used, such as the pixel gray-scale mean or simple edge detection results, to select the filtering strategy. This cannot fully characterize the image characteristics of the coding unit, resulting in a low degree of fit between the filtering strategy and the actual features of the coding unit, which in turn leads to poor filtering effect of the video image. Summary of the Invention
[0004] This disclosure provides a filtering method, apparatus, electronic device, storage medium, and product to solve the problem in related technologies where the filtering strategy has low compatibility with the actual characteristics of the coding unit, resulting in poor filtering effect of video images.
[0005] A first aspect of this disclosure provides a filtering method, the method comprising: Acquire the gradient spatial distribution data and pixel change data of coding units in video images; Based on gradient spatial distribution data, the gradient distribution type of the coding unit is determined, and based on pixel change degree data, the pixel change type of the coding unit is determined. Based on the combination of gradient distribution type and pixel change type, determine the target filtering strategy corresponding to the coding unit; The coding unit is filtered using a target filtering strategy.
[0006] In one embodiment, determining the gradient distribution type of the coding unit based on gradient spatial distribution data includes: Extract the horizontal and vertical gradients of each pixel in the coding unit from the gradient space distribution data; Based on the horizontal and vertical gradients, determine the first gradient magnitude and gradient direction for each pixel; The gradient direction is divided into a preset number of intervals, and based on the first gradient magnitude, the second gradient magnitude of each interval and the third gradient magnitude of the preset number of intervals are determined. The gradient distribution concentration of the coding unit is determined based on the second and third gradient magnitudes. The gradient distribution type of the encoding unit is determined based on the gradient distribution concentration and the preset concentration threshold. The gradient distribution types include gradient distribution concentration and gradient distribution dispersion.
[0007] In one embodiment, determining the pixel change type of the encoding unit based on pixel change level data includes: Based on pixel variation data, determine the average difference between adjacent pixels in the coding unit; The pixel change type of the encoding unit is determined based on the average difference between adjacent pixels and a preset pixel change threshold. The pixel change type includes all-zero blocks or non-all-zero blocks.
[0008] In one embodiment, the target filtering strategy corresponding to the coding unit is determined based on the combination of gradient distribution type and pixel change type, including: In response to the combination of gradient distribution type and pixel change type, which results in gradient distribution concentration and all-zero blocks, the target filtering strategy for the coding unit is determined to be a skip filtering strategy. In response to the combination of gradient distribution type and pixel change type, which results in a gradient distribution concentration and non-all-zero blocks, the target filtering strategy corresponding to the coding unit is determined to be a convolutional kernel filtering strategy based on gray-level entropy adjustment. The combined result of gradient distribution type and pixel change type is gradient distribution dispersion and all-zero block, and the target filtering strategy corresponding to the coding unit is determined to be the weighted interpolation filtering strategy. The result of the combination of gradient distribution type and pixel change type is a gradient distribution dispersion and non-all-zero blocks. The target filtering strategy corresponding to the coding unit is determined to be the orientation-sensitive convolutional kernel filtering strategy.
[0009] In one embodiment, filtering the coding unit using a target filtering strategy includes: In response to the target filtering strategy corresponding to the coding unit, which is a convolutional kernel filtering strategy based on gray-level entropy adjustment, the gray-level entropy of the coding unit is obtained. The gray-level entropy is used to indicate the degree of dispersion of pixel gray-level distribution within the coding unit. The adjustment factor is determined based on the gray entropy, and the adjustment factor is used to adjust the convolution kernel of the filter. The adjusted convolutional kernel is used to filter the coding unit.
[0010] In one embodiment, before filtering the coding unit using a target filtering strategy, the following steps are included: Based on the target filtering strategy corresponding to the target coding unit and the target filtering strategy corresponding to the adjacent coding unit, the degree of strategy consistency between the target coding unit and the adjacent coding unit is determined. In response to a policy consistency level that is lower than a preset consistency threshold, the filter policy with the largest proportion among the target filter policies corresponding to adjacent coding units is determined as the candidate filter policy for the target coding unit. In response to the fact that the filtering error of the candidate filtering strategy is lower than the filtering error of the target filtering strategy corresponding to the target coding unit, the target filtering strategy corresponding to the target coding unit is updated based on the candidate filtering strategy, and the updated target filtering strategy is used to perform filtering processing on the coding unit.
[0011] A second aspect of this disclosure provides a filtering device, the device comprising: The acquisition unit is used to acquire gradient spatial distribution data and pixel change data of coding units in video images; The first determining unit is used to determine the gradient distribution type of the coding unit based on gradient spatial distribution data, and to determine the pixel change type of the coding unit based on pixel change degree data. The second determining unit is used to determine the target filtering strategy corresponding to the encoding unit based on the combination result of the gradient distribution type and the pixel change type. The filtering unit is used to filter the coding unit using the target filtering strategy.
[0012] A third aspect of this disclosure provides an electronic device comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the methods described in the first aspect of this disclosure.
[0013] A fourth aspect of this disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause a computer to perform the methods described in the first aspect of this disclosure.
[0014] A fifth aspect of this disclosure provides a computer program product including a computer program that, when executed by a processor, implements the methods described in the first aspect of this disclosure.
[0015] In summary, this disclosure proposes a filtering method, which includes: acquiring gradient spatial distribution data and pixel change degree data of coding units in a video image; determining the gradient distribution type of the coding unit based on the gradient spatial distribution data, and determining the pixel change type of the coding unit based on the pixel change degree data; determining the target filtering strategy corresponding to the coding unit according to the combination result of the gradient distribution type and the pixel change type; and performing filtering processing on the coding unit using the target filtering strategy.
[0016] According to the scheme provided in this disclosure, gradient spatial distribution data and pixel change degree data of coding units in video images are obtained; based on the gradient spatial distribution data, the gradient distribution type of the coding unit is determined, and based on the pixel change degree data, the pixel change type of the coding unit is determined, thereby achieving dual accurate classification of coding units, comprehensively depicting the edge direction distribution pattern and pixel fluctuation characteristics of the coding units, and accurately distinguishing coding units with different feature types such as flat regions, single edge regions, and complex texture regions; by determining the target filtering strategy corresponding to the coding unit based on the combination result of gradient distribution type and pixel change type; using the target filtering strategy to filter the coding unit can avoid the limitations of single-dimensional judgment in traditional methods, making the filtering strategy accurately match the actual features of the coding unit, thereby improving the filtering effect of video images.
[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0019] Figure 1 A schematic diagram of a filtering boundary and reference pixel provided in an embodiment of this disclosure; Figure 2 A flowchart illustrating a filtering method provided in an embodiment of this disclosure; Figure 3 A flowchart illustrating a method for determining the gradient distribution type of an encoding unit according to an embodiment of this disclosure; Figure 4 A flowchart illustrating a method for determining a target filtering strategy corresponding to an encoding unit, provided in an embodiment of this disclosure; Figure 5 A schematic diagram of a convolution operation provided in an embodiment of this disclosure; Figure 6 This is a schematic diagram of the structure of a filtering device provided in an embodiment of the present disclosure; Figure 7 This is a schematic diagram of the hardware composition structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0020] Embodiments of this disclosure are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this disclosure, and should not be construed as limiting this disclosure.
[0021] To facilitate a better understanding of the technical solutions described in the embodiments of this disclosure by those skilled in the art, the technical terms in the embodiments of this disclosure are explained as follows before introducing the embodiments of this disclosure.
[0022] To mitigate and eliminate block artifacts in video images, filters are typically used to smooth abrupt changes in pixel values at block boundaries. This type of filtering is called a deblocking filter. The main filtering process includes obtaining boundary strength, filter switching decisions, and selecting filter strength. The final filtering step is calculated based on the filtered boundary pixels, such as... Figure 1 As shown, Figure 1 This is a schematic diagram of the filter boundary and reference pixels.
[0023] The following is a brief introduction to one filtering method in related technologies: The proposed solution employs motion prediction-based deblocking filtering. By segmenting the video into small blocks, techniques such as local illumination compensation, generalized bidirectional prediction, weighted prediction, and affine motion prediction are used to deeply analyze the illumination and motion information of the current block. By extracting relevant data from the bitstream, the filtering operation state and parameters required for the current block are determined, thereby optimizing the encoding and decoding process and improving video quality and compression efficiency.
[0024] The above solution has the following drawbacks: The computational complexity is high, especially in high-resolution video, which may lead to encoding delays and affect processing speed.
[0025] For fast-moving objects, the accuracy of prediction may be insufficient, which may lead to decreased coding efficiency or impaired visual quality.
[0026] To address the shortcomings of related technologies, this disclosure acquires gradient spatial distribution data and pixel change degree data of coding units in video images; based on the gradient spatial distribution data, it determines the gradient distribution type of the coding unit, and based on the pixel change degree data, it determines the pixel change type of the coding unit, achieving dual accurate classification of coding units. This comprehensively characterizes the edge direction distribution pattern and pixel fluctuation characteristics of the coding units, accurately distinguishing coding units with different feature types such as flat regions, single-edge regions, and complex texture regions. By determining the target filtering strategy corresponding to the coding unit based on the combination result of the gradient distribution type and pixel change type, the target filtering strategy is determined. Filtering the coding units using the target filtering strategy avoids the limitations of single-dimensional judgment in traditional methods, ensuring that the filtering strategy is accurately matched with the actual characteristics of the coding unit, thereby improving the filtering effect of the video image.
[0027] The present disclosure will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0028] The filtering method provided in this disclosure can be applied to scenarios with high video quality requirements, such as ultra-high-definition video live streaming, low bitrate video communication, cloud gaming, and virtual reality. The execution entity of the method can be a video codec, a dedicated image processing chip, or a software module running on a general-purpose processor.
[0029] like Figure 2 As shown, Figure 2 This is a flowchart illustrating a filtering method provided in an embodiment of this disclosure. The filtering method provided in this embodiment includes the following steps: Step 201: Obtain the gradient spatial distribution data and pixel change data of the coding units in the video image; In one embodiment, the encoding unit is a basic unit of image processing. In this application, the encoding unit refers to a macroblock in a video image. During the video image encoding / decoding process, the image is divided into fixed-size pixel blocks, such as 16×16 or 32×32 pixels.
[0030] In one embodiment, the gradient spatial distribution data is a set of the distribution states of pixel gradients in different directions within a macroblock, reflecting the directional distribution patterns of macroblock edges and textures; the pixel change degree data is the data on the fluctuation range of pixel values within a macroblock, reflecting the smoothness of the macroblock region, such as small pixel changes in flat areas and large changes in edge or textured areas.
[0031] In one embodiment, the gradient spatial distribution data of coding units in a video image can be obtained by calculating the Sobel operator, the Scharr operator, or the central difference method.
[0032] In one embodiment, pixel variation data can be determined based on the average difference between adjacent pixels in the horizontal and vertical directions.
[0033] Step 202: Based on the gradient spatial distribution data, determine the gradient distribution type of the coding unit, and based on the pixel change degree data, determine the pixel change type of the coding unit; In one embodiment, the gradient distribution type is a macroblock category based on gradient spatial distribution data, mainly divided into two categories: concentrated gradient distribution and dispersed gradient distribution. Among them, concentrated gradient distribution means that the pixel gradients in the macroblock are mainly concentrated in 1-2 directions, such as a single horizontal / vertical edge; dispersed gradient distribution means that the pixel gradients in the macroblock are distributed in multiple directions, such as complex textures and intersecting edges.
[0034] In one embodiment, the pixel change type is a macroblock category based on the degree of pixel change data, mainly divided into two types: those with gradual pixel change (All Zero Block, AZB) and those with drastic pixel change (Non-All Zero Block). An All Zero Block refers to a macroblock with minimal pixel value differences, often found in flat areas such as the image background, while a Non-All Zero Block refers to a macroblock with significant pixel value differences, often found in complex areas such as edges and textures.
[0035] In one embodiment, a gradient distribution score can be determined based on the gradient distribution characteristics of the current macroblock. The gradient distribution type is then determined by comparing the gradient distribution score with a classification threshold. Furthermore, the classification threshold can be dynamically adjusted based on the macroblock gradient magnitude. Alternatively, the gradient distribution characteristics of a large number of macroblocks can be used as training samples to train a logistic regression model. The gradient distribution characteristics of the current macroblock can then be used as input to the trained logistic regression model to predict the gradient distribution type. The logistic regression model can also be replaced with other machine learning models, which are not limited in this application.
[0036] In one embodiment, a pixel change score can be determined based on the pixel change level data of the current macroblock. The pixel change score is compared with a pixel change threshold to determine the pixel change type of the coding unit. Furthermore, the pixel change threshold can be dynamically adjusted based on the pixel values within the macroblock. Alternatively, a large amount of pixel change level data of macroblocks can be used as training data to train a Support Vector Machine (SVM) model. The pixel change level data of the current macroblock, such as the mean and variance, is input to predict the pixel change type of the macroblock.
[0037] Step 203: Determine the target filtering strategy corresponding to the coding unit based on the combination result of gradient distribution type and pixel change type; In one embodiment, the combination of gradient distribution type and pixel change type results in gradient distribution concentrated and all-zero blocks, gradient distribution concentrated and not all-zero blocks, gradient distribution dispersed and all-zero blocks, and gradient distribution dispersed and not all-zero blocks.
[0038] In one embodiment, the target filtering strategy is a differentiated filtering scheme that matches the combination of gradient distribution type and pixel change type of the macroblock.
[0039] In one embodiment, for macroblocks with concentrated gradient distribution and all-zero blocks, the filtering strategy can be skipped directly, i.e., the original pixel values are not changed. Alternatively, low-pass filtering, such as using a 3×3 mean filter, can be used to reduce computational load. For macroblocks with concentrated gradient distribution and not all-zero blocks, a fixed-size Gaussian filter can be used, such as using only a 3×3 Gaussian kernel. Alternatively, a content-adjustable convolutional kernel filter based on gray-level entropy can be used, such as a 3×3+5×5 Gaussian kernel, where the kernel weights are adjusted by gray-level entropy. Another option is to use a fusion filter of gray-level entropy and edge detection, such as first locating the edge position through edge detection and then using an adjustable convolutional kernel. Kernel-specific filtering: For gradient distributions that are scattered and consist entirely of zero blocks, simple mean interpolation filtering can be used, which means averaging the current pixel with its four neighboring pixels. Neighborhood weighted interpolation filtering or adaptive weighted interpolation filtering can also be used, which means dynamically adjusting the weights based on the similarity between the current pixel and its neighboring pixels. For gradient distributions that are not entirely of zero blocks, fixed-direction convolution kernel filtering can be used, which means pre-setting two kernels, one horizontal and one vertical. Direction-sensitive convolution kernel filtering or multi-direction convolution kernel fusion filtering can also be used, further introducing 45° and 135° direction kernels.
[0040] Differentiated strategies avoid the drawbacks of traditional one-size-fits-all filtering: smooth blocks skip filtering reduces invalid calculations, and complex blocks use precise filtering to improve deblocking performance.
[0041] Step 204: Filter the coding unit using the target filtering strategy.
[0042] In one embodiment, the target filtering strategy determined in step 203 above is used to adjust the pixel values of macroblocks to eliminate block effects, i.e., the sense of image fragmentation caused by abrupt changes in pixel boundaries of blocks, while preserving details such as image edges and textures.
[0043] Compared to traditional motion prediction-based filtering methods, it has lower computational complexity, lower encoding latency, and more stable performance on fast-moving objects.
[0044] This application achieves adaptive deblocking filtering by utilizing gradient spatial distribution data and pixel variation data to address the limitations of traditional filtering methods in terms of specificity and filtering effectiveness. First, this application acquires gradient spatial distribution data and pixel variation data of macroblocks in a video image. The gradient spatial distribution data reflects the spatial distribution of pixel gradients within the macroblock, while the pixel variation data characterizes the fluctuation range of pixel values within the macroblock. Then, based on the gradient spatial distribution data, the gradient distribution type of the macroblock is determined, and based on the pixel variation data, the pixel variation type of the macroblock is determined. Accurate classification of the macroblock is achieved through the combination of these two types of features. Next, based on different classification results, a corresponding target filtering strategy is matched to ensure that the filtering operation is adapted to the specific characteristics of the macroblock. Finally, the matched target filtering strategy is used to perform filtering processing on the macroblock, thereby effectively eliminating block artifacts.
[0045] By combining classification methods based on gradient spatial distribution data and pixel variation data with adaptive filtering strategies, the differential characteristics of macroblocks are fully considered, improving the targeting and accuracy of filtering; at the same time, the low efficiency caused by the uniform filtering strategy in traditional methods is avoided.
[0046] In one embodiment, such as Figure 3 As shown, based on gradient spatial distribution data, the gradient distribution type of the coding unit is determined, including: Step 301: Extract the horizontal and vertical gradients of each pixel in the coding unit from the gradient space distribution data; In one embodiment, the horizontal gradient (Gx) is the rate of change of grayscale value of a single pixel in the macroblock in the horizontal direction, i.e., the rate of change of grayscale value of the left and right adjacent pixels, representing the degree of brightness change of the pixel in the horizontal direction; the vertical gradient (Gy) is the rate of change of grayscale value of a single pixel in the macroblock in the vertical direction, i.e., the rate of change of grayscale value of the up and down adjacent pixels, representing the degree of brightness change of the pixel in the vertical direction.
[0047] In one embodiment, for each pixel within a macroblock, the gradient values in the horizontal and vertical directions are obtained by calculating the difference in grayscale values between it and its neighboring pixels. The mathematical expressions for the horizontal gradient Gx and the vertical gradient Gy for pixel (i,j) are as follows: ; Step 302: Based on the horizontal and vertical gradients, determine the first gradient magnitude and gradient direction for each pixel. In one embodiment, the first gradient magnitude (G(i,j)) is a combined value calculated based on the horizontal and vertical gradients of a single pixel, representing the edge intensity of that pixel.
[0048] In one embodiment, the gradient direction (θ(i,j)) is the angle between the gradient vector of a single pixel and the horizontal direction, representing the orientation of the edge.
[0049] In one embodiment, the mathematical expressions for determining the first gradient magnitude and gradient direction of each pixel are as follows: ; ; Step 303: Divide the gradient direction into a preset number of intervals, and based on the first gradient magnitude, determine the second gradient magnitude of each interval and the third gradient magnitude of the preset number of intervals. In one embodiment, the preset number (k) intervals refer to the angle ranges pre-divided for statistical gradient direction distribution, such as 8 intervals, each interval being 45°, or 4 intervals, each interval being 90°.
[0050] In one embodiment, the second gradient magnitude (S_k) is the sum of the first gradient magnitudes of all pixels within a single gradient direction interval.
[0051] In one embodiment, the third gradient magnitude (S) is the sum of the second gradient magnitudes across all gradient direction intervals, which is the sum of the first gradient magnitudes of all pixels within the macroblock.
[0052] In one embodiment, the mathematical expressions for determining the second gradient magnitude of each interval and the third gradient magnitude of a preset number of intervals are as follows: ; ; Step 304: Determine the gradient distribution concentration of the coding unit based on the second gradient magnitude and the third gradient magnitude; In one embodiment, the gradient distribution concentration (C) is the ratio of the largest second gradient magnitude to the third gradient magnitude. The larger the value, the more concentrated the gradient is in a few directions, such as a single edge. Conversely, the gradient distribution is more dispersed, such as a complex texture. The gradient distribution concentration characterizes the degree of concentration of gradients in a direction within a macroblock.
[0053] In one embodiment, the mathematical expression for determining the gradient distribution concentration of the coding unit is as follows: .
[0054] Step 305: Determine the gradient distribution type of the encoding unit based on the gradient distribution concentration and the preset concentration threshold. The gradient distribution type includes gradient distribution concentration and gradient distribution dispersion.
[0055] In one embodiment, the preset concentration threshold (T_new) is a critical value used to determine the type of gradient distribution, and is a standard for distinguishing between concentrated and dispersed gradient distributions. The size of the threshold will affect the classification accuracy. The preset concentration threshold can be dynamically adjusted based on the overall gradient characteristics of the macroblock.
[0056] In one embodiment, The base threshold can be set to a value that is... ,like The global gradient is biased towards concentration, and the threshold needs to be lowered; if The global gradient is too dispersed, and the threshold needs to be adjusted upwards.
[0057] In one embodiment, the mathematical expression for determining the preset concentration threshold is as follows: ; Here, k is an adjustment coefficient, which can be taken as k=0.2. The mathematical expression is as follows: .
[0058] Ultimately, the gradient distribution concentration C is greater than When C is less than 1, the gradient distribution is considered to be concentrated; when C is less than 1, the gradient distribution is considered to At that time, the gradient distribution was considered to be dispersed.
[0059] When determining the gradient distribution type of a macroblock based on gradient spatial distribution data, the horizontal gradient Gx and vertical gradient Gy of each pixel (i,j) in the macroblock are first calculated. Then, the first gradient magnitude G(i,j) of that pixel is calculated using the formula, and the gradient direction θ(i,j) is calculated using arctan(Gy(i,j) / Gx(i,j)). The gradient direction is divided into 8 preset intervals, each 45°. The sum of the first gradient magnitudes of all pixels in each interval is counted as the second gradient magnitude S_k of that interval. At the same time, the sum of the second gradient magnitudes of the 8 intervals is calculated to obtain the third gradient magnitude S. The ratio of the largest second gradient magnitude to the third gradient magnitude is determined as the gradient distribution concentration C of the macroblock. The preset concentration threshold is initially set to 0.7, and a dynamic threshold model is constructed using the average gradient magnitude of the current macroblock. = -0.2( - When C is greater than When determining that a macroblock has a concentrated gradient distribution, if C is less than 1, then... The gradient distribution is then determined to be dispersed.
[0060] By accurately calculating pixel gradient parameters and dividing gradient direction intervals, combined with adaptive dynamic threshold adjustment, the macroblock gradient distribution type can be accurately determined, avoiding classification errors caused by fixed thresholds. This provides a reliable basis for matching subsequent adaptive filtering strategies and improves the targeting of filtering processing.
[0061] In one embodiment, determining the pixel change type of the encoding unit based on pixel change level data includes: Based on pixel variation data, determine the average difference between adjacent pixels in the coding unit; The pixel change type of the encoding unit is determined based on the average difference between adjacent pixels and a preset pixel change threshold. The pixel change type includes all-zero blocks or non-all-zero blocks.
[0062] In one embodiment, pixel variation data refers to the core feature set of the fluctuation range of pixel values within a macroblock, reflecting the smoothness or complexity of the macroblock region.
[0063] In one embodiment, the average value (D) of the difference between adjacent pixels is the statistical average of the absolute differences in grayscale values between adjacent pixels in the horizontal and vertical directions within the macroblock.
[0064] In one embodiment, for all adjacent pixels within a macroblock, the absolute difference in their grayscale values is calculated, and then the average value of the difference between adjacent pixels is obtained by statistical averaging. The scattered pixel difference information is aggregated into a single quantitative index, which intuitively reflects the overall smoothness of the macroblock.
[0065] In one embodiment, the preset pixel change threshold (Td) is a preset critical value used to classify pixel change types, which can be dynamically adjusted based on the macroblock pixel value distribution characteristics.
[0066] In one embodiment, a zero-value macroblock refers to a macroblock where the average difference between adjacent pixels is lower than a preset pixel change threshold and the fluctuation is weak; a non-zero-value macroblock refers to a macroblock where the average difference between adjacent pixels is higher than the preset pixel change threshold and the fluctuation is obvious.
[0067] In one embodiment, if the macroblock size is N×N and its pixel value is I(i,j), the mathematical expression for determining the average difference between adjacent pixels in the coding unit, i.e., the average absolute difference between adjacent pixels within the macroblock, is as follows: ; Where D represents the degree of pixel variation in the entire macroblock, |I(i,j)-I(i,j+1)| represents the difference between adjacent pixels in the horizontal direction, and |I(i,j)-I(i+1,j)| represents the difference between adjacent pixels in the vertical direction. To distinguish between all-zero blocks and non-all-zero blocks, an adaptive threshold adjustment strategy based on the macroblock pixel value distribution can be adopted. Specifically, by calculating the proportion P of pixel values in the macroblock within the range [3,255], the all-zero block judgment threshold Td is dynamically adjusted: For example, when P < 10%, it indicates that there are few high-value pixels in the macroblock, and to reduce misjudgment, the threshold Td is increased to increase the error tolerance; when P ≥ 10%, the empirical baseline value of Td = 3 is maintained, and the mathematical expression for Td is as follows: ; Where k is 20, The final judgment rule is as follows: if the pixel change degree D of the entire macroblock is less than the adjusted threshold Td, it is judged as an all-zero block; if the pixel change degree D of the entire macroblock is greater than Td, it is judged as a non-all-zero block.
[0068] It should be noted that the pixel value range [3,255] here is used to exclude pixels with smaller pixel values. It can also be [6,255] or [10,255]. This application does not limit it.
[0069] In one embodiment, the aforementioned 10% can also be adjusted according to the classification accuracy requirements; the smaller the value, the more accurate the determination of the pixel change type.
[0070] When determining the pixel change type of a macroblock based on pixel change data, assuming the macroblock size is N×N and its pixel value is I(i,j), first calculate the absolute difference between horizontally adjacent pixels |I(i,j)-I(i,j+1)| and vertically adjacent pixels |I(i,j)-I(i+1,j)| within the macroblock. Then, average the absolute differences of all adjacent pixels to obtain the average difference D between adjacent pixels. The preset pixel change threshold Td is initially set to 3. Td is dynamically adjusted by calculating the proportion P of pixel values in the [3,255] interval of the macroblock. When P < 10%, Td = 3+20P When P≥10%, Td=3 is maintained; if D is less than the adjusted Td, the pixel change type of the macroblock is determined to be an all-zero block; if D is greater than Td, it is determined to be a non-all-zero block.
[0071] By statistically analyzing the average difference between adjacent pixels and dynamically adjusting the judgment threshold based on pixel value distribution, the accuracy of distinguishing between all-zero blocks and non-all-zero blocks is effectively improved, and misjudgments in flat and complex areas are reduced.
[0072] In one embodiment, such as Figure 4 As shown, based on the combination of gradient distribution type and pixel change type, the target filtering strategy corresponding to the coding unit is determined, including: Step 401: In response to the combination result of gradient distribution type and pixel change type being gradient distribution concentration and all-zero block, the target filtering strategy corresponding to the coding unit is determined to be the skip filtering strategy. In one embodiment, the combined result is a gradient distribution concentration and all-zero blocks, indicating that the macroblock belongs to a flat region and contains only weak edges in a single direction (such as slight light and dark transitions in a solid color background), without complex textures or intersecting edges, with extremely low risk of block effect, such as a solid color background (such as sky or wall) in a video, a flat region without details.
[0073] In one embodiment, for blocks with concentrated gradient distribution and all zeros, a skip filter is used due to the smoothness of the region, that is, no filtering adjustment is made to the macroblock pixel values, and the original pixel values are not changed.
[0074] In one embodiment, the skip filtering strategy is applicable to smoothing macroblocks without the risk of block artifacts, reducing invalid computations and improving coding efficiency.
[0075] Step 402: In response to the combination result of gradient distribution type and pixel change type being gradient distribution concentration and non-all-zero blocks, the target filtering strategy corresponding to the coding unit is determined to be a convolution kernel filtering strategy based on gray-level entropy adjustment. In one embodiment, the combined result is a gradient distribution concentration and non-all-zero block representation macroblock containing a clear edge in a single direction (such as horizontal / vertical lines, object outlines), with significant differences in pixel values on both sides of the edge, but no multi-directional texture interference. Block effects are likely to appear at the junction of the edge and flat areas, such as the stroke edges in text videos, the wall outlines in architectural videos, and horizontal / vertical dividing lines.
[0076] In one embodiment, the convolution kernel filtering strategy based on gray-level entropy adjustment is a filtering scheme that dynamically adjusts the convolution kernel parameters (size, weight) based on gray-level entropy.
[0077] By determining the target filtering strategy corresponding to the coding unit as a convolutional kernel filtering strategy based on gray entropy adjustment, gray entropy reflects the complexity of macroblock texture, and through adaptive parameter adjustment, the filtering can preserve texture details while smoothing block effects.
[0078] In one embodiment, filtering the coding unit using a target filtering strategy includes: In response to the target filtering strategy corresponding to the coding unit, which is a convolutional kernel filtering strategy based on gray-level entropy adjustment, the gray-level entropy of the coding unit is obtained. The gray-level entropy is used to indicate the degree of dispersion of pixel gray-level distribution within the coding unit. The adjustment factor is determined based on the gray entropy, and the adjustment factor is used to adjust the convolution kernel of the filter. The adjusted convolutional kernel is used to filter the coding unit.
[0079] In one embodiment, such as Figure 5 As shown, Figure 5 This is a schematic diagram of a convolution operation provided in an embodiment of the present disclosure, wherein, p is a 3x3 pixel block. These are the filtered pixel values. The mathematical expression for the Gaussian kernel G, i.e., the adjusted convolution kernel, is as follows: ; G uses 3x3 and 5x5 smooth convolution kernels as a baseline, with the addition of a 5x5 kernel to enhance smoothing of textured regions; α is an adjustment factor determined by gray-level entropy, and the mathematical expression for gray-level entropy H is as follows: ; in, This represents the probability of the current macroblock pixel value occurring. A higher entropy value H indicates a more dispersed grayscale distribution, containing more diverse textures and structures; therefore, in this case, the 5x5 convolution kernel needs a higher degree of bias. The mathematical expression for the adjustment factor is as follows: .
[0080] When the target filtering strategy is a convolutional kernel filtering strategy based on gray-level entropy adjustment, the gray-level entropy of the macroblock is first calculated as H = -ΣP_i log2P_i, where P_i is the probability of each pixel value appearing within the macroblock. This gray-level entropy directly reflects the dispersion of pixel gray-level distribution. Based on the gray-level entropy H, an adjustment factor α = H_max / H is determined, where H_max is the preset maximum entropy value. Using 3×3 and 5×5 Gaussian smooth convolutional kernels as benchmarks, the weight ratio of the two types of convolutional kernels is adjusted by the adjustment factor α. The higher the gray-level entropy, the greater the weighting of the 5×5 convolutional kernel. Then, the 3×3 pixel blocks of the macroblock are filtered using the weighted convolutional kernels to obtain the filtered pixel values.
[0081] By dynamically adjusting the convolution kernel parameters through grayscale entropy, the convolution kernel adapts to the texture complexity of macroblocks, effectively preserving image details while smoothing block artifacts, avoiding image blurring caused by over-filtering, and improving the subjective quality of the filtered image.
[0082] Step 403: In response to the combination result of gradient distribution type and pixel change type being gradient distribution dispersion and all-zero block, the target filtering strategy corresponding to the coding unit is determined to be the weighted interpolation filtering strategy; In one embodiment, the combined result is a gradient distribution dispersion and all-zero blocks indicating that the macroblock belongs to a flat, weak texture region with no obvious edges, but has weak textures in multiple directions (such as slight wood grain or fabric texture). The pixels are generally smooth but have slight fluctuations in some areas. The block effect is manifested as slight texture fragmentation, such as light-colored fabric, frosted wall, and flat natural textures (such as grass in the distance).
[0083] In one embodiment, the weighted interpolation filtering strategy is a filtering scheme that fuses the values of the current pixel and neighboring pixels and calculates the target pixel value according to a preset weight.
[0084] In one embodiment, for a gradient distribution that is scattered and consists entirely of zeros, in order to enhance the correlation between the current pixel and its surrounding pixels, this application employs a weighted average method. Specifically, the current pixel value is combined with the values of its four neighboring pixels (up, down, left, and right) according to certain weights, and then a filtering operation is performed. The details are as follows: ; ; in, It is the current pixel value. Represents the values of the four pixels: top, bottom, left, and right, where k ∈ [1, 4]. These are weight values; this proposal uses empirical values from smoothing filters to... Set it to 0.6, and the rest each take up 0.1.
[0085] By determining the target filtering strategy corresponding to the coding unit as a weighted interpolation filtering strategy, the correlation of pixels within the smooth block can be enhanced, block boundary abrupt changes caused by a single pixel value can be avoided, and the smoothness can be achieved without losing the characteristics of the flat area.
[0086] Step 404: In response to the combination result of gradient distribution type and pixel change type being gradient distribution dispersion and non-all-zero blocks, the target filtering strategy corresponding to the coding unit is determined to be the orientation-sensitive convolutional kernel filtering strategy.
[0087] In one embodiment, the combined result is a gradient distribution of scattered and non-all-zero blocks, indicating that the macroblock belongs to a complex texture or cross-edge region, containing clear edges, dense textures or cross structures in multiple directions, with large pixel value fluctuations, and the block effect is easily manifested as texture breakage, edge blurring or blocky fragmentation, such as natural landscapes (such as leaves, rocks), complex patterns (such as fabric patterns), and intersecting lines or contours (such as grids, branches).
[0088] In one embodiment, the orientation-sensitive convolution kernel filtering strategy employs a convolution kernel (horizontal / vertical direction) adapted to the edge direction and uses a weight adjustment factor to enhance the filtering scheme of the corresponding orientation pixel correlation.
[0089] For gradient distributions that are scattered and not all-zero blocks, a directional convolution kernel with weight k-adjustment is used. and enhancement level Pixel correlation in the vertical direction can adaptively enhance edge features in the corresponding direction, thereby improving the directional sensitivity of the filter. Specifically: when processing vertical boundaries in an image, a horizontal convolution kernel is used for optimization; when processing horizontal boundaries, a vertical convolution kernel is used.
[0090] First, there's the horizontal convolution kernel for the vertical boundaries. To enhance the features of the vertical boundaries, this proposal implements the horizontal convolution kernel based on the texture complexity of macroblock texture features. Adaptive adjustment of intensity The mathematical expression is as follows: ; ; in and These are the filtered pixel value and the original pixel value to be filtered, respectively. The calculation of the k value here is related to the variance of the pixels within the current macroblock. The relevant mathematical expression for k is as follows: ; in, For smoothing parameters, the average pixel value within the macroblock is typically used. That is, when... When k approaches zero (macroblock is relatively smooth), k also approaches zero; when As the threshold increases, k also gradually increases. Similarly, for the vertical convolution kernel of the horizontal boundary, in order to adaptively enhance the features of the horizontal boundary, a vertical convolution kernel with an adjustment factor k is also used for calculation. The mathematical expression is as follows: ; ; in and These are the filtered pixel value and the original pixel value to be filtered, respectively.
[0091] By determining the target filtering strategy corresponding to the coding unit as the direction-sensitive convolutional kernel filtering strategy, it is possible to accurately adapt to macroblocks with complex textures and intersecting edges, thereby eliminating block artifacts while enhancing edge features and avoiding edge blurring.
[0092] When matching the target filtering strategy based on the combination of gradient distribution type and pixel change type, if the combined result is a gradient distribution with all zeros, the filtering step is skipped to reduce invalid calculations because the pixel changes in this area are gradual. If the gradient distribution is concentrated but not all zeros, a convolutional kernel filtering strategy based on gray-level entropy adjustment is adopted to adapt to areas with relatively simple textures. If the gradient distribution is scattered and all zeros, the filtering coefficients are calculated by fusing neighboring pixel information through weighted interpolation to enhance pixel correlation. If the gradient distribution is scattered and not all zeros, a directional convolutional kernel filtering strategy with weight adjustment is adopted to strengthen pixel correlation in the edge direction.
[0093] By matching differentiated filtering strategies to the combination results of four types of macroblocks, the limitations of traditional unified filtering methods are avoided, enabling the filtering operation to accurately adapt to the different characteristics of macroblocks, ensuring both filtering effect and processing efficiency.
[0094] Considering that traditional image filtering and preprocessing techniques usually adopt a block-by-block independent judgment strategy, that is, each macroblock (such as 16×16, 32×32) determines the filtering method independently based on its own features (such as gradient, texture intensity, pixel variance, etc.). However, this local independent judgment method has two problems: (1) the adjacent block strategies are inconsistent, resulting in boundary artifacts; (2) some regions have structural and texture continuity, and relying solely on single-block information will lead to misclassification or unstable strategies.
[0095] In one embodiment, before filtering the coding unit using a target filtering strategy, the following steps are included: Based on the target filtering strategy corresponding to the target coding unit and the target filtering strategy corresponding to the adjacent coding unit, the degree of strategy consistency between the target coding unit and the adjacent coding unit is determined. In response to a policy consistency level that is lower than a preset consistency threshold, the filter policy with the largest proportion among the target filter policies corresponding to adjacent coding units is determined as the candidate filter policy for the target coding unit. In response to the fact that the filtering error of the candidate filtering strategy is lower than the filtering error of the target filtering strategy corresponding to the target coding unit, the target filtering strategy corresponding to the target coding unit is updated based on the candidate filtering strategy, and the updated target filtering strategy is used to perform filtering processing on the coding unit.
[0096] In one embodiment, the target coding unit refers to the macroblock currently undergoing filtering strategy optimization, and the adjacent coding unit refers to the set of macroblocks adjacent to the target macroblock, which is used to reflect the distribution characteristics of filtering strategies in the region where the target macroblock is located.
[0097] In one embodiment, the policy consistency level is the matching ratio between the target filtering policy of the target macroblock and the filtering policy of the adjacent macroblock. The higher the value, the more unified the policy is, and the lower the value, the easier it is to generate boundary artifacts.
[0098] In one embodiment, a preset consistency threshold (e.g., 0.4) is used as a critical value to determine whether a strategy is coordinated. If the value is below the threshold, the target macroblock strategy is considered to be an outlier strategy.
[0099] In one embodiment, the candidate filtering strategy is usually the filtering strategy that appears most frequently in adjacent macroblocks, and is an alternative to replace the original strategy of the target macroblock.
[0100] In one embodiment, filtering error is a quantitative indicator of filtering effectiveness, such as Peak Signal-to-Noise Ratio (PSNR) gain and Structural Similarity Index Measure (SSIM). Lower filtering error indicates better filtering performance. Specifically, the target macroblock can be filtered using both the original strategy and the candidate strategy, and the PSNR values after filtering with each strategy can be calculated. A higher PSNR indicates lower filtering error. If the PSNR of the candidate strategy is ≥3% higher than that of the original strategy, the candidate strategy is considered superior, and the candidate filtering strategy is determined as the target filtering strategy for the target coding unit. Alternatively, the SSIM values after filtering with both strategies can be calculated. The closer the SSIM value is to 1, the better the structure preservation and the lower the error. If the SSIM value of the candidate strategy is ≥0.053% higher than that of the original strategy, the candidate strategy is considered superior, and the candidate filtering strategy is determined as the target filtering strategy for the target coding unit.
[0101] Before executing the target filtering strategy, the target filtering strategies for all macroblocks within the 3×3 neighborhood of the target macroblock are obtained. The number of macroblocks in the neighborhood that have the same strategy as the target macroblock is counted, and the strategy consistency degree R(x,y) is calculated as: number of identical strategies / 9. The preset consistency threshold is 0.4. If R(x,y) is lower than this threshold, the filtering strategy with the highest frequency in the neighborhood is selected as the candidate filtering strategy. The filtering error (e.g., PSNR gain) between the candidate strategy and the original target strategy is calculated. If the filtering error of the candidate strategy is lower than that of the original strategy and the improvement is ≥3%, the filtering strategy of the target macroblock is updated to the candidate filtering strategy.
[0102] For example, based on the aforementioned steps 201 to 204, the target filtering policy label S(x,y) corresponding to each macroblock is obtained. S(x,y) represents the policy type of the (x,y)th macroblock, such as S=0: skip filtering, S=1: Gaussian convolution filtering, S=2: direction-sensitive filtering, S=3: weighted average filtering. Then, for each macroblock, the policy distribution of its adjacent macroblock regions is analyzed; the analysis of the policy distribution of its adjacent macroblock regions is the same as the aforementioned content, and will not be repeated here. Next, the policy consistency metric is determined. Specifically, a 3×3 macroblock region is defined, where the middle macroblock is the current macroblock (x,y), and the macroblocks in its upper, lower, left, right, and four diagonal directions, totaling 8 adjacent macroblocks. Therefore, this 3×3 region contains a total of 9 macroblocks. The mathematical expression for the policy consistency metric R(x,y) is as follows: ; If the policy consistency metric is lower than the preset consistency threshold (e.g., 0.4), the current policy is considered an outlier policy in the region.
[0103] If an outlier strategy occurs, select the strategy Smax with the largest proportion in the neighborhood as a candidate; recalculate the filtering simulation error (e.g., PSNR gain or structure preservation) of the block under the Smax strategy; if the new strategy is better than the original strategy or improves by a certain amount (e.g., ≥3%), then replace the current macroblock strategy with Smax.
[0104] For example, suppose the current macroblock policy is: skip filtering (S=0); its surrounding 8 macroblock policies are as follows: macroblock A is policy 1, macroblock B is policy 2, macroblock C is policy 1, macroblock D is policy 1, macroblock E is policy 1, macroblock F is policy 0, macroblock G is policy 1, and macroblock H is policy 1; the statistical results are: S=1 (Gaussian filtering): 6; S=2: 1; S=0 (skip): 1 (current). At this time, the current block policy is inconsistent with the majority of the neighbors, so an outlier policy is triggered; the policy with the largest proportion is Smax=1, so S=1 is used to filter the current macroblock. If the filtering effect of S=1 is better than S=0, then the policy is updated.
[0105] By determining the policy consistency between the target coding unit and its neighboring coding units based on the target filtering policy corresponding to the target coding unit and the target filtering policy corresponding to the neighboring coding units, the policy consistency is determined. If the policy consistency is lower than a preset consistency threshold, the filtering policy with the largest proportion among the target filtering policies corresponding to the neighboring coding units is determined as the candidate filtering policy for the target coding unit. If the filtering error of the candidate filtering policy is lower than the filtering error of the target filtering policy corresponding to the target coding unit, the target filtering policy corresponding to the target coding unit is updated based on the candidate filtering policy, and the updated target filtering policy is used to filter the coding unit. This accurately quantifies the coordination between the target macroblock policy and the region policy, avoiding optimization bias caused by subjective judgment.
[0106] By optimizing the consistency of neighborhood policies, boundary artifacts caused by inconsistent filtering policies of adjacent macroblocks are avoided. At the same time, the rationality of policy updates is ensured by comparing filtering errors, which further improves the coherence of the entire video image filtering process and the overall visual effect.
[0107] In summary, the solution provided in this public disclosure is as follows: First, the gradient spatial distribution data and pixel change degree data of coding units in the video image are acquired. Based on the gradient spatial distribution data, the gradient distribution type of the coding unit is determined, and based on the pixel change degree data, the pixel change type of the coding unit is determined, achieving dual accurate classification of coding units. This comprehensively depicts the edge direction distribution pattern and pixel fluctuation characteristics of the coding units, and can accurately distinguish coding units with different feature types such as flat regions, single edge regions, and complex texture regions. By determining the target filtering strategy corresponding to the coding unit based on the combination result of gradient distribution type and pixel change type, the target filtering strategy is determined. Filtering the coding unit using the target filtering strategy can avoid the limitations of single-dimensional judgment in traditional methods, making the filtering strategy accurately match the actual characteristics of the coding unit, thereby improving the filtering effect of the video image.
[0108] Secondly, by matching differentiated filtering strategies to the combination results of the four types of macroblocks, the limitations of the traditional unified filtering method are avoided, and the filtering operation is accurately adapted to the different characteristics of the macroblocks, ensuring both filtering effect and processing efficiency.
[0109] Furthermore, by optimizing the consistency of neighborhood strategies, boundary artifacts caused by inconsistent filtering strategies of adjacent macroblocks are avoided. At the same time, the rationality of strategy updates is ensured by comparing filtering errors, which further improves the coherence of the entire video image filtering process and the overall visual effect.
[0110] To implement the filtering method provided in this disclosure, this disclosure also provides a filtering device, such as... Figure 6 As shown. Figure 6This is a schematic diagram of a filtering device provided in an embodiment of the present disclosure. The filtering device 600 includes: The acquisition unit 601 is used to acquire gradient spatial distribution data and pixel change degree data of coding units in video images; The first determining unit 602 is used to determine the gradient distribution type of the coding unit based on gradient spatial distribution data, and to determine the pixel change type of the coding unit based on pixel change degree data. The second determining unit 603 is used to determine the target filtering strategy corresponding to the encoding unit based on the combination result of the gradient distribution type and the pixel change type. The filtering unit 604 is used to filter the coding unit using the target filtering strategy.
[0111] In one embodiment, the first determining unit 602 is specifically used for: Extract the horizontal and vertical gradients of each pixel in the coding unit from the gradient space distribution data; Based on the horizontal and vertical gradients, determine the first gradient magnitude and gradient direction for each pixel; The gradient direction is divided into a preset number of intervals, and based on the first gradient magnitude, the second gradient magnitude of each interval and the third gradient magnitude of the preset number of intervals are determined. The gradient distribution concentration of the coding unit is determined based on the second and third gradient magnitudes. The gradient distribution type of the encoding unit is determined based on the gradient distribution concentration and the preset concentration threshold. The gradient distribution types include gradient distribution concentration and gradient distribution dispersion.
[0112] In one embodiment, the first determining unit 602 is specifically used for: Based on pixel variation data, determine the average difference between adjacent pixels in the coding unit; The pixel change type of the encoding unit is determined based on the average difference between adjacent pixels and a preset pixel change threshold. The pixel change type includes all-zero blocks or non-all-zero blocks.
[0113] In one embodiment, the second determining unit 603 is specifically used for: In response to the combination of gradient distribution type and pixel change type, which results in gradient distribution concentration and all-zero blocks, the target filtering strategy for the coding unit is determined to be a skip filtering strategy. In response to the combination of gradient distribution type and pixel change type, which results in a gradient distribution concentration and non-all-zero blocks, the target filtering strategy corresponding to the coding unit is determined to be a convolutional kernel filtering strategy based on gray-level entropy adjustment. The combined result of gradient distribution type and pixel change type is gradient distribution dispersion and all-zero block, and the target filtering strategy corresponding to the coding unit is determined to be the weighted interpolation filtering strategy. The result of the combination of gradient distribution type and pixel change type is a gradient distribution dispersion and non-all-zero blocks. The target filtering strategy corresponding to the coding unit is determined to be the orientation-sensitive convolutional kernel filtering strategy.
[0114] In one embodiment, the filtering unit 604 is specifically used for: In response to the target filtering strategy corresponding to the coding unit, which is a convolutional kernel filtering strategy based on gray-level entropy adjustment, the gray-level entropy of the coding unit is obtained. The gray-level entropy is used to indicate the degree of dispersion of pixel gray-level distribution within the coding unit. The adjustment factor is determined based on the gray entropy, and the adjustment factor is used to adjust the convolution kernel of the filter. The adjusted convolutional kernel is used to filter the coding unit.
[0115] In one embodiment, the filtering unit 604 is specifically used for: Based on the target filtering strategy corresponding to the target coding unit and the target filtering strategy corresponding to the adjacent coding unit, the degree of strategy consistency between the target coding unit and the adjacent coding unit is determined. In response to a policy consistency level that is lower than a preset consistency threshold, the filter policy with the largest proportion among the target filter policies corresponding to adjacent coding units is determined as the candidate filter policy for the target coding unit. In response to the fact that the filtering error of the candidate filtering strategy is lower than the filtering error of the target filtering strategy corresponding to the target coding unit, the target filtering strategy corresponding to the target coding unit is updated based on the candidate filtering strategy, and the updated target filtering strategy is used to perform filtering processing on the coding unit.
[0116] It should be noted that the filtering device provided in the above embodiments is only illustrated by the division of the above program modules. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the filtering device can be divided into different program modules to complete all or part of the processing described above. In addition, the filtering device provided in the above embodiments and the filtering method provided in the embodiments of this disclosure belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0117] Figure 7 This is a schematic diagram of the hardware composition structure of the electronic device provided in the embodiments of this disclosure, such as... Figure 7As shown, the electronic device 700 includes at least one processor 702; and a memory 701 communicatively connected to the at least one processor 702; wherein the memory 701 stores instructions executable by the at least one processor 702, the instructions being executed by the at least one processor 702 to implement the steps of the filtering method of the present disclosure embodiments.
[0118] Optionally, the electronic device may specifically be a filtering device in the embodiments of this application, and the electronic device may implement the corresponding processes implemented by the filtering device in the various methods of the embodiments of this application. For the sake of brevity, it will not be described in detail here.
[0119] It is understood that the electronic device also includes a communication interface 703. Various components in the electronic device are coupled together via a bus system 704. It is understood that the bus system 704 is used to implement communication between these components. In addition to a data bus, the bus system 704 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 7 The general designated all buses as Bus System 704.
[0120] It is understood that memory 701 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 701 described in this embodiment of the invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0121] The methods disclosed in the above embodiments can be applied to or implemented by processor 702. Processor 702 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above methods can be completed by integrated logic circuits in the hardware of processor 702 or by instructions in software form. Processor 702 may be a general-purpose processor, DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 702 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, specifically memory 701. Processor 702 reads information from memory 701 and, in conjunction with its hardware, completes the steps of the aforementioned methods.
[0122] In an exemplary embodiment, the electronic device may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general-purpose processors, controllers, MCUs, microprocessors, or other electronic components to perform the aforementioned method.
[0123] This disclosure also provides a non-transitory computer-readable storage medium storing computer instructions, which are used to cause a computer to execute the steps of the filtering method of the present invention.
[0124] Optionally, the computer-readable storage medium can be applied to the filtering device in the embodiments of this application, and the computer instructions cause the computer to execute the corresponding processes implemented by the filtering device in the various methods of the embodiments of this application. For the sake of brevity, they will not be described in detail here.
[0125] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the filtering method provided in this embodiment of the invention.
[0126] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0127] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0128] In addition, in the various embodiments of the present invention, each functional unit can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be implemented in hardware or in the form of hardware plus software functional units.
[0129] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media that can store program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0130] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0131] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A filtering method, characterized in that, include: Acquire the gradient spatial distribution data and pixel change data of coding units in video images; Based on the gradient spatial distribution data, the gradient distribution type of the coding unit is determined, and based on the pixel change degree data, the pixel change type of the coding unit is determined. Based on the combination of the gradient distribution type and the pixel change type, the target filtering strategy corresponding to the coding unit is determined; The coding unit is filtered using the target filtering strategy.
2. The method according to claim 1, characterized in that, Determining the gradient distribution type of the coding unit based on the gradient spatial distribution data includes: Extract the horizontal and vertical gradients of each pixel in the encoding unit from the gradient spatial distribution data; Based on the horizontal and vertical gradients, the first gradient magnitude and gradient direction of each pixel are determined; The gradient direction is divided into a preset number of intervals, and based on the first gradient magnitude, a second gradient magnitude for each interval and a third gradient magnitude for a preset number of intervals are determined. Based on the second gradient magnitude and the third gradient magnitude, the gradient distribution concentration of the coding unit is determined; The gradient distribution type of the encoding unit is determined based on the gradient distribution concentration and the preset concentration threshold. The gradient distribution type includes gradient distribution concentration and gradient distribution dispersion.
3. The method according to claim 2, characterized in that, Determining the pixel change type of the encoding unit based on the pixel change level data includes: Based on the pixel change data, the average difference between adjacent pixels in the encoding unit is determined; The pixel change type of the encoding unit is determined based on the average difference between adjacent pixels and a preset pixel change threshold. The pixel change type includes all-zero blocks or non-all-zero blocks.
4. The method according to claim 3, characterized in that, The step of determining the target filtering strategy corresponding to the coding unit based on the combination result of the gradient distribution type and the pixel change type includes: In response to the combination of the gradient distribution type and the pixel change type resulting in a gradient distribution set and an all-zero block, the target filtering strategy corresponding to the coding unit is determined to be a skip filtering strategy. In response to the combination result of the gradient distribution type and the pixel change type being a gradient distribution cluster and a non-all-zero block, the target filtering strategy corresponding to the coding unit is determined to be a convolutional kernel filtering strategy based on gray-level entropy adjustment; In response to the combination result of the gradient distribution type and the pixel change type being a gradient distribution dispersion and an all-zero block, the target filtering strategy corresponding to the coding unit is determined to be a weighted interpolation filtering strategy. In response to the combination of the gradient distribution type and the pixel change type resulting in a gradient distribution dispersion and a non-all-zero block, the target filtering strategy corresponding to the coding unit is determined to be a direction-sensitive convolutional kernel filtering strategy.
5. The method according to claim 4, characterized in that, The step of filtering the coding unit using the target filtering strategy includes: In response to the target filtering strategy corresponding to the coding unit being a convolutional kernel filtering strategy based on gray-level entropy adjustment, the gray-level entropy of the coding unit is obtained, and the gray-level entropy is used to indicate the degree of dispersion of pixel gray-level distribution within the coding unit; An adjustment factor is determined based on the grayscale entropy, and the adjustment factor is used to adjust the convolution kernel of the filter; The coding unit is filtered using the adjusted convolutional kernel.
6. The method according to claim 1, characterized in that, The step of filtering the coding unit using the target filtering strategy includes: Based on the target filtering strategy corresponding to the target coding unit and the target filtering strategy corresponding to the adjacent coding unit, the degree of consistency between the strategies of the target coding unit and the adjacent coding unit is determined. In response to the policy consistency level being lower than a preset consistency threshold, the filter policy with the largest proportion among the target filter policies corresponding to the adjacent coding unit is determined as the candidate filter policy of the target coding unit; In response to the fact that the filtering error of the candidate filtering strategy is lower than the filtering error of the target filtering strategy corresponding to the target coding unit, the target filtering strategy corresponding to the target coding unit is updated based on the candidate filtering strategy, and the updated target filtering strategy is used to perform filtering processing on the coding unit.
7. A filtering device, characterized in that, include: The acquisition unit is used to acquire gradient spatial distribution data and pixel change data of coding units in video images; The first determining unit is configured to determine the gradient distribution type of the encoding unit based on the gradient spatial distribution data, and to determine the pixel change type of the encoding unit based on the pixel change degree data. The second determining unit is used to determine the target filtering strategy corresponding to the encoding unit based on the combination result of the gradient distribution type and the pixel change type. A filtering unit is used to perform filtering processing on the encoding unit using the target filtering strategy.
8. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 6.
10. A computer program product comprising a computer program that, when executed by a processor, implements the method of any one of claims 1 to 6.