Image processing methods, apparatus, devices and storage media

By adjusting the quantization parameters of the P-frame images according to the mini-GOP length, the problem of P-frame image distortion in mini-GOP was solved, thus improving video quality.

CN116055735BActive Publication Date: 2026-03-06BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310028914.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-09
Publication Date
2026-03-06
Estimated Expiration
2043-01-09

AI Technical Summary

Technical Problem

In existing technologies, when encoding video images for minimum group of images (mini-GOPs) of different lengths, using the same bitrate leads to increased distortion of P-frame images, which in turn increases overall distortion and reduces video quality.

Method used

The quantization parameters of the P-frame image are determined based on the length of the mini-GOP, making them negatively correlated with the mini-GOP length, and more bitrate is allocated to the P-frame image to reduce P-frame distortion.

Benefits of technology

By adjusting the quantization parameters of the P-frame images, P-frame distortion in mini-GOPs is reduced, thereby improving the overall video quality of mini-GOPs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116055735B_ABST
    Figure CN116055735B_ABST
Patent Text Reader

Abstract

This disclosure provides an image processing method, apparatus, device, and storage medium, relating to the field of image processing. The image processing method includes: acquiring a current image group to be processed and acquiring the length of the current image group to be processed; determining a first quantization parameter of a first target frame image in the current image group to be processed based on the length of the current image group to be processed; and encoding the first target frame image based on the first quantization parameter. This disclosure improves the video quality of the image group to be processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing, and more particularly to an image processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium. Background Technology

[0002] Video encoding bitrate and video quality are mutually restrictive. Lower bitrate video images are more suitable for network transmission, but the corresponding video image quality is also lower. Conversely, to obtain better video image quality, the bitrate needs to be increased. Therefore, when encoding video images, it is necessary to find the optimal balance between video image quality and video processing bitrate.

[0003] In related technologies, rate-distortion optimization algorithms are typically used to find the optimal point. For example, the Lagrange multiplier method can be used to construct a rate-distortion optimization objective function. The rate-distortion optimization objective function is a function of the rate-distortion cost, bitrate, and distortion. After constructing the rate-distortion optimization objective function, the point with the minimum rate-distortion cost is obtained from the rate-distortion curve representing the correspondence between bitrate and distortion of the video image, and this point is taken as the optimal point. After determining the optimal point, the video image is encoded using the bitrate corresponding to the optimal point.

[0004] However, when encoding video images using relevant techniques, the same bitrate is used when the video images are miniGroups of Pictures (mini-GOPs) of different lengths. Since the longer the mini-GOP, the more important the P-frames within it, the more bitrate needs to be allocated to them to reduce mini-GOP distortion. Using the same bitrate for encoding mini-GOPs of different lengths will increase the distortion of P-frames within the mini-GOP when the mini-GOP is long, thus increasing the overall distortion of the mini-GOP and reducing its video quality. Summary of the Invention

[0005] This disclosure provides an image processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium to at least solve the problem in related technologies that increases the distortion of P-frame images in a mini-GOP, thereby increasing the overall distortion of the mini-GOP and reducing the video quality of the mini-GOP. The technical solution of this disclosure is as follows:

[0006] According to a first aspect of the present disclosure, an image processing method is provided, comprising:

[0007] Obtain the current image group to be processed and obtain the length of the current image group to be processed;

[0008] A first quantization parameter of the first target frame image in the current image group to be processed is determined based on the length of the current image group to be processed; wherein, the first quantization parameter is negatively correlated with the length of the image group to be processed;

[0009] The first target frame image is encoded according to the first quantization parameter.

[0010] Optionally, determining the first quantization parameter of the target frame image in the current image group to be processed based on the length of the current image group to be processed includes:

[0011] Obtain the first quantization parameter factor of the first target frame image;

[0012] Determine the quantization factor parameter weights corresponding to the length of the current image group to be processed; wherein the quantization factor parameter weights are negatively correlated with the length of the current image group to be processed;

[0013] The first quantization parameter is determined based on the first quantization parameter factor and the weight of the quantization factor parameter.

[0014] Optionally, determining the quantization parameter factor weights corresponding to the length of the image group to be processed includes:

[0015] For each length of the current image group to be processed, multiple quantization parameter factor weights are obtained in a preset interval corresponding to that length according to a preset step size;

[0016] Calculate the BDBR parameter value corresponding to each of the multiple quantization parameter factor weights;

[0017] The quantization parameter factor weight corresponding to the maximum value of the BDBR parameter is used as the quantization factor parameter weight.

[0018] Optionally, the first quantization parameter factor for obtaining the first target frame image includes:

[0019] The complexity of obtaining the SATD of the first target frame image and the historical frame images;

[0020] Calculate the first weighted sum of the SATD of the first target frame image and the complexity of the historical frame image;

[0021] Calculate the ratio of the first weighted sum to the number of historical frame images;

[0022] The first quantization parameter factor is determined based on the ratio.

[0023] Optionally, after encoding the first target frame image according to the first quantization parameter, the method further includes:

[0024] Other quantization parameters of other frame images in the current image group to be processed are determined based on the first quantization parameter, wherein the other frame images are images in the current image group to be processed other than the first target frame image;

[0025] The other frame images are encoded according to the other quantization parameters.

[0026] Optionally, determining other quantization parameters of other frames in the image to be processed based on the first quantization parameter includes:

[0027] Obtain the rating of the other frame images;

[0028] A second quantization parameter is determined that corresponds to the level of the other frame images; wherein the second quantization parameter is inversely proportional to the level of the other frame images;

[0029] Obtain the third quantization parameter of the second target frame image in the next image group to be processed;

[0030] Calculate a second weighted sum of the first quantization parameter, the second quantization parameter, and the third quantization parameter, and use the second weighted sum as the other quantization parameters.

[0031] Optionally, encoding the other frame images according to the other quantization parameters includes:

[0032] The second bitrate of the other frame images is determined based on the other quantization parameters;

[0033] The other frame images are encoded according to the second bitrate.

[0034] Optionally, encoding the first target frame image according to the first quantization parameter includes:

[0035] The first bitrate of the first target frame image is determined based on the first quantization parameter.

[0036] The first target frame image is encoded according to the first bit rate.

[0037] According to a second aspect of the present disclosure, an image processing apparatus is provided, comprising:

[0038] The length acquisition module is configured to acquire the current image group to be processed and acquire the length of the current image group to be processed.

[0039] The first quantization parameter determination module is configured to determine a first quantization parameter of the first target frame image in the current image group to be processed based on the length of the current image group to be processed; wherein the first quantization parameter is negatively correlated with the length of the image group to be processed;

[0040] The first image processing module is configured to encode the first target frame image according to the first quantization parameter.

[0041] Optionally, the first quantization parameter determination module is configured as follows:

[0042] Obtain the first quantization parameter factor of the first target frame image;

[0043] Determine the quantization factor parameter weights corresponding to the length of the current image group to be processed; wherein the quantization factor parameter weights are negatively correlated with the length of the current image group to be processed;

[0044] The first quantization parameter is determined based on the first quantization parameter factor and the weight of the quantization factor parameter.

[0045] Optionally, the first quantization parameter determination module is configured as follows:

[0046] For each length of the current image group to be processed, multiple quantization parameter factor weights are obtained in a preset interval corresponding to that length according to a preset step size;

[0047] Calculate the BDBR parameter value corresponding to each of the multiple quantization parameter factor weights;

[0048] The quantization parameter factor weight corresponding to the maximum value of the BDBR parameter is used as the quantization factor parameter weight.

[0049] Optionally, the first quantization parameter determination module is configured as follows:

[0050] The complexity of obtaining the SATD of the first target frame image and the historical frame images;

[0051] Calculate the first weighted sum of the SATD of the first target frame image and the complexity of the historical frame image;

[0052] Calculate the ratio of the first weighted sum to the number of historical frame images;

[0053] The first quantization parameter factor is determined based on the ratio.

[0054] Optionally, the device further includes: a second image processing module, configured to:

[0055] Other quantization parameters of other frame images in the current image group to be processed are determined based on the first quantization parameter, wherein the other frame images are images in the current image group to be processed other than the first target frame image;

[0056] The other frame images are encoded according to the other quantization parameters.

[0057] Optionally, the second image processing module is configured as follows:

[0058] Obtain the rating of the other frame images;

[0059] A second quantization parameter is determined that corresponds to the level of the other frame images; wherein the second quantization parameter is inversely proportional to the level of the other frame images;

[0060] Obtain the third quantization parameter of the second target frame image in the next image group to be processed;

[0061] Calculate a second weighted sum of the first quantization parameter, the second quantization parameter, and the third quantization parameter, and use the second weighted sum as the other quantization parameters.

[0062] Optionally, the second image processing module is configured as follows:

[0063] The second bitrate of the other frame images is determined based on the other quantization parameters;

[0064] The other frame images are encoded according to the second bitrate.

[0065] Optionally, the first image processing module is configured as follows:

[0066] The first bitrate of the first target frame image is determined based on the first quantization parameter.

[0067] The first target frame image is encoded according to the first bit rate.

[0068] According to a third aspect of the present disclosure, an electronic device is provided, comprising:

[0069] processor;

[0070] Memory used to store the processor's executable instructions;

[0071] The processor is configured to execute the instructions to implement the image processing method as described in the first aspect.

[0072] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the image processing method as described in the first aspect.

[0073] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects: when the image group to be processed is a mini-GOP and the first target frame image is a P-frame image in the mini-GOP, the first quantization parameter of the P-frame image in the current image group to be processed can be determined according to the length of the mini-GOP; and the first quantization parameter of the P-frame image is negatively correlated with the length of the mini-GOP; since the larger the quantization parameter, the lower the bit rate, the larger the length of the mini-GOP, the smaller the first quantization parameter of the frame image, which can allocate more bit rate to the P-frame image in the mini-GOP, effectively reduce the distortion of the P-frame in the mini-GOP, thereby reducing the overall distortion of the mini-GOP and improving the video quality of the mini-GOP.

[0074] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0075] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.

[0076] Figure 1 This is a schematic diagram illustrating a rate-distortion curve according to an exemplary embodiment;

[0077] Figure 2 This is a schematic architecture diagram of an image processing system according to an exemplary embodiment;

[0078] Figure 3 This is a flowchart illustrating an image processing method according to an exemplary embodiment;

[0079] Figure 4 This is a flowchart illustrating a method for determining the length of a current group of images to be processed, according to an exemplary embodiment;

[0080] Figure 5 This is a flowchart illustrating another frame image encoding method according to an exemplary embodiment;

[0081] Figure 6 This is a schematic diagram of an image processing apparatus according to an exemplary embodiment;

[0082] Figure 7 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0083] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.

[0084] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0085] In related technologies, rate-distortion optimization algorithms are commonly used to find the optimal balance between video image quality and video image processing bitrate. For example, the Lagrange multiplier method can be used to construct a rate-distortion optimization objective function. The constructed rate-distortion optimization objective function is shown in formula (1). Wherein, J is the rate-distortion cost, R is the bitrate consumed by the coding mode, and D is the sum of absolute differences (SAD) or the sum of absolute transformed differences (SATD), used to characterize the distortion of the video image. The smaller the distortion of the video image, the better the quality of the video image. For the encoder, the quality of the coding mode is reflected by the calculated rate-distortion cost J of different coding modes. When J is the smallest, the coding mode of the encoder is the best. And the rate-distortion curve is as follows: Figure 1 As shown. Among them, when the point corresponding to the slope of the rate distortion curve is -lambda is substituted into formula (1), J is minimized. Therefore, the point corresponding to the slope of the rate distortion curve is the optimal point.

[0086] J = lambda * R + D (1).

[0087] Because the rate-distortion function used by the encoder differs from the rate-distortion curve of the video image, an optimal lambda is sought to make the rate-distortion function approximate the rate-distortion curve of the encoded video image, while satisfying constraints (limiting the encoding bitrate). For a specific encoding system, such as the X.265 encoder, different quantization parameters can yield different rate-distortion functions. Therefore, a rate-distortion optimization algorithm can be used to determine the target quantization parameter that best approximates the rate-distortion function and the rate-distortion curve, and the video image is then encoded based on this target quantization parameter.

[0088] However, when encoding video images using related technologies, the same quantizer parameter (QP) is used when encoding mini-GOPs of different lengths. This means the target quantization parameter, which is closest to the rate-distortion function and curve, is used for encoding. Therefore, the bitrate is the same for mini-GOPs of different lengths. Since a larger mini-GOP has more B-frames (reference P-frames) and thus a higher importance, more bitrate needs to be allocated to reduce mini-GOP distortion. Using the same bitrate for different mini-GOP lengths increases the distortion of P-frames, leading to increased overall mini-GOP distortion and reduced video quality. Furthermore, a larger mini-GOP with more B-frames increases the distortion of P-frames, ultimately increasing the overall distortion of the mini-GOP and reducing its video quality.

[0089] In view of the above problems, the exemplary embodiments of this disclosure provide an image processing method. The application scenarios of this image processing method include, but are not limited to: after obtaining a current mini-GOP to be processed, obtaining the length of the current mini-GOP; determining a first quantization parameter for the P-frame images in the current image group to be processed based on the length of the current mini-GOP; wherein the first quantization parameter is negatively correlated with the length of the mini-GOP; and encoding the first target frame image based on the first quantization parameter. This method can effectively reduce the distortion of P-frame images in the mini-GOP, thereby reducing the overall distortion of the mini-GOP and improving the video quality of the mini-GOP.

[0090] To implement the above-described image processing method, an exemplary embodiment of this disclosure provides an image processing system. Figure 2 A schematic architecture diagram of the image processing system is shown. Figure 2 As shown, the image processing system 200 may include a server 210 and a terminal device 220. The server 210 is a backend server deployed by the image processing service provider. The terminal device 220 is a terminal device with image processing products installed; more specifically, the terminal device may be a smartphone, personal computer, tablet computer, etc. The server 210 and the terminal device 220 can establish a connection through a network to perform image processing.

[0091] It should be understood that server 210 can be a single server or a cluster of multiple servers. This disclosure does not limit the specific architecture of server 210.

[0092] Specifically, terminal device 220 can acquire the current image group to be processed and send it to server 210. Server 210 can acquire the current image group to be processed and its length; determine a first quantization parameter of the first target frame image in the current image group to be processed based on the length of the current image group to be processed; wherein the first quantization parameter is negatively correlated with the length of the image group to be processed; and return the first quantization parameter to terminal device 210, which encodes the first target frame image based on the first quantization parameter.

[0093] In one optional implementation, the image processing function of the terminal device can be implemented independently, and the terminal device can independently implement the image processing method provided in the embodiments of this disclosure.

[0094] Figure 3 This is a flowchart illustrating an image processing method according to an exemplary embodiment. The image processing method can be applied to a terminal device, such as... Figure 3 As shown, the procedure includes steps S301 to S303.

[0095] Step S301: Obtain the current image group to be processed and obtain the length of the current image group to be processed;

[0096] Step S302: Determine the first quantization parameter of the first target frame image in the current image group to be processed based on the length of the current image group to be processed;

[0097] In an exemplary embodiment of this disclosure, the first quantization parameter is negatively correlated with the length of the image group to be processed.

[0098] Step S303: Encode the first target frame image according to the first quantization parameter.

[0099] In summary, the image processing method provided in this disclosure, when the image group to be processed is a mini-GOP and the first target frame image is a P-frame image in the mini-GOP, can determine the first quantization parameter of the P-frame image in the current image group to be processed based on the length of the mini-GOP; and the first quantization parameter of the P-frame image is negatively correlated with the length of the mini-GOP; since the larger the quantization parameter, the lower the bitrate, the larger the length of the mini-GOP, the higher the bitrate of the P-frame in the mini-GOP, which can effectively reduce the distortion of the P-frame image in the mini-GOP, thereby reducing the overall distortion of the mini-GOP and improving the video quality of the mini-GOP.

[0100] The following is about Figure 3 Each step in the process will be explained in detail:

[0101] In step S301, the terminal device can obtain the current image group to be processed and the length of the current image group to be processed.

[0102] In an exemplary embodiment of this disclosure, the current image group to be processed can be a Group of Pictures (GOP) or a mini-GOP; no specific limitation is made here. An image processing product can be running on the terminal device. During the operation of the image processing product, the terminal device can obtain the length of the current image group to be processed.

[0103] In step S302, the terminal device can determine the first quantization parameter of the first target frame image in the current image group to be processed based on the length of the current image group to be processed. The quantizer parameter (QP) is the sequence number of the quantization step size Qstep. For luminance coding, there are 52 possible values ​​for the quantization step size Qstep, with QP ranging from 0 to 51. For chroma coding, QP ranges from 0 to 39. The quantization parameter reflects the compression of spatial details in the image. The smaller the QP value, the finer the quantization, the higher the image quality, and the longer the bitstream generated by encoding. This is because when the QP value is very small, most of the image details are preserved; when the QP value is large, more image details are lost, the bitrate decreases, but image distortion is enhanced and quality degrades.

[0104] In an exemplary embodiment of this disclosure, when the current image group to be processed is a mini-GOP, the first target frame image is a P-frame image in the mini-GOP, and the first quantization parameter is negatively correlated with the length of the image group to be processed.

[0105] In one alternative embodiment, such as Figure 4 As shown, the terminal device determines the first quantization parameter of the target frame image in the current image group to be processed based on the length of the current image group to be processed, including steps S401 to S403:

[0106] Step S401: Obtain the first target parameter factor of the first target frame image.

[0107] In an exemplary embodiment of this disclosure, the terminal device acquires the first quantization parameter factor of the first target frame image, which includes:

[0108] Obtain the SATD of the first target frame image and the complexity of the historical frame images; calculate a first weighted sum of the SATD of the first target frame image and the complexity of the historical frame images; calculate the ratio of the first weighted sum to the number of historical frame images; determine the first quantization parameter factor based on the ratio.

[0109] For example, the historical frame images are a predetermined number of frame images preceding the first target frame image. For instance, the historical frame images are 20 frame images preceding the first target frame image, meaning the first target frame image is the 21st frame image. In one possible embodiment, the first weighting can be calculated according to the following formula:

[0110] cplx_sum(i)=0.5*cplx_sum(i-1)+SATD(2);

[0111] Where cplx_sum(i) is the first weighted sum; cplx_sum(i-1) is the complexity of the historical frame image, representing the cumulative complexity of the historical frame image; SATD is the SATD of the first target frame image.

[0112] Furthermore, after determining the first weighted sum, the ratio of the first weighted sum to the number of historical frame images can be calculated using the following formula:

[0113] cplx_blur=cplx_sum(i) / cplx_count (3);

[0114] Where cplx_count is the number of historical frame images; cplx_blur represents the ratio of the first weighted sum to the number of historical frame images.

[0115] Furthermore, after determining the ratio of the first weighted sum to the number of historical frame images, the first quantization parameter factor can be calculated according to the following formula:

[0116] qscale = cplx_blur 1-qc (4);

[0117] Where qscale is the first quantization parameter factor, and qc is the compression factor, which is usually a constant. For example, in an X.265 encoder, qc is 0.6.

[0118] Step S402: Determine the weight of the quantization factor parameter corresponding to the length of the current image group to be processed;

[0119] In embodiments of this disclosure, the weight of the quantization factor parameter is negatively correlated with the length of the current image group to be processed.

[0120] In the embodiments of this disclosure, the rate-distortion function of the mini-GOP can be expressed as formula (5):

[0121] J=(D1+D2+..Dn)+lambda(R1+R2+…Rn)(5);

[0122] Where D1 represents the distortion of the first frame (P-frame) in the mini-GOP, which can be either SAD or SATD of the first frame (P-frame). D2 represents the distortion of the second frame in the mini-GOP, and so on, with Dn representing the distortion of the nth frame in the mini-GOP; R1 represents the bitrate of the first frame (P-frame) in the mini-GOP, R2 represents the bitrate of the second frame in the mini-GOP, and so on, with Rn representing the bitrate of the nth frame in the mini-GOP; J represents the rate-distortion cost of the entire mini-GOP.

[0123] Differentiating formula (5) with respect to R1 yields formula (6). The bitrate change of the P-frame image allocation is represented by dR1, and the distortion change of the mini-GOP is represented by dD1+dD2+..dDn, where dD1 represents the distortion change value of the first frame (P-frame) in the mini-GOP, and dD2 represents the distortion change value of the second frame in the mini-GOP.

[0124] dJ = (dD1 + dD2 + .. dDn) / dR1 + lambda (6).

[0125] According to formula (6), when dJ = 0, the formula for calculating lambda corresponding to mini-GOP is as shown in (7):

[0126] lambda =- (dD1 + dD2 + .. dDn) / dR1 (7);

[0127] According to formula (7), the formula for calculating lambda for the P-frame image is shown in (8):

[0128] lambda_p =- dD1 / dR1 (8);

[0129] Where lambda_p is the lambda corresponding to the P-frame image.

[0130] According to formulas (6) to (8), the relationship between lambda_p corresponding to the P-frame image and lambda corresponding to the mini-GOP is shown in formulas (9) and (10):

[0131] lambda_p = lambda * w(9);

[0132] w=dD1 / (dD1+dD2+..dDn)(10).

[0133] Where w represents the ratio of the distortion change of the P-frame image to the total distortion change of the mini-GOP. From formula (10), it can be seen that the larger the value of n, that is, the more frames other than the P-frame image in the mini-GOP, the smaller w is. Since the second, third, ..., nth frames in the mini-GOP are all B-frame images referencing the P-frame image, the more B-frame images referencing the P-frame image in the mini-GOP, that is, the larger the length of the mini-GOP, the smaller w is.

[0134] In the embodiments of this disclosure, the correspondence between lambda and the quantization parameter factor is shown in formula (11):

[0135] lambda = qscale / x (11);

[0136] Where x is a positive real number, for example, x can take the value of 0.85 or other values, and no specific limitation is made here in this embodiment. As can be seen from formula (11), lambda is proportional to the quantization parameter factor. Therefore, the ratio w of the distortion change of the P-frame image to the distortion change of the entire mini-GOP can be used as the quantization factor parameter weight of the P-frame image. Since w is smaller when the length of the mini-GOP is larger, it can be concluded that the quantization factor parameter weight is negatively correlated with the length of the current image group to be processed.

[0137] In one optional embodiment, the terminal device determines the quantization parameter factor weights corresponding to the length of the image group to be processed, including:

[0138] For each length of the current image group to be processed, multiple quantization parameter factor weights are obtained in a preset interval corresponding to that length according to a preset step size; the Bjontegaard delta bitrate (BDBR) parameter value corresponding to each of the multiple quantization parameter factor weights is calculated; and the quantization parameter factor weight corresponding to the maximum value of the BDBR parameter value is taken as the quantization factor parameter weight.

[0139] For example, taking the open-source encoder X265 as an example, when the maximum length of the mini-GOP configured by the encoder is 4, the mini-GOP can be divided into four categories: mini-GOP length of 1, which is a continuous P-frame image (frame structure is P); mini-GOP length of 2, which contains a B-frame image (frame structure is PB); mini-GOP length of 3, which contains two B-frame images (frame structure is PBB); and mini-GOP length of 4, which contains three B-frame images (frame structure is PBBB).

[0140] For the above four types of mini-GOPs, the following explains how to determine the quantization factor weight w[1] corresponding to a mini-GOP length of 1. Multiple quantization factor weights w can be obtained by sequentially increasing the preset interval corresponding to a length of 1, such as [0.7, 1.4], with a preset step size of such as 0.1, for example, 0.7, 0.8, 0.9...1.4. Then, the BDBR parameter value corresponding to each of the multiple quantization factor weights is calculated, and the quantization factor weight corresponding to the maximum value of the BDBR parameter value is taken as w[1]. For example, the BDBR parameter value corresponding to 0.8 is the largest, so 0.8 is taken as w[1]. When the length of the mini-GOP is 2, 3, or 4, the determination methods of w[2], w[3], and w[4] are similar to w[1], and will not be repeated here in this embodiment. It should be noted that the larger the length of the mini-GOP, the smaller the value of its corresponding preset interval. For example, when the length of a mini-GOP is 2, its corresponding preset interval is [0.4, 0.7], and the value of [0.4, 0.7] is less than the value of [0.7, 1.4].

[0141] Step S403: Determine the first quantization parameter based on the first quantization parameter factor and the weight of the quantization factor parameter.

[0142] In embodiments of this disclosure, the first quantization parameter can be calculated according to the following formula:

[0143] QP= 12.0 + 6.0 * (double)log2(w*qscale / x) (12);

[0144] Wherein, QP is the first quantization parameter. For example, when the maximum length of the mini-GOP is 4, when the length of the mini-GOP is 1, replace w in formula (12) with w[1] and calculate the QP corresponding to the length 1; when the length of the mini-GOP is 2, replace w in formula (12) with w[2] and calculate the QP corresponding to the length 2; when the length of the mini-GOP is 3, replace w in formula (12) with w[3] and calculate the QP corresponding to the length 3; when the length of the mini-GOP is 4, replace w in formula (12) with w[4] and calculate the QP corresponding to the length 4.

[0145] Step S303: The terminal device encodes the first target frame image according to the first quantization parameter.

[0146] In embodiments of this disclosure, the terminal device determines a first bitrate of the first target frame image based on the first quantization parameter; and encodes the first target frame image based on the first bitrate.

[0147] For example, the relationship between bit rate and distortion and QP is as follows: the higher the QP, the lower the encoding bit rate and the greater the distortion; the lower the QP, the higher the encoding bit rate and the smaller the distortion. Therefore, after calculating the QP of the P-frame image using formula (12), the bit rate of the P-frame image is determined based on the QP, and the P-frame image is encoded, thereby determining the distortion of the encoded P-frame image.

[0148] In embodiments of this disclosure, such as Figure 5 As shown, after the terminal device encodes the first target frame image according to the first quantization parameter, the method further includes:

[0149] Step S501: Determine other quantization parameters for other frames in the current image group to be processed based on the first quantization parameter;

[0150] In embodiments of this disclosure, the other frame images are images in the current image group to be processed other than the first target frame image. For example, the other frame images are B-frame images in a mini-GOP.

[0151] In embodiments of this disclosure, the terminal device determines other quantization parameters of other frames in the image to be processed based on the first quantization parameter, including:

[0152] The levels of the other frame images are obtained; a second quantization parameter corresponding to the level of the other frame images is determined; wherein the second quantization parameter is inversely proportional to the level of the other frame images; a third quantization parameter of the second target frame image in the next image group to be processed is obtained; a second weighted sum of the first quantization parameter, the second quantization parameter, and the third quantization parameter is calculated, and the second weighted sum is used as the other quantization parameter.

[0153] For example, when the mini-GOP length is 4, it includes 3 B-frame images, and the frame structure of the mini-GOP is PBBB. The second B-frame image has the highest quantization level, so the third quantization parameter corresponding to the second B-frame image is the largest. The first quantization parameter, the third quantization parameter, and a second weighted sum of the third quantization parameter are calculated, and this second weighted sum is used as the other quantization parameters of the second B-frame image. Therefore, the other quantization parameters of the second B-frame image are the smallest.

[0154] For example, the higher the grade of a B-frame image, the greater its importance. Therefore, its corresponding other quantization parameters should be smaller in order to allocate a higher bitrate to the B-frame image and improve its quality.

[0155] Step S502: Encode the other frame images according to the other quantization parameters.

[0156] In embodiments of this disclosure, the terminal device determines a second bitrate for the other frame images based on the other quantization parameters; and encodes the other frame images according to the second bitrate. The encoding method for the other frame images is similar to that for P-frame images, and will not be described again here.

[0157] Figure 6 This is a schematic diagram illustrating an image processing apparatus according to an exemplary embodiment. Figure 6 As shown, the image processing apparatus 600 includes:

[0158] The length acquisition module 601 is configured to acquire the current image group to be processed and acquire the length of the current image group to be processed.

[0159] The first quantization parameter determination module 602 is configured to determine a first quantization parameter of the first target frame image in the current image group to be processed based on the length of the current image group to be processed; wherein the first quantization parameter is negatively correlated with the length of the image group to be processed;

[0160] The first image processing module 603 is configured to encode the first target frame image according to the first quantization parameter.

[0161] Optionally, the first quantization parameter determination module 602 is configured as follows:

[0162] Obtain the first quantization parameter factor of the first target frame image;

[0163] Determine the quantization factor parameter weights corresponding to the length of the current image group to be processed; wherein the quantization factor parameter weights are negatively correlated with the length of the current image group to be processed;

[0164] The first quantization parameter is determined based on the first quantization parameter factor and the weight of the quantization factor parameter.

[0165] Optionally, the first quantization parameter determination module 602 is configured as follows:

[0166] For each length of the current image group to be processed, multiple quantization parameter factor weights are obtained in a preset interval corresponding to that length according to a preset step size;

[0167] Calculate the BDBR parameter value corresponding to each of the multiple quantization parameter factor weights;

[0168] The quantization parameter factor weight corresponding to the maximum value of the BDBR parameter is used as the quantization factor parameter weight.

[0169] Optionally, the first quantization parameter determination module 602 is configured as follows:

[0170] The complexity of obtaining the SATD of the first target frame image and the historical frame images;

[0171] Calculate the first weighted sum of the SATD of the first target frame image and the complexity of the historical frame image;

[0172] Calculate the ratio of the first weighted sum to the number of historical frame images;

[0173] The first quantization parameter factor is determined based on the ratio.

[0174] Optionally, the device further includes: a second image processing module 604, configured to:

[0175] Other quantization parameters of other frame images in the current image group to be processed are determined based on the first quantization parameter, wherein the other frame images are images in the current image group to be processed other than the first target frame image;

[0176] The other frame images are encoded according to the other quantization parameters.

[0177] Optionally, the second image processing module 604 is configured to:

[0178] Obtain the rating of the other frame images;

[0179] A second quantization parameter is determined that corresponds to the level of the other frame images; wherein the second quantization parameter is inversely proportional to the level of the other frame images;

[0180] Obtain the third quantization parameter of the second target frame image in the next image group to be processed;

[0181] Calculate a second weighted sum of the first quantization parameter, the second quantization parameter, and the third quantization parameter, and use the second weighted sum as the other quantization parameters.

[0182] Optionally, the second image processing module 604 is configured to:

[0183] The second bitrate of the other frame images is determined based on the other quantization parameters;

[0184] The other frame images are encoded according to the second bitrate.

[0185] Optionally, the first image processing module 603 is configured to:

[0186] The first bitrate of the first target frame image is determined based on the first quantization parameter.

[0187] The first target frame image is encoded according to the first bit rate.

[0188] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0189] Exemplary embodiments of this disclosure also provide an electronic device, which may be a terminal device. References below... Figure 7 This electronic device will be described. It should be understood that... Figure 7 The electronic device 700 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0190] like Figure 7 As shown, the electronic device 700 is presented in the form of a general-purpose computing device. The components of the electronic device 700 may include, but are not limited to: at least one processing unit 710, at least one storage unit 720, and a bus 730 connecting different system components (including the storage unit 720 and the processing unit 710).

[0191] The storage unit stores program code, which can be executed by the processing unit 710 to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of the present invention. For example, the processing unit 710 can perform actions such as... Figure 2 The methods and steps shown are as follows.

[0192] Storage unit 720 may include volatile storage units, such as random access memory (RAM) 721 and / or cache memory 722, and may further include read-only memory (ROM) 723.

[0193] The storage unit 720 may also include a program / utility 724 having a set (at least one) of program modules 725, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0194] Bus 730 may include a data bus, an address bus, and a control bus.

[0195] Electronic device 700 can also communicate with one or more external devices 800 (e.g., keyboards, pointing devices, Bluetooth devices, etc.) via input / output (I / O) interface 740. Electronic device 700 can also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via network adapter 750. As shown, network adapter 750 communicates with other modules of electronic device 700 via bus 730. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0196] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0197] Those skilled in the art will understand that various aspects of this disclosure can be implemented as systems, methods, or program products. Therefore, various aspects of this disclosure can be embodied in entirely hardware implementations, entirely software implementations (including firmware, microcode, etc.), or implementations combining hardware and software aspects, collectively referred to herein as “circuit,” “module,” or “system.” Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0198] In addition, this disclosure also provides a computer-readable storage medium that, when the instructions in the computer-readable storage medium are executed by the processor of an electronic device, enables the electronic device to perform the image processing method provided in the above embodiments.

[0199] In addition, this disclosure also provides a computer program product, including computer instructions, which, when executed on an electronic device, cause the electronic device to perform the image processing method provided in the above embodiments.

[0200] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0201] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. An image processing method, characterized by, The method comprises: acquiring a current to-be-processed image group and acquiring a length of the current to-be-processed image group; determining a first quantization parameter of a first target frame image in the current to-be-processed image group according to the length of the current to-be-processed image group; wherein the first quantization parameter is negatively correlated with the length of the to-be-processed image group, and the first target frame image is a P frame image; encoding the first target frame image according to the first quantization parameter.

2. The image processing method of claim 1, wherein, The determination of the first quantization parameter of the target frame image in the current to-be-processed image group according to the length of the current to-be-processed image group comprises: acquiring a first quantization parameter factor of the first target frame image; determining a quantization factor parameter weight corresponding to the length of the current to-be-processed image group; wherein the quantization factor parameter weight is negatively correlated with the length of the current to-be-processed image group; determining the first quantization parameter according to the first quantization parameter factor and the quantization factor parameter weight.

3. The image processing method of claim 2, wherein, The determination of the quantization factor parameter weight corresponding to the length of the to-be-processed image group comprises: for each length of the current to-be-processed image group, acquiring a plurality of quantization factor weights in a preset interval corresponding to the length according to a preset step length; calculating a BDBR parameter value corresponding to each of the plurality of quantization factor weights; taking the quantization factor weight corresponding to the maximum value of the BDBR parameter value as the quantization factor parameter weight.

4. The image processing method of claim 2, wherein, The acquisition of the first quantization parameter factor of the first target frame image comprises: acquiring a transformed absolute value difference SATD of the first target frame image and a complexity of a historical frame image; calculating a first weighted sum value of the SATD of the first target frame image and the complexity of the historical frame image; calculating a ratio of the first weighted sum value to the number of the historical frame images; determining the first quantization parameter factor according to the ratio.

5. The method of claim 1, wherein, After the encoding of the first target frame image according to the first quantization parameter, the method further comprises: determining other quantization parameters of other frame images in the current to-be-processed image group according to the first quantization parameter, the other frame images being images other than the first target frame image in the current to-be-processed image group; encoding the other frame images according to the other quantization parameters.

6. The image processing method of claim 5, wherein, The determination of the other quantization parameters of the other frame images in the to-be-processed image group according to the first quantization parameter comprises: acquiring a level of the other frame images; determining a second quantization parameter corresponding to the level of the other frame images; wherein the second quantization parameter is inversely proportional to the level of the other frame images; acquiring a third quantization parameter of a second target frame image in a next to-be-processed image group; calculating a second weighted sum value of the first quantization parameter, the second quantization parameter and the third quantization parameter, and taking the second weighted sum value as the other quantization parameter.

7. The image processing method of claim 5, wherein, The encoding of the other frame images according to the other quantization parameters comprises: determining a second code rate of the other frame images according to the other quantization parameters; encoding the other frame images according to the second code rate.

8. The image processing method of claim 1, wherein, The encoding the first target frame image according to the first quantization parameter comprises: determining a first code rate of the first target frame image according to the first quantization parameter; encoding the first target frame image according to the first code rate.

9. An image processing apparatus characterized by comprising: comprise: a length obtaining module configured to obtain a current to-be-processed image group and obtain a length of the current to-be-processed image group; a first quantization parameter determining module configured to determine a first quantization parameter of a first target frame image in the current to-be-processed image group according to the length of the current to-be-processed image group; wherein the first quantization parameter is negatively correlated with the length of the to-be-processed image group, and the first target frame image is a P frame image; a first image processing module configured to encode the first target frame image according to the first quantization parameter.

10. An electronic device, comprising: comprise: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the image processing method according to any one of claims 1 to 8.

11. A computer readable storage medium characterized by When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the image processing method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method and device for code rate control in video coding

    CN101420601A