Video decompression method and device, video compression method and device and computer equipment
By segmenting the video data and calculating factors to generate a transformation coefficient matrix, the problem of image distortion in video data compression is solved, the image quality is improved and a higher compression ratio is achieved, and the image distortion at low bit rates in the existing technology is solved. problem.
Patent Information
- Application Number
- CN202410464063.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-17
- Publication Date
- 2024-08-27
AI Technical Summary
Existing video data compression technology can easily cause image distortion at low bit rates, especially obvious block-like distortion and color distortion at the edges and flat areas of image frames, which affects the visual perception of the video.
By segmenting the image frame to be decompressed, calculating high-frequency and low-frequency component factors, generating a transformation coefficient matrix to characterize the energy distribution of the image frame, performing inverse quantization processing, and adjusting quantization parameters to reduce distortion and improve image quality.
It effectively reduces image distortion during the compression and decompression process, improves image quality, and simultaneously achieves a higher compression ratio, reduces the size of video files, and saves storage space and transmission bandwidth.
Smart Images

Figure CN118555405A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of video data processing, and in particular to a video decompression method, a video compression method, a device and a computer device. Background Art
[0002] In order to reduce the amount of data, video data is usually compressed, which may cause a certain degree of distortion in the decompressed video, especially under low bit rate compression, which may cause obvious distortion, such as obvious block-shaped distortion at the edge or flat area of the image frame, making the image frame look like it is composed of many small blocks instead of continuous smooth changes, presenting a discontinuous and rough visual experience. Another example is the color distortion in the image, that is, the actual color is significantly different from the displayed color.
[0003] Therefore, there is an urgent need for a video data processing method to solve the image distortion problem existing in the above-mentioned video encoding and decoding process. Summary of the invention
[0004] In view of this, the present disclosure proposes a video decompression method, a video compression method, an apparatus and a computer device to solve the image distortion problem existing in the video encoding and decoding process in the related art.
[0005] The first aspect of the present disclosure provides a video compression method, including:
[0006] Segment each image frame in the image frame sequence to be decompressed to obtain a plurality of decoding blocks;
[0007] For any one of the plurality of decoding blocks, a first number of first factors and a second number of second factors are calculated based on the decoding block; wherein the first factor is used to characterize the high-frequency component factors in the decoding block, and the second factor is used to characterize the high-frequency component factors that are not zero in the quantized transform coefficient matrix corresponding to the decoding block;
[0008] Based on the first number and the second number, a transformation coefficient matrix is generated; the transformation coefficient matrix is used to characterize the energy distribution of the image frame under different frequency components;
[0009] The to-be-decompressed image frame sequence is decompressed based on the transformation coefficient matrix to obtain a decompressed video.
[0010] In the disclosed embodiment, a first number of a first factor and a second number of a second factor are calculated through a decoding block, a transformation coefficient matrix is generated based on the first number and the second number, and video decompression is performed based on the transformation coefficient matrix. This can reduce image distortion during compression and decompression, thereby improving image quality; and can achieve a higher compression ratio, that is, while maintaining image quality, reduce the size of the video file, and save storage space and transmission bandwidth.
[0011] In an embodiment of the present disclosure, generating a transform coefficient matrix based on the first number and the second number includes:
[0012] Determining a quantization parameter of a third factor based on the first number and the second number; the third factor is used to characterize a low-frequency component factor in the quantized transform coefficient matrix;
[0013] The quantized transform coefficient matrix is dequantized based on the quantization parameter to generate the transform coefficient matrix.
[0014] In the embodiment of the present disclosure, determining a quantization parameter of a third factor based on the first number and the second number includes:
[0015] determining a target frequency based on the first number and the second number;
[0016] If the target frequency is less than a preset frequency threshold, the quantization parameter of the third factor is adjusted to a target quantization parameter.
[0017] In the disclosed embodiment, the quantization parameter of the third factor is determined by the first quantity and the second quantity, and the quantization parameter is used to perform inverse quantization processing to generate a transform coefficient matrix. This can fully take into account the impact of the distortion of the DC transform coefficient (i.e., the third factor) on the decoded image quality, thereby achieving the goal of reducing the distortion of the image during the compression and decompression process and improving the image quality by adjusting the quantization parameter of the DC transform coefficient.
[0018] In the embodiment of the present disclosure, the step of performing inverse quantization processing on the quantized transform coefficient matrix based on the quantization parameter to generate the transform coefficient matrix includes:
[0019] Modifying a predefined quantization table using the quantization parameter;
[0020] The quantized transform coefficient matrix is dequantized based on the modified quantization table to obtain a transform coefficient matrix in the frequency domain.
[0021] In the embodiment of the present disclosure, decompressing the to-be-decompressed image frame sequence based on the transformation coefficient matrix to obtain a decompressed video includes:
[0022] Performing inverse transformation processing on the transformation coefficient matrix to obtain a residual matrix in the spatial domain;
[0023] Combining the residual matrix with corresponding reference pixel values to obtain image data corresponding to the decoded block;
[0024] Reconstructing a plurality of image data corresponding to the plurality of decoding blocks one by one to obtain a target image frame;
[0025] The multiple target image frames are restored according to a preset arrangement order to obtain a decompressed video.
[0026] The embodiment of the second aspect of the present disclosure provides a video compression method, including:
[0027] Segment each image frame in the image frame sequence to be compressed to obtain a plurality of coding blocks;
[0028] For any one of the plurality of coding blocks, a first number of first factors and a second number of second factors are calculated based on the coding block; wherein the first factor is used to characterize the high-frequency component factor in the coding block, and the second factor is used to characterize the high-frequency component factor that is not zero in the quantized transform coefficient matrix corresponding to the coding block;
[0029] generating a quantized transform coefficient matrix based on the first number and the second number;
[0030] The image frame sequence to be compressed is compressed based on the quantization transformation coefficient matrix to obtain a compressed video.
[0031] In an embodiment of the present disclosure, calculating a second number of second factors based on the coding block includes:
[0032] Predicting a pixel matrix of a current coding block to obtain a residual matrix in a spatial domain; the current coding block is any one of the multiple coding blocks;
[0033] Converting the residual matrix in the spatial domain into a transform coefficient matrix in the frequency domain; wherein the transform coefficient matrix includes high-frequency component factors and low-frequency component factors;
[0034] quantizing the transform coefficient matrix using a first quantization parameter corresponding to the high frequency component factor to generate a first quantized transform coefficient matrix;
[0035] Based on the first quantized transform coefficient matrix, a second number of second factors is determined.
[0036] In an embodiment of the present disclosure, generating a quantized transform coefficient matrix based on the first number and the second number includes:
[0037] Determine a second quantization parameter of a third factor based on the first number and the second number; the third factor is used to characterize a low-frequency component factor in the transform coefficient matrix;
[0038] The transform coefficient matrix is quantized based on the first quantization parameter and the second quantization parameter to generate the quantized transform coefficient matrix.
[0039] In an embodiment of the present disclosure, compressing the to-be-compressed image frame sequence based on the quantization transform coefficient matrix to obtain a compressed video includes:
[0040] Performing encoding processing on a plurality of quantized transform coefficient matrices corresponding to the plurality of encoding blocks one by one, respectively, to obtain a plurality of encoding processing results;
[0041] Combining the multiple encoding processing results to obtain a first image frame corresponding to a target image frame; the target image frame is any one of the multiple image frames in the image frame sequence to be compressed;
[0042] A plurality of first image frames corresponding to the plurality of image frames are combined to obtain a compressed video.
[0043] The third aspect of the present disclosure provides a video decompression device, including:
[0044] An image segmentation module is used to segment each image frame in the image frame sequence to be decompressed to obtain multiple decoding blocks;
[0045] A quantity determination module, configured to calculate, for any one of the plurality of decoding blocks, a first quantity of a first factor and a second quantity of a second factor based on the decoding block; wherein the first factor is used to characterize a high-frequency component factor in the decoding block, and the second factor is used to characterize a non-zero high-frequency component factor in a quantized transform coefficient matrix corresponding to the decoding block;
[0046] A transformation coefficient matrix generation module, used to generate a transformation coefficient matrix based on the first number and the second number; the transformation coefficient matrix is used to characterize the energy distribution of the corresponding image frame under different frequency components;
[0047] The video decompression module is used to decompress the image frame sequence to be decompressed based on the transformation coefficient matrix to obtain a decompressed video.
[0048] An embodiment of a fourth aspect of the present disclosure provides a video compression device, including:
[0049] An image segmentation module is used to segment each image frame in the image frame sequence to be compressed to obtain multiple coding blocks;
[0050] A quantity determination module, configured to calculate, for any one of the plurality of coding blocks, a first quantity of a first factor and a second quantity of a second factor based on the coding block; wherein the first factor is used to characterize a high-frequency component factor in the coding block, and the second factor is used to characterize a non-zero high-frequency component factor in a quantized transform coefficient matrix corresponding to the coding block;
[0051] A quantized transform coefficient matrix generation module, configured to generate a quantized transform coefficient matrix based on the first number and the second number;
[0052] The video compression module is used to compress the image frame sequence to be compressed based on the quantization transformation coefficient matrix to obtain a compressed video.
[0053] An embodiment of the fifth aspect of the present disclosure provides an electronic device, which includes a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the video compression method described in the first aspect by executing the computer instructions.
[0054] An embodiment of the sixth aspect of the present disclosure provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the video compression method described in the first aspect.
[0055] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will become apparent from the following description or be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] By reading the detailed description of the preferred embodiment below, various other advantages and benefits will become clear to those of ordinary skill in the art. The accompanying drawings are only used for the purpose of illustrating the preferred embodiment and are not considered to be limitations of the present disclosure. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings.
[0057] In the attached picture:
[0058] Figure 1 A schematic diagram showing a flow chart of a video decompression method provided by an embodiment of the present disclosure;
[0059] Figure 2 A schematic diagram showing a flow chart of another video decompression method provided by an embodiment of the present disclosure;
[0060] Figure 3 A schematic diagram showing a flow chart of another video decompression method provided by an embodiment of the present disclosure;
[0061] Figure 4 A schematic diagram showing a flow chart of another video decompression method provided by an embodiment of the present disclosure;
[0062] Figure 5 A schematic diagram showing a flow chart of another video decompression method provided by an embodiment of the present disclosure;
[0063] Figure 6 A schematic diagram showing the structure of a video decompression device provided by an embodiment of the present disclosure is shown;
[0064] Figure 7 A schematic diagram of the structure of a video compression device provided by an embodiment of the present disclosure is shown;
[0065] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown;
[0066] Fig. 9 A schematic diagram of a storage medium provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0067] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0068] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present disclosure should have the common meanings understood by those skilled in the art to which the present disclosure belongs.
[0069] The following describes the technical scenarios involved in the embodiments of the present disclosure.
[0070] According to an embodiment of the present disclosure, a video compression method embodiment is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0071] In this embodiment, a video decompression method is provided, which can be used in a decoder. Figure 1 is a flowchart of a video decompression method according to an embodiment of the present disclosure. Figure 1 As shown, the process includes the following steps:
[0072] Step S101 , segmenting each image frame in the image frame sequence to be decompressed to obtain a plurality of decoding blocks.
[0073] In some embodiments, the sequence of image frames to be decompressed in the video code stream includes multiple image frames, and any image frame among the multiple image frames is segmented into blocks to obtain multiple decoding blocks. More specifically, in the block segmentation process, the size of the block to be segmented is first determined, such as a block of 8x8 or 16x16 pixels; then, according to the block size, the image frame is segmented into multiple decoding blocks according to a preset segmentation rule. Each decoding block can be understood as a small block area segmented out of the image frame.
[0074] Step S102: for any one decoding block among the plurality of decoding blocks, a first number of first factors and a second number of second factors are calculated based on the decoding block.
[0075] The first factor is used to characterize the high-frequency component factor in the decoding block, which can be understood as the AC transformation coefficient; the second factor is used to characterize the non-zero high-frequency component factor in the quantization transformation coefficient matrix corresponding to the decoding block.
[0076] Step S103: Generate a transformation coefficient matrix based on the first number and the second number.
[0077] Among them, the transformation coefficient matrix is used to characterize the energy distribution of the image frame under different frequency components; the transformation coefficient matrix in the frequency domain includes a DC transformation coefficient and multiple AC transformation coefficients, the DC transformation coefficient corresponds to the low-frequency part in the image block, and the AC transformation coefficient corresponds to the high-frequency part in the image block.
[0078] In some embodiments, Figure 2 As shown, the above step S103 includes step S1031-step S1032:
[0079] Step S1031: determine a quantization parameter of a third factor based on the first number and the second number.
[0080] Specifically, the third factor is used to characterize the low-frequency component factor in the quantization transformation coefficient matrix, which can be understood as a direct current transformation coefficient.
[0081] More specifically, if Figure 3 As shown, the above step S1031 includes step 301-step 302:
[0082] Step 301: determine a target frequency based on the first number and the second number.
[0083] Specifically, the ratio of the second number to the first number can be used as the target frequency. For example, when the number of AC transform coefficients in the decoding block (i.e., the first number) is N1, and the number of non-zero AC transform coefficients in the quantization exchange coefficient matrix corresponding to the decoding block (i.e., the second number) is N2, the frequency of the non-zero AC transform coefficients (i.e., the target frequency) is N2 / N1.
[0084] Step 302: If the target frequency is less than a preset frequency threshold, the quantization parameter of the third factor is adjusted to a target quantization parameter.
[0085] Specifically, the preset frequency threshold can be set according to actual conditions, and is not specifically limited here, such as 1 / 8. When the target frequency is less than the preset frequency threshold, the quantization parameter of the third factor is adjusted to the target quantization parameter, for example: the quantization parameter of the DC transform coefficient is reduced by a preset value (the preset value may be 8), and the adjusted quantization parameter is obtained, i.e., the target quantization parameter in the above step S302 or the quantization parameter in the above step S1031.
[0086] Step S1032: Dequantize the quantized transform coefficient matrix based on the quantization parameter to generate the transform coefficient matrix.
[0087] In some embodiments, Figure 4 As shown, the above step S1032 includes steps S401-402:
[0088] Step S401: modify a predefined quantization table using the quantization parameter.
[0089] Specifically, the predefined quantization table contains a first quantization step size of a DC transformation coefficient (a low-frequency component factor) and a second quantization step size of an AC transformation coefficient (a high-frequency component factor); the first quantization step size in the predefined quantization table is replaced by the quantization parameter to obtain a modified quantization table.
[0090] Step S402: Dequantize the quantized transform coefficient matrix based on the modified quantization table to obtain a transform coefficient matrix in the frequency domain.
[0091] Specifically, each element in the quantization coefficient matrix is multiplied by its corresponding quantization step in the modified quantization table. This process can restore discrete quantization coefficients to continuous transform coefficients. For example, the quantization step of the AC transform coefficient in the modified quantization table is 20. If there is an AC transform coefficient of 1 in the quantized coefficient matrix, its inverse quantized value is 20. After inverse quantization, a transform coefficient matrix in the frequency domain can be obtained. The elements in the transform coefficient matrix represent the intensity of each frequency component of the image or video under a given quantization table.
[0092] Step S104: decompress the to-be-decompressed image frame sequence based on the transformation coefficient matrix to obtain a decompressed video.
[0093] In some embodiments, Figure 5 As shown, the above step S104 includes steps S1041 to S1044:
[0094] Step S1041, performing inverse transformation processing on the transformation coefficient matrix to obtain a residual matrix in the spatial domain.
[0095] Specifically, an inverse discrete cosine transform (IDCT) or an inverse discrete sine transform (IDST) is performed on the transform coefficient matrix to obtain a residual matrix in the spatial domain.
[0096] Step S1042: combining the residual matrix with the corresponding reference pixel value to obtain image data corresponding to the decoding block.
[0097] Specifically, the pixel value of the corresponding decoding block can be obtained by adding the residual matrix to the pixel value at the corresponding position of the reference block. The specific implementation process includes: for each pixel in the decoding block, find its corresponding position in the reference block, add the value of the pixel to the value of the residual matrix at that position, and obtain the image data corresponding to the combined decoding block, in which the pixel value already contains the lost detail information.
[0098] Step S1043, reconstructing the multiple image data corresponding to the multiple decoding blocks one by one to obtain a target image frame.
[0099] Specifically, all decoded image data are placed according to their positions in the original image to obtain a reconstructed target image frame.
[0100] Step S1044, restoring the plurality of target image frames according to a preset arrangement order to obtain a decompressed video.
[0101] Specifically, the preset arrangement order may be performed in chronological order, so that each target image frame is restored according to its timestamp, thereby obtaining a decompressed video code stream.
[0102] In the disclosed embodiment, it is considered that the distortion of the DC coefficient has a great influence on the quality of the decoded image, especially in the flat image area, serious subjective distortion problems such as block effect and color deviation are prone to occur. For this reason, the disclosed embodiment determines whether the current decoding block is flat by the size of the AC transform coefficient. For the flat decoding block, the quantization parameter of the DC transform coefficient is reduced by 8, so that the length of the quantization interval becomes half of the original (for example, the original 8 samples from -4 to 3 are quantized to level 0, and the 4 samples from -2 to 1 are quantized to level 0), thereby achieving the purpose of reducing the distortion of the image in the decompression process and improving the image quality.
[0103] In some embodiments, the "corresponding reference pixel values" in the above step S1042 can be understood as a predicted pixel matrix, that is, the residual matrix of the current decoded block and the predicted pixel matrix are combined to obtain a reconstructed pixel matrix; and a target image frame is obtained by reconstructing multiple reconstructed pixel matrices corresponding to the multiple decoded blocks one by one. The reconstructed pixel matrix represents the above image data.
[0104] The "prediction pixel matrix of the current decoding block" in the above specific embodiment can be obtained by following the steps c1:
[0105] Step c1, determining a prediction pixel matrix of a current decoding block based on prediction mode information in a video bitstream.
[0106] Specifically, the prediction mode information includes at least one of the following: a horizontal prediction mode, a vertical prediction mode and a low-frequency component prediction mode; the prediction pixel matrix contains prediction values of all pixels in the current decoding block; the current decoding block is any one of the multiple decoding blocks.
[0107] In some embodiments, the above step c1 includes steps c11-c12:
[0108] Step c11: determining a prediction value of each pixel in the current decoding block based on the prediction mode information and the target decoding block.
[0109] Specifically, the target decoding block is a decoded decoding block adjacent to the current decoding block.
[0110] In some embodiments, the above step c11 includes steps d1 to d3:
[0111] Step d1, determining the low-frequency component factor of the target decoding block.
[0112] Specifically, the low-frequency component factor here can be understood as a DC conversion coefficient.
[0113] Step d2: Calculate the average value of the predicted pixel matrix of the target decoding block based on the prediction mode information.
[0114] Specifically, the prediction mode information includes multiple prediction modes, such as horizontal prediction mode, vertical prediction mode and low-frequency component prediction mode; the average value of the prediction pixel matrix of the target decoding block can be calculated according to the type of prediction mode and the corresponding calculation method; each type of prediction mode corresponds to a calculation method.
[0115] In some embodiments, the above step d2 includes steps d21 to d23:
[0116] Step d21, if the prediction mode information is the horizontal prediction mode, calculating the average value based on the pixel value of any column in the prediction pixel matrix; or,
[0117] Specifically, the horizontal prediction mode estimates the value of each pixel in the current block by taking the value of the pixel on the left side of the current block as the prediction value. When the prediction mode information is the horizontal prediction mode, the average value of all pixel values in any column of the prediction pixel matrix can be used to calculate the average value, which is explained by the following example:
[0118] Existing 4x4 pixel matrix:
[0119]
[0120] Perform horizontal prediction on the above pixel matrix, including:
[0121] For the pixels in the first column (10, 20, 30, 40), since there are no pixels to their left, the horizontal prediction mode cannot be used, so another processing method (such as DC conversion coefficients, etc.) is required;
[0122] For the second column and subsequent pixels (11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43), a horizontal prediction mode can be used. For example, for pixel 21, pixel 20 can be used for horizontal prediction, that is, the value of pixel 21 is considered to be equal to the value of pixel 20; for pixel 11, pixel 10 can be used for horizontal prediction, that is, the value of pixel 11 is considered to be equal to the value of pixel 10. Similarly, for pixel 22, pixel 20 is used for horizontal prediction; for pixel 23, pixel 20 is used for horizontal prediction, and so on. The following predicted pixel matrix can be obtained:
[0123]
[0124] After obtaining the above-mentioned predicted pixel matrix, the pixel values in any column of the matrix may be averaged, for example: (10+20+30+40) / 4=25.
[0125] Step d22, if the prediction mode information is the vertical prediction mode, calculating the average value based on the pixel value of any row in the prediction pixel matrix; or,
[0126] Specifically, the vertical prediction mode estimates the value of each pixel in the current block by taking the value of the pixel above the current block as the prediction value. When the prediction mode information is the vertical prediction mode, the average value of all pixel values in any row of the prediction pixel matrix can be used to calculate the average value, which is explained by the following example:
[0127] Existing 4x4 pixel matrix:
[0128]
[0129] Perform horizontal prediction on the above pixel matrix, including:
[0130] For the pixels in the first row (10, 20, 30, 40), since there are no pixels above them, the vertical prediction mode cannot be used, so another processing method (such as DC conversion coefficients, etc.) is required;
[0131] For the second row and subsequent pixels (11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43), we can use the vertical prediction mode. For example, for pixel 21, pixel 20 can be used for horizontal prediction, that is, the value of pixel 21 is considered to be equal to the value of pixel 20; for pixel 11, pixel 10 can be used for horizontal prediction, that is, the value of pixel 11 is considered to be equal to the value of pixel 10. Similarly, for pixel 22, pixel 20 is used for horizontal prediction; for pixel 23, pixel 20 is used for horizontal prediction, and so on. The following predicted pixel matrix can be obtained:
[0132]
[0133] After obtaining the above-mentioned predicted pixel matrix, the pixel values of any row in the matrix may be averaged, for example: (10+20+30+40) / 4=25.
[0134] Step d23: If the prediction mode information is the low-frequency component prediction mode, the average value is calculated based on any pixel value in the prediction pixel matrix.
[0135] Specifically, the low-frequency component prediction mode can be understood as a high-parallel DC prediction mode.
[0136] More specifically, when the prediction mode information is a low-frequency component prediction mode, an average value may be calculated using any pixel value in the prediction pixel matrix, as described in the following example:
[0137] Existing 4x4 pixel matrix:
[0138]
[0139] Calculate the average value of all pixel values for the above pixel matrix, that is:
[0140] avg=(10+11+12+13+20+21+22+23+30+31+32+33+40+41
[0141] +42+43) / 16=26.5
[0142] Then, avg can be used as the predicted pixel value. For each pixel in this 4x4 image block, avg is used for prediction; the predicted pixel matrix obtained after prediction is as follows:
[0143]
[0144] After obtaining the above-mentioned predicted pixel matrix, any pixel value in the matrix can be taken as the average value.
[0145] Step d3, determining a prediction value of each pixel in the current coding block based on the low-frequency component factor and the average value.
[0146] Specifically, after obtaining the low-frequency component factor and the average value, the low-frequency component factor and the average value may be added, and the value obtained after the addition is used as the predicted value of each pixel in the current coding block.
[0147] Step c12: generating the predicted pixel matrix based on the predicted value of each pixel.
[0148] Specifically, after the predicted value of each pixel is obtained, a predicted pixel matrix can be generated according to the predicted values of all pixels. For example, when the predicted value of each pixel is determined to be N through the above step d3, the predicted pixel matrix is as follows:
[0149]
[0150] In this embodiment, a video compression method is also provided, which can be used in an encoder. The process of the video compression method includes the following steps a1 to a4:
[0151] Step a1, segmenting each image frame in the image frame sequence to be compressed to obtain multiple coding blocks.
[0152] Specifically, the sequence of image frames to be compressed includes multiple image frames, and any image frame among the multiple image frames is segmented into blocks to obtain multiple coding blocks. More specifically, in the block segmentation process, the block size to be segmented is first determined, such as a block of 8x8 or 16x16 pixels; then, according to the block size, the image frame is segmented into multiple coding blocks according to a preset segmentation rule. Each coding block can be understood as a small block area segmented out of the image frame.
[0153] Step a2: for any one coding block among the multiple coding blocks, calculate a first quantity of the first factor and a second quantity of the second factor based on the coding block.
[0154] Among them, the first factor is used to characterize the high-frequency component factor in the coding block, which can be understood as the AC transformation coefficient; the second factor is used to characterize the non-zero high-frequency component factor in the quantization transformation coefficient matrix corresponding to the coding block.
[0155] In some embodiments, the above step a2 includes steps a21-a2
[0156] Step a21, predicting the pixel matrix of the current coding block to obtain a residual matrix in the spatial domain.
[0157] Specifically, the current coding block is any one of the multiple coding blocks; each pixel in the pixel matrix can be predicted by intra-frame prediction or inter-frame prediction to obtain a residual matrix. More specifically, in the prediction process, neighboring pixel prediction can be used, that is, the value of the current pixel is estimated by the values of its surrounding pixels. Commonly used methods include pixel values in horizontal, vertical, and diagonal directions, etc.; linear prediction can also be used, that is, the linear relationship between the current pixel and its adjacent pixels is used for prediction. Methods such as linear regression can be used to fit the relationship between pixels to predict the value of the current pixel.
[0158] Step a22, converting the residual matrix in the spatial domain into a transformation coefficient matrix in the frequency domain.
[0159] The transformation coefficient matrix includes high-frequency component factors and low-frequency component factors.
[0160] Specifically, the residual matrix in the spatial domain can be converted into a transform coefficient matrix in the frequency domain using discrete cosine transform (DCT) and discrete sine transform (DST).
[0161] Step a23, using a first quantization parameter corresponding to the high-frequency component factor, quantize the transform coefficient matrix to generate a first quantized transform coefficient matrix.
[0162] Specifically, the transform coefficient matrix is quantized using the first quantization parameter corresponding to the AC transform coefficient (i.e., the high-frequency component factor) in the predefined quantization table to obtain a first quantized transform coefficient matrix, wherein the DC transform coefficients in the first quantized transform coefficient matrix are not quantized.
[0163] Step a24: determining a second number of second factors based on the first quantized transform coefficient matrix.
[0164] Specifically, the number of non-zero AC transform coefficients (ie, high-frequency component factors) in the first quantized transform coefficient matrix obtained through quantization processing is determined, ie, the second number.
[0165] Step a3: generating a quantized transform coefficient matrix based on the first number and the second number.
[0166] In some embodiments, the above step a3 includes steps a31 and a32:
[0167] Step a31, using the first quantity and the second quantity, determine the quantization parameter of the third factor; the third factor is used to characterize the low-frequency component factor, that is, the DC conversion coefficient.
[0168] In some embodiments, the above step a31 includes steps a311 to a312.
[0169] Step a311: determine a target frequency based on the first number and the second number.
[0170] Step a312: If the target frequency is less than a preset frequency threshold, the quantization parameter of the third factor is adjusted to the target quantization parameter.
[0171] Specifically, the specific implementation steps of the above steps a311 to a312 can refer to steps 301 to 302 of the above embodiment, and will not be repeated here.
[0172] Step a32, quantizing the DC transform coefficients in the first quantized transform coefficient matrix using the quantization parameter of the third factor to generate a quantized transform coefficient matrix.
[0173] Step a4, compressing the image frame sequence to be compressed based on the quantization transformation coefficient matrix to obtain a compressed video.
[0174] In some embodiments, the above step a4 includes steps a41 to a43:
[0175] Step a41, performing encoding processing on the multiple quantization transformation coefficient matrices corresponding to the multiple coding blocks one by one, to obtain multiple encoding processing results;
[0176] Step a42, combining the plurality of encoding processing results to obtain a first image frame corresponding to a target image frame; the target image frame is any one of the plurality of image frames in the image frame sequence to be compressed;
[0177] Step a43, combining multiple first image frames corresponding to the multiple image frames to obtain a compressed video.
[0178] Corresponding to the implementation of the above video decompression method, the embodiment of the present disclosure also provides a video decompression device for executing the above Figures 1 to 5 The video decompression method described in any of the embodiments shown in the figure. Figure 6 As shown, the video decompression device includes:
[0179] An image segmentation module is used to segment each image frame in the image frame sequence to be decompressed to obtain multiple decoding blocks;
[0180] A quantity determination module, configured to calculate, for any one of the plurality of decoding blocks, a first quantity of a first factor and a second quantity of a second factor based on the decoding block; wherein the first factor is used to characterize a high-frequency component factor in the decoding block, and the second factor is used to characterize a non-zero high-frequency component factor in a quantized transform coefficient matrix corresponding to the decoding block;
[0181] A transformation coefficient matrix generation module, used to generate a transformation coefficient matrix based on the first number and the second number; the transformation coefficient matrix is used to characterize the energy distribution of the corresponding image frame under different frequency components;
[0182] The video decompression module is used to decompress the image frame sequence to be decompressed based on the transformation coefficient matrix to obtain a decompressed video.
[0183] Optionally, the transform coefficient matrix generation module is also used to: determine a quantization parameter of a third factor based on the first quantity and the second quantity; the third factor is used to characterize a low-frequency component factor in the quantized transform coefficient matrix; and perform inverse quantization processing on the quantized transform coefficient matrix based on the quantization parameter to generate the transform coefficient matrix.
[0184] Optionally, the transform coefficient matrix generation module is further used to: determine a target frequency based on the first number and the second number; if the target frequency is less than a preset frequency threshold, adjust the quantization parameter of the third factor to the target quantization parameter.
[0185] Optionally, the transform coefficient matrix generation module is further used to: modify a predefined quantization table using the quantization parameter; and perform inverse quantization processing on the quantized transform coefficient matrix based on the modified quantization table to obtain a transform coefficient matrix in the frequency domain.
[0186] Optionally, the video compression module is also used to: perform inverse transformation processing on the transformation coefficient matrix to obtain a residual matrix in the spatial domain; combine the residual matrix with corresponding reference pixel values to obtain image data corresponding to the decoding block; reconstruct multiple image data corresponding one-to-one to the multiple decoding blocks to obtain target image frames; restore the multiple target image frames in a preset arrangement order to obtain a decompressed video.
[0187] The video decompression device provided by the above-mentioned embodiment of the present disclosure and the video decompression method provided by the embodiment of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.
[0188] Corresponding to the implementation of the above video compression method, the embodiment of the present disclosure also provides a video compression device for executing the video compression method described in the above embodiment. Figure 7 As shown, the video compression device comprises:
[0189] An image segmentation module is used to segment each image frame in the image frame sequence to be compressed to obtain multiple coding blocks;
[0190] A quantity determination module, configured to calculate, for any one of the plurality of coding blocks, a first quantity of a first factor and a second quantity of a second factor based on the coding block; wherein the first factor is used to characterize a high-frequency component factor in the coding block, and the second factor is used to characterize a non-zero high-frequency component factor in a quantized transform coefficient matrix corresponding to the coding block;
[0191] A quantized transform coefficient matrix generation module, configured to generate a quantized transform coefficient matrix based on the first number and the second number;
[0192] The video compression module is used to compress the image frame sequence to be compressed based on the quantization transformation coefficient matrix to obtain a compressed video.
[0193] The video compression device provided by the above-mentioned embodiment of the present disclosure and the video compression method provided by the embodiment of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.
[0194] The disclosed embodiment also provides an electronic device to perform the above-mentioned video compression method or video decompression method. Figure 8 , which shows a schematic diagram of an electronic device provided by some embodiments of the present disclosure. Figure 8As shown, the electronic device 8 includes: a processor 800, a memory 801, a bus 802 and a communication interface 803, wherein the processor 800, the communication interface 803 and the memory 801 are connected via the bus 802; the memory 801 stores a computer program that can be run on the processor 800, and the processor 800 executes the aforementioned Figures 1 to 5 A video compression method or a video decompression method is provided in any of the illustrated embodiments.
[0195] The memory 801 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 803 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0196] The bus 802 may be an ISA bus, a PCI bus, or an EISA bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The memory 801 is used to store programs. After receiving the execution instruction, the processor 800 executes the program. Figures 1 to 5 The video compression method or video decompression method disclosed in any of the illustrated embodiments may be applied to the processor 800 or implemented by the processor 800 .
[0197] The processor 800 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 800 or the instruction in the form of software. The above processor 800 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 801, and the processor 800 reads the information in the memory 801 and completes the steps of the above method in combination with its hardware.
[0198] The electronic device provided by the embodiment of the present disclosure and the video compression method or video decompression method provided by the embodiment of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by them.
[0199] The present disclosure also provides a computer-readable storage medium corresponding to the video compression method or video decompression method provided in the above embodiments. Fig. 9 The computer-readable storage medium shown is a CD 30 on which a computer program (ie, a program product) is stored. When the computer program is run by a processor, the video compression method or video decompression method provided by any of the aforementioned embodiments will be executed.
[0200] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical or magnetic storage media, which are not listed here one by one.
[0201] The computer-readable storage medium provided by the above-mentioned embodiments of the present disclosure and the video compression method provided by the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the application programs stored therein.
[0202] It should be noted that:
[0203] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present disclosure can be practiced without these specific details. In some instances, well-known structures and technologies are not shown in detail so as not to obscure the understanding of this description.
[0204] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present disclosure, the various features of the present disclosure are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following schematic diagram: the claimed disclosure requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, the inventive aspects lie in less than all the features of the single embodiment disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present disclosure.
[0205] In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of this disclosure and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.
[0206] The above is only a preferred specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A video decompression method, characterized in that: The method comprises: Segment each image frame in the image frame sequence to be decompressed to obtain a plurality of decoding blocks; For any one of the plurality of decoding blocks, a first number of first factors and a second number of second factors are calculated based on the decoding block; wherein the first factor is used to characterize the high-frequency component factors in the decoding block, and the second factor is used to characterize the high-frequency component factors that are not zero in the quantized transform coefficient matrix corresponding to the decoding block; Based on the first number and the second number, a transformation coefficient matrix is generated; the transformation coefficient matrix is used to characterize the energy distribution of the image frame under different frequency components; The to-be-decompressed image frame sequence is decompressed based on the transformation coefficient matrix to obtain a decompressed video.
2. The method according to claim 1, characterized in that The step of generating a transform coefficient matrix based on the first number and the second number comprises: Determining a quantization parameter of a third factor based on the first number and the second number; the third factor is used to characterize a low-frequency component factor in the quantized transform coefficient matrix; The quantized transform coefficient matrix is dequantized based on the quantization parameter to generate the transform coefficient matrix.
3. The method according to claim 2, characterized in that The determining a quantization parameter of a third factor based on the first quantity and the second quantity includes: determining a target frequency based on the first number and the second number; If the target frequency is less than a preset frequency threshold, the quantization parameter of the third factor is adjusted to a target quantization parameter.
4. The method according to claim 2 or 3, characterized in that: The step of performing inverse quantization processing on the quantized transform coefficient matrix based on the quantization parameter to generate the transform coefficient matrix comprises: Modifying a predefined quantization table using the quantization parameter; The quantized transform coefficient matrix is dequantized based on the modified quantization table to obtain a transform coefficient matrix in the frequency domain.
5. The method according to claim 1, characterized in that The decompressing the to-be-decompressed image frame sequence based on the transformation coefficient matrix to obtain a decompressed video includes: Performing inverse transformation processing on the transformation coefficient matrix to obtain a residual matrix in the spatial domain; Combining the residual matrix with corresponding reference pixel values to obtain image data corresponding to the decoded block; Reconstructing a plurality of image data corresponding to the plurality of decoding blocks one by one to obtain a target image frame; The multiple target image frames are restored according to a preset arrangement order to obtain a decompressed video.
6. A video compression method, characterized in that: The method comprises: Segment each image frame in the image frame sequence to be compressed to obtain a plurality of coding blocks; For any one of the plurality of coding blocks, a first number of first factors and a second number of second factors are calculated based on the coding block; wherein the first factor is used to characterize the high-frequency component factor in the coding block, and the second factor is used to characterize the high-frequency component factor that is not zero in the quantized transform coefficient matrix corresponding to the coding block; generating a quantized transform coefficient matrix based on the first number and the second number; The image frame sequence to be compressed is compressed based on the quantization transformation coefficient matrix to obtain a compressed video.
7. A video decompression device, characterized in that: The device comprises: An image segmentation module is used to segment each image frame in the image frame sequence to be decompressed to obtain multiple decoding blocks; A quantity determination module, configured to calculate, for any one of the plurality of decoding blocks, a first quantity of a first factor and a second quantity of a second factor based on the decoding block; wherein the first factor is used to characterize a high-frequency component factor in the decoding block, and the second factor is used to characterize a non-zero high-frequency component factor in a quantized transform coefficient matrix corresponding to the decoding block; A transformation coefficient matrix generation module, used to generate a transformation coefficient matrix based on the first number and the second number; the transformation coefficient matrix is used to characterize the energy distribution of the corresponding image frame under different frequency components; The video decompression module is used to decompress the image frame sequence to be decompressed based on the transformation coefficient matrix to obtain a decompressed video.
8. A video compression device, characterized in that: The device comprises: An image segmentation module is used to segment each image frame in the image frame sequence to be compressed to obtain multiple coding blocks; A quantity determination module, configured to calculate, for any one of the plurality of coding blocks, a first quantity of a first factor and a second quantity of a second factor based on the coding block; wherein the first factor is used to characterize a high-frequency component factor in the coding block, and the second factor is used to characterize a non-zero high-frequency component factor in a quantized transform coefficient matrix corresponding to the coding block; A quantized transform coefficient matrix generation module, configured to generate a quantized transform coefficient matrix based on the first number and the second number; The video compression module is used to compress the image frame sequence to be compressed based on the quantization transformation coefficient matrix to obtain a compressed video.
9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 6 by executing the computer instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 6.
