Reference frame lossless compression method and system
By employing image block prediction, residual separation, and efficient coding methods, the high complexity and low efficiency of lossless compression of reference frames are addressed, achieving more efficient compression and parallel processing, and making it suitable for reference frame storage in video compression standards.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-03-27
AI Technical Summary
Existing lossless compression methods for reference frames are characterized by high complexity, low compression efficiency, and poor parallelism, posing challenges to high-speed and low-power chip design.
A combination of image block prediction, residual separation, entropy coding, and direct transmission coding is adopted. By determining whether the residuals of the pixels to be encoded in the image block are all zero, an identifier is set, and the residuals of non-zero block components are separated into magnitude and sign bits for entropy coding and direct transmission coding. The total bit consumption is calculated to determine whether the compression is successful or not.
It reduces the complexity of lossless compression of reference frames, improves compression efficiency and parallelism, and meets the high-speed and low-power design requirements of chips.
Smart Images

Figure CN121750868A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image compression technology, in particular to a reference frame lossless compression method and system. BACKGROUND
[0002] In the video compression standard, the data amount of the reference frame is huge, which will be stored on the off-chip memory. When the encoder encodes, the motion estimation, motion compensation and other operations will use the reference frame. The encoder will load the reference frame from off-chip to on-chip, so as to bring a high off-chip access bandwidth, thereby challenging the high speed and low power design of the chip. One of the common methods to reduce the access bandwidth is reference frame compression. The reference frame compression method is mainly divided into two categories, one is lossy compression, and the other is lossless compression. Since there is an error between the decoded data and the original data in the lossy compression, and the error of the reference frame will gradually accumulate with the number of frames, so as to make the video quality decline. Therefore, in order to ensure the video quality, the lossless compression method is often used. However, the lossless compression method usually has the problems of complex method, poor compression effect, poor parallelism in hardware implementation and the like. SUMMARY
[0003] The purpose of the present application is to provide a reference frame lossless compression method and system, which reduces the complexity of the reference frame lossless compression method and improves the compression efficiency and parallelism.
[0004] In order to achieve the above purpose, the present application provides a reference frame lossless compression method, comprising:
[0005] providing a reference frame, the reference frame comprising a plurality of image blocks, the image block comprising a plurality of to-be-encoded pixels, and the to-be-encoded pixel having Y component, U component and V component;
[0006] performing pixel prediction on the image block to obtain the predicted value of each component of all to-be-encoded pixels in the image block;
[0007] obtaining the residual error of each component of all to-be-encoded pixels in the image block according to the true value of each component of the to-be-encoded pixel and the predicted value of each component of the to-be-encoded pixel;
[0008] judging whether the residual error of each component of all to-be-encoded pixels in the image block is all zero, if the residual error of any component of all to-be-encoded pixels in the image block is all zero, setting a first identifier to represent the component with all zero residual error;
[0009] setting the component with non-all-zero residual error as a non-zero block component, and separating the residual error of the non-zero block component into amplitude and sign bit;
[0010] The amplitude is entropy encoded to obtain amplitude encoding, and the sign bit is directly encoded to obtain sign bit encoding, and a second identifier is set for the non-zero block component;
[0011] The total bit consumption of the image block is calculated and compared with the bit consumption of the original pixel value of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel value of the image block, the compression is successful and the compressed bit stream is formed. The compressed bit stream includes the amplitude encoding and the sign bit encoding.
[0012] The compressed bitstream is stored in an off-chip storage unit until all image blocks are compressed.
[0013] Optionally, the image block comprises 64 pixels.
[0014] Optionally, the pixel prediction includes mean prediction, leftmost prediction, top prediction, leftmost prediction, and gradient adjustment prediction.
[0015] Optionally, the prediction formula DC for the mean prediction is: ; ; ;
[0016] The prediction formula L for the leftmost prediction is: ;
[0017] The prediction formula U mentioned above is: ;
[0018] The prediction formula LL for the left-second prediction is: ;
[0019] The prediction formula J for the gradient adjustment prediction is: ; ; ; ;
[0020] in, , , and These are the predicted values of the Y components of the four pixels to be encoded. and These are the predicted values of the U components of the two pixels to be encoded. and The predicted values of the V components for the two pixels to be encoded. , , and These are the true values of the Y components of the four pixels to be encoded. and The true values of the U components of the two pixels to be encoded. and The true values of the V components of the two pixels to be encoded; X represents the predicted value of the pixel to be encoded, where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
[0021] Optionally, the formula for calculating the residual of the pixel to be encoded is: ;
[0022] in, The actual value of the pixel to be encoded. The predicted value of the pixel to be encoded. Let X represent the residual of the pixel to be encoded, where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
[0023] Optionally, when the residuals of the Y components of all pixels to be encoded in the image block are all zero, the first identifier ModeY is set to represent the Y component, and ModeY=7; when the residuals of the U components of all pixels to be encoded in the image block are all zero, the first identifier ModeU is set to represent the U component, and ModeU=3; when the residuals of the V components of all pixels to be encoded in the image block are all zero, the first identifier ModeV is set to represent the V component, and ModeV=3.
[0024] Optionally, the formulas for calculating the amplitude and the sign bit are as follows: ; ;
[0025] in, For the amplitude, For the sign bit, Let X represent the residual of the pixel to be encoded, where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
[0026] Optionally, the amplitude is encoded using univariate exponential Columbus entropy encoding with the optimal k value, the steps of which include:
[0027] Traverse the k values within a preset range of the non-zero block components corresponding to the amplitude, and calculate the total bit consumption of the non-zero block components after unary exponential Columbus entropy encoding based on the candidate k values.
[0028] Obtain the k value that minimizes the total bit consumption of the non-zero block component, and set it as the optimal k value for the non-zero block component;
[0029] The amplitude is encoded by performing univariate exponential Columbus entropy encoding on the amplitude based on the optimal k value.
[0030] Optionally, the encoding rules for the unary exponential Columbus entropy encoding include:
[0031] Let the current value of k be... The current amplitude is The quotient is calculated to be The remainder of the quotient is The formula for calculating the quotient is: ;
[0032] The formula for calculating the remainder is: ;
[0033] Let N be The minimum required length is represented in binary, and , where [ ] is the rounding up symbol;
[0034] like The amplitude codes are as follows: One bit '0' and N bits The binary representation of the pixel to be encoded, where the bit consumption is... , ;
[0035] like The amplitude encoding is by One bit '0', one bit '1', The bits '0' and The binary representation of the pixel to be encoded, the bit consumption of which is , ;
[0036] Where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
[0037] Optionally, the second identifier can be set to the optimal k value for the non-zero block component.
[0038] Optionally, if the non-zero block component is a Y component, the preset range of the Y component is 0~6; if the non-zero block component is a U component or a V component, the preset range of the U component or the V component is 0~2.
[0039] Optionally, the direct transmission encoding involves directly writing the value of each sign bit into the bitstream. If the sign bit is '0' or '1', then '0' or '1' is directly written into the bitstream.
[0040] Optionally, the formula for calculating the total bit consumption of the image block is:
[0041] ;
[0042] in, The total bit consumption of the image block. The bit consumption for the sign bit. Bit consumption for entropy encoding The bit consumption for the first identifier and the second identifier. Bit consumption for mean prediction.
[0043] Optionally, if the total bit consumption of the image block is greater than or equal to the bit consumption of the original pixel value of the image block, then compression fails, and the original pixel value of the image block is packaged into an original pixel bitstream.
[0044] The original pixel bitstream is stored in the off-chip storage unit.
[0045] The present invention also provides a reference frame lossless compression system, comprising:
[0046] An image input module is used to provide a reference frame, the reference frame including a plurality of image blocks, the image blocks including a plurality of pixels to be encoded, and the pixels to be encoded having Y components, U components and V components;
[0047] A pixel prediction module is used to perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block;
[0048] The residual calculation module is used to perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block;
[0049] The zero-determination module is used to determine whether the residual of each component of all pixels to be encoded in the image block is all zero. If the residual of any component of all pixels to be encoded in the image block is all zero, then a first identifier is set to represent the component with all zero residuals.
[0050] The residual separation module is used to set components whose residuals are not all zero as non-zero block components, and to separate the residuals of the non-zero block components into amplitude and sign bits;
[0051] The encoding module is used to perform entropy encoding on the amplitude to obtain amplitude encoding, and to perform direct transmission encoding on the sign bit to obtain sign bit encoding, and to set a second identifier for the non-zero block component;
[0052] The total bit consumption calculation module is used to calculate the total bit consumption of the image block and compare the total bit consumption of the image block with the bit consumption of the original pixel value of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel value of the image block, it indicates that the compression is successful and the compressed bit stream is formed. The compressed bit stream includes the amplitude encoding and the sign bit encoding.
[0053] The bitstream output module is used to store the compressed bitstream to an off-chip storage unit until all the image blocks are compressed.
[0054] The lossless compression method and system for reference frames provided by this invention includes: providing a reference frame, the reference frame including a plurality of image blocks, each image block including a plurality of pixels to be encoded, and each pixel to be encoded having a Y component, a U component, and a V component; performing pixel prediction on the image blocks to obtain the predicted value of each component of all pixels to be encoded in the image blocks; obtaining the residual of each component of all pixels to be encoded in the image blocks based on the actual value of each component of the pixels to be encoded and the predicted value of each component of the pixels to be encoded; determining whether the residual of each component of all pixels to be encoded in the image blocks is all zero; if the residual of any component of all pixels to be encoded in the image blocks is all zero, then setting a first identifier to characterize the residual. The method involves several steps: First, compressing the image blocks. Second, it addresses the issue of compression by using spatial redundancy. This redundancy manifests as similar values between adjacent pixels, allowing for the prediction of the current pixel and encoding the residual between the actual and predicted pixel values. The method employs a combination of prediction methods and efficient entropy coding to solve the problems of high complexity, low efficiency, and poor parallelism in general reference frame lossless compression methods. Attached Figure Description
[0055] Figure 1 This is a flowchart of a lossless compression method for reference frames provided in an embodiment of the present invention.
[0056] Figure 2 This is a schematic diagram of the Y component of an image block in a lossless compression method for a reference frame provided in an embodiment of the present invention.
[0057] Figure 3 This is a schematic diagram of the U and V components of an image block in a lossless compression method for a reference frame provided in an embodiment of the present invention.
[0058] Figure 4 This is a distribution diagram of the prediction method for image blocks in a lossless compression method for reference frames provided in an embodiment of the present invention.
[0059] Figure 5 This is a diagram illustrating the bitstream organization method when compression is successful in a lossless compression method for reference frames provided in an embodiment of the present invention. Detailed Implementation
[0060] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. The accompanying drawings are all in a very simplified form and are not drawn to scale, only used to conveniently and clearly assist in illustrating the objectives of the embodiments of the present invention. In addition, the structures shown in the drawings are often part of the actual structures; in particular, different proportions are sometimes used because different drawings need to show different focuses.
[0061] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0062] In the description of this application, it should be understood that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship commonly used when the product is in use, or the orientation or positional relationship commonly understood by those skilled in the art. They are used only for the convenience of describing this application and simplifying the description, and are not intended to indicate or imply that the equipment or component referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0063] Furthermore, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such an article or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the article or apparatus that includes said element. Those skilled in the art will understand the specific meaning of the above terms in this application based on the specific circumstances.
[0064] Figure 1 This is a flowchart of the lossless compression method for the reference frame provided in this embodiment. Please refer to... Figure 1 This invention provides a lossless compression method for reference frames, comprising:
[0065] Step S1: Provide a reference frame, which includes several image blocks, each image block including several pixels to be encoded, and each pixel to be encoded having Y, U and V components;
[0066] Step S2: Perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block;
[0067] Step S3: Based on the true value of each component of the pixel to be encoded and the predicted value of each component of the pixel to be encoded, obtain the residual of each component of all pixels to be encoded in the image block.
[0068] Step S4: Determine whether the residual of each component of all pixels to be encoded in the image block is all zero. If the residual of any component of all pixels to be encoded in the image block is all zero, then set the first identifier to represent the component with all zero residuals.
[0069] Step S5: Set the components whose residuals are not all zero as non-zero block components, and separate the residuals of the non-zero block components into amplitude and sign bits;
[0070] Step S6: Perform entropy encoding on the amplitude to obtain amplitude encoding, and perform direct transmission encoding on the sign bit to obtain sign bit encoding, and set a second identifier for the non-zero block component;
[0071] Step S7: Calculate the total bit consumption of the image block and compare the total bit consumption of the image block with the bit consumption of the original pixel value of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel value of the image block, it means that the compression is successful and the compressed bit stream is formed. The compressed bit stream includes amplitude encoding and sign bit encoding.
[0072] Step S8: Store the compressed bitstream to an off-chip storage unit until all image blocks are compressed.
[0073] The lossless compression method for reference frames provided in this embodiment will be described in detail below.
[0074] Step S1: Provide a reference frame. The image source of the reference frame is preferably in YUV422 format. The reference frame includes several image blocks, each of which is a 16-pixel × 4-pixel YUV image block. That is, a YUV422 image frame is divided into several rectangular blocks with 16-pixel columns and 4-pixel rows. Subsequent encoding processing is required for the pixels in the image blocks; therefore, each image block includes several pixels to be encoded. In this embodiment, there are 64 pixels to be encoded. Each pixel to be encoded includes a Y component, a U component, and a V component, where Y represents luminance. Please refer to [reference needed]. Figure 2Each pixel to be encoded has an independent Y value, meaning the Y component of an image block has 64 (16×4) values; U and V represent chromaticity, and generally, every two horizontally adjacent pixels to be encoded share a set of U and V values. Please refer to [reference needed]. Figure 3 , Figure 3 The value in the image block does not represent the actual distribution of U and V values, but only the number of U and V values, i.e., there are 32 (8×4) U and V components in each image block. The data is input in the form of image blocks, and the compression between each image block is independent, which facilitates random access. Therefore, the following method is used to compress all image blocks in the reference frame.
[0075] Step S2: Perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block, that is, obtain the predicted values of the Y, U, and V components of all (e.g., 64) pixels to be encoded in the image block. Pixel prediction employs multiple prediction methods, including mean prediction, left-first prediction, top prediction, left-second prediction, and gradient adjustment prediction. Setting multiple prediction methods can increase the accuracy of prediction.
[0076] Mean prediction uses the mean of the true values of several pixels to be encoded as the predicted value. Specifically, the prediction formula DC for mean prediction is: ; ; ;
[0077] Left-first prediction uses the true value of the left-adjacent pixel to the left of the pixel to be encoded as the predicted value. Specifically, the prediction formula L for left-first prediction is: ;
[0078] Up-prediction uses the true value of the neighboring pixel above the pixel to be encoded as the predicted value. Specifically, the prediction formula U for up-prediction is: ;
[0079] The second-to-left prediction uses the true value of the second pixel to the left of the pixel to be encoded as the predicted value. Specifically, the prediction formula LL for the second-to-left prediction is: ;
[0080] The prediction formula J for gradient-adjusted prediction is: ; ; ; ;
[0081] The coordinates of the pixel to be encoded are (i,j), where i is the row coordinate of the pixel to be encoded in the image block and j is the column coordinate of the pixel to be encoded in the image block. The image block consists of 4 rows and 16 columns of pixels to be encoded. , , and The predicted values of the Y components for four pixels to be encoded (coordinates (0,0), (0,4), (0,8), and (0,12)). and The predicted values of the U component for two pixels to be encoded (coordinates (0,0) and (0,4)). and The predicted values of the V component for two pixels to be encoded (coordinates (0,0) and (0,4)). , , and The true values of the Y component of the four pixels to be encoded (coordinates (0,0), (0,4), (0,8) and (0,12) respectively) are given. and Let U be the true values of the U components of two pixels to be encoded (coordinates (0,0) and (0,4)). and Let V be the true value of the V component of two pixels to be encoded (coordinates (0,0) and (0,4)). X represents the predicted value of the pixel to be encoded, where X represents the Y component, U component, or V component. It can be , or ; It is the smallest of L and U. It is the largest of L and U.
[0082] Based on the above prediction method, all pixels to be encoded in the image patch are predicted, and the prediction method distribution map of the image patch is obtained. Please refer to [reference needed]. Figure 4DC, L, U, LL, and J represent different prediction methods. The numbers in parentheses represent the path dependence of the prediction point in terms of timing. For example, L(1) indicates that the prediction method used at the prediction point is L, and prediction can only be performed after DC(0) is decoded. J(2) indicates that the prediction method used at the prediction point is J, and prediction can only be performed after DC(0), L(1), and U(1) are decoded. Subsequently, the DC values of the mean prediction of the Y, U, and V components in the image block need to be written into the bitstream. Each DC value occupies 8 bits, and the bit consumption of the mean prediction is BitCostDC, which occupies a total of 24 bits. Since this embodiment processes the 16×4 image block in parallel into 4 4x4 blocks, and the path dependence of each 4x4 block is at most 5 pixels (i.e., J(5) depends on at most 5 pixels), the parallelism is high, which allows the hardware circuit to work at a lower clock frequency.
[0083] Step S3: Based on the true value and the predicted value of each component of the pixel to be encoded, obtain the residual of each component of the pixel to be encoded, thereby obtaining the residual of each component of all (e.g., 64) pixels to be encoded in the image block. The formula for calculating the residual of the pixel to be encoded is: ;
[0084] The coordinates of the pixel to be encoded are (i,j), where i is the row coordinate of the pixel to be encoded in the image block and j is the column coordinate of the pixel to be encoded in the image block. The image block consists of 4 rows and 16 columns of pixels to be encoded. The actual value of the pixel to be encoded. The predicted value of the pixel to be encoded. The residual of the pixel to be encoded is X, where X represents the Y component, U component, or V component, i.e. It can be , or , It can be , or .
[0085] Step S4: Determine if the residuals of each component of all pixels to be encoded in the image block are all zero. For example, if the image block has 64 pixels to be encoded, the residuals of the Y component of the image block are 64, and the residuals of the U and V components of the image block are both 32. If the residuals of any component of all pixels to be encoded in the image block are all zero, that is, the residual block of that component (all the residuals corresponding to the component constitute the residual block of that component) is a block of all zeros, then the first identifier is directly set to represent the component with all zero residuals. Specifically, when the residuals of the Y component of all pixels to be encoded in the image block are all zero, the first identifier ModeY is set to represent the Y component, ModeY=7; when the residuals of the U component of all pixels to be encoded in the image block are all zero, the first identifier ModeU is set to represent the U component, ModeU=3; when the residuals of the V component of all pixels to be encoded in the image block are all zero, the first identifier ModeV is set to represent the V component, ModeV=3. The first identifier can be represented in binary.
[0086] In this embodiment, if the residual of a certain component of the pixel to be encoded in the image block is all zero, the identifier of the corresponding component is set to all 1s, and the identifier is written into the bit stream and stored in the off-chip storage unit, without the need for further separation and encoding.
[0087] Step S5: Components in an image block whose residuals are not all zero are designated as non-zero block components. The residuals of these non-zero block components are then separated into amplitude and sign bits. Specifically, the formulas for calculating amplitude and sign bits are as follows: ; ;
[0088] Wherein, the coordinates of the pixel to be encoded are (i,j), where i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block. For amplitude, For the sign bit, The residual of the pixel to be encoded is X, where X represents the Y component, U component, or V component, i.e. It can be , or , It can be , or , It can be , or The amplitude of a value of 0 is 0, and there is no sign bit. Therefore, the number of sign bits is sometimes less than the number of amplitudes. For example, there are 64 amplitudes but only 60 sign bits. When decoding, the amplitude is decoded first. When the amplitude is 0, there is no sign bit.
[0089] Step S6: Entropy encoding is performed on the amplitude to obtain the amplitude code, and direct transmission encoding is performed on the sign bit to obtain the sign bit code, and a second identifier is set for the non-zero block components. Specifically, in this embodiment, the amplitude is subjected to unary exponential Golomb entropy encoding with the optimal k value. The steps include: traversing the k values within a preset range of the non-zero block components corresponding to the amplitude, and calculating the total bit consumption of the non-zero block components after unary exponential Golomb entropy encoding based on the candidate k values, that is, calculating the total bit consumption of the non-zero block components after unary exponential Golomb entropy encoding for each k value; then, obtaining the k value with the minimum total bit consumption of the non-zero block components, and setting it as the optimal k value for the non-zero block components, with each non-zero block component corresponding to an optimal k value; and performing unary exponential Golomb entropy encoding on the amplitude based on the optimal k value to obtain the amplitude code. In this embodiment, if the non-zero block component is a Y component, the preset range of the Y component is 0~6; if the non-zero component is a U component or a V component, the preset range of the U component or the V component is 0~2.
[0090] The encoding rules for unary exponential Columbus entropy coding include:
[0091] Let the current value of k be... The current amplitude is The quotient is calculated to be The remainder of the quotient is The formula for calculating the quotient is: ;
[0092] The formula for calculating the remainder is: ;
[0093] Let N be The minimum required length is represented in binary, and , where [ ] is the rounding up symbol.
[0094] like The amplitude codes are as follows: One bit '0' and N bits The binary representation of the pixel to be encoded consumes bits. , .
[0095] like Amplitude encoding is One bit '0', one bit '1', The bits '0' and The binary representation of the pixel to be encoded consumes bits. , .
[0096] Wherein, the coordinates of the pixel to be encoded are (i,j), where i is the row coordinate of the pixel to be encoded in the image block, j is the column coordinate of the pixel to be encoded in the image block, and X represents the Y component, U component, or V component. Can be , and The total bit consumption of all non-zero block components of the pixels to be encoded in the image block is obtained according to the above rules. The second identifier is set to the optimal k value for the non-zero block component; that is, the range of the second identifier for the Y component is 0~6, and the range of the second identifiers for the U and V components is 0~2. The second identifier can be represented in binary. Direct transmission encoding involves directly writing the value of each sign bit into the bitstream; if the sign bit is '0' or '1', then '0' or '1' is directly written into the bitstream.
[0097] Step S7: Calculate the total bit consumption of the image block and compare it with the bit consumption of the original pixel values of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel values of the image block, then the compression is successful and the image is packaged into a compressed bitstream. The compressed bitstream includes amplitude encoding and sign bit encoding. The formula for calculating the total bit consumption of the image block is:
[0098] ;
[0099] in, The total bit consumption of the image block. Bit consumption of the sign bit Bit consumption for entropy encoding The bit consumption for the first identifier and the second identifier. The bit consumption for mean prediction includes the bit consumption of the Y, U, and V components. Without any encoding, the bit consumption (BitCostOri) for directly transmitting the raw pixel values is 1024 bits. If the total bit consumption (BitCostTotal) of the image block is greater than or equal to the bit consumption (BitCostOri) of the raw pixel values, compression fails. An additional bit (Flag) is used to record the compression failure. After a failure, the raw pixel values are directly transmitted, i.e., the raw pixel values of the image block are packaged into a raw pixel bitstream, which is then stored in off-chip storage. Setting Flag to 0 indicates successful compression, and setting Flag to 1 indicates compression failure.
[0100] Execute step S8: Store the compressed bitstream to an off-chip storage unit until all image blocks are compressed. Please refer to [link / reference]. Figure 5After successful compression, the bitstream is organized with DC_U appended to SignDataY. The compressed bitstream is generated according to the sequence shown in the diagram, where Flag indicates whether compression was successful. DC_Y, DC_U, and DC_V represent the mean prediction values of the Y, U, and V components, respectively; Mode_Y, Mode_U, and Mode_V represent the identifiers of the Y, U, and V components, respectively; MagVlcY, MagVlcU, and MagVlcV represent the amplitude encodings of the Y, U, and V components, respectively; and SignDataY, SignDataU, and SignDataV represent the sign bit encodings of the Y, U, and V components, respectively. In case of compression failure, the bitstream contains only the original pixel values, except for the first Flag which is 1. Using this method, image blocks are compressed one by one until the entire reference frame is compressed.
[0101] This embodiment also provides a reference frame lossless compression system, including:
[0102] The image input module is used to provide a reference frame, which includes several image blocks, each image block including several pixels to be encoded, and each pixel to be encoded having Y, U and V components.
[0103] The pixel prediction module is used to perform pixel prediction on image blocks to obtain the predicted value of each component of all pixels to be encoded in the image block.
[0104] The residual calculation module is used to perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block;
[0105] The all-zero judgment module is used to determine whether the residual of each component of all pixels to be encoded in the image block is all zero. If the residual of any component of all pixels to be encoded in the image block is all zero, the first identifier is set to represent the component with all zero residuals.
[0106] The residual separation module is used to set components whose residuals are not all zero as non-zero block components, and to separate the residuals of non-zero block components into amplitude and sign bits;
[0107] The encoding module is used to perform entropy encoding on the amplitude to obtain amplitude encoding, and to perform direct transmission encoding on the sign bit to obtain sign bit encoding, and to set a second identifier for the non-zero block components;
[0108] The total bit consumption calculation module is used to calculate the total bit consumption of the image block and compare the total bit consumption of the image block with the bit consumption of the original pixel value of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel value of the image block, it means that the compression is successful and the compressed bit stream is formed. The compressed bit stream includes amplitude encoding and sign bit encoding.
[0109] The bitstream output module is used to store the compressed bitstream to an off-chip storage unit until all image blocks are compressed.
[0110] In this embodiment, a reference frame is first input, which includes several image blocks. Each image block is a 16-pixel × 4-pixel YUV image block, containing 64 pixels to be encoded. Each pixel to be encoded includes a Y component, a U component, and a V component. Then, various prediction methods are used to predict the pixels in the image block to obtain the predicted value of each component of all pixels to be encoded in the image block, i.e., the predicted values of the Y, U, and V components of all (e.g., 64) pixels to be encoded in the image block. Next, based on the true value and the predicted value of each component of the pixel to be encoded, the residual of each component of the pixel to be encoded is obtained, thus obtaining the residual of each component of all (e.g., 64) pixels to be encoded in the image block. Finally, it is determined whether all residuals of each component of all pixels to be encoded in the image block are zero. For example, if the image block has 64 pixels to be encoded, the residual of the Y component of the image block is 64, and the residuals of the U and V components of the image block are both 32. If the residual of any component of all pixels to be encoded in an image block is zero, that is, the residual block of that component (the residual block of that component consists of all the residuals corresponding to the component) is a zero block, then the first identifier is directly set to represent the component with all zero residuals. Further, components in the image block whose residuals are not all zero are set as non-zero block components, and the residuals of the non-zero block components in the image block are separated into amplitude and sign bits. Further still, entropy encoding is performed on the amplitude to obtain amplitude encoding, and direct transmission encoding is performed on the sign bit to obtain sign bit encoding, and a second identifier is set for the non-zero block components. Further still, the total bit consumption of the image block is calculated and compared with the bit consumption of the original pixel values of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel values of the image block, then the compression is successful and the compressed bitstream is formed. The compressed bitstream includes amplitude encoding and sign bit encoding. Finally, the compressed bitstream is stored in an off-chip storage unit until all image blocks are compressed.
[0111] In summary, the lossless compression method and system for reference frames provided by this invention includes: providing a reference frame, the reference frame including a plurality of image blocks, each image block including a plurality of pixels to be encoded, and each pixel to be encoded having a Y component, a U component, and a V component; performing pixel prediction on the image blocks to obtain the predicted value of each component of all pixels to be encoded in the image blocks; obtaining the residual of each component of all pixels to be encoded in the image blocks based on the actual value of each component of the pixels to be encoded and the predicted value of each component of the pixels to be encoded; determining whether the residual of each component of all pixels to be encoded in the image blocks is all zero; if the residual of any component of all pixels to be encoded in the image blocks is all zero, then setting a first identifier to characterize... The components with all residuals being zero are classified as non-zero block components. The residuals of the non-zero block components are then separated into amplitude and sign bits. Entropy encoding is performed on the amplitude to obtain amplitude encoding, and direct transmission encoding is performed on the sign bit to obtain sign bit encoding. A second identifier is assigned to the non-zero block components. The total bit consumption of the image block is calculated and compared with the bit consumption of the original pixel values of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel values of the image block, the compression is successful and the compressed bitstream is formed. The compressed bitstream includes amplitude encoding and sign bit encoding. The compressed bitstream is stored in the off-chip storage unit until all image blocks are compressed. The method of this invention starts from the spatial domain and uses the spatial redundancy of the image to achieve compression. Spatial redundancy is manifested in the similar values between adjacent pixels, so the current pixel can be predicted using adjacent pixels, thereby encoding the residual between the actual value and the predicted value of the pixel; and by using a combination of multiple prediction methods and an efficient entropy coding method, it solves the problems of high complexity, low compression efficiency and poor parallelism of general reference frame lossless compression methods.
[0112] The above are merely preferred embodiments of the present invention and do not constitute any limitation on the present invention. Any equivalent substitutions or modifications made by those skilled in the art to the technical solutions and content disclosed in the present invention without departing from the scope of the present invention shall be deemed to have remained within the scope of protection of the present invention.
Claims
1. A lossless compression method for reference frames, characterized in that, include: A reference frame is provided, the reference frame comprising a plurality of image blocks, the image blocks comprising a plurality of pixels to be encoded, and the pixels to be encoded having Y components, U components and V components; Pixel prediction is performed on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block; Based on the true value of each component of the pixel to be encoded and the predicted value of each component of the pixel to be encoded, the residual of each component of all pixels to be encoded in the image block is obtained. Determine whether the residual of each component of all pixels to be encoded in the image block is all zero. If the residual of any component of all pixels to be encoded in the image block is all zero, then set a first identifier to represent the component with all zero residuals. The components whose residuals are not all zero are set as non-zero block components, and the residuals of the non-zero block components are separated into amplitude and sign bits; The amplitude is entropy encoded to obtain amplitude encoding, and the sign bit is directly encoded to obtain sign bit encoding, and a second identifier is set for the non-zero block component; The total bit consumption of the image block is calculated and compared with the bit consumption of the original pixel value of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel value of the image block, the compression is successful and the compressed bit stream is formed. The compressed bit stream includes the amplitude encoding and the sign bit encoding. The compressed bitstream is stored in an off-chip storage unit until all image blocks are compressed.
2. The lossless compression method for reference frames as described in claim 1, characterized in that, The image block comprises 64 pixels.
3. The lossless compression method for reference frames as described in claim 1, characterized in that, The pixel prediction includes mean prediction, leftmost prediction, top prediction, leftmost prediction, and gradient adjustment prediction.
4. The lossless compression method for reference frames as described in claim 3, characterized in that, The prediction formula DC for the mean prediction is: ; ; ; The prediction formula L for the leftmost prediction is: ; The prediction formula U mentioned above is: ; The prediction formula LL for the left-second prediction is: ; The prediction formula J for the gradient adjustment prediction is: ; ; ; ; in, , , and These are the predicted values of the Y components of the four pixels to be encoded. and These are the predicted values of the U components of the two pixels to be encoded. and The predicted values of the V components for the two pixels to be encoded. , , and These are the true values of the Y components of the four pixels to be encoded. and The true values of the U components of the two pixels to be encoded. and The true values of the V components of the two pixels to be encoded; X represents the predicted value of the pixel to be encoded, where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
5. The lossless compression method for reference frames as described in claim 1, characterized in that, The formula for calculating the residual of the pixel to be encoded is: ; in, The actual value of the pixel to be encoded. The predicted value of the pixel to be encoded. Let X represent the residual of the pixel to be encoded, where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
6. The lossless compression method for reference frames as described in claim 1, characterized in that, When the residuals of the Y components of all pixels to be encoded in the image block are all zero, the first identifier ModeY is set to represent the Y component, and ModeY=7; when the residuals of the U components of all pixels to be encoded in the image block are all zero, the first identifier ModeU is set to represent the U component, and ModeU=3; when the residuals of the V components of all pixels to be encoded in the image block are all zero, the first identifier ModeV is set to represent the V component, and ModeV=3.
7. The lossless compression method for reference frames as described in claim 5, characterized in that, The formulas for calculating the amplitude and the sign bit are as follows: ; ; in, For the amplitude, For the sign bit, Let X represent the residual of the pixel to be encoded, where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
8. The lossless compression method for reference frames as described in claim 1, characterized in that, The steps for performing univariate exponential Golomb entropy encoding on the amplitude with the optimal k value include: Traverse the k values within a preset range of the non-zero block components corresponding to the amplitude, and calculate the total bit consumption of the non-zero block components after unary exponential Columbus entropy encoding based on the candidate k values. Obtain the k value that minimizes the total bit consumption of the non-zero block component, and set it as the optimal k value for the non-zero block component; The amplitude is encoded by performing univariate exponential Columbus entropy encoding on the amplitude based on the optimal k value.
9. The lossless compression method for reference frames as described in claim 8, characterized in that, The encoding rules of the unary exponential Columbus entropy encoding include: Let the current value of k be... The current amplitude is The quotient is calculated to be The remainder of the quotient is The formula for calculating the quotient is: ; The formula for calculating the remainder is: ; Let N be The minimum required length is represented in binary, and , where [ ] is the rounding up symbol; like The amplitude codes are as follows: One bit '0' and N bits The binary representation of the pixel to be encoded, where the bit consumption is... , ; like The amplitude encoding is by One bit '0', one bit '1', The bits '0' and The binary representation of the pixel to be encoded, where the bit consumption is... , ; Where X represents the Y component, U component, or V component, i is the row coordinate of the pixel to be encoded in the image block, and j is the column coordinate of the pixel to be encoded in the image block.
10. The lossless compression method for reference frames as described in claim 8, characterized in that, Set the second identifier to the optimal k value for the non-zero block component.
11. The lossless compression method for reference frames as described in claim 8, characterized in that, If the non-zero block component is a Y component, the preset range of the Y component is 0~6; if the non-zero block component is a U component or a V component, the preset range of the U component or the V component is 0~2.
12. The lossless compression method for reference frames as described in claim 1, characterized in that, The direct transmission encoding involves directly writing the value of each sign bit into the bitstream. If the sign bit is '0' or '1', then '0' or '1' is directly written into the bitstream.
13. The lossless compression method for reference frames as described in claim 10, characterized in that, The formula for calculating the total bit consumption of the image block is: ; in, The total bit consumption of the image block. The bit consumption for the sign bit. Bit consumption for entropy encoding The bit consumption for the first identifier and the second identifier. Bit consumption for mean prediction.
14. The lossless compression method for reference frames as described in claim 10, characterized in that, If the total bit consumption of the image block is greater than or equal to the bit consumption of the original pixel value of the image block, then compression fails, and the original pixel value of the image block is packaged into an original pixel bitstream. The original pixel bitstream is stored in the off-chip storage unit.
15. A reference frame lossless compression system, characterized in that, include: An image input module is used to provide a reference frame, the reference frame including a plurality of image blocks, the image blocks including a plurality of pixels to be encoded, and the pixels to be encoded having Y components, U components and V components; A pixel prediction module is used to perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block; The residual calculation module is used to perform pixel prediction on the image block to obtain the predicted value of each component of all pixels to be encoded in the image block; The zero-determination module is used to determine whether the residual of each component of all pixels to be encoded in the image block is all zero. If the residual of any component of all pixels to be encoded in the image block is all zero, then a first identifier is set to represent the component with all zero residuals. The residual separation module is used to set components whose residuals are not all zero as non-zero block components, and to separate the residuals of the non-zero block components into amplitude and sign bits; The encoding module is used to perform entropy encoding on the amplitude to obtain amplitude encoding, and to perform direct transmission encoding on the sign bit to obtain sign bit encoding, and to set a second identifier for the non-zero block component; The total bit consumption calculation module is used to calculate the total bit consumption of the image block and compare the total bit consumption of the image block with the bit consumption of the original pixel value of the image block. If the total bit consumption of the image block is less than the bit consumption of the original pixel value of the image block, it indicates that the compression is successful and the compressed bit stream is formed. The compressed bit stream includes the amplitude encoding and the sign bit encoding. The bitstream output module is used to store the compressed bitstream to an off-chip storage unit until all the image blocks are compressed.