A method of intra-inter mode selection and related apparatus
By using an intra-frame/inter-frame mode selection method, all encoding modes are classified using the known encoding information of video frames, which solves the problem of high time overhead in video codec mode selection and improves encoding efficiency.
Patent Information
- Application Number
- CN202511615996.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-11-06
AI Technical Summary
Existing video codecs incur significant time overhead during mode selection, resulting in low encoding efficiency.
By using the intra-frame and inter-frame mode selection method, all coding modes are classified using the known coding information of video frames, reducing the number of modes traversed and selecting the optimal coding mode.
It improves the execution efficiency of encoding mode selection and reduces the time overhead of video codecs in mode selection.
Smart Images

Figure CN121078231B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of video coding technology, and particularly relates to an intra-inter mode selection method and related equipment. BACKGROUND
[0002] A video codec is a device that provides an algorithm or software / hardware implementation for converting video data from one format to another, mainly including two processes: encoding and decoding. The encoding process is to compress the original video data into a smaller data stream for storage or transmission; the decoding process is to restore the compressed data stream to the original video data for playback. The video codec compresses and decompresses video data efficiently through technologies such as spatial redundancy compression, temporal redundancy compression, transform coding, and entropy coding, and plays a key role in video storage, transmission, and playback, enabling efficient storage and transmission of video under limited resources while maintaining good video quality.
[0003] Intra coding and inter coding are two types of predictive coding of video codec, intra coding is a video coding technology that only encodes a single image frame (like a still picture), it does not consider the relationship between different frames in the video sequence, but only focuses on the content inside the current frame. The advantage of intra coding is that the decoding is simple, because each frame is independently encoded, so when decoding, it does not need to consider the information of other frames, which makes it very useful in some scenarios that require fast random access to video frames, such as in video editing software, editors can quickly jump to any frame for editing operations, however, its compression efficiency is relatively low, because it does not utilize the information between frames, so for video sequences, a lot of repeated information (such as an object that does not change much in consecutive frames) is not fully utilized to reduce the data volume.
[0004] Inter-frame coding is a technique for encoding different frames in a video sequence. It primarily utilizes the temporal correlation between video frames to achieve data compression. In many cases, consecutive frames in a video exhibit minimal change. For example, in a scene where only a person is moving while the background remains largely unchanged, inter-frame coding encodes data by comparing the differences between adjacent frames (or frames spaced a certain number of frames apart). It finds a reference frame (usually an already encoded frame) and then calculates the motion vector (describing the direction and distance of the object's movement between frames) between the current frame and the reference frame. For parts that do not change or change very little, the encoder performs appropriate encoding processing. Common inter-frame coding methods include predictive coding, such as P-frames (forward prediction frames), which predict the current frame based on preceding I-frames (intra-coded frames) or P-frames, and B-frames (bidirectional prediction frames), which predict based on preceding and following frames. Inter-frame coding has high compression efficiency because it fully utilizes the temporal redundancy between video frames, thus significantly reducing data volume while maintaining video quality. This is highly beneficial for video storage and transmission (such as online video streaming services), saving substantial storage space and bandwidth. However, its decoding process is relatively complex because the encoding of each frame depends on other frames (reference frames). Therefore, these frames need to be decoded in a certain order. Moreover, if the reference frame is faulty or lost, it may cause problems in the decoding of multiple frames.
[0005] The encoder's modes are divided into intra-frame mode selection and inter-frame mode selection. For mode selection, the encoder iterates through every encoding mode and selects the mode with the smallest error as the final encoding mode. Obviously, selecting the optimal mode from all possible modes is a very time-consuming process. This is because most erroneous modes usually have significant loss and can be identified before encoding. Summary of the Invention
[0006] This invention provides an intra-frame / inter-frame mode selection method and related equipment, the purpose of which is to reduce the time overhead of video codecs in mode selection.
[0007] To achieve the above objectives, the present invention provides an intra-frame / inter-frame mode selection method for a video codec. The intra-frame / inter-frame mode selection method includes:
[0008] Step 1: Input the video data to be encoded into the video codec. The video data to be encoded includes multiple video frames.
[0009] Step 2: Analyze each video frame individually to obtain the judgment result;
[0010] Step 3: Select the optimal encoding mode based on the judgment result;
[0011] When the judgment result is an I frame or a first P frame or B frame, an optimal encoding mode is selected by a conventional mode selection manner;
[0012] When the judgment result is a non-I frame or a first P frame or B frame, all encoding modes are classified according to known encoding information of the video frame to obtain a classification result, and an optimal encoding mode is selected from the classification result.
[0013] Further, the optimal encoding mode is selected by the conventional mode selection manner, including:
[0014] all available encoding modes are traversed in a video codec;
[0015] The encoding cost of each available encoding mode is calculated respectively, and the encoding mode with the minimum encoding cost is selected as the optimal encoding mode.
[0016] Further, the known encoding information of the video frame includes the encoding mode of the encoded pixel block in the video frame, the motion vector of the encoded pixel block, and the absolute error sum, and the optimal encoding mode includes an intra-frame encoding mode and an inter-frame encoding mode.
[0017] Further, the classification of all encoding modes according to the known encoding information of the video frame to obtain the classification result includes:
[0018] All encoding modes of the encoded pixel block in the known encoding information are taken as a whole to obtain a first set;
[0019] The intra-frame encoding modes in the first set are sorted according to directions to obtain a second set;
[0020] All encoding modes appearing around each pixel block in the video frame and all encoding modes appearing in the same pixel block of the previous frame are counted to obtain a counting result;
[0021] The counting result is classified according to the second set to obtain the classification result.
[0022] Further, the classification of the counting result according to the second set includes:
[0023] It is determined whether all intra-frame encoding modes in the counting result are located in the second set, and all intra-frame encoding modes in the counting result are classified according to the determination result:
[0024] When the determination result is that there is an intra-frame encoding mode not located in the second set, the intra-frame encoding mode not located in the second set is classified as an intra-frame large mode;
[0025] When the result of the determination is that there is an intra coding mode located in the second set, two intra coding modes adjacent to the intra coding mode located in the second set are extracted from the second set, and the extracted intra coding modes and the intra coding mode located in the second set are classified as intra large modes, and the intra coding modes not adjacent to the intra coding mode located in the second set are classified as intra small modes in the second set;
[0026] Classify all inter coding modes in the statistical result by using the motion vector and the absolute error sum in the known coding information:
[0027] Calculate the first threshold value and the second threshold value by using the size of the pixel block to be coded in the video frame and the bit depth of the video frame;
[0028] Classify all inter modes corresponding to the coded pixel blocks with the motion vector less than the first threshold value and the absolute error sum less than the second threshold value as inter large modes, and classify all inter modes corresponding to the coded pixel blocks with the motion vector greater than or equal to the first threshold value and / or the absolute error sum greater than or equal to the second threshold value as inter small modes.
[0029] Further, the calculation expression of the first threshold value and the second threshold value by using the size of the pixel block to be coded in the video frame and the bit depth of the video frame is:
[0030] ;
[0031] ;
[0032] wherein, the first threshold value is represented by T1, the second threshold value is represented by T2, the width of the pixel block to be coded in the video frame is represented by W, the height of the pixel block to be coded in the video frame is represented by H, the bit depth of the video frame is represented by B.
[0033] Further, selecting an optimal coding mode in the classification result comprises:
[0034] Calculating the intra feature and the inter feature between the coded pixel block and the pixel block to be coded;
[0035] Inputting the classification result, the intra feature, the inter feature and the motion vector module length of the coded pixel block into a classification model to select a mode, and obtaining an optimal coding mode in a class;
[0036] Selecting an optimal coding mode in the optimal coding mode in the class by using a traversal method.
[0037] The application further provides an intra-inter mode selection device, comprising:
[0038] An input module is configured to input to-be-encoded video data into a video codec, the to-be-encoded video data comprising a plurality of video frames;
[0039] A judgment module is configured to judge each video frame respectively to obtain a judgment result;
[0040] A selection module is configured to select an optimal encoding mode according to the judgment result;
[0041] When the judgment result is an I frame or a first P frame or a B frame, the optimal encoding mode is selected by a conventional mode selection manner;
[0042] When the judgment result is a non-I frame or a first P frame or a B frame, all encoding modes are classified according to known encoding information of the video frame to obtain a classification result, and the optimal encoding mode is selected in the classification result.
[0043] The application further provides a terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the intra-inter mode selection method when executing the computer program.
[0044] The application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the intra-inter mode selection method.
[0045] The above scheme of the application has the following advantages:
[0046] The application inputs to-be-encoded video data into a video codec, the to-be-encoded video data comprising a plurality of video frames; judges each video frame respectively to obtain a judgment result; selects an optimal encoding mode according to the judgment result; when the judgment result is an I frame or a first P frame or a B frame, the optimal encoding mode is selected by a conventional mode selection manner; when the judgment result is a non-I frame or a first P frame or a B frame, all encoding modes are classified according to known encoding information of the video frame to obtain a classification result, and the optimal encoding mode is selected in the classification result; compared with the prior art, the application classifies and filters all encoding modes by using known encoding information of the video frame when the video codec selects an encoding mode, thereby reducing the number of modes that need to be traversed, improving the execution efficiency of the encoding mode selection, and further reducing the time cost of the video codec in mode selection.
[0047] Other advantages of the application will be described in detail in the following specific embodiment part. BRIEF DESCRIPTION OF DRAWINGS
[0048] Figure 1 The flowchart of the embodiment of the application is shown;
[0049] Figure 2 Fig. 9 is a schematic diagram of 9 4x4 intra coding modes in an embodiment of the present application;
[0050] Figure 3 Fig. 10 is a schematic diagram of 4 16x16 intra coding modes in an embodiment of the present application;
[0051] Figure 4 Fig. 11 is a schematic diagram of the structure of an intra-inter mode selection device in an embodiment of the present application;
[0052] Figure 5 Fig. 12 is a schematic diagram of the structure of a terminal device in an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the technical problems solved by the present application, the technical solutions and advantages clearer, the following will be described in detail with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of the present application.
[0054] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" and the like indicate the orientation or positional relationship shown in the drawings, and are only for the purpose of facilitating the description of the present application and simplifying the description, and therefore cannot be understood as indicating or implying that the device or element referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", "third" are only for the purpose of description, and cannot be understood as indicating or implying relative importance.
[0055] In the description of the present application, it should be noted that unless otherwise explicitly specified and limited, the terms "mounting", "connecting", "connection" should be understood broadly, for example, it can be a locking connection, or a detachable connection, or an integral connection; it can be a mechanical connection, or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or a communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.
[0056] In addition, the technical features involved in the different embodiments of the present application described below can be combined with each other as long as they do not conflict with each other.
[0057] The present application aims at the existing problems, and provides an intra-inter mode selection method and related device.
[0058] As Figure 1As shown, the embodiment of the present application provides an intra-inter mode selection method for a video codec, the intra-inter mode selection method comprising:
[0059] Step 1, inputting video data to be encoded into the video codec, the video data to be encoded comprising a plurality of video frames;
[0060] Step 2, judging each video frame respectively to obtain a judgment result;
[0061] Step 3, selecting an optimal encoding mode according to the judgment result;
[0062] When the judgment result is an I frame or a first P frame or a B frame, the optimal encoding mode is selected by a conventional mode selection method;
[0063] When the judgment result is a non-I frame or a first P frame or a B frame, all encoding modes are classified according to known encoding information of the video frame to obtain a classification result, and the optimal encoding mode is selected from the classification result.
[0064] In the embodiment of the present application, the video codec can be a versatile video coding test model (VTM) video codec, and the video data to be encoded is a YUV format video sequence, because the YUV format video sequence can be directly used by the encoder, and other common video formats such as MP4, MOV, etc. Video sequence can also be used as input, but when read by the encoder, the MP4, MOV, etc. Video sequence will still be transcoded into a YUV format video sequence.
[0065] Specifically, the optimal encoding mode is selected by a conventional mode selection method, comprising:
[0066] Traversing all available encoding modes in the video codec;
[0067] Calculating the encoding cost of each available encoding mode respectively, and selecting the encoding mode with the smallest encoding cost as the optimal encoding mode.
[0068] In the embodiment of the present application, the calculation expression of the encoding cost of each available encoding mode is:
[0069] ;
[0070] Wherein, represents the distortion degree of the encoded image compared with the original image, which is usually represented by the sum of absolute differences (SAD) or the sum of squared differences (SSD); represents the output code rate, which is used to reflect the compression efficiency; represents the Lagrange constant, which is determined by the quantization parameter.
[0071] Specifically, the known encoding information of the video frame includes encoding modes of the encoded pixel blocks in the video frame, motion vectors of the encoded pixel blocks, and absolute error sums, and the optimal encoding modes include intra-frame encoding modes and inter-frame encoding modes.
[0072] Specifically, all the encoding modes are classified according to the known encoding information of the video frame, and a classification result is obtained, including:
[0073] All the encoding modes of the encoded pixel blocks in the known encoding information are taken as a whole to obtain a first set;
[0074] The intra-frame encoding modes in the first set are sorted according to directions and taken as a whole to obtain a second set;
[0075] All the encoding modes that have appeared around each pixel block in the video frame and all the encoding modes that have appeared in a same-position pixel block in a previous frame are counted to obtain a counting result;
[0076] The counting result is classified according to the second set to obtain a classification result.
[0077] In the embodiments of the present application, all the encoding modes of the encoded pixel blocks in the known encoding information are taken as a whole to obtain the first set, which is denoted as , wherein, respectively represent nine 4x4 intra-frame encoding modes, which are a vertical mode, a horizontal mode, a mean value mode, a left-down diagonal mode, a right-down diagonal mode, a vertical right-biased mode, a horizontal down-biased mode, a vertical left-biased mode, and a horizontal up-biased mode, as shown in Figure 2 , respectively represent four 16x16 intra-frame encoding modes, which are a vertical mode, a horizontal mode, a mean value mode, and a diagonal mode, as shown in Figure 3 , respectively represent inter-frame encoding modes, such as 4x4, 8x16, and the like;
[0078] The intra-frame encoding modes in the first set are sorted according to a scheme and taken as a whole to obtain the second set, which is denoted as , .
[0079] It should be noted that, in the embodiment of the present application, since the encoding order is from top to bottom and from left to right, the pixel blocks around the current pixel block are the left pixel block, the upper left pixel block, the upper pixel block and the upper right pixel block, and the left pixel block, the upper left pixel block, the upper pixel block and the upper right pixel block have been encoded when the current pixel block is encoded, therefore, all the encoding modes appearing around each pixel block in the video frame are counted, that is, the encoding modes selected by the left pixel block, the upper left pixel block, the upper pixel block and the upper right pixel block of the current pixel block are counted.
[0080] Specifically, the classification of the counting result according to the second set comprises:
[0081] determining whether all the intra encoding modes in the counting result are located in the second set, and classifying all the intra encoding modes in the counting result according to the determination result:
[0082] when the determination result is that there is an intra encoding mode not located in the second set, the intra encoding mode not located in the second set is classified as an intra large mode;
[0083] when the determination result is that there is an intra encoding mode located in the second set, two intra encoding modes adjacent to the intra encoding mode located in the second set are extracted from the second set, and the extracted intra encoding modes and the intra encoding mode located in the second set are classified as an intra large mode, and the intra encoding modes not adjacent to the intra encoding mode located in the second set are classified as an intra small mode in the second set;
[0084] all the inter encoding modes corresponding to the encoded pixel blocks with the motion vector less than the first threshold value and the absolute error sum less than the second threshold value are classified as an inter large mode, and all the inter encoding modes corresponding to the encoded pixel blocks with the motion vector greater than or equal to the first threshold value and / or the absolute error sum greater than or equal to the second threshold value are classified as an inter small mode.
[0085] the size of the pixel block to be encoded in the video frame and the bit depth of the video frame are used to calculate the first threshold value and the second threshold value;
[0086] all the inter encoding modes corresponding to the encoded pixel blocks with the motion vector less than the first threshold value and the absolute error sum less than the second threshold value are classified as an inter large mode, and all the inter encoding modes corresponding to the encoded pixel blocks with the motion vector greater than or equal to the first threshold value and / or the absolute error sum greater than or equal to the second threshold value are classified as an inter small mode.
[0087] Specifically, the calculation expression of the first threshold value and the second threshold value using the size of the pixel block to be encoded in the video frame and the bit depth of the video frame is:
[0088] ;
[0089] ;
[0090] wherein, Indicates the first threshold. This represents the second threshold. This represents the width of the pixel block to be encoded in the video frame. This represents the height of the pixel block to be encoded in the video frame. Indicates the bit depth of a video frame.
[0091] In this embodiment of the invention, the pixel block to be encoded is set as follows: Its input size is 1920x1080, and its bit depth is 8. Based on the above calculation expression, the first threshold can be calculated. The value is 22.3, the second threshold. The value is 1500, and the information of the surrounding encoded pixel blocks is as follows:
[0092] Left pixel block: ;
[0093] Top left pixel block: ; ; ;
[0094] Top pixel block: ; ; ;
[0095] Top right pixel block: ;
[0096] Previous frame's corresponding pixel block: ; ; ;
[0097] It can be seen that the pixel block in the same position of the previous frame is coded in inter-frame mode, while the intra-frame coded mode is used. The conditions are met; the left pixel block is intra-frame mode coded and is Intra-frame coding mode, therefore intra-frame coding mode Add Intra-Frame Large Mode The top left pixel block is in inter-frame coding mode, while the intra-frame coding mode is in intra-frame coding mode. The conditions are met; the upper pixel block is coded in inter-frame mode, and the intra-frame coded mode is used. The conditions are met; the upper right pixel block is intra-frame mode coded and is Intra-frame coding modes, therefore, intra-frame coding modes 2, 3, 7, and 8 are added to the intra-frame big mode. In addition; at the same time, the surrounding intra-frame coding modes are also added, that is, additionally added. Two intra-frame coding modes; after the above steps, all modes can be divided into the following four sets:
[0098] ;
[0099] ;
[0100] ;
[0101] ;
[0102] wherein, represents an intra large mode, represents an intra small mode, represents an inter large mode, represents an inter small mode.
[0103] Specifically, the optimal coding mode is selected in the classification result, comprising:
[0104] calculating intra features and inter features between the coded pixel block and the pixel block to be coded;
[0105] inputting the classification result, the intra features, the inter features and the motion vector module length of the coded pixel block into the classification model for mode selection to obtain an optimal coding mode of one class;
[0106] selecting an optimal coding mode in the optimal coding mode of one class through an iterative manner.
[0107] In the embodiment of the present application, the intra features and the inter features are obtained by calculating the sum of squared errors, which is used to measure the difference between two pixel blocks, and the smaller the value of the sum of squared errors, the smaller the difference between the two pixel blocks, and vice versa, the calculation expression is:
[0108] ;
[0109] wherein, represents the sum of squared errors between , and represents the coded pixel block, represents the pixel block to be coded, represents the pixel position in the pixel block.
[0110] It should be noted that the motion vector (MV) is used to describe the displacement direction and size of the pixel block between adjacent frames, and its module length can reflect the motion intensity of the current image. When the MV module length is larger, it means that the reference pixel block is farther away from the current pixel block, that is, the current motion is more intense, and vice versa, which means that the current motion is more gentle. Assuming that the coordinates of the current pixel block are , the coordinates of the reference pixel block are , the motion vector between the two pixel blocks is , and the motion vector module length is 1.
[0111] In the embodiment of the present application, the classification model can be any conventional machine learning classification model, including but not limited to K-Nearest Neighbor algorithm, Support Vector Machine, Decision Tree, Random Forest, etc., and the classification model outputs an optimal one-class coding mode, which can be an intra large mode or an intra small mode or an inter large mode or an inter small mode.
[0112] In the embodiment of the present application, the optimal one-class coding mode is selected by traversal, specifically, the coding cost of each coding mode is calculated in the optimal one-class coding mode, and the coding mode with the minimum coding cost is taken as the optimal coding mode.
[0113] After step 3, the optimal coding mode, motion vector and other information are saved as the coding information of the current pixel block for subsequent encoding.
[0114] The feasibility of the intra-inter mode selection method provided by the embodiment of the present application in the multi-functional video codec is as follows:
[0115] All frames use All Intra mode, so finally there are only two types of intra large mode A and intra small mode B;
[0116] When selecting the optimal coding mode, a type of coding mode is randomly selected from the two types of A and B as the optimal one-class coding mode, which is used to simulate the machine learning system in the worst state;
[0117] In the experiment, high-definition video data (720p) and ultra-high-definition video data (1080p) are encoded for 4 frames on the original multi-functional video codec and the multi-functional video codec with the method, and the performance is tested, and the experimental results are shown in Tables 1, 2 and 3 as follows:
[0118] Table 1 Performance table of the encoder before optimization
[0119] ;
[0120] Table 2 Performance table of the encoder after optimization
[0121] ;
[0122] Table 3 Comparison table of performance before and after optimization
[0123] ;
[0124] From the experimental data, it can be seen that the method shortens the encoding time by 49.56% at the cost of increasing the code rate by 2.69% and losing the encoding quality by 0.05%.
[0125] The embodiment of the present application inputs to-be-encoded video data into a video codec, wherein the to-be-encoded video data comprises a plurality of video frames; each video frame is judged respectively to obtain a judgment result; an optimal encoding mode is selected according to the judgment result; when the judgment result is an I frame or a first P frame or a B frame, the optimal encoding mode is selected through a conventional mode selection manner; when the judgment result is a non-I frame or a first P frame or a B frame, all encoding modes are classified according to known encoding information of the video frame to obtain a classification result, and the optimal encoding mode is selected in the classification result; compared with the prior art, the embodiment of the present application classifies and filters all encoding modes by using known encoding information of the video frame when the video codec selects an encoding mode, thereby reducing the number of modes that need to be traversed, improving the execution efficiency of encoding mode selection, and further reducing the time cost of the video codec in mode selection.
[0126] Corresponding to the intra-inter mode selection method described in the above embodiment, as shown in FIG. 1, the embodiment of the present application further provides an intra-inter mode selection device 100, which comprises: Figure 4
[0127] An input module 101 is configured to input to-be-encoded video data into a video codec, wherein the to-be-encoded video data comprises a plurality of video frames;
[0128] A judgment module 102 is configured to judge each video frame respectively to obtain a judgment result;
[0129] A selection module 103 is configured to select an optimal encoding mode according to the judgment result;
[0130] When the judgment result is an I frame or a first P frame or a B frame, the optimal encoding mode is selected through a conventional mode selection manner;
[0131] When the judgment result is a non-I frame or a first P frame or a B frame, all encoding modes are classified according to known encoding information of the video frame to obtain a classification result, and the optimal encoding mode is selected in the classification result.
[0132] It should be noted that the information interaction and execution process between the above-described devices / units are based on the same concept as the method embodiments of the present application, and the specific functions and technical effects brought by the same can be referred to the method embodiments part, which will not be described here.
[0133] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0134] This invention also provides a terminal device, such as... Figure 5 As shown, the terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 5 The diagram shows only one processor, a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100. When the processor D100 executes the computer program D102, it implements the above-described intra-frame / inter-frame mode selection method.
[0135] The terminal device D10 can be a desktop computer, laptop, handheld computer, server, server cluster, or cloud server, etc. This terminal device may include, but is not limited to, a processor D100 and a memory D101. Those skilled in the art will understand that... Figure 5 This is merely an example of terminal device D10 and does not constitute a limitation on terminal device D10. It may include more or fewer components than shown in the figure, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0136] The processor D100 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0137] The memory D101 can be an internal storage unit of the terminal device D10 in some embodiments, for example, a hard disk or a memory of the terminal device D10. The memory D101 can also be an external storage device of the terminal device D10 in other embodiments, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory D101 can include both the internal storage unit and the external storage device of the terminal device D10. The memory D101 is used to store an operating system, application programs, a boot loader, data, and other programs, for example, program codes of the computer programs, etc. The memory D101 can also be used to temporarily store data that has been output or is to be output.
[0138] It should be noted that the information interaction, execution process, etc. between the above apparatuses / units can be based on the same concept as the method embodiments of the present application, and the specific functions and the technical effects brought by the specific functions can be referred to the method embodiments part, which will not be described herein.
[0139] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or software functional unit. In addition, the specific names of each functional unit and module are only for easy distinction, and do not limit the protection scope of the application. The specific working process of the unit and module in the system can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here.
[0140] The embodiment of the present application also provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to realize the method for selecting an intraframe interframe mode.
[0141] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on this understanding, all or part of the processes in the foregoing embodiment methods can be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. The computer program can implement the steps of each method embodiment when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium at least includes any entity or device capable of carrying the computer program code to the construction device / terminal equipment, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium. For example, U disk, mobile hard disk, magnetic disk or optical disk, etc.
[0142] The above is the preferred embodiment of the present application. It should be noted that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should also be considered as the protection scope of the present application.
Claims
1. A method for selecting intra-frame and inter-frame modes, characterized in that, For video codecs, the intra-frame / inter-frame mode selection method includes: Step 1: Input the video data to be encoded into the video codec, wherein the video data to be encoded includes multiple video frames; Step 2: Analyze each video frame individually to obtain the judgment result; Step 3: Select the optimal encoding mode based on the judgment result; When the judgment result is an I-frame, the first P-frame, or a B-frame, the optimal encoding mode is selected through the conventional mode selection method. When the judgment result is not an I-frame, the first P-frame, or a B-frame, all encoding modes are classified according to the known encoding information of the video frame to obtain the classification result, and the optimal encoding mode is selected from the classification result. Based on the known encoding information of the video frames, all encoding modes are classified to obtain classification results, including: By treating all the encoding patterns of the encoded pixel blocks in the known encoding information as a whole, a first set is obtained; The intra-frame coding modes in the first set are sorted by direction and then treated as a whole to obtain the second set; The statistical results are obtained by statistically analyzing all the encoding patterns that have appeared around each pixel block in the video frame and all the encoding patterns that have appeared in the same pixel block in the previous frame. The statistical results are classified according to the second set to obtain the classification results, including: Determine whether all intra-frame coding modes in the statistical results are located within the second set, and classify all intra-frame coding modes in the statistical results according to the determination result: When the determination result is that there is an intra-frame coding mode that is not located in the second set, the intra-frame coding mode that is not located in the second set is classified as an intra-frame big mode; When the determination result is that there is an intra-frame coding mode in the second set, extract two intra-frame coding modes that are adjacent to the intra-frame coding mode in the second set, and classify the extracted intra-frame coding mode and the intra-frame coding mode in the second set as intra-frame large mode. In the second set, classify the intra-frame coding modes that are not adjacent to the intra-frame coding mode in the second set as intra-frame small mode. Classify all inter-frame coding patterns in the statistical results using the motion vectors and absolute errors in the known coding information: The first threshold and the second threshold are calculated using the size of the pixel block to be encoded in the video frame and the bit depth of the video frame; All inter-frame patterns corresponding to encoded pixel blocks whose motion vectors are less than the first threshold and whose absolute errors are less than the second threshold are classified as large inter-frame patterns, and all inter-frame patterns corresponding to encoded pixel blocks whose motion vectors are greater than or equal to the first threshold and / or whose absolute errors are greater than or equal to the second threshold are classified as small inter-frame patterns.
2. The intra-frame / inter-frame mode selection method according to claim 1, characterized in that, The optimal encoding mode is selected through conventional mode selection methods, including: Iterate through all available encoding modes in the video codec; Calculate the encoding cost for each available encoding mode and select the encoding mode with the lowest encoding cost as the optimal encoding mode.
3. The intra-frame / inter-frame mode selection method according to claim 1, characterized in that, The known coding information of the video frame includes the coding mode of the encoded pixel blocks in the video frame, the motion vector of the encoded pixel blocks, and the sum of absolute errors. The optimal coding mode includes intra-frame coding mode and inter-frame coding mode.
4. The intra-frame / inter-frame mode selection method according to claim 1, characterized in that, The calculation expressions for the first threshold and the second threshold, using the size of the pixel block to be encoded in the video frame and the bit depth of the video frame, are as follows: ; ; in, Indicates the first threshold. This represents the second threshold. This represents the width of the pixel block to be encoded in the video frame. This represents the height of the pixel block to be encoded in the video frame. Indicates the bit depth of a video frame.
5. The intra-frame / inter-frame mode selection method according to claim 4, characterized in that, Selecting the optimal encoding pattern from the classification results includes: Calculate the intra-frame and inter-frame features between the encoded pixel block and the pixel block to be encoded; The classification results, intra-frame features, inter-frame features, and motion vector magnitudes of the encoded pixel blocks are input into the classification model for mode selection to obtain the optimal encoding mode. The optimal encoding pattern is selected from the best encoding patterns by traversing through them.
6. An intra-frame / inter-frame mode selection device, characterized in that, Used for video codecs, including: The input module is used to input the video data to be encoded into the video codec, wherein the video data to be encoded includes multiple video frames; The judgment module is used to judge each video frame separately and obtain the judgment result; The selection module is used to select the optimal encoding mode based on the judgment result; When the judgment result is an I-frame, the first P-frame, or a B-frame, the optimal encoding mode is selected through the conventional mode selection method. When the judgment result is not an I-frame, the first P-frame, or a B-frame, all encoding modes are classified according to the known encoding information of the video frame to obtain the classification result, and the optimal encoding mode is selected from the classification result. Based on the known encoding information of the video frames, all encoding modes are classified to obtain classification results, including: By treating all the encoding patterns of the encoded pixel blocks in the known encoding information as a whole, a first set is obtained; The intra-frame coding modes in the first set are sorted by direction and then treated as a whole to obtain the second set; The statistical results are obtained by statistically analyzing all the encoding patterns that have appeared around each pixel block in the video frame and all the encoding patterns that have appeared in the same pixel block in the previous frame. The statistical results are classified according to the second set to obtain the classification results, including: Determine whether all intra-frame coding modes in the statistical results are located within the second set, and classify all intra-frame coding modes in the statistical results according to the determination result: When the determination result is that there is an intra-frame coding mode that is not located in the second set, the intra-frame coding mode that is not located in the second set is classified as an intra-frame big mode; When the determination result is that there is an intra-frame coding mode in the second set, extract two intra-frame coding modes that are adjacent to the intra-frame coding mode in the second set, and classify the extracted intra-frame coding mode and the intra-frame coding mode in the second set as intra-frame large mode. In the second set, classify the intra-frame coding modes that are not adjacent to the intra-frame coding mode in the second set as intra-frame small mode. Classify all inter-frame coding patterns in the statistical results using the motion vectors and absolute errors in the known coding information: The first threshold and the second threshold are calculated using the size of the pixel block to be encoded in the video frame and the bit depth of the video frame; All inter-frame patterns corresponding to encoded pixel blocks whose motion vectors are less than the first threshold and whose absolute errors are less than the second threshold are classified as large inter-frame patterns, and all inter-frame patterns corresponding to encoded pixel blocks whose motion vectors are greater than or equal to the first threshold and / or whose absolute errors are greater than or equal to the second threshold are classified as small inter-frame patterns.
7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the intra-frame / inter-frame mode selection method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the intra-frame / inter-frame mode selection method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
AVS fast schema selection method and device
CN101426140A
Coding information determination method of coding block and related product
CN117596392A