cbs: ff_cbs_delete_unit: Replace return value with assert
ff_cbs_delete_unit never fails if the index of the unit to delete is valid, as it is with all current callers of the function. So just assert in ff_cbs_delete_unit that the index is valid and change the return value to void in order to remove the callers' checks for whether ff_cbs_delete_unit failed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
parent
70a4f46e48
commit
730e5be3aa
@ -167,13 +167,8 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
|
|||||||
|
|
||||||
if (ctx->delete_padding) {
|
if (ctx->delete_padding) {
|
||||||
for (i = frag->nb_units - 1; i >= 0; i--) {
|
for (i = frag->nb_units - 1; i >= 0; i--) {
|
||||||
if (frag->units[i].type == AV1_OBU_PADDING) {
|
if (frag->units[i].type == AV1_OBU_PADDING)
|
||||||
err = ff_cbs_delete_unit(ctx->cbc, frag, i);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,12 +737,12 @@ int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
|
void ff_cbs_delete_unit(CodedBitstreamContext *ctx,
|
||||||
CodedBitstreamFragment *frag,
|
CodedBitstreamFragment *frag,
|
||||||
int position)
|
int position)
|
||||||
{
|
{
|
||||||
if (position < 0 || position >= frag->nb_units)
|
av_assert0(0 <= position && position < frag->nb_units
|
||||||
return AVERROR(EINVAL);
|
&& "Unit to be deleted not in fragment.");
|
||||||
|
|
||||||
cbs_unit_uninit(ctx, &frag->units[position]);
|
cbs_unit_uninit(ctx, &frag->units[position]);
|
||||||
|
|
||||||
@ -752,6 +752,4 @@ int ff_cbs_delete_unit(CodedBitstreamContext *ctx,
|
|||||||
memmove(frag->units + position,
|
memmove(frag->units + position,
|
||||||
frag->units + position + 1,
|
frag->units + position + 1,
|
||||||
(frag->nb_units - position) * sizeof(*frag->units));
|
(frag->nb_units - position) * sizeof(*frag->units));
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -380,10 +380,12 @@ int ff_cbs_insert_unit_data(CodedBitstreamContext *ctx,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a unit from a fragment and free all memory it uses.
|
* 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,
|
void ff_cbs_delete_unit(CodedBitstreamContext *ctx,
|
||||||
CodedBitstreamFragment *frag,
|
CodedBitstreamFragment *frag,
|
||||||
int position);
|
int position);
|
||||||
|
|
||||||
|
|
||||||
#endif /* AVCODEC_CBS_H */
|
#endif /* AVCODEC_CBS_H */
|
||||||
|
@ -1664,7 +1664,7 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
|
|||||||
}
|
}
|
||||||
av_assert0(i < au->nb_units && "NAL unit not in access unit.");
|
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 {
|
} else {
|
||||||
cbs_h264_free_sei_payload(&sei->payload[position]);
|
cbs_h264_free_sei_payload(&sei->payload[position]);
|
||||||
|
|
||||||
@ -1672,7 +1672,7 @@ int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx,
|
|||||||
memmove(sei->payload + position,
|
memmove(sei->payload + position,
|
||||||
sei->payload + position + 1,
|
sei->payload + position + 1,
|
||||||
(sei->payload_count - position) * sizeof(*sei->payload));
|
(sei->payload_count - position) * sizeof(*sei->payload));
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -427,13 +427,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
|
|||||||
if (ctx->delete_filler) {
|
if (ctx->delete_filler) {
|
||||||
for (i = au->nb_units - 1; i >= 0; i--) {
|
for (i = au->nb_units - 1; i >= 0; i--) {
|
||||||
if (au->units[i].type == H264_NAL_FILLER_DATA) {
|
if (au->units[i].type == H264_NAL_FILLER_DATA) {
|
||||||
// Filler NAL units.
|
ff_cbs_delete_unit(ctx->cbc, au, i);
|
||||||
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;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,9 +94,7 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt)
|
|||||||
if (!au_has_sps) {
|
if (!au_has_sps) {
|
||||||
av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
|
av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS "
|
||||||
"at %"PRId64".\n", pkt->pts);
|
"at %"PRId64".\n", pkt->pts);
|
||||||
err = ff_cbs_delete_unit(ctx->input, au, i);
|
ff_cbs_delete_unit(ctx->input, au, i);
|
||||||
if (err < 0)
|
|
||||||
goto fail;
|
|
||||||
i--;
|
i--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user