IP Library Granted Patent US 12666004
Granted Patent B2
US 12666004 · App. 18/332,450 · Granted Jun 23, 2026

Reference frame selection method and apparatus, device, and medium

Inventor: Hongshun Zhang (Shenzhen, CN)
Assignee: Tencent Technology (Shenzhen) Company Limited
H04N19/105H04N19/119H04N19/147H04N19/52
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12666004
App. No.
18/332,450
Granted
Jun 23, 2026
Kind
B2
Abstract

A reference frame selection method and apparatus, a device, and a medium, relating to the field of video coding. The method includes: acquiring m candidate reference frames of a target coding unit, the target coding unit being one of a plurality of coding units of a video frame, m being an integer greater than 1; scoring the m candidate reference frames based on quality score information of the m candidate reference frames, the quality score information indicating coding quality of the target coding unit performing inter-frame prediction through the m candidate reference frames; and selecting an optimal reference frame of the target coding unit according to scoring results of the m candidate reference frames. The described technical solution simplifies the process of determining the optimal reference frame, and greatly accelerates the coding speed of the target coding unit.

Claims (64)

1 . A reference frame selection method, performed by a computer device, the method comprising:

acquiring m candidate reference frames of a target coding unit, the target coding unit being one of a plurality of coding units of a video frame, and m being an integer greater than 1;

scoring the m candidate reference frames based on quality score information associated with each of the m candidate reference frames, the quality score information indicating coding quality of the target coding unit performing inter-frame prediction through the m candidate reference frames, wherein the scoring comprises determining, based on degrees of distortion of the m candidate reference frames, a score of a first candidate reference frame having a minimum degree of distortion among the m candidate reference frames as a first score, and wherein when candidate reference frames among the m candidate reference frames are not optimal reference frames of an adjacent coding unit, the degrees of distortion of candidate reference frames are determined using a preset degree of distortion, the adjacent coding unit being a coding unit in the video frame that is coded by using inter-frame prediction and being adjacent to the target coding unit; and

selecting an optimal reference frame of the target coding unit according to scoring results of the m candidate reference frames.

2 . The method according to claim 1 , wherein:

the first candidate reference frame is determined as an optimal reference frame of an adjacent coding unit among the m candidate reference frames.

3 . The method according to claim 1 , wherein

the target coding unit is obtained based on p segmentation types; the method is applied to a target coding unit obtained by an x th segmentation type for coding; p is an integer greater than 1; x is a positive integer, and x is less than p; and

scoring the m candidate reference frames based on quality score information of the m candidate reference frames comprises:

determining optimal reference frames of the target coding unit under a first segmentation type to an (x−1) th segmentation type, x being a positive integer greater than 1;

counting a number of times that the m candidate reference frames are respectively selected as the optimal reference frames of the target coding unit under the first segmentation type to the (x−1) th segmentation type; and

determining, based on a counting result, a score of the first candidate reference frame with the number of times of being selected exceeding a first times threshold among the m candidate reference frames as the first score.

4 . The method according to claim 1 , wherein the m candidate reference frames are divided into a forward reference frame cluster, a backward reference frame cluster, and a long-term reference frame according to a reference frame direction; and

determining, based on degrees of distortion of the m candidate reference frames, a score of the first candidate reference frame having a minimum degree of distortion among the m candidate reference frames as the first score comprises at least one of the following:

determining, based on that a degree of distortion of a first forward reference frame in the forward reference frame cluster is less than degrees of distortion of other forward reference frames and the degree of distortion of the first forward reference frame is not greater than a preset degree of distortion, a score of the first forward reference frame as the first score;

determining, based on that a degree of distortion of a first backward reference frame in the backward reference frame cluster is less than degrees of distortion of other backward reference frames and the degree of distortion of the first backward reference frame is not greater than the preset degree of distortion, a score of the first backward reference frame as the first score; and

when a degree of distortion of the long-term reference frame is not equal to the preset degree of distortion, neither the degree of distortion of the first forward reference frame nor the degree of distortion of the first backward reference frame is greater than the preset degree of distortion, and the degree of distortion of the long-term reference frame is less than a first distortion threshold:

determining a score of the long-term reference frame as the first score, wherein the first distortion threshold is a sum of the degree of distortion of the first forward reference frame and the degree of distortion of the first backward reference frame.

5 . The method according to claim 1 , further comprising:

when a first candidate reference frame is an optimal reference frame of an adjacent coding unit among the m candidate reference frames, using a motion vector of the adjacent coding unit as a motion vector of the target coding unit;

calculating a degree of distortion of the first candidate reference frame based on the motion vector of the target coding unit; and

when the first candidate reference frame corresponds to the degrees of distortion of the optimal reference frames of at least two adjacent coding units:

determining a minimum degree of distortion as the degree of distortion of the first candidate reference frame, wherein the adjacent coding unit is a coding unit in the video frame that is coded by using inter-frame prediction, and the adjacent coding unit is adjacent to the target coding unit.

6 . The method according to claim 1 , wherein scoring the m candidate reference frames based on quality score information of the m candidate reference frames comprises:

determining, based on that a first candidate reference frame belongs to a preset reference frame set among the m candidate reference frames, a score of the first candidate reference frame as a first score, the preset reference frame set comprising at least one of the m candidate reference frames.

7 . The method according to claim 1 , wherein the inter-frame prediction comprises k prediction modes, and the method is applied to inter-frame prediction in an i th prediction mode; and

scoring the m candidate reference frames based on quality score information of the m candidate reference frames comprises:

determining the optimal reference frames of the target coding unit in a first prediction mode to an (i−1) th prediction mode, i being a positive integer greater than 1;

counting a number of times that the m candidate reference frames are respectively selected as the optimal reference frames of the target coding unit in the first prediction mode to the (i−1) th prediction mode; and

determining, based on a counting result, a score of a first candidate reference frame with the number of times of being selected exceeding a second times threshold among the m candidate reference frames as a first score.

8 . The method according to claim 1 , wherein scoring the m candidate reference frames based on quality score information of the m candidate reference frames comprises:

determining, based on that a quantity of candidate coding units of a current frame where the target coding unit being located is less than a first quantity threshold, scores of the nearest forward reference frame, the nearest backward reference frame and the farthest backward reference frame among the m candidate reference frames as a first score,

wherein each candidate coding unit is configured to provide a motion vector of the target coding unit, the first quantity threshold corresponds to a frame type of the current frame where the target coding unit is located, and the frame type is divided based on a reference relationship within a frame group where the current frame is located.

9 . The method according to claim 1 , wherein scoring the m candidate reference frames based on quality score information of the m candidate reference frames comprises:

scoring, based on q pieces of quality score information of scored candidate reference frames among the m candidate reference frames, the scored candidate reference frames q times to obtain q scoring results; and summing the q scoring results to obtain final scores of the scored candidate reference frames, q being a positive integer.

10 . A device comprising:

a processor, and

a memory, the memory storing a plurality of instructions that, when executed by the processor, cause the processor to:

acquire m candidate reference frames of a target coding unit, the target coding unit being one of a plurality of coding units of a video frame, and m being an integer greater than 1;

score the m candidate reference frames based on quality score information associated with each of the m candidate reference frames, the quality score information indicating coding quality of the target coding unit performing inter-frame prediction through the m candidate reference frames, wherein the scoring comprises determining, based on degrees of distortion of the m candidate reference frames, a score of a first candidate reference frame having a minimum degree of distortion among the m candidate reference frames as a first score, and wherein when candidate reference frames among the m candidate reference frames are not optimal reference frames of an adjacent coding unit, the degrees of distortion of candidate reference frames are determined using a preset degree of distortion, the adjacent coding unit being a coding unit in the video frame that is coded by using inter-frame prediction and being adjacent to the target coding unit; and

select an optimal reference frame of the target coding unit according to scoring results of the m candidate reference frames.

11 . The device according to claim 10 , wherein:

the first candidate reference frame is determined as an optimal reference frame of an adjacent coding unit among the m candidate reference frames.

12 . The device according to claim 10 , wherein when the processor is configured to score the m candidate reference frames based on quality score information of the m candidate reference frames, the processor is further configured to:

determine, based on that a first candidate reference frame belongs to a preset reference frame set among the m candidate reference frames, a score of the first candidate reference frame as a first score, the preset reference frame set comprising at least one of the m candidate reference frames.

13 . The device according to claim 10 , wherein when the processor is configured to score the m candidate reference frames based on quality score information of the m candidate reference frames, the processor is further configured to:

determine, based on that a quantity of candidate coding units of a current frame where the target coding unit is located is less than a first quantity threshold, scores of the nearest forward reference frame, the nearest backward reference frame and the farthest backward reference frame among the m candidate reference frames as a first score,

wherein each candidate coding unit is configured to provide a motion vector of the target coding unit, the first quantity threshold corresponds to a frame type of the current frame where the target coding unit is located, and the frame type is divided based on a reference relationship within a frame group where the current frame is located.

14 . The device according to claim 10 , wherein when the processor is configured to score the m candidate reference frames based on quality score information of the m candidate reference frames, the processor is further configured to:

score, based on q pieces of quality score information of scored candidate reference frames among the m candidate reference frames, the scored candidate reference frames q times to obtain q scoring results; and summing the q scoring results to obtain final scores of the scored candidate reference frames, q being a positive integer.

15 . A non-transitory computer-readable storage medium, storing a plurality of instructions configured to, when executed by a processor, cause the processor to:

acquire m candidate reference frames of a target coding unit, the target coding unit being one of a plurality of coding units of a video frame, and m being an integer greater than 1;

score the m candidate reference frames based on quality score information associated with each of the m candidate reference frames, the quality score information indicating coding quality of the target coding unit performing inter-frame prediction through the m candidate reference frames, wherein the scoring comprises determining, based on degrees of distortion of the m candidate reference frames, a score of a first candidate reference frame having a minimum degree of distortion among the m candidate reference frames as a first score, and wherein when candidate reference frames among the m candidate reference frames are not optimal reference frames of an adjacent coding unit, the degrees of distortion of candidate reference frames are determined using a preset degree of distortion, the adjacent coding unit being a coding unit in the video frame that is coded by using inter-frame prediction and being adjacent to the target coding unit; and

select an optimal reference frame of the target coding unit according to scoring results of the m candidate reference frames.

16 . The method according to claim 1 , wherein selecting the optimal reference frame of the target coding unit according to scoring results of the m candidate reference frames comprises:

eliminating candidate reference frames with scoring results less than a score threshold among the m candidate reference frames, to obtain n candidate reference frames, n being an integer greater than 1, and n being less than m;

calculating rate-distortion costs of all or some of the n candidate reference frames during the inter-frame prediction; and

determining a candidate reference frame with a minimum rate-distortion cost as the optimal reference frame of the target coding unit.

17 . The method according to claim 2 , wherein the inter-frame prediction comprises k prediction modes, the k prediction modes are obtained based on motion vector predictor classification of the target coding unit, and k is an integer greater than 1; and

wherein calculating rate-distortion costs of all or some of the n candidate reference frames during the inter-frame prediction comprises:

ranking the scoring results of the n candidate reference frames from high to low to obtain a ranking result;

performing, for an i th prediction mode, inter-frame prediction on a j th candidate reference frame based on the ranking result, and calculating a rate-distortion cost of the j th candidate reference frame, j being a positive integer, and an initial value of j being 1;

when the rate-distortion cost of the j th candidate reference frame is less than an i th cost threshold, updating j+1 to j, and re-executing the operation of performing, for an i th prediction mode, inter-frame prediction on a j th candidate reference frame based on the ranking result, and calculating a rate-distortion cost of the j th candidate reference frame; and

when the rate-distortion cost of the j th candidate reference frame is not less than an ith cost threshold, performing inter-frame prediction of an (i+1) th prediction mode, updating j to 1, updating i+1 to i, and re-executing the operation of performing, for an i th prediction mode, inter-frame prediction on a j th candidate reference frame based on the ranking result, and calculating a rate-distortion cost of the j th candidate reference frame.