Method for determining coding information of coding block and related products
By utilizing the correlation between video frames and skipping unnecessary encoding information traversal, the video encoding speed is improved and the problem of slow encoding speed in the existing technology is solved.
Patent Information
- Application Number
- CN202311277999.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2043-09-28
AI Technical Summary
When existing video compression technology determines the coding information of each coding block of each video frame in the video, it needs to traverse all the coding information, resulting in a reduction in coding speed.
By utilizing the coding information of the corresponding coding block of the reference frame of the current frame and the coding information of the neighboring coding blocks of the corresponding coding block, traversal of some coding information is skipped to determine the coding information of the coding block.
It effectively increases the encoding speed without reducing the video quality.
Smart Images

Figure CN117596392B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video coding technology, and in particular to a method for determining coding information of a coding block and related products. Background Art
[0002] As network-based video applications become more common, modern devices and network infrastructure have jointly promoted the rapid growth of high-resolution and low-latency video content, such as video on demand, real-time streaming, and screen sharing. The application forms of these video contents have created a strong demand for efficient video compression technology. At present, when determining the encoding information of each encoding block of each video frame in the video, the existing video compression technology will traverse all the encoding information to determine it. This method of determining the encoding information will reduce the video encoding speed. Summary of the invention
[0003] An embodiment of the present application provides a method for determining coding information of a coding block and related products, which skips traversal of some coding information by utilizing the coding information of the corresponding coding block of the reference frame of the current frame and the coding information of the neighboring coding blocks of the corresponding coding block to improve the coding speed.
[0004] In a first aspect, an embodiment of the present application provides a method for determining coding information of a coding block, the method comprising:
[0005] The j-th video frame is divided into a plurality of coding blocks, wherein the j-th video frame is any one of the video frames in the video to be encoded; when the j-th video frame has a corresponding reference frame, the coding information of the n-th coding block is determined based on the coding information of the corresponding coding block of the n-th coding block in the reference frame and the coding information of the first neighboring coding block of the corresponding coding block, wherein the n-th coding block is any one of the plurality of coding blocks.
[0006] In a second aspect, an embodiment of the present application provides a device for determining coding information of a coding block, the device comprising: a transceiver unit and a processing unit;
[0007] The transceiver unit is used to obtain the video to be encoded;
[0008] The processing unit is used to divide the j-th video frame into multiple coding blocks, wherein the j-th video frame is any one of the video frames in the video to be encoded; the processing unit is used to determine the coding information of the n-th coding block based on the coding information of the corresponding coding block of the n-th coding block in the reference frame and the coding information of the first neighboring coding block of the corresponding coding block when there is a corresponding reference frame for the j-th video frame, wherein the n-th coding block is any one of the multiple coding blocks.
[0009] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the electronic device executes the method of the first aspect.
[0010] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method of the first aspect.
[0011] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is computer-operable to cause the computer to execute the method of the first aspect.
[0012] Implementing the embodiments of the present application has the following beneficial effects:
[0013] It can be seen that in the embodiment of the present application, the jth video frame is divided into multiple coding blocks, wherein the jth video frame is any one of the video frames in the video to be encoded; and the nth coding block is any one of the multiple coding blocks. When determining the coding information of the nth coding block, it is not to directly traverse all the coding information to obtain the coding information of the nth coding block, but to determine the coding information of the nth coding block based on the correlation between adjacent video frames. Specifically, when there is a corresponding reference frame for the jth video frame, the prediction mode of the nth coding block is determined based on the prediction mode of the corresponding coding block of the nth coding block in the reference frame and the prediction mode of the first neighboring coding block of the corresponding coding block. It should be noted that the nth coding block is any one of the multiple coding blocks. For example, when the encoding information of the first neighborhood coding block and the encoding information of the corresponding coding block are both inter-frame prediction modes, it means that the j-th video frame has a large correlation with the reference frame. Therefore, when traversing the prediction mode of the n-th coding block, the intra-frame prediction mode can be skipped to obtain the encoding information of the n-th coding block, which can effectively improve the encoding speed without reducing the video quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0015] Figure 1 A schematic diagram of a system for determining coding information of a coding block provided in an embodiment of the present application;
[0016] Figure 2 A flowchart of a method for determining coding information of a coding block provided in an embodiment of the present application;
[0017] Figure 3 A flowchart of a method for determining a prediction mode of a coding block provided in an embodiment of the present application;
[0018] Figure 4 A block diagram of the functional units of a device for determining coding information of a coding block provided in an embodiment of the present application;
[0019] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0021] The terms "first", "second", "third" and "fourth" etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0022] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0023] In order to facilitate understanding of the technical solution of this application, the relevant technical knowledge involved in this application is first explained and illustrated.
[0024] Frame type: In current video encoders, images are organized in groups of pictures (Group of Pictures, GOP). A group of pictures is a data stream after a segment of image encoding, starting with an I frame and ending with the next I frame. A group is a string of data streams generated after encoding a segment of images with high content similarity. A complete group of pictures includes three different frame types: I frame, P frame and B frame, which can also be understood as I type, P type and B type. Among them, I frame is the first frame of the picture group. There is only one I frame in a group. I frame is an intra-frame coded frame, which is an independent frame with all information. It can be encoded independently without referring to other images. P frame is an inter-frame coded frame, which needs to refer to the previous I frame or P frame to be encoded. P frame does not have complete picture data, only the data of the picture difference with the previous reference frame. Compared with I frame, P frame usually occupies fewer data bits. B frame is a bidirectional predictive coding frame, that is, B frame records the difference between the current frame and the previous reference frame and the next reference frame. In other words, to decode B frame, not only the previous cached picture must be obtained, but also the subsequent picture must be decoded, and the final picture is obtained by superimposing the previous and subsequent pictures with the current frame data.
[0025] Prediction mode: It should be noted that different video codecs correspond to different prediction modes. This application mainly takes the prediction mode under the Open Media Alliance Video One (AOMedia One, AV1) video codec mode as an example for explanation. According to the type of prediction mode, the prediction mode can be divided into two groups: intra-frame prediction mode and inter-frame prediction mode. Among them, the intra-frame prediction mode and the inter-frame prediction mode correspond to a variety of sub-frame intra-prediction modes and sub-frame inter-prediction modes respectively. In the AV1 video codec mode, the intra-frame prediction mode includes: directional intra-frame prediction mode, non-directional intra-frame prediction mode, intra-frame filtering mode and chroma intra-frame prediction mode; the inter-frame prediction mode includes: motion vector prediction mode, spatial motion vector prediction mode and temporal motion vector prediction mode. The prediction mode determination method under other video codecs is similar to that of this application, and this application will not be described in detail here.
[0026] Intra-frame prediction: Intra-frame prediction refers to the use of the similarity or correlation between adjacent pixels in the video, using the encoded adjacent pixels of the current image to predict the current pixel, thereby achieving the purpose of removing spatial redundancy. The resulting prediction residual will be further processed by subsequent transformation, quantization and entropy coding modules to generate the final bitstream.
[0027] Inter-frame prediction: Inter-frame prediction refers to the process of predicting the block to be coded in the current image from the adjacent coded images to obtain a reference block. The purpose is to remove the temporal redundancy of the video signal. The block to be coded in the current frame searches for the best matching block in the reference frame according to the coding block matching criteria.
[0028] See also Figure 1 , Figure 1 A schematic diagram of a system for determining coding information of a coding block provided in an embodiment of the present application. The system for determining a prediction mode of a coding block includes a terminal device 101 and a server 102 .
[0029] When the terminal device 101 needs to upload a video to the server 102 (the video is referred to as the video to be encoded in this application), the terminal device 101 needs to encode the video before uploading it to the server 102. Specifically, the terminal device 101 first divides the video to be encoded into frames to obtain multiple video frames. Then, the terminal device 101 divides the jth video frame into multiple coding blocks, wherein the jth video frame is any one of the multiple video frames of the video to be encoded; when the jth video frame has a corresponding reference frame, the terminal device 101 determines the coding information of the nth coding block based on the coding information of the corresponding coding block of the nth coding block in the reference frame and the first neighbor coding block of the corresponding coding block, and the nth coding block is any one of the multiple coding blocks. Further, the terminal device 101 can obtain the coding information of each coding block in the jth video frame based on the coding information of the nth coding block, and encode the jth video frame based on the coding information of each coding block, thereby completing the encoding of multiple video frames, and then realizing the encoding of the video to be encoded. Finally, the terminal device 101 uploads the encoded video to be encoded to the server 102.
[0030] It should be noted that if the server 102 needs to send a video to the terminal device 101, it can also encode according to the above encoding strategy to obtain the encoded video, and send the encoded video to the terminal device 101, which will not be described in detail. Therefore, the method for determining the encoding block in this application can be executed on the terminal device side or on the server side, and this application does not limit this.
[0031] It can be seen that in the embodiment of the present application, the terminal device 101 determines the coding information of the nth coding block based on the coding information of the corresponding coding block of the nth coding block in the reference frame and the coding information of the first neighbor coding block of the corresponding coding block. The coding information of the block to be coded is determined by using the temporal and spatial correlation between the nth coding block and the reference frame. Specifically, the temporal correlation between the nth coding block of the jth video frame and the corresponding coding block of the reference frame, the spatial correlation between the nth coding block of the jth video frame and the first neighbor coding block, and the temporal and spatial correlation between the nth coding block and the second neighbor coding block of the corresponding coding block are used to determine the coding information of the nth coding block, which can effectively improve the coding speed while ensuring the video quality.
[0032] See also Figure 2 , Figure 2The present invention provides a flowchart of a method for determining coding information of a coding block provided in an embodiment of the present application, wherein the method includes but is not limited to steps 201-203:
[0033] 201: Divide the jth video frame into a plurality of coding blocks, wherein the jth video frame is any video frame in the video to be encoded.
[0034] When encoding a video to be encoded, the video to be encoded is first divided into frames to obtain multiple video frames, and then each video is divided into encoding blocks to obtain multiple encoding blocks corresponding to each video frame, and then the prediction mode of each encoding block in each video frame is determined to encode each video frame. In this application, the jth video frame is used as an example to illustrate the process of determining the prediction mode of each encoding block, wherein the jth video frame is any video frame in the video to be encoded. It should be understood that a video frame is an image framed from a video, and the arrangement order of the video frames corresponds one-to-one to the display time of the image. Therefore, the jth video frame can also be called a video frame at moment j.
[0035] 202: When there is a corresponding reference frame for the j-th video frame, determine the encoding information of the n-th encoding block based on the encoding information of the corresponding encoding block of the n-th encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, wherein the n-th encoding block is any one of the multiple encoding blocks.
[0036] It should be noted that the encoding information of the coding block is the prediction mode of the coding block, and the position of the corresponding coding block in the reference frame is the same as the position of the nth coding block in the jth video frame.
[0037] Specifically, when traversing the prediction mode of the nth coding block, the temporal correlation and spatial correlation between video frames are used to skip some prediction modes to increase the encoding speed. When determining the prediction mode of the nth coding block, first obtain the prediction mode of the second neighboring coding block of the nth coding block, the prediction mode of the corresponding coding block of the nth coding block in the reference frame, and the prediction mode of the first neighboring coding block of the corresponding coding block to obtain the prediction mode of the nth coding block. It should be noted that the first neighboring coding block can be the upper adjacent coding block and the left adjacent coding block of the corresponding coding block; the second neighboring coding block can be the upper adjacent coding block and the left adjacent coding block of the nth coding block, and this application does not limit this.
[0038] Exemplarily, when the prediction mode of the first neighbor coding block, the prediction mode of the second neighbor coding block, and the prediction mode of the corresponding coding block are all inter-frame prediction modes, if the prediction mode of the nth coding block is traversed, the intra-frame prediction mode is skipped to obtain the prediction mode of the nth coding block. It should be noted that when the intra-frame prediction mode is skipped, all sub-frame intra-frame prediction modes of the intra-frame prediction mode are skipped, and prediction modes other than the intra-frame prediction mode are traversed to obtain the prediction mode of the nth coding block.
[0039] Exemplarily, when the prediction mode of the first neighbor coding block, the prediction mode of the second neighbor coding block, and the prediction mode of the corresponding coding block are all intra-frame prediction modes, if the prediction mode of the nth coding block is traversed, some or all inter-subframe prediction modes are skipped to obtain the prediction mode of the nth coding block, wherein the inter-frame prediction mode includes multiple inter-subframe prediction modes. It should be noted that when skipping the inter-frame prediction mode, all inter-subframe prediction modes are not directly skipped, but by obtaining the rate-distortion cost of the corresponding coding block, it is determined whether to skip the inter-subframe prediction mode corresponding to the rate-distortion cost when encoding the prediction mode of the nth coding block.
[0040] Specifically, skipping some sub-frame inter-modes includes: obtaining the rate-distortion cost when encoding the corresponding coding block under each sub-frame inter-prediction mode, and obtaining multiple rate-distortion costs, wherein each rate-distortion cost corresponds to each sub-frame inter-prediction mode one by one. For example, when there is only one reference frame, that is, when the frame type of the jth video frame is P type, it is only necessary to obtain a corresponding encoding fast rate-distortion cost under each sub-frame inter-prediction mode; when there are two reference frames, that is, when the frame type of the jth video frame is B type, it is necessary to obtain the rate-distortion cost of the corresponding coding block of each reference frame under each sub-frame inter-prediction mode, determine the average value of the rate-distortion cost of the two corresponding coding blocks, and use the average value as the corresponding encoding fast rate-distortion cost. When the hth rate-distortion cost is greater than the preset threshold, skip the sub-frame inter-prediction mode corresponding to the hth rate-distortion cost, wherein the hth rate-distortion cost is any one of the multiple rate-distortion costs. The optimal prediction mode is selected by comparing the rate-distortion cost when encoding the coding block using each prediction mode, and selecting the prediction mode corresponding to the minimum rate-distortion cost as the optimal prediction mode.
[0041] It can be seen that in the embodiment of the present application, when the prediction mode of the first neighborhood coding block, the prediction mode of the second neighborhood coding block and the prediction mode of the corresponding coding block are all intra-frame prediction modes, if the prediction mode of the nth coding block is traversed, the rate-distortion cost of encoding the corresponding coding block in each sub-frame inter-prediction mode is calculated, and the skipped part or all of the sub-frame inter-prediction modes are determined by comparing the rate-distortion cost with the preset threshold value to obtain the prediction mode of the nth coding block. It is ensured that when traversing the prediction mode of the nth coding block, no possible sub-frame inter-prediction mode is omitted, which not only ensures the accuracy of the prediction mode selection but also effectively improves the encoding speed.
[0042] In one embodiment of the present application, before determining the encoding information of the nth encoding block based on the encoding information of the corresponding encoding block of the nth encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, the method further includes:
[0043] Based on the frame type of the j-th video frame and the similarity between the j-th video frame and the adjacent frames, a reference frame corresponding to the j-th video frame is determined. Specifically, in the embodiment of the present application, when selecting the adjacent frames of the j-th video frame, the previous video frame or the next video frame of the j-th video frame is not directly selected as the adjacent frame of the j-th video frame, but the adjacent frame selection method and the number of reference frames are determined based on the frame type of the j-th video frame.
[0044] Exemplarily, when the frame type of the jth video frame is the P type, the jth video frame needs to refer to the previous video frame before it can be encoded, therefore, the first k video frames of the jth video frame are obtained as adjacent frames of the jth video frame, so as to select the reference frame of the jth video frame. Specifically, the similarity between each video frame in the first k video frames and the jth video frame is determined to obtain multiple first similarities, and the video frame corresponding to the maximum value of the multiple first similarities is used as the reference frame corresponding to the jth video frame.
[0045] Exemplarily, when the frame type of the jth video frame is type B, when encoding the jth video frame, it is necessary to obtain not only the adjacent video frames before the jth video frame but also the adjacent video frames after the jth video frame, so as to select at least two reference frames, so as to encode each coding block of the jth video frame. Specifically, the first m video frames and the last t video frames of the jth video frame are obtained as the adjacent frames of the jth video frame; based on the similarity between the first m video frames and the last t video frames and the jth video frame, the reference frame corresponding to the jth video frame is determined. The similarity between each video frame in the first m video frames and the jth video frame is determined to obtain multiple second similarities; the similarity between each video frame in the last t video frames and the jth video frame is determined to obtain multiple third similarities; the video frame corresponding to the maximum value among the multiple second similarities and the video frame corresponding to the maximum value among the multiple third similarities are used as the reference frame corresponding to the jth video frame.
[0046] It should be noted that when the frame type of the j-th video frame is type I, that is, the j-th video frame is the first video frame, there is no need to calculate the similarity between the adjacent frames and the j-th video frame to determine the reference frame, because type I is an intra-frame coded frame, which is an independent frame that carries all its own information and can be independently encoded without referring to other images.
[0047] It can be seen that in an embodiment of the present application, the frame type of the jth video frame of the current encoding frame is determined to obtain a reference frame determination method under each frame type. Different frame types correspond to different numbers of reference frames and different reference frame selection methods. For example, when the frame type of the jth video frame is type B, it is necessary not only to select reference frames from adjacent frames before the jth video frame, but also to select reference frames from adjacent frames after the jth video frame. This makes full use of the time correlation between the jth video frame to be encoded and the adjacent frames, so that the reference frame is determined more accurately and the video encoding quality is guaranteed. Furthermore, when determining the prediction mode of the nth coding block, the prediction mode of the block to be encoded is determined using the temporal and spatial correlations between the nth coding block and the reference frame. Specifically, the prediction mode of the nth coding block is determined using the temporal correlation between the nth coding block of the jth video frame and the corresponding coding block of the reference frame, the spatial correlation between the nth coding block of the jth video frame and the first neighboring coding block, and the temporal and spatial correlations between the nth coding block and the second neighboring coding block of the corresponding coding block. This can effectively improve the encoding speed while ensuring the video quality.
[0048] In one embodiment of the present application, when there is no corresponding reference frame for the j-th video frame, that is, when the frame type of the j-th video frame is type I, the prediction mode of the n-th coding block is determined to be the intra-frame prediction mode. Because the frame type of the j-th video frame is type I, there is no reference frame for the j-th video frame, and the j-th video frame does not need to use the temporal correlation between adjacent frames to encode the coding block of the j-th video frame. It only needs to use the correlation between adjacent pixels in the video frame, that is, the spatial correlation, to encode the coding block of the j-th video frame, thereby achieving the purpose of removing spatial redundancy.
[0049] See also Figure 3 , Figure 3 A flowchart of a method for determining a prediction mode of a coding block provided in an embodiment of the present application is provided. The contents repeated in the above steps 201-202 in this embodiment are not described again. The method includes but is not limited to the following steps:
[0050] 301: Encode the j-1th video frame, and divide the j-1th video frame into multiple coding blocks.
[0051] Specifically, the j-1th video frame is a video frame at a moment before the jth video frame.
[0052] 302: Traverse each coding block of the j-1th video frame to obtain a prediction mode of each coding block.
[0053] It should be noted that, in the present application, before encoding the j-th video frame, not only each coding block of the j-1-th video frame is traversed to obtain the prediction mode of each coding block, but also the video frames before the j-th video frame need to be traversed, wherein the video frames before the j-th video frame include the first I frame before the j-th video frame to the j-th video frame. In order to obtain the prediction mode corresponding to each coding block of each video frame from the first I frame before the j-th video frame to the j-th video frame.
[0054] 303: After loop filtering, store the prediction mode of each coding block of the j-1th video frame into a global variable.
[0055] Specifically, the prediction mode of each coding block of the j-1th video frame is stored in a global variable to facilitate obtaining the prediction mode of each coding block of the j-1th video frame. Furthermore, the video coding loop filter can reduce the error and distortion after encoding and remove the block effect by filtering the pixel values in the encoding process. Specifically, the loop filter adjusts the predicted pixel values in the encoder to match the original pixel values. It should be noted that when the prediction mode is stored in a global variable, not only the prediction mode of each coding block of the j-1th video frame is stored, but also the prediction mode corresponding to each coding block of each video frame from the first I frame before the jth video frame to the jth video frame is stored.
[0056] 304: Encode the j-th video frame, and divide the j-th video frame into multiple coding blocks.
[0057] 305: Traverse each coding block in the j-th video frame.
[0058] 306: Determine whether there is a reference frame for the j-th video frame.
[0059] Specifically, based on the frame type of the jth video frame and the similarity between the jth video frame and adjacent frames, a reference frame corresponding to the jth video frame is determined. The implementation process of 306 is referred to the implementation process of the above embodiment, and no further description is given here.
[0060] 307a: If yes, obtain the prediction mode of each coding block of the reference frame in the global variable.
[0061] For example, when the reference frame is the j-1th video frame, the prediction mode of each coding block of the j-1th video frame stored in the global variable is obtained. It should be noted that when there are two reference frames, the prediction mode of each coding block of each reference frame needs to be obtained respectively.
[0062] 307b: If not, determine that the prediction mode of the j-th video frame is the intra-frame prediction mode.
[0063] It should be noted that after determining that the prediction mode is the intra-frame prediction mode, it is necessary to continue to traverse multiple sub-frame intra-frame prediction modes in the intra-frame prediction mode to obtain the prediction mode of the j-th video frame.
[0064] 308: When encoding an nth coding block in a jth video frame, obtaining a prediction mode of a coded block in the jth video frame, wherein the nth coding block is any one of a plurality of coding blocks in the jth video frame.
[0065] Specifically, when encoding to the nth coding block in the jth video frame, the prediction modes of all coding blocks encoded before the nth coding block in the jth video frame are obtained, wherein the nth coding block is any one of the multiple coding blocks.
[0066] 309: Determine whether the prediction mode of the first neighboring coding block of the nth coding block, the prediction mode of the corresponding coding block of the nth coding block in the reference frame, and the prediction mode of the second neighboring coding block of the corresponding coding block are all inter-frame prediction modes.
[0067] It should be noted that the position of the corresponding coding block in the reference frame is the same as the position of the nth coding block in the jth video frame. The first neighborhood coding block can be the upper adjacent coding block and the left adjacent coding block of the nth coding block; the second neighborhood coding block can be the upper adjacent coding block and the left adjacent coding block of the corresponding coding block, which is not limited in this application.
[0068] 310: If yes, when traversing the prediction mode of the nth coding block, skip the intra prediction mode to obtain the prediction mode of the nth coding block.
[0069] Exemplarily, when the prediction mode of the first neighbor coding block, the prediction mode of the second neighbor coding block, and the prediction mode of the corresponding coding block are all inter-frame prediction modes, if the prediction mode of the nth coding block is traversed, the intra-frame prediction mode is skipped to obtain the prediction mode of the nth coding block. It should be noted that when the intra-frame prediction mode is skipped, all sub-frame intra-frame prediction modes of the intra-frame prediction mode are skipped, and prediction modes other than the intra-frame prediction mode are traversed to obtain the prediction mode of the nth coding block.
[0070] See also Figure 4 , Figure 4 The functional unit composition block diagram of a device for determining coding information of a coding block provided in an embodiment of the present application. The device for determining coding information of a coding block 400 comprises: a transceiver unit 401 and a processing unit 402;
[0071] The transceiver unit 401 is used to obtain the video to be encoded;
[0072] The processing unit 402 is used to divide the j-th video frame into multiple coding blocks, wherein the j-th video frame is any one of the video frames in the video to be encoded; the processing unit 402 is used to determine the coding information of the n-th coding block based on the coding information of the corresponding coding block of the n-th coding block in the reference frame and the coding information of the first neighboring coding block of the corresponding coding block when there is a corresponding reference frame for the j-th video frame, wherein the n-th coding block is any one of the multiple coding blocks.
[0073] In one embodiment of the present application, in determining the encoding information of the nth encoding block based on the encoding information of the corresponding encoding block of the nth encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, the processing unit 402 is specifically configured to:
[0074] Obtaining encoding information of a second neighboring encoding block of the nth encoding block;
[0075] The encoding information of the nth encoding block is determined based on the encoding information of the corresponding encoding block, the encoding information of the first neighboring encoding block, and the encoding information of the second neighboring encoding block.
[0076] In one embodiment of the present application, the coding information of the coding block is a prediction mode of the coding block; in terms of determining the coding information of the nth coding block based on the coding information of the corresponding coding block, the coding information of the first neighboring coding block, and the coding information of the second neighboring coding block, the processing unit 402 is specifically configured to:
[0077] When the prediction mode of the first neighboring coding block, the prediction mode of the second neighboring coding block, and the prediction mode of the corresponding coding block are all inter-frame prediction modes, if the prediction modes of the n-th coding block are traversed, the intra-frame prediction mode is skipped to obtain the prediction mode of the n-th coding block;
[0078] When the prediction mode of the first neighborhood coding block, the prediction mode of the second neighborhood coding block and the prediction mode of the corresponding coding block are all the intra-frame prediction mode, if the prediction modes of the nth coding block are traversed, some or all of the inter-subframe prediction modes are skipped to obtain the prediction mode of the nth coding block, wherein the inter-frame prediction mode includes multiple inter-subframe prediction modes.
[0079] In one embodiment of the present application, in terms of skipping some or all inter-subframe prediction modes, the processing unit 402 is specifically configured to:
[0080] Obtaining a rate-distortion cost when encoding the corresponding coding block under each sub-inter-frame prediction mode, to obtain a plurality of rate-distortion costs, wherein each rate-distortion cost corresponds one-to-one to each sub-inter-frame prediction mode;
[0081] When the hth rate-distortion cost is greater than a preset threshold, the inter-subframe prediction mode corresponding to the hth rate-distortion cost is skipped, wherein the hth rate-distortion cost is any one of the multiple rate-distortion costs.
[0082] In one embodiment of the present application, the position of the corresponding coding block in the reference frame is the same as the position of the nth coding block in the jth video frame.
[0083] In one embodiment of the present application, the first neighborhood coding block includes an upper adjacent coding block and a left adjacent coding block of the corresponding coding block;
[0084] The second neighborhood coding block includes an upper adjacent coding block and a left adjacent coding block of the nth coding block.
[0085] In one embodiment of the present application, before determining the encoding information of the nth encoding block based on the encoding information of the first neighboring encoding block of the nth encoding block, the encoding information of the corresponding encoding block of the nth encoding block in the reference frame, and the encoding information of the second neighboring encoding block of the corresponding encoding block, the processing unit 402 is specifically used to:
[0086] When the frame type of the j-th video frame is the P type, obtaining the first k video frames of the j-th video frame as adjacent frames of the j-th video frame;
[0087] Determine the similarity between each of the first k video frames and the j-th video frame to obtain a plurality of first similarities;
[0088] Using the video frame corresponding to the maximum value among the multiple first similarities as the reference frame corresponding to the j-th video frame;
[0089] When the frame type of the j-th video frame is type B, acquiring the first m video frames and the last t video frames of the j-th video frame as adjacent frames of the j-th video frame;
[0090] Based on the similarities between the first m video frames and the last t video frames and the j-th video frame, a reference frame corresponding to the j-th video frame is determined.
[0091] In one embodiment of the present application, in determining a reference frame corresponding to the j-th video frame based on the similarity between the first m video frames and the last t video frames and the j-th video frame, the processing unit 402 is specifically configured to:
[0092] Determine the similarity between each of the first m video frames and the j-th video frame to obtain a plurality of second similarities;
[0093] Determine the similarity between each of the last t video frames and the j-th video frame to obtain a plurality of third similarities;
[0094] The video frame corresponding to the maximum value among the multiple second similarities and the video frame corresponding to the maximum value among the multiple third similarities are used as reference frames corresponding to the j-th video frame.
[0095] In one embodiment of the present application, when the j-th video frame does not have a corresponding reference frame, the processing unit 402 is specifically configured to:
[0096] Determine the prediction mode of the nth coding block as the intra prediction mode.
[0097] See also Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the electronic device 500 includes a transceiver 501, a processor 502 and a memory 503. They are connected via a bus 504. The memory 503 is used to store computer programs and data, and can transmit the data stored in the memory 503 to the processor 502.
[0098] The processor 502 is used to read the computer program in the memory 503 and perform the following operations:
[0099] Divide the jth video frame into a plurality of coding blocks, wherein the jth video frame is any video frame in the video to be encoded;
[0100] When the j-th video frame has a corresponding reference frame, the encoding information of the n-th encoding block is determined based on the encoding information of the corresponding encoding block of the n-th encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, wherein the n-th encoding block is any one of the multiple encoding blocks.
[0101] In one embodiment of the present application, in determining the encoding information of the nth encoding block based on the encoding information of the corresponding encoding block of the nth encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, the processing unit 402 is specifically configured to:
[0102] Obtaining encoding information of a second neighboring encoding block of the nth encoding block;
[0103] The encoding information of the nth encoding block is determined based on the encoding information of the corresponding encoding block, the encoding information of the first neighboring encoding block, and the encoding information of the second neighboring encoding block.
[0104] In one embodiment of the present application, the coding information of the coding block is a prediction mode of the coding block; in terms of determining the coding information of the nth coding block based on the coding information of the corresponding coding block, the coding information of the first neighboring coding block, and the coding information of the second neighboring coding block, the processor 502 is specifically configured to perform the following steps:
[0105] When the prediction mode of the first neighboring coding block, the prediction mode of the second neighboring coding block, and the prediction mode of the corresponding coding block are all inter-frame prediction modes, if the prediction modes of the n-th coding block are traversed, the intra-frame prediction mode is skipped to obtain the prediction mode of the n-th coding block;
[0106] When the prediction mode of the first neighborhood coding block, the prediction mode of the second neighborhood coding block and the prediction mode of the corresponding coding block are all the intra-frame prediction mode, if the prediction modes of the nth coding block are traversed, some or all of the inter-subframe prediction modes are skipped to obtain the prediction mode of the nth coding block, wherein the inter-frame prediction mode includes multiple inter-subframe prediction modes.
[0107] In one embodiment of the present application, in terms of skipping some or all inter-subframe prediction modes, the processor 502 is specifically configured to perform the following steps:
[0108] Obtaining a rate-distortion cost when encoding the corresponding coding block under each sub-inter-frame prediction mode, to obtain a plurality of rate-distortion costs, wherein each rate-distortion cost corresponds one-to-one to each sub-inter-frame prediction mode;
[0109] When the hth rate-distortion cost is greater than a preset threshold, the inter-subframe prediction mode corresponding to the hth rate-distortion cost is skipped, wherein the hth rate-distortion cost is any one of the multiple rate-distortion costs.
[0110] In one embodiment of the present application, the position of the corresponding coding block in the reference frame is the same as the position of the nth coding block in the jth video frame.
[0111] In one embodiment of the present application, the first neighborhood coding block includes an upper adjacent coding block and a left adjacent coding block of the corresponding coding block;
[0112] The second neighborhood coding block includes an upper adjacent coding block and a left adjacent coding block of the nth coding block.
[0113] In one embodiment of the present application, before determining the encoding information of the nth encoding block based on the encoding information of the first neighboring encoding block of the nth encoding block, the encoding information of the corresponding encoding block of the nth encoding block in the reference frame, and the encoding information of the second neighboring encoding block of the corresponding encoding block, the processor 502 is specifically used to perform the following steps:
[0114] When the frame type of the j-th video frame is the P type, obtaining the first k video frames of the j-th video frame as adjacent frames of the j-th video frame;
[0115] Determine the similarity between each of the first k video frames and the j-th video frame to obtain a plurality of first similarities,
[0116] Using the video frame corresponding to the maximum value among the multiple first similarities as the reference frame corresponding to the j-th video frame;
[0117] When the frame type of the j-th video frame is type B, acquiring the first m video frames and the last t video frames of the j-th video frame as adjacent frames of the j-th video frame;
[0118] Based on the similarities between the first m video frames and the last t video frames and the j-th video frame, a reference frame corresponding to the j-th video frame is determined.
[0119] In one embodiment of the present application, in terms of determining a reference frame corresponding to the j-th video frame based on the similarity between the first m video frames and the last t video frames and the j-th video frame, the processor 502 is specifically configured to perform the following steps:
[0120] Determine the similarity between each of the first m video frames and the j-th video frame to obtain a plurality of second similarities;
[0121] Determine the similarity between each of the last t video frames and the j-th video frame to obtain a plurality of third similarities;
[0122] The video frame corresponding to the maximum value among the multiple second similarities and the video frame corresponding to the maximum value among the multiple third similarities are used as reference frames corresponding to the j-th video frame.
[0123] In one embodiment of the present application, when the j-th video frame does not have a corresponding reference frame, the processing unit 402 is specifically configured to:
[0124] Determine the prediction mode of the nth coding block as the intra prediction mode.
[0125] Specifically, the transceiver 501 may be Figure 4 In the transceiver unit 401 of the device 400 for determining coding information of a coding block of an embodiment, the processor 502 may be Figure 4 A processing unit 402 of an apparatus 400 for determining coding information of a coding block according to an embodiment of the present invention.
[0126] It should be understood that the electronic devices in this application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, mobile Internet devices MID (Mobile Internet Devices, referred to as: MID) or wearable devices, etc. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices. In practical applications, the above electronic devices may also include: smart vehicle terminals, computer equipment, etc.
[0127] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to implement part or all of the steps of any method for determining encoding information of a coding block as recorded in the above method embodiments.
[0128] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program can be operated to enable a computer to execute part or all of the steps of any method for determining encoding information of a coding block as recorded in the above method embodiments.
[0129] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0130] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0131] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0132] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0134] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0135] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0136] The embodiments of the present application are introduced in detail above. 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 those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for determining coding information of a coding block, characterized in that: include: Divide the jth video frame into a plurality of coding blocks, wherein the jth video frame is any video frame in the video to be encoded; When the j-th video frame has a corresponding reference frame, determining the encoding information of the n-th encoding block based on the encoding information of the corresponding encoding block of the n-th encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, wherein the n-th encoding block is any one of the multiple encoding blocks; comprising: Obtaining encoding information of a second neighboring encoding block of the nth encoding block; Determining the encoding information of the nth encoding block based on the encoding information of the corresponding encoding block, the encoding information of the first neighboring encoding block, and the encoding information of the second neighboring encoding block; the first neighboring encoding block includes an upper adjacent encoding block and a left adjacent encoding block of the corresponding encoding block, and the encoding information of the encoding block is a prediction mode of the encoding block; comprising: When the prediction mode of the first neighboring coding block, the prediction mode of the second neighboring coding block of the nth coding block, and the prediction mode of the corresponding coding block are all intra-frame prediction modes and the jth frame is a B frame, when traversing the prediction modes of the nth coding block, the rate-distortion cost of the corresponding coding block of each reference frame using each sub-frame inter-prediction mode is obtained, the average value of the rate-distortion costs of the two corresponding coding blocks is determined, and the average value is used as the rate-distortion cost of the corresponding coding block to obtain multiple rate-distortion costs, and when the hth rate-distortion cost is greater than a preset threshold, the inter-subframe prediction mode corresponding to the hth rate-distortion cost is skipped, wherein the hth rate-distortion cost is any one of the multiple rate-distortion costs.
2. The method according to claim 1, characterized in that The determining, based on the encoding information of the corresponding encoding block, the encoding information of the first neighboring encoding block, and the encoding information of the second neighboring encoding block, the encoding information of the nth encoding block includes: When the prediction mode of the first neighborhood coding block, the prediction mode of the second neighborhood coding block and the prediction mode of the corresponding coding block are all inter-frame prediction modes, if the prediction modes of the nth coding block are traversed, the intra-frame prediction mode is skipped to obtain the prediction mode of the nth coding block.
3. The method according to claim 2, characterized in that The position of the corresponding coding block in the reference frame is the same as the position of the nth coding block in the jth video frame.
4. The method according to any one of claims 1 to 3, characterized in that: The second neighborhood coding block includes an upper adjacent coding block and a left adjacent coding block of the nth coding block.
5. The method according to any one of claims 1 to 3, characterized in that: Before determining the encoding information of the nth encoding block based on the encoding information of the corresponding encoding block of the nth encoding block in the reference frame and the encoding information of the first neighboring encoding block of the corresponding encoding block, the method further includes: When the frame type of the j-th video frame is the P type, obtaining the first k video frames of the j-th video frame as adjacent frames of the j-th video frame; Determine the similarity between each of the first k video frames and the j-th video frame to obtain a plurality of first similarities; Using the video frame corresponding to the maximum value among the multiple first similarities as the reference frame corresponding to the j-th video frame; When the frame type of the j-th video frame is type B, acquiring the first m video frames and the last t video frames of the j-th video frame as adjacent frames of the j-th video frame; Based on the similarities between the first m video frames and the last t video frames and the j-th video frame, a reference frame corresponding to the j-th video frame is determined.
6. The method according to claim 5, characterized in that The determining a reference frame corresponding to the j-th video frame based on the similarities between the first m video frames and the last t video frames and the j-th video frame comprises: Determine the similarity between each of the first m video frames and the j-th video frame to obtain a plurality of second similarities; Determine the similarity between each of the last t video frames and the j-th video frame to obtain a plurality of third similarities; The video frame corresponding to the maximum value among the multiple second similarities and the video frame corresponding to the maximum value among the multiple third similarities are used as reference frames corresponding to the j-th video frame.
7. The method according to any one of claims 1 to 3, characterized in that: When the j-th video frame does not have a corresponding reference frame, the method further includes: Determine the prediction mode of the nth coding block as the intra prediction mode.
8. A device for determining coding information of a coding block, characterized in that: include: Transceiver unit and processing unit; The transceiver unit is used to obtain the video to be encoded; The processing unit is used to divide the j-th video frame into a plurality of coding blocks, wherein the j-th video frame is any video frame in the video to be encoded; The processing unit is configured to determine, when the j-th video frame has a corresponding reference frame, encoding information of the n-th encoding block based on encoding information of a corresponding encoding block of the n-th encoding block in the reference frame and encoding information of a first neighboring encoding block of the corresponding encoding block, wherein the n-th encoding block is any one of the multiple encoding blocks; comprising: Obtaining encoding information of a second neighboring encoding block of the nth encoding block; Determining the encoding information of the nth encoding block based on the encoding information of the corresponding encoding block, the encoding information of the first neighboring encoding block, and the encoding information of the second neighboring encoding block; the first neighboring encoding block includes an upper adjacent encoding block and a left adjacent encoding block of the corresponding encoding block, and the encoding information of the encoding block is a prediction mode of the encoding block; comprising: When the prediction mode of the first neighboring coding block, the prediction mode of the second neighboring coding block of the nth coding block, and the prediction mode of the corresponding coding block are all intra-frame prediction modes and the jth frame is a B frame, when traversing the prediction modes of the nth coding block, the rate-distortion cost of the corresponding coding block of each reference frame using each sub-frame inter-prediction mode is obtained, the average value of the rate-distortion costs of the two corresponding coding blocks is determined, and the average value is used as the rate-distortion cost of the corresponding coding block to obtain multiple rate-distortion costs, and when the hth rate-distortion cost is greater than a preset threshold, the inter-subframe prediction mode corresponding to the hth rate-distortion cost is skipped, wherein the hth rate-distortion cost is any one of the multiple rate-distortion costs.
9. An electronic device, characterized in that: include: A processor and a memory, wherein the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.
