CN108574841B - Coding method and device based on self-adaptive quantization parameter - Google Patents

Coding method and device based on self-adaptive quantization parameter Download PDF

Info

Publication number
CN108574841B
CN108574841B CN201710130401.2A CN201710130401A CN108574841B CN 108574841 B CN108574841 B CN 108574841B CN 201710130401 A CN201710130401 A CN 201710130401A CN 108574841 B CN108574841 B CN 108574841B
Authority
CN
China
Prior art keywords
quality
preset
coding
coding unit
quantization parameter
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
Application number
CN201710130401.2A
Other languages
Chinese (zh)
Other versions
CN108574841A (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.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Beijing Kingsoft Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd, Beijing Kingsoft Cloud Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN201710130401.2A priority Critical patent/CN108574841B/en
Publication of CN108574841A publication Critical patent/CN108574841A/en
Application granted granted Critical
Publication of CN108574841B publication Critical patent/CN108574841B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression, Expansion, Code Conversion, And Decoders (AREA)

Abstract

The embodiment of the invention provides an encoding method and device based on self-adaptive quantization parameters, wherein the method comprises the following steps: obtaining a quantization parameter of a coding unit to be coded; coding a coding unit to be coded according to a preset quality threshold, a preset coding unit size and a preset quantization parameter to obtain a coding result comprising a plurality of quality values; comparing the quality values with a quality threshold, reducing the quantization parameters when one quality value does not meet a preset first quality judgment condition, and coding the coding unit to be coded again until the coding result meets the preset first quality judgment condition; and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and re-encoding the encoding unit to be encoded until the encoding result meets the first quality judgment condition and the second quality judgment condition.

Description

Coding method and device based on self-adaptive quantization parameter
Technical Field
The present invention relates to the field of video coding, and in particular, to an adaptive quantization parameter based coding method and apparatus.
Background
With the development of internet and digital multimedia technology, video applications have been deeply applied to various corners of people's work and life, such as video conferencing, shooting, watching, downloading and transmitting video images, and the like. Video applications have become the biggest hotspot in the internet and digital multimedia fields.
The main problem in video applications is that in video encoding and decoding, especially in the video encoding process, an original image needs to be compressed into a coded image with a small occupied space through encoding processing for network storage or network transmission, so how to obtain high compression efficiency of video encoding becomes the primary problem in the field of video encoding. In the video coding process, the determination of a Quantization Parameter (QP) is a key problem, the size of the QP directly affects the coding quality and the compression efficiency, and the larger the QP is, the larger the distortion between a coded image and an original image is, the worse the coding quality is; the smaller the QP, the greater the coding rate of the coded picture, resulting in a larger occupied space of the coded picture and lower compression efficiency.
In the existing video coding method, the reference relationship between video frames is considered to determine the QP of each coding unit, and the coding units are subjected to video coding one by one according to the QP of each coding unit, so that a coding result with higher overall compression efficiency is obtained. When the method obtains the coding result with high overall compression efficiency, the QP of each coding unit is fixedly taken as a value in the coding process, but the distortion of some coding units is too large due to the value taking mode, the overall coding quality of the video image is affected, and the requirement of a specific application scene on the coding quality, such as the application scene of a high-definition video, cannot be met.
Disclosure of Invention
The embodiments of the present invention provide an encoding method and apparatus based on adaptive quantization parameters, which can adaptively change quantization parameters of an encoding unit to be encoded, reduce distortion of the encoding unit to be encoded, and meet requirements of a specific application scenario on encoding quality. The specific technical scheme is as follows:
the embodiment of the invention discloses an encoding method based on self-adaptive quantization parameters, which comprises the following steps:
obtaining a quantization parameter of a coding unit to be coded;
coding a coding unit to be coded according to a preset quality threshold, a preset coding unit size and the quantization parameter to obtain a coding result of the coding unit to be coded, wherein the coding result comprises a plurality of quality values;
comparing the quality value with the quality threshold, reducing the quantization parameter when one quality value does not meet a preset first quality judgment condition, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the reduced quantization parameter until the coding result meets the preset first quality judgment condition;
and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and re-encoding the encoding unit to be encoded according to the quality threshold, the size of the encoding unit and the increased quantization parameter until the encoding result meets the first quality judgment condition and the second quality judgment condition.
Optionally, the encoding the coding unit to be encoded includes:
acquiring a reference coding unit of a coding unit to be coded by using a coded historical frame image corresponding to a frame image where the coding unit to be coded is located;
acquiring a difference value between a coding unit to be coded and a pixel point of the reference coding unit, and performing discrete cosine transform on the difference value to obtain frequency domain data of the difference value;
obtaining a quantization step corresponding to a quantization parameter according to a preset relationship between the quantization parameter and the quantization step, and quantizing the frequency domain data of the difference value by using the quantization step to obtain quantized data of a coding unit to be coded;
and entropy coding the quantized data of the coding unit to be coded to obtain a coding result.
Optionally, when there is a quality value that does not satisfy the preset first quality determination condition, reducing the quantization parameter includes:
when one quality value does not meet a preset first quality judgment condition, reducing the quantization parameter by a first preset quantity;
correspondingly, when all the quality values satisfy a preset first quality judgment condition and one quality value does not satisfy a preset second quality judgment condition, increasing the quantization parameter includes:
and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset quantity.
Optionally, after the reducing the quantization parameter by the first preset amount, the method further includes:
the method comprises the steps that the counting of a first counter is increased by one, and when the counting times of the first counter are larger than a preset first counting value, a reminding instruction is sent, wherein the reminding instruction carries a coding result corresponding to the last counting in the first counter.
Optionally, after the increasing the quantization parameter by the first preset amount, the method further includes:
and the counting of the second counter is increased by one, and a reminding instruction is sent when the counting times of the second counter is greater than a preset second counting value, wherein the reminding instruction carries a coding result corresponding to the last counting in the second counter.
Optionally, after the encoding result meets the preset first quality determination condition and the preset second quality determination condition, the method further includes:
and saving the coding result of the coding unit to be coded.
Optionally, the preset quality threshold is:
an upper limit threshold value of a pixel mean square error (MSD) of an NxN block of a preset reconstructed image and an original image, wherein N is a preset natural number;
accordingly, the quality values are:
MSD corresponding to each of a plurality of NxN blocks into which a coding unit to be coded is divided;
correspondingly, the first quality determination condition is that MSD is smaller than an upper threshold of MSD, and the second quality determination condition is that a difference between the upper threshold of MSD and MSD is smaller than a first preset difference.
Optionally, the preset quality threshold is:
a lower threshold of peak signal-to-noise ratio (PSNR);
accordingly, the quality values are:
the PSNR;
correspondingly, the first quality determination condition is that the PSNR is greater than a lower threshold of the PSNR, and the second quality determination condition is that a difference between the PSNR and the lower threshold of the PSNR is smaller than a second preset difference.
The embodiment of the invention also discloses a coding device based on the self-adaptive quantization parameter, which comprises the following steps:
the acquisition module is used for acquiring the quantization parameter of the coding unit to be coded;
the encoding module is used for encoding the encoding unit to be encoded according to a preset quality threshold, a preset encoding unit size and the quantization parameter to obtain an encoding result of the encoding unit to be encoded, wherein the encoding result comprises a plurality of quality values;
the first judgment module is used for comparing the quality value with the quality threshold, reducing the quantization parameter when one quality value does not meet a preset first quality judgment condition, and recoding the coding unit to be coded according to the quality threshold, the size of the coding unit and the reduced quantization parameter until a coding result meets the preset first quality judgment condition;
and the second judging module is used for increasing the quantization parameter when all the quality values meet a preset first quality judging condition and one quality value does not meet a preset second quality judging condition, and recoding the coding unit to be coded according to the quality threshold, the size of the coding unit and the increased quantization parameter until a coding result meets the first quality judging condition and the second quality judging condition.
Optionally, the encoding module includes:
the prediction submodule is used for acquiring a reference coding unit of the coding unit to be coded by utilizing a coded historical frame image corresponding to the frame image where the coding unit to be coded is located;
the transformation submodule is used for acquiring a difference value between a coding unit to be coded and a pixel point of the reference coding unit, and performing discrete cosine transformation on the difference value to acquire frequency domain data of the difference value;
the quantization submodule is used for acquiring a quantization step corresponding to a quantization parameter according to a preset relationship between the quantization parameter and the quantization step, and quantizing the frequency domain data of the difference value by using the quantization step to acquire quantized data of a coding unit to be coded;
and the entropy coding sub-module is used for entropy coding the quantized data of the coding unit to be coded to obtain a coding result.
Optionally, the first determining module is specifically configured to:
when one quality value does not meet a preset first quality judgment condition, reducing the quantization parameter by a first preset quantity;
correspondingly, the second determination module is specifically configured to:
and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset quantity.
Optionally, the first determining module is further configured to:
the method comprises the steps that the counting of a first counter is increased by one, and when the counting times of the first counter are larger than a preset first counting value, a reminding instruction is sent, wherein the reminding instruction carries a coding result corresponding to the last counting in the first counter.
Optionally, the second determining module is further configured to:
and the counting of the second counter is increased by one, and a reminding instruction is sent when the counting times of the second counter is greater than a preset second counting value, wherein the reminding instruction carries a coding result corresponding to the last counting in the second counter.
Optionally, the apparatus further comprises:
and the storage module is used for storing the coding result of the coding unit to be coded until the coding result meets the preset first quality judgment condition and the preset second quality judgment condition.
Optionally, the preset quality threshold is:
an upper limit threshold value of a pixel mean square error (MSD) of an NxN block of a preset reconstructed image and an original image, wherein N is a preset natural number;
accordingly, the quality values are:
MSD corresponding to each of a plurality of NxN blocks into which a coding unit to be coded is divided;
correspondingly, the first quality determination condition is that MSD is smaller than an upper threshold of MSD, and the second quality determination condition is that a difference between the upper threshold of MSD and MSD is smaller than a first preset difference.
Optionally, the preset quality threshold is:
a lower threshold of peak signal-to-noise ratio (PSNR);
accordingly, the quality values are:
the PSNR;
correspondingly, the first quality determination condition is that the PSNR is greater than a lower threshold of the PSNR, and the second quality determination condition is that a difference between the PSNR and the lower threshold of the PSNR is smaller than a second preset difference.
According to the coding method and device based on the adaptive quantization parameter, a preset quality threshold is added in a coding process, after a coding result of a coding unit to be coded is obtained, a plurality of quality values in the coding result are compared with the preset quality threshold, when one quality value does not meet a preset first quality judgment condition, the quantization parameter is reduced, and the coding unit to be coded is coded again according to the quality threshold, the size of the coding unit and the reduced quantization parameter until the coding result meets the preset first quality judgment condition. And when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and re-encoding the encoding unit to be encoded according to the quality threshold, the size of the encoding unit and the increased quantization parameter until the encoding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the quality threshold, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, and obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition. Therefore, the embodiment of the invention can effectively improve the compression efficiency of the code on the premise of meeting the specific application scene, and can meet the requirement of the specific application scene on the coding quality.
Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flowchart of an adaptive quantization parameter based coding method according to an embodiment of the present invention;
FIG. 2 is another flow chart of an adaptive quantization parameter based coding method according to an embodiment of the present invention;
FIG. 3 is a flow chart based on an example of the method shown in FIG. 2;
FIG. 4 is a flow chart based on another example of the method shown in FIG. 2;
FIG. 5 is a block diagram of an adaptive quantization parameter based coding apparatus according to an embodiment of the present invention;
fig. 6 is another block diagram of an adaptive quantization parameter-based coding apparatus according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention discloses an encoding method and an encoding device based on self-adaptive quantization parameters, which can change the quantization parameters of an encoding unit to be encoded in a self-adaptive manner, reduce the distortion of the encoding unit to be encoded and meet the requirements of specific application scenes on encoding quality.
First, a coding method based on adaptive quantization parameters according to an embodiment of the present invention is described below.
The data size of uncompressed video images is huge, which causes storage difficulty, for example, a DVD can only store several seconds of uncompressed video images; or cause transmission difficulties such as a 1 megabyte bandwidth required to transmit one second of digital television video for approximately 4 minutes. It is therefore desirable to compress video images to reduce storage space and increase transmission rates. Because redundant information exists in the video image, such as spatial redundancy with strong correlation between adjacent pixels of the image, temporal redundancy with similar contents between adjacent images of a video sequence, coding redundancy with different occurrence probabilities of different pixel values, visual redundancy of which the human visual system is insensitive to certain details, and the like, the video image can be compressed. An important index for evaluating the compression effect is the compression efficiency, and the higher the compression efficiency is, the better the compression effect is. A video encoding process for encoding a video image to obtain an encoded video image, i.e., a process for compressing a video image. However, in the video encoding and compressing process, loss of the video image may occur, the loss is expressed as distortion of the video image, the larger the distortion is, the larger the difference between the encoded and compressed video image and the original video image is, pixel point missing, poor definition and the like may occur, and the quality of the video encoding is poor.
The existing video coding method divides a frame of a video image to be compressed into a plurality of coding units, each coding unit is a block comprising a plurality of pixels, the coding process is to code each coding unit one by one to obtain a coding result with higher overall compression efficiency, in order to meet the requirement of the overall compression performance, the existing coding process may cause improper values of QPs of part of the coding units, and further cause overlarge distortion of some coding units, thereby affecting the overall coding quality of the video image, and therefore, the requirement of a specific application scene on the coding quality, such as the requirement of the application scene for limiting coding loss, cannot be met.
In the encoding process of an encoding unit to be encoded, a quality threshold for limiting encoding quality is added, after encoding is completed, the quality threshold is compared with a quality value in an encoding result, corresponding adjustment is carried out on a quantization parameter under the condition that a first quality judgment condition is not met or the first quality judgment condition is met but a second quality judgment condition is not met, and encoding is carried out again by using the adjusted quantization parameter until an encoding result meets the first quality judgment condition and the second quality judgment condition. Compared with the fixed value of the quantization parameter of the coding unit in the prior art, the embodiment of the invention can adaptively adjust the quantization parameter according to the coding result and recode the quantization parameter according to the limitation of the quality judgment condition, thereby reducing the distortion of the unit to be coded, and obtaining the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition.
Referring to fig. 1, fig. 1 is a flowchart of an adaptive quantization parameter-based encoding method according to an embodiment of the present invention, including the following steps:
step 101, obtaining a quantization parameter of a coding unit to be coded.
Embodiments of the invention are performed by a processor. The processor may be an encoder, a computer with encoding function, or software provided in a computer, etc.
The coding unit is a basic unit of video coding and can be pixel blocks with different sizes. Such as a 32x32 block of pixels, etc.
The quantization parameter is a parameter of quantization coding in video coding, and is denoted as QP.
In video coding, Quantization coding is a key Step, a parameter actually used by Quantization coding is QStep (Quantization Step size), a Quantization parameter QP is mainly used for providing an index for QStep according to a correspondence between QP and QStep, the QP may be regarded as a serial number of QStep, and each QP corresponds to one QStep. For example, in the encoding standard h.264 codec, for luma coding, QP takes values of 0 to 51, and correspondingly, Qstep has 52 values. Different coding standards have respective corresponding QP and Qstep relationships.
When the QP takes the minimum value of 0, it indicates that the quantization is the finest, and conversely, when the QP takes the maximum value of 51, it indicates that the quantization is the coarsest. The influence of the QP value on the quality and the compression efficiency of video coding is reflected in that the higher the QP is, the higher the distortion between the coded image and the original image is, and the worse the quality of the video coding is; the smaller the QP, the greater the coding rate of the coded picture, resulting in a larger occupied space of the coded picture and lower compression efficiency. Therefore, in the actual video encoding process, it is necessary to obtain a proper QP with a balance between encoding quality and compression efficiency, and then obtain QStep corresponding to the QP to complete the quantization encoding process.
And 102, coding the coding unit to be coded according to a preset quality threshold, a preset coding unit size and a preset quantization parameter to obtain a coding result of the coding unit to be coded, wherein the coding result comprises a plurality of quality values.
The process of video encoding is actually a process of compressing the original image. The compression of video images can be classified into lossless video compression in which there is no difference between images before compression and after decompression, and lossy video compression in which there is a difference between images before compression and after decompression, and the lossy video compression makes the encoded and decoded images different, and a means is required to evaluate the quality of images before and after encoding or before and after decoding. The quality evaluation includes objective quality evaluation, subjective quality evaluation, and the like. Common methods for objective quality evaluation include SAD (Sum of Absolute Difference), SSD (Sum of Squared Difference), MAD (Mean Absolute Difference), MSD (Mean Squared Difference, pixel Mean square Difference between reconstructed image and NxN block of original image), SNR (Signal Noise Rate, Signal to Noise ratio), PSNR (peak Signal to Noise ratio), and the like. The quality evaluation method can be embodied in the form of quality evaluation models, such as an MSD model, a PSNR model, and the like.
In the embodiment of the present invention, the quality threshold is preset, and the threshold for measuring video coding quality may be a threshold in various video coding quality evaluation methods, including an upper threshold MAXMSD of MSD, a lower threshold minsnr of PSNR, and the like.
The coding unit size is the size of the coding unit and may be various sizes, such as 4 × 4, 8 × 8, 16 × 16, 32 × 32, and the like. It should be noted that the selection of the coding unit size affects the coding result, for example, the smaller the coding unit size, the smaller the difference between the allowed coded image and the original image, the higher the coding precision, but the higher the time complexity. Therefore, in the actual encoding process, an appropriate coding unit size needs to be selected according to the scene requirements of video encoding.
The coding unit to be coded may adopt a plurality of existing video coding methods, such as the coding standard H264/AVC, the coding standard HEVC, and the like. The specific encoding process is the prior art and is not described herein.
The encoding result includes an encoded image and a plurality of quality values, wherein the quality values correspond to quality thresholds.
And 103, comparing the quality values with a quality threshold, reducing the quantization parameter when one quality value does not meet a preset first quality judgment condition, and recoding the coding unit to be coded according to the quality threshold, the size of the coding unit and the reduced quantization parameter until the coding result meets the preset first quality judgment condition.
The first quality determination condition is a determination condition of a relationship between a preset quality value and a quality threshold value. Including a quality number less than a quality threshold, or a quality number greater than a quality threshold, etc.
Different from the prior art, the quantization parameter of the coding unit to be coded is fixed, the quality threshold value is compared with the quality value in the coding result, if the quality threshold value does not meet the first quality judgment condition, the quantization parameter is reduced, and the coding unit to be coded is coded again by using the reduced quantization parameter, the reduced quality threshold value and the coding unit size. Reducing the quantization parameter can improve the coding quality of video coding.
And 104, when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and re-encoding the encoding unit to be encoded according to the quality threshold, the size of the encoding unit and the increased quantization parameter until the encoding result meets the first quality judgment condition and the second quality judgment condition.
The second quality determination condition is a determination condition of a relationship between a preset quality value and a quality threshold value. Including the degree to which the quality number is less than the quality threshold, or the degree to which the quality number is greater than the quality threshold, etc.
The embodiment of the invention not only uses the first quality judgment condition, but also continuously compares the quality threshold value with the quality value in the coding result under the condition of meeting the first quality judgment condition, whether the quality threshold value meets the second quality judgment condition or not, if the quality threshold value does not meet the second quality judgment condition, the quantization parameter is increased, so that the purposes of properly reducing the coding rate of the current coding unit and improving the compression efficiency by increasing QP on the basis of ensuring that the coding result meets the quality threshold value limit are achieved. And coding the coding unit to be coded again by using the increased quantization parameter, the quality threshold and the coding unit size. The embodiment of the invention uses two quality judgment conditions to adaptively adjust the quantization parameter, and can improve the compression efficiency of coding while reducing the distortion of a coding unit to be coded.
The coding method based on the adaptive quantization parameter provided by the embodiment of the invention is characterized in that a preset quality threshold is added in the coding process, after a coding result of a coding unit to be coded is obtained, a plurality of quality values in the coding result are compared with the preset quality threshold, when one quality value does not meet a preset first quality judgment condition, the quantization parameter is reduced, and the coding unit to be coded is coded again according to the quality threshold, the size of the coding unit and the reduced quantization parameter until the coding result meets the preset first quality judgment condition. And when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the increased quantization parameter until the coding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the quality threshold, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, and obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition. Therefore, the embodiment of the invention can improve the coding efficiency and the compression rate of the coding and can meet the requirement of a specific application scene on the coding quality.
On the basis of fig. 1, as a preferred embodiment, referring to fig. 2, fig. 2 is another flowchart of an adaptive quantization parameter-based coding method according to an embodiment of the present invention, including the following steps:
in step 201, a quantization parameter of a coding unit to be coded is obtained.
In the embodiment of the present invention, the quantization parameter may be a preset value, or a value obtained by using another quantization parameter determination method, such as a setting method using a fixed QP for each frame, or a method of determining an initial QP for each frame according to a preset code rate control method, and further determining a QP for each unit to be encoded. Therefore, the embodiment of the invention can be used independently, and can also be connected with other quantization parameter determination methods to carry out video image coding.
Step 202, according to a preset quality threshold, a preset size of the coding unit, and a quantization parameter, coding the coding unit to be coded to obtain a coding result of the coding unit to be coded, where the coding result includes a plurality of quality values.
The quality threshold value in the embodiment of the invention is introduced in a quality subjective model mode, wherein the subjective model needs to be reasonably selected according to the application scene and the use requirement of the video image.
The conventional coding method is generally called a hybrid coding method, and mainly comprises the following steps:
the first step is predictive coding, namely, a reference coding unit of a coding unit to be coded is obtained by using a coded historical frame image corresponding to a frame image where the coding unit to be coded is located.
Known from the existing knowledge of video images, a video image is divided into multiple frames, one frame of video image can be divided into multiple coding units for video coding, if the current video image to be coded is the 5 th frame, a reference image of the video image of the 5 th frame can be obtained by using the coded video image of the previous 4 frames, the reference image of the video image of the 5 th frame includes multiple reference coding units, wherein the reference coding unit corresponding to the coding unit to be coded in the 5 th frame may be a coding unit in any frame of the video image of the previous 4 frames.
And secondly, transforming and coding, namely obtaining a difference value between a coding unit to be coded and a pixel point of a reference coding unit, and performing discrete cosine transform on the difference value to obtain frequency domain data of the difference value.
The difference between the pixel points of the coding unit to be coded and the reference coding unit is generally called residual, transform coding transforms the residual to remove frequency domain correlation, transform coding transforms the image from a time domain signal to a frequency domain signal, and concentrates energy to a low frequency region.
And thirdly, quantizing and coding, namely acquiring a quantization step corresponding to the quantization parameter according to the relation between the preset quantization parameter and the quantization step, and quantizing the frequency domain data of the difference value by using the quantization step to obtain quantized data of a coding unit to be coded.
The quantization is to reduce the image coding length on the premise of not reducing the visual effect, reduce unnecessary information in visual recovery, quantize the transformed data by the quantization coding, can reduce the dynamic range of the image coding, reduce the data amount of the coding by representing the fine data by the coarser data, and can remove the visual redundancy in the video sequence to a certain extent. Quantization is generally divided into scalar quantization and vector quantization, and a common coding specification such as h.265 uses a scale quantizer to perform scalar quantization, uses a quantizer with 52 steps for quantization of transform residual coefficients, the quantization step size is increased by 12.5%, uses quantization parameters to index the quantization step size, and doubles the quantization step size every 6 increments of the quantization parameters, so that the corresponding coding quality is also reduced to some extent.
And fourthly, entropy coding, namely entropy coding the quantized data of the coding unit to be coded to obtain a coding result. Entropy coding is to encode the quantized data to remove coding redundancy. The encoding result comprises an encoded image and a plurality of quality values corresponding to the quality threshold.
Step 203, comparing the quality values with the quality threshold, reducing the quantization parameter by a first preset amount when one quality value does not meet a preset first quality judgment condition, and re-encoding the encoding unit to be encoded according to the quality threshold, the size of the encoding unit and the reduced quantization parameter until the encoding result meets the preset first quality judgment condition.
After the coding result is obtained, the embodiment of the present invention adjusts the quantization parameter according to the relationship between the coding result and the subjective model, and specifically, when there is a quality value that does not satisfy the preset first quality determination condition, the quantization parameter is decreased by the first preset number. And re-encoding according to the adjusted QP until the encoding result meets a preset first quality judgment condition. The first preset number is a numerical value set according to industrial requirements or manually, such as 1, 2 and the like.
The embodiment of the invention considers the limit of the subjective model in the encoding process, and avoids the condition that the encoding target does not meet the subjective model after the encoding is finished. But considering that within the same coded frame, too much difference in QP can lead to boundary effects. Therefore, according to the practical application scenario, the embodiment of the present invention limits the number of times of re-encoding the encoding unit to be encoded. That is, after step 203, the embodiment of the present invention further includes that the first counter counts up by one, and when the number of times counted by the first counter is greater than a preset first count value, a reminding instruction is sent, where the reminding instruction carries an encoding result corresponding to the last counting in the first counter. The first count value is a predetermined limit value of the number of recoding times, such as 3. According to the embodiment of the invention, different first counting values can be set according to actual scene requirements.
The method of the embodiment of the invention further comprises the step of making a decision on the reminding instruction, specifically, receiving a coding result corresponding to the last counting in the first counter, or stopping the coding, and the like.
And 204, when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset amount, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the increased quantization parameter until the coding result meets the first quality judgment condition and the second quality judgment condition.
As above, according to the practical application scenario, the embodiment of the present invention limits the number of encoding times for re-encoding the encoding unit to be encoded. That is, after step 204, the embodiment of the present invention further includes that the second counter counts up by one, and when the number of times counted by the second counter is greater than a preset second count value, a reminding instruction is sent, where the reminding instruction carries an encoding result corresponding to the last counting in the second counter. The second count value is a predetermined limit value of the number of recoding times, such as 2. According to the embodiment of the invention, different second counting values can be set according to actual scene requirements.
The method of the embodiment of the invention further comprises the step of making a decision on the reminding instruction, specifically, receiving a coding result corresponding to the last counting in the second counter, or stopping the coding, and the like.
Step 205, saving the coding result of the coding unit to be coded.
And after the coding result meets the first quality judgment condition and the second quality judgment condition, storing the coding result of the coding unit to be coded. Then, the embodiment of the present invention continues to perform the encoding process of the next encoding unit to be encoded, and repeats the above steps 201 to 205 until the encoding of all the encoding units to be encoded of the video image to be encoded is completed, and a complete encoding sequence is obtained, that is, a complete encoded video image is obtained.
In the encoding method based on the adaptive quantization parameter provided by the embodiment of the invention, in an encoding process, a preset quality threshold is added by using a subjective model, an encoding result of an encoding unit to be encoded is obtained, then a plurality of quality values in the encoding result are compared with the preset quality threshold, when one quality value does not meet a preset first quality judgment condition, the quantization parameter is reduced by a first preset amount, and the encoding unit to be encoded is encoded again according to the quality threshold, the size of the encoding unit and the reduced quantization parameter until the encoding result meets the preset first quality judgment condition. And when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset amount, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the increased quantization parameter until the coding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the subjective model, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition, code each coding unit to be coded by applying the method and the device, re-code the coding unit to be coded which has distortion which does not meet the quality judgment condition in time, and avoid the situation that all the coding units to be coded are re-coded due to larger distortion after the coding of all the coding units to be coded is finished. The embodiment of the invention ensures that the coding loss of the whole coding sequence is kept in a certain range by limiting the coding loss of the coding unit in the coding process, thereby improving the compression efficiency of the coding under the condition of meeting the subjective model. Therefore, the embodiment of the invention can improve the coding efficiency and the compression efficiency of the coding, and can meet the requirement of a specific application scene on the coding quality.
Referring to fig. 3, fig. 3 is a flowchart based on an example of the method shown in fig. 2, including:
step 301, obtain the QP of the coding unit to be coded.
Step 302, encoding the coding unit to be encoded according to the preset MAXMSD, the preset coding unit size and the preset QP, and obtaining an encoding result of the coding unit to be encoded, where the encoding result includes a plurality of MSDs.
In the embodiment of the present invention, the subjective model is an MSD model, specifically, the subjective model selects an MSD value with N × N blocks as a unit as a measurement criterion, where N is 4, and sets a maximum MSD allowed by an encoding result MSD to be 8, that is, an upper limit threshold MAXMSD of the MSD as a quality threshold is 8. The coding unit size is chosen to be 32x 32. N is a preset natural number, and different natural numbers, such as 8 and 16, may be set as required.
The embodiment of the invention can adopt an HEVC encoder and the like, and the encoding process is not described any more.
Step 303, comparing MSD and MAXMSD of all nxn blocks, and determining whether a preset first quality determination condition is that MSD is smaller than an upper threshold of MSD, that is, MSD < MAXMSD.
The encoding unit to be encoded comprises a plurality of nxn blocks, and the embodiment of the invention counts whether MSD and MAXMSD corresponding to all the nxn blocks in the encoding result meet the preset first quality judgment condition that MSD is less than MAXMSD.
If an MSD does not satisfy the preset first quality judgment condition, executing step 304, QP-1, and returning to execute step 302, and re-encoding the coding unit to be encoded according to the MAXMSD, the coding unit size and the reduced QP until the encoding result satisfies the preset first quality judgment condition.
If all MSD satisfy the preset first quality determination condition, step 305 is executed to determine whether the second quality determination condition is satisfied, that is, the difference between the upper threshold of MSD and MSD is smaller than the first preset difference, that is, MAXMSD-MSD is less than or equal to 3. Wherein the first predetermined difference value is 3. It should be noted that the first preset difference may be set to other values greater than 0 according to needs.
If an MSD does not satisfy the preset second quality judgment condition, step 306, QP +1 is executed, and the step 302 is returned to, and the coding unit to be coded is coded again according to the MAXMSD, the size of the coding unit and the added QP until the coding result satisfies the first quality judgment condition and the second quality judgment condition.
It should be noted that, in the embodiment of the present invention, the number of times of QP increase or decrease is still limited, the number of times of QP decrease does not exceed the first count value, and the number of times of QP increase does not exceed the second count value. In the embodiment of the present invention, the first count value is preferably 3, and the second count value is preferably 2.
If all MSDs satisfy the preset first quality determination condition and second quality determination condition, step 307 is executed to save the encoding result of the encoding unit to be encoded.
The coding method based on the self-adaptive quantization parameter, provided by the embodiment of the invention, is characterized in that a subjective model MSD is added in a coding process, a coding result of a coding unit to be coded is obtained, then a plurality of MSDs and MAXMSDs in the coding result are compared, when one MSD which does not meet a preset first quality judgment condition is MSD < MAXMSSD, QP-1 is coded again according to the MAXMSD, the size of the coding unit and the reduced QP until the coding result meets the preset first quality judgment condition. And when all MSDs meet the preset first quality judgment condition and one MSD does not meet the preset second quality judgment condition that the MAXMSD-MSD is less than or equal to 3, recoding the coding unit to be coded by the QP +1 according to the MAXMSD, the size of the coding unit and the increased QP until the coding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the subjective model MSD, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, and obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition. The embodiment of the invention ensures that the coding loss of the whole coding sequence is kept in a certain range by limiting the coding loss of the coding unit in the coding process, thereby improving the coding compression efficiency under the condition of meeting the MSD (maximum data rate) of a subjective model. Therefore, the embodiment of the invention can improve the coding efficiency and the compression efficiency of the coding, and can meet the requirement of a specific application scene on the coding quality.
Referring to fig. 4, fig. 4 is a flowchart based on another example of the method shown in fig. 2, including:
step 401, obtain the QP of the coding unit to be coded.
Step 402, encoding the coding unit to be encoded according to a preset MINPSR, a preset coding unit size and a preset QP, and obtaining an encoding result of the coding unit to be encoded, wherein the encoding result comprises a PSNR.
In the embodiment of the present invention, the subjective model used is a PSNR model, and the minimum PSNR allowed by the coding result PSNR is set to 39, that is, the lower limit threshold minnpsnr of the PSNR serving as the quality threshold is 39. The coding unit size is chosen to be 32x 32.
The embodiment of the invention can adopt an HEVC encoder and the like, and the encoding process is not described any more.
Step 303, comparing the PSNR with the minsnr, and determining whether the predetermined first quality determination condition is that the PSNR is greater than the lower threshold of the PSNR, that is, the PSNR > minsnr.
If the PSNR does not satisfy the preset first quality determination condition, step 404, QP-1 is performed, and step 402 is returned to, where the coding unit to be coded is coded again according to the minnpsnr, the coding unit size, and the reduced QP until the coding result satisfies the preset first quality determination condition.
If the PSNR satisfies the predetermined first quality determination condition, step 405 is executed to determine whether the second quality determination condition is satisfied, where a difference between the PSNR and the lower threshold of the PSNR is smaller than a second predetermined difference, that is, PSNR-minsnr is less than or equal to 2. Wherein the second predetermined difference value is 2. It should be noted that the second preset difference may be set to other values greater than 0 according to needs.
If the PSNR does not satisfy the preset second quality determination condition, step 406, QP +1 is executed, and the process returns to step 402, where the coding unit to be coded is coded again according to the minnpsnr, the coding unit size, and the increased QP until the coding result satisfies the first quality determination condition and the second quality determination condition.
It should be noted that, in the embodiment of the present invention, the number of times of QP increase or decrease is still limited, the number of times of QP decrease does not exceed the first count value, and the number of times of QP increase does not exceed the second count value. In the embodiment of the present invention, the first count value is preferably 3, and the second count value is preferably 2.
If the PSNR satisfies the preset first quality determination condition and the second quality determination condition, step 407 is executed to store the encoding result of the encoding unit to be encoded.
The coding method based on the adaptive quantization parameter, provided by the embodiment of the invention, is characterized in that a subjective model PSNR is added in a coding process, after a coding result of a coding unit to be coded is obtained, PSNR and MINPSR in the coding result are compared, when PSNR does not meet a preset first quality judgment condition that PSNR > MINPSNR, QP-1 is used for coding the coding unit to be coded again according to the MINPSR, the size of the coding unit and the reduced QP until the coding result meets the preset first quality judgment condition. And when the PSNR meets a preset first quality judgment condition and the PSNR does not meet a preset second quality judgment condition, namely PSNR-MINPSR is less than or equal to 2, coding the coding unit to be coded by the QP +1 again according to the MINPSR, the size of the coding unit and the increased QP until the coding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the subjective model PSNR, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, and obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition. The embodiment of the invention ensures that the coding loss of the whole coding sequence is kept in a certain range by limiting the coding loss of the coding unit in the coding process, thereby improving the coding compression efficiency under the condition of meeting the PSNR (subjective model). Therefore, the embodiment of the invention can improve the coding efficiency and the compression efficiency of the coding, and can meet the requirement of a specific application scene on the coding quality.
Referring to fig. 5, fig. 5 is a block diagram of an adaptive quantization parameter-based encoding apparatus according to an embodiment of the present invention, including:
an obtaining module 501, configured to obtain a quantization parameter of a coding unit to be coded.
The encoding module 502 is configured to encode the coding unit to be encoded according to a preset quality threshold, a preset coding unit size, and a quantization parameter, and obtain an encoding result of the coding unit to be encoded, where the encoding result includes a plurality of quality values.
The first determining module 503 is configured to compare the quality values with the quality threshold, reduce the quantization parameter when one quality value does not satisfy the preset first quality determining condition, and re-encode the encoding unit to be encoded according to the quality threshold, the size of the encoding unit, and the reduced quantization parameter until the encoding result satisfies the preset first quality determining condition.
The second determining module 504 is configured to, when all the quality values meet a preset first quality determining condition and one quality value does not meet a preset second quality determining condition, increase the quantization parameter, and re-encode the encoding unit to be encoded according to the quality threshold, the size of the encoding unit, and the increased quantization parameter until the encoding result meets the first quality determining condition and the second quality determining condition.
The coding device based on the adaptive quantization parameter, provided by the embodiment of the present invention, adds a preset quality threshold in a coding process, obtains a coding result of a coding unit to be coded, compares a plurality of quality values in the coding result with the preset quality threshold, reduces the quantization parameter when one quality value does not satisfy a preset first quality determination condition, and re-codes the coding unit to be coded according to the quality threshold, the size of the coding unit, and the reduced quantization parameter until the coding result satisfies the preset first quality determination condition. And when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the increased quantization parameter until the coding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the quality threshold, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, and obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition. Therefore, the embodiment of the invention can improve the coding efficiency and the compression rate of the coding and can meet the requirement of a specific application scene on the coding quality. It should be noted that, the apparatus according to the embodiment of the present invention is an apparatus applying the above-mentioned coding method based on adaptive quantization parameter, and all embodiments applying the above-mentioned coding method based on adaptive quantization parameter are applicable to the apparatus and can achieve the same or similar beneficial effects.
Referring to fig. 6, fig. 6 is another structural diagram of an adaptive quantization parameter-based encoding apparatus according to an embodiment of the present invention, including:
in this embodiment of the present invention, the encoding module 602 includes:
the prediction sub-module 6021 is configured to obtain a reference coding unit of the coding unit to be coded by using the coded historical frame image corresponding to the frame image in which the coding unit to be coded is located.
The transform submodule 6022 is configured to obtain a difference between the coding unit to be coded and a pixel point of the reference coding unit, and perform discrete cosine transform on the difference to obtain frequency domain data of the difference.
The quantization submodule 6023 is configured to obtain a quantization step corresponding to the quantization parameter according to a preset relationship between the quantization parameter and the quantization step, and quantize the frequency domain data of the difference by using the quantization step to obtain quantized data of the coding unit to be coded.
The entropy coding sub-module 6024 is configured to perform entropy coding on the quantized data of the coding unit to be coded, so as to obtain a coding result.
In this embodiment of the present invention, the first determining module 603 is specifically configured to:
when there is a quality value that does not satisfy a preset first quality determination condition, the quantization parameter is decreased by a first preset amount.
Correspondingly, the second determining module 604 is specifically configured to:
and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset quantity.
In this embodiment of the present invention, the first determining module 603 is further configured to:
and the first counter counts by one, and when the counting times of the first counter are greater than a preset first counting value, a reminding instruction is sent, wherein the reminding instruction carries a coding result corresponding to the last counting in the first counter.
In this embodiment of the present invention, the second determining module 604 is further configured to:
and the counting of the second counter is increased by one, and a reminding instruction is sent when the counting times of the second counter is greater than a preset second counting value, wherein the reminding instruction carries a coding result corresponding to the last counting in the second counter.
In the embodiment of the present invention, the apparatus further includes:
a saving module 605, configured to save the encoding result of the encoding unit to be encoded until the encoding result meets a preset first quality determination condition and a preset second quality determination condition.
In the embodiment of the present invention, the preset quality threshold is: and presetting an upper threshold of Mean Square Deviation (MSD) of pixels of the NxN blocks of the reconstructed image and the original image, wherein N is a preset natural number.
Accordingly, the mass values are: MSD corresponding to each of a plurality of NxN blocks into which a coding unit to be encoded is divided.
Correspondingly, the first quality determination condition is that MSD is smaller than an upper threshold of MSD, and the second quality determination condition is that a difference between the upper threshold of MSD and MSD is smaller than a first preset difference.
In the embodiment of the present invention, the preset quality threshold is: a lower threshold for peak signal-to-noise ratio (PSNR).
Accordingly, the mass values are: PSNR.
Correspondingly, the first quality determination condition is that the PSNR is greater than a lower threshold of the PSNR, and the second quality determination condition is that a difference between the PSNR and the lower threshold of the PSNR is smaller than a second preset difference.
The coding device based on the adaptive quantization parameter, provided by the embodiment of the present invention, adds a preset quality threshold in a coding process, obtains a coding result of a coding unit to be coded, compares a plurality of quality values in the coding result with the preset quality threshold, reduces the quantization parameter when one quality value does not satisfy a preset first quality determination condition, and re-codes the coding unit to be coded according to the quality threshold, the size of the coding unit, and the reduced quantization parameter until the coding result satisfies the preset first quality determination condition. And when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the increased quantization parameter until the coding result meets the first quality judgment condition and the second quality judgment condition.
Compared with the prior art that the quantization parameter of the coding unit to be coded is a fixed value in the coding process, the method and the device can adaptively change the quantization parameter of the coding unit to be coded according to the quality threshold, the first quality judgment condition and the second quality judgment condition, reduce the distortion of the coding unit to be coded, and obtain the coding result which ensures the coding quality and has higher compression efficiency under the limitation of the first quality judgment condition and the second quality judgment condition. Therefore, the embodiment of the invention can improve the coding efficiency and the compression rate of the coding and can meet the requirement of a specific application scene on the coding quality.
It should be noted that, the apparatus according to the embodiment of the present invention is an apparatus applying the above method, and all the above embodiments are applicable to the apparatus and can achieve the same or similar beneficial effects.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (16)

1. An adaptive quantization parameter based coding method, comprising:
obtaining a quantization parameter of a coding unit to be coded;
coding a coding unit to be coded according to a preset quality threshold, a preset coding unit size and the quantization parameter to obtain a coding result of the coding unit to be coded, wherein the coding result comprises a plurality of quality values;
comparing the quality value with the quality threshold, reducing the quantization parameter when one quality value does not meet a preset first quality judgment condition, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the reduced quantization parameter until the coding result meets the preset first quality judgment condition;
when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing a quantization parameter, and coding the coding unit to be coded again according to the quality threshold, the size of the coding unit and the increased quantization parameter until a coding result meets the first quality judgment condition and the second quality judgment condition; wherein the second quality determination condition is: the preset condition for determining the relationship between the quality number and the quality threshold includes a degree that the quality number is smaller than the quality threshold, or a degree that the quality number is larger than the quality threshold.
2. The method of claim 1, wherein encoding the coding unit to be encoded comprises:
acquiring a reference coding unit of a coding unit to be coded by using a coded historical frame image corresponding to a frame image where the coding unit to be coded is located;
acquiring a difference value between a coding unit to be coded and a pixel point of the reference coding unit, and performing discrete cosine transform on the difference value to obtain frequency domain data of the difference value;
obtaining a quantization step corresponding to a quantization parameter according to a preset relationship between the quantization parameter and the quantization step, and quantizing the frequency domain data of the difference value by using the quantization step to obtain quantized data of a coding unit to be coded;
and entropy coding the quantized data of the coding unit to be coded to obtain a coding result.
3. The method according to claim 1, wherein the reducing the quantization parameter when there is a quality value that does not satisfy a preset first quality determination condition comprises:
when one quality value does not meet a preset first quality judgment condition, reducing the quantization parameter by a first preset quantity;
correspondingly, when all the quality values satisfy a preset first quality judgment condition and one quality value does not satisfy a preset second quality judgment condition, increasing the quantization parameter includes:
and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset quantity.
4. The method of claim 3, wherein the quantization parameter is reduced by a first predetermined amount, and thereafter, the method further comprises:
the method comprises the steps that the counting of a first counter is increased by one, and when the counting times of the first counter are larger than a preset first counting value, a reminding instruction is sent, wherein the reminding instruction carries a coding result corresponding to the last counting in the first counter.
5. The method of claim 3, wherein the quantization parameter is increased by a first predetermined amount, and thereafter, the method further comprises:
and the counting of the second counter is increased by one, and a reminding instruction is sent when the counting times of the second counter is greater than a preset second counting value, wherein the reminding instruction carries a coding result corresponding to the last counting in the second counter.
6. The method according to claim 1, wherein the method further comprises, after the encoding result satisfies the preset first quality determination condition and the preset second quality determination condition:
and saving the coding result of the coding unit to be coded.
7. The method according to claim 1, wherein the preset quality threshold is:
an upper limit threshold value of a pixel mean square error (MSD) of an NxN block of a preset reconstructed image and an original image, wherein N is a preset natural number;
accordingly, the quality values are:
MSD corresponding to each of a plurality of NxN blocks into which a coding unit to be coded is divided;
correspondingly, the first quality determination condition is that MSD is smaller than an upper threshold of MSD, and the second quality determination condition is that a difference between the upper threshold of MSD and MSD is smaller than a first preset difference.
8. The method according to claim 1, wherein the preset quality threshold is:
a lower threshold of peak signal-to-noise ratio (PSNR);
accordingly, the quality values are:
the PSNR;
correspondingly, the first quality determination condition is that the PSNR is greater than a lower threshold of the PSNR, and the second quality determination condition is that a difference between the PSNR and the lower threshold of the PSNR is smaller than a second preset difference.
9. An apparatus for adaptive quantization parameter based coding, comprising:
the acquisition module is used for acquiring the quantization parameter of the coding unit to be coded;
the encoding module is used for encoding the encoding unit to be encoded according to a preset quality threshold, a preset encoding unit size and the quantization parameter to obtain an encoding result of the encoding unit to be encoded, wherein the encoding result comprises a plurality of quality values;
the first judgment module is used for comparing the quality value with the quality threshold, reducing the quantization parameter when one quality value does not meet a preset first quality judgment condition, and recoding the coding unit to be coded according to the quality threshold, the size of the coding unit and the reduced quantization parameter until a coding result meets the preset first quality judgment condition;
the second judging module is used for increasing the quantization parameter when all the quality values meet a preset first quality judging condition and one quality value does not meet a preset second quality judging condition, and recoding the coding unit to be coded according to the quality threshold, the size of the coding unit and the increased quantization parameter until a coding result meets the first quality judging condition and the second quality judging condition; wherein the second quality determination condition is: the preset condition for determining the relationship between the quality number and the quality threshold includes a degree that the quality number is smaller than the quality threshold, or a degree that the quality number is larger than the quality threshold.
10. The apparatus of claim 9, wherein the encoding module comprises:
the prediction submodule is used for acquiring a reference coding unit of the coding unit to be coded by utilizing a coded historical frame image corresponding to the frame image where the coding unit to be coded is located;
the transformation submodule is used for acquiring a difference value between a coding unit to be coded and a pixel point of the reference coding unit, and performing discrete cosine transformation on the difference value to acquire frequency domain data of the difference value;
the quantization submodule is used for acquiring a quantization step corresponding to a quantization parameter according to a preset relationship between the quantization parameter and the quantization step, and quantizing the frequency domain data of the difference value by using the quantization step to acquire quantized data of a coding unit to be coded;
and the entropy coding sub-module is used for entropy coding the quantized data of the coding unit to be coded to obtain a coding result.
11. The apparatus of claim 9, wherein the first determining module is specifically configured to:
when one quality value does not meet a preset first quality judgment condition, reducing the quantization parameter by a first preset quantity;
correspondingly, the second determination module is specifically configured to:
and when all the quality values meet a preset first quality judgment condition and one quality value does not meet a preset second quality judgment condition, increasing the quantization parameter by a first preset quantity.
12. The apparatus of claim 11, wherein the first determining module is further configured to:
the method comprises the steps that the counting of a first counter is increased by one, and when the counting times of the first counter are larger than a preset first counting value, a reminding instruction is sent, wherein the reminding instruction carries a coding result corresponding to the last counting in the first counter.
13. The apparatus of claim 11, wherein the second determining module is further configured to:
and the counting of the second counter is increased by one, and a reminding instruction is sent when the counting times of the second counter is greater than a preset second counting value, wherein the reminding instruction carries a coding result corresponding to the last counting in the second counter.
14. The apparatus of claim 9, further comprising:
and the storage module is used for storing the coding result of the coding unit to be coded until the coding result meets the preset first quality judgment condition and the preset second quality judgment condition.
15. The apparatus of claim 9, wherein the preset quality threshold is:
an upper limit threshold value of a pixel mean square error (MSD) of an NxN block of a preset reconstructed image and an original image, wherein N is a preset natural number;
accordingly, the quality values are:
MSD corresponding to each of a plurality of NxN blocks into which a coding unit to be coded is divided;
correspondingly, the first quality determination condition is that MSD is smaller than an upper threshold of MSD, and the second quality determination condition is that a difference between the upper threshold of MSD and MSD is smaller than a first preset difference.
16. The apparatus of claim 9, wherein the preset quality threshold is:
a lower threshold of peak signal-to-noise ratio (PSNR);
accordingly, the quality values are:
the PSNR;
correspondingly, the first quality determination condition is that the PSNR is greater than a lower threshold of the PSNR, and the second quality determination condition is that a difference between the PSNR and the lower threshold of the PSNR is smaller than a second preset difference.
CN201710130401.2A 2017-03-07 2017-03-07 Coding method and device based on self-adaptive quantization parameter Active CN108574841B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710130401.2A CN108574841B (en) 2017-03-07 2017-03-07 Coding method and device based on self-adaptive quantization parameter

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710130401.2A CN108574841B (en) 2017-03-07 2017-03-07 Coding method and device based on self-adaptive quantization parameter

Publications (2)

Publication Number Publication Date
CN108574841A CN108574841A (en) 2018-09-25
CN108574841B true CN108574841B (en) 2020-10-30

Family

ID=63576986

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710130401.2A Active CN108574841B (en) 2017-03-07 2017-03-07 Coding method and device based on self-adaptive quantization parameter

Country Status (1)

Country Link
CN (1) CN108574841B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109803146B (en) * 2019-04-04 2021-05-25 网易(杭州)网络有限公司 Method, apparatus, medium, and device for secondary compression of video
CN110298895A (en) * 2019-05-08 2019-10-01 平安科技(深圳)有限公司 Picture compression method, apparatus, equipment and storage medium based on artificial intelligence
CN110225340B (en) * 2019-05-31 2021-07-09 北京猿力未来科技有限公司 Control method and device for video coding, computing equipment and storage medium
CN113132728B (en) * 2019-12-31 2023-06-27 上海海思技术有限公司 Coding method and coder
CN114697656B (en) * 2020-12-31 2024-02-13 浙江宇视科技有限公司 Encoding method, encoding device, electronic equipment and medium
CN113115040A (en) * 2021-04-20 2021-07-13 上海交通大学 Visual lossless image compression method and device
CN116800967A (en) * 2022-03-15 2023-09-22 华为技术有限公司 Image coding method, device and equipment
CN115665425B (en) * 2022-11-16 2024-04-19 北极星云空间技术股份有限公司 Progressive picture transmission method suitable for satellite short message communication
CN116600106B (en) * 2023-05-18 2024-04-09 深圳聚源视芯科技有限公司 Image compression method and system capable of dynamically adjusting compression rate

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007086589A1 (en) * 2006-01-25 2007-08-02 Matsushita Electric Industrial Co., Ltd. Video transcoding with suppression on drift errors

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7260826B2 (en) * 2000-05-31 2007-08-21 Microsoft Corporation Resource allocation in multi-stream IP network for optimized quality of service
US8582647B2 (en) * 2007-04-23 2013-11-12 Qualcomm Incorporated Methods and systems for quality controlled encoding
CN101202912A (en) * 2007-11-30 2008-06-18 上海广电(集团)有限公司中央研究院 Method for controlling balanced code rate and picture quality code rate
CN101547349B (en) * 2009-04-27 2010-10-13 宁波大学 Method for controlling code rate of secondary AVS encoding of video signal
CN101895759B (en) * 2010-07-28 2011-10-05 南京信息工程大学 H.264 code rate control method
CN102685472B (en) * 2011-03-08 2014-11-05 华为技术有限公司 Method, device and system of data transmission
JP5988577B2 (en) * 2011-12-28 2016-09-07 キヤノン株式会社 Image coding apparatus, image coding method, and program
CN103124347B (en) * 2012-10-22 2016-04-27 上海大学 Vision perception characteristic is utilized to instruct the method for multiple view video coding quantizing process
CN102932641B (en) * 2012-11-13 2016-04-06 北京大学 A kind of constant-quality bit rate control method
CN104581157B (en) * 2015-01-26 2018-07-24 东南大学 JPEG2000 encoding region of interest methods based on pre-cut

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2007086589A1 (en) * 2006-01-25 2007-08-02 Matsushita Electric Industrial Co., Ltd. Video transcoding with suppression on drift errors

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
H.264/AVC中计算复杂度可调的快速模式选择算法;朱向军,朱善安;《中国图象图形学报》;20060930;第1210-1216页 *

Also Published As

Publication number Publication date
CN108574841A (en) 2018-09-25

Similar Documents

Publication Publication Date Title
CN108574841B (en) Coding method and device based on self-adaptive quantization parameter
EP3001885B1 (en) Region-of-interest aware video coding
KR101518358B1 (en) A buffer-based rate control exploiting frame complexity buffer level and position of intra frames in video coding
US8780972B2 (en) Methods and devices for data compression using offset-based adaptive reconstruction levels
US5892548A (en) Adaptive quantizer with modification of high frequency coefficients
US8218624B2 (en) Fractional quantization step sizes for high bit rates
US20200068200A1 (en) Methods and apparatuses for encoding and decoding video based on perceptual metric classification
US20150063461A1 (en) Methods and apparatuses for adjusting macroblock quantization parameters to improve visual quality for lossy video encoding
JPH08256335A (en) Apparatus and method for determining quantization parameter
US20100166075A1 (en) Method and apparatus for coding video image
WO2013115972A1 (en) Video coding using eye tracking maps
EP1516493B1 (en) A method and system for optimizing image sharpness during coding
Naccari et al. Intensity dependent spatial quantization with application in HEVC
KR100621003B1 (en) Decoding method of digital image data
CN116527909A (en) Method, apparatus, device, storage medium and program product for transmitting coding parameters
CN116982262A (en) State transition for dependent quantization in video coding
KR102020953B1 (en) Image Reencoding Method based on Decoding Data of Image of Camera and System thereof
KR101737006B1 (en) Method for fast transform coding based on perceptual quality and apparatus for the same
CN110430427B (en) SKIP mode coding result-based fast video coding decision method and system
EP2536144A1 (en) Method and device of lossy compress-encoding an image
US20200413105A1 (en) Metric driven adaptive processing for video encoders
CN116137658A (en) Video coding method and device
Chodisetti et al. H. 264 video coding artifacts: measurement and reduction of flickering
KR101533051B1 (en) Encoding method method using block quantization level based on block characteristic and system thereof
Wei et al. A Perceptual Rate-Distortion Based Quantization Level Adjustment Algorithm

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