# US 2013/0279585 A1 · Method and apparatus for detecting frame types

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2013/0279585 A1
- Document ID: US20130279585A1
- Status: Published application
- Kind: A1
- Application number: 13/919,674
- Filed: 2013-06-17
- Published: 2013-10-24
- Earliest claimed: 2010-12-17
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Qiu SHEN; Qingpeng XIE; Dong ZHANG; Houqiang LI
- Web page: https://patentgrep.com/patent/US20130279585A1

## CPC

- H04N 19/577: Motion compensation with bidirectional frame interpolation, i.e. using B-pictures
- H04N 19/503: involving temporal prediction (adaptive coding with adaptive selection between spatial and temporal predictive coding H04N19/107; adaptive coding with adaptive selection among a plurality of temporal predictive coding modes H04N19/109)
- H04N 19/89: involving methods or arrangements for detection of transmission errors at the decoder
- H04N: PICTORIAL COMMUNICATION, e.g. TELEVISION

## Abstract

Embodiments of the present invention disclose a method and an apparatus for detecting frame types. The method includes: detecting play time of each frame; and if the play time of a current frame is less than the maximum play time of received frames, determining the current frame as a bi-directional predicted frame, B-frame. In the technical solutions provided by the embodiments of the present invention, the frame types are determined according to a coding sequence of various frames and comparison between data amounts of various frames received earlier and later, without decoding a payload. Therefore the impact of a reduction factor is eliminated and the frame types can be detected more accurately.

## Claims

### Claim 1

A method for detecting frame types, comprising:
detecting play time of each frame; and
if the play time of a current frame is less than the maximum play time of received frames, determining the current frame as a bi-directional predicted frame (B-frame).

### Claim 2 (depends on 1)

The method according to claim 1, wherein after frame type detection ends, the method further comprises:
according to a play sequence and coding sequence of each frame, determining a layer to which the B-frame belongs in hierarchical coding.

### Claim 3 (depends on 1)

The method according to claim 1, wherein if the play time fails to be detected, the method further comprises:
obtaining a coding type of a bitstream comprising the received frames, wherein the coding type comprises open-loop coding and closed-loop coding;
if a data amount of the current frame is larger than a first threshold, determining the current frame as an obvious intra coded frame (I-frame), wherein the first threshold is obtained by calculation according to an average data amount of a specified number of consecutive frames and an data amount of the I-frame;
if a frame previous to the current frame is an I-frame and the coding type is closed-loop coding and the current frame is a non-obvious I-frame, or if the frame previous to the current frame is an I-frame and the coding type is open-loop coding and the data amount of the current frame is larger than a fourth threshold, determining the current frame as a unidirectional predicted frame (P-frame), wherein the fourth threshold is an average of an average data amount of the P-frames and an average data amount of B-frames in a group of pictures; and
if the current frame is neither an I-frame nor a P-frame, determining the current frame as a B-frame.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the obtaining a coding type of a bitstream comprising the received frames comprises:
counting the type of a frame next to an obvious I-frame, and if a ratio of P-frames reaches a specified ratio, determining that the coding type is closed-loop coding; if the ratio of the P-frames does not reach the specified ratio, determining that the coding type is open-loop coding.

### Claim 5 (depends on 3)

The method according to claim 3, further comprising:
if the data amount of the current frame is larger than a second threshold, determining the current frame as an I-frame, wherein the second threshold is a maximum threshold of the data amount of an I-frame previous to the current frame, the average data amount of P-frames in the group of pictures comprising the current frame, and the average data amount of the specified number of consecutive frames.

### Claim 6 (depends on 3)

The method according to claim 3, further comprising:
if an interval between the current frame and a previous I-frame is longer than a fixed interval and the data amount of the current frame is larger than a third threshold, determining the current frame as an I-frame, wherein the third threshold is obtained by calculation according to an average data amount of frames in the group of pictures comprising the current frame, the data amount of a P-frame previous to the current frame, the data amount of the I-frame in the group of pictures comprising the current frame, and a difference between a distance from the previous I-frame to the current frame and an expected fixed I-frame interval, or the third threshold is obtained by calculation according to the average data amount of frames in the group of pictures comprising the current frame and the difference between the distance from the previous I-frame to the current frame and the expected fixed I-frame interval.

### Claim 7 (depends on 3)

The method according to claim 3, further comprising:
if the frame previous to the current frame is a P-frame and the data amount of the current frame is larger than a fifth threshold, or if the group of pictures comprising the current frame comprises B-frames and the data amount of the current frame is larger than a sixth threshold, determining the current frame as a P-frame, wherein the fifth threshold is a product of a first adjustment factor and the average data amount of P-frames in the group of pictures comprising the current frame, wherein the first adjustment factor is larger than 0.5 and smaller than 1, and the sixth threshold is the average of the average data amount of P-frames and the average data amount of B-frames; and
if the frame previous to the current frame is a B-frame and the data amount of the current frame is smaller than a seventh threshold, or if the group of pictures comprising the current frame comprises P-frames and the data amount of the current frame is smaller than an eighth threshold, determining the current frame as a P-frame, wherein the seventh threshold is a product of a second adjustment factor and the average data amount of B-frames in the group of pictures comprising the current frame, wherein the second adjustment factor is larger than 1 and smaller than 1.5, and the eighth threshold is the average of the average data amount of P-frames and the average data amount of B-frames.

### Claim 8 (depends on 3)

The method according to claim 3, further comprising:
after frame type determination ends, determining the fixed I-frame interval, and after the fixed I-frame interval expires, if no I-frame exists, determining a frame having a maximum data amount in a specified range in the fixed interval as an I-frame; and updating average data amounts of various frames in the group of pictures and an I-frame interval parameter.

### Claim 9 (depends on 3)

The method according to claim 3, further comprising:
after frame type determination ends, counting consecutive B-frames, and if a quantity of consecutive B-frames is larger than a predicted value, determining a frame having a maximum data amount among the consecutive B-frames as a P-frame, and updating average data amounts of various frames in the group of pictures, wherein the predicted value is larger than or equal to 3 and smaller than or equal to 7.

### Claim 10 (depends on 3)

The method according to claim 3, further comprising:
determining whether any packet of a received frame is lost, and if packet loss occurs, determining a packet loss type;
if the packet loss type is packet loss occurred in intra frame, when calculating the data amount of the frame, determining a sum of the data amount of the received frame and the data amount of a lost packet as the data amount of the frame; and
if the packet loss type is packet loss occurred in an inter frame, determining whether a flag of a packet previous to the lost packet is 1, and if the flag of the packet previous to the lost packet is 1, counting the data amount of the lost packet into a next frame; if the flag of the packet previous to the lost packet is not 1, evenly allocating the data amount of a lost packet to the previous frame and the next frame.

### Claim 11

A method for detecting frame types, comprising:
obtaining a coding type of a bitstream comprising received frames, wherein the coding type comprises open-loop coding and closed-loop coding;
if a data amount of a current frame is larger than a first threshold, determining the current frame as an obvious intra coded frame (I-frame), wherein the first threshold is obtained by calculation according to an average data amount of a specified number of consecutive frames and the data amount of the I-frame;
if a frame previous to the current frame is an I-frame and the coding type is closed-loop coding and the current frame is a non-obvious I-frame, or if the frame previous to the current frame is an I-frame and the coding type is open-loop coding and the data amount of the current frame is larger than a fourth threshold, determining the current frame as a unidirectional predicted frame (P-frame), wherein the fourth threshold is an average of an average data amount of P-frames and an average data amount of bi-directional predicted frames (B-frames) in a group of pictures; and
if the current frame is neither an I-frame nor a P-frame, determining the current frame as a B-frame.

### Claim 12 (depends on 11)

The method according to claim 11, wherein the obtaining the coding type of the bitstream comprising the received frames comprises:
counting the type of a frame next to an obvious I-frame, and if a ratio of P-frames reaches a specified ratio, determining that the coding type is closed-loop coding, if the ratio of the P-frames does not reach the specified ratio, determining that the coding type is open-loop coding.

### Claim 13 (depends on 11)

The method according to claim 11, further comprising:
if the data amount of the current frame is larger than a second threshold, determining the current frame as an I-frame, wherein the second threshold is a maximum threshold of the data amount of an I-frame previous to the current frame, the average data amount of P-frames in the group of pictures comprising the current frame, and the average data amount of the specified number of consecutive frames.

### Claim 14 (depends on 11)

The method according to claim 11, further comprising:
if an interval between the current frame and a previous I-frame is longer than a fixed interval and the data amount of the current frame is larger than a third threshold, determining the current frame as an I-frame, wherein the third threshold is obtained by calculation according to an average data amount of frames in the group of pictures comprising the current frame, the data amount of a P-frame previous to the current frame, the data amount of the I-frame in the group of pictures comprising the current frame, and a difference between a distance from the previous I-frame to the current frame and an expected fixed I-frame interval, or the third threshold is obtained by calculation according to the average data amount of frames in the group of pictures comprising the current frame and the difference between the distance from the previous I-frame to the current frame and the expected fixed I-frame interval.

### Claim 15 (depends on 11)

The method according to claim 11, further comprising:
if the frame previous to the current frame is a P-frame and the data amount of the current frame is larger than a fifth threshold, or if the group of pictures comprising the current frame comprises B-frames and the data amount of the current frame is larger than a sixth threshold, determining the current frame as a P-frame, wherein the fifth threshold is a product of a first adjustment factor and the average data amount of P-frames in the group of pictures comprising the current frame, wherein the first adjustment factor is larger than 0.5 and smaller than 1, and the sixth threshold is the average of the average data amount of P-frames and the average data amount of B-frames; and
if the frame previous to the current frame is a B-frame and the data amount of the current frame is smaller than a seventh threshold, or if the group of pictures comprising the current frame comprises P-frames and the data amount of the current frame is smaller than an eighth threshold, determining the current frame as a P-frame, wherein the seventh threshold is a product of a second adjustment factor and the average data amount of B-frames in the group of pictures comprising the current frame, wherein the second adjustment factor is larger than 1 and smaller than 1.5, and the eighth threshold is the average of the average data amount of P-frames and the average data amount of B-frames.

### Claim 16 (depends on 11)

The method according to claim 11, further comprising:
after frame type determination ends, determining the fixed I-frame interval, and after the fixed I-frame interval expires, if it is still determined that no I-frame exists, determining a frame having a maximum data amount in a specified range in the fixed interval as an I-frame; and updating average data amounts of various frames in the group of pictures and an I-frame interval parameter.

### Claim 17 (depends on 11)

The method according to claim 11, further comprising:
after frame type determination ends, counting consecutive B-frames, and if a quantity of consecutive B-frames is larger than a predicted value, determining a frame having a maximum data amount among the consecutive B-frames as a P-frame, and updating average data amounts of various frames in the group of pictures, wherein the predicted value is larger than or equal to 3 and smaller than or equal to 7.

### Claim 18 (depends on 11)

The method according to claim 11, further comprising:
determining whether any packet of a received frame is lost, and if packet loss occurs, determining a packet loss type;
if the packet loss type is packet loss occurred in an intra frame, when calculating the data amount of the frame, determining a sum of the data amount of the received frame and the data amount of the lost packet as the data amount of the frame; and
if the packet loss type is packet loss occurred in an inter frame, determining whether a flag of a packet previous to the lost packet is 1, and if the flag of the packet previous to the lost packet is 1, counting the data amount of the lost packet into a next frame, if the flag of the packet previous to the lost packet is not 1, evenly allocating the data amount of a lost packet to the previous frame and the next frame.

### Claim 19 (depends on 18)

The method according to claim 18, further comprising:
predicting a coding structure by counting the detected types of frames; and
if the packet loss type is packet loss occurred in the inter frame and the flag of the packet previous to the position of the lost packet fails to be detected, dividing the length of current data according to the predicted coding structure and the position of the lost packet.

### Claim 20

An apparatus for detecting frame types, comprising:
a time detecting unit, configured to detect play time of each frame; and
a frame type determining unit, configured to determine a current frame as a bi-directional predicted frame (B-frame), if the play time of the current frame is less than a maximum play time of received frames.

### Claim 21 (depends on 20)

The apparatus according to claim 20, further comprising:
a layer determining unit, configured to determine, according to a play sequence and coding sequence of each frame, a layer to which the B-frame belongs in hierarchical coding.

### Claim 22

An apparatus for detecting frame types, comprising:
a type obtaining unit, configured to obtain a coding type of a bitstream comprising received frames, wherein the coding type comprises open-loop coding and closed-loop coding; and
a frame type determining unit, configured to: if a data amount of a current frame is larger than a first threshold, determine the current frame as an obvious intra coded frame (I-frame), wherein the first threshold is obtained by calculation according to an average data amount of a specified number of consecutive frames and the data amount of the I-frame;
if a frame previous to the current frame is an I-frame and the coding type is closed-loop coding and the current frame is a non-obvious I-frame, or if a frame previous to the current frame is an I-frame and the coding type is open-loop coding and the data amount of the current frame is larger than a fourth threshold, determine the current frame as a predicted frame (P-frame), wherein the fourth threshold is an average of an average data amount of P-frames and an average data amount of bi-directional predicted frames (B-frames) in a group of pictures; and
if the current frame is neither an I-frame nor a P-frame, determine the current frame as a B-frame.

### Claim 23 (depends on 22)

The apparatus according to claim 22, wherein:
the frame type determining unit is further configured to: if the data amount of the current frame is larger than a second threshold, determine the current frame as an I-frame, wherein the second threshold is a maximum one of a data amount of an I-frame previous to the current frame, the average data amount of the P-frames in the group of pictures comprising the current frame, and the average data amount of the specified number of consecutive frames.

### Claim 24 (depends on 22)

The apparatus according to claim 22, wherein:
the frame type determining unit is further configured to: if an interval between the current frame and a previous I-frame is longer than a fixed interval and the data amount of the current frame is larger than a third threshold, determine the current frame as an I-frame, wherein the third threshold is obtained by calculation according to an average data amount of frames in the group of pictures comprising the current frame, the data amount of a P-frame previous to the current frame, the data amount of the I-frame in the group of pictures comprising the current frame, and a difference between a distance from the previous I-frame to the current frame and an expected fixed I-frame interval, or the third threshold is obtained by calculation according to an average data amount of frames in the group of pictures comprising the current frame and a difference between a distance from the previous I-frame to the current frame and an expected fixed I-frame interval.

### Claim 25 (depends on 22)

The apparatus according to claim 22, wherein:
the frame type determining unit is further configured to: if the frame previous to the current frame is a P-frame and the data amount of the current frame is larger than a fifth threshold, or if the group of pictures comprising the current frame comprises B-frames and the data amount of the current frame is larger than a sixth threshold, determine the current frame as a P-frame, wherein the fifth threshold is a product of a first adjustment factor and the average data amount of P-frames in the group of pictures comprising the current frame, wherein the first adjustment factor is larger than 0.5 and smaller than 1, and the sixth threshold is the average of the average data amount of P-frames and the average data amount of B-frames; and
if the frame previous to the current frame is a B-frame and the data amount of the current frame is smaller than a seventh threshold, or if the group of pictures comprising the current frame comprises P-frames and the data amount of the current frame is smaller than an eighth threshold, determine the current frame as a P-frame, wherein the seventh threshold is a product of a second adjustment factor and the average data amount of B-frames in the group of pictures comprising the current frame, wherein the second adjustment factor is larger than 1 and smaller than 1.5, and the eighth threshold is the average of the average data amount of P-frames and the average data amount of B-frames.

### Claim 26 (depends on 22)

The apparatus according to claim 22, further comprising:
an interval obtaining unit, configured to determine the fixed I-frame interval after frame type determination ends;
the frame type determining unit, further configured to determine a frame having a maximum data amount in a specified range in the fixed interval as an I-frame after the fixed interval expires, if no I-frame exists; and
a first updating unit, configured to update average data amounts of various frames in the group of pictures and an I-frame interval parameter.

### Claim 27 (depends on 22)

The apparatus according to claim 22, further comprising:
a counting unit, configured to count consecutive B-frames after frame type determination ends;
the frame type determining unit, further configured to determine a frame having a maximum data amount among the consecutive B-frames as a P-frame if the number of consecutive B-frames is larger than a predicted value, wherein the predicted value is larger than or equal to 3 and smaller than or equal to 7; and
a second updating unit, configured to update average data amounts of various frames in the group of pictures.

### Claim 28 (depends on 22)

The apparatus according to claim 22, further comprising:
a packet loss type determining unit, configured to determine whether any packet of a received frame is lost, and if packet loss occurs, determine a packet loss type;
a data amount determining unit, configured to: if the packet loss type is packet loss occurred in intra frame, when calculating the data amount of the frame, determine a sum of the data amount of the received frame and the data amount of the lost packet as the data amount of the frame; and
if the packet loss type is packet loss occurred in inter frame, determine whether a flag of a packet previous to the lost packet is 1, and if the flag of the packet previous to the lost packet is 1, count the data amount of the lost packet into a next frame, if the flag of the packet previous to the lost packet is not 1, evenly allocate the data amount of the lost packet to the previous frame and the next frame.
