avcodec/bsf: use av_packet_make_refcounted to ensure packets are ref counted
authorJames Almer <jamrial@gmail.com>
Sun, 25 Mar 2018 03:23:58 +0000 (00:23 -0300)
committerJames Almer <jamrial@gmail.com>
Mon, 2 Apr 2018 03:37:46 +0000 (00:37 -0300)
Simplifies code.

Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/bsf.c

index 05a44e2..bd611ea 100644 (file)
@@ -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;
 }