avformat: Always return ref-counted AVPacket
authorLuca Barbato <lu_zero@gentoo.org>
Fri, 23 Oct 2015 09:11:30 +0000 (11:11 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 26 Oct 2015 17:00:55 +0000 (18:00 +0100)
And drop the av_dup_packet from the input_thread.

avconv.c
avplay.c
libavformat/utils.c

index c52f292..f6bcb02 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -2130,7 +2130,6 @@ static void *input_thread(void *arg)
         while (!av_fifo_space(f->fifo))
             pthread_cond_wait(&f->fifo_cond, &f->fifo_lock);
 
-        av_dup_packet(&pkt);
         av_fifo_generic_write(f->fifo, &pkt, sizeof(pkt), NULL);
 
         pthread_mutex_unlock(&f->fifo_lock);
index dd2073c..55e018a 100644 (file)
--- a/avplay.c
+++ b/avplay.c
@@ -320,10 +320,6 @@ static int packet_queue_put(PacketQueue *q, AVPacket *pkt)
 {
     AVPacketList *pkt1;
 
-    /* duplicate the packet */
-    if (pkt != &flush_pkt && av_dup_packet(pkt) < 0)
-        return -1;
-
     pkt1 = av_malloc(sizeof(AVPacketList));
     if (!pkt1)
         return -1;
index f8926bd..fd96b9d 100644 (file)
@@ -413,6 +413,14 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             continue;
         }
 
+        if (!pkt->buf) {
+            AVPacket tmp = { 0 };
+            ret = av_packet_ref(&tmp, pkt);
+            if (ret < 0)
+                return ret;
+            *pkt = tmp;
+        }
+
         if ((s->flags & AVFMT_FLAG_DISCARD_CORRUPT) &&
             (pkt->flags & AV_PKT_FLAG_CORRUPT)) {
             av_log(s, AV_LOG_WARNING,