7 #ifndef MEDIA_CODECS_NALU_READER_H_
8 #define MEDIA_CODECS_NALU_READER_H_
13 #include "packager/base/compiler_specific.h"
14 #include "packager/base/macros.h"
22 const uint8_t kIsAnnexbByteStream = 0;
38 H264_SPSExtension = 13,
39 H264_PrefixNALUnit = 14,
41 H264_DepthParameterSet = 16,
44 H264_CodedSliceExtension = 20,
56 H265_RSV_VCL_N10 = 10,
57 H265_RSV_VCL_R15 = 15,
64 H265_RSV_IRAP_VCL22 = 22,
65 H265_RSV_IRAP_VCL23 = 23,
91 bool Initialize(CodecType
type,
93 uint64_t size) WARN_UNUSED_RESULT;
96 const uint8_t*
data()
const {
return data_; }
104 int ref_idc()
const {
return ref_idc_; }
107 int nuh_layer_id()
const {
return nuh_layer_id_; }
108 int nuh_temporal_id()
const {
return nuh_temporal_id_; }
112 int type()
const {
return type_; }
113 bool is_aud()
const {
return is_aud_; }
114 bool is_video_slice()
const {
return is_video_slice_; }
115 bool can_start_access_unit()
const {
return can_start_access_unit_; }
118 bool InitializeFromH264(
const uint8_t* data, uint64_t size);
119 bool InitializeFromH265(
const uint8_t* data, uint64_t size);
123 const uint8_t* data_ =
nullptr;
126 uint64_t header_size_ = 0;
128 uint64_t payload_size_ = 0;
131 int nuh_layer_id_ = 0;
132 int nuh_temporal_id_ = 0;
134 bool is_aud_ =
false;
135 bool is_video_slice_ =
false;
136 bool can_start_access_unit_ =
false;
157 uint8_t nal_length_size,
158 const uint8_t* stream,
159 uint64_t stream_size);
171 static bool FindStartCode(
const uint8_t* data,
174 uint8_t* start_code_size);
188 kAnnexbByteStreamFormat,
199 bool LocateNaluByStartCode(uint64_t* nalu_size, uint8_t* start_code_size);
202 const uint8_t* stream_;
204 uint64_t stream_size_;
206 Nalu::CodecType nalu_type_;
209 uint8_t nalu_length_size_;
219 #endif // MEDIA_CODECS_NALU_READER_H_