Fast adaptive loop filtering algorithm based on class merging

Through the fast adaptive loop filtering algorithm of phased category merging and linearized cost estimation, the existing ALF has been solved, and significant reduction in computational complexity and coding efficiency have been achieved.

CN119420931APending Publication Date: 2025-02-11上海芯开技术有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411661848.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The existing adaptive loop filter (ALF) has high computational complexity during video encoding, resulting in a significant increase in encoding time and difficulty in taking into account both accuracy and computing efficiency.

Method used

A fast adaptive loop filtering algorithm based on class merge is proposed. Through phased class merge and linearized cost estimation, the calculation and update process of filter coefficients is simplified and the calculation complexity is reduced.

Benefits of technology

The calculation complexity during the encoding process is significantly reduced, and the number of iterations is reduced from 4900 to 248, which improves the encoding efficiency and optimizes the cost of rate distortion while ensuring image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420931A_ABST
    Figure CN119420931A_ABST
Patent Text Reader

Abstract

The invention relates to the field of video coding, and discloses a fast adaptive loop filtering algorithm based on class merging, which comprises the following steps of: dividing image brightness components into a plurality of filtering classes; based on the rate distortion optimization cost, gradually reducing the number of categories by adopting a staged strategy of coarse screening and fine merging, merging from an initial category to a preset target category, further merging until only one category is left, and recording the merging process; the filter coefficient is updated for the category after each time of merging, matrix calculation is simplified through linearization cost estimation, and the number of iterations is reduced; further selecting an optimal filter set based on a rate distortion optimization cost traversal merging process; in the filtering parameter output stage, the combined filtering categories and the corresponding filter coefficients are packaged into a self-adaptive parameter set, and application of a decoding end is facilitated. According to the algorithm, on the premise that the image quality is kept, the coding efficiency is remarkably improved, and the algorithm is suitable for video coding application scenes with high requirements for real-time performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of video encoding, and in particular to a fast adaptive loop filtering algorithm based on class merging. Background Art

[0002] The current video coding standard, Versatile Video Coding (VVC), was proposed in 2020 with the goal of improving coding efficiency by about 40% compared to the previous generation High Efficiency Video Coding (HEVC) standard. VVC introduces a variety of new coding tools to improve compression efficiency, among which in-loop filtering tools include de-blocking filters, sample adaptive offset (SAO), adaptive loop filters (ALF), and luminance mapping with chroma scaling (LMCS). These filtering tools significantly improve video compression efficiency, among which the introduction of ALF brings about a 4.2% improvement in coding performance. However, ALF requires dynamic adjustment of filter parameters during the encoding process, which relies on the solution of the Wiener filter and the Wiener-Hoff equation. The process is complex and computationally intensive, resulting in a significant increase in encoding time.

[0003] In the ALF module, the luminance component is usually classified based on gradient information. For example, the gradient of each pixel in the horizontal, vertical and diagonal directions is calculated according to the 4×4 macroblock, and the gradient values ​​of the macroblock are accumulated and quantized to obtain the category index. In the VVC standard, the filter selection of the luminance component is based on this category information, and one filter is selected from 25 filters for each 4×4 macroblock for processing. In order to obtain the filter coefficients, the VVC standard provides two methods: one is online calculation based on the current video slice, that is, the filter parameter set (APS) is calculated for each coding tree block (CTB) and encoded and transmitted; the other is to use one of the 16 fixed pre-trained filter sets and select the corresponding filter coefficients to reduce the transmission overhead. However, the complexity of online calculation is high, and the fixed filter is limited in adaptability. Both methods fail to take into account the requirements of accuracy and computational efficiency.

[0004] In the prior art, the computational complexity and coding efficiency of the adaptive loop filter have become the main bottlenecks. In the current algorithm, ALF needs to build a list that gradually merges from 25 categories to 1 category to record the optimal choice at each merging stage. This method usually uses a complete traversal, that is, checking all possible pairwise merging combinations one by one to obtain the best merging solution. Since each calculation requires solving an N-order matrix equation (N=13 in the luminance component), it takes about 4900 iterations to complete the entire merging process. Complex algorithms such as Cholesky decomposition are often used in the matrix solution process, so the overall calculation process is time-consuming and computationally intensive, which is difficult to meet the needs of real-time applications. Although studies have tried to accelerate ALF calculations in different ways, such as using specific filter shapes or neural networks to optimize filter parameters, these methods mainly focus on improving filtering performance, and the control of encoding time is still limited, and it is impossible to fundamentally reduce the complexity of the algorithm.

[0005] The existing optimization scheme fails to effectively simplify the matrix calculation process in the process of class merging and solving filter coefficients, and its adaptability to different types of video content is not ideal. The commonly used fixed threshold pruning method fails to consider the differences in different video textures, resulting in an insufficient balance between acceleration effect and filtering performance. Therefore, an improved ALF algorithm is urgently needed to significantly reduce the computational complexity while ensuring filtering accuracy to meet the coding requirements in practical applications. Summary of the invention

[0006] In view of the deficiencies of the prior art, the present invention provides a fast adaptive loop filtering algorithm based on class merging, which significantly reduces the computational complexity in the encoding process and improves the encoding efficiency by optimizing the adaptive loop filtering (ALF) process while maintaining the filtering accuracy.

[0007] To achieve the above objectives, the present invention is implemented by the following technical scheme: a fast adaptive loop filtering algorithm based on class merging, comprising the following steps: Initialize multiple filter categories and set initial filter coefficients for each category; Based on the rate-distortion optimization cost, the number of initial categories is reduced to the preset target number of categories, and then further merged to the optimal number of filters retained in the end; updating filter coefficients of the filtering category; Output the combined filter category and the corresponding filter coefficients.

[0008] Preferably, the step of initializing multiple filtering categories and setting initial filter coefficients for each category comprises: Divide the video brightness component into multiple filter categories, each filter category corresponds to a predefined filter index; For each filtering category, determining filter coefficients, the filter coefficients being initially set based on local image characteristics of the luminance component, including gradient directionality and gradient activity; Calculate the gradient features of the luminance macroblock in each category, including the gradient components in the horizontal, vertical and diagonal directions, and accumulate these gradient components into the overall gradient value of the macroblock; quantizing the gradient features into a directionality level and an activity level according to a predetermined rule, and generating a corresponding category index; According to the category index, an initial filter coefficient set is allocated to each filtering category, and the filter coefficient set is used for adaptive adjustment and updating during the merging process.

[0009] Preferably, the step of reducing the initial number of categories to a preset target number of categories comprises: Count the occurrence frequency of each initial category in the video slice, and sort all categories in ascending order according to the frequency of occurrence; Select categories with lower frequency of occurrence and merge them first to reduce the number of categories; The merging operation is repeated until the number of initial categories is reduced to the preset target number of categories.

[0010] Preferably, the step of reducing the initial number of categories to a preset target number of categories further comprises: In each merging operation, a candidate set of categories to be merged is screened based on a preset similarity condition, wherein the similarity condition includes the same directional characteristics or activity characteristics; The category with the lowest frequency of occurrence is selected from the candidate set for merging to obtain the optimal initial category merging solution.

[0011] Preferably, the step of further merging until only one filter remains comprises: After completing the preliminary category merging, a full traversal search is performed on the remaining categories to determine the merging cost of each pair of categories, where the merging cost is calculated based on the rate-distortion optimization cost; Compare the distortion costs of different category combinations, select the category combination with the lowest distortion cost for merging, and gradually reduce the number of categories to the optimal number of filters retained in the end.

[0012] Preferably, the step of further merging until only one filter remains further comprises: After each merging operation, the filter coefficients of the merged category are updated to ensure that the adaptability of the merged category reaches the optimal state; The final optimal number of filters and the corresponding category allocation scheme are determined to ensure that the filter coefficients of each retained category minimize the rate-distortion cost and meet the coding efficiency requirements.

[0013] Preferably, the calculation of the distortion cost includes: Subtract the distortion cost of each individual class from the combined distortion cost to obtain the error value; The quality of the current category merging is judged based on the error value to determine the merging solution.

[0014] Preferably, the updating of the filter coefficients includes: Recalculate the filter coefficients for the merged categories based on a simplified linear calculation model; By approximating the linear equation, the original matrix equation is transformed into a linear addition process.

[0015] The present invention also provides a fast adaptive loop filtering device based on class merging, comprising: An initialization module, used to initialize multiple filter categories and set filter coefficients; A merging module, used for coarse screening merging and fine merging of filter categories based on rate-distortion optimization cost, wherein a simplified linear calculation model is used; An update module recalculates the filter coefficients for the merged categories; The output module is used to output the combined filter categories and corresponding filter coefficients.

[0016] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the above method is implemented.

[0017] The present invention also provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described above is implemented.

[0018] The present invention provides a fast adaptive loop filtering algorithm based on class merging, which has the following beneficial effects: 1. The present invention significantly reduces the demand for computing resources in the adaptive loop filtering process through staged category merging and linearized cost estimation. The matrix solution in the original algorithm is simplified to a linear calculation process, and the number of iterations is reduced from the original 4900 times to 248 times, which greatly reduces the computational burden and makes the algorithm suitable for scenarios with high real-time requirements.

[0019] 2. The present invention optimizes the category merging process to make the process of reducing the number of filter categories more efficient and avoid unnecessary traversal calculations. The phased coarse screening and fine merging strategy ensures that only the key categories that appear frequently are finely screened, while the low-frequency categories are merged first, thereby improving the overall coding efficiency.

[0020] 3. The present invention dynamically updates the filter coefficients, thereby reducing the computational complexity and ensuring the optimization effect of the rate-distortion cost. By linearizing the cost estimation, the accuracy of the image details during the merging process is retained, so that the final image quality remains at a high level after different filter categories are merged.

[0021] 4. The adaptive parameter set (APS) output by the present invention can contain the filter coefficients and category index information of each merged category, which is convenient for selective application to different coding blocks at the decoding end. The flexibility of APS enables the encoder to adapt to the texture characteristics and frequency distribution of different regions in the video clip, thereby achieving a more refined image restoration effect.

[0022] 5. The present invention reduces the bit rate overhead caused by adaptive filtering during transmission by optimizing the information in the adaptive parameter set. For a fixed filter set, only the index of the selected filter needs to be recorded, and the filter coefficient set calculated online is directly applied to the coding tree block (CTB), thereby further reducing the transmission cost of APS.

[0023] 6. The category merging information of the present invention ensures that the decoding end can accurately apply the filter coefficients corresponding to each category, avoiding the error accumulation that may occur in the traditional method. By outputting the mapping relationship of the category index, the decoding end does not need to repeat the calculation and can directly obtain the filter parameters of each category, thereby improving the decoding efficiency and the accuracy of image restoration. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a schematic diagram of the method flow of the present invention; Figure 2 A schematic diagram for describing the ALF merging process of the present invention; Figure 3 It is a schematic diagram of the original algorithm of the present invention; Figure 4 It is a schematic diagram of the algorithm of the present invention; Figure 5 Schematic diagram of probability statistics experiment of the final number of filters k of the present invention; Figure 6 A schematic diagram of a probability statistical experiment of the sorted classes being retained according to the present invention; Figure 7 It is a schematic diagram of the structure of the device of the present invention; Figure 8 It is a schematic diagram of the computer device structure of the present invention.

[0025] Among them, 100, initialization module; 200, merging module; 300, updating module; 400, output module; 40, computer equipment; 41, processor; 42, memory; 43, storage medium. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the specification of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] Please refer to the attached Figure 1 The embodiment of the present invention provides a fast adaptive loop filtering algorithm based on class merging. By optimizing the initialization of filter categories and the class merging process, the computational complexity is significantly reduced by combining matrix calculation simplification and iterative process simplification, thereby improving the efficiency of video coding.

[0028] The algorithm mainly includes four steps: initializing the filter category, merging process based on rate-distortion optimization cost, updating the filter coefficients and outputting the results. The following describes each step of the method of the present invention in detail.

[0029] S1. Initialize filter category In the present invention, the basic preparation work of the adaptive loop filtering process is completed by initializing multiple filter categories and setting filter coefficients. Specifically, the initialization step not only includes category division and initial setting of filter coefficients, but also combines the quantization and classification of image gradient features, laying the foundation for subsequent category merging and filter update processes.

[0030] In this implementation, the ALF (Adaptive Loop Filter) first divides the image brightness component into multiple filtering categories and sets initial filter coefficients for each category to reduce the computational burden while maintaining image quality.

[0031] Specifically, in the processing of the luminance component, in some implementations, the local features of the image are classified in units of 4×4 macroblocks. For each 4×4 luminance macroblock, the gradient components of the macroblock in each direction are obtained by calculating the gradients of each pixel in the horizontal, vertical and diagonal directions. The purpose of this process is to obtain the local change features of the image so as to classify the image regions according to these features and adapt to the filtering requirements of different regions.

[0032] In a further embodiment, all pixel gradients are accumulated as the overall gradient value of the macroblock, and quantized based on a predetermined rule. In some embodiments, the specific quantization method adopts a directional and activity Two levels to finely divide the local features of macroblocks. Directionality It reflects the dominant directional characteristics of the macroblock and divides the gradient components into five directional levels; activity It reflects the texture activity of the macroblock and divides the gradient component into 5 activity levels. and activity A total of 25 different categories are formed, and a category index is generated for each category. The category to which each 4×4 macroblock belongs can be determined by the following formula: (1) in, and Represents gradient directionality and gradient activity, respectively. In this way, each 4×4 luminance macroblock is assigned to a specific category, and the corresponding filter is selected according to its category information. The quantization process based on this formula can effectively distinguish macroblocks with different image features, providing support for subsequent adaptive filtering.

[0033] In the process of setting the filter coefficients, this embodiment combines two different methods for obtaining filter coefficients. For each 4×4 luminance macroblock, a 7×7 filter shape is selected according to the block classification information in some embodiments, and then an initial set of filter coefficients is assigned to each category. Specifically, the VVC standard provides two methods for generating filter coefficients: online calculation coefficients and fixed coefficients. The online calculation coefficients calculate the filter coefficients of each coding tree block (CTB) frame by frame based on the current video slice information, and package the calculated filter parameters into the adaptive parameter set (APS) for storage for subsequent transmission and application. Another way is to select the optimal set from 16 pre-trained fixed filter sets, which can reduce the bit rate overhead caused by the adaptive parameter set during transmission to a certain extent.

[0034] In addition, the initialization step of this embodiment also involves preliminary calculation of distortion cost and dynamic adjustment of filter coefficients. In this process, mean square error (MSE) is the optimization target, and the calculation method of MSE is shown in formula (2): (2) Among them, the filtered pixels is the filter coefficient and reconstructed pixel difference The product and sum of are as shown in formula (3): (3) In order to minimize the distortion cost, the partial derivative of each coefficient is required to be close to zero. The partial derivative calculation process of is shown in formula (4): (4) By deducing the above partial derivatives, we can obtain the matrix equation (5), namely: (5) Among them, the coefficient Defined as:

[0035] Matrix Items The expected value is:

[0036] In the above initialization step, the initial setting of the filter coefficients provides the initial conditions for the subsequent class merging and coefficient updating, and ensures the effectiveness of the initial classification by using the classification method based on image gradient features. Through the initial classification and setting of the filter coefficients in this step, the subsequent merging process can be based on a more accurate feature description, thereby improving the efficiency and accuracy of the adaptive loop filtering process.

[0037] S2, merging process based on rate-distortion optimization cost and filter coefficient update The dynamic merging of filter categories and the updating of filter coefficients are realized, and the image quality is maintained under the premise of reducing the computational complexity by simplifying the calculation process and optimizing the cost estimation. First, the initial number of categories is merged in stages through the rate-distortion optimization cost, so that the number of categories is gradually reduced to the target number of categories, and then further merged to the final optimal number of filters on this basis. Afterwards, the filter coefficients are dynamically updated for the merged categories to optimize the rate-distortion cost. Specifically, the present invention uses linearization processing to simplify the matrix calculation and the number of iterations in the merging process, effectively improving the efficiency of loop filtering.

[0038] In this implementation, the 25 initial filter categories are first reduced to a preset target number of categories (eg, 10) so as to be further merged into a final optimal number of filters in subsequent steps.

[0039] In the coarse screening stage of merging, this embodiment reduces the computational complexity of class merging through a two-step optimization process. First, the frequency of occurrence of each category in the video slice is statistically sorted by sorting based on the frequency of occurrence, and categories with lower frequency of occurrence are merged preferentially, thereby reducing the computational complexity of uncommon categories. Specifically, the merging process in the coarse screening stage no longer traverses all possible pairwise merging combinations, but is performed selectively based on the frequency of occurrence of the class. For example, experimental results show that low-frequency categories are more likely to be merged. Therefore, in this embodiment, the category with the lowest frequency of occurrence among the remaining categories is preferentially selected in each coarse screening merging operation, avoiding a complete traversal and significantly reducing the number of merging operations.

[0040] This embodiment further combines merge screening based on similarity conditions. Based on the screening of similar categories, the merge in the present invention is only performed in categories with the same directional (D) or activity (A) characteristics, thereby narrowing the merge search range. For example, categories with the same characteristic direction (such as horizontal, vertical or diagonal direction) as the current category are preferentially merged, so that the number of traversals required for each iteration is significantly reduced. According to this screening criterion, the coarse screening merge operation in this embodiment only requires 248 cycles in the coarse screening process of merging 10 times, which greatly simplifies the calculation process compared to 4900 cycles in the traditional algorithm.

[0041] In the fine merging stage, the present embodiment uses a full traversal method to merge the remaining categories in detail. In this stage, by calculating the rate-distortion cost of each possible pairwise combination, the present invention can select the appropriate category combination according to the lowest merging cost to further reduce the number of categories. Through the screening after the above-mentioned coarse screening merger, the number of categories in the fine merging stage has been reduced to 10, so the number of calculations required in the full traversal has been greatly reduced. In some embodiments, the goal of the fine merging stage is to retain the optimal number of filters to ensure that the rate-distortion optimization cost is minimized.

[0042] In order to simplify the calculation of rate-distortion cost, the present invention further introduces a linearized cost estimation method to reduce the computational complexity. In the original algorithm, in order to achieve the optimal filter set selection, it is usually necessary to solve a complex matrix equation, and the rate-distortion optimization cost (RDO) must be calculated in each iteration, resulting in a huge amount of overall calculation. To this end, the present invention linearizes the cost calculation process and reduces the need for matrix solution.

[0043] In this implementation, the rate-distortion cost It can be expressed as the following formula: (6) in, represents the original pixel value, Represents the reconstructed pixel value, coefficient and In order to optimize the matrix equation solving process to linear calculation, this implementation assumes that in each merging operation, except for a certain coefficient All other coefficients except for remain unchanged. That is, during the merging process, only The relevant parts are considered dynamic, while the rest are treated as constants. This simplifying assumption allows us to transform complex matrix calculations into simple linear additions.

[0044] Specifically, for each partial derivative , a new equation can be constructed, where is the only variable, and the remaining terms can be obtained by fixed linear addition. This simplified partial derivative expression is as follows: (7) in, Represents the cumulative result of other fixed items, which are defined as follows:

[0045] When merging two classes (e.g., Class A and Class B), the error According to the derivation of conditions (6) and (9), the following formula can be obtained: (8) In actual calculation, the combined error can be linearly calculated by the following conditions: (9) In this process, the complex matrix solution is avoided by linearly estimating the combined cost. The present invention adopts a simplified accumulation method, which significantly reduces the computational burden in the iterative process.

[0046] Furthermore, the error It can be calculated by the following expression: (10) Through this linear estimation method, the present embodiment can significantly reduce the computational complexity of each merging operation while ensuring the rate-distortion cost optimization effect. In some embodiments, once the optimal merging decision for the current iteration is obtained, the present invention will accurately analyze each filter coefficient to ensure that the updated coefficient value is used in the next iteration.

[0047] Through this simplified calculation method, the linearized cost estimation method of the present invention effectively reduces the complex matrix operations and iteration times in the traditional algorithm during the category merging process, reduces the demand for computing resources, and thus achieves a fast adaptive loop filtering effect. This improvement is particularly suitable for application scenarios of high-efficiency video coding, so that the filtering process improves the encoding speed while ensuring image quality.

[0048] Through the above steps, the present invention realizes efficient merging and updating from the initial category to the optimal filter set through staged category merging and linearization cost estimation, greatly improving the overall efficiency of the loop filtering algorithm, and is suitable for video encoding scenarios with high real-time requirements.

[0049] S3, output the combined filter category and the corresponding filter coefficient Based on the initialization, category merging and filter coefficient update in the previous steps, the final filter set generated significantly reduces the complexity and computational cost while maintaining image quality. In the output step, by storing the finalized filter category and the corresponding filter coefficients as an adaptive parameter set (APS), it is ensured that these optimized parameters can be efficiently applied during the decoding process and the balance between coding efficiency and image restoration quality is maintained.

[0050] In this embodiment, an adaptive parameter set (APS) is first generated at the output stage of video encoding, which contains filter coefficients for each retained filter category. In some embodiments, the APS is designed to include several specific syntax elements for describing the filter coefficients and category index of each filter category, which is convenient for transmission in the coded stream. The APS can realize the necessary filter information transmission between the encoding end and the decoding end, so that the decoding end can accurately apply the merged filter parameters.

[0051] This implementation further optimizes the storage method of filter coefficients during the output process, reducing the bit rate overhead. For example, when a fixed filter set is used, only the index of the selected filter needs to be recorded, thereby effectively reducing the transmission cost of APS. When using online calculated filter coefficients, combined with the simplified calculation process described above, the generated filter coefficient set will be directly applied to each coding tree block (CTB), improving the filtering efficiency. In addition, the stored APS parameter set can also be selectively applied to different coding blocks to adapt to the differences in image areas and further optimize the coding effect.

[0052] In some embodiments, the APS also includes specific filter merging information. This information is based on the optimal number of categories and the final category division scheme determined in the previous steps, so that the decoder can effectively distinguish the filters corresponding to each category and accurately apply the filter coefficients to ensure the details and quality of image restoration. In addition, the merging information includes a mapping relationship between the number of categories and the index, so that the decoder can directly obtain the parameters of each category without repeated calculations.

[0053] Through the above output process, the present invention can efficiently transmit the optimized filter parameters and apply them to the decoding end, providing a good rate-distortion balance for video coding.

[0054] In general, the present invention simplifies the filter coefficient calculation and update process through staged category merging and linearized cost estimation, thereby significantly reducing the computational complexity. First, multiple initial filter categories are initialized, and then gradually merged in stages based on the rate-distortion optimization cost to eventually obtain the optimal filter set. Subsequently, the filter coefficients are dynamically updated for the merged categories to ensure the best filtering effect under low-complexity conditions. Finally, the merged filter categories and filter coefficients are packaged into an adaptive parameter set for efficient image restoration at the decoding end. The present invention effectively improves the coding efficiency while maintaining image quality, and is suitable for video coding application scenarios with high real-time requirements.

[0055] Example: Please refer to the attached Figure 2 -Attached Figure 6 The embodiment of the present invention provides a fast adaptive loop filtering algorithm based on class merging, which achieves more efficient filtering performance by simplifying both matrix calculation and iterative process. The main implementation steps of this embodiment are described in detail below with reference to the accompanying drawings.

[0056] 1. Initialization of filter categories This embodiment first calculates and quantizes the gradient of the 4×4 macroblock of the luminance component to achieve the classification of local features of the image. For each 4×4 luminance macroblock, the gradient of each pixel in the horizontal, vertical and diagonal directions is calculated, and all gradient values ​​are accumulated as the overall gradient of the macroblock. According to the classification rules of the VVC standard, the gradient is quantized into 5 levels according to the directionality D and activity A, and the block category index is calculated by formula (1), and each luminance macroblock is divided into 25 different categories. For each category, a set of initial filter coefficients is assigned for use in the subsequent adaptive adjustment process.

[0057] 2. Phased Category Merger Initially, each class has a set of filter coefficients after the first pass of coefficient calculation. To balance adaptivity and overhead, there is a class merging process for the luminance component in ALF. Similar classes will be merged by comparing the rate-distortion cost to share the same filter set. To achieve merging, a two-step rate-distortion optimization process is used, as Figure 2 The first step is to build a merge list that records the best merge scenarios when different numbers of filters (25 to 1) are kept for step 2. The second step is to traverse the list and determine the final number of filters k.

[0058] like Figure 3As shown in the figure, the complete traversal method in the original algorithm is shown, that is, all possible situations are traversed pair by pair to calculate the optimal choice for each merger. In the original algorithm, ALF needs to build a list from 25 categories to 1 category in sequence, involving 4900 iterations, and each coefficient calculation requires solving an N-order matrix equation (N=13 in the brightness component). To simplify this process, this implementation example Figure 4 As shown in the figure, the category merging process is divided into two stages: coarse screening merging and fine merging. The specific steps are as follows: Coarse Screening Merging Stage: In this stage, the initial 25 categories are first reduced to a preset number of target categories (e.g., 10) to reduce the search space and computational overhead. This embodiment counts the frequency of occurrence of each category in the video slice and preferentially merges the categories with lower frequencies, thereby reducing the computational effort of uncommon categories. In addition, according to experimental analysis, each merging operation in the coarse screening stage is performed only in categories with the same directional D or activity A features to narrow the search scope. This simplification process significantly reduces the number of iterations from 4900 in the original algorithm to 248.

[0059] Fine merging phase: After the coarse screening and merging are completed, this embodiment adopts a pair-by-pair fine merging of the retained categories. By calculating the rate-distortion cost of each possible pairwise combination, the optimal combination is selected as shown in formula (6) to ensure that the rate-distortion cost of the category merging solution is minimized. At this stage, the fine screening process of the original algorithm is completely retained to ensure that the merged categories maintain image quality.

[0060] 3. Application of Linearized Cost Estimation In order to simplify the cost calculation after the category merger, this embodiment further adopts a linearized cost estimation method to avoid complex matrix solutions. Specifically, by linearizing the rate-distortion cost (Formula 6), the present invention can simplify the merged cost estimation into a linear calculation process. In actual calculations, in order to reduce the dependence on matrix equations, this embodiment assumes that when merging, except for a specific variable, other coefficients remain unchanged, so that the partial derivative formula can be converted into a linear solution. The accumulated term is the accumulated result of the non-variable term, which further simplifies the updated cost.

[0061] On this basis, the calculation of the error can be expressed by formulas (8) to (10), and the cost after merging is calculated by the difference in cost before and after merging. In addition, when merging two categories (such as category A and category B), the linear cost estimation used in this embodiment calculates the merging cost (Formula 8). By linearizing the cost estimation, the present invention can ensure the minimization of the cost when selecting a merging scheme, while effectively reducing the amount of calculation for each merging operation and avoiding the need for complex matrix solving.

[0062] 4. Update of filter coefficients After each merging operation, the present embodiment further updates the filter coefficients of each merged category to ensure that the optimal filtering effect is achieved after reducing the number of categories. The filter coefficient update is based on the aforementioned linearization model to avoid complex matrix decomposition operations. For example, in the simplified partial derivative equation, by using the accumulated term as a fixed term to obtain the filter coefficient update value, it is possible to ensure that the merged category maintains a balance between image quality and rate distortion cost.

[0063] 5. Experimental part of optimization iteration This embodiment also carries out experimental verification to further optimize the merging effect in the iterative process. Figure 5 As shown in the figure, the experiment counted the number of filters finally selected by ALF after the rate-distortion optimization process, and found that in more than 90% of the cases, the number of selected filters does not exceed 10. Therefore, this embodiment adopts the optimization merging process from 25 categories to 10 categories, and reduces invalid traversal through coarse screening. Figure 6 In another experiment in , the frequencies of all categories in the current slice were counted and sorted. The experiment showed that categories with lower frequencies were more likely to be merged. Therefore, in the coarse screening and merging stage of this embodiment, categories are merged in order of their frequencies of occurrence, reducing invalid selections during the merging process.

[0064] In addition, experiments also show that categories with the same directionality D or activity A as the current category are more likely to be merged, so each merge operation only searches among categories with the same D and A features, further narrowing the loop range and reducing the total number of loops from 4900 to a maximum of 248 times.

[0065] 6. Output Adaptive Parameter Set (APS) After all categories are merged and filter coefficients are updated, this embodiment packages the final merged results and filter coefficients into an adaptive parameter set (APS) and passes it to the decoding end through the APS. The APS contains the filter coefficients and category index information for each category, which can be accurately applied to the loop filtering operation during the decoding process. For different video clips, the APS can be selectively applied to different coding blocks to adapt to the differences in image areas and further optimize the coding effect.

[0066] Through the above implementation steps, this embodiment significantly improves the efficiency of adaptive loop filtering by simplifying the calculation process and optimizing the iteration method. Combined with staged merging, linearized cost estimation and dynamic update of filter coefficients, the present invention achieves effective control of computational complexity while maintaining image quality, and is suitable for video encoding scenarios with high requirements for real-time performance and compression efficiency.

[0067] The fast adaptive loop filtering device based on class merging described below and the fast adaptive loop filtering algorithm based on class merging described above can be referred to each other.

[0068] Please refer to the attached Figure 7 The present invention also provides a fast adaptive loop filtering device based on class merging, comprising: An initialization module 100, for initializing a plurality of filter categories and setting filter coefficients; A merging module 200, for performing coarse screening merging and fine merging of filter categories based on rate distortion optimization cost, wherein a simplified linear calculation model is used; An updating module 300 recalculates filter coefficients for the merged categories; The output module 400 is used to output the combined filter categories and corresponding filter coefficients.

[0069] The device of this embodiment can be used to execute the above method embodiment, and its principles and technical effects are similar, which will not be repeated here.

[0070] Please refer to the attached Figure 8 The present invention further provides a computer device 40, comprising: a processor 41 and a memory 42, wherein the memory 42 stores a computer program executable by the processor, and when the computer program is executed by the processor, the above method is executed.

[0071] The present invention further provides a storage medium 43 on which a computer program is stored. When the computer program is run by the processor 41, the above method is executed.

[0072] Among them, the storage medium 43 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable red-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, disk or optical disk.

[0073] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A fast adaptive loop filtering algorithm based on class merging, characterized in that: The following steps are involved: Initialize multiple filter categories and set initial filter coefficients for each category; Based on the rate-distortion optimization cost, the number of initial categories is reduced to the preset target number of categories, and then further merged until only one category remains, and the merging process is recorded; updating filter coefficients of the filtering category; After the merging is completed, the merging process is further traversed based on the rate-distortion optimization cost, and the filter set under the optimal merging condition is selected; Output the optimal merging situation and the corresponding filter coefficients selected after the merging is completed.

2. The fast adaptive loop filtering algorithm based on class merging according to claim 1, characterized in that: The step of initializing multiple filter categories and setting initial filter coefficients for each category comprises: Divide the video brightness component into multiple filter categories, each filter category corresponds to a predefined filter index; For each filtering category, determining filter coefficients, the filter coefficients being initially set based on local image characteristics of the luminance component, including gradient directionality and gradient activity; Calculate the gradient features of the luminance macroblock in each category, including the gradient components in the horizontal, vertical and diagonal directions, and accumulate these gradient components into the overall gradient value of the macroblock; quantizing the gradient features into a directionality level and an activity level according to a predetermined rule, and generating a corresponding category index; According to the category index, an initial filter coefficient set is allocated to each filtering category, and the filter coefficient set is used for adaptive adjustment and updating during the merging process.

3. The fast adaptive loop filtering algorithm based on class merging according to claim 1, characterized in that: The step of reducing the number of initial categories to the number of preset target categories comprises: Count the occurrence frequency of each initial category in the video slice, and sort all categories in ascending order according to the frequency of occurrence; Select categories with lower frequency of occurrence and merge them first to reduce the number of categories; The merging operation is repeated until the number of initial categories is reduced to the preset target number of categories.

4. The fast adaptive loop filtering algorithm based on class merging according to claim 3 is characterized in that: The step of reducing the number of initial categories to the number of preset target categories also includes: In each merging operation, a candidate set of categories to be merged is screened based on a preset similarity condition, wherein the similarity condition includes the same directional characteristics or activity characteristics; The category with the lowest frequency of occurrence is selected from the candidate set for merging to obtain the optimal initial category merging solution.

5. The fast adaptive loop filtering algorithm based on class merging according to claim 1, characterized in that: The step of further merging until only one filter remains comprises: After completing the preliminary category merging, a full traversal search is performed on the remaining categories to determine the merging cost of each pair of categories, where the merging cost is calculated based on the rate-distortion optimization cost; Compare the distortion costs of different category combinations, select the category combination with the lowest distortion cost for merging, and gradually reduce the number of categories to the optimal number of filters retained in the end.

6. The fast adaptive loop filtering algorithm based on class merging according to claim 5, characterized in that: The step of further merging until only one filter remains also includes: After each merging operation, the filter coefficients of the merged category are updated to ensure that the adaptability of the merged category reaches the optimal state; The final optimal number of filters and the corresponding category allocation scheme are determined to ensure that the filter coefficients of each retained category minimize the rate-distortion cost and meet the coding efficiency requirements.

7. The fast adaptive loop filtering algorithm based on class merging according to claim 5, characterized in that: The calculation of the distortion cost includes: Subtract the distortion cost of each individual class from the combined distortion cost to obtain the error value; The quality of the current category merging is judged based on the error value to determine the merging solution.

8. The fast adaptive loop filtering algorithm based on class merging according to claim 1, characterized in that: The updating of the filter coefficients includes: Recalculate the filter coefficients for the merged categories based on a simplified linear calculation model; By approximating the linear equation, the original matrix equation is transformed into a linear addition process.

9. A fast adaptive loop filtering device based on class merging, executing the method according to any one of claims 1 to 8, characterized in that: include: An initialization module, used to initialize multiple filter categories and set filter coefficients; A merging module, used for coarse screening merging and fine merging of filter categories based on rate-distortion optimization cost, wherein a simplified linear calculation model is used; An update module recalculates the filter coefficients for the merged categories; The output module is used to output the combined filter categories and corresponding filter coefficients.

10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.