]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/encode: use av_packet_make_refcounted to ensure packets are ref counted
authorJames Almer <jamrial@gmail.com>
Sun, 25 Mar 2018 00:58:56 +0000 (21:58 -0300)
committerJames Almer <jamrial@gmail.com>
Mon, 2 Apr 2018 02:40:42 +0000 (23:40 -0300)
Simplifies code.

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

index 71b1b14afc029dfb5ea61afc22a668bbc0b02e46..d9761515aa84e2ccdf5040fdabd6fb9af310bc4f 100644 (file)
@@ -223,12 +223,9 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
             avpkt->buf      = user_pkt.buf;
             avpkt->data     = user_pkt.data;
         } else if (!avpkt->buf) {
-            AVPacket tmp = { 0 };
-            ret = av_packet_ref(&tmp, avpkt);
-            av_packet_unref(avpkt);
+            ret = av_packet_make_refcounted(avpkt);
             if (ret < 0)
                 goto end;
-            *avpkt = tmp;
         }
     }
 
@@ -318,12 +315,9 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
             avpkt->buf      = user_pkt.buf;
             avpkt->data     = user_pkt.data;
         } else if (!avpkt->buf) {
-            AVPacket tmp = { 0 };
-            ret = av_packet_ref(&tmp, avpkt);
-            av_packet_unref(avpkt);
+            ret = av_packet_make_refcounted(avpkt);
             if (ret < 0)
                 return ret;
-            *avpkt = tmp;
         }
     }