CN114025166A - Video compression method, electronic device and computer-readable storage medium - Google Patents

Video compression method, electronic device and computer-readable storage medium Download PDF

Info

Publication number
CN114025166A
CN114025166A CN202111299542.XA CN202111299542A CN114025166A CN 114025166 A CN114025166 A CN 114025166A CN 202111299542 A CN202111299542 A CN 202111299542A CN 114025166 A CN114025166 A CN 114025166A
Authority
CN
China
Prior art keywords
frame
frames
video
reference frame
processed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111299542.XA
Other languages
Chinese (zh)
Inventor
唐聃
解峥
蔡红亮
刘斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu University of Information Technology
Original Assignee
Chengdu University of Information Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu University of Information Technology filed Critical Chengdu University of Information Technology
Priority to CN202111299542.XA priority Critical patent/CN114025166A/en
Publication of CN114025166A publication Critical patent/CN114025166A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/136Incoming video signal characteristics or properties
    • H04N19/137Motion inside a coding unit, e.g. average field, frame or block difference
    • H04N19/139Analysis of motion vectors, e.g. their magnitude, direction, variance or reliability
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/184Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being bits, e.g. of the compressed video stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/90Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using coding techniques not provided for in groups H04N19/10-H04N19/85, e.g. fractals
    • H04N19/91Entropy coding, e.g. variable length coding [VLC] or arithmetic coding

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The embodiment of the invention provides a video compression method, electronic equipment and a computer readable storage medium, belonging to the technical field of digital image processing, wherein the method comprises the following steps: reading a video to be compressed into multiple frames of ordered video frames, transforming and macro-block dividing each frame of video frames to obtain multiple frames of frames to be processed, dividing the multiple frames of frames to be processed into multiple image groups, determining a reference frame from each image group, further taking a macro block as a motion unit for each image group, estimating motion vectors between a reference frame and the rest frames of frames to be processed by adopting a motion estimation algorithm, coding each motion vector to obtain multiple bit streams, coding each reference frame according to the ratio of each pixel value to obtain a first code table of the reference frame, thus obtaining a first compressed file, converting the change between the images in the video into the motion vectors, and coding the motion vectors and the reference frames, thereby improving the video quality of the compressed file and reducing the size of the compressed file.

Description

Video compression method, electronic device and computer-readable storage medium
Technical Field
The present invention relates to the field of digital image processing, and in particular, to a video compression method, an electronic device, and a computer-readable storage medium.
Background
Video processing is a special case of digital image processing, where the processed signal is a video file or a video stream. Video processing is widely used in televisions, Digital Versatile Disks (DVDs), video players, and the like. In the case of long-distance processing, the bit error rate of the digital video signal can still be kept low, but compared with the analog video, the transmission of the digital video requires higher transmission bandwidth and larger storage capacity. Therefore, video compression is usually used to reduce the amount of data to be transmitted.
A digital analog video sequence may contain up to 165mbps of data, in order to reduce the media overhead of distributing such sequences, by employing a video compression method of: reducing color nuances in images, reducing resolution relative to prevailing light intensity, removing spatial redundancy or correlation between adjacent pixel values, and comparing adjacent images and removing unchanged detail between adjacent frames in an image sequence. However, these methods have poor video quality in the case where the compressed file of the video is small enough.
Disclosure of Invention
In view of the foregoing, it is an object of the present invention to provide a video compression method, an electronic device and a computer-readable storage medium, which can improve the problem of poor video quality when the existing video compression method compresses video to the minimum.
In order to achieve the above object, the embodiments of the present invention adopt the following technical solutions.
In a first aspect, the present invention provides a video compression method, which adopts the following technical solutions.
A method of video compression, the method comprising:
reading a video to be compressed into a plurality of frames of ordered video frames, and converting and dividing macro blocks of each frame of video frames to obtain a plurality of frames to be processed, wherein each frame of frames to be processed comprises a plurality of macro blocks;
dividing a plurality of frames to be processed into a plurality of image groups, and determining a reference frame from each image group, wherein each image group comprises a plurality of continuous frames to be processed;
for each image group, taking a macro block as a motion unit, estimating motion vectors between the reference frame and each frame to be processed which is remained in each frame by adopting a motion estimation algorithm, and coding each motion vector to obtain a plurality of bit streams;
scanning each frame of the reference frame to obtain a ratio of each pixel value in each frame of the reference frame, and coding each pixel value of each frame of the reference frame according to the ratio to obtain a first code table of each frame of the reference frame;
and obtaining a first compressed file according to each first code table and each bit stream.
In one possible embodiment, the method further comprises:
scanning each frame of the reference frame by adopting an embedded wavelet zero tree algorithm according to a preset sequence to obtain a pixel value of each pixel of the reference frame, and constructing a zero tree of each frame of the reference frame according to the pixel value;
and coding according to the zero tree to obtain a second code table of each frame of the reference frame, and obtaining a second compressed file according to each second code table.
In a possible implementation, the step of coding according to the zero tree to obtain a second code table of the reference frame for each frame includes:
and calculating a plurality of intervals corresponding to each frame of the reference frame by adopting arithmetic coding based on the zero tree, and selecting a pixel value in each interval for coding to obtain a second code table of each frame of the reference frame.
In a possible implementation, the motion estimation algorithm includes a four-step search algorithm, and the step of estimating a motion vector between the reference frame and the frame to be processed in each frame by using a motion estimation algorithm with a macro block as a motion unit for each of the image groups includes:
processing each frame to be processed by adopting a four-step search method aiming at each image group to obtain an optimal matching point corresponding to each macro block of each frame to be processed;
and taking the reference frame as a reference, and obtaining a motion vector of each macro block of each frame to be processed relative to the reference frame according to the best matching point of each macro block.
In a possible implementation manner, the step of obtaining a motion vector of each macroblock of the frame to be processed relative to the reference frame according to the best matching point of each macroblock by using the reference frame as a reference includes:
searching a matching position consistent with the optimal matching point and a corresponding macro block in the reference frame according to the optimal matching point of each macro block;
and obtaining a motion vector of each macro block according to the position relationship between the macro block and the optimal matching point in each frame to be processed and the position relationship between the macro block and the matching position in the reference frame.
In a possible implementation manner, the step of transforming and macro-block dividing the video frame of each frame to obtain multiple frames to be processed includes:
performing transform processing on each frame of the video frame by adopting discrete wavelet transform;
and carrying out macro block division on each frame of the video frame after the conversion processing according to a preset size to obtain a frame to be processed comprising a plurality of macro blocks.
In a possible implementation manner, the step of encoding the pixel values of the reference frames according to the ratio to obtain a first code table of each frame of the reference frames includes:
according to the ratio of each pixel value, assigning unique code words with different lengths to each pixel value; the ratio of the pixel values is in inverse proportion to the length of the code word corresponding to the pixel values;
and recording the code words and the pixel values in a corresponding relationship to obtain a first code table.
In a possible implementation, the step of encoding each of the motion vectors to obtain a plurality of bit streams includes:
and performing Huffman coding on each motion vector to obtain a plurality of bit streams.
In a second aspect, the present invention provides an electronic device, which adopts the following technical solutions.
An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor to implement a video compression method as described in the first aspect.
In a third aspect, the present invention provides a computer-readable storage medium, which adopts the following technical solutions.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the video compression method as claimed in the first aspect.
The video compression method provided by the embodiment of the invention comprises the steps of converting and macro-block dividing a plurality of frames of video to be compressed, dividing the frames into a plurality of image groups, selecting a reference frame from each image group, carrying out motion estimation based on the reference frame to obtain motion vectors of other frames to be processed in the image groups relative to the reference frame, coding the motion vectors to obtain bit streams, coding each frame of reference frame according to each pixel value to obtain a first code table, obtaining a first compressed file according to the bit streams and the first code table, converting changes among images in the video into the motion vectors for measuring, coding the motion vectors, coding the reference frames, describing the changes of the video frames by the motion vectors and the reference frames to compress the subsequent video, and describing the changes of the images by the motion vectors, so that the quality of the video can be ensured to a certain degree while the video is compressed, and the problem that the video quality is poor when the video is compressed to the minimum by the existing video compression method is further improved.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 shows a block schematic diagram of an electronic device provided by an embodiment of the present invention.
Fig. 2 is a block diagram of a video compression system according to an embodiment of the present invention.
Fig. 3 is a schematic flow chart of a video compression method according to an embodiment of the present invention.
Fig. 4 is a schematic flow chart of a video compression method according to an embodiment of the present invention.
Fig. 5 shows a schematic flow diagram of a part of the sub-steps of step S101 in fig. 3 or 4.
Fig. 6 shows a schematic flow diagram of a part of the sub-steps of step S103 in fig. 3 or 4.
Fig. 7 shows a schematic flow diagram of part of the sub-steps of S103-2 in fig. 6.
Fig. 8 shows a comparison of a reference frame and a frame to be processed.
Fig. 9 shows a schematic flow diagram of a part of the sub-steps of step S104 in fig. 3 or 4.
Fig. 10 is a block diagram of a video compression apparatus according to an embodiment of the present invention.
Icon: 100-an electronic device; 110-a memory; 120-a processor; 130-a communication module; 140-a video compression system; 150-a video compression device; 160-a camera; 170-a pre-processing module; 180-an inter-frame compression module; 190-intra compression module.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present invention, belong to the protection scope of the present invention.
It is noted that relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
With the development of the internet, the application of video platforms is more and more common in people's entertainment life, and the proportion of video data on the network in network data is also increased year by year, which makes great challenge to video compression.
The video compression methods used before are H264 and H265, the updated standard H266 will be published, and the new standard has more complicated coding while having more excellent compression ratio. These conventional compression methods all use the same framework, such as motion compensated prediction, block-based transforms, and artificially designed entropy coding. And the intensive research of these conventional frameworks is also approaching saturation.
At present, another video compression method based on skipping frames with small information amount in the fames sequence mainly includes: and comparing the two frames on the subframe level, judging which frame is more important to the overall video quality perceived by the eyes of the user, namely obtaining the information content of each frame, and skipping the frames with small information content to compress the video.
Although these methods can make the compressed file small enough, the quality of the compressed and reconstructed video is poor.
In view of the above, the present invention provides a video compression method, an electronic device, and a computer-readable storage medium.
Fig. 1 is a block diagram of an electronic device 100. The electronic device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, the processor 120, and the communication module 130 are electrically connected to each other directly or indirectly to enable data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines.
The memory 110 is used to store programs or data. The Memory 110 may be, but is not limited to, a Random Access Memory 110 (RAM), a Read Only Memory 110 (ROM), a Programmable Read Only Memory 110 (PROM), an Erasable Read Only Memory 110 (EPROM), an electrically Erasable Read Only Memory 110 (EEPROM), and the like. Also, the memory 110 may be a computer-readable storage medium.
The processor 120 is used to read/write data, computer programs, or machine executable instructions stored in the memory 110 and perform corresponding functions. Also, the processor 120 may execute a computer program or machine executable instructions to implement the video compression method.
The communication module 130 is used for establishing a communication connection between the electronic device 100 and other communication terminals through a network, and for transceiving data through the network.
It should be understood that the configuration shown in fig. 1 is merely a schematic diagram of the configuration of the electronic device 100, and that the electronic device 100 may include more or fewer components than shown in fig. 1, or have a different configuration than shown in fig. 1. The components shown in fig. 1 may be implemented in hardware, software, or a combination thereof.
Specifically, the electronic device 100 may be, but is not limited to, a computer, a mobile phone, an IPad, a server, a notebook computer, a mobile internet device, and the like.
Referring to fig. 2, the video compression method provided by the present invention can be applied to a video compression system 140, where the video compression system 140 includes a video compression device 150 and a camera 160, and the camera 160 and the video compression device 150 are connected through a network communication. The video compression apparatus 150 may be any one of the electronic devices 100 described above.
In an embodiment, referring to fig. 3, fig. 3 is a flowchart illustrating a video compression method according to the present invention. This embodiment is mainly illustrated by applying the method to the video compression apparatus 150 in fig. 2. In this embodiment, the method may include the following steps.
S101, reading a video to be compressed into a plurality of frames of ordered video frames, and performing conversion and macro block division on each frame of video frame to obtain a plurality of frames to be processed.
Wherein each frame to be processed comprises a plurality of macro blocks.
Specifically, the camera 160 sends the recorded video to be compressed to the video compression device 150, and the video compression device 150 reads the video to be compressed into multiple frames of ordered video frames, and performs transformation and macroblock division on each frame of video frame to obtain multiple frames of frames to be processed.
S102, dividing a plurality of frames to be processed into a plurality of image groups, and determining a reference frame from each image group.
Wherein each image group comprises a plurality of continuous frames to be processed.
Specifically, the video compression apparatus 150 divides a plurality of frames to be processed into a plurality of image groups, and determines a reference frame from each image group. The number of frames to be processed in the plurality of image groups may be uniform or non-uniform. The reference frame may be any frame to be processed in the group of images.
For example, 20 frames to be processed are total, and an image group is divided into five frames, so that 4 image groups can be obtained, the first image group includes a first frame to be processed to a fifth frame to be processed, the second image group includes a sixth frame to be processed to a tenth frame to be processed, the third image group includes an eleventh frame to a fifteenth frame to be processed, and the fourth image group includes a sixteenth frame to a twentieth frame to be processed.
S103, aiming at each image group, taking the macro block as a motion unit, estimating motion vectors between the reference frame and each frame to be processed of the rest frames by adopting a motion estimation algorithm, and coding each motion vector to obtain a plurality of bit streams.
Specifically, for each image group, the video compression value yellow paper takes a macro block as a motion unit, a motion estimation algorithm is adopted to estimate a motion vector between a reference frame and each frame to be processed remaining in the group, and each motion vector is encoded to obtain a bit stream corresponding to the motion vector.
For example, each frame to be processed is divided into 4 macroblocks, each macroblock has one motion vector with respect to the reference frame, and each frame to be processed has 4 motion vectors. If part of the macro blocks do not have motion, the motion vector is a zero vector.
S104, scanning each frame of reference frame to obtain the ratio of each pixel value in each frame of reference frame, and coding each pixel value of each reference frame according to the ratio to obtain a first code table of each frame of reference frame.
Specifically, the video compression apparatus 150 scans the reference frame, reads a plurality of pixel values of the reference frame, obtains a ratio of each pixel value according to the pixel values, and encodes each reference frame according to the ratio of each pixel value to obtain a first code table of each frame of the reference frame. That is, if there are 4 frames of reference frames, there are 4 first code tables.
S105, obtaining a first compressed file according to the first code tables and the bit streams.
Specifically, the first compressed file obtained by the video compression apparatus 150 includes a first code table and bit streams.
In the video compression method, a plurality of frames of video to be compressed are converted and macro-block divided, and then divided into a plurality of image groups, a reference frame is selected from each image group, motion estimation is carried out on the basis of the reference frame, motion vectors of other frames to be processed in the image groups relative to the reference frame are obtained, the motion vectors are coded to obtain bit streams, each frame of reference frame is coded according to each pixel value to obtain a first code table, a first compression file is obtained according to the bit streams and the first code table, namely, changes among the images in the video are converted into the motion vectors for measurement, the motion vectors are coded, the reference frame is coded, and the bit streams corresponding to the motion vectors and the first code table corresponding to the reference frame can describe video with compression, so that video compression is realized.
Moreover, the motion vector can describe the change of the image, so that the quality of the video can be ensured to a certain extent while the video is compressed, and the problem that the video quality is poor when the video is compressed to the minimum by the conventional video compression method is solved.
In the video compression method in which the inter-frame compression is performed in S101 to S105, the inter-frame transformation can be described by using a motion vector method, and the obtained first compressed file is an inter-frame compressed file. To further improve the quality of video compression, referring to fig. 4, fig. 4 is another flow chart of the video compression method provided by the present invention, which includes S106 and S107. S106 may be executed after S102 in parallel with S103, may be executed in parallel with any one of steps after S102, and may be executed after S105.
S106, scanning each frame of reference frame according to a preset sequence by adopting an embedded wavelet zero tree algorithm to obtain a pixel value of each pixel of the reference frame, and constructing a zero tree of each frame of reference frame according to the pixel values.
Specifically, the video compression apparatus 150 scans each frame of reference frames according to a preset sequence by using an embedded wavelet zero tree algorithm to obtain a pixel value of each pixel of the reference frames, and constructs a zero tree of each frame of reference frames according to the pixel values.
And S107, coding according to the zero tree to obtain a second code table of each frame of reference frame, and obtaining a second compressed file according to each second code table.
Specifically, the video compression apparatus 150 performs encoding according to the zero tree to obtain a second code table of the reference frame, and further obtain a second compressed file, where the second compressed file includes each second code table.
The embedded wavelet zero-tree algorithm realizes the embedding function of image coding by utilizing the characteristics of wavelet coefficients, and mainly comprises zero-tree prediction, coding of a significant graph by using a zero-tree structure and successive approximation quantization.
Steps S106 to S107 are performed to intra-code the reference frame and compress the reference frame more finely, so as to improve the compression quality of the reference frame, which is helpful for improving the quality of video compression.
For S101, in an embodiment, referring to fig. 5, specifically, a plurality of frames to be processed can be obtained by performing transform and macroblock partition on each frame of a video frame through the following steps.
S101-1, performing transformation processing on each frame of video frame by adopting discrete wavelet transformation.
Specifically, each frame of video is subjected to multi-scale refinement by utilizing a telescopic translation operation so as to achieve the purpose that the video frame is subdivided in time at a high frequency and is subdivided in frequency at a low frequency. And discretizing the multi-scale refined video frame by using a dyadic wavelet (namely, a wavelet transform function using 2 to the integral power).
S101-2, carrying out macro block division on each frame of video frame after conversion processing according to a preset size to obtain a frame to be processed comprising a plurality of macro blocks.
Specifically, the preset size may be 16 × 16, that is, each frame of the video frame is divided into a plurality of macroblocks by the size of 16 × 16, and the number of macroblocks in each frame of the video frame is obtained by dividing the size of the video frame by 16 × 16, that is, the size of each macroblock is 16 × 16.
In this embodiment, the motion estimation algorithm in S103 may be a four-step search method. On this basis, with reference to fig. 6 for S103, a motion vector between the reference frame and each of the remaining frames to be processed is estimated by using a motion estimation algorithm with a macroblock as a motion unit for each image group through the following steps.
S103-1, processing each frame to be processed by adopting a four-step search method aiming at each image group to obtain the optimal matching point corresponding to each macro block of each frame to be processed.
S103-2, taking the reference frame as a reference, and obtaining a motion vector of each macro block of each frame to be processed relative to the reference frame according to the best matching point of each macro block.
For S103-1, specifically, for each macro block in the frame to be processed, the size of the macro block is 16 × 16, first, with a step size of 5 × 5 (25 points in total), a search is started from a search window of 5 × 5 in the macro block, in each step size, a center point in the search window is compared with eight points around the search window, a minimum difference Sum (SAD) of each of the nine points is calculated, the point with the minimum difference sum is selected as a center point of the next search, and the minimum difference sum of the nine points in the next search is obtained in the same method.
And after the minimum difference sum is obtained in each search, if the point with the minimum difference sum is the central point, the step size is changed to 3 x 3, and the search with the step size of 3 x 3 is performed. In the searching with the step length of 3 x 3, four points around the minimum difference and the minimum central point are calculated to obtain the minimum difference sum of each point, and the point with the minimum difference sum is the best matching point. The best matching point is the best matching point of the macroblock.
Repeating the above steps to obtain the best matching point of each macro block.
Referring to fig. 7 for S103-2, a schematic flow chart of a part of sub-steps of S103-2 is shown, which includes the following steps.
S201, according to the best matching point of each macro block, a matching position consistent with the best matching point and a corresponding macro block are searched out in the reference frame.
S202, obtaining the motion vector of each macro block according to the position relation between the macro block in each frame to be processed and the best matching point and the position relation between the macro block in the reference frame and the matching position.
It should be understood that the motion vector of the macro block may be the motion vector of a small object within the macro block, or may be the motion of the macro block.
For example, referring to fig. 8, the left image is a reference frame, the right image is a frame to be processed, the white square block in the figure is the best matching point of a macroblock, and the white circular sphere is the moving block in the macroblock. And obtaining the motion vector of each macro block of the frame to be processed by contrasting the reference frame.
In S103, encoding each motion vector may obtain a plurality of bit streams as follows: and performing Huffman coding on each motion vector to obtain a plurality of bit streams. That is, huffman coding is used in the present embodiment, and other coding methods may be used in other embodiments.
Further, with reference to fig. 9, in S104, the following steps are performed to encode each pixel value of each reference frame according to the ratio, thereby obtaining a first code table for each frame of the reference frame.
S104-1, according to the ratio of each pixel value, assigning unique code words with different lengths to each pixel value.
The ratio of the pixel values is inversely proportional to the length of the code word corresponding to the pixel values.
S104-2, recording the code words and the pixel values in a corresponding relation to obtain a first code table.
By the method, the pixel value with large ratio can be coded by the code word with shorter length, thereby reducing the size of the compressed file without influencing the video quality.
For S106, in an embodiment, the following may be specifically mentioned:
the first step is to scan in the counterclockwise direction from the top left corner of the frame to be processed, read the pixel value of each pixel, and take a pixel value at the top left corner of the frame to be processed as a root node, and take the secondary high-frequency signal related to the pixel value as its sub-tree to perform construction operation.
Wherein the second highest order high frequency signal refers to a pixel value which is smaller but closest in pixel value.
In other embodiments, the root node and the scanning order may be set according to actual conditions.
And secondly, scanning the tree constructed in the first step according to a preset sequence, wherein each time of scanning obtains one datum (pixel value), and the datum scanned at the previous time is more important than the datum scanned at the next time so as to divide the datum.
Whether the data is important or not is compared with a set threshold value in an EZW algorithm (namely an embedded wavelet zero tree algorithm), if the data is larger than the threshold value, the data is important data, and otherwise, the data is unimportant data.
A group of wavelet-transformed frames to be processed form a tree structure (namely a zero tree) according to the frequency bands from low to high, and the root of the tree is a node of the lowest-frequency sub-band (with the minimum pixel value).
On this basis, in S107, the encoding is performed according to the zero tree, and the step of obtaining the second code table of the reference frame of each frame may be:
and calculating a plurality of intervals corresponding to each frame of reference frame by adopting arithmetic coding based on the zero tree, and selecting a pixel value in each interval for coding to obtain a second code table of each frame of reference frame.
Arithmetic coding is one of the main algorithms for image compression, and is a lossless data compression method and also an entropy coding method.
The video compression method provided by the invention firstly adopts an interframe compression method to convert the conversion among video frames into motion vectors relative to a reference frame, and codes the reference frame and the motion vectors to obtain a first compressed file, so that the size of the compressed file is reduced, and the video quality of the compressed file can be ensured to a certain extent when interframe compression is carried out. And the embedded wavelet zero tree coding algorithm is adopted to perform intraframe compression on each reference frame, namely the reference frames are compressed more finely to obtain a second compressed file, so that the size of the compressed file can be reduced according to the first compressed file and the second compressed file, and the video quality can be improved as much as possible.
It should be understood that although the various steps in the flowcharts of fig. 3-9 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 3-9 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In order to execute the corresponding steps in the above embodiments and various possible manners, an implementation manner of the video compression apparatus 150 is given below, and optionally, the video compression apparatus 150 may adopt the device structure of the electronic device 100 shown in the above figures. Further, please refer to fig. 10, which is a functional block diagram of a video compression apparatus 150 according to an embodiment of the present invention. It should be noted that the basic principle and the technical effects of the video compression apparatus 150 provided in the present embodiment are the same as those of the above embodiments, and for the sake of brief description, no part of the present embodiment is mentioned, and corresponding contents in the above embodiments may be referred to. The compression device includes: a pre-processing module 170, an intra-frame compression module 190, and an inter-frame compression module 180.
The pre-processing module 170 is configured to read a video to be compressed into multiple frames of ordered video frames, perform transform and macroblock division on each frame of video frame to obtain multiple frames of frames to be processed, divide the multiple frames of frames to be processed into multiple image groups, and determine a reference frame from each image group.
Each frame to be processed comprises a plurality of macro blocks, and each image group comprises a plurality of continuous frames to be processed.
And the inter-frame compression module 180 is configured to estimate, for each image group, a motion vector between the reference frame and each of the remaining frames to be processed by using a motion estimation algorithm with a macro block as a motion unit, and encode each motion vector to obtain a plurality of bit streams.
The inter-frame compression module 180 is further configured to scan each frame of reference frame, obtain a ratio of each pixel value in each frame of reference frame, encode each pixel value of each reference frame according to the ratio, obtain a first code table of each frame of reference frame, and obtain a first compressed file according to each first code table and each bit stream.
The intra-frame compression module 190 is configured to scan each frame of reference frames according to a preset sequence by using an embedded wavelet zero tree algorithm to obtain a pixel value of each pixel of the reference frame, construct a zero tree of each frame of reference frames according to the pixel value, perform coding according to the zero tree to obtain a second code table of each frame of reference frames, and obtain a second compressed file according to each second code table.
In the video compression apparatus 150, after the preprocessing module 170 processes the video to be compressed to obtain the frame to be processed, the inter-frame compression module 180 converts the conversion between the video frames into the motion vector relative to the reference frame, and encodes the reference frame and the motion vector to obtain the first compressed file, so that the size of the compressed file is reduced, and the video quality of the compressed file can be ensured to a certain extent when the inter-frame compression is performed. And, the intra-frame compression module 190 performs intra-frame compression on each reference frame by using an embedded wavelet zero tree coding algorithm, that is, the reference frames are compressed more finely to obtain a second compressed file. Thus, the resulting first and second compressed files are sufficiently small while improving the video quality as much as possible.
Alternatively, the modules may be stored in the memory 110 shown in fig. 1 in the form of software or Firmware (Firmware) or be fixed in an Operating System (OS) of the electronic device 100, and may be executed by the processor 120 in fig. 1. Meanwhile, data, codes of programs, and the like required to execute the above-described modules may be stored in the memory 110.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method can be implemented in other manners. The apparatus embodiments described above are merely illustrative, and the flowcharts and block diagrams in the figures, for example, illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, the functional modules in the embodiments of the present invention may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of video compression, the method comprising:
reading a video to be compressed into a plurality of frames of ordered video frames, and converting and dividing macro blocks of each frame of video frames to obtain a plurality of frames to be processed, wherein each frame of frames to be processed comprises a plurality of macro blocks;
dividing a plurality of frames to be processed into a plurality of image groups, and determining a reference frame from each image group, wherein each image group comprises a plurality of continuous frames to be processed;
for each image group, taking a macro block as a motion unit, estimating motion vectors between the reference frame and each frame to be processed which is remained in each frame by adopting a motion estimation algorithm, and coding each motion vector to obtain a plurality of bit streams;
scanning each frame of the reference frame to obtain a ratio of each pixel value in each frame of the reference frame, and coding each pixel value of each frame of the reference frame according to the ratio to obtain a first code table of each frame of the reference frame;
and obtaining a first compressed file according to each first code table and each bit stream.
2. The video compression method of claim 1, wherein the method further comprises:
scanning each frame of the reference frame by adopting an embedded wavelet zero tree algorithm according to a preset sequence to obtain a pixel value of each pixel of the reference frame, and constructing a zero tree of each frame of the reference frame according to the pixel value;
and coding according to the zero tree to obtain a second code table of each frame of the reference frame, and obtaining a second compressed file according to each second code table.
3. The method of claim 2, wherein said step of encoding according to said zero tree to obtain a second code table of said reference frame for each frame comprises:
and calculating a plurality of intervals corresponding to each frame of the reference frame by adopting arithmetic coding based on the zero tree, and selecting a pixel value in each interval for coding to obtain a second code table of each frame of the reference frame.
4. The video compression method according to claim 1, wherein the motion estimation algorithm comprises a four-step search algorithm, and the step of estimating the motion vector between the reference frame and the frame to be processed in each frame by using the motion estimation algorithm with a macro block as a motion unit for each of the image groups comprises:
processing each frame to be processed by adopting a four-step search method aiming at each image group to obtain an optimal matching point corresponding to each macro block of each frame to be processed;
and taking the reference frame as a reference, and obtaining a motion vector of each macro block of each frame to be processed relative to the reference frame according to the best matching point of each macro block.
5. The video compression method according to claim 4, wherein the step of obtaining a motion vector of each macroblock of the frame to be processed relative to the reference frame according to the best matching point of each macroblock by using the reference frame as a reference comprises:
searching a matching position consistent with the optimal matching point and a corresponding macro block in the reference frame according to the optimal matching point of each macro block;
and obtaining a motion vector of each macro block according to the position relationship between the macro block and the optimal matching point in each frame to be processed and the position relationship between the macro block and the matching position in the reference frame.
6. The video compression method according to any one of claims 1 to 5, wherein the step of transforming and macro-block dividing each frame of the video frame to obtain a plurality of frames to be processed comprises:
performing transform processing on each frame of the video frame by adopting discrete wavelet transform;
and carrying out macro block division on each frame of the video frame after the conversion processing according to a preset size to obtain a frame to be processed comprising a plurality of macro blocks.
7. The method according to any of claims 1 to 5, wherein said step of coding each pixel value of each of said reference frames according to said ratio to obtain a first code table of each of said reference frames comprises:
according to the ratio of each pixel value, assigning unique code words with different lengths to each pixel value; the ratio of the pixel values is in inverse proportion to the length of the code word corresponding to the pixel values;
and recording the code words and the pixel values in a corresponding relationship to obtain a first code table.
8. The video compression method according to any one of claims 1 to 5, wherein said step of encoding each of said motion vectors to obtain a plurality of bit streams comprises:
and performing Huffman coding on each motion vector to obtain a plurality of bit streams.
9. An electronic device comprising a processor and a memory, the memory storing machine executable instructions executable by the processor to implement the video compression method of any one of claims 1-8.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out a video compression method according to any one of claims 1 to 8.
CN202111299542.XA 2021-11-04 2021-11-04 Video compression method, electronic device and computer-readable storage medium Pending CN114025166A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111299542.XA CN114025166A (en) 2021-11-04 2021-11-04 Video compression method, electronic device and computer-readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111299542.XA CN114025166A (en) 2021-11-04 2021-11-04 Video compression method, electronic device and computer-readable storage medium

Publications (1)

Publication Number Publication Date
CN114025166A true CN114025166A (en) 2022-02-08

Family

ID=80060977

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111299542.XA Pending CN114025166A (en) 2021-11-04 2021-11-04 Video compression method, electronic device and computer-readable storage medium

Country Status (1)

Country Link
CN (1) CN114025166A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114449347A (en) * 2022-03-03 2022-05-06 辽宁向日葵教育科技有限公司 Intelligent optimization method for video rendering picture

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114449347A (en) * 2022-03-03 2022-05-06 辽宁向日葵教育科技有限公司 Intelligent optimization method for video rendering picture

Similar Documents

Publication Publication Date Title
CN110024392B (en) Low complexity symbol prediction for video coding
US10659804B2 (en) Method and apparatus for encoding/decoding images using adaptive motion vector resolution
US9462279B2 (en) Image encoding/decoding method and device
JP4700491B2 (en) Adaptive coefficient scan ordering
CA2498384C (en) Context-based adaptive variable length coding for adaptive block transforms
RU2720975C2 (en) Method of encoding and decoding images, an encoding and decoding device and corresponding computer programs
RU2518935C1 (en) Method and apparatus for encoding and decoding image and method and apparatus for decoding image using adaptive coefficient scan order
KR101717510B1 (en) Device, method and program for image prediction encoding, device, method and program for image prediction decoding, and encoding/decoding system and method
RU2608682C2 (en) Image encoding and decoding method, device for encoding and decoding and corresponding software
KR20010075232A (en) Encoding method for the compression of a video sequence
AU2021200431B2 (en) Techniques for high efficiency entropy coding of video data
Kumar et al. Performance Comparison of Jpeg, Jpeg XT, Jpeg LS, Jpeg 2000, Jpeg XR, HEVC, EVC and VVC for Images
KR20170084213A (en) Systems and methods for processing a block of a digital image
CN114025166A (en) Video compression method, electronic device and computer-readable storage medium
US20230056211A1 (en) Video encoding method and apparatus, video decoding method and apparatus, computer program product, computer-readable storage medium, and electronic device
CN109672891B (en) Lossless secondary compression method of JPEG image
US8811474B2 (en) Encoder and encoding method using coded block pattern estimation
CN116647673A (en) Video encoding and decoding method and device
JP6992825B2 (en) Video coding device, video coding method, video decoding device, video decoding method, and video coding system
CN113115041A (en) Lossless picture compression method, device and medium supporting alpha channel
JP6497100B2 (en) Video encoding apparatus, method and program
JP6159139B2 (en) Image processing apparatus, encoding apparatus, and program
CN115834882A (en) Intra-frame prediction method and device, electronic equipment and storage medium
CN116980609A (en) Video data processing method, device, storage medium and equipment
KR20040028318A (en) Image encoding and decoding method and apparatus using spatial predictive coding

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination