CN108429910B - Image compression method - Google Patents

Image compression method Download PDF

Info

Publication number
CN108429910B
CN108429910B CN201710081374.4A CN201710081374A CN108429910B CN 108429910 B CN108429910 B CN 108429910B CN 201710081374 A CN201710081374 A CN 201710081374A CN 108429910 B CN108429910 B CN 108429910B
Authority
CN
China
Prior art keywords
block
mode
binarization
component
grouping
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
Application number
CN201710081374.4A
Other languages
Chinese (zh)
Other versions
CN108429910A (en
Inventor
李英
董火新
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ali Corp
Original Assignee
Ali Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ali Corp filed Critical Ali Corp
Priority to CN201710081374.4A priority Critical patent/CN108429910B/en
Publication of CN108429910A publication Critical patent/CN108429910A/en
Application granted granted Critical
Publication of CN108429910B publication Critical patent/CN108429910B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/186Methods 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/587Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal sub-sampling or interpolation, e.g. decimation or subsequent interpolation of pictures in a video sequence

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

An image compression method. The first block, the second block and the third block are respectively used as compression units of a luminance component, a first chrominance component and a second chrominance component of the image. And respectively performing compression coding calculation on the brightness component of the first block, the first chrominance component of the second block and the second chrominance component of the third block according to the prediction results of the candidate prediction modes to obtain the pre-compressed data size after the summation of the first block, the second block and the third block corresponding to each candidate prediction mode so as to determine the prediction mode. If the pre-compressed data size of the prediction mode is larger than or equal to the total original data size of the components of the first block, the second block and the third block, the components of the first block, the second block and the third block are not compressed. If the pre-compressed data size is smaller than the original data size, each component of the first block, the second block and the third block is encoded in a semi-fixed length mode.

Description

Image compression method
Technical Field
The present invention relates to an encoding method, and more particularly, to an image compression method.
Background
With the occurrence of 4K high resolution and 10 bit color depth code streams, the data transmission capacity of a Video Codec (Video Codec) is remarkably increased and can reach 3GB/s, and the bandwidth of hardware is more sensitive. Therefore, the data access amount of the image can be greatly reduced by storing and compressing the image frame, and the utilization rate of the hardware bandwidth is improved. Conventional frame storage compression algorithms include lossy compression (lossy compression) and lossless compression (lossless compression). With lossless compression, every data in the original document remains after decompression, and all information can be fully recovered. Lossy compression is typically used for video or audio, and most users do not perceive a certain amount of information loss.
Disclosure of Invention
The invention provides an image compression method, which improves the existing frame storage compression algorithm, reduces the decoding bandwidth requirement and improves the parallelism of hardware implementation.
The image compression method of the present invention includes: respectively taking the first block, the second block and the third block as compression units of a brightness component, a first chrominance component and a second chrominance component of the image; respectively performing compression coding calculation on the brightness component of the first block, the first chrominance component of the second block and the second chrominance component of the third block according to the prediction results of the candidate prediction modes to obtain the pre-compressed data size after the summation of the first block, the second block and the third block corresponding to each candidate prediction mode so as to determine the prediction mode; if the pre-compressed data size of the prediction mode is larger than or equal to the total original data size of the components of the first block, the second block and the third block, not compressing the components of the first block, the second block and the third block; and if the pre-compressed data size is smaller than the original data size, performing semi-fixed length coding on each component of the first block, the second block and the third block in a prediction mode.
In an embodiment of the present invention, the step of performing semi-fixed length coding includes: the first block, the second block and the third block are respectively divided again to obtain a plurality of groups, wherein each group comprises a plurality of small blocks, and the size of each small block is the same; selecting the maximum absolute value of the residual errors as a representative value of each small block based on the residual errors corresponding to the pixels of each small block; obtaining a binarization mode corresponding to the representative numerical value; determining a grouping mode corresponding to each group and a binarization mode needing to be encoded based on a binarization mode corresponding to each small block; and combining the prediction seed data, the prediction mode, the grouping mode, the binarization mode needing to be coded and the residual coding data of each component of the first block, the second block and the third block to obtain a compressed code stream.
In an embodiment of the present invention, the image compression method further includes: and establishing a binarization mode table. The binarization mode table comprises a plurality of binarization modes, and each binarization mode corresponds to a numerical range, an occupied length and an encoding rule. The step of obtaining the binarization mode corresponding to the representative value comprises the following steps: and searching the binarization mode table to determine the value range in which the representative value is located, and further obtaining the corresponding binarization mode, the occupied length and the encoding rule.
In an embodiment of the present invention, the image compression method further includes: and establishing a grouping table based on the groups respectively included in the first block, the second block and the third block. The grouping table comprises a plurality of grouping types, and each grouping type corresponds to a grouping mode and a corresponding binarization mode needing to be encoded. Based on the binarization mode corresponding to each small block, determining a grouping mode corresponding to each group and a binarization mode needing encoding, wherein the step comprises the following steps of: and searching the grouping table to obtain a grouping mode corresponding to each group and a binarization mode needing to be encoded.
In an embodiment of the invention, the encoding rule is a two's complement code.
In an embodiment of the present invention, the coding rule is a binary value of plus/minus sign bit plus absolute value of residual error.
In an embodiment of the present invention, the step of determining the prediction mode from a plurality of candidate prediction modes comprises: a candidate test pattern corresponding to the minimum value is selected from the plurality of pre-compressed data sizes as a prediction pattern.
In an embodiment of the present invention, the step of performing compression coding calculation on the luma component of the first block, the first chroma component of the second block, and the second chroma component of the third block includes: dividing the first block, the second block and the third block into a plurality of groups respectively; obtaining a plurality of residuals of each small block of each group based on a prediction result of the corresponding candidate prediction mode to select a representative value of each small block; obtaining a binarization mode and an occupation length corresponding to the representative numerical value; determining a grouping mode corresponding to each group and a binarization mode needing to be encoded based on a binarization mode corresponding to each small block; and calculating the pre-compression data size according to the number of the binarization modes needing to be coded and the occupation length.
In an embodiment of the invention, the luminance component is a Y component, the first chrominance component is a Cb component, and the second chrominance component is a Cr component. The predicted data size and the original data size are one of a byte number, a character number and a bit number.
In an embodiment of the invention, the prediction mode is one of a horizontal prediction mode, a vertical prediction mode, a horizontal average prediction mode, and a vertical average prediction mode.
Based on the above, the data amount of each macro block (macro block) after compression is not more than the original data amount, so that the existing frame storage compression algorithm is improved, the bandwidth requirement of decoding is reduced, and the parallelism of hardware implementation is improved.
In order to make the aforementioned and other features and advantages of the invention more comprehensible, embodiments accompanied with figures are described in detail below.
Drawings
FIG. 1 is a flow chart of an image compression method according to an embodiment of the invention.
Fig. 2 is a flow chart of semi-fixed length encoding according to an embodiment of the invention.
FIG. 3 is a block partitioning diagram according to an embodiment of the invention.
Fig. 4 is a schematic diagram of a grouping type according to an embodiment of the present invention.
Description of the reference numerals
Y, Cb, Cr: component(s) of
G1-G6: grouping
Y10-Y13, b 0-b 3, r 0-r 3: small block
a to d: residual error
M1-M8, N1-N8: type of marshalling
Sy, Scb, Scr: predicting seeds
S105 to S125: image compression method steps
S205 to S225: each step of semi-fixed length coding
Detailed Description
In the following embodiments, the image compression method is implemented by an electronic device with an arithmetic function. The electronic device is, for example, a Computer, a laptop Computer (laptop Computer), a Tablet Computer (Tablet Computer), a smart phone, a smart tv, or a set top box (set top box). The processor of the electronic device is used to execute the program code or software stored in the memory, so as to implement the image compression method described below.
FIG. 1 is a flow chart of an image compression method according to an embodiment of the invention. Referring to fig. 1, in step S105, a processor (not shown) may determine a compression unit used in the compression process according to different color coding formats. Here, the pixel sizes corresponding to the first block, the second block, and the third block are used as compression units of a luminance component (component), a first chrominance component, and a second chrominance component of the image, respectively. When performing compression, a frame of image is first divided into a plurality of macro blocks (macro blocks), each macro block including a first block representing a luminance component, a second block representing a first chrominance component, and a third block representing a second chrominance component.
In color coded format YUV4:2: 0, the luminance component is the Y component, the first chrominance component is the Cb component, and the second chrominance component is the Cr component. For example, in the compression process, the Y component of each macroblock has 16 × 4 pixels as a compression unit (i.e., a first block), the Cb component has 8 × 2 pixels as a compression unit (i.e., a second block), and the Cr component has 8 × 2 pixels as a compression unit (i.e., a third block).
Next, in step S110, the processor determines a prediction mode from a plurality of preset candidate prediction modes. Here, the candidate prediction modes are, for example, a combination of a horizontal difference prediction mode, a vertical difference prediction mode, a horizontal average prediction mode, a vertical average prediction mode, or other prediction modes based on Differential Pulse-code Modulation (DPCM). In this step, according to the prediction results of the candidate prediction modes, the luma component of the first block, the first chroma component of the second block, and the second chroma component of the third block are compressed and encoded, so as to obtain the pre-compressed data size of the first block, the second block, and the third block corresponding to each candidate prediction mode. The pre-compressed data size is, for example, the number of bytes, characters, or bits.
For example, the number of bits is calculated by performing compression coding in advance for each candidate prediction mode so as to obtain the number of bits compressed according to different candidate prediction modes of the same macroblock. More specifically, in a specific candidate prediction mode (e.g., the horizontal difference prediction mode), the processor calculates the prediction results (e.g., calculates the residual of each pixel component) of the components of each pixel in the first block, the second block, and the third block according to the specific candidate prediction mode, and performs the compression coding calculation on the first block according to the prediction result of the first block, the second block according to the prediction result of the second block, and the third block according to the prediction result of the third block, so as to obtain the number of bits occupied by the Y component of the first block, the number of bits occupied by the Cb component of the second block, and the number of bits occupied by the Cr component of the third block. And finally, adding the bit numbers occupied by the Y component, the Cb component and the Cr component to obtain the pre-compressed data size corresponding to the specific candidate prediction mode. The "occupied number of bits" referred to above refers to the number of bits that need to be stored.
After the first block, the second block and the third block in a macro block are respectively coded and calculated by each candidate prediction mode, and the pre-compressed data size (such as the total bit number required to be stored after compression) corresponding to each candidate prediction mode is obtained, the candidate prediction mode corresponding to the minimum value of the total bit number in the candidate prediction mode is taken out to be used as the prediction mode, so that the subsequent semi-fixed length coding is carried out, and the candidate prediction mode is also used as the prediction mode corresponding to the final assembled code stream.
Next, in step S115, the processor determines whether the pre-compressed data size corresponding to the prediction mode is larger than or equal to the original data size (e.g., the total number of bits of the original data) obtained by summing the uncompressed components of the first block, the second block, and the third block. If the pre-compressed data size of the prediction mode is larger than or equal to the original data size, the components of the first block, the second block and the third block are not compressed, i.e. Y, Cb and Cr data in the macro block are not compressed, as shown in step S120. If the pre-compressed data size is smaller than the original data size, in step S125, the component data of the first block, the second block and the third block are encoded with a semi-fixed length according to the prediction result generated by the selected prediction mode, so as to compress the data size of each block. For example, after performing prediction and encoding calculation on the first to third blocks according to the candidate prediction modes, and when determining that the pre-compressed data size corresponding to the horizontal difference prediction mode is the minimum, the processor performs subsequent semi-fixed length encoding on the residual (i.e., the prediction result) calculated by the horizontal difference prediction mode for the first to third blocks.
The flow of half-length encoding is described below with an embodiment.
Fig. 2 is a flow chart of semi-fixed length encoding according to an embodiment of the invention. Referring to fig. 2, the processor first performs block division. In step S205, the first block, the second block and the third block are respectively subdivided to obtain a plurality of groups, wherein each group includes a plurality of small blocks, and each small block has the same size and includes a plurality of pixels.
Please refer to fig. 3. FIG. 3 is a block partitioning diagram according to an embodiment of the invention. The following description will proceed with the YUV4:2: 0 format as an example. In fig. 3, the Y component (first tile) of 16 × 4 pixels is divided into 4 adjacent groups G1 to G4, the groups G1 to G4 respectively including 2 × 2 small blocks. For grouping G1, it includes 4 tiles Y10-Y13, and so on for other groupings. And, each tile in turn comprises 2 × 2 pixels, with each pixel having a corresponding residual.
In addition, the Cb component (second block) of 8 × 2 pixels and the Cr component (third block) of 8 × 2 pixels are divided into 1 group, i.e., group G5 and group G6, respectively. Group G5 includes 4 adjacent tiles b 0-b 3, and group G6 includes 4 adjacent tiles r 0-r 3. And, each tile includes 2 × 2 pixels, and each pixel has a corresponding cb (cr) component residual.
Next, returning to fig. 2, in step S210, based on a plurality of residuals corresponding to a plurality of pixels of each tile, the maximum absolute value of the plurality of residuals is selected as a representative value for each tile. Referring to fig. 3 again, regarding the block Y13, the block Y13 includes 4 pixels, and the residuals of the pixels are a, b, c, and d, respectively, where a, b, c, and d are integers. Of the absolute values of the residuals a, b, c, d, the maximum value is selected as the representative value of the tile Y13.
Next, in step S215, a binarization pattern corresponding to the representative value is obtained. In this embodiment, the binarization mode table can be searched to determine the value range in which the representative value is located, so as to obtain the corresponding binarization mode, the occupied length, and the encoding rule. That is, for the block division of fig. 3, for each small block, a table is looked up according to the maximum absolute value of the residual error to obtain the binarization pattern of each small block.
That is, the image compression method further includes establishing a binarization mode table, and storing the binarization mode table in a memory of the electronic device for a processor to read and compare according to instructions of software/programs. The binarization pattern table may include a plurality of binarization patterns, each binarization pattern corresponding to a value range, an occupied length and an encoding rule. Table 1 shows an example of a binarization mode table, wherein the occupied length represents the number of bits required for storing residuals corresponding to each pixel in the same small block; the numerical ranges are ranges representing numerical values, each of the numerical ranges being non-overlapping; the coding rule refers to a compression coding mode of each residual in the same small block.
TABLE 1
Figure BDA0001226001400000061
For example, assuming that the residuals a, b, c, d of the tile Y13 are-30, 24, -28, 32, respectively, the maximum 32 of the absolute values of the four is selected as the representative value of the tile Y13. The representative value 32 is used to look up the value range of table 1, which is located in the interval of 32-63, the corresponding binarization mode obtained by looking up the table is 110, the occupied length is 7 bits, and the coding rule is "two-system complement". By analogy, the binarization mode, the occupied length and the encoding rule corresponding to each small block in the Y component, the Cb component and the Cr component can be obtained.
In table 1, 8 binarization patterns are included, and 3 bits are used to represent each pattern (i.e., 000 to 111), respectively. The binarization mode "000" corresponds to a small block representing a value of 0 (i.e. the residual errors in the small block are all 0), so that the small block corresponding to the binarization mode does not need to be encoded and does not consume any bit number. On the other hand, when the representative value is greater than or equal to a certain range, the components of 4 pixels in the small block are not compressed, which is greater than or equal to 64 in the example of table 1. In other words, the binarization mode "111" does not implement the compression of the small blocks, that is, when the compressed code stream is assembled, the small blocks corresponding to the binarization mode "111" are directly assembled by the original data of each component, so that the occupied length thereof is the original bit depth (bit depth) of the original data.
In the example shown in table 1, the coding rule corresponding to the other binarization modes except the 2 binarization modes is "two's complement". For example, the complement of residue 5 is 0101 and the complement of residue-5 is 1011. In other embodiments, the encoding rule may also be "sign bit plus residual absolute value binary". Assuming that the most significant bit is taken as the sign bit, and 0 represents the sign of a positive number, 1 represents the sign of a negative number, the residual 5 can be encoded as 0101, and the residual-5 can be encoded as 1101.
In addition, other binarization pattern tables, such as another binarization pattern table shown in table 2, may be used as appropriate. The binarization mode table shown in table 2 mainly combines several adjacent intervals with smaller probability in the value ranges, for example, the values 1-7 are divided into three value ranges in table 1, and are combined and divided into two value ranges in table 2, so as to increase the interval of the value ranges 64-127 for encoding, thereby realizing data compression in a larger range. It should be noted that the occupation length corresponding to each binarization mode is different according to the value range. Specifically, if the maximum value of the specific numerical range is M, then 2(N-1)<M<2NThe corresponding occupancy length is (N +1) bits, where M, N is a positive integer. Comparing tables 1 and 2, the binarization pattern table shown in Table 1 divides the value rangeThe residual block compression method is more precise, the bit number consumed by residual coding can be saved (especially when the residual of each small block is mostly less than 64), and the range of the residual small blocks (when the binarization mode is 001-110) which can be compressed in the table 2 is larger (1-127). The present invention does not limit the interval representing the value, the number of the binarization modes or the occupied length in the binarization mode table, and the binarization mode table may be changed according to the above principle according to the design or implementation requirements.
TABLE 2
Figure BDA0001226001400000071
Then, in step S220, based on the binarization mode corresponding to each small block, the grouping mode corresponding to each group and the binarization mode to be encoded are determined, so as to eliminate the spatial correlation between the small blocks, thereby saving the storage space required to be consumed after encoding. With the block division of fig. 3, for each packet, a grouping mode and a binarization mode to be encoded are determined according to the binarization modes of the included 4 small blocks. The 4 binarization patterns included in each packet can be distinguished into a plurality of grouping types.
In this embodiment, at least one grouping table may be pre-established based on the grouping type of the first block, the second block, and the third block, and stored in the storage. The grouping table comprises a plurality of grouping types, and each grouping type corresponds to a grouping mode and a corresponding binarization mode needing encoding.
For example, tables 3 and 4 are grouping tables according to an embodiment of the present invention. The grouping types M1 to M8 are suitable for the grouping type of 2 × 2 small blocks (e.g., grouping G1 to G4), and the grouping types N1 to N8 are suitable for the grouping type of 4 × 1 small blocks (e.g., grouping G5 and G6). pbm represents the binarization mode and number to be encoded. pbm is used to indicate the number of binarization modes to be encoded (which would need to be known during pre-encoding) corresponding to a grouping mode, and also to indicate which binarization modes are used for a particular group (which would need to be known during actual encoding).
TABLE 3
Figure BDA0001226001400000081
TABLE 4
Figure BDA0001226001400000082
Please refer to fig. 4. Fig. 4 is a schematic diagram of a grouping type according to an embodiment of the present invention. The grouping type M1 shown in table 3 represents that the binarization modes corresponding to the 4 patches are the same. The grouping types M2 to M7 represent that two binarization modes are included in 4 small blocks. The grouping type M2 represents that the binarization pattern of the upper left tile is different from the binarization patterns of the other 3 tiles, M3 represents that the binarization pattern of the upper right tile is different from the binarization patterns of the other 3 tiles, M4 represents that the binarization pattern of the lower left tile is different from the binarization patterns of the other 3 tiles, M5 represents that the binarization pattern of the lower right tile is different from the binarization patterns of the other 3 tiles, M6 represents that the binarization pattern of the upper 2 tiles is different from the binarization pattern of the lower 2 tiles, and M7 represents that the binarization pattern of the lower 2 tiles is different from the binarization pattern of the upper 2 tiles. While the modes not belonging to the grouping types M1-M7 are all classified into the grouping type M8, which in this embodiment means: the 4 small blocks comprise two binarization modes which do not belong to M2-M7 configuration, the 4 small blocks comprise three binarization modes, or the four binarization modes corresponding to the 4 small blocks are all different.
Similarly, the grouping type N1 of table 4 represents that the binarization patterns of the 4 patches are the same. Grouping types N2 to N7 represent that two binarization modes are included in 4 small blocks. N2 indicates that the binarization pattern of the leftmost tile is different from the binarization patterns of the other 3 tiles. N3 indicates that the binarization pattern of the left 2 nd small block is different from the binarization patterns of the other 3 small blocks. N4 indicates that the binarization pattern of the left 3 rd small block is different from that of the other 3 small blocks. N5 indicates that the binarization pattern of the rightmost tile is different from the binarization patterns of the other 3 tiles. N6 indicates that the binarization patterns of the leftmost and 3 rd small blocks are the same, and the binarization patterns of the remaining 2 small blocks are the same. N7 indicates that the binarization pattern of the left 2 small blocks is different from the binarization pattern of the right 2 small blocks. Similar to the M8 principle, the patterns not belonging to the grouping types N1-N7 are all classified into the grouping type N8. The processor can execute instructions to perform operations according to the positions of the small blocks in the specific grouping and the corresponding binarization modes thereof, so as to judge the grouping type corresponding to the specific grouping, and the number and the type of the binarization modes required to be coded by the specific grouping can also be known from the operation process.
When pbm has only "bm 0" representing only 1 binarization pattern to be encoded, the binarization pattern is a value obtained from the binarization pattern table. pbm is "bm 0, bm 1" represents 2 binarization patterns. The following description will be made by taking a packet having 2 × 2 small blocks as an example. Assuming that the binarization patterns corresponding to the 4 small blocks are 001, and 001, indicating that the grouping type is M1, it can be known from table 3 that the grouping pattern is 000, and the binarization pattern to be encoded is bm0 (indicating that there are only 1 binarization pattern), i.e. the same binarization pattern 001 for the 4 small blocks. Further, assuming that the binarization modes corresponding to the 4 small blocks are 001, 100 and 100 in order from top left, top right, bottom left and bottom right, the grouping type is M6, and it can be known from table 3 that the grouping mode is 101, and the binarization modes to be encoded are bm0 and bm1 (indicating that there are 2 binarization modes), i.e., the binarization modes to be encoded are 001 and 100.
In addition, pbm corresponding to the group type M8 and the group type N8 is "bm 0, bm1, bm2, bm 3". For example, in the case of the group G1, assuming that the binarization modes corresponding to 4 small blocks are 001, 011, 101, and 100 (grouping type M8), respectively, 4 different binarization modes are represented, and the binarization modes to be encoded are bm0, bm1, bm2, and bm3, that is, original 001, 011, 101, and 100. It is assumed that the binarization modes corresponding to the 4 small blocks are 001, 011, 001, and 100, respectively, and there are only 3 different binarization modes, but in the present embodiment, in order to avoid the excessive grouping type and the excessive data size consumed by the grouping, this case also corresponds to the grouping type M8, and the original 4 binarization modes are encoded, in other words, the binarization modes that need to be encoded are 001, 011, 001, and 100. It is further assumed that the binarization modes corresponding to the 4 small blocks are 001, 100, and 001 in order from top left, top right, bottom left, and bottom right, and there are only 2 binarization modes (i.e. 001 and 100), but the configuration is different from the grouping types M2-M7, and the grouping type M8 is also corresponded to in this embodiment, so the encoding is performed according to the original 4 binarization modes, i.e. the binarization modes to be encoded are 001, 100, and 001.
Finally, after all the groups (G1-G6 shown in fig. 3) in the first block, the second block and the third block complete the operations of the steps S210-S220, in step S225, the prediction seed data of the first block, the second block and the third block, the prediction mode selected in the current encoding, the grouping mode of each group, the binarization mode to be encoded and the residual encoded data of each pixel of each small block are combined to obtain the compressed code stream of all the components Y, Cr and Cb of the first block to the third block. The prediction seed data is the original data of the top left pixel (shown in fig. 3 as Sy, Scb and Scr pixels, which are prediction seeds) of each component, which is used as the basis of the prediction matrix.
Here, the top-left pixel of each block is used as the prediction seed data, and the storage size required for each block containing the small blocks of the top-left pixels (such as Y10, b0 and r0 of fig. 3) is 3 × the occupied length (each small block includes 2 × 2 pixels). This is because the top-left most pixel has been taken as the prediction seed data and therefore only the other 3 pixels are considered. While the storage size required for the other small blocks is 4 x the footprint length. Next, the binarization mode to be encoded for each packet is determined based on the binarization modes of the 4 patches within the packet.
Finally, for each compressed macroblock, the storage size consumed by the compressed code stream is: prediction seed data, prediction mode data, grouping mode data of all the groups, binarization mode data required to be coded by a grouping mode corresponding to each group, and the bit number of residual coded data obtained by residual coding all the small blocks of the first block to the third block.
The data size (i.e., the size of the consumed storage) of the compressed bitstream is illustrated in detail in FIGS. 3-4 and tables 1 and 3-4. If the original image data is 8-bit code stream, the prediction seeds Sy, Scb and Scr respectively have 8-bit data, and the total number is 24 bits; if the bit depth of the original image data is 10 bits, Sy, Scb and Scr have 10 bits of data, totaling 30 bits, and so on. The prediction mode is selected from a plurality of candidate prediction modes, and if there are 4 candidate prediction modes, 2-bit data can be used as an index for each candidate prediction mode, so that the prediction mode data is also 2 bits. The grouping patterns of the groups G1-G6 are 3 bits of data, and thus 18 bits are consumed. The number of binarization modes to be coded for each of the 6 groups is different according to the corresponding grouping mode, and in the minimum case, the 6 groups only need to consume 1 binarization mode data (i.e. the grouping modes of G1-G4 are all M1, and the grouping modes of G5-G6 are all N1), and a total of 18 bits is consumed; in the maximum case, 4 binarization modes of data are consumed for 6 packets (i.e., M8 for the grouping modes G1-G4 and N8 for the grouping modes G5-G6), which consumes 72 bits in total. And calculating residual coded data of all the small blocks from the first block to the third block according to the occupied length corresponding to the binarization mode of each small block.
In other embodiments, the first block, the second block and the third block may have other sizes. For example, in the YUV4:4:4 format, the first block, the second block, and the third block may all be 16 × 4 pixels in size. For YUV4:2:2 format, the sizes of the first block, the second block, and the third block may be 16 × 4 pixels, 8 × 4 pixels, respectively. In YUV4:4:4 format and YUV4:2:2 format, the size of the divided groups of the first block, the second block and the third block may be 4 × 4 pixels, and each group includes 2 × 2 small blocks, each of which is 2 × 2 pixels. In the above example where the grouping sizes of the first to third blocks are all 2 × 2 small blocks, the grouping table corresponding to M1 to M8 (i.e., table 3) can be referred to only when searching for the grouping type and the grouping mode.
In particular, the above-described process of performing the compression coding calculation in advance in the candidate prediction mode is similar to the process of the semi-fixed length coding. The purpose of performing the compression coding calculation in advance is to calculate how much data (e.g. bit number) is needed for the entire compressed code stream, so it is necessary to know how many occupied lengths are needed for each small block (to calculate residual coded data), and pbm data amount corresponding to each packet after the grouping is performed. That is, as shown in steps S205 to S220, the first block, the second block and the third block are divided into the plurality of groups, respectively; obtaining a plurality of residuals of each small block of each group based on a prediction result of the corresponding candidate prediction mode to select a representative value of each small block; obtaining a binarization mode and an occupation length corresponding to the representative numerical value; and determining a grouping mode corresponding to each group and a binarization mode needing to be encoded based on the binarization mode corresponding to each small block. And finally, calculating the pre-compression data size at least according to the number and the occupied length of the binary modes needing to be coded.
In summary, in the above embodiments, the luminance component and the chrominance components (e.g., Y component, Cb component, Cr component) are assembled together, and the pre-compressed data size and the original data size are further compared after the prediction mode is determined, so as to ensure that the compressed data size of each macroblock does not exceed the original data size. In addition, in the embodiment, the occupation length of each pixel of each small block is determined by utilizing the binarization mode table, so that the encoded pixel data can not exceed the original data volume. In addition, the above embodiments use grouping types to remove the spatial correlation between the binarization patterns, and the appropriate number of grouping patterns also keeps the grouping patterns from consuming excessive data amount. In addition, the distribution characteristics of the bit depth of the luminance component and the chrominance component are fully utilized by utilizing a semi-fixed length coding mode. More specifically, the amount of data consumed by each macroblock during image storage can be sequentially recorded in a continuous storage block (corresponding to a header block of the entire image stream). Even though the lengths of the compressed code streams contained in the compressed macroblocks in the image may not be equal, when the processor needs to read specific pixel information in the specific macroblock, the processor can determine the macroblock according to the coordinates of the pixel in the image, and quickly determine whether the data of the macroblock is compressed according to the data amount information recorded in the header block by the macroblock. Therefore, when accessing (access) the storage block where the specific macro block is located, if the access is the compressed macro block, the information of the specific pixel can be obtained by decoding the information of the prediction seed data, the prediction mode, the grouping mode and the binarization mode needing to be encoded, which are clearly recorded in the compressed code stream according to the embodiment of the invention; if the access is the uncompressed macro block, the information of the specific pixel can be read according to the uncompressed original data, so as to achieve the effect of supporting random access (random access).
Although the present invention has been described with reference to the above embodiments, it should be understood that various changes and modifications can be made therein by those skilled in the art without departing from the spirit and scope of the invention.

Claims (9)

1. An image compression method, comprising:
respectively taking the first block, the second block and the third block as compression units of a brightness component, a first chrominance component and a second chrominance component of an image;
performing compression coding calculation on the luma component of the first block, the first chroma component of the second block, and the second chroma component of the third block according to prediction results of a plurality of candidate prediction modes, respectively, to obtain a plurality of pre-compressed data sizes obtained by summing up the first block, the second block, and the third block corresponding to each of the plurality of candidate prediction modes, and selecting one of the plurality of candidate prediction modes corresponding to a minimum value from the plurality of pre-compressed data sizes as a prediction mode;
when the pre-compressed data size corresponding to the prediction mode is larger than or equal to the original data size obtained by summing the components of the first block, the second block and the third block, not compressing the components of the first block, the second block and the third block; and
and when the pre-compressed data size corresponding to the prediction mode is smaller than the original data size, performing semi-fixed length coding on each component of the first block, the second block and the third block by using the prediction mode.
2. The image compression method of claim 1, wherein the step of performing the semi-fixed length encoding comprises:
the first block, the second block and the third block are respectively divided again to obtain a plurality of groups, wherein each group comprises a plurality of small blocks, and the size of each small block is the same;
selecting the maximum absolute value of the residual errors as a representative value of each small block based on the residual errors corresponding to the pixels of each small block;
obtaining a binarization mode corresponding to the representative numerical value;
determining a grouping mode corresponding to each group and a binarization mode needing to be encoded based on the binarization mode corresponding to each small block; and
and combining the prediction seed data of the first block, the second block and the third block, the prediction mode, the grouping mode, the binarization mode to be coded and the residual coding data of each component to obtain a compressed code stream.
3. The image compression method of claim 2, further comprising:
establishing a binarization mode table, wherein the binarization mode table comprises a plurality of binarization modes, and each binarization mode corresponds to a numerical range, an occupied length and a coding rule;
the step of obtaining the binarization mode corresponding to the representative value comprises the following steps:
and searching the binarization mode table to determine the value range in which the representative value is positioned, so as to obtain the corresponding binarization mode, the occupied length and the coding rule.
4. The image compression method of claim 2, further comprising:
establishing a grouping table based on the grouping included in each of the first block, the second block and the third block, the grouping table including a plurality of grouping types, each of the grouping types corresponding to one of the grouping modes and the corresponding binarization mode to be encoded,
the step of determining the grouping mode corresponding to each group and the binarization mode to be encoded based on the binarization mode corresponding to each small block includes:
and searching the grouping table to obtain the grouping mode corresponding to each group and the binarization mode needing to be encoded.
5. The image compression method of claim 3, wherein the encoding rule is a two's complement code.
6. The image compression method of claim 3, wherein the coding rule is a sign bit plus a residual absolute value binary value.
7. The image compression method of claim 3, wherein the step of performing compression coding calculation on the luma component of the first block, the first chroma component of the second block, and the second chroma component of the third block comprises:
dividing the first block, the second block, and the third block into the plurality of groups, respectively;
obtaining the plurality of residuals for each of the patches of each of the groups based on a prediction result of the corresponding candidate prediction mode to select the representative value for each of the patches;
obtaining the binarization mode and the occupation length corresponding to the representative numerical value;
determining a grouping mode corresponding to each group and a binarization mode needing to be encoded based on the binarization mode corresponding to each small block; and
and calculating the pre-compression data size at least according to the number of the binarization modes needing to be coded and the occupation length.
8. The image compression method of claim 1, wherein the luma component is a Y component, the first chroma component is a Cb component, the second chroma component is a Cr component, and the pre-compressed data size and the original data size are one of a number of bytes, a number of characters, and a number of bits.
9. The image compression method of claim 1, wherein the prediction mode is one of a horizontal difference prediction mode, a vertical difference prediction mode, a horizontal average prediction mode, and a vertical average prediction mode.
CN201710081374.4A 2017-02-15 2017-02-15 Image compression method Active CN108429910B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710081374.4A CN108429910B (en) 2017-02-15 2017-02-15 Image compression method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710081374.4A CN108429910B (en) 2017-02-15 2017-02-15 Image compression method

Publications (2)

Publication Number Publication Date
CN108429910A CN108429910A (en) 2018-08-21
CN108429910B true CN108429910B (en) 2021-09-10

Family

ID=63155425

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710081374.4A Active CN108429910B (en) 2017-02-15 2017-02-15 Image compression method

Country Status (1)

Country Link
CN (1) CN108429910B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101394565A (en) * 2008-10-20 2009-03-25 成都九洲电子信息系统有限责任公司 Intra-frame prediction method
CN101494782A (en) * 2008-01-25 2009-07-29 三星电子株式会社 Video encoding method and apparatus, and video decoding method and apparatus
CN101742301A (en) * 2008-11-24 2010-06-16 北京中星微电子有限公司 Block mode coding method and device
WO2014107073A1 (en) * 2013-01-04 2014-07-10 삼성전자 주식회사 Method and apparatus for encoding video, and method and apparatus for decoding said video
CN105723707A (en) * 2013-11-01 2016-06-29 高通股份有限公司 Color residual prediction for video coding
CN105812806A (en) * 2011-06-23 2016-07-27 Jvc建伍株式会社 Image decoding device and image decoding method

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101448162B (en) * 2001-12-17 2013-01-02 微软公司 Method for processing video image
TW200714077A (en) * 2005-09-20 2007-04-01 Ali Corp Image processing method and a 2-D discrete cosine transformation device thereof

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101494782A (en) * 2008-01-25 2009-07-29 三星电子株式会社 Video encoding method and apparatus, and video decoding method and apparatus
CN101394565A (en) * 2008-10-20 2009-03-25 成都九洲电子信息系统有限责任公司 Intra-frame prediction method
CN101742301A (en) * 2008-11-24 2010-06-16 北京中星微电子有限公司 Block mode coding method and device
CN105812806A (en) * 2011-06-23 2016-07-27 Jvc建伍株式会社 Image decoding device and image decoding method
WO2014107073A1 (en) * 2013-01-04 2014-07-10 삼성전자 주식회사 Method and apparatus for encoding video, and method and apparatus for decoding said video
CN105723707A (en) * 2013-11-01 2016-06-29 高通股份有限公司 Color residual prediction for video coding

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于视觉感知的视频压缩算法研究;郭姗;《中国优秀硕士学位论文全文数据库信息科技辑》;20090515;全文 *

Also Published As

Publication number Publication date
CN108429910A (en) 2018-08-21

Similar Documents

Publication Publication Date Title
WO2020253828A1 (en) Coding and decoding method and device, and storage medium
US9906817B2 (en) Indexed color values in image coding
AU2012332327B2 (en) Method and apparatus for image compression storing encoding parameters in 2D matrices
US9756347B2 (en) Screen content coding systems and methods
WO2015120818A1 (en) Picture coding and decoding methods and devices
CN104754361A (en) Image encoding and decoding method and device
CN104853211A (en) Image compression method and apparatus employing various forms of reference pixel storage spaces
JP2018061263A (en) Method of encoding and decoding, and device
KR20140028142A (en) Selective lossless-lossy compression of image data based on bit budget
WO2020009758A9 (en) Context-based binary arithmetic encoding and decoding
CN106375762A (en) Reference frame data compression method and apparatus
CN114222129A (en) Image compression encoding method, image compression encoding device, computer equipment and storage medium
EP3761646A1 (en) Context modelling method and device for partition flag bit
CN113573056A (en) Method, device, storage medium and terminal for optimizing and quantizing rate distortion
CN101657973B (en) Recorded medium having program for coding and decoding using bit-precision, and apparatus thereof
CN108429910B (en) Image compression method
CN115474044B (en) Bayer domain image lossy compression method
CN114584773A (en) Image compression device, method, electronic device, and computer-readable storage medium
CN111010574B (en) Image compression method and device and electronic equipment
CN112565760B (en) Encoding method, apparatus and storage medium for string encoding technique
CN115022636A (en) Rate distortion optimization quantization method and device
CN107172425B (en) Thumbnail generation method and device and terminal equipment
CN113473150B (en) Image processing method and device and computer readable storage device
CN108419078B (en) Image processing method and device based on WebP image compression algorithm
CN116546193A (en) Image decoding method, encoding method and device

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