CN114786011A - JPEG image compression method, system, equipment and storage medium - Google Patents

JPEG image compression method, system, equipment and storage medium Download PDF

Info

Publication number
CN114786011A
CN114786011A CN202210712053.0A CN202210712053A CN114786011A CN 114786011 A CN114786011 A CN 114786011A CN 202210712053 A CN202210712053 A CN 202210712053A CN 114786011 A CN114786011 A CN 114786011A
Authority
CN
China
Prior art keywords
frame
bandwidth
factor
calculating
image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210712053.0A
Other languages
Chinese (zh)
Other versions
CN114786011B (en
Inventor
孙旭
周玉龙
刘刚
李拓
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202210712053.0A priority Critical patent/CN114786011B/en
Publication of CN114786011A publication Critical patent/CN114786011A/en
Application granted granted Critical
Publication of CN114786011B publication Critical patent/CN114786011B/en
Priority to PCT/CN2022/141668 priority patent/WO2023246047A1/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/136Incoming video signal characteristics or properties
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/186Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being a colour or a chrominance component

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention provides a method, a system, equipment and a storage medium for JPEG image compression, wherein the method comprises the following steps: in response to a current image frame being in a starting frame, encoding the current image using a standard quantization coefficient table; in response to the current image frame not being in the starting frame, calculating a weighted average image data length adjacent to a first predetermined number of frames, and calculating an encoding factor according to the weighted average image data length; predicting a bandwidth factor of a next frame according to the change condition of the bandwidth of the adjacent second predetermined number of frames; and determining a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to a quantization table corresponding to the next frame. The invention aims at optimizing the encoding process frame by frame when the system bandwidth changes and the image characteristics change, so that the encoded image is always in the highest allowable image quality.

Description

JPEG image compression method, system, equipment and storage medium
Technical Field
The present invention relates to the field of chip design, and more particularly, to a method, system, device, and storage medium for JPEG image compression.
Background
JPEG video image compression is a commonly used international standard for video image compression, and is used to compress continuous tone still images (including grayscale images and color images). JPEG is an abbreviation for Joint Photographic Experts Group (Joint Photographic Experts Group), and this standard is intended to support a variety of applications based on continuous tone static image compression. The image to be compressed can be any color space, and a user can enable the compression effect to reach or approach the top compression performance in the industry field by adjusting the compression ratio and has good analysis and reduction quality. Therefore, JPEG image compression is very essential when a large number of images need to be stored and transmitted.
As shown in fig. 1, it is a flow chart of classic JPEG image compression, which mainly includes color mode conversion, DCT (discrete cosine transform), quantization, Z-word arrangement, run-length encoding, huffman encoding, and data packing. The color mode conversion is to convert an RGB color mode into a YCbCr color mode. DCT is to process the whole image according to 8X8 small blocks, and DCT is performed on 3 color channels of each small block, in this process, image data input according to rows and columns needs to be divided into a plurality of 8X8 small blocks, and then DCT is performed in sequence. The DCT process has the most resource consumption, the largest delay and the highest technical realization difficulty, and the performance of the whole algorithm is determined to a great extent.
In the actual technical application process, a video image is transmitted to a subsequent stage or other devices after being compressed by JPEG, but the bandwidth of an actual physical channel for transmission is fixed, other data needs to be transmitted in the bandwidth (the bandwidth occupied by the data also changes at any time), and the priority of the data may also be higher than that of the video image, which causes the bandwidth actually allocated to the video image to change, so that the image is prone to being jammed or displayed. In the prior art, the following two methods are generally used: 1. performing compression processing according to the minimum bandwidth possibly allocated to the video image; 2. when the bandwidth changes, the compression rate of each frame is fixedly improved, and the frame rate is ensured to be stable. The prior art has the following defects: 1. the method is simple, has small realization difficulty, can greatly reduce the image quality, and has lower average bandwidth utilization rate; 2. although this method can ensure the frame rate to be stable, i.e. the video image is not jammed, it will seriously reduce the image quality.
Disclosure of Invention
In view of the above, an object of embodiments of the present invention is to provide a method, a system, a computer device, and a computer readable storage medium for JPEG image compression, where when an external bandwidth changes, the coding characteristics of an image are analyzed frame by frame, quantization coefficients are calculated, and a quantization coefficient table is optimized frame by frame, so as to improve image quality as much as possible while ensuring that the image is not jammed.
Based on the above object, an aspect of the embodiments of the present invention provides a method for JPEG image compression, including the following steps: in response to a current image frame being in a starting frame, encoding the current image using a standard quantization coefficient table; in response to the current image frame not being in the starting frame, calculating a weighted average image data length adjacent to a first predetermined number of frames, and calculating an encoding factor according to the weighted average image data length; predicting a bandwidth factor of a next frame according to the change condition of the bandwidth of the adjacent second predetermined number of frames; and determining a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to a quantization table corresponding to the next frame.
In some embodiments, said calculating a weighted average image data length adjacent to the first predetermined number of frames comprises: and carrying out weighted average calculation on the length of the coded image of each frame in the adjacent first preset number of frames.
In some embodiments, said calculating an encoding factor from said weighted average image data length comprises: and determining the frame length after standard coding according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the weighted average image data length to the frame length after standard coding.
In some embodiments, the predicting the bandwidth factor of the next frame according to the bandwidth change of the adjacent second predetermined number of frames includes: respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
In some embodiments, said calculating a bandwidth factor for a next frame from said prediction value comprises: and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
In some embodiments, said calculating the average bandwidth of said adjacent second predetermined number of frames respectively comprises: calculating the time mark point of each frame according to the original frame rate and the frame starting position of the image, recording the corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
In some embodiments, the determining a quantization parameter of the current image frame by a quantization table according to the relationship between the coding factor and the bandwidth factor comprises: determining the brightness and the chroma of the current image frame according to the quantization table in response to the coding factor being less than or equal to the bandwidth factor; and in response to the coding factor being greater than the bandwidth factor, determining the luminance and chrominance of the current image frame from the ratio of the coding factor and the bandwidth factor.
In another aspect of the embodiments of the present invention, a JPEG image compression system is provided, including: an encoding module configured to encode a current image using a standard quantization coefficient table in response to the current image frame being in a starting frame; the first calculation module is used for calculating the weighted average image data length adjacent to a first preset number of frames in response to the fact that the current image frame is not located in the starting frame, and calculating a coding factor according to the weighted average image data length; the second calculation module is configured to predict a bandwidth factor of a next frame according to a change condition of bandwidths of adjacent second predetermined number of frames; and the execution module is configured for determining a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to a quantization table corresponding to the next frame.
In some embodiments, the first computing module is configured to: and carrying out weighted average calculation on the length of the coded image of each frame in the adjacent first preset number of frames.
In some embodiments, the first computing module is configured to: and determining the length of a standard coded frame according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the length of the weighted average image data to the length of the standard coded frame.
In some embodiments, the second computing module is configured to: respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
In some embodiments, the second computing module is configured to: and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
In some embodiments, the second computing module is configured to: calculating the time mark point of each frame according to the original frame rate and the frame starting position of the image, recording the corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
In another aspect of the embodiments of the present invention, there is also provided a computer device, including: at least one processor; and a memory storing computer instructions executable on the processor, the instructions when executed by the processor implementing the steps of the method as above.
In a further aspect of the embodiments of the present invention, a computer-readable storage medium is also provided, in which a computer program for implementing the above method steps is stored when the computer program is executed by a processor.
The invention has the following beneficial technical effects: when the external bandwidth changes, the coding characteristics of the image are analyzed frame by frame, the quantization coefficient is calculated, the quantization coefficient table is optimized frame by frame, and the image quality is improved as much as possible under the condition that the image is not blocked.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other embodiments can be obtained according to the drawings without creative efforts.
FIG. 1 is a prior art JPEG image compression flow chart;
FIG. 2 is a schematic diagram of an embodiment of a method of JPEG image compression provided by the present invention;
FIG. 3 is a flowchart of an embodiment of a method for JPEG image compression provided by the present invention;
FIG. 4 is a table of luminance standard quantization coefficients;
FIG. 5 is a schematic diagram of an embodiment of a JPEG image compression system provided in the present invention;
FIG. 6 is a schematic diagram of a hardware structure of an embodiment of a computer device for JPEG image compression according to the present invention;
FIG. 7 is a schematic diagram of an embodiment of a computer storage medium for JPEG image compression provided by the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the following embodiments of the present invention are described in further detail with reference to the accompanying drawings.
It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are used for distinguishing two entities with the same name but different names or different parameters, and it should be noted that "first" and "second" are only used for convenience of expression and should not be construed as a limitation to the embodiments of the present invention, and no description is given in the following embodiments.
In a first aspect of the embodiments of the present invention, an embodiment of a method for JPEG image compression is provided. Fig. 2 is a schematic diagram illustrating an embodiment of a method for JPEG image compression according to the present invention. As shown in fig. 2, the embodiment of the present invention includes the following steps:
s1, in response to the current image frame being in the initial frame, encoding the current image by using a standard quantization coefficient table;
s2, in response to the current image frame not being in the start frame, calculating the weighted average image data length adjacent to the first predetermined number of frames, and calculating the coding factor according to the weighted average image data length;
s3, predicting the bandwidth factor of the next frame according to the bandwidth change condition of the adjacent second predetermined number of frames; and
and S4, determining the quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to the quantization table corresponding to the next frame.
The essence of the quantization process is the process of optimizing the generation of an 8x8 coefficient matrix after discrete cosine transformation. Since the human eye is insensitive to high frequency components, the reduction of the data size can be achieved by keeping a small amount or removing the high frequency part of the 8 × 8 coefficient matrix. The actual purpose of the quantization process is to reduce the amplitude values of the non-zero frequency component coefficients and to increase the number of zero-valued frequency component coefficients. The actual implementation of the quantization process is to divide each coefficient value of the 8 × 8 coefficient matrix generated after discrete cosine transformation by a constant corresponding to the coefficient value (the coefficients are combined to form a quantization parameter table), and round the quotient to obtain a quantized coefficient value. The quantization process is a lossy process and the high frequency component part of the quantized coefficient matrix will be substantially close to 0. The quantization parameter table can be produced by a standard quantization coefficient table and a quantization step size, and the selection of the quantization step size can change the compression rate and the precision of the whole encoder. The quantization step value is large, the compression ratio of the obtained code stream is high, and the loss of image detail information is large; and otherwise, the compression ratio of the obtained code stream is lower, but the detail information of the image can be more reserved. Therefore, the output code stream state of the encoder can be controlled by adjusting the value of the quantization step. The human eye is more sensitive to luminance than to color difference, so two quantization tables are often used in the quantization process: a luminance quantization table and a color difference quantization table.
The Huffman coding principle is that the probability of each pixel value in an image is counted firstly, then each pixel value is in one-to-one correspondence with each code word according to the probability of each pixel value, the pixel value with high probability of occurrence is allocated with a shorter code word, the pixel value with low probability of occurrence is allocated with a longer code word, and therefore data is further compressed.
Fig. 3 is a flowchart of an embodiment of a JPEG image compression method according to the present invention, and the embodiment of the present invention is described with reference to fig. 3.
In response to a current image frame being in a starting frame, the current image is encoded using a standard quantization coefficient table. In the embodiment of the present invention, the start frame refers to the first 6 frames of images of the video image when the video image starts to be encoded. When the frames are coded, the standard quantization coefficient table is used for coding without considering the influence of external bandwidth. Fig. 4 is a luminance standard quantization coefficient table.
In response to the current image frame not being in the starting frame, a weighted average image data length adjacent to a first predetermined number of frames is calculated, and an encoding factor is calculated based on the weighted average image data length.
In some embodiments, said calculating a weighted average image data length adjacent to the first predetermined number of frames comprises: and carrying out weighted average calculation on the coded image length of each frame in the adjacent first predetermined number of frames.
In some embodiments, said calculating an encoding factor from said weighted average image data length comprises: and determining the frame length after standard coding according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the weighted average image data length to the frame length after standard coding.
When the frame head is detected, the frame count frame _ cnt is set to 0, when the effective data is output after the huffman coding, the counter starts to accumulate, and when the frame tail is detected, the frame _ cnt is registered as the frame _ cnt _ reg. The encoded picture lengths are registered for the first 1-5 frames, namely frame _ cnt _ reg _1, frame _ cnt _ reg _2, frame _ cnt _ reg _3, frame _ cnt _ reg _4, and frame _ cnt _ reg _ 5.
When the encoded image length frame _ cnt _ reg _6 of the 6 th frame is obtained, the time-weighted average image data length frame _ ave is calculated. frame _ ave = (6 _ frame _ cnt _ reg _6+4 _ frame _ cnt _ reg _5 +2 _ frame _ cnt _ reg _4+2 _ frame _ cnt _ reg _3+ frame _ cnt _ reg _2+ frame _ cnt _ reg _ 1)/16. When the coded picture length of the 7 th frame is obtained, the value is assigned to frame _ cnt _ reg _6, the previous value of frame _ cnt _ reg _5 is assigned to frame _ cnt _ reg _4, and so on, the picture length of the nearest 6 frames is obtained, and then frame _ ave is calculated according to the same formula method.
The coding factor Ta is calculated, Ta = frame _ ave/frame _ std. Where frame _ std is the standard encoded frame length, and is related to the image resolution and pixel depth, and this value is a fixed value when the video image specification determines.
And predicting the bandwidth factor of the next frame according to the change condition of the bandwidth adjacent to the second preset number of frames.
In some embodiments, the predicting the bandwidth factor of the next frame according to the variation of the bandwidth of the adjacent second predetermined number of frames includes: respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
In some embodiments, said calculating a bandwidth factor for a next frame from said prediction value comprises: and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
In some embodiments, said calculating the average bandwidth of said second predetermined number of frames comprises: and calculating a time mark point of each frame according to the original frame rate and the frame starting position of the image, recording corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
The bandwidth factor is calculated by using the bandwidth gradient based on the adjacent 3 frames, and the available bandwidth of the next frame is predicted, and finally the bandwidth factor of the next frame is calculated. Therefore, the bandwidth factor is essentially a prediction value, and is predicted to be the next frame based on the change of the available bandwidth of the previous 3 frames. In the design and operation process of an actual chip system, the change of the bandwidth is correlated in time, so that the method has a solid theoretical support. The method comprises the following specific steps:
the granted average bandwidth Band _ ave for each frame of image is calculated. The granted bandwidth of the image refers to the allocated bandwidth of the jpeg compressed data stream in the whole bus system. In a bus architecture of the soc system, under the influence of a plurality of factors such as priority setting and actual data bandwidth, allocated bandwidth of different master and slave devices changes in real time, some bus systems can provide bandwidth Band _ i of each path of data in real time, and some bus systems need to calculate according to related protocols.
Firstly, 3 groups of time mark points T1, T2 and T3 of each frame are calculated, the time of the frame starting position is T1, the time of the frame tail position is T3, the time of the frame middle position is T2= T1+1/(frame x 2), and the frame is the frame rate according to the original frame rate of the image and the frame starting position. Secondly, recording the corresponding bandwidth Band _ i at the time mark point, and registering and naming Band _ T1, Band _ T2 and Band _ T3. Finally, Band _ ave = (Band _ T1+ Band _ T2+ Band _ T3)/3 is calculated. The average bandwidth of the latest consecutive 3 frames is calculated and recorded in the same way, and recorded as Band _ ave _1, Band _ ave _2, and Band _ ave _ 3. Calculating gradient value grad = (Band _ ave _3-Band _ ave _2) + (Band _ ave _ 2-Band _ ave _ 1). And calculating a predicted value Band _ p = Band _ ave _1+ grad of the bandwidth of the next frame. The bandwidth factor Tb = Band _ p/Band _ std is calculated. The Band _ std is a standard bandwidth, i.e. a maximum bandwidth occupied under the current image specification, and is related to the image resolution, the pixel depth and the frame rate, and when the video image specification is determined, the value is a fixed value.
And determining a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to a quantization table corresponding to the next frame.
In some embodiments, the determining a quantization parameter of the current image frame by a quantization table according to the relationship between the coding factor and the bandwidth factor comprises: in response to the coding factor being less than or equal to the bandwidth factor, determining the luminance and chrominance of the current image frame according to the quantization table; and in response to the coding factor being greater than the bandwidth factor, determining the luminance and chrominance of the current image frame from the ratio of the coding factor and the bandwidth factor.
The JPEG protocol specifies a standard quantization parameter table Q _ s (essentially an 8x8 matrix) for luminance and chrominance, and the calculation process of the quantization parameter table is the same as that of luminance and chrominance, and is not separately described here. When T1/(T2) <1 or =1, [ Q ] = [ Q _ s ]; when T1/(T2) >1, [ Q ] = [ Q _ s ] × T1/(T2), where [ Q ] represents luminance or chrominance.
And updating the calculated quantization parameter table to a quantization table of the next frame image coding, and performing corresponding division operation to finish quantization calculation. It should be noted that the bandwidth factor, the coding factor, and the quantization parameter table are calculated at the end of each frame, and the quantization table is used as the quantization parameter table for the next frame during the quantization process.
The embodiment of the invention provides a design and implementation method of high-performance self-adaptive JPEG compression, which can optimize the encoding process frame by frame aiming at the change of system bandwidth and the change of image characteristics, so that the encoded image is always in the highest allowable image quality.
It should be noted that, the steps in the embodiments of the method for JPEG image compression described above can be mutually intersected, replaced, added, or deleted, and therefore, these methods for JPEG image compression that are reasonably arranged and combined to transform also belong to the scope of the present invention, and the scope of the present invention should not be limited to the embodiments.
In view of the above objects, a second aspect of the embodiments of the present invention provides a system for JPEG image compression. As shown in fig. 5, the system 200 includes the following modules: an encoding module configured to encode a current image using a standard quantization coefficient table in response to the current image frame being in a starting frame; a first calculation module configured to calculate a weighted average image data length adjacent to a first predetermined number of frames in response to a current image frame not being in a start frame, and calculate an encoding factor according to the weighted average image data length; the second calculation module is configured to predict a bandwidth factor of a next frame according to a change condition of bandwidths of adjacent second predetermined number of frames; and the execution module is configured for determining a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to a quantization table corresponding to the next frame.
In some embodiments, the first computing module is configured to: and carrying out weighted average calculation on the length of the coded image of each frame in the adjacent first preset number of frames.
In some embodiments, the first computing module is configured to: and determining the frame length after standard coding according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the weighted average image data length to the frame length after standard coding.
In some embodiments, the second computing module is configured to: respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
In some embodiments, the second computing module is configured to: and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
In some embodiments, the second computing module is configured to: and calculating a time mark point of each frame according to the original frame rate and the frame starting position of the image, recording corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
In some embodiments, the execution module is configured to: in response to the coding factor being less than or equal to the bandwidth factor, determining the luminance and chrominance of the current image frame according to the quantization table; and in response to the coding factor being greater than the bandwidth factor, determining the luminance and chrominance of the current image frame from the ratio of the coding factor and the bandwidth factor.
In view of the above object, a third aspect of an embodiment of the present invention provides a computer device, including: at least one processor; and a memory storing computer instructions executable on the processor, the instructions being executable by the processor to perform the steps of: s1, in response to the current image frame being in the initial frame, encoding the current image by using a standard quantization coefficient table; s2, in response to the current image frame not being in the start frame, calculating the weighted average image data length adjacent to the first predetermined number of frames, and calculating the coding factor according to the weighted average image data length; s3, predicting the bandwidth factor of the next frame according to the bandwidth change condition of the adjacent second predetermined number of frames; and S4, determining the quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to the quantization table corresponding to the next frame.
In some embodiments, said calculating a weighted average image data length adjacent to the first predetermined number of frames comprises: and carrying out weighted average calculation on the coded image length of each frame in the adjacent first predetermined number of frames.
In some embodiments, said calculating an encoding factor from said weighted average image data length comprises: and determining the length of a standard coded frame according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the length of the weighted average image data to the length of the standard coded frame.
In some embodiments, the predicting the bandwidth factor of the next frame according to the variation of the bandwidth of the adjacent second predetermined number of frames includes: respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
In some embodiments, said calculating a bandwidth factor for a next frame from said prediction value comprises: and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
In some embodiments, said calculating the average bandwidth of said second predetermined number of frames comprises: and calculating a time mark point of each frame according to the original frame rate and the frame starting position of the image, recording corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
In some embodiments, the determining a quantization parameter of the current image frame by a quantization table according to the relationship between the coding factor and the bandwidth factor comprises: determining the brightness and the chroma of the current image frame according to the quantization table in response to the coding factor being less than or equal to the bandwidth factor; and in response to the coding factor being greater than the bandwidth factor, determining the luminance and chrominance of the current image frame from the ratio of the coding factor and the bandwidth factor.
Fig. 6 is a schematic diagram of a hardware structure of an embodiment of the computer device for JPEG image compression according to the present invention.
Taking the device shown in fig. 6 as an example, the device includes a processor 301 and a memory 302.
The processor 301 and the memory 302 may be connected by a bus or other means, and fig. 6 illustrates a connection by a bus as an example.
The memory 302 is a non-volatile computer-readable storage medium, and can be used for storing non-volatile software programs, non-volatile computer-executable programs, and modules, such as program instructions/modules corresponding to the JPEG image compression method in the embodiment of the present application. The processor 301 executes various functional applications of the server and data processing, i.e., implements a method of JPEG image compression, by running nonvolatile software programs, instructions, and modules stored in the memory 302.
The memory 302 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the JPEG image compression method, or the like. Further, the memory 302 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some embodiments, memory 302 optionally includes memory located remotely from processor 301, which may be connected to a local module via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Computer instructions 303 corresponding to one or more methods of JPEG image compression are stored in the memory 302 and when executed by the processor 301, perform the method of JPEG image compression in any of the above-described method embodiments.
Any embodiment of a computer device for performing the above-described method for JPEG image compression may achieve the same or similar effects as any of the preceding method embodiments corresponding thereto.
The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs a method of JPEG image compression.
Fig. 7 is a schematic diagram of an embodiment of a computer storage medium for JPEG image compression according to the present invention. Taking the computer storage medium as shown in fig. 7 as an example, the computer readable storage medium 401 stores a computer program 402 which, when executed by a processor, performs the method as described above.
Finally, it should be noted that, as one of ordinary skill in the art can appreciate that all or part of the processes of the methods of the above embodiments can be implemented by a computer program to instruct related hardware to implement the methods of JPEG image compression. The storage medium of the program may be a magnetic disk, an optical disk, a read-only memory (ROM), or a Random Access Memory (RAM). The embodiments of the computer program may achieve the same or similar effects as any of the above-described method embodiments.
The foregoing is an exemplary embodiment of the present disclosure, but it should be noted that various changes and modifications could be made herein without departing from the scope of the present disclosure as defined by the appended claims. The functions, steps and/or actions of the method claims in accordance with the disclosed embodiments described herein need not be performed in any particular order. Furthermore, although elements of the disclosed embodiments of the invention may be described or claimed in the singular, the plural is contemplated unless limitation to the singular is explicitly stated.
It should be understood that, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly supports the exception. It should also be understood that "and/or" as used herein is meant to include any and all possible combinations of one or more of the associated listed items.
The numbers of the embodiments disclosed in the embodiments of the present invention are merely for description, and do not represent the merits of the embodiments.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
Those of ordinary skill in the art will understand that: the discussion of any embodiment above is meant to be exemplary only, and is not intended to intimate that the scope of the disclosure, including the claims, of embodiments of the invention is limited to these examples; within the idea of an embodiment of the invention, also technical features in the above embodiment or in different embodiments may be combined and there are many other variations of the different aspects of the embodiments of the invention as described above, which are not provided in detail for the sake of brevity. Therefore, any omissions, modifications, substitutions, improvements, and the like that may be made without departing from the spirit and principles of the embodiments of the present invention are intended to be included within the scope of the embodiments of the present invention.

Claims (15)

1. A JPEG image compression method is characterized by comprising the following steps:
in response to a current image frame being in a starting frame, encoding the current image using a standard quantization coefficient table;
in response to the current image frame not being in the starting frame, calculating a weighted average image data length adjacent to a first predetermined number of frames and calculating an encoding factor according to the weighted average image data length;
predicting a bandwidth factor of a next frame according to the change condition of the bandwidth of the adjacent second predetermined number of frames; and
and determining a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and updating the quantization parameter to a quantization table corresponding to the next frame.
2. The method of claim 1, wherein calculating the weighted average image data length adjacent to the first predetermined number of frames comprises:
and carrying out weighted average calculation on the length of the coded image of each frame in the adjacent first preset number of frames.
3. The method of claim 1, wherein said calculating an encoding factor based on said weighted average image data length comprises:
and determining the frame length after standard coding according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the weighted average image data length to the frame length after standard coding.
4. The method of claim 1, wherein predicting the bandwidth factor of the next frame according to the bandwidth change of the adjacent second predetermined number of frames comprises:
respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and
and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
5. The method of claim 4, wherein the calculating a bandwidth factor for the next frame based on the prediction value comprises:
and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
6. The method of claim 4, wherein said separately calculating the average bandwidth of the adjacent second predetermined number of frames comprises:
calculating the time mark point of each frame according to the original frame rate and the frame starting position of the image, recording the corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
7. The method of claim 1, wherein determining the quantization parameter of the current image frame from a quantization table according to the relationship between the coding factor and the bandwidth factor comprises:
in response to the coding factor being less than or equal to the bandwidth factor, determining the luminance and chrominance of the current image frame according to the quantization table; and
in response to the coding factor being greater than the bandwidth factor, determining the luminance and chrominance of the current image frame from a ratio of the coding factor and the bandwidth factor.
8. A system for JPEG image compression, comprising:
an encoding module configured to encode a current image using a standard quantization coefficient table in response to the current image frame being in a starting frame;
the first calculation module is used for calculating the weighted average image data length adjacent to a first preset number of frames in response to the fact that the current image frame is not located in the starting frame, and calculating a coding factor according to the weighted average image data length;
the second calculation module is used for predicting the bandwidth factor of the next frame according to the change situation of the bandwidth adjacent to the second preset number of frames; and
and the execution module is configured to determine a quantization parameter of the current image frame through a quantization table according to the relation between the coding factor and the bandwidth factor, and update the quantization parameter to a quantization table corresponding to the next frame.
9. The system of claim 8, wherein the first computing module is configured to:
and carrying out weighted average calculation on the coded image length of each frame in the adjacent first predetermined number of frames.
10. The system of claim 8, wherein the first computing module is configured to:
and determining the frame length after standard coding according to the image resolution and the pixel depth, and determining a coding factor according to the ratio of the weighted average image data length to the frame length after standard coding.
11. The system of claim 8, wherein the second computing module is configured to:
respectively calculating the average bandwidth of the adjacent second predetermined number of frames, and calculating a gradient value according to the average bandwidth; and
and calculating a predicted value of the bandwidth of the next frame according to the gradient value and the average bandwidth of the latest frame, and calculating a bandwidth factor of the next frame according to the predicted value.
12. The system of claim 11, wherein the second computing module is configured to:
and determining a standard bandwidth according to the image resolution, the pixel depth and the frame rate, and determining a bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth.
13. The system of claim 11, wherein the second computing module is configured to:
calculating the time mark point of each frame according to the original frame rate and the frame starting position of the image, recording the corresponding bandwidth according to the time mark point, and taking the average value of all the bandwidths as the average bandwidth of the current frame.
14. A computer device, comprising:
at least one processor; and
a memory storing computer instructions executable on the processor, the instructions when executed by the processor implementing the steps of the method of any one of claims 1 to 7.
15. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202210712053.0A 2022-06-22 2022-06-22 JPEG image compression method, system, equipment and storage medium Active CN114786011B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202210712053.0A CN114786011B (en) 2022-06-22 2022-06-22 JPEG image compression method, system, equipment and storage medium
PCT/CN2022/141668 WO2023246047A1 (en) 2022-06-22 2022-12-23 Jpeg image compression method and system, device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210712053.0A CN114786011B (en) 2022-06-22 2022-06-22 JPEG image compression method, system, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114786011A true CN114786011A (en) 2022-07-22
CN114786011B CN114786011B (en) 2022-11-15

Family

ID=82422426

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210712053.0A Active CN114786011B (en) 2022-06-22 2022-06-22 JPEG image compression method, system, equipment and storage medium

Country Status (2)

Country Link
CN (1) CN114786011B (en)
WO (1) WO2023246047A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116489361A (en) * 2023-06-25 2023-07-25 之江实验室 JPEG coding code stream control method and device based on FPGA
WO2023246047A1 (en) * 2022-06-22 2023-12-28 苏州元脑智能科技有限公司 Jpeg image compression method and system, device, and storage medium
WO2024098843A1 (en) * 2022-11-10 2024-05-16 苏州元脑智能科技有限公司 Method and system for improving compression quality of jpeg, chip and electronic device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5638125A (en) * 1994-07-08 1997-06-10 Samsung Electronics Co., Ltd. Quantization step size control apparatus using neural networks
CN1285691A (en) * 1999-08-20 2001-02-28 三星电子株式会社 Apparatus of self-adaptive controlling data transmission rate according to network bandwidth
CN111726633A (en) * 2020-05-11 2020-09-29 河南大学 Compressed video stream recoding method based on deep learning and significance perception
CN112399176A (en) * 2020-11-17 2021-02-23 深圳大学 Video coding method and device, computer equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5115309A (en) * 1990-09-10 1992-05-19 At&T Bell Laboratories Method and apparatus for dynamic channel bandwidth allocation among multiple parallel video coders
WO1999063760A1 (en) * 1998-05-30 1999-12-09 Sgs-Thomson Microelectronics Asia Pacific (Pte) Ltd. Sequence adaptive bit allocation for pictures encoding
HUP0301368A3 (en) * 2003-05-20 2005-09-28 Amt Advanced Multimedia Techno Method and equipment for compressing motion picture data
CN110381315B (en) * 2019-07-01 2021-08-17 西安万像电子科技有限公司 Code rate control method and device
CN113766226A (en) * 2020-06-05 2021-12-07 深圳市中兴微电子技术有限公司 Image encoding method, apparatus, device and storage medium
CN114786011B (en) * 2022-06-22 2022-11-15 苏州浪潮智能科技有限公司 JPEG image compression method, system, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5638125A (en) * 1994-07-08 1997-06-10 Samsung Electronics Co., Ltd. Quantization step size control apparatus using neural networks
CN1285691A (en) * 1999-08-20 2001-02-28 三星电子株式会社 Apparatus of self-adaptive controlling data transmission rate according to network bandwidth
CN111726633A (en) * 2020-05-11 2020-09-29 河南大学 Compressed video stream recoding method based on deep learning and significance perception
CN112399176A (en) * 2020-11-17 2021-02-23 深圳大学 Video coding method and device, computer equipment and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023246047A1 (en) * 2022-06-22 2023-12-28 苏州元脑智能科技有限公司 Jpeg image compression method and system, device, and storage medium
WO2024098843A1 (en) * 2022-11-10 2024-05-16 苏州元脑智能科技有限公司 Method and system for improving compression quality of jpeg, chip and electronic device
CN116489361A (en) * 2023-06-25 2023-07-25 之江实验室 JPEG coding code stream control method and device based on FPGA
CN116489361B (en) * 2023-06-25 2023-09-26 之江实验室 JPEG coding code stream control method and device based on FPGA

Also Published As

Publication number Publication date
WO2023246047A1 (en) 2023-12-28
CN114786011B (en) 2022-11-15

Similar Documents

Publication Publication Date Title
CN114786011B (en) JPEG image compression method, system, equipment and storage medium
US7843998B2 (en) Method for improved entropy coding
JP6512928B2 (en) Image coding apparatus, image processing apparatus, image coding method
US9621900B1 (en) Motion-based adaptive quantization
CN103581678B (en) To improve the method and system of decoder capabilities by using multiple decoder channels
JP2017055267A (en) Image encoding device, image processing apparatus, and image encoding method
JP2017508415A (en) Image encoding / decoding method and apparatus
CN113613004A (en) Image encoding method, image encoding device, electronic device, and storage medium
TW201919398A (en) Video data decoding method and device
US10110896B2 (en) Adaptive motion JPEG encoding method and system
TWI705693B (en) Apparatus and method for vector-based entropy coding for display stream compression
CN116489360A (en) Image coding and decoding method and device
CN115474062B (en) Method, system, chip and electronic equipment for improving JPEG compression quality
CN112887725A (en) Reference frame buffer data compression method, computer device and computer readable storage medium
US20060278725A1 (en) Image encoding and decoding method and apparatus, and computer-readable recording medium storing program for executing the method
JPH1066077A (en) Code amount control method for image data and its device
US7477787B2 (en) Image compression device and method
JP2007019878A (en) Image coding apparatus and image coding method
CN112866696A (en) 4K, 8K and 16K ultra-high-definition video coding optimization control method and device
CN113115041A (en) Lossless picture compression method, device and medium supporting alpha channel
CN110896487A (en) Method for compressing image data
JP3768691B2 (en) Image processing apparatus and method, and storage medium
CN116527903B (en) Image shallow compression method and decoding method
TWI832661B (en) Methods, devices and storage media for image coding or decoding
CN114051140B (en) Video encoding method, video encoding device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant