#include <h264utils.h>
Theory of operation: A true H.264 keyframe is an IDR (instantaneous decoding refresh) slice.
You submit bytes to instances of this class, and it will tell you if you're synced on a NAL unit. More bytes and you get the type. Keep going and you'll be know when you're on keyframes.
As a bonus, if you submit stream offsets, it will track access unit offsets such that you can seek in a stream and please H.264 decoders.
This class only applies to the byte stream format as specified by ITU-T Rec. H.264 (03/2005) Annex B.
Definition at line 143 of file h264utils.h.
Public Member Functions | |
| KeyframeSequencer () | |
| bool | IsErrored (void) const |
| bool | HasStateChanged (void) const |
| void | Reset (void) |
| uint32_t | AddBytes (const uint8_t *bytes, const uint32_t byte_count, const int64_t stream_offset) |
| This function more or less follows the method in ITU-T Rec. | |
| uint8_t | LastSyncedType (void) const |
| This function returns the NAL unit type of the last synced unit. | |
| bool | IsOnFrame (void) const |
| bool | IsOnKeyframe (void) const |
| int64_t | KeyframeAUStreamOffset (void) const |
Private Member Functions | |
| void | KeyframePredicate (const uint8_t new_first_NAL_byte) |
Private Attributes | |
| bool | errored |
| bool | state_changed |
| uint32_t | sync_accumulator |
| int64_t | sync_stream_offset |
| uint8_t | first_NAL_byte |
| bool | saw_AU_delimiter |
| bool | saw_first_VCL_NAL_unit |
| bool | saw_sps |
| bool | did_evaluate_once |
| bool | keyframe |
| int64_t | keyframe_sync_stream_offset |
| H264::KeyframeSequencer::KeyframeSequencer | ( | ) |
Definition at line 50 of file h264utils.cpp.
| bool H264::KeyframeSequencer::IsErrored | ( | void | ) | const [inline] |
Definition at line 148 of file h264utils.h.
| bool H264::KeyframeSequencer::HasStateChanged | ( | void | ) | const [inline] |
Definition at line 150 of file h264utils.h.
Referenced by DTVRecorder::FindH264Keyframes(), and AvFormatDecoder::H264PreProcessPkt().
| void H264::KeyframeSequencer::Reset | ( | void | ) |
Definition at line 55 of file h264utils.cpp.
Referenced by AvFormatDecoder::CloseContext(), KeyframeSequencer(), DTVRecorder::ResetForNewFile(), and AvFormatDecoder::ScanStreams().
| uint32_t H264::KeyframeSequencer::AddBytes | ( | const uint8_t * | bytes, | |
| const uint32_t | byte_count, | |||
| const int64_t | stream_offset | |||
| ) |
This function more or less follows the method in ITU-T Rec.
H.264 (03/2005) B.2. It returns the number of bytes it has consumed when the sequencer's state has changed or when there are no bytes left to process.
Definition at line 139 of file h264utils.cpp.
Referenced by DTVRecorder::FindH264Keyframes(), and AvFormatDecoder::H264PreProcessPkt().
| uint8_t H264::KeyframeSequencer::LastSyncedType | ( | void | ) | const [inline] |
This function returns the NAL unit type of the last synced unit.
Definition at line 165 of file h264utils.h.
Referenced by DTVRecorder::FindH264Keyframes().
| bool H264::KeyframeSequencer::IsOnFrame | ( | void | ) | const |
| bool H264::KeyframeSequencer::IsOnKeyframe | ( | void | ) | const [inline] |
Definition at line 169 of file h264utils.h.
Referenced by DTVRecorder::FindH264Keyframes(), and AvFormatDecoder::H264PreProcessPkt().
| int64_t H264::KeyframeSequencer::KeyframeAUStreamOffset | ( | void | ) | const [inline] |
| void H264::KeyframeSequencer::KeyframePredicate | ( | const uint8_t | new_first_NAL_byte | ) | [private] |
bool H264::KeyframeSequencer::errored [private] |
bool H264::KeyframeSequencer::state_changed [private] |
Definition at line 179 of file h264utils.h.
Referenced by AddBytes(), HasStateChanged(), KeyframePredicate(), and Reset().
Definition at line 182 of file h264utils.h.
Referenced by AddBytes(), KeyframePredicate(), and Reset().
uint8_t H264::KeyframeSequencer::first_NAL_byte [private] |
Definition at line 184 of file h264utils.h.
Referenced by AddBytes(), KeyframePredicate(), LastSyncedType(), and Reset().
Definition at line 187 of file h264utils.h.
Referenced by IsOnFrame(), KeyframePredicate(), and Reset().
bool H264::KeyframeSequencer::saw_sps [private] |
bool H264::KeyframeSequencer::keyframe [private] |
Definition at line 191 of file h264utils.h.
Referenced by AddBytes(), IsOnKeyframe(), KeyframePredicate(), and Reset().
Definition at line 192 of file h264utils.h.
Referenced by KeyframeAUStreamOffset(), KeyframePredicate(), and Reset().
1.5.5