Video encoding method, video decoding method and device
By analyzing the motion scenes of video frames, dynamically adjusting quantization parameters and optimizing video coding technology, the problem of poor bit rate and volume in the existing technology is solved, and the coding quality and efficiency are improved.
Patent Information
- Application Number
- CN202111509090.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-10
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2041-12-10
AI Technical Summary
Existing video encoding technology is difficult to optimize the bit rate and volume while maintaining encoding quality. This results in the encoded video being large in size when the bit rate is high, or having a low bit rate in small size, which reduces the encoding quality.
By analyzing the motion scene of the video frame to be encoded, the intensity value of the video frame is dynamically adjusted, the quantization parameters of the encoding area are corrected, and the bit rate and volume are optimized to meet the look and feel requirements of the motion scene.
While maintaining the visual quality of the encoded video picture, the volume of the encoded video is reduced, the encoding quality is improved, and the bit rate and volume are optimized.
Smart Images

Figure CN114302139B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a video encoding method, a video decoding method and device, an electronic device, and a machine-readable medium. Background Art
[0002] Video encoding refers to the method of converting files in the original video format into files in another video format through compression technology. Video encoding is an important step in obtaining watchable videos.
[0003] In the related technology, CUTree is one of the effective coding tools in video coding. It controls the image quality loss of video frames by analyzing the mutual reference process between video frames, thereby controlling the bit rate and volume of the encoded video.
[0004] However, it is difficult to further optimize the bit rate and volume of the encoded video in the current solution, resulting in the encoded video having a large volume when the bit rate is high, or a low bit rate when the volume is small, thereby reducing the encoding quality. Summary of the invention
[0005] The embodiments of the present application provide a video encoding method and a video decoding method to solve the problem of low encoding quality in the related art.
[0006] Correspondingly, the embodiments of the present application also provide a video encoding device, an electronic device and a storage medium to ensure the implementation and application of the above method.
[0007] In order to solve the above problems, an embodiment of the present application discloses a video encoding method, the method comprising:
[0008] Acquire a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding regions;
[0009] According to the motion scene in which the video frame is located, adjusting an adjustment strength value of the video frame, wherein the adjustment strength value is used to control a size of a quantization parameter of a coding area in the video frame;
[0010] Acquire a quantization parameter of the coding area according to the adjustment strength value of the video frame and a reference value parameter of the coding area obtained by pre-coding the video frame;
[0011] The video to be encoded is encoded according to the quantization parameter of the encoding area to obtain an encoded video.
[0012] The present application discloses a video decoding method, which includes:
[0013] Acquire a coded video, wherein a video frame of the coded video is divided into a plurality of coded areas;
[0014] Decoding the encoded video to obtain a quantization parameter of the encoded region, wherein the quantization parameter is: an adjustment strength value determined by a motion scene in which a video frame of the encoded video before encoding is located, and a parameter calculated by a reference value parameter obtained by pre-encoding the encoded region;
[0015] A video to be played is constructed according to the quantization parameters of the encoding area.
[0016] The embodiment of the present application discloses a video encoding device, the device comprising:
[0017] A first acquisition module is used to acquire a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding regions;
[0018] An adjustment module, used for adjusting an adjustment strength value of the video frame according to a motion scene in which the video frame is located, wherein the adjustment strength value is used for controlling a size of a quantization parameter of a coding area in the video frame;
[0019] A calculation module, configured to obtain a quantization parameter of the coding area according to the adjustment strength value of the video frame and a reference value parameter of the coding area obtained by pre-coding the video frame;
[0020] The encoding module is used to encode the video to be encoded according to the quantization parameter of the encoding area to obtain an encoded video.
[0021] The embodiment of the present application discloses a video decoding device, the device comprising:
[0022] A second acquisition module is used to acquire a coded video, wherein a video frame of the coded video is divided into a plurality of coded areas;
[0023] A decoding module, used for decoding the encoded video to obtain a quantization parameter of the encoded region, wherein the quantization parameter is: an adjustment strength value determined by a motion scene in which a video frame of the encoded video before encoding is located, and a parameter calculated by a reference value parameter obtained by pre-encoding of the encoded region;
[0024] The reconstruction module is used to construct the video to be played according to the quantization parameters of the encoding area.
[0025] An embodiment of the present application further discloses an electronic device, including: a processor; and a memory, on which executable code is stored. When the executable code is executed, the processor executes one or more methods described in the embodiments of the present application.
[0026] The embodiments of the present application also disclose one or more machine-readable media on which executable codes are stored. When the executable codes are executed, the processor executes one or more methods described in the embodiments of the present application.
[0027] Compared with the prior art, the embodiments of the present application have the following advantages:
[0028] In an embodiment of the present application, the motion scene in which the video frame of the video to be encoded is located can be analyzed to dynamically adjust the video frame adjustment intensity value according to the motion scene, thereby correcting the size of the quantization parameter of the encoding area. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, while satisfying the picture viewing quality of the encoded video and reducing the volume of the encoded video, thereby improving the encoding quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is an architecture diagram of a video encoding method according to an embodiment of the present application;
[0030] Figure 2 is an architecture diagram of a video decoding method according to an embodiment of the present application;
[0031] Figure 3 It is an architecture diagram of a video encoding method in an e-commerce live broadcast scenario according to an embodiment of the present application;
[0032] Figure 4 It is an architecture diagram of a video encoding method in a short video scenario according to an embodiment of the present application;
[0033] Figure 5 It is an architecture diagram of a video encoding method in a video conferencing scenario according to an embodiment of the present application;
[0034] Figure 6 It is an architecture diagram of a video encoding method in a network video on demand scenario according to an embodiment of the present application;
[0035] Figure 7 is a flowchart of the steps of a video encoding method according to an embodiment of the present application;
[0036] Figure 8 is a schematic diagram of a video frame according to an embodiment of the present application;
[0037] Fig. 9 is a flowchart of another video encoding method embodiment of the present application;
[0038] Fig.10 is a schematic diagram of a precoding process in an embodiment of the present application;
[0039] Fig.11is a specific example schematic diagram of a precoding process in an embodiment of the present application;
[0040] Fig.12 is a flowchart of the steps of a video decoding method according to an embodiment of the present application;
[0041] Fig.13 is a structural block diagram of a video encoding device according to an embodiment of the present application;
[0042] Fig.14 is a structural block diagram of a video decoding device according to an embodiment of the present application;
[0043] Fig.15 It is a schematic diagram of the structure of a device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0045] In order to enable those skilled in the art to better understand the present application, the concepts involved in the present application are explained below:
[0046] The video to be encoded is the original video file before encoding, which is a YUV (a color coding, Y is brightness, UV is color) video sequence composed of original video frame images.
[0047] Encoded video: The file obtained after the video to be encoded is processed by video encoding, also called a video raw stream file. After the video raw stream file is subsequently encapsulated, a watchable audio and video can be obtained.
[0048] Coding area: also known as coding unit (CU), is an image block of a fixed size (such as 8×8) that is pre-divided in the video frame, and is also a processing object in the encoding process.
[0049] Motion scene: a scene that reflects an instantaneous or continuous motion process. In the embodiment of the present application, the motion scene in which the current video frame is located can affect the size of its quantization parameter. The motion scene includes a motion scene with drastic changes in the picture and a motion scene with slow changes in the picture.
[0050] Quantization parameter (QP): Quantization is the process of mapping the continuous value of a signal into multiple discrete amplitudes, realizing a many-to-one mapping of signal values. Quantization can effectively reduce the value range of the signal, thereby achieving better compression effects. The quantization parameter is a parameter that can be used to derive the quantization step size during the encoding process, and is used to control the size and quality of the encoded bitstream. The smaller the quantization parameter, the larger the size of the encoded bitstream and the higher the picture quality; the larger the quantization parameter, the smaller the size of the encoded bitstream and the lower the picture quality.
[0051] CUTree: During video encoding, a method for adjusting the quantization parameter offset of the current coding region based on the degree to which the current coding region is referenced by coding regions of other frames.
[0052] Lookahead module: When encoding the current frame in the CUTree algorithm, a module that quickly encodes several subsequent frames of the current frame in advance to obtain the reference value parameters of the current frame for subsequent reference frames.
[0053] Strength adjustment value: CUTree Strength, a parameter used to control the adjustment range of the quantization parameter offset of the current coding area. The quantization parameter offset is superimposed on the initial quantization parameter to obtain the adjusted quantization parameter. The larger the strength adjustment value, the smaller the adjusted quantization parameter.
[0054] Reference value parameter (propagateCost): Assuming that the coding region b of the reference video frame refers to the coding region a of the referenced video frame, the reference value parameter of the coding region a reflects the reference value provided by the coding region a to the coding region b.
[0055] Motion search: The process of finding the matching coding area with the smallest difference with the current coding area on the reference frame, which is used to identify the motion scene in the video frame.
[0056] Motion vector (MV): A vector connecting the current coding area and the matching coding area, used to indicate the direction of movement of an object in a video frame.
[0057] Static coding region: a coding region whose motion vector approaches 0. The position of the static coding region in the current frame is close to the position of its matching coding region in the reference frame.
[0058] Pixel cost parameter (cost): reflects the pixel-level difference between the current coding area and the matching coding area. The larger the pixel cost parameter, the smaller the similarity between the current coding area and the matching coding area.
[0059] Intra prediction mode (intra): A mode that uses only the reconstructed pixels of the current frame for prediction.
[0060] Inter prediction mode (inter): A mode that uses pixels from previously encoded frames to predict the current frame.
[0061] Intra-frame prediction cost (intracost): reflects the total amount of information of the video frame in the intra-frame prediction mode.
[0062] Inter-frame prediction cost (intercost): reflects the total amount of information of the video frame in the inter-frame prediction mode. The difference between the intra-frame prediction cost and the inter-frame prediction cost represents the amount of information transferred from the current frame to its reference frame.
[0063] Preset index parameter (preset): The encoder uses preset index parameters to configure the encoding level. For example, 10 encoding levels can be set, and the preset index parameters range from 0 to 9. The encoding speed becomes slower as the preset index parameter becomes larger, and the encoding efficiency increases as the preset index parameter increases.
[0064] H.265 / HEVC: International video coding standard.
[0065] x265: An open source H.265 / HEVC encoder.
[0066] s265: Self-developed H.265 / HEVC encoder.
[0067] Reference Figure 1 , which shows an architecture diagram of a video encoding method provided in an embodiment of the present application, including: a downsampling module, a pre-encoding module, an analysis module, a calculation module, and an encoding module.
[0068] The architecture of the video encoding method of the embodiment of the present application can be applied to the fields of short video, video conferencing, video live broadcast, network video on demand, etc. Specifically, when the target video needs to be output in these fields, the video to be encoded can be firstly encoded according to Figure 1 The process encodes the video to obtain the encoded video, and finally encapsulates the encoded video according to a preset format to obtain a target video in a preset format for output.
[0069] In the above process, video encoding bears the heavy responsibility of video compression. Its mission is to reduce the size of video files as much as possible while ensuring that the quality of the video viewed by the human eye does not decrease significantly, thereby saving bandwidth costs and improving the smooth viewing experience. In addition, there are different requirements for the bit rate and size of encoded videos in various fields. For example, some fields require the output of high-quality videos with high bit rates, and some fields require the output of lightweight videos with small volumes. Specifically, in the encoding process, the requirements for bit rate and volume in these fields can be met by adjusting relevant parameters, and after meeting the requirements of the parameters of the encoded video on one hand, the parameters on the other hand can be made to have excellent performance as much as possible. For example, under the premise of meeting the requirement of small volume of encoded video, the bit rate of the encoded video can be increased as much as possible; under the premise of meeting the requirement of high bit rate of encoded video, the volume of encoded video can be reduced as much as possible.
[0070] In the video encoding process, the reference coding area of the reference video frame in the video to be encoded can control its own image quality loss by obtaining reference from the reference coding area of the referenced video frame, thereby controlling its own bit rate (picture quality) and volume. Among them, if the reference value provided by the reference coding area to the reference coding area is greater, then the reference coding area can be given a smaller quantization parameter through the control of relevant parameters, so that its image quality loss is smaller and has a higher bit rate, so that it can provide sufficient reference value to the subsequent reference coding area and improve the quality of the subsequent reference coding area; if the reference value provided by the reference coding area to the reference coding area is smaller, it can be considered that the utilization value of the reference coding area itself is lower, even if its picture quality is lower, it will not affect the subsequent encoding, then the reference coding area can be given a larger quantization parameter through the control of relevant parameters, so that its image quality loss is larger and has a lower bit rate, thereby reducing the volume of the reference coding area, and then reducing the volume of the entire encoded video.
[0071] Furthermore, the embodiment of the present application can draw a conclusion by analyzing the motion scene in which the video frame of the video to be encoded is located: a coding area in a motion scene with drastic changes in the picture, and a coding area in a motion scene with slow changes in the picture, even if these two coding areas have the same reference value for subsequent frames, but because the picture distortion of the coding area in the motion scene with slow changes in the picture is more easily captured by the human eye, the picture quality of the coding area in the motion scene with slow changes in the picture is more important; and because the human eye is not sensitive to rapidly changing scenes, even if the image quality of the coding area in the motion scene with drastic changes in the picture is reduced, it will not affect the actual viewing experience.
[0072] In addition, the image noise of the video frame will also affect the bit rate and volume of the coding area. Since the human eye is not sensitive to scene changes in the picture when the image noise is high, even if the image quality of the coding area in the moving scene when the image noise is high is reduced, it will not affect the actual viewing experience. When the image noise is low, the changes in the picture are easier to be captured by the human eye. Therefore, the picture quality of the coding area is more important when the image noise is low.
[0073] Based on the above conclusions, the embodiments of the present application can dynamically adjust the video frame adjustment strength value according to the motion scene by analyzing the motion scene in which the video frame of the video to be encoded is located, and then correct the size of the quantization parameter of the encoding area. When the video frame is in a motion scene with drastic changes in the picture or large image noise, the adjustment strength value of the video frame is reduced, and then the quantization parameter of the encoding area in the video frame is increased, so that the volume of the encoding area after encoding decreases, meeting the demand for reducing the volume of the encoded video; when the video frame is in a motion scene with slow changes in the picture and small image noise, the adjustment strength value of the video frame is increased, and then the quantization parameter of the encoding area in the video frame is reduced, so that the bit rate of the encoding area after encoding is improved, meeting the high image quality requirements in scenes where the human eye can easily capture changes.
[0074] It should be noted that, in a simplified scenario, the embodiments of the present application can also set the adjustment strength value of the video frame only by distinguishing between drastic changes in the picture or slow changes in the picture. When it is determined that the video frame is in a motion scene with drastic changes in the picture, the adjustment strength value of the video frame is reduced; when it is determined that the video frame is in a motion scene with slow changes in the picture, the adjustment strength value of the video frame is increased.
[0075] Specifically, refer to Figure 1 The downsampling module can downsample the input video to be encoded, such as downsampling the original resolution of the video frame to be encoded by 1 / 2 horizontally and 1 / 2 vertically to obtain a downsampled image with an original resolution of 1 / 4. The downsampling process can effectively reduce the amount of data calculation in the subsequent encoding process and has a slight impact on the calculation accuracy. The downsampled video to be encoded can be further input into the pre-encoding module for subsequent encoding processing. It should be noted that.
[0076] The pre-coding module can execute the related functions of the Lookahead module in the CUTree algorithm. The pre-coding module can pre-code the video frames of the video to be encoded, with the aim of obtaining the reference value parameters of the encoding area of the video frame for the subsequent reference frame. The reference value parameters are important parameters in the subsequent calculation of the quantization parameters of the encoding area.
[0077] The analysis module can identify the proportion of static coding areas in video frames and the cumulative value of image noise of video frames based on motion search of video frames to be encoded, and determine the motion scene of the video frame through the proportion of static coding areas and the cumulative value of image noise of the video frame, and finally assign the corresponding adjustment intensity value to the video frame according to the motion scene of the video frame.
[0078] The calculation module can calculate the quantization parameter of each coding area of the video frame by combining the reference value parameter of the coding area of the video frame output by the pre-coding module for the subsequent reference frame and the adjustment strength value dynamically set to the video frame according to the motion scene.
[0079] The encoding module can encode the entire video to be encoded based on the quantization parameters of each encoding area of the video frame, and finally obtain the encoded video. The encoded video is also called a video raw stream file. After the subsequent encapsulation processing of the video raw stream file, a watchable audio and video can be obtained.
[0080] Furthermore, in actual applications, when the encoder defines the encoding method, it will also define a decoding method that matches the encoding method. Therefore, after the viewing terminal obtains the encapsulated audio and video that can be viewed, it can decapsulate the audio and video according to the decapsulation method corresponding to the encapsulation method, and then decode the decapsulated audio and video according to the decoding method corresponding to the encoding method to obtain the decoded video stream for viewing.
[0081] For example, if the encoding rules defined by s265 are used to encode the video to be encoded to obtain the encoded video, and then the encoded video is encapsulated into an audio and video in MP4 format according to the MP4 (MPEG-4 Part 14) encapsulation method and sent to the viewing terminal, the viewing terminal can first decapsulate the audio and video in MP4 format according to the MP4 decapsulation method, and then decode the decapsulated audio and video according to the decoding rules defined by s265, so as to obtain a watchable video stream for direct playback.
[0082] When decoding, refer to Figure 2, which shows an architecture diagram of a video decoding method provided in an embodiment of the present application. Specifically, the encoded video can be entropy decoded (binary decoding) to obtain the quantization parameter, transform coefficient and prediction coefficient of each encoding area of the encoded video, wherein the transform coefficient is the coefficient of the transform unit in the encoding area. During the encoding and decoding process, the luminance data and the chrominance data are based on the transform unit, and the position information of the non-zero coefficient and the amplitude information of the non-zero coefficient are encoded to represent the transform coefficient; the prediction coefficient is the coefficient of the prediction unit in the encoding area, and the prediction coefficient is related to the prediction mode (intra-frame / inter-frame prediction mode) selected during encoding. The quantization parameter is the adjustment intensity value determined by the motion scene of the video frame of the encoded video before encoding in the embodiment of the present application, and the parameter calculated by the reference value parameter obtained by pre-encoding of the encoding area. Subsequently, the video to be played can be constructed based on the quantization parameter, the transform coefficient and the prediction coefficient.
[0083] Furthermore, based on one calculation branch, an embodiment of the present application can perform inverse quantization and inverse transformation operations in sequence according to the quantization parameters and quantization coefficients of the coding area to obtain residual parameters of the pixel values in the coding area. Inverse quantization and inverse transformation are the reverse operations of quantization and transformation in the corresponding encoding process. The residual parameters are the reconstructed residuals, which are parameters reflecting the mean square error before and after the pixel values are encoded; based on another calculation branch, an embodiment of the present application can perform a prediction operation according to the prediction mode of the prediction unit in the coding area to obtain prediction parameters of the pixel values in the coding area, and finally add the residual parameters and the prediction parameters of the coding area to obtain the reconstructed pixel values of the pixel points in the coding area, and then construct the video to be played from the reconstructed pixel values of the pixel points in the coding area of the video frame.
[0084] In order to better describe the application scenarios of the video encoding method of the embodiment of the present application, several specific application scenarios of the video encoding method are now provided:
[0085] In an e-commerce live broadcast scenario where a video encoding method is applied, refer to Figure 3 , which shows an architecture diagram of a video encoding method in an e-commerce live broadcast scenario provided by an embodiment of the present application, including: a live broadcaster client, an e-commerce live broadcast server, and a viewer client. Among them, the live broadcaster client can be integrated with an encoding program for implementing the video encoding method of the embodiment of the present application.
[0086] Specifically, the live broadcast client can execute S11, collect the original live video stream including the live broadcast screen, encode the original live video stream through the encoding program according to the encoding method provided in the embodiment of the present application, obtain the encoded video, and encapsulate the encoded video to obtain the target live video stream. And further execute S12, send the target live video stream to the e-commerce live broadcast service end, the e-commerce live broadcast service end can further execute S13, send the target live video stream to the viewer client, the viewer client can execute S14, decapsulate and decode the target live video stream in turn, and then watch it, providing the encoding method of the embodiment of the present application, so that in the e-commerce live broadcast scene, the picture quality of the encoded video stream is met while reducing the volume of the encoded video stream.
[0087] It should be noted that the encoding program for implementing the video encoding method of the embodiment of the present application can also be integrated in the e-commerce live broadcast server. The live broadcaster client can send the original live video stream to the e-commerce live broadcast server, so that the process of encoding the original live video stream through the encoding program to obtain the encoded video and the process of packaging the encoded video can be completed on the e-commerce live broadcast server.
[0088] In a short video scenario where a video encoding method is applied, refer to Figure 4 , which shows an architecture diagram of a video encoding method in a short video scenario provided by an embodiment of the present application, including: a creator client, a short video server, and a viewer client. Among them, the creator client can be integrated with an encoding program for implementing the video encoding method of the embodiment of the present application.
[0089] Specifically, the creator client can execute S21, collect the original short video stream including the material, encode the original short video stream through the encoding program according to the encoding method provided in the embodiment of the present application, obtain the encoded video, and encapsulate the encoded video to obtain the target short video. And further execute S22, send the target short video to the short video server, the short video server can further execute S23, send the target short video to the viewer client, the viewer client can execute S24, decapsulate and decode the target short video in turn, and then watch it, providing the encoding method of the embodiment of the present application, so that in the short video scene, the picture quality of the encoded video stream is satisfied while reducing the volume of the encoded video stream.
[0090] It should be noted that the short video server can also integrate an encoding program for implementing the video encoding method of the embodiment of the present application. The creator client can send the original short video stream to the short video server, so that the process of encoding the original short video stream through the encoding program to obtain the encoded video and the process of packaging the encoded video can be completed on the short video server.
[0091] In a video conferencing scenario where a video encoding method is applied, reference Figure 5 , which shows an architecture diagram of a video encoding method in a video conference scenario provided by an embodiment of the present application, including: a host client, a conference server, and a viewer client. Among them, the host client can be integrated with an encoding program for implementing the video encoding method of the embodiment of the present application.
[0092] Specifically, the host client can execute S31, collect the original conference video stream including the host screen, encode the original conference video stream through the encoding program to obtain the encoded video, and encapsulate the encoded video to obtain the target conference video stream. And further execute S32, send the target conference video stream to the conference server, the conference server can further execute S33, send the target conference video stream to the viewer client, the viewer client can execute S34, decapsulate and decode the target conference video stream in turn, and then watch it, providing an encoding method for applying the embodiment of the present application, so that in the video conferencing scenario, the picture quality of the encoded video stream is met while reducing the volume of the encoded video stream.
[0093] It should be noted that the conference server can also integrate an encoding program for implementing the video encoding method of the embodiment of the present application. The creator client can send the original conference video stream to the conference server, so that the process of encoding the original conference video stream through the encoding program to obtain the encoded video and the process of packaging the encoded video can be completed on the conference server.
[0094] In a network video on demand scenario where a video encoding method is applied, referring to Figure 6 , which shows an architecture diagram of a video encoding method in a network video on demand scenario provided by an embodiment of the present application, including: a network video on demand server and a viewer client. Among them, the network video on demand server can be integrated with an encoding program for implementing the video encoding method of the embodiment of the present application.
[0095] Specifically, the network video on demand server can execute S41, respond to the on-demand request of the viewer client, obtain the original video stream of the on-demand video, encode the original video stream through the encoding program to obtain the encoded video, and encapsulate the encoded video to obtain the on-demand video. And further execute S42, send the on-demand video to the viewer client, and the viewer client can execute S43, decapsulate and decode the on-demand video in sequence and then watch it, providing an encoding method using the embodiment of the present application, so that in the network video on demand scenario, the picture quality of the encoded video stream is met while reducing the volume of the encoded video stream.
[0096] In an embodiment of the present application, the motion scene in which the video frame of the video to be encoded is located can be analyzed to dynamically adjust the video frame adjustment intensity value according to the motion scene, thereby correcting the size of the quantization parameter of the encoding area. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, while satisfying the picture viewing quality of the encoded video and reducing the volume of the encoded video, thereby improving the encoding quality.
[0097] Reference Figure 7 , which shows a flow chart of the steps of a video encoding method provided by an embodiment of the present application, including:
[0098] Step 101: obtaining a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding areas.
[0099] In an embodiment of the present application, the video to be encoded is the original video file before encoding, which is a video sequence composed of original video frame images. The encoding area is also called a coding unit, which is an image block of a fixed size divided in advance in the video frame and is also a processing object in the encoding process.
[0100] For example, refer to Figure 8 , which shows a schematic diagram of a video frame provided in an embodiment of the present application. Assuming a 24×24 video frame, if a coding area is 8×8 in size, the video frame can be divided into 9 coding areas.
[0101] Step 102: adjusting an adjustment strength value of the video frame according to the motion scene in which the video frame is located, wherein the adjustment strength value is used to control the size of a quantization parameter of a coding area in the video frame.
[0102] In an embodiment of the present application, according to the characteristics of the different effects of the human eye's sense of the speed of change of the picture in the video frame and the image noise, it is specifically possible to perform motion search on the video frame of the video to be encoded to identify the proportion of static coding areas in the video frame and the cumulative value of the image noise of the video frame, and determine the motion scene of the video frame through the proportion of static coding areas and the cumulative value of the image noise of the video frame, and finally assign the corresponding adjustment intensity value to the video frame according to the motion scene of the video frame.
[0103] It should be noted that the motion scene in which the video frame is located may also be marked in advance, so that the adjustment strength value of the video frame can be adjusted according to the marked motion scene.
[0104] Step 103: Acquire a quantization parameter of the coding area according to the adjustment strength value of the video frame and a reference value parameter of the coding area obtained by pre-coding the video frame.
[0105] In an embodiment of the present application, the video frames of the video to be encoded can be pre-encoded by executing the relevant functions in the Lookahead module in the CUTree algorithm, so as to obtain the reference value parameters of the encoding area of the video frame for the subsequent reference frame. The reference value parameters are important parameters in the subsequent calculation of the quantization parameters of the encoding area.
[0106] Furthermore, different encoding rules have different slice QPs, and slice QP is the basic quantization parameter. After selecting an encoding rule (encoder), the basic quantization parameter corresponding to the encoding rule is also selected. In addition, based on the adjustment strength value of the video frame and the reference value parameters of each encoding area in the video frame, the quantization parameter offset can be calculated. By correcting the basic quantization parameter by the quantization parameter offset, the final quantization parameter of the encoding area can be obtained.
[0107] Step 104: Encode the video to be encoded according to the quantization parameter of the encoding area to obtain an encoded video.
[0108] In this step, during the encoding process, the quantization parameter is used to control the degree of image quality loss in the encoding area during the encoding process. The larger the quantization parameter, the greater the image quality loss in the encoding area, the smaller the bit rate of the encoding area, and the smaller the volume of the encoding area; the smaller the quantization parameter, the smaller the image quality loss in the encoding area, the larger the bit rate of the encoding area, and the larger the volume of the encoding area.
[0109] The encoded video is also called a video raw stream file. After the video raw stream file is subsequently packaged, a watchable audio and video can be obtained.
[0110] Further, for the encoding process using the video encoding method provided in the embodiment of the present application, compared with the encoding process not using the present method, when the encoding configuration is completely the same, through 46 1080p high-definition test files, 3 preset index parameters corresponding to each encoding level, and 2 evaluation indicators, the encoding process using the video encoding method provided in the embodiment of the present application can be obtained. The gain effect shown in Table 1 below:
[0111] Preset index parameters psnr-bdrate ssim-bdrate 2 (coding level veryfast) -3.59% -1.74% 5 (encoding level medium) -3.86% -1.55% 7 (coding level very slow) -2.36% -2.00%
[0112] Table 1
[0113] Among them, PSNR-BDRATE (Peak Signal-to-Noise Ratio - the average of the difference between the two rate-distortion curves corresponding to the two schemes) is the bit rate saved under the same PSNR quality; SSIM-BDRATE (Structural Similarity - the average of the difference between the two rate-distortion curves corresponding to the two schemes) is the bit rate saved under the same SSIM quality. It can be seen that, under any fixed indicator, the encoding process using the video encoding method provided in the embodiment of the present application has achieved obvious bit rate saving effect, thereby improving the coding gain effect.
[0114] To summarize, in the embodiments of the present application, the motion scene in which the video frame of the video to be encoded is analyzed, and the video frame adjustment intensity value can be dynamically adjusted according to the motion scene, thereby correcting the size of the quantization parameter of the encoding area. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, thereby reducing the volume of the encoded video while satisfying the picture viewing quality of the encoded video, thereby improving the encoding quality.
[0115] Reference Fig. 9 , shows a step flow chart of another video encoding method embodiment of the present application.
[0116] include:
[0117] Step 201: obtaining a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding areas.
[0118] This step may specifically refer to the above step 101, which will not be described in detail here.
[0119] Step 202: downsample the video frames of the video to be encoded to reduce the resolution of the video frames.
[0120] In an embodiment of the present application, after obtaining the video to be encoded, the video to be encoded can be downsampled to reduce the resolution of the video frame of the video to be encoded, thereby reducing the amount of calculation in the subsequent calculation process and slightly affecting the calculation accuracy.
[0121] For example, the original resolution of the video frame of the video to be encoded may be downsampled to 1 / 2 horizontally and 1 / 2 vertically to obtain a downsampled image with a size of 1 / 4 of the original resolution.
[0122] It should be noted that downsampling is an optional processing process. In some scenarios where computing resources are sufficient, it is also possible not to perform downsampling processing on the video to be encoded, but to directly perform subsequent encoding processing on the video to be encoded.
[0123] Step 203: Obtain intra-frame prediction cost parameters and inter-frame prediction cost parameters of the coding region.
[0124] In an embodiment of the present application, the selected coding rule may use an intra-frame prediction mode or an inter-frame prediction mode for reference and prediction between frames, wherein the intra-frame prediction mode is a mode that uses only the reconstructed pixels of the current frame for prediction; the inter-frame prediction mode is a mode that uses the pixels of the previously encoded frame for prediction of the current frame. After selecting these two modes, the intra-frame prediction cost parameters and inter-frame prediction cost parameters of the coding area can be obtained. The intra-frame prediction cost parameters and inter-frame prediction cost parameters of the coding area are important parameters for the subsequent calculation of the quantization parameters of the coding area. The intra-frame prediction cost of each coding area represents the total amount of information of the current frame, and the difference between the intra-frame prediction cost and the inter-frame prediction cost of the coding area represents the amount of information transmitted by the current frame from its reference frame.
[0125] Step 204 , pre-encode the video frame, and obtain reference value parameters of the encoding region of the video frame according to the intra-frame prediction cost parameter and the inter-frame prediction cost parameter.
[0126] In this step, refer to Fig.10 , shows a schematic diagram of a precoding process of the present application, wherein, when precoding the current frame, n subsequent frames of the current frame may be selected to construct a precoding window. It can be seen that a coding region 11 of each frame refers to a coding region 11 of an adjacent previous frame. It should be noted that, Fig.10 The reference link of the coding area 11 shown is only an implementation link. A coding area 11 of a frame can also refer to a coding area 11 of the previous frames, or a coding area 11 of a frame can also refer to a coding area 11 of a subsequent frame. The embodiment of the present application does not specifically limit the reference link.
[0127] Specifically, to calculate the reference value parameters of the coding area 11 of the current frame, the following steps need to be performed in sequence:
[0128] The first step is to start from frame n in the pre-coding window and calculate the amount of information info1 obtained by the coding area 11 in frame n from frame n-1:
[0129]
[0130] Wherein, intracost is the intra-frame prediction cost parameter of the coding region 11 in frame n; intercost is the inter-frame prediction cost parameter of the coding region 11 in frame n;
[0131] The second step is that if the reference area of frame n-1 in frame n-2 covers multiple coding areas in frame n-2, then the value of info1 needs to be distributed proportionally according to the coding areas covering each CU. After traversing all the coding areas of frame n, the reference value parameter of each coding area in frame n-1 to frame n is obtained, which is recorded as propagateCost.
[0132] Step 3: The amount of information that frame n-1 obtains from frame n-2 will not only affect frame n-1, but also the following frame n. Therefore, the amount of information info2 that the coding area of frame n-1 obtains from frame n-2 is:
[0133] Info2=(0.5*intracost+propagateCost)*propagate_faction;
[0134] Wherein, intracost is the intra-frame prediction cost parameter of the coding region 11 in frame n-1; intercost is the inter-frame prediction cost parameter of the coding region 11 in frame n-1; propagate cost is the reference value parameter of each coding region in frame n-1 to frame n;
[0135] Step 4: Similar to step 2, info2 is evenly divided according to the area, and each coding area of frame n-1 is traversed to finally obtain the reference value parameters of each coding area of frame n-2 to frame n-1.
[0136] Step 5: Calculate according to the logic of steps 1 to 4 until the current frame, and obtain the reference value parameters of each coding area of the current frame to frame 1.
[0137] By performing the above logic calculation on all or part of the video frames of the video to be encoded, the reference value parameters of the encoding area of the video frame can be obtained.
[0138] In order to explain the specific execution process of step 204 more clearly, a specific example is provided for illustration:
[0139] Reference Fig.11 , shows a specific example schematic diagram of a precoding process of the present application, assuming that for the current frame, it is precoded through the p1 frame and the p2 frame in the precoding window, the area of each video frame is 16×16, the size of each coding area is 8×8, and the coding area 1 of the p2 frame in the reference area 12 in the p1 frame covers the coding areas 1-4 of the p1 frame, and the overlapping areas with the coding areas are s1, s2, s3, and s4 respectively.
[0140] Then the amount of information obtained by the coding area 1 of the p2 frame from the p1 frame is info_p2(1)=intracost_p2(1)-intercost_p2(1); the amount of information provided by the four coding areas in the p1 frame to the coding area 1 of the p2 frame is:
[0141] Pro_p1(1)=(s1 / 64)×info_p2(1);
[0142] Pro_p1(2)=(s2 / 64)×info_p2(1);
[0143] Pro_p1(3)=(s3 / 64)×info_p2(1);
[0144] Pro_p1(4)=(s4 / 64)×info_p2(1);
[0145] Further, assuming that coding region 2 of frame p2 refers to coding region 2 of frame p1, coding region 3 of frame p2 refers to coding region 3 of frame p1, and coding region 4 of frame p2 refers to coding region 4 of frame p1, the amount of information provided by coding region 2 of frame p1 to coding region 2 of frame p2 is:
[0146] Pro_p1(2)'=info_p2(2)=intracost_p2(2)-intercost_p2(2);
[0147] The amount of information provided by coding region 3 of p1 frame to coding region 3 of p2 frame is:
[0148] Pro_p1(3)'=info_p2(3)=intracost_p2(3)-intercost_p2(3);
[0149] The amount of information provided by coding region 4 of p1 frame to coding region 4 of p2 frame is:
[0150] Pro_p1(4)'=info_p2(4)=intracost_p2(4)-intercost_p2(4);
[0151] The reference value parameters propagatecost of the four coding regions in the p1 frame are:
[0152] propagatecost_p1(1)=Pro_p1(1);
[0153] propagatecost_p1(2)=Pro_p1(2)+Pro_p1(2)';
[0154] propagatecost_p1(3)=Pro_p1(3)+Pro_p1(3)';
[0155] propagatecost_p1(4)=Pro_p1(4)+Pro_p1(4)';
[0156] Finally, assuming that coding regions 1-4 in the p1 frame refer to coding regions 1-4 of the current frame respectively, the reference value parameter of coding region 1 of the current frame to coding region 1 of the p1 frame is:
[0157] Propagatecost_curr(1)=(0.5×intracost_p1(1)+propagate cost_p1(1))×((intracost_p1(1)-intercost_p1(1)) / intracost_p1 (1));
[0158] The reference value parameters of the coding area 2 of the current frame to the coding area 2 of the p1 frame are:
[0159] Propagate cost_curr(2)=(0.5×intracost_p1(2)+propagate cost_p1(2))×((intracost_p1(2)-intercost_p1(2)) / intracost_p1 (2));
[0160] The reference value parameters of the coding area 3 of the current frame to the coding area 3 of the p1 frame are:
[0161] Propagate cost_curr(3)=(0.5×intracost_p1(3)+propagate cost_p1(3))×((intracost_p1(3)-intercost_p1(3)) / intracost_p1 (3));
[0162] The reference value parameters of the coding area 4 of the current frame to the coding area 4 of the p1 frame are:
[0163] Propagate cost_curr(4)=(0.5×intracost_p1(4)+propagate cost_p1(4))×((intracost_p1(4)-intercost_p1(4)) / intracost_p1 (4));
[0164] Step 205: adjusting an adjustment strength value of the video frame according to the motion scene in which the video frame is located, wherein the adjustment strength value is used to control the size of a quantization parameter of a coding area in the video frame.
[0165] This step may specifically refer to the above step 102, which will not be described in detail here.
[0166] Optionally, the adjustment strength value is in inverse proportion to the quantization parameter.
[0167] Specifically, during the encoding process, the adjustment strength value is inversely proportional to the quantization parameter. The quantization parameter is used to control the amount of image quality loss in the encoding area during the encoding process. The smaller the adjustment strength value, the larger the quantization parameter, the greater the image quality loss in the encoding area, the smaller the bit rate of the encoding area, and the smaller the volume of the encoding area; the larger the adjustment strength value, the smaller the quantization parameter, the smaller the image quality loss in the encoding area, the larger the bit rate of the encoding area, and the larger the volume of the encoding area.
[0168] Optionally, in one implementation, step 205 includes:
[0169] Sub-step 2051, when it is determined that the video frame is in a motion scene with drastic picture changes, reducing the adjustment strength value.
[0170] Sub-step 2052: when it is determined that the video frame is in a motion scene with slowly changing images, increase the adjustment strength value.
[0171] In an embodiment of the present application, a conclusion can be drawn by analyzing the motion scene in which the video frame of the video to be encoded is located: a coding area in a motion scene with drastic changes in the picture, and a coding area in a motion scene with slow changes in the picture, even if these two coding areas have the same reference value for subsequent frames, but because the picture distortion of the coding area in the motion scene with slow changes in the picture is more easily captured by the human eye, the picture quality of the coding area in the motion scene with slow changes in the picture is more important; and because the human eye is not sensitive to rapidly changing scenes, even if the picture quality of the coding area in the motion scene with drastic changes in the picture is reduced, it will not affect the actual viewing experience.
[0172] Based on the above conclusions, in an implementation scheme, an embodiment of the present application can set the adjustment strength value of the video frame by distinguishing between drastic changes in the picture and slow changes in the picture. When it is determined that the video frame is in a motion scene with drastic changes in the picture, the adjustment strength value of the video frame is reduced, and the quantization parameter of the coding area in the video frame is increased, so that the volume of the coding area after encoding decreases, thereby meeting the demand for reducing the volume of the encoded video; when it is determined that the video frame is in a motion scene with slow changes in the picture, the adjustment strength value of the video frame is increased, and the quantization parameter of the coding area in the video frame is reduced, so that the bit rate of the coding area after encoding is improved, thereby meeting the high image quality demand in scenes where the human eye can easily capture changes.
[0173] Optionally, in another implementation, step 205 includes:
[0174] Sub-step 2053, when it is determined that the video frame is in a motion scene with drastic picture changes or in a motion scene with large image noise, reducing the adjustment strength value.
[0175] Sub-step 2054, when it is determined that the video frame is in a motion scene with a slowly changing picture and a motion scene with less image noise, increase the adjustment strength value.
[0176] In another implementation method of the embodiment of the present application, based on the analysis of the speed of picture changes in the video frame to be encoded, it is also found that the image noise of the video frame will also affect the bit rate and volume of the encoding area. Since the human eye is not sensitive to scenes with picture changes under high image noise, even if the image quality of the encoding area in the moving scene under high image noise is reduced, it will not affect the actual viewing experience; and the changes in the picture under low image noise are easier to be captured by the human eye, so the picture quality of the encoding area under low image noise is more important.
[0177] Therefore, the embodiments of the present application can dynamically adjust the video frame adjustment strength value according to the motion scene by analyzing the motion scene in which the video frame of the video to be encoded is located, and then correct the size of the quantization parameter of the encoding area. When the video frame is in a motion scene with drastic changes in the picture or large image noise, the adjustment strength value of the video frame is reduced, and then the quantization parameter of the encoding area in the video frame is increased, so that the volume of the encoding area after encoding decreases, meeting the demand for reducing the volume of the encoded video; when the video frame is in a motion scene with slow changes in the picture and small image noise, the adjustment strength value of the video frame is increased, and then the quantization parameter of the encoding area in the video frame is reduced, so that the bit rate of the encoding area after encoding is improved, meeting the high image quality requirements in scenes where the human eye can easily capture changes.
[0178] Optionally, the step of increasing the adjustment strength value may be specifically implemented by adding the current adjustment strength value to a preset adjustment threshold to obtain an increased adjustment strength value.
[0179] Optionally, the step of reducing the adjustment strength value may be specifically implemented by subtracting the current adjustment strength value from the preset adjustment threshold to obtain a reduced adjustment strength value.
[0180] In an embodiment of the present application, a preset adjustment threshold may be set so that when adjusting the intensity adjustment value, specific adjustment may be achieved by adding the current adjustment intensity value to the preset adjustment threshold or subtracting the current adjustment intensity value from the preset adjustment threshold.
[0181] For example, assuming that the adjustment strength value before adjustment is 0.5, and assuming that the preset adjustment threshold is 0.1, when the adjustment strength value is increased, the increased adjustment strength value = 0.5 + 0.1 = 0.6; when the adjustment strength value is decreased, the decreased adjustment strength value = 0.5 - 0.1 = 0.4.
[0182] Optionally, the method may further include:
[0183] Step A1, determining a static coding area in the video frame.
[0184] In the embodiment of the present application, the coding region of the current video frame can obtain useful information from the reference video frame by referring to the coding region of another reference video frame. The static coding region in the current video frame refers to the coding region whose motion vector approaches 0, that is, the position of the static coding region in the current video frame is close to the position of the reference coding region in the reference video frame. Specifically, the static coding region in the video frame can be determined by motion search technology.
[0185] Step A2, obtaining the ratio of the number of static coding areas in the video frame to all coding areas in the video frame.
[0186] After determining the number of static coding areas in the video frame, the proportion of the static coding areas in all coding areas of the video frame can be further calculated, which helps to subsequently determine the motion scene in the current video frame.
[0187] Step A3: when the number ratio is greater than a first threshold, determine that the video frame is in a motion scene with slowly changing images.
[0188] Step A4: when the number ratio is less than a second threshold, determining that the video frame is in a motion scene with drastic picture changes; the first threshold is greater than or equal to the second threshold.
[0189] In the embodiment of the present application, the first threshold or the second threshold can be pre-set to compare the quantity ratio with the threshold, so as to determine the motion scene of the video frame according to the comparison result.
[0190] In a preferred implementation, the first threshold value may be set to 62%, and the second threshold value may be set to 12%. In addition, the first threshold value may also be equal to the second threshold value, such as both being 50%.
[0191] Optionally, the method may further include:
[0192] Step A5: determining the first threshold and the second threshold according to a preset index parameter adopted by the currently used encoding rule, wherein the preset index parameter is in direct proportion to the first threshold and the second threshold respectively.
[0193] In an embodiment of the present application, preset index parameters can be used in the encoder to configure the encoding level. For example, 10 encoding levels can be set, and the preset index parameters range from 0 to 9. The encoding speed becomes slower as the preset index parameter becomes larger, and the encoding efficiency increases as the preset index parameter increases.
[0194] Therefore, based on the relationship between different preset index parameters and coding efficiency and coding speed, the first threshold and the second threshold can be determined based on the preset index parameters adopted by the currently used coding rules, and the preset index parameters are respectively in direct proportion to the first threshold and the second threshold. That is, the slower the coding speed and the higher the coding efficiency, the stricter the judgment condition for the video frame in the motion scene with slowly changing pictures, which reduces the number of video frames judged to be in the motion scene with slowly changing pictures; and the slower the coding speed and the higher the coding efficiency, the looser the judgment condition for the video frame in the motion scene with drastic picture changes, which increases the number of video frames judged to be in the motion scene with drastic picture changes, thereby effectively reducing the volume of the encoded video, and vice versa.
[0195] Optionally, the method may further include:
[0196] Step B1, determining a static coding area in the video frame.
[0197] This step can refer to step A1 and will not be repeated here.
[0198] Step B2, obtaining a pixel cost parameter of a static coding area; the pixel cost parameter is used to reflect: the similarity between the coding area corresponding to the static coding area in the reference video frame of the video frame and the static coding area; the pixel cost parameter is more negatively correlated with the similarity.
[0199] In the embodiment of the present application, in the process of motion search for the coding region, in addition to obtaining the motion vector of the coding region, the pixel-level difference between the current coding region and the reference coding region can also be obtained, and the pixel-level difference is the pixel cost parameter of the current coding region. The pixel cost parameter is more negatively correlated with the similarity between the current coding region and the reference coding region. This step can obtain the pixel cost parameter of each static coding region.
[0200] Step B3: acquiring an average pixel cost parameter of all the static coding regions in the video frame according to the pixel cost parameter of the static coding region.
[0201] In this step, after obtaining the pixel cost parameter of each static coding area, the average pixel cost parameter of the static coding area in the video frame can be calculated according to the number of static coding areas and the sum of the pixel cost parameters of all static coding areas. Since it is generally believed that the pixel cost of the static coding area comes from the image noise, the average pixel cost parameter can be regarded as the magnitude of the image noise of the current video frame.
[0202] Step B4: when the average pixel cost parameter is less than a third threshold, determining that the video frame is in a motion scene with less image noise.
[0203] Step B5: when the average pixel cost parameter is greater than a fourth threshold, determining that the video frame is in a motion scene with large image noise, and the third threshold is less than or equal to the fourth threshold.
[0204] In the embodiment of the present application, the third threshold or the fourth threshold may be preset to compare the average pixel cost parameter with the threshold, so as to determine the motion scene of the video frame according to the comparison result.
[0205] In a preferred implementation, the third threshold value may be set to 30, and the fourth threshold value may be set to 50. In addition, the third threshold value may also be equal to the fourth threshold value.
[0206] Optionally, the method may further include:
[0207] Step B6, determining the third threshold and the fourth threshold according to the preset index parameter adopted by the currently used encoding rule, wherein the preset index parameter is in inverse proportion to the third threshold and the fourth threshold respectively.
[0208] In an embodiment of the present application, preset index parameters can be used in the encoder to configure the encoding level. For example, 10 encoding levels can be set, and the preset index parameters range from 0 to 9. The encoding speed becomes slower as the preset index parameter becomes larger, and the encoding efficiency increases as the preset index parameter increases.
[0209] Therefore, based on the relationship between different preset index parameters and coding efficiency and coding speed, the third threshold and the fourth threshold can be determined based on the preset index parameters adopted by the currently used coding rules, and the preset index parameters are inversely proportional to the third threshold and the fourth threshold, respectively. That is, the slower the coding speed and the higher the coding efficiency, the stricter the judgment condition for the video frame to be in a motion scene with less image noise, which reduces the number of video frames judged to be in a motion scene with less image noise; and the slower the coding speed and the higher the coding efficiency, the looser the judgment condition for the video frame to be in a motion scene with greater image noise, which increases the number of video frames judged to be in a motion scene with greater image noise, thereby effectively reducing the volume of the encoded video, and vice versa.
[0210] In the embodiment of the present application, it should be noted that if the first threshold value and the second threshold value are the same, and the third threshold value and the fourth threshold value are the same, then the judgment of the motion scene in which the video frame is located and the adjustment of the adjustment intensity value include all the situations as follows:
[0211] When it is determined that the video frame is in a motion scene with drastic picture changes or in a motion scene with large image noise, the adjustment strength value is reduced.
[0212] When it is determined that the video frame is in a motion scene with a slowly changing picture and a motion scene with less image noise, the adjustment strength value is increased.
[0213] If the first threshold and the second threshold are different, and / or the third threshold and the fourth threshold are different, then the judgment of the motion scene in which the video frame is located and the adjustment of the adjustment intensity value include all situations in addition to the above situations, there may be other situations, such as the situation where the quantity proportion is less than the first threshold but greater than the second threshold, and the situation where the average pixel cost parameter is greater than the third threshold but less than the fourth threshold. For this situation, it can be determined that the current state has entered a neutral state, that is, the current adjustment intensity value is maintained unchanged, and the adjustment intensity value is neither increased nor decreased.
[0214] Optionally, the process of determining the static coding area in the video frame includes:
[0215] Step C1, obtaining a reference video frame of the video frame from the video to be encoded.
[0216] In an embodiment of the present application, the current video frame of the video to be encoded can obtain useful information from another reference video frame, so this step can obtain a reference video frame of the video frame from the video to be encoded.
[0217] Step C2: determining, in the reference video frame, by motion search, a second coding region that matches the first coding region of the video frame.
[0218] In an embodiment of the present application, motion search is the process of finding a matching coding region on a reference frame that has the smallest difference from the current coding region. Therefore, the second coding region that matches the first coding region of the video frame determined by motion search is the coding region that is closest to the first coding region in terms of pixels.
[0219] Step C3: determining the difference between the coordinates of the second coding region and the coordinates of the first coding region as a motion vector of the first coding region relative to the second coding region.
[0220] In an embodiment of the present application, through motion search, the motion vector mv of the first coding region relative to the second coding region can be obtained. The motion vector mv is specifically (mv.x, mv.y), mv.x is the difference between the horizontal coordinate of the second coding region and the horizontal coordinate of the first coding region, and mv.y is the difference between the vertical coordinate of the second coding region and the vertical coordinate of the first coding region.
[0221] Step C4: determine the first coding region whose motion vector is smaller than a fifth threshold as the static coding region.
[0222] In an embodiment of the present application, since the motion vector (mv.x, mv.y) is a coordinate value, the fifth threshold can be set to a threshold coordinate (a, b) accordingly, so that the motion vector is less than the fifth threshold, which can be specifically mv.x is less than a, and mv.y is less than b, which means that the motion vector approaches 0. If the first coding area satisfies the motion vector being less than the fifth threshold, the first coding area can be a static coding area.
[0223] In order to accurately describe the process of traversing various coding areas to determine the static coding areas, and accurately describe the statistics of the number of static coding areas and the statistics of pixel cost parameters, an example is provided to illustrate the entire implementation process:
[0224] The first step is to create three parameters cuIndex, stationCuNum, and stationCuCost, and initialize these three parameters. Among them, cuIndex is the index number of the current coding area, which is initially 0. The initial 0 indicates the first coding area in the current frame coding order; stationCuNum indicates the number of static coding areas, which is initially 0; stationCuCost indicates the sum of the pixel cost parameters of the static coding areas, which is initially 0.
[0225] The second step is to perform motion search on the current coding area to obtain the motion vector and pixel cost parameters of the current coding area.
[0226] Step 3: When the motion vector of the current coding region is less than the fifth threshold, the current coding region is determined to be a static coding region, and stationCuNum is increased by 1, and stationCuCost is added with the pixel cost parameter of the current coding region. When the motion vector of the current coding region is greater than or equal to the fifth threshold, the current coding region is determined not to be a static coding region, and cuIndex is increased by 1 to start the analysis of the next coding region.
[0227] Step 4: After all coding areas are traversed, the number of static coding areas is obtained according to stationCuNum, and the average pixel cost parameter of the video frame is determined according to the value of stationCuCost and the number of static coding areas.
[0228] Optionally, in another implementation, step 205 includes:
[0229] Sub-step 2055, obtaining basic adjustment parameters.
[0230] Sub-step 2056, adjusting the adjustment intensity value by adjusting the basic adjustment parameter according to the motion scene of the video frame, wherein the basic adjustment parameter is in inverse proportion to the adjustment intensity value.
[0231] In the embodiment of the present application, the adjustment strength value cutreeStrength=5.0*(1-qcompress), wherein the basic adjustment parameter is qcompress, and qcompress is a compression ratio parameter used to control the compression amount. It can be seen that the basic adjustment parameter qcompress and the adjustment strength value cutreeStrength are inversely proportional.
[0232] Based on the above characteristics, the embodiment of the present application can adjust the adjustment strength value by adjusting the basic adjustment parameter according to the motion scene in which the video frame is located; when it is determined that the video frame is in a motion scene with drastic changes in the picture, or in a motion scene with large image noise, the basic adjustment parameter qcompress is increased to achieve the purpose of reducing the adjustment strength value cutreeStrength; when it is determined that the video frame is in a motion scene with drastic changes in the picture, or in a motion scene with large image noise, the basic adjustment parameter qcompress is reduced to achieve the purpose of increasing the adjustment strength value cutreeStrength. For example, in the process of reducing cutreeStrength by increasing qcompress, if the original value of qcompress is set to 0.6, it can be increased to 0.7.
[0233] Step 206: Obtain a basic quantization parameter that matches the current encoding rule.
[0234] In the embodiment of the present application, different encoding rules have different slice QPs, and the slice QP is the basic quantization parameter. After selecting an encoding rule (encoder), the basic quantization parameter corresponding to the encoding rule is also selected.
[0235] In practical applications, the bitstream structure of the entire coding rule can be divided into two layers: the network abstraction layer (NAL) and the video coding layer (VCL). In the NAL layer, the bitstream of the coding rule can be represented as a series of NAL units, and different NAL units contain different types of syntax elements. In addition, the part that actually saves the image data of the original video can be saved in the NAL units of other VCL layers. This part of the data is called a slice in the bitstream. A slice contains part or all of the data of a frame of image. In other words, a frame of video image can be encoded into one or several slices. A slice contains at least one macroblock and at most the data of an entire frame of image. In different coding implementations, the number of slices in the same frame of image may not be the same.
[0236] The purpose of designing Slices in the coding rules is mainly to prevent the spread of bit errors. Because the decoding operations of different slices are independent. The data referenced by the decoding process of a slice (such as predictive coding) cannot cross the boundary of the slice. In the embodiment of the present application, a coding rule can correspond to a basic quantization parameter slice QP.
[0237] Step 207: Acquire a quantization parameter offset of the coding region according to the intra-frame prediction cost parameter, the inter-frame prediction cost parameter, the adjustment strength value and the reference value parameter.
[0238] In the embodiment of the present application, the quantization parameter offset deltaQP is calculated as follows:
[0239]
[0240] As can be seen from the above, the quantization parameter offset deltaQP can be calculated based on the intra-frame prediction cost parameter intracost, the inter-frame prediction cost parameter intercost, the adjustment strength value cutreStrength and the reference value parameter propagateCost. Among them, the quantization parameter offset deltaQP is a negative value.
[0241] Step 208: Correct the basic quantization parameter by using the quantization parameter offset to obtain the quantization parameter of the coding area.
[0242] Optionally, step 208 may be specifically implemented by taking the difference between the basic quantization parameter and the absolute value of the quantization parameter offset as the quantization parameter of the coding area.
[0243] In the embodiment of the present application, the quantization parameter QP of the coding area = basic quantization parameter slice QP + |quantization parameter offset deltaQP|; that is, the difference between the absolute value of the basic quantization parameter slice QP and the quantization parameter offset deltaQP is used as the quantization parameter QP of the coding area.
[0244] Step 209: Encode the video to be encoded according to the quantization parameter of the encoding area to obtain an encoded video.
[0245] This step may specifically refer to the above step 104, which will not be described in detail here.
[0246] Optionally, the method may further include:
[0247] Step 210: Acquire a mapping relationship between index parameters and adjustment strength values, and query parameters of the video frame.
[0248] Step 211: According to the mapping relationship, determine the adjustment intensity value matching the query parameter as the adjustment intensity value of the video frame.
[0249] Among them, the index parameters and the query parameters include: the proportion of the number of static coding areas in the video frame in all coding areas of the video frame, the average pixel cost parameter of the static coding areas in the video frame, the target bit rate set for the encoded video, and at least one of the preset index parameters adopted by the currently used encoding rules.
[0250] In an embodiment of the present application, a more sophisticated continuous adjustment scheme can also be provided for the adjustment process of the adjustment intensity value, specifically, a mapping relationship between index parameters and adjustment intensity values is pre-fitted, and before the adjustment is performed, the query parameters of the current video frame are obtained, the query parameters are provided in the mapping relationship to match the index parameters, and the adjustment intensity value corresponding to the index parameters that match the query parameters is determined as the adjustment intensity value of the current video frame.
[0251] Among them, the parameter types selected by the index parameters and the query parameters can be consistent, that is, the index parameters and the query parameters include: the proportion of the number of static coding areas in the video frame in all coding areas of the video frame, the average pixel cost parameter of the static coding area in the video frame, the target bit rate set for the encoded video, and at least one of the preset index parameters adopted by the currently used encoding rules.
[0252] To summarize, in the embodiments of the present application, the motion scene in which the video frame of the video to be encoded is analyzed, and the video frame adjustment intensity value can be dynamically adjusted according to the motion scene, thereby correcting the size of the quantization parameter of the encoding area. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, thereby reducing the volume of the encoded video while satisfying the picture viewing quality of the encoded video, thereby improving the encoding quality.
[0253] Reference Fig.12 , which shows a flowchart of the steps of a video decoding method provided by an embodiment of the present application, including:
[0254] Step 301: Obtain a coded video, wherein a video frame of the coded video is divided into a plurality of coding areas.
[0255] Step 302, decode the encoded video to obtain the quantization parameter of the encoded area, the quantization parameter is: the adjustment intensity value determined by the motion scene of the video frame of the encoded video before encoding, and the parameter calculated by the reference value parameter obtained by pre-encoding of the encoded area.
[0256] Step 303: construct a video to be played according to the quantization parameter of the encoding area.
[0257] The specific implementation process of steps 301-303 can refer to the above Figure 2 The relevant description will not be repeated here. In the embodiment of the present application, since the bit rate and volume of the coding area are adjusted according to the quantization parameters after the coding area is optimized during the encoding process, in the decoded video stream, the video frames in the motion scenes with drastic picture changes or large image noise have a smaller volume, and the image quality loss is almost not captured by the human eye, thereby saving the volume of the video to be played; for the video frames in the motion scenes with slow picture changes or small image noise, it has a high bit rate, thereby improving the human eye's capture of the picture quality details in the video frames in such slow and low-noise motion scenes through higher picture quality, thereby improving the viewing quality.
[0258] To summarize, in the embodiments of the present application, the motion scene in which the video frame of the video to be encoded is analyzed, and the video frame adjustment intensity value can be dynamically adjusted according to the motion scene, thereby correcting the size of the quantization parameter of the encoding area. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, thereby reducing the volume of the encoded video while satisfying the picture viewing quality of the encoded video, thereby improving the encoding quality.
[0259] Reference Fig.13 , which shows a block diagram of a video encoding device provided by an embodiment of the present application, including:
[0260] A first acquisition module 401 is used to acquire a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding regions;
[0261] An adjustment module 402, configured to adjust an adjustment strength value of the video frame according to a motion scene in which the video frame is located, wherein the adjustment strength value is used to control a size of a quantization parameter of a coding region in the video frame;
[0262] The calculation module 403 is used to obtain the quantization parameter of the coding area according to the adjustment strength value of the video frame and the reference value parameter of the coding area obtained by pre-coding the video frame;
[0263] The encoding module 404 is used to encode the video to be encoded according to the quantization parameter of the encoding area to obtain an encoded video.
[0264] Optionally, the adjustment module 402 includes:
[0265] A first adjustment submodule, configured to reduce the adjustment strength value when it is determined that the video frame is in a motion scene with drastic picture changes;
[0266] The second adjustment submodule is used to increase the adjustment strength value when it is determined that the video frame is in a motion scene with slowly changing images.
[0267] Optionally, the adjustment module 402 includes:
[0268] A third adjustment submodule, configured to reduce the adjustment strength value when it is determined that the video frame is in a motion scene with drastic picture changes or in a motion scene with large image noise;
[0269] The fourth adjustment submodule is used to increase the adjustment strength value when it is determined that the video frame is in a motion scene with a slowly changing picture and a motion scene with less image noise.
[0270] Optionally, the adjustment strength value is in inverse proportion to the quantization parameter.
[0271] Optionally, increasing the adjustment strength value includes:
[0272] Adding the current adjustment strength value to the preset adjustment threshold value to obtain an increased adjustment strength value;
[0273] The reducing the adjustment strength value comprises:
[0274] The current adjustment strength value is subtracted from the preset adjustment threshold to obtain a reduced adjustment strength value.
[0275] Optionally, the device further comprises:
[0276] A first determination module, used to determine a static coding area in the video frame;
[0277] A proportion module, used to obtain the proportion of the static coding area in the video frame to all the coding areas in the video frame;
[0278] A first judgment module is used to determine that the video frame is in a motion scene with a slowly changing picture when the proportion of the number is greater than a first threshold;
[0279] The second judgment module is used to determine that the video frame is in a motion scene with drastic picture changes when the number ratio is less than a second threshold; the first threshold is greater than or equal to the second threshold.
[0280] Optionally, the device further comprises:
[0281] A second determination module, used to determine a static coding area in the video frame;
[0282] A pixel cost module is used to obtain a pixel cost parameter of a static coding region; the pixel cost parameter is used to reflect: a similarity between a coding region corresponding to the static coding region in a reference video frame of the video frame and the static coding region; the pixel cost parameter is more negatively correlated with the similarity;
[0283] An average calculation module, used for obtaining an average pixel cost parameter of all static coding regions in the video frame according to the pixel cost parameter of the static coding region;
[0284] A third judgment module is used to determine that the video frame is in a motion scene with less image noise when the average pixel cost parameter is less than a third threshold;
[0285] The fourth judgment module is used to determine that the video frame is in a motion scene with large image noise when the average pixel cost parameter is greater than a fourth threshold, and the third threshold is less than or equal to the fourth threshold.
[0286] Optionally, determining the static coding area in the video frame includes:
[0287] Obtaining a reference video frame of the video frame from the video to be encoded;
[0288] In the reference video frame, determining, by motion search, a second coding region that matches the first coding region of the video frame;
[0289] Determine the difference between the coordinates of the second coding region and the coordinates of the first coding region as a motion vector of the first coding region relative to the second coding region;
[0290] The first coding region whose motion vector is smaller than a fifth threshold is determined as the static coding region.
[0291] Optionally, the device further comprises:
[0292] The first mapping module is used to determine the first threshold and the second threshold according to a preset index parameter adopted by a currently used encoding rule, and the preset index parameter is in direct proportion to the first threshold and the second threshold respectively.
[0293] Optionally, the device further comprises:
[0294] The second mapping module is used to determine the third threshold and the fourth threshold according to the preset index parameter adopted by the currently used encoding rule, and the preset index parameter is in inverse proportion to the third threshold and the fourth threshold respectively.
[0295] Optionally, the adjustment module 402 includes:
[0296] A first basic parameter submodule, used to obtain basic adjustment parameters;
[0297] The adjustment submodule is used to adjust the adjustment intensity value by adjusting the basic adjustment parameter according to the motion scene of the video frame, and the basic adjustment parameter is in inverse proportion to the adjustment intensity value.
[0298] Optionally, the device further comprises:
[0299] A cost parameter acquisition module, used to acquire intra-frame prediction cost parameters and inter-frame prediction cost parameters of the coding region;
[0300] A pre-coding module, used for pre-coding the video frame, and obtaining a reference value parameter of a coding region of the video frame according to the intra-frame prediction cost parameter and the inter-frame prediction cost parameter;
[0301] The calculation module 403 includes:
[0302] A second basic parameter submodule, used to obtain a basic quantization parameter matching the current encoding rule;
[0303] An offset quantum module, used for obtaining a quantization parameter offset of the coding area according to the intra-frame prediction cost parameter, the inter-frame prediction cost parameter, the adjustment strength value and the reference value parameter;
[0304] The correction submodule is used to correct the basic quantization parameter by using the quantization parameter offset to obtain the quantization parameter of the coding area.
[0305] Optionally, the correction submodule includes:
[0306] The difference unit is used to use the difference between the basic quantization parameter and the absolute value of the quantization parameter offset as the quantization parameter of the coding area.
[0307] Optionally, the device further comprises:
[0308] A mapping establishment module, used to obtain a mapping relationship between index parameters and adjustment strength values, and query parameters of the video frame;
[0309] A query module, configured to determine, according to the mapping relationship, an adjustment intensity value matching the query parameter as an adjustment intensity value of the video frame;
[0310] Among them, the index parameters and the query parameters include: the proportion of the number of static coding areas in the video frame in all coding areas of the video frame, the average pixel cost parameter of the static coding areas in the video frame, the target bit rate set for the encoded video, and at least one of the preset index parameters adopted by the currently used encoding rules.
[0311] Optionally, the device further comprises:
[0312] The downsampling module is used to downsample the video frames of the video to be encoded to reduce the resolution of the video frames.
[0313] In summary, in the embodiments of the present application, the motion scene in which the video frame of the video to be encoded is analyzed, the video frame adjustment intensity value can be dynamically adjusted according to the motion scene, and then the size of the quantization parameter of the encoding area can be corrected. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, while satisfying the picture viewing quality of the encoded video and reducing the volume of the encoded video, thereby improving the encoding quality.
[0314] Reference Fig.14 , which shows a block diagram of a video decoding device provided by an embodiment of the present application, including:
[0315] A second acquisition module 501 is used to acquire a coded video, wherein a video frame of the coded video is divided into a plurality of coded areas;
[0316] A decoding module 502 is used to decode the encoded video to obtain a quantization parameter of the encoded region, where the quantization parameter is: an adjustment strength value determined by a motion scene in which a video frame of the encoded video before encoding is located, and a parameter calculated by a reference value parameter obtained by pre-encoding of the encoded region;
[0317] The reconstruction module 503 is used to construct the video to be played according to the quantization parameter of the encoding area.
[0318] In summary, in the embodiments of the present application, the motion scene in which the video frame of the video to be encoded is analyzed, the video frame adjustment intensity value can be dynamically adjusted according to the motion scene, and then the size of the quantization parameter of the encoding area can be corrected. During subsequent encoding, the bit rate and volume of the encoding area can be adjusted according to the quantization parameter of the encoding area, so that the bit rate and volume are optimized on the basis of meeting the viewing requirements under the corresponding motion scene, while satisfying the picture viewing quality of the encoded video and reducing the volume of the encoded video, thereby improving the encoding quality.
[0319] The embodiment of the present application also provides a non-volatile readable storage medium, which stores one or more modules (programs). When the one or more modules are applied to a device, the device can execute instructions (instructions) of each method step in the embodiment of the present application.
[0320] The present application embodiment provides one or more machine-readable media on which instructions are stored, and when executed by one or more processors, an electronic device executes one or more of the methods described in the above embodiments. In the present application embodiment, the electronic device includes various types of devices such as terminal devices and server terminals (clusters).
[0321] The embodiments of the present disclosure may be implemented as a device that uses any appropriate hardware, firmware, software, or any combination thereof to perform desired configurations, and the device may include electronic devices such as terminal devices and server (cluster). Fig.15 An exemplary device 1000 that can be used to implement various embodiments described in the embodiments of the present application is schematically shown.
[0322] For one embodiment, Fig.15 An exemplary apparatus 1000 is shown having one or more processors 1002, a control module (chip set) 1004 coupled to at least one of the (one or more) processors 1002, a memory 1006 coupled to the control module 1004, a non-volatile memory (NVM) / storage device 1008 coupled to the control module 1004, one or more input / output devices 1010 coupled to the control module 1004, and a network interface 1012 coupled to the control module 1004.
[0323] The processor 1002 may include one or more single-core or multi-core processors, and the processor 1002 may include any combination of general-purpose processors or special-purpose processors (such as graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 1000 can be used as a terminal device, a server (cluster), and other devices described in the embodiments of the present application.
[0324] In some embodiments, the apparatus 1000 may include one or more computer-readable media (e.g., memory 1006 or NVM / storage device 1008) having instructions 1014 and one or more processors 1002 combined with the one or more computer-readable media and configured to execute the instructions 1014 to implement a module to perform the actions described in the present disclosure.
[0325] For one embodiment, the control module 1004 may include any suitable interface controller to provide any suitable interface to at least one of the processor(s) 1002 and / or any suitable device or component in communication with the control module 1004 .
[0326] The control module 1004 may include a memory controller module to provide an interface to the memory 1006. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0327] The memory 1006 may be used, for example, to load and store data and / or instructions 1014 for the device 1000. For one embodiment, the memory 1006 may include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the memory 1006 may include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).
[0328] For one embodiment, control module 1004 may include one or more input / output controllers to provide an interface to NVM / storage device 1008 and input / output device(s) 1010 .
[0329] For example, NVM / storage 1008 may be used to store data and / or instructions 1014. NVM / storage 1008 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).
[0330] NVM / storage device 1008 may include storage resources that are physically part of the device on which apparatus 1000 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 1008 may be accessed via input / output device(s) 1010 over a network.
[0331] (One or more) input / output devices 1010 may provide an interface for the apparatus 1000 to communicate with any other appropriate device, and the input / output device 1010 may include a communication component, an audio component, a sensor component, etc. The network interface 1012 may provide an interface for the apparatus 1000 to communicate through one or more networks, and the apparatus 1000 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, for example, accessing a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G, 5G, etc., or a combination thereof for wireless communication.
[0332] For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers (e.g., a memory controller module) of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be packaged together with the logic of one or more controllers of the control module 1004 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004. For one embodiment, at least one of the processor(s) 1002 may be integrated on the same die with the logic of one or more controllers of the control module 1004 to form a system-on-chip (SoC).
[0333] In various embodiments, the device 1000 may be, but is not limited to, a terminal device such as a server, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the device 1000 may have more or fewer components and / or different architectures. For example, in some embodiments, the device 1000 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.
[0334] Among them, the main control chip can be used as a processor or control module in the detection device, sensor data, location information, etc. are stored in a memory or NVM / storage device, the sensor group can be used as an input / output device, and the communication interface may include a network interface.
[0335] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0336] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0337] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0338] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0339] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0340] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0341] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0342] The above is a detailed introduction to a video encoding method, device, electronic device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A video encoding method, characterized in that: include: Acquire a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding regions; According to the motion scene in which the video frame is located, adjusting an adjustment strength value of the video frame, wherein the adjustment strength value is used to control a size of a quantization parameter of a coding area in the video frame; Acquire a quantization parameter of the coding area according to the adjustment strength value of the video frame and a reference value parameter of the coding area obtained by pre-coding the video frame; Encoding the video to be encoded according to the quantization parameter of the encoding area to obtain an encoded video; The method further includes: determining a first threshold and a second threshold according to a preset index parameter adopted by a currently used encoding rule, wherein the preset index parameter is in direct proportion to the first threshold and the second threshold respectively; Determining a static coding region in the video frame; Obtaining a ratio of the number of static coding areas in the video frame to the number of all coding areas in the video frame; When the proportion of the number is greater than a first threshold, determining that the video frame is in a motion scene with a slowly changing picture; When the number ratio is less than a second threshold, it is determined that the video frame is in a motion scene where the picture changes drastically; and the first threshold is greater than or equal to the second threshold; The adjusting the adjustment strength value of the video frame includes: When it is determined that the video frame is in a motion scene with drastic picture changes, reducing the adjustment strength value; When it is determined that the video frame is in a motion scene with slowly changing images, the adjustment strength value is increased.
2. The method according to claim 1, characterized in that: The adjusting the adjustment intensity value of the video frame according to the motion scene in which the video frame is located also includes: When it is determined that the video frame is in a motion scene with drastic picture changes or in a motion scene with large image noise, reducing the adjustment strength value; When it is determined that the video frame is in a motion scene with a slowly changing picture and a motion scene with less image noise, the adjustment strength value is increased.
3. The method according to any one of claims 1 to 2, characterized in that: The adjustment strength value is in inverse proportion to the quantization parameter.
4. The method according to claim 1 or 2, characterized in that: The increasing the adjustment strength value comprises: Adding the current adjustment strength value to the preset adjustment threshold value to obtain an increased adjustment strength value; The reducing the adjustment strength value comprises: The current adjustment strength value is subtracted from the preset adjustment threshold to obtain a reduced adjustment strength value.
5. The method according to claim 2, characterized in that: The method further comprises: Determining a static coding region in the video frame; Obtaining a pixel cost parameter of a static coding region; the pixel cost parameter is used to reflect: a similarity between a coding region corresponding to the static coding region in a reference video frame of the video frame and the static coding region; the pixel cost parameter is more negatively correlated with the similarity; According to the pixel cost parameter of the static coding area, obtaining the average pixel cost parameter of all static coding areas in the video frame; When the average pixel cost parameter is less than a third threshold, determining that the video frame is in a motion scene with less image noise; When the average pixel cost parameter is greater than a fourth threshold, it is determined that the video frame is in a motion scene with relatively large image noise, and the third threshold is less than or equal to the fourth threshold.
6. The method according to claim 5, characterized in that: The determining of the static coding area in the video frame comprises: Obtaining a reference video frame of the video frame from the video to be encoded; In the reference video frame, determining, by motion search, a second coding region that matches the first coding region of the video frame; Determine the difference between the coordinates of the second coding region and the coordinates of the first coding region as a motion vector of the first coding region relative to the second coding region; The first coding region whose motion vector is smaller than a fifth threshold is determined as the static coding region.
7. The method according to claim 5, characterized in that: The method further comprises: The third threshold and the fourth threshold are determined according to a preset index parameter adopted by the currently used encoding rule, and the preset index parameter is in inverse proportion to the third threshold and the fourth threshold respectively.
8. A video decoding method, characterized in that: include: Acquire a coded video, wherein a video frame of the coded video is divided into a plurality of coded areas; Decoding the encoded video to obtain a quantization parameter of the encoded region, wherein the quantization parameter is: an adjustment strength value determined by a motion scene in which a video frame of the encoded video before encoding is located, and a parameter calculated by a reference value parameter obtained by pre-encoding the encoded region; Constructing a video to be played according to the quantization parameters of the encoding area; Wherein, determining the adjustment strength value comprises: when it is determined that the video frame is in a motion scene with a drastic picture change, reducing the adjustment strength value; when it is determined that the video frame is in a motion scene with a slow picture change, increasing the adjustment strength value; Determining the motion scene in which the video frame is located includes: determining a static coding area in the video frame; obtaining the ratio of the static coding area in the video frame to all coding areas in the video frame; when the ratio is greater than a first threshold, determining that the video frame is in a motion scene in which the picture changes slowly; when the ratio is less than a second threshold, determining that the video frame is in a motion scene in which the picture changes drastically; the first threshold is greater than or equal to the second threshold; determining the first threshold and the second threshold according to a preset index parameter adopted by a currently used coding rule, the preset index parameter being in direct proportion to the first threshold and the second threshold, respectively.
9. A video encoding device, characterized in that: include: A first acquisition module is used to acquire a video to be encoded, wherein a video frame of the video to be encoded is divided into a plurality of encoding regions; An adjustment module, used for adjusting an adjustment strength value of the video frame according to a motion scene in which the video frame is located, wherein the adjustment strength value is used for controlling a size of a quantization parameter of a coding area in the video frame; A calculation module, configured to obtain a quantization parameter of the coding area according to the adjustment strength value of the video frame and a reference value parameter of the coding area obtained by pre-coding the video frame; An encoding module, used for encoding the video to be encoded according to the quantization parameter of the encoding area to obtain an encoded video; A first adjustment submodule, configured to reduce the adjustment strength value when it is determined that the video frame is in a motion scene with drastic picture changes; A second adjustment submodule, configured to increase the adjustment strength value when it is determined that the video frame is in a motion scene with a slowly changing picture; A first determination module, used to determine a static coding area in the video frame; A proportion module, used to obtain the proportion of the static coding area in the video frame to all the coding areas in the video frame; A first judgment module is used to determine that the video frame is in a motion scene with a slowly changing picture when the proportion of the number is greater than a first threshold; A second judgment module is used to determine that the video frame is in a motion scene with drastic picture changes when the number ratio is less than a second threshold; the first threshold is greater than or equal to the second threshold; The first mapping module is used to determine the first threshold and the second threshold according to a preset index parameter adopted by a currently used encoding rule, and the preset index parameter is in direct proportion to the first threshold and the second threshold respectively.
10. A video decoding device, characterized in that: include: A second acquisition module is used to acquire a coded video, wherein a video frame of the coded video is divided into a plurality of coded areas; A decoding module, used for decoding the encoded video to obtain a quantization parameter of the encoded region, wherein the quantization parameter is: an adjustment strength value determined by a motion scene in which a video frame of the encoded video before encoding is located, and a parameter calculated by a reference value parameter obtained by pre-encoding of the encoded region; A reconstruction module, used for constructing a video to be played according to the quantization parameters of the encoding area; Wherein, determining the adjustment strength value comprises: when it is determined that the video frame is in a motion scene with a drastic picture change, reducing the adjustment strength value; when it is determined that the video frame is in a motion scene with a slow picture change, increasing the adjustment strength value; Determining the motion scene in which the video frame is located includes: determining a static coding area in the video frame; obtaining the ratio of the static coding area in the video frame to all coding areas in the video frame; when the ratio is greater than a first threshold, determining that the video frame is in a motion scene in which the picture changes slowly; when the ratio is less than a second threshold, determining that the video frame is in a motion scene in which the picture changes drastically; the first threshold is greater than or equal to the second threshold; determining the first threshold and the second threshold according to a preset index parameter adopted by a currently used coding rule, the preset index parameter being in direct proportion to the first threshold and the second threshold, respectively.
11. An electronic device, characterized in that: include: processor; and A memory having executable codes stored thereon, which, when executed, enables the processor to execute the video encoding method according to any one of claims 1 to 7.
12. A machine-readable storage medium having executable codes stored thereon, which, when executed, causes a processor to execute the video encoding method according to any one of claims 1 to 7.
