}
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;
}
}
}
goto fail;
}
- for (i = 0; i < frag->nb_units; i++) {
+ for (i = frag->nb_units - 1; i >= 0; i--) {
for (j = 0; j < ctx->nb_types; j++) {
if (frag->units[i].type == ctx->type_list[j])
break;
}
if (ctx->mode == REMOVE ? j < ctx->nb_types
- : j >= ctx->nb_types) {
+ : j >= ctx->nb_types)
ff_cbs_delete_unit(ctx->cbc, frag, i);
- --i;
- }
}
if (frag->nb_units == 0) {
}
if (ctx->delete_filler) {
- for (i = 0; i < au->nb_units; i++) {
+ 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);
"filler NAL.\n");
goto fail;
}
- --i;
continue;
}
// Filler SEI messages.
H264RawSEI *sei = au->units[i].content;
- for (j = 0; j < sei->payload_count; j++) {
+ for (j = sei->payload_count - 1; j >= 0; j--) {
if (sei->payload[j].payload_type ==
H264_SEI_TYPE_FILLER_PAYLOAD) {
err = ff_cbs_h264_delete_sei_message(ctx->cbc, au,
"filler SEI message.\n");
goto fail;
}
- // Renumbering might have happened, start again at
- // the same NAL unit position.
- --i;
- break;
}
}
}
}
if (ctx->display_orientation != PASS) {
- for (i = 0; i < au->nb_units; i++) {
+ for (i = au->nb_units - 1; i >= 0; i--) {
H264RawSEI *sei;
if (au->units[i].type != H264_NAL_SEI)
continue;
sei = au->units[i].content;
- for (j = 0; j < sei->payload_count; j++) {
+ for (j = sei->payload_count - 1; j >= 0; j--) {
H264RawSEIDisplayOrientation *disp;
int32_t *matrix;
"display orientation SEI message.\n");
goto fail;
}
- --i;
- break;
+ continue;
}
matrix = av_mallocz(9 * sizeof(int32_t));
av_display_matrix_flip(matrix, disp->hor_flip, disp->ver_flip);
// If there are multiple display orientation messages in an
- // access unit then ignore all but the last one.
+ // access unit then ignore all but the first one.
av_freep(&displaymatrix_side_data);
displaymatrix_side_data = (uint8_t*)matrix;