Video compression method and device, equipment and storage medium
By calculating the error distribution value of pixel blocks in the video sequence and determining whether time domain filtering is performed based on it, the problem of lack of error distribution measurement indicators in the prior art is solved, and the compression performance and efficiency of the video encoder are improved.
Patent Information
- Application Number
- CN202510537057.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-27
AI Technical Summary
The lack of indicators and related calculation methods for measuring block error distribution in existing video encoders, resulting in block error measurement distortion in certain error concentrations, which in turn affects the compression performance of the encoder.
By calculating the sum of squared errors, vertical squared errors and horizontal squared errors of pixel blocks in each frame image in the video sequence, the error distribution value is calculated based on these error values and the size of the pixel block, and whether it is less than the preset threshold value is determined based on the error distribution value. If it is less than, the time domain filtering operation will be performed and the encoding compression will be performed; if it is not less than, the encoding compression will be performed directly.
The compression performance of the video encoder and the efficiency of video compression are improved. By more accurately measuring the block error distribution, encoding distortion in the case of error concentration is avoided, and the overall effect of the encoding process is improved.
Smart Images

Figure CN120075451A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of video processing technologies, and particularly relates to a video compression method, apparatus, device, and storage medium. Background Art
[0002] Currently, when compressing a video, a video encoder such as an AVS3 (Audio Video Standard) encoder is usually used to encode video data to achieve efficient video compression. Temporal Filter (TF), as a tool in the video encoder, filters images that are more likely to be referenced in inter-frame coding in the temporal domain, thereby reducing the residuals of the frames encoded with the image as a reference subsequently, so as to achieve the purpose of saving the bit rate.
[0003] For example, when there is a video sequence of two frames to be encoded, where the first frame is A and the second frame is B, then in the encoding process, frame B will be encoded with frame A as a reference. Before the formal encoding, TF will use a filtering weight to filter frame A with frame B, that is, part of the information in frame B is fused into frame A. In the subsequent encoding process, frame B will be predicted and encoded with frame A as a reference. Since frame A already has some information in frame B at this time, the residuals remaining after the predictive encoding will be reduced, enabling higher compression efficiency in subsequent transformation, quantization, and entropy encoding, that is, saving the bitstream.
[0004] However, in current video encoders (such as AVS3 encoders), there are only methods related to block (pixel block) error calculation, and there are no metrics and related calculation methods for measuring the block error distribution. This causes the measurement of block errors to be distorted in some cases where errors are concentrated (such as when large errors are distributed in a small range), and further leads to poor algorithm effects relying on block errors, resulting in a decline in the compression performance of the encoder. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a video compression method, apparatus, device, and storage medium, which can improve the compression performance of the encoder and at the same time improve the efficiency of video compression. The specific solutions are as follows:
[0006] In a first aspect, this application discloses a video compression method applied to a video encoder, including:
[0007] Determine a target video sequence to be compressed, and sequentially obtain multiple pixel blocks within each frame image of the target video sequence;
[0008] Calculate the sum of squared errors, vertical sum of squared errors, and horizontal sum of squared errors of the multiple pixel blocks in each frame image respectively;
[0009] Calculate the error distribution of each pixel block based on the size of each pixel block, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value, and determine whether the error distribution value is less than a preset threshold;
[0010] If the error distribution value is less than the preset threshold, perform a time-domain filtering operation on the corresponding pixel block to obtain filtered data, and perform encoding compression on the filtered data to obtain a compression result;
[0011] If the error distribution value is not less than the preset threshold, directly perform encoding compression on the corresponding pixel block to obtain a compression result.
[0012] Optionally, the calculation formula for the sum of squared errors is:
[0013] ;
[0014] In the formula, SSD represents the sum of squared errors, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search, represents each of the pixel blocks.
[0015] Optionally, the calculation formula for the horizontal sum of squared errors is:
[0016] ;
[0017] In the formula, HSD represents the horizontal sum of squared errors, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search.
[0018] Optionally, the calculation formula for the vertical sum of squared errors is:
[0019] ;
[0020] In the formula, VSD represents the vertical sum of squared errors, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search.
[0021] Optionally, calculating the error distribution of each of the pixel blocks based on the size of each of the pixel blocks, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value, includes:
[0022] Obtain the width and height of the pixel block, and calculate the product of the width and the height to obtain a first calculation result;
[0023] Calculate the product of the first calculation result and a preset coefficient to obtain a second calculation result, and calculate the sum value of the width and the height;
[0024] Calculate the difference between the second calculation result and the sum value, and calculate the error distribution of the corresponding pixel block based on the difference, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value.
[0025] Optionally, calculating the error distribution of the corresponding pixel block based on the difference, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value, includes:
[0026] Use a preset error distribution calculation formula and calculate the error distribution of the corresponding pixel block based on the difference, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value;
[0027] Wherein, the preset error distribution calculation formula is:
[0028] ;
[0029] In the formula, represents the error distribution value, represents the first calculation result, represents the difference, and b1 is a preset parameter.
[0030] Optionally, the error distribution value is inversely proportional to the error distribution concentration degree of the pixel block.
[0031] In a second aspect, the present application discloses a video compression device, which is applied to a video encoder and includes:
[0032] A determination module, configured to determine a target video sequence to be compressed;
[0033] An acquisition module, configured to sequentially acquire a plurality of pixel blocks in each frame image of the target video sequence;
[0034] A first calculation module, configured to respectively calculate the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors of the plurality of pixel blocks in each frame image;
[0035] A second calculation module, configured to calculate an error distribution of a corresponding pixel block based on the size of each pixel block, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, obtain an error distribution value, and determine whether the error distribution value is less than a preset threshold;
[0036] A filtering and compression module, configured to, if the error distribution value is less than the preset threshold, perform a time-domain filtering operation on the corresponding pixel block to obtain filtered data, and perform encoding and compression on the filtered data to obtain a compression result;
[0037] An encoding and compression module, configured to, if the error distribution value is not less than the preset threshold, directly perform encoding and compression on the corresponding pixel block to obtain a compression result.
[0038] In a third aspect, the present application discloses an electronic device, including a processor and a memory; wherein, when the processor executes a computer program stored in the memory, the foregoing video compression method is implemented.
[0039] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the foregoing video compression method is implemented.
[0040] It can be seen that the present application is applied to a video encoder. First, a target video sequence to be compressed is determined, and a plurality of pixel blocks in each frame image of the target video sequence are sequentially obtained. Then, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors of the plurality of pixel blocks in each frame image are respectively calculated. Next, an error distribution of a corresponding pixel block is calculated based on the size of each pixel block, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, an error distribution value is obtained, and it is determined whether the error distribution value is less than a preset threshold; if the error distribution value is less than the preset threshold, a time-domain filtering operation is performed on the corresponding pixel block to obtain filtered data, and encoding and compression are performed on the filtered data to obtain a compression result; if the error distribution value is not less than the preset threshold, encoding and compression are directly performed on the corresponding pixel block to obtain a compression result. The present application calculates an error distribution value for measuring the block error distribution situation based on the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors of pixel blocks in each frame image of a video sequence, and the size of each pixel block. When the error distribution value is not less than the preset threshold, encoding and compression are directly performed on the pixel block, that is, the time-domain filtering operation is directly skipped when it is not less than the preset threshold. By judging whether to skip the current time-domain filtering process according to the error distribution situation of the pixel block, the compression performance of the encoder can be improved, and at the same time, the efficiency of video compression is increased. Description of the Drawings
[0041] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on the provided drawings.
[0042] Figure 1 Flowchart of a video compression method disclosed in the present application;
[0043] Figure 2 Structural schematic diagram of a video compression device disclosed in the present application;
[0044] Figure 3 Structural diagram of an electronic device disclosed in the present application. Detailed implementation manners
[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0046] The embodiments of the present application disclose a video compression method, which is applied to a video encoder. Refer to Figure 1 As shown, the method includes:
[0047] Step S11: Determine a target video sequence to be compressed, and sequentially obtain multiple pixel blocks in each frame image of the target video sequence.
[0048] It should be noted that the video compression scheme proposed in the present application is specifically applied to a video encoder, such as an AVS3 encoder, which can compress the original uncompressed video signal into a bitstream in the AVS3 format for storage or transmission. In actual applications, the AVS3 encoder can be used in multiple fields. For example, ultra-high-definition content distribution: such as 4K / 8K video on demand, ultra-high-definition television; video live broadcast: such as sports live broadcast, real-time streaming media; cloud gaming and VR / AR: providing low-latency and high-quality video transmission; video surveillance: efficiently storing a large amount of high-definition video content. In the above applications, the encoder needs to execute the encoding process more efficiently while ensuring the video quality.
[0049] In this embodiment, when video compression is required, the video sequence to be compressed can be obtained first to obtain the target video sequence, and then multiple in each frame image of the above target video sequence are sequentially performed according to a preset block size (such as obtain pixel blocks of a size.
[0050] Step S12: Calculate the sum of squared differences, vertical squared differences, and horizontal squared differences of the multiple pixel blocks in each frame of image respectively.
[0051] In this embodiment, after obtaining multiple pixel blocks in each frame of image, further calculate multiple error values of pixel blocks of a size according to a preset error factor, such as calculating the sum of squared differences (SSD), vertical squared differences (VSD), and horizontal squared differences (HSD) of the multiple pixel blocks of a size in each frame of image respectively.
[0052] Among them, the calculation formula of the sum of squared differences (i.e., SSD) is:
[0053] ;
[0054] In the formula, SSD represents the sum of squared differences, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search, represents each of the pixel blocks.
[0055] Specifically, the calculation formula of the horizontal squared difference (i.e., HSD) is:
[0056] ;
[0057] In the formula, HSD represents the horizontal squared difference, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search.
[0058] In a specific embodiment, the calculation formula of the vertical squared difference (i.e., VSD) is:
[0059] ;
[0060] In the formula, VSD represents the vertical squared difference, represents the value of the pixel point with coordinates The value of the pixel point, represents the value of the pixel point with coordinates on the reference block obtained by motion search.
[0061] Step S13: Calculate the error distribution of the corresponding pixel block based on the size of each pixel block, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, obtain the error distribution value, and determine whether the error distribution value is less than a preset threshold.
[0062] In this embodiment, after obtaining the multiple error values of the multiple pixel blocks in each frame of image, the error distribution of the corresponding pixel block can be calculated based on the size of the pixel block and the multiple error values. Specifically, the error distribution of the corresponding pixel block can be calculated based on the size of the above pixel block, the above sum of squared errors, the above vertical sum of squared errors, and the above horizontal sum of squared errors, obtain the error distribution value, and then determine whether the error distribution value is less than a preset threshold.
[0063] In a specific implementation manner, the calculating the error distribution of the corresponding pixel block based on the size of each pixel block, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, and obtaining the error distribution value may specifically include: obtaining the width and height of the pixel block, and calculating the product of the width and the height to obtain a first calculation result; calculating the product of the first calculation result and a preset coefficient to obtain a second calculation result, and calculating the sum value of the width and the height; calculating the difference between the second calculation result and the sum value, and calculating the error distribution of the corresponding pixel block based on the difference, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, to obtain the error distribution value. In this embodiment, first obtain the width and height of the current pixel block, then calculate the product of the width and height to obtain the corresponding first calculation result , then, calculate the product of the first calculation result and the preset coefficient to obtain the corresponding second calculation result, then calculate the sum value of the width and height , and finally calculate the difference between the above second calculation result and the above sum value , and calculate the error distribution of the corresponding pixel block based on this difference
[0064] , the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, so as to obtain the error distribution value. Among them, the calculation formula of the first calculation result
[0065] can be expressed as:
[0066] The said difference The calculation formula can be expressed as:
[0067] ;
[0068] In the formula, 2 represents the said preset coefficient, and this value can be selected according to actual application requirements.
[0069] Specifically, calculating the error distribution of the corresponding pixel block based on the said difference, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value may specifically include: using a preset error distribution calculation formula and calculating the error distribution of the corresponding pixel block based on the said difference, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors to obtain an error distribution value;
[0070] Among them, the preset error distribution calculation formula is:
[0071] ;
[0072] In the formula, represents the said error distribution value, represents the said first calculation result, represents the said difference, and b1 is a preset parameter.
[0073] It should be noted that the said error distribution value is inversely proportional to the error distribution concentration degree of the pixel block. In this embodiment, the calculated error distribution value can reflect the error distribution situation of the pixel block. The smaller the error distribution value , the more concentrated the error distribution is, and vice versa, it indicates that the error distribution is more dispersed.
[0074] Step S14: If the error distribution value is less than a preset threshold, perform a time-domain filtering operation on the corresponding pixel block to obtain filtered data, and perform encoding and compression on the filtered data to obtain a compression result.
[0075] In this embodiment, if the above error distribution value is less than a preset threshold, perform a time-domain filtering operation on the corresponding pixel block, such as prediction, transformation, quantization, entropy coding and other operations, to obtain filtered data, and then perform encoding and compression on the above filtered data to obtain a compression result.
[0076] Step S15: If the error distribution value is not less than a preset threshold, directly perform encoding and compression on the corresponding pixel block to obtain a compression result.
[0077] In this embodiment, if the above error distribution value is not less than the preset threshold, it indicates that in the current situation, the time-domain filtering operation can be skipped and the compression process can be directly performed. At this time, the time-domain filtering operation is skipped, and the corresponding pixel block is directly encoded and compressed, thereby obtaining the compression result of the target video sequence.
[0078] It can be seen that the embodiment of the present application is applied to a video encoder. First, the target video sequence to be compressed is determined, and a plurality of pixel blocks in each frame image of the target video sequence are sequentially obtained. Then, the sum of squared errors, vertical squared errors, and horizontal squared errors of the plurality of pixel blocks in each frame image are respectively calculated. Next, based on the size of each pixel block, the sum of squared errors, the vertical squared error, and the horizontal squared error, the error distribution of the corresponding pixel block is calculated to obtain an error distribution value, and it is determined whether the error distribution value is less than the preset threshold. If the error distribution value is less than the preset threshold, the time-domain filtering operation is performed on the corresponding pixel block to obtain filtered data, and the filtered data is encoded and compressed to obtain a compression result. If the error distribution value is not less than the preset threshold, the corresponding pixel block is directly encoded and compressed to obtain a compression result. The embodiment of the present application calculates an error distribution value for measuring the block error distribution situation based on the sum of squared errors, vertical squared errors, and horizontal squared errors of pixel blocks in each frame image of the video sequence, and the size of each pixel block. When the error distribution value is not less than the preset threshold, the pixel block is directly encoded and compressed, that is, when it is not less than the preset threshold, the time-domain filtering operation is directly skipped. By judging whether to skip the current time-domain filtering process according to the error distribution situation of the pixel block, the compression performance of the encoder can be improved, and at the same time, the efficiency of video compression can be increased.
[0079] Correspondingly, the embodiment of the present application also discloses a video compression device, which is applied to a video encoder. Refer to Figure 2 As shown, the device includes:
[0080] A determination module 11, configured to determine a target video sequence to be compressed;
[0081] An acquisition module 12, configured to sequentially acquire a plurality of pixel blocks in each frame image of the target video sequence;
[0082] A first calculation module 13, configured to respectively calculate the sum of squared errors, vertical squared errors, and horizontal squared errors of the plurality of pixel blocks in each frame image;
[0083] A second calculation module 14, configured to calculate the error distribution of the corresponding pixel block based on the size of each pixel block, the sum of squared errors, the vertical squared error, and the horizontal squared error, obtain an error distribution value, and determine whether the error distribution value is less than a preset threshold;
[0084] A filtering and compression module 15, configured to perform a temporal filtering operation on the corresponding pixel block if the error distribution value is less than a preset threshold, obtain filtered data, and perform encoding and compression on the filtered data to obtain a compression result;
[0085] An encoding and compression module 16, configured to directly perform encoding and compression on the corresponding pixel block to obtain a compression result if the error distribution value is not less than the preset threshold.
[0086] Wherein, for the specific working processes of the above-mentioned respective modules, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not described herein again.
[0087] It can be seen that the embodiment of the present application is applied to a video encoder. First, a target video sequence to be compressed is determined, and a plurality of pixel blocks in each frame image of the target video sequence are sequentially obtained. Then, the sum of squared errors, vertical sum of squared errors, and horizontal sum of squared errors of the plurality of pixel blocks in each frame image are respectively calculated. Next, based on the size of each pixel block, the sum of squared errors, the vertical sum of squared errors, and the horizontal sum of squared errors, the error distribution of the corresponding pixel block is calculated to obtain an error distribution value, and it is determined whether the error distribution value is less than a preset threshold; if the error distribution value is less than the preset threshold, a temporal filtering operation is performed on the corresponding pixel block to obtain filtered data, and encoding and compression are performed on the filtered data to obtain a compression result; if the error distribution value is not less than the preset threshold, encoding and compression are directly performed on the corresponding pixel block to obtain a compression result. The embodiment of the present application calculates an error distribution value for measuring the block error distribution situation based on the sum of squared errors, vertical sum of squared errors, and horizontal sum of squared errors of pixel blocks in each frame image of a video sequence, and the size of each pixel block, and directly performs encoding and compression on the pixel block when the error distribution value is not less than the preset threshold, that is, directly skips the temporal filtering operation when it is not less than the preset threshold. By making a skip determination on the currently performed temporal filtering process according to the error distribution situation of the pixel block, the compression performance of the encoder can be improved, and at the same time, the efficiency of video compression can be increased.
[0088] In some specific embodiments, the calculation formula for the sum of squared errors is:
[0089] ;
[0090] In the formula, SSD represents the sum of squared errors, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search, represents each of the pixel blocks.
[0091] In some specific embodiments, the calculation formula of the horizontal square error is as follows:
[0092] ;
[0093] In the formula, HSD represents the horizontal square error, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search.
[0094] In some specific embodiments, the calculation formula of the vertical square error is as follows:
[0095] ;
[0096] In the formula, VSD represents the vertical square error, represents the value of the pixel point with coordinates on the current pixel block, represents the value of the pixel point with coordinates on the reference block obtained by motion search.
[0097] In some specific embodiments, the second calculation module 14 may specifically include:
[0098] An information acquisition unit for acquiring the width and height of the pixel block;
[0099] A first calculation unit for calculating the product of the width and the height to obtain a first calculation result;
[0100] A second calculation unit for calculating the product of the first calculation result and a preset coefficient to obtain a second calculation result, and calculating the sum value of the width and the height;
[0101] A third calculation unit for calculating the difference between the second calculation result and the sum value, and calculating the error distribution of the corresponding pixel block based on the difference, the sum of the square errors, the vertical square error, and the horizontal square error to obtain an error distribution value.
[0102] In some specific embodiments, the third calculation unit may specifically include:
[0103] A fourth calculation unit for calculating the error distribution of the corresponding pixel block by using a preset error distribution calculation formula and based on the difference, the sum of the square errors, the vertical square error, and the horizontal square error to obtain an error distribution value;
[0104] Among them, the preset error distribution calculation formula is:
[0105] ;
[0106] In the formula, represents the error distribution value, represents the first calculation result, represents the difference, and b1 is a preset parameter.
[0107] In some specific embodiments, the error distribution value is inversely proportional to the error distribution concentration degree of the pixel block.
[0108] Furthermore, an embodiment of the present application also discloses an electronic device. Figure 3 It is a structural diagram of an electronic device 20 shown according to an exemplary embodiment. The content in the figure cannot be considered as any limitation on the scope of use of the present application.
[0109] Figure 3 It is a schematic structural diagram of an electronic device 20 provided by an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. Among them, the memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the video compression method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0110] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of the present application, and specific limitations are not imposed on it here; the input / output interface 25 is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application requirements, and specific limitations are not imposed here.
[0111] In addition, as a carrier for resource storage, the memory 22 may be a read-only memory, a random access memory, a magnetic disk, or an optical disc, etc. The resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage method may be short-term storage or permanent storage.
[0112] Among them, the operating system 221 is used to manage and control each hardware device and computer program 222 on the electronic device 20, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the video compression method executed by the electronic device 20 disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs that can be used to complete other specific tasks.
[0113] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the foregoing disclosed video compression method is implemented. For the specific steps of this method, reference can be made to the corresponding content disclosed in the foregoing embodiments, and details will not be elaborated herein.
[0114] Furthermore, the embodiments of the present application also disclose a computer program product, including a computer program / instructions, and when the computer program / instructions are executed by a processor, the steps of the video compression method disclosed as above are implemented.
[0115] In this specification, the various embodiments are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple. For the relevant parts, reference can be made to the description in the method part.
[0116] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0117] The steps of the method or algorithm described in combination with the embodiments disclosed herein can be directly implemented by hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium well-known in the technical field.
[0118] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0119] The above has introduced in detail a video compression method, apparatus, device and storage medium provided by the present application. Specific examples are used in this text to elaborate on the principle and implementation manner of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A video compression method, characterized in that: Applicable to video encoders, including: Determine a target video sequence to be compressed, and sequentially obtain a plurality of pixel blocks in each frame image of the target video sequence; Respectively calculating the sum of square errors, vertical square errors and horizontal square errors of the plurality of pixel blocks in each frame image; Calculating the error distribution of the corresponding pixel block based on the size of each pixel block, the sum of square errors, the vertical square error and the horizontal square error to obtain an error distribution value, and determining whether the error distribution value is less than a preset threshold; If the error distribution value is less than a preset threshold, a time domain filtering operation is performed on the corresponding pixel block to obtain filtered data, and the filtered data is encoded and compressed to obtain a compression result; If the error distribution value is not less than a preset threshold, the corresponding pixel block is directly coded and compressed to obtain a compression result.
2. The video compression method according to claim 1, characterized in that: The calculation formula of the sum of square errors is: ; In the formula, SSD represents the sum of square errors, Indicates that the coordinates on the current pixel block are The pixel value of The coordinates of the reference block obtained by motion search are The pixel value of represents each of the pixel blocks.
3. The video compression method according to claim 2, characterized in that: The calculation formula of the horizontal square error is: ; Wherein, HSD represents the horizontal square error, Indicates that the coordinates on the current pixel block are The pixel value of The coordinates of the reference block obtained by motion search are The pixel value of .
4. The video compression method according to claim 3, characterized in that: The calculation formula of the vertical square error is: ; Wherein, VSD represents the vertical square error, Indicates that the coordinates on the current pixel block are The pixel value of The coordinates of the reference block obtained by motion search are The pixel value of .
5. The video compression method according to claim 4, characterized in that: The calculating the error distribution of the corresponding pixel block based on the size of each pixel block, the sum of square errors, the vertical square error and the horizontal square error to obtain the error distribution value includes: Acquire the width and height of the pixel block, and calculate the product of the width and the height to obtain a first calculation result; Calculate the product of the first calculation result and a preset coefficient to obtain a second calculation result, and calculate the sum of the width and the height; The difference between the second calculation result and the sum value is calculated, and the error distribution of the corresponding pixel block is calculated based on the difference, the square error sum, the vertical square error and the horizontal square error to obtain an error distribution value.
6. The video compression method according to claim 5, characterized in that: The step of calculating the error distribution of the corresponding pixel block based on the difference, the sum of square errors, the vertical square error and the horizontal square error to obtain an error distribution value comprises: Calculating the error distribution of the corresponding pixel block by using a preset error distribution calculation formula based on the difference, the sum of square errors, the vertical square error and the horizontal square error to obtain an error distribution value; Wherein, the preset error distribution calculation formula is: ; In the formula, represents the error distribution value, represents the first calculation result, represents the difference, and b1 is a preset parameter.
7. The video compression method according to any one of claims 1 to 6, characterized in that: The error distribution value is inversely proportional to the error distribution concentration of the pixel block.
8. A video compression device, characterized in that: Applicable to video encoders, including: A determination module, used for determining a target video sequence to be compressed; An acquisition module, used to sequentially acquire a plurality of pixel blocks in each frame image of the target video sequence; A first calculation module, used for respectively calculating the sum of square errors, vertical square errors and horizontal square errors of the plurality of pixel blocks in each frame image; a second calculation module, configured to calculate the error distribution of the corresponding pixel block based on the size of each pixel block, the sum of square errors, the vertical square error and the horizontal square error, obtain an error distribution value, and determine whether the error distribution value is less than a preset threshold; A filtering and compression module, configured to perform a time domain filtering operation on the corresponding pixel block to obtain filtered data if the error distribution value is less than a preset threshold, and to perform encoding and compression on the filtered data to obtain a compression result; The coding and compression module is used to directly perform coding and compression on the corresponding pixel block to obtain a compression result if the error distribution value is not less than a preset threshold.
9. An electronic device, characterized in that: It comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the video compression method as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the video compression method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Video noise reduction method and device based on time domain filtering
CN113612996A
Video noise reduction method and device based on time domain filtering
CN113613005A
Method and device for video processing and medium
CN117242479A
Video coding pre-processing method, system, device, medium and program product
CN118660168A
Time domain filtering method and system
CN119676433A