Video encoding method and apparatus and cloud desktop image encoding method and apparatus

By dividing video frames into macroblocks and calculating quantization adjustment coefficients based on the degree of macroblock change to update quantization parameters, the problem of frequent changes in local scenes affecting image quality is solved, video encoding performance is optimized, and the image quality of cloud desktop video images is improved.

WO2026007747A1PCT designated stage Publication Date: 2026-01-08CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/103036
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-07-01
Filing Date
2025-06-24
Publication Date
2026-01-08

AI Technical Summary

Technical Problem

Existing video coding methods suffer from poor video coding quality when there are frequent and drastic changes in local scenes, affecting the image quality of non-drastically changing areas after encoding.

Method used

The video frame to be encoded is divided into multiple macroblocks. The temporal complexity of the macroblock is determined based on the degree of inter-frame variation. The quantization adjustment coefficient is calculated in combination with the temporal complexity of the frame, and the basic quantization parameters of the macroblock are updated for encoding.

Benefits of technology

The performance of video encoding has been optimized, and the image quality of macroblock encoding with different degrees of variation has been controlled in a targeted manner, which has improved the video encoding effect, especially enhancing the image quality and ensuring the overall bitrate balance in cloud desktop video images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025103036_08012026_PF_FP_ABST
    Figure CN2025103036_08012026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the embodiments of the present disclosure are a video encoding method and apparatus and a cloud desktop image encoding method and apparatus. The video encoding method comprises: dividing a video frame to be encoded into a plurality of macroblocks, and on the basis of the macroblock inter-frame variation degree of each macroblock in said video frame, determining the macroblock temporal complexity of each macroblock; on the basis of the macroblock temporal complexity of each macroblock, determining the frame temporal complexity of said video frame, and on the basis of the frame temporal complexity and a target macroblock temporal complexity of a target macroblock, calculating a quantization adjustment coefficient of the target macroblock; on the basis of the quantization adjustment coefficient of the target macroblock, updating basic quantization parameters of the target macroblock to obtain updated quantization parameters; and on the basis of the updated quantization parameters, encoding the target macroblock.
Need to check novelty before this filing date? Find Prior Art

Description

Video encoding method, cloud desktop image encoding method and device Cross-reference to related applications

[0001] The present disclosure claims priority to Chinese Patent Application No. 202410875951.7, filed on July 01, 2024, the entire contents of which are incorporated herein by reference. TECHNICAL FIELD

[0002] Embodiments of the present disclosure relate to the field of computer technology, and particularly relate to a video encoding method, a cloud desktop image encoding method and device. BACKGROUND

[0003] With the rapid development of computer technology, communication technology and network technology, various videos emerge in an endless stream, and watching videos has become an important way for people to relax and entertain. Since the data volume of a video is very large, video encoding technology is needed to compress the video for convenient transmission and storage. Video encoding is a lossy compression process, and the decoded video is not consistent with the original video, so how to balance video quality and compression loss is the research focus of video encoding.

[0004] In the prior art, a base quantization parameter of a macroblock to be encoded in a video frame can be calculated first, and encoding is performed based on the base quantization parameter. However, in the above encoding method, if local picture changes are very frequent and severe, the picture content of a non-severe change area will be severely affected after being encoded by a video encoder, resulting in poor video encoding effect. Therefore, there is an urgent need for a method for improving the video encoding effect. SUMMARY

[0005] In view of this, the present disclosure provides a video encoding method. One or more embodiments of the present disclosure also relate to a cloud desktop image encoding method, a video encoding device, a cloud desktop image encoding device, a computing device, a computer-readable storage medium and a computer program product to solve the technical defects in the prior art.

[0006] According to a first aspect of the embodiments of the present disclosure, a video encoding method is provided, including: dividing a to-be-encoded video frame into a plurality of macroblocks, determining macroblock time domain complexity of each macroblock in the to-be-encoded video frame according to macroblock inter-frame variation degree of the macroblock; determining frame time domain complexity of the to-be-encoded video frame according to the macroblock time domain complexity of each macroblock, calculating a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current to-be-encoded macroblock; updating a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter; and encoding the target macroblock according to the updated quantization parameter.

[0007] According to a second aspect of the embodiments of the present disclosure, a cloud desktop image encoding method is provided, applied to a backend server of a cloud application, including: obtaining a to-be-encoded cloud desktop image, and dividing the cloud desktop image into a plurality of macroblocks, determining macroblock time domain complexity of each macroblock in the cloud desktop image according to macroblock inter-frame variation degree of the macroblock; determining frame time domain complexity of the cloud desktop image according to the macroblock time domain complexity of each macroblock, calculating a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current to-be-encoded macroblock; updating a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter; and encoding the target macroblock according to the updated quantization parameter, and transmitting encoded macroblock data to a client of the cloud application.

[0008] According to a third aspect of the embodiments of the present disclosure, a video encoding apparatus is provided, including: a first determining module configured to divide a to-be-encoded video frame into a plurality of macroblocks, and determine macroblock time domain complexity of each macroblock in the to-be-encoded video frame according to macroblock variation degree of the macroblock; a first calculating module configured to determine frame time domain complexity of the to-be-encoded video frame according to the macroblock time domain complexity of each macroblock, and calculate a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current to-be-encoded macroblock; a first updating module configured to update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter; and an encoding module configured to encode the target macroblock according to the updated quantization parameter.

[0009] According to a fourth aspect of the embodiments of the present disclosure, an encoding apparatus of a cloud desktop image is provided, applied to a backend server of a cloud application, and includes: a second determination module configured to obtain a cloud desktop image to be encoded, divide the cloud desktop image into a plurality of macroblocks, determine macroblock time domain complexity of each macroblock in the cloud desktop image according to a macroblock interframe variation degree of the macroblock; a second calculation module configured to determine frame time domain complexity of the cloud desktop image according to the macroblock time domain complexity of each macroblock, calculate a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current macroblock to be encoded; a second update module configured to update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock, and obtain an updated quantization parameter; and a transmission module configured to encode the target macroblock according to the updated quantization parameter, and transmit encoded macroblock data to a client of the cloud application.

[0010] According to a fifth aspect of the embodiments of the present disclosure, a computing device is provided, including: a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions, which realize the steps of the above-mentioned video encoding method or the encoding method of the cloud desktop image when executed by the processor.

[0011] According to a sixth aspect of the embodiments of the present disclosure, a computer readable storage medium is provided, which stores computer executable instructions, which realize the steps of the above-mentioned video encoding method or the encoding method of the cloud desktop image when executed by the processor.

[0012] According to a seventh aspect of the embodiments of the present disclosure, a computer program product is provided, including computer programs / instructions, which realize the steps of the above-mentioned video encoding method or the encoding method of the cloud desktop image when executed by the processor.

[0013] According to an embodiment of the present disclosure, a video encoding method is provided, including: dividing a video frame to be encoded into a plurality of macroblocks; determining macroblock time domain complexity of each macroblock in the video frame to be encoded according to a macroblock interframe variation degree of the macroblock; determining frame time domain complexity of the video frame to be encoded according to the macroblock time domain complexity of each macroblock; calculating a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current macroblock to be encoded; updating a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock, and obtaining an updated quantization parameter; and encoding the target macroblock according to the updated quantization parameter.

[0014] One embodiment of the present disclosure realizes that the macroblock temporal complexity of a macroblock is calculated according to the macroblock inter-frame change degree of each macroblock in a to-be-encoded video frame, and then the quantization adjustment coefficient of a target macroblock is calculated in combination with the frame temporal complexity of the to-be-encoded video frame, the basic quantization parameter is updated based on the quantization adjustment coefficient, the updated quantization parameter is obtained, and the target macroblock is encoded. In this way, the picture content change degree of the region where the macroblock is located is predicted based on the macroblock temporal complexity. The greater the macroblock temporal complexity is, the smaller the inter-frame correlation of the macroblock is, which means that the macroblock changes more frequently, and the picture quality of the macroblock can be reduced. The smaller the macroblock temporal complexity is, the greater the inter-frame correlation of the macroblock is, which means that the macroblock changes slowly, and the picture quality of the macroblock can be enhanced. That is, the basic quantization parameter is updated based on the macroblock temporal complexity, so that different macroblocks with different change degrees can use different quantization parameters for encoding, the encoding picture quality of macroblocks with different change degrees is controlled in a targeted manner, the effect of video encoding is ensured, and the performance of video encoding is optimized. BRIEF DESCRIPTION OF DRAWINGS

[0015] FIG. 1 is a flowchart of a video encoding method according to one embodiment of the present disclosure;

[0016] FIG. 2a is a schematic diagram of macroblock encoding according to one embodiment of the present disclosure;

[0017] FIG. 2b is a schematic diagram of an encoding process according to one embodiment of the present disclosure;

[0018] FIG. 3a is a flowchart of a cloud desktop image encoding method according to one embodiment of the present disclosure;

[0019] FIG. 3b is a flowchart of a processing process of a video encoding method according to one embodiment of the present disclosure;

[0020] FIG. 4 is a schematic diagram of the structure of a video encoding apparatus according to one embodiment of the present disclosure;

[0021] FIG. 5 is a schematic diagram of the structure of a cloud desktop image encoding apparatus according to one embodiment of the present disclosure;

[0022] FIG. 6 is a structural block diagram of a computing device according to one embodiment of the present disclosure. DETAILED DESCRIPTION

[0023] In the following description, many specific details are set forth in order to provide a thorough understanding of the present disclosure. However, the present disclosure can be practiced in many different ways from those described herein, and the present disclosure is not limited to the specific implementations described herein. It can be apparent that the specific implementations, as set forth in the following description, and the accompanying drawings are not limiting on the scope or spirit of the present disclosure.

[0024] The terminology used in the one or more embodiments of the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of the present disclosure. As used in the one or more embodiments of the present disclosure and the accompanying claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "and / or," as used in the one or more embodiments of the present disclosure, refers to and encompasses any or all possible combinations of one or more of the associated listed items.

[0025] It will be understood that, although the terms first, second, etc. can be employed in describing various information, such information should not be limited by these terms. These terms are only used to distinguish one particular information from another. For example, a first item can also be termed a second item, and, similarly, a second item can also be termed a first item, without departing from the scope of the one or more embodiments of the present disclosure. The word "if' as used herein means "when" or "upon" or "in response to the determination" depending on the context.

[0026] In addition, it should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the one or more embodiments of the present disclosure are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0027] First, the nomenclature involved in the one or more embodiments of the present disclosure is explained.

[0028] Cloud desktop: It is a new mode that replaces traditional computers with cloud computing technology. The computer host is virtually created in the server in the back end. The front-end device mainly uses a lightweight client to connect the display and input device. After the user installs the client, the user accesses the virtual machine host on the back-end server through a special communication protocol to realize interactive operation, achieving consistent experience effect with the computer host.

[0029] Video encoding: In the process of video transmission, if the video is not compressed, the existing bandwidth cannot meet the demand of video transmission, so it is necessary to compress the video. More specifically, encoding is a technology that converts information from one form (format) to another form (format) according to a specified method. Video encoding is a technology that uses data compression techniques to remove redundant information in digital video signals, converts the original video format file into another video format file, reduces the code rate required to represent the original video, and facilitates the transmission and storage of video data.

[0030] Bitrate: The data flow used by a video file in a unit of time, simply referred to as bitrate, is the most important part of picture quality control in video coding. Generally speaking, under the same resolution, the greater the video bitrate, the smaller the compression ratio and the distortion level, and the higher the picture quality.

[0031] Subjective quality: A method of evaluating video quality by scoring the video after human viewing, reflecting the visual quality of the video in the human eye.

[0032] Rate control: Video coding is a lossy coding process, and the goal of video coding is to save bitrate as much as possible while ensuring the subjective quality of the video, and rate control is an important tool for balancing bitrate and subjective quality.

[0033] Quantization: It refers to the process of mapping the continuous values of a signal (or a large number of possible discrete values) to a finite number of discrete values, achieving a many-to-one mapping of signal values. In video / image coding, after DCT, the transform coefficients often have a large dynamic range, so quantizing the transform coefficients can effectively reduce the signal value space and achieve better compression effect.

[0034] Quantization parameter (QP): In the process of quantization, the quantization parameter is an important parameter for controlling the discrete amplitude of the variable, and is also a major factor affecting the video bitrate and compression level. The quantization parameter is the threshold value selected in the quantization process to discretize the continuous values, which reflects the compression of spatial details. For example, if QP is small, most of the details will be preserved, and the coding quality will be good; if QP is increased, some details will be lost, the bitrate will be reduced, but the image distortion will be increased and the quality will be decreased, and the coding quality will be poor. That is, QP and bitrate are inversely proportional, and as the complexity of the video source increases, this inverse relationship will be more pronounced. The core of rate control is to determine the QP of the macroblock.

[0035] Macroblock (MB): When selecting the quantization parameter for a frame of image, a fixed-size sliding window is usually used as the unit, and the pixel block framed by this sliding window is called a macroblock. Macroblock is the basic unit of coding processing, and the size of a macroblock is usually 16x16 pixels. A coded image must first be divided into multiple blocks (4x4 pixels) to be processed, and obviously a macroblock should be composed of an integer number of blocks. Macroblocks are divided into I, P, and B macroblocks: I macroblocks (intra prediction macroblocks) can only use the decoded pixels in the current slice as reference for intra prediction; P macroblocks (inter prediction macroblocks) can use the previously decoded images as reference images for intra prediction; B macroblocks (inter bi-directional prediction macroblocks) use forward and backward reference images for intra prediction.

[0036] Base quantization parameter: calculated according to the characteristics of the macroblock to be encoded in the video frame to be encoded, as the initial value of macroblock quantization.

[0037] Temporal adaptive quantization: a video compression technique that automatically adjusts the quantization parameter by analyzing the dynamic changes of the video frame, to achieve higher compression efficiency and image quality.

[0038] Blocking effect: refers to the phenomenon of sawtooth, blockiness and other discontinuities in the image during video compression due to the limitation of quantization parameter.

[0039] Macroblock tree (MB-Tree): the main idea of this algorithm is to estimate the information of each macroblock to assist in predicting the future video frame with greater possibility, and these estimated information allows the macroblock tree to weight the quality of each macroblock according to its contribution, for this, the macroblock tree works in the opposite direction of prediction, propagating information from the future frame back to the current frame to be encoded.

[0040] It should be noted that in the cloud desktop scenario, when the local picture of the desktop changes very frequently and dramatically, the image of the non-dramatic change area after being encoded by the video encoder will be severely affected, and obvious blocking effect or blurring will occur, affecting the user experience.

[0041] In one possible implementation, a commonly used encoding tool is to use MB-tree, first analyze the propagation relationship, and allocate bits according to the contribution of MB in inter prediction. But this tool will introduce coding delay, which is not suitable for real-time encoding scenarios such as cloud desktop.

[0042] One embodiment of the present disclosure provides a video encoding method, which realizes temporal adaptive quantization, that is, the quantization parameter can be adaptively updated based on the temporal complexity of the macroblock, to control the image quality of different macroblocks, improve the performance of video encoding by improving the code control mechanism of video encoding, and improve the image quality of cloud desktop video. Specifically, the interframe temporal complexity of the macroblock can be defined and calculated, the greater the temporal complexity of the macroblock, the smaller the interframe correlation, which means that the area changes more frequently, and the image quality of the area can be reduced; if the temporal complexity of the macroblock is small, the area where the macroblock is located changes not dramatically, and more bandwidth is worth to be allocated for encoding to improve the image quality. During encoding, the quantization adjustment coefficient of the macroblock and the quantization parameter compensation coefficient are calculated according to the ratio parameter between the temporal complexity of the macroblock and the average temporal complexity of the encoding frame, and are superimposed into the original code control result. Through the above method, the changes of different areas of the desktop image in the time domain can be analyzed, the slowly changing area can be found out and the image quality can be enhanced, while the overall code rate balance is ensured.

[0043] In the present disclosure, a video encoding method is provided, and the present disclosure also relates to a video encoding apparatus, a computing device, a computer-readable storage medium, and a computer program product, which are described in the following embodiments.

[0044] Referring to FIG. 1, FIG. 1 shows a flowchart of a video encoding method according to an embodiment of the present disclosure, which specifically includes the following steps 102-108.

[0045] Step 102: Divide the to-be-encoded video frame into a plurality of macroblocks, and determine the macroblock time domain complexity of each macroblock according to the macroblock inter-frame variation degree of each macroblock in the to-be-encoded video frame.

[0046] It should be noted that the video encoding method provided by the embodiments of the present disclosure can be applied to a client or a cloud server. If applied to a client, the to-be-encoded video can be obtained through a cloud server or other devices, and transmitted to other devices or a cloud server after encoding. If applied to a cloud server, the to-be-encoded video can be obtained from a client, other servers, or a local cloud server, and transmitted to a client for display after encoding. The cloud server can be connected to one or more clients through a local area network, a wide area network, the Internet, or other types of data networks. The client can include, but is not limited to, a smartphone, a tablet computer, a notebook computer, a palm computer, a personal computer, a smart home device, a vehicle-mounted device, etc. The client can interact with the user through a graphical user interface to realize control operations such as uploading, encoding, and displaying the to-be-encoded video, thereby realizing the video encoding method provided by the embodiments of the present disclosure.

[0047] In actual implementation, when encoding a video, the to-be-encoded video frame can be divided into a plurality of macroblocks, and encoding can be performed in units of macroblocks. Specifically, the to-be-encoded video frame can be divided into a plurality of macroblocks based on the division manner and division size allowed by the encoding rule adopted during the encoding process. For example, the to-be-encoded video frame can be divided into 16*16 macroblocks, 32*32 macroblocks, or 64*64 macroblocks. Generally, the to-be-encoded video frame is divided into 16*16 macroblocks.

[0048] It should be noted that after dividing the macroblocks, the macroblock inter-frame variation degree can be determined, and the macroblock time domain complexity of each macroblock can be calculated. The greater the macroblock time domain complexity, the smaller the macroblock inter-frame correlation, which means that the area of the macroblock changes more frequently. The smaller the macroblock time domain complexity, the greater the macroblock inter-frame correlation, which means that the area of the macroblock changes more slowly. Thus, the macroblock quantization parameter of the encoding process can be controlled based on the macroblock time domain complexity in the subsequent process, thereby realizing targeted control of the encoding quality of macroblocks with different variation degrees.

[0049] In an optional implementation of the embodiment, the macroblock time domain complexity of each macroblock in the to-be-encoded video frame is determined according to the macroblock inter-frame variation degree of each macroblock in the to-be-encoded video frame, comprising: determining the macroblock inter-frame variation degree of each macroblock in the target video frame according to the pixel difference of each macroblock in the target video frame and the previous video frame of the target video frame, wherein the target video frame is a video frame before the to-be-encoded video frame in the to-be-encoded video; calculating the macroblock inter-frame variation degree of each macroblock in the to-be-encoded video frame according to the macroblock inter-frame variation degree of each macroblock in the target video frame; and determining the macroblock time domain complexity of each macroblock in the to-be-encoded video frame according to the macroblock inter-frame variation degree of each macroblock in the to-be-encoded video frame, the weight factor and the historical time domain complexity of each macroblock in the previous video frame of the to-be-encoded video frame.

[0050] In actual implementation, when calculating the macroblock inter-frame variation degree of each macroblock in the target video frame, the previous video frame of the target video frame is combined to calculate the macroblock inter-frame variation degree of each macroblock in the target video frame according to the pixel difference of each macroblock in the two video frames, wherein the pixel difference can be the difference of pixel gray value of each pixel. Each video frame before the to-be-encoded video frame is a target video frame, and the macroblock inter-frame variation degree of each macroblock in the target video frame can be calculated.

[0051] Then, for each macroblock in the target video frame, the macroblock inter-frame variation degrees of the macroblock in each target video frame before the to-be-encoded video frame are summed to obtain the macroblock inter-frame variation degree of the corresponding macroblock in the to-be-encoded video frame, so as to calculate the macroblock inter-frame variation degree of each macroblock in the to-be-encoded video frame by comprehensively considering the macroblock inter-frame variation degrees of each macroblock in each target video frame before the to-be-encoded video frame, and then determine the macroblock time domain complexity of each macroblock in the to-be-encoded video frame according to the macroblock inter-frame variation degree of each macroblock in the to-be-encoded video frame, the weight factor and the historical time domain complexity of each macroblock in the previous video frame of the to-be-encoded video frame.

[0052] In specific implementation, the to-be-encoded video frame is the nth video frame, and the macroblock time domain complexity of the macroblock at the (i, j) position can be calculated by the following formula (1):

[0053] Wherein, MSSE(i, j, n) represents the macroblock time domain complexity of the macroblock at the (i, j) position in the nth video frame; Yn(i, j) represents the macroblock inter-frame variation degree of the macroblock at the (i, j) position in the nth video frame; Factor represents a pre-configured weight factor, which is used to adjust the proportion of the macroblock inter-frame variation degree of the current to-be-encoded video frame and the previous video frame of the to-be-encoded video frame, and is generally configured as 0.2; MSSE(i, j, n-1) is the macroblock time domain complexity of the macroblock at the (i, j) position in the (n-1)th video frame, that is, the historical time domain complexity.

[0054] It should be noted that the macroblock time domain complexity of each macroblock in the current to-be-encoded video frame can be calculated in combination with the macroblock inter-frame variation degree and the historical time domain complexity of each macroblock in the to-be-encoded video frame, fully considering the macroblock variation degree in each video frame before the current to-be-encoded video frame, thereby improving the accuracy of the macroblock time domain complexity and further ensuring the accuracy of the quantization parameter controlled based on the macroblock time domain complexity, and improving the encoding performance.

[0055] In an optional embodiment of the present embodiment, the macroblock inter-frame variation degree of each macroblock in the target video frame is determined according to the pixel difference values of each macroblock in the target video frame and the previous video frame of the target video frame, comprising: subtracting the pixel values of each pixel point in the macroblock at the same position in the previous video frame of the target video frame from the pixel values of each pixel point in the macroblock in the target video frame, respectively, to obtain the pixel difference values of each pixel point in the macroblock; and summing the pixel difference values of each pixel point to obtain the macroblock inter-frame variation degree of the macroblock.

[0056] In actual implementation, the SSE (Sum of Squared Error, error square sum) can be used to measure the variation degree of each macroblock in each target video frame, so as to calculate the macroblock inter-frame variation degree of each macroblock in each target video frame. Specifically, for each macroblock in each target video frame, the pixel difference values of each pixel point in the macroblock can be obtained according to the pixel values of each pixel point in the macroblock at the same position in the two video frames before and after; the pixel difference values of each pixel point are summed to obtain the inter-frame variation degree of the macroblock, thereby obtaining the macroblock inter-frame variation degree of each macroblock in the target video frame.

[0057] In addition, for each macroblock in the to-be-encoded video frame, the macroblock inter-frame variation degrees of the corresponding macroblocks in each target video frame are summed to obtain the macroblock inter-frame variation degree of the macroblock in the to-be-encoded video frame.

[0058] In specific implementation, the macroblock inter-frame variation degree of the macroblock at the (i, j) position in the to-be-encoded video frame can be calculated by the following formula (2):

[0059] wherein (d, k) represents the position coordinates of the pixel point in the macroblock; Cur(i, j)(d, k) represents the pixel gray value of the (d, k) position pixel point of the macroblock at the (i, j) position in the vth target video frame; Pred(i, j)(d, k) represents the pixel gray value of the (d, k) position pixel point of the macroblock at the (i, j) position in the (v-1)th target video frame (i.e. the previous frame of the target video); represents the inter-frame change degree of the macroblock of the vth target video frame.

[0060] In combination with the above formula (1) and formula (2), the formula for calculating the macroblock time domain complexity of the macroblock at the (i, j) position in the nth video frame can be obtained, as shown in the following formula (3):

[0061] For example, FIG. 2a is a schematic diagram of macroblock encoding provided by one embodiment of the present disclosure, as shown in FIG. 2a, the macroblock (MB) at the ((x, x+16), (y, y+16)) position in the (N-1)th video frame is also located at ((x, x+16), (y, y+16)) in the Nth video frame, and based on the pixel difference value of the macroblock at the same position in the previous and subsequent two video frames, the inter-frame change degree of the macroblock can be determined.

[0062] It should be noted that the error sum of squares can be used to measure the change degree of the macroblock in each video frame, and then based on the current to-be-encoded video frame and the previous video frame, the historical average value is calculated in combination with the weight factor, as the time domain complexity of the macroblock in the current to-be-encoded video frame, which comprehensively considers the change degree of the macroblock in the to-be-encoded video frame and the historical video frame, improves the accuracy of the macroblock time domain complexity, and further ensures the accuracy of the quantization parameter controlled based on the macroblock time domain complexity, and improves the encoding performance. The greater the macroblock time domain complexity, the higher the time domain complexity, which means that the change is very drastic and frequent, and the picture quality of the macroblock can be reduced; otherwise, the lower the time domain complexity of the macroblock, the slower and less frequent the change, and then the picture quality can be enhanced.

[0063] Step 104: determining the frame time domain complexity of the to-be-encoded video frame according to the macroblock time domain complexity of each macroblock, and calculating the quantization adjustment coefficient of the target macroblock according to the frame time domain complexity and the target macroblock time domain complexity of the target macroblock, wherein the target macroblock is the current to-be-encoded macroblock.

[0064] wherein the frame time domain complexity is the time domain complexity of the entire image of the to-be-encoded video frame.

[0065] In actual implementation, the quantization adjustment factor of the target macroblock can be calculated according to the frame time domain complexity and the target macroblock time domain complexity of the target macroblock, and the quantization adjustment factor is used to control the quantization parameter of the target macroblock, so as to control the picture quality when different macroblocks are encoded.

[0066] In an optional embodiment of the present embodiment, the frame time domain complexity of the to-be-encoded video frame is determined according to the macroblock time domain complexity of each macroblock, and the method comprises: determining the sum of the macroblock time domain complexity of each macroblock; and determining the frame time domain complexity of the to-be-encoded video frame according to the sum of the macroblock time domain complexity of each macroblock and the number of macroblocks of the to-be-encoded video frame.

[0067] It should be noted that the sum of the macroblock time domain complexity of each macroblock in the to-be-encoded video frame can be determined, and the sum of the macroblock time domain complexity of each macroblock is divided by the number of macroblocks of the to-be-encoded video frame to obtain the average of the time domain complexity of each macroblock in the to-be-encoded video frame, which is used as the frame time domain complexity of the to-be-encoded video frame.

[0068] In actual implementation, the frame time domain complexity of the to-be-encoded video frame can be calculated by the following formula (4):

[0069] wherein, Avg(n) MSSE represents the frame time domain complexity of the nth video frame; (i, j) represents the macroblock position, and Mb represents the number of macroblocks in the nth video frame.

[0070] In the present embodiment, the average of the time domain complexity of each macroblock in the to-be-encoded video frame can be determined as the frame time domain complexity of the to-be-encoded video frame, which is convenient for subsequent calculation of the quantization adjustment factor of the target macroblock by combining the frame time domain complexity of the to-be-encoded video frame and the target macroblock time domain complexity of the target macroblock to be encoded, so as to control the quantization parameter of the target macroblock and thus control the encoding picture quality of the target macroblock.

[0071] In an optional embodiment of the present embodiment, the quantization adjustment factor of the target macroblock is calculated according to the frame time domain complexity and the target macroblock time domain complexity of the target macroblock, and the method comprises: determining a scale parameter of the target macroblock time domain complexity and the frame time domain complexity; and calculating the quantization adjustment factor of the target macroblock according to the scale parameter and a set adjustment factor in the encoding rule.

[0072] In actual implementation, the scale parameter of the target macroblock time domain complexity and the frame time domain complexity can be calculated by the following formula (5): MSSE (5)

[0073] wherein Scale(i, j, n) represents the proportion parameter of the macroblock at the (i, j) position in the nth video frame to the frame time domain complexity.

[0074] In the embodiments of the present disclosure, the proportion of the target macroblock time domain complexity in the frame time domain complexity can be determined, and then the quantization adjustment coefficient of the target macroblock is calculated according to the proportion and the set adjustment coefficient in the encoding rule. Through the proportion of the time domain complexity, the change degree of a certain macroblock in the video frame relative to other macroblocks can be measured, and the quantization adjustment coefficient of the macroblock is calculated. Thus, for the macroblocks in the video to be encoded, different change degrees will determine different quantization adjustment coefficients, so that macroblocks with different change degrees are encoded with different encoding qualities.

[0075] In an optional embodiment of the present embodiment, the set adjustment coefficient includes a frame time domain complexity threshold, a frame time domain complexity adjustment coefficient, and a quantization parameter adjustment coefficient. The calculation of the quantization adjustment coefficient of the target macroblock according to the proportion parameter and the set adjustment coefficient in the encoding rule includes: subtracting the frame time domain complexity threshold from the proportion parameter to obtain a first intermediate value; subtracting the frame time domain complexity adjustment coefficient from the proportion parameter to obtain a second intermediate value; multiplying the proportion of the first intermediate value and the second intermediate value by the quantization parameter adjustment coefficient to obtain the quantization adjustment coefficient of the target macroblock.

[0076] wherein the frame time domain complexity threshold is an adjustment threshold, and when the proportion parameter (Scale) of the macroblock at the (i, j) position in the nth video frame to the frame time domain complexity is less than the frame time domain complexity threshold, it indicates that the change of the macroblock is relatively small, and the quality needs to be enhanced.

[0077] In actual implementation, the frame time domain complexity threshold, the frame time domain complexity adjustment coefficient, and the quantization parameter adjustment coefficient can all be pre-configured. The higher the degree of quality enhancement required, the larger the frame time domain complexity threshold configured, the smaller the frame time domain complexity adjustment coefficient configured, and the larger the quantization parameter adjustment coefficient configured. For example, the frame time domain complexity threshold can generally be set to 10000, the frame time domain complexity adjustment coefficient can generally be set to 9900, and the quantization parameter adjustment coefficient can generally be set to 12000.

[0078] Specifically, the calculation of the quantization adjustment coefficient of the target macroblock according to the proportion parameter and the set adjustment coefficient in the encoding rule can be realized through the following formula (6):

[0079] wherein DeltaQp(i, j, n) represents the quantization adjustment coefficient of the macroblock at the (i, j) position in the nth video frame; Modelthreshold The threshold representing the temporal complexity of a frame, Model Alpha The adjustment factor representing the time-domain complexity of a frame, Model Beta express.

[0080] In this embodiment, the frame temporal complexity threshold, frame temporal complexity adjustment coefficient, and quantization parameter adjustment coefficient are flexibly configured according to the required level of image quality enhancement. Then, based on the frame temporal complexity threshold, frame temporal complexity adjustment coefficient, and quantization parameter adjustment coefficient, the quantization adjustment coefficient of the target macroblock is calculated, thereby controlling the quantization parameters of the target macroblock and controlling the encoded image quality. In this way, the degree of image quality enhancement can be flexibly controlled, optimizing the encoded signal.

[0081] In an optional implementation of this embodiment, after calculating the quantization adjustment coefficient of the target macroblock based on the frame temporal complexity and the target macroblock temporal complexity, the method further includes: determining the quantization parameter compensation coefficient of the video frame to be encoded based on the quantization adjustment coefficient of each macroblock, wherein the quantization parameter compensation coefficient is used to control the bitrate balance of the video frame to be encoded.

[0082] In practice, the quantization parameter compensation coefficient of the video frame to be encoded can be determined based on the quantization adjustment coefficient of each macroblock. This quantization parameter compensation coefficient is used to reduce the image quality of other macroblocks while enhancing the image quality of a certain macroblock.

[0083] It should be noted that since the image quality of some macroblocks is enhanced, in order not to affect the overall bandwidth performance, it is necessary to reduce the image quality of other areas to ensure the overall bitrate balance. Therefore, in addition to introducing quantization adjustment coefficients to control the encoded image quality, quantization parameter compensation coefficients can also be introduced to control the overall bitrate balance of the video frames to be encoded.

[0084] In one optional implementation of this embodiment, determining the quantization parameter compensation coefficient of the video frame to be encoded based on the quantization adjustment coefficient of each macroblock includes: identifying macroblocks among the macroblocks whose quantization adjustment coefficients are less than a set threshold as macroblocks to be enhanced; and calculating the quantization parameter compensation coefficient of the video frame to be encoded based on the quantization adjustment coefficient of the macroblocks to be enhanced.

[0085] The threshold is a pre-configured value used to determine whether a macroblock needs enhanced image quality; for example, the threshold can be set to 0.

[0086] In the embodiments of the present disclosure, if the quantization adjustment coefficient is less than the set threshold, it indicates that the quality of the macroblock needs to be enhanced; if the quantization adjustment coefficient is not less than the set threshold, it indicates that the quality of the macroblock does not need to be enhanced. Thus, the macroblock with the quantization adjustment coefficient less than the set threshold in each macroblock can be determined as a macroblock to be enhanced, and then the quantization parameter compensation coefficient is calculated based on the macroblock to be enhanced, so as to reduce the quality of other macroblocks by using the quantization parameter compensation coefficient, and ensure the code rate balance.

[0087] In an optional embodiment of the present embodiment, the quantization parameter compensation coefficient of the video frame to be encoded is calculated according to the quantization adjustment coefficients of the macroblocks to be enhanced, comprising: determining the sum of the quantization adjustment coefficients of each macroblock to be enhanced; calculating the quantization parameter compensation coefficient of the video frame to be encoded according to the sum of the quantization adjustment coefficients of each macroblock to be enhanced and the number of macroblocks of the video frame to be encoded.

[0088] In actual implementation, the quantization parameter compensation coefficient of the video frame to be encoded is calculated by adding the quantization adjustment coefficients of all the macroblocks to be enhanced in the video frame to be encoded and dividing the sum by the number of all the macroblocks.

[0089] Specifically, the quantization parameter compensation coefficient of the video frame to be encoded is calculated according to the quantization adjustment coefficients of the macroblocks to be enhanced, which can be realized by the following formula (7):

[0090] Wherein, F(n)comp represents the quantization parameter compensation coefficient of the nth video frame; DeltaQp(k,n) represents the quantization adjustment coefficient of the kth macroblock to be enhanced in the nth video frame; Num aq_m b Num mb represents the number of all the macroblocks to be enhanced in the video frame to be encoded.

[0091] In the embodiments of the present disclosure, the sum of the quantization adjustment coefficients of each macroblock to be enhanced is divided by the number of macroblocks of the video frame to be encoded to obtain the quantization parameter compensation coefficient, so as to reduce the quality of other macroblocks by using the quantization parameter compensation coefficient, and ensure the code rate balance.

[0092] Step 106: updating the base quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter.

[0093] It should be noted that the higher the time domain complexity of the target macroblock, the greater the quantization adjustment coefficient obtained by calculation, the greater the quantization adjustment coefficient, the worse the coding quality; the lower the time domain complexity of the target macroblock, the smaller the quantization adjustment coefficient obtained by calculation, the smaller the quantization adjustment coefficient, the better the coding quality. Therefore, according to the quantization adjustment coefficient of the target macroblock, the basic quantization parameter of the target macroblock is updated to obtain an updated quantization parameter, and the target macroblock is encoded based on the updated quantization parameter. If the target macroblock changes more frequently, the updated quantization parameter obtained by calculation will be larger, which realizes reducing the quality of the target macroblock; if the target macroblock changes more frequently, the updated quantization parameter obtained by calculation will be larger, which realizes reducing the quality of the target macroblock.

[0094] In an optional embodiment of the present embodiment, the basic quantization parameter of the target macroblock is updated according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter, comprising: updating the basic quantization parameter of the target macroblock according to the quantization parameter compensation coefficient and the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter.

[0095] It should be noted that if the quantization parameter compensation coefficient is introduced, the basic quantization parameter of the target macroblock can be updated to obtain an updated quantization parameter by combining the quantization parameter compensation coefficient and the quantization adjustment coefficient of the target macroblock, so that macroblocks with different degrees of change can use different quantization parameters to realize encoding, and the coding quality of macroblocks with different degrees of change is controlled in a targeted manner while ensuring overall code rate balance.

[0096] In an optional embodiment of the present embodiment, the basic quantization parameter of the target macroblock is updated according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter, comprising: using the basic quantization parameter of the target macroblock to subtract the quantization adjustment coefficient of the target macroblock to obtain an initial adjustment parameter; and determining the sum of the initial adjustment parameter and the quantization parameter compensation coefficient as the updated quantization parameter.

[0097] In actual implementation, the basic quantization parameter of the target macroblock is updated according to the quantization adjustment coefficient of the target macroblock and the quantization parameter compensation coefficient, and is superimposed into the original code control result. Specifically, the basic quantization parameter of the target macroblock is updated according to the quantization parameter compensation coefficient and the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter, which can be realized by the following formula (8): comp (8)

[0098] Wherein, QP'(i,j) represents the updated quantization parameter of the macroblock at the (i,j) position; and QP(i,j) represents the basic quantization parameter of the macroblock at the (i,j) position.

[0099] In the embodiment of the present disclosure, the basic quantization parameter of the target macroblock is subtracted by the quantization adjustment coefficient of the target macroblock to obtain an initial adjustment parameter; and the sum of the initial adjustment parameter and the quantization parameter compensation coefficient is determined as the updated quantization parameter, so that the quantization adjustment coefficient is added to the code control result, the macroblocks with different change degrees are encoded with different picture qualities, the encoding performance is optimized, and the encoding effect is improved.

[0100] Step 108: encoding the target macroblock according to the updated quantization parameter.

[0101] For example, FIG. 2b is a schematic diagram of an encoding process provided by an embodiment of the present disclosure. As shown in FIG. 2b, after inputting the video frame to be encoded, the macroblock time domain complexity MSSE of each macroblock is determined according to the macroblock inter-frame change degree, and the frame time domain complexity of the video frame to be encoded is calculated based on the macroblock time domain complexity of each macroblock. The quantization adjustment coefficient DQP of the target macroblock is calculated according to the macroblock time domain complexity and the frame time domain complexity. The quantization parameter compensation coefficient is calculated based on the quantization adjustment coefficient of each macroblock. The quantization adjustment coefficient and the quantization parameter compensation coefficient are applied to the initial basic quantization parameter QP to obtain the updated quantization parameter QP' for quantization.

[0102] The inverse quantization and inverse transformation are performed, and then the deblocking effect filtering, the reconstructed frame, the determination of the reference frame, and the intra-frame prediction / inter-frame prediction are performed on the input video frame to be encoded to obtain the prediction result. The video frame to be encoded and the prediction result are subjected to the transformation and quantization to output the encoding result.

[0103] The video encoding method provided by the embodiment of the present disclosure calculates the macroblock time domain complexity of each macroblock according to the macroblock inter-frame change degree of each macroblock in the video frame to be encoded, and then combines the frame time domain complexity of the video frame to be encoded to calculate the quantization adjustment coefficient of the target macroblock. The quantization parameter compensation coefficient of the video frame to be encoded is calculated based on the quantization adjustment coefficient of the macroblock to be enhanced. The basic quantization parameter is updated by combining the quantization adjustment coefficient and the quantization parameter compensation coefficient to obtain the updated quantization parameter, and the target macroblock is encoded. In this way, the picture content change degree of the region where the macroblock is located is predicted based on the macroblock time domain complexity, so that the macroblocks with different change degrees can be encoded by using different quantization parameters, the encoding picture quality of the macroblocks with different change degrees is controlled in a targeted manner, and the quantization parameter compensation coefficient is introduced to reduce the picture quality of other macroblocks when enhancing the picture quality of some macroblocks, so as to ensure the overall code rate balance and thus ensure the video encoding effect and optimize the video encoding performance.

[0104] Referring to FIG. 3a, FIG. 3a shows a flow chart of an encoding method of a cloud desktop image according to an embodiment of the present disclosure, applied to a backend server of a cloud application, and specifically comprising the following steps 302 to 308.

[0105] Step 302: Obtain a cloud desktop image to be encoded, and divide the cloud desktop image into a plurality of macroblocks, and determine macroblock time domain complexity of each macroblock according to macroblock interframe variation degree of each macroblock in the cloud desktop image.

[0106] In an optional embodiment of the present embodiment, the determination of the macroblock time domain complexity of each macroblock according to the macroblock interframe variation degree of each macroblock in the cloud desktop image comprises: determining the macroblock interframe variation degree of each macroblock in a target image frame according to pixel difference values of each macroblock in the target image frame and a previous image frame of the target image frame, wherein the target image frame is an image frame before the cloud desktop image in the cloud desktop video to be encoded; calculating the macroblock interframe variation degree of each macroblock in the cloud desktop image according to the macroblock interframe variation degree of each macroblock in the target image frame; and determining the macroblock time domain complexity of each macroblock in the cloud desktop image according to the macroblock interframe variation degree of each macroblock in the cloud desktop image, a weight factor and the historical time domain complexity of each macroblock in the previous image frame of the cloud desktop image.

[0107] Step 304: Determine frame time domain complexity of the cloud desktop image according to the macroblock time domain complexity of each macroblock, and calculate a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and the target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current macroblock to be encoded.

[0108] In an optional embodiment of the present embodiment, after the calculation of the quantization adjustment coefficient of the target macroblock according to the frame time domain complexity and the target macroblock time domain complexity of the target macroblock, the method further comprises: determining a quantization parameter compensation coefficient of the cloud desktop image according to the quantization adjustment coefficient of each macroblock, wherein the quantization parameter compensation coefficient is used to control cloud desktop image rate balance.

[0109] Step 306: Update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock, to obtain an updated quantization parameter.

[0110] In an optional embodiment of the present embodiment, if the quantization parameter compensation coefficient of the cloud desktop image is also calculated after the calculation of the quantization adjustment coefficient of the target macroblock, the updating of the basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain the updated quantization parameter comprises: updating the basic quantization parameter of the target macroblock according to the quantization parameter compensation coefficient and the quantization adjustment coefficient of the target macroblock to obtain the updated quantization parameter.

[0111] Step 308: encode the target macroblock according to the updated quantization parameter, and transmit the encoded macroblock data to the client of the cloud application.

[0112] The cloud desktop image encoding method provided in the embodiments of the present disclosure can be applied to the backend server of the cloud application. The macroblock time domain complexity of each macroblock is calculated according to the macroblock interframe variation degree of each macroblock in the cloud desktop image. Then, the quantization adjustment coefficient of the target macroblock is calculated in combination with the frame time domain complexity of the cloud desktop image. The quantization parameter compensation coefficient of the cloud desktop image is calculated based on the quantization adjustment coefficient obtained by calculation. The basic quantization parameter is updated in combination with the quantization adjustment coefficient and the quantization parameter compensation coefficient. The updated quantization parameter is obtained. The target macroblock is encoded. Then, the encoded macroblock data is transmitted to the client of the front end for display. In this way, when the cloud desktop image is scrolled rapidly, the variation degree of the area that changes slowly is relatively small. The calculated quantization adjustment coefficient is small. The updated quantization parameter is small. Most of the details are retained. The encoding quality is enhanced. At the same time, the overall code rate balance is guaranteed with the help of the quantization parameter compensation coefficient. When the cloud desktop image is scrolled rapidly, the area that changes slowly is relatively optimized and clearer than before.

[0113] The above is a schematic scheme of the cloud desktop image encoding method of the present embodiment. It should be noted that the technical scheme of the cloud desktop image encoding method belongs to the same concept as the technical scheme of the video encoding method described above. The details of the technical scheme of the cloud desktop image encoding method that are not described in detail can be referred to the description of the technical scheme of the video encoding method.

[0114] The video encoding method provided by the present disclosure is taken as an example to further illustrate the video encoding method in the application of the cloud desktop in combination with FIG. 3b. FIG. 3b shows a processing process flowchart of a video encoding method provided by an embodiment of the present disclosure. As shown in FIG. 3b, the backend server of the cloud desktop obtains a cloud desktop image to be encoded. The cloud desktop image is a video frame to be encoded. The cloud desktop image is divided into multiple macroblocks.

[0115] The macroblock time domain complexity of each macroblock is determined according to the macroblock interframe variation degree. The sum of the macroblock time domain complexity of each macroblock is determined. The frame time domain complexity of the cloud desktop image is determined according to the sum of the macroblock time domain complexity of each macroblock and the number of macroblocks in the cloud desktop image.

[0116] For the case that the cloud desktop image is scrolled rapidly, for example, the target macroblock corresponding to the task manager area, the quantization adjustment coefficient of the target macroblock is calculated in combination with the frame time domain complexity and the target macroblock time domain complexity of the target macroblock.

[0117] The quantization parameter compensation coefficient of the cloud desktop image is determined according to the quantization adjustment coefficient of each macroblock.

[0118] The base quantization parameter of the target macroblock is updated according to the quantization adjustment coefficient and the quantization parameter compensation coefficient of the target macroblock, and an updated quantization parameter is output. The task manager area is encoded using the updated quantization parameter, and the encoded desktop image is pushed to the front-end device for display.

[0119] In the embodiments of the present disclosure, when the cloud desktop image is scrolled violently, the text in the task manager area changes slowly, the calculated quantization adjustment coefficient is small, and the updated quantization parameter is small, so most details are retained, the encoding quality is enhanced, and the overall code rate is balanced with the help of the quantization parameter compensation coefficient. When the desktop image is scrolled violently, the text in the task manager area is clearer than before.

[0120] Corresponding to the method embodiments, the present disclosure also provides video encoding device embodiments. FIG. 4 shows a structural schematic diagram of a video encoding device according to an embodiment of the present disclosure. As shown in FIG. 4, the device includes a first determination module 402, a first calculation module 404, a first update module 406, and an encoding module 408.

[0121] The first determination module 402 is configured to divide a to-be-encoded video frame into a plurality of macroblocks, and determine the macroblock time domain complexity of each macroblock in the to-be-encoded video frame according to the macroblock change degree of the macroblock.

[0122] The first calculation module 404 is configured to determine the frame time domain complexity of the to-be-encoded video frame according to the macroblock time domain complexity of each macroblock, and calculate the quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and the target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current to-be-encoded macroblock.

[0123] The first update module 406 is configured to update the base quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock, and obtain an updated quantization parameter.

[0124] The encoding module 408 is configured to encode the target macroblock according to the updated quantization parameter.

[0125] Optionally, the first determining module 402 is further configured to: determine the inter-frame variation degree of each macroblock in the target video frame according to the pixel difference of each macroblock in the target video frame and the pixel difference of each macroblock in a previous video frame of the target video frame, wherein the target video frame is a video frame before the to-be-encoded video frame in the to-be-encoded video; obtain the inter-frame variation degree of each macroblock in the to-be-encoded video frame according to the inter-frame variation degree of each macroblock in the target video frame; and determine the temporal complexity of each macroblock in the to-be-encoded video frame according to the inter-frame variation degree of each macroblock in the to-be-encoded video frame, a weight factor, and the historical temporal complexity of each macroblock in a previous video frame of the to-be-encoded video frame.

[0126] Optionally, the first determining module 402 is further configured to: subtract the pixel value of each pixel point in a macroblock at the same position in a previous video frame of the target video frame from the pixel value of each pixel point in the macroblock in the target video frame to obtain the pixel difference of each pixel point in the macroblock; and sum the pixel difference of each pixel point to obtain the inter-frame variation degree of the macroblock.

[0127] Optionally, the first calculating module 404 is further configured to: determine the sum of the temporal complexity of each macroblock; and determine the frame temporal complexity of the to-be-encoded video frame according to the sum of the temporal complexity of each macroblock and the number of macroblocks in the to-be-encoded video frame.

[0128] Optionally, the first calculating module 404 is further configured to: determine a proportion parameter of the target macroblock temporal complexity and the frame temporal complexity; and calculate the quantization adjustment coefficient of the target macroblock according to the proportion parameter and a set adjustment coefficient in the encoding rule.

[0129] Optionally, the set adjustment coefficient includes a threshold of the frame temporal complexity, an adjustment coefficient of the frame temporal complexity, and a quantization parameter adjustment coefficient; the first calculating module 404 is further configured to: subtract the threshold of the frame temporal complexity from the proportion parameter to obtain a first intermediate value; subtract the adjustment coefficient of the frame temporal complexity from the proportion parameter to obtain a second intermediate value; and multiply the proportion of the first intermediate value and the second intermediate value by the quantization parameter adjustment coefficient to obtain the quantization adjustment coefficient of the target macroblock.

[0130] Optionally, the apparatus further includes a third determining module configured to: determine a quantization parameter compensation coefficient of the to-be-encoded video frame according to the quantization adjustment coefficient of each macroblock, wherein the quantization parameter compensation coefficient is used to control the rate balance of the to-be-encoded video frame.

[0131] Correspondingly, the first updating module 406 is further configured to: update the base quantization parameter of the target macroblock to obtain an updated quantization parameter according to the quantization adjustment coefficient of the target macroblock and the quantization parameter compensation coefficient of the target macroblock.

[0132] Optionally, the third determining module is further configured to: determine a macroblock whose quantization adjustment coefficient is less than a set threshold as a macroblock to be enhanced; and calculate the quantization parameter compensation coefficient of the video frame to be encoded according to the quantization adjustment coefficient of the macroblock to be enhanced.

[0133] Optionally, the third determining module is further configured to: determine a sum of quantization adjustment coefficients of all the macroblocks to be enhanced; and calculate the quantization parameter compensation coefficient of the video frame to be encoded according to the sum of the quantization adjustment coefficients of all the macroblocks to be enhanced and a number of macroblocks of the video frame to be encoded.

[0134] Optionally, the first updating module 406 is further configured to: obtain an initial adjustment parameter by subtracting the quantization adjustment coefficient of the target macroblock from the base quantization parameter of the target macroblock; and determine a sum of the initial adjustment parameter and the quantization parameter compensation coefficient as the updated quantization parameter.

[0135] The video encoding apparatus provided in the embodiments of the present disclosure includes a first determining module, a first calculating module, a first updating module and an encoding module. The above modules are used to predict the degree of change of the picture content of the region where the macroblock is located based on the time domain complexity of the macroblock, so that macroblocks with different degrees of change can be encoded using different quantization parameters, the encoding quality of macroblocks with different degrees of change is controlled in a targeted manner, the quantization parameter compensation coefficient is introduced, the quality of other macroblocks is reduced when the quality of some macroblocks is enhanced, and the overall code rate balance is ensured, thereby ensuring the effect of video encoding and optimizing the performance of video encoding.

[0136] The above is a schematic scheme of the video encoding apparatus of the present embodiment. It should be noted that the technical scheme of the video encoding apparatus belongs to the same concept as the technical scheme of the video encoding method described above, and the details of the technical scheme of the video encoding apparatus that are not described in detail can be referred to the description of the technical scheme of the video encoding method.

[0137] Corresponding to the method embodiments described above, the present disclosure further provides an encoding apparatus for cloud desktop images. FIG. 5 shows a structural schematic diagram of an encoding apparatus for cloud desktop images according to an embodiment of the present disclosure. As shown in FIG. 5, the apparatus includes a second determining module 502, a second calculating module 504, a second updating module 506 and a transmission module 508.

[0138] The second determining module 502 is configured to acquire a cloud desktop image to be encoded, divide the cloud desktop image into a plurality of macroblocks, and determine macroblock time domain complexity of each macroblock in the cloud desktop image according to macroblock interframe variation degree of each macroblock in the cloud desktop image.

[0139] The second calculating module 504 is configured to determine frame time domain complexity of the cloud desktop image according to the macroblock time domain complexity of each macroblock, and calculate a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current macroblock to be encoded.

[0140] The second updating module 506 is configured to update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock, and obtain an updated quantization parameter.

[0141] The transmission module 508 is configured to encode the target macroblock according to the updated quantization parameter, and transmit encoded macroblock data to a client of the cloud application.

[0142] Optionally, the second determining module 502 is further configured to: determine macroblock interframe variation degree of each macroblock in a target image frame according to pixel difference values of each macroblock in the target image frame and a previous image frame of the target image frame, wherein the target image frame is an image frame before the cloud desktop image in the cloud desktop video to be encoded; calculate the macroblock interframe variation degree of each macroblock in the cloud desktop image according to the macroblock interframe variation degree of each macroblock in the target image frame; and determine macroblock time domain complexity of each macroblock in the cloud desktop image according to the macroblock interframe variation degree of each macroblock in the cloud desktop image, a weight factor, and historical time domain complexity of each macroblock in the previous image frame of the cloud desktop image.

[0143] Optionally, the apparatus further includes a fourth determining module configured to: determine a quantization parameter compensation coefficient of the cloud desktop image according to the quantization adjustment coefficient of each macroblock, wherein the quantization parameter compensation coefficient is used to control code rate balance of the cloud desktop image.

[0144] Correspondingly, the second updating module 506 is further configured to: update the basic quantization parameter of the target macroblock according to the quantization parameter compensation coefficient and the quantization adjustment coefficient of the target macroblock to obtain the updated quantization parameter.

[0145] The cloud desktop image encoding device provided in the embodiments of the present disclosure can be applied to a back-end server of a cloud application, and comprises a second determination module, a second calculation module, a second updating module and a transmission module. By using the above modules, for a region with a slow change degree when the cloud desktop image is rolling rapidly, a calculated quantization adjustment coefficient is small, and then an updated quantization parameter is small, so most details are retained, the coding quality is enhanced, and meanwhile, the overall code rate balance is ensured by means of a quantization parameter compensation coefficient. When the cloud desktop image is rolling rapidly, the region with a slow change degree is relatively clearer than before optimization.

[0146] The above is a schematic scheme of the cloud desktop image encoding device of the present embodiment. It should be noted that the technical scheme of the cloud desktop image encoding device belongs to the same concept as the technical schemes of the video encoding method and the cloud desktop image encoding method, and the details of the technical scheme of the cloud desktop image encoding device that are not described in detail can be referred to the description of the technical schemes of the video encoding method and the cloud desktop image encoding method.

[0147] FIG. 6 shows a structural block diagram of a computing device according to an embodiment of the present disclosure. The components of the computing device 600 include, but are not limited to, a memory 610 and a processor 620. The processor 620 is connected with the memory 610 through a bus 630, and a database 650 is used to save data.

[0148] The computing device 600 also includes an access device 640 that enables the computing device 600 to communicate via one or more networks 660. Examples of such networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or combinations of such networks, such as the Internet. The access device 640 can include one or more of any type of network interface (for example, a network interface card (NIC)) such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a Worldwide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC).

[0149] In one embodiment of the present disclosure, the above-mentioned components of the computing device 600 and other components not shown in FIG. 6 can also be connected to each other, for example, through a bus. It should be understood that the computing device structure block diagram shown in FIG. 6 is only for the purpose of example, and is not a limitation on the scope of the present disclosure. Other components can be added or replaced by those skilled in the art as needed.

[0150] The computing device 600 can be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (for example, a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, and the like), a mobile phone (for example, a smartphone), a wearable computing device (for example, a smart watch, smart glasses, and the like), or other types of mobile devices, or a stationary computing device such as a desktop computer or a personal computer (PC). The computing device 600 can also be a mobile or stationary server.

[0151] The processor 620 is configured to execute computer-executable instructions, which, when executed by the processor, implement the steps of the above-mentioned video encoding method or the cloud desktop image encoding method.

[0152] The above is a schematic scheme of the computing device of the embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the video encoding method and the encoding method of the cloud desktop image belong to the same concept, and the details of the technical scheme of the computing device that are not described in detail can be referred to the description of the technical scheme of the video encoding method and the encoding method of the cloud desktop image.

[0153] An embodiment of the present disclosure further provides a computer readable storage medium storing computer executable instructions, and the computer executable instructions are executed by a processor to implement the steps of the video encoding method or the encoding method of the cloud desktop image.

[0154] The above is a schematic scheme of the computer readable storage medium of the embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the video encoding method and the encoding method of the cloud desktop image belong to the same concept, and the details of the technical scheme of the storage medium that are not described in detail can be referred to the description of the technical scheme of the video encoding method and the encoding method of the cloud desktop image.

[0155] An embodiment of the present disclosure further provides a computer program product, comprising computer program / instructions, and the computer program / instructions are executed by a processor to implement the steps of the video encoding method or the encoding method of the cloud desktop image.

[0156] The above is a schematic scheme of the computer program product of the embodiment. It should be noted that the technical scheme of the computer program product and the technical scheme of the video encoding method and the encoding method of the cloud desktop image belong to the same concept, and the details of the technical scheme of the computer program product that are not described in detail can be referred to the description of the technical scheme of the video encoding method and the encoding method of the cloud desktop image.

[0157] The above describes specific embodiments of the present disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order to achieve the desired results. In certain implementations, multitasking and parallel processing can be advantageous.

[0158] The computer readable medium can include any entity or apparatus capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, software distribution medium, etc. It should be noted that the computer readable medium can include appropriate additions or subtractions according to the requirements of patent practice. For example, according to the patent practice in some regions, the computer readable medium does not include electrical carrier signals and telecommunication signals.

[0159] It should be noted that, for the foregoing method embodiments, in order to facilitate description, each is described as a combination of a series of acts, but those skilled in the art should appreciate that the embodiments of the present disclosure are not limited by the order of the described acts, because, according to the embodiments of the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should appreciate that the embodiments described in the specification are all preferred embodiments, and the acts and modules involved are not necessarily essential to the embodiments of the present disclosure.

[0160] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0161] The preferred embodiments of the present disclosure disclosed above are only used to help explain the present disclosure. The alternative embodiments do not describe all the details and do not limit the invention to the specific embodiments described. Obviously, according to the content of the embodiments of the present disclosure, many modifications and changes can be made. The present disclosure selects and describes these embodiments in order to better explain the principles and practical applications of the embodiments of the present disclosure, so that those skilled in the art can well understand and utilize the present disclosure. The present disclosure is limited only by the claims and their full scope and equivalents.

Claims

1. A method for video coding, comprising: dividing a video frame to be coded into a plurality of macroblocks, determining macroblock temporal complexity of each macroblock in the video frame to be coded according to macroblock inter-frame variation of the macroblock; determining frame temporal complexity of the video frame to be coded according to the macroblock temporal complexity of each macroblock, calculating a quantization adjustment coefficient of a target macroblock according to the frame temporal complexity and target macroblock temporal complexity of the target macroblock, wherein the target macroblock is a current macroblock to be coded; updating a base quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter; and coding the target macroblock according to the updated quantization parameter. 2.The method of claim 1, wherein the macroblock temporal complexity of each macroblock in the video frame to be coded is determined according to macroblock inter-frame variation of each macroblock in a target video frame and a previous video frame of the target video frame, wherein the target video frame is a video frame before the video frame to be coded in the video to be coded; the macroblock inter-frame variation of each macroblock in the target video frame is calculated according to the macroblock inter-frame variation of each macroblock in the target video frame; and the macroblock temporal complexity of each macroblock in the video frame to be coded is determined according to the macroblock inter-frame variation of each macroblock in the video frame to be coded, a weight factor and historical temporal complexity of each macroblock in a previous video frame of the video frame to be coded. 3.The method of claim 2, wherein the macroblock inter-frame variation of each macroblock in the target video frame is determined according to pixel difference of each pixel point in the macroblock in the target video frame and the macroblock in the previous video frame of the target video frame, wherein the pixel difference of each pixel point in the macroblock is obtained by subtracting pixel value of each pixel point in the macroblock in the previous video frame of the target video frame from pixel value of each pixel point in the macroblock in the target video frame; and the macroblock inter-frame variation of the macroblock is obtained by summing the pixel difference of each pixel point. 4.The method of any one of claims 1-3, wherein the frame temporal complexity of the video frame to be coded is determined according to the sum of the macroblock temporal complexity of each macroblock; and the frame temporal complexity of the video frame to be coded is determined according to the sum of the macroblock temporal complexity of each macroblock and the number of macroblocks in the video frame to be coded. 5.The method of any one of claims 1-3, wherein the quantization adjustment coefficient of the target macroblock is calculated according to a proportional parameter of the target macroblock temporal complexity and the frame temporal complexity; and the quantization adjustment coefficient of the target macroblock is calculated according to the proportional parameter and a set adjustment coefficient in a coding rule. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ 6. The video coding method of claim 5, wherein the setting the adjustment factor comprises a frame temporal complexity threshold, a frame temporal complexity adjustment factor, and a quantization parameter adjustment factor; and wherein the calculating the quantization adjustment factor of the target macroblock according to the scaling parameter and the set adjustment factor in the coding rule comprises: subtracting the frame temporal complexity threshold from the scaling parameter to obtain a first intermediate value; subtracting the frame temporal complexity adjustment factor from the scaling parameter to obtain a second intermediate value; multiplying the scaling parameter by a ratio of the first intermediate value and the second intermediate value to obtain the quantization adjustment factor of the target macroblock.

7. The video coding method of any one of claims 1-3, wherein after the calculating the quantization adjustment factor of the target macroblock according to the frame temporal complexity and the target macroblock temporal complexity of the target macroblock, the method further comprises: determining a quantization parameter compensation factor of the video frame to be coded according to the quantization adjustment factor of each macroblock, wherein the quantization parameter compensation factor is used to control a code rate balance of the video frame to be coded; and correspondingly, the updating the base quantization parameter of the target macroblock according to the quantization adjustment factor of the target macroblock to obtain an updated quantization parameter comprises: updating the base quantization parameter of the target macroblock according to the quantization parameter compensation factor and the quantization adjustment factor of the target macroblock to obtain the updated quantization parameter.

8. The video coding method of claim 7, wherein the determining the quantization parameter compensation factor of the video frame to be coded according to the quantization adjustment factor of each macroblock comprises: determining a macroblock whose quantization adjustment factor is less than a set threshold as an enhanced macroblock; and calculating the quantization parameter compensation factor of the video frame to be coded according to the quantization adjustment factor of the enhanced macroblock.

9. The video coding method of claim 8, wherein the calculating the quantization parameter compensation factor of the video frame to be coded according to the quantization adjustment factor of the enhanced macroblock comprises: determining a sum of the quantization adjustment factors of the enhanced macroblocks; and calculating the quantization parameter compensation factor of the video frame to be coded according to the sum of the quantization adjustment factors of the enhanced macroblocks and a number of macroblocks of the video frame to be coded.

10. The video coding method of claim 7, wherein the updating the base quantization parameter of the target macroblock according to the quantization parameter compensation factor and the quantization adjustment factor of the target macroblock to obtain the updated quantization parameter comprises: obtaining an initial adjustment parameter by subtracting the quantization adjustment factor of the target macroblock from the base quantization parameter of the target macroblock; and determining a sum of the initial adjustment parameter and the quantization parameter compensation factor as the updated quantization parameter.

11. A cloud desktop image coding method applied to a backend server of a cloud application, comprising: obtaining a cloud desktop image to be coded, and dividing the cloud desktop image into a plurality of macroblocks, and determining a macroblock temporal complexity of each macroblock in the cloud desktop image according to a macroblock inter-frame variation degree of the macroblock. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ determine a frame temporal complexity of the cloud desktop image according to the macroblock temporal complexity of each macroblock, calculate a quantization adjustment coefficient of a target macroblock according to the frame temporal complexity and a target macroblock temporal complexity of the target macroblock, wherein the target macroblock is a current to-be-encoded macroblock; update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter; encode the target macroblock according to the updated quantization parameter, and transmit encoded macroblock data to a client of the cloud application.

12. The cloud desktop image encoding method of claim 11, wherein the macroblock temporal complexity of each macroblock in the cloud desktop image is determined according to a macroblock interframe variation degree of each macroblock in the cloud desktop image, and the macroblock interframe variation degree of each macroblock in the target image frame is determined according to a pixel difference value of each macroblock in the target image frame and a previous image frame of the target image frame.

12. The cloud desktop image encoding method of claim 11, wherein the macroblock temporal complexity of each macroblock in the cloud desktop image is determined according to a macroblock interframe variation degree of each macroblock in the cloud desktop image, and the macroblock interframe variation degree of each macroblock in the target image frame is determined according to a pixel difference value of each macroblock in the target image frame and a previous image frame of the target image frame.

13. The cloud desktop image encoding method of claim 11 or 12, wherein after the quantization adjustment coefficient of the target macroblock is calculated according to the frame temporal complexity and the target macroblock temporal complexity of the target macroblock, the method further comprises: determining a quantization parameter compensation coefficient of the cloud desktop image according to the quantization adjustment coefficient of each macroblock, wherein the quantization parameter compensation coefficient is used to control a code rate balance of the cloud desktop image.

13. The cloud desktop image encoding method of claim 11 or 12, wherein after the quantization adjustment coefficient of the target macroblock is calculated according to the frame temporal complexity and the target macroblock temporal complexity of the target macroblock, the method further comprises: determining a quantization parameter compensation coefficient of the cloud desktop image according to the quantization adjustment coefficient of each macroblock, wherein the quantization parameter compensation coefficient is used to control a code rate balance of the cloud desktop image.

14. A video encoding apparatus, comprising: a first determining module configured to divide a to-be-encoded video frame into a plurality of macroblocks, and determine a macroblock temporal complexity of each macroblock in the to-be-encoded video frame according to a macroblock variation degree of each macroblock in the to-be-encoded video frame; a first calculating module configured to determine a frame temporal complexity of the to-be-encoded video frame according to the macroblock temporal complexity of each macroblock, and calculate a quantization adjustment coefficient of a target macroblock according to the frame temporal complexity and a target macroblock temporal complexity of the target macroblock, wherein the target macroblock is a current to-be-encoded macroblock; a first updating module configured to update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock to obtain an updated quantization parameter; and an encoding module configured to encode the target macroblock according to the updated quantization parameter. ​ ​ ​ ​ ​ ​ ​ ​ 15. An apparatus for encoding a cloud desktop image, applied to a backend server of a cloud application, comprising: a second determining module configured to obtain a cloud desktop image to be encoded, divide the cloud desktop image into a plurality of macroblocks, and determine a macroblock time domain complexity of each macroblock in the cloud desktop image according to a macroblock inter-frame variation degree of the each macroblock; a second calculating module configured to determine a frame time domain complexity of the cloud desktop image according to the macroblock time domain complexity of the each macroblock, calculate a quantization adjustment coefficient of a target macroblock according to the frame time domain complexity and a target macroblock time domain complexity of the target macroblock, wherein the target macroblock is a current macroblock to be encoded; a second updating module configured to update a basic quantization parameter of the target macroblock according to the quantization adjustment coefficient of the target macroblock, and obtain an updated quantization parameter; a transmitting module configured to encode the target macroblock according to the updated quantization parameter, and transmit encoded macroblock data to a client of the cloud application.

16. A computing device, comprising: a memory and a processor; the memory is configured to store computer programs / instructions, and the processor is configured to execute the computer programs / instructions, which, when executed by the processor, implement steps of the video encoding method of any one of claims 1 to 10 or the cloud desktop image encoding method of any one of claims 11 to 13.

17. A computer readable storage medium storing computer programs / instructions, which, when executed by a processor, implement steps of the video encoding method of any one of claims 1 to 10 or the cloud desktop image encoding method of any one of claims 11 to 13.

18. A computer program product comprising computer programs / instructions, which, when executed by a processor, implement steps of the video encoding method of any one of claims 1 to 10 or the cloud desktop image encoding method of any one of claims 11 to 13.

Citation Information

Patent Citations

  • Video coding method applied to web camera, computer readable medium and electronic equipment

    CN116074513A

  • Code rate control method and device for image block level of P frame or B frame

    CN116916027A

  • Dynamic image decoding apparatus and dynamic image coding apparatus

    JP2005094801A

  • Temporal Local Activity for Quantization Parameter (QP) Offset for Video Coding

    US20180109794A1