Bit rate control method and device
By determining the product relationship between the quantization parameter and the number of samples for each category, the problem of inconsistent encoding bit rates for samples with different sampling rates is solved, and the encoding bit rate is balanced and the image quality is improved.
Patent Information
- Application Number
- CN202310035241.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-10
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-01-10
AI Technical Summary
The existing technology fails to effectively determine the sample quantization parameters of different sampling rates, resulting in unequal encoding bit rates and an inability to ensure consistent encoding bit rates for samples of different categories in an image.
By obtaining the coding unit quantization parameter, the number of samples of different categories in the target image and the preset quantization parameter deviation value, the quantization parameter of each category of samples is determined so that its weighted sum with the corresponding number of samples is equal to the product of the coding unit quantization parameter and the total number of samples, ensuring the consistency of the encoding bit rate.
The quantization parameter encoding bit rate of samples of different categories is made equal to the quantization parameter encoding bit rate of the coding unit, thereby improving the consistency of coding efficiency and image quality.
Smart Images

Figure CN116016925B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video processing technology, and in particular to a method and device for bit rate control. Background Art
[0002] With the increasing popularity of image and video applications, video compression technology is undergoing continuous iteration and innovation. Common video compression standards such as Display Stream Compression (DSC), VESA Display Compression-M (VDC-M), Apple ProRes codec, and JPEG-XS are widely used in display interfaces such as High Definition Multimedia Interface (HDMI) and Display Port (DP), and in image and video production. The primary goal of general video compression standards is to achieve 4-16x data compression while maintaining low latency, low complexity, and subjective losslessness. Taking the more common DSC coding standard as an example, the lightweight compression coding framework primarily includes modules such as input and output, buffer slicing, prediction, quantization, reconstruction, entropy coding, rate control, and stream synthesis. Other standards may optionally include transform and other specialized tool modules. The rate control module controls the quantization parameter (QP) of each frame or coding unit to ensure that the output encoded video bitrate meets specific constraints.
[0003] Typically, when encoding an image of a certain format, since the image contains n different types of samples, for example, for a YUV image, the two types of samples it contains are luminance samples and chrominance samples. The average number of samples corresponding to each pixel position for the two types of samples is different, that is, the sample sampling rates of the two types of samples are different. Specifically, the quantization parameters corresponding to the two types of samples can be obtained by looking up the table, and then bit rate control can be performed based on the quantization parameters obtained from the lookup table. The prior art does not have a clear method for determining the correspondence between different sampling rates and the quantization parameters in the table, nor can it guarantee that the encoding bit rate of encoding based on the quantization parameters of samples with multiple different sampling rates in the image is equal to the encoding bit rate of encoding using the coding unit quantization parameters.
[0004] Therefore, a current research direction is to provide a method that can ensure that the encoding bit rate of encoding according to the quantization parameters of n different categories of samples in the image is equal to the encoding bit rate of encoding using the coding unit quantization parameter. Summary of the Invention
[0005] The present invention provides a method and apparatus for bit rate control, which is used to provide a method for bit rate control, so as to ensure that the encoding bit rate of encoding according to the quantization parameters of n different categories of samples in an image is equal to the encoding bit rate of encoding using the quantization parameters of the coding unit.
[0006] The present invention provides a method for bit rate control, comprising: obtaining a coding unit quantization parameter, the number of samples of n different categories in a target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories, where n is an integer greater than 1; determining a quantization parameter for each category of samples in the target image based on the coding unit quantization parameter, the number of samples of n different categories in the target image, and the preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image; and determining a coding bit rate of the coding unit based on the quantization parameter of each category of samples.
[0007] In one embodiment, the determining of the quantization parameter of each of the n different categories of samples in the target image based on the coding unit quantization parameter, the number of samples of the n different categories in the target image, and the preset quantization parameter deviation values corresponding to the samples of the n different categories, includes: determining a primary sample and a secondary sample in the n different categories of samples: wherein the primary sample is the most important sample in the n different categories of samples; the secondary sample is other samples in the n different categories of samples except the primary sample; based on the quantization parameter and the corresponding number of samples of each category, and the coding unit quantization parameter, determining a first expression between the three: Among them, cu_qp is the coding unit quantization parameter; N i represents the number of samples of the i-th category, qp i Representing the quantization parameter of the sample of the i-th category; determining a second expression between the preset quantization parameter deviation value and the quantization parameter of the sample based on the quantization parameter of the main sample, the quantization parameter of the auxiliary sample, and the preset quantization parameter deviation values corresponding to the n different categories of samples: qp j -p0=qpBias j , where j = 1, 2, ..., n-1, qp j Indicates the quantization parameter of the auxiliary sample of the jth category, qp0 indicates the quantization parameter of the main sample, qpBias j A preset quantization parameter deviation value representing the secondary sample of the jth category; and determining the quantization parameter of the sample of each category based on the first expression and the second expression.
[0008] In one embodiment, the third expression of the quantization parameter of the main sample in the determined quantization parameters of each category of samples is: Among them, N j represents the number of samples of the j-th category of auxiliary samples; the fourth expression of the quantization parameter of the j-th category of auxiliary samples is: qp i =p0+qpBias j .
[0009] In one embodiment, if n=2, that is, there are two different types of samples in the target image: a main sample and an auxiliary sample; the quantization parameter qp0 of the main sample is expressed as: The expression of the quantization parameter qp1 of the auxiliary sample is: Among them, cu_qp is the coding unit quantization parameter; qpBias1 is the preset quantization parameter deviation value corresponding to the auxiliary sample, which represents the deviation value between the quantization parameter of the auxiliary sample and the quantization parameter of the main sample, and is a positive number; N0 is the number of samples of the main sample; N1 is the number of samples of the auxiliary sample.
[0010] In one embodiment, the target image is a YUV image, and accordingly, the primary samples are luminance samples, and the secondary samples are chrominance samples.
[0011] In one embodiment, the target image is an RGB image, and accordingly, the primary samples are green samples, and the secondary samples are red and blue samples.
[0012] The present invention also provides a device for bit rate control, comprising: an acquisition module, used to acquire a coding unit quantization parameter, a preset quantization parameter deviation value and the number of samples of n different categories in a target image; a first determination module, used to determine the quantization parameter of each category of samples in the target image based on the coding unit quantization parameter, the number of samples of n different categories in the target image and the quantization parameter deviation values corresponding to the n different categories of samples; a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of n different categories in the target image; and a second determination module, used to determine the encoding bit rate of the coding unit based on the quantization parameter of each category of samples.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above-described rate control methods when executing the program.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which implements the steps of any of the above-mentioned rate control methods when executed by a processor.
[0015] The method and apparatus for bit rate control provided by the present invention ensure that the weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of n different categories in the target image, thereby providing a method for determining the quantization parameters of n different categories of samples. That is, the quantization parameter of each category of samples in the target image is determined based on the coding unit quantization parameter, a preset quantization parameter deviation value, and the number of samples of n different categories in the target image, thereby ensuring that the encoding bit rate of encoding according to the quantization parameters of samples of multiple different sampling rates in the image is equal to the encoding bit rate of encoding using the coding unit quantization parameter. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 It is a schematic diagram of the framework of the video compression method in the prior art;
[0018] Figure 2 This is one of the flow charts of the rate control method provided by the present invention;
[0019] Figure 3 This is the second flow chart of the rate control method provided by the present invention;
[0020] Figure 4 1 is a schematic structural diagram of a rate control device provided by the present invention;
[0021] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0022] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0023] In order to facilitate understanding, the technical terms involved in the present invention are first explained.
[0024] Rate Control: Rate control technology is a crucial technical module in practical video encoders. Depending on the specific application scenario, such as real-time or offline encoding, traditional broadcast television services, or internet streaming services, the output bitrate of the video encoder is subject to various specific requirements and limitations, such as average or maximum target bitrate, buffer size, and initial latency. Rate control controls the quantization parameters of each frame or coding unit for each application scenario, ensuring that the output encoded video bitrate meets the specified constraints while optimizing encoding performance, including coding efficiency and subjective quality.
[0025] Bit rate: Bit rate is the number of data bits transmitted per unit time during data transmission, and the unit is kilobits per second (kbps).
[0026] Quantization parameter: The quantization parameter reflects the compression of spatial detail. Smaller quantization parameter values result in finer quantization, higher image quality, and a longer bitrate. A low QP preserves most detail; increasing the QP results in some loss of detail and a lower bitrate, but also increases image distortion and quality.
[0027] The following combination Figure 1-Figure 5 The method and apparatus for bit rate control of the present invention are described.
[0028] For ease of understanding, Figure 1 An application example of the method for rate control of the present invention is given as an example. Taking the DSC coding standard as an example, Figure 1 As shown, the light compression coding framework mainly includes modules such as input, cache segmentation, flatness measurement, prediction, quantization, reconstruction, entropy coding, rate control, bitstream synthesis, coding buffer, and output. The rate control module can output quantization parameters to the flatness measurement module and the prediction, quantization, and reconstruction modules, and the entropy coding module can feed back the number of coded bits to the rate control module. The rate control method of the present invention can be mainly applied to the rate control module in the above light compression coding framework.
[0029] It can be understood that the present invention can be applied not only to DSC, but also to video compression methods such as VDC-M, Apple ProRes and JPEG-XS.
[0030] Figure 2The flow chart of the rate control method provided by the present invention is as follows. It can be understood that the rate control method can be applied to the field of video compression and can be executed by a rate control device, such as Figure 2 As shown, the method includes the following steps:
[0031] Step 210 : Obtain the coding unit quantization parameter, the number of samples of n different categories in the target image, and the preset quantization parameter deviation values corresponding to the n different categories of samples, where n is an integer greater than 1.
[0032] The coding unit quantization parameter is a preset quantization parameter corresponding to the coding unit. It can be understood that the coding unit quantization parameter can be understood as the coding unit quantization parameter used to calculate all samples of the coding unit.
[0033] The target image is the target type of image to be encoded. The n different categories of samples in the target image are samples corresponding to different channels in the target image. Accordingly, the number of samples of the n different categories in the target image is the average number of samples of the n different categories corresponding to each pixel position. For example, for a YUV image, the two categories of samples it contains are luminance samples and chrominance samples, and the average number of samples corresponding to each pixel position for these two categories of samples is different.
[0034] Step 220: Determine the quantization parameter of each of the n different categories of samples in the target image based on the coding unit quantization parameter, the number of samples of the n different categories in the target image, and the preset quantization parameter deviation values corresponding to the n different categories of samples; wherein the weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image.
[0035] It can be understood that the number of samples of the main sample and auxiliary sample that the coding unit needs to encode is N i If encoding is performed according to the coding unit quantization parameter, when the encoding bit rate is calculated using the quantization parameter of the primary sample and the quantization parameter of the secondary sample, the encoding bit rate of each category of samples is related to the sample number of the samples corresponding to each category; when the encoding bit rate is calculated using the coding unit quantization parameter, the encoding bit rate is related to the sample number sum of the sample number of the primary sample and the sample number of the secondary sample. Therefore, the weighted sum of the quantization parameter of each category of samples and the corresponding sample number is made constant equal to the product of the coding unit quantization parameter and the total sample number of n different categories of samples in the target image, thereby achieving the encoding bit rate of encoding based on the quantization parameters of the n different categories of samples in the target image being equal to the encoding bit rate of encoding using the coding unit quantization parameter.
[0036] Step 230 : Determine the encoding rate of the coding unit based on the quantization parameter of each category of samples.
[0037] Specifically, the process of determining the encoding rate of the coding unit based on the quantization parameter of each category of samples can refer to the existing technology, and for the sake of brevity, it is not repeated here.
[0038] The rate control method provided by the present invention ensures that the weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of n different categories in the target image, thereby providing a method for determining the quantization parameters of n different categories of samples. That is, the quantization parameter of each category of samples in the target image is determined based on the coding unit quantization parameter, a preset quantization parameter deviation value, and the number of samples of n different categories in the target image, thereby ensuring that the encoding rate of encoding according to the quantization parameters of samples of multiple different sampling rates in the image is equal to the encoding rate of encoding using the coding unit quantization parameter.
[0039] In one embodiment, Figure 3 As shown, the method of determining the quantization parameter of each of the n different categories of samples in the target image based on the coding unit quantization parameter, the number of samples of the n different categories in the target image, and the preset quantization parameter deviation values corresponding to the n different categories of samples respectively includes the following steps:
[0040] Step 310 , determining the primary sample and the secondary sample among the n different categories of samples: the primary sample is the most important sample among the n different categories of samples; the secondary sample is the other samples among the n different categories of samples except the primary sample.
[0041] Step 320 : Determine a first expression between the quantization parameter of each category of samples, the corresponding sample quantity, and the coding unit quantization parameter.
[0042] As mentioned above, the weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of n different categories in the target image. Therefore, the first expression is: Among them, cu_qp is the coding unit quantization parameter; N i represents the number of samples of the i-th category, qp i represents the quantization parameter of the sample of category i. By transforming the first expression above, we can get
[0043] Step 330 : Determine a second expression between the preset quantization parameter deviation value and the sample quantization parameter based on the quantization parameter of the main sample, the quantization parameter of the auxiliary sample, and the preset quantization parameter deviation values corresponding to the n different types of samples.
[0044] Among them, the second expression is: qp j -qp0=qpBias j , where j = 1, 2, ..., n-1, qp j Indicates the quantization parameter of the auxiliary sample of the jth category, qp0 indicates the quantization parameter of the main sample, qpBias j Indicates the preset quantization parameter deviation value of the secondary samples of the j-th category.
[0045] Among them, the preset quantization parameter bias value qpBias of the auxiliary sample of the jth category j It represents the deviation between the quantization parameter of the auxiliary sample and the quantization parameter of the main sample. It is a positive number and can be a value preset based on expert experience.
[0046] It can be understood that, in general, the smaller the quantization parameter, the higher the corresponding encoding bit rate and the higher the image quality. Therefore, in practical applications, based on actual conditions, the samples of the more important categories can be set as primary samples, and the corresponding samples of another category can be set as secondary samples. The quantization parameter of the primary sample is smaller than that of the secondary sample. Therefore, qpBias j Is a positive number.
[0047] Step 340: Determine the quantization parameter of the samples of each category based on the first expression and the second expression.
[0048] It can be understood that in the first expression above, N i , cu_qp are known, qpBias j is a preset value, so the corresponding qp0 and qp can be obtained by combining the first expression and the second expression. j .
[0049] In one embodiment, the third expression of the quantization parameter of the main sample in the determined quantization parameters of each category of samples is: Among them, N j represents the number of samples of the j-th category of auxiliary samples; the fourth expression of the quantization parameter of the j-th category of auxiliary samples is: qp i =qp0+qpBias j .
[0050] In one embodiment, if n=2, that is, there are two different types of samples in the target image: a main sample and an auxiliary sample; the quantization parameter qp0 of the main sample is expressed as: The expression of the quantization parameter qp1 of the auxiliary sample is: Among them, cu_qp is the coding unit quantization parameter; qpBias1 is the preset quantization parameter deviation value corresponding to the auxiliary sample, which represents the deviation value between the quantization parameter of the auxiliary sample and the quantization parameter of the main sample, and is a positive number; N0 is the number of samples of the main sample; N1 is the number of samples of the auxiliary sample.
[0051] In one embodiment, the target image is a YUV image, and accordingly, the primary samples are luminance samples, and the secondary samples are chrominance samples.
[0052] It can be understood that YUV images include multiple formats, such as YUV444 format images and YUV422 format images. For YUV444 format, the number of chroma samples corresponding to it is chroma_N=2, for YUV422 format, chroma_N is equal to 1, and the number of luminance samples is luma_N equal to 1. Then the quantization parameter of the luminance sample is Quantization parameter of chroma samples
[0053] In one embodiment, the target image is an RGB image, and accordingly, the primary samples are green samples, and the secondary samples are red and blue samples.
[0054] The rate control device provided by the present invention is described below. The rate control device described below and the rate control method described above can be referenced to each other.
[0055] Figure 4 Schematic diagram of the rate control device provided by the present invention, such as Figure 4 As shown, the apparatus for rate control provided by an embodiment of the present invention includes:
[0056] An acquisition module 410 is configured to acquire a coding unit quantization parameter, the number of samples of n different categories in a target image, and preset quantization parameter deviation values corresponding to the samples of n different categories, where n is an integer greater than 1;
[0057] A first determining module 420 is configured to determine a quantization parameter for each of the n different categories of samples in the target image based on a coding unit quantization parameter, the number of samples of n different categories in the target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to a product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image;
[0058] The second determining module 430 is configured to determine an encoding rate of a coding unit based on the quantization parameter of each category of samples.
[0059] The rate control device provided by the present invention ensures that the weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of n different categories in the target image, thereby providing a method for determining the quantization parameters of n different categories of samples. That is, the quantization parameter of each category of samples in the target image is determined based on the coding unit quantization parameter, a preset quantization parameter deviation value, and the number of samples of n different categories in the target image, thereby ensuring that the encoding rate of encoding according to the quantization parameters of samples of multiple different sampling rates in the image is equal to the encoding rate of encoding using the coding unit quantization parameter.
[0060] In one embodiment, the first determining module 420 includes:
[0061] A first determining unit is configured to determine a primary sample and secondary samples from among the n different categories of samples: wherein the primary sample is the most important sample from among the n different categories of samples; and the secondary samples are other samples from among the n different categories of samples except the primary sample;
[0062] The second determining unit is configured to determine a first expression between the quantization parameter of each category of samples and the corresponding number of samples, and the coding unit quantization parameter: Among them, cu_qp is the coding unit quantization parameter; N i represents the number of samples of the i-th category, qp i represents the quantization parameter of the sample of category i;
[0063] The third determining unit is configured to determine a second expression between the preset quantization parameter deviation value and the quantization parameter of the sample based on the quantization parameter of the main sample, the quantization parameter of the auxiliary sample, and the preset quantization parameter deviation values corresponding to the n different types of samples: qp j -p0=qpBias j , where j = 1, 2, ..., n-1, qpj Indicates the quantization parameter of the auxiliary sample of the jth category, qp0 indicates the quantization parameter of the main sample, qpBias j The preset quantization parameter deviation value representing the secondary sample of the j-th category;
[0064] The fourth determining unit is configured to determine the quantization parameter of the samples of each category based on the first expression and the second expression.
[0065] In one embodiment, the third expression of the quantization parameter of the main sample in the determined quantization parameters of each category of samples is: Among them, N j represents the number of samples of the j-th category of auxiliary samples; the fourth expression of the quantization parameter of the j-th category of auxiliary samples is: qp i =p0+qpBias j .
[0066] In one embodiment, if n=2, that is, there are two different types of samples in the target image: a main sample and an auxiliary sample; the quantization parameter qp0 of the main sample is expressed as: The expression of the quantization parameter qp1 of the auxiliary sample is: Among them, cu_qp is the coding unit quantization parameter; qpBias1 is the preset quantization parameter deviation value corresponding to the auxiliary sample, which represents the deviation value between the quantization parameter of the auxiliary sample and the quantization parameter of the main sample, and is a positive number; N0 is the number of samples of the main sample; N1 is the number of samples of the auxiliary sample.
[0067] In one embodiment, the target image is a YUV image, and accordingly, the primary samples are luminance samples, and the secondary samples are chrominance samples.
[0068] In one embodiment, the target image is an RGB image, and accordingly, the primary samples are green samples, and the secondary samples are red and blue samples.
[0069] Figure 5 An example of a physical structure diagram of an electronic device is shown below. Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logic instructions in the memory 530 to execute a method for bit rate control, which includes: obtaining a coding unit quantization parameter, the number of samples of n different categories in a target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories, where n is an integer greater than 1; determining a quantization parameter for each of the n different categories of samples in the target image based on the coding unit quantization parameter, the number of samples of n different categories in the target image, and the preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image; and determining the encoding bit rate of the coding unit based on the quantization parameter of each category of samples.
[0070] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk, etc. Various media that can store program codes.
[0071] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can perform the rate control method provided by the present invention, the method including: obtaining a coding unit quantization parameter, the number of samples of n different categories in a target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories, where n is an integer greater than 1; determining the quantization parameter of each category of samples in the target image based on the coding unit quantization parameter, the number of samples of n different categories in the target image, and the preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein the weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image; and determining the encoding rate of the coding unit based on the quantization parameter of each category of samples.
[0072] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the method for bit rate control provided by the present invention, the method comprising: obtaining a coding unit quantization parameter, the number of samples of n different categories in a target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories, where n is an integer greater than 1; determining the quantization parameter of each category of samples in the target image based on the coding unit quantization parameter, the number of samples of n different categories in the target image, and the preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image; and determining the encoding bit rate of the coding unit based on the quantization parameter of each category of samples.
[0073] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0074] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0075] It can be understood that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for bit rate control, characterized in that: include: Obtaining a coding unit quantization parameter, the number of samples of n different categories in a target image, and preset quantization parameter deviation values corresponding to the samples of n different categories, where n is an integer greater than 1; Determining a quantization parameter for each of the n different categories of samples in the target image based on the coding unit quantization parameter, the number of samples of the n different categories in the target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to the product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image; An encoding bit rate of a coding unit is determined based on the quantization parameter of the samples of each category.
2. The method for bit rate control according to claim 1, wherein: The determining, based on the coding unit quantization parameter, the number of samples of the n different categories in the target image, and the preset quantization parameter deviation values respectively corresponding to the samples of the n different categories, of the quantization parameters of each category of samples in the target image includes: Determine the main sample and auxiliary sample among n different categories of samples: the main sample is the most important sample among the n different categories of samples; the auxiliary sample is the other samples among the n different categories of samples except the main sample; Based on the quantization parameter of each category of samples and the corresponding number of samples, and the coding unit quantization parameter, a first expression between the three is determined: Among them, cu_qp is the coding unit quantization parameter; N i represents the number of samples of the i-th category, qp i represents the quantization parameter of the sample of category i; Based on the quantization parameter of the main sample, the quantization parameter of the auxiliary sample and the preset quantization parameter deviation values corresponding to the n different types of samples, a second expression between the preset quantization parameter deviation value and the quantization parameter of the sample is determined: qp j -qp0=qpBias j , where j = 1, 2, ..., n-1, qp j Indicates the quantization parameter of the auxiliary sample of the jth category, qp0 indicates the quantization parameter of the main sample, qpBias j The preset quantization parameter deviation value representing the secondary sample of the j-th category; A quantization parameter of the samples of each category is determined based on the first expression and the second expression.
3. The method for bit rate control according to claim 2, wherein: The third expression of the quantization parameter of the main sample in the determined quantization parameters of each category of samples is: Among them, N j represents the number of samples of the j-th category of auxiliary samples; the fourth expression of the quantization parameter of the j-th category of auxiliary samples is: qp i =qp0+qpBias j .
4. The method for bit rate control according to claim 3, wherein: If n=2, that is, there are two different types of samples in the target image: a main sample and a secondary sample; the quantization parameter qp0 of the main sample is expressed as: The expression of the quantization parameter qp1 of the auxiliary sample is: Among them, cu_qp is the coding unit quantization parameter; qpBias1 is the preset quantization parameter deviation value corresponding to the auxiliary sample, which represents the deviation value between the quantization parameter of the auxiliary sample and the quantization parameter of the main sample, and is a positive number; N0 is the number of samples of the main sample; N1 is the number of samples of the auxiliary sample.
5. The method for bit rate control according to claim 2, wherein: The target image is a YUV image. Accordingly, the primary samples are luminance samples, and the secondary samples are chrominance samples.
6. The method for bit rate control according to claim 2, wherein: The target image is an RGB image. Accordingly, the primary sample is a green sample, and the secondary samples are red and blue samples.
7. A rate control device, characterized in that: include: An acquisition module is used for the number of samples of n different categories in the target image and the preset quantization parameter deviation values corresponding to the samples of n different categories, where n is an integer greater than 1; A first determination module is configured to determine a quantization parameter for each of the n different categories of samples in the target image based on a coding unit quantization parameter, the number of samples of the n different categories in the target image, and preset quantization parameter deviation values corresponding to the samples of the n different categories; wherein a weighted sum of the quantization parameter of each category of samples and the corresponding number of samples is always equal to a product of the coding unit quantization parameter and the total number of samples of the n different categories in the target image; The second determining module is configured to determine an encoding bit rate of the coding unit based on the quantization parameter of each category of samples.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the rate control method according to any one of claims 1 to 6 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the rate control method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Self-adapting code rate control method
CN101252689A
Code rate control method and device based on layered B frame and electronic equipment
CN109862359A