modules/rtp_rtcp/source/h264_bitstream_parser.cc
rtc::ByteBuffer* ParseRbsp(const uint8_t* bytes, size_t length) {
  // Copied from webrtc::H264SpsParser::Parse.
  rtc::ByteBuffer* rbsp_buffer = new rtc::ByteBuffer;
  for (size_t i = 0; i < length;) {
    if (length - i >= 3 && bytes[i] == 0 && bytes[i + 1] == 0 &&
        bytes[i + 2] == 3) {
      rbsp_buffer->WriteBytes(reinterpret_cast<const char*>(bytes) + i, 2);
      i += 3;
    } else {
      rbsp_buffer->WriteBytes(reinterpret_cast<const char*>(bytes) + i, 1);
      i++;
    }
  }
  return rbsp_buffer;
}
// Parses RBSP from source bytes. Removes emulation bytes, but leaves the
// rbsp_trailing_bits() in the stream, since none of the parsing reads all the
// way to the end of a parsed RBSP sequence. When writing, that means the
// rbsp_trailing_bits() should be preserved and don't need to be restored (i.e.
// the rbsp_stop_one_bit, which is just a 1, then zero padded), and alignment
// should "just work".
// TODO(pbos): Make parsing RBSP something that can be integrated into BitBuffer
// so we don't have to copy the entire frames when only interested in the
// headers.
Parses RBSP from source bytes. Removes emulation bytes, but leaves the
rbsp_trailing_bits() in the stream, since none of the parsing reads all the
way to the end of a parsed RBSP sequence. When writing, that means the
rbsp_trailing_bits() should be preserved and don't need to be restored , and alignment
should "just work".
TODO(pbos): Make parsing RBSP something that can be integrated into BitBuffer
so we don't have to copy the entire frames when only interested in the
headers.
Parses RBSP from source bytes . Removes emulation bytes but leaves the rbsp_trailing_bits () in the stream since none of the parsing reads all the way to the end of a parsed RBSP sequence . When writing that means the rbsp_trailing_bits () should be preserved and don ' t need to be restored and alignment should " just work " . TODO ( pbos ) : Make parsing RBSP something that can be integrated into BitBuffer so we don ' t have to copy the entire frames when only interested in the headers .
rtc::ByteBuffer* ParseRbsp(const uint8_t* bytes, size_t length) {
  rtc::ByteBuffer* rbsp_buffer = new rtc::ByteBuffer;
  for (size_t i = 0; i < length;) {
    if (length - i >= 3 && bytes[i] == 0 && bytes[i + 1] == 0 &&
        bytes[i + 2] == 3) {
      rbsp_buffer->WriteBytes(reinterpret_cast<const char*>(bytes) + i, 2);
      i += 3;
    } else {
      rbsp_buffer->WriteBytes(reinterpret_cast<const char*>(bytes) + i, 1);
      i++;
    }
  }
  return rbsp_buffer;
}
rtc :: ByteBuffer * ParseRbsp ( const uint8_t * bytes , size_t length ) { rtc :: ByteBuffer * rbsp_buffer = new rtc :: ByteBuffer ; for ( size_t i = 0 ; i < length ; ) { if ( length - i >= 3 && bytes [ i ] == 0 && bytes [ i + 1 ] == 0 && bytes [ i + 2 ] == 3 ) { rbsp_buffer -> WriteBytes ( reinterpret_cast < const char * > ( bytes ) + i , 2 ) ; i += 3 ; } else { rbsp_buffer -> WriteBytes ( reinterpret_cast < const char * > ( bytes ) + i , 1 ) ; i ++ ; } } return rbsp_buffer ; }
Parses RBSP from source bytes.
Parses RBSP from source bytes .
// Copied from webrtc::H264SpsParser::Parse.