Optimization method, device and electronic equipment for video encoding

By adjusting the quantization value of the encoding using the mapping relationship between encoding statistics and motion vectors, the problem of low motion mapping accuracy in low bitrate security monitoring is solved, thus improving encoding quality and stability.

CN122293860APending Publication Date: 2026-06-26BEIJING TSINGMICRO INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610194378.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-10
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In low-bitrate security monitoring scenarios, existing video encoding technologies have low motion mapping accuracy in special motion scenarios with frequent jitter or violent shaking, resulting in loss of details of moving objects and image quality degradation, making it difficult to meet encoding quality requirements.

Method used

By acquiring the encoding statistics generated during the video encoding process, it is determined whether the current encoding block meets the motion mapping conditions, and the quantization value of the current encoding block is adjusted according to the predefined mapping relationship between motion vectors and encoding quantization values ​​to optimize the encoding quality.

Benefits of technology

It improves the coding quality of motion regions, reduces computational resource consumption, and enhances the stability of the coding process and the overall coding effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122293860A_ABST
    Figure CN122293860A_ABST
Patent Text Reader

Abstract

This disclosure discloses a method, apparatus, and electronic device for optimizing video coding, including: in response to acquiring a current frame image and a reference frame image in video data, acquiring coding statistics information in the reference frame image; wherein the reference frame image is any frame image previously encoded before the current frame image; based on the coding statistics information, determining whether the current coding block satisfies motion mapping conditions; the current coding block is any coding block of the current frame image; if it is determined that the current coding block satisfies motion mapping conditions, adjusting the coding quantization value of the current coding block to a target coding quantization value according to a predefined mapping relationship between motion vectors and the adjustment amount of coding quantization values ​​and the motion vector of the current coding block; by using the coding statistics information and motion vectors generated during the video coding process to perform motion mapping judgment and coding quantization value adjustment, the coding quality of motion regions is improved, the consumption of computing resources is reduced, and the stability of coding is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, and in particular to a method, apparatus and electronic device for optimizing video encoding. Background Technology

[0002] With the development of ultra-high-definition video technology, video application scenarios are becoming increasingly diverse. Under the constraints of limited network bandwidth and storage resources, achieving high-quality video transmission and storage has become a key focus of the industry. This is especially true in low-bitrate application scenarios such as security monitoring, where it is necessary to capture the details of moving objects, such as facial features of moving people, license plate numbers of high-speed vehicles, and road sign text on highways. At the same time, it is also necessary to deal with image quality issues such as ghosting and trailing caused by high-speed moving objects, which places higher demands on the specificity and stability of encoding quality.

[0003] In related technologies, preprocessing feature recognition, motion vector mapping, or absolute residual mapping are used to optimize the encoding quality of motion regions. However, these methods consume a lot of computing resources, have low accuracy in motion mapping under special motion scenarios with frequent jitter or violent shaking, and reduce the overall encoding stability. In low bitrate scenarios of security monitoring, they can lead to loss of details of moving objects and image quality degradation, making it difficult to meet the encoding quality requirements of actual business. Summary of the Invention

[0004] This disclosure provides a method, apparatus, and electronic device for optimizing video encoding to solve problems in related technologies. By utilizing encoding statistics and motion vectors generated during the video encoding process to perform motion mapping judgment and encoding quantization value adjustment, the encoding quality of motion regions is improved, while reducing the consumption of computing resources and improving the overall stability of the encoding process.

[0005] According to a first aspect of this disclosure, a method for optimizing video encoding is provided, comprising:

[0006] In response to obtaining the current frame image and the reference frame image in the video data, the encoding statistics information in the reference frame image is obtained; wherein, the reference frame image is any frame image that has been encoded before the current frame image; Based on the encoding statistics, it is determined whether the current encoding block satisfies the motion mapping condition; wherein, the current encoding block is any encoding block of the current frame image; If the current coding block satisfies the motion mapping condition, the coding quantization value of the current coding block is adjusted to the target coding quantization value according to the predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block, so as to optimize the current frame image.

[0007] In some embodiments of this disclosure, the coding statistics include the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image, the mean motion vector of the reference frame image, and the mean coding cost of the reference frame image; The step of determining whether the current coding block satisfies the motion mapping condition based on the coding statistics includes: Based on the prediction mode identifier, it is determined whether the prediction mode of the reference coding block is an intra-frame prediction mode; wherein, the prediction mode identifier is used to indicate whether the prediction mode is the intra-frame prediction mode or the inter-frame prediction mode. If the prediction mode of the reference coding block is determined to be the intra-frame prediction mode, it is determined whether the motion vector of the current coding block is greater than the motion vector threshold. If it is determined that the motion vector of the current coding block is greater than the motion vector threshold, it is then determined whether the coding cost of the current coding block is greater than the coding cost threshold. If the coding cost of the current coding block is determined to be greater than the coding cost threshold, then the current coding block is determined to satisfy the motion mapping condition.

[0008] In some embodiments of this disclosure, obtaining the encoded statistics in the reference frame image includes: Obtain the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image; The motion vectors of all reference coded blocks in the reference frame image are counted, and the mean value of the motion vectors is determined based on the motion vectors of all reference coded blocks. The coding cost of all reference coding blocks in the reference frame image is calculated, and the average coding cost is determined based on the coding cost of all reference coding blocks.

[0009] In some embodiments of this disclosure, before adjusting the coding quantization value of the current coding block to a target coding quantization value based on a predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value, and the motion vector of the current coding block, to optimize the current frame image, the method further includes: Based on the mean motion vector of the reference frame image, at least two preset motion vector intervals are determined; wherein, each preset motion vector interval corresponds to an adjustment amount of an encoded quantization value; The mapping relationship is determined based on the adjustment amount of the at least two preset motion vector intervals and the encoded quantization value; The step of adjusting the coding quantization value of the current coding block to a target coding quantization value, based on a predefined mapping relationship between the adjustment amount of motion vectors and coding quantization values ​​and the motion vector of the current coding block, to optimize the current frame image, includes: Based on the mapping relationship, the target adjustment amount corresponding to the motion vector of the current coding block is determined; The coding quantization value of the current coding block is adjusted to the target coding quantization value according to the target adjustment amount.

[0010] In some embodiments of this disclosure, determining whether the coding cost of the current coding block is greater than the coding cost threshold includes: The coding cost threshold is determined based on the average coding cost of the reference frame image and a preset constant parameter. Based on the relationship between the coding cost value of the current coding block and the coding cost threshold, it is determined whether the coding cost value of the current coding block is greater than the coding cost threshold.

[0011] In some embodiments of this disclosure, determining whether the motion vector of the current coded block is greater than a motion vector threshold includes: The motion vector threshold is determined based on the mean value of the motion vectors in the reference frame image and a preset constant parameter. Based on the relationship between the motion vector of the current coding block and the motion vector threshold, it is determined whether the motion vector of the current coding block is greater than the motion vector threshold.

[0012] In some embodiments of this disclosure, the method for determining the motion vector of the current coding block includes: Obtain the optimal matching position of the current coded block in the reference coded block of the reference frame image; wherein, the optimal matching position is related to the coded cost value; Calculate the distance between the optimal matching position and the position of the current coded block; The distance value is determined as the motion vector of the current coding block.

[0013] In some embodiments of this disclosure, the method for determining the coding cost value of the current coding block includes: A cost transformation is performed on the pixel values ​​of the current coding block in the current frame image and the pixel values ​​of at least two reference coding blocks in the reference frame image to obtain the transformation result. Based on the transformation process result, the coding value of the current coding block is determined.

[0014] According to a second aspect of this disclosure, a video encoding optimization apparatus is provided, comprising: The acquisition unit is configured to, in response to acquiring the current frame image and the reference frame image in the video data, acquire the encoding statistics information in the reference frame image; wherein, the reference frame image is any frame image that has been encoded before the current frame image; The judgment unit is used to determine whether the current coding block satisfies the motion mapping condition based on the coding statistics information; wherein the current coding block is any coding block of the current frame image; An adjustment unit is configured to, when it is determined that the current coding block satisfies the motion mapping condition, adjust the coding quantization value of the current coding block to a target coding quantization value based on a predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block, so as to optimize the current frame image.

[0015] In some embodiments of this disclosure, the coding statistics include the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image, the mean motion vector of the reference frame image, and the mean coding cost of the reference frame image; The judgment unit includes: The first determination module is used to determine whether the prediction mode of the reference coding block is an intra-frame prediction mode based on the prediction mode identifier; wherein, the prediction mode identifier is used to indicate whether the prediction mode is the intra-frame prediction mode or the inter-frame prediction mode. The second judgment module is used to determine whether the motion vector of the current coding block is greater than the motion vector threshold when the prediction mode of the reference coding block is determined to be the intra-frame prediction mode. The third judgment module is used to determine whether the encoding cost of the current encoding block is greater than the encoding cost threshold when it is determined that the motion vector of the current encoding block is greater than the motion vector threshold. The first determining module is used to determine that the current coding block satisfies the motion mapping condition when the coding cost value of the current coding block is greater than the coding cost threshold.

[0016] In some embodiments of this disclosure, the acquisition unit includes: The first acquisition module is used to acquire the prediction mode identifier of the reference coding block in the reference frame image at the position corresponding to the current coding block; The second determining module is used to count the motion vectors of all reference coding blocks in the reference frame image and determine the average motion vector based on the motion vectors of all reference coding blocks. The third determining module is used to calculate the coding cost of all reference coding blocks in the reference frame image and determine the average coding cost based on the coding cost of all reference coding blocks.

[0017] In some embodiments of this disclosure, the apparatus further includes: The first determining unit is configured to, when the adjustment unit determines that the current coding block satisfies the motion mapping condition, adjust the coding quantization value of the current coding block to a target coding quantization value based on a predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value, and the motion vector of the current coding block, in order to optimize the current frame image, determine at least two preset motion vector intervals based on the average motion vector of the reference frame image; wherein each preset motion vector interval corresponds to an adjustment amount of the coding quantization value; The second determining unit is used to determine the mapping relationship based on the adjustment amount of the at least two preset motion vector intervals and the encoded quantization value; The adjustment unit includes: The fourth determining module is used to determine the target adjustment amount corresponding to the motion vector of the current coding block based on the mapping relationship; An adjustment module is used to adjust the coding quantization value of the current coding block to the target coding quantization value according to the target adjustment amount.

[0018] In some embodiments of this disclosure, the third determination module includes: The first determining submodule is used to determine the coding cost threshold based on the average coding cost of the reference frame image and a preset constant parameter. The first judgment submodule is used to determine whether the encoding cost of the current encoding block is greater than the encoding cost threshold based on the relationship between the encoding cost of the current encoding block and the encoding cost threshold.

[0019] In some embodiments of this disclosure, the second determining module includes: The second determining submodule is used to determine the motion vector threshold based on the mean value of the motion vector of the reference frame image and a preset constant parameter; The second judgment submodule is used to determine whether the motion vector of the current coding block is greater than the motion vector threshold based on the relationship between the motion vector of the current coding block and the motion vector threshold.

[0020] In some embodiments of this disclosure, prior to the determining unit, the apparatus further includes a third determining unit, the third determining unit comprising: The second acquisition module is used to acquire the optimal matching position of the current coding block in the reference frame image of the reference coding block; wherein, the optimal matching position is related to the coding cost value; The calculation module is used to calculate the distance between the optimal matching position and the position of the current coding block; The fifth determining module is used to determine the distance value as the motion vector of the current coding block.

[0021] In some embodiments of this disclosure, prior to the determining unit, the apparatus further includes a fourth determining unit, the fourth determining unit comprising: The processing module is used to perform cost transformation processing on the pixel values ​​of the current coding block in the current frame image and the pixel values ​​of at least two reference coding blocks in the reference frame image to obtain the transformation processing result; The sixth determining module is used to determine the coding value of the current coding block based on the transformation processing result.

[0022] According to a third aspect of this disclosure, an electronic device is provided, comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect embodiment.

[0023] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are configured to cause the computer to perform the method described in the first aspect of the present disclosure.

[0024] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described in the first aspect of the preceding embodiments.

[0025] In summary, the video coding optimization method, apparatus, and electronic device provided in this disclosure include: in response to acquiring a current frame image and a reference frame image in video data, acquiring coding statistics information in the reference frame image; wherein the reference frame image is any frame image previously encoded before the current frame image; based on the coding statistics information, determining whether the current coding block satisfies motion mapping conditions; wherein the current coding block is any coding block of the current frame image; if it is determined that the current coding block satisfies motion mapping conditions, adjusting the coding quantization value of the current coding block to a target coding quantization value according to a predefined mapping relationship between motion vectors and the adjustment amount of coding quantization values ​​and the motion vector of the current coding block, thereby optimizing the current frame image; by utilizing the coding statistics information and motion vectors generated during the video coding process for motion mapping judgment and coding quantization value adjustment, the coding quality of motion regions is improved, while reducing the consumption of computing resources and improving the overall stability of the coding process.

[0026] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description

[0027] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 A flowchart illustrating a video encoding optimization method provided in an embodiment of this disclosure; Figure 2 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 3 This is a schematic flowchart illustrating a method for determining motion mapping conditions according to an embodiment of the present disclosure. Figure 4 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 5 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 6 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 7 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 8 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 9 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 10 A flowchart illustrating another video encoding optimization method provided in this embodiment of the disclosure; Figure 11 A schematic diagram of the structure of a video encoding optimization device provided in an embodiment of this disclosure; Figure 12 A schematic diagram of the structure of another video encoding optimization device provided in an embodiment of this disclosure; Figure 13 A schematic block diagram of an example electronic device provided for embodiments of this disclosure. Detailed Implementation

[0028] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0029] The following description, with reference to the accompanying drawings, outlines a method, apparatus, and electronic device for optimizing video encoding according to embodiments of the present disclosure.

[0030] This invention has a wide range of applications, especially in video encoding IP, video encoding chips, and various terminal products involving video encoding bitrate control strategies, where it has significant application value.

[0031] Figure 1 This is a flowchart illustrating a video encoding optimization method provided in an embodiment of the present disclosure.

[0032] like Figure 1 As shown, the method includes the following steps: Step 101: In response to obtaining the current frame image and the reference frame image in the video data, obtain the encoding statistics information in the reference frame image; wherein, the reference frame image is any frame image that has been encoded before the current frame image.

[0033] In some embodiments, video data may originate from various video data sources containing continuous frame images, such as video streams captured in real time by a camera or video files pre-stored in a storage device. The current frame image refers to the frame image currently in the encoding process, while the reference frame image refers to any frame image that is located before the current frame image in the time series and has completed the entire encoding process. Since the reference frame image has been encoded, its related encoding data will be stored in the encoding cache and can be directly accessed. Encoding statistics refer to the relevant data set generated by the reference frame image during the encoding process, which can be used for motion mapping condition judgment. The encoding statistics can be obtained from the encoding cache data of the reference frame image without re-encoding the reference frame image.

[0034] The above method can utilize the cached data of the encoded reference frame image to obtain encoding statistics, avoiding the additional computational overhead caused by repeated encoding, while ensuring that the obtained encoding statistics are authentic and effective, providing reliable data support for motion mapping condition judgment.

[0035] Step 102: Based on the encoding statistics, determine whether the current encoding block satisfies the motion mapping condition; wherein, the current encoding block is any encoding block of the current frame image.

[0036] In some embodiments, the current coding block refers to a single image block to be processed formed after dividing the current frame image according to a preset coding block size (such as 4×4, 8×8, 16×16, etc.) when encoding the current frame image. The motion mapping condition refers to the judgment criteria used to filter out the current coding blocks that need to be adjusted in terms of coding quantization value. The judgment criteria are constructed based on coding statistics. The judgment process is to compare the relevant feature data of the current coding block with the judgment criteria corresponding to the coding statistics to determine whether the current coding block meets the adjustment requirements.

[0037] The above method enables precise selection of the current coding block based on the coding statistics of the reference frame, and adjusts the coding block that meets the motion mapping conditions. This avoids the waste of resources caused by indiscriminate processing of all coding blocks and improves the targeting and efficiency of coding optimization.

[0038] Step 103: If it is determined that the current coding block satisfies the motion mapping condition, the coding quantization value of the current coding block is adjusted to the target coding quantization value according to the predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block, so as to optimize the current frame image.

[0039] In some embodiments, motion vectors refer to parameters that characterize the positional offset relationship between the current coding block and the corresponding matching block in the reference frame image. Motion vectors can be obtained through a preset motion estimation algorithm in video coding. Coding quantization values ​​refer to parameters used to control bitrate and coding distortion during video coding. Different quantization values ​​correspond to different bitrate outputs and image distortion levels. Predefined mapping relationships refer to mapping relationships between motion vectors and the adjustment amounts of coding quantization values, which are pre-set through experimental data calibration or coding requirements. These relationships can be stored in a configuration file for direct reading during calls. Target coding quantization values ​​refer to the final coding quantization values ​​adopted after the current coding block has been adjusted. The process of obtaining the target coding quantization value involves querying the mapping relationship based on the motion vector of the current coding block to obtain the corresponding adjustment amount of the coding quantization value, and then correcting the initial coding quantization value based on this adjustment amount. After correction, the target coding quantization value is obtained. By adjusting the target coding quantization value, the current frame image is optimized so that the coding effect of the current coding block matches the motion features, thereby improving the coding quality and bitrate adaptability of the entire current frame image.

[0040] Using the above method, the adjustment amount of the coded quantization value can be quickly determined by using the preset mapping relationship, so as to realize the targeted adjustment of the coded quantization value, and make the coding parameters of the current coding block match the motion features. While ensuring coding efficiency, the overall coding effect of the current frame image can be effectively optimized, and a balance between bit rate and distortion can be achieved.

[0041] In summary, the video coding optimization method disclosed herein includes: in response to acquiring the current frame image and the reference frame image in the video data, acquiring coding statistics information in the reference frame image; wherein the reference frame image is any frame image that has been encoded before the current frame image; based on the coding statistics information, determining whether the current coding block satisfies the motion mapping condition; the current coding block is any coding block of the current frame image; if it is determined that the current coding block satisfies the motion mapping condition, adjusting the coding quantization value of the current coding block to the target coding quantization value according to the predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block; by using the coding statistics information and motion vector generated during the video coding process to perform motion mapping judgment and coding quantization value adjustment, the coding quality of the motion region is improved, the consumption of computing resources is reduced, and the stability of coding is improved.

[0042] Figure 2 This further illustrates a flowchart of a video coding optimization method provided in an embodiment of this disclosure. The coding statistics include the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image, the mean motion vector of the reference frame image, and the mean coding cost of the reference frame image, based on... Figure 1 The embodiment shown, Figure 2 This may include the following steps: Step 201: Based on the prediction mode identifier, determine whether the prediction mode of the reference coding block is an intra-frame prediction mode; wherein, the prediction mode identifier is used to indicate whether the prediction mode is the intra-frame prediction mode or the inter-frame prediction mode.

[0043] In some embodiments, the prediction mode identifier is a parameter generated during the encoding of the reference frame image to mark the prediction mode of the reference coding block. The prediction mode identifier can be marked using a method such as IntraFlag, where IntraFlag=1 indicates that the prediction mode of the reference coding block is the intra-frame prediction mode, and IntraFlag=0 indicates that the prediction mode of the reference coding block is the inter-frame prediction mode. Intra-frame prediction is a technique that uses the encoded data in the current frame image to predict and encode uncoded data. It makes full use of the strong spatial correlation of natural images, the prediction method is simple and has low implementation cost, and the coding error is limited to the current frame, without causing the error propagation problem in the temporal domain of inter-frame prediction. Inter-frame prediction, on the other hand, uses the temporally adjacent reference frame data for prediction and encoding. The prediction mode identifier is obtained by extracting the coding buffer data from the reference frame image.

[0044] Step 202: If the prediction mode of the reference coding block is determined to be the intra-frame prediction mode, determine whether the motion vector of the current coding block is greater than the motion vector threshold.

[0045] In some embodiments, when the reference coding block is in intra-prediction mode, the motion-related features of the current coding block are further determined. Intra-prediction blocks have shortcomings in subjective performance, especially in high compression ratio or low bit rate coding applications: on the one hand, the correlation between spatially adjacent data is limited and there are coding quantization errors, making the compression performance of intra-prediction far inferior to inter-prediction using temporal reference; on the other hand, intra-prediction constructs the predicted value of the current block based on a certain direction or pattern, exhibiting obvious directionality or pattern morphology, and block-based prediction methods can lead to boundary traces between blocks, requiring the use of techniques such as deblocking filters (DBF) and sample adaptive filters (SAP). While encoding tools such as Offset and SAO (Self-Optical Offset) are used for processing, shortcomings still exist in actual encoding processes. For example, intra-frame prediction mode still frequently appears at the motion boundaries of objects with rich boundary information, such as billboard text and license plates, and at the motion boundaries of rapidly moving objects in low bitrate mode. In these scenarios, either intra-frame prediction mode can better preserve details, or the motion search matches a large motion vector, resulting in significant distortion and bitrate overhead due to low bitrate encoding. This leads to the final selection of the intra-frame prediction mode, which has a lower encoding cost. Therefore, motion-related judgments are needed for the current coding block corresponding to these scenarios. The motion vector of the current coding block is a parameter representing the positional offset relationship with the matching block in the reference frame image. The motion vector threshold is a benchmark value used to measure the motion intensity of the current coding block. The motion vector threshold is determined based on the average motion vector of the reference frame image and preset constant parameters. It should be noted that the above examples are only illustrative and do not limit the specific content.

[0046] Step 203: If it is determined that the motion vector of the current coding block is greater than the motion vector threshold, determine whether the coding cost value of the current coding block is greater than the coding cost threshold.

[0047] In some embodiments, when it is determined that the motion vector of the current coding block is greater than the motion vector threshold, it indicates that the current coding block has obvious motion. At this time, it is necessary to further determine whether its coding cost value meets the threshold condition in order to filter out coding blocks with high coding distortion risk. The coding cost value of the current coding block is a parameter used to evaluate the degree of coding distortion, which can be calculated by the sum of absolute transformed differences (SATD). The coding cost threshold is a benchmark value used to determine whether the coding cost value exceeds a reasonable range. The coding cost threshold is determined based on the average coding cost of the reference frame image and a preset constant parameter.

[0048] Step 204: If the coding cost of the current coding block is determined to be greater than the coding cost threshold, then the current coding block is determined to satisfy the motion mapping condition.

[0049] In some embodiments, the motion mapping condition is determined using a progressive logic. The current coding block is considered to satisfy the motion mapping condition only when all three conditions are met simultaneously: the reference coding block is in intra-prediction mode, the motion vector of the current coding block is greater than a motion vector threshold, and the coding cost value of the current coding block is greater than a coding cost threshold. Taking the current coding block (x,y) as an example, this progressive determination process can be described as follows: First, the prediction mode of the current coding block (x,y) at the corresponding position in the reference frame is obtained based on coding statistics, resulting in IntraFlag(x,y). If IntraFlag(x,y)=1, the next step is performed; then, the mean value of the optimal mode cost value of the reference coding block is obtained (…). ) and the mean motion vector of the reference coded block with IntraFlag=0 in the reference frame image ( Then, it is determined whether the motion vector and encoding value of the current encoding block meet the threshold conditions; finally, when all conditions are met, it is determined that the encoding block (x,y) meets the motion mapping conditions.

[0050] Using the above method, we can accurately select current coding blocks that have the corresponding intra-frame mode, violent motion, and high risk of coding distortion, providing an accurate selection basis for targeted adjustment of coding quantization values.

[0051] As a feasible approach, Figure 3 This illustration shows a flowchart of a method for determining motion mapping conditions according to an embodiment of the present disclosure, such as... Figure 3 As shown, the process begins by obtaining the prediction mode identifier of the reference coding block. First, it determines whether the reference coding block is in intra-frame prediction mode. If it is, it obtains the motion vector and motion vector threshold of the current coding block. Then, it checks if the motion vector is greater than the motion vector threshold. If it is, it obtains the coding cost value and coding cost threshold of the current coding block. Finally, it checks if the coding cost value is greater than the coding cost threshold. If it is, it determines that the current coding block satisfies the motion mapping condition. In this process, the formula for determining the motion mapping condition can be expressed as: IntraFlag(x,y)=1 ∩ MV(x,y)> ∩ Satd(x,y)> Where MV(x,y) is the motion vector of the current coded block. Here, Satd(x,y) is the motion vector threshold, and Satd(x,y) is the encoding cost of the current encoding block. This is the encoding cost threshold.

[0052] Figure 4A flowchart illustrating an optimization method for video encoding provided in this embodiment is further illustrated. Based on Figure 1 The embodiment shown, Figure 4 This may include the following steps: Step 301: Obtain the prediction mode identifier of the reference coding block in the reference frame image that corresponds to the position of the current coding block.

[0053] In some embodiments, the prediction mode identifier of the reference coding block is a parameter generated and stored during the encoding of the reference frame image. The prediction mode identifier is used to indicate whether the prediction mode of the reference coding block is an intra-frame prediction mode or an inter-frame prediction mode. It is marked with IntraFlag, where IntraFlag=1 corresponds to the intra-frame prediction mode and IntraFlag=0 corresponds to the inter-frame prediction mode. When obtaining the prediction mode identifier, the reference coding block at the corresponding position in the reference frame image is located according to the position information of the current coding block, and then its corresponding prediction mode identifier is extracted.

[0054] Step 302: Calculate the motion vectors of all reference coding blocks in the reference frame image, and determine the mean motion vector based on the motion vectors of all reference coding blocks.

[0055] In some embodiments, since the reference coding blocks in the intra-prediction mode do not have motion vectors, the motion vectors of the reference coding blocks in the reference frame image whose prediction mode is inter-prediction mode (i.e., IntraFlag=0) are statistically analyzed during the statistical process. The statistical method includes, but is not limited to, calculating the arithmetic mean of the motion vectors of all reference coding blocks in the inter-prediction mode. The calculation process of the motion vector mean is as follows: first, all reference coding blocks in the reference frame image are traversed, and reference coding blocks with IntraFlag=0 are selected and their motion vectors are collected. (i is the sequence number of the inter-frame reference coding block), and then through the formula =(Σ The mean value of the motion vector is calculated by ) / N. , where N is the total number of inter-frame prediction mode reference coding blocks in the reference frame image. It should be noted that the statistical method used for motion vectors is not limited.

[0056] Step 303: Calculate the coding cost value of all reference coding blocks in the reference frame image, and determine the average coding cost based on the coding cost value of all reference coding blocks.

[0057] In some embodiments, the coding cost of a reference coding block is calculated using the sum of absolute values ​​of residual transforms (SATD), and the statistical process covers all reference coding blocks in the reference frame image; the calculation process of the mean coding cost is as follows: first, the coding cost of all reference coding blocks in the reference frame image is collected. (i is the reference coding block number), then through the formula =(Σ The mean encoding cost is calculated as ) / M. Where M is the total number of reference coded blocks in the reference frame image. It should be noted that the statistical method used for the coding cost value is not limited.

[0058] The above method can accurately extract and statistically obtain the components of the encoded statistical information from the reference frame image, providing reliable benchmark data for judging motion mapping conditions. Moreover, the statistical process is based on the cached data encoded in the reference frame, without the need for additional encoding calculations, and will not increase additional computational overhead.

[0059] Figure 5 A flowchart illustrating an optimization method for video encoding provided in this embodiment is further illustrated. Based on Figure 1 The embodiment shown, Figure 5 This may include the following steps: Step 401: Based on the mean motion vector of the reference frame image, determine at least two preset motion vector intervals; wherein each preset motion vector interval corresponds to an adjustment amount of an encoded quantization value.

[0060] In some embodiments, the division of the preset motion vector interval is based on the mean motion vector of the reference frame image. Based on this, the data is divided according to preset multiple relationships, such as using a 9-level interval division method. The preset multiple relationships include, but are not limited to, 0.25 times, 0.5 times, 0.75 times, 1.0 times, 1.25 times, 1.5 times, 1.75 times, 2.0 times, and 2.5 times. The specific interval division is as follows: The first interval is: MV < ×0.25, the second interval is: ×0.25≤MV< ×0.5, the third interval is: ×0.5≤MV< ×0.75, the fourth interval is: ×0.75≤MV< ×1.0, the fifth interval is: ×1.0≤MV< ×1.25, the sixth interval is: ×1.25≤MV< ×1.5, the seventh interval is: ×1.5≤MV< ×1.75, the eighth interval is: ×1.75≤MV< ×2.0, the ninth interval is: ×2.0≤MV< ×2.5. The adjustment amount (deltaQP) of the encoded quantization value corresponding to each interval is a parameter calibrated in advance through experiments, and different intervals correspond to different deltaQP values. It should be noted that the number of preset motion vector intervals and the preset multiple relationships include, but are not limited to, the above 9-level division method, and can be adjusted according to actual encoding needs.

[0061] Step 402: Determine the mapping relationship based on the adjustment amount of the at least two preset motion vector intervals and the encoded quantization value.

[0062] In some embodiments, the mapping relationship is a correspondence between a preset motion vector interval and the adjustment amount of the encoded quantization value, which can be achieved by establishing a mapping table. Combined with the 9-level interval division, the corresponding mapping table is shown in Table 1: Table 1 Mapping Table

[0063] This mapping table can be stored in a configuration file for direct reading during calls. It should be noted that the coefficients and adjustment amounts involved in the mapping table can be configured according to actual conditions, and there are no specific limitations. The methods for establishing mapping relationships include, but are not limited to, creating mapping tables. It should be noted that the above mapping table is only an example, and there is no limit to the number of hierarchical divisions in the mapping table.

[0064] Step 403: Based on the mapping relationship, determine the target adjustment amount corresponding to the motion vector of the current coding block.

[0065] In some embodiments, the process of determining the target adjustment amount is as follows: First, obtain the motion vector MV(x,y) of the current coding block; then, according to the established mapping relationship, determine the preset motion vector interval to which MV(x,y) belongs; then, extract the adjustment amount of the encoded quantization value corresponding to this interval; and use the adjustment amount of the encoded quantization value as the target adjustment amount deltaQP of the current coding block. For example, if the motion vector MV(x,y) of the current coding block satisfies ×0.5≤MV(x,y)< ×0.75, then querying the mapping table yields the corresponding deltaQP as: That is, the target adjustment amount is It should be noted that the above examples are merely illustrative and do not limit the specific content.

[0066] Step 404: Adjust the coding quantization value of the current coding block to the target coding quantization value according to the target adjustment amount.

[0067] In some embodiments, the coded quantization value of the current coded block The quantization value is determined by the coding rate control. The target quantization value QP is calculated using the formula... The implementation, where deltaQP is a defined target adjustment amount, is achieved through the coded quantization value of the current coding block. The target coding quantization value QP is determined by the target adjustment amount deltaQP. For example, if the coding rate control determines the coding quantization value... The target adjustment deltaQP is 25. Therefore, the target quantization value QP is 25 + 2 = 27. After calculating the target quantization value, this target quantization value is used to encode the current coding block.

[0068] Using the above method, a reasonable mapping relationship between motion vectors and the adjustment amount of coded quantization values ​​can be established based on the mean motion vector of the reference frame image, so as to realize the targeted adjustment of coded quantization values, make the coding parameters of the current coding block match the motion features, and effectively optimize the coding effect.

[0069] Figure 6 A flowchart illustrating an optimization method for video encoding provided in an embodiment of this disclosure is further shown. Figure 6 This may include the following steps: Step 501: Determine the coding cost threshold based on the average coding cost of the reference frame image and a preset constant parameter.

[0070] In some embodiments, the coding cost threshold is determined by multiplying the average coding cost of the reference frame image by a preset constant parameter, and the corresponding calculation formula is as follows: ,in, The encoding cost threshold, The average coding cost of the reference frame image. These are preset constant parameters. It should be noted that these are preset constant parameters. The value can be adjusted according to the needs of the actual encoding scenario. For example, it can be 0.5, 0.6, 0.7, etc., and there is no specific limitation.

[0071] Step 502: Based on the relationship between the coding cost value of the current coding block and the coding cost threshold, determine whether the coding cost value of the current coding block is greater than the coding cost threshold.

[0072] In some embodiments, the coding cost value Satd(x,y) of the current coding block is first obtained. This coding cost value is calculated using the sum of absolute values ​​of residual transforms (SATD). Then, Satd(x,y) is compared with the coding cost threshold. Perform a size comparison. If Satd(x,y) > 0. If Satd(x,y) ≤ 0, it indicates that the encoding cost of the current encoding block is greater than the encoding cost threshold, meaning that the encoding distortion of the current encoding block exceeds the average distortion baseline of the reference frame image. Significant image quality degradation may occur after encoding, requiring adjustment of the encoding quantization value to optimize the encoding effect. If the coding cost value of the current coding block is less than or equal to the coding cost threshold, it means that the coding distortion of the current coding block is within a reasonable range and conforms to the average distortion level of the reference frame image, and no additional coding quantization value adjustment is required.

[0073] Using the above method, a reasonable coding cost threshold can be determined based on the average coding cost of the reference frame, enabling accurate judgment of the coding distortion risk of the current coding block and providing a reliable basis for the precise selection of motion mapping conditions.

[0074] Figure 7 A flowchart illustrating an optimization method for video encoding provided in an embodiment of this disclosure is further shown. Figure 7 This may include the following steps: Step 601: Determine the motion vector threshold based on the mean value of the motion vector of the reference frame image and a preset constant parameter.

[0075] In some embodiments, the motion vector threshold is determined by multiplying the mean motion vector of the reference frame image by a preset constant parameter, and the corresponding calculation formula is as follows: ,in, For motion vector threshold, K is the mean motion vector of the reference frame image, and K is a preset constant parameter. It should be noted that the value of the preset constant parameter K can be adjusted according to the motion intensity requirements of the actual encoding scene. For example, in a scene with intense motion, it can be 0.5, 0.6, etc., and there is no specific limitation.

[0076] Step 602: Based on the relationship between the motion vector of the current coding block and the motion vector threshold, determine whether the motion vector of the current coding block is greater than the motion vector threshold.

[0077] In some embodiments, the motion vector MV(x,y) of the current coding block is first obtained. This motion vector is the distance between the current coding block and the optimal matching position in the reference frame image. Then, MV(x,y) is compared with a motion vector threshold. Perform a size comparison. If MV(x,y) > 0. If the motion vector of the current coding block is greater than the motion vector threshold, it indicates that there is significant motion in the current coding block; if MV(x,y)≤ If the motion vector of the current coding block is less than or equal to the motion vector threshold, it indicates that the motion of the current coding block is not obvious.

[0078] The above method can determine a reasonable motion vector threshold based on the mean motion vector of the reference frame, thereby accurately measuring the motion intensity of the current coding block and providing a precise basis for motion feature judgment for the selection of motion mapping conditions.

[0079] Figure 8 A flowchart illustrating an optimization method for video encoding provided in an embodiment of this disclosure is further shown. Figure 8 This may include the following steps: Step 701: Obtain the optimal matching position of the current coding block in the reference coding block of the reference frame image; wherein, the optimal matching position is related to the coding cost.

[0080] In some embodiments, the process of obtaining the optimal matching position belongs to the coding motion search process, specifically: at least two reference coding blocks are selected as candidate matching blocks in the reference frame image; the coding cost value of the current coding block and each candidate matching block is calculated respectively; and the position of the candidate matching block with the smallest coding cost value is determined as the optimal matching position of the current coding block; the coding cost value of the current coding block and the candidate matching block is calculated using the sum of absolute values ​​of residual transforms (SATD). Since the video encoder uses the Rate Distortion Optimization (RDO) coding mode selection model to implement the mode control strategy of video coding, the selection cost function of coding mode (intra-frame prediction mode or inter-frame prediction mode) measures the merits of different coding modes, and then selects the optimal coding mode. This cost function is: ,in, R is the Lagrange parameter used to balance the weights of coding distortion and bit rate. R is the bit rate after coding, and D is the coding distortion, which measures the difference between the reconstructed image and the original image. The coding distortion D is calculated based on the sum of squared residuals (SSD) between the reconstructed and original images. The formula for calculating SSD is: ,in, This represents the pixel value of the current coded block in the current frame image. This represents the pixel value of the corresponding reference coding block in the reference frame image. However, obtaining the SSD to calculate the coding distortion D requires completing the entire RDO decision process, including a series of steps such as transform, quantization, inverse transform, inverse quantization, entropy coding, and reconstruction. This results in a large computational load and latency, failing to meet the efficiency requirements of real-time coding. Therefore, in real-time coding scenarios, SATD cost is used to replace SSD distortion for coding cost calculation. The selection of the optimal matching position is also based on SATD cost, eliminating the need for a complete coding reconstruction process. This significantly reduces computational complexity and latency while ensuring that the calculation result is close to the SSD distortion value.

[0081] Step 702: Calculate the distance between the optimal matching position and the position of the current coding block.

[0082] In some embodiments, the distance value is calculated using, but is not limited to, the Euclidean distance calculation method. The formula for calculating Euclidean distance is: ,in, These are the coordinates of the current coded block location. These are the coordinates of the optimal matching position. It should be noted that the distance value can be calculated using methods including, but not limited to, Euclidean distance calculation; the specific calculation method is not limited.

[0083] Step 703: Determine the distance value as the motion vector of the current coding block.

[0084] In some embodiments, since the calculated distance value can accurately characterize the degree of offset between the current coding block and the optimal matching position in the reference frame image, this distance value is used as the motion vector MV(x,y) of the current coding block. This motion vector will be used to determine the motion mapping conditions and the amount of adjustment of the coding quantization value.

[0085] The above method can obtain the optimal matching position of the current coding block based on the coding motion search process, obtain accurate motion vectors through distance calculation, provide reliable motion feature data for coding optimization processing, and use SATD cost to filter the optimal matching position, which can reduce the amount of computation and computation latency, and adapt to the real-time coding requirements.

[0086] Figure 9 A flowchart illustrating an optimization method for video encoding provided in an embodiment of this disclosure is further shown. Figure 9 This may include the following steps: Step 801: Perform cost transformation processing on the pixel values ​​of the current coding block in the current frame image and the pixel values ​​of at least two reference coding blocks in the reference frame image to obtain the transformation processing result.

[0087] In some embodiments, the cost transformation process employs the Hadamard transform (i.e., fast residual transform). The Hadamard transform is an orthogonal transform that can be performed using only addition and subtraction operations, resulting in low computational complexity, low hardware implementation cost, and the ability to concentrate the energy of image pixels onto a few transform coefficients, facilitating the differentiation of the frequency distribution of the residuals. The Discrete Cosine Transform (DCT) is a step in video coding to remove spatial redundancy, but the SATD cost is calculated using the Hadamard transform domain, making it more suitable for the low computational requirements of real-time coding scenarios compared to DCT. The cost transformation process targets the pixel values ​​of the current coding block in the current frame image and the pixel values ​​of at least two reference coding blocks in the reference frame image. The transformation process involves applying the Hadamard transform to the residuals of the pixel values ​​of the current coding block and the pixel values ​​of at least two reference coding blocks in the reference frame image to obtain the transformation result. It should be noted that the cost transformation process includes, but is not limited to, the Hadamard transform, and the specific cost transformation method is not limited.

[0088] Step 802: Based on the transformation processing result, determine the coding value of the current coding block.

[0089] In some embodiments, the coding cost of the current coding block is obtained by calculating the sum of absolute values ​​of the residual transforms (SATD) based on the transform processing results. The formula for calculating SATD is as follows: Where H() represents the Hadamard transform operation, and M and N represent the size of the coding block, corresponding to the number of pixels in the horizontal (i) and vertical (j) directions of the coding block, respectively. This represents the pixel value of the current coded block in the current frame image. This represents the pixel value of the reference coded block in the reference frame, which is the pixel of the matching block selected during motion search, where (i,j) are the pixel coordinates within the coded block. This represents the pixel residual between the current coding block and the reference coding block. Since SATD is calculated using the Hadamard transform domain, considering the frequency distribution of the pixel residual, it distinguishes between energy concentration (such as smooth regions) and dispersion (such as complex texture regions). The calculation result is close to the SSD distortion value after final encoding, so it is used as the encoding cost value of the current coding block. The SATD value between the current coding block and each reference coding block is calculated, and the smallest SATD value among the reference coding blocks is determined as the encoding cost value of the current coding block.

[0090] The above method enables the use of cost transformation processing with low computational complexity to obtain accurate encoding cost value, which not only ensures the reliability of encoding cost value, but also reduces the amount of computation and computational latency, thus meeting the needs of real-time encoding scenarios.

[0091] As a feasible approach, Figure 10 The diagram illustrates a flowchart of a video encoding optimization method provided in an embodiment of this disclosure, as shown below. Figure 10 As shown, firstly, the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image is obtained, and the mean coding cost and mean motion vector of the reference frame image are also obtained. Next, the motion vector of the current coding block is obtained, and the motion mapping condition is calculated: based on the prediction mode identifier, it is determined whether the reference coding block is in an intra-frame prediction mode. If so, it is determined whether the motion vector of the current coding block is greater than a motion vector threshold. If it is greater, it is determined whether the coding cost of the current coding block is greater than a coding cost threshold. If it is greater, it is determined that the current coding block satisfies the motion mapping condition. The method for implementing the motion mapping condition of the current coding block is as follows: subsequently, a preset motion vector is divided based on the mean motion vector of the reference frame image. The motion vector interval is defined and a mapping relationship is established between it and the coded quantization value adjustment. The target adjustment amount is obtained by querying the mapping relationship based on the motion vector of the current coded block. The target coded quantization value is calculated by combining it with the coded quantization value of the current coded block and the current coded block is encoded. After the encoding of all current coded blocks in the current frame image is completed, the encoding statistics of the current frame image are output: the prediction mode identifier, motion vector and encoding cost of all reference coded blocks in the current frame image are statistically analyzed. Based on the statistical results, the mean motion vector and mean encoding cost of the current frame image are determined. The mean motion vector and mean encoding cost of the current frame image are used as the encoding statistics of the current frame image for encoding optimization of the next frame image.

[0092] Corresponding to the video encoding optimization method described above, this invention also proposes a video encoding optimization apparatus. Since the apparatus embodiments of this invention correspond to the method embodiments described above, details not disclosed in the apparatus embodiments can be referred to in the method embodiments described above, and will not be repeated here.

[0093] Figure 11 This is a schematic diagram of the structure of a video encoding optimization device provided in an embodiment of the present disclosure, as shown below. Figure 11 As shown, it includes: an acquisition unit 51, a judgment unit 52, and an adjustment unit 53.

[0094] The acquisition unit 51 is configured to acquire encoding statistics in the reference frame image in response to acquiring the current frame image and the reference frame image in the video data; wherein the reference frame image is any frame image that has been encoded before the current frame image; The judgment unit 52 is used to determine whether the current coding block satisfies the motion mapping condition based on the coding statistics information; wherein the current coding block is any coding block of the current frame image; The adjustment unit 53 is used to adjust the coding quantization value of the current coding block to the target coding quantization value according to the predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block when it is determined that the current coding block satisfies the motion mapping condition, so as to optimize the current frame image.

[0095] In summary, the video coding optimization apparatus provided in this disclosure includes: in response to acquiring a current frame image and a reference frame image in video data, acquiring coding statistics information in the reference frame image; wherein the reference frame image is any frame image previously encoded before the current frame image; determining, based on the coding statistics information, whether the current coding block satisfies motion mapping conditions; wherein the current coding block is any coding block of the current frame image; if it is determined that the current coding block satisfies motion mapping conditions, adjusting the coding quantization value of the current coding block to a target coding quantization value according to a predefined mapping relationship between motion vectors and the adjustment amount of coding quantization values ​​and the motion vector of the current coding block, thereby optimizing the current frame image; by utilizing the coding statistics information and motion vectors generated during the video coding process for motion mapping judgment and coding quantization value adjustment, the coding quality of motion regions is improved, while reducing the consumption of computing resources and improving the overall stability of the coding process.

[0096] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, the coding statistics include the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image, the mean motion vector of the reference frame image, and the mean coding cost of the reference frame image; The judgment unit 52 includes: The first judgment module 521 is used to determine whether the prediction mode of the reference coding block is an intra-frame prediction mode based on the prediction mode identifier; wherein, the prediction mode identifier is used to indicate whether the prediction mode is the intra-frame prediction mode or the inter-frame prediction mode. The second judgment module 522 is used to determine whether the motion vector of the current coding block is greater than the motion vector threshold when the prediction mode of the reference coding block is determined to be the intra-frame prediction mode. The third judgment module 523 is used to determine whether the encoding cost of the current encoding block is greater than the encoding cost threshold when it is determined that the motion vector of the current encoding block is greater than the motion vector threshold. The first determining module 524 is used to determine that the current coding block satisfies the motion mapping condition when the coding cost value of the current coding block is greater than the coding cost threshold.

[0097] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, the acquisition unit 51 includes: The first acquisition module 511 is used to acquire the prediction mode identifier of the reference coding block in the reference frame image at the position corresponding to the current coding block; The second determining module 512 is used to count the motion vectors of all reference coding blocks in the reference frame image and determine the average motion vector based on the motion vectors of all reference coding blocks. The third determining module 513 is used to calculate the coding cost of all reference coding blocks in the reference frame image and determine the average coding cost based on the coding cost of all reference coding blocks.

[0098] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, the device further includes: The first determining unit 54 is configured to, when the adjusting unit 53 determines that the current coding block satisfies the motion mapping condition, adjust the coding quantization value of the current coding block to a target coding quantization value based on a predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value, and the motion vector of the current coding block, in order to optimize the current frame image, determine at least two preset motion vector intervals based on the average motion vector of the reference frame image; wherein each preset motion vector interval corresponds to an adjustment amount of the coding quantization value; The second determining unit 55 is used to determine the mapping relationship based on the adjustment amount of the at least two preset motion vector intervals and the encoded quantization value; The adjustment unit 53 includes: The fourth determining module 531 is used to determine the target adjustment amount corresponding to the motion vector of the current coding block based on the mapping relationship; The adjustment module 532 is used to adjust the coding quantization value of the current coding block to the target coding quantization value according to the target adjustment amount.

[0099] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, the third judgment module 523 includes: The first determining submodule 5231 is used to determine the coding cost threshold based on the average coding cost of the reference frame image and a preset constant parameter; The first judgment submodule 5232 is used to determine whether the encoding cost value of the current encoding block is greater than the encoding cost threshold based on the relationship between the encoding cost value of the current encoding block and the encoding cost threshold.

[0100] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, the second judgment module 522 includes: The second determining submodule 5221 is used to determine the motion vector threshold based on the mean value of the motion vector of the reference frame image and a preset constant parameter; The second judgment submodule 5222 is used to determine whether the motion vector of the current coding block is greater than the motion vector threshold based on the relationship between the motion vector of the current coding block and the motion vector threshold.

[0101] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, before the determination unit 52, the device further includes a third determining unit 56, which includes: The second acquisition module 561 is used to acquire the optimal matching position of the current coding block in the reference frame image of the reference coding block; wherein, the optimal matching position is related to the coding cost value; The calculation module 562 is used to calculate the distance between the optimal matching position and the position of the current coding block; The fifth determining module 563 is used to determine the distance value as the motion vector of the current coding block.

[0102] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 12 As shown, before the determination unit 52, the device further includes a fourth determination unit 57, which includes: Processing module 571 is used to perform cost transformation processing on the pixel values ​​of the current coding block in the current frame image and the pixel values ​​of at least two reference coding blocks in the reference frame image to obtain the transformation processing result; The sixth determining module 572 is used to determine the encoding value of the current encoding block based on the transformation processing result.

[0103] It should be noted that the foregoing explanation of the method embodiments also applies to the apparatus of the embodiments of this disclosure, and the principle is the same. Therefore, the embodiments of this disclosure are not limited thereto.

[0104] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0105] Figure 13A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as security cameras, surveillance cameras, edge boxes, laptop computers, desktop computers, workstations, personal digital assistants, and servers. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0106] like Figure 13 As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes based on a computer program stored in ROM (Read-Only Memory) 602 or loaded from storage unit 608 into RAM (Random Access Memory) 603. The RAM 603 may also store various programs and data required for the operation of the electronic device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via a bus 604. An I / O (Input / Output) interface 605 is also connected to the bus 604.

[0107] Multiple components in electronic device 600 are connected to I / O interface 605, including: input unit 606, such as keyboard, mouse, etc.; output unit 607, such as various types of displays, speakers, etc.; storage unit 608, such as disk, optical disk, etc.; and communication unit 609, such as network card, modem, wireless transceiver, etc. Communication unit 609 allows electronic device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0108] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, CPUs (Central Processing Units), GPUs (Graphics Processing Units), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSPs (Digital Signal Processors), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as video encoding optimization methods. For example, in some embodiments, the video encoding optimization method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via ROM 602 and / or communication unit 609. When the computer program is loaded into RAM 603 and executed by the computing unit 601, one or more steps of the methods described above may be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to perform the aforementioned video encoding optimization method by any other suitable means (e.g., by means of firmware).

[0109] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System-on-Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0110] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0111] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0112] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0113] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include LANs (Local Area Networks), WANs (Wide Area Networks), the Internet, and blockchain networks.

[0114] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service system that addresses the shortcomings of traditional physical hosts and VPS (Virtual Private Server) services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.

[0115] It's important to note that artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.

[0116] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0117] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for optimizing video encoding, characterized in that, The method includes: In response to obtaining the current frame image and the reference frame image in the video data, the encoding statistics information in the reference frame image is obtained; wherein, the reference frame image is any frame image that has been encoded before the current frame image; Based on the encoding statistics, it is determined whether the current encoding block satisfies the motion mapping condition; wherein, the current encoding block is any encoding block of the current frame image; If the current coding block satisfies the motion mapping condition, the coding quantization value of the current coding block is adjusted to the target coding quantization value according to the predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block, so as to optimize the current frame image.

2. The method according to claim 1, characterized in that, The coding statistics include the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image, the mean motion vector of the reference frame image, and the mean coding cost of the reference frame image. The step of determining whether the current coding block satisfies the motion mapping condition based on the coding statistics includes: Based on the prediction mode identifier, it is determined whether the prediction mode of the reference coding block is an intra-frame prediction mode; wherein, the prediction mode identifier is used to indicate whether the prediction mode is the intra-frame prediction mode or the inter-frame prediction mode. If the prediction mode of the reference coding block is determined to be the intra-frame prediction mode, it is determined whether the motion vector of the current coding block is greater than the motion vector threshold. If it is determined that the motion vector of the current coding block is greater than the motion vector threshold, it is then determined whether the coding cost of the current coding block is greater than the coding cost threshold. If the coding cost of the current coding block is determined to be greater than the coding cost threshold, then the current coding block is determined to satisfy the motion mapping condition.

3. The method according to claim 1, characterized in that, The step of obtaining the encoded statistics information in the reference frame image includes: Obtain the prediction mode identifier of the reference coding block at the position corresponding to the current coding block in the reference frame image; The motion vectors of all reference coded blocks in the reference frame image are counted, and the mean value of the motion vectors is determined based on the motion vectors of all reference coded blocks. The coding cost of all reference coding blocks in the reference frame image is calculated, and the average coding cost is determined based on the coding cost of all reference coding blocks.

4. The method according to claim 2, characterized in that, Before adjusting the coding quantization value of the current coding block to the target coding quantization value according to the predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block, in order to optimize the current frame image, the method further includes: Based on the mean motion vector of the reference frame image, at least two preset motion vector intervals are determined; wherein, each preset motion vector interval corresponds to an adjustment amount of an encoded quantization value; The mapping relationship is determined based on the adjustment amount of the at least two preset motion vector intervals and the encoded quantization value; The step of adjusting the coding quantization value of the current coding block to a target coding quantization value, based on a predefined mapping relationship between the adjustment amount of motion vectors and coding quantization values ​​and the motion vector of the current coding block, to optimize the current frame image, includes: Based on the mapping relationship, the target adjustment amount corresponding to the motion vector of the current coding block is determined; The coding quantization value of the current coding block is adjusted to the target coding quantization value according to the target adjustment amount.

5. The method according to claim 2, characterized in that, The step of determining whether the coding cost value of the current coding block is greater than the coding cost threshold includes: The coding cost threshold is determined based on the average coding cost of the reference frame image and a preset constant parameter. Based on the relationship between the coding cost value of the current coding block and the coding cost threshold, it is determined whether the coding cost value of the current coding block is greater than the coding cost threshold.

6. The method according to claim 2, characterized in that, The step of determining whether the motion vector of the current coded block is greater than the motion vector threshold includes: The motion vector threshold is determined based on the mean value of the motion vectors in the reference frame image and a preset constant parameter. Based on the relationship between the motion vector of the current coding block and the motion vector threshold, it is determined whether the motion vector of the current coding block is greater than the motion vector threshold.

7. The method according to claim 2, characterized in that, The method for determining the motion vector of the current coding block includes: Obtain the optimal matching position of the current coded block in the reference coded block of the reference frame image; wherein, the optimal matching position is related to the coded cost value; Calculate the distance between the optimal matching position and the position of the current coded block; The distance value is determined as the motion vector of the current coding block.

8. The method according to claim 2, characterized in that, The method for determining the encoding cost value of the current encoding block includes: A cost transformation is performed on the pixel values ​​of the current coding block in the current frame image and the pixel values ​​of at least two reference coding blocks in the reference frame image to obtain the transformation result. Based on the transformation process result, the coding value of the current coding block is determined.

9. A video encoding optimization device, characterized in that, include: The acquisition unit is configured to, in response to acquiring the current frame image and the reference frame image in the video data, acquire the encoding statistics information in the reference frame image; wherein, the reference frame image is any frame image that has been encoded before the current frame image; The judgment unit is used to determine whether the current coding block satisfies the motion mapping condition based on the coding statistics information; wherein the current coding block is any coding block of the current frame image; An adjustment unit is configured to, when it is determined that the current coding block satisfies the motion mapping condition, adjust the coding quantization value of the current coding block to a target coding quantization value based on a predefined mapping relationship between the adjustment amount of the motion vector and the coding quantization value and the motion vector of the current coding block, so as to optimize the current frame image.

10. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-8.