CN114786011B - JPEG image compression method, system, equipment and storage medium - Google Patents
JPEG image compression method, system, equipment and storage medium Download PDFInfo
- Publication number
- CN114786011B CN114786011B CN202210712053.0A CN202210712053A CN114786011B CN 114786011 B CN114786011 B CN 114786011B CN 202210712053 A CN202210712053 A CN 202210712053A CN 114786011 B CN114786011 B CN 114786011B
- Authority
- CN
- China
- Prior art keywords
- frame
- bandwidth
- factor
- image
- frames
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 63
- 230000006835 compression Effects 0.000 title claims abstract description 41
- 238000007906 compression Methods 0.000 title claims abstract description 41
- 238000013139 quantization Methods 0.000 claims abstract description 91
- 230000004044 response Effects 0.000 claims abstract description 26
- 230000008859 change Effects 0.000 claims abstract description 14
- 238000004364 calculation method Methods 0.000 claims description 29
- 230000015654 memory Effects 0.000 claims description 19
- 238000004590 computer program Methods 0.000 claims description 7
- 241000023320 Luma <angiosperm> Species 0.000 claims 2
- OSWPMRLSEDHDFF-UHFFFAOYSA-N methyl salicylate Chemical compound COC(=O)C1=CC=CC=C1O OSWPMRLSEDHDFF-UHFFFAOYSA-N 0.000 claims 2
- 230000008569 process Effects 0.000 abstract description 17
- 238000010586 diagram Methods 0.000 description 6
- 239000011159 matrix material Substances 0.000 description 5
- 230000000694 effects Effects 0.000 description 4
- 238000013461 design Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000014509 gene expression Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 208000003028 Stuttering Diseases 0.000 description 1
- 230000003044 adaptive effect Effects 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000004806 packaging method and process Methods 0.000 description 1
- 230000000717 retained effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods 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/124—Quantisation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods 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/136—Incoming video signal characteristics or properties
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods 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/17—Methods 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/176—Methods 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods 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/186—Methods 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
Description
技术领域technical field
本发明涉及芯片设计领域,更具体地,特别是指一种JPEG图像压缩的方法、系统、设备和存储介质。The present invention relates to the field of chip design, more specifically, to a method, system, device and storage medium for JPEG image compression.
背景技术Background technique
JPEG视频图像压缩是一种常用的视频图像压缩的国际标准,用于对连续色调静态图像进行压缩(包括灰度图像和彩色图像)。JPEG是联合图像专家组(Joint PhotographicExperts Group)的缩写,这个标准目的在于支持各种基于连续色调静态图像压缩的应用。待压缩的图像可以是任何一个色彩空间,用户可以通过调整压缩比能让压缩效果达到或者接近行业领域中顶尖的压缩性能,且具有良好的解析还原质量。因此,当需要存储和传输大量的图像时,JPEG图像压缩是非常有必要的。JPEG video image compression is a commonly used international standard for video image compression, which is used to compress continuous tone still images (including grayscale images and color images). JPEG is the abbreviation of Joint Photographic Experts Group (Joint Photographic Experts Group), the purpose of this standard is to support various applications based on continuous tone still image compression. The image to be compressed can be in any color space, and the user can adjust the compression ratio so that the compression effect can reach or approach the top compression performance in the industry, and has good resolution and restoration quality. Therefore, when a large number of images need to be stored and transmitted, JPEG image compression is very necessary.
如图1所示,为经典的JPEG图像压缩流程图,主要包括色彩模式转换,DCT(离散余弦变换)、量化、Z字编排、行程编码、霍夫曼编码、数据打包。色彩模式转换是将RGB色彩模式转换为YCbCr色彩模式。DCT是将整个图像按照8X8的小块进行处理,每个小块的3个色彩通道分别进行DCT,在这个过程中需要将按照行列输入的图像数据分割为若干个8x8的小块,然后依次进行DCT。DCT过程资源消耗最多、延迟最大、技术实现难度最高,很大程度上决定整个算法的性能。As shown in Figure 1, it is a classic JPEG image compression flow chart, mainly including color mode conversion, DCT (discrete cosine transform), quantization, Z-arrangement, run-length encoding, Huffman encoding, and data packaging. Color mode conversion is to convert RGB color mode to YCbCr color mode. DCT is to process the entire image according to 8X8 small blocks, and the three color channels of each small block are respectively DCTed. In this process, the image data input according to the row and column needs to be divided into several 8X8 small blocks, and then sequentially DCT. The DCT process consumes the most resources, has the greatest delay, and is the most difficult to implement, which largely determines the performance of the entire algorithm.
在实际的技术应用过程中,常遇到这样的情景,视频图像经过JPEG压缩后向后级或其他设备发送,但发送的实际物理通道的带宽是固定的,在这个带宽中还需要发送其他的数据(数据占用的带宽也是随时变化的),且这些数据的优先级可能还会高于视频图像,这就会导致实际分配给视频图像的带宽会变化,因此图像就容易出现卡顿或花屏现象。在现有的技术中,一般使用如下两种方法:1、按照视频图像可能分配到的最小带宽进行压缩处理;2、在带宽发生变化时固定提高每一帧的压缩率,保证帧率稳定。现有技术的缺点:1、此方法较为简单,实现难度小,但会极大的降低图像质量,同时平均带宽利用率也较低;2、此方法虽然可以保证帧率稳定,即视频图像不卡顿,但会严重降低图像质量。In the actual technical application process, such a situation is often encountered, the video image is sent to the subsequent stage or other equipment after JPEG compression, but the bandwidth of the actual physical channel to be sent is fixed, and other channels need to be sent in this bandwidth Data (the bandwidth occupied by data is also changing at any time), and the priority of these data may be higher than that of video images, which will cause the actual bandwidth allocated to video images to change, so images are prone to freeze or blur . In the existing technology, the following two methods are generally used: 1. Compression processing is performed according to the minimum bandwidth that may be allocated to video images; 2. When the bandwidth changes, the compression rate of each frame is fixedly increased to ensure a stable frame rate. Shortcomings of prior art: 1, this method is comparatively simple, and realization difficulty is little, but can reduce image quality greatly, and average bandwidth utilization rate is also lower simultaneously; 2, although this method can guarantee frame rate stability, promptly video image does not Stuttering, but severely degrades image quality.
发明内容Contents of the invention
有鉴于此,本发明实施例的目的在于提出一种JPEG图像压缩的方法、系统、计算机设备及计算机可读存储介质,本发明在外部带宽变化时,逐帧分析图像的编码特性,计算量化系数,进而逐帧优化量化系数表,在保证图像不卡顿的情况下尽可能的提高图像质量。In view of this, the purpose of the embodiments of the present invention is to propose a method, system, computer equipment and computer-readable storage medium for JPEG image compression. The present invention analyzes the encoding characteristics of the image frame by frame and calculates the quantization coefficient when the external bandwidth changes. , and then optimize the quantization coefficient table frame by frame, and improve the image quality as much as possible while ensuring that the image is not stuck.
基于上述目的,本发明实施例的一方面提供了一种JPEG图像压缩的方法,包括如下步骤:响应于当前图像帧处于起始帧,使用标准量化系数表对所述当前图像进行编码;响应于当前图像帧不处于起始帧,计算邻近第一预定数量帧的加权平均图像数据长度,并根据所述加权平均图像数据长度计算编码因子;根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子;以及根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数,并将所述量化参数更新到下一帧对应的量化表中。Based on the above purpose, an aspect of the embodiments of the present invention provides a method for compressing a JPEG image, including the following steps: in response to the current image frame being at the start frame, encoding the current image using a standard quantization coefficient table; in response to The current image frame is not in the starting frame, calculate the weighted average image data length adjacent to the first predetermined number of frames, and calculate the encoding factor according to the weighted average image data length; predict the next according to the bandwidth change of the adjacent second predetermined number of frames a bandwidth factor of a frame; and determining the quantization parameter of the current image frame through a quantization table according to the relationship between the coding factor and the bandwidth factor, and updating the quantization parameter into the quantization table corresponding to the next frame.
在一些实施方式中,所述计算邻近第一预定数量帧的加权平均图像数据长度包括:将所述邻近第一预定数量帧中的每一帧的编码后图像长度进行加权平均计算。In some implementations, the calculating the weighted average image data length of frames adjacent to the first predetermined number includes: performing weighted average calculation on the encoded image length of each frame in the frames adjacent to the first predetermined number.
在一些实施方式中,所述根据所述加权平均图像数据长度计算编码因子包括:根据图像分辨率和像素深度确定标准编码后帧长度,并根据所述加权平均图像数据长度和所述标准编码后帧长度的比值确定编码因子。In some embodiments, the calculating the encoding factor according to the weighted average image data length includes: determining the standard encoded frame length according to the image resolution and pixel depth, and determining the frame length after encoding according to the weighted average image data length and the standard encoded frame length. The ratio of the frame lengths determines the coding factor.
在一些实施方式中,所述根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子包括:分别计算所述邻近第二预定数量帧的平均带宽,并根据所述平均带宽计算梯度值;以及根据所述梯度值和最近一帧的平均带宽计算下一帧带宽的预测值,并根据所述预测值计算下一帧的带宽因子。In some embodiments, the predicting the bandwidth factor of the next frame according to the change of the bandwidth of the frames adjacent to the second predetermined number includes: respectively calculating the average bandwidth of the frames adjacent to the second predetermined number, and calculating according to the average bandwidth a gradient value; 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 implementations, the calculating the bandwidth factor of the next frame according to the predicted value includes: determining the standard bandwidth according to the image resolution, pixel depth and frame rate, and determining according to the ratio of the predicted value to the standard bandwidth The bandwidth factor for the next frame.
在一些实施方式中,所述分别计算所述邻近第二预定数量帧的平均带宽包括:根据图像的原始帧率和帧起始位置计算每帧的时间标记点,根据所述时间标记点记录对应的带宽,并将所有带宽的平均值作为当前帧的平均带宽。In some implementations, said respectively calculating the average bandwidth of the adjacent second predetermined number of frames includes: calculating the time mark point of each frame according to the original frame rate of the image and the frame start position, and recording the corresponding time mark point according to the time mark point bandwidth, and take the average of all bandwidths as the average bandwidth of the current frame.
在一些实施方式中,所述根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数包括:响应于所述编码因子小于或等于所述带宽因子,按照所述量化表确定所述当前图像帧的亮度和色度;以及响应于所述编码因子大于所述带宽因子,根据所述编码因子和所述带宽因子的比值确定所述当前图像帧的亮度和色度。In some embodiments, the determining the quantization parameter of the current image frame through the quantization table according to the relationship between the coding factor and the bandwidth factor includes: responding to the coding factor being less than or equal to the bandwidth factor, according to the The quantization table determines the luminance and chroma of the current image frame; and in response to the encoding factor being greater than the bandwidth factor, determines the luminance and chrominance of the current image frame according to the ratio between the encoding factor and the bandwidth factor Spend.
本发明实施例的另一方面,提供了一种JPEG图像压缩的系统,包括:编码模块,配置用于响应于当前图像帧处于起始帧,使用标准量化系数表对所述当前图像进行编码;第一计算模块,配置用于响应于当前图像帧不处于起始帧,计算邻近第一预定数量帧的加权平均图像数据长度,并根据所述加权平均图像数据长度计算编码因子;第二计算模块,配置用于根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子;以及执行模块,配置用于根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数,并将所述量化参数更新到下一帧对应的量化表中。Another aspect of the embodiments of the present invention provides a JPEG image compression system, including: an encoding module configured to encode the current image using a standard quantization coefficient table in response to the fact that the current image frame is in the initial frame; The first calculation module is configured to calculate the weighted average image data length adjacent to the first predetermined number of frames in response to the current image frame not being in the initial frame, and calculate the encoding factor according to the weighted average image data length; the second calculation module , configured to predict the bandwidth factor of the next frame according to the variation of the bandwidth adjacent to the second predetermined number of frames; and an execution module configured to determine the current The quantization parameter of the image frame is updated to the quantization table corresponding to the next frame.
在一些实施方式中,所述第一计算模块配置用于:将所述邻近第一预定数量帧中的每一帧的编码后图像长度进行加权平均计算。In some implementations, the first calculation module is configured to: perform weighted average calculation on the encoded image lengths of each frame in the adjacent first predetermined number of frames.
在一些实施方式中,所述第一计算模块配置用于:根据图像分辨率和像素深度确定标准编码后帧长度,并根据所述加权平均图像数据长度和所述标准编码后帧长度的比值确定编码因子。In some implementations, the first calculation module is configured to: determine the standard coded frame length according to image resolution and pixel depth, and determine according to the ratio of the weighted average image data length to the standard coded frame length coding factor.
在一些实施方式中,所述第二计算模块配置用于:分别计算所述邻近第二预定数量帧的平均带宽,并根据所述平均带宽计算梯度值;以及根据所述梯度值和最近一帧的平均带宽计算下一帧带宽的预测值,并根据所述预测值计算下一帧的带宽因子。In some implementations, the second calculation module is configured to: respectively calculate the average bandwidth of the frames adjacent to the second predetermined number of frames, and calculate a gradient value according to the average bandwidth; and calculate the gradient value according to the gradient value and the latest frame The average bandwidth of the next frame is calculated to predict the bandwidth of the next frame, and the bandwidth factor of the next frame is calculated according to the predicted value.
在一些实施方式中,所述第二计算模块配置用于:根据图像分辨率、像素深度和帧率确定标准带宽,并根据所述预测值和所述标准带宽的比值确定下一帧的带宽因子。In some implementations, the second calculation module is configured to: determine the standard bandwidth according to the image resolution, pixel depth and frame rate, and determine the bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth .
在一些实施方式中,所述第二计算模块配置用于:根据图像的原始帧率和帧起始位置计算每帧的时间标记点,根据所述时间标记点记录对应的带宽,并将所有带宽的平均值作为当前帧的平均带宽。In some implementations, the second calculation module is configured to: calculate the time mark point of each frame according to the original frame rate of the image and the frame start position, record the corresponding bandwidth according to the time mark point, and store all bandwidth The average value of is used 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, the memory stores computer instructions executable on the processor, and the instructions are executed by the The steps of the above method are realized when the processor executes.
本发明实施例的再一方面,还提供了一种计算机可读存储介质,计算机可读存储介质存储有被处理器执行时实现如上方法步骤的计算机程序。In yet another aspect of the embodiments of the present invention, a computer-readable storage medium is also provided, and the computer-readable storage medium stores a computer program for implementing the above method steps when executed by a processor.
本发明具有以下有益技术效果:在外部带宽变化时,逐帧分析图像的编码特性,计算量化系数,进而逐帧优化量化系数表,在保证图像不卡顿的情况下尽可能的提高图像质量。The present invention has the following beneficial technical effects: when the external bandwidth changes, the encoding characteristics of the image are analyzed frame by frame, the quantization coefficient is calculated, and the quantization coefficient table is optimized frame by frame, so as to improve the image quality as much as possible while ensuring that the image is not stuck.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的实施例。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention, and those skilled in the art can obtain other embodiments according to these drawings without any creative effort.
图1为现有技术中JPEG图像压缩流程图;Fig. 1 is a flow chart of JPEG image compression in the prior art;
图2为本发明提供的JPEG图像压缩的方法的实施例的示意图;Fig. 2 is the schematic diagram of the embodiment of the method for JPEG image compression provided by the present invention;
图3为本发明提供的JPEG图像压缩的方法的实施例的流程图;Fig. 3 is the flowchart of the embodiment of the method for JPEG image compression provided by the present invention;
图4为亮度标准量化系数表;Fig. 4 is a brightness standard quantization coefficient table;
图5为本发明提供的JPEG图像压缩的系统的实施例的示意图;Fig. 5 is the schematic diagram of the embodiment of the system of JPEG image compression provided by the present invention;
图6为本发明提供的JPEG图像压缩的计算机设备的实施例的硬件结构示意图;Fig. 6 is the hardware structural representation of the embodiment of the computer equipment of JPEG image compression that the present invention provides;
图7为本发明提供的JPEG图像压缩的计算机存储介质的实施例的示意图。FIG. 7 is a schematic diagram of an embodiment of a computer storage medium for JPEG image compression provided by the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明实施例进一步详细说明。In order to make the object, technical solution and advantages of the present invention clearer, the embodiments of the present invention will be further described in detail below in conjunction with specific embodiments and 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 to distinguish two entities with the same name but different parameters or parameters that are not the same, see "first" and "second" It is only for the convenience of expression, and should not be construed as a limitation on the embodiments of the present invention, which will not be described one by one in the subsequent embodiments.
本发明实施例的第一个方面,提出了一种JPEG图像压缩的方法的实施例。图2示出的是本发明提供的JPEG图像压缩的方法的实施例的示意图。如图2所示,本发明实施例包括如下步骤:According to the first aspect of the embodiments of the present invention, an embodiment of a method for compressing a JPEG image is proposed. FIG. 2 is a schematic diagram of an embodiment of a method for compressing a JPEG image provided by the present invention. As shown in Figure 2, the embodiment of the present invention includes the following steps:
S1、响应于当前图像帧处于起始帧,使用标准量化系数表对所述当前图像进行编码;S1. In response to the fact that the current image frame is in the initial frame, encode the current image using a standard quantization coefficient table;
S2、响应于当前图像帧不处于起始帧,计算邻近第一预定数量帧的加权平均图像数据长度,并根据所述加权平均图像数据长度计算编码因子;S2. In response to the fact that the current image frame is not in the initial frame, calculate a weighted average image data length adjacent to the first predetermined number of frames, and calculate a coding factor according to the weighted average image data length;
S3、根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子;以及S3. Predict the bandwidth factor of the next frame according to the change of the bandwidth of the adjacent second predetermined number of frames; and
S4、根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数,并将所述量化参数更新到下一帧对应的量化表中。S4. Determine the quantization parameter of the current image frame through the quantization table according to the relationship between the encoding factor and the bandwidth factor, and update the quantization parameter into the quantization table corresponding to the next frame.
量化过程的本质是对离散余弦变换后生成8×8系数矩阵进行优化的过程。由于人类的眼睛对高频分量不敏感,因此可以通过保留少量或者去除8×8系数矩阵的高频部分来达到减少数据量的目的。量化过程的实际目的是减小非零频率分量系数的幅度值和增加零值频率分量系数的数量。量化过程的实际实现过程为将离散余弦变换后生成8×8系数矩阵的每个系数值除以对应于该系数值的常数(这些系数组合在一起就是量化参数表),将得到的商值四舍五入取整后得到量化后的系数值。量化过程是一个有损过程,量化后的系数矩阵的高频分量部分都基本会基本接近0。量化参数表可以通过标准量化系数表和量化步长生产,量化步长的选择可以改变整个编码器的压缩率和精度。量化步长取值较大,得到的码流压缩比较高,图像细节信息的损失较大;反之则得到的码流压缩比会比较低,但是图像的细节信息可以得到更多的保留。因此可以通过调整量化步长的值来控制编码器的输出码流状态。相对于色差,人类的眼睛对亮度的敏感程度更高,因此量化过程中往往使用两个量化表:亮度量化表和色差量化表。The essence of the quantization process is the process of optimizing the 8×8 coefficient matrix generated after the discrete cosine transform. Since human eyes are not sensitive to high-frequency components, the purpose of reducing the amount of data can be achieved by retaining a small amount or removing high-frequency parts of the 8×8 coefficient matrix. The actual purpose of the quantization process is to reduce the magnitude values of the non-zero frequency component coefficients and to increase the number of zero-valued frequency component coefficients. The actual implementation process of the quantization process is to divide each coefficient value of the 8×8 coefficient matrix generated by the discrete cosine transform by the constant corresponding to the coefficient value (these coefficients are combined together to form the quantization parameter table), and round the obtained quotient value After rounding, the quantized coefficient value is obtained. The quantization process is a lossy process, and the high-frequency components of the quantized coefficient matrix are basically close to 0. The quantization parameter table can be produced through the standard quantization coefficient table and quantization step size, and the selection of the quantization step size can change the compression rate and precision of the entire encoder. The larger the quantization step size, the higher the compression rate of the obtained code stream, and the greater loss of image detail information; otherwise, the obtained code stream compression ratio will be relatively low, but more image detail information can be retained. Therefore, it is possible to control the output stream state of the encoder by adjusting the value of the quantization step. Compared with color difference, human eyes are more sensitive to brightness, so two quantization tables are often used in the quantization process: brightness quantization table and color difference quantization table.
Huffman编码的原理为先统计图像中各个像素值出现的概率,然后根据各个像素值的概率将各个像素值用各个码字一一对应,将出现概率高的像素值分配较短的码字,而将出现概率低的像素值分配较长的码字,从而将数据进一步压缩。The principle of Huffman coding is to first count the probability of occurrence of each pixel value in the image, and then correspond each pixel value with each codeword one by one according to the probability of each pixel value, assign a shorter codeword to the pixel value with a high probability of occurrence, and A longer codeword is assigned to pixel values with low occurrence probability, thereby further compressing the data.
图3为本发明提供的JPEG图像压缩的方法的实施例的流程图,根据图3对本发明实施例进行说明。FIG. 3 is a flowchart of an embodiment of a method for compressing a JPEG image provided by the present invention, and the embodiment of the present invention will be described according to FIG. 3 .
响应于当前图像帧处于起始帧,使用标准量化系数表对所述当前图像进行编码。在本发明实施例中,起始帧是指视频图像刚开始编码时的前6帧图像。在这几帧编码时,不需要考虑外部带宽的影响,使用标准量化系数表进行编码。图4为亮度标准量化系数表。In response to the fact that the current image frame is the initial frame, the current image is encoded using a standard quantization coefficient table. In the embodiment of the present invention, the starting frame refers to the first 6 frames of images when the encoding of the video image is just started. When encoding these frames, it is not necessary to consider the impact of external bandwidth, and the standard quantization coefficient table is used for encoding. Figure 4 is a table of brightness standard quantization coefficients.
响应于当前图像帧不处于起始帧,计算邻近第一预定数量帧的加权平均图像数据长度,并根据所述加权平均图像数据长度计算编码因子。In response to the fact that the current image frame is not in the initial frame, calculate the weighted average image data length of adjacent first predetermined number of frames, and calculate the encoding factor according to the weighted average image data length.
在一些实施方式中,所述计算邻近第一预定数量帧的加权平均图像数据长度包括:将所述邻近第一预定数量帧中的每一帧的编码后图像长度进行加权平均计算。In some implementations, the calculating the weighted average image data length of frames adjacent to the first predetermined number includes: performing weighted average calculation on the encoded image length of each frame in the frames adjacent to the first predetermined number.
在一些实施方式中,所述根据所述加权平均图像数据长度计算编码因子包括:根据图像分辨率和像素深度确定标准编码后帧长度,并根据所述加权平均图像数据长度和所述标准编码后帧长度的比值确定编码因子。In some embodiments, the calculating the encoding factor according to the weighted average image data length includes: determining the standard encoded frame length according to the image resolution and pixel depth, and determining the frame length after encoding according to the weighted average image data length and the standard encoded frame length. The ratio of the frame lengths determines the coding factor.
在检测到图像帧首时将编码帧计数frame_cnt置为0,huffman编码后输出有效数据时,计数器开始累加,当检测到帧尾时,将frame_cnt寄存为frame_cnt_reg。在起始的1-5帧时,将编码后的图像长度寄存,即为frame_cnt_reg_1、frame_cnt_reg_2、frame_cnt_reg_3、frame_cnt_reg_4和frame_cnt_reg_5。When the beginning of the image frame is detected, the coded frame count frame_cnt is set to 0, and when valid data is output after huffman encoding, the counter starts to accumulate. When the end of the frame is detected, frame_cnt is registered as frame_cnt_reg. In the first 1-5 frames, the encoded image length is registered as frame_cnt_reg_1, frame_cnt_reg_2, frame_cnt_reg_3, frame_cnt_reg_4 and frame_cnt_reg_5.
在得到第6帧的编码后图像长度frame_cnt_reg_6时,计算时加权平均图像数据长度frame_ave。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。在得到第7帧的编码后图像长度时,将其的值赋给frame_cnt_reg_6,之前frame_cnt_reg_5值赋给frame_cnt_reg_4,依次类推,得到最邻近的6帧的图像长度,之后按照同样的公式方法计算frame_ave。When the encoded image length frame_cnt_reg_6 of the sixth 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 obtaining the encoded image length of the 7th frame, assign its value to frame_cnt_reg_6, assign the previous frame_cnt_reg_5 value to frame_cnt_reg_4, and so on, to obtain the image length of the nearest 6 frames, and then calculate frame_ave according to the same formula.
计算编码因子Ta,Ta=frame_ave/frame_std。其中,frame_std为标准编码后帧长度,与图像分辨率和像素深度有关,在视频图像规格确定时,此值为定值。Calculate the encoding factor Ta, Ta=frame_ave/frame_std. Among them, frame_std is the frame length after standard encoding, which is related to image resolution and pixel depth. When the video image specification is determined, this value is a fixed value.
根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子。The bandwidth factor of the next frame is predicted according to the variation of the bandwidth of the adjacent second predetermined number of frames.
在一些实施方式中,所述根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子包括:分别计算所述邻近第二预定数量帧的平均带宽,并根据所述平均带宽计算梯度值;以及根据所述梯度值和最近一帧的平均带宽计算下一帧带宽的预测值,并根据所述预测值计算下一帧的带宽因子。In some embodiments, the predicting the bandwidth factor of the next frame according to the change of the bandwidth of the frames adjacent to the second predetermined number includes: respectively calculating the average bandwidth of the frames adjacent to the second predetermined number, and calculating according to the average bandwidth a gradient value; 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 implementations, the calculating the bandwidth factor of the next frame according to the predicted value includes: determining the standard bandwidth according to the image resolution, pixel depth and frame rate, and determining according to the ratio of the predicted value to the standard bandwidth The bandwidth factor for the next frame.
在一些实施方式中,所述分别计算所述邻近第二预定数量帧的平均带宽包括:根据图像的原始帧率和帧起始位置计算每帧的时间标记点,根据所述时间标记点记录对应的带宽,并将所有带宽的平均值作为当前帧的平均带宽。In some implementations, said respectively calculating the average bandwidth of the adjacent second predetermined number of frames includes: calculating the time mark point of each frame according to the original frame rate of the image and the frame start position, and recording the corresponding time mark point according to the time mark point bandwidth, and take the average of all bandwidths as the average bandwidth of the current frame.
带宽因子计算时使用基于邻近3帧带宽梯度计算并预测下一帧的可用带宽,并最终计算出下一帧的带宽因子。因此,从本质上说带宽因子是一个预测值,是基于之前3帧的可用带宽的变化情况预测的下一帧。在实际的芯片系统的设计和操作过程中,带宽的变化是具有时间上的相关性的,因此使用此方法具有扎实的理论支撑。具体步骤如下:When calculating the bandwidth factor, calculate and predict the available bandwidth of the next frame based on the bandwidth gradient of the adjacent 3 frames, and finally calculate the bandwidth factor of the next frame. Therefore, in essence, the bandwidth factor is a predictive value, which is based on the changes in the available bandwidth of the previous 3 frames to predict the next frame. In the design and operation of the actual chip system, the change of the bandwidth has time correlation, so there is a solid theoretical support for using this method. Specific steps are as follows:
计算每帧图像的被授予的平均带宽Band_ave。图像被授予的带宽是指jpeg压缩数据流在整个总线系统中被分配的带宽。在soc系统的总线架构中,不同的主从设备在优先级设置、实际数据带宽等诸多因素影响下,被分配到的带宽是实时变化的,有的总线系统可以实时提供每路数据的带宽Band_i,有的则需要根据相关协议自行计算。Computes the average bandwidth Band_ave granted per image frame. The bandwidth granted to the image refers to the bandwidth allocated by the jpeg compressed data stream in the entire bus system. In the bus architecture of the SOC system, under the influence of many factors such as priority settings and actual data bandwidth, the allocated bandwidth of different master-slave devices changes in real time. Some bus systems can provide the bandwidth Band_i of each channel of data in real time. , and others need to be calculated by themselves according to relevant agreements.
首先,计算3组每帧的时间标记点T1、T2、T3,根据图像的原始帧率和帧起始位置计算,帧起始位置时间即为T1,帧尾位置时间为T3,帧中间位置时间为T2=T1+1/(frame*2),frame为帧率。其次,在时间标记点记录对应的带宽Band_i,并进行寄存,命名为Band_T1、Band_T2和Band_T3。最后,计算Band_ave=(Band_T1+ Band_T2+Band_T3)/3。同样方法计算并记录最近连续3帧的平均带宽,并记录为Band_ave_1、Band_ave_2和Band_ave_3。计算梯度值grad=(Band_ave_3-Band_ave_2)+(Band_ave_2- Band_ave_1)。计算下一帧带宽的预测值Band_p=Band_ave_1+grad。计算带宽因子Tb=Band_p/Band_std。其中,Band_std为标准带宽,即为在当前图像规格下占用的最大带宽,与图像分辨率、像素深度、帧率有关,在视频图像规格确定时,此值为定值。First, calculate the time mark points T1, T2, and T3 of 3 groups of each frame, and calculate according to the original frame rate of the image and the frame start position. The time of the frame start position is T1, the time of the end position of the frame is T3, and the time of the middle position of the frame It is T2=T1+1/(frame*2), and frame is the frame rate. Second, record the corresponding bandwidth Band_i at the time mark point, and register it, and name it Band_T1, Band_T2, and Band_T3. Finally, calculate Band_ave=(Band_T1+ Band_T2+Band_T3)/3. The same method calculates and records the average bandwidth of the last 3 consecutive frames, and records them as Band_ave_1, Band_ave_2 and Band_ave_3. Calculate the gradient value grad=(Band_ave_3-Band_ave_2)+(Band_ave_2- Band_ave_1). Calculate the predicted value of the bandwidth of the next frame Band_p=Band_ave_1+grad. Calculate the bandwidth factor Tb=Band_p/Band_std. Among them, Band_std is the standard bandwidth, that is, the maximum bandwidth occupied under the current image specification, which is related to image resolution, pixel depth, and frame rate. When the video image specification is determined, this value is a fixed value.
根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数,并将所述量化参数更新到下一帧对应的量化表中。Determine the quantization parameter of the current image frame through a quantization table according to the relationship between the encoding factor and the bandwidth factor, and update the quantization parameter into a corresponding quantization table of the next frame.
在一些实施方式中,所述根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数包括:响应于所述编码因子小于或等于所述带宽因子,按照所述量化表确定所述当前图像帧的亮度和色度;以及响应于所述编码因子大于所述带宽因子,根据所述编码因子和所述带宽因子的比值确定所述当前图像帧的亮度和色度。In some embodiments, the determining the quantization parameter of the current image frame through the quantization table according to the relationship between the coding factor and the bandwidth factor includes: responding to the coding factor being less than or equal to the bandwidth factor, according to the The quantization table determines the luminance and chroma of the current image frame; and in response to the encoding factor being greater than the bandwidth factor, determines the luminance and chrominance of the current image frame according to the ratio between the encoding factor and the bandwidth factor Spend.
JPEG协议规定了标准的亮度和色度量化参数表[Q_s](本质上是8*8的矩阵),而此处量化参数表的计算过程,亮度和色度的计算方式相同,不再分开介绍。当T1/(T2)<1或=1时,[Q]=[Q_s];当T1/(T2)>1时,[Q]= [Q_s]*T1/(T2),其中,[Q]表示亮度或色度。The JPEG protocol stipulates a standard luminance and chroma quantization parameter table [Q_s] (essentially an 8*8 matrix), and the calculation process of the quantization parameter table here, the calculation method of luminance and chrominance is the same, and will not be introduced separately . When T1/(T2)<1 or =1, [Q]=[Q_s]; when T1/(T2)>1, [Q]=[Q_s]*T1/(T2), where, [Q] Indicates luminance or chroma.
将计算好的量化参数表更新到下一帧图像编码的量化表中,并进行相应的除法运算,完成量化计算。需要特别注意的是,带宽因子、编码因子、量化参数表都是在每一帧的帧尾计算完成的,并将此量化表作为下一帧在量化处理时的量化参数表。The calculated quantization parameter table is updated to the quantization table of the next frame image encoding, and the corresponding division operation is performed to complete the quantization calculation. It should be noted that the bandwidth factor, encoding factor, and quantization parameter table are all calculated at the end of each frame, and this quantization table is used as the quantization parameter table for the next frame during quantization processing.
本发明实施例提出了一种高性能自适应JPEG压缩的设计和实现方法,可以针对系统带宽变化及图像特性发生变化时,逐帧的优化编码过程,使编码后的图像始终处于允许的最高图像质量。The embodiment of the present invention proposes a high-performance adaptive JPEG compression design and implementation method, which can optimize the encoding process frame by frame when system bandwidth changes and image characteristics change, so that the encoded image is always at the highest allowable image quality.
需要特别指出的是,上述JPEG图像压缩的方法的各个实施例中的各个步骤均可以相互交叉、替换、增加、删减,因此,这些合理的排列组合变换之于JPEG图像压缩的方法也应当属于本发明的保护范围,并且不应将本发明的保护范围局限在实施例之上。It should be pointed out that the various steps in the various embodiments of the above-mentioned JPEG image compression method can be intersected, replaced, added, and deleted. Therefore, these reasonable permutations and combinations should also belong to the JPEG image compression method. protection scope of the present invention and should not be limited to the embodiments.
基于上述目的,本发明实施例的第二个方面,提出了一种JPEG图像压缩的系统。如图5所示,系统200包括如下模块:编码模块,配置用于响应于当前图像帧处于起始帧,使用标准量化系数表对所述当前图像进行编码;第一计算模块,配置用于响应于当前图像帧不处于起始帧,计算邻近第一预定数量帧的加权平均图像数据长度,并根据所述加权平均图像数据长度计算编码因子;第二计算模块,配置用于根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子;以及执行模块,配置用于根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数,并将所述量化参数更新到下一帧对应的量化表中。Based on the above purpose, a second aspect of the embodiments of the present invention proposes a JPEG image compression system. As shown in FIG. 5 , the
在一些实施方式中,所述第一计算模块配置用于:将所述邻近第一预定数量帧中的每一帧的编码后图像长度进行加权平均计算。In some implementations, the first calculation module is configured to: perform weighted average calculation on the encoded image lengths of each frame in the adjacent first predetermined number of frames.
在一些实施方式中,所述第一计算模块配置用于:根据图像分辨率和像素深度确定标准编码后帧长度,并根据所述加权平均图像数据长度和所述标准编码后帧长度的比值确定编码因子。In some implementations, the first calculation module is configured to: determine the standard coded frame length according to image resolution and pixel depth, and determine according to the ratio of the weighted average image data length to the standard coded frame length coding factor.
在一些实施方式中,所述第二计算模块配置用于:分别计算所述邻近第二预定数量帧的平均带宽,并根据所述平均带宽计算梯度值;以及根据所述梯度值和最近一帧的平均带宽计算下一帧带宽的预测值,并根据所述预测值计算下一帧的带宽因子。In some implementations, the second calculation module is configured to: respectively calculate the average bandwidth of the frames adjacent to the second predetermined number of frames, and calculate a gradient value according to the average bandwidth; and calculate the gradient value according to the gradient value and the latest frame The average bandwidth of the next frame is calculated to predict the bandwidth of the next frame, and the bandwidth factor of the next frame is calculated according to the predicted value.
在一些实施方式中,所述第二计算模块配置用于:根据图像分辨率、像素深度和帧率确定标准带宽,并根据所述预测值和所述标准带宽的比值确定下一帧的带宽因子。In some implementations, the second calculation module is configured to: determine the standard bandwidth according to the image resolution, pixel depth and frame rate, and determine the bandwidth factor of the next frame according to the ratio of the predicted value to the standard bandwidth .
在一些实施方式中,所述第二计算模块配置用于:根据图像的原始帧率和帧起始位置计算每帧的时间标记点,根据所述时间标记点记录对应的带宽,并将所有带宽的平均值作为当前帧的平均带宽。In some implementations, the second calculation module is configured to: calculate the time mark point of each frame according to the original frame rate of the image and the frame start position, record the corresponding bandwidth according to the time mark point, and store all bandwidth The average value of is used as the average bandwidth of the current frame.
在一些实施方式中,所述执行模块配置用于:响应于所述编码因子小于或等于所述带宽因子,按照所述量化表确定所述当前图像帧的亮度和色度;以及响应于所述编码因子大于所述带宽因子,根据所述编码因子和所述带宽因子的比值确定所述当前图像帧的亮度和色度。In some embodiments, the execution module is configured to: determine the brightness and chrominance of the current image frame according to the quantization table in response to the encoding factor being less than or equal to the bandwidth factor; and in response to the The encoding factor is greater than the bandwidth factor, and the brightness and chrominance of the current image frame are determined according to a ratio between the encoding factor and the bandwidth factor.
基于上述目的,本发明实施例的第三个方面,提出了一种计算机设备,包括:至少一个处理器;以及存储器,存储器存储有可在处理器上运行的计算机指令,指令由处理器执行以实现如下步骤:S1、响应于当前图像帧处于起始帧,使用标准量化系数表对所述当前图像进行编码;S2、响应于当前图像帧不处于起始帧,计算邻近第一预定数量帧的加权平均图像数据长度,并根据所述加权平均图像数据长度计算编码因子;S3、根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子;以及S4、根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数,并将所述量化参数更新到下一帧对应的量化表中。Based on the above purpose, a third aspect of the embodiments of the present invention proposes a computer device, including: at least one processor; and a memory, the memory stores computer instructions that can run on the processor, and the instructions are executed by the processor to The following steps are implemented: S1, in response to the current image frame being in the initial frame, encoding the current image using a standard quantization coefficient table; S2, in response to the current image frame not being in the initial frame, calculating the adjacent first predetermined number of frames Weighted average image data length, and calculate the encoding factor according to the weighted average image data length; S3, predict the bandwidth factor of the next frame according to the change of the bandwidth of the adjacent second predetermined number of frames; and S4, according to the encoding factor and The relationship between the bandwidth factors determines the quantization parameter of the current image frame through the quantization table, and updates the quantization parameter to the corresponding quantization table of the next frame.
在一些实施方式中,所述计算邻近第一预定数量帧的加权平均图像数据长度包括:将所述邻近第一预定数量帧中的每一帧的编码后图像长度进行加权平均计算。In some implementations, the calculating the weighted average image data length of frames adjacent to the first predetermined number includes: performing weighted average calculation on the encoded image length of each frame in the frames adjacent to the first predetermined number.
在一些实施方式中,所述根据所述加权平均图像数据长度计算编码因子包括:根据图像分辨率和像素深度确定标准编码后帧长度,并根据所述加权平均图像数据长度和所述标准编码后帧长度的比值确定编码因子。In some embodiments, the calculating the encoding factor according to the weighted average image data length includes: determining the standard encoded frame length according to the image resolution and pixel depth, and determining the frame length after encoding according to the weighted average image data length and the standard encoded frame length. The ratio of the frame lengths determines the coding factor.
在一些实施方式中,所述根据邻近第二预定数量帧的带宽的变化情况预测下一帧的带宽因子包括:分别计算所述邻近第二预定数量帧的平均带宽,并根据所述平均带宽计算梯度值;以及根据所述梯度值和最近一帧的平均带宽计算下一帧带宽的预测值,并根据所述预测值计算下一帧的带宽因子。In some embodiments, the predicting the bandwidth factor of the next frame according to the change of the bandwidth of the frames adjacent to the second predetermined number includes: respectively calculating the average bandwidth of the frames adjacent to the second predetermined number, and calculating according to the average bandwidth a gradient value; 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 implementations, the calculating the bandwidth factor of the next frame according to the predicted value includes: determining the standard bandwidth according to the image resolution, pixel depth and frame rate, and determining according to the ratio of the predicted value to the standard bandwidth The bandwidth factor for the next frame.
在一些实施方式中,所述分别计算所述邻近第二预定数量帧的平均带宽包括:根据图像的原始帧率和帧起始位置计算每帧的时间标记点,根据所述时间标记点记录对应的带宽,并将所有带宽的平均值作为当前帧的平均带宽。In some implementations, said respectively calculating the average bandwidth of the adjacent second predetermined number of frames includes: calculating the time mark point of each frame according to the original frame rate of the image and the frame start position, and recording the corresponding time mark point according to the time mark point bandwidth, and take the average of all bandwidths as the average bandwidth of the current frame.
在一些实施方式中,所述根据所述编码因子和所述带宽因子之间的关系通过量化表确定当前图像帧的量化参数包括:响应于所述编码因子小于或等于所述带宽因子,按照所述量化表确定所述当前图像帧的亮度和色度;以及响应于所述编码因子大于所述带宽因子,根据所述编码因子和所述带宽因子的比值确定所述当前图像帧的亮度和色度。In some embodiments, the determining the quantization parameter of the current image frame through the quantization table according to the relationship between the coding factor and the bandwidth factor includes: responding to the coding factor being less than or equal to the bandwidth factor, according to the The quantization table determines the luminance and chroma of the current image frame; and in response to the encoding factor being greater than the bandwidth factor, determines the luminance and chrominance of the current image frame according to the ratio between the encoding factor and the bandwidth factor Spend.
如图6所示,为本发明提供的上述JPEG图像压缩的计算机设备的一个实施例的硬件结构示意图。As shown in FIG. 6 , it is a schematic diagram of the hardware structure of an embodiment of the above-mentioned JPEG image compression computer device provided by the present invention.
以如图6所示的装置为例,在该装置中包括一个处理器301以及一个存储器302。Taking the device shown in FIG. 6 as an example, the device includes a
处理器301和存储器302可以通过总线或者其他方式连接,图6中以通过总线连接为例。The
存储器302作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块,如本申请实施例中的JPEG图像压缩的方法对应的程序指令/模块。处理器301通过运行存储在存储器302中的非易失性软件程序、指令以及模块,从而执行服务器的各种功能应用以及数据处理,即实现JPEG图像压缩的方法。The
存储器302可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储根据JPEG图像压缩的方法的使用所创建的数据等。此外,存储器302可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他非易失性固态存储器件。在一些实施例中,存储器302可选包括相对于处理器301远程设置的存储器,这些远程存储器可以通过网络连接至本地模块。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The
一个或者多个JPEG图像压缩的方法对应的计算机指令303存储在存储器302中,当被处理器301执行时,执行上述任意方法实施例中的JPEG图像压缩的方法。
执行上述JPEG图像压缩的方法的计算机设备的任何一个实施例,可以达到与之对应的前述任意方法实施例相同或者相类似的效果。Any one embodiment of the computer device that executes the above-mentioned JPEG image compression method can achieve the same or similar effects as any of the above-mentioned method embodiments corresponding thereto.
本发明还提供了一种计算机可读存储介质,计算机可读存储介质存储有被处理器执行时执行JPEG图像压缩的方法的计算机程序。The present invention also provides a computer-readable storage medium, which stores a computer program for executing the JPEG image compression method when executed by a processor.
如图7所示,为本发明提供的上述JPEG图像压缩的计算机存储介质的一个实施例的示意图。以如图7所示的计算机存储介质为例,计算机可读存储介质401存储有被处理器执行时执行如上方法的计算机程序402。As shown in FIG. 7 , it is a schematic diagram of an embodiment of the above-mentioned JPEG image compression computer storage medium provided by the present invention. Taking the computer storage medium shown in FIG. 7 as an example, the computer
最后需要说明的是,本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关硬件来完成,JPEG图像压缩的方法的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,程序的存储介质可为磁碟、光盘、只读存储记忆体(ROM)或随机存储记忆体(RAM)等。上述计算机程序的实施例,可以达到与之对应的前述任意方法实施例相同或者相类似的效果。Finally, it should be noted that those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware to complete, and the program of the JPEG image compression method can be stored in a computer-readable When the program is executed, the program may include the processes of the embodiments of the above-mentioned methods. Wherein, 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 foregoing computer program embodiments can achieve the same or similar effects as any of the foregoing method embodiments corresponding thereto.
以上是本发明公开的示例性实施例,但是应当注意,在不背离权利要求限定的本发明实施例公开的范围的前提下,可以进行多种改变和修改。根据这里描述的公开实施例的方法权利要求的功能、步骤和/或动作不需以任何特定顺序执行。此外,尽管本发明实施例公开的元素可以以个体形式描述或要求,但除非明确限制为单数,也可以理解为多个。The above are the exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications can be made without departing from the scope of the disclosed embodiments of the present invention defined in the 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. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in an individual form, they may also be understood as a plurality unless explicitly limited to a singular number.
应当理解的是,在本文中使用的,除非上下文清楚地支持例外情况,单数形式“一个”旨在也包括复数形式。还应当理解的是,在本文中使用的“和/或”是指包括一个或者一个以上相关联地列出的项目的任意和所有可能组合。It should be understood that as used herein, the singular form "a" and "an" are intended to include the plural forms as well, unless the context clearly supports an 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 serial numbers of the embodiments disclosed in the above-mentioned embodiments of the present invention are only for description, and do not represent the advantages and disadvantages of the embodiments.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above-mentioned embodiments can be completed by hardware, or can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. The above-mentioned The storage medium may be a read-only memory, a magnetic disk or an optical disk, and the like.
所属领域的普通技术人员应当理解:以上任何实施例的讨论仅为示例性的,并非旨在暗示本发明实施例公开的范围(包括权利要求)被限于这些例子;在本发明实施例的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,并存在如上的本发明实施例的不同方面的许多其它变化,为了简明它们没有在细节中提供。因此,凡在本发明实施例的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本发明实施例的保护范围之内。Those of ordinary skill in the art should understand that: the discussion of any of the above embodiments is exemplary only, and is not intended to imply that the disclosed scope (including claims) of the embodiments of the present invention is limited to these examples; under the idea of the embodiments of the present invention , the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the above embodiments of the present invention, which are not provided in details for the sake of brevity. Therefore, within the spirit and principle of the embodiments of the present invention, any omissions, modifications, equivalent replacements, improvements, etc., shall be included in the protection scope of the embodiments of the present invention.
Claims (14)
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 CN114786011A (en) | 2022-07-22 |
CN114786011B true 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) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114786011B (en) * | 2022-06-22 | 2022-11-15 | 苏州浪潮智能科技有限公司 | JPEG image compression method, system, equipment and storage medium |
CN115474062B (en) * | 2022-11-10 | 2023-04-28 | 苏州浪潮智能科技有限公司 | Method, system, chip and electronic equipment for improving JPEG compression quality |
CN116489361B (en) * | 2023-06-25 | 2023-09-26 | 之江实验室 | JPEG coding code stream control method and device based on FPGA |
Family Cites Families (10)
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 |
KR0139154B1 (en) * | 1994-07-08 | 1998-06-15 | 김광호 | Coding method in a neural network |
WO1999063760A1 (en) * | 1998-05-30 | 1999-12-09 | Sgs-Thomson Microelectronics Asia Pacific (Pte) Ltd. | Sequence adaptive bit allocation for pictures encoding |
KR100601615B1 (en) * | 1999-08-20 | 2006-07-14 | 삼성전자주식회사 | Video Compression Device Adaptive to Network Bandwidth |
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 |
CN111726633B (en) * | 2020-05-11 | 2021-03-26 | 河南大学 | Recoding method of compressed video stream based on deep learning and saliency awareness |
CN113766226A (en) * | 2020-06-05 | 2021-12-07 | 深圳市中兴微电子技术有限公司 | Image encoding method, apparatus, device and storage medium |
CN112399176B (en) * | 2020-11-17 | 2022-09-16 | 深圳市创智升科技有限公司 | Video coding method and device, computer equipment and storage medium |
CN114786011B (en) * | 2022-06-22 | 2022-11-15 | 苏州浪潮智能科技有限公司 | JPEG image compression method, system, equipment and storage medium |
-
2022
- 2022-06-22 CN CN202210712053.0A patent/CN114786011B/en active Active
- 2022-12-23 WO PCT/CN2022/141668 patent/WO2023246047A1/en unknown
Also Published As
Publication number | Publication date |
---|---|
WO2023246047A1 (en) | 2023-12-28 |
CN114786011A (en) | 2022-07-22 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN114786011B (en) | JPEG image compression method, system, equipment and storage medium | |
JP6626295B2 (en) | Image encoding device, image processing device, image encoding method | |
US9621900B1 (en) | Motion-based adaptive quantization | |
JP2016213528A (en) | Image encoder, image processing apparatus, image coding method | |
US20060146938A1 (en) | Method for improved entropy coding | |
CN113613004A (en) | Image encoding method, image encoding device, electronic device, and storage medium | |
EP1143737A2 (en) | Image encoding apparatus and method, video camera, image recording apparatus, and image transmission apparatus | |
TWI705693B (en) | Apparatus and method for vector-based entropy coding for display stream compression | |
US20080107349A1 (en) | Method and circuit of high performance variable length coding and decoding for image compression | |
TW201919398A (en) | Video data decoding method and device | |
US10110896B2 (en) | Adaptive motion JPEG encoding method and system | |
JP2006191253A (en) | Rate converting method and rate converter | |
CN115474062B (en) | Method, system, chip and electronic equipment for improving JPEG compression quality | |
WO2022252222A1 (en) | Encoding method and encoding device | |
TWI734501B (en) | Method and apparatus of video coding | |
TWI829424B (en) | Decoding method, encoding method and apparatus | |
TW202406352A (en) | Image encoding and decoding method and apparatus | |
WO2023138562A1 (en) | Image decoding method, image coding method, and corresponding devices | |
CN116055743A (en) | Image compression method, system, electronic equipment and storage medium | |
JPH1066077A (en) | Code amount control method for image data and its device | |
CN116156168A (en) | Image encoding and decoding method and device | |
JP2004007526A (en) | Data compression device and its method | |
CN116828200B (en) | Image processing method, processing device, equipment and medium | |
CN116074525B (en) | Coefficient decoding method and device, image decoder and electronic equipment | |
RU2781233C2 (en) | Device and filtration method in video encoding |
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 |