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);
}
}
return 0;
}
-int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag,
- int position)
+void ff_cbs_delete_unit(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ int position)
{
- if (position < 0 || position >= frag->nb_units)
- return AVERROR(EINVAL);
+ av_assert0(0 <= position && position < frag->nb_units
+ && "Unit to be deleted not in fragment.");
cbs_unit_uninit(ctx, &frag->units[position]);
memmove(frag->units + position,
frag->units + position + 1,
(frag->nb_units - position) * sizeof(*frag->units));
-
- return 0;
}
/**
* Delete a unit from a fragment and free all memory it uses.
+ *
+ * Requires position to be >= 0 and < frag->nb_units.
*/
-int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
- CodedBitstreamFragment *frag,
- int position);
+void ff_cbs_delete_unit(CodedBitstreamContext *ctx,
+ CodedBitstreamFragment *frag,
+ int position);
#endif /* AVCODEC_CBS_H */
}
av_assert0(i < au->nb_units && "NAL unit not in access unit.");
- return ff_cbs_delete_unit(ctx, au, i);
+ ff_cbs_delete_unit(ctx, au, i);
} else {
cbs_h264_free_sei_payload(&sei->payload[position]);
memmove(sei->payload + position,
sei->payload + position + 1,
(sei->payload_count - position) * sizeof(*sei->payload));
-
- return 0;
}
+
+ return 0;
}
if (ctx->delete_filler) {
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;
}
if (!au_has_sps) {
av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
"at %"PRId64".\n", pkt->pts);
- err = ff_cbs_delete_unit(ctx->input, au, i);
- if (err < 0)
- goto fail;
+ ff_cbs_delete_unit(ctx->input, au, i);
i--;
continue;
}