Adaptive coding method, device, equipment and computer program product

By dynamically adjusting the quantization parameters according to the video conference scene and the degree of change in the data frame, the problem of poor coding flexibility at low bit rates is solved, and the stability and image quality of the video conference are improved.

CN118413674BActive Publication Date: 2024-08-23HANGZHOU HIKVISION DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410859104.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-27
Publication Date
2024-08-23
Estimated Expiration
2044-06-27

AI Technical Summary

Technical Problem

In video conferencing, traditional encoding methods in low bit rate scenarios have poor encoding flexibility due to fixed configuration of quantization parameters (QP values), which may cause the bit rate to exceed the range or the picture to be blurred, affecting the stability and quality of the video conference.

Method used

By automatically determining the target encoding scene according to the degree of change between the current encoding scene and the data frame during the video conference, and setting appropriate quantization parameters (QP values) according to the target encoding scene, it improves the flexibility of the encoding process and ensures that the code rate is within Tolerable range and maintain image quality.

Benefits of technology

It improves the stability and image quality of video conferencing, avoids the problems of bit rate over-range and blurry images, and enhances the flexibility of the encoding process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118413674B
    Figure CN118413674B
Patent Text Reader

Abstract

The present application provides an adaptive coding method, apparatus, device and computer program product. The method comprises: obtaining data frames from the data to be coded at a preset time interval; obtaining a target coding scene when the scene switching condition is determined to be satisfied according to the current coding scene and the degree of change between adjacent data frames in the obtained data frames; and encoding the data to be coded according to the QP value corresponding to the target coding scene. The method can improve the flexibility of the QP value configuration process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data coding technology, and in particular to an adaptive coding method, device, equipment and computer program product. Background Art

[0002] With the rapid development of online office, users have higher requirements for improving the online office experience, such as improving the experience during video conferencing.

[0003] At present, during a video conference, the data to be encoded on the local device needs to be encoded and then transmitted to the peer device. In a video conference scenario, there may be a problem of poor network conditions. At this time, the network bandwidth is limited, and the bit rate it can support (the number of data bits transmitted per unit time during data transmission, which can also be called bit rate in the video field) is low. For example, the supported bit rate is 1024Kbps and below. This scenario can be called a low bit rate scenario. In addition, in order to ensure the compatibility of the encoding format with the device, that is, to provide more comprehensive support for all possible conference access devices (peer devices), the most basic encoding format is generally used, such as H.264BP, and the amount of data corresponding to this encoding format is larger than the amount of data corresponding to other encoding formats, which makes it easier to exceed the supported bit rate during transmission.

[0004] However, in this low bit rate scenario, traditional solutions either configure the QP (Quantizer Parameter) value involved in the encoding process to be large in order to avoid the encoded data exceeding the supported bit rate, or configure the QP value involved in the encoding process to be small in order to ensure image quality. That is, regardless of the purpose, the QP value is fixed, resulting in poor flexibility in the configuration process. Summary of the invention

[0005] In view of this, the present application provides an adaptive encoding method, apparatus, device and computer program product.

[0006] Specifically, the present application is implemented through the following technical solutions:

[0007] According to a first aspect of an embodiment of the present application, there is provided an adaptive encoding method, including:

[0008] Obtaining data frames from the data to be encoded at preset time intervals;

[0009] Determining a target coding scene when it is determined that a scene switching condition is met based on the current coding scene and the degree of change between adjacent data frames in the acquired data frames;

[0010] The to-be-encoded data is encoded according to the QP value corresponding to the target encoding scenario.

[0011] According to a second aspect of an embodiment of the present application, a low bit rate scene adaptive encoding device is provided, including:

[0012] An acquisition unit, used for acquiring data frames from the data to be encoded at preset time intervals;

[0013] A determination unit, configured to determine a target coding scene when it is determined that a scene switching condition is met based on a current coding scene and a degree of change between adjacent data frames in the acquired data frames;

[0014] The encoding unit is used to encode the to-be-encoded data according to the QP value corresponding to the target encoding scenario.

[0015] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including a processor and a memory, wherein:

[0016] Memory, used to store computer programs;

[0017] The processor is used to implement the method provided in the first aspect when executing the program stored in the memory.

[0018] According to a fourth aspect of an embodiment of the present application, a computer program product is provided, wherein a computer program is stored in the computer program product, and when the computer program is executed by a processor, the method provided in the first aspect is implemented.

[0019] The adaptive encoding method of the embodiment of the present application obtains data frames from the data to be encoded at preset time intervals, determines the target encoding scene when it is determined that the scene switching condition is met based on the current encoding scene and the degree of change between adjacent data frames in the acquired data frames, encodes the data to be encoded based on the QP value corresponding to the target encoding scene, automatically determines the encoding scene by presetting the degree of change between adjacent data frames, and determines the QP value to be used based on the encoding scene. Compared with the implementation scheme using a fixed configuration QP value, the flexibility of using the QP value in the encoding process is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a flowchart of an adaptive coding method shown in an exemplary embodiment of the present application;

[0021] Figure 2 is a schematic diagram of a method for calculating a degree of change shown in an exemplary embodiment of the present application;

[0022] Figure 3a is a schematic diagram of a method for obtaining a target component value shown in an exemplary embodiment of the present application;

[0023] Figure 3b is a schematic diagram of another method for obtaining a target component value according to an exemplary embodiment of the present application;

[0024] Figure 3c is a schematic diagram of another method for obtaining a target component value according to an exemplary embodiment of the present application;

[0025] Figure 4 is a schematic diagram of distribution of a data frame shown in an exemplary embodiment of the present application;

[0026] Figure 5 is a structural schematic diagram of an adaptive coding device shown in an exemplary embodiment of the present application;

[0027] Figure 6 It is a schematic diagram of the hardware structure of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0028] An embodiment of the present application proposes an adaptive encoding method, which is applied to a local device. The local device is used to encode the data to be encoded collected during the video conference and send it to the opposite device, so that the opposite device can display the data to be encoded to other participants (except the participants of the local device), thereby realizing the normal progress of the video conference.

[0029] In actual applications, the QP value is configured fixedly, resulting in poor flexibility in the configuration process. In addition, a small QP value configuration will cause the bit rate to exceed the setting range, resulting in the loss of data packets received by the peer device; a large QP value configuration will cause the peer device to have blurred images. In other words, the way of configuring the QP value in actual applications not only leads to poor flexibility in the configuration process, but also no matter how the QP value is configured, there will be some unsatisfactory conditions during the video conference, resulting in poor stability and quality of the video conference.

[0030] In response to the above problems, an encoding scheme based on the correspondence between the target encoding scenario and the QP value is proposed in an embodiment of the present application. The encoding scheme corresponds different QP values ​​to the target encoding scenario. That is, after determining the target encoding scenario under the current video conference, a matching QP value can be obtained, thereby improving the flexibility of the QP value configuration process, and specifically solving the problems of over-bitrate and blurred picture, thereby improving the stability and quality of the video conference.

[0031] In order to enable those skilled in the art to better understand the technical solutions provided in the embodiments of the present application, some terms involved in the embodiments of the present application are explained below:

[0032] Macroblock: Macroblock is a basic concept in video coding technology. It is a strategy that divides the picture into several blocks of different sizes to apply different compression to different positions. In video coding, a coded image (data frame) is usually divided into several macroblocks. A macroblock consists of a luminance pixel block and two additional chrominance pixel blocks. Generally speaking, the luminance pixel block is a 16x16 pixel block, and the size of the two chrominance pixel blocks depends on the sampling format of the coded image. For example, for a YUV420 sampled image, the chrominance pixel block is an 8x8 pixel block. In each coded image, several macroblocks are arranged in the form of slices. The video coding algorithm encodes macroblocks one by one in units of macroblocks and organizes them into a continuous video code stream.

[0033] YUV: YUV is a color encoding method, commonly used in various video processing components. YUV represents the type of compiled true-color color space (color space). Y'UV, YUV, YCbCr, YPbPr and other special terms can all be referred to as YUV. The value of YUV includes three components, namely the Y component value, the U component value and the V component value. Among them, "Y" represents brightness (Luminance or Luma), which is the grayscale value of the pixel, and "U" and "V" represent chrominance (Chrominance or Chroma), which is used to describe the color and saturation of the image and is used to specify the color of the pixel.

[0034] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.

[0035] See also Figure 1 , is a flow chart of an adaptive encoding method provided in an embodiment of the present application, such as Figure 1 As shown, the adaptive encoding method may include the following steps:

[0036] Step S100: obtaining data frames from the data to be encoded at preset time intervals.

[0037] Exemplarily, the preset time interval can be set according to actual needs, including but not limited to 200 ms, 300 ms or 500 ms.

[0038] Exemplarily, the data to be encoded is collected during a video conference, encoded, and then transmitted between participating devices (including the above-mentioned local device and opposite device). The code streams used during the video conference include but are not limited to single stream, auxiliary stream, dual stream, and multiple streams.

[0039] It should be noted that for different preset time intervals, when acquiring data frames (hereinafter referred to as frame acquisition), different degrees of change may be obtained, which may cause the subsequent target encoding scene to be accurate or inaccurate. For example, if the frequency of frame acquisition (the preset time interval is inversely proportional to the frequency, wherein the larger the preset time interval, the lower the frequency; the smaller the preset time interval, the higher the frequency) is too high, the degree of change will be low; if the frequency of frame acquisition is low, the changes in the intermediate data frames between two adjacent frames after frame acquisition may be ignored. This makes the inaccurate degree of change used for determining the target encoding scene, which will lead to misjudgment, resulting in the QP value used for encoding being incompatible with the QP value actually required, and then causing the encoded data to fail to achieve the expected effect (such as unclear image quality). For the frequency of frame acquisition, it can be determined through debugging or preset based on the expected effect (such as any value between 2-5Hz).

[0040] The degree of change refers to the pixels in the data frame, and is used to characterize the change in the parameters such as brightness and / or color of the pixels at the same position between two data frames. The same position means that the position coordinates of the pixels in the data frame are the same. For example, there are data frame A and data frame B, and the pixel a with the position coordinates (1, 1) in data frame A is the same as the pixel b with the position coordinates (1, 1) in data frame B.

[0041] In addition, the data frames in the data to be encoded have a certain frame rate, such as any frame rate between 10 and 60 FPS. For the case of a lower frame rate, such as less than 10 FPS, considering that the effect of the peer device processing and displaying the data to be encoded at this frame rate is too poor (such as freeze), it is not meaningful to determine the scene for it, and the embodiment of the present application does not consider the corresponding processing of the data to be encoded in this case.

[0042] Step S110: Determine a target coding scene when it is determined that a scene switching condition is met based on the current coding scene and the degree of change between adjacent data frames in the acquired data frames.

[0043] Exemplarily, for the acquired data frames, the degree of change between adjacent data frames in the data frames can be determined, and based on the current encoding scene and the determined degree of change, it can be determined whether the scene switching condition is met. Then, if it is determined that the scene switching condition is met, the target encoding scene is determined.

[0044] For example, when the current coding scene is a static scene and it is determined that the scene switching condition is met, the target coding scene is a dynamic scene.

[0045] When the current coding scene is a dynamic scene and it is determined that the scene switching condition is met, the target coding scene is a static scene.

[0046] Among them, adjacent data frames are data frames that are adjacent in time sequence. It can be understood that being adjacent in time sequence means being closest in time sequence. For example, the data frames obtained by taking frames include data frame 1, data frame 2 and data frame 3, wherein the time sequence of data frame 1 is 0ms, the time sequence of data frame 2 is 200ms, and the time sequence of data frame 3 is 400ms, then data frame 1 is closest to data frame 2 in time sequence, data frame 2 is closest to data frame 1 and data frame 3, and data frame 3 is closest to data frame 2, that is, data frame 1 is adjacent in time sequence to data frame 2, data frame 2 is adjacent in time sequence to data frame 1 or data frame 3, and data frame 3 is adjacent in time sequence to data frame 2. Of course, this is only for the convenience of understanding the concept of being adjacent in time sequence, and there is no difference between data frame 3 being adjacent in time sequence to data frame 2 and data frame 2 being adjacent in time sequence to data frame 3.

[0047] It should be emphasized that the target coding scenario is proposed in the embodiment of the present application to solve the above-mentioned problems. For business scenarios such as playing videos, PPT, Excel, etc. in actual applications, the applicant has found that they can be divided into static scenes, dynamic scenes, mixed scenes, etc. according to the degree of change.

[0048] Among them, static scenes and dynamic scenes are a set of relative concepts, which are defined by the degree of change corresponding to the media data played (mainly data frames, the amount of data to be encoded and the playback quality are mainly affected by the data frames). Among them, the degree of change in static scenes is generally smaller than that in dynamic scenes. The degree of change represents the information change between different data frames. The information change is the change of the parameters related to the pixels in the data frames (such as the brightness mentioned above).

[0049] The degree of change in the mixed scenario is sometimes large and sometimes small. The mixed scenario can be understood through static and dynamic scenarios, that is, the mixed scenario is equivalent to frequent switching between static and dynamic scenes. A typical business scenario is to find the target PPT page from multiple pages of PPT when playing PPT. During the search process, it is easy to pause reading (corresponding to static scenarios) and slide down or up to search (corresponding to dynamic scenarios).

[0050] For example, in the business scenario of playing videos, most of the time there are large changes (such as the switching of the background of the characters in the video), and only a small part of the time there are small changes (such as the characters in the video are talking, at this time only the information corresponding to the face or body changes); in the scenario of playing PPT, most of the time there are small changes (such as the host of the video conference underlines the corresponding text on the PPT page), and only a small part of the time there are large changes (such as turning the PPT page); in the scenario of playing Excel, most of the time there are small changes (such as the host of the video conference explains the data recorded in Excel), and only a small part of the time there are large changes (such as the host of the video conference shows other data and slides Excel). In other words, when playing videos, most of the time is dynamic scenes and a small part of the time is static scenes; when playing PPT, most of the time is static scenes and a small part of the time is dynamic scenes; when playing Excel, most of the time is static scenes and a small part of the time is dynamic scenes. In addition, each business scenario is generally a mixed scene for very little time. Among them, the scene switching is generally between a static scene and a dynamic scene, and does not switch to a mixed scene, which represents the frequent changes in the degree of change corresponding to the business scene.

[0051] It should be noted that each target encoding scenario corresponds to a set of parameters (the parameters are used to encode the data to be encoded, including at least a QP value), and the parameters are obtained through verification, and the verification process may include the following steps:

[0052] 1) Set a set of initial parameters for each target encoding scenario;

[0053] 2) Encoding the data to be encoded in the corresponding target encoding scenario using the initial parameters;

[0054] 3) Obtain the corresponding coding effect and adjust the initial parameters by analyzing the coding effect (such as whether the bit rate is exceeded);

[0055] 4) The adjusted initial parameters are used as the initial parameters of step 2), and step 2) is performed until the encoding effect meets the requirements (such as not exceeding the bit rate).

[0056] Therefore, the problem of poor image quality can be solved by the QP value corresponding to the static scene, and the problem of the bit rate exceeding the set range can be solved by the QP value corresponding to the dynamic scene.

[0057] It should be noted that the QP value corresponding to the static scene is used to ensure that the clarity of the encoded data to be encoded is greater than the preset clarity, so as to ensure that the image quality is better when the peer device processes and displays the encoded data to be encoded. Among them, the clarity is not only affected by the QP value, but also by the screen resolution of the peer device. Among them, the screen resolution is an inherent property of the device. After the screen resolution is set to the highest resolution supported by the device, the screen resolution can no longer be changed to make the picture clearer. Therefore, the clarity is mainly changed by changing the QP value.

[0058] For example, since the bit rate is affected by the QP value, the clarity can be adjusted by adjusting the QP value, that is, the clarity is related to the size of the QP value. The correlation is that the clarity from high to low can correspond to multiple QP value ranges from small to large. For example, the range of QP values ​​corresponding to high clarity is (10, 20], the range of QP values ​​corresponding to medium clarity is (20, 30], and the range of QP values ​​corresponding to low clarity is (30, 40].

[0059] Exemplarily, the clarity may also be determined by other means, such as by BIQA (Blind Image Quality Assessment).

[0060] The preset definition level may be set as required. For example, the definition level is determined by the bit rate, and the preset definition level may be medium definition level, low definition level, or the like.

[0061] It should be noted that the QP value corresponding to the dynamic scene is used to ensure that the bit rate of the encoded data to be encoded does not exceed the preset bit rate. The preset bit rate can be set by the supported bandwidth of the video conference. The bit rate limit is to ensure that the data transmission is completed under the supported bandwidth, that is, the bit rate cannot exceed the supported bandwidth, otherwise data packets will be lost. Based on this, the preset bit rate can be set to the supported bandwidth, or slightly less than the supported bandwidth, for example, the difference between the supported bandwidth and the preset bandwidth threshold is less than the preset bandwidth threshold. The specific setting is not limited in this embodiment.

[0062] It should be noted that the QP value corresponding to the mixed scene is used to avoid frequent changes in image quality caused by frequent scene switching, thereby improving the stability of the video conference.

[0063] Step S120 : Encode the data to be encoded according to the QP value corresponding to the target encoding scenario.

[0064] The QP value can be obtained from a preset mapping table according to the corresponding target coding scene, and the preset mapping table records the correspondence between the target coding scene and the QP value. Of course, the QP value can also be obtained in other ways, such as from the cache of the local device.

[0065] In summary, the embodiment of the present application can set at least two sets of parameters (including at least QP values), for example, one set for static scenes and the other set for dynamic scenes. When the data frame determines whether the current scene is in a static scene or a dynamic scene, the data to be encoded is encoded by a corresponding set of parameters. This improves the flexibility of the QP value configuration process, and solves the problems caused by configuring a larger QP value or configuring a smaller QP value, thereby improving the stability and quality of the video conference.

[0066] Exemplarily, when a data frame is obtained from the data to be encoded, the target encoding scene can also be determined based on the obtained data frame through a classification model based on artificial intelligence, the input of the classification model is the data frame, and the target encoding scene can be determined through the output of the classification model. The output of the classification model is a probability value, and the target encoding scene is determined by the probability value. For example, if the target encoding scene is a static scene or a dynamic scene, if the probability value is greater than or equal to 0.5, the target encoding scene is determined to be a dynamic scene, and if the probability value is less than 0.5, the target encoding scene is determined to be a static scene.

[0067] Exemplarily, for step S110, the degree of change between adjacent data frames in the acquired data frame can be determined in the following manner: determining the target pixel position in the data frame; determining the degree of change between adjacent data frames based on the difference between the target pixel positions in adjacent data frames; determining the corresponding target encoding scene based on the degree of change between adjacent data frames.

[0068] The data frame includes a plurality of pixels, each pixel has a certain position in the data frame, such as a 1080P data frame includes 1920×1080 pixels, the position coordinates of the pixel in the upper left corner are (1, 1), and the position coordinates of the pixel in the lower right corner are (1920, 1080). The target pixel position is the position of the pixel or macroblock in the data frame, wherein the macroblock includes a plurality of pixels and is obtained by dividing the data frame, that is, the data frame is divided into a plurality of macroblocks. When determining the degree of change between adjacent data frames, it is determined by corresponding pixels, and the corresponding pixels are pixels at the target pixel position. When determining the degree of change by corresponding pixels, the difference between corresponding pixels is specifically used to determine the degree of change, that is, the difference between pixels in the "same position" mentioned above. If the adjacent data frames include data frame 1 and data frame 2, data frame 1 includes pixel 11 with the upper left corner position (1, 1), and data frame 2 includes pixel 12 with the upper left corner position (1, 1), then the degree of change can be determined by the difference between pixel 11 and pixel 12. It can be understood that since a macroblock includes multiple pixels, determining the degree of change through a macroblock is equivalent to indirectly using pixels to determine the degree of change.

[0069] It should be noted that when determining the degree of change between adjacent data frames based on the difference between the target pixel positions in adjacent data frames, there are the following two situations:

[0070] Case 1: By comparing adjacent data frames, an information change situation is obtained, and the information change situation is directly used as the change degree.

[0071] Case 2: After obtaining an information change by comparing adjacent data frames, continue to compare adjacent data frames obtained by taking frames to obtain two or more information changes, and determine the degree of change through all the information changes. The determination method can be to find the average of two or more information changes or calculate the median of two or more information changes.

[0072] For example, for data frames within a preset statistical time length, the information change between each pair of adjacent data frames can be determined respectively, and the degree of change between adjacent data frames can be determined based on the information change between each pair of adjacent data frames within the preset statistical time length.

[0073] For example, the mean or median of the information change between each pair of adjacent data frames within a preset statistical time length is determined as the degree of change between adjacent data frames.

[0074] It should be noted that the preset statistical time length can be set according to needs. In the process of setting the preset statistical time length, the preset statistical time length should not be set too short to avoid the determined degree of change being too floating and unable to identify the real scene; it should not be set too long, resulting in slow scene judgment.

[0075] Exemplarily, the preset statistical time length may be 1.5 to 4 seconds, for example, the preset statistical time length may be 2 seconds.

[0076] The information change is the embodiment of the difference, and the comparison between adjacent data frames refers to comparing the difference between the target pixel positions in adjacent data frames, that is, the difference between pixels.

[0077] Exemplarily, the above-mentioned degree of change includes but is not limited to the degree of change of image information and the number of pixel changes.

[0078] According to the degree of change of the image information, there are different processing flows for the above-mentioned case 1 and case 2.

[0079] For the above situation one, the process of determining the degree of change of image information between adjacent data frames based on the difference between the target pixel positions in adjacent data frames is: determining the target component value of the pixel at the target pixel position in each data frame of the adjacent data frames; and determining the degree of change of image information based on the target component value.

[0080] For the second situation mentioned above, the process of determining the degree of change of image information between adjacent data frames based on the difference between the target pixel positions in adjacent data frames is as follows: determining the target component value of the pixel at the target pixel position in each data frame of the current adjacent data frames, and determining the target component value of the pixel at the target pixel position in each data frame of the subsequent adjacent data frames; determining the degree of change of image information based on the current target component value and the subsequent target component value.

[0081] The size of the macroblock may be N×M, where N and M are positive integers, such as N is 16 and M is 16. Generally, the macroblock is square.

[0082] When determining the target component value of a pixel at a target pixel position in any data frame, the target component value of each pixel in the data frame may be determined, the target component value of a pixel in each macroblock may be determined, or the average of the target component values ​​of all pixels or part of the pixels (the number is greater than 1) in the macroblock may be determined.

[0083] Among them, pixels also have fixed positions in the macroblock. For example, if the size of the macroblock is 4×4, the position coordinates of the pixel in the upper left corner of the macroblock are (1, 1), and the position coordinates of the pixel in the lower right corner of the macroblock are (4, 4). Accordingly, in order to simultaneously represent the position of a pixel in a data frame and in a macroblock, the position of the pixel can be represented by a four-dimensional vector. For example, if the size of the macroblock is 4×4, for the macroblock located at the upper left corner of the data frame and the pixel located at the lower right corner of the macroblock, the position coordinates of the pixel can be represented as (1, 1, 4, 4), where the element values ​​1 and 1 at element positions 0 and 1 can be used to represent the position of the macroblock in the data frame, and the element values ​​4 and 4 at element positions 2 and 3 can be used to represent the position of the pixel in the macroblock; the position of the pixel can also be represented by a two-dimensional vector. For example, if the size of the macroblock is 4×4, for the macroblock located at the upper left corner of the data frame and the pixel located at the upper right corner of the macroblock, the position coordinates of the pixel can be represented as ((1, 1), (1, 4)), where the element value (1, 1) at element position 0 can be used to represent the position of the macroblock in the data frame, and the element value (1, 4) at element position 1 can be used to represent the position of the pixel in the macroblock. This embodiment does not limit the representation method of the pixel position.

[0084] For example, the processing flow corresponding to the above situation is as follows:

[0085] When determining the degree of change of image information according to the target component value, it is specifically determined according to the target difference corresponding to the target pixel position in the adjacent data frames, that is, according to the target component values ​​at the corresponding positions of two data frames in the adjacent data frames, the target difference is obtained. How to obtain the target difference according to the target component value can be achieved by the following method:

[0086] Method 1: The target pixel position is all pixel positions in the data frame, that is, the target component value of each pixel in the data frame is determined, and the target difference is calculated accordingly; Figure 3a As shown, 301 is a data frame, 302 is a pixel, and the target difference is calculated by determining the target component value of each pixel 302.

[0087] Method 2: The target pixel position is a specified pixel position in each macroblock, that is, a target component value of a pixel at a specified pixel position is taken from each macroblock of the data frame, and the target difference is calculated accordingly; Figure 3b As shown, 301 is a data frame, 302 is a pixel, 303 is a macroblock of size 4×4, 304 is a pixel 302 in the macroblock 303, and the target difference is calculated at least by determining the target component value of the pixel 304; for example, a 1080P data frame can be divided into more than 8,000 macroblocks, that is, one frame of the data frame corresponds to more than 8,000 specified pixel positions.

[0088] Method 3: The target pixel position is the position of the macroblock in the data frame, that is, the target component values ​​of all pixels or part of the pixels (the number is greater than 1) are taken from each macroblock of the data frame, and the mean of the target component values ​​of all pixels or part of the pixels in each macroblock is determined, thereby calculating the target difference; Figure 3c As shown, 301 is a data frame, 302 is a pixel, 303 is a macroblock of size 4×4, the macroblock 303 includes 16 pixels, and the target difference is calculated by determining the target component values ​​of (1, 16] pixels.

[0089] It can be understood that different implementation methods consume different degrees of device computing resources. Technicians can choose methods based on the performance of the device. Among them, the consumption of device computing resources by different methods is ranked from low to high as method 2, method 3, method 1, or method 2, method 1, method 3.

[0090] Exemplarily, the target component value includes but is not limited to at least one of the YUV value or the RGB value. The YUV value includes three component values, namely, the Y component value, the U component value, and the V component value; the RGB value includes three component values, namely, the R component value, the G component value, and the B component value. When the degree of change is obtained by the three methods of obtaining the target difference value according to the target component value, there is an application of different arrangements of the three methods.

[0091] Take the target component value as YUV value as an example:

[0092] For the above method 1 or method 2:

[0093] The difference of the Y component value, U component value and / or V component value at each identical target pixel position between two data frames in adjacent data frames can be determined respectively to obtain a target difference value (referred to herein as a first target difference value). For example, if the two data frames are data frame 1 and data frame 2, the coordinates of the target pixel position are (1, 1), the Y component value at the target pixel position in data frame 1 is 30, and the Y component value at the target pixel position in data frame 2 is 50, then the first target difference value is 50-30=20. Then, the absolute value of the first target difference value corresponding to each target pixel position is calculated, and the degree of change between adjacent data frames can be determined.

[0094] In a possible implementation, for method 2:

[0095] The target component value includes at least two of the Y component value, the U component value, and the V component value, and the target difference includes target sub-differences corresponding to each component value. Since the target component value includes at least two of the Y component value, the U component value, and the V component value, the target difference cannot be directly obtained by simply calculating the difference between the target component values, but it is necessary to calculate the sum of the absolute values ​​of the target sub-differences corresponding to each target pixel position and the component value for each component value. For example, if the two data frames are data frame 1 and data frame 2, the coordinates of the target pixel positions are (1, 1), (5, 5), (9, 9), etc., the Y component value at (1, 1) in data frame 1 is 30, the Y component value at (5, 5) in data frame 2 is 30, the Y component value at (5, 5) in data frame 1 is 50, the Y component value at (9, 9) in data frame 2 is 20, the Y component value at (9, 9) in data frame 1 is 20, and the Y component value at (1, 1) in data frame 2 is 50, then the target sub-differences are 50-30=20, 30-50=-20, 20-20=0 respectively. It can be seen that if the sum of the target sub-differences is calculated directly, the sum is 0, which obviously cannot reflect the difference between data frame 1 and data frame 2. Therefore, the sum of the absolute values ​​of the target sub-differences needs to be calculated, that is, the sum of the target sub-differences is 20+|-20|+0+……. Then, the sum of the target sub-difference values ​​corresponding to each component value in the target component value is calculated to determine the degree of change between adjacent data frames.

[0096] Regarding the above method 3:

[0097] For any macroblock, determine the mean value of the target component values ​​of all pixels or part of the pixels in the macroblock, use the mean value as the target component value corresponding to the macroblock, and determine the target difference value corresponding to the macroblock in the adjacent data frame (referred to as the third target difference value in this article); wherein the third target difference value is the difference between the target component values. If the adjacent data frame includes data frame 1 and data frame 2, there is macroblock 1 in data frame 1, and macroblock 1 is a 4×4 macroblock, that is, macroblock 1 includes 16 pixels, that is, the target component value is the mean value of the target component values ​​of all pixels or part of the pixels in the 16 pixels. Wherein, the target component value includes at least one of the Y component value, the U component value, and the V component value. When the number of target component values ​​is greater than 1, the mean value corresponding to each component value is calculated and the absolute value is calculated, and the absolute values ​​are summed. Then, the degree of change between adjacent data frames is determined according to the sum of the absolute values ​​of the third target difference values ​​corresponding to each macroblock.

[0098] In a possible implementation, for method 2 + method 3:

[0099] For any macroblock, determine the mean value of the target component values ​​of all pixels or part of the pixels in the macroblock, and determine the target difference value corresponding to the macroblock in the adjacent data frame (referred to as the second target difference value in this article) based on the mean value; wherein the second target difference value is the difference between the target component values. Determine the larger value between the first target difference value (calculated by method 2) and the second target difference value corresponding to the macroblock to obtain the effective value corresponding to the macroblock. Then determine the degree of change between adjacent data frames based on the sum of the effective values ​​corresponding to each macroblock.

[0100] Exemplarily, in the case where the target component value includes at least two of the Y component value, the U component value, and the V component value, for any macroblock, and any component value among the target component values, on the one hand, a target sub-difference value (which may be referred to as a first target sub-difference value) corresponding to the component value and a specified pixel position of the macroblock in an adjacent data frame can be determined; on the other hand, a mean value of the component value of all pixels in the macroblock can be determined, and a target sub-difference value (which may be referred to as a second target sub-difference value) corresponding to the macroblock and the component value in the adjacent data frame can be determined based on the mean value, and a larger value between the absolute value of the first target sub-difference value and the absolute value of the second target sub-difference value can be determined as the effective target sub-difference value corresponding to the macroblock and the component value, and based on the sum of the absolute values ​​of the effective target sub-difference values ​​corresponding to each macroblock and the component value, the effective target sub-difference value sum corresponding to the component value can be determined.

[0101] Furthermore, the degree of change between adjacent data frames may be determined based on the sum of the valid target sub-difference values ​​corresponding to each component value in the target component value.

[0102] In addition, when the target component value includes at least two of the Y component value, the U component value, and the V component value, for any macroblock, and any component value among the target component values, in the process of determining the first target sub-difference value, the product of the component value at the specified pixel position of the macroblock and a preset coefficient (such as 1.5) can be used as the component value participating in subsequent calculations; or, when the first target sub-difference value is calculated, the product of the first target sub-difference value and the preset coefficient (such as 1.5) can be used as the first target sub-difference value participating in the comparison of the effective target sub-difference values.

[0103] Similarly, in the process of determining the second target sub-difference, the product of the component value of all pixels in the macroblock and a preset coefficient (such as 1.5) can be used as the component value participating in subsequent calculations; or, when the second target sub-difference is calculated, the product of the second target sub-difference and a preset coefficient (such as 1.5) can be used as the second target sub-difference participating in the comparison of the effective target sub-difference.

[0104] Alternatively, when the sum of the absolute values ​​of the effective target sub-differences is obtained based on the original values, the product of the sum of the absolute values ​​and a preset coefficient (such as 1.5) may be determined as the sum of the effective target sub-differences corresponding to the component value.

[0105] Furthermore, the degree of change between adjacent data frames can be determined based on the sum of the effective target sub-difference values ​​corresponding to each component value in the target component value. For ease of description, the following embodiments refer to the sum of the absolute values ​​of the first target difference values ​​corresponding to each target pixel position, the sum of the target sub-difference values ​​corresponding to each component value in the target component value, the sum of the absolute values ​​of the third target difference values ​​corresponding to each macroblock, and the sum of the effective values ​​corresponding to each macroblock as difference parameters.

[0106] For the target component values ​​​​are RGB values:

[0107] If the target component value is a YUV value, the difference parameter and the degree of change can be obtained by the above method 1, method 2 or method 3, or the above method 2 + method 3. The implementation method can refer to the above implementation method where the target component value is a YUV value, which will not be repeated here.

[0108] Regarding how to determine the degree of change through the difference parameter:

[0109] When determining the degree of change of the image information, it is determined by comparing and determining the preset value range of the difference parameter. The preset value range is set by the number of pixels or the number of macroblocks, wherein when calculating the target difference value by each pixel, it is set by the number of pixels, and when calculating the target difference value by macroblocks, it is set by the number of macroblocks.

[0110] In a possible implementation, the target difference is calculated by macroblocks, and the preset value range is calculated and determined by the number of macroblocks. Figure 2 As shown, the corresponding values ​​of different change degrees (image information change degrees) are the product of the number of macroblocks (the number of macroblocks) and the fixed value, such as the corresponding value of change degree 2 is 3*N (3×N). If the corresponding value of change degree 0 < difference parameter ≤ corresponding value of change degree 1, it is considered that the current state is change degree 1; if the corresponding value of change degree 1 < difference parameter ≤ corresponding value of change degree 2, it is considered that the current state is change degree 2; if the corresponding value of change degree 2 < difference parameter ≤ corresponding value of change degree 3, it is considered that the current state is change degree 3; if the corresponding value of change degree 3 < difference parameter ≤ corresponding value of change degree 4, it is considered that the current state is change degree 4; if the corresponding value of change degree 4 < difference parameter, it is considered that the current state is change degree 5.

[0111] It should be noted that, in the process of determining the above-mentioned first target difference, the data amount of the U component value or the V component value is relatively low, not as good as the data amount of the Y component value. Therefore, during encoding, the influence of the Y component value on the bit rate and image quality is greater than that of the U component value or the V component value. That is, for whether the picture of the other device is clear and the bit rate of the local device during encoding, the influence of the Y component value is greater than that of the U component value or the V component value. That is, for the degree of change of the image information, the influence of the Y component value is greater than that of the U component value or the V component value.

[0112] In addition, since different component values ​​are used to obtain the first target difference, the values ​​of the first target difference will be different, so the corresponding values ​​of the above-mentioned various change degrees need to be adjusted accordingly, and the adjustment method can be multiplied by a coefficient respectively. For example, when the first target difference is obtained by the Y component value, the U component value, and the V component value, the coefficient can be 1.5, 1.6, etc., and the specific value of the coefficient is not limited in this embodiment.

[0113] Accordingly, in the case where the target component value includes at least two of the Y component value, the U component value and the V component value, for any component value among the target component values, the sum of the absolute values ​​of the target sub-difference values ​​corresponding to each target pixel position and the component value can be calculated, and the product of the sum of the absolute values ​​and a preset coefficient (such as 1.5) can be determined as the target sub-difference sum corresponding to the component value; or, for any component value among the target component values, the product of the sum and the preset coefficient (such as 1.5) can be used as the component value participating in subsequent calculations, and the sum of the absolute values ​​of the target sub-difference values ​​corresponding to each target pixel position and the component value is calculated, and the sum of the absolute values ​​is determined as the target sub-difference sum corresponding to the component value, and then, the degree of change between adjacent data frames can be determined based on the sum of the target sub-difference sums corresponding to each component value in the target component value.

[0114] In addition, in actual applications, each pixel has an independently determined Y component value, but the U component value and the V component value may be shared by multiple pixels. For example, the ratio of the three YUV components is 4:1:1, that is, every 4 pixels share one U component value and one V component value.

[0115] The corresponding processing flow for the above situation 2 is:

[0116] The difference parameters corresponding to the current adjacent data frame and the subsequent adjacent data frame are calculated respectively. The calculation method is basically the same as the processing flow corresponding to the above situation 1, and will not be repeated here. Among them, the calculation method of the difference parameters corresponding to the current adjacent data frame and the subsequent adjacent data frame should be the same. For example, the current adjacent data frame calculates the sum of the absolute values ​​of the first target difference values ​​corresponding to each target pixel position, and the subsequent adjacent data frame also calculates the sum of the absolute values ​​of the first target difference values ​​corresponding to each target pixel position.

[0117] It should be noted that after calculating the difference parameters corresponding to the current adjacent data frame and the subsequent adjacent data frame, all the difference parameters are summed and averaged to obtain a mean value, and then the degree of change is determined by the mean value. Accordingly, when determining the degree of change, the difference from the processing flow corresponding to the first situation is that the difference parameter is replaced by the mean value for judgment.

[0118] Regarding the number of pixel changes, it is similar to the solution for the degree of change of image information. The difference lies in the specific means of determining the degree of change corresponding to the data frame. This embodiment does not calculate the above-mentioned target difference, but counts the number of pixels in which the target component values ​​in adjacent data frames have changed, and compares the size of the number with multiple different preset quantity thresholds to determine the degree of change.

[0119] It should be noted that, no matter in the above-mentioned case 1 or case 2, when determining the target coding scene according to the degree of change, the determination means include but are not limited to scene switching and direct setting.

[0120] Exemplary scene switching methods include but are not limited to the following two:

[0121] Method 1: After obtaining the degree of change, directly determine whether to switch scenes. The scene switching achieved by method 1 can be called instant switching.

[0122] The process of comparing whether the degree of change meets the scene switching condition is as follows:

[0123] When the current scene is a static scene, compare whether the degree of change is greater than or equal to a first preset degree of change. If so, it is determined that the scene switching condition is met and the target coding scene is a dynamic scene; or, when the current scene is a dynamic scene, compare whether the degree of change is less than or equal to a second preset degree of change. If so, it is determined that the scene switching condition is met and the target coding scene is a static scene.

[0124] Among them, if the first preset change degree is the same as the second preset change degree, that is, the threshold for triggering the static scene to switch to the dynamic scene is the same as the threshold for triggering the dynamic scene to switch to the static scene, it is easy to cause frequent switching between the static scene and the dynamic scene due to the fluctuation of the change degree between adjacent data frames in a small range, resulting in poor video conference quality. Therefore, the first preset change degree can be set to be greater than the second preset change degree, so as to avoid poor video conference quality due to frequent scene switching.

[0125] Exemplarily, the first preset degree of change and the second preset degree of change can be set as needed, and this embodiment does not limit this.

[0126] For example, the degree of change may be any value between 0 and 5, the first preset degree of change is 4, and the second preset degree of change is 2.

[0127] Accordingly, when the degree of change meets the following conditions, no scene switching is performed:

[0128] Condition 1: when the current scene is a static scene, the degree of change is less than a first preset degree of change;

[0129] Condition 2: when the current scene is a dynamic scene, the degree of change is greater than a second preset degree of change.

[0130] Method 2: After obtaining the degree of change, continue to obtain subsequent degrees of change, and determine whether to switch scenes based on the degrees of change obtained before and after. The scene switching achieved by method 2 can be called non-instant switching.

[0131] It should be emphasized that in order to solve the above problems, a smaller QP value will cause the bit rate to exceed the setting range, resulting in the loss of data packets received by the peer device; a larger QP value will cause the image on the peer device to be blurred.

[0132] In actual applications, the QP value will also be configured in a larger range, and the QP value will be adaptively adjusted. For example, if the configurable range of the QP value is 1-51, the QP value range can be configured to 10-40, and the QP value can be adaptively adjusted between 10-40. The specific method is to detect the bit rate through the video encoder. When the video encoder detects that the bit rate suddenly increases, in order to cope with the sudden change in bit rate, the QP value will be directly configured to a larger value, and then the QP value will be gradually reduced to a suitable QP value in combination with the encoding effect corresponding to the configured QP value; when the video encoder detects that the bit rate suddenly decreases, in order to cope with the sudden change in bit rate, the QP value will be directly configured to a smaller value, and then the QP value will be gradually increased to a suitable QP value in combination with the encoding effect corresponding to the configured QP value.

[0133] However, in actual applications, adaptive adjustment of the QP value still results in a poor viewing experience for users during video conferences. For example, when playing a PPT, the user turning pages will cause the bit rate to increase suddenly. To adapt to this situation, the video encoder needs to configure the QP value as described above. During this configuration process, the user perceives the picture change as blurry first and then clear. For another example, when playing a video, there is also the problem of blurry first and then clear. In addition, there is also the problem of alternating clear and blurry pictures. Because the video picture may change frequently, the user's viewing experience will be poor when the picture is blurred where the picture changes greatly and clear where the picture changes less.

[0134] In summary, adaptive adjustment of QP value solves the above problems but also brings new problems.

[0135] In response to this new problem, the applicant has found through research that the new problem is caused by dynamically and in real time adjusting the QP value. The above-mentioned method 2 proposed in the embodiment of the present application can solve the new problem well, that is, instead of performing dynamic and real-time adjustment, a comprehensive judgment is made based on at least two degrees of change to determine whether to perform scene switching, thereby solving the new problem.

[0136] For the second method, the process of comparing whether the degree of change meets the scene switching condition is as follows: when the current scene is a static scene, and the number of times the degree of change between adjacent data frames is greater than or equal to the third preset degree of change meets the first preset number requirement, it is determined that the scene switching condition is met; or, when the current scene is a dynamic scene, and the number of times the degree of change between adjacent data frames is less than or equal to the fourth preset degree of change meets the second preset number requirement, it is determined that the scene switching condition is met. Among them, the third preset degree of change and the fourth preset degree of change can be set as needed, and this embodiment does not limit it.

[0137] The first preset number requirement may include one of the following:

[0138] 1. The situation where the degree of change between adjacent data frames is greater than or equal to the third preset degree of change occurs I times in succession, where I is a positive integer and can be set as needed. For example, if I is 3, then when the situation where the degree of change between adjacent data frames is greater than or equal to the third preset degree of change occurs three times in succession, it is determined that the scene switching condition is met.

[0139] 2. Within the frequency judgment interval, the situation where the degree of change between adjacent data frames is greater than or equal to the third preset degree of change occurs J times, where J is a positive integer and can be set as needed, such as J is 3. The frequency judgment interval is used to determine the position at the start of the judgment and the number of degrees of change used for judgment. For example, when the degree of change between adjacent data frames is greater than or equal to the third preset degree of change, the judgment is determined to start, and the number is 5, that is, the situation where the degree of change between adjacent data frames is greater than or equal to the third preset degree of change is taken as the starting point of the frequency judgment interval, that is, the corresponding adjacent data frame is taken as the current adjacent data frame, and the degree of change between the subsequent 4 consecutive adjacent data frames is judged to be greater than or equal to the third preset degree of change. If within the frequency judgment interval, the situation where the degree of change between adjacent data frames is greater than or equal to the third preset degree of change occurs at least J times, it is determined that the scene switching condition is met.

[0140] Accordingly, when the degree of change meets the following conditions, the scene will not be switched:

[0141] Condition three: when the current scene is a static scene, the number of times does not meet the first preset number requirement.

[0142] Condition 4: When the current scene is a dynamic scene, the number of times does not meet the second preset number requirement.

[0143] It should be noted that different business scenarios may correspond to different switching strategies, and the switching strategy is used to control the frequency of scene switching. A high frequency means frequent switching, and a low frequency means occasional switching.

[0144] In one example, when the static scene is a document presentation scene and the dynamic scene is a video presentation scene, the first preset number requirement is greater than the second preset number requirement.

[0145] For example, considering actual scenarios, such as video conferencing, which are usually in static scenes or expected to be in static scenes most of the time, for example, document presentation (such as PPT presentation) scenes, the scene judgment strategy may also tend to be static scenes to a certain extent.

[0146] Accordingly, when setting the preset number requirement, the first preset number requirement can be greater than the second preset number requirement. Thus, in a static scene, the switch to a dynamic scene will be triggered only when the degree of change between adjacent data frames is greater than or equal to the third preset change degree more often; and in a dynamic scene (such as a video display scene), the switch to a static scene can be triggered only when the degree of change between adjacent data frames is less than or equal to the fourth preset change degree relatively less often.

[0147] In a possible implementation, the switching strategy is determined based on the proportion of static scenes, dynamic scenes and mixed scenes in the business scene. When the proportion of static scenes or dynamic scenes is high, such as when the proportion of static scenes is 50%, the frequency of scene switching is low, so as to avoid the image being sometimes clear and sometimes blurred, which affects the perception; when the proportion of mixed scenes is high, such as when the proportion of mixed scenes is 60%, the frequency of scene switching is high. Among them, the frequency can be adjusted by setting the first preset change degree and the second preset change degree in method one, and the I and J, the third preset change degree and the fourth preset change degree of the number of times judgment interval in method two accordingly. If the gap between the first preset change degree and the second preset change degree is large, the frequency is low, and the gap between the first preset change degree and the second preset change degree is small, the frequency is high; for example, if the I and J of the number of times judgment interval are set larger, and / or the gap between the third preset change degree and the fourth preset change degree is large, the frequency is low, and the I and J of the number of times judgment interval are set smaller, and / or the gap between the third preset change degree and the fourth preset change degree is small, the frequency is high.

[0148] In addition, for setting the scene:

[0149] That is, when the pixel change number is greater than the preset change number, the target coding scene can be set as a dynamic scene, and when the pixel change number is less than or equal to the preset change number, the target coding scene can be set as a static scene.

[0150] It should be noted that, for the direct setting scenario, it also includes immediate setting and non-immediate setting. The specific methods for immediate setting and non-immediate setting can refer to the above-mentioned instant switching and non-immediate switching schemes, which will not be described in detail in this embodiment.

[0151] In addition, the adaptive encoding method provided in the embodiment of the present application may also include:

[0152] When the current scene is a static scene, if the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded is greater than or equal to the fifth preset degree of change, and the degree of change between adjacent data frames does not meet the scene switching condition, then at least one subsequent data frame in time sequence of the current data frame to be encoded in the data to be encoded is replaced by the current data frame to be encoded; wherein the number of data frames replaced is related to the degree of change.

[0153] Exemplarily, the number of replaced data frames under different degrees of change may not be exactly the same; the number of replaced data frames under a larger degree of change is not less than the number of replaced data frames under a smaller degree of change.

[0154] In an example, the number of replaced data frames may be positively correlated with the degree of change, that is, the greater the degree of change, the greater the number of replaced frames may be.

[0155] The following example illustrates the degree of change and the number of replaced data frames.

[0156] For example, assuming that the fifth preset degree of change is 1, when the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded is 2, it can be considered that the current video picture has changed very little. For example, it is currently in a static picture display process (such as the host of a video conference underlining the corresponding text on the PPT page). In this case, the probability of over-bit rate is small, and fewer frames can be replaced in the above manner.

[0157] When the degree of change between the current data frame to be encoded and its previous data frame in the time sequence of the data to be encoded is 3, it can be considered that the current video picture has changed significantly. Since it is still in a static scene, the large degree of change may be caused by the picture switching process (such as PPT page turning). In this case, replacing the frames in the switching process with the frames before the switching will not affect the display of normal picture content, and if frame replacement is not performed, over-bit rate may easily occur. Therefore, more frames can be replaced in the above manner.

[0158] Exemplarily, if the current scene is a dynamic scene or the degree of change between adjacent data frames does not meet the scene switching condition or the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded is less than the fifth preset degree of change, the replacement processing is not performed.

[0159] It should be noted that since the current scene is a static scene, which corresponds to a smaller QP value, the bit rate may exceed the set range. When encoding the data frame in the data to be encoded, residual coding (Forward Binary Coding, FBC) is used. Therefore, replacing the at least one data frame with the current data frame to be encoded can reduce the amount of data when encoding the data to be encoded, thereby reducing the bit rate and reducing the probability of excessive bit rate.

[0160] The fifth preset change degree may be set as required. For example, if the change degree includes change degrees 0-5, the fifth preset change degree may be any one of the six change degrees 0-5.

[0161] Exemplarily, when judging the difference between the variation degree and the fifth preset variation degree, the judgment may be made for each data frame, or once every certain number of frames (such as 3), or conditionally for the data frame, which can improve the coding efficiency.

[0162] Exemplarily, the frequency of comparing the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded and the fifth preset degree of change can be a fixed frequency, that is, the above comparison is performed once at a fixed interval of several frames (such as 2 frames).

[0163] Alternatively, the frequency of comparing the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded and the fifth preset degree of change may be related to the degree of change.

[0164] In one example, the comparison frequency may be positively correlated with the degree of change, that is, when the degree of change is large, the comparison frequency may be correspondingly large, and the number of skipped video frames may be relatively small; when the degree of change is small, the comparison frequency may be correspondingly small, and the number of skipped video frames may be relatively large.

[0165] For example, when the degree of change is degree of change 1, it can be considered that the current video picture has changed very little. For example, it is currently in a static picture display process (such as a PPT page display). In this case, the subsequent two frames of data can be skipped and the next frame of the subsequent two frames of data can be judged instead.

[0166] When the degree of change is degree of change 3, it can be considered that a certain degree of change has occurred in the current video screen. Taking the PPT page display as an example, the current process may be in the PPT page turning process. In this case, the subsequent frame of data can be skipped and the next frame of the subsequent frame of data can be judged instead.

[0167] The replacing of at least one subsequent data frame in time sequence of the current data frame to be encoded with the current data frame to be encoded is achieved according to a corresponding process, which is encoding the same frame, such as encoding a PSkip frame.

[0168] Exemplarily, replacing at least one subsequent data frame of the current data frame in the time sequence in the data to be encoded with the current data frame to be encoded is equivalent to discarding the original frame of at least one subsequent data frame of the current data frame in the time sequence in the data to be encoded, so as to avoid over-bitrate due to large changes in adjacent frames in static scenes.

[0169] For dynamic scenes, since the QP value is relatively large, the bit rate will not exceed the limit due to the large change of adjacent data frames. In addition, frame loss in dynamic scenes is likely to cause screen freeze. Therefore, for dynamic scenes, frame replacement operation is not required in the above manner.

[0170] In summary, taking the fifth preset change degree as change degree 2 and determining once every certain number of frames, the certain number of frames being 2 (taking fixed frame interval detection as an example), as an example, Figure 4 As shown, 401 is the time sequence direction, from left to right is the time sequence from small to large, 402 is the data frame with the sequence number (data frame sequence number) X+1, and the sequence numbers of the data frames along the time sequence direction are X~X+9, that is, 403 is the data frame with the sequence number X+4, and 404 is the data frame X+7. Among them, the change degree of data frame 402 relative to the previous data frame in its time sequence is change degree 1, the change degree of data frame 403 relative to the previous data frame in its time sequence is change degree 3, and the change degree of data frame 404 relative to the previous data frame in its time sequence is change degree 5. On this basis, after determining that the degree of change corresponding to data frame 402 is degree of change 1, the two subsequent data frames are skipped, that is, the above-mentioned judgment and the corresponding processing are not performed; data frame 403 is judged, and after determining that the degree of change corresponding to data frame 403 is degree of change 3, the above-mentioned judgment is not performed on the two data frames with sequence numbers X+5 and X+6, and the above-mentioned corresponding processing is performed on the data frame with sequence number X+5; data frame 404 is judged, and after determining that the degree of change corresponding to data frame 404 is degree of change 5, the above-mentioned judgment is not performed on the two data frames with sequence numbers X+8 and X+9, but the above-mentioned corresponding processing is performed on both data frames.

[0171] Based on the same application concept as the above method, an adaptive encoding device is proposed in the embodiment of the present application, such as Figure 5 FIG. 1 is a schematic diagram of the structure of the device, and the device may include:

[0172] The acquisition unit 501 is used to acquire data frames from the data to be encoded at a preset time interval;

[0173] The determination unit 502 is used to determine the target coding scene when it is determined that the scene switching condition is met according to the current coding scene and the degree of change between adjacent data frames in the acquired data frames;

[0174] The encoding unit 503 is used to encode the to-be-encoded data according to the QP value corresponding to the target encoding scenario.

[0175] In some embodiments, the determination unit 502 is specifically configured to determine the target pixel position in the data frame; and determine the degree of change between adjacent data frames based on the difference between the target pixel positions in adjacent data frames.

[0176] In some embodiments, the data frame is divided into a plurality of macroblocks, and for any macroblock, the target pixel position in the data frame includes a specified pixel position in the macroblock;

[0177] The determination unit 502 is specifically used to determine, for any target pixel position, a first target difference value corresponding to the target pixel position in adjacent data frames; wherein the first target difference value is the difference between target component values; and determine the degree of change between adjacent data frames based on the first target difference values ​​corresponding to each target pixel position.

[0178] In some embodiments, the target component value includes at least two of a Y component value, a U component value, and a V component value; the first target difference value includes a target sub-difference value corresponding to each of the component values;

[0179] The determination unit 502 is specifically used to calculate the sum of the absolute values ​​of the target sub-differences between each target pixel position and the component value corresponding to any component value included in the target component value to obtain the target sub-difference sum; and determine the degree of change between adjacent data frames based on the sum of the target sub-difference sums corresponding to each component value in the target component value.

[0180] In some embodiments, the determination unit 502 is specifically used to determine, for any macroblock, the mean of the target component values ​​of all pixels in the macroblock, and determine the second target difference corresponding to the macroblock in the adjacent data frame based on the mean; wherein the second target difference is the difference between the mean values; determine the larger value between the absolute value of the first target difference corresponding to the macroblock and the absolute value of the second target difference to obtain the effective value corresponding to the macroblock; and determine the degree of change between adjacent data frames based on the sum of the effective values ​​corresponding to each macroblock.

[0181] In some embodiments, the data frame is divided into a plurality of macroblocks;

[0182] The determination unit 502 is specifically used to determine, for any macroblock, a mean value of target component values ​​of all pixels in the macroblock, use the mean value as the target component value corresponding to the macroblock, and determine a third target difference value corresponding to the macroblock in adjacent data frames; wherein the third target difference value is the difference between the target component values; and determine the degree of change between adjacent data frames based on the sum of the absolute values ​​of the third target differences corresponding to each macroblock.

[0183] In some embodiments, the determination unit 502 is specifically used to determine, for each pair of adjacent data frames within a preset statistical time length, the information change between each pair of adjacent data frames; and determine the degree of change between adjacent data frames based on the information change between each pair of adjacent data frames within the preset statistical time length.

[0184] In some embodiments, the scene switching includes instant switching;

[0185] The determining unit 502 is specifically configured to determine that the scene switching condition is satisfied when the current scene is a static scene and the degree of change between the adjacent data frames is greater than or equal to a first preset degree of change; and the target coding scene is a dynamic scene; or, when the current scene is the dynamic scene and the degree of change between the adjacent data frames is less than or equal to a second preset degree of change, determine that the scene switching condition is satisfied; and the target coding scene is a static scene;

[0186] Among them, the first preset change degree is greater than the second preset change degree.

[0187] In some embodiments, the scene switching includes non-instantaneous switching;

[0188] The determining unit 502 is specifically configured to determine that the scene switching condition is satisfied when the current scene is a static scene and the number of times the degree of change between adjacent data frames is greater than or equal to the third preset degree of change meets the first preset number requirement; or, when the current scene is a dynamic scene and the number of times the degree of change between adjacent data frames is less than or equal to the fourth preset degree of change meets the second preset number requirement, determine that the scene switching condition is satisfied;

[0189] Among them, when the static scene is a document display scene and the dynamic scene is a video display scene, the first preset number requirement is greater than the second preset number requirement.

[0190] In some embodiments, the encoding unit 503 is further configured to, when the current scene is a static scene, replace at least one subsequent data frame of the current data frame to be encoded in the time sequence of the data to be encoded with the current data frame to be encoded if the degree of change between the current data frame to be encoded and the previous data frame in the time sequence in the data to be encoded is greater than or equal to a fifth preset degree of change, and the degree of change between adjacent data frames does not meet the scene switching condition;

[0191] The number of replaced data frames is related to the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded;

[0192] The frequency of comparing the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded and the fifth preset degree of change is related to the size of the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded.

[0193] An embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory is used to store a computer program; and the processor is used to implement the adaptive encoding method described above when executing the program stored in the memory.

[0194] See also Figure 6 , is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 601 and a memory 602 storing machine executable instructions. The processor 601 and the memory 602 may communicate via a system bus 603. In addition, by reading and executing the machine executable instructions corresponding to the adaptive coding logic in the memory 602, the processor 601 may execute the adaptive coding method described above.

[0195] The memory 602 mentioned herein may be any electronic, magnetic, optical or other physical storage device that may contain or store information, such as executable instructions, data, etc. For example, the machine-readable storage medium may be: RAM (RadomAccess Memory, random access memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as optical disk, DVD, etc.), or similar storage medium, or a combination thereof.

[0196] In some embodiments, a machine-readable storage medium is also provided. Figure 6 The memory 602 in the machine readable storage medium stores machine executable instructions, and the machine executable instructions implement the adaptive encoding method described above when executed by the processor. For example, the machine readable storage medium can be ROM, RAM, CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.

[0197] The embodiment of the present application also provides a computer program product, which stores a computer program and, when a processor executes the computer program, prompts the processor to execute the adaptive encoding method described above.

Claims

1. An adaptive coding method, characterized in that: include: Obtaining data frames from the data to be encoded at preset time intervals; Determining a target coding scene when it is determined that a scene switching condition is met based on the current coding scene and the degree of change between adjacent data frames in the acquired data frames; Encoding the data to be encoded according to the QP value corresponding to the target encoding scenario; Wherein, the method further comprises: In the case where the current scene is a static scene, if the degree of change between the current data frame to be encoded and the previous data frame in the time sequence in the data to be encoded is greater than or equal to a fifth preset degree of change, and the degree of change between adjacent data frames does not meet the scene switching condition, then at least one subsequent data frame in the time sequence of the current data frame to be encoded in the data to be encoded is replaced with the current data frame to be encoded; The number of replaced data frames is related to the degree of change between the current data frame to be encoded and its previous data frame in the time sequence in the data to be encoded; The frequency of comparing the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded and the fifth preset degree of change is related to the size of the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded.

2. The method according to claim 1, characterized in that The degree of change between adjacent data frames in the acquired data frames is determined in the following manner: Determine the target pixel position in the data frame; The degree of change between adjacent data frames is determined based on the difference between the target pixel positions in adjacent data frames.

3. The method according to claim 2, characterized in that The data frame is divided into a plurality of macroblocks, and for any macroblock, the target pixel position in the data frame includes a specified pixel position in the macroblock; Determining the degree of change between adjacent data frames based on the difference between the target pixel positions in adjacent data frames includes: For any target pixel position, determining a first target difference value corresponding to the target pixel position in adjacent data frames; wherein the first target difference value is a difference between target component values; The degree of change between adjacent data frames is determined according to the first target difference corresponding to each target pixel position.

4. The method according to claim 3, characterized in that The target component value includes at least two of a Y component value, a U component value, and a V component value; the first target difference value includes a target sub-difference value corresponding to each of the component values; The step of determining the degree of change between adjacent data frames according to the first target difference corresponding to each target pixel position includes: For any component value included in the target component value, calculate the sum of the absolute values ​​of the target sub-difference values ​​corresponding to each target pixel position and the component value to obtain the target sub-difference value sum; The degree of change between adjacent data frames is determined according to the sum of the target sub-difference values ​​corresponding to each component value in the target component value.

5. The method according to claim 3, characterized in that: The step of determining the degree of change between adjacent data frames according to the first target difference corresponding to each target pixel position includes: For any macroblock, determine the mean value of the target component values ​​of all pixels in the macroblock, and determine the second target difference value corresponding to the macroblock in adjacent data frames according to the mean value; wherein the second target difference value is the difference between the mean values; Determine a larger value between an absolute value of a first target difference value and an absolute value of a second target difference value corresponding to the macroblock, and obtain a valid value corresponding to the macroblock; The degree of change between adjacent data frames is determined based on the sum of the effective values ​​corresponding to each macroblock.

6. The method according to claim 2, characterized in that The data frame is divided into multiple macroblocks; Determining the degree of change between adjacent data frames based on the difference between the target pixel positions in adjacent data frames includes: For any macroblock, determine the mean value of the target component values ​​of all pixels in the macroblock, use the mean value as the target component value corresponding to the macroblock, and determine a third target difference value corresponding to the macroblock in adjacent data frames; wherein the third target difference value is the difference between the target component values; The degree of change between adjacent data frames is determined according to the sum of the absolute values ​​of the third target differences corresponding to each macroblock.

7. The method according to claim 1, characterized in that The degree of change between adjacent data frames in the acquired data frames is determined in the following manner: For data frames within a preset statistical time period, respectively determine information changes between each pair of adjacent data frames; The degree of change between adjacent data frames is determined according to the information change between each pair of adjacent data frames within the preset statistical time length.

8. The method according to claim 1, characterized in that Scene switching includes instant switching; The determining, based on the current coding scene and the degree of change between the adjacent data frames, that a scene switching condition is satisfied includes: When the current scene is a static scene and the degree of change between the adjacent data frames is greater than or equal to a first preset degree of change, determining that the scene switching condition is met; The target coding scene is a dynamic scene; or, When the current scene is the dynamic scene and the degree of change between the adjacent data frames is less than or equal to a second preset degree of change, determining that the scene switching condition is met; The target coding scene is a static scene; Among them, the first preset change degree is greater than the second preset change degree.

9. The method according to claim 1, characterized in that: Scene switching includes non-instantaneous switching; The determining, based on the current coding scene and the degree of change between the adjacent data frames, that a scene switching condition is satisfied includes: When the current scene is a static scene and the number of times that the degree of change between adjacent data frames is greater than or equal to the third preset degree of change meets the first preset number requirement, determining that the scene switching condition is met; or, When the current scene is a dynamic scene and the number of times that the degree of change between adjacent data frames is less than or equal to the fourth preset degree of change reaches the second preset number requirement, determining that the scene switching condition is met; Among them, when the static scene is a document display scene and the dynamic scene is a video display scene, the first preset number requirement is greater than the second preset number requirement.

10. An adaptive encoding device, characterized in that: include: An acquisition unit, used for acquiring data frames from the data to be encoded at preset time intervals; A determination unit, configured to determine a target coding scene when it is determined that a scene switching condition is met based on a current coding scene and a degree of change between adjacent data frames in the acquired data frames; An encoding unit, configured to encode the data to be encoded according to a QP value corresponding to the target encoding scenario; The encoding unit is further configured to, when the current scene is a static scene, replace at least one subsequent data frame of the current data frame to be encoded in the time sequence in the data to be encoded with the current data frame to be encoded if the degree of change between the current data frame to be encoded and the previous data frame in the time sequence in the data to be encoded is greater than or equal to a fifth preset degree of change, and the degree of change between adjacent data frames does not meet the scene switching condition; The number of replaced data frames is related to the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded; The frequency of comparing the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded and the fifth preset degree of change is related to the size of the degree of change between the current data frame to be encoded and its previous data frame in time sequence in the data to be encoded.

11. An electronic device, characterized in that: comprising a processor and a memory, wherein: Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 9 when executing a program stored in a memory.

12. A computer program product, characterized in that The computer program product stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.