A dct coefficient processing circuit and method for image compression
By optimizing run-length encoding in the DCT coefficient processing circuit of image compression, it is only necessary to obtain the AC coefficient and run value of the previous pixel, which solves the problem of low efficiency of run-length encoding in the prior art and achieves a more efficient image compression effect.
Patent Information
- Application Number
- CN202411260875.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2044-09-10
AI Technical Summary
In existing image coding, run-length encoding is inefficient, especially in applications that process large amounts of data or require fast response times, where it demands significant computational resources and has poor real-time performance.
By using the DCT coefficient processing circuit in image compression, only the AC coefficient and run value of the previous pixel are needed to calculate the target run value of the current pixel, thus optimizing the run-length encoding process, reducing scanning operations, and improving encoding efficiency.
This significantly accelerates the computational efficiency of run-length encoding, improves the overall encoding efficiency of DCT coefficients during image compression, and reduces the computational resource requirements.
Smart Images

Figure CN119232953B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image compression technology, and in particular to a DCT coefficient processing circuit and method for image compression. Background Technology
[0002] Image compression generally includes operations such as DCT transform, quantization, zigzag scanning, run-length encoding, and post-coding processing. DCT transform is the first step in image compression, performing it on each small block of the image to transform the spatial domain image into the frequency domain. The DCT coefficients are then quantized, which reduces the precision of the coefficients, thus achieving compression. Many of the quantized coefficients become zero. The quantized DCT coefficients are then rearranged using a zigzag scan, grouping all zero and non-zero coefficients together. After the zigzag scan, run-length encoding is used to further compress the data. Run-length encoding identifies consecutive zero or non-zero values and replaces these consecutive values with a count value and a single value. The encoded DCT coefficients are then further entropy encoded (usually Huffman coding) to further compress the data.
[0003] Current image coding methods, such as run-length encoding, record the number of zero values by scanning the DCT coefficients of an image row by row or column by column. However, this method is inefficient and time-consuming, especially in applications that process large amounts of data or require fast response times. It has high computational resource requirements and poor real-time performance. Summary of the Invention
[0004] This application provides a DCT coefficient processing circuit and method for image compression, which only needs to obtain the AC coefficient and run value of the previous pixel when performing run-length encoding on the current pixel, greatly improving the efficiency of run-length encoding.
[0005] In a first aspect, embodiments of this application provide a DCT coefficient processing circuit for image compression, comprising:
[0006] The input module is used to receive the DC coefficient of the pixel block and the AC coefficient of each pixel in the pixel block;
[0007] The coefficient code calculation module is used to calculate the DC coefficient code of pixel blocks based on the DC coefficient.
[0008] The run-length statistics module includes a reference pixel register and a run-length calculation unit; the run-length calculation unit is used for:
[0009] Obtain the reference AC coefficients and reference run value from the reference pixel register;
[0010] The target run value of the current pixel is determined based on the reference AC coefficient and the reference run value;
[0011] Replace the reference AC coefficient in the reference pixel register with the AC coefficient of the current pixel;
[0012] Replace the reference run value in the reference pixel register with the target run value of the current pixel;
[0013] The code length calculation module is used to calculate the target binary code and code length of the DC coefficient and each AC coefficient;
[0014] The output module is used to combine and output the DC coefficient code, each target run length value, each target binary code, and each code length.
[0015] Furthermore, the coefficient code calculation module includes a coefficient register and a coefficient code unit; the coefficient code unit is used to obtain the reference DC coefficient in the coefficient register; calculate the difference between the DC coefficient and the reference DC coefficient, and use it as the DC coefficient code; and replace the reference DC coefficient in the coefficient register with the DC coefficient.
[0016] Furthermore, the run calculation unit is specifically used to increment the reference run value by 1 to obtain the target run value when the reference AC coefficient is 0 and the reference run value is not equal to the preset threshold; to set the target run value to 0 when the reference AC coefficient is 0 and the reference run value is equal to the preset threshold; and to set the target run value to 0 when the reference AC coefficient is not equal to 0.
[0017] Furthermore, the code length calculation module includes:
[0018] The absolute value unit is used to take the absolute value of the original binary code and then reverse the order to obtain the first sequence; where the original binary code is the binary representation of the DC coefficient or AC coefficient;
[0019] The inverting unit is used to subtract 1 from the first sequence and then invert it to obtain the second sequence;
[0020] The third sequence unit is used to obtain the third sequence based on the first and second sequences;
[0021] The code length unit is used to determine the initial binary code and code length based on the third sequence;
[0022] A binary unit is used to perform a bitwise AND operation between the original binary code and the initial binary code to obtain the target binary code.
[0023] Furthermore, the absolute value unit is used to take the reverse of the original binary code as the first sequence when the original binary code is positive; and to invert the original binary code and add 1 when the original binary code is negative to obtain the first sequence.
[0024] Furthermore, the third sequence unit is used to perform a bitwise AND operation on the first and second sequences, and then subtract 1 from the result to obtain the third sequence.
[0025] Furthermore, the code length unit is used to take the third sequence as the initial binary code when the original binary code is positive; to perform signal modulation on the third sequence when the original binary code is negative to obtain the initial binary code; to calculate the number of 1s in the third sequence and add 1 to the number of 1s to obtain the code length.
[0026] Furthermore, the circuit also includes:
[0027] The zero-value detection module is used to obtain the AC coefficients of each pixel in the input module and determine whether there are zero values in each AC coefficient; if so, the AC coefficients are sent to the run-length statistics module.
[0028] The zero-value judgment module and the coefficient code calculation module run within the same clock cycle.
[0029] Secondly, embodiments of this application also provide a DCT coefficient processing method for image compression, comprising:
[0030] Receive the DC coefficient of the pixel block and the AC coefficient of each pixel in the pixel block;
[0031] The DC coefficient code of a pixel block is calculated based on the DC coefficient.
[0032] Get the reference AC coefficient and reference run value of the previous pixel of the current pixel;
[0033] The target run value of the current pixel is determined based on the reference AC coefficient and the reference run value;
[0034] Calculate the target binary code and code length of the DC coefficient and each AC coefficient;
[0035] The DC coefficient code, each target run length value, each target binary code, and each code length are combined and output.
[0036] Furthermore, the above-mentioned determination of the target run value of the current pixel based on the reference AC coefficient and the reference run value includes:
[0037] If the reference AC coefficient is 0 and the reference run value is not equal to the preset threshold, then the reference run value is incremented by 1 to obtain the target run value; if the reference AC coefficient is 0 and the reference run value is equal to the preset threshold, then the target run value is 0; if the reference AC coefficient is not equal to 0, then the target run value is 0.
[0038] In summary, compared with the prior art, the beneficial effects of the technical solution provided in this application include at least the following:
[0039] This application provides a DCT coefficient processing circuit for image compression. In its run-length statistics module, the run-length calculation unit only needs to obtain the AC coefficient and run-length value of the previous pixel from the reference pixel register to calculate the target run-length value of the current pixel. This eliminates the need for scanning multiple coefficients, significantly accelerating the calculation efficiency of run-length encoding. By optimizing the run-length encoding process in the run-length statistics module, the circuit improves the efficiency of run-length encoding, thereby enhancing the overall encoding efficiency of DCT coefficients during image compression. Attached Figure Description
[0040] Figure 1 This is a structural diagram of a DCT coefficient processing circuit for image compression, provided as an exemplary embodiment of this application.
[0041] Figure 2 A data flow diagram of the run statistics module provided in an exemplary embodiment of this application.
[0042] Figure 3 A structural diagram of a DCT coefficient processing circuit for image compression is provided as another exemplary embodiment of this application.
[0043] Figure 4 A flowchart of a DCT coefficient processing method for image compression is provided as an exemplary embodiment of this application. Detailed Implementation
[0044] The technical solutions in 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, and not all embodiments.
[0045] Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0046] Run-length encoding is used in image compression standards primarily when processing specific parts of an image, especially the lossless parts, such as for compressing DCT (Discrete Cosine Transform) coefficients.
[0047] The first step in image compression is to perform a Directed Transform (DCT) on each small block of the image (typically 8x8 pixels), converting the spatial domain image to the frequency domain. The DCT coefficients are then quantized, a step that reduces the precision of the coefficients, thus achieving compression. Many of the quantized coefficients become zero. The quantized DCT coefficients are then rearranged using a zigzag scan, which groups all zero and non-zero coefficients together. After the zigzag scan, run-length encoding is used to further compress the data. Run-length encoding identifies consecutive zero or non-zero values and replaces these consecutive values with a count value and a single value. The encoded coefficients are then further entropy encoded (usually Huffman coding) to compress the data even further.
[0048] DCT coefficient quantization yields DC coefficients and AC coefficients. The DC coefficient refers to the value of the first pixel in each block (typically 8x8 pixels, but not limited to 8x8 in this application), and the AC coefficient refers to the values of the remaining 63 pixels in each block.
[0049] Current image compression coding generally uses software algorithms to implement run-length encoding. While software implementation of run-length encoding offers advantages in flexibility and portability, it also has some potential drawbacks. For example, software implementation requires more computational resources, especially in applications handling large amounts of data or requiring fast response times. Software implementation may consume more memory and storage resources, particularly when dealing with large datasets, leading to a decrease in overall system efficiency.
[0050] To resolve the above issues, please refer to [link / reference]. Figure 1 This application provides a DCT coefficient processing circuit for image compression, which may specifically include the following structure:
[0051] The input module is used to receive the DC coefficient of the pixel block and the AC coefficient of each pixel in the pixel block.
[0052] The coefficient code calculation module is used to calculate the DC coefficient code of pixel blocks based on DC coefficients.
[0053] The DC coefficient code refers to the difference between the first pixel value (DC coefficient) of each pixel block and the DC coefficient of the previous pixel block. Specifically, the coefficient code calculation module includes a coefficient register and a coefficient code unit. The coefficient code unit is used to obtain the reference DC coefficient in the coefficient register; calculate the difference between the DC coefficient and the reference DC coefficient and use it as the DC coefficient code; and replace the reference DC coefficient in the coefficient register with the DC coefficient.
[0054] For example, if the first block (pixel block) includes data: 15, ...; the second block includes data: 17, ...; the third block includes data: 17, ...; the fourth block includes data: 16, ...; ..., then their DC coefficients are 15, 17, 17, 16, ..., and their corresponding DC coefficient codes are 15, +2, 0, -1, ...
[0055] The run-length statistics module includes a reference pixel register and a run-length calculation unit. The run-length calculation unit is used to obtain the reference AC coefficient and reference run value in the reference pixel register; determine the target run value of the current pixel based on the reference AC coefficient and reference run value; replace the reference AC coefficient in the reference pixel register with the AC coefficient of the current pixel; and replace the reference run value in the reference pixel register with the target run value of the current pixel.
[0056] Specifically, please see Figure 2 The run-length calculation module of this application may include multiple cascaded run-length calculation units. Pixel blocks are grouped according to the number of run-length calculation units. Each run-length calculation unit receives one pixel's data within the pixel group. The first run-length calculation unit is connected to a reference pixel register, and then receives the AC coefficient of the current pixel as a reference AC coefficient. It then sends the target run-length value calculated based on the reference pixel register as a reference run-length value to the next-level run-length calculation unit, and so on until the last run-length calculation unit. The last run-length calculation unit uses the received AC coefficient as a reference AC coefficient and the calculated target run-length value as a reference run-length value into the reference pixel register.
[0057] Before receiving pixel data, the reference AC coefficient and reference run value in the reference pixel register are both 0 in the run statistics module. Taking an example where the run statistics module has 8 run calculation units, if a pixel block contains 8x8 pixels, it is divided into 8 groups for batch processing, with each group containing 8 pixels.
[0058] When the first set of pixel data is input into the run-length statistics module, the eight pixels are input into the eight run-length calculation units of the run-length statistics module. At this time, the reference run value and reference AC coefficient in the reference pixel register cnt[0] obtained by the first run-length calculation unit cnt[1] are both 0. The target run value of the first pixel of the first set of pixel data is calculated based on the two 0 values. Then, the target run value of the first pixel is used as the reference run value, and the AC coefficient of the first pixel is used as the reference AC coefficient and sent to the second run-length calculation unit cnt[2]. And so on. After all eight run-length calculation units have completed their calculations, the AC coefficient and target run value output by the last run-length calculation unit cnt buf are put into the reference pixel register cnt[0] as the reference AC coefficient and reference run value. When the next set of pixel data comes in, the first run-length calculation unit cnt[1] obtains the AC coefficient and target run value of the last pixel of the previous set when calculating the target run value of the first pixel of the next set of pixel data. The last run calculation unit, cnt buf, can also be used to obtain and store the target run values calculated by the previous 7 run calculation units and its own target run value. After all the run values of each group of pixel data in the pixel block have been calculated, the stored target run values are sent to the output module.
[0059] Understandably, the number of run calculation units in the run statistics module can be one or more. When there is only one run calculation unit, the pixels in the pixel block are input one by one into the run calculation unit of the run statistics module for calculation. The number of calculations performed by one run calculation unit is equal to the number of pixels in the pixel block. When there are n run calculation units, the pixel block is divided into n pairs of pixels to obtain m groups of pixel data. Each group of pixel data contains n pixels. The pixel data is input into the run statistics module one group at a time for run statistics. The number of calculations performed by each run calculation unit in the run statistics module is equal to the number of batches of pixel data, i.e., m.
[0060] The code length calculation module is used to calculate the target binary code and code length of the DC coefficient and each AC coefficient.
[0061] The output module combines and outputs the DC coefficient code, each target run length value, each target binary code, and each code length. Finally, the data output by the output module will proceed to the next step of image compression: entropy coding.
[0062] Each module in the DCT coefficient processing circuit described above can be obtained by appropriate combination of application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gates, or transistor logic devices.
[0063] The DCT coefficient processing circuit for image compression provided in the above embodiment allows the run-length calculation unit in the run-length statistics module to calculate the target run-length value of the current pixel simply by obtaining the AC coefficient and run-length value of the previous pixel from the reference pixel register. This eliminates the need to perform scanning operations on multiple coefficients, significantly accelerating the calculation efficiency of run-length encoding. By optimizing the run-length encoding process in the run-length statistics module, the circuit improves the efficiency of run-length encoding, thereby enhancing the overall encoding efficiency of DCT coefficients during image compression.
[0064] In some embodiments, the run calculation unit is specifically used to increment the reference run value by 1 to obtain the target run value when the reference AC coefficient is 0 and the reference run value is not equal to the preset threshold; to set the target run value to 0 when the reference AC coefficient is 0 and the reference run value is equal to the preset threshold; and to set the target run value to 0 when the reference AC coefficient is not equal to 0.
[0065] The preset threshold is determined by the number of bits used in the run-length encoding corresponding to the image format. Taking JPEG as an example, since JPEG encoding uses 4 bits to represent the number of consecutive 0s, its maximum value is 15, that is, the maximum run-length value is 15. Therefore, when the pixel block is in JPEG format, the pixel block includes 64 pixels; the preset threshold is 15.
[0066] Specifically, when the AC coefficient of the previous pixel is 0 and the run value is equal to 15, it means that the previous data is the 16th 0 value (which has reached the maximum value of JPEG run encoding). Therefore, the run value of the current pixel is cut to 0 and the counting starts again.
[0067] The above embodiments limit the run-length encoding by a preset threshold because different image formats provide different numbers of bits for run-length encoding. That is, this application can achieve image encoding of different formats by setting a preset threshold.
[0068] In some embodiments, the code length calculation module includes:
[0069] The absolute value unit is used to take the absolute value of the original binary code and then reverse the order to obtain the first sequence.
[0070] The original binary code is the binary representation of the DC coefficient or AC coefficient.
[0071] Specifically, the absolute value unit is used to take the reverse of the original binary code as the first sequence when the original binary code is positive; and to invert the original binary code and add 1 when the original binary code is negative to obtain the first sequence.
[0072] The invert unit is used to subtract 1 from the first sequence and then invert it to obtain the second sequence.
[0073] The third sequence unit is used to obtain the third sequence based on the first and second sequences. Specifically, the third sequence unit is used to perform a bitwise AND operation on the first and second sequences, reverse the result, and subtract 1 to obtain the third sequence.
[0074] The code length unit is used to determine the initial binary code and code length based on the third sequence. Specifically, the code length unit is used to take the third sequence as the initial binary code when the original binary code is positive; to perform signal modulation on the third sequence when the original binary code is negative to obtain the initial binary code; to calculate the number of 1s in the third sequence and add 1 to the number of 1s to obtain the code length.
[0075] A binary unit is used to perform a bitwise AND operation between the original binary code and the initial binary code to obtain the target binary code.
[0076] The code length calculation module in the above embodiment takes into account the possibility that both coefficients after DCT transformation may have negative values. Therefore, when calculating the code length, the absolute value of the original binary code of the two coefficients is taken and then processed, realizing the binary encoding and code length calculation of the coefficients of positive and negative numbers.
[0077] Let's take a specific example to illustrate the calculation process of the code length calculation module mentioned above:
[0078] DC and AC coefficients are usually 8-bit binary data. Suppose the original binary code of the DC or AC coefficient to be calculated is 11111010, which is -6 in decimal. Since it is a negative number, taking its absolute value will result in 00000110, which is 6 in decimal. The process of taking the absolute value of a negative number can be ANDed / ORed with a certain number, or it can be the negative number inverted and then 1 added.
[0079] Reverse the order of 00000110 to get 01100000, which is used as the first sequence.
[0080] Subtract 1 from the first sequence and then invert it to get 10100000, which is the second sequence. Perform a bitwise AND operation between the second sequence and the original first sequence, i.e., 01100000&10100000=00100000. Then subtract 1 from 00100000 to get 00000011, which is the third sequence.
[0081] Since the original binary code is negative, the third sequence is further processed by masking the signal to become 00000111, which is the initial binary code. The initial binary code and the original binary code are then ANDed: 11111010 & 00000111 = 00000110.
[0082] The mask signal processing involves taking the lower 7 bits of the original sequence and then appending a 1 to the last bit to obtain a new 8-bit binary number. In the above embodiment, the lower 7 bits of the third sequence are 0000011, and appending a 1 to the end results in 00000111.
[0083] After the above calculation, the target binary code of the original binary code can be obtained as 00000110. The target code length is the number of 1s in the third sequence plus 1. Since there are 2 1s in the third sequence, the target code length is 2 + 1 = 3.
[0084] Through the above process, the target binary code and code length of the DC coefficient and AC coefficient can be obtained within one clock cycle.
[0085] Please see Figure 3 In some embodiments, the circuit may further include a zero-value determination module, which is connected to the input module and the run-length statistics module respectively. The zero-value determination module is used to obtain the AC coefficients of each pixel in the input module and determine whether there are zero values in each AC coefficient. If there are, the AC coefficients are sent to the run-length statistics module.
[0086] Specifically, in the quantization step of the image compression process, the DCT coefficients are quantized using a quantization table, and the quantized AC coefficients are usually integers. During this process, if the quantized AC coefficient value becomes zero, then these AC coefficients will be considered zero by the zero-value detection module; that is, the zero-value detection module is designed to identify AC coefficients that are 0 after quantization. Therefore, if there are no AC coefficients of 0 in the input data, the calculation by the run-length statistics module 103 can be omitted, and the DC coefficient code and the target binary code and code length of both coefficients can be directly output, saving a significant amount of time.
[0087] When a zero-value judgment module is included, the zero-value judgment module and the coefficient code calculation module run within the same clock cycle, and run length statistics and coefficient code length calculation are performed within the same clock cycle. At this time, the entire pipeline only needs two clock cycles to complete the DCT coefficient processing of the input data, which significantly improves the coding efficiency of DCT coefficients.
[0088] Please see Figure 4 This application also provides a method for processing DCT coefficients in image compression, including:
[0089] Step S1: Receive the DC coefficient of the pixel block and the AC coefficient of each pixel in the pixel block.
[0090] Step S2: Calculate the DC coefficient code of the pixel block based on the DC coefficient.
[0091] Step S3: Obtain the reference AC coefficient and reference run value of the previous pixel of the current pixel.
[0092] Step S4: Determine the target run length value of the current pixel based on the reference AC coefficient and the reference run length value.
[0093] Step S5: Calculate the target binary code and code length of the DC coefficient and each AC coefficient.
[0094] Step S6: Output the DC coefficient code, each target run length value, each target binary code, and each code length.
[0095] In some embodiments, the above-mentioned calculation of the DC coefficient code of a pixel block based on the DC coefficient includes: obtaining the reference DC coefficient of the previous pixel block; calculating the difference between the DC coefficient and the reference DC coefficient, and using it as the DC coefficient code.
[0096] In some embodiments, determining the target run value of the current pixel based on the reference AC coefficient and the reference run value includes:
[0097] If the reference AC coefficient is 0 and the reference run value is not equal to the preset threshold, then the reference run value is incremented by 1 to obtain the target run value; if the reference AC coefficient is 0 and the reference run value is equal to the preset threshold, then the target run value is 0; if the reference AC coefficient is not equal to 0, then the target run value is 0.
[0098] In some embodiments, the above calculation of the target binary code and code length of the DC coefficients and each AC coefficient includes:
[0099] Step S51: Take the absolute value of the original binary code and then reverse the order to obtain the first sequence; wherein, the original binary code is the binary representation of the DC coefficient or AC coefficient.
[0100] Specifically, when the original binary code is positive, the reverse of the original binary code is used as the first sequence; when the original binary code is negative, the original binary code is inverted and then 1 is added to obtain the first sequence.
[0101] Step S52: Subtract 1 from the first sequence and then invert it to obtain the second sequence.
[0102] Step S53: Obtain the third sequence based on the first and second sequences.
[0103] Specifically, perform a bitwise AND operation on the first and second sequences, reverse the result, and subtract 1 to obtain the third sequence.
[0104] Step S54: Determine the initial binary code and code length based on the third sequence. Specifically, when the original binary code is positive, the third sequence is used as the initial binary code; when the original binary code is negative, the third sequence is modulated to obtain the initial binary code; the number of 1s in the third sequence is calculated, and the number of 1s is increased by 1 to obtain the code length.
[0105] Step S55: Perform a bitwise AND operation between the original binary code and the initial binary code to obtain the target binary code.
[0106] In some embodiments, the method further includes: after obtaining each AC coefficient, determining whether there is a zero value in each AC coefficient; if so, performing run statistics on each AC coefficient.
[0107] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0108] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A DCT coefficient processing circuit for image compression, characterized in that, include: The input module is used to receive the DC coefficient of the pixel block and the AC coefficient of each pixel in the pixel block; A coefficient code calculation module is used to calculate the DC coefficient code of the pixel block based on the DC coefficient; The coefficient code calculation module includes a coefficient register and a coefficient code unit; The coefficient code unit is used to obtain the reference DC coefficient in the coefficient register; calculate the difference between the DC coefficient and the reference DC coefficient, and use it as the DC coefficient code; Replace the reference DC coefficient in the coefficient register with the DC coefficient; The run-length statistics module includes a reference pixel register and a run-length calculation unit; the run-length calculation unit is used for: Obtain the reference AC coefficients and reference run value from the reference pixel register; The target run length value of the current pixel is determined based on the reference AC coefficient and the reference run length value; when the reference AC coefficient is 0 and the reference run length value is not equal to a preset threshold, the reference run length value is incremented by 1 to obtain the target run length value; when the reference AC coefficient is 0 and the reference run length value is equal to the preset threshold, the target run length value is set to 0. When the reference AC coefficient is not equal to 0, the target run value is set to 0; Replace the reference AC coefficient in the reference pixel register with the AC coefficient of the current pixel; Replace the reference run value in the reference pixel register with the target run value of the current pixel; The code length calculation module is used to calculate the target binary code and code length of the DC coefficient and each of the AC coefficients; The code length calculation module includes: an absolute value unit, used to take the absolute value of the original binary code and then reverse it to obtain a first sequence; wherein the original binary code is the binary representation of the DC coefficient or the AC coefficient; an inversion unit, used to subtract 1 from the first sequence and then invert it to obtain a second sequence; a third sequence unit, used to obtain a third sequence based on the first sequence and the second sequence; a code length unit, used to determine the initial binary code and code length based on the third sequence; and a binary unit, used to perform a bitwise AND operation between the original binary code and the initial binary code to obtain the target binary code. The output module is used to combine and output the DC coefficient code, each of the target run length values, each of the target binary codes, and each of the code lengths.
2. The DCT coefficient processing circuit for image compression according to claim 1, characterized in that, The absolute value unit is used to take the reverse of the original binary code as the first sequence when the original binary code is positive; and to invert the original binary code and add 1 when the original binary code is negative to obtain the first sequence.
3. The DCT coefficient processing circuit for image compression according to claim 1, characterized in that, The third sequence unit is used to perform a bitwise AND operation on the first sequence and the second sequence, and then subtract 1 from the result to obtain the third sequence.
4. The DCT coefficient processing circuit for image compression according to claim 1, characterized in that, The code length unit is used to use the third sequence as the initial binary code when the original binary code is positive. When the original binary code is negative, the third sequence is modulated to obtain the initial binary code; Calculate the number of 1s in the third sequence, and then add 1 to the number of 1s to obtain the code length.
5. The DCT coefficient processing circuit for image compression according to claim 1, characterized in that, Also includes: A zero-value determination module is used to obtain the AC coefficients of each pixel in the input module and determine whether there are zero values among the AC coefficients. If so, each of the AC coefficients is sent to the run statistics module; The zero-value judgment module and the coefficient code calculation module operate within the same clock cycle.
6. A method for processing DCT coefficients in image compression, characterized in that, The DCT coefficient processing circuit for image compression as described in any one of claims 1-5 includes: Receive the DC coefficient of the pixel block and the AC coefficient of each pixel in the pixel block; Calculate the DC coefficient code of the pixel block based on the DC coefficient; Get the reference AC coefficient and reference run value of the previous pixel of the current pixel; The target run length value of the current pixel is determined based on the reference AC coefficient and the reference run length value; Calculate the target binary code and code length of the DC coefficient and each of the AC coefficients; The DC coefficient code, each of the target run length values, each of the target binary codes, and each of the code lengths are combined and output.
7. The DCT coefficient processing method for image compression according to claim 6, characterized in that, Determining the target run length value of the current pixel based on the reference AC coefficient and the reference run length value includes: If the reference AC coefficient is 0 and the reference run value is not equal to the preset threshold, then increment the reference run value by 1 to obtain the target run value; If the reference AC coefficient is 0 and the reference run value is equal to the preset threshold, then the target run value is 0; If the reference AC coefficient is not equal to 0, then the target run value is 0.
Citation Information
Patent Citations
Video compression using adaptive variable length codes
CN101491098A
Image compression method and device, image decompression method and device, electronic equipment and storage medium
CN118573877A