CN116055743A - Image compression method, system, electronic equipment and storage medium - Google Patents
Image compression method, system, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN116055743A CN116055743A CN202310316590.8A CN202310316590A CN116055743A CN 116055743 A CN116055743 A CN 116055743A CN 202310316590 A CN202310316590 A CN 202310316590A CN 116055743 A CN116055743 A CN 116055743A
- Authority
- CN
- China
- Prior art keywords
- image data
- memory
- data
- direct current
- encoded
- 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.)
- Granted
Links
Images
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/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
- H04N19/423—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 characterised by memory arrangements
-
- 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/189—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding
- H04N19/192—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the adaptation method, adaptation tool or adaptation type used for the adaptive coding the adaptation method, adaptation tool or adaptation type being iterative or recursive
-
- 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/85—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression
- H04N19/86—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression involving reduction of coding artifacts, e.g. of blockiness
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The invention relates to the technical field of video image compression, and particularly discloses an image compression method, an image compression system, electronic equipment and a storage medium, wherein the method comprises the following steps: dividing the first image data in the memory into a plurality of sets of second image data; pre-calculating a first direct current differential value of adjacent second image data based on the segmentation result; reading the second image data from the memory; the read second image data is encoded based on the first direct current differential value, and the encoded second image data is written again to the memory. By the scheme of the invention, the compression of the image data is realized, and the compression speed of the image data is improved.
Description
Technical Field
The present invention relates to the field of video image compression technologies, and in particular, to an image compression method, an image compression system, an electronic device, and a storage medium.
Background
JPEG (Joint Photographic Experts Group ) video image compression is a common international standard for video image compression for compression of continuous tone still images, including gray scale images and color images. The practical efficiency of JPEG compression is related to the video image itself, and when the redundant information of the image itself is more (e.g., the image changes less, flatter or more high frequency components), the coding efficiency is higher, i.e., the amount of data after coding is less, the time consumed in the coding process is less, and vice versa. Therefore, when JPEG compression is used, there is a possibility that performance is unstable and performance is low.
Disclosure of Invention
In view of this, the present invention provides an image compression method, system, electronic device and storage medium, which realizes an efficient and stable compression, and solves the problem of unstable and low performance during JPEG compression.
Based on the above object, an aspect of the embodiments of the present invention provides an image compression method, which specifically includes the following steps:
dividing the first image data in the memory into a plurality of sets of second image data;
pre-calculating a first direct current differential value adjacent to the second image data based on the segmentation result;
reading the second image data from the memory;
and encoding the read second image data based on the first direct current differential value, and writing the encoded second image data into the memory again.
In some embodiments, after the step of dividing the first image data in the memory into a plurality of sets of second image data, the step of dividing the first image data into a plurality of sets of second image data includes:
assigning each set of the second image data to a corresponding computing unit;
the step of encoding the read second image data based on the first direct current differential value includes:
the computing unit encodes the second image data based on the first direct current differential value.
In some embodiments, the method further comprises:
and distributing uncoded second image data to the computing units with finished coding for secondary coding and storage through image self-adaptive segmentation in response to the fact that part of the computing units do not finish the second image data needing to be coded.
In some embodiments, the step of dividing the first image data in the memory into a plurality of sets of second image data comprises:
the first image data in the memory is divided into a plurality of sets of the second image data on average, wherein the number of the packets corresponds to the number of the calculation units.
In some embodiments, the method further comprises:
a first starting position of the second image data in the memory is calculated.
In some embodiments, the pre-calculating the first direct current differential value adjacent to the second image data includes:
determining a storage address of a first data block and a storage address of a second data block corresponding to the second image data based on the calculated first starting position, wherein the second image data is stored in the memory in units of data blocks, the first data block is the first data block corresponding to the second image data, and the second data block is the last data block corresponding to the second image data;
The second image data is read based on the storage address of the first data block and the storage address of the second data block and transferred to the calculation unit to calculate the first direct current differential value.
In some embodiments, the step of calculating the first direct current differential value comprises:
calculating the direct current coefficients of the brightness and the chromaticity of the third image data stored by the first data block and the direct current coefficients of the brightness and the chromaticity of the third image data stored by the second data block;
the first direct current differential value is calculated based on the direct current coefficients of the luminance and the chromaticity of the third image data stored in the first data block and the direct current coefficients of the luminance and the chromaticity of the third image data stored in the second data block obtained by the adjacent calculating unit.
In some embodiments, the step of reading the second image data from the memory includes:
each set of the second image data is read in parallel from the memory.
In some embodiments, the step of reading the second image data from the memory includes:
and calculating a storage address of the second image data, and reading the second image data based on the storage address.
In some embodiments, the step of encoding the read second image data based on the first direct current differential value includes:
and sequentially performing discrete cosine transform, quantization, differential pulse coding, run-length coding and Huffman coding on the read second image data, wherein the differential pulse coding is performed based on the first direct current differential value.
In some embodiments, the step of distributing the uncoded second image data to the computing unit with the finished encoding for secondary encoding and storage through image adaptive segmentation includes:
determining the position of the last data block corresponding to the encoded second image data in the memory;
distributing the uncoded second image data to the computing unit after coding is completed through image self-adaptive segmentation;
determining a second starting position of the corresponding data block in the memory based on fourth image data which is allocated to the calculation unit after encoding is completed and needs to be encoded again, and calculating a second direct current differential value based on the second starting position and the position;
and the calculation unit after the encoding is completed performs secondary encoding and storage on the fourth image data based on the second direct current differential value.
In some embodiments, the step of determining the second starting position of the corresponding data block in the memory based on the fourth image data allocated to the calculation unit to be encoded again after the completion of the encoding includes:
and determining the second starting position of the data block corresponding to the fourth image data in the memory based on the encoded second image data and the unencoded second image data.
In some embodiments, the step of determining the second starting position of the corresponding data block in the memory based on the fourth image data allocated to the calculation unit to be encoded again after the completion of the encoding includes:
recording the number of the encoded data blocks, and calculating the number of the data blocks still needing to be encoded based on the number of the encoded data blocks;
calculating an initial starting position of a data block corresponding to the fourth image data in the memory based on the number of data blocks still required to be encoded and the number of data blocks already encoded;
and carrying out data block line alignment processing on the calculated initial starting position to determine the second starting position of the data block corresponding to the fourth image data in the memory.
In some embodiments, the method further comprises:
after the computing unit finishes encoding, recording a write address corresponding to the encoding completed computing unit;
the step of the computing unit after the encoding is completed, which performs secondary encoding and storage on the fourth image data based on the second direct current differential value, includes:
and the calculation unit after the encoding is completed carries out secondary encoding and storage on the fourth image data based on the second direct current differential value and the recorded write address.
In some embodiments, the method further comprises:
reading the encoded second image data from the memory after the encoding of all the second image data is completed, and performing data fusion on the read second image data;
and adding a header file for the fused data and outputting the data.
In some embodiments, the step of reading the encoded second image data from the memory and performing data fusion on the read second image data includes:
reading the encoded second image data from the memory in sequence according to the original position of the encoded second image data in the memory;
And carrying out data fusion on the brightness and color information of the read second image data according to an image protocol standard.
In some embodiments, the method further comprises:
the first image data is written into the memory in units of data blocks.
In still another aspect of the embodiment of the present invention, there is also provided an image compression system including:
an image pre-start segmentation module configured to segment the first image data in the memory into a plurality of sets of second image data;
a pre-calculation direct current differential value module configured to pre-calculate a first direct current differential value adjacent to the second image data based on a division result;
an address mapping calculation module configured to read the second image data from the memory;
and an encoding module configured to encode the read second image data based on the first direct current differential value, and write the encoded second image data again to the memory.
In still another aspect of the embodiment of the present invention, there is also provided an electronic device, including: at least one processor; and a memory storing a computer program executable on the processor, which when executed by the processor, performs the steps of the method as above.
In yet another aspect of the embodiments of the present invention, there is also provided a storage medium storing a computer program which, when executed by a processor, implements the above method steps.
The invention has at least the following beneficial technical effects: by the scheme of the invention, the compression of the image data is realized, and the compression speed of the image data is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are necessary for the description of the embodiments or the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention and that other embodiments may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of an embodiment of an image compression method according to the present invention;
FIG. 2 is a schematic diagram of an embodiment of an image data compression method according to the present invention;
FIG. 3 is a block diagram of an embodiment of the original image data according to the present invention;
FIG. 4 is a schematic diagram of an embodiment of the original image data location and the storage location in memory provided by the present invention;
FIG. 5 is a schematic diagram of an embodiment of an image compression system according to the present invention;
FIG. 6 is a schematic structural diagram of an embodiment of an electronic device according to the present invention;
fig. 7 is a schematic structural diagram of an embodiment of a storage medium according to the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention will be described in further detail with reference to the accompanying drawings.
It should be noted that, in the embodiments of the present invention, all the expressions "first" and "second" are used to distinguish two entities with the same name but different entities or different parameters, and it is noted that the "first" and "second" are only used for convenience of expression, and should not be construed as limiting the embodiments of the present invention, and the following embodiments are not described one by one.
Based on the above object, a first aspect of the embodiments of the present invention proposes an image compression method. In the embodiment shown in fig. 1, the method comprises the steps of:
s10, dividing the first image data in the memory into a plurality of groups of second image data;
s20, pre-calculating a first direct current differential value adjacent to the second image data based on the segmentation result;
S30, reading the image data from the memory;
and S40, encoding the read second image data based on the first direct current differential value, and writing the encoded second image data into the memory again.
Specifically, in step S10, the first image data refers to the original image data written in the memory, the original image data is written in the memory in units of data blocks, after the original image data is written in the memory in units of data blocks, the original image data stored in the memory is pre-divided to divide the original image data into a plurality of sets of second image data, and the second image data in each set is allocated to the corresponding calculation unit for calculation.
In step S20, direct current differential values of the second image data adjacent data blocks of the two adjacent groups at the division are calculated.
In step S30, the reading and calculation of the second image data are performed, that is, the calculation of the read memory port address of the calculation unit is completed.
In step S40, the read second image data is encoded, that is, the read data is sequentially subjected to DCT (DCT for Discrete Cosine Transform, discrete cosine transform), quantization, DPCM (differential pulse code), RLE (run length code), and Huffman (Huffman) code. After quantization processing, the block is divided into a direct current component and an alternating current component, wherein the alternating current component uses run length coding, the coding of data is only related to the current block (data block) data, and the direct current component uses a differential coding mode, and the direct current component is the difference between the corresponding component of the current block and the corresponding component of the previous block group during coding, so that the direct current differential value calculated in the step S20 is used when the calculation unit except the first calculation unit calculates the DC component of the first block. After encoding of the read image data is completed, the encoded data is written back to the memory.
By the scheme, the compression of the image data is realized, and the compression speed of the image data is improved.
In some embodiments, after the step of dividing the first image data in the memory into a plurality of sets of second image data, the step of dividing the first image data into a plurality of sets of second image data includes:
assigning each set of the second image data to a corresponding computing unit;
the step of encoding the read second image data based on the first direct current differential value includes:
the computing unit encodes the second image data based on the first direct current differential value.
In some embodiments, the method further comprises:
and distributing uncoded second image data to the computing units with finished coding for secondary coding and storage through image self-adaptive segmentation in response to the fact that part of the computing units do not finish the second image data needing to be coded.
In a specific embodiment, the target image data refers to image data originally distributed to the encoding uncompleted calculation units by image segmentation minus the encoding uncompleted calculation units divided by the image data that has completed encoding.
The method and the device can be applied to JPEG image compression scenes. JPEG (Joint Photographic Experts Group ) video image compression is a common international standard for video image compression for compression of continuous tone still images. When the JPEG compression process is used, although separate coding units are used for the Y component (luminance component), the Cr component (blue component), and the Cb component (blue component), it is still necessary to wait for all of the 3 channels of the current block to be encoded before the subsequent block can be encoded. In practical application scenarios, since the sensitivity of human eyes to the luminance component Y is far higher than that of the chrominance components Cr and Cb, after quantization processing, the chrominance components will appear more continuous 0 components, so the subsequent huffman coding will be faster, which results in that in most cases, the chrominance components are already coded, but the luminance component is not finished, the chrominance components only wait for the former to be finished, so that even 3 independent channels will have efficiency waste.
According to the scheme, the waiting time of the chrominance component can be shortened to a certain extent through image pre-start segmentation, direct current differential value pre-calculation, address mapping calculation and multiple memory reading operations, and the coding efficiency can be improved.
On the basis, the embodiment of the invention also provides a compression scheme, after the original image data is segmented into a plurality of computing units for coding and storing, an image self-adaptive segmentation function is started, once the second image data needing to be coded in a certain computing unit is coded, and the coding of the second image data needing to be coded in other computing units is not finished, the second image data in the coding unfinished computing unit is segmented again, so that the coding of a part of data is still carried out in the original coding unfinished computing unit, and the coding of the rest part of data is carried out in the coding finished computing unit, thereby further improving the coding efficiency and further improving the compression performance.
In some embodiments, the step of dividing the first image data in the memory into a plurality of sets of second image data comprises:
the first image data in the memory is divided into a plurality of sets of the second image data on average, wherein the number of the packets corresponds to the number of the calculation units.
In some embodiments, the method further comprises:
a first starting position of the second image data in the memory is calculated.
In one embodiment, the image segmentation process is described in connection with the image data compression flow of FIG. 2. In this embodiment, the memory adopts DDR (Double Data Rate) and the original image Data is divided into two groups, the number of corresponding computing units is 2, and the original image is 8×8 image blocks. It is to be understood that the embodiments described herein are for illustration and explanation of the invention only and are not intended to limit the invention.
8 x 8 tile write DDR: as shown in fig. 2, original image data (Y/Cr/Cb format) is written in DDR in blocks, and the space sp=8×8×component equivalent number×color depth occupied by each block. For example, when the original image data is in the YCrCb format, the YCrCb format is in the 444 format, which is a component equivalent number of 3 at this time. When using an 8bit color depth, the space sp=8×8×3 (component equivalent number) occupied by each block×8 bits (color depth) =192 bytes (bytes).
Thus, in performing write operation (1), if the write DDR address ddr_wraddr=bar_0 corresponding to the first block data set, the write address corresponding to the second block data set is ddr_wraddr=bar_0+192, and so on, the write address corresponding to the nth block data set is ddr_wraddr=bar_0+sp (N-1), where bar_0 is the base address for storing the partial image.
Image pre-segmentation: for completing the calculation of the starting positions of the two sets of encoding calculation units. In this step, by using the image size division method, the entropy distribution of the whole image is uniform (i.e., the high-frequency component and the low-frequency component are uniformly distributed) by default, so that the entropy distribution is uniformly divided according to the number of calculation units, the number of blocks to be calculated in each group is recorded as block_half, in this embodiment, the calculation unit (1) starts to calculate from the data of block-1, and the calculation unit (2) starts to calculate from the data of block-16200.
In some embodiments, the pre-calculating the first direct current differential value adjacent to the second image data includes:
determining a storage address of a first data block and a storage address of a second data block corresponding to the second image data based on the calculated first starting position, wherein the second image data is stored in the memory in units of data blocks, the first data block is the first data block corresponding to the second image data, and the second data block is the last data block corresponding to the second image data;
the second image data is read based on the storage address of the first data block and the storage address of the second data block and transferred to the calculation unit to calculate the first direct current differential value.
In some embodiments, the step of calculating the first direct current differential value comprises:
calculating the direct current coefficients of the brightness and the chromaticity of the third image data stored by the first data block and the direct current coefficients of the brightness and the chromaticity of the third image data stored by the second data block;
the first direct current differential value is calculated based on the direct current coefficients of the luminance and the chromaticity of the third image data stored in the first data block and the direct current coefficients of the luminance and the chromaticity of the third image data stored in the second data block obtained by the adjacent calculating unit.
In one embodiment, the pre-calculation of the dc differential value process is described in connection with the image data compression flow of fig. 2 and 3.
1) Firstly, according to an original image data segmentation result, finding a last group of blocks corresponding to second image data which is required to be encoded in a computing unit (1), namely U_1_last, and a first group of blocks corresponding to second image data which is required to be encoded in a computing unit (2), namely U_2_first;
2) Calculating the storage addresses of U_1_last and U_2_first at DDR in the same manner as the write address in the previous embodiment, DDR_ADDR=bar_0+SP (N-1), and recording as DDR_ADDR_U1_last and DDR_ADDR_U2_first;
3) Performing a read operation (1), assigning the DDR_ADDR_U1_last to an address DDR_RDADDR_1=DDR_ADDR_U1_last of a DDR read port corresponding to the computing unit (1), wherein the data LENGTH DDR_LENGTH is SP, and reading out and transmitting the data of the U_1_last (namely third image data) to the computing unit (1); performing a read operation (2), assigning DDR_ADDR_U2_first to an address DDR_RDADDR_2=DDR_ADDR_U2_first of a DDR read port corresponding to the computing unit (2), reading data of U_2_first (namely third image data) and transmitting the data to the computing unit (2), wherein the data LENGTH DDR_LENGTH is SP;
4) Calculating DC (Direct Current) coefficients of brightness and chromaticity synchronously by using the calculating units (1) and (2), and respectively marking as:
Y_DC_LAST,Cr_DC_LAST,Cb_DC_LAST;
Y_DC_FIRST,Cr_DC_FIRST,Cb_DC_FIRST;
calculating a corresponding differential value based on the DC coefficients calculated by the calculation units (1) and (2):
Y_DC_diff = Y_DC_FIRST - Y_DC_LAST;
Cr_DC_diff = Cr_DC_FIRST - Cr_DC_LAST;
Cb_DC_diff = Cb_DC_FIRST - Cb_DC_LAST;
thus, the calculation of the direct current differential values by the calculation units (1) and (2) is completed.
In some embodiments, the step of reading the second image data from the memory includes:
each set of the second image data is read in parallel from the memory.
In some embodiments, the step of reading the second image data from the memory includes:
And calculating a storage address of the second image data, and reading the second image data based on the storage address.
In one embodiment, the address map calculation process is described in connection with the image data compression flow of FIG. 2.
After the pre-calculation of the first direct current differential value is completed, the reading and calculation of the normal image data (i.e., the second image data) are started, that is, the calculation of the reading DDR port addresses of the two calculation units is completed. In the present embodiment, the calculation unit (1) sequentially reads and calculates the data of blocks 1 to u_1_last from DDR, and the calculation unit (2) sequentially reads and calculates the data of u_2_first to last Block from DDR.
In some embodiments, encoding the read second image data based on the first direct current differential value includes:
and sequentially performing discrete cosine transform, quantization, differential pulse coding, run-length coding and Huffman coding on the read second image data, wherein the differential pulse coding is performed based on the first direct current differential value.
In one embodiment, the process of image encoding and encoded stream storage is described in connection with the image data compression flow of FIG. 2.
The two computing units are identical in hardware, and the read second image data sequentially performs DCT, quantization, DPCM coding, RLE coding and Huffman coding. It should be noted that, after quantization processing, the Block is divided into a direct current DC component (located in the upper left corner of the entire 8 x 8 matrix) and an alternating current AC component (the other 63 components except the direct current component), wherein the alternating current component uses run-length coding, the coding of the data is related to the current Block data only, and the DC component uses differential coding, which is the difference between the corresponding component of the current Block and the corresponding component of the previous Block, and thus, when the calculation unit (2) calculates the DC component of the first Block, the difference value calculated in the first direct current difference value precalculation step is used.
After the current block is coded, the coded data needs to be written into the DDR again, wherein the base address of the output data of the computing unit (1) is bar_encode_1, the coded data of the subsequent block is written into the subsequent space in sequence, and the coded data length encode_1_length is recorded. Wherein the base address of the storage of the output data of the computing unit (2) is bar_encode_2, the encoded data of the subsequent block is sequentially written into the subsequent space, and the encoded data length encode_1_length is recorded. Since the encoded image data length is not fixed, a larger space is used when bar_encode_1 and bar_encode_2 are preset, and therefore, the write address of the encoded data is set to 1/2 or more of the original image data, in this embodiment, 1/2 of the original image data raw_data, that is, bar_encode_2-bar_encode_1=raw_data/2, raw_data=row_color Depth, and 1920×1080×24bit in this embodiment.
Through multiple DDR read-write operations, intermediate variables and coded data are stored through DDR read-write, and higher coding efficiency is achieved.
In some embodiments, the step of distributing the uncoded second image data to the computing unit with the finished encoding for secondary encoding and storage through image adaptive segmentation includes:
determining the position of the last data block corresponding to the encoded second image data in the memory;
distributing the uncoded second image data to the computing unit after coding is completed through image self-adaptive segmentation;
determining a second starting position of the corresponding data block in the memory based on fourth image data which is allocated to the calculation unit after encoding is completed and needs to be encoded again, and calculating a second direct current differential value based on the second starting position and the position;
and the calculation unit after the encoding is completed performs secondary encoding and storage on the fourth image data based on the second direct current differential value.
In some embodiments, the step of determining the second starting position of the corresponding data block in the memory based on the fourth image data allocated to the calculation unit to be encoded again after the completion of the encoding includes:
And determining the second starting position of the data block corresponding to the fourth image data in the memory based on the encoded second image data and the unencoded second image data.
In some embodiments, the step of determining the second starting position of the corresponding data block in the memory based on the fourth image data allocated to the calculation unit to be encoded again after the completion of the encoding includes:
recording the number of the encoded data blocks, and calculating the number of the data blocks still needing to be encoded based on the number of the encoded data blocks;
calculating an initial starting position of a data block corresponding to the fourth image data in the memory based on the number of data blocks still required to be encoded and the number of data blocks already encoded;
and carrying out data block line alignment processing on the calculated initial starting position to determine the second starting position of the data block corresponding to the fourth image data in the memory.
In some embodiments, the method further comprises:
after the computing unit finishes encoding, recording a write address corresponding to the encoding completed computing unit;
The step of the computing unit after the encoding is completed, which performs secondary encoding and storage on the fourth image data based on the second direct current differential value, includes:
and the calculation unit after the encoding is completed carries out secondary encoding and storage on the fourth image data based on the second direct current differential value and the recorded write address.
In one embodiment, the processes of image adaptive segmentation, direct current differential value calculation, address mapping calculation, and secondary encoding are described in connection with the image data compression flow of fig. 2 and 4.
Since the distribution of the image contents is random, this results in the two sets of computing units completing the encoding at different times, taking the case where the computing unit (2) completes the encoding first as an example.
Image adaptive segmentation:
1) When the computing unit (2) finishes encoding the lower half of the image, the total length U_2_DONE_length of the data after the encoding of the lower half and the corresponding write DDR address U_2_DONE_addr are recorded.
2) Meanwhile, the number of blocks (position a in fig. 4) currently coded by the coding unit (1) is recorded and is recorded as block_1_mid, and the number of blocks still required to be calculated is calculated, wherein block_rem=block_half-block_1_mid. For example, block-9980, then block_rem=16200-9980=6620.
3) Calculating the block initial position of the secondary coding of the coding unit (2),
block_start_temp = block_1_mid + block_rem/2;
block_start_temp = 9980+6620 = 16600;
then, the intermediate variables are aligned in a row direction of 240 blocks in the present proposal, and the aligned intermediate variables are aligned downwards to form blocks-16560, namely the position B in fig. 4, and the position coded by the computing unit (1), namely the position C in fig. 4 and the position block-16559 are recorded.
And calculating the secondary coding position and length according to the actual coding condition of the two paths of calculation units.
D.C. differential value calculation: the calculation process is the same as the process of pre-calculating the DC differential value, and the block-C U _1_last and the block-B are equivalent to U_2_first in the step of pre-calculating the DC differential value.
Address mapping calculation: and mapping the corresponding DDR address according to the secondary coding position and the length.
Image secondary coding and coding stream storage:
after the secondary calculation position of the calculation unit (2) is calculated, image data of the B position and the subsequent position (namely fourth image data) are read out from the DDR, and are calculated by the calculation unit, and the data are subjected to DCT, quantization, DPCM, RLE and Huffman coding in sequence. It should be noted that, after quantization processing, the Block is divided into a direct current DC component (located in the upper left corner of the entire 8×8 matrix) and an alternating current AC component (other than the direct current component by using run-length coding, the coding of the data is related to the current Block data only, and the DC component is a difference between the corresponding component of the current Block and the corresponding component of the previous Block in the differential coding mode, so that the direct current differential value calculated in the direct current differential value calculation step is used when the calculation unit (2) performs the calculation of the DC component of the first Block in the secondary calculation. The encoded data is stored in succession in the corresponding position in DDR of the computing unit (2), i.e. in position 3 in fig. 4.
The calculation unit (1) continues to calculate the subsequent image data and stores the subsequent image data in the corresponding positions in the DDR, namely blocks-9980 to block-16559.
In some embodiments, the method further comprises:
reading the encoded second image data from the memory after the encoding of all the second image data is completed, and performing data fusion on the read second image data;
and adding a header file for the fused data and outputting the data.
In some embodiments, the step of reading the encoded second image data from the memory and performing data fusion on the read second data includes:
reading the encoded second image data from the memory in sequence according to the original position of the encoded second image data in the memory;
and carrying out data fusion on the brightness and color information of the read second image data according to an image protocol standard.
In one embodiment, the process of image data fusion is described in connection with the image data compression flow of FIG. 2.
Data fusion: the encoded luma and chroma components are read from the DDR and reassembled together in a standard format.
After the encoding of all the images is completed, the encoded image data is read out from the DDR according to the original position of the image (read operation (3) in fig. 4), that is, the data of blocks 1-3-2 in the DDR are sequentially read. And the read data are recombined and fused together according to the information such as brightness, chromaticity and the like according to the protocol standard, so that the recombination of the data position and the format is completed. The protocol standard may be a JPEG standard.
Adding a header file and outputting:
adds information required by protocol standards (such as image size, quantization table, human table, etc.) and outputs the data.
The scheme of the invention realizes the improvement of compression performance by means of two-way (or multi-way) coding, self-adaptive secondary calculation and the like.
In some embodiments, the method further comprises:
and writing the first image data into the memory according to the data blocks.
According to the embodiment of the invention, the compression performance and the compression speed are improved by storing intermediate variables through reading and writing of DDR for many times, parallel computing of a multi-path coding unit, image pre-segmentation, pre-computing of direct current differential value, adaptive computing of secondary coding position, data fusion and other methods.
Based on the same inventive concept, according to another aspect of the present invention, as shown in fig. 5, an embodiment of the present invention further provides an image compression system, including:
An image pre-start segmentation module 110, the image pre-start segmentation module 110 configured to segment the first image data in the memory into a plurality of sets of second image data;
a pre-calculation direct current differential value module 120, the pre-calculation direct current differential value module 120 being configured to pre-calculate a first direct current differential value of adjacent second image data based on a segmentation result;
an address mapping calculation module 130, the address mapping calculation module 130 being configured to read the second image data from the memory;
and an encoding module 140, wherein the encoding module 140 is configured to encode the read second image data based on the first direct current differential value, and write the encoded second image data into the memory again.
By the scheme, the compression of the image data is realized, the compression speed of the image data is improved, and the performance of an image compression system is improved.
According to another aspect of the present invention, as shown in fig. 6, an electronic device 30 is further provided according to an embodiment of the present invention, where the electronic device 30 includes a processor 310 and a memory 320, and the memory 320 stores a computer program 321 that can be run on the processor, and the processor 310 executes the steps of the method as described above when executing the program.
The memory is used as a nonvolatile storage medium, and can be used for storing nonvolatile software programs, nonvolatile computer executable programs and modules, such as program instructions/modules corresponding to the compression method in the embodiment of the application. The processor executes various functional applications of the apparatus and data processing, namely, implements the compression method of the above-described method embodiments by running non-volatile software programs, instructions and modules stored in the memory.
The memory may include a memory program area and a memory data area, wherein the memory program area may store an operating system, at least one application program required for a function; the storage data area may store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the local module through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
According to another aspect of the present invention, as shown in fig. 7, there is also provided a storage medium 40, the storage medium 40 storing a computer program 410 which when executed by a processor performs the above method, based on the same inventive concept.
Finally, it should be noted that, as will be appreciated by those skilled in the art, all or part of the procedures in implementing the methods of the embodiments described above may be implemented by a computer program for instructing relevant hardware, and the program may be stored in a computer readable storage medium, and the program may include the procedures of the embodiments of the methods described above when executed. The storage medium of the program may be a magnetic disk, an optical disk, a read-only memory (ROM), a random-access memory (RAM), or the like. The computer program embodiments described above may achieve the same or similar effects as any of the method embodiments described above.
Those of skill would further appreciate that the various illustrative logical blocks, modules, circuits, and algorithm steps described in connection with the disclosure herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate this interchangeability of hardware and software, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as software or hardware depends upon the particular application and design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. The foregoing embodiment of the present invention has been disclosed with reference to the number of embodiments for the purpose of description only, and does not represent the advantages or disadvantages of the embodiments. Furthermore, although elements of the disclosed embodiments may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that as used herein, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
Those of ordinary skill in the art will appreciate that: the above discussion of any embodiment is merely exemplary and is not intended to imply that the scope of the disclosure of embodiments of the invention, including the claims, is limited to such examples; combinations of features of the above embodiments or in different embodiments are also possible within the idea of an embodiment of the invention, and many other variations of the different aspects of the embodiments of the invention as described above exist, which are not provided in detail for the sake of brevity. Therefore, any omission, modification, equivalent replacement, improvement, etc. of the embodiments should be included in the protection scope of the embodiments of the present invention.
Claims (20)
1. An image compression method, comprising:
dividing the first image data in the memory into a plurality of sets of second image data;
pre-calculating a first direct current differential value adjacent to the second image data based on the segmentation result;
reading the second image data from the memory;
and encoding the read second image data based on the first direct current differential value, and writing the encoded second image data into the memory again.
2. The method of claim 1, wherein after the step of dividing the first image data in the memory into a plurality of sets of second image data, comprising:
assigning each set of the second image data to a corresponding computing unit;
the step of encoding the read second image data based on the first direct current differential value includes:
the computing unit encodes the second image data based on the first direct current differential value.
3. The method as recited in claim 2, further comprising:
and distributing uncoded second image data to the computing units with finished coding for secondary coding and storage through image self-adaptive segmentation in response to the fact that part of the computing units do not finish the second image data needing to be coded.
4. The method of claim 2, wherein the step of dividing the first image data in the memory into a plurality of sets of second image data comprises:
the first image data in the memory is divided into a plurality of sets of the second image data on average, wherein the number of the packets corresponds to the number of the calculation units.
5. The method as recited in claim 4, further comprising:
a first starting position of the second image data in the memory is calculated.
6. The method of claim 5, wherein the pre-calculating the first direct current differential value adjacent to the second image data comprises:
determining a storage address of a first data block and a storage address of a second data block corresponding to the second image data based on the calculated first starting position, wherein the second image data is stored in the memory in units of data blocks, the first data block is the first data block corresponding to the second image data, and the second data block is the last data block corresponding to the second image data;
the second image data is read based on the storage address of the first data block and the storage address of the second data block and transferred to the calculation unit to calculate the first direct current differential value.
7. The method of claim 6, wherein the step of calculating the first direct current differential value comprises:
calculating the direct current coefficients of the brightness and the chromaticity of the third image data stored by the first data block and the direct current coefficients of the brightness and the chromaticity of the third image data stored by the second data block;
the first direct current differential value is calculated based on the direct current coefficients of the luminance and the chromaticity of the third image data stored in the first data block and the direct current coefficients of the luminance and the chromaticity of the third image data stored in the second data block obtained by the adjacent calculating unit.
8. The method of claim 1, wherein the step of reading the second image data from the memory comprises:
each set of the second image data is read in parallel from the memory.
9. The method of claim 1, wherein the step of reading the second image data from the memory comprises:
and calculating a storage address of the second image data, and reading the second image data based on the storage address.
10. The method of claim 1, wherein the step of encoding the read second image data based on the first direct current differential value comprises:
And sequentially performing discrete cosine transform, quantization, differential pulse coding, run-length coding and Huffman coding on the read second image data, wherein the differential pulse coding is performed based on the first direct current differential value.
11. A method according to claim 3, wherein the step of distributing the uncoded second image data to the encoded computing unit for secondary encoding and storage by image adaptive segmentation comprises:
determining the position of the last data block corresponding to the encoded second image data in the memory;
distributing the uncoded second image data to the computing unit after coding is completed through image self-adaptive segmentation;
determining a second starting position of the corresponding data block in the memory based on fourth image data which is allocated to the calculation unit after encoding is completed and needs to be encoded again, and calculating a second direct current differential value based on the second starting position and the position;
and the calculation unit after the encoding is completed performs secondary encoding and storage on the fourth image data based on the second direct current differential value.
12. The method of claim 11, wherein the step of determining a second starting position of the corresponding data block in the memory based on fourth image data allocated to the calculation unit to be encoded again after the encoding is completed comprises:
And determining the second starting position of the data block corresponding to the fourth image data in the memory based on the encoded second image data and the unencoded second image data.
13. The method of claim 11, wherein the step of determining a second starting position of the corresponding data block in the memory based on fourth image data allocated to the calculation unit to be encoded again after the encoding is completed comprises:
recording the number of the encoded data blocks, and calculating the number of the data blocks still needing to be encoded based on the number of the encoded data blocks;
calculating an initial starting position of a data block corresponding to the fourth image data in the memory based on the number of data blocks still required to be encoded and the number of data blocks already encoded;
and carrying out data block line alignment processing on the calculated initial starting position to determine the second starting position of the data block corresponding to the fourth image data in the memory.
14. The method as recited in claim 11, further comprising:
after the computing unit finishes encoding, recording a write address corresponding to the encoding completed computing unit;
The step of the computing unit after the encoding is completed, which performs secondary encoding and storage on the fourth image data based on the second direct current differential value, includes:
and the calculation unit after the encoding is completed carries out secondary encoding and storage on the fourth image data based on the second direct current differential value and the recorded write address.
15. The method according to any one of claims 1 to 14, further comprising:
reading the encoded second image data from the memory after the encoding of all the second image data is completed, and performing data fusion on the read second image data;
and adding a header file for the fused data and outputting the data.
16. The method of claim 15, wherein the step of reading the encoded second image data from the memory and performing data fusion on the read second image data comprises:
reading the encoded second image data from the memory in sequence according to the original position of the encoded second image data in the memory;
and carrying out data fusion on the brightness and color information of the read second image data according to an image protocol standard.
17. The method as recited in claim 1, further comprising:
the first image data is written into the memory in units of data blocks.
18. An image compression system, comprising:
an image pre-start segmentation module configured to segment the first image data in the memory into a plurality of sets of second image data;
a pre-calculation direct current differential value module configured to pre-calculate a first direct current differential value adjacent to the second image data based on a division result;
an address mapping calculation module configured to read the second image data from the memory;
and an encoding module configured to encode the read second image data based on the first direct current differential value, and write the encoded second image data again to the memory.
19. An electronic device, comprising:
at least one processor; and
a memory storing a computer program executable on the processor, wherein the processor performs the steps of the method of any one of claims 1 to 17 when the program is executed.
20. A storage medium storing a computer program which, when executed by a processor, performs the steps of the method of any one of claims 1 to 17.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310316590.8A CN116055743B (en) | 2023-03-29 | 2023-03-29 | Image compression method, system, electronic equipment and storage medium |
PCT/CN2024/080580 WO2024198887A1 (en) | 2023-03-29 | 2024-03-07 | Image compression method and system, electronic device, and non-volatile readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310316590.8A CN116055743B (en) | 2023-03-29 | 2023-03-29 | Image compression method, system, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN116055743A true CN116055743A (en) | 2023-05-02 |
CN116055743B CN116055743B (en) | 2023-07-14 |
Family
ID=86116643
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310316590.8A Active CN116055743B (en) | 2023-03-29 | 2023-03-29 | Image compression method, system, electronic equipment and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN116055743B (en) |
WO (1) | WO2024198887A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024198887A1 (en) * | 2023-03-29 | 2024-10-03 | 山东云海国创云计算装备产业创新中心有限公司 | Image compression method and system, electronic device, and non-volatile readable storage medium |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH05227519A (en) * | 1991-03-19 | 1993-09-03 | Olympus Optical Co Ltd | Encoder and decoder for picture data |
US6614483B1 (en) * | 1998-04-30 | 2003-09-02 | Hynix Semiconductor Inc. | Apparatus and method for compressing image data received from image sensor having bayer pattern |
JP2008104164A (en) * | 2006-09-19 | 2008-05-01 | Ricoh Co Ltd | Image processor, and image processing method |
CN104125461A (en) * | 2013-04-27 | 2014-10-29 | 深圳市振华微电子有限公司 | Large-size image compression processing system and method |
CN109842803A (en) * | 2018-09-19 | 2019-06-04 | 华为技术有限公司 | A kind of method and device of compression of images |
CN112422985A (en) * | 2020-10-26 | 2021-02-26 | 眸芯科技(上海)有限公司 | Multi-core parallel hardware coding method and device suitable for JPEG |
CN113301344A (en) * | 2021-05-22 | 2021-08-24 | 兰州大学 | Image compression and decompression method based on FPGA |
CN114125463A (en) * | 2021-11-14 | 2022-03-01 | 山东云海国创云计算装备产业创新中心有限公司 | Video compression method, system, storage medium and equipment |
CN114173126A (en) * | 2021-12-16 | 2022-03-11 | 广东赛昉科技有限公司 | RISC-V SOC based jpeg image coding method and system |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW376628B (en) * | 1997-05-06 | 1999-12-11 | Holtek Semiconductor Inc | Method of accelerating JPEG quantization calculation in image compression |
CN108200436B (en) * | 2017-12-29 | 2019-06-18 | 华中科技大学 | A kind of lossless compression method towards alignment scanned infrared imaging heterogeneity residual error |
CN114157871A (en) * | 2021-11-25 | 2022-03-08 | 北京澜景科技有限公司 | Video encoding and decoding method, device, equipment and storage medium |
CN116055743B (en) * | 2023-03-29 | 2023-07-14 | 山东云海国创云计算装备产业创新中心有限公司 | Image compression method, system, electronic equipment and storage medium |
-
2023
- 2023-03-29 CN CN202310316590.8A patent/CN116055743B/en active Active
-
2024
- 2024-03-07 WO PCT/CN2024/080580 patent/WO2024198887A1/en unknown
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH05227519A (en) * | 1991-03-19 | 1993-09-03 | Olympus Optical Co Ltd | Encoder and decoder for picture data |
US6614483B1 (en) * | 1998-04-30 | 2003-09-02 | Hynix Semiconductor Inc. | Apparatus and method for compressing image data received from image sensor having bayer pattern |
JP2008104164A (en) * | 2006-09-19 | 2008-05-01 | Ricoh Co Ltd | Image processor, and image processing method |
CN104125461A (en) * | 2013-04-27 | 2014-10-29 | 深圳市振华微电子有限公司 | Large-size image compression processing system and method |
CN109842803A (en) * | 2018-09-19 | 2019-06-04 | 华为技术有限公司 | A kind of method and device of compression of images |
CN112422985A (en) * | 2020-10-26 | 2021-02-26 | 眸芯科技(上海)有限公司 | Multi-core parallel hardware coding method and device suitable for JPEG |
CN113301344A (en) * | 2021-05-22 | 2021-08-24 | 兰州大学 | Image compression and decompression method based on FPGA |
CN114125463A (en) * | 2021-11-14 | 2022-03-01 | 山东云海国创云计算装备产业创新中心有限公司 | Video compression method, system, storage medium and equipment |
CN114173126A (en) * | 2021-12-16 | 2022-03-11 | 广东赛昉科技有限公司 | RISC-V SOC based jpeg image coding method and system |
Non-Patent Citations (2)
Title |
---|
RAFAEL GALVÃO DE OLIVEIRA: "Intra-frame prediction with lapped transforms for image coding", 《 2011 IEEE INTERNATIONAL CONFERENCE ON ACOUSTICS, SPEECH AND SIGNAL PROCESSING (ICASSP)》 * |
李金凤;高巍;: "基于DCT变换矢量数据压缩", 计算机应用与软件, no. 11 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2024198887A1 (en) * | 2023-03-29 | 2024-10-03 | 山东云海国创云计算装备产业创新中心有限公司 | Image compression method and system, electronic device, and non-volatile readable storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN116055743B (en) | 2023-07-14 |
WO2024198887A1 (en) | 2024-10-03 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9716891B2 (en) | Quantization method and apparatus in encoding/decoding | |
US7843998B2 (en) | Method for improved entropy coding | |
CN108271024B (en) | Image coding and decoding method and device | |
EP3512199B1 (en) | Image coding apparatus, method for coding image, program therefor, image decoding apparatus, method for decoding image, and program therefor | |
US20060017592A1 (en) | Method of context adaptive binary arithmetic coding and apparatus using the same | |
WO2015078422A1 (en) | Image encoding and decoding method and device | |
JP4440308B2 (en) | Rate control method and system in image compression | |
CN116055743B (en) | Image compression method, system, electronic equipment and storage medium | |
CN115474062B (en) | Method, system, chip and electronic equipment for improving JPEG compression quality | |
US11202085B1 (en) | Low-cost hash table construction and hash-based block matching for variable-size blocks | |
CN114786011A (en) | JPEG image compression method, system, equipment and storage medium | |
JP3940672B2 (en) | Image processing apparatus and image processing method | |
US20210250575A1 (en) | Image processing device | |
CN116112683A (en) | Video compression method, apparatus, computer device and storage medium | |
CN113395516B (en) | Intra-frame prediction method and device, and computer readable storage medium | |
CN113709459B (en) | Intra-frame prediction method, device and computer storage medium | |
US7199733B2 (en) | Variable length decoding apparatus and method for the image format of a digital video camera | |
US7477787B2 (en) | Image compression device and method | |
US11515961B2 (en) | Encoding data arrays | |
KR100753504B1 (en) | In-loop Deblocking Filter System and method for filterring data using the same | |
WO2023083239A1 (en) | Image decoding method and apparatus, and image encoding method and apparatus | |
WO2024060791A1 (en) | Multimedia data processing method and apparatus, and device, storage medium and program product | |
JP2020530229A (en) | Motion compensation reference frame compression | |
US7787537B2 (en) | Method and apparatus for low-memory high-performance discrete cosine transform coefficient prediction | |
WO2024212190A1 (en) | Encoding and decoding methods and apparatuses, codec, bitstream, device, and storage medium |
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 |