X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fh264_redundant_pps_bsf.c;h=a8af4105cf5af93f56bb75aa15f2457feb5321c0;hb=14b84a2e997945467e445b1d246ee03a0c3ba806;hp=db8717d69a061d1718b55ebe165d86112bd8b907;hpb=44085b9951b06df1cab4105dcda004213988d84f;p=ffmpeg diff --git a/libavcodec/h264_redundant_pps_bsf.c b/libavcodec/h264_redundant_pps_bsf.c index db8717d69a0..a8af4105cf5 100644 --- a/libavcodec/h264_redundant_pps_bsf.c +++ b/libavcodec/h264_redundant_pps_bsf.c @@ -22,6 +22,7 @@ #include "libavutil/mem.h" #include "bsf.h" +#include "bsf_internal.h" #include "cbs.h" #include "cbs_h264.h" #include "h264.h" @@ -66,19 +67,18 @@ static int h264_redundant_pps_fixup_slice(H264RedundantPPSContext *ctx, return 0; } -static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *out) +static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *pkt) { H264RedundantPPSContext *ctx = bsf->priv_data; - AVPacket *in; CodedBitstreamFragment *au = &ctx->access_unit; int au_has_sps; int err, i; - err = ff_bsf_get_packet(bsf, &in); + err = ff_bsf_get_packet_ref(bsf, pkt); if (err < 0) return err; - err = ff_cbs_read_packet(ctx->input, au, in); + err = ff_cbs_read_packet(ctx->input, au, pkt); if (err < 0) goto fail; @@ -94,10 +94,10 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *out) goto fail; if (!au_has_sps) { av_log(bsf, AV_LOG_VERBOSE, "Deleting redundant PPS " - "at %"PRId64".\n", in->pts); - err = ff_cbs_delete_unit(ctx->input, au, i); - if (err < 0) - goto fail; + "at %"PRId64".\n", pkt->pts); + ff_cbs_delete_unit(au, i); + i--; + continue; } } if (nal->type == H264_NAL_SLICE || @@ -107,21 +107,15 @@ static int h264_redundant_pps_filter(AVBSFContext *bsf, AVPacket *out) } } - err = ff_cbs_write_packet(ctx->output, out, au); - if (err < 0) - goto fail; - - - err = av_packet_copy_props(out, in); + err = ff_cbs_write_packet(ctx->output, pkt, au); if (err < 0) goto fail; err = 0; fail: - ff_cbs_fragment_reset(ctx->output, au); - av_packet_free(&in); + ff_cbs_fragment_reset(au); if (err < 0) - av_packet_unref(out); + av_packet_unref(pkt); return err; } @@ -167,7 +161,7 @@ static int h264_redundant_pps_init(AVBSFContext *bsf) err = 0; fail: - ff_cbs_fragment_reset(ctx->output, au); + ff_cbs_fragment_reset(au); return err; } @@ -181,7 +175,7 @@ static void h264_redundant_pps_close(AVBSFContext *bsf) { H264RedundantPPSContext *ctx = bsf->priv_data; - ff_cbs_fragment_free(ctx->input, &ctx->access_unit); + ff_cbs_fragment_free(&ctx->access_unit); ff_cbs_close(&ctx->input); ff_cbs_close(&ctx->output); }