Video coding method and device, electronic equipment and computer program product
By increasing the number of tap coefficients and optimizing the filter coefficient generation function, combined with motion vector and bilateral filtering processing, the accuracy problem of the motion compensated time domain filtering algorithm in high-frequency signal processing is solved, high-precision video encoding effect is achieved, and the computational complexity is controlled at the same time.
Patent Information
- Application Number
- CN202511149625.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2025-10-21
AI Technical Summary
Existing motion-compensated time-domain filtering algorithms have limited accuracy when processing high-frequency signals, resulting in motion blur or artifacts, and have high computational complexity, which limits their application in complex scenes.
By increasing the number of tap coefficients, combining the filter coefficient generation function with the motion vector to optimize the reference block pixel value calculation, using bilateral filtering to process the encoding results, using multi-reference frame information fusion to suppress the single-frame prediction residual, using cosine window function and Singer function, using the cosine window function and Singer function to generate filter coefficients, combining the motion vector to perform high-precision interpolation of the pixel position, and processing the encoding results through bilateral filtering.
It effectively improves the motion compensation prediction accuracy, reduces the motion discontinuity between consecutive frames, and improves video encoding performance while maintaining low computational complexity.
Smart Images

Figure CN120825577A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a video encoding method, a video encoding device, an electronic device, and a computer program product. Background Art
[0002] MCTF (Motion Compensated Temporal Filter) is a pre-processing technology for video coding. Its core idea is to use the temporal correlation of video sequences to perform temporal filtering on the current frame using multiple adjacent frames based on the reference situation of the current frame, so as to reduce the prediction residual and improve the compression efficiency.
[0003] During MCTF motion compensation, since object motion often involves sub-pixel-scale offsets, the currently commonly used 6-tap filtering algorithm, while computationally complex, has limited accuracy. This is particularly true when processing high-frequency signals, where it can easily introduce significant errors, leading to motion blur or artifacts. This limits its effectiveness in complex scenes.
[0004] In view of this, there is an urgent need in the art for a video encoding method that can effectively improve the motion compensation prediction accuracy while maintaining low computational complexity.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0006] The purpose of the present disclosure is to provide a video encoding method, a video encoding device, an electronic device and a computer program product, which can effectively improve the motion compensation prediction accuracy at least to a certain extent while maintaining low computational complexity.
[0007] According to a first aspect of the present disclosure, a video encoding method is provided, comprising:
[0008] Obtaining a group of pictures according to a plurality of video frames to be encoded, determining a current encoding frame in the group of pictures, and using other video frames in the group of pictures as reference frames for the current encoding frame;
[0009] Obtaining filter coefficients corresponding to respective pixel coordinate values according to a preset number of filter coefficients and a filter coefficient generation function, and determining motion vectors corresponding to respective reference frames;
[0010] For a current coding block in the current coding frame, determining, based on pixel coordinate values of each pixel position in a reference block corresponding to the current coding block in the reference frame, a filter coefficient corresponding to each pixel position in the reference block;
[0011] Obtaining a pixel value at each pixel position in the reference block according to the filter coefficient corresponding to each pixel position and the motion vector corresponding to the reference frame;
[0012] The current coding frame is filtered according to the pixel value of each pixel position in the reference block to obtain a coding result of the current coding frame.
[0013] In an exemplary embodiment of the present disclosure, obtaining the filter coefficients corresponding to the respective pixel coordinate values according to the preset number of filter coefficients and the filter coefficient generation function includes:
[0014] determining a scaling factor in the filter coefficient generation function according to the pixel precision of the pixel coordinate value, wherein the filter coefficient generation function includes a cosine window function and a sinc function, and the cosine window function includes the scaling factor;
[0015] A plurality of groups of filter coefficients are obtained according to the scaling coefficient, the number of filter coefficients and the filter coefficient generation function, and each group of filter coefficients corresponds to a pixel coordinate value.
[0016] In an exemplary embodiment of the present disclosure, the pixel position includes a sub-pixel position, and obtaining a pixel value of each pixel position in the reference block according to a filter coefficient corresponding to each pixel position and a motion vector corresponding to the reference frame includes:
[0017] Determining a target sub-pixel position in the reference block according to a target pixel position in the current coding block and a motion vector corresponding to the reference frame;
[0018] Determining, according to the number of filter coefficients, a plurality of horizontal reference pixel positions of the target sub-pixel position in the horizontal direction and a plurality of vertical reference pixel positions of the target sub-pixel position in the vertical direction;
[0019] Determining a horizontal filter coefficient from the multiple sets of filter coefficients according to the pixel coordinate value of the target sub-pixel position in the horizontal direction, and determining a vertical filter coefficient from the multiple sets of filter coefficients according to the pixel coordinate value of the target sub-pixel position in the vertical direction;
[0020] Obtaining a first pixel value at the target sub-pixel position according to a weighted sum of the horizontal filter coefficient and the pixel value corresponding to the horizontal reference pixel position;
[0021] A second pixel value at the target sub-pixel position is obtained according to a weighted sum of the vertical filtering coefficient and the first pixel value corresponding to the vertical reference pixel position.
[0022] In an exemplary embodiment of the present disclosure, determining the motion vector corresponding to each reference frame includes:
[0023] Motion estimation is performed on each of the reference frames to obtain a motion vector corresponding to each of the reference frames.
[0024] In an exemplary embodiment of the present disclosure, filtering the current coding frame according to the pixel values of each pixel position in the reference block to obtain the coding result of the current coding frame includes:
[0025] Obtaining a weight coefficient for each of the reference blocks according to a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block;
[0026] Perform bilateral filtering on the current coding frame according to the weight coefficients of the reference blocks to obtain a coding result of the current coding frame.
[0027] In an exemplary embodiment of the present disclosure, obtaining the weight coefficient of each reference block according to the pixel value of each pixel position in the reference block and the pixel value of each pixel position in the current coding block includes:
[0028] Obtaining a similarity coefficient between the reference block and the current coding block according to a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block;
[0029] The weight coefficient of each reference block is determined according to the similarity coefficient between the reference block and the current coding block.
[0030] In an exemplary embodiment of the present disclosure, the method further includes:
[0031] The encoding process of each of the currently encoded frames in the image group is implemented through a preset single instruction multiple data instruction set.
[0032] According to a second aspect of the present disclosure, a video encoding apparatus is provided, including:
[0033] a coding frame determination module configured to obtain a picture group according to a plurality of video frames to be coded, determine a current coding frame in the picture group, and use other video frames in the picture group as reference frames for the current coding frame;
[0034] a filter coefficient generation module configured to execute a filter coefficient generation function according to a preset number of filter coefficients and a filter coefficient generation function to obtain filter coefficients corresponding to respective pixel coordinate values, and determine motion vectors corresponding to respective reference frames;
[0035] a filter coefficient determination module configured to determine, for a current coding block in the current coding frame, a filter coefficient corresponding to each pixel position in a reference block corresponding to the current coding block in the reference frame according to pixel coordinate values of each pixel position in the reference block;
[0036] a pixel value determination module configured to obtain a pixel value of each pixel position in the reference block based on a filter coefficient corresponding to each pixel position and a motion vector corresponding to the reference frame;
[0037] The encoding result determination module is configured to perform filtering on the current encoding frame according to the pixel value of each pixel position in the reference block to obtain the encoding result of the current encoding frame.
[0038] In an exemplary embodiment of the present disclosure, the filter coefficient generation module includes:
[0039] a scaling coefficient determining unit configured to determine a scaling coefficient in the filter coefficient generating function according to the pixel precision of the pixel coordinate value, wherein the filter coefficient generating function includes a cosine window function and a sinc function, and the cosine window function includes the scaling coefficient;
[0040] The multiple coefficient generation units are configured to obtain multiple groups of filter coefficients according to the scaling coefficient, the number of filter coefficients and the filter coefficient generation function, wherein each group of filter coefficients corresponds to a pixel coordinate value.
[0041] In an exemplary embodiment of the present disclosure, the pixel value determination module includes:
[0042] a target sub-pixel determination unit, configured to determine a target sub-pixel position in the reference block according to the target pixel position in the current coding block and a motion vector corresponding to the reference frame;
[0043] a reference pixel position determining unit, configured to determine, according to the number of filter coefficients, a plurality of horizontal reference pixel positions of the target sub-pixel position in the horizontal direction and a plurality of vertical reference pixel positions of the target sub-pixel position in the vertical direction;
[0044] a filter coefficient selection unit configured to determine a horizontal filter coefficient from the plurality of filter coefficients according to a pixel coordinate value of the target sub-pixel position in the horizontal direction, and to determine a vertical filter coefficient from the plurality of filter coefficients according to a pixel coordinate value of the target sub-pixel position in the vertical direction;
[0045] a first pixel value determining unit configured to perform a weighted sum of the horizontal filter coefficient and the pixel values corresponding to the horizontal reference pixel position to obtain a first pixel value at the target sub-pixel position;
[0046] The second pixel value determining unit is configured to perform a weighted sum of the vertical filtering coefficient and the first pixel value corresponding to the vertical reference pixel position to obtain a second pixel value at the target sub-pixel position.
[0047] In an exemplary embodiment of the present disclosure, the filter coefficient generation module further includes:
[0048] The motion vector determining unit is configured to perform motion estimation on each of the reference frames to obtain a motion vector corresponding to each of the reference frames.
[0049] In an exemplary embodiment of the present disclosure, the encoding result determination module includes:
[0050] a weight coefficient determining unit configured to obtain a weight coefficient for each of the reference blocks based on a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block;
[0051] The encoding result determining unit is configured to perform bilateral filtering on the current encoding frame according to the weight coefficients of the reference blocks to obtain an encoding result of the current encoding frame.
[0052] In an exemplary embodiment of the present disclosure, the weight coefficient determining unit includes:
[0053] a similarity coefficient determining unit, configured to obtain a similarity coefficient between the reference block and the current coding block based on a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block;
[0054] The weight coefficient calculation unit is configured to determine the weight coefficient of each reference block according to the similarity coefficient between the reference block and the current coding block.
[0055] In an exemplary embodiment of the present disclosure, the video encoding apparatus further includes:
[0056] The encoding process implementation module is configured to execute the encoding process of each of the current encoding frames in the image group through a preset single instruction multiple data instruction set.
[0057] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement any one of the above-mentioned video encoding methods.
[0058] According to a fourth aspect of the present disclosure, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any one of the above-mentioned video encoding methods.
[0059] The exemplary embodiments of the present disclosure may have the following beneficial effects:
[0060] In the video encoding method of the example implementation mode of the present disclosure, on the one hand, by increasing the number of tap coefficients, it is possible to effectively reduce the motion discontinuity between consecutive frames, more accurately fit the signal characteristics, thereby improving the video encoding performance and solving the problem of large errors when processing high-frequency signals, resulting in motion blur or artifacts; on the other hand, by combining the filter coefficient generation function with the motion vector to optimize the reference block pixel value calculation, using multi-reference frame information fusion to suppress the single-frame prediction residual, and using bilateral filtering to process the encoding results, the motion compensation prediction accuracy is effectively improved, which has the advantages of effectively improving the motion compensation prediction accuracy while maintaining low computational complexity.
[0061] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort.
[0063] Figure 1 A schematic diagram showing a flow chart of a video encoding method according to an exemplary embodiment of the present disclosure;
[0064] Figure 2 A schematic diagram showing a process of generating multiple sets of filter coefficients according to an exemplary embodiment of the present disclosure is shown;
[0065] Figure 3 A schematic diagram illustrating a process of determining pixel values of respective pixel positions in a reference block according to an exemplary embodiment of the present disclosure is shown;
[0066] Figure 4 A schematic diagram showing a process of obtaining an encoding result of a current encoding frame according to an exemplary embodiment of the present disclosure is shown;
[0067] Figure 5 A block diagram showing a video encoding apparatus according to an exemplary embodiment of the present disclosure is provided;
[0068] Figure 6 A schematic structural diagram of a computer system suitable for implementing the electronic device according to the embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0069] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0070] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, such that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0071] The following example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; rather, these embodiments are provided so that the present disclosure will be more comprehensive and complete and will fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or that other methods, components, devices, steps, etc. may be employed. In other cases, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0072] In addition, the accompanying drawings are merely schematic illustrations of the present disclosure and are not necessarily drawn to scale. Identical reference numerals in the figures denote identical or similar parts, and thus repetitive descriptions thereof will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0073] This exemplary embodiment first provides a video encoding method. Figure 1 As shown, the above video encoding method may include the following steps:
[0074] Step S110 : Obtain a picture group according to a plurality of video frames to be encoded, determine a current encoding frame in the picture group, and use other video frames in the picture group as reference frames for the current encoding frame.
[0075] Step S120: According to the preset number of filter coefficients and the filter coefficient generation function, the filter coefficients corresponding to the respective pixel coordinate values are obtained, and the motion vectors corresponding to the respective reference frames are determined.
[0076] Step S130. For the current coding block in the current coding frame, determine the filter coefficient corresponding to each pixel position in the reference block according to the pixel coordinate values of each pixel position in the reference block corresponding to the current coding block in the reference frame.
[0077] Step S140: Obtain the pixel value of each pixel position in the reference block according to the filter coefficient corresponding to each pixel position and the motion vector corresponding to the reference frame.
[0078] Step S150: Filter the current coding frame according to the pixel value of each pixel position in the reference block to obtain the coding result of the current coding frame.
[0079] In the video encoding method of the example embodiment of the present disclosure, on the one hand, by increasing the number of tap coefficients, it is possible to effectively reduce the motion discontinuity between consecutive frames, more accurately fit the signal characteristics, thereby improving the video encoding performance and solving the problem of large errors when processing high-frequency signals, resulting in motion blur or artifacts; on the other hand, by combining the filter coefficient generation function with the motion vector to optimize the reference block pixel value calculation, and using bilateral filtering to process the encoding results, the motion compensation prediction accuracy is effectively improved, which has the advantages of effectively improving the motion compensation prediction accuracy while maintaining low computational complexity.
[0080] Next, combine Figures 2 to 4 The above steps of this exemplary embodiment are described in more detail.
[0081] In step S110 , a picture group is obtained according to a plurality of video frames to be encoded, a current encoding frame in the picture group is determined, and other video frames in the picture group are used as reference frames for the current encoding frame.
[0082] In this example implementation, several consecutive video frames to be encoded may first be grouped into a group of pictures (GOP), a current encoding frame may be determined from the GOP, and other video frames in the GOP may be used as reference frames for the current encoding frame.
[0083] In step S120 , the filter coefficients corresponding to the respective pixel coordinate values are obtained according to the preset number of filter coefficients and the filter coefficient generation function, and the motion vectors corresponding to the respective reference frames are determined.
[0084] In this example implementation, the filter coefficient generation function refers to an algorithm that generates filter parameters based on a combination of mathematical functions. The function parameters can be adjusted to accommodate interpolation requirements at different pixel locations. The filter coefficients corresponding to pixel coordinate values are weight parameters dynamically generated based on the sub-pixel position coordinates. This is achieved through coordinate mapping and function calculation to ensure that the optimal interpolation coefficient is obtained for each sub-pixel position.
[0085] In this example implementation, Figure 2 As shown, according to the preset number of filter coefficients and the filter coefficient generation function, the filter coefficients corresponding to the respective pixel coordinate values are obtained, which may specifically include the following steps:
[0086] Step S210: Determine a scaling coefficient in a filter coefficient generation function according to the pixel precision of the pixel coordinate value, wherein the filter coefficient generation function includes a cosine window function and a sinc function, and the cosine window function includes a scaling coefficient.
[0087] In this example implementation, pixel precision refers to the spatial resolution level of pixel coordinate values, which can be specifically implemented using whole pixel, half pixel, or quarter pixel precision levels. This parameter directly affects the accuracy of generating filter coefficients during the interpolation process.
[0088] In this example implementation, a cosine window function plus a sinc function may be used. The calculation formula may be, for example:
[0089] f(x)=Cos(Ax)sinc(x)
[0090] Where x represents the coordinate position to be interpolated, F(x) represents the specific interpolation result at the coordinate, and A∈(0,1) is a scaling factor used to generate the required number of tap coefficients.
[0091]
[0092] During motion compensation prediction, a motion vector with 1 / 16 pixel accuracy can be used.
[0093] Specifically, during the motion compensation prediction process, the corresponding scaling coefficient is first automatically matched based on the coordinate precision category of the currently processed pixel. The scaling coefficient is then substituted into a composite function containing the product term of the Singer function. By setting the number of filter coefficients to a fixed value, such as 12 taps, the composite function is discretized and sampled, forming multiple sets of coefficients that correspond one-to-one to the pixel coordinates. This dynamic parameter adjustment mechanism enables the filter function to adapt to spatial positional characteristics of varying interpolation precision while maintaining the frequency domain stopband attenuation characteristics.
[0094] Step S220: Obtain multiple groups of filter coefficients according to the scaling coefficient, the number of filter coefficients, and the filter coefficient generation function, where each group of filter coefficients corresponds to a pixel coordinate value.
[0095] A preset 12-tap filter coefficient generation function is used to generate exclusive filter coefficients for each sub-pixel position. For each sub-pixel position, a set of corresponding interpolation coefficients is generated, corresponding to the cases [0 / 16, 1 / 16, 2 / 16, ..., 15 / 16]. Taking the case of 1 / 16 as an example:
[0096] coeff(i)=Cos(A(i-5-1 / 16))sinc(i-5-1 / 16),i∈[0,11]
[0097] The final 16 sets of filter coefficients generated are filter_12=
[0098] {0,0,0,0,0,256,0,0,0,0,0,0},
[0099] {-1,2,-3,6,-14,254,16,-7,4,-2,1,0},
[0100] {-1,3,-7,12,-26,249,35,-15,8,-4,2,0},
[0101] {-2,5,-9,17,-36,241,54,-22,12,-6,3,-1},
[0102] {-2,5,-11,21,-43,230,75,-29,15,-8,4,-1},
[0103] {-2,6,-13,24,-48,216,97,-36,19,-10,4,-1},
[0104] {-2,7,-14,25,-51,200,119,-42,22,-12,5,-1},
[0105] {-2,7,-14,26,-51,181,140,-46,24,-13,6,-2},
[0106] {-2,6,-13,25,-50,162,162,-50,25,-13,6,-2},
[0107] {-2,6,-13,24,-46,140,181,-51,26,-14,7,-2},
[0108] {-1,5,-12,22,-42,119,200,-51,25,-14,7,-2},
[0109] {-1,4,-10,19,-36,97,216,-48,24,-13,6,-2},
[0110] {-1,4,-8,15,-29,75,230,-43,21,-11,5,-2},
[0111] {-1,3,-6,12,-22,54,241,-36,17,-9,5,-2},
[0112] {0,2,-4,8,-15,35,249,-26,12,-7,3,-1},
[0113] {0,1,-2,4,-7,16,254,-14,6,-3,2,-1}.
[0114] In addition, the coefficient generation function can be modified to generate sharper coefficients. For example, it can be modified to: Where a and b can be parameters less than 1.
[0115] This example implementation significantly improves the accuracy of per-pixel motion compensation prediction by constructing a composite filter function that adapts to pixel precision. This approach achieves more precise reconstruction of high-frequency signal components while maintaining reasonable computational complexity, resulting in clearer predicted images in complex motion scenes.
[0116] In this example implementation, motion estimation may be performed on each reference frame to obtain a motion vector corresponding to each reference frame.
[0117] Motion estimation involves calculating the spatial displacement between a reference frame and the current coding block using a block matching algorithm. This can be achieved using a three-step search or a full search method, minimizing the residual energy to determine the position of the best matching block. A motion vector, the displacement between the reference frame and the current frame, is calculated using a block matching algorithm and used to determine the position of the reference block within the reference frame.
[0118] In step S130 , for a current coding block in a current coding frame, filter coefficients corresponding to respective pixel positions in a reference block corresponding to the current coding block in a reference frame are determined according to pixel coordinate values of respective pixel positions in the reference block.
[0119] In this example embodiment, pixel positions include sub-pixel positions. Sub-pixel positions refer to sub-pixel precision positions between integer pixel coordinates. Specifically, they can be located using sub-pixel precision parameters of motion vectors. By processing sub-pixel positions, the actual trajectory of an object's motion can be more accurately simulated. Based on the pixel coordinate values of the sub-pixel positions, the filter coefficient corresponding to the coordinate value can be determined from the multiple sets of generated filter coefficients.
[0120] In step S140 , the pixel value of each pixel position in the reference block is obtained according to the filter coefficient corresponding to each pixel position and the motion vector corresponding to the reference frame.
[0121] The pixel value in the reference block refers to the predicted value after motion compensation and filtering, which can be obtained by weighted calculation of the filter coefficients and adjacent pixels to achieve high-precision interpolation. When performing motion compensation prediction at the sub-pixel position, the reference pixel range in the horizontal and vertical directions of the target sub-pixel position can be determined according to the number of filter coefficients, and the final pixel value can be obtained by two weighted calculations. For example, based on the generated 12tap filter coefficients and the searched motion vector, motion compensation can be performed to obtain each reference block, and the adjacent left and right and upper and lower reference pixels can be used to perform horizontal and vertical filtering respectively to improve video coding efficiency.
[0122] In this example implementation, Figure 3 As shown, according to the filter coefficient corresponding to each pixel position and the motion vector corresponding to the reference frame, the pixel value of each pixel position in the reference block is obtained, which may specifically include the following steps:
[0123] Step S310: Determine the target sub-pixel position in the reference block according to the target pixel position in the current coding block and the motion vector corresponding to the reference frame.
[0124] In MCTF motion compensation, motion vectors often point to non-integer pixel locations, which means the target pixel location may be a fractional value. For example, a motion vector may point to position x f ,y f , where x f and y f Is a non-integer value. Assume that the motion vector points to x f =1.5,y f = 2.25. This indicates that the target pixel position is 1.5 pixel units away from the nearest integer pixel position in the horizontal direction and 2.25 pixel units away from the nearest integer pixel position in the vertical direction.
[0125] Step S320 : Determine multiple horizontal reference pixel positions in the horizontal direction of the target sub-pixel position and multiple vertical reference pixel positions in the vertical direction of the target sub-pixel position according to the number of filter coefficients.
[0126] The horizontal reference pixel position refers to a set of reference points distributed along the horizontal axis of the image. Specifically, six integer pixel positions can be selected to the left and right of the target sub-pixel position. By expanding the horizontal sampling range, higher-frequency texture changes can be captured. The vertical reference pixel position refers to a set of reference points distributed along the vertical axis of the image. Specifically, six integer pixel positions can be selected above and below the target sub-pixel position. By increasing the vertical sampling density, aliasing effects in the direction of motion can be effectively suppressed.
[0127] For the horizontal direction, you can choose x f The pixel values of the 6 integer pixel positions on the left and right are used as references. Specifically, the position of the reference pixel can be expressed as (x f -6,x f -5,…,x f +5). For vertical interpolation, you can select y f The pixel values of the 6 integer pixel positions above and below are used as references. Specifically, the position of the reference pixel can be expressed as (y f -6,y f -5,…,y f +5).
[0128] Step S330: Determine a horizontal filter coefficient from multiple sets of filter coefficients based on the pixel coordinate value of the target sub-pixel position in the horizontal direction, and determine a vertical filter coefficient from multiple sets of filter coefficients based on the pixel coordinate value of the target sub-pixel position in the vertical direction.
[0129] The horizontal filter coefficients refer to the weight parameters corresponding to the horizontal coordinate offset, and the vertical filter coefficients refer to the weight parameters corresponding to the vertical coordinate offset. For different sub-pixel positions, the corresponding filter coefficient group can be selected from the generated filter coefficients filter_12 by looking up the table.
[0130] Step S340: Obtain a first pixel value at the target sub-pixel position according to a weighted sum of the horizontal filter coefficient and the pixel values corresponding to the horizontal reference pixel position.
[0131] Then, a weighted sum calculation is performed in the horizontal direction. Assume that the reference pixel value is (p0, p1, ..., p 11 ), then the pixel value p at the pixel position f It can be calculated by the following formula: where h i is the weight, that is, the pixel value at the target pixel position is the weighted sum of the reference pixel values, and the weight is determined by the filter coefficient.
[0132] Step S350: Obtain a second pixel value at the target sub-pixel position according to a weighted sum of the vertical filter coefficient and the first pixel value corresponding to the vertical reference pixel position.
[0133] After performing weighted sum calculation on the pixel values in the horizontal direction for all pixel positions, weighted sum calculation is performed in the vertical direction to obtain the final pixel value.
[0134] Specifically, when a motion vector points to a sub-pixel position, the sub-pixel coordinates that need to be interpolated in the reference block are first determined based on the motion vector offset. Twelve adjacent integer pixels are selected horizontally and weighted summed using the horizontal filter coefficients to obtain the intermediate pixel value. Twelve integer pixels are also selected vertically, and the intermediate pixel value is used as input for another vertical weighted calculation. This two-stage filtering structure processes high-frequency components in the horizontal and vertical directions separately. Through two independent but continuous filtering operations, unidirectional interpolation errors are eliminated, allowing the final predicted pixel value to more accurately restore object edge details.
[0135] In step S150 , the current coding frame is filtered according to the pixel value of each pixel position in the reference block to obtain a coding result of the current coding frame.
[0136] The pixel value at each pixel position in the reference block refers to the brightness or color information of all pixels in the reference block generated by motion compensation prediction. Specifically, this can be achieved by extracting the pixel values at the corresponding positions after mapping the motion vector to the reference frame, and used for comparison and analysis with the pixel values of the current coding block. The pixel value at each pixel position in the current coding block refers to the brightness or color information of all pixels in the currently processed block in the frame to be coded. Specifically, it can be obtained through intra-frame prediction or original pixel data, and is used to calculate similarity with the pixel values of the reference block.
[0137] In this example implementation, Figure 4 As shown, filtering the current coding frame according to the pixel values of each pixel position in the reference block to obtain the coding result of the current coding frame may include the following steps:
[0138] Step S410: Obtain weight coefficients for each reference block according to the pixel values at each pixel position in the reference block and the pixel values at each pixel position in the current coding block.
[0139] In this example implementation, the similarity coefficient between the reference block and the current coding block can be obtained based on the pixel values of each pixel position in the reference block and the pixel values of each pixel position in the current coding block, and then the weight coefficient of each reference block can be determined based on the similarity coefficient between the reference block and the current coding block.
[0140] The weight coefficient is a quantitative parameter that reflects the contribution of a reference block to the current coding block. The weight of each reference block can be calculated based on the similarity between the reference block and the current coding block. The similarity coefficient is a quantitative indicator that reflects the overall match between the reference block and the current coding block. This is achieved by calculating the sum of squared differences between corresponding pixel positions.
[0141] Step S420: Perform bilateral filtering on the current coding frame according to the weight coefficients of each reference block to obtain a coding result of the current coding frame.
[0142] Bilateral filtering refers to a filtering algorithm that considers both spatial distance and pixel value similarity. Specifically, it can be achieved by using a Gaussian kernel function to perform a joint weighted average of the spatial domain and the pixel value domain, thereby suppressing noise while retaining edge details.
[0143] Specifically, the similarity coefficient between the reference block and the current coding block is first calculated by comparing the pixel values of the reference block and the current coding block pixel by pixel. For example, for each pixel position, the square of the difference between the pixel value of the reference block and the pixel value of the corresponding position in the current coding block is summed, and then mapped to a similarity coefficient through an exponential function. The larger the similarity coefficient, the higher the match between the reference block and the current coding block, and the higher the weight is given in the filtering process. Subsequently, the weight coefficient is input into the bilateral filter, which performs Gaussian weighting on adjacent pixels in the spatial domain and adjusts the filtering strength according to the weight coefficient in the pixel value domain. Through the dual constraint mechanism, it can not only effectively fuse the prediction information of multiple reference blocks, but also suppress the interference of abnormal pixel values caused by motion estimation errors.
[0144] In this example implementation, the similarity coefficient generated through global pixel comparison accurately captures the spatial correlation differences between the reference block and the current coding block, giving highly similar reference blocks a higher decision weight during the filtering process. This mechanism significantly reduces the impact of low-quality prediction data on the coding results, suppressing motion blur and blocking artifacts, thereby improving edge clarity and texture fidelity in the reconstructed image.
[0145] In this example implementation, the encoding process of each current encoding frame in the image group may also be implemented using a preset single instruction multiple data instruction set.
[0146] Taking into account the large number of loops in the interpolation process and the high computational complexity, the encoding speed may be affected. Therefore, assembly language can be used for acceleration. The Single Instruction Multiple Data instruction set refers to a parallel computing architecture that supports a single instruction to operate multiple data streams simultaneously. It can be implemented using the processor's built-in SIMD (Single Instruction Multiple Data) extended instruction set. The Single Instruction Multiple Data instruction set combines the same operation steps of multiple encoding frames into a single instruction, using hardware parallelism to improve data processing throughput, thereby significantly improving computing efficiency and speeding up encoding.
[0147] The encoding process for each currently coded frame in a GIP refers to the complete flow of motion estimation, motion compensation, and filtering for multiple frames within the same GIP in a video sequence. This feature batches the encoding tasks for multiple frames, enabling SIMD instructions to handle the same type of computation across multiple frames simultaneously, such as performing multiple pixel-wise interpolations or weight coefficient calculations.
[0148] During the specific implementation process, under the self-developed codec standard KVC (Key-Value Coding) software and Random Access configuration, when the CRF (Conditional Random Field) was 2 to 40, 50 sequences in the MSU (Moscow State University) sequence set were tested. The objective benefits were: BD-Rate (bitrate) SSIM (Structural Similarity Index) 611: -0.12%, BD-Rate PSNR (Peak Signal-to-Noise Ratio) 611: -0.21%, BD-Rate VMAF 611: -0.2%, and encoding time increased by 0.5%.
[0149] It should be noted that although the steps of the method of the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all steps must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0150] Furthermore, the present disclosure also provides a video encoding device. Figure 5As shown, the video encoding apparatus may include an encoding frame determination module 510, a filter coefficient generation module 520, a filter coefficient determination module 530, a pixel value determination module 540, and an encoding result determination module 550. Among them:
[0151] The coding frame determination module 510 is configured to obtain a picture group based on multiple video frames to be encoded, determine a current coding frame in the picture group, and use other video frames in the picture group as reference frames for the current coding frame;
[0152] The filter coefficient generation module 520 is configured to execute a filter coefficient generation function based on a preset number of filter coefficients and a filter coefficient generation function to obtain filter coefficients corresponding to respective pixel coordinate values and determine motion vectors corresponding to respective reference frames;
[0153] The filter coefficient determination module 530 is configured to determine, for a current coding block in a current coding frame, a filter coefficient corresponding to each pixel position in a reference block corresponding to the current coding block in a reference frame according to pixel coordinate values of each pixel position in the reference block;
[0154] The pixel value determination module 540 is configured to obtain a pixel value of each pixel position in the reference block according to the filter coefficient corresponding to each pixel position and the motion vector corresponding to the reference frame;
[0155] The encoding result determination module 550 is configured to perform filtering on the current encoding frame according to the pixel value of each pixel position in the reference block to obtain the encoding result of the current encoding frame.
[0156] In some exemplary embodiments of the present disclosure, the filter coefficient generation module 520 may include a scaling coefficient determination unit and a plurality of coefficient generation units.
[0157] a scaling coefficient determining unit configured to determine a scaling coefficient in a filter coefficient generating function according to pixel accuracy of pixel coordinate values, wherein the filter coefficient generating function includes a cosine window function and a sinc function, and the cosine window function includes the scaling coefficient;
[0158] The multiple coefficient generation units are configured to obtain multiple groups of filter coefficients according to the scaling coefficient, the number of filter coefficients and the filter coefficient generation function, where each group of filter coefficients corresponds to a pixel coordinate value.
[0159] In some exemplary embodiments of the present disclosure, the pixel value determination module 540 may include a target sub-pixel determination unit, a reference pixel position determination unit, a filter coefficient selection unit, a first pixel value determination unit, and a second pixel value determination unit.
[0160] a target sub-pixel determination unit configured to determine a target sub-pixel position in a reference block based on a target pixel position in a current coding block and a motion vector corresponding to a reference frame;
[0161] a reference pixel position determining unit configured to determine a plurality of horizontal reference pixel positions of the target sub-pixel position in the horizontal direction and a plurality of vertical reference pixel positions of the target sub-pixel position in the vertical direction according to the number of filter coefficients;
[0162] a filter coefficient selection unit configured to determine a horizontal filter coefficient from the plurality of filter coefficients according to a pixel coordinate value of the target sub-pixel position in the horizontal direction, and to determine a vertical filter coefficient from the plurality of filter coefficients according to a pixel coordinate value of the target sub-pixel position in the vertical direction;
[0163] A first pixel value determining unit is configured to perform a weighted sum of the horizontal filter coefficient and the pixel values corresponding to the horizontal reference pixel position to obtain a first pixel value at the target sub-pixel position;
[0164] The second pixel value determining unit is configured to perform a weighted sum of the vertical filtering coefficient and the first pixel value corresponding to the vertical reference pixel position to obtain a second pixel value at the target sub-pixel position.
[0165] In some exemplary embodiments of the present disclosure, the filter coefficient generation module 520 may further include a motion vector determination unit configured to perform motion estimation on each reference frame to obtain a motion vector corresponding to each reference frame.
[0166] In some exemplary embodiments of the present disclosure, the encoding result determination module 550 may include a weight coefficient determination unit and an encoding result determination unit.
[0167] A weight coefficient determination unit is configured to obtain a weight coefficient for each reference block based on a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block;
[0168] The encoding result determining unit is configured to perform bilateral filtering on the current encoding frame according to the weight coefficients of each reference block to obtain an encoding result of the current encoding frame.
[0169] In some exemplary embodiments of the present disclosure, the weight coefficient determination unit may include a similarity coefficient determination unit and a weight coefficient calculation unit.
[0170] a similarity coefficient determining unit configured to obtain a similarity coefficient between the reference block and the current coding block based on a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block;
[0171] The weight coefficient calculation unit is configured to determine the weight coefficient of each reference block according to the similarity coefficient between the reference block and the current coding block.
[0172] In some exemplary embodiments of the present disclosure, a video encoding device provided by the present disclosure may further include an encoding process implementation module configured to execute the encoding process of each current encoding frame in the image group through a preset single instruction multiple data instruction set.
[0173] The specific details of each module / unit in the above video encoding device have been described in detail in the corresponding method embodiment part and will not be repeated here.
[0174] Figure 6 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present disclosure is shown.
[0175] It should be noted that Figure 6 The computer system 600 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0176] like Figure 6 As shown, computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage unit 608 into a random access memory (RAM) 603. Various programs and data required for system operation are also stored in RAM 603. CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to bus 604.
[0177] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, and the like; an output section 607 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 608 including a hard disk; and a communication section 609 including a network interface card such as a LAN card or a modem. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 610 as needed, so that computer programs read therefrom can be installed into the storage section 608 as needed.
[0178] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from a removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, various functions defined in the system of the present disclosure are executed.
[0179] The exemplary embodiments of the present disclosure further provide a computer program product, which includes a computer program, and when the computer program is executed by a processor, implements the above-mentioned video encoding method.
[0180] In one embodiment, a computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing the computer program. The computer-readable storage medium may be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, including but not limited to random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk drive (HDD), solid-state drive (SSD), and the like. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing the computer program, such as a read-only memory, NAND flash memory, and the like.
[0181] In one embodiment, the computer program product may be an intangible product containing a computer program. For example, the computer program product may be implemented as a virtual digital product, such as a digital file such as an executable file or installation package storing the computer program.
[0182] The code of the computer program can be written in one or more programming languages. Programming languages include C, Java, C++, etc. The program code can be executed entirely on the user computing device, partially on the user computing device, or as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device via any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (e.g., via an Internet connection provided by a carrier).
[0183] Computer programs can be carried or transmitted via electrical, magnetic, optical, electromagnetic, infrared, or other signals. Electronic devices can convert signals carrying computer programs into digital signals to run the computer programs. When the computer program is run on an electronic device, its code is used to cause the electronic device to execute (more specifically, to cause the processor of the electronic device to execute) the method steps of various exemplary embodiments of the present disclosure, such as the video encoding method described above.
[0184] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0185] It should be noted that although several modules of the device for action execution are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules described above can be embodied in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be embodied.
[0186] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein.
[0187] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A video encoding method, characterized in that: include: Obtaining a group of pictures according to a plurality of video frames to be encoded, determining a current encoding frame in the group of pictures, and using other video frames in the group of pictures as reference frames for the current encoding frame; Obtaining filter coefficients corresponding to respective pixel coordinate values according to a preset number of filter coefficients and a filter coefficient generation function, and determining motion vectors corresponding to respective reference frames; For a current coding block in the current coding frame, determining, based on pixel coordinate values of each pixel position in a reference block corresponding to the current coding block in the reference frame, a filter coefficient corresponding to each pixel position in the reference block; Obtaining a pixel value at each pixel position in the reference block according to the filter coefficient corresponding to each pixel position and the motion vector corresponding to the reference frame; The current coding frame is filtered according to the pixel value of each pixel position in the reference block to obtain a coding result of the current coding frame.
2. The video encoding method according to claim 1, wherein: The method of obtaining the filter coefficients corresponding to the respective pixel coordinate values according to the preset number of filter coefficients and the filter coefficient generation function includes: determining a scaling factor in the filter coefficient generation function according to the pixel precision of the pixel coordinate value, wherein the filter coefficient generation function includes a cosine window function and a sinc function, and the cosine window function includes the scaling factor; A plurality of groups of filter coefficients are obtained according to the scaling coefficient, the number of filter coefficients and the filter coefficient generation function, and each group of filter coefficients corresponds to a pixel coordinate value.
3. The video encoding method according to claim 2, wherein: The pixel position includes a sub-pixel position, and obtaining a pixel value of each pixel position in the reference block according to a filter coefficient corresponding to each pixel position and a motion vector corresponding to the reference frame includes: Determining a target sub-pixel position in the reference block according to a target pixel position in the current coding block and a motion vector corresponding to the reference frame; Determining, according to the number of filter coefficients, a plurality of horizontal reference pixel positions of the target sub-pixel position in the horizontal direction and a plurality of vertical reference pixel positions of the target sub-pixel position in the vertical direction; Determining a horizontal filter coefficient from the multiple sets of filter coefficients according to the pixel coordinate value of the target sub-pixel position in the horizontal direction, and determining a vertical filter coefficient from the multiple sets of filter coefficients according to the pixel coordinate value of the target sub-pixel position in the vertical direction; Obtaining a first pixel value at the target sub-pixel position according to a weighted sum of the horizontal filter coefficient and the pixel value corresponding to the horizontal reference pixel position; A second pixel value at the target sub-pixel position is obtained according to a weighted sum of the vertical filtering coefficient and the first pixel value corresponding to the vertical reference pixel position.
4. The video encoding method according to claim 1, wherein: The determining of the motion vector corresponding to each of the reference frames includes: Motion estimation is performed on each of the reference frames to obtain a motion vector corresponding to each of the reference frames.
5. The video encoding method according to claim 1, wherein: The filtering the current coding frame according to the pixel values of each pixel position in the reference block to obtain the coding result of the current coding frame includes: Obtaining a weight coefficient for each of the reference blocks according to a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block; Perform bilateral filtering on the current coding frame according to the weight coefficients of the reference blocks to obtain a coding result of the current coding frame.
6. The video encoding method according to claim 5, wherein: Obtaining weight coefficients for the reference blocks according to pixel values at respective pixel positions in the reference blocks and pixel values at respective pixel positions in the current coding block includes: Obtaining a similarity coefficient between the reference block and the current coding block according to a pixel value at each pixel position in the reference block and a pixel value at each pixel position in the current coding block; The weight coefficient of each reference block is determined according to the similarity coefficient between the reference block and the current coding block.
7. The video encoding method according to claim 1, wherein: The method further comprises: The encoding process of each of the currently encoded frames in the image group is implemented through a preset single instruction multiple data instruction set.
8. A video encoding device, characterized in that: include: a coding frame determination module configured to obtain a picture group according to a plurality of video frames to be coded, determine a current coding frame in the picture group, and use other video frames in the picture group as reference frames for the current coding frame; a filter coefficient generation module configured to execute a filter coefficient generation function according to a preset number of filter coefficients and a filter coefficient generation function to obtain filter coefficients corresponding to respective pixel coordinate values, and determine motion vectors corresponding to respective reference frames; a filter coefficient determination module configured to determine, for a current coding block in the current coding frame, a filter coefficient corresponding to each pixel position in a reference block corresponding to the current coding block in the reference frame according to pixel coordinate values of each pixel position in the reference block; a pixel value determination module configured to obtain a pixel value of each pixel position in the reference block based on a filter coefficient corresponding to each pixel position and a motion vector corresponding to the reference frame; The encoding result determination module is configured to perform filtering on the current encoding frame according to the pixel value of each pixel position in the reference block to obtain the encoding result of the current encoding frame.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the video encoding method according to any one of claims 1 to 7.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the video encoding method according to any one of claims 1 to 7 is implemented.