Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H265: Support demux vps/pps info. v6.0.15 #3379

Merged
merged 18 commits into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The changelog for SRS.

## SRS 6.0 Changelog

* v6.0, 2023-01-17, Merge [#3379](https://github.com/ossrs/srs/pull/3379): H265: Support demux vps/pps info. v6.0.15
* v6.0, 2023-01-08, Merge [#3360](https://github.com/ossrs/srs/pull/3360): H265: Support DVR HEVC stream to MP4. v6.0.14
* v6.0, 2023-01-06, Merge [#3363](https://github.com/ossrs/srs/issues/3363): HTTP: Add CORS Header for private network access. v6.0.13
* v6.0, 2023-01-04, Merge [#3362](https://github.com/ossrs/srs/issues/3362): SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_statistic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ struct SrsStatisticStream
// The level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
SrsAvcLevel avc_level;
#ifdef SRS_H265
// The profile_idc, T-REC-H.265-202108-I!!PDF-E.pdf, page 559.
// The profile_idc, ITU-T-H.265-2021.pdf, page 62.
SrsHevcProfile hevc_profile;
// The level_idc, T-REC-H.265-202108-I!!PDF-E.pdf, page 684.
// The level_idc, ITU-T-H.265-2021.pdf, page 63.
SrsHevcLevel hevc_level;
#endif
// The width and height in codec info.
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 6
#define VERSION_MINOR 0
#define VERSION_REVISION 14
#define VERSION_REVISION 15

#endif
65 changes: 57 additions & 8 deletions trunk/src/kernel/srs_kernel_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,17 +458,66 @@ int32_t SrsBitBuffer::read_32bits()
return read_bits(32);
}

int32_t SrsBitBuffer::read_bits_ue()
srs_error_t SrsBitBuffer::read_bits_ue(uint32_t& v)
{
int32_t r = 0;
int i = 0;
srs_error_t err = srs_success;

while((read_bit() == 0) && (i < 32) && (left_bits() > 0) ) {
i++;
if (empty()) {
return srs_error_new(ERROR_HEVC_NALU_UEV, "empty stream");
}

r = read_bits(i);
r += (1 << i) - 1;
// ue(v) in 9.2 Parsing process for Exp-Golomb codes
// ITU-T-H.265-2021.pdf, page 221.
// 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 && !empty(); leadingZeroBits++) {
b = read_bit();
}

if (leadingZeroBits >= 31) {
return srs_error_new(ERROR_HEVC_NALU_UEV, "%dbits overflow 31bits", leadingZeroBits);
}

v = (1 << leadingZeroBits) - 1;
for (int i = 0; i < (int)leadingZeroBits; i++) {
if (empty()) {
return srs_error_new(ERROR_HEVC_NALU_UEV, "no bytes for leadingZeroBits=%d", leadingZeroBits);
}

uint32_t b = read_bit();
v += b << (leadingZeroBits - 1 - i);
}

return err;
}

srs_error_t SrsBitBuffer::read_bits_se(int32_t& v)
{
srs_error_t err = srs_success;

if (empty()) {
return srs_error_new(ERROR_HEVC_NALU_SEV, "empty stream");
}

// ue(v) in 9.2.1 General Parsing process for Exp-Golomb codes
// ITU-T-H.265-2021.pdf, page 221.
uint32_t val = 0;
if ((err = read_bits_ue(val)) != srs_success) {
return srs_error_wrap(err, "read uev");
}

// se(v) in 9.2.2 Mapping process for signed Exp-Golomb codes
// ITU-T-H.265-2021.pdf, page 222.
if (val & 0x01) {
v = (val + 1) / 2;
} else {
v = -(val / 2);
}

return r;
return err;
}
3 changes: 2 additions & 1 deletion trunk/src/kernel/srs_kernel_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ class SrsBitBuffer
int8_t read_8bits();
int16_t read_16bits();
int32_t read_32bits();
int32_t read_bits_ue();
srs_error_t read_bits_ue(uint32_t& v);
srs_error_t read_bits_se(int32_t& v);
};

#endif
Loading