A coding decision method, computer equipment, device and storage medium
Through prediction and adaptive adjustment of coding strategies, the problem of long encoding decision-making time in the prior art is solved, and the encoding efficiency and speed are improved.
Patent Information
- Application Number
- CN202011524076.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2040-12-21
AI Technical Summary
When making decisions between inter-encoding mode and intra-encoding mode, existing encoders need to compare a large number of encoding parameters combinations, resulting in a long decision time and low encoding efficiency.
By obtaining the encoding strategy and pre-coding strategy of the historical encoding unit, predict the encoding cost of the unit to be encoded, select a strategy that meets the encoding cost standard for encoding, adaptively adjust the prediction order of inter- and intra-coding strategies, and exit the encoding cost prediction in advance .
Reduces the time to determine the target encoding strategy, and improves coding efficiency and speed.
Smart Images

Figure CN114650417B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video coding or image coding, and in particular to a coding decision method, computer equipment, device and storage medium. Background Art
[0002] With the continuous development of computer technology, digital multimedia technology and coding and decoding technology, videos and images are becoming more and more popular in various fields and people's daily lives. Among them, the coding mode adopted by the encoder for data (such as video data or image data) can be an inter-frame coding mode or an intra-frame coding mode. When the encoder encodes the data, it is often necessary to make a decision on the inter-frame coding mode and the intra-frame coding mode first, so as to determine the coding mode (inter-frame coding mode or intra-frame coding mode) to be used for the data from the inter-frame coding mode and the intra-frame coding mode.
[0003] At present, when making decisions on inter-frame coding mode and intra-frame coding mode, the encoder usually needs to compare all possible coding parameter combinations corresponding to the inter-frame coding mode and the coding parameter combinations corresponding to the intra-frame coding mode, and calculate the coding performance corresponding to each coding parameter combination, such as the rate-distortion cost, and then determine the coding mode to be used for the unit to be coded according to the rate-distortion cost. However, determining the coding mode to be used for data by this method consumes a lot of decision coding time, resulting in low coding efficiency. Summary of the invention
[0004] The embodiments of the present application provide a coding decision method, a computer device, an apparatus, and a storage medium, which can reduce the time for determining a target coding strategy, thereby improving coding efficiency.
[0005] The first aspect of the embodiment of the present application discloses a coding decision method, the method comprising:
[0006] Get the encoding strategy of the historical encoding unit;
[0007] Determining a prediction strategy for a coding cost of a unit to be coded according to the coding strategy of the historical coding unit and at least two preliminary coding strategies; the prediction strategy includes the at least two preliminary coding strategies and a prediction order for predicting the coding cost of the unit to be coded using the at least two preliminary coding strategies;
[0008] The prediction strategy is adopted to predict the coding cost of the unit to be encoded. When the coding cost prediction of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the unit to be encoded is encoded using the target coding strategy; the target coding strategy refers to a preliminary coding strategy among the at least two preliminary coding strategies, in which the predicted coding cost of the unit to be encoded meets the coding cost standard.
[0009] A second aspect of an embodiment of the present application discloses a coding decision device, the device comprising:
[0010] An acquisition unit, used for acquiring the encoding strategy of the historical encoding unit;
[0011] A determination unit, configured to determine a prediction strategy for a coding cost of a unit to be coded according to a coding strategy of the historical coding unit and at least two preliminary coding strategies; the prediction strategy includes the at least two preliminary coding strategies and a prediction order for predicting the coding cost of the unit to be coded using the at least two preliminary coding strategies;
[0012] A prediction unit is used to adopt the prediction strategy to predict the coding cost of the unit to be encoded. When the coding cost prediction of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the unit to be encoded is encoded using the target coding strategy; the target coding strategy refers to a preliminary coding strategy among the at least two preliminary coding strategies, in which the predicted coding cost of the unit to be encoded meets the coding cost standard.
[0013] A third aspect of an embodiment of the present application discloses a computer device, comprising a processor, a memory and a network interface, wherein the processor, the memory and the network interface are interconnected, wherein the memory is used to store a computer program, and the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method of the first aspect above.
[0014] A fourth aspect of an embodiment of the present application discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method of the first aspect.
[0015] The fifth aspect of the embodiment of the present application discloses a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method of the first aspect above.
[0016] In an embodiment of the present application, the coding strategy of the historical coding unit can be obtained, and the prediction strategy for the coding cost of the unit to be coded can be obtained based on the coding strategy of the historical coding unit and at least two preliminary coding strategies. The prediction strategy is used to predict the coding cost of the unit to be coded. When the prediction of the coding cost of the unit to be coded is completed through the target coding strategy, the prediction of the coding cost of the unit to be coded is stopped, and the unit to be coded is encoded using the target coding strategy. By implementing the above method, the prediction order of the inter-frame coding strategy and the intra-frame coding strategy can be adaptively adjusted according to the coding strategy of the historical coding unit to ensure that the coding strategy corresponding to the first order in the prediction order is as much as possible the coding strategy required when the unit to be coded is coded, and the prediction of the coding cost of the unit to be coded can be exited in advance according to different coding cost standards, which can further reduce the time for determining the target coding strategy, thereby improving the coding speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of 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.
[0018] Figure 1 It is a schematic diagram of the architecture of a coding decision system provided in an embodiment of the present application;
[0019] Figure 2 It is a flowchart of a coding decision method provided in an embodiment of the present application;
[0020] Figure 3a This is a schematic diagram of the position correspondence between a current image frame and a historical image frame provided in an embodiment of the present application;
[0021] Figure 3b is a schematic diagram of the positions of adjacent coding units provided in an embodiment of the present application;
[0022] Figure 3c It is a structural diagram of a prediction order of units to be encoded provided by an embodiment of the present application;
[0023] Figure 3d is a curve diagram showing the variation of coding distortion with coding bit rate provided in an embodiment of the present application;
[0024] Figure 4 It is a flowchart of another coding decision method provided in an embodiment of the present application;
[0025] Figure 5 It is a structural diagram of a coding decision device provided in an embodiment of the present application;
[0026] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0027] 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.
[0028] Cloud Technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0029] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0030] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use.
[0031] The present application stores the data required for coding decisions in the "cloud", and the data in the cloud can be obtained and expanded at any time according to needs. For example, when the encoder encodes data (such as video data or image data), it needs to make a decision on the coding mode (inter-frame coding mode and intra-frame coding mode) first, and the relevant data of multiple historical coding units required for making decisions on the coding mode can be stored in the "cloud". If the encoder encodes another data, the relevant data can be obtained from the "cloud" to make a decision on the coding mode.
[0032] See also Figure 1 , Figure 1 1 is a schematic diagram of the architecture of a coding decision system provided in an embodiment of the present application. The present application involves a terminal 101 and a server 102.
[0033] Taking the terminal 101 as an example, the terminal 101 can obtain the video data or image data to be encoded, and send the video data or image data to the server 102. The server 102 obtains the encoding strategy of the historical encoding unit, and obtains the prediction strategy for the encoding cost of the unit to be encoded according to the encoding strategy of the historical encoding unit and at least two preliminary encoding strategies. The server 102 will adopt the prediction strategy to predict the encoding cost of the unit to be encoded. When the encoding cost prediction of the unit to be encoded is completed through the target encoding strategy, the server 102 stops predicting the encoding cost of the unit to be encoded, and adopts the target encoding strategy to encode the unit to be encoded.
[0034] Figure 1 The terminal 101 shown can be a smart device with video processing function such as a mobile phone, a tablet computer, a laptop computer, a PDA, a mobile Internet device (MID), a wearable device, etc. The server 102 can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal 101 and the server 102 can be directly or indirectly connected by wired or wireless communication, and this application does not limit this.
[0035] In one implementation, a coding decision method provided by an embodiment of the present application can be executed by a computer device, wherein the computer device can be a terminal or a server in the above-mentioned coding decision system; its general principle is as follows: the computer device can obtain the coding strategy of the historical coding unit. According to the coding strategy of the historical coding unit and at least two preliminary coding strategies, a prediction strategy for the coding cost of the unit to be coded is obtained. The prediction strategy is adopted to predict the coding cost of the unit to be coded. When the prediction of the coding cost of the unit to be coded is completed by the target coding strategy, the prediction of the coding cost of the unit to be coded is stopped, and the unit to be coded is encoded by adopting the target coding strategy. By implementing the above method, the prediction order of the inter-frame coding strategy and the intra-frame coding strategy can be adaptively adjusted according to the coding strategy of the historical coding unit to ensure that the coding strategy corresponding to the first order in the prediction order is as much as possible the coding strategy required when the unit to be coded is coded, and the prediction of the coding cost of the unit to be coded can be exited in advance according to different coding cost standards, which can further reduce the time for determining the target coding strategy, thereby improving the coding speed.
[0036] The implementation details of the technical solution of the embodiment of the present application are described in detail below:
[0037] See also Figure 2 , Figure 2 1 is a flow chart of a coding decision method provided by an embodiment of the present application. The method is applied to a computer device and can be executed by the computer device, wherein the computer device can be a server or a terminal. Figure 2 As shown, the coding decision method may include:
[0038] S201: Obtain the encoding strategy of the historical encoding unit.
[0039] The coding strategy may include an inter-frame coding strategy or an intra-frame coding strategy.
[0040] In one implementation, a computer device may obtain a coding strategy of a historical coding unit. Specifically, in order to obtain the coding strategy of a historical coding unit, the historical coding unit may be determined first. The image frame to which the historical coding unit belongs may be a historical image frame or a current image frame. If the current image frame is an image frame to which the unit to be coded belongs, then the historical image frame is equivalent to an encoded image frame before the current image frame. For example, if the current image frame is the 10th frame, then the historical image frame may be an image frame before the 10th frame, such as the 9th frame, the 8th frame, and so on.
[0041] Optionally, in the case that the image frame to which the historical coding unit belongs is a historical image frame, the position information of the unit to be coded in the current image frame may be obtained first, and the position information indicates the position of the unit to be coded in the current image frame, and the position of the unit to be coded in the current image frame may be referred to as the first position, and then the position corresponding to the first position in the historical image frame is determined based on the first position, and the position corresponding to the first position in the historical image frame may be referred to as the second position, and the coding unit at the second position in the historical image frame is the historical coding unit. The first position may be the coordinate information of the unit to be coded in the current image frame, and correspondingly, the second position may also be the coordinate information, and the coordinate information corresponding to the first position in the current image frame and the coordinate information corresponding to the second position in the historical image frame are the same, that is, the position of the unit to be coded in the current image frame is the same as the position of the historical coding unit in the historical image frame. It can be understood that the prediction order of the unit to be encoded is very likely to be the same as the prediction order adopted by the encoding unit at the same position as the unit to be encoded in the historical image frame. Therefore, the encoding strategy of the encoding unit at the same position as the unit to be encoded in the historical image frame can be obtained, so as to facilitate the subsequent use of the encoding strategy to determine the prediction order of the unit to be encoded.
[0042] For example, if Figure 3a As shown, the current image frame can be Figure 3a In the image marked by 301, the historical image frame can be as follows Figure 3a The image marked by 302, the image marked by 301 or the block in the image marked by 302 can be understood as a coding unit, such as the A1 area, the A2 area, and the A3 area in the image marked by 301 are different coding units, and the B1 area, the B2 area, and the B3 area in the image marked by 302 are different coding units. For example, if the unit to be coded is the A1 area in the image marked by 301, then the B1 area at the same position as the A1 area in the image marked by 302 is the historical coding unit. For another example, if the unit to be coded is the A3 area in the image marked by 301, then the B3 area at the same position as the A3 area in the image marked by 302 is the historical coding unit.
[0043] Optionally, in the case that the image frame to which the historical coding unit belongs is the current image frame, the adjacent coding unit of the unit to be coded in the coded units of the current image frame can be determined as the historical coding unit. Among them, the adjacent coding unit can be any coded coding unit in the current image frame whose distance from the unit to be coded is less than a certain threshold, which is not limited in the present application. It can be understood that the prediction order of the unit to be coded is very likely to be the same as the prediction order used by the image frame that is closer to the unit to be coded. Therefore, when determining the historical coding unit, the coded coding unit with a smaller distance to the unit to be coded can be selected as much as possible. For example, the above threshold can be set to 1, that is, any coded coding unit whose distance between the historical coding unit and the unit to be coded is less than 1.
[0044] For example, if Figure 3b The image marked by 30 in the image is the current image frame, wherein each box in the image represents a coding unit. Taking the coding unit P in the image marked by 30 as the unit to be coded as an example, assuming that the adjacent coding unit is any coded coding unit in the current image frame whose distance to the unit to be coded is less than 1, it can be obtained from the following: Figure 3b The historical coding units are determined in the image marked by 31. For the coding units other than the coding unit P in the image marked by 31, all of them may have been coded, or some of them may have been coded. For example, Figure 3b All adjacent coding units of the coding unit P in the image marked by 32 in FIG. 1 are already coded, and the coded coding units include S1, S2, S3, S4, S5, S6, S7, and S8, as shown in FIG. Figure 3b Some of the adjacent coding units of the coding unit P in the image marked by 33 are already coded, and the coded coding units include S9, S10, S11, and S12. Therefore, the coded coding units may be first obtained from the image marked by 32 or the image marked by 33, and then the historical coding units may be determined from the coded coding units.
[0045] S202: Determine a prediction strategy for the coding cost of the unit to be coded according to the coding strategy of the historical coding unit and at least two preliminary coding strategies.
[0046] Among them, the prediction strategy may include at least two preliminary coding strategies, and the prediction order of using at least two preliminary coding strategies to predict the coding cost of the coding unit to be coded. If the at least two preliminary coding strategies may include an inter-frame coding strategy and an intra-frame coding strategy. Then, it can be understood that the prediction order of using at least two preliminary coding strategies to predict the coding cost of the coding unit to be coded may be the inter-frame coding strategy and the intra-frame coding strategy in sequence, and the prediction order may also be the intra-frame coding strategy and the inter-frame coding strategy in sequence. Figure 3cAs shown, for the coding unit to be coded, if the inter-frame coding strategy is not preferentially used, the prediction order is the intra-frame coding strategy and the inter-frame coding strategy in sequence. If the inter-frame coding strategy is preferentially used, the prediction order is the inter-frame coding strategy and the intra-frame coding strategy in sequence. Compared with the fixed prediction order existing in the existing encoder, such as first performing the inter-frame coding strategy on the coding unit to be coded and then the intra-frame coding strategy, or first performing the intra-frame coding strategy on the coding unit to be coded and then the inter-frame coding strategy. The present application can adaptively adjust the prediction order of the inter-frame coding strategy and the intra-frame coding strategy according to statistical features, for example, according to the coding strategies of multiple historical coding units, so as to ensure that the coding strategy corresponding to the first order in the prediction order is as much as possible the coding strategy required when the coding unit to be coded is coded.
[0047] In one implementation, according to the coding strategy of the historical coding unit and at least two preliminary coding strategies, namely the intra-frame coding strategy and the inter-frame coding strategy, the specific implementation of obtaining the prediction strategy of the coding cost for the coding unit to be coded can be: an initial value B and thresholds A and C can be set, and A < B < C, where the threshold A is the threshold corresponding to preferentially using the intra-frame coding strategy, and the threshold C is the threshold corresponding to preferentially using the inter-frame coding strategy. The prediction order of the Nth coding unit (i.e., the coding unit to be coded) of the current image frame can be understood as follows. If the coding strategy of the historical coding unit is the intra-frame coding strategy, then B new = B old - rou × 1, where rou is the update rate. That is, when the coding strategy of the historical coding unit is the intra-frame coding strategy, the B value is updated once, and the update rule is that the B value minus the rou value. If the coding strategy of the historical coding unit is the inter-frame coding strategy, then B new = B old + rou × 1, that is, when the coding strategy of the historical coding unit is the intra-frame coding strategy, the B value is also updated once, but the update rule is that the B value plus the rou value. Then, according to the size relationship between the updated B value and the thresholds A and C, the prediction order of the Nth coding unit is determined. Specifically, if B > C exists, the prediction order in the prediction strategy of the coding unit to be coded is the inter-frame coding strategy and the intra-frame coding strategy in sequence; if B < A exists, the prediction order in the prediction strategy of the coding unit to be coded is the intra-frame coding strategy and the inter-frame coding strategy in sequence; if B > C or B < A does not exist, the default prediction order is not modified. Among them, the default prediction order can refer to the prediction order of the predecessor coding unit, and the predecessor coding unit can be the (N - 1)th coding unit. Then, the prediction order of the predecessor coding unit is the prediction order of the (N - 1)th coding unit.
[0048] Among them, the initial value B, threshold A, threshold C and update rate rou can be set in advance, and the corresponding values can be set as required, which is not limited in this application.
[0049] For example, A, B, and C are set to 15, 20, and 25 respectively, and the update rate is 2. Assume that the prediction order of the Nth coding unit is determined, and after processing the first N-1 coding units, the initial value B is updated to 22, that is, B old =22. If the encoding strategy of the historical encoding unit is an intra-frame encoding strategy, then B new =B old -rou×1=22-2=20, and 20<25, 20>15, then the prediction order of the N-1th coding unit is used; if the coding strategy of the obtained historical coding unit is the inter-frame coding strategy, then B new =B old +rou×1=22+2=25, and 24<25, 24>15, the prediction order of the N-1th coding unit is used.
[0050] For example, A, B, and C are set to 15, 20, and 25 respectively, and the update rate is 2. Assume that the prediction order of the Nth coding unit is determined, and after processing the first N-1 coding units, the initial value B is updated to 26, that is, B old =26. If the encoding strategy of the historical encoding unit is an intra-frame encoding strategy, then B new =B old -rou×1=26-2=24, and 24<25, 24>15, then the prediction order of the N-1th coding unit is used; if the coding strategy of the obtained historical coding unit is the inter-frame coding strategy, then B new =B old +rou×1=26+2=28, and 28>25, then, considering that threshold C is the threshold corresponding to the priority use of inter-frame coding strategy. Therefore, no matter what the prediction order of the N-1th coding unit is, the prediction order of the Nth coding unit is inter-frame coding strategy and intra-frame coding strategy.
[0051] S203: adopting a prediction strategy to predict the coding cost of the coding unit to be coded. When the coding cost prediction of the coding unit to be coded is completed through the target coding strategy, stop predicting the coding cost of the coding unit to be coded, and adopt the target coding strategy to encode the coding unit.
[0052] The target coding strategy refers to a coding strategy in which the coding cost of the unit to be coded is predicted to meet the coding cost standard among at least two preliminary coding strategies. The at least two preliminary coding strategies may include an inter-frame coding strategy and an intra-frame coding strategy.
[0053] In one implementation, a prediction strategy may be adopted to predict the coding cost of a coding unit to be coded, that is, the coding cost of the coding unit to be coded may be predicted according to the prediction order in the prediction strategy. If the prediction order is the inter-frame coding strategy and the intra-frame coding strategy, the coding cost of the coding unit to be coded may be predicted according to the inter-frame coding strategy first, and then the coding cost of the coding unit to be coded may be predicted according to the intra-frame coding strategy; if the prediction order is the intra-frame coding strategy and the inter-frame coding strategy, the coding cost of the coding unit to be coded may be predicted according to the intra-frame coding strategy first, and then the coding cost of the coding unit to be coded may be predicted according to the inter-frame coding strategy. In the process of predicting the coding cost of the coding unit to be coded according to the prediction order in the prediction strategy, when the coding cost prediction of the coding unit to be coded is completed by a certain coding strategy (intra-frame coding strategy or inter-frame coding strategy), it may be detected whether the coding cost of the coding unit to be coded obtained by the certain coding strategy meets the coding cost standard. If it meets the standard, the prediction of the coding cost of the coding unit to be coded may be stopped, and the coding unit to be coded may be encoded by the certain coding strategy. It can be seen that the above method can reduce the time for determining the target coding strategy, that is, the prediction of the coding cost of the coding unit to be coded can be exited in advance, saving coding prediction time, thereby improving the coding speed.
[0054] Among them, different encoding cost standards can be set for different preliminary encoding strategies.
[0055] Optionally, when the preliminary coding strategy is an inter-frame coding strategy, the coding cost criterion may specifically be: the pixel variance corresponding to the unit to be coded is greater than a measured coding error, wherein the measured coding error is the smallest predicted coding error among the predicted coding errors of the unit to be coded under all inter-frame coding sub-strategies (at least two inter-frame coding sub-strategies) of the inter-frame coding strategy.
[0056] Optionally, when the preliminary coding strategy is an inter-frame coding strategy, the specific implementation of the coding cost standard can also be: pre-set a first threshold and a second threshold, wherein the first threshold and the second threshold are correlated, and the corresponding correlation coefficient can be set as required, which is not limited in this application. For example, the correlation coefficient is 0.5, that is, the second threshold = 0.5 × the first threshold. Then, the coding cost standard can be that the pixel variance corresponding to the unit to be coded is greater than the first threshold, and the measured coding error is less than the second threshold.
[0057] In one implementation, when the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the prediction of the coding cost of the unit to be coded is completed by the inter-frame coding strategy, the pixel variance corresponding to the unit to be coded and the prediction coding error of the unit to be coded under all the inter-frame coding sub-strategies of the inter-frame coding strategy can be obtained. The acquisition of the pixel variance and the prediction coding error can refer to the following description, which is not repeated here. Then, the smallest prediction coding error of the prediction coding error of the unit to be coded under all the inter-frame coding sub-strategies can be determined as the measured coding error. Then, it is determined whether the relationship between the pixel variance and the measured coding error meets the coding cost standard when the preliminary coding strategy is the inter-frame coding strategy. If the coding cost of the unit to be coded predicted by the inter-frame coding strategy meets the coding cost standard, it also means that there is a high probability that the texture of the unit to be coded is more complex, and the inter-frame coding strategy has found a matching block. Using the intra-frame coding strategy will consume more bit rate than the inter-frame coding strategy. Then, the prediction of the coding cost of the unit to be coded can be stopped, that is, it is no longer necessary to use the intra-frame coding strategy to predict the coding cost of the unit to be coded, saving coding prediction time. The inter-frame coding strategy is the target coding strategy, and finally it can be determined to use the inter-frame coding strategy to encode the coding unit.
[0058] Among them, the pixel variance corresponding to the unit to be encoded may refer to the variance of the pixel values in the unit to be encoded. For example, assuming that the unit to be encoded is an image with an image size of 8×8, there are 8×8 pixel values in the unit to be encoded. The variance of the 8×8 pixel values is calculated, and the result obtained is the pixel variance corresponding to the unit to be encoded.
[0059] The prediction coding error may refer to the error between the current image frame where the unit to be coded is located before and after coding compression, which may be reflected in the pixel value. Specifically, the prediction coding error may be the sum of the difference between all pixel values in the current image frame before and after coding compression. It should be noted that under different inter-frame coding sub-strategies, the coding compression effect on the image is also different, that is, the prediction coding error generated by the unit to be coded under different inter-frame coding sub-strategies is also different.
[0060] For different inter-frame coding sub-strategies, it may mean that each inter-frame coding sub-strategy corresponds to a different coding parameter combination, wherein the coding parameters in the coding parameter combination may include a division mode parameter, a quantization parameter, a coding strategy, etc., and may also include other parameters, which are not limited in this application. Then, the coding parameter combination is a combination of multiple coding parameters. Among them, the above-mentioned division mode parameter refers to the use of different division sizes for an image block. For example, a 64×64 image block can be encoded using 1 64×64 coding unit, 4 32×32 coding units, or 64 8×8 coding units. The above-mentioned quantization parameter corresponds to the quantization step size in video or image coding. For example, for luminance coding, the quantization parameter value ranges from 0 to 51; for chrominance coding, the quantization parameter value ranges from 0 to 39. The above-mentioned coding strategy is an inter-frame coding strategy or an intra-frame coding strategy.
[0061] For example, the coding parameters in the coding parameter combination corresponding to the inter-frame coding sub-strategy include a partition mode parameter, a quantization parameter, and a coding strategy. It should be noted that for the coding parameter combination of the inter-frame coding sub-strategy, the coding strategy in the coding parameter combination is the inter-frame coding strategy, and correspondingly, for the coding parameter combination of the intra-frame coding sub-strategy, the coding strategy in the coding parameter combination is the intra-frame coding strategy. Assuming that the partition mode parameters include E1, E2, E3, E4, and E5, and the quantization parameters include F1, F2, F3, and F4, the partition mode parameters and the quantization parameters can be arranged and combined to obtain multiple parameter combinations. For example, three of the multiple parameter combinations can be (E1, F1), (E1, F2), and (E1, F1), then the coding parameter combination corresponding to the inter-frame coding sub-strategy can be (E1, F1, inter-frame coding strategy), (E1, F2, inter-frame coding strategy), and (E1, F1, inter-frame coding strategy). Different inter-frame coding sub-strategies correspond to different coding parameter combinations, so the prediction coding errors generated by the to-be-coded unit under different inter-frame coding sub-strategies are also different.
[0062] Optionally, when the preliminary coding strategy is an intra-frame coding strategy, the coding cost standard can specifically be: the minimum rate-distortion cost of the rate-distortion cost of the unit to be coded under all intra-frame coding sub-strategies (at least two intra-frame coding sub-strategies) of the intra-frame coding strategy is less than the minimum rate-distortion cost of the rate-distortion cost corresponding to all inter-frame coding sub-strategies (at least two inter-frame coding sub-strategies) of the inter-frame coding strategy for the unit to be coded.
[0063] The intra-frame coding sub-strategy can be understood in the same way as the above-mentioned inter-frame coding sub-strategy. It is only necessary to replace the coding strategy in the coding parameters from the inter-frame coding strategy to the intra-frame coding strategy.
[0064] In one implementation, when the prediction strategy is used to predict the coding cost of the coding unit to be coded, when it is detected that the coding cost prediction of the coding unit to be coded is completed by the intra-frame coding strategy, the rate-distortion cost of the coding unit to be coded under all intra-frame coding sub-strategies of the intra-frame coding strategy can be obtained, and the rate-distortion cost of the coding unit to be coded under all inter-frame coding sub-strategies of the inter-frame coding strategy can also be obtained, and the minimum rate-distortion cost (for convenience of description, referred to as the first rate-distortion cost) among the rate-distortion costs corresponding to all intra-frame coding sub-strategies and the minimum rate-distortion cost (for convenience of description, referred to as the second rate-distortion cost) among the rate-distortion costs corresponding to all inter-frame coding sub-strategies are determined. The acquisition of the rate-distortion cost can refer to the following description, which is not repeated here. After determining the first rate distortion cost and the second rate distortion cost, the magnitude of the first rate distortion cost and the second rate distortion cost can be determined. If the first rate distortion cost is greater than the second rate distortion cost, it means that the coding cost of the unit to be coded predicted by the intra-frame coding strategy meets the coding cost standard, and the coding cost prediction of the unit to be coded can be stopped, that is, there is no need to use the inter-frame coding strategy to predict the coding cost of the unit to be coded, and the coding cost prediction of the unit to be coded can be exited in advance. The intra-frame coding strategy is the target coding strategy, and finally it can be determined to use the intra-frame coding strategy to encode the unit to be coded.
[0065] It should be understood that, in the process of video encoding or image encoding, when predicting the coding cost of the coding unit to be coded, predicting the coding cost of the coding unit to be coded by the inter-coding strategy may include two predictions, the first being a rough prediction and the second being a fine prediction. Optionally, the difference between the rough prediction and the fine prediction lies in the number of inter-coding sub-strategies or the number of intra-coding sub-strategies used when predicting the coding cost of the coding unit to be coded, and the number of inter-coding sub-strategies or the number of intra-coding sub-strategies used for the fine prediction is greater than the number of inter-coding sub-strategies or the number of intra-coding sub-strategies used for the rough prediction. For example, the number of inter-coding sub-strategies used for the fine prediction is 50, while the number of inter-coding sub-strategies used for the rough prediction may be 20.
[0066] It should be noted that, in the embodiment of the present application, the cost accuracy of the rate-distortion cost of the unit to be encoded under at least two intra-frame coding sub-strategies is higher than the cost accuracy of the rate-distortion cost of the unit to be encoded under at least two inter-frame coding sub-strategies. According to the above description, it can be understood that when the coding cost of the unit to be encoded is predicted by the inter-frame coding strategy, a coarse prediction is used, and when the coding cost of the unit to be encoded is predicted by the intra-frame coding strategy, a fine prediction is used. Then, in the embodiment of the present application, after the first rate-distortion cost obtained by the fine prediction is greater than the second rate-distortion cost obtained by the coarse prediction, the prediction of the coding cost of the unit to be encoded can be stopped, that is, the prediction of the coding cost of the unit to be encoded is exited in advance, thereby avoiding the fine prediction of the coding cost of the unit to be encoded by the inter-frame coding strategy, avoiding a lot of invalid exhaustive enumeration, saving time, and improving the encoding speed.
[0067] In one implementation, determining the minimum rate-distortion cost among the rate-distortion costs of the unit to be encoded under all intra-frame coding sub-strategies of the intra-frame coding strategy, or the minimum rate-distortion cost among the rate-distortion costs corresponding to all inter-frame coding sub-strategies of the intra-frame coding strategy of the unit to be encoded. The specific implementation of the rate-distortion cost can be described as follows:
[0068] It should be understood that when the encoder encodes data (such as video data or image data), for the same video or the same image, different coding parameter combinations (division mode parameters, quantization parameters, coding strategies (inter-frame coding strategy or intra-frame coding strategy)) are used in the encoding process, that is, different inter-frame coding sub-strategies or intra-frame coding sub-strategies are used for encoding, and the information of the bit rate R and distortion D corresponding to the current coding parameter combination P can be obtained, which is recorded as (R, D) P , because there are multiple partition mode parameters, multiple quantization parameters, and multiple coding strategies in the coding parameter set, the coding parameter combination is any combination of the partition mode parameters, quantization parameters, and coding strategies. The combinations of different coding parameters in the coding parameter set are limited. Therefore, if all possible coding parameter combinations are traversed, a large number of RD point pairs will be obtained, that is, under each coding parameter combination, there is a corresponding bit rate R and distortion D. Mathematically prove that the boundaries of all RD point pairs can be formed as follows Figure 3d The convex hull line shown in Figure 1 can be understood as the rate-distortion curve of the encoder for a certain video or image. The rate-distortion curve represents the minimum distortion that can be achieved for the video or image at each bit rate point. The rate-distortion curve also reflects the performance limit of the current encoder at different bit rates.
[0069] When the encoder encodes video data or image data, the compression goal can be expressed as selecting a coding parameter combination P from the coding parameter set S to minimize the distortion D (i.e., closest to the rate-distortion curve), while also ensuring that the bit rate does not exceed the target bit rate. The mathematical representation can be shown as formula (1):
[0070]
[0071] The solution for the optimal coding parameter combination P can finally be obtained by introducing the Lagrange multiplier method, so formula (1) can be transformed into formula (2):
[0072] J i ,J i =D i +λR i (2)
[0073] That is, if a certain encoding parameter combination P i The corresponding D i With R i Using the above formula (2), we can get J i minimum, it means that the encoding parameter combination P i is the optimal solution under the target bit rate corresponding to the Lagrange multiplier λ, and the coding parameter combination P i , the optimal video or image quality at the target bit rate can be obtained.
[0074] Then, it can be known that the minimum rate-distortion cost of the unit to be encoded under all intra-frame coding sub-strategies of the intra-frame coding strategy is the minimum J value obtained by the above formula (2) when the coding strategy in the coding parameter combination P is the intra-frame coding strategy. Correspondingly, the minimum rate-distortion cost rate of the unit to be encoded corresponding to all inter-frame coding sub-strategies of the inter-frame coding strategy is the minimum J value obtained by the above formula (2) when the coding strategy in the coding parameter combination P is the inter-frame coding strategy. In an embodiment of the present application, the coding strategy of the historical coding unit can be obtained, and a prediction strategy for the coding cost of the unit to be encoded can be obtained according to the coding strategy of the historical coding unit and at least two preliminary coding strategies. The prediction strategy is used to predict the coding cost of the unit to be encoded. When the prediction of the coding cost of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the target coding strategy is used to encode the unit to be encoded. By implementing the above method, the prediction order of the inter-frame coding strategy and the intra-frame coding strategy can be adaptively adjusted according to the coding strategy of the historical coding unit to ensure that the coding strategy corresponding to the first order in the prediction order is as close as possible to the coding strategy required for encoding the unit to be encoded, and the prediction of the coding cost of the unit to be encoded can be exited in advance according to different coding cost standards, which can reduce the time for determining the target coding strategy, thereby improving the encoding speed.
[0075] See also Figure 4 , Figure 4 FIG. 1 is a flow chart of another coding decision method provided in an embodiment of the present application. The method is applied to a computer device and can be executed by the computer device, wherein the computer device can be a server or a terminal. Figure 4 As shown, the coding decision method may include:
[0076] S401: Obtain the encoding strategy of the historical encoding unit.
[0077] S402: Determine a prediction order in a prediction strategy based on a relationship between the number of historical coding units whose coding strategy is an intra-frame coding strategy and an intra-frame number threshold, and / or a relationship between the number of historical coding units whose coding strategy is an inter-frame coding strategy and an inter-frame number threshold, among at least two historical coding units.
[0078] In one implementation, a prediction strategy for the coding cost of the unit to be coded can be obtained based on the coding strategy of the historical coding unit and at least two preliminary coding strategies. The number of historical coding units includes multiple ones, that is, the number of historical coding units includes at least two. Specifically, the prediction strategy for the coding cost of the unit to be coded can be determined based on the relationship between the number of historical coding units whose coding strategy is an intra-frame coding strategy and the intra-frame number threshold, and / or the relationship between the number of historical coding units whose coding strategy is an inter-frame coding strategy and the inter-frame number threshold.
[0079] Optionally, if the prediction strategy for the coding cost of the unit to be coded is determined based on the relationship between the number of historical coding units whose coding strategy is the intra-frame coding strategy in at least two historical coding units and the intra-frame number threshold.
[0080] If, in at least two historical coding units, the number of historical coding units to which the coding strategy belongs is the intra-frame coding strategy is greater than or equal to the intra-frame number threshold, it can be understood that, for the coding unit to be encoded, the intra-frame coding strategy is also more inclined to be adopted, that is, compared with the inter-frame coding strategy, the coding effect of encoding the historical coding unit using the intra-frame coding strategy is better than the coding effect of encoding the historical coding unit using the inter-frame coding strategy. Therefore, according to the data of the historical coding unit, it can be considered to first use the intra-frame coding strategy to predict the coding cost of the coding unit to be encoded, and then the prediction order in the prediction strategy for the coding unit to be encoded can include the intra-frame coding strategy and the inter-frame coding strategy in sequence.
[0081] If, among at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the inter-frame number threshold, it can be understood that, for the coding unit to be encoded, the coding effect of encoding the historical coding units using the intra-frame coding strategy is not very prominent compared to the coding effect of encoding the historical coding units using the inter-frame coding strategy. In this case, the prediction order in the prediction strategy of the unit to be encoded is determined to be the prediction order of the predecessor coding unit of the unit to be encoded.
[0082] The predecessor coding unit can be understood as a historical coding unit in the previous image frame of the current image frame to which the unit to be coded belongs. For example, if the current image frame to which the unit to be coded belongs is the 10th frame, the predecessor coding unit is a historical coding unit in the 10th frame image. The predecessor coding unit can also be understood as a previous encoded coding unit in the current image frame to which the unit to be coded belongs. For example, if the unit to be coded is the 10th coding unit in the current image frame, the predecessor coding unit is the previous encoded coding unit in the current image frame, such as the 9th coding unit.
[0083] Among them, the intra-frame number threshold can be pre-set, for example, it can be a value of 5, 7, etc., optionally, the intra-frame number threshold can be determined according to the number of historical coding units, for example, the intra-frame number threshold can be 2 / 3 or 4 / 5 of the number of historical coding units, etc. It should be noted that its value should be as large as possible. 1 / 2, that is, in order to ensure that the number of coding units encoded using the intra-frame coding strategy in multiple historical coding units is as large as possible. The number of coding units encoded using the inter-frame coding strategy can also be determined according to other methods, which is not limited in this application.
[0084] For example, if the intra-frame number threshold is set to 2 / 3 of the number of historical coding units, then, when the coding strategies of 15 historical coding units are obtained, the intra-frame number threshold is 10 (15×2 / 3=10). Therefore, among the 15 historical coding units, when the number of historical coding units whose coding strategy is the intra-frame coding strategy is greater than or equal to 10, it is determined that the prediction order in the prediction strategy for the unit to be coded may include the intra-frame coding strategy and the inter-frame coding strategy in sequence.
[0085] Optionally, if the prediction strategy for the coding cost of the unit to be coded is determined according to the relationship between the number of historical coding units whose coding strategy is an intra-frame coding strategy and the inter-frame number threshold among multiple historical coding units.
[0086] If the number of historical coding units whose coding strategy is the inter-frame coding strategy in at least two historical coding units is greater than or equal to the inter-frame number threshold, it can be understood that the inter-frame coding strategy is also more inclined to be adopted for the coding unit to be encoded, that is, the coding effect of encoding the historical coding unit using the inter-frame coding strategy is better than the coding effect of encoding the historical coding unit using the intra-frame coding strategy. Therefore, according to the data of the historical coding unit, it can be considered to first use the inter-frame coding strategy to predict the coding cost of the coding unit to be encoded, and then the prediction order in the prediction strategy for the coding unit to be encoded can include the inter-frame coding strategy and the intra-frame coding strategy in sequence.
[0087] If, among at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the intra-frame number threshold, it can be understood that, for the coding unit to be encoded, the coding effect of encoding the historical coding units using the inter-frame coding strategy is not very prominent compared to the coding effect of encoding the historical coding units using the intra-frame coding strategy. In this case, the prediction order in the prediction strategy of the unit to be encoded is determined to be the prediction order of the predecessor coding unit of the unit to be encoded.
[0088] The inter-frame quantity threshold can be understood in the same way as the intra-frame quantity threshold, which will not be elaborated here.
[0089] Optionally, a prediction strategy for the coding cost of the unit to be encoded can be determined based on the relationship between the number of historical coding units whose coding strategy is an intra-frame coding strategy and an intra-frame number threshold, and the relationship between the number of historical coding units whose coding strategy is an inter-frame coding strategy and an inter-frame number threshold in at least two historical coding units.
[0090] If, in at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is greater than or equal to the intra-frame number threshold, and the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the inter-frame number threshold, then the prediction order in the prediction strategy for the unit to be encoded may include the intra-frame coding strategy and the inter-frame coding strategy in sequence.
[0091] If, in at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the intra-frame number threshold, but the number of historical coding units whose coding strategy is the inter-frame coding strategy is greater than or equal to the inter-frame number threshold, then the prediction order in the prediction strategy for determining the unit to be encoded may include the inter-frame coding strategy and the intra-frame coding strategy in sequence.
[0092] If, in at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the intra-frame number threshold, and the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the inter-frame number threshold, then the prediction order in the prediction strategy of the unit to be encoded is determined to be the prediction order of the predecessor coding unit for the unit to be encoded.
[0093] For example, if the intra-frame number threshold and the inter-frame number threshold are both set to 2 / 3 of the number of historical coding units, then, when the coding strategies of 15 historical coding units are obtained, the intra-frame number threshold and the inter-frame number threshold are both 10 (15×2 / 3=10). If, among the 15 historical coding units, the numbers of historical coding units whose coding strategies are the intra-frame coding strategy and the inter-frame coding strategy are 12 and 3 respectively, 12 is greater than the intra-frame number threshold, and 3 is less than the inter-frame number threshold, it can be determined that the prediction order in the prediction strategy for the unit to be coded can include the intra-frame coding strategy and the inter-frame coding strategy in sequence. If, among the 15 historical coding units, the numbers of historical coding units whose coding strategies are the intra-frame coding strategy and the inter-frame coding strategy are 4 and 11 respectively, 4 is less than the intra-frame number threshold, and 11 is greater than the inter-frame number threshold, it can be determined that the prediction order in the prediction strategy for the unit to be coded can include the inter-frame coding strategy and the intra-frame coding strategy in sequence. If, among the 15 historical coding units, the numbers of historical coding units whose coding strategies are intra-frame coding strategy and inter-frame coding strategy are 7 and 8 respectively, 7 is less than the intra-frame number threshold, and 8 is less than the inter-frame number threshold, then it can be determined that the prediction order in the prediction strategy of the unit to be encoded is the prediction order of the predecessor coding unit for the unit to be encoded.
[0094] S403: adopting a prediction strategy to predict the coding cost of the coding unit to be coded. When the coding cost prediction of the coding unit to be coded is completed through the target coding strategy, stop predicting the coding cost of the coding unit to be coded, and adopt the target coding strategy to encode the coding unit.
[0095] The specific implementation of steps S401 and S403 may refer to the specific description of steps S101 and S103 in the above embodiment, which will not be repeated here.
[0096] In an embodiment of the present application, the coding strategies of historical coding units can be obtained, and the prediction order can be determined according to the number of historical coding units whose coding strategies are intra-frame coding strategies and the number of historical coding units whose coding strategies are inter-frame coding strategies. By implementing the above method, the prediction order of inter-frame coding strategies and intra-frame coding strategies can be adaptively adjusted according to the number of intra-frame coding strategies and the number of inter-frame coding strategies of multiple historical coding units, so as to ensure that the coding strategy corresponding to the first order in the prediction order is as close as possible to the coding strategy required for encoding the unit to be encoded.
[0097] See also Figure 5 , Figure 5 : is a schematic diagram of a structure of a coding decision device provided in an embodiment of the present application. The coding decision device described in this embodiment includes:
[0098] An acquisition unit 501 is used to acquire the encoding strategy of the historical encoding unit;
[0099] A determination unit 502 is configured to determine a prediction strategy for a coding cost of a unit to be coded according to the coding strategy of the historical coding unit and at least two preliminary coding strategies; the prediction strategy includes the at least two preliminary coding strategies and a prediction order for predicting the coding cost of the unit to be coded using the at least two preliminary coding strategies;
[0100] The prediction unit 503 is used to adopt the prediction strategy to predict the coding cost of the unit to be encoded. When the coding cost prediction of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the unit to be encoded is encoded using the target coding strategy; the target coding strategy refers to a preliminary coding strategy among the at least two preliminary coding strategies, in which the predicted coding cost of the unit to be encoded meets the coding cost standard.
[0101] In one implementation, the historical encoding unit belongs to a historical image frame; the unit to be encoded belongs to a current image frame; and the determining unit 502 is further configured to:
[0102] Obtaining a first position of the unit to be encoded in the current image frame;
[0103] Determine, according to the first position, a second position in the historical image frame corresponding to the first position;
[0104] The coding unit at the second position in the historical image frame is determined as the historical coding unit.
[0105] In one implementation, the historical encoding unit belongs to the current image frame; the determining unit 502 is further configured to:
[0106] The adjacent coding units of the unit to be coded in the coded units of the current image frame are determined as the historical coding units.
[0107] In one implementation, the number of the historical coding units is at least two; the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the determining unit 502 is specifically configured to:
[0108] If, in at least two historical coding units, the number of historical coding units to which the coding strategy belongs is the intra-frame coding strategy is greater than or equal to the intra-frame number threshold, determining that the prediction order in the prediction strategy includes the intra-frame coding strategy and the inter-frame coding strategy in sequence;
[0109] If, among the at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the intra-frame number threshold, the prediction order in the prediction strategy is determined to be the prediction order of the predecessor coding unit for the unit to be encoded.
[0110] In one implementation, the number of the historical coding units is at least two; the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the determining unit 502 is specifically configured to:
[0111] If, in at least two historical coding units, the number of historical coding units to which the coding strategy belongs is the inter-frame coding strategy is greater than or equal to the inter-frame number threshold, determining that the prediction order in the prediction strategy includes the inter-frame coding strategy and the intra-frame coding strategy in sequence;
[0112] If, among the at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the inter-frame number threshold, the prediction order in the prediction strategy is determined to be the prediction order of the predecessor coding unit of the unit to be encoded.
[0113] In one implementation, the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the prediction unit 503 is specifically configured to:
[0114] When the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the prediction of the coding cost of the unit to be coded is completed by the inter-frame coding strategy, a pixel variance corresponding to the unit to be coded and a prediction coding error of the unit to be coded under at least two inter-frame coding sub-strategies of the inter-frame coding strategy are obtained;
[0115] Determine the smallest prediction coding error of the unit to be coded under the at least two inter-frame coding sub-strategies as a measured coding error;
[0116] When the pixel variance is greater than the measured coding error, the inter-frame coding strategy is determined as the target coding strategy, and the prediction of the coding cost of the unit to be coded is stopped.
[0117] In one implementation, the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the prediction unit 503 is specifically configured to:
[0118] When the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the coding cost prediction of the unit to be coded is completed by the intra-frame coding strategy, the rate-distortion cost of the unit to be coded under at least two intra-frame coding sub-strategies of the intra-frame coding strategy is obtained, and the rate-distortion cost of the unit to be coded under at least two inter-frame coding sub-strategies of the inter-frame coding strategy is obtained; the cost accuracy of the rate-distortion cost of the unit to be coded under the at least two intra-frame coding sub-strategies is higher than the cost accuracy of the rate-distortion cost of the unit to be coded under the at least two inter-frame coding sub-strategies;
[0119] When the minimum rate-distortion cost among the rate-distortion costs corresponding to the at least two intra-frame coding sub-strategies is less than the minimum rate-distortion cost among the rate-distortion costs corresponding to the at least two inter-frame coding sub-strategies, the intra-frame coding strategy is determined as the target coding strategy, and prediction of the coding cost of the unit to be encoded is stopped.
[0120] It is understood that the division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. The functional units in the embodiments of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software functional units.
[0121] See also Figure 6 , Figure 6 601, memory 602, and network interface 603. The processor 601, memory 602, and network interface 603 can exchange data.
[0122] The processor 601 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0123] The memory 602 may include a read-only memory and a random access memory, and provide program instructions and data to the processor 601. A portion of the memory 602 may also include a non-volatile random access memory. When the processor 601 calls the program instructions, it is used to execute:
[0124] Get the encoding strategy of the historical encoding unit;
[0125] Determining a prediction strategy for a coding cost of a unit to be coded according to the coding strategy of the historical coding unit and at least two preliminary coding strategies; the prediction strategy includes the at least two preliminary coding strategies and a prediction order for predicting the coding cost of the unit to be coded using the at least two preliminary coding strategies;
[0126] The prediction strategy is adopted to predict the coding cost of the unit to be encoded. When the coding cost prediction of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the unit to be encoded is encoded using the target coding strategy; the target coding strategy refers to a preliminary coding strategy among the at least two preliminary coding strategies, in which the predicted coding cost of the unit to be encoded meets the coding cost standard.
[0127] In one implementation, the historical encoding unit belongs to a historical image frame; the unit to be encoded belongs to a current image frame; and the processor 601 is further configured to:
[0128] Obtaining a first position of the unit to be encoded in the current image frame;
[0129] Determine, according to the first position, a second position in the historical image frame corresponding to the first position;
[0130] The coding unit at the second position in the historical image frame is determined as the historical coding unit.
[0131] In one implementation, the historical encoding unit belongs to the current image frame; the processor 601 is further configured to:
[0132] The adjacent coding units of the unit to be coded in the coded units of the current image frame are determined as the historical coding units.
[0133] In one implementation, the number of the historical coding units is at least two; the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the processor 601 is specifically configured to:
[0134] If, in at least two historical coding units, the number of historical coding units to which the coding strategy belongs is the intra-frame coding strategy is greater than or equal to the intra-frame number threshold, determining that the prediction order in the prediction strategy includes the intra-frame coding strategy and the inter-frame coding strategy in sequence;
[0135] If, among the at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the intra-frame number threshold, the prediction order in the prediction strategy is determined to be the prediction order of the predecessor coding unit for the unit to be encoded.
[0136] In one implementation, the number of the historical coding units is at least two; the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the processor 601 is specifically configured to:
[0137] If, in at least two historical coding units, the number of historical coding units to which the coding strategy belongs is the inter-frame coding strategy is greater than or equal to the inter-frame number threshold, determining that the prediction order in the prediction strategy includes the inter-frame coding strategy and the intra-frame coding strategy in sequence;
[0138] If, among the at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the inter-frame number threshold, the prediction order in the prediction strategy is determined to be the prediction order of the predecessor coding unit of the unit to be encoded.
[0139] In one implementation, the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the processor 601 is specifically configured to:
[0140] When the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the prediction of the coding cost of the unit to be coded is completed by the inter-frame coding strategy, a pixel variance corresponding to the unit to be coded and a prediction coding error of the unit to be coded under at least two inter-frame coding sub-strategies of the inter-frame coding strategy are obtained;
[0141] Determine the smallest prediction coding error of the unit to be coded under the at least two inter-frame coding sub-strategies as a measured coding error;
[0142] When the pixel variance is greater than the measured coding error, the inter-frame coding strategy is determined as the target coding strategy, and the prediction of the coding cost of the unit to be coded is stopped.
[0143] In one implementation, the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the processor 601 is specifically configured to:
[0144] When the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the coding cost prediction of the unit to be coded is completed by the intra-frame coding strategy, the rate-distortion cost of the unit to be coded under at least two intra-frame coding sub-strategies of the intra-frame coding strategy is obtained, and the rate-distortion cost of the unit to be coded under at least two inter-frame coding sub-strategies of the inter-frame coding strategy is obtained; the cost accuracy of the rate-distortion cost of the unit to be coded under the at least two intra-frame coding sub-strategies is higher than the cost accuracy of the rate-distortion cost of the unit to be coded under the at least two inter-frame coding sub-strategies;
[0145] When the minimum rate-distortion cost among the rate-distortion costs corresponding to the at least two intra-frame coding sub-strategies is less than the minimum rate-distortion cost among the rate-distortion costs corresponding to the at least two inter-frame coding sub-strategies, the intra-frame coding strategy is determined as the target coding strategy, and prediction of the coding cost of the unit to be encoded is stopped.
[0146] The present application also provides a computer storage medium in which program instructions are stored. When the program is executed, it may include: Figure 2 or Figure 4 Part or all of the steps of the encoding decision method in the corresponding embodiment.
[0147] It should be noted that, for the above-mentioned various method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some 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 preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0148] A person skilled in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0149] The embodiment of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the steps performed in the embodiments of the above-mentioned methods.
[0150] The above is a detailed introduction to a coding decision method, computer equipment, device and storage medium provided in an embodiment of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for a person skilled in the art, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A coding decision method, It is characterized in that include: Get the encoding strategy of the historical encoding unit; Determining a prediction strategy for a coding cost of a unit to be coded according to a coding strategy of the historical coding unit and at least two preliminary coding strategies; the prediction strategy includes the at least two preliminary coding strategies and a prediction order for predicting the coding cost of the unit to be coded using the at least two preliminary coding strategies; the number of the historical coding units is at least two; the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; The step of determining the prediction strategy for the coding cost of the unit to be coded according to the coding strategy of the historical coding unit and at least two preliminary coding strategies comprises: if, among at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is greater than or equal to an intra-frame number threshold, determining that the prediction order in the prediction strategy includes the intra-frame coding strategy and the inter-frame coding strategy in sequence; if, among at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the intra-frame number threshold, determining that the prediction order in the prediction strategy is the prediction order of the predecessor coding unit of the unit to be coded; if, among at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is greater than or equal to the inter-frame number threshold, determining that the prediction order in the prediction strategy includes the inter-frame coding strategy and the intra-frame coding strategy in sequence; if, among at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the inter-frame number threshold, determining that the prediction order in the prediction strategy is the prediction order of the predecessor coding unit of the unit to be coded; The prediction strategy is adopted to predict the coding cost of the unit to be encoded. When the coding cost prediction of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the unit to be encoded is encoded using the target coding strategy; the target coding strategy refers to a preliminary coding strategy among the at least two preliminary coding strategies, in which the predicted coding cost of the unit to be encoded meets the coding cost standard.
2. The method according to claim 1, It is characterized in that The historical encoding unit belongs to the historical image frame; the unit to be encoded belongs to the current image frame; The method further comprises: Obtaining a first position of the unit to be encoded in the current image frame; Determine, according to the first position, a second position in the historical image frame corresponding to the first position; The coding unit at the second position in the historical image frame is determined as the historical coding unit.
3. The method according to claim 1, It is characterized in that The historical encoding unit belongs to the current image frame; The method further comprises: The adjacent coding units of the unit to be coded in the coded units of the current image frame are determined as the historical coding units.
4. The method according to any one of claims 1 to 3, It is characterized in that The at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; When the prediction of the coding cost of the unit to be coded is completed through the target coding strategy, the prediction of the coding cost of the unit to be coded is stopped, including: When the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the prediction of the coding cost of the unit to be coded is completed by the inter-frame coding strategy, a pixel variance corresponding to the unit to be coded and a prediction coding error of the unit to be coded under at least two inter-frame coding sub-strategies of the inter-frame coding strategy are obtained; Determine the smallest prediction coding error of the unit to be coded under the at least two inter-frame coding sub-strategies as a measured coding error; When the pixel variance is greater than the measured coding error, the inter-frame coding strategy is determined as the target coding strategy, and the prediction of the coding cost of the unit to be coded is stopped.
5. The method according to any one of claims 1 to 3, It is characterized in that The at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; When the prediction of the coding cost of the unit to be coded is completed through the target coding strategy, the prediction of the coding cost of the unit to be coded is stopped, including: When the prediction strategy is used to predict the coding cost of the unit to be coded, when it is detected that the coding cost prediction of the unit to be coded is completed by the intra-frame coding strategy, the rate-distortion cost of the unit to be coded under at least two intra-frame coding sub-strategies of the intra-frame coding strategy is obtained, and the rate-distortion cost of the unit to be coded under at least two inter-frame coding sub-strategies of the inter-frame coding strategy is obtained; the cost accuracy of the rate-distortion cost of the unit to be coded under the at least two intra-frame coding sub-strategies is higher than the cost accuracy of the rate-distortion cost of the unit to be coded under the at least two inter-frame coding sub-strategies; When the minimum rate-distortion cost among the rate-distortion costs corresponding to the at least two intra-frame coding sub-strategies is less than the minimum rate-distortion cost among the rate-distortion costs corresponding to the at least two inter-frame coding sub-strategies, the intra-frame coding strategy is determined as the target coding strategy, and prediction of the coding cost of the unit to be encoded is stopped.
6. A coding decision device, It is characterized in that The device comprises: An acquisition unit, used for acquiring the encoding strategy of the historical encoding unit; A determination unit, for determining a prediction strategy for a coding cost of a unit to be coded according to a coding strategy of the historical coding unit and at least two preliminary coding strategies; the prediction strategy includes the at least two preliminary coding strategies, and a prediction order for predicting the coding cost of the unit to be coded by using the at least two preliminary coding strategies; the number of the historical coding units is at least two; the at least two preliminary coding strategies include an inter-frame coding strategy and an intra-frame coding strategy; the determination of the prediction strategy for the coding cost of the unit to be coded according to the coding strategy of the historical coding unit and at least two preliminary coding strategies comprises: if the number of historical coding units whose coding strategy is the intra-frame coding strategy among at least two historical coding units is greater than or equal to an intra-frame number threshold, then determining the prediction order in the prediction strategy includes the following in sequence: Intra-frame coding strategy and the inter-frame coding strategy; if among the at least two historical coding units, the number of historical coding units whose coding strategy is the intra-frame coding strategy is less than the intra-frame number threshold, then determine that the prediction order in the prediction strategy is the prediction order of the predecessor coding unit of the unit to be encoded; if among the at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is greater than or equal to the inter-frame number threshold, then determine that the prediction order in the prediction strategy includes the inter-frame coding strategy and the intra-frame coding strategy in sequence; if among the at least two historical coding units, the number of historical coding units whose coding strategy is the inter-frame coding strategy is less than the inter-frame number threshold, then determine that the prediction order in the prediction strategy is the prediction order of the predecessor coding unit of the unit to be encoded; A prediction unit is used to adopt the prediction strategy to predict the coding cost of the unit to be encoded. When the coding cost prediction of the unit to be encoded is completed through the target coding strategy, the prediction of the coding cost of the unit to be encoded is stopped, and the unit to be encoded is encoded using the target coding strategy; the target coding strategy refers to a preliminary coding strategy among the at least two preliminary coding strategies, in which the predicted coding cost of the unit to be encoded meets the coding cost standard.
7. A computer device, It is characterized in that The method comprises a processor, a memory and a network interface, wherein the processor, the memory and the network interface are interconnected, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 5.
