CN116506617A - Image shallow compression code rate control method and device - Google Patents

Image shallow compression code rate control method and device Download PDF

Info

Publication number
CN116506617A
CN116506617A CN202310770774.1A CN202310770774A CN116506617A CN 116506617 A CN116506617 A CN 116506617A CN 202310770774 A CN202310770774 A CN 202310770774A CN 116506617 A CN116506617 A CN 116506617A
Authority
CN
China
Prior art keywords
quantization parameter
compression
data block
parameter
buffer
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
CN202310770774.1A
Other languages
Chinese (zh)
Other versions
CN116506617B (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.)
Guangzhou Kuvision Digital Technology Co ltd
Peng Cheng Laboratory
Original Assignee
Guangzhou Kuvision Digital Technology Co ltd
Peng Cheng Laboratory
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 Guangzhou Kuvision Digital Technology Co ltd, Peng Cheng Laboratory filed Critical Guangzhou Kuvision Digital Technology Co ltd
Priority to CN202310770774.1A priority Critical patent/CN116506617B/en
Publication of CN116506617A publication Critical patent/CN116506617A/en
Application granted granted Critical
Publication of CN116506617B publication Critical patent/CN116506617B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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
    • H04N19/146Data rate or code amount at the encoder output
    • H04N19/149Data rate or code amount at the encoder output by estimating the code amount by means of a model, e.g. mathematical model or statistical model
    • 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/146Data rate or code amount at the encoder output
    • H04N19/15Data rate or code amount at the encoder output by monitoring actual compressed data size at the memory before deciding storage at the transmission buffer
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • Algebra (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The application discloses a method and a device for controlling the code rate of image shallow compression, and relates to the technical field of shallow compression. The method comprises the steps of obtaining a reference frame data block and compression parameters in an image shallow compression code rate control method, calculating a maximum quantization parameter and a minimum code rate, dividing the image shallow compression code rate control method into a plurality of reference quantization parameters, dividing a buffer area into a plurality of sub-buffers correspondingly, wherein different sub-buffers correspond to different filling values, the reference quantization parameters and the filling values meet a preset mapping relation, obtaining the reference quantization parameters corresponding to the current filling values according to the mapping relation, encoding the reference frame data block by combining the compression parameters to obtain an encoded data block, judging whether the data size of the encoded data block is overflowed to the buffer area in the encoding process, and adjusting the quantization parameters to continue encoding if the buffer area overflows. Therefore, quantization parameters are adaptively selected and adjusted according to the filling value of the buffer, and joint control of code rate and compression quality is realized in the buffer.

Description

Image shallow compression code rate control method and device
Technical Field
The present disclosure relates to the field of shallow compression technologies, and in particular, to a method and an apparatus for controlling a bit rate of shallow compression of an image.
Background
In the transmission process of media files such as video, if video data exceeds the available bandwidth range, the video data is lost or a screen is jumped, and the watching experience of a user is affected. And the VBV buffer (Video Buffering Verifier) is used for storing video data being encoded, and the control code rate ensures that the video will not lose data or generate a splash screen phenomenon during transmission.
In the process of coding compressed data, the compression quality is reduced due to lower code rate, and the compression quality is better when the code rate is higher. However, the high code rate may result in insufficient transmission bandwidth, occupy more storage space, increase storage cost, and the low compression quality may result in blurring and distortion of video image quality, thereby affecting viewing effect. Therefore, how to realize the joint control of the code rate and the compression quality in the buffer model has important significance for completing the data transmission under the limited bandwidth.
Disclosure of Invention
The present application aims to solve at least one of the technical problems existing in the prior art. Therefore, the embodiment of the application provides a method and a device for controlling the shallow compression code rate of an image, which can adaptively adjust quantization parameters according to the filling value of a buffer zone, so that joint control of the code rate and the compression quality is realized in a buffer zone model.
In a first aspect, an embodiment of the present application provides a method for controlling a shallow compression code rate of an image, including:
acquiring a reference frame data block of a reference frame to be compressed, and acquiring compression parameters of the reference frame data block;
calculating a maximum quantization parameter according to the compression parameter, and calculating a minimum code rate based on the compression parameter and the maximum quantization parameter;
dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters, and dividing a buffer area to obtain a plurality of sub-buffer areas corresponding to the reference quantization parameters; wherein, different sub-buffers correspond to different filling values, the reference quantization parameter and the filling values meet a preset mapping relation, and the buffer size of the buffer is related to the minimum code rate;
obtaining the reference quantization parameter corresponding to the filling value based on the mapping relation, and setting the quantization parameter as the reference quantization parameter;
coding the reference frame data block according to the compression parameter and the quantization parameter to obtain a coded data block; and judging whether the data size of the encoded data block is output to the buffer area or not in the encoding process, if so, adjusting the quantization parameter to continue the encoding process until the encoded data block of the reference frame data block is obtained, and obtaining the compressed image of the reference frame to be compressed according to the encoded data block.
In some embodiments of the present application, the compression parameters include pixel bit width and data block size; the calculating the maximum quantization parameter according to the compression parameter, and calculating the minimum code rate based on the compression parameter and the maximum quantization parameter, includes:
judging whether the pixel bit width is even;
if the pixel bit width is even, calculating the maximum quantization parameter according to a first formula; wherein, the first formula is: maxqp=4 pixel bit width/2, maxQp representing the maximum quantization parameter;
if the pixel bit width is odd, calculating the maximum quantization parameter according to a second formula; wherein the second formula is: maxqp=4 (pixel bit width+1)/2;
calculating a code rate control parameter according to a third formula based on the data block size and the pixel bit width; wherein the third formula is: code rate control parameter = data block size x pixel bit width/2 + macroblock header byte number x8;
calculating the minimum code rate according to a fourth formula based on the code rate control parameter and the maximum quantization parameter; wherein the fourth formula is: minimum code rate = code rate control parameter + MaxQp +1.
In some embodiments of the present application, the dividing the maximum quantization parameter into a plurality of reference quantization parameters, and dividing a buffer into a plurality of sub-buffers corresponding to the reference quantization parameters, includes:
Dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters; wherein each of the reference quantization parameters is an integer within a range of [0, maxqp ];
obtaining the buffer area size of the buffer area; wherein the buffer size is greater than the minimum code rate;
equally dividing the buffer zone based on the size of the buffer zone to obtain N sub-buffer zones; wherein n=maxqp+1;
setting a reference quantization parameter corresponding to the filling value of the 1 st sub-buffer as 0, and setting a reference quantization parameter corresponding to the filling value of the N-th sub-buffer as MaxQp, so that the reference quantization parameter and the filling value meet a preset mapping relation.
In some embodiments of the present application, the obtaining the reference quantization parameter corresponding to the padding value based on the mapping relationship, setting the quantization parameter as the reference quantization parameter, includes:
acquiring the current filling value of the buffer area, and based on the filling value, obtaining a target filling value; setting the target filling value to be 0 if the filling value is smaller than the code rate control parameter, otherwise setting the target filling value to be the difference value between the filling value and the code rate control parameter;
Based on the mapping relation, obtaining the reference quantization parameter according to the maximum quantization parameter, the target filling value and the buffer area size of the buffer area, and setting the quantization parameter as the reference quantization parameter; wherein reference quantization parameter = target padding value (maximum quantization parameter + 1)/buffer size.
In some embodiments of the present application, the determining whether the data size of the encoded data block is output to the buffer area during the encoding process may overflow, and if the buffer area may overflow, adjusting the quantization parameter includes:
calculating a predictive quantization parameter according to a preset relation; wherein, the preset relation is: predictive quantization parameter = quantization parameter-4 x log2 ((buffer size-padding value)/data size);
comparing the predicted quantization parameter with the quantization parameter, and if the predicted quantization parameter is equal to the quantization parameter, setting a predicted quantization parameter=quantization parameter+1;
comparing the predicted quantization parameter with the maximum quantization parameter, and setting the predicted quantization parameter as the maximum quantization parameter if the predicted quantization parameter is larger than the maximum quantization parameter;
setting a new quantization parameter as the predicted quantization parameter, and repeating the encoding of the reference frame data block according to the new quantization parameter.
In some embodiments of the present application, the compression parameter comprises a compression ratio; the maximum quantization parameter is positively correlated with the compression ratio, comprising:
the higher the compression ratio, the greater the maximum quantization parameter;
the lower the compression ratio, the smaller the maximum quantization parameter.
In some embodiments of the present application, the method further comprises:
precoding for different quantization parameters, determining a target quantization parameter, comprising:
setting the reference quantization parameter corresponding to the filling value obtained based on the mapping relation as a minimum quantization parameter;
increasing the reference quantization parameter in a preset step within the range of the minimum quantization parameter and the maximum quantization parameter to obtain a test quantization parameter;
pre-coding the reference frame data block based on each test quantization parameter to obtain a pre-coded data block;
selecting the smallest test quantization parameter as the target quantization parameter under the condition that the preset condition is met; the preset condition is that the size of the pre-coded data block is output to the buffer zone without overflowing.
In a second aspect, an embodiment of the present application further provides an image shallow compression bitrate control device, where the image shallow compression bitrate control method according to the embodiment of the first aspect of the present application includes:
The first acquisition module is used for acquiring a reference frame data block of a reference frame to be compressed and acquiring compression parameters of the reference frame data block;
the calculating module is used for calculating a maximum quantization parameter according to the compression parameter and calculating a minimum code rate based on the compression parameter and the maximum quantization parameter;
the dividing module is used for dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters, and dividing the buffer area to obtain a plurality of sub-buffer areas corresponding to the reference quantization parameters; wherein, different sub-buffers correspond to different filling values, the reference quantization parameter and the filling values meet a preset mapping relation, and the buffer size of the buffer is related to the minimum code rate;
the setting module is used for obtaining the reference quantization parameter corresponding to the filling value based on the mapping relation and setting the quantization parameter as the reference quantization parameter;
the coding module is used for coding the reference frame data block according to the compression parameter and the quantization parameter to obtain a coded data block; and judging whether the data size of the encoded data block is output to the buffer area or not in the encoding process, if so, adjusting the quantization parameter to continue the encoding process until the encoded data block of the reference frame data block is obtained, and obtaining the compressed image of the reference frame to be compressed according to the encoded data block.
In a third aspect, an embodiment of the present application further provides an electronic device, including a memory, and a processor, where the memory stores a computer program, and the processor implements the method for controlling the shallow image compression code rate according to the embodiment of the first aspect of the present application when executing the computer program.
In a fourth aspect, embodiments of the present application further provide a computer readable storage medium, where a program is stored, where the program is executed by a processor to implement the method for controlling the shallow image compression rate according to the embodiments of the first aspect of the present application.
The embodiment of the application at least comprises the following beneficial effects:
the embodiment of the application provides an image shallow compression code rate control method and device, wherein in the image shallow compression code rate control method, a reference frame data block of a reference frame to be compressed and compression parameters thereof are obtained, a maximum quantization parameter and a minimum code rate are calculated based on the reference frame data block and the compression parameters, a plurality of reference quantization parameters are obtained according to the maximum quantization parameter, a buffer area is correspondingly divided to obtain a plurality of sub-buffer areas, different sub-buffer areas correspond to different filling values, the reference quantization parameter and the filling values meet a preset mapping relation, therefore, the reference quantization parameter corresponding to the filling value of the current buffer area can be obtained according to the mapping relation, the quantization parameter is set as the reference quantization parameter, the reference frame data block is encoded by combining the compression parameters to obtain an encoded data block, in the encoding process, whether the data size of the encoded data block is output to the buffer area can overflow or not is judged, if the buffer area can overflow, the quantization parameter is adjusted until the encoded data block of the reference frame data block is obtained, and a compressed image of the reference frame to be compressed is obtained according to the encoded data block. The quantization parameters are adaptively selected and adjusted according to the filling value of the buffer zone, and the balance of the code rate and the compression quality is coordinated through the quantization parameters, so that the joint control of the code rate and the compression quality is realized in the buffer zone model.
Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, wherein:
fig. 1 is a flow chart of an image shallow compression code rate control method according to an embodiment of the present application;
fig. 2 is a schematic flow chart of step S102 in fig. 1;
fig. 3 is a schematic flow chart of step S103 in fig. 1;
FIG. 4 is a schematic diagram of a mapping relationship provided in one embodiment of the present application;
fig. 5 is a schematic flow chart of step S104 in fig. 1;
fig. 6 is a schematic flow chart of step S105 in fig. 1;
fig. 7 is a flowchart of an image shallow compression code rate control method according to another embodiment of the present application;
FIG. 8 is a flow chart of a decoding method according to an embodiment of the present application;
FIG. 9 is a schematic diagram of a shallow compression system encoding flow at the encoding end of the present application;
FIG. 10 is a schematic diagram of a decoding flow of the shallow compression system at the decoding end of the present application;
FIG. 11 is a schematic diagram of quality assessment of a codec method of the present application;
FIG. 12 is a schematic diagram of the encoding and decoding method of the present application with 20-30 times compression tandem effect;
FIG. 13 is a schematic diagram of the encoding and decoding method of the present application with 80-120 times compression tandem effect;
FIG. 14 is a schematic diagram of an image shallow compression rate control device according to an embodiment of the present application;
fig. 15 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Reference numerals: the device comprises a first acquisition module 101, a calculation module 102, a division module 103, a setting module 104, an encoding module 105, an electronic device 1000, a processor 1001 and a memory 1002.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
Embodiments of the present application are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present application.
In the description of the present application, it should be understood that references to orientation descriptions, such as directions of up, down, front, back, left, right, etc., are based on the orientation or positional relationship shown in the drawings, are merely for convenience of describing the present application and simplifying the description, and do not indicate or imply that the apparatus or element referred to must have a specific orientation, be configured and operated in a specific orientation, and thus should not be construed as limiting the present application.
In the description of the present application, the meaning of a number is one or more, the meaning of a number is two or more, greater than, less than, exceeding, etc. are understood to not include the present number, and the meaning of a number above, below, within, etc. are understood to include the present number. The description of the first and second is for the purpose of distinguishing between technical features only and should not be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present application, unless explicitly defined otherwise, terms such as arrangement, installation, connection, etc. should be construed broadly and the specific meaning of the terms in the present application can be reasonably determined by a person skilled in the art in combination with the specific contents of the technical solution.
For a better understanding of the technical solutions provided in the present application, terms appearing herein will be described accordingly:
VBV: and the video buffer checker (Video Buffering Verifier) is used for buffering and managing the video data in the encoding process so as to ensure that the video can keep stable quality and smoothness when being played. The VBV technology receives and stores video data by setting a video Buffer (Buffer), and then dynamically controls a transmission speed of video according to a size and a code rate of the video data. If the code rate of the video data is too high, part of the data can be stored in a buffer area first and waiting for the decoder to process; if the code rate of the video data is too low, the data stored before can be obtained from the buffer area for supplementing so as to ensure the consistency and fluency of the video data.
Quantization parameters: QP (Quantization Parameter) is a common parameter in video coding for controlling video image quality and compression ratio. In video coding, the smaller the QP value, the higher quantization accuracy and better image quality are represented, but at the same time lower compression ratio and larger code rate are brought; conversely, when the QP value is larger, lower quantization accuracy and poor image quality are represented, but a higher compression ratio and a smaller code rate can be obtained.
With the increasing data and the development of the internet, data compression has become a necessary technology. Shallow compression, also known as light compression (Light Compression), is a data compression technique that can meet various types of data processing requirements, reduce storage space and network transmission bandwidth consumption, and is commonly used for compressing media files such as images, audio and video.
In the transmission process of media files such as video, if video data exceeds the available bandwidth range, the video data is lost or a screen is jumped, and the watching experience of a user is affected. And the VBV buffer (Video Buffering Verifier) is used for storing video data being encoded, and the control code rate ensures that the video will not lose data or generate a splash screen phenomenon during transmission.
In the process of coding compressed data, the compression quality is reduced due to lower code rate, and the compression quality is better when the code rate is higher. However, the high code rate may result in insufficient transmission bandwidth, occupy more storage space, increase storage cost, and the low compression quality may result in blurring and distortion of video image quality, thereby affecting viewing effect. In a video compression system with an upper bound of code rate, the compression quality is also related to a reference frame, the quality of images is better when the number of the reference frames is more, but the main frequency of an image type professional chip is generally about 400M, and when 4K 120:4:4 input image data is processed, only one reference frame is used to exceed the upper bound of the processing capacity of the chip. Therefore, how to realize the joint control of the code rate and the compression quality in the buffer model has important significance for completing the data transmission under the limited bandwidth, reducing the complexity of chip design and the like.
In the related art, VBV buffer models of high compression coding architectures (e.g., H264, H265, AVS/avs+, AVS2, etc.) generally control the filling value of the buffer in units of frames, require a very large buffer and cause a corresponding long delay. Therefore, the negative feedback delay of the rate control based on the frame type and the buffer filling value is too large and the improvement of the compression quality cannot be controlled.
Based on this, the embodiment of the application provides a method and a device for controlling the shallow compression code rate of an image, which are suitable for a buffer zone model with quality control design and realized by hardware, and perform code rate control by taking MB as a unit, are irrelevant to frame types, organically combine the target code rate and the target quality, and realize extremely fast response speed. The embodiment can control the combination of the quality and the code rate under the condition of very small buffer area size (generally tens of macro blocks and delay time of microsecond), thereby improving the compression quality of a shallow compression system under the condition of limited bandwidth.
The embodiment of the application provides a method and a device for controlling the image shallow compression code rate, and specifically, the method for controlling the image shallow compression code rate in the embodiment of the application is described through the following embodiment.
The embodiment of the application provides an image shallow compression code rate control method, which relates to the technical field of image compression, in particular to the technical field of shallow compression. The image shallow compression code rate control method provided by the embodiment of the application is applied to the terminal. In some embodiments, the terminal may be a smart phone, tablet, notebook, or desktop computer, or the like.
The subject application is operational with numerous general purpose or special purpose computer system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The following describes an image shallow compression code rate control method in the embodiment of the invention.
Referring to fig. 1, an embodiment of the present application provides an image shallow compression rate control method, which is applied to a buffer model of a shallow compression system, and includes, but is not limited to, the following steps S101 to S105.
Step S101, obtaining a reference frame data block of a reference frame to be compressed, and obtaining compression parameters of the reference frame data block.
Reference frames (Reference frames) are a technique used in video coding to compress video files. In video coding, a reference frame contains complete image information independent of any frame preceding or following. In some embodiments, the read reference frame to be compressed is subjected to block processing, so as to obtain a plurality of reference frame data blocks, i.e. macro blocks. It will be appreciated that the macroblock (macroblock) is a basic coding unit in the image compression technology, and may be a size of 16×16 pixels or a size of 8×8 pixels, which is not limited in this embodiment.
In some embodiments, the compression parameters of the reference frame data block are acquired at the same time as the reference frame data block of the reference frame to be compressed, and the compression parameters may be, for example, parameters of a data block size, a pixel bit width, a compression ratio, and the like of the reference frame data block. Specifically, the data block size, i.e., how many pixels a reference frame data block has, e.g., a data block size of 8 x 8, represents that the reference frame data block has 64 pixels; the pixel bit width, namely how many bits a pixel has, the higher the bit number is, the wider the color range can be represented, but the data quantity and the calculation complexity are increased at the same time; the higher the compression ratio, i.e. the ratio of the data size before compression to the data size after compression, the more tightly the data is compressed, but the greater the loss of image detail.
Step S102, calculating a maximum quantization parameter according to the compression parameter, and calculating a minimum code rate based on the compression parameter and the maximum quantization parameter.
It will be appreciated that the quantization parameter is used to control the balance of image quality and compression ratio and thus affect the rate, and is therefore an important parameter for controlling the rate and compression quality of video compression coding. In the video compression encoding process, a digital signal is quantized according to a compression algorithm and an encoding standard, and is converted into a series of digital values, which are used to represent information such as strength and details of the signal, so as to perform compression encoding. Different quantization parameters can generate different compression quality and code rate, and specifically, the smaller the quantization parameter is, the better the compressed image quality is, and the corresponding code rate is increased; in contrast, the larger the quantization parameter is, the quality of the compressed image is deteriorated, but the corresponding code rate is decreased.
In some embodiments, the maximum quantization parameter is calculated according to the compression parameter, so that the maximum quantization parameter of the reference frame data block is determined, that is, the quantization parameter with the worst compression quality and the highest code rate corresponding to the reference frame data block is limited, so that image distortion or detail loss caused by over-compression can be effectively avoided. The corresponding minimum code rate, i.e. the minimum number of bits transmitted per second in the data stream, corresponding to the amount of data per second, is further calculated based on the compression parameters and the maximum quantization parameters. The code rate can be reduced to the maximum extent on the premise of ensuring the video compression quality, so that the optimal utilization of storage and transmission resources is realized.
Step S103, dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters, and dividing the buffer to obtain a plurality of sub-buffers corresponding to the reference quantization parameters.
In some embodiments, the maximum quantization parameter is divided by a quantization step length of 1 to obtain a plurality of reference quantization parameters, that is, each reference quantization parameter is an integer, it may be understood that the reference quantization parameter may also be a floating point number or an integer obtained by dividing by a quantization step length of 2, and the embodiment is not limited thereto.
In some embodiments, the buffer is divided into a plurality of sub-buffers corresponding to the reference quantization parameter, and illustratively, when the number of the reference quantization parameters is 10, the buffer is divided into 10 sub-buffers correspondingly. Wherein, different sub-buffers correspond to different filling values, and corresponding reference quantization parameters and filling values meet a preset mapping relation.
In some embodiments, the fill value of the buffer refers to the size of the data currently stored in the buffer. For example, if the buffer size of one buffer is 100 bytes, divided into 10 sub-buffers, in which 60 bytes of data are currently stored, the corresponding sub-buffer is the 6 th sub-buffer, and the corresponding fill value is 60 bytes, thereby corresponding to the 6 th reference quantization parameter. It will be appreciated that different sub-buffers are located in different positions of the buffer in the order of storage, and thus the filling value of a sub-buffer is obtained and then used as the current filling value of the buffer.
In some embodiments, the filling value may also be expressed in terms of a filling degree, where the filling degree is expressed as a ratio of the filling value to the size of the buffer, i.e. the current storage level of the buffer, which is not limited in this embodiment.
In some embodiments, the buffer size is also related to the minimum code rate. In video streaming, buffers are used to balance the difference between network transmission speed and playback speed. If the buffer is too small, the transmission speed may fluctuate, resulting in interruption or jamming of video or audio playback; if the buffer is too large, the playback delay increases, resulting in a poor user experience. Thus, in order to provide a good user experience, the buffer should be set according to the relevant user parameters and the minimum code rate. The minimum code rate is the minimum speed required for video or audio streaming. The buffer size should be large enough to hold enough data to ensure seamless playback as the network transmission speed decreases; at the same time, the buffer size should also be small enough to ensure minimum playback delay.
Step S104, obtaining a reference quantization parameter corresponding to the filling value of the buffer area based on the mapping relation, and setting the quantization parameter as the reference quantization parameter.
In some embodiments, based on the mapping relationship between the reference quantization parameter and the filling value, a corresponding reference quantization parameter may be obtained according to the filling degree of the current buffer, and the reference quantization parameter is used as the quantization parameter. Therefore, quantization parameters corresponding to the reference frame data blocks are adaptively selected in real time according to different storage conditions of the buffer zone, so that balance between compression quality and code rate is coordinated, and joint control of the buffer zone on the compression quality and the code rate is realized.
Step S105, coding the reference frame data block according to the compression parameter and the quantization parameter to obtain a coded data block.
In some embodiments, the reference frame data block is compression-encoded according to the compression parameter and the quantization parameter to obtain an encoded data block, specifically, the reference frame data block is quantized according to the quantization parameter, and then the encoded data block is encoded by using a compression algorithm. In the process of quantization coding, judging whether the data size of the coded data block is output to a buffer area, if so, feeding back and adjusting quantization parameters to continue the coding process until the buffer area is not overflowed, thereby obtaining the coded data block of the reference frame data block, and finally obtaining a compressed image of the reference frame to be compressed according to the coded data block.
As shown with reference to fig. 2, in some embodiments of the present application, the step S102 may further include, but is not limited to, the following steps S201 to S205.
In step S201, it is determined whether the pixel bit width is even.
In some embodiments, the compression parameter is a pixel bit width, also referred to as a color depth or a color bit depth, which refers to the number of bits required to describe a single pixel color in binary coding, typically used to describe the color accuracy of an image or video. A lower pixel bit width means that the color rendering of the image is lower, and color banding and color inaccuracies may occur. While a higher bit width means a more accurate and fine color display, but also requires more memory and processing power. Common pixel bitwidths include 8 bits, 16 bits, 24 bits, and 32 bits. Specifically, an 8-bit pixel bit width may represent 256 different colors, while a 24-bit pixel bit width may represent about 1677 thousands of different colors.
In some embodiments, it is first determined whether the pixel bit width of the reference frame data block is even, so that the maximum quantization parameter is calculated by correspondingly selecting a different formula.
In step S202, if the pixel bit width is even, the maximum quantization parameter is calculated according to the first formula.
In some embodiments, if the pixel bit width is determined to be even, the maximum quantization parameter is calculated according to a first formula, where the first formula is: maxqp=4 pixel bit width/2, maxQp representing the maximum quantization parameter. For example, when the pixel bit width is 10, the maximum quantization parameter maxqp=4×10/2=20 is calculated.
In step S203, if the pixel bit width is odd, the maximum quantization parameter is calculated according to the second formula.
In some embodiments, if the pixel bit width is determined to be odd, the maximum quantization parameter is calculated according to a second formula, where the second formula is: maxqp=4× (pixel bit width+1)/2. For example, when the pixel bit width is 13, the maximum quantization parameter maxqp=4 (13+1)/2=28 is calculated.
In some embodiments of the present application, the compression parameters further include a compression ratio, and the maximum quantization parameter is positively correlated with the compression ratio, specifically, the higher the compression ratio, the greater the maximum quantization parameter; the lower the compression ratio, the smaller the maximum quantization parameter.
Step S204, calculating the code rate control parameter according to a third formula based on the data block size and the pixel bit width.
In some embodiments, the compression parameters also include a data block size, i.e., the number of pixels in the reference frame data block. Based on the data block size and the pixel bit width, calculating a code rate control parameter according to a third formula, wherein the third formula is as follows: code rate control parameter = data block size x pixel bit width/2 + macroblock header byte number x8. It will be appreciated that the macroblock header is a structure describing information about the macroblock in the video coding standard, and the number of bytes of each macroblock header in the reference frame depends on the encoder settings and the video resolution, frame rate, etc. For example, the reference frame data block has a data block size of 8×8, a pixel bit width of 10, and a macroblock header byte number of 2, and the corresponding rate control parameter is calculated as 8×8×10/2+2×8=336, where the units are bits.
In some embodiments, the rate control parameter may also be used as a target size of a control block, where the target size of the control block refers to a data size corresponding to a target rate in a unit time.
Step S205, based on the code rate control parameter and the maximum quantization parameter, the minimum code rate is calculated according to the fourth formula.
In some embodiments, based on the rate control parameter and the maximum quantization parameter, the minimum rate may be calculated according to a fourth formula, which is: minimum code rate = code rate control parameter + MaxQp +1 in bit. It is understood that the code rate refers to the lower bound of data read from the buffer at each macroblock time, so the minimum code rate is also the minimum buffer size of the buffer, i.e., the minimum lower bound of the buffer.
As shown in fig. 3, in some embodiments of the present application, the step S103 may further include, but is not limited to, the following steps S301 to S304.
In step S301, the maximum quantization parameter is divided to obtain a plurality of reference quantization parameters.
In some embodiments, the maximum quantization parameter is divided from 0 with a quantization step size of 1, and a plurality of reference quantization parameters are correspondingly obtained, so that each reference quantization parameter is an integer in the range of [0, maxqp ]. For example, if the maximum quantization parameter is 20, that is, maxqp=20, 21 reference quantization parameters may be obtained by corresponding division, which is not limited in this embodiment.
In step S302, the buffer size of the buffer is obtained.
In some embodiments, the buffer size is specified by a user parameter, is associated with a compression parameter, is typically several times the rate control parameter, and is greater than the minimum code rate. The buffer size of the buffer, i.e. the total capacity of the buffer, is obtained.
In step S303, the buffer is equally divided into N sub-buffers based on the size of the buffer.
In some embodiments, the buffer is equally divided into N sub-buffers based on the buffer size, in particular, n=maxqp+1, corresponding to the number of reference quantization parameters. For example, maxqp=20, then the buffer is equally divided into 21 sub-buffers.
Step S304, setting the reference quantization parameter corresponding to the filling value of the 1 st sub-buffer as 0, and setting the reference quantization parameter corresponding to the filling value of the N-th sub-buffer as MaxQp, so that the reference quantization parameter and the filling value meet the preset mapping relation.
In some embodiments, different sub-buffers correspond to different filling values, and referring to the mapping relationship diagram shown in fig. 4, the reference quantization parameter corresponding to the 1 st sub-buffer is set to 0, that is, the reference quantization parameter corresponding to the filling value 1 is set to 0; setting the reference quantization parameter corresponding to the 2 nd sub-buffer area as 1, namely the reference quantization parameter corresponding to the filling value 2 as 1, and so on until the reference quantization parameter of the N th sub-buffer area is set as MaxQp, namely the reference quantization parameter corresponding to the filling value N as the maximum quantization parameter, so that the reference quantization parameter and the filling value meet the preset mapping relation.
As shown in fig. 5, in some embodiments of the present application, the step S104 may further include, but is not limited to, the following steps S401 to S402.
Step S401, obtaining the current filling value of the buffer area and based on the filling value, obtaining a target filling value.
In some embodiments, the current fill value of the buffer is obtained and then a target fill value is obtained based on the fill value and the rate control parameter. Specifically, the relation between the filling value and the code rate control parameter can be judged first, if the filling value is smaller than the code rate control parameter, the target filling value is directly set to 0, otherwise, the target filling value is set to be the difference value between the filling value and the code rate control parameter. Or the target filling value may be directly set as the difference between the filling value and the code rate control parameter, and then whether the target filling value is smaller than 0 is determined, if the target filling value is smaller than 0, the target filling value is set to 0, which is not limited in this embodiment.
It will be appreciated that the target fill value is a fill value after reading data from the current buffer per unit time, thereby ensuring that no overflow occurs even in the buffer corresponding to the maximum quantization parameter.
Step S402, obtaining a reference quantization parameter according to the maximum quantization parameter, the target filling value and the buffer size of the buffer based on the mapping relation, and setting the quantization parameter as the reference quantization parameter.
In some embodiments, based on the mapping relationship, the reference quantization parameter may be calculated according to the maximum quantization parameter, the target filling value, and the buffer size of the buffer, where the mapping relationship is specifically: reference quantization parameter=target filling value (maximum quantization parameter+1)/buffer size, thereby setting the quantization parameter as the reference quantization parameter, so as to select the corresponding quantization parameter according to the storage condition of the buffer to realize joint control of code rate and compression quality.
Referring to fig. 6, in some embodiments of the present application, the step S105 may further include, but is not limited to, the following steps S501 to S504.
In step S501, a predicted quantization parameter is calculated according to a preset relationship.
It will be appreciated that buffer overflow can create a related hazard, for example, when VBV buffer overflows, the compression encoder may discard some image data, which can lead to a degradation of video quality; when the VBV buffer overflows, the compression encoder may halt the encoding process, waiting for the buffer to resume, which may cause the video to clip or stop playing; or the problems of unstable code rate, video delay, incapability of playing and the like can occur. The buffer overflows, indicating that the compressed data size is larger than the remaining capacity of the buffer, so that the quantization parameter needs to be increased to reduce the compressed data size. Specifically, the predicted quantization parameter may be calculated according to a preset relationship.
In some embodiments, the preset relationship is: predictive quantization parameter = quantization parameter-4 x log2 ((buffer size-padding value)/data size).
In step S502, the predicted quantization parameter is compared with the quantization parameter, and if the predicted quantization parameter is equal to the quantization parameter, a predicted quantization parameter=quantization parameter+1 is set.
In some embodiments, comparing the magnitude relation between the predicted quantization parameter and the quantization parameter, if the predicted quantization parameter is equal to the quantization parameter, the predicted quantization parameter is set to be quantization parameter +1, so that the quantization parameter is increased to compress the reference frame data block, so that the output to the buffer area is facilitated without overflowing the buffer area.
In step S503, the predicted quantized parameter is compared with the maximum quantized parameter, and if the predicted quantized parameter is greater than the maximum quantized parameter, the predicted quantized parameter is set as the maximum quantized parameter.
In some embodiments, it is further desirable to compare the predicted quantization parameter with the maximum quantization parameter, preventing the predicted quantization parameter from exceeding the range of the maximum quantization parameter, such that the compression quality is poor. Specifically, if the predicted quantization parameter is greater than the maximum quantization parameter, the predicted quantization parameter is set as the maximum quantization parameter.
Step S504, setting the new quantization parameter as the predictive quantization parameter, and repeating the encoding of the reference frame data block according to the new quantization parameter.
In some embodiments, finally, taking the predicted quantization parameter as a new quantization parameter, repeating the encoding of the reference frame data block according to the new quantization parameter, and continuously judging whether the data size of the encoded data block is output to the buffer area to overflow or not in the encoding process until the buffer area is not overflowed, thereby obtaining the corresponding encoded data block.
Regarding chip hardware implementation, since iteration of quantization parameters may require an indefinite number of precoding, accurate rate control cannot be performed in an environment where chip implementation has strict timing requirements. Therefore, in some embodiments of the present application, the image shallow compression code rate control method further includes pre-encoding for different quantization parameters, determining a target quantization parameter, and by using the discrete parallel pre-image shallow compression code rate control method, the time sequence accuracy of code rate control can be achieved at a low resource cost. As shown with reference to fig. 7, the following steps S601 to S604 may be specifically included but are not limited.
Step S601, setting a reference quantization parameter corresponding to the filling value obtained based on the mapping relation as a minimum quantization parameter.
In some embodiments, the reference quantization parameter corresponding to the target filling value calculated by the filling value of the current buffer is taken as the minimum quantization parameter, i.e. the entry quantization parameter taken as the starting point in the quantization parameter iteration process.
Step S602, increasing the reference quantization parameter by a preset step within the range of the minimum quantization parameter and the maximum quantization parameter to obtain the test quantization parameter.
It can be understood that, according to the principle of single-side iteration, the compression quality corresponding to the minimum quantization parameter is the best, while the compression quality corresponding to the maximum quantization parameter is the worst as the maximum quantization point. The optimal quantization parameter for rate control is thus in the range of the minimum quantization parameter and the maximum quantization parameter.
In some embodiments, the reference quantization parameter is increased by a predetermined step to obtain the corresponding test quantization parameter. For example, if the reference quantization parameter is 2, that is, the minimum quantization parameter is 2, the maximum quantization parameter is 20, and the preset step is 4, the test quantization parameters obtained correspondingly are respectively: 2. 6, 10, 14, 18, 20. It will be appreciated that the maximum quantization parameter needs to be taken in order to pre-code the target quantization parameter within this range.
Step S603, pre-encoding the reference frame data block based on each test quantization parameter, to obtain a pre-encoded data block.
In some embodiments, the reference frame data block is precoded based on the respective test quantization parameters, and specifically, the quantization/inverse quantization amplification coefficients are: quantization scale [4] = {16384,13777,11585,9742}, inverse quantization scale [4] = {16384,19484,23170,27554}. For example, assuming that a point data value in a reference frame data block is M, and is regarded as an unsigned number, and the currently selected quantization parameter is QP, the formula of the quantized data QuantM is: quantm= (M x QuantScale [ QP%4 ]) > (14+qp/4); let the inverse data be DequatM, then its inverse quantization formula is: dequatM= ((QuantM < < (QP/4)). DequatScale [ QP%4 ]) >14.
It can be understood that the preset step is 4, if the quantization parameter is 0, which corresponds to no quantization (M > > 0), the compression quality is the best, and if the quantization parameter is the maximum quantization parameter, which corresponds to the maximum quantization (M > > (MaxQp/4)), the corresponding compression quality is the worst.
Step S604, selecting the smallest test quantization parameter as the target quantization parameter when the preset condition is satisfied.
In some embodiments, each test quantization parameter is operated in parallel in a chip, so that the target quantization parameter with optimal rate distortion can be obtained in a high concurrence and high speed, and then the minimum test quantization parameter is selected as the target quantization parameter under the condition of meeting the preset condition so as to realize the joint control of the code rate and the compression quality in the buffer area. Specifically, the preset condition is that the pre-coded data size of the pre-coded data block is output to the buffer area without overflowing, namely, the corresponding target quantization parameter is selected according to the principle that the coded data size can enter the minimum quantization parameter of the buffer area.
The embodiment of the present application further provides a decoding method, after encoding by the image shallow compression rate control method, a corresponding decoding method, referring to fig. 8, may include, but is not limited to, the following steps S701 to S702.
Step S701, acquiring a plurality of encoded data blocks corresponding to the compressed image, and acquiring a compression parameter and a quantization parameter.
In some embodiments, the compressed image is obtained by encoding during the method for controlling the shallow compression rate of an image according to the first aspect of the embodiments of the present application, and a plurality of encoded data blocks corresponding to the compressed image are obtained, and compression parameters and quantization parameters are obtained. It will be appreciated that the compression parameters and quantization parameters are packed together into the encoded data block.
Step S702, performing inverse quantization on the encoded data block according to the compression parameter and the quantization parameter, decoding the compressed image to obtain a corresponding reference frame data block, and obtaining a reference frame according to the reference frame data block.
In some embodiments, the encoded data blocks are dequantized according to the compression parameters and the quantization parameters to effect decoding of respective encoded data blocks corresponding to the compressed image, thereby obtaining corresponding reference frames.
The following description will refer to a schematic diagram of the encoding flow of the shallow compression system at the encoding end shown in fig. 9 and a schematic diagram of the decoding flow of the shallow compression system at the decoding end shown in fig. 10. In the encoding process, after the reference frame data block is obtained, the reference frame data block is quantized according to the quantization parameter to obtain a quantized data block, then the quantized data block can be predicted to obtain a residual error, or the quantized data block can be directly output to an intermediate buffer and then transmitted through a lossless fixed-length code or a lossless variable-length code. Specifically, the transmitted data may be direct quantized data or a predicted residual. And finally, based on the optimal comparison of the buffer areas, selecting the output with the least bits, and determining whether to adjust quantization parameters to realize joint control of code rate and compression quality by judging whether the VBV buffer area overflows upwards. Correspondingly, in the decoding process, firstly, the direct quantized data or predicted residual errors are restored through lossless fixed-length codes or variable-length codes, then the quantized data are restored through lossless residual error data, and finally, the direct quantized data or the quantized data restored through the residual errors are dequantized, so that lossy or lossless original image data, namely a reference frame, is obtained. It should be appreciated that the degradation of the image quality of the shallow compression system is due to quantization, and the degree to which quantization produces the degradation of the image quality is determined by the buffer. The buffer region is transmitted by controlling the code rate, and when the code rate is higher, more information can be transmitted, so that quantization errors can be reduced, and image quality can be improved. Therefore, the method and the device select the corresponding quantization parameters to code according to the mapping relation between the current filling value of the buffer area and different quantization parameters so as to realize joint control of the code rate and compression quality of the buffer area.
It can be understood that the method and the device are suitable for use scenes with low requirements on coding delay, and have no dependence on coding standards and coding types. When the compression ratio of the image changes, for example, when a higher compression ratio is needed, only the value of the maximum quantization parameter needs to be regulated to be larger, so that the higher compression ratio and the maximum quantization parameter are in positive correlation, and meanwhile, the calculation of the buffer size and the code rate control parameter can be correspondingly regulated according to the compression ratio, so that the embodiment is not limited.
In some embodiments, the application can use lower main frequency and hardware resources to realize 2-3 times of shallow compression of transparent quality, and referring to a quality evaluation schematic diagram of a coding and decoding method shown in fig. 11, the result of direct coding and decoding compression test of 22 ultra-high definition sequences is used, and specifically, VMAF, PSNR, MS-SSIM quality indexes commonly used in video coding quality evaluation are used. It can be appreciated that VMAF (Video Multi-method Assessment Fusion) is an index for comprehensively evaluating Video quality, and can evaluate various aspects of Video such as distortion degree, sharpness, color saturation, etc.; PSNR (Peak Signal-to-Noise Ratio) is a conventional video quality evaluation index that evaluates the distortion degree of video, i.e., the degree of difference between an original video and a coded video, the higher the PSNR, the better the coded video quality; MS-SSIM (Multi-Scale Structural Similarity Index) is a structural similarity index that evaluates the degree of distortion and structural variation of video. Compared to PSNR, MS-SSIM is more reflective of the perception of video quality by the human eye, as it takes into account factors such as the structure and texture of the video. Specifically, the sequence 22 in fig. 11 is random noise, so it can be known that the present application can well converge and maintain high quality for unpredictable random noise; and the rest of the sequence is completely lossless (40% of the sequence), and the rest of the sequence reaches error accuracy which cannot be distinguished by human eyes (> 50 dB).
In some embodiments, the present application may be used in scenes such as reference frame compression and video interface compression, and it can be understood that, in either scene, multiple compression may be faced, and as shown in fig. 12 and 13, the effect of the present application when the present application is used for encoding and decoding in series with an algorithm with a higher compression ratio is shown, so that when the present application is used for encoding and decoding in series with compression codecs in different compression rate ranges, the effect on quality or code rate is extremely small (the code rate effect < = 0.7%), and the effect is basically negligible, and a transparent series effect is achieved.
By mapping the filling value and the compression quality of the current buffer area, the code rate and the compression quality are controlled in a combined way, the stability of the compression quality is obviously improved, and a better overall coding effect is achieved. And by using the full-precision mapping entry quantization parameter and the preset stepping discrete pre-coding quantization parameter point to perform parallel operation, the deterministic code rate control time sequence is realized and the clock requirement is reduced by up to 75% at the cost of less resources. Therefore, the method and the device realize accurate code rate control and highly stable compression quality simultaneously with fewer parallel resources, for example, when the compression ratio is 2, 40% of sequences in a test sequence realize mathematical lossless, PSNR (Power System noise ratio) of all video sequences is greater than 50dB except random noise, and a transparent compression coding effect is achieved, so that the quality stability and the accurate code rate control are realized under the resources of limited bandwidth and the like.
The embodiment of the invention also provides an image shallow compression code rate control device, which can realize the image shallow compression code rate control method, and referring to fig. 14, in some embodiments of the present application, the image shallow compression code rate control device includes:
a first obtaining module 101, configured to obtain a reference frame data block of a reference frame to be compressed, and obtain a compression parameter of the reference frame data block;
a calculating module 102, configured to calculate a maximum quantization parameter according to the compression parameter, and calculate a minimum code rate based on the compression parameter and the maximum quantization parameter;
a dividing module 103, configured to divide the maximum quantization parameter to obtain a plurality of reference quantization parameters, and divide the buffer to obtain a plurality of sub-buffers corresponding to the reference quantization parameters; wherein, different sub-buffers correspond to different filling values, the reference quantization parameter and the filling value meet the preset mapping relation, and the buffer is related to the minimum code rate;
the setting module 104 is configured to obtain a reference quantization parameter corresponding to the filling value based on the mapping relationship, and set the quantization parameter as the reference quantization parameter;
an encoding module 105, configured to encode the reference frame data block according to the compression parameter and the quantization parameter to obtain an encoded data block; judging whether the data size of the encoded data block is output to a buffer area or not to overflow in the encoding process, if so, adjusting quantization parameters until the encoded data block of the reference frame data block is obtained, and obtaining a compressed image of the reference frame to be compressed according to the encoded data block.
The specific implementation of the image shallow compression code rate control device in this embodiment is basically identical to the specific implementation of the image shallow compression code rate control method described above, and will not be described in detail here.
Fig. 15 shows an electronic device 1000 provided in an embodiment of the present application. The electronic device 1000 includes: the image shallow compression rate control method comprises a processor 1001, a memory 1002 and a computer program stored in the memory 1002 and capable of running on the processor 1001, wherein the computer program is used for executing the image shallow compression rate control method.
The processor 1001 and the memory 1002 may be connected by a bus or other means.
The memory 1002 is used as a non-transitory computer readable storage medium for storing a non-transitory software program and a non-transitory computer executable program, such as the image shallow compression rate control method described in the embodiments of the present application. The processor 1001 implements the above-described image shallow compression rate control method by running a non-transitory software program and instructions stored in the memory 1002.
Memory 1002 may include a storage program area that may store an operating system, at least one application program required for functionality, and a storage data area; the storage data area can store and execute the image shallow compression code rate control method. In addition, the memory 1002 may include high-speed random access memory 1002, and may also include non-transitory memory 1002, such as at least one storage device memory device, flash memory device, or other non-transitory solid state memory device. In some implementations, the memory 1002 optionally includes memory 1002 remotely located relative to the processor 1001, which remote memory 1002 can be connected to the electronic device 1000 over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The non-transitory software programs and instructions required to implement the above-described image shallow compression rate control method are stored in the memory 1002, and when executed by the one or more processors 1001, the above-described image shallow compression rate control method is performed, for example, method steps S101 to S105 in fig. 1, method steps S201 to S205 in fig. 2, method steps S301 to S304 in fig. 3, method steps S401 to S402 in fig. 5, method steps S501 to S504 in fig. 6, method steps S601 to S604 in fig. 7, and method steps S701 to S702 in fig. 8.
The embodiment of the application also provides a storage medium, which is a computer readable storage medium, and the storage medium stores a computer program, and the computer program realizes the image shallow compression code rate control method when being executed by a processor. The memory, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
According to the image shallow compression code rate control method and device, the filling value and the quantization parameter of the current buffer area are mapped, so that the code rate and the compression quality are controlled in a combined mode, the stability of the compression quality is remarkably improved, parallel operation is performed by using the full-precision mapping entry quantization parameter and the preset stepping discrete pre-coding quantization parameter, and accurate code rate control time sequence is achieved under limited resources. Therefore, under the resources of limited bandwidth and the like, quantization parameters are adaptively selected and adjusted according to the filling value of the buffer area, and meanwhile, accurate code rate control and highly stable compression quality are realized.
The embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, i.e. may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, storage device storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically include computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and may include any information delivery media.
It should also be appreciated that the various embodiments provided in the embodiments of the present application may be arbitrarily combined to achieve different technical effects. While the preferred embodiments of the present application have been described in detail, the present application is not limited to the above embodiments, and various equivalent modifications and substitutions can be made by those skilled in the art without departing from the spirit and scope of the present application.

Claims (10)

1. The method for controlling the image shallow compression code rate is characterized by comprising the following steps of:
acquiring a reference frame data block of a reference frame to be compressed, and acquiring compression parameters of the reference frame data block;
calculating a maximum quantization parameter according to the compression parameter, and calculating a minimum code rate based on the compression parameter and the maximum quantization parameter;
dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters, and dividing a buffer area to obtain a plurality of sub-buffer areas corresponding to the reference quantization parameters; wherein, different sub-buffers correspond to different filling values, the reference quantization parameter and the filling values meet a preset mapping relation, and the buffer size of the buffer is related to the minimum code rate;
obtaining the reference quantization parameter corresponding to the filling value based on the mapping relation, and setting the quantization parameter as the reference quantization parameter;
Coding the reference frame data block according to the compression parameter and the quantization parameter to obtain a coded data block; and judging whether the data size of the encoded data block is output to the buffer area or not in the encoding process, if so, adjusting the quantization parameter to continue the encoding process until the encoded data block of the reference frame data block is obtained, and obtaining the compressed image of the reference frame to be compressed according to the encoded data block.
2. The method according to claim 1, wherein the compression parameters include a pixel bit width and a data block size; the calculating the maximum quantization parameter according to the compression parameter, and calculating the minimum code rate based on the compression parameter and the maximum quantization parameter, includes:
judging whether the pixel bit width is even;
if the pixel bit width is even, calculating the maximum quantization parameter according to a first formula; wherein, the first formula is: maxqp=4 pixel bit width/2, maxQp representing the maximum quantization parameter;
if the pixel bit width is odd, calculating the maximum quantization parameter according to a second formula; wherein the second formula is: maxqp=4 (pixel bit width+1)/2;
Calculating a code rate control parameter according to a third formula based on the data block size and the pixel bit width; wherein the third formula is: code rate control parameter = data block size x pixel bit width/2 + macroblock header byte number x8;
calculating the minimum code rate according to a fourth formula based on the code rate control parameter and the maximum quantization parameter; wherein the fourth formula is: minimum code rate = code rate control parameter + MaxQp +1.
3. The method of claim 2, wherein the dividing the maximum quantization parameter into a plurality of reference quantization parameters and dividing a buffer into a plurality of sub-buffers corresponding to the reference quantization parameters comprises:
dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters; wherein each of the reference quantization parameters is an integer within a range of [0, maxqp ];
obtaining the buffer area size of the buffer area; wherein the buffer size is greater than the minimum code rate;
equally dividing the buffer zone based on the size of the buffer zone to obtain N sub-buffer zones; wherein n=maxqp+1;
setting a reference quantization parameter corresponding to the filling value of the 1 st sub-buffer as 0, and setting a reference quantization parameter corresponding to the filling value of the N-th sub-buffer as MaxQp, so that the reference quantization parameter and the filling value meet a preset mapping relation.
4. The method according to claim 2, wherein the obtaining the reference quantization parameter corresponding to the filling value based on the mapping relation, setting the quantization parameter as the reference quantization parameter, includes:
acquiring the current filling value of the buffer area, and based on the filling value, obtaining a target filling value; setting the target filling value to be 0 if the filling value is smaller than the code rate control parameter, otherwise setting the target filling value to be the difference value between the filling value and the code rate control parameter;
based on the mapping relation, obtaining the reference quantization parameter according to the maximum quantization parameter, the target filling value and the buffer area size of the buffer area, and setting the quantization parameter as the reference quantization parameter; wherein reference quantization parameter = target padding value (maximum quantization parameter + 1)/buffer size.
5. The method according to claim 1, wherein the determining whether the data size of the encoded data block is output to the buffer area is overflowed in the encoding process, and if the buffer area is overflowed, adjusting the quantization parameter includes:
Calculating a predictive quantization parameter according to a preset relation; wherein, the preset relation is: predictive quantization parameter = quantization parameter-4 x log2 ((buffer size-padding value)/data size);
comparing the predicted quantization parameter with the quantization parameter, and if the predicted quantization parameter is equal to the quantization parameter, setting a predicted quantization parameter=quantization parameter+1;
comparing the predicted quantization parameter with the maximum quantization parameter, and if the predicted quantization parameter is larger than the maximum quantization parameter, setting the predicted quantization parameter as the maximum quantization parameter;
setting a new quantization parameter as the predicted quantization parameter, and repeating the encoding of the reference frame data block according to the new quantization parameter.
6. The image shallow compression rate control method according to claim 1, wherein the compression parameter includes a compression ratio; the maximum quantization parameter is positively correlated with the compression ratio, comprising:
the higher the compression ratio, the greater the maximum quantization parameter;
the lower the compression ratio, the smaller the maximum quantization parameter.
7. The image shallow compression code rate control method according to any one of claims 1 to 6, characterized in that the method further comprises:
Precoding for different quantization parameters, determining a target quantization parameter, comprising:
setting the reference quantization parameter corresponding to the filling value obtained based on the mapping relation as a minimum quantization parameter;
increasing the reference quantization parameter in a preset step within the range of the minimum quantization parameter and the maximum quantization parameter to obtain a test quantization parameter;
pre-coding the reference frame data block based on each test quantization parameter to obtain a pre-coded data block;
selecting the smallest test quantization parameter as the target quantization parameter under the condition that the preset condition is met; the preset condition is that the size of the pre-coded data block is output to the buffer zone without overflowing.
8. An image shallow compression rate control device, characterized in that it is applied to the image shallow compression rate control method according to any one of claims 1 to 7, comprising:
the first acquisition module is used for acquiring a reference frame data block of a reference frame to be compressed and acquiring compression parameters of the reference frame data block;
the calculating module is used for calculating a maximum quantization parameter according to the compression parameter and calculating a minimum code rate based on the compression parameter and the maximum quantization parameter;
The dividing module is used for dividing the maximum quantization parameter to obtain a plurality of reference quantization parameters, and dividing the buffer area to obtain a plurality of sub-buffer areas corresponding to the reference quantization parameters; wherein, different sub-buffers correspond to different filling values, the reference quantization parameter and the filling values meet a preset mapping relation, and the buffer size of the buffer is related to the minimum code rate;
the setting module is used for obtaining the reference quantization parameter corresponding to the filling value based on the mapping relation and setting the quantization parameter as the reference quantization parameter;
the coding module is used for coding the reference frame data block according to the compression parameter and the quantization parameter to obtain a coded data block; and judging whether the data size of the encoded data block is output to the buffer area or not in the encoding process, if so, adjusting the quantization parameter to continue the encoding process until the encoded data block of the reference frame data block is obtained, and obtaining the compressed image of the reference frame to be compressed according to the encoded data block.
9. An electronic device comprising a memory, a processor, the memory storing a computer program, the processor implementing the image shallow compression bitrate control method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a program that is executed by a processor to implement the image shallow compression rate control method according to any one of claims 1 to 7.
CN202310770774.1A 2023-06-28 2023-06-28 Image shallow compression code rate control method and device Active CN116506617B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310770774.1A CN116506617B (en) 2023-06-28 2023-06-28 Image shallow compression code rate control method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310770774.1A CN116506617B (en) 2023-06-28 2023-06-28 Image shallow compression code rate control method and device

Publications (2)

Publication Number Publication Date
CN116506617A true CN116506617A (en) 2023-07-28
CN116506617B CN116506617B (en) 2023-09-12

Family

ID=87321669

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310770774.1A Active CN116506617B (en) 2023-06-28 2023-06-28 Image shallow compression code rate control method and device

Country Status (1)

Country Link
CN (1) CN116506617B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20090049108A (en) * 2007-11-13 2009-05-18 바로비젼(주) Bit rate control advice and method using quantization coefficient property
CN102724507A (en) * 2012-06-18 2012-10-10 上海交通大学 GPU (graphic processing unit) accelerating encoder rate control method
CN112887725A (en) * 2021-01-19 2021-06-01 珠海全志科技股份有限公司 Reference frame buffer data compression method, computer device and computer readable storage medium
CN113491125A (en) * 2019-02-22 2021-10-08 北京字节跳动网络技术有限公司 History-based affine pattern sub-table
CN113780549A (en) * 2021-08-05 2021-12-10 鹏城实验室 Quantitative model training method, device, medium and terminal equipment for overflow perception
CN115103190A (en) * 2022-06-14 2022-09-23 晶晨芯半导体(成都)有限公司 Encoder code rate control method and module, chip, electronic equipment and storage medium
CN115550650A (en) * 2022-09-27 2022-12-30 上海富瀚微电子股份有限公司 Method and device for effectively adjusting compression rate of reference frame image and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20090049108A (en) * 2007-11-13 2009-05-18 바로비젼(주) Bit rate control advice and method using quantization coefficient property
CN102724507A (en) * 2012-06-18 2012-10-10 上海交通大学 GPU (graphic processing unit) accelerating encoder rate control method
CN113491125A (en) * 2019-02-22 2021-10-08 北京字节跳动网络技术有限公司 History-based affine pattern sub-table
CN112887725A (en) * 2021-01-19 2021-06-01 珠海全志科技股份有限公司 Reference frame buffer data compression method, computer device and computer readable storage medium
CN113780549A (en) * 2021-08-05 2021-12-10 鹏城实验室 Quantitative model training method, device, medium and terminal equipment for overflow perception
CN115103190A (en) * 2022-06-14 2022-09-23 晶晨芯半导体(成都)有限公司 Encoder code rate control method and module, chip, electronic equipment and storage medium
CN115550650A (en) * 2022-09-27 2022-12-30 上海富瀚微电子股份有限公司 Method and device for effectively adjusting compression rate of reference frame image and electronic equipment

Also Published As

Publication number Publication date
CN116506617B (en) 2023-09-12

Similar Documents

Publication Publication Date Title
US10743032B2 (en) Substream multiplexing for display stream compression
US10574988B2 (en) System and methods for reducing slice boundary visual artifacts in display stream compression (DSC)
US10244255B2 (en) Rate-constrained fallback mode for display stream compression
JP6921873B2 (en) Substream multiplexing for display stream compression
TWI743098B (en) Apparatus and methods for adaptive calculation of quantization parameters in display stream compression
CN108810545B (en) Method, apparatus, computer readable medium and electronic device for video encoding
CN106165420B (en) Method and apparatus for coding video data
CN110225343B (en) Code rate control method and device for video coding
TWI721042B (en) System and methods for fixed-point approximations in display stream compression (dsc)
WO2021129007A1 (en) Method and device for determining video bitrate, computer apparatus, and storage medium
US20240040127A1 (en) Video encoding method and apparatus and electronic device
CN113132728B (en) Coding method and coder
CN113132726B (en) Encoding method and encoder
TWI686078B (en) System and methods for calculating distortion in display stream compression (dsc)
KR102112942B1 (en) Apparatus and methods for perceptual quantization parameter (QP) weighting for display stream compression
CN116506617B (en) Image shallow compression code rate control method and device
CN113727102B (en) Low-delay lossy image encoder and decoder
US10123045B2 (en) Modification to block size for transform mode in display stream compression
Le Pendu et al. Template based inter-layer prediction for high dynamic range scalable compression
CN117676143A (en) Encoding and decoding method and device
CN116156169A (en) Quantization parameter determination method and device

Legal Events

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