[FFmpeg-cvslog] avdevice/decklink_dec: use av_packet_make_refcounted to ensure packets are ref counted

James Almer git at videolan.org
Mon Apr 2 06:50:06 EEST 2018


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sat Mar 24 22:28:42 2018 -0300| [38fa61b94766fc21bf32a279c77fc4084b30de1c] | committer: James Almer

avdevice/decklink_dec: use av_packet_make_refcounted to ensure packets are ref counted

Partially reverts commit e91f0c4f8b, simplifying code.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=38fa61b94766fc21bf32a279c77fc4084b30de1c
---

 libavdevice/decklink_dec.cpp | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 28a748a28f..e97a4402ea 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -464,24 +464,22 @@ static unsigned long long avpacket_queue_size(AVPacketQueue *q)
 static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt)
 {
     AVPacketList *pkt1;
-    int ret;
 
     // Drop Packet if queue size is > maximum queue size
     if (avpacket_queue_size(q) > (uint64_t)q->max_q_size) {
         av_log(q->avctx, AV_LOG_WARNING,  "Decklink input buffer overrun!\n");
         return -1;
     }
-
-    pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList));
-    if (!pkt1) {
+    /* ensure the packet is reference counted */
+    if (av_packet_make_refcounted(pkt) < 0) {
         return -1;
     }
-    ret = av_packet_ref(&pkt1->pkt, pkt);
-    av_packet_unref(pkt);
-    if (ret < 0) {
-        av_free(pkt1);
+
+    pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList));
+    if (!pkt1) {
         return -1;
     }
+    av_packet_move_ref(&pkt1->pkt, pkt);
     pkt1->next = NULL;
 
     pthread_mutex_lock(&q->mutex);



More information about the ffmpeg-cvslog mailing list