]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/encode: remove usage of av_dup_packet()
authorJames Almer <jamrial@gmail.com>
Tue, 26 Sep 2017 03:24:29 +0000 (00:24 -0300)
committerJames Almer <jamrial@gmail.com>
Mon, 2 Oct 2017 14:14:57 +0000 (11:14 -0300)
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/encode.c

index 525ee1f5d64b6ceac4ce28d8073ef809f0dc0b8b..dd50486bcfeb8614881e34cddf35a191839de9a6 100644 (file)
@@ -222,10 +222,12 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
             }
             avpkt->buf      = user_pkt.buf;
             avpkt->data     = user_pkt.data;
-        } else {
-            if (av_dup_packet(avpkt) < 0) {
-                ret = AVERROR(ENOMEM);
-            }
+        } else if (!avpkt->buf) {
+            AVPacket tmp = { 0 };
+            ret = av_packet_ref(&tmp, avpkt);
+            if (ret < 0)
+                return ret;
+            *avpkt = tmp;
         }
     }
 
@@ -318,10 +320,12 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
             }
             avpkt->buf      = user_pkt.buf;
             avpkt->data     = user_pkt.data;
-        } else {
-            if (av_dup_packet(avpkt) < 0) {
-                ret = AVERROR(ENOMEM);
-            }
+        } else if (!avpkt->buf) {
+            AVPacket tmp = { 0 };
+            ret = av_packet_ref(&tmp, avpkt);
+            if (ret < 0)
+                return ret;
+            *avpkt = tmp;
         }
     }