History

avcodec/cbs_h265: fix range of sps_max_sub_layers_minus1

The VPS referenced by the SPS must always be present as the max value for sps_max_sub_layers_minus1 is vps_max_sub_layers_minus1. This replaces a buggy custom range check for the aforementioned field. Also, add the missing conformance check for sps_temporal_id_nesting_flag while at it.

James Almer committed 2 years ago

Commit 5fe13ae1 parent 350146a1 file · +20 −17Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/cbs_h265_syntax_template.c+20−17
@@ -788,25 +788,28 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, · 787 unmodified lines
788 788
789 ub(4, sps_video_parameter_set_id);789 ub(4, sps_video_parameter_set_id);
790 h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id];790 h265->active_vps = vps = h265->vps[current->sps_video_parameter_set_id];
791 if (!vps) {
792 av_log(ctx->log_ctx, AV_LOG_ERROR, "VPS id %d not available.\n",
793 current->sps_video_parameter_set_id);
794 return AVERROR_INVALIDDATA;
795 }
791 796
792 u(3, sps_max_sub_layers_minus1, 0, HEVC_MAX_SUB_LAYERS - 1);797 u(3, sps_max_sub_layers_minus1, 0, vps->vps_max_sub_layers_minus1);
793 flag(sps_temporal_id_nesting_flag);798 flag(sps_temporal_id_nesting_flag);
794 if (vps) {799
795 if (vps->vps_max_sub_layers_minus1 > current->sps_max_sub_layers_minus1) {800 if (vps->vps_temporal_id_nesting_flag &&
796 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "801 !current->sps_temporal_id_nesting_flag) {
797 "sps_max_sub_layers_minus1 (%d) must be less than or equal to "802 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
798 "vps_max_sub_layers_minus1 (%d).\n",803 "sps_temporal_id_nesting_flag must be 1 if "
799 vps->vps_max_sub_layers_minus1,804 "vps_temporal_id_nesting_flag is 1.\n");
800 current->sps_max_sub_layers_minus1);805 return AVERROR_INVALIDDATA;
801 return AVERROR_INVALIDDATA;806 }
802 }807 if (current->sps_max_sub_layers_minus1 == 0 &&
803 if (vps->vps_temporal_id_nesting_flag &&808 current->sps_temporal_id_nesting_flag != 1) {
804 !current->sps_temporal_id_nesting_flag) {809 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "
805 av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid stream: "810 "sps_temporal_id_nesting_flag must be 1 if "
806 "sps_temporal_id_nesting_flag must be 1 if "811 "sps_max_sub_layers_minus1 is 0.\n");
807 "vps_temporal_id_nesting_flag is 1.\n");812 return AVERROR_INVALIDDATA;
808 return AVERROR_INVALIDDATA;
809 }
810 }813 }
811 814
812 CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level,815 CHECK(FUNC(profile_tier_level)(ctx, rw, &current->profile_tier_level,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t