diff options
author | James Almer <jamrial@gmail.com> | 2018-03-25 00:23:58 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-04-02 00:37:46 -0300 |
commit | 265ec55983bf3b981190b564925a609d53391aa5 (patch) | |
tree | f0d3e6bf5a5593d06685be784b16ea4bdc6378c1 /libavcodec/bsf.c | |
parent | 38fa61b94766fc21bf32a279c77fc4084b30de1c (diff) | |
download | ffmpeg-265ec55983bf3b981190b564925a609d53391aa5.tar.gz |
avcodec/bsf: use av_packet_make_refcounted to ensure packets are ref counted
Simplifies code.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec/bsf.c')
-rw-r--r-- | libavcodec/bsf.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c index 05a44e2e31..bd611ea16b 100644 --- a/libavcodec/bsf.c +++ b/libavcodec/bsf.c @@ -174,6 +174,8 @@ int av_bsf_init(AVBSFContext *ctx) int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) { + int ret; + if (!pkt || (!pkt->data && !pkt->side_data_elems)) { ctx->internal->eof = 1; return 0; @@ -188,15 +190,10 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt) ctx->internal->buffer_pkt->side_data_elems) return AVERROR(EAGAIN); - if (pkt->buf) { - av_packet_move_ref(ctx->internal->buffer_pkt, pkt); - } else { - int ret = av_packet_ref(ctx->internal->buffer_pkt, pkt); - - if (ret < 0) - return ret; - av_packet_unref(pkt); - } + ret = av_packet_make_refcounted(pkt); + if (ret < 0) + return ret; + av_packet_move_ref(ctx->internal->buffer_pkt, pkt); return 0; } |