Video encoding method and device, computer readable storage medium, and terminal device

By performing multiple encoding and quantization parameter adjustments on video frame images, the problem of inaccurate bit rate control for flat areas and complex areas in the prior art is solved, and more accurate bit rate control and consistency of picture quality of video frame images is achieved.

CN115589486BActive Publication Date: 2025-04-22SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211192465.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-28
Publication Date
2025-04-22
Estimated Expiration
2042-09-28

AI Technical Summary

Technical Problem

Existing video encoding technology is difficult to achieve accurate bit rate control of flat areas and complex areas in video frame images, resulting in inconsistent picture quality.

Method used

By dividing the video frame image into M primary coded bars and performing secondary encoding based on the first coded bit information, the number of macroblock rows and their quantization parameters of each secondary coded bar are readjusted to achieve more accurate code rate control.

Benefits of technology

The quantization parameter setting of flat areas and complex areas in the video frame image is realized, ensuring the accuracy of bit rate control and the consistency of picture quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115589486B_ABST
    Figure CN115589486B_ABST
Patent Text Reader

Abstract

A video encoding method and device, a computer-readable storage medium, and a terminal device, the method comprising: dividing a video frame image into M primary encoding strips, M≥2; encoding the M primary encoding strips using the same first quantization parameter to obtain encoding information corresponding to each primary encoding strip; re-dividing the video frame image according to the encoding information to obtain multiple secondary encoding strips; determining the quantization parameter of each secondary encoding strip; sequentially encoding each secondary encoding strip using its corresponding quantization parameter to obtain encoding data corresponding to the video frame image. By using the scheme of the present invention, more accurate bit rate control can be achieved in the video encoding process to ensure the consistency of picture quality in different areas of the video image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of video encoding technology, and in particular to a video encoding method and device, a computer-readable storage medium, and a terminal device. Background Art

[0002] At present, with the rapid development of communication technology and semiconductor technology, mobile devices have been widely popularized, and terminal multimedia applications have become increasingly rich. Video applications such as live broadcast, online conferences, video calls, terminal recording functions, etc., all apply video encoding technology. For video or streaming media, bit rate is an important parameter, which refers to the amount of data contained / transmitted by the video per unit time. For the same encoder input, the higher the actual bit rate after encoding and compression using the same encoder, the larger the amount of data per unit time, and the corresponding picture content is clearer and the picture quality is better.

[0003] Although users subjectively want the clearest picture quality, objectively speaking, storage and network bandwidth are limited, so the size of video files is subject to certain restrictions. At the same time, in order to facilitate real-time transmission of code streams, online video applications also need to avoid generating large amounts of data, thereby increasing the challenge to bandwidth. All of the above require effective control of the video bit rate, and in some scenarios, not only the average bit rate but also the instantaneous bit rate needs to be controlled.

[0004] The visual characteristics of the human eye determine that the human eye is more sensitive to distortion in flat areas of an image. When faced with flat areas with small color / texture changes, it is easier to visually perceive distortion in flat areas than in complex areas under the same objective coding distortion. However, common rate control algorithms such as CBR (constant bitrate) and VBR (variable bitrate) do not take this visual characteristic of the human eye into account when calculating the QP (Quantization Parameter) of each area, so accurate rate control cannot be achieved. Summary of the invention

[0005] The embodiments of the present invention provide a video encoding method and apparatus, a computer-readable storage medium, and a terminal device to achieve more accurate bit rate control and ensure the consistency of picture quality in different areas of a video image.

[0006] To this end, the embodiment of the present invention provides the following technical solutions:

[0007] On the one hand, an embodiment of the present invention provides a video encoding method, the method comprising:

[0008] Divide the video frame image into M primary encoding strips in terms of height, M ≥ 2;

[0009] Encoding the M primary coding strips using the same first quantization parameter to obtain coding information corresponding to each primary coding strip;

[0010] Re-dividing the video frame image according to the coding information to obtain a plurality of secondary coding strips;

[0011] Determining quantization parameters of each secondary encoding strip;

[0012] Each secondary coding strip is encoded in turn using its corresponding quantization parameter to obtain encoded data corresponding to the video frame image.

[0013] Optionally, dividing the video frame image into M primary encoding strips in terms of height includes: dividing the video frame image into M primary encoding strips evenly in terms of height.

[0014] Optionally, the step of evenly dividing the video frame image into M primary encoding strips in terms of height includes: if the number of macroblock rows of the video frame image height is MB height If it is not an integer multiple of M, the MB1 macroblock rows are divided into the 0th to (M-extra-1)th primary coding strips, and the MB2 macroblock rows are divided into the (M-extra)th to (M-1)th primary coding strips, where: extra=MB heig %M,MB2=MB1+1.

[0015] Optionally, the coding information is a bit number; the multiple secondary coding strips include: a flat area, a transition area, and a complex area, and the transition area is located between the flat area and the complex area.

[0016] Optionally, re-dividing the video frame image according to the coding information to obtain multiple secondary coding strips includes: determining the area types of the M primary coding strips in sequence according to the coding information, and dividing adjacent primary coding strips of the same type into the same secondary coding strip.

[0017] Optionally, the re-dividing the video frame image according to the coding information to obtain a plurality of secondary coding strips includes:

[0018] Determine in sequence according to the coding information whether a current one-time coding strip among the M one-time coding strips is a flat area;

[0019] If yes, the current primary coding strip is divided into the previous primary coding strip as a secondary coding strip with a flat area as the area type;

[0020] If not, the currently set number of primary coding strips are sequentially used as secondary coding strips whose region type is transition region, and the remaining primary coding strips are used as secondary coding strips whose region type is complex region.

[0021] Optionally, the re-dividing the video frame image according to the encoding information to obtain a plurality of secondary encoding strips further comprises: dividing the transition area into a plurality of secondary encoding strips.

[0022] Optionally, determining the quantization parameter of each secondary coding strip includes:

[0023] Determine the current frame-level quantization parameter QP frame ;

[0024] According to the current frame level quantization parameter QP frame Determine the quantization parameter for each secondary encoding stripe.

[0025] Optionally, the current frame level quantization parameter QP frame Determining the quantization parameters of each secondary coding strip includes:

[0026] Set the quantization parameter of the secondary coding strip of the flat area to be less than or equal to the current frame-level quantization parameter QP frame ;

[0027] Set the quantization parameter of the secondary coding strip of the complex area to be greater than or equal to the current frame-level quantization parameter QP frame ;

[0028] The quantization parameter of the secondary coding strip in the transition area is set to be greater than or equal to the quantization parameter of the secondary coding strip in the flat area, and less than or equal to the quantization parameter of the secondary coding strip in the complex area.

[0029] Optionally, the current frame level quantization parameter QP frame Determining the quantization parameters of each secondary coding strip includes:

[0030] Set the quantization parameter of the jth secondary encoding strip to: N is the number of secondary encoding strips, and set And each secondary coding strip remains unchanged or increases in turn.

[0031] On the other hand, an embodiment of the present invention further provides a video encoding device, the device comprising: a first division module, an encoding module, a second division module, and a quantization parameter determination module;

[0032] The first division module is used to divide the video frame image into M primary encoding strips in terms of height, where M≥2;

[0033] The encoding module is used to encode the M primary encoding strips using the same first quantization parameter to obtain encoding information corresponding to each primary encoding strip;

[0034] The second division module is used to re-divide the video frame according to the coding information to obtain a plurality of secondary coding strips;

[0035] The quantization parameter determination module is used to determine the quantization parameter of each secondary encoding strip;

[0036] The encoding module is also used to encode each secondary encoding strip in turn using its corresponding quantization parameter to obtain encoding data corresponding to the video frame image.

[0037] Optionally, the first division module is specifically used to evenly divide the video frame image into M primary encoding strips in terms of height.

[0038] Optionally, the first division module is further configured to divide the number of macroblock rows MB in the video frame image height by height When it is not an integer multiple of M, the MB1 macroblock rows are divided into the 0th to (M-extra-1)th primary coding strips, and the MB2 macroblock rows are divided into the (M-extra)th to (M-1)th primary coding strips, where: extra=MB heigh %M,MB2=MB1+1.

[0039] Optionally, the coding information is a bit number; the multiple secondary coding strips include: a flat area, a transition area, and a complex area, and the transition area is located between the flat area and the complex area.

[0040] Optionally, the second division module is further used to divide the transition area into a plurality of secondary coding strips.

[0041] Optionally, the quantization parameter determination module includes:

[0042] A frame-level quantization parameter determination unit, used to determine the current frame-level quantization parameter QP frame ;

[0043] The slice-level quantization parameter determination unit is used to determine the slice-level quantization parameter QP according to the current frame-level quantization parameter QP frame Determine the quantization parameter for each secondary encoding stripe.

[0044] On the other hand, an embodiment of the present invention further provides a computer-readable storage medium, which is a non-volatile storage medium or a non-transient storage medium, on which a computer program is stored, and is characterized in that the computer program executes the steps of the above-mentioned method when executed by a processor.

[0045] On the other hand, an embodiment of the present invention further provides a terminal device, comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and wherein the processor executes the steps of the aforementioned method when running the computer program.

[0046] The video encoding method and device provided by the embodiment of the present invention are based on a frame-level bit rate control algorithm and utilize Two-Pass (secondary) encoding. According to the bit information of each first encoding strip in the first encoding, the number of macroblock rows and its quantization parameters of each second encoding strip are readjusted during the secondary encoding, thereby more reasonably and effectively setting appropriate quantization parameters for the flat area and complex area in each frame image, achieving more accurate bit rate control, and ensuring the consistency of picture quality in the flat area and the complex area. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 is a flow chart of a video encoding method according to an embodiment of the present invention;

[0048] Figure 2 is a schematic diagram of a situation where the flat area in the video frame image accounts for a small proportion in an embodiment of the present invention;

[0049] Figure 3 is a schematic diagram of a situation where the flat area in a video frame image is centered in proportion in an embodiment of the present invention;

[0050] Figure 4 is a schematic diagram of a situation where a flat area accounts for a large proportion in a video frame image in an embodiment of the present invention;

[0051] Figure 5 Schematic diagram of M primary encoding strips divided during First-Pass encoding in an embodiment of the present invention;

[0052] Figure 6 Schematic diagram of N secondary coding strips divided by Second-Pass coding in an embodiment of the present invention;

[0053] Figure 7 1 is a schematic diagram of a process of two encodings in a video encoding method according to an embodiment of the present invention;

[0054] Figure 8 It is the image obtained by One-Pass encoding of the flat area in the video frame image;

[0055] Fig. 9 It is the image obtained by using Two-Pass encoding in the flat area of ​​the video frame image;

[0056] Fig.10 It is a structural schematic diagram of a video encoding device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0057] In order to make the above-mentioned objects, features and beneficial effects of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0058] Macroblock (MB) is the basic unit of video coding. Usually, a macroblock consists of a luminance pixel block and two additional chrominance pixel blocks. Generally speaking, the luminance block is a 16x16 pixel block, and the size of the two chrominance image pixel blocks depends on the sampling format of the image. For example, for a YUV420 sampled image, the chrominance block is an 8x8 pixel block. In each image, several macroblocks are arranged in the form of slices. The video coding algorithm encodes each macroblock one by one in units of macroblocks and organizes them into a continuous video code stream.

[0059] The encoder rate control algorithm aims to control the bit rate of the output bitstream by adjusting the QP, so that the instantaneous bit rate or average bit rate is close to the set target bit rate, while ensuring that the buffer and bandwidth do not overflow or underflow. The rate control algorithm needs to allocate and achieve the target bit rate based on the target bit rate size configured by the user, the current decoding buffer and bandwidth conditions, and the texture complexity of each frame of the image. The target bit rate allocation algorithm can be subdivided into group of picture (GOP) level bit allocation, frame level bit allocation, stripe level bit allocation, and basic unit level bit allocation according to the granularity of the bit rate allocation.

[0060] Because the human eye has the following visual characteristics, that is, when faced with flat areas with small color and texture changes, it is easier to visually perceive the distortion of flat areas than complex areas under the same objective coding distortion. Therefore, in the same video frame, flat areas require smaller coding distortion to basically maintain the same visual perception as complex areas in the output bitstream.

[0061] The existing One-Pass rate control algorithm cannot effectively distinguish between flat and complex areas in an image because it cannot know the texture distribution information of the current frame. Since the human eye is more sensitive to distortion in flat areas of an image, people are more likely to find mosaics in flat areas under the same coding distortion.

[0062] Two-Pass encoding allows the encoder to encode twice or more times. The advantage of Two-Pass encoding is that it can estimate the unencoded content in advance. The encoding cost is calculated during the first encoding process, and then the bits are used more efficiently during the second encoding process. Two-Pass encoding can effectively improve the defect of the One-Pass algorithm that cannot predict the texture distribution of the current frame, and reasonably allocate the bit rate to a certain extent in the Second-Pass stage.

[0063] The x264 macroblock-level Two-Pass encoding is relatively complex. For real-time encoding scenarios such as DV (Digital Video) recording, it may affect the real-time performance of the scene and cause problems such as video freeze after DV recording. In addition, the hardware cost of the macroblock-level bitrate control algorithm is higher.

[0064] Taking into account that the basic unit-level rate control algorithm has a high algorithm complexity and a large hardware cost, an embodiment of the present invention provides a rate control method and device for video encoding, which is based on a frame-level rate control algorithm and utilizes Two-Pass encoding. According to the bit information of each first coding strip in the first encoding, the number of macroblock rows and its quantization parameters of each second coding strip are readjusted during the second encoding, and appropriate quantization parameters are set for flat areas and complex areas in each frame to achieve more accurate rate control.

[0065] like Figure 1 FIG. 1 is a flow chart of a video encoding method according to an embodiment of the present invention, and the method comprises the following steps:

[0066] Step 101: Divide the video frame image into M primary encoding strips in terms of height, where M≥2.

[0067] In practical applications, the video frame image may be divided in an average or non-average manner, so that the number of macroblocks in different primary coding strips after division is the same or different.

[0068] When the video frame image is evenly divided in height, there are two cases:

[0069] 1. The number of macroblock rows of the video frame image height MB height is an integer multiple of M, then the number of macroblocks evenly divided into M primary coding strips is the same.

[0070] 2. The number of macroblock rows of the video frame image height MB height It is not an integer multiple of M. For this case, there are many ways to divide it.

[0071] For example, a non-restrictive division method may be: divide MB1 macroblock rows into the 0th to (M-extra-1)th primary coding strips, and divide MB2 macroblock rows into the (M-extra)th to (M-1)th primary coding strips.

[0072]

[0073] extra=MB heig %M (2)

[0074] MB2=MB1+1 (3)

[0075] The above-mentioned Floor() represents a round-down operation, and % represents a remainder operation.

[0076] For example, another non-restrictive partitioning method may be: height %(M-1)th macroblock rows are divided into the (M-1)th primary coding strip, and the other macroblock rows are evenly divided into the 0th to (M-2)th primary coding strips.

[0077] Of course, other division methods may also be used, which is not limited in the embodiment of the present invention.

[0078] Step 102: Encode the M primary coding strips using the same first quantization parameter to obtain coding information corresponding to each primary coding strip.

[0079] That is to say, in the First-Pass encoding, the code control algorithm is not used in each encoding bar, and the quantization parameter is set to the first quantization parameter QP C Encoding is performed to ensure that the encoding distortion of each encoding strip is close. Under the same quantization parameter, the number of bits of each encoding strip after First-Pass encoding represents the texture complexity of the current encoding strip. The smaller the number of bits, the smaller the texture change of the current encoding strip. This low-complexity area can be considered a flat area.

[0080] It should be noted that the first quantization parameter QP C is a constant, for example, you can set QP C <30.

[0081] The coding information is the number of bits corresponding to each primary coding strip.

[0082] Step 103: re-divide the video frame image according to the coding information to obtain a plurality of secondary coding strips.

[0083] The purpose of re-dividing the video frame image is to distinguish different areas in the image, and then use different quantization parameters for encoding different areas, so as to more reasonably and effectively set appropriate quantization parameters for the flat area and complex area in each frame image, achieve more precise bit rate control, and ensure the consistency of picture quality in flat areas and complex areas.

[0084] In an embodiment of the present invention, the plurality of secondary encoding strips include: a flat region, a transition region, and a complex region, and the transition region is located between the flat region and the complex region.

[0085] There are many ways to re-divide the video frame image into a plurality of secondary encoding strips, such as:

[0086] In a non-limiting manner, the area types of the M primary coding strips may be determined in sequence according to the coding information, and adjacent primary coding strips of the same type may be divided into the same secondary coding strip.

[0087] In another non-restrictive manner, it can be determined in sequence based on the coding information whether the current first coding strip among the M first coding strips is a flat area; if so, the current first coding strip is divided into the previous first coding strip as a secondary coding strip with an area type of a flat area; if not, the currently set number of first coding strips are sequentially used as secondary coding strips with an area type of a transition area, and the remaining first coding strips are used as secondary coding strips with an area type of a complex area.

[0088] Accordingly, when judging the region type of the M primary coding strips, the judgment can be made according to the number of bits of the primary coding strips. If the number of bits of the primary coding strips is less than the first threshold, the region type of the primary coding strip is determined to be a flat region; if the number of bits of the primary coding strips is greater than the second threshold, the region type of the primary coding strip is determined to be a complex region.

[0089] It should be noted that, for the primary coding strips that are completely evenly divided, that is, the number of macroblocks in the M primary coding strips is the same, the number of bits of the primary coding strips can be the total number of bits of the primary coding strips, or the average number of bits per pixel. For the M primary coding strips that are not evenly divided, the number of bits of the primary coding strips should be the average number of bits per pixel.

[0090] In addition, it should be noted that the first threshold and the second threshold corresponding to the total number of bits and the average number of bits per pixel are also different. The first threshold and the second threshold can be determined based on the statistically obtained prior information. Specifically, after fully collecting video images with flat areas in the early stage, the flat areas in each image can be manually screened out, and the flat areas in these flat areas under a given first quantization parameter QP can be counted. C The second threshold is determined similarly to the first threshold, and will not be described in detail here.

[0091] Furthermore, in order to better balance the changes in quantization parameters corresponding to the flat area and the complex area, the transition area may be divided into a plurality of secondary coding strips.

[0092] For example, the M primary coding strips are judged starting from slice 10 to determine whether they meet the above flat area judgment condition. If they meet the condition, the next primary coding strip is judged until slice 10. i Until the flat area judgment condition is not met. slice10 to slice1 i-1 It can be considered as a flat area in the current coding frame and is divided into the same secondary coding strip slice20, and the area type of the secondary coding strip slice20 is a flat area. After determining the flat area, slice1 in the M primary coding strips i 、slice1 i+1 、slice1 i+2 In the Second-Pass stage, they will also be retained as the secondary coding strips slice21, slice22, and slice23 in the Second-Pass stage coding frame. These secondary coding strips will serve as transition zones between flat areas and complex areas to balance the changes in quantization parameters. i+3 To slice1 M-1 In the Second-Pass stage, it will also be divided into the same secondary encoding strip slice 24 as a complex area.

[0093] By re-dividing the video frame image as described above, 5 secondary coding strips are finally obtained, including 1 flat area, 3 transition areas, and 1 complex area.

[0094] It should be noted that the number of the secondary coding strips and the number of transition areas are merely examples and can be set arbitrarily in specific applications.

[0095] Step 104, determining the quantization parameter of each secondary coding strip.

[0096] Specifically, the current frame-level quantization parameter QP is first calculated based on the frame-level rate control algorithm. frame , the value of the quantization parameter for each secondary encoding strip will be based on QP frame That is, according to the current frame-level quantization parameter QP frame Determine the quantization parameter for each secondary encoding stripe.

[0097] For example, the quantization parameter of the secondary coding strip in the flat area can be set to be less than or equal to the current frame-level quantization parameter QP frame ; Set the quantization parameter of the secondary coding strip of the complex area to be greater than or equal to the current frame level quantization parameter QP frame ; Setting the quantization parameter of the secondary coding strip of the transition area to be greater than or equal to the quantization parameter of the secondary coding strip of the flat area, and less than or equal to the quantization parameter of the secondary coding strip of the complex area.

[0098] For another example, the quantization parameter of the jth secondary encoding strip is set to:

[0099]

[0100] Wherein, N is the number of secondary encoding strips.

[0101] For the overall picture quality, it is recommended No more than ±6, QP j The value range of can be 0 to 51, and remains unchanged or increases for each secondary encoding bar.

[0102] Taking the above five secondary coding strips as an example, Δ QP ={a,b,c,d,e}.

[0103] Furthermore, considering that the proportion of flat areas in the current frame image is different, and because the code control algorithm has allocated the target number of bits to the current frame, the frame-level QP frame It is calculated based on the target number of bits. No matter how the current frame is divided into different regions and the QP is adjusted, the actual number of bits after encoding must still be maintained near the target number of bits.

[0104] Based on the above considerations, the Δ QP There are different ways to choose. For example, Figure 2 , Figure 3 and Figure 4 Three different situations of the flat area ratio in the video frame image shown:

[0105] like Figure 2As shown in the figure, the flat area accounts for a smaller range of the current frame image. In this case, even if a lower QP is given to the flat area, the increased number of bits is within a limited range. Therefore, by appropriately increasing the QP value of the complex area, the overall number of bits of the current frame image will not be affected. In this case, The following setting may be used as a reference: a<b<c<d=0<e.

[0106] like Figure 3 As shown in the figure, the flat area occupies about half of the current frame image. In this case, it is necessary to balance the increased bit consumption of the flat area at low QP and the reduced bit consumption of the complex area at high QP to maintain the overall bit number of the current frame. To this end, Refer to the following settings to maintain The balance of positive and negative increases and decreases: a<b<c=0<d<e.

[0107] like Figure 4 As shown in the figure, the flat area occupies the vast majority of the current frame image. At this time, the QP adjustment of the flat area will greatly affect the overall bit number of the current frame. The complex area needs to significantly increase the QP value to balance the low QP value of the flat area. Therefore, in this case, in order to avoid serious distortion in the complex area, the QP value of the flat area can only be adjusted slightly. The following two configurations can be used as reference: a<b=c=0<d<e; or a<b=c=d=0<e.

[0108] Of course, the values ​​of a, b, c, d, and e and their relationship will vary in different scenarios and different application requirements, and are not limited to the above-listed groups of settings. The values ​​can be adjusted according to actual conditions.

[0109] Step 105 , sequentially encode each secondary coding strip using its corresponding quantization parameter to obtain encoded data corresponding to the video frame image.

[0110] The video encoding method provided by the embodiment of the present invention is based on a frame-level bit rate control algorithm and utilizes Two-Pass encoding. According to the bit information of each first encoding strip in the first encoding, the number of macroblock rows and their quantization parameters of each second encoding strip are readjusted during the secondary encoding.

[0111] Figure 5 A schematic diagram showing M primary encoding strips divided during First-Pass encoding is shown. Figure 6 It is a schematic diagram of N secondary coding strips divided by Second-Pass coding.

[0112] The two encoding processes for the M primary encoding strips and N secondary encoding strips divided as above are as follows: Figure 7After re-dividing the number of macroblock rows and quantization parameters of each secondary coding strip, the output bitstream of Second-Pass will balance the overall picture perception of each frame of video image from the perspective of human visual characteristics.

[0113] like Figure 8 If One-Pass encoding is used in the flat area, the mosaic phenomenon is obvious. Fig. 9 After using the Two-Pass encoding proposed in this patent to reduce coding distortion in flat areas, the mosaic phenomenon is effectively improved.

[0114] It can be seen that by using the video encoding method provided by the embodiment of the present invention, it is possible to more reasonably and effectively set appropriate quantization parameters for the flat area and the complex area in each frame image, achieve more accurate bit rate control, and ensure the consistency of the picture quality of the flat area and the complex area. In particular, for video images that are flat on the top and complex on the bottom, such as images containing outdoor sky and street scenes, the sky is a flat area and the street scene is a complex area, using the solution of the present invention, a better picture effect can be obtained.

[0115] Accordingly, an embodiment of the present invention further provides a video encoding device, such as Fig.10 FIG. 1 is a schematic diagram of the structure of a video encoding device according to an embodiment of the present invention.

[0116] The video encoding device 200 includes: a first division module 201, an encoding module 202, a second division module 203, and a quantization parameter determination module 204. Among them:

[0117] The first division module 201 is used to divide the video frame image into M primary coding strips, M≥2;

[0118] The encoding module 202 is used to encode the M primary encoding strips using the same first quantization parameter value to obtain encoding information corresponding to each primary encoding strip;

[0119] The second division module 203 is used to re-divide the video frame image according to the coding information to obtain a plurality of secondary coding strips;

[0120] The quantization parameter determination module 204 is used to determine the quantization parameter of each secondary encoding strip;

[0121] The encoding module 202 is further configured to sequentially encode each secondary encoding strip using its corresponding quantization parameter to obtain encoding data corresponding to the video frame image.

[0122] In a specific application, the first division module 201 is specifically used to divide the video frame image into M primary encoding strips evenly or unevenly in height. The specific division method can be referred to the description in the above method embodiment of the present invention, which will not be repeated here.

[0123] The second division module 203 can divide the video frame image into a plurality of secondary coding strips in terms of height in a variety of ways. The specific division method can be referred to the description in the above embodiment of the method of the present invention, which will not be described again here.

[0124] A specific structure of the quantization parameter determination module 204 may include the following units:

[0125] A frame-level quantization parameter determination unit, used to determine the current frame-level quantization parameter QP frame ;

[0126] The slice-level quantization parameter determination unit is used to determine the slice-level quantization parameter QP according to the current frame-level quantization parameter QP frame Determine the quantization parameter for each secondary encoding stripe.

[0127] The video encoding device provided by the embodiment of the present invention utilizes Two-Pass encoding. According to the bit information of each first encoding strip in the first encoding, the number of macroblock rows and the quantization parameters of each second encoding strip are readjusted during the secondary encoding. Thus, appropriate quantization parameters can be set for the flat areas and complex areas in each frame image more reasonably and effectively, more accurate bit rate control can be achieved, and the consistency of picture quality in the flat areas and complex areas can be ensured.

[0128] The video encoding method and device provided in the embodiments of the present invention can be applied to various terminals with functions such as shooting, video recording, screen recording, and screen projection, such as mobile phones, computers, monitoring, and driving recorders.

[0129] Regarding the various modules / units included in the various devices and products described in the above embodiments, they can be software modules / units, or hardware modules / units, or they can be partially software modules / units and partially hardware modules / units. For example, for various devices and products applied to or integrated in a chip, the various modules / units included therein can all be implemented in the form of hardware such as circuits, or at least some of the modules / units can be implemented in the form of software programs, which run on a processor integrated inside the chip, and the remaining (if any) modules / units can be implemented in the form of hardware such as circuits; for various devices and products applied to or integrated in a chip module, the various modules / units included therein can all be implemented in the form of hardware such as circuits, and different modules / units can be located in the same component of the chip module (such as a chip, circuit module, etc.) or in different components, or at least some of the modules / units can be implemented in the form of software programs. It is implemented in the form of a software program, which runs on a processor integrated inside the chip module, and the remaining (if any) modules / units can be implemented in hardware such as circuits; for various devices and products applied to or integrated in the terminal equipment, the various modules / units contained therein can be implemented in hardware such as circuits, and different modules / units can be located in the same component (for example, chip, circuit module, etc.) or in different components in the terminal equipment, or, at least some modules / units can be implemented in the form of a software program, which runs on a processor integrated inside the terminal equipment, and the remaining (if any) modules / units can be implemented in hardware such as circuits.

[0130] The present application also discloses a storage medium, which is a computer-readable storage medium and stores a computer program, which can be executed when the computer program is run. Figure 1 All or part of the steps of the method shown in . The storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc. The storage medium may also include a non-volatile memory (non-volatile) or a non-transitory memory, etc.

[0131] The embodiment of the present invention further provides a terminal device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and the processor executes Figure 1 All or part of the steps of the method.

[0132] It should be noted that the “plurality” appearing in the embodiments of the present application refers to two or more than two.

[0133] The first, second, etc. descriptions appearing in the embodiments of the present application are only used for illustration and distinction of the description objects. There is no order, nor do they indicate any special limitation on the number of devices in the embodiments of the present application, and cannot constitute any limitation on the embodiments of the present application.

[0134] The above embodiments may be implemented in whole or in part by software, hardware, firmware or any other combination thereof. When implemented using software, the above embodiments may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means.

[0135] It should be understood that in the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0136] In the several embodiments provided in the present application, it should be understood that the disclosed methods, devices and systems can be implemented in other ways. For example, the device embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0137] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0138] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may be physically included separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0139] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform some steps of the method described in each embodiment of the present application.

[0140] Although the present application is disclosed as above, the present application is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present application. Therefore, the protection scope of the present application shall be subject to the scope defined by the claims.

Claims

1. A video encoding method, characterized in that: The method comprises: Divide the video frame image into M primary encoding strips in terms of height. ; Encoding the M primary coding strips using the same first quantization parameter to obtain coding information corresponding to each primary coding strip; Determine different regions of the video frame image according to the coding information, and re-divide the video frame image according to the different regions to obtain a plurality of secondary coding strips; the different regions include: a flat region, a transition region, and a complex region; Determining quantization parameters of each secondary encoding strip; Each secondary coding strip is encoded in turn using its corresponding quantization parameter to obtain encoded data corresponding to the video frame image.

2. The method according to claim 1, characterized in that The step of dividing the video frame image into M primary encoding strips in terms of height comprises: The video frame image is evenly divided into M primary encoding strips in terms of height.

3. The method according to claim 2, characterized in that The step of evenly dividing the video frame image into M primary encoding strips in terms of height comprises: If the video frame image height has the number of macroblock rows is not an integer multiple of M, then The macroblock rows are divided into 0 to In a one-time coding strip, The macroblock rows are divided into to One-time coding strip, among which, , , .

4. The method according to claim 1, characterized in that: The coding information is a bit number; the plurality of secondary coding strips include: a flat area, a transition area, and a complex area, and the transition area is located between the flat area and the complex area.

5. The method according to claim 4, characterized in that The re-dividing the video frame image according to the coding information to obtain a plurality of secondary coding strips comprises: The area types of the M primary coding strips are determined in sequence according to the coding information, and adjacent primary coding strips belonging to the same type are divided into the same secondary coding strip.

6. The method according to claim 4, characterized in that The re-dividing the video frame image according to the coding information to obtain a plurality of secondary coding strips comprises: Determine in sequence according to the coding information whether a current one-time coding strip among the M one-time coding strips is a flat area; If yes, the current primary coding strip is divided into the previous primary coding strip as a secondary coding strip with a flat area as the area type; If not, the currently set number of primary coding strips are sequentially used as secondary coding strips whose region type is transition region, and the remaining primary coding strips are used as secondary coding strips whose region type is complex region.

7. The method according to claim 5 or 6, characterized in that: The re-dividing the video frame image according to the coding information to obtain a plurality of secondary coding strips further comprises: The transition region is divided into a plurality of secondary encoding strips.

8. The method according to claim 7, characterized in that Determining the quantization parameters of each secondary coding strip includes: Determine the current frame-level quantization parameter ; According to the current frame level quantization parameter Determine the quantization parameter for each secondary encoding stripe.

9. The method according to claim 8, characterized in that The current frame level quantization parameter Determining the quantization parameters of each secondary coding strip includes: Set the quantization parameter of the secondary coding strip of the flat area to be less than or equal to the current frame level quantization parameter ; Set the quantization parameter of the secondary coding strip of the complex area to be greater than or equal to the current frame level quantization parameter ; The quantization parameter of the secondary coding strip in the transition area is set to be greater than or equal to the quantization parameter of the secondary coding strip in the flat area, and less than or equal to the quantization parameter of the secondary coding strip in the complex area.

10. The method according to claim 8, characterized in that The current frame level quantization parameter Determining the quantization parameters of each secondary coding strip includes: Set The quantization parameter of the secondary encoding strip is: , N is the number of secondary encoding strips, and set And each secondary coding strip remains unchanged or increases in turn.

11. A video encoding device, characterized in that: The device comprises: a first division module, an encoding module, a second division module, and a quantization parameter determination module; The first division module is used to divide the video frame image into M primary encoding strips in terms of height, ; The encoding module is used to encode the M primary encoding strips using the same first quantization parameter to obtain encoding information corresponding to each primary encoding strip; The second division module is used to determine different regions of the video frame image according to the coding information, and re-divide the video frame according to the different regions to obtain a plurality of secondary coding strips; the different regions include: a flat region, a transition region, and a complex region; The quantization parameter determination module is used to determine the quantization parameter of each secondary encoding strip; The encoding module is also used to encode each secondary encoding strip in turn using its corresponding quantization parameter to obtain encoding data corresponding to the video frame image.

12. The device according to claim 11, characterized in that The first division module is specifically used to divide the video frame image into M primary encoding strips evenly in height.

13. The device according to claim 12, characterized in that The first division module is also used to divide the number of macroblock rows in the video frame image height. If it is not an integer multiple of M, The macroblock rows are divided into 0 to In a one-time coding strip, The macroblock rows are divided into to One-time coding strip, among which, , , .

14. The device according to claim 11, characterized in that The coding information is a bit number; the plurality of secondary coding strips include: a flat area, a transition area, and a complex area, and the transition area is located between the flat area and the complex area.

15. The device according to claim 14, characterized in that The second division module is further used to divide the transition area into a plurality of secondary coding strips.

16. The device according to claim 15, characterized in that The quantization parameter determination module includes: A frame-level quantization parameter determination unit, used to determine the current frame-level quantization parameter ; A slice-level quantization parameter determination unit is used to determine the current frame-level quantization parameter Determine the quantization parameter for each secondary encoding stripe.

17. A computer-readable storage medium, wherein the computer-readable storage medium is a non-volatile storage medium or a non-transient storage medium, and a computer program is stored thereon, wherein: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are performed.

18. A terminal device, comprising a memory and a processor, wherein the memory stores a computer program that can be run on the processor, characterized in that: When the processor runs the computer program, the steps of the method according to any one of claims 1 to 10 are performed.

Citation Information

Patent Citations

  • Fixed code rate control algorithm with low time delay and low complexity

    CN112040246A

  • Adaptive area division image encoding system

    JP1997074561A