--- libavcodec/cbs_h2645.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c index 36212d1da6..fdc527f8e8 100644 --- a/libavcodec/cbs_h2645.c +++ b/libavcodec/cbs_h2645.c @@ -664,6 +664,7 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx, static int cbs_h2645_replace_ps(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit) { + static const size_t INVALID_OFFSET = (size_t)-1; typedef struct { int nal_unit_type; int max_count; @@ -728,8 +729,8 @@ static int cbs_h2645_replace_ps(CodedBitstreamContext *ctx, const PSType *ps_type; AVBufferRef **ref_array; void **ptr_array; - void **active; - int err, id, i, nb_ps_types; + void **active = NULL; + int err, id = 0, i, nb_ps_types; switch (ctx->codec->codec_id) { case AV_CODEC_ID_H264: @@ -751,12 +752,14 @@ static int cbs_h2645_replace_ps(CodedBitstreamContext *ctx, } av_assert0(i < nb_ps_types); - id = *((uint8_t*)unit->content + ps_type->id_offset); + if (ps_type->id_offset != INVALID_OFFSET) { + id = *((uint8_t*)unit->content + ps_type->id_offset); - if (id >= ps_type->max_count) { - av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid %s id: %d.\n", - ps_type->name, id); - return AVERROR_INVALIDDATA; + if (id >= ps_type->max_count) { + av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid %s id: %d.\n", + ps_type->name, id); + return AVERROR_INVALIDDATA; + } } err = ff_cbs_make_unit_refcounted(ctx, unit); @@ -766,9 +769,10 @@ static int cbs_h2645_replace_ps(CodedBitstreamContext *ctx, ref_array = (AVBufferRef**)((uint8_t*)ctx->priv_data + ps_type->ref_array_offset); ptr_array = (void**)((uint8_t*)ctx->priv_data + ps_type->ptr_array_offset); - active = (void**)((uint8_t*)ctx->priv_data + ps_type->active_offset); + if (ps_type->active_offset != INVALID_OFFSET) + active = (void**)((uint8_t*)ctx->priv_data + ps_type->active_offset); - if (ptr_array[id] == *active) { + if (active && ptr_array[id] == *active) { // The old active parameter set is being overwritten, so it can't // be active after this point. *active = NULL; -- 2.25.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".