Video encoding method, device, computer equipment, readable storage medium and program product
By preprocessing blocks of video frames and generating probability tables for statistical frames, the problem of inconsistency between the video encoding method in hardware and the processing order of the hardware pipeline is solved, and block-level pipeline hardware implementation is realized, improving video quality and compression rate.
Patent Information
- Application Number
- CN202411027221.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-30
AI Technical Summary
The existing video encoding method cannot be implemented in hardware because its processing sequence is inconsistent with the block-based processing sequence of the pipeline implementation in the hardware, resulting in the inability to effectively encode in the hardware.
By preprocessing each block of the target video frame, determining its corresponding statistical frame, and using a preset counting algorithm to generate a probability table, entropy encoding is performed on the blocks to achieve block-based preprocessing and entropy encoding, adapting to the hardware Pipeline processing sequence.
It implements video encoding in hardware in a block-level pipeline manner, improves video quality and compression rate, reduces video encoding time, and speeds up encoding.
Smart Images

Figure CN118573876B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing technology, and in particular to a video encoding method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of computer technology, video applications are being applied to more and more fields. The P frame encoding process of the reference software of the VP9 / SVAC2 standard first transforms, quantizes, and tokenizes the entire frame image data, and then forms a set of probability tables based on the processing results of the entire frame image. This set of probability tables is used to perform entropy encoding of the entire frame image. Therefore, in order to obtain the probability table used for entropy encoding, the relevant video encoding method needs to transform, quantize, and tokenize the entire frame image first.
[0003] However, in hardware implementation, a pipeline implementation is usually adopted, with blocks as units. This is different from the processing order of related video encoding methods. Therefore, the related video encoding methods cannot be implemented in hardware. Summary of the invention
[0004] Based on this, it is necessary to provide a video encoding method, apparatus, computer device, computer-readable storage medium and computer program product that can be implemented in hardware to address the above technical problems.
[0005] In a first aspect, the present application provides a video encoding method, comprising:
[0006] For each block in a target video frame of a target video, preprocessing the block to obtain a preprocessing result of the block;
[0007] In the case where the target video frame is a P frame and is not the first P frame of each I frame interval, determining a statistical frame corresponding to the target video frame; the statistical frame is located before the target video frame;
[0008] Using a preset counting algorithm, counting each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame, and generating a probability table of the statistical frame according to the counting result;
[0009] The block is entropy encoded according to the preprocessing result of the block and the probability table of the statistical frame.
[0010] In one of the embodiments, determining the statistical frame corresponding to the target video frame includes:
[0011] The previous frame of the target video frame is used as a statistical frame corresponding to the target video frame.
[0012] In one of the embodiments, determining the statistical frame corresponding to the target video frame includes:
[0013] A first number of video frames that are before the target video frame and are spaced apart from the target video frame are used as statistical frames corresponding to the target video frame.
[0014] In one of the embodiments, determining the statistical frame corresponding to the target video frame includes:
[0015] Determining each video frame group of the target video according to a preset probability table update interval;
[0016] The previous video frame group of the video frame group where the target video frame is located is used as the statistical frame group corresponding to the target video frame;
[0017] The first video frame in the statistical frame group, or the video frames in the statistical frame group that are spaced a second number apart from the first video frame, are used as statistical frames corresponding to the target video frame.
[0018] In one embodiment, the method further comprises:
[0019] When the target video frame is an I frame or the first P frame of each I frame interval, entropy encoding is performed on the block according to the preprocessing result of the block and a preset probability table; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0020] In one embodiment, the using of a preset counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame includes:
[0021] A 32-bit unsigned integer counting algorithm is adopted to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0022] In a second aspect, the present application further provides a video encoding device, including:
[0023] A preprocessing module, used for preprocessing each block in a target video frame of a target video to obtain a preprocessing result of the block;
[0024] A first determining module is used to determine a statistical frame corresponding to the target video frame when the target video frame is a P frame and is not the first P frame of each I frame interval; the statistical frame is located before the target video frame;
[0025] A generating module, configured to use a preset counting algorithm to count each encoded syntax element of the statistical frame, obtain a counting result corresponding to the statistical frame, and generate a probability table of the statistical frame according to the counting result;
[0026] The first entropy coding module is used to perform entropy coding on the block according to the preprocessing result of the block and the probability table of the statistical frame.
[0027] In one embodiment, the first determining module is specifically configured to:
[0028] The previous frame of the target video frame is used as a statistical frame corresponding to the target video frame.
[0029] In one embodiment, the first determining module is specifically configured to:
[0030] A first number of video frames that are before the target video frame and are spaced apart from the target video frame are used as statistical frames corresponding to the target video frame.
[0031] In one embodiment, the first determining module is specifically configured to:
[0032] Determining each video frame group of the target video according to a preset probability table update interval;
[0033] The previous video frame group of the video frame group where the target video frame is located is used as the statistical frame group corresponding to the target video frame;
[0034] The first video frame in the statistical frame group, or the video frames in the statistical frame group that are spaced a second number apart from the first video frame, are used as statistical frames corresponding to the target video frame.
[0035] In one embodiment, the device further comprises:
[0036] The second entropy coding module is used to perform entropy coding on the block according to the preprocessing result of the block and a preset probability table when the target video frame is an I frame or the first P frame of each I frame interval; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0037] In one embodiment, the generating module is specifically used for:
[0038] A 32-bit unsigned integer counting algorithm is adopted to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0039] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps described in the first aspect when executing the computer program.
[0040] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps described in the first aspect above.
[0041] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which implements the steps described in the first aspect when executed by a processor.
[0042] The above-mentioned video encoding method, apparatus, computer equipment, computer-readable storage medium and computer program product, for each block in the target video frame of the target video, preprocess the block to obtain the preprocessing result of the block; when the target video frame is a P frame and is not the first P frame of each I frame interval, determine the statistical frame corresponding to the target video frame; the statistical frame is located before the target video frame; a preset counting algorithm is used to count the syntax elements of each encoding of the statistical frame to obtain the counting result corresponding to the statistical frame, and a probability table of the statistical frame is generated according to the counting result; according to the preprocessing result of the block and the probability table of the statistical frame, entropy coding is performed on the block. In this way, the probability table calculated based on the counting of the statistical frame located before the target video frame is used for entropy coding of the block of the target video frame, and the probability table required for entropy coding of the block is obtained. It is not necessary to wait for the preprocessing of the entire frame image of the target video frame to be completed, and the preprocessing and entropy coding are performed simultaneously in units of blocks. This is the same as the implementation method of using pipelines in hardware implementation, and the processing order is based on blocks. It can be implemented in hardware and can be implemented in hardware according to pipelines at the block level. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0044] FIG1 is a schematic diagram of a flow chart of a video encoding method in one embodiment;
[0045] FIG2 is a schematic diagram of a video encoding process in one embodiment;
[0046] FIG3 is a schematic diagram of a video encoding process in another embodiment;
[0047] FIG4 is a schematic flow chart of a step of determining a statistical frame corresponding to a target video frame in one embodiment;
[0048] FIG5 is a schematic diagram of a video encoding process in another embodiment;
[0049] FIG6 is a structural block diagram of a video encoding device in one embodiment;
[0050] FIG. 7 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0052] In one embodiment, as shown in FIG1 , a video encoding method is provided. This embodiment uses the method applied to a terminal as an example. It is understandable that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, projection devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services. In this embodiment, the method includes the following steps:
[0053] Step 101 , preprocessing is performed on each block in a target video frame of a target video to obtain a preprocessing result of the block.
[0054] In an embodiment of the present application, for each block in the target video frame of the target video, the terminal exchanges, quantizes and tokenizes the block in turn to obtain a preprocessing result of the block. The preprocessing result may include the grammatical information to be entropy encoded and / or the count of the grammatical information to be encoded (bin), or may not include the grammatical information to be entropy encoded and / or the count of the grammatical information to be encoded (bin). It is understandable that any algorithm that can preprocess each block in the target video frame of the target video and obtain the preprocessing result of the block can be used in step 101, and this application is not limited thereto.
[0055] Step 102: When the target video frame is a P frame and is not the first P frame of each I frame interval, determine a statistical frame corresponding to the target video frame.
[0056] The statistical frame is located before the target video frame.
[0057] In the embodiment of the present application, a P frame is a forward predictive-coded frame, and an I frame is an intra-coded frame. The statistical frame corresponding to the target video frame is the P frame located before the target video frame. The statistical frame provides a reference for the probability table according to which the blocks in the target video frame are entropy-coded. The statistical frames corresponding to different target video frames may be different or the same.
[0058] Step 103: Using a preset counting algorithm, count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame, and generate a probability table of the statistical frame according to the counting result.
[0059] In the embodiment of the present application, the counting algorithm may be a 16-bit counting algorithm. It is understood that any algorithm capable of generating a probability table of a statistical frame based on the counting result may be used in step 103, and the present application does not limit this. The probability table of the statistical frame is a probability table generated based on the counting result corresponding to the statistical frame, and is used for entropy coding of other video frames.
[0060] Specifically, while entropy encoding the statistical frame, the terminal uses a preset counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame. After entropy encoding the statistical frame is completed, the terminal generates a probability table of the statistical frame according to the counting result. For example, at the beginning or before encoding the target video frame, the terminal can generate a probability table of the statistical frame according to the counting result.
[0061] Step 104: perform entropy coding on the block according to the preprocessing result of the block and the probability table of the statistical frame.
[0062] In the embodiment of the present application, the probability table of the statistical frame is a probability table for entropy coding the block in the target video frame. It is understandable that any algorithm that can entropy code the block according to the preprocessing result of the block and the probability table of the target video frame can be used in step 104, and the present application does not limit it.
[0063] In the above video encoding method, for each block in the target video frame of the target video, the block is preprocessed to obtain the preprocessing result of the block; when the target video frame is a P frame and is not the first P frame of each I frame interval, the statistical frame corresponding to the target video frame is determined; the statistical frame is located before the target video frame; a preset counting algorithm is used to count the syntax elements of each encoding of the statistical frame to obtain the counting result corresponding to the statistical frame, and a probability table of the statistical frame is generated according to the counting result; according to the preprocessing result of the block and the probability table of the statistical frame, the block is entropy encoded. In this way, the probability table calculated based on the counting of the statistical frame located before the target video frame is used for the entropy encoding of the block of the target video frame, and the probability table required for the entropy encoding of the block is obtained. It is not necessary to wait for the preprocessing of the entire frame image of the target video frame to be completed, and the preprocessing and entropy encoding are carried out simultaneously in units of blocks. This is the same as the implementation method of the pipeline in the hardware implementation, and the processing order in units of blocks is the same, which can be implemented in hardware and can be implemented in hardware according to the pipeline at the block level.
[0064] In an exemplary embodiment, the specific process of step 102 includes the following steps: taking the previous frame of the target video frame as the statistical frame corresponding to the target video frame.
[0065] In the embodiment of the present application, the target video frame is the Nth frame, and the statistical frame corresponding to the target video frame is the N-1th frame, where N is a positive integer. The terminal uses the N-1th frame as the statistical frame corresponding to the Nth frame.
[0066] In one embodiment, the process of video encoding is shown in FIG2. The terminal uses the updated probability table generated based on the counting result corresponding to the N-1 frame to entropy encode the N frame, and counts the syntax symbols of the N frame to obtain the counting result corresponding to the N frame. Then, the terminal generates an updated probability table based on the counting result corresponding to the N frame. Then, the terminal uses the updated probability table generated based on the counting result corresponding to the N frame to entropy encode the N+1 frame, and counts the syntax symbols of the N+1 frame to obtain the counting result corresponding to the N+1 frame. And so on.
[0067] In the above-mentioned video encoding method, the probability table calculated based on the count of the previous frame of the target video frame is approximated as a probability table calculated based on the count of the target video frame, which is used for entropy encoding of blocks of the target video frame, and the statistical frame is adjacent to the target video frame. While the method is implemented in hardware according to the pipeline at the block level, it can improve the video quality at the same compression rate and the compression rate at the same video quality.
[0068] In an exemplary embodiment, the specific process of step 102 includes the following steps: taking a preset first number of video frames before the target video frame and spaced apart from the target video frame as statistical frames corresponding to the target video frame.
[0069] In the embodiment of the present application, the first number may be an integer greater than 0. The first number may be 1. The target video frame is the Nth frame, and the statistical frame corresponding to the target video frame is the Nith frame, where N is a positive integer and i is a positive integer greater than 1. The terminal uses the Nith frame as the statistical frame corresponding to the Nth frame.
[0070] In one example, while generating a probability table based on the counting result corresponding to the Nth frame, the terminal also uses the probability table generated based on the counting result corresponding to the N-i+1th frame, entropy encodes the N+1th frame, and counts the syntax symbols of the N+1th frame to obtain the counting result corresponding to the N+1th frame.
[0071] In one embodiment, the process of video encoding is shown in FIG3. i is 2. The terminal generates an updated probability table based on the counting result corresponding to the N-1th frame. At the same time, the terminal uses the probability table generated based on the counting result corresponding to the N-2th frame to entropy encode the Nth frame, and counts the syntax symbols of the Nth frame to obtain the counting result corresponding to the Nth frame. Then, the terminal generates an updated probability table based on the counting result corresponding to the Nth frame. At the same time, the terminal uses the probability table generated based on the counting result corresponding to the N-1th frame to entropy encode the N+1th frame, and counts the syntax symbols of the N+1th frame to obtain the counting result corresponding to the N+1th frame. Then, the terminal generates an updated probability table based on the counting result corresponding to the N+1th frame. At the same time, the terminal uses the probability table generated based on the counting result corresponding to the Nth frame to entropy encode the N+2th frame, and counts the syntax symbols of the N+2th frame to obtain the counting result corresponding to the N+2th frame. And so on.
[0072] In the above-mentioned video encoding method, the probability table calculated based on the count of the video frames before the target video frame and with a preset first number of intervals between the target video frame and the target video frame is approximated as the probability table calculated based on the count of the target video frame, and is used for entropy encoding of the block of the target video frame. There is at least one video frame interval between the statistical frame and the target video frame. The software calculation of the probability table can be carried out in parallel with the hardware encoding of the image, so that the software and hardware parallel of the probability table update and the image encoding are realized, and the extra time consumption of the software calculation of the probability table is not required, and the encoding of the next frame of the hardware is not affected, which can reduce the video encoding time and speed up the video encoding speed. In addition, the method can update the probability table of the current frame and use it for entropy encoding of the next frame, which can not only reduce the video encoding time and speed up the video encoding speed, but also make the statistical frame used for approximation closer to the target video frame, and can also improve the video quality at the same compression rate and the compression rate at the same video quality.
[0073] In an exemplary embodiment, as shown in FIG4 , step 102 includes steps 401 to 403. Among them:
[0074] Step 401, determining each video frame group of the target video according to a preset probability table update interval.
[0075] In an embodiment of the present application, the terminal uses each preset probability table update interval video frames as a video frame group of the target video. The probability table update interval is the interval between every two statistical frames, which is the interval between video frames for probability table update. A video frame group includes at least two video frames, and the video frames in each video frame group correspond to the same statistical frames.
[0076] Step 402: The previous video frame group of the video frame group in which the target video frame is located is used as the statistical frame group corresponding to the target video frame.
[0077] Step 403: Use the first video frame in the statistical frame group, or the video frames in the statistical frame group that are spaced apart from the first video frame by a preset second number, as the statistical frame corresponding to the target video frame.
[0078] In an embodiment of the present application, the statistical frame group is a video frame group in which the statistical frame corresponding to the target video frame is located. The second number is an integer greater than or equal to 0 and less than the probability table update interval-1. The statistical frame can be the first video frame in the statistical frame group, or it can be a video frame after the first video frame in the statistical frame group. The probability table update interval is n frames, and the Nth frame and the N+nth frame are both the first video frame in the video frame group, and n is a positive integer.
[0079] In one example, the terminal generates a probability table based on the counting result corresponding to a certain frame from the Nth frame to the N+n-1th frame. Then, the terminal performs entropy coding on the N+nth frame to the N+2n-1th frame using the probability table generated based on the counting result corresponding to a certain frame from the Nth frame to the N+n-1th frame.
[0080] In one embodiment, the process of video encoding is shown in FIG5. The terminal uses a probability table generated based on the counting result corresponding to a certain frame from the Nnth frame to the N-1th frame to entropy encode the Nth frame, and counts the syntax symbols of the Nth frame. Then, the terminal uses a probability table generated based on the counting result corresponding to a certain frame from the Nnth frame to the N-1th frame to entropy encode the N+1th frame to the N+n-1th frame, and counts the syntax symbols of the N+1th frame to the N+n-1th frame. At the same time, the terminal generates a probability table based on the counting result corresponding to a certain frame from the Nth frame to the N+n-1th frame. Then, the terminal uses a probability table generated based on the counting result corresponding to a certain frame from the Nth frame to the N+n-1th frame to entropy encode the N+nth frame, and counts the syntax symbols of the N+nth frame. And so on.
[0081] In the above video encoding method, each video frame group of the target video is determined according to a preset probability table update interval; the previous video frame group of the video frame group in which the target video frame is located is used as the statistical frame group corresponding to the target video frame; the first video frame in the statistical frame group, or the video frame in the statistical frame group with a preset second number of intervals from the first video frame, is used as the statistical frame corresponding to the target video frame. In this way, the probability table is calculated and updated once every n frames, and the n video frames in each video frame group use the probability table generated based on one statistical frame, which can further reduce the overhead of probability table calculation, achieve a compromise between the amount of calculation and the encoding quality or compression rate, and reduce the amount of calculation while ensuring the encoding quality and compression rate.
[0082] In an exemplary embodiment, the method further includes the following steps: when the target video frame is an I frame or the first P frame of each I frame interval, entropy encoding the block according to the preprocessing result of the block and a preset probability table.
[0083] Among them, the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0084] In the above-mentioned video encoding method, when the target video frame is an I frame, or the first P frame of each I frame interval, entropy encoding is performed on the block according to the preprocessing result of the block and the preset probability table. Entropy encoding of the I frame and the first P frame of each I frame interval does not have to wait until operations such as transformation / quantization of the entire frame image are completed, and can be performed simultaneously at the block level according to the pipeline, and can be implemented in hardware at the block level according to the pipeline.
[0085] In an exemplary embodiment, the specific process of step 103 includes the following steps: using a 32-bit unsigned integer counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0086] In the above video encoding method, a 32-bit unsigned integer counting algorithm is used to count each encoded syntax element of the statistical frame, and then generate a probability table. Compared with other counting algorithms, this method can count all possible values, avoid the occurrence of counting saturation, and achieve a compromise between storage capacity and compression rate.
[0087] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0088] Based on the same inventive concept, the embodiment of the present application also provides a video encoding device for implementing the above-mentioned video encoding method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in the one or more video encoding device embodiments provided below can refer to the above-mentioned limitations on the video encoding method, and will not be repeated here.
[0089] In an exemplary embodiment, as shown in FIG6 , a video encoding apparatus 600 is provided, comprising: a preprocessing module 610, a first determining module 620, a generating module 630 and a first entropy encoding module 640, wherein:
[0090] A preprocessing module 610 is used to preprocess each block in a target video frame of a target video to obtain a preprocessing result of the block;
[0091] A first determining module 620 is configured to determine a statistical frame corresponding to the target video frame when the target video frame is a P frame and is not the first P frame of each I frame interval; the statistical frame is located before the target video frame;
[0092] A generating module 630 is used to count each coded syntax element of the statistical frame by using a preset counting algorithm to obtain a counting result corresponding to the statistical frame, and generate a probability table of the statistical frame according to the counting result;
[0093] The first entropy coding module 640 is used to perform entropy coding on the block according to the preprocessing result of the block and the probability table of the statistical frame.
[0094] Optionally, the first determining module 620 is specifically configured to:
[0095] The previous frame of the target video frame is used as a statistical frame corresponding to the target video frame.
[0096] Optionally, the first determining module 620 is specifically configured to:
[0097] A first number of video frames that are before the target video frame and are spaced apart from the target video frame are used as statistical frames corresponding to the target video frame.
[0098] Optionally, the first determining module 620 is specifically configured to:
[0099] Determining each video frame group of the target video according to a preset probability table update interval;
[0100] The previous video frame group of the video frame group where the target video frame is located is used as the statistical frame group corresponding to the target video frame;
[0101] The first video frame in the statistical frame group, or the video frames in the statistical frame group that are spaced a second number apart from the first video frame, are used as statistical frames corresponding to the target video frame.
[0102] Optionally, the device 600 further includes:
[0103] The second entropy coding module is used to perform entropy coding on the block according to the preprocessing result of the block and a preset probability table when the target video frame is an I frame or the first P frame of each I frame interval; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0104] Optionally, the generating module 630 is specifically configured to:
[0105] A 32-bit unsigned integer counting algorithm is adopted to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0106] Each module in the above video encoding device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0107] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG7. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, a near field communication (NFC) or other technologies. When the computer program is executed by the processor, a video encoding method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0108] Those skilled in the art will understand that the structure shown in FIG. 7 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0109] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0110] For each block in a target video frame of a target video, preprocessing the block to obtain a preprocessing result of the block;
[0111] In the case where the target video frame is a P frame and is not the first P frame of each I frame interval, determining a statistical frame corresponding to the target video frame; the statistical frame is located before the target video frame;
[0112] Using a preset counting algorithm, counting each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame, and generating a probability table of the statistical frame according to the counting result;
[0113] The block is entropy encoded according to the preprocessing result of the block and the probability table of the statistical frame.
[0114] In one embodiment, when the processor executes the computer program, the following steps are further implemented: using a frame preceding the target video frame as a statistical frame corresponding to the target video frame.
[0115] In one embodiment, when the processor executes the computer program, the following steps are further implemented: a first number of video frames that are before the target video frame and are spaced apart from the target video frame are used as statistical frames corresponding to the target video frame.
[0116] In one embodiment, the processor further implements the following steps when executing the computer program: determining each video frame group of the target video according to a preset probability table update interval; using the previous video frame group of the video frame group in which the target video frame is located as the statistical frame group corresponding to the target video frame; using the first video frame in the statistical frame group, or the video frames in the statistical frame group that are preset a second number apart from the first video frame, as the statistical frame corresponding to the target video frame.
[0117] In one embodiment, when the processor executes the computer program, the following steps are also implemented: when the target video frame is an I frame, or the first P frame of each I frame interval, entropy encoding is performed on the block according to the preprocessing result of the block and a preset probability table; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0118] In one embodiment, when the processor executes the computer program, the following steps are further implemented: using a 32-bit unsigned integer counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0119] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0120] For each block in a target video frame of a target video, preprocessing the block to obtain a preprocessing result of the block;
[0121] In the case where the target video frame is a P frame and is not the first P frame of each I frame interval, determining a statistical frame corresponding to the target video frame; the statistical frame is located before the target video frame;
[0122] Using a preset counting algorithm, counting each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame, and generating a probability table of the statistical frame according to the counting result;
[0123] The block is entropy encoded according to the preprocessing result of the block and the probability table of the statistical frame.
[0124] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: using a frame preceding the target video frame as a statistical frame corresponding to the target video frame.
[0125] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: a first number of video frames that are before the target video frame and are spaced apart from the target video frame are used as statistical frames corresponding to the target video frame.
[0126] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: determining each video frame group of the target video according to a preset probability table update interval; using the previous video frame group of the video frame group in which the target video frame is located as the statistical frame group corresponding to the target video frame; using the first video frame in the statistical frame group, or the video frames in the statistical frame group that are preset a second number apart from the first video frame, as the statistical frame corresponding to the target video frame.
[0127] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: when the target video frame is an I frame, or the first P frame of each I frame interval, entropy encoding is performed on the block according to the preprocessing result of the block and a preset probability table; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0128] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: using a 32-bit unsigned integer counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0129] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0130] For each block in a target video frame of a target video, preprocessing the block to obtain a preprocessing result of the block;
[0131] In the case where the target video frame is a P frame and is not the first P frame of each I frame interval, determining a statistical frame corresponding to the target video frame; the statistical frame is located before the target video frame;
[0132] Using a preset counting algorithm, counting each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame, and generating a probability table of the statistical frame according to the counting result;
[0133] The block is entropy encoded according to the preprocessing result of the block and the probability table of the statistical frame.
[0134] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: using a frame preceding the target video frame as a statistical frame corresponding to the target video frame.
[0135] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented: a first number of video frames that are before the target video frame and are spaced apart from the target video frame are used as statistical frames corresponding to the target video frame.
[0136] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: determining each video frame group of the target video according to a preset probability table update interval; using the previous video frame group of the video frame group in which the target video frame is located as the statistical frame group corresponding to the target video frame; using the first video frame in the statistical frame group, or the video frames in the statistical frame group that are preset a second number apart from the first video frame, as the statistical frame corresponding to the target video frame.
[0137] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: when the target video frame is an I frame, or the first P frame of each I frame interval, entropy encoding is performed on the block according to the preprocessing result of the block and a preset probability table; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
[0138] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: using a 32-bit unsigned integer counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0140] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0141] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0142] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A video encoding method, characterized in that: The method comprises: For each block in a target video frame of a target video, preprocessing the block to obtain a preprocessing result of the block; In the case where the target video frame is a P frame and is not the first P frame of each I frame interval, determining a statistical frame corresponding to the target video frame; the statistical frame is located before the target video frame; Using a preset counting algorithm, counting each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame, and generating a probability table of the statistical frame according to the counting result; Performing entropy coding on the block according to the preprocessing result of the block and the probability table of the statistical frame; Wherein, determining the statistical frame corresponding to the target video frame includes: Using the previous frame of the target video frame as the statistical frame corresponding to the target video frame; or Using a preset first number of video frames before the target video frame and spaced apart from the target video frame as statistical frames corresponding to the target video frame; or According to a preset probability table update interval, each video frame group of the target video is determined; the previous video frame group of the video frame group in which the target video frame is located is used as the statistical frame group corresponding to the target video frame; the first video frame in the statistical frame group, or the video frames in the statistical frame group that are preset to a second number apart from the first video frame, are used as the statistical frame corresponding to the target video frame.
2. The method according to claim 1, characterized in that: The method further comprises: When the target video frame is an I frame or the first P frame of each I frame interval, entropy encoding is performed on the block according to the preprocessing result of the block and a preset probability table; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
3. The method according to claim 1, characterized in that The adopting a preset counting algorithm to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame includes: A 32-bit unsigned integer counting algorithm is adopted to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
4. The method according to claim 1, characterized in that: The first number is 1.
5. A video encoding device, characterized in that: The device comprises: A preprocessing module, used for preprocessing each block in a target video frame of a target video to obtain a preprocessing result of the block; A first determining module is used to determine a statistical frame corresponding to the target video frame when the target video frame is a P frame and is not the first P frame of each I frame interval; the statistical frame is located before the target video frame; A generating module, configured to use a preset counting algorithm to count each encoded syntax element of the statistical frame, obtain a counting result corresponding to the statistical frame, and generate a probability table of the statistical frame according to the counting result; A first entropy coding module, configured to perform entropy coding on the block according to a preprocessing result of the block and a probability table of the statistical frame; Wherein, the first determining module is specifically used to: Using the previous frame of the target video frame as the statistical frame corresponding to the target video frame; or Using a preset first number of video frames before the target video frame and spaced apart from the target video frame as statistical frames corresponding to the target video frame; or According to a preset probability table update interval, each video frame group of the target video is determined; the previous video frame group of the video frame group in which the target video frame is located is used as the statistical frame group corresponding to the target video frame; the first video frame in the statistical frame group, or the video frames in the statistical frame group that are preset to a second number apart from the first video frame, are used as the statistical frame corresponding to the target video frame.
6. The device according to claim 5, characterized in that The device also includes: The second entropy coding module is used to perform entropy coding on the block according to the preprocessing result of the block and a preset probability table when the target video frame is an I frame or the first P frame of each I frame interval; the probability corresponding to each symbol in the preset probability table is a fixed constant value.
7. The device according to claim 5, characterized in that The generation module is specifically used for: A 32-bit unsigned integer counting algorithm is adopted to count each encoded syntax element of the statistical frame to obtain a counting result corresponding to the statistical frame.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Video encoding method and device, computer equipment and storage medium
CN112203096A
Video coding method and device, equipment, storage medium and program product
CN116939216A
