class H264Parser
Defined at line 434 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.h
Class to parse an Annex-B H.264 stream,
as specified in chapters 7 and Annex B of the H.264 spec.
Public Methods
bool FindStartCode (base::span<const uint8_t>data,size_t *offset,size_t *start_code_size)
Find offset from start of data to next NALU start code
and size of found start code (3 or 4 bytes).
If no start code is found, offset is pointing to the first unprocessed byte
(i.e. the first byte that was not considered as a possible start of a start
code) and |*start_code_size| is set to 0.
Preconditions:
- |data_size| >= 0
Postconditions:
- |*offset| is between 0 and |data_size| included.
It is strictly less than |data_size| if |data_size| > 0.
- |*start_code_size| is either 0, 3 or 4.
Defined at line 354 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
bool FindStartCodeInClearRanges (base::span<const uint8_t>data,const Ranges<const uint8_t *> &ranges,size_t *offset,size_t *start_code_size)
Wrapper for FindStartCode() that skips over start codes that
may appear inside of |encrypted_ranges_|.
Returns true if a start code was found. Otherwise returns false.
Defined at line 427 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
bool FindStartCodeInClearRanges (const uint8_t *data,off_tdata_size,const Ranges<const uint8_t *> &ranges,off_t *offset,off_t *start_code_size)
DEPRECATED: Use the above `base::span` variant to avoid unsafe buffer
usage.
TODO(https://crbug.com/40284755): Remove this once the callers are gone.
Defined at line 463 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
VideoCodecProfile ProfileIDCToVideoCodecProfile (int profile_idc)
static
Defined at line 479 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
bool ParseNALUs (base::span<const uint8_t> stream, std::vector<H264NALU> * nalus)
Parses the input stream and returns all the NALUs through |nalus|. Returns
false if the stream is invalid.
Defined at line 507 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void H264Parser ()
Defined at line 285 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void ~H264Parser ()
Defined at line 289 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void Reset ()
Defined at line 291 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void SetStream (base::span<const uint8_t> stream)
Set current stream pointer to |stream| of |stream_size| in bytes,
|stream| owned by caller.
|subsamples| contains information about what parts of |stream| are
encrypted.
Defined at line 302 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void SetStream (const uint8_t * stream, off_t stream_size)
DEPRECATED: Use the above `base::span` variant to avoid unsafe buffer
usage.
TODO(https://crbug.com/40284755): Remove this once the callers are gone.
Defined at line 297 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void SetEncryptedStream (base::span<const uint8_t> stream, const std::vector<SubsampleEntry> & subsamples)
Defined at line 307 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
void H264Parser (const H264Parser & )
Defined at line 484 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.h
H264Parser & operator= (const H264Parser & )
Defined at line 485 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.h
Result AdvanceToNextNALU (H264NALU * nalu)
Read the stream to find the next NALU, identify it and return
that information in |*nalu|. This advances the stream to the beginning
of this NALU, but not past it, so subsequent calls to NALU-specific
parsing functions (ParseSPS, etc.) will parse this NALU.
If the caller wishes to skip the current NALU, it can call this function
again, instead of any NALU-type specific parse functions below.
Defined at line 527 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result ParseSPS (int * sps_id)
SPSes and PPSes are owned by the parser class and the memory for their
structures is managed here, not by the caller, as they are reused
across NALUs.
For accepting variants, the caller passes in a std::unique_ptr
<
> which
transfers ownership from caller to parser class.
Parse/accept an SPS/PPS NALU and save their data in the parser, returning
id of the parsed structure in |*pps_id|/|*sps_id|.
To get a pointer to a given SPS/PPS structure, use GetSPS()/GetPPS(),
passing the returned |*sps_id|/|*pps_id| as parameter.
TODO(posciak,fischman): consider replacing returning Result from Parse*()
methods with a scoped_ptr and adding an AtEOS() function to check for EOS
if Parse*() return NULL.
Defined at line 945 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result AcceptPreparsedSPS (std::unique_ptr<H264SPS> preparsed_sps, int * sps_id)
Defined at line 1068 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result ParsePPS (int * pps_id)
Defined at line 1094 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result AcceptPreparsedPPS (std::unique_ptr<H264PPS> preparsed_pps, int * pps_id)
Defined at line 1189 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result ParseSPSExt (int * sps_id)
Parses the SPS ID from the SPSExt, but otherwise does nothing.
Defined at line 1213 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
const H264SPS * GetSPS (int sps_id)
Return a pointer to SPS/PPS with given |sps_id|/|pps_id| or NULL if not
present.
Defined at line 338 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
const H264PPS * GetPPS (int pps_id)
Defined at line 328 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result ParseSliceHeader (const H264NALU & nalu, H264SliceHeader * shdr)
Parse a slice header, returning it in |*shdr|. |*nalu| must be set to
the NALU returned from AdvanceToNextNALU() and corresponding to |*shdr|.
Defined at line 1419 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Result ParseSEI (H264SEI * sei)
Parse a SEI, returning it in |*sei|, provided and managed by the caller.
Defined at line 1624 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
std::vector<SubsampleEntry> GetCurrentSubsamples ()
The return value of this method changes for every successful call to
AdvanceToNextNALU().
This returns the subsample information for the last NALU that was output
from AdvanceToNextNALU().
Defined at line 1776 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.cc
Enumerations
enum Result
| Name | Value | Comments |
|---|---|---|
| kOk | 0 | -- |
| kInvalidStream | 1 |
error in stream |
| kUnsupportedStream | 2 |
stream not supported by the parser |
| kEOStream | 3 |
end of stream |
Defined at line 436 of file ../../src/media/third_party/chromium_media/media/parsers/h264_parser.h