CN116471405A - Encoding method, encoding device, electronic equipment and readable storage medium - Google Patents
Encoding method, encoding device, electronic equipment and readable storage medium Download PDFInfo
- Publication number
- CN116471405A CN116471405A CN202310582182.7A CN202310582182A CN116471405A CN 116471405 A CN116471405 A CN 116471405A CN 202310582182 A CN202310582182 A CN 202310582182A CN 116471405 A CN116471405 A CN 116471405A
- Authority
- CN
- China
- Prior art keywords
- quantization parameter
- quantization
- quantization step
- target
- determining
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000013139 quantization Methods 0.000 claims abstract description 438
- 230000006870 function Effects 0.000 claims description 91
- 230000000694 effects Effects 0.000 abstract description 17
- 238000004364 calculation method Methods 0.000 abstract description 4
- 230000005540 biological transmission Effects 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 238000004891 communication Methods 0.000 description 3
- 238000013507 mapping Methods 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 238000007906 compression Methods 0.000 description 2
- 230000006835 compression Effects 0.000 description 2
- 238000010295 mobile communication Methods 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000009466 transformation Effects 0.000 description 2
- 230000008094 contradictory effect Effects 0.000 description 1
- 238000013144 data compression Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 230000007717 exclusion Effects 0.000 description 1
- 230000010365 information processing Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000011002 quantification Methods 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
- H04N19/124—Quantisation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/42—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
-
- Y—GENERAL 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
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE 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/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The application provides an encoding method, an encoding device, electronic equipment and a readable storage medium. The method comprises the following steps: determining a first quantization parameter of the coding unit; determining a target quantization step according to the first quantization parameter and a quantization parameter-quantization step function; searching a standard comparison table according to the target quantization step length, and determining a second quantization parameter matched with the target quantization step length; the standard comparison table comprises a plurality of corresponding relations between a plurality of quantization step sizes and a plurality of quantization parameters; the coding unit is coded based on the second quantization parameter. According to the embodiment of the application, after the target quantization step is obtained through calculation based on the estimated first quantization parameter and the quantization parameter-quantization step function, the second quantization parameter corresponding to the target quantization step is obtained through searching the standard comparison table, fine adjustment of the quantization parameter is achieved, the second quantization parameter is used for encoding, and therefore the encoding effect of an image or video is improved.
Description
Technical Field
The present disclosure relates to the field of multimedia data transmission technology and the field of video encoding processing technology, and in particular, to an encoding method, an encoding device, an electronic device, and a readable storage medium.
Background
With the development of computer technology and video technology, more and more video coding standards are proposed, such as AV1 (Alliance for Open Media Video 1), HEVC (High Efficiency Video Coding ) and the like.
The encoding process includes compressing the image with a specific quantization step size to reduce unnecessary information in the image. The quantization step has a corresponding quantization parameter. In encoding, the image portions may be encoded by selecting appropriate quantization parameters. In the H.264/AVC standard, the quantization parameter and the quantization step size accord with a specific exponential function relation. In the AV1 standard, however, the quantization parameter and quantization step do not completely conform to an exponential function relationship.
Disclosure of Invention
The embodiment of the application provides an encoding method, an encoding device, an electronic device and a readable storage medium, so as to solve the problems of the related technology, and the technical scheme is as follows:
in a first aspect, an embodiment of the present application provides an encoding method, including:
determining a first quantization parameter of the coding unit;
determining a target quantization step according to the first quantization parameter and a quantization parameter-quantization step function;
searching a standard comparison table according to the target quantization step length, and determining a second quantization parameter matched with the target quantization step length; the standard comparison table comprises a plurality of corresponding relations between a plurality of quantization step sizes and a plurality of quantization parameters;
the coding unit is coded based on the second quantization parameter.
In a second aspect, an embodiment of the present application provides an encoding apparatus, including:
a first quantization parameter determination unit configured to determine a first quantization parameter of the encoding unit;
the target quantization step length determining unit is used for determining a target quantization step length according to the first quantization parameter and a quantization parameter-quantization step length function;
the second quantization parameter determining unit is used for searching a standard comparison table according to the target quantization step length and determining a second quantization parameter matched with the target quantization step length; the standard comparison table comprises a plurality of corresponding relations between a plurality of quantization step sizes and a plurality of quantization parameters;
and the coding unit is used for coding the coding unit based on the second quantization parameter.
In a third aspect, an embodiment of the present application provides an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the encoding method described above.
In a fourth aspect, embodiments of the present application provide a computer-readable storage medium storing computer instructions that, when executed on a computer, perform a method according to any one of the above-described embodiments.
According to the embodiment of the application, after the target quantization step is obtained through calculation based on the estimated first quantization parameter and the quantization parameter-quantization step function, the second quantization parameter corresponding to the target quantization step is obtained through searching the standard comparison table, fine adjustment of the quantization parameter is achieved, the second quantization parameter is used for encoding, and therefore the encoding effect of an image or video is improved.
The foregoing summary is for the purpose of the specification only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the present application will become apparent by reference to the drawings and the following detailed description.
Drawings
In the drawings, the same reference numerals refer to the same or similar parts or elements throughout the several views unless otherwise specified. The figures are not necessarily drawn to scale. It is appreciated that these drawings depict only some embodiments according to the disclosure and are not therefore to be considered limiting of its scope.
FIG. 1 schematically illustrates an operational environment diagram of an encoding method according to an embodiment of the present application;
FIG. 2 schematically illustrates a flow chart of an encoding method according to an embodiment of the present application;
FIG. 3 schematically illustrates a block diagram of an encoding apparatus according to an embodiment of the present application;
fig. 4 schematically shows a hardware architecture diagram of a computer device according to an embodiment of the present application.
Detailed Description
Hereinafter, only certain exemplary embodiments are briefly described. As will be recognized by those of skill in the pertinent art, the described embodiments may be modified in various different ways without departing from the spirit or scope of the present application. Accordingly, the drawings and description are to be regarded as illustrative in nature and not as restrictive.
It should be noted that the descriptions of "first," "second," etc. in the embodiments of the present application are for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be regarded as not exist and not within the protection scope of the present application.
In the description of the present application, it should be understood that the numerical references before the steps do not identify the order of performing the steps, but are only used for convenience in describing the present application and distinguishing each step, and thus should not be construed as limiting the present application.
When multimedia data such as video and the like are communicated and transmitted, the multimedia data needs to be encoded firstly so as to realize data compression and facilitate transmission; and decoding the compressed multimedia data when the receiving end receives the compressed multimedia data, so as to play or display the multimedia data.
Among many coding schemes, a double coding method of pre-analysis and main coding with high coding efficiency becomes one of the more ideal coding schemes of video. Pre-analysis is to adjust the Quantization Parameters (QP) of portions of an image by evaluating the effect of the portions on the overall encoding before entering the main encoding flow. The main coding is to code the corresponding image unit according to the adjusted quantization parameter.
Related terms referred to in this application are explained first below:
AV1 (Alliance for Open Media Video 1): is a royalty-free video coding standard developed by AOM (Alliance for Open Media, open media alliance). Depending on the use case, AV1 may achieve higher compression efficiency than VP9 and H.264/AVC.
H.264/AVC: an international standard for video coding developed jointly by ITU-t T, ISO.
x264: a video encoder based on the H.264/AVC standard.
h.265/HEVC (High Efficiency Video Coding): an international standard for video coding developed jointly by ITU-t T, ISO.
x265: a video encoder based on the h.265/HEVC standard.
Quantification: refers to a process of mapping a continuous value (or a large number of possible discrete values) of a signal to a finite number of discrete values, a many-to-one mapping. In the video coding process, after the residual signal is transformed, the transformation coefficient usually has a larger range, so that the quantization of the transformation coefficient can effectively reduce the signal value space, and further, a proper bit rate is obtained. But due to the many-to-one mapping nature, the quantization process inevitably introduces data loss. Quantization is an important source of video distortion in video coding.
Quantization step size (Qstep: quantization step): qstep reflects the compression of spatial detail. The smaller the Qstep value, the finer the quantization, the higher the image quality and the longer the resulting code stream. If Qstep is small, most of the details will be preserved; qstep increases and some of the details may be lost, but the code rate may decrease.
Quantization parameter (QP: quantization Parameter): in most current video coding, QP is typically a reference number reflecting the quantization step size used, typically taking a non-negative integer value. The larger the quantization step size in general, the larger the corresponding QP.
For the convenience of understanding the technical solutions provided in the embodiments of the present application by those skilled in the art, the following description will explain related technologies:
the encoder is used for realizing the encoding of the multimedia data. Common video encoders include x264 encoders based on the h.264/AVC standard, and x265 encoders based on the h.265/HEVC standard, among others. Encoders based on the AV1 standard are a new class of encoders. The encoder obtains quantization parameters when encoding, each quantization parameter having a corresponding quantization step, so as to encode with a quantization step corresponding to the quantization parameter.
In the H.264/AVC standard and the H.265/HEVC standard, the exponential relationship between the quantization parameter and the quantization step size is satisfied:
where c is a constant, qstep is a quantization step, and QP is a quantization parameter.
Common encoders based on H.264/AVC and H.265/HEVC, such as x264 and x265, can estimate quantization parameters accurately by using an mbtree or a cut algorithm based on the exponential relation, so that a good coding effect can be obtained. In the AV1 standard, however, the quantization step size and the quantization parameter do not completely satisfy the exponential relationship. Therefore, when the quantization parameter is estimated directly using the existing method of the dependent exponential relationship, the desired quantization step may have an error from the quantization step used in the actual encoding, resulting in an undesirable encoding effect. Therefore, the present application provides a coding method and a corresponding coding device, which aim to obtain more accurate quantization parameters for coding when AV1 standard coding is adopted, so as to improve coding effect. The coding device may be a device module in the encoder to adopt the coding method improved by the embodiments of the present application when coding.
Exemplary application environments for the present application are provided below, for example, as may be used in a computer device.
The computer device may be configured to access the content (e.g., video) and services of the server 2.
The computer devices may include electronic devices 6 that carry or circumscribe a display panel, such as mobile devices, tablet devices, laptop computers, workstations, virtual reality devices, gaming devices, digital streaming media devices, vehicle user terminals, smart televisions, set top boxes, etc., as well as virtualized computing instances. Wherein virtualized computing instances may comprise virtual machines, such as emulation of computer systems, operating systems, servers, etc.
The computer device may be associated with one or more users. A single user may also use one or more of the computer devices to access the server. The computer device may travel to various locations and access the server using a different network 4. Wherein the computer device may comprise a plurality of client programs, such as: and the video coder-decoder is used for providing coding and decoding services. The video codec can compress the video or the image in a coding way so as to facilitate the transmission or the storage of the video or the image.
Hereinafter, various embodiments will be provided in the above-described exemplary application environments to explain the technical solutions of the present application.
Fig. 2 shows a flow chart of an encoding method according to an embodiment of the present application. As shown in fig. 2, the encoding method may include:
s210, determining a first quantization parameter of the coding unit.
Multimedia data such as images or video. The video comprises continuous and dynamic multi-frame images, and each frame of image is coded, so that the video is coded, and compressed video data is obtained and used for transmission. Meanwhile, one image or a plurality of images also comprise a plurality of image blocks, and the image can be divided into a plurality of image blocks according to a preset strategy, and each image block is respectively encoded to obtain compressed image data. Wherein one image block may be one encoding unit.
The first quantization parameter of the coding unit may be a predicted quantization parameter obtained according to a reference or comparison of the reference image block and the present image block. The estimated quantization parameter may be determined based on a particular quantization step required for encoding. The reference image block may be other image blocks of the current image or may be similar image blocks between adjacent image frames.
In one image, the multiple image blocks may be distinguished by equal areas, or may be distinguished by different areas according to the specific content of the image. For example, a portion of the background region may be divided into a plurality of larger image blocks and a portion of the main region may be divided into a plurality of smaller image blocks. The distinction of image blocks may be performed using existing or future possible technical solutions by those skilled in the art.
The first quantization parameter for determining the coding unit may be obtained using an mbtree method or a cut method. These two methods are methods for obtaining quantization parameters commonly used for x264 and x265 encoders, respectively.
S220, determining a target quantization step according to the first quantization parameter and the quantization parameter-quantization step function.
The quantization parameter-quantization step function is used for representing the correspondence between a plurality of quantization parameters and a plurality of quantization step sizes, that is, the correspondence between a plurality of quantization parameters and a plurality of quantization step sizes is represented in a function form.
The exponential relationship is satisfied between the quantization parameters and quantization step sizes in the H.264/AVC standard and the H.265/HEVC standard. Therefore, by adopting an mbtree or cut method based on an exponential relationship, the predicted quantization parameter will be more accurate, and the quantization step used by the encoder in encoding is the quantization step expected in predicting the quantization parameter. In the AV1 standard, the quantization parameter-quantization step function may be a function relationship obtained by fitting a plurality of corresponding relationships between quantization parameters and quantization steps in a lookup table according to the AV1 standard, so as to represent the corresponding relationship between quantization parameters and quantization steps of the AV1 standard.
In this embodiment of the present application, the first quantization parameter is a predicted quantization parameter, and the predicted quantization parameter represents a target quantization step size expected during encoding. The target quantization step size can be obtained by substituting the first quantization parameter into the quantization parameter-quantization step size function.
S230, searching a standard comparison table according to the target quantization step length, and determining a second quantization parameter matched with the target quantization step length; the standard comparison table comprises a corresponding relation between a plurality of quantization step sizes and a plurality of quantization parameters.
Since the quantization parameter-quantization step function is a fitted function, there must be some discrete points that do not fall exactly on the fitted curve.
Based on the above, in the embodiment of the present application, the target quantization step is matched from the standard lookup table, so as to obtain the quantization parameter that best matches the target quantization step, thereby implementing fine adjustment of the quantization parameter, implementing encoding with more accurate quantization parameter, and improving encoding effect.
In one example, differences may be calculated between a plurality of real quantization steps in the standard lookup table and the target quantization step, and a quantization parameter corresponding to a quantization step with the smallest difference may be determined as the second quantization parameter.
S240, encoding the encoding unit based on the second quantization parameter.
The second quantization parameter is a quantization parameter obtained by fine adjustment based on the real corresponding relation of the AV1 standard, and the corresponding quantization step length is more in line with the quantization step length expected by the expected coding effect, so that the obtained coding effect is good by coding with the second quantization parameter.
According to the embodiment of the application, after the target quantization step is obtained through calculation based on the estimated first quantization parameter and the quantization parameter-quantization step function, the second quantization parameter corresponding to the target quantization step is obtained through searching the standard comparison table, fine adjustment of the quantization parameter is achieved, and coding is carried out through the second quantization parameter, so that a better coding effect can be obtained.
In one embodiment, the encoding method further comprises: and performing data fitting based on the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the standard comparison table to obtain the quantization parameter-quantization step size function.
In the standard comparison table, one quantization parameter corresponds to one quantization step. The quantization parameter is a sequence number representing a corresponding quantization step, so the quantization parameter is used to identify the quantization step, and the value actually used in encoding is the quantization step, except that the encoder determines the quantization step corresponding to the quantization parameter according to the correspondence defined by the encoding standard.
Assuming that the quantization parameter is the horizontal axis and the quantization step is the vertical axis in one coordinate system, the data in the standard lookup table indicates that there are a plurality of discrete points in the coordinate system. Fitting the discrete points into a curve, and obtaining an expression of the curve, wherein the quantization parameter-quantization step function obtained by fitting is obtained.
The fitted quantization parameter-quantization step function may be used to approximate the relationship between quantization parameter and quantization step in the AV1 standard, but there is still some deviation in practice. Therefore, in the embodiment of the present application, the target quantization step size is obtained through the functional relationship, and the second quantization parameter is obtained by looking up the table, so as to adjust the deviation, so that the obtained second quantization parameter meets the coding requirement more accurately.
In one embodiment, when determining the first quantization parameter of the coding unit, the fitting may be performed according to the quantization parameter-quantization step function, so that the target quantization step corresponding to the first quantization parameter obtained by prediction is more accurate, and the second quantization parameter obtained by prediction is also more accurate, so as to further improve the coding effect.
In the embodiment of the application, the first quantization parameter is determined by fitting the obtained quantization parameter-quantization step function, the quantization parameter is adjusted, the second quantization parameter is determined, and finally the second quantization parameter is used for encoding. When the encoder adopts AV1 standard coding, the dependence of the existing estimation method on the exponential function relation can be eliminated.
In one embodiment, the encoding method further comprises:
obtaining a preset quantization parameter range;
and according to the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the quantization parameter range in the standard comparison table, performing data fitting to obtain the quantization parameter-quantization step size function.
In this embodiment of the present application, the preset quantization parameter range may be manually configured. The quantization parameter range can be configured according to the coding requirement, so that the encoder codes according to certain requirements. For example, in the case where the picture obtained by the encoding is required to be clearer, a quantization parameter range having a smaller value, for example, a quantization parameter range of (1-30) may be set, which indicates that the picture obtained by the encoding is required to be high in quality, and a certain code rate is sacrificed. As another example, a quantization parameter range of (50-120) may be set, indicating that the image quality requirements obtained by the encoding are somewhat lower, but a lower code rate is desirable.
In the embodiment of the application, assuming that the quantization parameter range is configured to be (1-100), data fitting can be performed by using a plurality of quantization step values of the quantization parameter in (1-100), so that the quantization parameter-quantization step function obtained by fitting is more accurate, and the error between the calculated quantization step function value and the quantization step actual value is smaller. The function obtained by fitting the small-range data is used, the determined second quantization parameter is more accurate, and the coding effect can be further improved.
In one example, when the quantization parameter range is configured to be (1-100), if the obtained first quantization parameter exceeds the boundary value, for example, 110, the encoding may be performed with the maximum boundary value 100 of the quantization parameter range, so that the overall encoding effect is uniform, and the desired encoding effect is satisfied.
In an example, when the quantization parameter range is configured to be (1-100), the obtained first quantization parameter exceeds the boundary value, for example, 110, and the first quantization parameter is 110, and the quantization parameter-quantization step function is adjusted to a function obtained by fitting the quantization parameter range, so as to obtain the second quantization parameter.
According to the embodiment of the application, the quantization parameter range is configured, the fitting is carried out by using a plurality of quantization step data in the quantization parameter range, and the fitting function is obtained, so that the effect is better when the function obtained by fitting is encoded in a certain range.
The quantization parameter range may be configured according to experience history data, for example, quantization parameters that are not used frequently may be avoided. As an example, the quantization parameter range that is usually used in encoding is (50-125), considering that in the case where the quantization parameter is usually less than 50, the picture quality is good, but the code rate is too high, which affects the transmission; under the condition that the quantization parameter is larger than 125, the code rate is low, but the picture quality is fuzzy and difficult to use; therefore, the quantization parameter range can be configured to be (50-125), and then the data fitting is carried out by a plurality of quantization step sizes in (50-125) independently, so that the fitting function is more accurate.
In one embodiment, the encoding method further comprises:
obtaining a preset multi-section quantization parameter range;
for each section of quantization parameter range, respectively carrying out data fitting based on the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the quantization parameter range; a plurality of quantization parameter-quantization step functions corresponding to the plurality of segments of quantization parameter ranges are obtained.
In the embodiment of the application, by configuring multiple segments of quantization parameter ranges, fitting functions are obtained for each segment of quantization parameter range, so that multiple fitting functions are obtained. In the case of use, a fitting function to be used may be determined for the first quantization parameter, and then the second quantization parameter may be obtained by adjusting the fitting function to be used to perform encoding.
The configuration of the multi-segment quantization parameter range may be configured according to the distribution of discrete points. For example, in the case where the points of the quantization parameter range (51-100) are approximately smooth curves, and the inflection points or trends appear to be greatly different from those of the curves (51-100) from 101, the quantization parameter range (51-100) may be configured as a segment. If 101 starts, if no inflection point appears later, (101-255) is taken as a quantization parameter range. Therefore, the obtained fitting function curve is closer to the real corresponding relation in a segmentation mode, and the fitting function is more accurate.
Configuring the multi-segment quantization parameter range may also be configured according to coding requirements. For example, if the coding effect is desired to be better when the quantization parameter range is (25-100), and the coding effect requirement is not high when the quantization parameter range is (1-24) or (101-255), the data fitting can be performed by taking (25-100) as a section of the quantization parameter range to obtain a first fitting function; and (3) taking (1-255) as a section of quantization parameter range, and performing data fitting once to obtain a second fitting function. In the event that the first quantization parameter falls within (25-100), adjusting with a first fitting function; in the event that the first quantization parameter does not fall within (25-100), the adjustment is performed with a second fitting function.
According to the embodiment of the application, the multi-section data fitting is performed by configuring the multi-section quantization parameter ranges, so that a user can adjust quantization parameters according to actual coding requirements, and various requirements of the user are met.
In one embodiment, the determining the target quantization step according to the first quantization parameter and a quantization parameter-quantization step function includes:
determining a target quantization parameter range within which the first quantization parameter falls according to the first quantization parameter;
and determining a target quantization step according to the quantization parameter-quantization step function corresponding to the target quantization parameter range and the first quantization parameter.
In the above example, in the case that the multi-segment quantization parameter range includes (25-100) and (1-255), the first quantization parameter is 120, and then the target quantization parameter range that falls into is (1-255), and the quantization parameter is adjusted by using the second fitting function. In the case that the first quantization parameter is 40, the range of the target quantization parameter is (25-100), and the quantization parameter is adjusted by the first fitting function.
In one embodiment, performing data fitting according to a correspondence between a plurality of quantization parameters and a plurality of quantization steps includes:
determining the quantization parameter-quantization step function as an exponential function, wherein the exponent power of the exponential function is a quantization parameter; the exponential function comprises two constant terms, one of which is a base of the exponential function and the other of which is a coefficient of the exponential function;
and under the condition that the error value of the quantization step length accords with a preset condition, determining the two constant items, wherein the error value is an absolute value error or standard deviation between the quantization step length true value of the standard comparison table and the quantization step length function value of the exponential function. Based on the trend of the discrete curve, the quantization parameter-quantization step function of the embodiments of the present application may be fitted in the form of an exponential function.
In one example, the fitting may be performed using the following exponential function form:
Qstep=s·t QP
where s and t are constant terms. t is a base number, and t is greater than 0 and not equal to 1.s is a coefficient.
In one example, the fitting function is obtained by calculating an error between a quantization step size true value and a quantization step size function value corresponding to a plurality of quantization parameters, and determining two constant terms s and t if the error meets a preset condition.
The error values of the quantization step meet the preset condition, and the error values of the quantization step can meet the preset threshold range, for example, the preset threshold range of the error value is (-1.019,1.019), and two constant items can be determined.
The error value of the quantization step length accords with a preset condition, and the fitting function is determined to be the final fitting function under the condition that the calculated error value sum is the smallest in error value sums in multiple fitting.
In this embodiment of the present application, the exponential function form adopted may also be other forms, and the constant term may also include a plurality of constant terms, and may be selected for use according to specific application situations. For example, the exponent power may be (QP-c)/d or the like. c and d are constant terms.
The embodiment of the application adopts an exponential function form to fit the data in the standard comparison table, and can be more conveniently applied to the situation of determining the first quantization parameter or determining the second quantization parameter.
In one embodiment, the relationships between the multiple segments of quantization parameter ranges include inclusion relationships and/or mutually exclusive relationships;
the determining, according to the first quantization parameter, a target quantization parameter range within which the first quantization parameter falls, includes:
respectively obtaining the difference value between the boundary value of the multi-section quantization parameter range and the first quantization parameter;
and when the absolute value of the difference value is minimum, the corresponding quantization parameter range is the target quantization parameter range.
For example, in the case where the multi-segment quantization parameter range includes (25-100) and (1-255), the quantization parameter ranges at both ends thereof are in an inclusion relationship.
As another example, in the case where the multi-segment quantization parameter range includes (12-50), (51-100), (101-180), and (1-255), then both inclusion and exclusion relationships are included.
In the case of obtaining the first quantization parameter, a target quantization parameter range is determined by calculating differences between the first quantization parameter and boundary values of the plurality of pieces of quantization parameter ranges, respectively.
For example, if the first quantization parameter is 55, the value of the boundary difference 55-51=4 between the first quantization parameter and the second quantization parameter range (51-100) is the smallest, and if the target quantization parameter range within which the first quantization parameter 55 falls is determined to be (51-100), the first quantization parameter is adjusted by using a fitting function corresponding to (51-100).
Fig. 3 shows a block diagram of an encoding apparatus 300 according to an embodiment of the present application. As shown in fig. 3, the encoding apparatus 300 may include:
a first quantization parameter determining unit 310 for determining a first quantization parameter of the encoding unit;
a target quantization step size determining unit 320, configured to determine a target quantization step size according to the first quantization parameter and a quantization parameter-quantization step size function;
a second quantization parameter determining unit 330, configured to find a standard lookup table according to the target quantization step, and determine a second quantization parameter that matches the target quantization step; the standard comparison table comprises a plurality of corresponding relations between a plurality of quantization step sizes and a plurality of quantization parameters;
an encoding unit 340, configured to encode the encoding unit based on the second quantization parameter.
In one embodiment, the encoding apparatus 300 further includes:
and the fitting unit is used for carrying out data fitting based on the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the standard comparison table to obtain the quantization parameter-quantization step size function.
In one embodiment, the encoding apparatus 300 further includes:
the first configuration unit is used for obtaining a preset quantization parameter range;
and the fitting unit is used for carrying out data fitting according to the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the quantization parameter range in the standard comparison table, so as to obtain the quantization parameter-quantization step size function.
In one embodiment, the encoding apparatus 300 further includes:
the second configuration unit is used for obtaining a preset multi-section quantization parameter range;
the fitting unit is used for performing data fitting on each section of quantization parameter range based on the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the quantization parameter range; a plurality of quantization parameter-quantization step functions corresponding to the plurality of segments of quantization parameter ranges are obtained.
In one embodiment, the target quantization step size determination unit is configured to:
determining a target quantization parameter range within which the first quantization parameter falls according to the first quantization parameter;
and determining a target quantization step according to the quantization parameter-quantization step function corresponding to the target quantization parameter range and the first quantization parameter.
In one embodiment, the fitting unit is for:
determining the quantization parameter-quantization step function as an exponential function, wherein the exponent power of the exponential function is a quantization parameter; the exponential function comprises two constant terms, one of which is a base of the exponential function and the other of which is a coefficient of the exponential function;
and under the condition that the error value of the quantization step length accords with a preset condition, determining the two constant items, wherein the error value is an absolute value error or standard deviation between the quantization step length true value of the standard comparison table and the quantization step length function value of the exponential function.
In one embodiment, the relationships between the multiple segments of quantization parameter ranges include inclusion relationships and/or mutually exclusive relationships;
the target quantization step size determination unit is further configured to:
respectively obtaining the difference value between the boundary value of the multi-section quantization parameter range and the first quantization parameter;
and when the absolute value of the difference value is minimum, the corresponding quantization parameter range is the target quantization parameter range.
The functions of each module in each apparatus of the embodiments of the present application may be referred to the corresponding descriptions in the above methods, which are not described herein again.
Fig. 4 schematically shows a hardware architecture diagram of a computer device 400 adapted to implement a video encoding method according to a third embodiment of the present application. The computer device 400 may be part of the server 2 or the electronic device 6. In this embodiment, the computer device 400 is a device capable of automatically performing numerical calculation and/or information processing in accordance with instructions set or stored in advance. For example, it may be a smart phone, tablet, laptop, personal computer, virtual device, set top box, television, projector, car terminal, headset, etc. In other embodiments, the computer device 400 may be a rack server, a blade server, a tower server, or a rack server (including a stand-alone server, or a server cluster composed of multiple servers), or the like. As shown in fig. 4, the computer device 400 includes at least, but is not limited to: memory 410, processor 420, and network interface 430 may be communicatively linked to each other via a system bus.
Wherein:
the memory 410 includes at least one type of computer-readable storage medium including flash memory, hard disk, multimedia card, card memory (e.g., SD or DX memory, etc.), random Access Memory (RAM), static Random Access Memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 410 may be an internal storage module of the computer device 400, such as a hard disk or memory of the computer device 400. In other embodiments, the memory 410 may also be an external storage device of the computer device 400, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card) or the like, which are provided on the computer device 400. Of course, the memory 410 may also include both internal memory modules of the computer device 400 and external memory devices. In this embodiment, the memory 410 is typically used to store an operating system and various types of application software installed on the computer device 400, such as program codes of an encoding method, and the like. In addition, the memory 410 may also be used to temporarily store various types of data that have been output or are to be output.
The processor 420 may be a central processing unit (Central Processing Unit, simply CPU), controller, microcontroller, microprocessor, or other data processing chip in some embodiments. The processor 420 is generally used to control the overall operation of the computer device 400, such as performing control and processing related to data interaction or communication with the computer device 400, and the like. In this embodiment, the processor 420 is used to execute program code or process data stored in the memory 410.
The network interface 430 may include a wireless network interface or a wired network interface, the network interface 430 typically being used to establish a communication link between the computer device 400 and other computer devices. For example, the network interface 430 is used to connect the computer device 400 to an external terminal through a network, establish a data transmission channel and a communication link between the computer device 400 and the external terminal, and the like. The network may be a wireless or wired network such as an Intranet (Intranet), the Internet (Internet), a global system for mobile communications (Global System of Mobile communication, abbreviated as GSM), wideband code division multiple access (Wideband Code Division Multiple Access, abbreviated as WCDMA), a 4G network, a 5G network, bluetooth (Bluetooth), wi-Fi, etc.
It should be noted that FIG. 4 only shows a computer device having components 410-430, but it should be understood that not all of the illustrated components are required to be implemented and that more or fewer components may be implemented instead.
In this embodiment, the encoding method stored in the memory 410 may also be divided into one or more program modules and executed by one or more processors (the processor 420 in this embodiment) to complete the embodiments of the present application.
The present application also provides a computer-readable storage medium having stored therein computer instructions which, when executed by a processor, implement the steps of the encoding method in the embodiments.
In this embodiment, the computer-readable storage medium includes a flash memory, a hard disk, a multimedia card, a card memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the computer readable storage medium may be an internal storage unit of a computer device, such as a hard disk or a memory of the computer device. In other embodiments, the computer readable storage medium may also be an external storage device of a computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash Card (Flash Card), etc. that are provided on the computer device. Of course, the computer-readable storage medium may also include both internal storage units of a computer device and external storage devices. In this embodiment, the computer readable storage medium is typically used to store an operating system and various types of application software installed on a computer device, such as program codes of the encoding method in the embodiment, and the like. Furthermore, the computer-readable storage medium may also be used to temporarily store various types of data that have been output or are to be output.
It will be apparent to those skilled in the art that the modules or steps of the embodiments of the application described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, they may alternatively be implemented in program code executable by computing devices, so that they may be stored in a storage device for execution by computing devices, and in some cases, the steps shown or described may be performed in a different order than what is shown or described, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps of them may be fabricated into a single integrated circuit module. Thus, embodiments of the present application are not limited to any specific combination of hardware and software.
It should be noted that the foregoing is only a preferred embodiment of the present application, and is not intended to limit the scope of the patent protection of the present application, and all equivalent structures or equivalent processes using the descriptions and the contents of the present application or direct or indirect application to other related technical fields are included in the scope of the patent protection of the present application.
Claims (10)
1. A method of encoding, comprising:
determining a first quantization parameter of the coding unit;
determining a target quantization step according to the first quantization parameter and a quantization parameter-quantization step function;
searching a standard comparison table according to the target quantization step length, and determining a second quantization parameter matched with the target quantization step length; the standard comparison table comprises a plurality of corresponding relations between a plurality of quantization step sizes and a plurality of quantization parameters;
the coding unit is coded based on the second quantization parameter.
2. The method as recited in claim 1, further comprising:
and performing data fitting based on the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the standard comparison table to obtain the quantization parameter-quantization step size function.
3. The method as recited in claim 1, further comprising:
obtaining a preset quantization parameter range;
and according to the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the quantization parameter range in the standard comparison table, performing data fitting to obtain the quantization parameter-quantization step size function.
4. The method as recited in claim 1, further comprising:
obtaining a preset multi-section quantization parameter range;
for each section of quantization parameter range, respectively carrying out data fitting based on the corresponding relation between a plurality of quantization parameters and a plurality of quantization step sizes in the quantization parameter range; a plurality of quantization parameter-quantization step functions corresponding to the plurality of segments of quantization parameter ranges are obtained.
5. The method of claim 4, wherein said determining a target quantization step based on said first quantization parameter and a quantization parameter-quantization step function comprises:
determining a target quantization parameter range within which the first quantization parameter falls according to the first quantization parameter;
and determining a target quantization step according to the quantization parameter-quantization step function corresponding to the target quantization parameter range and the first quantization parameter.
6. The method of any one of claims 2 to 5, wherein performing data fitting based on correspondence between a plurality of quantization parameters and a plurality of quantization steps comprises:
determining the quantization parameter-quantization step function as an exponential function, wherein the exponent power of the exponential function is a quantization parameter; the exponential function comprises two constant terms, one of which is a base of the exponential function and the other of which is a coefficient of the exponential function;
and under the condition that the error value of the quantization step length accords with a preset condition, determining the two constant items, wherein the error value is an absolute value error or standard deviation between the quantization step length true value of the standard comparison table and the quantization step length function value of the exponential function.
7. The method of claim 5, wherein the relationships between the multiple segments of quantization parameter ranges include inclusion relationships and/or mutually exclusive relationships;
the determining, according to the first quantization parameter, a target quantization parameter range within which the first quantization parameter falls, includes:
respectively obtaining the difference value between the boundary value of the multi-section quantization parameter range and the first quantization parameter;
and when the absolute value of the difference value is minimum, the corresponding quantization parameter range is the target quantization parameter range.
8. An encoding device, comprising:
a first quantization parameter determination unit configured to determine a first quantization parameter of the encoding unit;
the target quantization step length determining unit is used for determining a target quantization step length according to the first quantization parameter and a quantization parameter-quantization step length function;
the second quantization parameter determining unit is used for searching a standard comparison table according to the target quantization step length and determining a second quantization parameter matched with the target quantization step length; the standard comparison table comprises a plurality of corresponding relations between a plurality of quantization step sizes and a plurality of quantization parameters;
and the coding unit is used for coding the coding unit based on the second quantization parameter.
9. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
10. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein computer instructions which, when executed by a processor, implement the method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310582182.7A CN116471405A (en) | 2023-05-22 | 2023-05-22 | Encoding method, encoding device, electronic equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310582182.7A CN116471405A (en) | 2023-05-22 | 2023-05-22 | Encoding method, encoding device, electronic equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116471405A true CN116471405A (en) | 2023-07-21 |
Family
ID=87173846
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310582182.7A Pending CN116471405A (en) | 2023-05-22 | 2023-05-22 | Encoding method, encoding device, electronic equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116471405A (en) |
-
2023
- 2023-05-22 CN CN202310582182.7A patent/CN116471405A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5796435A (en) | Image coding system with adaptive spatial frequency and quantization step and method thereof | |
US7720145B2 (en) | Model based bit rate control for a macroblock encoder | |
US20100195733A1 (en) | Video scene change detection and encoding complexity reduction in a video encoder system having multiple processing devices | |
CN109660825B (en) | Video transcoding method and device, computer equipment and storage medium | |
CN111193924B (en) | Method and device for determining video code rate, computer equipment and storage medium | |
CN111131828B (en) | Image compression method and device, electronic equipment and storage medium | |
CN112672149B (en) | Video processing method and device, storage medium and server | |
KR20030069282A (en) | Method for encoding motion image having fixed computational complexity and apparatus thereof | |
US10536696B2 (en) | Image encoding device and image encoding method | |
US20100027617A1 (en) | Method and apparatus for compressing a reference frame in encoding/decoding moving images | |
CN109951706B (en) | Video coding method, device and coder | |
US8300967B2 (en) | Bit rate control circuit and method for image compression | |
CN116471405A (en) | Encoding method, encoding device, electronic equipment and readable storage medium | |
CN115022636A (en) | Rate distortion optimization quantization method and device | |
CN113068050B (en) | Method and device for determining sample point adaptive compensation mode of tree-shaped coding block | |
US11825088B2 (en) | Adaptively encoding video frames based on complexity | |
CN114584779A (en) | Video coding method, device, equipment and medium based on H264 coding algorithm | |
CN109561315B (en) | Motion estimation method and device, electronic equipment and storage medium | |
CN115914629A (en) | Video coding method and device and electronic equipment | |
CN116471407A (en) | Video coding method and device | |
CN109995962B (en) | Method and system for controlling upper limit of picture coding size | |
CN111327895B (en) | Data processing method and device | |
CN102271247B (en) | Method and device for adjusting coding code rate | |
CN116248895B (en) | Video cloud transcoding method and system for virtual reality panorama roaming | |
CN111247800B (en) | Method and device for determining image information quantity |
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 |