summaryrefslogtreecommitdiff
path: root/libavcodec/av1_metadata_bsf.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-06-17 05:42:12 +0200
committerMark Thompson <sw@jkqxz.net>2019-07-07 22:17:07 +0100
commit36fcdc3fbe089bc01066e2afa5645f383025f0ec (patch)
tree9dd8747ccdaac0cb1997903678f6436871948b51 /libavcodec/av1_metadata_bsf.c
parentb0810454e473dd321a27c43de2d0e9d02fdba556 (diff)
av1/h264_metadata, filter_units: Count down when deleting units
When testing whether a particular unit should be kept or discarded, it is best to start at the very last unit of a fragment and count down, because that way a unit that will eventually be deleted won't be memmoved during earlier deletions; and frag/au->nb_units need only be evaluated once in this case and the counter is automatically correct when a unit got deleted. It also works for double loops, i.e. when looping over all SEI messages in all SEI units of an access unit. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/av1_metadata_bsf.c')
-rw-r--r--libavcodec/av1_metadata_bsf.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index e294d7a24e..842b80c201 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -160,14 +160,13 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
}
if (ctx->delete_padding) {
- for (i = 0; i < frag->nb_units; i++) {
+ 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;
}
- --i;
}
}
}