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

Kernel: Fix demux SPS error for NVENC and LARIX. v6.0.22 #3389

Merged
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-02-08, Merge [#3389](https://github.com/ossrs/srs/pull/3389): Kernel: Fix demux SPS error for NVENC and LARIX. v6.0.22 (#3389)
* v6.0, 2023-01-29, Merge [#3371](https://github.com/ossrs/srs/pull/3371): HLS: support kick-off hls client. v6.0.21 (#3371)
* v6.0, 2023-01-19, Merge [#3366](https://github.com/ossrs/srs/pull/3366): H265: Support HEVC over SRT. v6.0.20 (#465) (#3366)
* v6.0, 2023-01-19, Merge [#3318](https://github.com/ossrs/srs/pull/3318): RTC: fix rtc publisher pli cid. v6.0.19 (#3318)
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_srt_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ srs_error_t SrsRtmpFromSrtBridge::check_vps_sps_pps_change(SrsTsMessage* msg)
}

if ((err = live_source_->on_video(&rtmp)) != srs_success) {
return srs_error_wrap(err, "srt to rtmp sps/pps");
return srs_error_wrap(err, "srt to rtmp vps/sps/pps");
}

return err;
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 21
#define VERSION_REVISION 22

#endif
120 changes: 43 additions & 77 deletions trunk/src/kernel/srs_kernel_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ srs_error_t SrsFormat::video_avc_demux(SrsBuffer* stream, int64_t timestamp)
if (avc_packet_type == SrsVideoAvcFrameTraitSequenceHeader) {
// TODO: demux vps/sps/pps for hevc
if ((err = hevc_demux_hvcc(stream)) != srs_success) {
return srs_error_wrap(err, "demux hevc SPS/PPS");
return srs_error_wrap(err, "demux hevc VPS/SPS/PPS");
}
} else if (avc_packet_type == SrsVideoAvcFrameTraitNALU) {
// TODO: demux nalu for hevc
Expand Down Expand Up @@ -928,6 +928,42 @@ srs_error_t SrsFormat::video_avc_demux(SrsBuffer* stream, int64_t timestamp)
// LCOV_EXCL_START

#ifdef SRS_H265
// struct ptl
SrsHevcProfileTierLevel::SrsHevcProfileTierLevel()
{
general_profile_space = 0;
general_tier_flag = 0;
general_profile_idc = 0;
memset(general_profile_compatibility_flag, 0, 32);
general_progressive_source_flag = 0;
general_interlaced_source_flag = 0;
general_non_packed_constraint_flag = 0;
general_frame_only_constraint_flag = 0;
general_max_12bit_constraint_flag = 0;
general_max_10bit_constraint_flag = 0;
general_max_8bit_constraint_flag = 0;
general_max_422chroma_constraint_flag = 0;
general_max_420chroma_constraint_flag = 0;
general_max_monochrome_constraint_flag = 0;
general_intra_constraint_flag = 0;
general_one_picture_only_constraint_flag = 0;
general_lower_bit_rate_constraint_flag = 0;
general_max_14bit_constraint_flag = 0;
general_reserved_zero_7bits = 0;
general_reserved_zero_33bits = 0;
general_reserved_zero_34bits = 0;
general_reserved_zero_35bits = 0;
general_reserved_zero_43bits = 0;
general_inbld_flag = 0;
general_reserved_zero_bit = 0;
general_level_idc = 0;
memset(reserved_zero_2bits, 0, 8);
}

SrsHevcProfileTierLevel::~SrsHevcProfileTierLevel()
{
}

// Parse the hevc vps/sps/pps
srs_error_t SrsFormat::hevc_demux_hvcc(SrsBuffer* stream)
{
Expand Down Expand Up @@ -1047,7 +1083,7 @@ srs_error_t SrsFormat::hevc_demux_hvcc(SrsBuffer* stream)

// demux nalu
if ((err = hevc_demux_vps_sps_pps(&hevc_unit)) != srs_success) {
return srs_error_wrap(err, "hevc demux vps sps pps failed");
return srs_error_wrap(err, "hevc demux vps/sps/pps failed");
}
}

Expand Down Expand Up @@ -1317,7 +1353,6 @@ srs_error_t SrsFormat::hevc_demux_sps_rbsp(char* rbsp, int nb_rbsp)

// profile tier level...
SrsHevcProfileTierLevel profile_tier_level;
memset((void*)&profile_tier_level, 0, sizeof(SrsHevcProfileTierLevel));
// profile_tier_level(1, sps_max_sub_layers_minus1)
if ((err = hevc_demux_rbsp_ptl(&bs, &profile_tier_level, 1, sps_max_sub_layers_minus1)) != srs_success) {
return srs_error_wrap(err, "sps rbsp ptl sps_max_sub_layers_minus1=%d", sps_max_sub_layers_minus1);
Expand All @@ -1343,7 +1378,7 @@ srs_error_t SrsFormat::hevc_demux_sps_rbsp(char* rbsp, int nb_rbsp)
sps->sps_max_sub_layers_minus1 = sps_max_sub_layers_minus1;
sps->sps_temporal_id_nesting_flag = sps_temporal_id_nesting_flag;
sps->sps_seq_parameter_set_id = sps_seq_parameter_set_id;
memcpy(&(sps->ptl), &profile_tier_level, sizeof(SrsHevcProfileTierLevel));
sps->ptl = profile_tier_level;

// chroma_format_idc ue(v)
if ((err = bs.read_bits_ue(sps->chroma_format_idc)) != srs_success) {
Expand Down Expand Up @@ -1652,7 +1687,7 @@ srs_error_t SrsFormat::hevc_demux_pps_rbsp(char* rbsp, int nb_rbsp)
pps->deblocking_filter_override_enabled_flag = bs.read_bit();
// pps_deblocking_filter_disabled_flag u(1)
pps->pps_deblocking_filter_disabled_flag = bs.read_bit();
if (pps->pps_deblocking_filter_disabled_flag) {
if (!pps->pps_deblocking_filter_disabled_flag) {
// pps_beta_offset_div2 se(v)
if ((err = bs.read_bits_se(pps->pps_beta_offset_div2)) != srs_success) {
return srs_error_wrap(err, "pps_beta_offset_div2");
Expand Down Expand Up @@ -1744,78 +1779,9 @@ srs_error_t SrsFormat::hevc_demux_pps_rbsp(char* rbsp, int nb_rbsp)
pps->pps_extension_4bits = bs.read_bits(4);
}

if (pps->pps_range_extension_flag) {
if (pps->transform_skip_enabled_flag) {
chundonglinlin marked this conversation as resolved.
Show resolved Hide resolved
if ((err = bs.read_bits_ue(pps->pps_range_extension.log2_max_transform_skip_block_size_minus2)) != srs_success) {
return srs_error_wrap(err, "log2_max_transform_skip_block_size_minus2");
}
}

if (!bs.require_bits(2)) {
return srs_error_new(ERROR_HEVC_DECODE_ERROR, "cross_component_prediction_enabled_flag requires 2 only %d bits", bs.left_bits());
}

// cross_component_prediction_enabled_flag u(1)
pps->pps_range_extension.cross_component_prediction_enabled_flag = bs.read_bit();
// chroma_qp_offset_list_enabled_flag u(1)
pps->pps_range_extension.chroma_qp_offset_list_enabled_flag = bs.read_bit();
if (pps->pps_range_extension.chroma_qp_offset_list_enabled_flag) {
// diff_cu_chroma_qp_offset_depth ue(v)
if ((err = bs.read_bits_ue(pps->pps_range_extension.diff_cu_chroma_qp_offset_depth)) != srs_success) {
return srs_error_wrap(err, "diff_cu_chroma_qp_offset_depth");
}

// chroma_qp_offset_list_len_minus1 ue(v)
if ((err = bs.read_bits_ue(pps->pps_range_extension.chroma_qp_offset_list_len_minus1)) != srs_success) {
return srs_error_wrap(err, "chroma_qp_offset_list_len_minus1");
}

pps->pps_range_extension.cb_qp_offset_list.resize(pps->pps_range_extension.chroma_qp_offset_list_len_minus1);
pps->pps_range_extension.cr_qp_offset_list.resize(pps->pps_range_extension.chroma_qp_offset_list_len_minus1);

for (int i = 0; i < (int)pps->pps_range_extension.chroma_qp_offset_list_len_minus1; i++) {
// cb_qp_offset_list[i] se(v)
if ((err = bs.read_bits_se(pps->pps_range_extension.cb_qp_offset_list[i])) != srs_success) {
return srs_error_wrap(err, "cb_qp_offset_list");
}

// cr_qp_offset_list[i] se(v)
if ((err = bs.read_bits_se(pps->pps_range_extension.cr_qp_offset_list[i])) != srs_success) {
return srs_error_wrap(err, "cr_qp_offset_list");
}
}
}

// log2_sao_offset_scale_luma ue(v)
if ((err = bs.read_bits_ue(pps->pps_range_extension.log2_sao_offset_scale_luma)) != srs_success) {
return srs_error_wrap(err, "log2_sao_offset_scale_luma");
}

// log2_sao_offset_scale_chroma ue(v)
if ((err = bs.read_bits_ue(pps->pps_range_extension.log2_sao_offset_scale_chroma)) != srs_success) {
return srs_error_wrap(err, "log2_sao_offset_scale_chroma");
}
}

if (pps->pps_multilayer_extension_flag){
// pps_multilayer_extension, specified in Annex F
// TODO: FIXME: add support for pps_multilayer_extension()
}

if (pps->pps_3d_extension_flag) {
// pps_3d_extension, specified in Annex I
// TODO: FIXME: add support for pps_3d_extension()
}

if (pps->pps_scc_extension_flag) {
// pps_scc_extension_flag
// TODO: FIXME: add support for pps_scc_extension()
}

if (pps->pps_extension_4bits) {
// more_rbsp_data
// TODO: FIXME: add support for more_rbsp_data()
}
// TODO: FIXME: Implements it, you might parse remain bits for pic_parameter_set_rbsp.
// @see 7.3.2.3 Picture parameter set RBSP syntax
// @doc ITU-T-H.265-2021.pdf, page 59.

// TODO: FIXME: rbsp_trailing_bits

Expand Down
5 changes: 5 additions & 0 deletions trunk/src/kernel/srs_kernel_codec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ const int SrsHevcMax_PPS_COUNT = 64;
*/
struct SrsHevcProfileTierLevel
{
public:
uint8_t general_profile_space;
uint8_t general_tier_flag;
uint8_t general_profile_idc;
Expand Down Expand Up @@ -565,6 +566,10 @@ struct SrsHevcProfileTierLevel
std::vector<uint8_t> sub_layer_inbld_flag;
std::vector<uint8_t> sub_layer_reserved_zero_bit;
std::vector<uint8_t> sub_layer_level_idc;

public:
SrsHevcProfileTierLevel();
virtual ~SrsHevcProfileTierLevel();
};

/**
Expand Down