ff_cbs_delete_unit never fails if the index of the unit to delete is valid; document this behaviour explicitly and remove the checks for whether ff_cbs_delete_unit failed, because all the callers of ff_cbs_delete_unit already make sure that the index is valid.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@gmail.com> --- Several callers already ignored to check the return value. libavcodec/av1_metadata_bsf.c | 9 ++------- libavcodec/cbs.h | 2 ++ libavcodec/h264_metadata_bsf.c | 7 +------ libavcodec/h264_redundant_pps_bsf.c | 4 +--- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c index 842b80c201..dafddced63 100644 --- a/libavcodec/av1_metadata_bsf.c +++ b/libavcodec/av1_metadata_bsf.c @@ -161,13 +161,8 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (ctx->delete_padding) { for (i = frag->nb_units - 1; i >= 0; i--) { - if (frag->units[i].type == AV1_OBU_PADDING) { - err = ff_cbs_delete_unit(ctx->cbc, frag, i); - if (err < 0) { - av_log(bsf, AV_LOG_ERROR, "Failed to delete Padding OBU.\n"); - goto fail; - } - } + if (frag->units[i].type == AV1_OBU_PADDING) + ff_cbs_delete_unit(ctx->cbc, frag, i); } } diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index 5260a39c63..e1e6055ceb 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -380,6 +380,8 @@ int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx, /** * Delete a unit from a fragment and free all memory it uses. + * + * Never returns failure if position is >= 0 and < frag->nb_units. */ int ff_cbs_delete_unit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index f7ca1f0f09..d05b75be14 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -428,12 +428,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) for (i = au->nb_units - 1; i >= 0; i--) { if (au->units[i].type == H264_NAL_FILLER_DATA) { // Filler NAL units. - err = ff_cbs_delete_unit(ctx->cbc, au, i); - if (err < 0) { - av_log(bsf, AV_LOG_ERROR, "Failed to delete " - "filler NAL.\n"); - goto fail; - } + ff_cbs_delete_unit(ctx->cbc, au, i); continue; } diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index db8717d69a..8526b5b4c4 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -95,9 +95,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *out) if (!au_has_sps) { av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS " "at %"PRId64".\n", in->pts); - err = ff_cbs_delete_unit(ctx->input, au, i); - if (err < 0) - goto fail; + ff_cbs_delete_unit(ctx->input, au, i); } } if (nal->type == H264_NAL_SLICE || -- 2.21.0 _______________________________________________ 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".