diff --git a/libavcodec/filter_units_bsf.c b/libavcodec/filter_units_bsf.c index 8c501e1726..f3691a5755 100644 --- a/libavcodec/filter_units_bsf.c +++ b/libavcodec/filter_units_bsf.c @@ -98,24 +98,20 @@ invalid: return AVERROR(EINVAL); } -static int filter_units_filter(AVBSFContext *bsf, AVPacket *out) +static int filter_units_filter(AVBSFContext *bsf, AVPacket *pkt) { FilterUnitsContext *ctx = bsf->priv_data; CodedBitstreamFragment *frag = &ctx->fragment; - AVPacket *in = NULL; int err, i, j; - err = ff_bsf_get_packet(bsf, &in); + err = ff_bsf_get_packet_ref(bsf, pkt); if (err < 0) return err; - if (ctx->mode == NOOP) { - av_packet_move_ref(out, in); - av_packet_free(&in); + if (ctx->mode == NOOP) return 0; - } - err = ff_cbs_read_packet(ctx->cbc, frag, in); + err = ff_cbs_read_packet(ctx->cbc, frag, pkt); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); goto fail; @@ -139,21 +135,16 @@ static int filter_units_filter(AVBSFContext *bsf, AVPacket *out) goto fail; } - err = ff_cbs_write_packet(ctx->cbc, out, frag); + err = ff_cbs_write_packet(ctx->cbc, pkt, frag); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); goto fail; } - err = av_packet_copy_props(out, in); - if (err < 0) - goto fail; - fail: if (err < 0) - av_packet_unref(out); + av_packet_unref(pkt); ff_cbs_fragment_reset(ctx->cbc, frag); - av_packet_free(&in); return err; }