Coding control method, device, equipment and storage medium

By configuring the target encoding strategy, decoupling the encoding algorithm and motion estimation parameters, and selecting the appropriate encoding algorithm, the problem of high encoding complexity in the H.264/AVC encoding method is solved, and the encoding performance and terminal battery life are improved.

CN117750017BActive Publication Date: 2024-09-24SHUXING TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311827393.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2024-09-24
Estimated Expiration
2043-12-27

AI Technical Summary

Technical Problem

The existing H.264/AVC encoding method only starts a specific encoding algorithm when the sub-pixel motion estimation parameter value is specific, resulting in a significant increase in the computational complexity of the encoder, a decrease in encoding performance, and the inability to effectively control the encoding complexity.

Method used

By obtaining the macroblocks of the video to be encoded, the target encoding strategy is configured according to the encoding frame type and complexity parameters of the macroblocks, the encoding algorithm and the motion estimation parameters are decoupled, and an appropriate encoding algorithm is selected to reduce the encoding complexity.

Benefits of technology

It effectively reduces the coding complexity, improves the coding performance and coding revenue, reduces the heat generated by the terminal, and improves the battery life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117750017B
    Figure CN117750017B
Patent Text Reader

Abstract

The present application provides a coding control method, apparatus, device and storage medium, the method comprising: obtaining a video to be encoded, dividing the video to be encoded into macroblocks, and obtaining macroblocks of the video to be encoded; configuring a target coding strategy for the macroblock according to the coding frame type and macroblock complexity parameters of the macroblock; wherein the target coding strategy is a coding strategy for configuring the algorithm state of a preset coding algorithm corresponding to the macroblock; encoding the macroblock using the target coding strategy to obtain the coding result of the macroblock. The technical solution of the present application is achieved by decoupling each coding algorithm in the coding process from the motion estimation parameters, and jointly determining whether to start a specific coding algorithm when encoding a video frame or macroblock according to the coding frame type and macroblock complexity, so that a coding algorithm with a smaller coding complexity is selected from multiple macroblock complexity dimensions for processing, thereby reducing the coding complexity and improving the coding performance and coding benefits.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of coding, and in particular to a coding control method, device, equipment and storage medium. Background Art

[0002] At present, with the rapid development of the live broadcast industry and the video industry, more and more users will watch live broadcasts, long videos and short videos for entertainment in their spare time. In existing video content transmission scenarios, encoding methods such as H.264 / AVC are used to encode, compress and transmit video content. The existing H.264 / AVC encoding method divides the image frame to be encoded into multiple macroblocks and performs pixel reconstruction operations according to each macroblock. However, the existing H.264 / AVC encoding method combines multiple encoding algorithms and controls them through sub-pixel motion estimation parameters. However, this control method only starts a specific encoding algorithm when the value of the sub-pixel motion estimation parameter reaches a specific value, that is, when the motion estimation mode is more complex, resulting in a significant increase in the computational complexity of the encoder and a decrease in encoding performance, and it is impossible to effectively control the encoding complexity at the macroblock level. Summary of the invention

[0003] The embodiments of the present application provide a coding control method, apparatus, device and storage medium, aiming to solve the technical problem in the prior art that the coding complexity of coding modes such as H.264 / AVC cannot be effectively controlled, resulting in reduced coding performance.

[0004] On the one hand, an embodiment of the present application provides a coding control method, the coding control method comprising the following steps:

[0005] Obtaining a video to be encoded, dividing the video to be encoded into macroblocks, and obtaining macroblocks of the video to be encoded;

[0006] Configuring a target coding strategy for the macroblock according to a coding frame type and a macroblock complexity parameter of the macroblock; wherein the target coding strategy is a coding strategy for configuring an algorithm state of a preset coding algorithm corresponding to the macroblock;

[0007] The target encoding strategy is adopted to encode the macroblock to obtain an encoding result of the macroblock.

[0008] In a possible implementation of the present application, configuring the target encoding strategy of the macroblock according to the encoding frame type and macroblock complexity parameter of the macroblock includes:

[0009] Acquire a coding frame type of the macroblock, and configure an initial coding strategy for the macroblock based on the coding frame type, wherein the initial coding strategy is used to configure a coding strategy for an algorithm state of a preset coding algorithm;

[0010] The initial coding strategy is updated according to the coding frame type and the macroblock complexity of the macroblock to obtain a target coding strategy for the macroblock.

[0011] In a possible implementation of the present application, the preset encoding algorithm includes a first encoding algorithm, a second encoding algorithm and a third encoding algorithm;

[0012] The obtaining the coding frame type of the macroblock and configuring the initial coding strategy of the macroblock based on the coding frame type includes:

[0013] Obtaining a coding frame type of the macroblock, where the coding frame type includes a key frame type and a predicted frame type;

[0014] If the coding frame type is a key frame type, the first coding algorithm and the third coding algorithm in the preset coding strategy corresponding to the macroblock are configured in state to obtain an initial coding strategy;

[0015] If the coding frame type is a prediction frame type, the state of the second coding algorithm in the prediction coding strategy corresponding to the macroblock is configured to obtain an initial coding strategy.

[0016] In a possible implementation of the present application, updating the initial coding strategy according to the coding frame type and the macroblock complexity of the macroblock to obtain the target coding strategy of the macroblock includes:

[0017] Acquire a macroblock complexity parameter of the macroblock, wherein the macroblock complexity parameter includes any one or more of a macroblock partition type, a macroblock residual cost, a macroblock rate distortion cost, a macroblock bit number, and a macroblock non-zero coefficient number;

[0018] The preset coding algorithm in the initial coding strategy is configured to update its state according to the coding frame type, the macroblock complexity parameter and the preset complexity threshold, so as to obtain the target coding strategy of the macroblock.

[0019] In a possible implementation of the present application, the state updating configuration of the preset coding algorithm in the initial coding strategy is performed according to the coding frame type, the macroblock complexity parameter and the preset complexity threshold to obtain the target coding strategy of the macroblock, including:

[0020] If the coded frame type is a key frame type, obtaining a macroblock residual cost and a macroblock rate distortion cost in the macroblock complexity parameter;

[0021] If the target residual cost in the macroblock residual cost is less than the remaining residual cost in the macroblock residual cost, and the absolute value of the difference between the target residual cost and the preset residual cost is less than a preset difference threshold, then the state of the first encoding algorithm in the initial encoding strategy is updated to obtain the target encoding strategy of the macroblock;

[0022] If the target rate-distortion cost in the macroblock rate-distortion cost is less than the residual rate-distortion cost in the macroblock rate-distortion cost, the state of the third coding algorithm in the initial coding strategy is updated to obtain the target coding strategy for the macroblock.

[0023] In a possible implementation of the present application, the state updating configuration of the preset coding algorithm in the initial coding strategy is performed according to the coding frame type, the macroblock complexity parameter and the preset complexity threshold to obtain the target coding strategy of the macroblock, including:

[0024] If the coding frame type is a key frame type, obtaining the number of macroblock bits and the number of macroblock non-zero coefficients in the macroblock complexity parameter;

[0025] If the number of bits of the macroblock is less than a preset bit number threshold, updating the state of the third coding algorithm in the initial coding strategy to obtain a target coding strategy for the macroblock;

[0026] Alternatively, if the number of non-zero coefficients of the macroblock is equal to a preset first number threshold, the state of the third coding algorithm in the initial coding strategy is updated to obtain a target coding strategy for the macroblock.

[0027] In a possible implementation of the present application, updating the initial activation state of each of the preset encoding algorithms according to the encoding frame type, the macroblock complexity parameter and the preset complexity threshold, and determining the algorithm activation state of each preset encoding algorithm includes:

[0028] If the coded frame type is a predicted frame type, obtaining the macroblock partition type and the number of macroblock non-zero coefficients in the macroblock complexity parameter;

[0029] If the number of non-zero coefficients of the macroblock is less than a preset second number threshold, performing a first state update on the second coding algorithm in the initial coding strategy to obtain a target coding strategy for the macroblock;

[0030] If the macroblock partition type is a target partition type and the number of non-zero coefficients of the macroblock is greater than a preset third number threshold, a second state update is performed on the second coding algorithm in the initial coding strategy to obtain a target coding strategy for the macroblock.

[0031] In a possible implementation of the present application, before configuring the target encoding strategy of the macroblock according to the encoding frame type and macroblock complexity parameter of the macroblock, the method further includes:

[0032] Performing discrete cosine transform on the macroblock to obtain macroblock coefficients corresponding to the macroblock;

[0033] Quantize the macroblock coefficients according to a preset quantization matrix to obtain the quantized coefficients of each macroblock, and entropy encode the quantized coefficients of each macroblock to obtain the coded bit streams corresponding to each macroblock;

[0034] The number of bits associated with the minimum coded bit stream among the coded bit streams of each macroblock is set as the number of bits of the macroblock;

[0035] Decoding each coded bitstream of each macroblock to obtain a decoding coefficient of each macroblock, and counting the number of macroblock non-zero coefficients of each macroblock based on each decoding coefficient;

[0036] The number of macroblock bits and the number of non-zero coefficients of the macroblock are set as macroblock complexity parameters of each macroblock in the to-be-encoded video.

[0037] On the other hand, the present application provides a coding control device, the coding control device comprising:

[0038] The macroblock division module is configured to obtain a video to be encoded, divide the video to be encoded into macroblocks, and obtain macroblocks of the video to be encoded;

[0039] A strategy configuration module is configured to configure a target coding strategy for the macroblock according to a coding frame type and a macroblock complexity parameter of the macroblock; wherein the target coding strategy is a coding strategy for configuring an algorithm state of a preset coding algorithm corresponding to the macroblock;

[0040] The encoding control module is configured to encode the macroblock using the target encoding strategy to obtain an encoding result of the macroblock.

[0041] On the other hand, the present application also provides a coding control device, the coding control device comprising:

[0042] one or more processors;

[0043] Memory; and

[0044] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the steps of the encoding control method.

[0045] On the other hand, the present application also provides a computer-readable storage medium on which a computer program is stored, and the computer program is loaded by a processor to execute the steps in the encoding control method.

[0046] In the present application, by responding to the encoding control event for the target encoder, the video to be encoded is obtained, the video to be encoded is divided into macroblocks to obtain the macroblocks of the video to be encoded; the target encoding strategy of the macroblock is configured according to the encoding frame type and macroblock complexity parameters of the macroblock; wherein the target encoding strategy is a coding strategy for configuring the algorithm state of the preset encoding algorithm corresponding to the macroblock; the macroblock is encoded using the target encoding strategy to obtain the encoding result of the macroblock. This is achieved by decoupling each encoding algorithm in the encoding process from the motion estimation parameters, and jointly determining whether to start a specific encoding algorithm when encoding a video frame or macroblock according to the encoding frame type and macroblock complexity, so that a coding algorithm with a smaller encoding complexity is selected from multiple macroblock complexity dimensions for processing, thereby reducing the encoding complexity and improving the encoding performance and encoding benefits. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 A schematic diagram of a scenario of a coding control method according to an embodiment of the present application;

[0049] Figure 2 This is a flow chart of an embodiment of the coding control method in the embodiment of the present application;

[0050] Figure 3a A schematic diagram of a scene of an embodiment in which a target encoder divides video data into macroblocks;

[0051] Figure 3b A schematic diagram of a scenario of an embodiment in which a target encoder performs pixel reconstruction on a sub-macroblock;

[0052] Figure 4 A schematic diagram of a flow chart of an embodiment of determining an initial activation state of a preset encoding algorithm in an encoding control method provided in an embodiment of the present application;

[0053] Figure 5 A flowchart of an embodiment of updating the initial activation state of a preset encoding algorithm in the encoding control method provided in an embodiment of the present application;

[0054] Figure 6A schematic diagram of a scenario in which a coding algorithm to be enabled is selected in the coding control method provided in an embodiment of the present application;

[0055] Figure 7 A schematic diagram of a flow chart of an embodiment of obtaining macroblock complexity in a coding control method provided in an embodiment of the present application;

[0056] Figure 8 This is a schematic diagram of the structure of an embodiment of the coding control device provided in the embodiments of the present application;

[0057] Fig. 9 This is a schematic diagram of the structure of an embodiment of the encoding control device provided in the embodiments of the present application. DETAILED DESCRIPTION

[0058] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0059] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0060] In this application, the word "exemplary" is used to mean "serving as an example, illustration, or illustration." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any person skilled in the art to implement and use the invention. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the invention can be implemented without using these specific details. In other instances, well-known structures and processes are not elaborated in detail to avoid obscuring the description of the invention with unnecessary details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in this application.

[0061] At present, with the rapid development of the live broadcast industry and the video industry, more and more users will watch live broadcasts, long videos and short videos for entertainment in their spare time. In existing video content transmission scenarios, encoding methods such as H.264 / AVC are used to encode, compress and transmit video content. The existing H.264 / AVC encoding method divides the image frame to be encoded into multiple macroblocks and performs pixel reconstruction operations according to each macroblock. However, the existing H.264 / AVC encoding method combines multiple encoding algorithms and controls them through sub-pixel motion estimation parameters. However, this control method only starts a specific encoding algorithm when the value of the sub-pixel motion estimation parameter reaches a specific value, that is, when the motion estimation mode is more complex, resulting in a significant increase in the computational complexity of the encoder and a decrease in encoding performance, and it is impossible to effectively control the encoding complexity at the macroblock level.

[0062] Based on this, the present application proposes a coding control method, apparatus, device and computer-readable storage medium to solve the technical problem in the prior art that the coding complexity of coding modes such as H.264 / AVC cannot be effectively controlled, resulting in reduced coding performance.

[0063] The encoding control method in the embodiment of the present invention is applied to an encoding control device, which is arranged in an encoding control device. The encoding control device is provided with one or more processors, a memory, and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the encoding control method; wherein the encoding control device may be an intelligent terminal including an 264 / AVC encoder, such as a mobile phone, a tablet computer, a network device, and a smart computer; optionally, the encoding control device may also be a server, or a service cluster composed of multiple servers.

[0064] like Figure 1 As shown, Figure 1This is a scenario diagram of the coding control method in an embodiment of the present application. The coding control scenario in the embodiment of the present invention includes a coding control device 100 (a coding control apparatus is integrated in the coding control device 100), and a computer-readable storage medium corresponding to the coding control method runs in the coding control device 100 to execute the steps of the coding control method.

[0065] Understandably, Figure 1 The coding control device in the coding control method scenario shown, or the devices included in the coding control device, does not constitute a limitation on the embodiments of the present invention, that is, the number of devices and types of devices of the coding control device included in the coding control method scenario, or the number of devices and types of devices included in each device, do not affect the overall implementation of the technical solution in the embodiments of the present invention, and can all be regarded as equivalent replacements or derivatives of the technical solution claimed to be protected in the embodiments of the present invention.

[0066] The encoding control device 100 in the embodiment of the present invention is mainly used for: acquiring a video to be encoded, dividing the video to be encoded into macroblocks, and obtaining macroblocks of the video to be encoded; configuring a target encoding strategy for the macroblock according to the encoding frame type and macroblock complexity parameters of the macroblock; wherein the target encoding strategy is a coding strategy for configuring the algorithm state of a preset encoding algorithm corresponding to the macroblock; and encoding the macroblock using the target encoding strategy to obtain an encoding result of the macroblock.

[0067] The coding control device 100 in the embodiment of the present invention can be an independent coding control device, such as a smart terminal such as a mobile phone, a tablet computer, a network device, a server, and a smart computer, or it can be a coding control network or a coding control cluster composed of multiple coding control devices.

[0068] The embodiments of the present application provide a coding control method, apparatus, device, and computer-readable storage medium, which are described in detail below.

[0069] It can be understood by those skilled in the art that Figure 1 The application environment shown in is only one of the application scenarios related to the present application solution and does not constitute a limitation on the application scenario of the present application solution. Other application environments may also include Figure 1 More or fewer coding control devices, or coding control network connection relationships shown, such as Figure 1 Only one encoding control device is shown in the figure. It can be understood that the scenario of the encoding control method can also include one or more encoding control devices, which is not specifically limited here. The encoding control device 100 can also include a memory for storing video data and other data.

[0070] It should be noted that Figure 1The scenario diagram of the coding control method shown is only an example. The scenario of the coding control method described in the embodiment of the present invention is to more clearly illustrate the technical solution of the embodiment of the present invention, and does not constitute a limitation on the technical solution provided by the embodiment of the present invention.

[0071] Based on the scenario of the above encoding control method, various embodiments of the encoding control method disclosed in the present invention are proposed.

[0072] like Figure 2 As shown, Figure 2 This is a flow chart of an embodiment of a coding control method in an embodiment of the present application. The coding control method includes the following steps 201 to 203:

[0073] 201. Obtain a video to be encoded, and divide the video to be encoded into macroblocks to obtain macroblocks of the video to be encoded;

[0074] The encoding control method in this embodiment is applied to an encoding control device, and the type and quantity of the encoding control device are not specifically limited. That is, the encoding control device can be one or more intelligent terminals or servers that include a target encoder that supports video encoding methods such as H.264 / AVC. In a specific embodiment, the encoding control device is an intelligent computer.

[0075] The target encoder is an encoder module that supports video encoding methods such as H.264 / AVC, can encode video data, and output the encoded video data. The video to be encoded is the original video stream or video frame to be encoded. In a specific embodiment, the target encoder is an H.264 / AVC encoder.

[0076] Specifically, Figure 3a and Figure 3b As shown, Figure 3a A schematic diagram of a scene of an embodiment in which a target encoder divides video data into macroblocks, Figure 3b A schematic diagram of a scenario of an embodiment in which a target encoder reconstructs pixels of a sub-macroblock. In a specific embodiment, the target encoder obtains a video to be encoded and divides the video to be encoded into macroblocks, that is, the target encoder divides each video frame in the video to be encoded into multiple macroblocks of 16*16 brightness pixels to obtain macroblocks of the video to be encoded. In order to capture the texture features of different image regions, the target encoder further divides each macroblock to obtain sub-macroblocks of different sizes. For example, Figure 3a As shown in FIG. 1 , the target encoder can divide the macroblock into sub-macroblocks of sizes such as 16*16, 16*8, 8*16, 8*8, 8*4, 4*8, and 4*4. Among them, 8*16 is a sub-macroblock with a length of 8 luminance pixels and a width of 16 luminance pixels.

[0077] Depend on Figure 3b As shown, after acquiring each sub-macroblock, the target encoder also selects a prediction mode from a preset intra-frame prediction mode or an inter-frame prediction mode, and uses the prediction mode and the reconstructed pixel values ​​of the adjacent blocks or the reconstructed pixel values ​​of the adjacent frames to generate the predicted pixel value of the prediction unit. Then, the original pixel value of the prediction unit is subtracted from its predicted pixel value to generate a prediction residual; after the prediction residual is transformed and quantized, a transform quantization coefficient is generated; then the transform quantization coefficient is dequantized and de-transformed to generate a reconstruction residual; the reconstruction residual is added to the predicted pixel value to generate the reconstructed pixel value of the sub-macroblock. Among them, the target encoder also calculates the distortion rate according to the difference between the original pixel and the reconstructed pixel of each sub-macroblock. In this calculation process, operations such as transformation, quantization, inverse transformation and dequantization are required, resulting in a high computational complexity of the rate-distortion cost in the mode selection process. The target encoder needs to reduce the computational complexity in the mode selection process by selecting various encoding algorithms. Among them, the coding algorithm includes a rate-distortion-based mode selection coding method (RD mode decision), a rate-distortion-based mode refinement coding algorithm (RD refinement) and a rate-distortion-based quantization parameter selection coding algorithm (QPRD). Among them, the rate-distortion-based mode selection coding method (RD mode decision) is that the target encoder calculates the rate-distortion cost of each macroblock division method in the optimal mode, and then selects the division method with the smallest rate-distortion cost as the optimal division method of the macroblock. The rate-distortion-based mode refinement coding algorithm (RD refinement) is that the target encoder uses the rate-distortion cost of the macroblock as an indicator to refine the optimal prediction mode, thereby obtaining the final optimal prediction mode. The rate-distortion-based quantization parameter selection coding algorithm (QPRD) is that the target encoder uses the rate-distortion cost of the macroblock as an indicator to select the optimal quantization parameter for the current macroblock.

[0078] Specifically, the existing H.264 / AVC encoder couples the motion estimation mode selection with each encoding algorithm, and determines whether to start or not by the value of the motion estimation parameter "sumbe" in the motion estimation mode, and the value of the motion estimation parameter is associated with the complexity of the motion estimation mode. For example, the rate-distortion-based mode selection algorithm is started only when the motion estimation parameter is not equal to 0, the rate-distortion-based mode refinement algorithm is started when the motion estimation parameter is greater than or equal to 2, and the rate-distortion-based quantization parameter selection algorithm is started when the motion estimation parameter is equal to 3. That is, the corresponding encoding algorithm is started only when the complexity of the motion estimation mode is high, and the encoding algorithm cannot be selected according to the actual situation of the macroblock, resulting in an increase in the computational complexity of the target encoder. Therefore, the target encoder needs to control the complexity of the encoding process during the encoding process, thereby reducing the computational complexity of the target encoder.

[0079] Specifically, during operation, the target encoder responds to an encoding control event for the video to be encoded. The encoding control event is an operation event that requests the target encoder to control the preset encoding algorithm configuration during encoding of the video to be encoded. Optionally, the triggering method of the encoding control event is not specifically limited here, that is, the encoding control event can be triggered by a user, for example, the user actively triggers the encoding control event of the target encoder for the video to be encoded by clicking an encoding control button in the encoding control device or an encoding control control of the target encoder. Optionally, the encoding control event can also be actively triggered by the encoding control device, for example, the encoding control device pre-sets an encoding control strategy for the target encoder, and actively triggers the encoding control event when the target encoder encodes the video to be encoded.

[0080] 202. Configure a target coding strategy for the macroblock according to a coding frame type and a macroblock complexity parameter of the macroblock;

[0081] Specifically, after obtaining the video to be encoded, the target encoder divides the video to be encoded, obtains the macroblocks of the video to be encoded, and further obtains the coding frame type and macroblock complexity of each macroblock in the video to be encoded, and configures the target coding strategy of each macroblock according to the coding frame type and macroblock complexity parameters. The target coding strategy is a coding strategy for configuring the algorithm state of the preset coding algorithm corresponding to each macroblock. That is, the target encoder configures the target coding strategy through the coding frame type and macroblock complexity parameters of each macroblock, thereby decoupling each preset coding algorithm from the motion estimation parameters to reduce the computational complexity of enabling the preset coding algorithm.

[0082] Specifically, before encoding the video to be encoded, the target encoder pre-selects the encoding gear and encoding parameters of the video to be encoded, so as to determine the encoding frame type structure of each video frame in the encoded video. For example, in a specific embodiment, the encoding gear selected by the target encoder is the fast encoding gear and the encoding parameter "bframe" is set to 2, then the encoding frame structure of the video to be encoded during the encoding process is IBBPBPBBP. The encoding frame structure includes a key frame type and a predicted frame type. The "I" in the encoding frame structure represents the key frame type, that is, the intra-frame coded image frame; the "B" in the encoding frame structure represents the bidirectional predicted coded image frame in the predicted frame type; the "P" in the encoding frame structure represents the inter-frame predicted coded image frame in the predicted frame type.

[0083] Specifically, the target encoder also obtains the macroblock complexity parameter of each video frame in the video to be encoded, wherein the macroblock complexity parameter is a parameter that characterizes the complexity of each macroblock in the video sequence in video encoding. In a specific embodiment, the macroblock complexity parameter includes any one or more of the macroblock partition type, macroblock residual cost, macroblock rate distortion cost, macroblock bit number, and macroblock non-zero coefficient number.

[0084] The macroblock partition type is a partitioning method for partitioning a macroblock into a plurality of sub-blocks. In a specific embodiment, the macroblock partition type includes 16*16, 16*8, 8*16, 8*8, 8*4, 4*8 and 4*4 partition types.

[0085] The macroblock residual cost is the optimal residual cost (SATD, Sum of Absolute Transform Differences) of each sub-macroblock obtained under a specific macroblock division type. In a specific embodiment, the macroblock residual cost includes a first macroblock residual cost corresponding to dividing the macroblock into 16*16 sub-macroblocks, a second macroblock residual cost corresponding to dividing the macroblock into 8*8 sub-macroblocks, and a macroblock residual cost corresponding to dividing the macroblock into 4*4 sub-macroblocks.

[0086] The macroblock rate-distortion cost is the optimal rate-distortion cost (Rate-Distortion Optimization) of each sub-macroblock obtained under a specific macroblock division type. In a specific embodiment, the macroblock rate-distortion cost includes a first macroblock rate-distortion cost corresponding to dividing the macroblock into 16*16 sub-macroblocks, a second macroblock rate-distortion cost corresponding to dividing the macroblock into 8*8 sub-macroblocks, and a macroblock rate-distortion cost corresponding to dividing the macroblock into 4*4 sub-macroblocks.

[0087] The number of macroblock bits is the number of bits that minimizes the size of the encoded bitstream. The number of non-zero coefficients in a macroblock is the number of non-zero coefficients in the macroblock.

[0088] Specifically, after obtaining the video to be encoded, the target encoder obtains the encoding frame type of the video to be encoded, and configures the initial encoding strategy of each macroblock based on the encoding frame type, that is, the target encoder configures the initial algorithm state of each preset encoding algorithm in the initial encoding strategy through the encoding frame type. Among them, the preset encoding algorithm includes a first encoding algorithm, a second encoding algorithm and a third encoding algorithm. The first encoding algorithm is a rate-distortion-based mode selection encoding method, the third encoding algorithm is a rate-distortion-based mode refinement encoding algorithm, and the second encoding algorithm is a rate-distortion-based quantization parameter selection encoding algorithm.

[0089] Specifically, the target encoder decouples each preset encoding algorithm from the motion estimation parameter, and sets a corresponding algorithm control parameter for each preset encoding algorithm, and controls the activation state of each preset encoding algorithm through the algorithm control parameter. The target encoder adjusts the algorithm control parameters of each preset encoding algorithm according to the encoding frame type of the video to be encoded, thereby setting the initial algorithm state of each preset encoding algorithm in the initial encoding strategy according to the encoding frame type. In a specific embodiment, the algorithm control parameter includes mbrd parameter, rdqp parameter and rdrefine parameter, wherein the mbrd parameter is the algorithm control parameter corresponding to the first encoding algorithm; the rdqp parameter is the algorithm control parameter corresponding to the second encoding algorithm; and the rdrefine parameter is the algorithm control parameter corresponding to the third encoding algorithm. Among them, the initial algorithm state is the algorithm activation state that characterizes each preset encoding algorithm in the initial encoding strategy.

[0090] Specifically, Figure 4 As shown, Figure 4 A flowchart of an embodiment of determining the initial activation state of a preset encoding algorithm in the encoding control method provided in an embodiment of the present application, specifically, comprising steps 301 to 303:

[0091] S301, obtaining a coding frame type of the macroblock, where the coding frame type includes a key frame type and a predicted frame type;

[0092] Specifically, the target encoder obtains the coding frame type of each macroblock in the video to be encoded, and determines whether the coding frame type of the macroblock is a key frame type or a predicted frame type. Among them, the key frame type is an intra-frame coding frame type. The predicted frame type is a non-key frame type that depends on other frames for encoding. Among them, the predicted frame type includes a forward prediction frame type and a bidirectional prediction frame type.

[0093] S302: If the coding frame type is a key frame type, the first coding algorithm and the third coding algorithm in the preset coding strategy corresponding to the macroblock are configured in state to obtain an initial coding strategy;

[0094] Specifically, if the target encoder determines that the encoding frame type of the macroblock is a key frame type, the algorithm control parameters of each preset encoding algorithm are adjusted accordingly, thereby adjusting the initial algorithm state of the preset encoding algorithm in each initial encoding strategy.

[0095] Specifically, after determining that the coding frame type of the macroblock is a key frame type, the target encoder configures the algorithm control parameters of each preset coding algorithm in the initial coding strategy according to the algorithm activation strategy corresponding to the key frame type, sets the algorithm control parameters of the first coding algorithm and the third coding algorithm to the on position, and sets the algorithm control parameters of the second coding algorithm to the off position, thereby setting the initial activation state of the first coding algorithm in the initial coding strategy to the on state, setting the initial activation state of the third coding algorithm to the off state, and setting the initial activation state of the third coding algorithm to the off state.

[0096] S303: If the coding frame type is a prediction frame type, a state configuration is performed on the second coding algorithm in the prediction coding strategy corresponding to the macroblock to obtain an initial coding strategy.

[0097] Specifically, if the target encoder determines that the coding frame type of the macroblock is a predicted frame type, the algorithm control parameters of each preset coding algorithm in the initial coding strategy are configured according to the algorithm activation strategy corresponding to the predicted frame type, the algorithm control parameter corresponding to the second coding algorithm is set to the on position, and the algorithm control parameters corresponding to the first coding algorithm and the second coding algorithm are set to the off position, so that the initial activation state of the second coding algorithm in the initial coding strategy associated with the macroblock of the predicted frame type is set to the on state, and the initial activation state of the first coding algorithm and the third coding algorithm of the video frame of the predicted frame type is set to the off state. This realizes the preliminary configuration of the target coding strategy according to the frame type to reduce the coding complexity.

[0098] Specifically, the target encoder can also update the initial activation state of the preset encoding algorithm according to the encoding frame type and macroblock complexity of each macroblock, and determine the algorithm activation state of each preset encoding algorithm. That is, the target encoder further updates the algorithm control parameters of each preset encoding algorithm in the initial encoding strategy according to the macroblock complexity parameters and encoding frame type of each macroblock in the video to be encoded, thereby determining the final algorithm activation state of each preset encoding algorithm during actual encoding.

[0099] Specifically, the target encoder pre-sets a corresponding preset complexity threshold for the macroblock complexity parameters of each macroblock, and updates the algorithm control parameters of the preset encoding algorithm by encoding the frame type, macroblock complexity parameters and preset complexity parameters, thereby updating the initial activation state of the preset encoding algorithm, and obtaining the algorithm activation state of each preset encoding algorithm after the update.

[0100] like Figure 5 As shown, Figure 5 This is a flow chart of an embodiment of updating the initial activation state of a preset encoding algorithm in the encoding control method provided in an embodiment of the present application. Specifically, based on the above embodiment, in this embodiment, the encoding control algorithm further includes steps 401 to 403:

[0101] 401. If the coded frame type is a key frame type, obtain a macroblock residual cost and a macroblock rate distortion cost in the macroblock complexity parameter;

[0102] Based on the above embodiment, in this embodiment, the target encoder determines the coding frame type of the macroblock, and when determining that the coding frame type of the video to be encoded is a key frame type, that is, when the coding frame type is an I frame, the target encoder further obtains the macroblock residual cost and the macroblock rate distortion cost in the macroblock complexity parameter.

[0103] Among them, the macroblock residual cost includes the optimal macroblock residual cost corresponding to each macroblock partitioning type. In a specific embodiment, the macroblock residual cost includes a first macroblock residual cost satd_i16x16 with a macroblock partitioning type of 16*16, a second macroblock residual cost satd_i8x8 with a macroblock partitioning type of 8*8, and a third macroblock residual cost satd_i4x4 with a macroblock partitioning type of 4*4.

[0104] Among them, the macroblock rate-distortion cost includes the optimal rate-distortion cost corresponding to each macroblock partition type. In a specific embodiment, the macroblock rate-distortion cost includes a first macroblock rate-distortion cost rd_i16x16 for a macroblock partition type of 16*16, a second macroblock rate-distortion cost rd_i8x8 for a macroblock partition type of 8*8, and a third macroblock rate-distortion cost rd_i4x4 for a macroblock partition type of 4*4.

[0105] 402. If the target residual cost in the macroblock residual cost is less than the remaining residual cost in the macroblock residual cost, and the absolute value of the difference between the target residual cost and the preset residual cost is less than a preset difference threshold, then the state of the first coding algorithm in the initial coding strategy is updated to obtain the target coding strategy of the macroblock;

[0106] Specifically, the target encoder pre-sets a preset difference threshold for evaluating the computational complexity of the macroblock residual cost, and the preset difference threshold is calculated by the second macroblock residual cost and the third macroblock residual cost, that is, the macroblock residual cost with a smaller value between the second macroblock residual cost and the third macroblock residual cost is obtained by multiplying it by a preset coefficient to obtain a preset residual threshold. In a specific embodiment, the preset coefficient is 0.1. Specifically, the calculation formula of the preset difference threshold is: thr0=0.1*min(satd_i8x8, satd_i4x4), where thr0 is the preset difference threshold.

[0107] Specifically, the target encoder sets the first macroblock residual cost in the macroblock residual cost as the target residual cost, and sets the third macroblock residual cost as the preset residual cost. If the target macroblock residual cost is less than the remaining residual cost in the target macroblock residual cost, that is, the target macroblock residual cost is less than the second macroblock residual cost and the target macroblock residual cost is less than the third macroblock residual cost, then the target encoder calculates the absolute value of the difference between the target residual cost and the preset residual cost, and compares the absolute value of the difference with the preset difference threshold. If the absolute value of the difference is less than the preset difference threshold, the state of the first coding algorithm in the initial coding strategy is updated, and the algorithm control parameters of the first coding algorithm are updated and set to the off position, that is, the initial enabled state of the first coding algorithm is updated to the off state, and the target coding strategy of the macroblock is obtained. In this embodiment, the algorithm startup state of the first coding algorithm of the target coding strategy is the off state. That is, when the macroblock is subsequently encoded through the target coding strategy, the macroblock is encoded through the third coding algorithm, that is, when the target encoder encodes the macroblock, it follows the rate-distortion-based mode refinement method that is in the activated state in the target coding strategy, and takes the rate-distortion cost of the macroblock as an indicator to refine the optimal prediction mode of the macroblock, thereby obtaining the optimal prediction mode of the macroblock, and processes the macroblock according to the default mode selection algorithm and default quantization parameter selection algorithm of the target encoder.

[0108] 403. If the target rate-distortion cost in the macroblock rate-distortion cost is less than the residual rate-distortion cost in the macroblock rate-distortion cost, update the state of the third coding algorithm in the initial coding strategy to obtain the target coding strategy of the macroblock.

[0109] Specifically, the target encoder also updates the initial activation state of the third encoding algorithm in the initial encoding strategy according to the macroblock rate-distortion cost. That is, the target encoder sets the third macroblock rate-distortion cost in the macroblock rate-distortion cost as the target rate-distortion cost, and compares the target rate-distortion cost with the remaining rate-distortion costs in the macroblock rate-distortion cost except the target rate-distortion cost, that is, compares the target rate-distortion cost with the first macroblock rate-distortion cost and the second macroblock rate-distortion cost in the macroblock rate-distortion cost, thereby updating the initial activation state of the third encoding algorithm in the initial encoding strategy according to the comparison result.

[0110] Optionally, if the target rate-distortion cost is less than the remaining rate-distortion cost in the macroblock rate-distortion cost, that is, the target rate-distortion cost is less than the first macroblock rate-distortion cost and the target rate-distortion cost is less than the second macroblock rate-distortion cost, then the target encoder updates the algorithm control parameter of the third encoding algorithm in the initial encoding strategy corresponding to the macroblock to the off position, and updates the initial activation state of the third encoding algorithm to the off state, so as to obtain an updated target encoding strategy. The algorithm activation state of the third encoding algorithm in the updated target encoding strategy is the off state, that is, when the target encoder encodes the macroblock, the rate-distortion-based mode selection encoding algorithm in the target encoding strategy is in the activated state, and the rate-distortion cost of each division mode of the macroblock is calculated in the optimal mode, and then the division mode with the smallest rate-distortion cost is selected as the optimal division mode of the macroblock, and the macroblock is processed according to the quantization parameter selection algorithm and the default mode refinement algorithm of the target encoder.

[0111] Optionally, in other embodiments, if the coding frame type of the macroblock is a key frame type, the target encoder also updates the initial activation state of each preset coding algorithm in the initial coding strategy according to the number of macroblock bits and the number of macroblock non-zero coefficients in the macroblock complexity parameter to obtain a target coding algorithm, which is configured with the algorithm activation state of the preset coding algorithm.

[0112] Optionally, if the parameter value of the third algorithm control parameter in the initial coding strategy is an on parameter value, and the number of bits of the macroblock is less than a preset bit number threshold, the initial enabled state of the third coding algorithm in the initial coding strategy is updated to a closed state, and a target coding strategy is obtained, wherein the algorithm enabled state of the third coding algorithm in the target coding strategy is a closed state. That is, when the target encoder encodes the macroblock, the rate-distortion-based mode selection coding algorithm in the target coding strategy is in the enabled state, and the rate-distortion cost of each macroblock partitioning method in the optimal mode is calculated, and then the partitioning method with the smallest rate-distortion cost is selected as the optimal partitioning method for the macroblock, and the macroblock is processed according to the quantization parameter selection algorithm and the default mode refinement algorithm of the target encoder.

[0113] The preset bit number threshold is obtained by multiplying the maximum number of bits of the encoded macroblock by the preset bit number coefficient, and is used to determine the threshold parameter of the macroblock bit number calculation complexity. In a specific embodiment, the preset bit number coefficient is 0.75.

[0114] Optionally, if the number of non-zero coefficients of the macroblock is equal to a preset first number threshold, the initial activation state of the third encoding algorithm in the initial encoding strategy is updated to an on state, and a target encoding strategy for the macroblock is obtained, and the algorithm activation state of the third encoding algorithm in the target encoding strategy is an on state. In a specific embodiment, the first number threshold is 0. That is, when the encoding frame type is a key frame type and the number of non-zero coefficients of the macroblock is 0, the initial activation state of the third encoding algorithm in the initial encoding strategy is updated to an on state, and the target encoding strategy for the macroblock is obtained, and the algorithm activation state of the third encoding algorithm is determined to be an on state. That is, when the macroblock is subsequently encoded by the target encoding strategy, the macroblock is encoded by the third encoding algorithm, that is, when the target encoder encodes the macroblock, according to the rate-distortion-based mode refinement method in the target encoding strategy that is in the enabled state, the rate-distortion cost of the macroblock is used as an indicator to refine the optimal prediction mode of the macroblock, thereby obtaining the optimal prediction mode of the macroblock, and processing the macroblock according to the optimal prediction mode.

[0115] Optionally, in other embodiments, if the target encoder determines that the coded frame type is a predicted frame type, the macroblock partition type and the number of macroblock non-zero coefficients in the macroblock complexity parameter are obtained.

[0116] Optionally, if the number of non-zero coefficients of the macroblock is less than a preset second number threshold, the initial activation state of the second coding algorithm in the initial coding strategy is updated to a closed state, the target coding strategy is obtained, and the algorithm activation state of the second coding algorithm in the target coding strategy is determined to be a closed state. In a specific embodiment, the second number threshold is 3.

[0117] Optionally, if the macroblock partition type is a target partition type, and the number of non-zero coefficients of the macroblock is greater than a preset third quantity threshold, the initial activation state of the second encoding algorithm in the initial encoding strategy is updated to an on state, and a target encoding strategy for the macroblock is obtained, wherein the algorithm activation state of the second encoding algorithm in the target encoding strategy is an on state. That is, when the macroblock is subsequently encoded by the target encoding strategy, the macroblock is encoded by the second encoding algorithm: when the target encoder encodes the macroblock, according to the rate-distortion-based quantization parameter encoding method in the target encoding strategy that is in the activated state, the rate-distortion cost of the macroblock is used as an indicator to select the optimal quantization parameter for the current macroblock, and the macroblock is processed by the optimal quantization parameter. In a specific embodiment, the third quantity threshold is 5.

[0118] 203. Encode the macroblock using the target encoding strategy to obtain an encoding result of the macroblock.

[0119] Specifically, when encoding the initial encoding data, the target encoder selects the target encoding algorithm to be started based on the algorithm activation status of each preset encoding algorithm configured in each target encoding strategy, and in the process of encoding the macroblock of the video frame to be encoded, starts the preset encoding algorithm configured in the target encoding strategy corresponding to each encoding frame type and macroblock complexity, so as to adaptively select the preset enabled encoding algorithm according to the target encoding to encode the macroblock of the video to be encoded, and obtain the encoding result of the macroblock.

[0120] Specifically, the encoding control device determines the algorithm activation state of each preset encoding algorithm according to the algorithm control parameters of the preset encoding algorithm, sets the preset encoding algorithm whose algorithm activation state is on as the target encoding algorithm corresponding to the video to be encoded, and starts the target encoding algorithm during the encoding process to drive the target encoder to encode the video to be encoded, so as to obtain the target video data corresponding to the video to be encoded.

[0121] In a specific embodiment, the target encoder obtains the algorithm control parameters corresponding to the first encoding algorithm, the second encoding algorithm and the third encoding algorithm in each macroblock in the video to be encoded and the target encoding strategy, determines the algorithm activation status of the first encoding algorithm, the second encoding algorithm and the third encoding algorithm when encoding the macroblock, sets the preset encoding algorithm whose algorithm activation status is turned on in the target encoding strategy as the target encoding algorithm, adjusts the encoding complexity in the encoding process of the video to be encoded through the target encoding algorithm, and improves the encoding benefit and encoding performance.

[0122] Optionally, if the target encoder determines that the algorithm control parameter of the first encoding algorithm in the target encoding strategy corresponding to the macroblock is an on position based on the encoding frame type and the macroblock complexity parameter, then the algorithm activation state of the first encoding algorithm is determined to be an on state, and when the target encoder encodes the macroblock, the macroblock is processed by the first encoding algorithm, that is, when the target encoder encodes the macroblock, the macroblock is encoded by the first encoding algorithm: a coding algorithm is selected according to the rate-distortion-based mode that is in the startup state in the target encoding strategy, and the rate-distortion cost of each division method of the macroblock is calculated in the optimal mode, and then the division method with the smallest rate-distortion cost is selected as the optimal division method of the macroblock for encoding to obtain the encoded pixel data.

[0123] Optionally, if the target encoder determines that the algorithm control parameter of the second encoding algorithm in the target encoding strategy corresponding to the macroblock is turned on based on the encoding frame type and the macroblock complexity parameter, then the algorithm activation state of the second encoding algorithm of the target encoding strategy is determined to be turned on, and when encoding the macroblock, the macroblock is processed by the second encoding algorithm: when encoding the macroblock, the target encoder selects the optimal quantization parameter for the current macroblock for encoding processing according to the rate-distortion-based quantization parameter encoding method that is in the enabled state in the target encoding strategy, taking the rate-distortion cost of the macroblock as an indicator, to obtain the encoded pixel data.

[0124] Optionally, if the target encoder determines that the algorithm control parameter of the third encoding algorithm in the target encoding strategy corresponding to the macroblock is in the on position based on the encoding frame type and the macroblock complexity parameter, then the algorithm activation state of the third encoding algorithm in the target encoding strategy is determined to be on, and when the target encoder encodes the macroblock, the macroblock is processed by the third encoding algorithm, that is, when the target encoder encodes the macroblock, the rate-distortion-based mode refinement method that is in the enabled state in the target encoding strategy is used to refine the optimal prediction mode of the macroblock using the rate-distortion cost of the macroblock as an indicator, thereby obtaining the optimal prediction mode of the macroblock, and encoding the macroblock through the optimal prediction mode to obtain the encoded pixel data.

[0125] Specifically, Figure 6 As shown, Figure 6 A schematic diagram of a scenario for selecting a coding algorithm to be enabled in the coding control method provided in an embodiment of the present application. The coding control device obtains the frame type and macroblock complexity of each macroblock in the video to be encoded, and sets the algorithm control parameters of the first coding algorithm of the initial coding strategy of the macroblock according to the key frame type and the macroblock complexity, and then determines the algorithm enablement state of the first coding algorithm. When the algorithm enablement state is enabled, the first coding algorithm in the initial coding strategy is set as the target coding algorithm enabled in the subsequent coding process of the macroblock, and the algorithm control parameters of the third coding algorithm are set according to the key frame type and the macroblock complexity, and then the algorithm control parameters of the third coding algorithm in the initial coding strategy are updated, and then the algorithm enablement state of the third coding algorithm is determined to obtain the target coding strategy. When the algorithm enablement state of the third coding algorithm in the target coding strategy is enabled, the third coding algorithm in the target coding strategy is set as the target coding algorithm enabled in the subsequent coding process of the macroblock. In addition, the algorithm activation state of the second encoding algorithm in the target encoding strategy is set according to the predicted frame type and the macroblock complexity. When the algorithm activation state is on, the second encoding algorithm is set as the target encoding algorithm to be turned on in the subsequent encoding process of the macroblock, so as to realize macroblock-level control of the start and stop state of the encoding algorithm according to the encoding frame type and the macroblock complexity.

[0126] In this embodiment, the encoding control device obtains the video to be encoded by responding, divides the video to be encoded into macroblocks, and obtains the macroblocks of the video to be encoded; configures the target encoding strategy of the macroblock according to the encoding frame type and macroblock complexity parameters of the macroblock; wherein the target encoding strategy is an encoding strategy for configuring the algorithm state of the preset encoding algorithm corresponding to the macroblock; and encodes the macroblock using the target encoding strategy to obtain the encoding result of the macroblock. This is achieved by decoupling each encoding algorithm from the motion estimation parameters in the encoding process, and jointly determining whether to start a specific encoding algorithm when encoding a video frame or macroblock according to the encoding frame type and macroblock complexity, so that an encoding algorithm with a smaller encoding complexity is selected from multiple macroblock complexity dimensions for processing, thereby reducing the encoding complexity and improving the encoding performance and encoding benefits, and being able to reduce the heat generated in applications such as live broadcast applications / video playback applications, and improve the terminal endurance.

[0127] like Figure 7 As shown, Figure 7 This is a flow chart of an embodiment of obtaining macroblock complexity in the coding control method provided in the embodiment of the present application. Specifically, based on the above embodiment, in this embodiment, the coding control method further includes steps 501 to 505:

[0128] 501. Perform discrete cosine transform on each of the macroblocks to obtain a macroblock coefficient corresponding to each macroblock;

[0129] Based on the above embodiments, in this embodiment, before following up the encoding frame type and macroblock complexity to determine the algorithm activation state of each preset encoding algorithm, the encoding control device also pre-acquires the macroblock complexity of the video to be encoded.

[0130] Specifically, the encoding control device divides any video frame of the to-be-encoded video into macroblocks according to a preset macroblock division type to obtain macroblocks, and performs discrete cosine transform on each macroblock to obtain macroblock coefficients corresponding to each macroblock.

[0131] 502. Perform quantization processing on each macroblock coefficient according to a preset quantization matrix to obtain each macroblock quantization coefficient, and perform entropy coding on each macroblock quantization coefficient to obtain each coded bitstream corresponding to each macroblock;

[0132] Specifically, the encoding control device also follows the preset quantization matrix to quantize the macroblock coefficients, that is, mapping the macroblock coefficients to integer values ​​to obtain the quantization coefficients of each macroblock, and entropy encoding the quantized macroblock coefficients to obtain the encoding code stream corresponding to each macroblock.

[0133] 503. Setting the number of bits associated with the minimum coded stream among the coded streams of each macroblock as the number of bits of the macroblock;

[0134] Specifically, after acquiring the encoding streams of each macroblock, the encoding control device compares the numerical values ​​of the encoding streams, acquires the minimum encoding stream among the encoding streams, and sets the number of bits associated with the minimum encoding stream as the number of bits of the macroblock.

[0135] 504. Decode each coded bitstream of each macroblock to obtain a decoding coefficient of each macroblock, and count the number of macroblock non-zero coefficients of each macroblock based on each decoding coefficient;

[0136] Specifically, the encoding control device also decodes each encoded bitstream of each macroblock to obtain a decoding coefficient of each macroblock, obtains macroblock non-zero coefficients whose coefficients are not equal to 0 in each macroblock, and counts the number of macroblock non-zero coefficients of each macroblock.

[0137] 505. Set the number of macroblock bits and the number of non-zero coefficients of the macroblock as macroblock complexity parameters of each macroblock in the to-be-encoded video.

[0138] Specifically, after obtaining the number of macroblock bits and the number of macroblock non-zero coefficients of each macroblock, the encoding control device sets the number of macroblock bits and the number of macroblock non-zero coefficients as the macroblock complexity parameter of each video frame in the video to be encoded.

[0139] In this embodiment, the encoding control device divides any video frame of the video to be encoded into macroblocks according to a preset macroblock division type to obtain macroblocks, performs discrete cosine transform on each macroblock to obtain macroblock coefficients corresponding to each macroblock; performs quantization processing on each macroblock coefficient according to a preset quantization matrix to obtain each macroblock quantization coefficient, performs entropy coding on each macroblock quantization coefficient to obtain each encoding stream corresponding to each macroblock; sets the number of bits associated with the minimum encoding stream in each encoding stream of each macroblock as the number of macroblock bits; performs decoding processing on each encoding stream of each macroblock to obtain decoding coefficients of each macroblock, and counts the number of macroblock non-zero coefficients of each macroblock based on each decoding coefficient; sets the number of macroblock bits and the number of macroblock non-zero coefficients as the macroblock complexity parameter of each video frame in the video to be encoded. The complexity of each macroblock is obtained, and the activation state of each encoding algorithm is adjusted according to the macroblock complexity and the encoding frame type in subsequent steps.

[0140] In order to better implement the coding control method in the embodiment of the present application, based on the coding control method, the embodiment of the present application also provides a coding control device, such as Figure 8 As shown, Figure 8 This is a schematic diagram of the structure of a coding control device provided in an embodiment of the present application. Specifically, the coding control device 600 includes:

[0141] The macroblock division module 601 is configured to obtain a video to be encoded, and perform macroblock division on the video to be encoded to obtain macroblocks of the video to be encoded;

[0142] The strategy configuration module 602 is configured to configure the target coding strategy of the macroblock according to the coding frame type and macroblock complexity parameter of the macroblock; wherein the target coding strategy is a coding strategy for configuring the algorithm state of the preset coding algorithm corresponding to the macroblock;

[0143] The encoding control module 603 is configured to encode the macroblock using the target encoding strategy to obtain an encoding result of the macroblock.

[0144] In a possible implementation of this embodiment, the encoding control device configures the target encoding strategy of the macroblock according to the encoding frame type and macroblock complexity parameter of the macroblock, including:

[0145] Acquire a coding frame type of the macroblock, and configure an initial coding strategy for the macroblock based on the coding frame type, wherein the initial coding strategy is used to configure a coding strategy for an algorithm state of a preset coding algorithm;

[0146] The initial coding strategy is updated according to the coding frame type and the macroblock complexity of the macroblock to obtain a target coding strategy for the macroblock.

[0147] In a possible implementation manner of this embodiment, the encoding control device obtains the encoding frame type of the macroblock, and configures the initial encoding strategy of the macroblock based on the encoding frame type, including:

[0148] Obtaining a coding frame type of the macroblock, where the coding frame type includes a key frame type and a predicted frame type;

[0149] If the coding frame type is a key frame type, the first coding algorithm and the third coding algorithm in the preset coding strategy corresponding to the macroblock are configured in state to obtain an initial coding strategy;

[0150] If the coding frame type is a prediction frame type, the state of the second coding algorithm in the prediction coding strategy corresponding to the macroblock is configured to obtain an initial coding strategy.

[0151] In a possible implementation manner of this embodiment, the encoding control device updates the initial encoding strategy according to the encoding frame type and the macroblock complexity of the macroblock to obtain the target encoding strategy of the macroblock, including:

[0152] Acquire a macroblock complexity parameter of the macroblock, wherein the macroblock complexity parameter includes any one or more of a macroblock partition type, a macroblock residual cost, a macroblock rate distortion cost, a macroblock bit number, and a macroblock non-zero coefficient number;

[0153] The preset coding algorithm in the initial coding strategy is configured to update its state according to the coding frame type, the macroblock complexity parameter and the preset complexity threshold, so as to obtain the target coding strategy of the macroblock.

[0154] In a possible implementation of this embodiment, the encoding control device performs a state update configuration on the preset encoding algorithm in the initial encoding strategy according to the encoding frame type, the macroblock complexity parameter and the preset complexity threshold to obtain the target encoding strategy of the macroblock, including:

[0155] If the coded frame type is a key frame type, obtaining a macroblock residual cost and a macroblock rate distortion cost in the macroblock complexity parameter;

[0156] If the target residual cost in the macroblock residual cost is less than the remaining residual cost in the macroblock residual cost, and the absolute value of the difference between the target residual cost and the preset residual cost is less than a preset difference threshold, then the state of the first encoding algorithm in the initial encoding strategy is updated to obtain the target encoding strategy of the macroblock;

[0157] If the target rate-distortion cost in the macroblock rate-distortion cost is less than the residual rate-distortion cost in the macroblock rate-distortion cost, the state of the third coding algorithm in the initial coding strategy is updated to obtain the target coding strategy for the macroblock.

[0158] In a possible implementation of this embodiment, the encoding control device performs a state update configuration on the preset encoding algorithm in the initial encoding strategy according to the encoding frame type, the macroblock complexity parameter and the preset complexity threshold to obtain the target encoding strategy of the macroblock, including:

[0159] If the coding frame type is a key frame type, obtaining the number of macroblock bits and the number of macroblock non-zero coefficients in the macroblock complexity parameter;

[0160] If the number of bits of the macroblock is less than a preset bit number threshold, updating the state of the third coding algorithm in the initial coding strategy to obtain a target coding strategy for the macroblock;

[0161] Alternatively, if the number of non-zero coefficients of the macroblock is equal to a preset first number threshold, the state of the third coding algorithm in the initial coding strategy is updated to obtain a target coding strategy for the macroblock.

[0162] In a possible implementation manner of this embodiment, the encoding control device updates the initial activation state of each of the preset encoding algorithms according to the encoding frame type, the macroblock complexity parameter and the preset complexity threshold, and determines the algorithm activation state of each preset encoding algorithm, including:

[0163] If the coded frame type is a predicted frame type, obtaining the macroblock partition type and the number of macroblock non-zero coefficients in the macroblock complexity parameter;

[0164] If the number of non-zero coefficients of the macroblock is less than a preset second number threshold, performing a first state update on the second coding algorithm in the initial coding strategy to obtain a target coding strategy for the macroblock;

[0165] If the macroblock partition type is a target partition type and the number of non-zero coefficients of the macroblock is greater than a preset third number threshold, a second state update is performed on the second coding algorithm in the initial coding strategy to obtain a target coding strategy for the macroblock.

[0166] In a possible implementation manner of this embodiment, before the encoding control device configures the target encoding strategy of the macroblock according to the encoding frame type and the macroblock complexity parameter of the macroblock, it also includes:

[0167] Performing discrete cosine transform on the macroblock to obtain macroblock coefficients corresponding to the macroblock;

[0168] Quantize the macroblock coefficients according to a preset quantization matrix to obtain the quantized coefficients of each macroblock, and entropy encode the quantized coefficients of each macroblock to obtain the coded bit streams corresponding to each macroblock;

[0169] The number of bits associated with the minimum coded bit stream among the coded bit streams of each macroblock is set as the number of bits of the macroblock;

[0170] Decoding each coded bitstream of each macroblock to obtain a decoding coefficient of each macroblock, and counting the number of macroblock non-zero coefficients of each macroblock based on each decoding coefficient;

[0171] The number of macroblock bits and the number of non-zero coefficients of the macroblock are set as macroblock complexity parameters of each macroblock in the to-be-encoded video.

[0172] In this embodiment, the encoding control device obtains the video to be encoded by responding to the encoding control event for the target encoder, divides the video to be encoded into macroblocks, and obtains the macroblocks of the video to be encoded; configures the target encoding strategy of the macroblock according to the encoding frame type and macroblock complexity parameters of the macroblock; wherein the target encoding strategy is an encoding strategy for configuring the algorithm state of the preset encoding algorithm corresponding to the macroblock; and encodes the macroblock using the target encoding strategy to obtain the encoding result of the macroblock. This is achieved by decoupling each encoding algorithm in the encoding process from the motion estimation parameters, and jointly determining whether to start a specific encoding algorithm when encoding a video frame or macroblock according to the encoding frame type and macroblock complexity, so that a coding algorithm with a smaller encoding complexity is selected from multiple macroblock complexity dimensions for processing, thereby reducing the encoding complexity and improving the encoding performance and encoding benefits.

[0173] The embodiment of the present invention also provides a coding control device, such as Fig. 9 As shown, Fig. 9 This is a schematic diagram of the structure of an embodiment of the encoding control device provided in the embodiments of the present application.

[0174] The coding control device integrates any one of the coding control devices provided in the embodiments of the present invention, and the coding control device includes:

[0175] one or more processors;

[0176] Memory; and

[0177] One or more applications, wherein the one or more applications are stored in the memory and are configured so that the processor executes the steps of the encoding control method described in any of the above encoding control method embodiments.

[0178] Specifically, the encoding control device may include one or more processing core processors 701, one or more computer-readable storage media memories 702, a power supply 703, an input unit 704 and other components. Those skilled in the art will understand that Fig. 9 The structure of the coding control device shown in the figure does not constitute a limitation on the coding control device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0179] The processor 701 is the control center of the coding control device. It uses various interfaces and lines to connect various parts of the entire coding control device. By running or executing software programs and / or modules stored in the memory 702, and calling data stored in the memory 702, it performs various functions of the coding control device and processes data, thereby monitoring the coding control device as a whole. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701.

[0180] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the encoding control device, etc. In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.

[0181] The coding control device also includes a power supply 703 for supplying power to each component. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 703 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0182] The coding control device may further include an input unit 704, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0183] Although not shown, the encoding control device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 701 in the encoding control device will load the executable files corresponding to the processes of one or more application programs into the memory 702 according to the following instructions, and the processor 701 will run the application programs stored in the memory 702, thereby realizing various functions, as follows:

[0184] Obtaining a video to be encoded, dividing the video to be encoded into macroblocks, and obtaining macroblocks of the video to be encoded;

[0185] Configuring a target coding strategy for the macroblock according to a coding frame type and a macroblock complexity parameter of the macroblock; wherein the target coding strategy is a coding strategy for configuring an algorithm state of a preset coding algorithm corresponding to the macroblock;

[0186] The target encoding strategy is adopted to encode the macroblock to obtain an encoding result of the macroblock.

[0187] To this end, an embodiment of the present invention provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any one of the encoding control methods provided in the embodiments of the present invention. For example, the computer program may be loaded by a processor to execute the following steps:

[0188] Obtaining a video to be encoded, dividing the video to be encoded into macroblocks, and obtaining macroblocks of the video to be encoded;

[0189] Configuring a target coding strategy for the macroblock according to a coding frame type and a macroblock complexity parameter of the macroblock; wherein the target coding strategy is a coding strategy for configuring an algorithm state of a preset coding algorithm corresponding to the macroblock;

[0190] The target encoding strategy is adopted to encode the macroblock to obtain an encoding result of the macroblock.

[0191] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.

[0192] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.

[0193] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0194] The above is a detailed introduction to a coding control method provided in an embodiment of the present application. Specific embodiments are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A coding control method, characterized in that: The coding control method comprises: Obtaining a video to be encoded, dividing the video to be encoded into macroblocks, and obtaining macroblocks of the video to be encoded; If the coding frame type of the macroblock is a key frame type, the algorithm control parameters in the first coding algorithm and the third coding algorithm in the preset coding algorithm corresponding to the macroblock are set to the on position to obtain an initial coding strategy, and the key frame type is an intra-frame coding frame type; If the coding frame type is a prediction frame type, the algorithm control parameter in the second coding algorithm in the preset coding algorithm corresponding to the macroblock is set to the on position to obtain an initial coding strategy, the prediction frame type includes a forward prediction frame type and a bidirectional prediction frame type, the preset coding algorithm includes a first coding algorithm, a second coding algorithm and a third coding algorithm, the first coding algorithm is a rate-distortion-based mode selection coding method, the second coding algorithm is a rate-distortion-based quantization parameter selection coding algorithm, the third coding algorithm is a rate-distortion-based mode refinement coding algorithm, the rate-distortion-based mode selection coding method is that the target encoder calculates the rate-distortion cost of each macroblock division method in the optimal mode, selects the division method with the smallest rate-distortion cost as the optimal division method of the macroblock, and the rate-distortion-based mode refinement coding algorithm is that the target encoder uses the rate-distortion cost of the macroblock as an indicator to refine the optimal prediction mode to obtain the final optimal prediction mode; Acquire the macroblock complexity parameter, wherein the macroblock complexity parameter includes one of a macroblock residual cost, a macroblock rate distortion cost, a macroblock bit number, and a macroblock non-zero coefficient number, or the macroblock complexity parameter includes a macroblock partition type and a macroblock non-zero coefficient number; According to the coding frame type of the macroblock, the macroblock complexity parameter and the preset complexity threshold, the preset coding algorithm in the initial coding strategy is updated and configured with an algorithm activation state to obtain a target coding strategy for the macroblock; Determine the algorithm activation state of the preset encoding algorithm corresponding to the algorithm control parameter with the on bit in the target encoding strategy as the on state; The macroblock is encoded using a preset encoding algorithm corresponding to the enabled state in the target encoding strategy to obtain an encoding result of the macroblock.

2. The coding control method according to claim 1, characterized in that: The step of performing state update configuration on the preset coding algorithm in the initial coding strategy according to the coding frame type, the macroblock complexity parameter and the preset complexity threshold to obtain the target coding strategy of the macroblock includes: If the coding frame type is a key frame type, obtain the macroblock residual cost and the macroblock rate-distortion cost in the macroblock complexity parameter, the macroblock residual cost includes a first macroblock residual cost corresponding to the 16*16 sub-macroblock, a second macroblock residual cost corresponding to the 8*8 sub-macroblock, and a third macroblock residual cost corresponding to the 4*4 sub-macroblock, and the macroblock rate-distortion cost includes a first macroblock rate-distortion cost corresponding to the 16*16 sub-macroblock, a second macroblock rate-distortion cost corresponding to the 8*8 sub-macroblock, and a third macroblock rate-distortion cost corresponding to the 4*4 sub-macroblock; If the target residual cost in the macroblock residual cost is less than the remaining residual cost in the macroblock residual cost, and the absolute value of the difference between the target residual cost and the preset residual cost is less than the preset difference threshold, the algorithm control parameter of the first encoding algorithm in the initial encoding strategy is updated to a closed position to obtain the target encoding strategy of the macroblock, the target residual cost is the first macroblock residual cost, the remaining residual cost includes the second macroblock residual cost and the third macroblock residual cost, and the preset residual cost is the third macroblock residual cost; If the target rate-distortion cost in the macroblock rate-distortion cost is less than the residual rate-distortion cost in the macroblock rate-distortion cost, the algorithm control parameter of the third encoding algorithm in the initial encoding strategy is updated to a closed position to obtain the target encoding strategy of the macroblock, the target rate-distortion cost is the third macroblock rate-distortion cost, and the residual rate-distortion cost includes the first macroblock rate-distortion cost and the second macroblock rate-distortion cost.

3. The coding control method according to claim 1, characterized in that: The step of performing state update configuration on the preset coding algorithm in the initial coding strategy according to the coding frame type, the macroblock complexity parameter and the preset complexity threshold to obtain the target coding strategy of the macroblock includes: If the coding frame type is a key frame type, obtaining the number of macroblock bits and the number of macroblock non-zero coefficients in the macroblock complexity parameter; If the number of bits of the macroblock is less than a preset bit number threshold, the algorithm control parameter of the third encoding algorithm in the initial encoding strategy is updated to a closed bit to obtain a target encoding strategy for the macroblock; Or, if the number of non-zero coefficients of the macroblock is equal to a preset first number threshold, the algorithm control parameter of the third encoding algorithm in the initial encoding strategy is set to an on bit to obtain a target encoding strategy for the macroblock.

4. The coding control method according to claim 1, characterized in that: The updating of the initial activation state of each of the preset encoding algorithms according to the encoding frame type, the macroblock complexity parameter and the preset complexity threshold, and determining the algorithm activation state of each of the preset encoding algorithms, comprises: If the coded frame type is a predicted frame type, obtaining the macroblock partition type and the number of macroblock non-zero coefficients in the macroblock complexity parameter; If the number of non-zero coefficients of the macroblock is less than a preset second number threshold, updating the algorithm control parameter of the second encoding algorithm in the initial encoding strategy to a closed bit to obtain a target encoding strategy for the macroblock; If the macroblock partition type is a target partition type and the number of non-zero coefficients of the macroblock is greater than a preset third number threshold, the algorithm control parameter of the second encoding algorithm in the initial encoding strategy is set to the on position to obtain the target encoding strategy of the macroblock.

5. The coding control method according to any one of claims 1 to 4, characterized in that: Before determining the target coding strategy, also include: Divide any video frame of the to-be-encoded video into macroblocks according to a preset macroblock division type to obtain macroblocks, and perform discrete cosine transform on each macroblock to obtain macroblock coefficients corresponding to each macroblock; Quantize the coefficients of each macroblock according to a preset quantization matrix to obtain the quantization coefficients of each macroblock, and perform entropy coding on the quantization coefficients of each macroblock to obtain the coded bit streams corresponding to each macroblock; The number of bits associated with the minimum coded bit stream among the coded bit streams of each macroblock is set as the number of bits of the macroblock; Decoding each coded bitstream of each macroblock to obtain a decoding coefficient of each macroblock, and counting the number of macroblock non-zero coefficients of each macroblock based on each decoding coefficient; The number of macroblock bits and the number of non-zero coefficients of the macroblock are set as the macroblock complexity parameters of each video frame in the video to be encoded.

6. A coding control device, characterized in that: The coding control device comprises: The macroblock division module is configured to obtain a video to be encoded, divide the video to be encoded into macroblocks, and obtain macroblocks of the video to be encoded; The strategy configuration module is configured to, if the coding frame type of the macroblock is a key frame type, set the algorithm control parameters in the first coding algorithm and the third coding algorithm in the preset coding algorithm corresponding to the macroblock to the on position, and obtain the initial coding strategy, the key frame type is an intra-frame coding frame type; if the coding frame type is a predicted frame type, set the algorithm control parameter in the second coding algorithm in the preset coding algorithm corresponding to the macroblock to the on position, and obtain the initial coding strategy, the predicted frame type includes a forward prediction frame type and a bidirectional prediction frame type, the preset coding algorithm includes a first coding algorithm, a second coding algorithm and a third coding algorithm, the first coding algorithm is a rate-distortion-based mode selection coding method, the second coding algorithm is a rate-distortion-based quantization parameter selection coding algorithm, the third coding algorithm is a rate-distortion-based mode refinement coding algorithm, and the rate-distortion-based mode selection coding method is a target encoder for each macroblock The method comprises the steps of: calculating the rate-distortion cost of each division mode in the optimal mode, selecting the division mode with the minimum rate-distortion cost as the optimal division mode of the macroblock, and refining the optimal prediction mode for the target encoder with the rate-distortion cost of the macroblock as an indicator to obtain the final optimal prediction mode; obtaining the macroblock complexity parameter, wherein the macroblock complexity parameter includes one of the macroblock residual cost, the macroblock rate-distortion cost, the number of macroblock bits and the number of non-zero coefficients of the macroblock, or the macroblock complexity parameter includes the macroblock division type and the number of non-zero coefficients of the macroblock; updating the algorithm activation state of the preset coding algorithm in the initial coding strategy according to the coding frame type of the macroblock, the macroblock complexity parameter and the preset complexity threshold, and obtaining the target coding strategy of the macroblock; determining the algorithm activation state of the preset coding algorithm corresponding to the algorithm control parameter with the on bit in the target coding strategy as the on state; The encoding control module is configured to encode the macroblock using a preset encoding algorithm corresponding to the enabled state in the target encoding strategy to obtain an encoding result of the macroblock.

7. A coding control device, characterized in that: The coding control device comprises: one or more processors; Memory; and One or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the processor to implement the steps of the encoding control method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps of the encoding control method according to any one of claims 1 to 5.