mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
enhanced avc decode, parse the sps get width+height. 2.0.156.
This commit is contained in:
parent
7e1749e029
commit
70c59da1bf
9 changed files with 351 additions and 8 deletions
|
@ -46,6 +46,53 @@ using namespace std;
|
|||
// @see SRS_SYS_TIME_RESOLUTION_MS_TIMES
|
||||
#define SYS_TIME_RESOLUTION_US 300*1000
|
||||
|
||||
int srs_avc_nalu_read_uev(SrsBitStream* stream, int64_t& v)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (stream->empty()) {
|
||||
return ERROR_AVC_NALU_UEV;
|
||||
}
|
||||
|
||||
// ue(v) in 9.1 Parsing process for Exp-Golomb codes
|
||||
// H.264-AVC-ISO_IEC_14496-10-2012.pdf, page 227.
|
||||
// Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded.
|
||||
// leadingZeroBits = -1;
|
||||
// for( b = 0; !b; leadingZeroBits++ )
|
||||
// b = read_bits( 1 )
|
||||
// The variable codeNum is then assigned as follows:
|
||||
// codeNum = (2<<leadingZeroBits) – 1 + read_bits( leadingZeroBits )
|
||||
int leadingZeroBits = -1;
|
||||
for (int8_t b = 0; !b && !stream->empty(); leadingZeroBits++) {
|
||||
b = stream->read_bit();
|
||||
}
|
||||
|
||||
if (leadingZeroBits >= 64) {
|
||||
return ERROR_AVC_NALU_UEV;
|
||||
}
|
||||
|
||||
v = (1 << leadingZeroBits) - 1;
|
||||
for (int i = 0; i < leadingZeroBits; i++) {
|
||||
int64_t b = stream->read_bit();
|
||||
v += b << (leadingZeroBits - 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int srs_avc_nalu_read_bit(SrsBitStream* stream, int8_t& v)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if (stream->empty()) {
|
||||
return ERROR_AVC_NALU_UEV;
|
||||
}
|
||||
|
||||
v = stream->read_bit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int64_t _srs_system_time_us_cache = 0;
|
||||
static int64_t _srs_system_time_startup_time = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue