34 unsigned int fromHex(
const std::string & s )
36 unsigned int result = 0U ;
37 for(
size_t i = 0U ; i < s.length() ; i++ )
40 unsigned int c =
static_cast<unsigned char>(s.at(i)) ;
41 if( c >= 48U && c <= 57U ) result += c - 48U ;
42 else if( c >= 65U && c <= 70U ) result += c - 65U + 10U ;
43 else if( c >= 97U && c <= 102U ) result += c - 97U + 10U ;
44 else throw std::runtime_error(
"invalid hex string [" + s +
"]" ) ;
62 is_fmtp ? initFmtp(s) : initAvcc(s) ;
67 report(
"default constructed" ) ;
70 void Gr::Avc::Configuration::initFmtp(
const std::string & fmtp )
73 for( G::StringArray::iterator p = parts.begin() ; p != parts.end() ; ++p )
75 typedef std::string::size_type pos_t ;
76 pos_t pos = (*p).find(
"=") ;
77 std::string key =
G::Str::head( *p , pos , std::string() ) ;
78 std::string value =
G::Str::tail( *p , pos , std::string() ) ;
79 if( key ==
"profile-level-id" )
83 m_fmtp_info.profile = value.length() == 6U ? fromHex(value.substr(0U,2U)) : 999U ;
84 m_fmtp_info.level = value.length() == 6U ? fromHex(value.substr(2U)) : 999U ;
87 else if( key ==
"packetization-mode" )
91 else if( key ==
"sprop-parameter-sets" )
94 for( G::StringArray::iterator sp = s.begin() ; sp != s.end() ; ++sp )
96 G_DEBUG(
"Gr::Avc: fmtp parameter set [" << *sp <<
"]" ) ;
98 G_DEBUG(
"Gr::Avc: fmtp parameter set [" << G::hexdump<999>(pset) <<
"]" ) ;
99 unsigned int nalu_type =
static_cast<unsigned char>(pset.at(0U)) & 0x1f ;
101 m_sps_list.push_back( pset ) ;
102 else if( nalu_type == 8 )
103 m_pps_list.push_back( pset ) ;
105 G_WARNING(
"Gr::Avc: unexpected nalu type in fmtp: " << nalu_type ) ;
117 void Gr::Avc::Configuration::initAvcc(
const std::string & avcc_in )
121 G_DEBUG(
"Gr::Avc: avcc=[" << G::hexdump<999>(avcc_in.begin(),avcc_in.end()) <<
"]" ) ;
122 bit_stream_t stream( bit_iterator_t(avcc_in.data()) , bit_iterator_t(avcc_in.data()+avcc_in.size()) ) ;
124 m_avcc_info.configuration_version = stream.get_byte() ;
125 m_avcc_info.profile = stream.get_byte() ;
126 m_avcc_info.profile_compat = stream.get_byte() ;
127 m_avcc_info.level = stream.get_byte() ;
129 m_avcc_info.length_size_minus_one = stream.get_byte() ;
130 if( ( m_avcc_info.length_size_minus_one & 0xfc ) != 0xfc ) report(
"invalid reserved bits" ) ;
131 m_avcc_info.length_size_minus_one &= 0x03 ;
133 unsigned int sps_count = stream.get_byte() ;
134 if( ( sps_count & 0xe0 ) != 0xe0 ) report(
"invalid reserved bits" ) ;
137 unsigned int sps_size = stream.get_word() ;
138 G_DEBUG(
"Gr::Avc: avcc: sps_count=" << sps_count <<
" sps_size=" << sps_size ) ;
139 for(
unsigned int i = 0 ; i < sps_count ; i++ )
142 for(
unsigned int j = 0 ; j < sps_size ; j++ )
143 s.append( 1U , static_cast<char>(stream.get_byte()) ) ;
144 m_sps_list.push_back( s ) ;
145 G_DEBUG(
"Gr::Avc: avcc: sps=[" << G::hexdump<999>(m_sps_list.back().begin(),m_sps_list.back().end()) <<
"]" ) ;
148 unsigned int pps_count = stream.get_byte() ;
149 unsigned int pps_size = stream.get_word() ;
150 G_DEBUG(
"Gr::Avc: avcc: pps_count=" << pps_count <<
" pps_size=" << pps_size ) ;
151 for(
unsigned int i = 0 ; i < pps_count ; i++ )
154 for(
unsigned int j = 0 ; j < pps_size ; j++ )
155 s.append( 1U , static_cast<char>(stream.get_byte()) ) ;
156 m_pps_list.push_back( s ) ;
157 G_DEBUG(
"Gr::Avc: avcc: pps=[" << G::hexdump<999>(m_pps_list.back().begin(),m_pps_list.back().end()) <<
"]" ) ;
160 checkStream( stream ) ;
167 void Gr::Avc::Configuration::checkFmtp()
169 if( m_fmtp_info.packetisation_mode != 1U )
170 report(
"unsuported packetisation mode in fmtp string" ) ;
173 void Gr::Avc::Configuration::checkStream( bit_stream_t & stream )
176 report(
"avcc premature end" ) ;
177 else if( !stream.at_end() )
178 report(
"avcc has trailing junk" ) ;
181 void Gr::Avc::Configuration::spsListParse()
183 for(
unsigned int i = 0 ; i < m_sps_list.size() ; i++ )
185 m_sps.push_back( Sps(m_sps_list.at(i)) ) ;
186 if( !m_sps.back().valid() )
187 report( m_sps.back().reason() ) ;
191 void Gr::Avc::Configuration::ppsListParse()
195 report(
"cannot parse pps without sps" ) ;
203 int sps_chroma_format_idc = m_sps.front().m_chroma_format_idc ;
205 for(
unsigned int i = 0 ; m_reason.empty() && i < m_pps_list.size() ; i++ )
207 m_pps.push_back( Pps(m_pps_list.at(i),sps_chroma_format_idc) ) ;
208 if( !m_pps.back().valid() )
209 report( m_pps.back().reason() ) ;
213 void Gr::Avc::Configuration::checkIds()
215 std::set<unsigned int> sps_ids ;
216 for(
size_t i = 0U ; i < m_sps.size() ; i++ )
218 unsigned int sps_id = m_sps.at(i).m_sequence_parameter_set_id ;
219 if( sps_ids.find(sps_id) != sps_ids.end() ) report(
"sps id not unique" ) ;
220 sps_ids.insert( sps_id ) ;
222 std::set<unsigned int> pps_ids ;
223 for(
size_t i = 0U ; i < m_pps.size() ; i++ )
225 unsigned int pps_id = m_pps.at(i).m_pic_parameter_set_id ;
226 unsigned int sps_id = m_pps.at(i).m_seq_parameter_set_id ;
227 if( pps_ids.find(pps_id) != pps_ids.end() ) report(
"pps id not unique" ) ;
228 if( sps_ids.find(sps_id) == sps_ids.end() ) report(
"invalid sps id in pps" ) ;
229 pps_ids.insert( pps_id ) ;
233 void Gr::Avc::Configuration::commit()
235 if( !m_reason.empty() )
241 void Gr::Avc::Configuration::report(
const std::string & s )
243 m_reason.append( m_reason.empty() ? s : (
": "+s) ) ;
248 return m_reason.empty() ;
258 return m_avcc_info.length_size_minus_one + 1U ;
273 return m_sps.size() ;
278 return m_pps.size() ;
298 result.append( sep ) ;
299 result.append( m_sps_list.at(i) ) ;
303 result.append( sep ) ;
304 result.append( m_pps_list.at(i) ) ;
319 m_nalu_type = stream.
get_byte() & 0x1f ;
321 m_constraint_set0_flag = stream.
get_bool() ;
322 m_constraint_set1_flag = stream.
get_bool() ;
323 m_constraint_set2_flag = stream.
get_bool() ;
324 m_constraint_set3_flag = stream.
get_bool() ;
325 m_constraint_set4_flag = stream.
get_bool() ;
326 m_constraint_set5_flag = stream.
get_bool() ;
327 m_zero = stream.
get( 2U ) ;
331 bool extended_profile =
332 m_profile_idc == 100 || m_profile_idc == 110 || m_profile_idc == 122 ||
333 m_profile_idc == 244 || m_profile_idc == 44 || m_profile_idc == 83 ||
334 m_profile_idc == 86 || m_profile_idc == 118 || m_profile_idc == 128 ;
335 m_chroma_format_idc = 0 ;
336 m_separate_colour_plane_flag = false ;
337 m_bit_depth_luma_minus8 = 0U ;
338 m_bit_depth_chroma_minus8 = 0U ;
339 m_qpprime_y_zero_transform_bypass_flag = false ;
340 m_seq_scaling_matrix_present_flag = false ;
341 if( extended_profile )
344 m_separate_colour_plane_flag = m_chroma_format_idc == 3 ? stream.
get_bool() : false ;
347 m_qpprime_y_zero_transform_bypass_flag = stream.
get_bool() ;
348 m_seq_scaling_matrix_present_flag = stream.
get_bool() ;
349 if( m_seq_scaling_matrix_present_flag )
351 report(
"sps seq_scaling_matrix_present_flag not yet implemented" ) ;
352 int n = (m_chroma_format_idc != 3) ? 8 : 12 ;
353 for(
int i = 0 ; i < n ; i++ )
361 m_log2_max_pic_order_cnt_lsb_minus4 = 0U ;
362 m_delta_pic_order_always_zero_flag = false ;
363 m_offset_for_non_ref_pic = 0 ;
364 m_offset_for_top_to_bottom_field = 0 ;
365 m_num_ref_frames_in_pic_order_cnt_cycle = 0U ;
366 if( m_pic_order_cnt_type == 0U )
370 else if( m_pic_order_cnt_type == 1U )
372 m_delta_pic_order_always_zero_flag = stream.
get_bool() ;
376 for(
unsigned int i = 0 ; i < m_num_ref_frames_in_pic_order_cnt_cycle ; i++ )
381 m_gaps_in_frame_num_value_allowed_flag = stream.
get_bool() ;
385 m_frame_mbs_only_flag = stream.
get_bool() ;
386 m_mb_adaptive_frame_field_flag = m_frame_mbs_only_flag ?
false : stream.
get_bool() ;
388 m_direct_8x8_inference_flag = stream.
get_bool() ;
390 m_frame_cropping_flag = stream.
get_bool() ;
396 m_vui_parameters_present_flag = stream.
get_bool() ;
397 m_nal_hrd_parameters_present_flag = false ;
398 m_vcl_hrd_parameters_present_flag = false ;
399 if( m_vui_parameters_present_flag )
402 G_DEBUG(
"Gr::Avc: vui parameters preset at bit offset " << stream.
tellg() ) ;
403 bool aspect_ratio_info_present_flag = stream.
get_bool() ;
404 if( aspect_ratio_info_present_flag )
406 unsigned char aspect_ratio_idc = stream.
get_byte() ;
407 if( aspect_ratio_idc == 255U )
413 bool overscan_info_present_flag = stream.
get_bool() ;
414 if( overscan_info_present_flag )
416 bool video_signal_type_present_flag = stream.
get_bool() ;
417 if( video_signal_type_present_flag )
421 bool colour_description_present_flag = stream.
get_bool() ;
422 if( colour_description_present_flag )
425 bool chroma_loc_info_present_flag = stream.
get_bool() ;
426 if( chroma_loc_info_present_flag )
428 bool timing_info_present_flag = stream.
get_bool() ;
429 if( timing_info_present_flag )
431 m_nal_hrd_parameters_present_flag = stream.
get_bool() ;
432 if( m_nal_hrd_parameters_present_flag )
433 skip_hrd_parameters( stream ) ;
434 m_vcl_hrd_parameters_present_flag = stream.
get_bool() ;
435 if( m_vcl_hrd_parameters_present_flag )
436 skip_hrd_parameters( stream ) ;
437 if( m_nal_hrd_parameters_present_flag || m_vcl_hrd_parameters_present_flag )
440 bool stream_restriction_flag = stream.
get_bool() ;
441 if( stream_restriction_flag )
444 for(
int i = 0 ; i < 6 ; i++ )
448 G_DEBUG(
"Gr::Avc: sps: tellg=" << stream.
tellg() <<
" stopbit=" << rbsp_stop_bit_pos ) ;
452 if( !stream.
good() ) report(
"premature end of data" ) ;
453 if( stream.
tellg() != rbsp_stop_bit_pos ) report(
"parsing did not finish at the stop bit" ) ;
454 if( m_nalu_type != 7U ) report(
"invalid nalu type (" , m_nalu_type ,
")" ) ;
455 if( m_zero != 0U ) report(
"invalid zero field (" , m_zero ,
")" ) ;
456 if( m_pic_order_cnt_type > 1U ) report(
"invalid pic_order_cnt_type (" , m_pic_order_cnt_type ,
")" ) ;
457 if( m_seq_scaling_matrix_present_flag ) report(
"seq_scaling_matrix_present_flag not yet implemented" ) ;
458 if( m_nal_hrd_parameters_present_flag ) report(
"nal_hrd_parameters_present_flag not yet implemented" ) ;
459 if( m_vcl_hrd_parameters_present_flag ) report(
"vcl_hrd_parameters_present_flag not yet implemented" ) ;
465 unsigned int mb_width = m_pic_width_in_mbs_minus1 + 1 ;
466 const bool chroma_444 = m_chroma_format_idc == 3 ;
468 return 16U * mb_width - std::min( m_frame_crop_right_offset , 15U ) ;
470 return 16U * mb_width - 2U * std::min( m_frame_crop_right_offset , 7U ) ;
475 unsigned int mb_height = m_pic_height_in_map_units_minus1 + 1U ;
476 const unsigned int chroma_y_shift = ( m_chroma_format_idc <= 1U ) ? 1U : 0U ;
477 if( m_frame_mbs_only_flag )
478 return 16U * mb_height - (1<<chroma_y_shift) * std::min( m_frame_crop_bottom_offset , (0x10>>chroma_y_shift)-1U ) ;
480 return 16U * mb_height - (2<<chroma_y_shift) * std::min( m_frame_crop_bottom_offset , (0x10>>chroma_y_shift)-1U ) ;
483 void Gr::Avc::Sps::report(
const std::string & a ,
unsigned int b ,
const std::string & c )
485 m_reason.append( m_reason.empty() ?
"sps error: " :
": " ) ;
496 return m_reason.empty() ;
504 void Gr::Avc::Sps::skip_hrd_parameters(
bit_stream_t & )
512 "profile_idc=" << m_profile_idc <<
" "
513 "constraint_set0_flag=" << m_constraint_set0_flag <<
" "
514 "constraint_set1_flag=" << m_constraint_set1_flag <<
" "
515 "constraint_set2_flag=" << m_constraint_set2_flag <<
" "
516 "constraint_set3_flag=" << m_constraint_set3_flag <<
" "
517 "constraint_set4_flag=" << m_constraint_set4_flag <<
" "
518 "constraint_set5_flag=" << m_constraint_set5_flag <<
" "
519 "zero=" << m_zero <<
" "
520 "level_idc=" << m_level_idc <<
" "
521 "sequence_parameter_set_id=" << m_sequence_parameter_set_id <<
" "
522 "log2_max_frame_num_minus4=" << m_log2_max_frame_num_minus4 <<
" "
523 "pic_order_cnt_type=" << m_pic_order_cnt_type <<
" "
524 "log2_max_pic_order_cnt_lsb_minus4=" << m_log2_max_pic_order_cnt_lsb_minus4 <<
" "
525 "delta_pic_order_always_zero_flag=" << m_delta_pic_order_always_zero_flag <<
" "
526 "offset_for_non_ref_pic=" << m_offset_for_non_ref_pic <<
" "
527 "offset_for_top_to_bottom_field=" << m_offset_for_top_to_bottom_field <<
" "
528 "num_ref_frames_in_pic_order_cnt_cycle=" << m_num_ref_frames_in_pic_order_cnt_cycle <<
" "
529 "max_num_ref_frames=" << m_max_num_ref_frames <<
" "
530 "gaps_in_frame_num_value_allowed_flag=" << m_gaps_in_frame_num_value_allowed_flag <<
" "
531 "pic_width_in_mbs_minus1=" << m_pic_width_in_mbs_minus1 <<
" "
532 "pic_height_in_map_units_minus1=" << m_pic_height_in_map_units_minus1 <<
" "
533 "frame_mbs_only_flag=" << m_frame_mbs_only_flag <<
" "
534 "mb_adaptive_frame_field_flag=" << m_mb_adaptive_frame_field_flag <<
" "
535 "direct_8x8_inference_flag=" << m_direct_8x8_inference_flag <<
" "
536 "frame_cropping_flag=" << m_frame_cropping_flag <<
" "
537 "frame_crop_left_offset=" << m_frame_crop_left_offset <<
" "
538 "frame_crop_right_offset=" << m_frame_crop_right_offset <<
" "
539 "frame_crop_top_offset=" << m_frame_crop_top_offset <<
" "
540 "frame_crop_bottom_offset=" << m_frame_crop_bottom_offset <<
" "
541 "vui_parameters_present_flag=" << m_vui_parameters_present_flag <<
" "
556 m_nalu_type = stream.
get_byte() & 0x1f ;
559 m_entropy_coding_mode_flag = stream.
get_bool() ;
560 m_bottom_field_pic_order_in_frame_present_flag = stream.
get_bool() ;
562 if( m_num_slice_groups_minus1 > 0U )
565 report(
"slice group parsing not yet implemented" ) ;
569 m_weighted_pred_flag = stream.
get_bool() ;
570 m_weighted_bipred_idc = stream.
get(2) ;
574 m_deblocking_filter_control_present_flag = stream.
get_bool() ;
575 m_constrained_intra_pred_flag = stream.
get_bool() ;
576 m_redundant_pic_cnt_present_flag = stream.
get_bool() ;
578 m_transform_8x8_mode_flag = false ;
579 m_pic_scaling_matrix_present_flag = false ;
580 m_second_chroma_qp_index_offset = 0 ;
581 if( stream.
tellg() < rbsp_stop_bit_pos )
583 G_DEBUG(
"Gr::Avc: more_rbsp_data at " << stream.
tellg() ) ;
584 m_transform_8x8_mode_flag = stream.
get_bool() ;
585 m_pic_scaling_matrix_present_flag = stream.
get_bool() ;
586 if( m_pic_scaling_matrix_present_flag )
588 if( sps_chroma_format_idc < 0 ) report(
"invalid chroma format idc when parsing pps" ) ;
589 int n = 6+((sps_chroma_format_idc!=3)?2:6)*(m_transform_8x8_mode_flag?1:0) ;
590 G_DEBUG(
"Gr::Avc: pic_scaling_matrix_present: chroma_format_idc=" << sps_chroma_format_idc <<
" n=" << n ) ;
591 for(
int i = 0 ; i < n ; i++ )
596 G_DEBUG(
"Gr::Avc: pic_scaling_list_present but parsing not implemented" ) ;
597 report(
"pic_scaling_list_present_flag not yet implemented" ) ;
603 G_DEBUG(
"Gr::Avc: pps: tellg=" << stream.
tellg() <<
" stopbit=" << rbsp_stop_bit_pos ) ;
607 if( !stream.
good() ) report(
"premature end of pps data" ) ;
608 if( stream.
tellg() != rbsp_stop_bit_pos ) report(
"parsing did not finish at the stop bit" ) ;
609 if( m_nalu_type != 8U ) report(
"invalid nalu type" ) ;
612 void Gr::Avc::Pps::report(
const std::string & s )
614 m_reason.append( m_reason.empty() ?
"pps error: " :
": " ) ;
615 m_reason.append( s ) ;
620 return m_reason.empty() ;
631 "pic_parameter_set_id=" << m_pic_parameter_set_id <<
" "
632 "seq_parameter_set_id=" << m_seq_parameter_set_id <<
" "
633 "entropy_coding_mode_flag=" << m_entropy_coding_mode_flag <<
" "
634 "bottom_field_pic_order_in_frame_present_flag=" << m_bottom_field_pic_order_in_frame_present_flag <<
" "
635 "num_slice_groups_minus1=" << m_num_slice_groups_minus1 <<
" "
636 "num_ref_idx_10_default_active_minus1=" << m_num_ref_idx_10_default_active_minus1 <<
" "
637 "num_ref_idx_11_default_active_minus1=" << m_num_ref_idx_11_default_active_minus1 <<
" "
638 "weighted_pred_flag=" << m_weighted_pred_flag <<
" "
639 "weighted_bipred_idc=" << m_weighted_bipred_idc <<
" "
640 "pic_init_qp_minus26=" << m_pic_init_qp_minus26 <<
" "
641 "pic_init_qs_minus26=" << m_pic_init_qs_minus26 <<
" "
642 "chroma_qp_index_offset=" << m_chroma_qp_index_offset <<
" "
643 "deblocking_filter_control_present_flag=" << m_deblocking_filter_control_present_flag <<
" "
644 "constrained_intra_pred_flag=" << m_constrained_intra_pred_flag <<
" "
645 "redundant_pic_cnt_present_flag=" << m_redundant_pic_cnt_present_flag <<
" "
646 "transform_8x8_mode_flag=" << m_transform_8x8_mode_flag <<
" "
647 "pic_scaling_matrix_present_flag=" << m_pic_scaling_matrix_present_flag <<
" "
648 "second_chroma_qp_index_offset=" << m_second_chroma_qp_index_offset ;
653 std::ostream & Gr::Avc::operator<<( std::ostream & stream ,
const Pps & pps )
659 std::ostream & Gr::Avc::operator<<( std::ostream & stream ,
const Avc::Sps & sps )
669 size_t pos = s.find_last_not_of( std::string(1U,
'\0') ) ;
670 if( pos == std::string::npos )
673 unsigned int c =
static_cast<unsigned char>(s.at(pos)) ;
674 size_t result = (pos+1U) * 8U - 1U ;
675 for( ; !(c&1U) ; result-- ) c >>= 1 ;
681 static const std::string s(
"\x00\x00\x00" , 3U ) ;
687 static const std::string s(
"\x00\x00\x01" , 3U ) ;
693 static const std::string s(
"\x00\x00\x02" , 3U ) ;
699 static const std::string s(
"\x00\x00\x00\x01" , 4U ) ;
705 std::string result( s ) ;
706 G::Str::replaceAll( result , std::string(
"\x00\x00\x03",3U) , std::string(
"\x00\x00",2U) ) ;
712 static const std::string _00(
"\0\0" , 2U ) ;
716 pos = s.find( _00 , pos ) ;
717 if( pos == std::string::npos || (pos+2U) >= s.length() )
719 char c = s.at(pos+2U) ;
720 if( c ==
'\x00' || c ==
'\x01' || c ==
'\x02' || c ==
'\x03' )
722 s.insert( pos+2U , 1U ,
'\x03' ) ;
730 std::string result( s ) ;
731 addByteStuffing( result ) ;
738 s.find(_000()) != std::string::npos ||
739 s.find(_001()) != std::string::npos ||
740 s.find(_002()) != std::string::npos ;
const std::vector< std::string > & spsList() const
Returns a list of binary strings for the sps structures.
Sps(const std::string &binary_sps_buffer)
Constructor taking a binary byte-stuffed sps buffer.
static Configuration fromAvcc(const std::string &binary_string)
Factory function taking an "avcC" binary string, including RBSP byte-stuffing (but no start code) – s...
g_uint16_t get_word()
Gets a word. Sets the fail state on underflow.
void streamOut(std::ostream &) const
Streams out the sps info.
size_t spsCount() const
Returns sps().size().
bool good() const
Returns !fail().
static const std::string & _002()
Returns the 00-00-02 string.
Contains AVC configuration parameters, initialised from an "avcC" file segment or from an SDP "fmtp" ...
size_t ppsCount() const
Returns pps().size().
std::vector< std::string > StringArray
A std::vector of std::strings.
Pps(const std::string &binary_pps_buffer, int sps_chroma_format_idc)
Constructor taking a binary byte-stuffed pps buffer.
static void splitIntoTokens(const std::string &in, StringArray &out, const std::string &ws)
Splits the string into 'ws'-delimited tokens.
void streamOut(std::ostream &) const
Streams out the pps info.
unsigned int get_unsigned_golomb()
Gets an exp-golomb encoded unsigned value. Sets the fail state on underflow.
bool valid() const
Returns true if a usable object.
unsigned int dx() const
Returns the picture width in pixels.
static std::string tail(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the last part of the string after the given position.
A Picture Sequence Parameter Set (PPS) structure.
A Sequence Parameter Set (SPS) structure.
unsigned char get_byte()
Gets a byte. Sets the fail state on underflow.
unsigned char get(int bits)
Gets a number of bits, returned in a byte.
int get_signed_golomb()
Gets an exp-golomb encoded signed value. Sets the fail state on underflow.
static unsigned int toUInt(const std::string &s)
Converts string 's' to an unsigned int.
static std::string fromUInt(unsigned int ui)
Converts unsigned int 'ui' to a string.
static unsigned int replaceAll(std::string &s, const std::string &from, const std::string &to)
Does a global replace on string 's', replacing all occurances of sub-string 'from' with 'to'...
static std::string head(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the first part of the string up to just before the given position.
static const std::string & _001()
Returns the 00-00-01 string.
A class for pulling integer values of various widths out of a bit stream.
static Configuration fromFmtp(const std::string &fmtp)
Factory function taking a SDP (Session Description Protocol) "fmtp" attribute string, something like "profile-level-id=...; ...; sprop-parameters-sets=Z00AKZpmA8==,aO48gA==".
std::string reason() const
Returns the in-valid() reason.
A bit-by-bit input iterator that extracts bits in msb-to-lsb order from a sequence of bytes...
static std::string removeByteStuffing(const std::string &s)
Removes byte stuffing from a byte-stuffed RBSP buffer.
size_t tellg() const
Returns the current bit offset.
unsigned int dy() const
Returns the picture height in pixels.
bool valid() const
Returns true if a usable object.
bool valid() const
Returns true if a usable object.
static std::string byteStuffed(const std::string &s)
Returns a byte-stuffed version of the given unstuffed RBSP buffer.
const Pps & pps(size_t i) const
Returns a reference to the i-th pps structure.
bool get_bool()
Extracts a boolean. Sets the fail state on underflow.
static bool hasMarkers(const std::string &s)
Returns true if the string contains one of the inter-RBSP markers (000, 001, 002).
g_uint32_t get_dword()
Gets a dword. Sets the fail state on underflow.
static std::string decode(const std::string &)
Decodes the given string.
std::string reason() const
Returns the in-valid() reason.
static void addByteStuffing(std::string &s)
Adds byte-stuffing to the given unstuffed RBSP buffer.
const Sps & sps(size_t i) const
Returns a reference to the i-th sps structure.
const std::vector< std::string > & ppsList() const
Returns a list of binary strings for the pps structures.
static size_t findStopBit(const std::string &s, size_t fail=0U)
Returns the bit offset of the RBSP stop bit.
std::string reason() const
Returns the in-valid() reason.
std::string nalus() const
Returns the NALU byte-stream comprising the four-byte 00-00-00-01 start-code followed by the byte-stu...
static const std::string & _000()
Returns the 00-00-00 string.
unsigned int nalu_length_size() const
Returns the size of the nalu length values, typically 2.
static void splitIntoFields(const std::string &in, StringArray &out, const std::string &seperators, char escape= '\0', bool remove_escapes=true)
Splits the string into fields.
static const std::string & _0001()
Returns the 00-00-00-01 string.
Configuration()
A default constructor for an in-valid() object.