Method and device for determining inter-frame prediction direction of image block in B frame
By voting by calculating the motion vector difference and prediction cost ratio of image blocks in B frame, the problem of bidirectional prediction delay in B frame is solved, reducing the design complexity and cost of hardware video encoder.
Patent Information
- Application Number
- CN202310755206.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-25
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-06-25
AI Technical Summary
The bidirectional prediction of the image block to be encoded in the B frame is high in the hardware video encoder, which increases the design difficulty and cost.
By calculating the direction amplitude difference and prediction cost ratio of the optimal forward and backward motion vectors, the two voting mechanism is used to judge the prediction direction of the image block in the B frame, and avoiding actual bidirectional prediction operations.
It greatly reduces the delay in inter-frame prediction of image blocks in B frames, and reduces the design difficulty and implementation cost of hardware video encoder.
Smart Images

Figure CN116828173B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a digital video coding technology, and particularly to a method for determining an inter-frame prediction direction suitable for hardware implementation. Background Art
[0002] Video coding is a technology that compresses redundant components in video images and uses as little data as possible to represent video information. Common video coding standards include HEVC (High Efficiency Video Coding), also known as H.265, and AVC (Advanced Video Coding), also known as H.264. Since the computational complexity of video coding algorithms is very high, in order to improve the video coding speed, it has become a common practice in the industry to use application-specific integrated circuits (ASICs) to perform hardware acceleration on the video coding process.
[0003] Video coding technology uses image blocks as the most basic coding units. For example, in HEVC, the basic unit of video coding is a CU (Coding Unit). A CU can be an image block with a size of 64 pixels × 64 pixels, 32 pixels × 32 pixels, 16 pixels × 16 pixels, or 8 pixels × 8 pixels.
[0004] In order to improve the video compression ratio as much as possible, video coding often uses lossy compression algorithms, resulting in a difference (distortion) between the encoded and reconstructed video and the original video. Both HEVC and AVC belong to lossy compression algorithms. The coding performance of lossy compression algorithms needs to be jointly measured by the coding bit rate (Rate) and the distortion (Distortion) introduced by coding. During video coding, the coding bit rate R and the coding distortion D restrict and contradict each other. Reducing the coding bit rate R often increases the coding distortion D, and reducing the coding distortion D often increases the coding bit rate R. Rate Distortion Optimization (RDO) is to minimize the coding distortion D as much as possible under a certain coding bit rate R, or to minimize the coding bit rate R as much as possible under a certain coding distortion D. Common video coding algorithms all adopt a rate distortion optimization method based on the Lagrange multiplier λ, which is to obtain the minimum coding rate distortion cost (Rate Distortion Cost, RD Cost) J, where J = D + λ × R.
[0005] During video coding, each coding mode has a coding distortion D and a coding bit rate R, and the coding rate distortion cost J of each coding mode can be calculated. When video coding, the coding mode with the minimum coding rate distortion cost J is selected for coding to obtain the optimal coding performance.
[0006] Motion estimation is a process of searching for the optimal matching block in an encoded video frame (referred to as the reference frame) for the image block to be encoded in the current encoded video frame, so as to minimize the coding rate-distortion cost J. Motion estimation is one of the core technologies of video coding algorithms, which is used to eliminate the temporal information redundancy of video signals, thereby improving the coding efficiency. Please refer to Figure 1 that the relative offset between the co-located image block (image block at the same position) of the image block to be encoded in the current encoded video frame in the reference frame and the reference image block in the reference frame is the motion vector (MV) between the image block to be encoded and the reference image block. The motion vector MV can be decomposed into a horizontal component MVx and a vertical component MVy. During the motion estimation process, the reference image block that minimizes the coding rate-distortion cost J is the optimal matching block of the image block to be encoded in the reference frame, and its corresponding motion vector is the optimal motion vector. Generally speaking, the motion estimation process is also called "inter-frame prediction", and is simply referred to as "prediction" in the context where intra-frame prediction is not involved; the minimum coding rate-distortion cost J of motion estimation is also called "inter-frame prediction cost", and is simply referred to as "prediction cost" in the context where intra-frame prediction is not involved.
[0007] In video coding technology, the video frames encoded using inter-frame prediction technology are P frames and B frames. Please refer to Figure 2 that for the B frame, the inter-frame prediction adopts bidirectional prediction technology, and the reference frame can be either a forward reference frame (i.e., the sampling time of the reference frame is before the encoded frame) or a backward reference frame (i.e., the sampling time of the reference frame is after the encoded frame). For the image block to be encoded in the B frame, the process of inter-frame prediction on the forward reference frame is simply referred to as forward prediction, the reference image block on the forward reference frame is called the forward reference block, and the motion vector between the image block to be encoded and the forward reference block is called the forward motion vector; the process of inter-frame prediction on the backward reference frame is called backward prediction, the reference image block on the backward reference frame is called the backward reference block, and the motion vector between the image block to be encoded and the backward reference block is called the backward motion vector.
[0008] For the image block to be encoded in the B frame, in addition to forward prediction and backward prediction, there is also a bidirectional prediction process. When the forward prediction and backward prediction of the image block to be encoded in the B frame are completed, the optimal forward motion vector and the optimal backward motion vector are obtained. Bidirectional prediction is to use the optimal forward motion vector and the optimal backward motion vector to index the optimal forward matching block and the optimal backward matching block in the forward reference frame and the backward reference frame respectively, then perform weighted summation on the optimal forward matching block and the optimal backward matching block to generate a composite reference block, and finally use the composite reference block to perform motion estimation with the image block to be encoded and calculate the corresponding minimum coding rate-distortion cost J as the bidirectional prediction cost.
[0009] For the image block to be encoded in the B frame, if the prediction cost of forward prediction is the smallest, the prediction direction of the image block to be encoded will be determined as forward prediction, and forward motion vectors will be used for encoding; if the prediction cost of backward prediction is the smallest, the prediction direction of the image block to be encoded will be determined as backward prediction, and backward motion vectors will be used for encoding; if the prediction cost of bidirectional prediction is the smallest, the prediction direction of the image block to be encoded will be determined as bidirectional prediction, and both forward motion vectors and backward motion vectors will be used for encoding. This process is called the determination of the prediction direction of the image block to be encoded in the B frame, as Figure 3 shown.
[0010] Compared with forward prediction and backward prediction, the computational complexity of the bidirectional prediction process is not large. However, since its calculation depends on the results of forward prediction and backward prediction, it is difficult to achieve parallel pipelining with forward prediction and backward prediction. As a result, when implemented in hardware, the delay of the bidirectional prediction process will be very large, greatly increasing the cost and difficulty of hardware design.
[0011] Currently, the bidirectional prediction of the image block to be encoded in the B frame is a difficult point in the design of hardware video encoders. To reduce the delay caused by bidirectional prediction, generally, more hardware computing units are added to accelerate its operation process, or the algorithm of bidirectional prediction is simplified to reduce the operation time. However, these methods still cannot completely eliminate the delay caused by bidirectional prediction, and the design difficulty and implementation cost of hardware video encoders are still relatively high. Summary of the Invention
[0012] The technical problem to be solved by the present invention is: how to obtain the prediction direction of the image block to be encoded in the B frame faster and be more suitable for hardware implementation.
[0013] To solve the above technical problem, the present invention proposes a method for determining the inter-frame prediction direction of an image block in a B frame, including the following steps. Step S1: Perform forward prediction on the image block to be encoded in the B frame to obtain the optimal forward motion vector and the corresponding forward prediction cost. Step S2: Perform backward prediction on the image block to be encoded in the B frame to obtain the optimal backward motion vector and the corresponding backward prediction cost. The order of Step S1 and Step S2 can be either one before the other or simultaneous. Step S3: Calculate the direction amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector and compare it with "the first determination threshold τ that is positively correlated with the video resolution", and then perform the first vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result. Step S4: Calculate the forward prediction cost cost 前向 and the backward prediction cost cost 后向The ratio θ of the smaller to the larger of them is compared with "the second determination threshold α and the third determination threshold β that are positively correlated with the quantization parameter and the Lagrange multiplier adopted by the image block to be coded", and then, according to the comparison result, a second vote is conducted on the inter-frame prediction direction of the image block to be coded in the B frame. The order of step S3 and step S4 is either that one is before the other or they are carried out simultaneously. Step S5: Determine the optimal prediction direction and the optimal motion vector of the image block to be coded in the B frame according to the results of the two votes.
[0014] Further, in step S3, use and to represent the horizontal direction component and the vertical direction component of the optimal forward motion vector respectively, and use and to represent the horizontal direction component and the vertical direction component of the optimal backward motion vector respectively, then there is: where, abs() represents the absolute value operation.
[0015] Further, in step S3, if δ ≤ τ, vote 1 for the inter-frame prediction direction of the image block to be coded; if δ > τ, vote 0 for the inter-frame prediction direction of the image block to be coded.
[0016] Further, in step S4, if α ≤ θ ≤ β, vote 1 for the inter-frame prediction direction of the image block to be coded; if θ < α or θ > β, vote 0 for the inter-frame prediction direction of the image block to be coded; where, α and β satisfy 0 < α < β < 1, and β - α is negatively correlated with the quantization parameter and the Lagrange multiplier adopted by the image block to be coded in the B frame.
[0017] Further, in step S5, if the total number of votes in the results of the two votes is 2, then determine that the optimal prediction direction of the image block to be coded in the B frame is bidirectional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector; if the total number of votes in the results of the two votes is less than 2 and cost 前向 ≤ cost 后向 , then determine that the optimal prediction direction of the image block to be coded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if the total number of votes in the results of the two votes is less than 2 and cost 前向 > cost 后向 , then determine that the optimal prediction direction of the image block to be coded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
[0018] Alternatively, steps S3 - S5 are combined into step S3a. Step S3a: Calculate the directional amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector, and compare it with the first determination threshold τ that is positively correlated with the video resolution. Calculate the ratio θ of the smaller value to the larger value between the forward prediction cost cost 前向 and the backward prediction cost cost 后向 , and compare it with the second determination threshold α and the third determination threshold β that are positively correlated with the quantization parameter and the Lagrangian multiplier used for the image block to be encoded. Determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B - frame according to the results of the two comparisons.
[0019] Furthermore, in step S3a, if δ ≤ τ and α ≤ θ ≤ β, then it is determined that the optimal prediction direction of the image block to be encoded in the B - frame is bi - directional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector; in other cases, if cost 前向 ≤ cost 后向 , then it is determined that the optimal prediction direction of the image block to be encoded in the B - frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if cost 前向 > cost 后向 , then it is determined that the optimal prediction direction of the image block to be encoded in the B - frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
[0020] The present invention also proposes a decision device for the inter - frame prediction direction of an image block in a B - frame, including a forward prediction module, a backward prediction module, a motion vector relationship determination module, a prediction cost relationship determination module, and a prediction direction decision module. The forward prediction module is used to perform forward prediction on the image block to be encoded in the B - frame to obtain the optimal forward motion vector and the corresponding forward prediction cost. The backward prediction module is used to perform backward prediction on the image block to be encoded in the B - frame to obtain the optimal backward motion vector and the corresponding backward prediction cost. The motion vector relationship determination module is used to calculate the directional amplitude difference between the optimal forward motion vector and the optimal backward motion vector and compare it with the first determination threshold that is positively correlated with the video resolution, and then perform the first vote on the inter - frame prediction direction of the image block to be encoded in the B - frame according to the comparison result. The prediction cost relationship determination module is used to calculate the ratio of the smaller value to the larger value between the forward prediction cost and the backward prediction cost and compare it with the second and third determination thresholds that are positively correlated with the quantization parameter and the Lagrangian multiplier used for the image block to be encoded, and then perform the second vote on the inter - frame prediction direction of the image block to be encoded in the B - frame according to the comparison result. The prediction direction decision module is used to determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B - frame according to the results of the two votes.
[0021] Alternatively, the motion vector relationship determination module, the prediction cost relationship determination module, and the prediction direction decision module are combined into a comprehensive comparison and judgment module. The comprehensive comparison and judgment module is used to calculate the direction amplitude difference between the optimal forward motion vector and the optimal backward motion vector and compare it with the "first determination threshold that is positively correlated with the video resolution", and is also used to calculate the ratio of the smaller value to the larger value between the forward prediction cost and the backward prediction cost and compare it with the "second and third determination thresholds that are positively correlated with the quantization parameter and the Lagrangian multiplier used for the image block to be encoded", and is further used to determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the results of the two comparisons.
[0022] The technical effects achieved by the present invention are as follows: Instead of performing actual bidirectional prediction operations, through two voting mechanisms (i.e., two comparison processes) and comprehensive judgment, the optimal prediction direction and its corresponding motion vector of the image block to be encoded in the B frame can be determined, greatly reducing the delay of the inter-frame prediction operation for the image block in the B frame and significantly reducing the design difficulty and implementation cost of the hardware video encoder. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the motion estimation (inter-frame prediction) of the image block to be encoded.
[0024] Figure 2 It is a schematic diagram of the inter-frame prediction of the image block to be encoded in the B frame.
[0025] Figure 3 It is a schematic diagram of the module of the decision process of the prediction direction of the image block to be encoded in the B frame.
[0026] Figure 4 It is a schematic flowchart of the method for determining the inter-frame prediction direction of the image block in the B frame proposed by the present invention.
[0027] Figure 5 It is a schematic structural diagram of the device for determining the inter-frame prediction direction of the image block in the B frame proposed by the present invention.
[0028] Explanation of the reference numerals in the drawings: 1 is the forward prediction module, 2 is the backward prediction module, 3 is the motion vector relationship determination module, 4 is the prediction cost relationship determination module, and 5 is the prediction direction decision module. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0029] Please refer to Figure 4 , the method for determining the inter-frame prediction direction of the image block in the B frame proposed by the present invention includes the following steps.
[0030] Step S1: The image block to be encoded in the B frame is subjected to forward prediction, that is, inter-frame prediction (motion estimation) is performed on the forward reference frame to obtain the optimal forward motion vector and the corresponding forward prediction cost (the minimum coding rate distortion cost J of forward prediction). Forward prediction is an existing video coding technology and will not be elaborated here.
[0031] Step S2: The image block to be encoded in the B frame is subjected to backward prediction, that is, inter-frame prediction is performed on the backward reference frame to obtain the optimal backward motion vector and the corresponding backward prediction cost (the minimum coding rate distortion cost J of backward prediction). Backward prediction is an existing video coding technology and will not be elaborated here.
[0032] The order of Step S1 and Step S2 is not strictly restricted, and either can be performed first or they can be performed simultaneously.
[0033] Step S3: Calculate the directional amplitude difference between the optimal forward motion vector and the optimal backward motion vector and compare it with the "first determination threshold that is positively correlated with the video resolution", and then perform the first vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result.
[0034] Specifically, use and to represent the horizontal direction component and the vertical direction component of the optimal forward motion vector respectively, use and to represent the horizontal direction component and the vertical direction component of the optimal backward motion vector respectively, and use δ to represent the directional amplitude difference between the optimal forward motion vector and the optimal backward motion vector. Then there is: where abs() represents the absolute value operation. Then compare δ with the first determination threshold τ. If δ ≤ τ, vote 1 for the inter-frame prediction direction of the image block to be encoded. If δ > τ, vote 0 for the inter-frame prediction direction of the image block to be encoded. The first determination threshold τ is a positive integer that is positively correlated with the video resolution. The larger the video resolution, the larger the value of τ.
[0035] Step S4: Calculate the ratio of the smaller value to the larger value between the forward prediction cost and the backward prediction cost and compare it with the "second and third determination thresholds that are positively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be encoded", and then perform the second vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result.
[0036] The order of Step S3 and Step S4 is not strictly restricted, and either can be performed first or they can be performed simultaneously. Consider Step S1 and Step S2 as the first group, and consider Step S3 and Step S4 as the second group. The second group of steps must be performed after the first group of steps is completed.
[0037] Specifically, use cost 前向 to represent the forward prediction cost corresponding to the optimal forward motion vector, and use cost 后向 to represent the backward prediction cost corresponding to the optimal backward motion vector. Use cost min to represent the smaller value between cost 前向 and cost 后向 , and use cost max to represent the larger value between cost 前向 and cost 后向 . Then there is: cost min = min(cost 前向 , cost 后向 ), cost max = max(cost 前向 , cost 后向 ). Among them, min() represents taking the minimum value, and max() represents taking the maximum value. Use θ to represent the ratio of cost min to cost max , then there is: Then compare θ with the second decision threshold α and the third decision threshold β. If α ≤ θ ≤ β, vote 1 for the inter-frame prediction direction of the image block to be encoded. If θ < α, vote 0 for the inter-frame prediction direction of the image block to be encoded. If θ > β, vote 0 for the inter-frame prediction direction of the image block to be encoded. Among them, the second decision threshold α and the third decision threshold β satisfy 0 < α < β < 1, and the difference between β and α is negatively correlated with the quantization parameter and Lagrange multiplier used for the image block to be encoded in the B frame. The single second decision threshold α is positively correlated with the quantization parameter and Lagrange multiplier used for the image block to be encoded in the B frame. The single third decision threshold β is positively correlated with the quantization parameter and Lagrange multiplier used for the image block to be encoded in the B frame. The larger the quantization parameter and Lagrange multiplier used for the image block to be encoded in the B frame, the smaller the difference between β and α, that is, the closer β is to α.
[0038] Step S5: Determine the optimal prediction direction (i.e., the finally determined inter-frame prediction direction) and the optimal motion vector of the image block to be encoded in the B frame according to the first voting result and the second voting result.
[0039] Specifically, if the total number of votes for the two voting results of the inter-frame prediction direction of the image block to be encoded in the B frame is 2 votes, then it is determined that the optimal prediction direction of the image block to be encoded in the B frame is bi-directional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector. If the total number of votes for the two voting results of the inter-frame prediction direction of the image block to be encoded in the B frame is less than 2 votes, and cost 前向 ≤ cost 后向, then the optimal prediction direction of the image block to be encoded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector. If the total number of votes for the two voting results of the inter-frame prediction direction of the image block to be encoded in the B frame is less than 2 votes, and cost 前向 > cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
[0040] Alternatively, steps S3 - S5 are combined into step S3a.
[0041] Step S3a: Calculate the direction amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector and compare it with the "first determination threshold τ that is positively correlated with the video resolution", calculate the ratio θ of the smaller value to the larger value between the forward prediction cost cost 前向 and the backward prediction cost cost 后向 , and compare it with the "second determination threshold α and the third determination threshold β that are positively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be encoded", and determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the two comparison results. Specifically, if δ ≤ τ and α ≤ θ ≤ β, then the optimal prediction direction of the image block to be encoded in the B frame is bidirectional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector. In other cases, if cost 前向 ≤ cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if cost 前向 > cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
[0042] Please refer to Figure 5 , the determination device for the inter-frame prediction direction of the image block in the B frame proposed by the present invention includes a forward prediction module 1, a backward prediction module 2, a motion vector relationship determination module 3, a prediction cost relationship determination module 4, and a prediction direction determination module 5. Figure 5 The device shown corresponds to Figure 4 the method shown.
[0043] The forward prediction module 1 is used to perform forward prediction on the image block to be encoded in the B frame to obtain the optimal forward motion vector and the corresponding forward prediction cost.
[0044] The backward prediction module 2 is used to perform backward prediction on the image block to be encoded in the B frame to obtain the optimal backward motion vector and the corresponding backward prediction cost.
[0045] The motion vector relationship determination module 3 is used to calculate the direction amplitude difference between the optimal forward motion vector and the optimal backward motion vector, compare it with the "first determination threshold positively correlated with the video resolution", and then perform the first vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result.
[0046] The prediction cost relationship determination module 4 is used to calculate the ratio of the smaller value to the larger value between the forward prediction cost and the backward prediction cost, compare it with the "second and third determination thresholds positively correlated with the quantization parameter and the Lagrange multiplier adopted by the image block to be encoded", and then perform the second vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result.
[0047] The prediction direction decision module 5 is used to determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the results of the first vote and the second vote.
[0048] Alternatively, the motion vector relationship determination module 3, the prediction cost relationship determination module 4, and the prediction direction decision module 5 are combined into an integrated comparison and judgment module 3a. The integrated comparison and judgment module 3a corresponds to the step S3a.
[0049] The integrated comparison and judgment module 3a is used to calculate the direction amplitude difference between the optimal forward motion vector and the optimal backward motion vector, compare it with the "first determination threshold positively correlated with the video resolution", and is also used to calculate the ratio of the smaller value to the larger value between the forward prediction cost and the backward prediction cost, compare it with the "second and third determination thresholds positively correlated with the quantization parameter and the Lagrange multiplier adopted by the image block to be encoded", and is also used to determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the results of the two comparisons.
[0050] The present invention proposes a method for determining the inter-frame prediction direction of an image block to be encoded in a B frame suitable for implementation by a hardware video encoder. By analyzing the relationship between the optimal forward motion vector and the optimal backward motion vector of the image block to be encoded in the B frame, and the corresponding relationship between the forward prediction cost and the backward prediction cost, without performing actual bidirectional prediction operations, the optimal prediction direction and the corresponding motion vector of the image block to be encoded in the B frame are determined. Since no actual bidirectional prediction operations are required, the present invention greatly reduces the delay of the inter-frame prediction operation of the image block in the B frame, and greatly reduces the design difficulty and implementation cost of the hardware video encoder.
[0051] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, various modifications and variations can be made to the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for determining the inter-frame prediction direction of an image block in a B frame, characterized in that, including the following steps; Step S1: Perform forward prediction on the image block to be encoded in the B frame to obtain the optimal forward motion vector and the corresponding forward prediction cost; use and to represent the horizontal and vertical components of the optimal forward motion vector respectively; Step S2: Perform backward prediction on the image block to be encoded in the B frame to obtain the optimal backward motion vector and the corresponding backward prediction cost; use and to represent the horizontal and vertical components of the optimal backward motion vector respectively; The order of step S1 and step S2, either one is before the other, or they are carried out simultaneously; Step S3: Calculate the direction amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector, and compare it with "the first determination threshold τ that is positively correlated with the video resolution", and then perform the first vote on the inter-frame prediction direction of the image block to be encoded in the B frame; ; where abs() represents the absolute value operation; if δ ≤ τ, vote 1 for the inter-frame prediction direction of the image block to be encoded; if δ > τ, vote 0 for the inter-frame prediction direction of the image block to be encoded; Step S4: Calculate the forward prediction cost cost 前向 and the backward prediction cost cost 后向 Calculate the ratio θ of the smaller value to the larger value between them, and compare it with "the second decision threshold α and the third decision threshold β that are positively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be encoded", and then perform a second vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result; if α ≤ θ ≤ β, vote 1 for the inter-frame prediction direction of the image block to be encoded; if θ < α or θ > β, vote 0 for the inter-frame prediction direction of the image block to be encoded; where α and β satisfy 0 < α < β < 1, and β - α is negatively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be encoded in the B frame; The order of step S3 and step S4, either one is before the other, or they are carried out simultaneously; Step S5: Determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the two voting results; if the total number of votes of the two voting results is 2 votes, then determine that the optimal prediction direction of the image block to be encoded in the B frame is bidirectional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector; if the total number of votes of the two voting results is less than 2 votes and cost 前向 ≤cost 后向 , then determine that the optimal prediction direction of the image block to be encoded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if the total number of votes of the two voting results is less than 2 votes and cost 前向 >cost 后向 , then determine that the optimal prediction direction of the image block to be encoded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
2. The decision method for the inter-frame prediction direction of an image block in a B frame according to claim 1, wherein Step S3, step S4, and step S5 are combined into step S3a; Step S3a: Calculate the direction amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector and compare it with "the first determination threshold τ that is positively correlated with the video resolution", and calculate the forward prediction cost cost 前向 and the backward prediction cost cost 后向 Calculate the ratio θ of the smaller value to the larger value in and compare it with "the second determination threshold α and the third determination threshold β that are positively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be encoded", and determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the results of the two comparisons; If δ ≤ τ and α ≤ θ ≤ β, then the optimal prediction direction of the image block to be encoded in the B frame is bi-directional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector; in other cases, if cost 前向 ≤ cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if cost 前向 > cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
3. An apparatus for determining an inter prediction direction of an image block in a B frame, characterized in that including a forward prediction module, a backward prediction module, a motion vector relationship determination module, a prediction cost relationship determination module, and a prediction direction decision module; The forward prediction module is used to perform forward prediction on the image block to be encoded in the B frame, obtain the optimal forward motion vector and the corresponding forward prediction cost; and represent the horizontal direction component and the vertical direction component of the optimal forward motion vector respectively; The backward prediction module is used to perform backward prediction on the image block to be encoded in the B frame, obtain the optimal backward motion vector and the corresponding backward prediction cost; use and represent the horizontal direction component and the vertical direction component of the optimal backward motion vector respectively; The motion vector relationship determination module is used to calculate the direction amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector, and compare it with "the first determination threshold τ that is positively correlated with the video resolution", and then perform the first vote on the inter-frame prediction direction of the image block to be encoded in the B frame according to the comparison result; ; where abs() represents the absolute value operation; if δ ≤ τ, vote 1 for the inter-frame prediction direction of the image block to be encoded; if δ > τ, vote 0 for the inter-frame prediction direction of the image block to be encoded; The predicted cost relationship determination module is used to calculate the smaller and larger ratio θ of the forward prediction cost cost 前向 and the backward prediction cost cost 后向 and compare it with "the second determination threshold α and the third determination threshold β that are positively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be coded", and then perform a second vote on the inter-frame prediction direction of the image block to be coded in the B frame according to the comparison result; if α ≤ θ ≤ β, vote 1 for the inter-frame prediction direction of the image block to be coded; if θ < α or θ > β, vote 0 for the inter-frame prediction direction of the image block to be coded; where α and β satisfy 0 < α < β < 1, and β - α is negatively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be coded in the B frame; The prediction direction decision module is used to determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the two voting results; if the total number of votes in the two voting results is 2 votes, it is determined that the optimal prediction direction of the image block to be encoded in the B frame is bidirectional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector; if the total number of votes in the two voting results is less than 2 votes and cost 前向 ≤cost 后向 , it is determined that the optimal prediction direction of the image block to be encoded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if the total number of votes in the two voting results is less than 2 votes and cost 前向 >cost 后向 , it is determined that the optimal prediction direction of the image block to be encoded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
4. The decision device for the inter - prediction direction of image blocks in a B - frame according to claim 3, characterized in that, The motion vector relationship determination module, the prediction cost relationship determination module, and the prediction direction decision module are combined into a comprehensive comparison and judgment module; The comprehensive comparison and judgment module is used to calculate the direction amplitude difference δ between the optimal forward motion vector and the optimal backward motion vector and compare it with "the first determination threshold τ that is positively correlated with the video resolution", and is also used to calculate the forward prediction cost cost 前向 and the backward prediction cost cost 后向 The ratio θ of the smaller value to the larger value in is compared with "the second determination threshold α and the third determination threshold β that are positively correlated with the quantization parameter and the Lagrange multiplier used for the image block to be encoded", and is also used to determine the optimal prediction direction and the optimal motion vector of the image block to be encoded in the B frame according to the results of the two comparisons; If δ ≤ τ and α ≤ θ ≤ β, then the optimal prediction direction of the image block to be encoded in the B frame is bi - directional prediction, and the corresponding optimal motion vector is the optimal forward motion vector and the optimal backward motion vector; in other cases, if cost 前向 ≤ cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is forward prediction, and the corresponding optimal motion vector is the optimal forward motion vector; if cost 前向 > cost 后向 , then the optimal prediction direction of the image block to be encoded in the B frame is backward prediction, and the corresponding optimal motion vector is the optimal backward motion vector.
Citation Information
Patent Citations
Image encoding device and method
JP1998145792A