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 1 commit
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
Prev Previous commit
Next Next commit
Kernel: dumps SrsHevcProfileTierLevel.
  • Loading branch information
chundonglinlin committed Feb 1, 2023
commit fe4bac78bf6e7a7315cfa5db2a8186acf2479a09
128 changes: 127 additions & 1 deletion trunk/src/kernel/srs_kernel_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,132 @@ 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()
{
sub_layer_profile_present_flag.clear();
sub_layer_level_present_flag.clear();
sub_layer_profile_space.clear();
sub_layer_tier_flag.clear();
sub_layer_profile_idc.clear();
sub_layer_profile_compatibility_flag.clear();
Copy link
Member

@winlinvip winlinvip Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When released, these vectors don't need to be taken care of, right? They will be released automatically.

TRANS_BY_GPT3

sub_layer_progressive_source_flag.clear();
sub_layer_interlaced_source_flag.clear();
sub_layer_non_packed_constraint_flag.clear();
sub_layer_frame_only_constraint_flag.clear();
sub_layer_max_12bit_constraint_flag.clear();
sub_layer_max_10bit_constraint_flag.clear();
sub_layer_max_8bit_constraint_flag.clear();
sub_layer_max_422chroma_constraint_flag.clear();
sub_layer_max_420chroma_constraint_flag.clear();
sub_layer_max_monochrome_constraint_flag.clear();
sub_layer_intra_constraint_flag.clear();
sub_layer_one_picture_only_constraint_flag.clear();
sub_layer_lower_bit_rate_constraint_flag.clear();
sub_layer_reserved_zero_7bits.clear();
sub_layer_reserved_zero_33bits.clear();
sub_layer_reserved_zero_34bits.clear();
sub_layer_reserved_zero_35bits.clear();
sub_layer_reserved_zero_43bits.clear();
sub_layer_inbld_flag.clear();
sub_layer_reserved_zero_bit.clear();
sub_layer_level_idc.clear();
}

srs_error_t SrsHevcProfileTierLevel::dumps(SrsHevcProfileTierLevel* ptl)
Copy link
Member

@winlinvip winlinvip Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just do a direct value copy?

*this = *ptl

Or maybe we don't need to use dumps, just do a direct assignment.

sps->ptl.dumps(&profile_tier_level);

Change it to...

sps->ptl = profile_tier_level;

TRANS_BY_GPT3

{
srs_error_t err = srs_success;

general_profile_space = ptl->general_profile_space;
general_tier_flag = ptl->general_tier_flag;
general_profile_idc = ptl->general_profile_idc;
memcpy(general_profile_compatibility_flag, ptl->general_profile_compatibility_flag, 32);
general_progressive_source_flag = ptl->general_progressive_source_flag;
general_interlaced_source_flag = ptl->general_interlaced_source_flag;
general_non_packed_constraint_flag = ptl->general_non_packed_constraint_flag;
general_frame_only_constraint_flag = ptl->general_frame_only_constraint_flag;
general_max_12bit_constraint_flag = ptl->general_max_12bit_constraint_flag;
general_max_10bit_constraint_flag = ptl->general_max_10bit_constraint_flag;
general_max_8bit_constraint_flag = ptl->general_max_8bit_constraint_flag;
general_max_422chroma_constraint_flag = ptl->general_max_422chroma_constraint_flag;
general_max_420chroma_constraint_flag = ptl->general_max_420chroma_constraint_flag;
general_max_monochrome_constraint_flag = ptl->general_max_monochrome_constraint_flag;
general_intra_constraint_flag = ptl->general_intra_constraint_flag;
general_one_picture_only_constraint_flag = ptl->general_one_picture_only_constraint_flag;
general_lower_bit_rate_constraint_flag = ptl->general_lower_bit_rate_constraint_flag;
general_max_14bit_constraint_flag = ptl->general_max_14bit_constraint_flag;
general_reserved_zero_7bits = ptl->general_reserved_zero_7bits;
general_reserved_zero_33bits = ptl->general_reserved_zero_33bits;
general_reserved_zero_34bits = ptl->general_reserved_zero_34bits;
general_reserved_zero_35bits = ptl->general_reserved_zero_35bits;
general_reserved_zero_43bits = ptl->general_reserved_zero_43bits;
general_inbld_flag = ptl->general_inbld_flag;
general_reserved_zero_bit = ptl->general_reserved_zero_bit;
general_level_idc = ptl->general_level_idc;
memcpy(reserved_zero_2bits, ptl->reserved_zero_2bits, 8);

sub_layer_profile_present_flag.swap(ptl->sub_layer_profile_present_flag);
sub_layer_level_present_flag.swap(ptl->sub_layer_level_present_flag);
sub_layer_profile_space.swap(ptl->sub_layer_profile_space);
sub_layer_tier_flag.swap(ptl->sub_layer_tier_flag);
sub_layer_profile_idc.swap(ptl->sub_layer_profile_idc);
sub_layer_profile_compatibility_flag.swap(ptl->sub_layer_profile_compatibility_flag);
sub_layer_progressive_source_flag.swap(ptl->sub_layer_progressive_source_flag);
sub_layer_interlaced_source_flag.swap(ptl->sub_layer_interlaced_source_flag);
sub_layer_non_packed_constraint_flag.swap(ptl->sub_layer_non_packed_constraint_flag);
sub_layer_frame_only_constraint_flag.swap(ptl->sub_layer_frame_only_constraint_flag);
sub_layer_max_12bit_constraint_flag.swap(ptl->sub_layer_max_12bit_constraint_flag);
sub_layer_max_10bit_constraint_flag.swap(ptl->sub_layer_max_10bit_constraint_flag);
sub_layer_max_8bit_constraint_flag.swap(ptl->sub_layer_max_8bit_constraint_flag);
sub_layer_max_422chroma_constraint_flag.swap(ptl->sub_layer_max_422chroma_constraint_flag);
sub_layer_max_420chroma_constraint_flag.swap(ptl->sub_layer_max_420chroma_constraint_flag);
sub_layer_max_monochrome_constraint_flag.swap(ptl->sub_layer_max_monochrome_constraint_flag);
sub_layer_intra_constraint_flag.swap(ptl->sub_layer_intra_constraint_flag);
sub_layer_one_picture_only_constraint_flag.swap(ptl->sub_layer_one_picture_only_constraint_flag);
sub_layer_lower_bit_rate_constraint_flag.swap(ptl->sub_layer_lower_bit_rate_constraint_flag);
sub_layer_reserved_zero_7bits.swap(ptl->sub_layer_reserved_zero_7bits);
sub_layer_reserved_zero_33bits.swap(ptl->sub_layer_reserved_zero_33bits);
sub_layer_reserved_zero_34bits.swap(ptl->sub_layer_reserved_zero_34bits);
sub_layer_reserved_zero_35bits.swap(ptl->sub_layer_reserved_zero_35bits);
sub_layer_reserved_zero_43bits.swap(ptl->sub_layer_reserved_zero_43bits);
sub_layer_inbld_flag.swap(ptl->sub_layer_inbld_flag);
sub_layer_reserved_zero_bit.swap(ptl->sub_layer_reserved_zero_bit);
sub_layer_level_idc.swap(ptl->sub_layer_level_idc);

return err;
}

// Parse the hevc vps/sps/pps
srs_error_t SrsFormat::hevc_demux_hvcc(SrsBuffer* stream)
{
Expand Down Expand Up @@ -1339,7 +1465,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((void*)&sps->ptl, &profile_tier_level, sizeof(profile_tier_level));
sps->ptl.dumps(&profile_tier_level);

// chroma_format_idc ue(v)
if ((err = bs.read_bits_ue(sps->chroma_format_idc)) != srs_success) {
Expand Down
36 changes: 7 additions & 29 deletions trunk/src/kernel/srs_kernel_codec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ struct SrsHevcHvccNalu {
*/
struct SrsHevcProfileTierLevel
{
public:
uint8_t general_profile_space;
uint8_t general_tier_flag;
uint8_t general_profile_idc;
Expand Down Expand Up @@ -552,35 +553,12 @@ struct SrsHevcProfileTierLevel
std::vector<uint8_t> sub_layer_reserved_zero_bit;
std::vector<uint8_t> sub_layer_level_idc;

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);
}
public:
SrsHevcProfileTierLevel();
virtual ~SrsHevcProfileTierLevel();

public:
virtual srs_error_t dumps(SrsHevcProfileTierLevel* ptl);
};

/**
Expand Down