Skip to content

Commit def7d4f

Browse files
H265: Refine reference page num.
1 parent 7a7f6d8 commit def7d4f

File tree

3 files changed

+58
-44
lines changed

3 files changed

+58
-44
lines changed

trunk/src/app/srs_app_statistic.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ struct SrsStatisticStream
7171
// The level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
7272
SrsAvcLevel avc_level;
7373
#ifdef SRS_H265
74-
// The profile_idc, ITU-T-H.265-2021.pdf, page 559.
74+
// The profile_idc, ITU-T-H.265-2021.pdf, page 62.
7575
SrsHevcProfile hevc_profile;
76-
// The level_idc, ITU-T-H.265-2021.pdf, page 684.
76+
// The level_idc, ITU-T-H.265-2021.pdf, page 63.
7777
SrsHevcLevel hevc_level;
7878
#endif
7979
// The width and height in codec info.

trunk/src/kernel/srs_kernel_codec.cpp

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ srs_error_t SrsFormat::hevc_demux_vps(SrsBuffer *stream)
10991099
}
11001100

11011101
// nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.
1102-
// @see 7.4.2 NAL unit semantics
1103-
// @doc ITU-T-H.265-2021.pdf, page 64.
1102+
// @see 7.4.2.2 NAL unit header semantics
1103+
// @doc ITU-T-H.265-2021.pdf, page 86.
11041104
SrsHevcNaluType nal_unit_type = (SrsHevcNaluType)((nutv >> 1) & 0x3f);
11051105
if (nal_unit_type != SrsHevcNaluType_VPS) {
11061106
return srs_error_new(ERROR_HEVC_DECODE_ERROR, "hevc vps nal_unit_type=%d shall be equal to 33", nal_unit_type);
@@ -1143,8 +1143,8 @@ srs_error_t SrsFormat::hevc_demux_vps_rbsp(char* rbsp, int nb_rbsp)
11431143
SrsBuffer stream(rbsp, nb_rbsp);
11441144

11451145
// H265 VPS (video_parameter_set_rbsp()) NAL Unit.
1146-
// Section 7.3.2.1 ("Video parameter set data syntax") of the H.265
1147-
// ITU-T-H.265-2021.pdf, page 53.
1146+
// Section 7.3.2.1 ("Video parameter set RBSP syntax") of the H.265
1147+
// ITU-T-H.265-2021.pdf, page 54.
11481148
if (!stream.require(4)) {
11491149
return srs_error_new(ERROR_HEVC_DECODE_ERROR, "vps requires 4 only %d bytes", stream.left());
11501150
}
@@ -1328,8 +1328,8 @@ srs_error_t SrsFormat::hevc_demux_sps(SrsBuffer *stream)
13281328
}
13291329

13301330
// nal_unit_type specifies the type of RBSP data structure contained in the NAL unit as specified in Table 7-1.
1331-
// @see 7.4.2 NAL unit semantics
1332-
// @doc ITU-T-H.265-2021.pdf, page 64.
1331+
// @see 7.4.2.2 NAL unit header semantics
1332+
// @doc ITU-T-H.265-2021.pdf, page 86.
13331333
SrsHevcNaluType nal_unit_type = (SrsHevcNaluType)((nutv >> 1) & 0x3f);
13341334
if (nal_unit_type != SrsHevcNaluType_SPS) {
13351335
return srs_error_new(ERROR_HEVC_DECODE_ERROR, "hevc sps nal_unit_type=%d shall be equal to 33", nal_unit_type);
@@ -1378,7 +1378,7 @@ srs_error_t SrsFormat::hevc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
13781378
SrsBuffer stream(rbsp, nb_rbsp);
13791379

13801380
// H265 SPS Nal Unit (seq_parameter_set_rbsp()) parser.
1381-
// Section 7.3.2.2 ("Sequence parameter set data syntax") of the H.265
1381+
// Section 7.3.2.2 ("Sequence parameter set RBSP syntax") of the H.265
13821382
// ITU-T-H.265-2021.pdf, page 55.
13831383
if (!stream.require(2)) {
13841384
return srs_error_new(ERROR_HEVC_DECODE_ERROR, "sps requires 2 only %d bytes", stream.left());
@@ -1516,7 +1516,7 @@ srs_error_t SrsFormat::hevc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
15161516
srs_error_t SrsFormat::hevc_demux_pps(SrsBuffer *stream)
15171517
{
15181518
// for NALU, ITU-T H.265 7.3.2.3 Picture parameter set RBSP syntax
1519-
// @see 7.3.2.3.1 General picture parameter set RBSP syntax
1519+
// @see 7.3.2.3 Picture parameter set RBSP syntax
15201520
// @doc ITU-T-H.265-2021.pdf, page 57.
15211521
if (!stream->require(1)) {
15221522
return srs_error_new(ERROR_HEVC_DECODE_ERROR, "decode hevc pps requires 1 only %d bytes", stream->left());
@@ -1574,7 +1574,7 @@ srs_error_t SrsFormat::hevc_demux_pps_rbsp(char* rbsp, int nb_rbsp)
15741574
SrsBuffer stream(rbsp, nb_rbsp);
15751575

15761576
// H265 PPS NAL Unit (pic_parameter_set_rbsp()) parser.
1577-
// Section 7.3.2.3 ("Parameter parameter set data syntax") of the H.265
1577+
// Section 7.3.2.3 ("Picture parameter set RBSP syntax") of the H.265
15781578
// ITU-T-H.265-2021.pdf, page 57.
15791579
SrsBitBuffer bs(&stream);
15801580

@@ -1922,7 +1922,11 @@ srs_error_t SrsFormat::hevc_demux_rbsp_ptl(SrsBitBuffer* bs, SrsHevcProfileTierL
19221922
if (ptl->general_profile_idc == 4 || ptl->general_profile_compatibility_flag[4] ||
19231923
ptl->general_profile_idc == 5 || ptl->general_profile_compatibility_flag[5] ||
19241924
ptl->general_profile_idc == 6 || ptl->general_profile_compatibility_flag[6] ||
1925-
ptl->general_profile_idc == 7 || ptl->general_profile_compatibility_flag[7])
1925+
ptl->general_profile_idc == 7 || ptl->general_profile_compatibility_flag[7] ||
1926+
ptl->general_profile_idc == 8 || ptl->general_profile_compatibility_flag[8] ||
1927+
ptl->general_profile_idc == 9 || ptl->general_profile_compatibility_flag[9] ||
1928+
ptl->general_profile_idc == 10 || ptl->general_profile_compatibility_flag[10] ||
1929+
ptl->general_profile_idc == 11 || ptl->general_profile_compatibility_flag[11])
19261930
{
19271931
// The number of bits in this syntax structure is not affected by
19281932
// this condition
@@ -1945,12 +1949,10 @@ srs_error_t SrsFormat::hevc_demux_rbsp_ptl(SrsBitBuffer* bs, SrsHevcProfileTierL
19451949
// lower_bit_rate_constraint_flag u(1)
19461950
ptl->general_lower_bit_rate_constraint_flag = bs->read_bit();
19471951

1948-
if (ptl->general_profile_idc == 5 ||
1949-
ptl->general_profile_compatibility_flag[5] == 1 ||
1950-
ptl->general_profile_idc == 9 ||
1951-
ptl->general_profile_compatibility_flag[9] == 1 ||
1952-
ptl->general_profile_idc == 10 ||
1953-
ptl->general_profile_compatibility_flag[10] == 1)
1952+
if (ptl->general_profile_idc == 5 || ptl->general_profile_compatibility_flag[5] == 1 ||
1953+
ptl->general_profile_idc == 9 || ptl->general_profile_compatibility_flag[9] == 1 ||
1954+
ptl->general_profile_idc == 10 || ptl->general_profile_compatibility_flag[10] == 1 ||
1955+
ptl->general_profile_idc == 11 || ptl->general_profile_compatibility_flag[11] == 1)
19541956
{
19551957
// max_14bit_constraint_flag u(1)
19561958
ptl->general_max_14bit_constraint_flag = bs->read_bit();
@@ -1971,13 +1973,14 @@ srs_error_t SrsFormat::hevc_demux_rbsp_ptl(SrsBitBuffer* bs, SrsHevcProfileTierL
19711973
ptl->general_reserved_zero_43bits = ((uint64_t)bits_tmp_hi << 32) | bits_tmp;
19721974
}
19731975

1974-
// The number of bits in this syntax structure is not affected by
1975-
// this condition
1976-
if ((ptl->general_profile_idc >= 1 && ptl->general_profile_idc<=5) ||
1977-
ptl->general_profile_compatibility_flag[1] || ptl->general_profile_compatibility_flag[2] ||
1978-
ptl->general_profile_compatibility_flag[3] || ptl->general_profile_compatibility_flag[4] ||
1979-
ptl->general_profile_compatibility_flag[5])
1980-
{
1976+
// The number of bits in this syntax structure is not affected by this condition
1977+
if (ptl->general_profile_idc == 1 || ptl->general_profile_compatibility_flag[1] ||
1978+
ptl->general_profile_idc == 2 || ptl->general_profile_compatibility_flag[2] ||
1979+
ptl->general_profile_idc == 3 || ptl->general_profile_compatibility_flag[3] ||
1980+
ptl->general_profile_idc == 4 || ptl->general_profile_compatibility_flag[4] ||
1981+
ptl->general_profile_idc == 5 || ptl->general_profile_compatibility_flag[5] ||
1982+
ptl->general_profile_idc == 9 || ptl->general_profile_compatibility_flag[9] ||
1983+
ptl->general_profile_idc == 11 || ptl->general_profile_compatibility_flag[11]) {
19811984
// inbld_flag u(1)
19821985
ptl->general_inbld_flag = bs->read_bit();
19831986
} else {
@@ -2064,7 +2067,11 @@ srs_error_t SrsFormat::hevc_demux_rbsp_ptl(SrsBitBuffer* bs, SrsHevcProfileTierL
20642067
if (ptl->sub_layer_profile_idc[i] == 4 || ptl->sub_layer_profile_compatibility_flag[i][4] ||
20652068
ptl->sub_layer_profile_idc[i] == 5 || ptl->sub_layer_profile_compatibility_flag[i][5] ||
20662069
ptl->sub_layer_profile_idc[i] == 6 || ptl->sub_layer_profile_compatibility_flag[i][6] ||
2067-
ptl->sub_layer_profile_idc[i] == 7 || ptl->sub_layer_profile_compatibility_flag[i][7])
2070+
ptl->sub_layer_profile_idc[i] == 7 || ptl->sub_layer_profile_compatibility_flag[i][7] ||
2071+
ptl->sub_layer_profile_idc[i] == 8 || ptl->sub_layer_profile_compatibility_flag[i][8] ||
2072+
ptl->sub_layer_profile_idc[i] == 9 || ptl->sub_layer_profile_compatibility_flag[i][9] ||
2073+
ptl->sub_layer_profile_idc[i] == 10 || ptl->sub_layer_profile_compatibility_flag[i][10] ||
2074+
ptl->sub_layer_profile_idc[i] == 11|| ptl->sub_layer_profile_compatibility_flag[i][11])
20682075
{
20692076
// max_12bit_constraint_flag u(1)
20702077
ptl->sub_layer_max_12bit_constraint_flag[i] = bs->read_bit();
@@ -2085,12 +2092,12 @@ srs_error_t SrsFormat::hevc_demux_rbsp_ptl(SrsBitBuffer* bs, SrsHevcProfileTierL
20852092
// lower_bit_rate_constraint_flag u(1)
20862093
ptl->sub_layer_lower_bit_rate_constraint_flag[i] = bs->read_bit();
20872094

2088-
if (ptl->general_profile_idc == 5 ||
2089-
ptl->general_profile_compatibility_flag[5] == 1 ||
2090-
ptl->general_profile_idc == 9 ||
2091-
ptl->general_profile_compatibility_flag[9] == 1 ||
2092-
ptl->general_profile_idc == 10 ||
2093-
ptl->general_profile_compatibility_flag[10] == 1)
2095+
if (ptl->sub_layer_profile_idc[i] == 5 ||
2096+
ptl->sub_layer_profile_compatibility_flag[i][5] == 1 ||
2097+
ptl->sub_layer_profile_idc[i] == 9 ||
2098+
ptl->sub_layer_profile_compatibility_flag[i][9] == 1 ||
2099+
ptl->sub_layer_profile_idc[i] == 10 ||
2100+
ptl->sub_layer_profile_compatibility_flag[i][10] == 1)
20942101
{
20952102
// max_14bit_constraint_flag u(1)
20962103
ptl->general_max_14bit_constraint_flag = bs->read_bit();
@@ -2111,14 +2118,21 @@ srs_error_t SrsFormat::hevc_demux_rbsp_ptl(SrsBitBuffer* bs, SrsHevcProfileTierL
21112118
ptl->sub_layer_reserved_zero_43bits[i] = ((uint64_t)bits_tmp_hi << 32) | bits_tmp;
21122119
}
21132120

2114-
// to check
2115-
if ((ptl->sub_layer_profile_idc[i] >= 1 && ptl->sub_layer_profile_idc[i] <= 5) ||
2121+
// The number of bits in this syntax structure is not affected by this condition
2122+
if (ptl->sub_layer_profile_idc[i] == 1 ||
21162123
ptl->sub_layer_profile_compatibility_flag[i][1] ||
2124+
ptl->sub_layer_profile_idc[i] == 2 ||
21172125
ptl->sub_layer_profile_compatibility_flag[i][2] ||
2126+
ptl->sub_layer_profile_idc[i] == 3 ||
21182127
ptl->sub_layer_profile_compatibility_flag[i][3] ||
2128+
ptl->sub_layer_profile_idc[i] == 4 ||
21192129
ptl->sub_layer_profile_compatibility_flag[i][4] ||
2120-
ptl->sub_layer_profile_compatibility_flag[i][5])
2121-
{
2130+
ptl->sub_layer_profile_idc[i] == 5 ||
2131+
ptl->sub_layer_profile_compatibility_flag[i][5] ||
2132+
ptl->sub_layer_profile_idc[i] == 9 ||
2133+
ptl->sub_layer_profile_compatibility_flag[i][9] ||
2134+
ptl->sub_layer_profile_idc[i] == 11 ||
2135+
ptl->sub_layer_profile_compatibility_flag[i][11]) {
21222136
// inbld_flag u(1)
21232137
ptl->sub_layer_inbld_flag[i] = bs->read_bit();
21242138
} else {

trunk/src/kernel/srs_kernel_codec.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,6 @@ struct SrsHevcRbspVps
752752
/**
753753
* Sequence Parameter Set
754754
* @see 7.3.2.2 Sequence parameter set RBSP syntax
755-
* 7.3.2.2.1 General sequence parameter set RBSP syntax
756755
* @doc ITU-T-H.265-2021.pdf, page 55.
757756
*/
758757
struct SrsHevcRbspSps
@@ -823,7 +822,6 @@ struct SrsHevcRbspSps
823822
/**
824823
* Picture Parameter Set
825824
* @see 7.3.2.3 Picture parameter set RBSP syntax
826-
* 7.3.2.3.1 General picture parameter set RBSP syntax
827825
* @doc ITU-T-H.265-2021.pdf, page 57.
828826
*/
829827
struct SrsHevcRbspPps
@@ -1034,8 +1032,9 @@ std::string srs_avc_level2str(SrsAvcLevel level);
10341032
#ifdef SRS_H265
10351033

10361034
/**
1037-
* the profile for hevc/h.265.
1038-
* @see Annex A Profiles and levels, ITU-T-H.265-2021.pdf, page 559.
1035+
* the profile for hevc/h.265, Annex A Profiles, tiers and levels
1036+
* @see A.3 Profiles
1037+
* @doc ITU-T-H.265-2021.pdf, page 268.
10391038
*/
10401039
enum SrsHevcProfile
10411040
{
@@ -1050,8 +1049,9 @@ enum SrsHevcProfile
10501049
std::string srs_hevc_profile2str(SrsHevcProfile profile);
10511050

10521051
/**
1053-
* the level for hevc/h.265.
1054-
* @see Annex A Profiles and levels, ITU-T-H.265-2021.pdf, page 684.
1052+
* the level for hevc/h.265, Annex A Profiles, tiers and levels
1053+
* @see A.4 Tiers and levels
1054+
* @doc ITU-T-H.265-2021.pdf, page 283.
10551055
*/
10561056
enum SrsHevcLevel
10571057
{
@@ -1190,9 +1190,9 @@ class SrsVideoCodecConfig : public SrsCodecConfig
11901190
// level_idc, ISO_IEC_14496-10-AVC-2003.pdf, page 45.
11911191
SrsAvcLevel avc_level;
11921192
#ifdef SRS_H265
1193-
// The profile_idc, ITU-T-H.265-2021.pdf, page 559.
1193+
// The profile_idc, ITU-T-H.265-2021.pdf, page 62.
11941194
SrsHevcProfile hevc_profile;
1195-
// The level_idc, ITU-T-H.265-2021.pdf, page 684.
1195+
// The level_idc, ITU-T-H.265-2021.pdf, page 63.
11961196
SrsHevcLevel hevc_level;
11971197
#endif
11981198
// lengthSizeMinusOne, ISO_IEC_14496-15-AVC-format-2012.pdf, page 16

0 commit comments

Comments
 (0)