CN108540799B - Compression method capable of accurately representing difference between two frames of images of video file - Google Patents
Compression method capable of accurately representing difference between two frames of images of video file Download PDFInfo
- Publication number
- CN108540799B CN108540799B CN201810470423.8A CN201810470423A CN108540799B CN 108540799 B CN108540799 B CN 108540799B CN 201810470423 A CN201810470423 A CN 201810470423A CN 108540799 B CN108540799 B CN 108540799B
- Authority
- CN
- China
- Prior art keywords
- area
- index
- frame
- image
- values
- 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.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods 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/136—Incoming video signal characteristics or properties
- H04N19/137—Motion inside a coding unit, e.g. average field, frame or block difference
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods 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/182—Methods 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 a pixel
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods 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/186—Methods 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 a colour or a chrominance component
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/42—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention discloses a compression method capable of accurately representing the difference between two frame images of a video file, which comprises the following steps: s1, determining a reference frame; s2, averagely dividing the current frame image into four areas, namely an upper left area, an upper right area, a lower left area and a lower right area, and performing recursive division on each area respectively until each area is divided to have only one pixel at most; and S3, comparing the color values of the current pixel and the pixel at the corresponding position of the reference frame, if the color values are the same, returning to 1, and if the color values are not the same, returning to 0 and storing the current color value in the data area. S2 calls S3 to compare that there are four return values, if all 1, then directly returns 1; when the number of the data is not 1, sequentially storing return values into the index area and returning to 0; and S4, splicing the frame header, the index and the content together in sequence to form the complete image part compressed data of the current frame. The invention is a lossless compression method, and can generate extremely high compression ratio in partial field.
Description
Technical Field
The invention belongs to the field of video compression, and particularly relates to a compression method capable of accurately representing the difference between two frame images of a video file.
Background
The current video compression field generally uses MPEG and H.26X series algorithms, the compression principle is different, generally, the difference between two frames of the video is not changed greatly, only the difference between the two frames is stored, and details which are not easy to be seen by naked eyes can be lost, so that a certain compression ratio is achieved. All have three common drawbacks: firstly, because the code rate is generally constant, the limit compression ratio is limited by the code rate, therefore, the compression ratio is a relatively fixed parameter, and a large video file can be generated even if the images in the whole video are not changed basically; secondly, the compression is lossy compression, namely, the difference between the image seen during playing and the original image is more or less, and the field with harsh requirements on the picture quality cannot be met; thirdly, the algorithm is complex, involves some profound mathematical knowledge, and is not convenient for self-improvement or multi-thread optimization.
Disclosure of Invention
In order to solve the above problems in the prior art, the present invention is directed to a compression method capable of accurately representing the difference between two frames of images of a video file. The invention can generate higher compression ratio in the scene with almost no change of video, and simultaneously, the invention is a lossless compression method and can also be used in some scenes with harsh requirements on picture quality.
The technical scheme adopted by the invention is as follows:
a compression method capable of accurately representing the difference between two frames of images of a video file comprises the following steps:
s1, determining a reference frame;
s2, performing recursive compression on the current frame image, averagely dividing the image into four regions, namely an upper left region, an upper right region, a lower left region and a lower right region, and performing recursive division on each region respectively until each region is divided into at most one pixel;
s3, comparing the color values of the pixels in each area with the color values of the pixels at the corresponding positions of the reference frame, if the color values are the same, returning to 1, if the color values are not the same, returning to 0 and storing the current color values into the data area, and directly returning to 1 (index value used for the index area) when the comparison return values of the four areas are all 1 without performing any operation on the index file; when the return values compared in the four areas are not all 1, the return values are sequentially stored in the index area;
and S4, sequentially splicing the frame header, the index and the content together to form the complete image part compressed data of the current frame, wherein when the return values in the step S3 are all 1, the current frame is completely the same as the reference frame, and the current frame is stored as the frame header.
Under the condition that pixels in the regions are completely the same, only one return value is provided, under different conditions, a plurality of bits in the index file are used for storing difference, under the limit condition that two frames of images are completely the same, only a frame header is provided, no index and data area exists, and the limit of the storage space occupied by one frame of image is one bit.
Preferably, in step S1, the reference frame is determined by comparing the entire pixel by pixel or sampling the comparison or directly using the previous frame.
Preferably, in step S2, the image is divided into four regions, i.e., upper left, upper right, lower left and lower right.
Preferably, before step S2, the image is virtually expanded so that the length and width are equal to each other and are to the power of N of 2.
Further, the image after virtual expansion is not smaller than the length and width of the image before virtual expansion.
If virtual expansion is not performed, the length and width of the video are not exactly equal and are N times of 2 in general, and the division process may not be performed by one pixel in each of exactly four regions.
The compression method further comprises a decompression flow, and the decompression flow comprises the following steps:
s5, reading the frame header file, and respectively positioning the index area and the data area;
s6, if the current frame is judged to be completely the same as the reference frame according to the total comparison result value stored in the frame header, directly filling the current frame with the data of the reference frame, and ending;
s7, reading four index values of the index area at a time, respectively assigning the four index values to each area block, advancing the pointer of the index area by 4, and if the corresponding index value (namely the value 0 or 1 stored in the index area by the previous comparison result) is 1, directly filling the corresponding index value with the color value corresponding to the previous frame; if 0, repeating S7 until the reaching area is only one pixel;
If the index value corresponding to the pixel comparison is 1, filling the color value of the pixel corresponding to the reference frame; if the color value is 0, filling the color value with the color value of the data area, and advancing the color value pointer of the data area by 1;
if the current context is in a region, it represents the result of the comparison of the current region, and if the context is a pixel, it is the result value of the pixel comparison. If the current decompressed context is a region or a point, for example, a region with coordinates from (0, 0) to (15,15) 16 × 16, and the 256 pixels are all the same as the previous frame, the reference frame region is copied, and if the current decompressed context is a point, the point at the corresponding position of the reference frame is copied.
And S8, repeating S7 until the index pointer points to 0, the pointer of the data area also points to 0, and the current frame image is decompressed.
Specifically, in step S7, the pointer of the index area is advanced by the number of bits corresponding to the number of area blocks.
The invention has the beneficial effects that:
the invention can generate extremely high compression ratio in the field of video monitoring, especially under the condition that the angle of a camera is fixed and the shot scene is also fixed, can store a video for a longer time than before in the same space, can completely save the video file without loss and generate more brilliant video effect in the field with harsh requirements on picture quality, such as a movie master disc, and can save the video reaching or even exceeding the human eye recognition speed limit under the condition of slightly increasing the space occupation because the compression method is not sensitive to the frame number per second. The method is convenient for multithread optimization, and can realize real-time compression and decompression with ultrahigh resolution and increased frame number by using a display card for acceleration or special hardware, so that the speed bottleneck does not exist.
Detailed Description
The invention will be further illustrated with reference to specific examples.
The first embodiment is as follows:
the compression method for accurately representing the difference between two frames of images in a video file can generate higher compression ratio in partial fields, and can accurately restore images in all fields. In addition, the method is simple, the demonstration code comprises 300 lines of compression, decompression and annotation, and can be easily improved by self, a natural place divided into four is arranged in the method, 4 power N threads can be easily changed to run in parallel, and the high compression and decompression speed is achieved.
A compression method for accurately representing the difference between two frames of image in a video file includes compression and decompression.
First, the principles of the present invention are assumed and explained briefly as follows:
1. the image data of each frame is finally stored as a frame header, and the difference value index and different colors are sequentially arranged to form a data area.
2. And calculating the difference index and the position and the size of the data area according to the frame header.
3. Assuming that the same is represented by 1 bit 1 and the different by 1 bit 0, the reverse is practically without effect.
4. For simplicity, the detection and optimization of the omitted part of the method specification and demonstration code, for example, when the stored index is 1110, it may be stored as 111, the last 0 may be omitted by calculation, and some addresses (the memory address of the address, for example, an object, occupies 100 bytes, and the use of a transmission value will generate a copy overhead of at least 100 bytes, and if the address is a transmission address, it is 4 bytes above a 32-bit system, and 8 bytes above a 64-bit system, and obviously the overhead is much less) are used directly.
5. The color data are directly and sequentially stored during storage, and no optimization is performed before and after storage.
6. The demonstration program directly assumes that the length and the width of the image are both the N power of 2, the length and the width can be extended to be consistent and the N power of 2 in an actual environment, and detection pixels or areas can be directly added in the method to detect whether the pixels or the areas are in the video range, and when the detection pixels or the areas are compared, if the corresponding pixels or the areas are not in the video range of the image, the 1 is directly returned.
The following description is only used for single thread, and the multithreading improvement is not a core part of the method of the application.
The compression process comprises the following steps: original image stream- > encode- > file storage.
The specific process comprises the following steps:
in a first step, the reference frame is determined by a pixel-by-pixel full comparison or a sample comparison or simply by directly using the previous frame.
And secondly, virtually expanding the length and the width of the image to ensure that the length and the width are the same and are N times of 2, and the virtually expanded image is not smaller than the length and the width of the image before virtually expanding.
Thirdly, recursively compressing the current frame image, equally dividing the image into four regions of upper left, upper right, lower left and lower right, recursively dividing the four regions respectively until the four regions divided into the upper left, upper right, lower left and lower right regions have at most one pixel, comparing the pixels of the four regions with the pixel color values of the corresponding positions of the reference frame respectively, if the pixels are the same, returning 1, if the pixels are not the same, returning 0 and storing the current color value in the data region, wherein the four regions have one return value respectively and four return values in total, directly returning 1 when the return values compared in the four regions are all 1 (the 1 is the return value as a method function, and is a possible index value, because the index region cannot be operated if 4 regions are all 1, not performing any operation on the index file, and when the return values compared in the four regions are not all 1, and sequentially storing the four return values into the index area.
And fourthly, sequentially splicing the frame header, the index and the content together to form the complete image part compressed data of the current frame, and when the return values of the four functions called during the first division in the third step are all 1, storing the current frame as the frame header (the length of the index and the data is both 0, and only the frame header needs to be stored). The frame header must have a bit of 0 or 1 to indicate the comparison result of two frames of images, if 1, the index area and the data area have no data, if 0, the data will be in the affirmative.
And repeating the third step and the fourth step until the last frame of the video is reached.
The decompression flow comprises the following steps: file- > decode- > original image stream.
The specific flow of decompressing (frame) is as follows:
firstly, reading a frame header file, and respectively positioning an index area and a data area.
And secondly, if the current frame is completely the same as the reference frame, directly filling the current frame with the data of the reference frame, and ending.
Reading four index values of an index area once, respectively assigning the four index values to four area blocks of a lower right area, a lower left area, an upper right area and an upper left area, advancing a pointer of the index area by 4, and directly filling the index area with a color value corresponding to a previous frame if the corresponding index value is 1; if the pixel value is 0, repeating the third step until the reaching area is only one pixel;
If the index value corresponding to the pixel comparison is 1, filling the color value of the pixel corresponding to the reference frame; if the color value is 0, the color value pointer of the data area is shifted forward by 1.
And repeating the third step until the index pointer points to 0 finally, the pointer of the data area also points to 0, and the decompression of the current frame image is completed.
Under the condition that the pixels in the four regions are completely the same, only one return value is provided, and under different conditions, the difference is stored by using 4 bits in the index file, under the limit condition that two frames of images are completely the same, only the frame header is provided, and no index and data area is provided, and the limit of the storage space occupied by one frame of image is one bit.
The following is a simplified C + + source code implementation of the present invention that can be compiled directly for testing. In the code, the actual calculation process is greatly simplified without influencing the core of the invention.
The invention is not limited to the above alternative embodiments, and any other various forms of products can be obtained by anyone in the light of the present invention, but any changes in shape or structure thereof, which fall within the scope of the present invention as defined in the claims, fall within the scope of the present invention.
Claims (6)
1. A compression method for accurately representing the difference between two frames of an image of a video file, comprising: the compression process comprises the following steps:
s1, determining a reference frame;
s2, performing recursive compression on the current frame image, averagely dividing the image into four initial regions of upper left, upper right, lower left and lower right, and performing recursive division on each initial region respectively until each minimum region divided into the initial regions has only one pixel at most;
s3, comparing the color values of the pixels in each minimum area with the color values of the pixels at the corresponding positions of the reference frame, respectively, if the color values are the same, returning to 1, and if the color values are not the same, returning to 0, and storing the current color values in the data area, wherein the four minimum areas have 4 return values, performing summarization processing, if all the return values are 1, returning to 1, if not all the return values are 1, sequentially storing the four return values in the index area, returning to 0, then amplifying step by step, performing reverse recursion summarization until only one total return value is at last, and storing the total return value in the frame header area;
and S4, sequentially splicing the frame header, the index and the content together to form the complete image part compressed data of the current frame, and when the return values in the step S3 are all 1, storing the current frame as the frame header.
2. A compression method as claimed in claim 1, which is capable of accurately representing the difference between two frames of images of a video file, wherein: in step S1, the reference frame is determined by comparing the entire pixel by pixel or sampling the comparison or directly using the previous frame.
3. A compression method according to any one of claims 1-2 for accurately representing the difference between two frames of an image of a video file, wherein: before step S2, the image is also virtually expanded so that the length and width are the same and 2 to the power of N.
4. A compression method as claimed in claim 3, which is capable of accurately representing the difference between two frames of images of a video file, wherein: the length and width of the image after virtual expansion are not less than those of the image before virtual expansion.
5. A compression method as claimed in claim 1, which is capable of accurately representing the difference between two frames of images of a video file, wherein: the compression method further comprises a decompression process, wherein the decompression process comprises the following steps:
s5, reading the frame header file, and respectively positioning the index area and the data area;
s6, if the current frame is judged to be completely the same as the reference frame according to the total comparison result value stored in the frame header, directly filling the current frame with the data of the reference frame;
S7, reading four index values of the index area once, respectively assigning the four index values to each initial area, advancing the pointer of the index area by 4, and if the corresponding index value is 1, directly filling the index area with the color value corresponding to the previous frame; if 0, repeating S7 until the reaching area is only one pixel; if the index value corresponding to the pixel comparison is 1, filling the color value of the pixel corresponding to the reference frame; if the color value is 0, filling the color value with the color value of the data area, and advancing the color value pointer of the data area by 1;
and S8, repeating S7 until the index pointer points to 0, the pointer of the data area also points to 0, and the current frame image is decompressed.
6. A compression method as claimed in claim 5, which is capable of accurately representing the difference between two frames of images of a video file, wherein: in step S7, the index area pointer is moved forward by the same number of bits as the number of area blocks.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810470423.8A CN108540799B (en) | 2018-05-16 | 2018-05-16 | Compression method capable of accurately representing difference between two frames of images of video file |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810470423.8A CN108540799B (en) | 2018-05-16 | 2018-05-16 | Compression method capable of accurately representing difference between two frames of images of video file |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108540799A CN108540799A (en) | 2018-09-14 |
CN108540799B true CN108540799B (en) | 2022-06-03 |
Family
ID=63472166
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810470423.8A Active CN108540799B (en) | 2018-05-16 | 2018-05-16 | Compression method capable of accurately representing difference between two frames of images of video file |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108540799B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109982091B (en) * | 2019-04-26 | 2022-04-22 | 京东方科技集团股份有限公司 | Image processing method and device |
CN110896497A (en) * | 2019-10-30 | 2020-03-20 | 厦门天锐科技股份有限公司 | Image processing method, video playing method and device |
CN111294600A (en) * | 2020-03-17 | 2020-06-16 | 广州致远电子有限公司 | Compression method, decompression method and device for video sequence frame |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1522401A (en) * | 2001-10-29 | 2004-08-18 | ض� | Method and apparatus for parallel shift right merge of data |
WO2015059880A1 (en) * | 2013-10-22 | 2015-04-30 | パナソニック インテレクチュアル プロパティ コーポレーション オブ アメリカ | Motion compensation method, image encoding method, image decoding method, image encoding device and image decoding device |
CN105814889A (en) * | 2013-12-10 | 2016-07-27 | 佳能株式会社 | Improved palette mode in hevc |
CN105844683A (en) * | 2016-03-23 | 2016-08-10 | 深圳市富途网络科技有限公司 | Pixel difference frame-by-frame animation realization method based on Canvas and WebWorker |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
GB2531004A (en) * | 2014-10-06 | 2016-04-13 | Canon Kk | Residual colour transform signalled at sequence level for specific coding modes |
-
2018
- 2018-05-16 CN CN201810470423.8A patent/CN108540799B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1522401A (en) * | 2001-10-29 | 2004-08-18 | ض� | Method and apparatus for parallel shift right merge of data |
WO2015059880A1 (en) * | 2013-10-22 | 2015-04-30 | パナソニック インテレクチュアル プロパティ コーポレーション オブ アメリカ | Motion compensation method, image encoding method, image decoding method, image encoding device and image decoding device |
CN105814889A (en) * | 2013-12-10 | 2016-07-27 | 佳能株式会社 | Improved palette mode in hevc |
CN105844683A (en) * | 2016-03-23 | 2016-08-10 | 深圳市富途网络科技有限公司 | Pixel difference frame-by-frame animation realization method based on Canvas and WebWorker |
Also Published As
Publication number | Publication date |
---|---|
CN108540799A (en) | 2018-09-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8421821B2 (en) | Differential encoding using a 3D graphics processor | |
CN108540799B (en) | Compression method capable of accurately representing difference between two frames of images of video file | |
US5353061A (en) | System and method for frame-differencing video compression/decompression using perceptually-constant information and image analysis | |
CN110996105B (en) | Variable rate compression method and variable rate decompression method | |
WO2012096768A2 (en) | Method of detecting logos, titles, or sub-titles in video frames | |
CN108229346B (en) | Video summarization using signed foreground extraction and fusion | |
JPH06231234A (en) | Compression method of image frame and data processing system | |
US20100054542A1 (en) | Processing video frames with the same content but with luminance variations across frames | |
CN108322722B (en) | Image processing method and device based on augmented reality and electronic equipment | |
CN109977952B (en) | Candidate target detection method based on local maximum | |
US20140198843A1 (en) | Compressed video | |
US9100642B2 (en) | Adjustable depth layers for three-dimensional images | |
CN112019827B (en) | Method, device, equipment and storage medium for enhancing video image color | |
CN111723713B (en) | Video key frame extraction method and system based on optical flow method | |
CN105828081A (en) | Encoding method and encoding device | |
CN110691246B (en) | Video coding method and device and electronic equipment | |
US20150172705A1 (en) | Window detection device and method on multi-media system | |
US6411652B1 (en) | Motion estimation | |
US20150242988A1 (en) | Methods of eliminating redundant rendering of frames | |
CN111160340B (en) | Moving object detection method and device, storage medium and terminal equipment | |
Banterle et al. | Real-Time High Fidelity Inverse Tone Mapping for Low Dynamic Range Content. | |
CN108462878B (en) | Teaching video compression algorithm based on key frame and indicator motion model | |
EP1139291A2 (en) | Method for visualization of time sequences of 3D optical flurescence microscopy images | |
CN110111380A (en) | 3D rendering transmission and method for reconstructing based on depth camera | |
CN111754412A (en) | Method and device for constructing data pairs and terminal equipment |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |