avformat: replace all uses of av_copy_packet()
authorJames Almer <jamrial@gmail.com>
Sat, 23 Sep 2017 23:30:13 +0000 (20:30 -0300)
committerJames Almer <jamrial@gmail.com>
Tue, 26 Sep 2017 00:26:38 +0000 (21:26 -0300)
Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/aiffenc.c
libavformat/apngenc.c
libavformat/gif.c
libavformat/img2enc.c
libavformat/movenc.c
libavformat/mp3enc.c
libavformat/subtitles.c
libavformat/webpenc.c
libavformat/wtvenc.c

index fcadf14..aab3741 100644 (file)
@@ -233,7 +233,8 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
         if (!pict_list)
             return AVERROR(ENOMEM);
 
-        if ((ret = av_copy_packet(&pict_list->pkt, pkt)) < 0) {
+        ret = av_packet_ref(&pict_list->pkt, pkt);
+        if (ret < 0) {
             av_freep(&pict_list);
             return ret;
         }
index d4191c0..77c1c91 100644 (file)
@@ -218,7 +218,7 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet)
 
     av_packet_unref(apng->prev_packet);
     if (packet)
-        av_copy_packet(apng->prev_packet, packet);
+        av_packet_ref(apng->prev_packet, packet);
     return 0;
 }
 
@@ -232,7 +232,7 @@ static int apng_write_packet(AVFormatContext *format_context, AVPacket *packet)
         if (!apng->prev_packet)
             return AVERROR(ENOMEM);
 
-        av_copy_packet(apng->prev_packet, packet);
+        av_packet_ref(apng->prev_packet, packet);
     } else {
         ret = flush_packet(format_context, packet);
         if (ret < 0)
index d6113db..01d98a2 100644 (file)
@@ -175,7 +175,7 @@ static int flush_packet(AVFormatContext *s, AVPacket *new)
 
     av_packet_unref(gif->prev_pkt);
     if (new)
-        av_copy_packet(gif->prev_pkt, new);
+        av_packet_ref(gif->prev_pkt, new);
 
     return 0;
 }
@@ -206,7 +206,7 @@ static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
             gif_image_write_header(s->pb, video_st, gif->loop, palette);
         }
 
-        return av_copy_packet(gif->prev_pkt, pkt);
+        return av_packet_ref(gif->prev_pkt, pkt);
     }
     return flush_packet(s, pkt);
 }
index 87b5ec2..9b60bfc 100644 (file)
@@ -161,7 +161,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
         st->id = pkt->stream_index;
 
         fmt->pb = pb[0];
-        if ((ret = av_copy_packet(&pkt2, pkt))                            < 0 ||
+        if ((ret = av_packet_ref(&pkt2, pkt))                             < 0 ||
             (ret = av_dup_packet(&pkt2))                                  < 0 ||
             (ret = avcodec_parameters_copy(st->codecpar, s->streams[0]->codecpar)) < 0 ||
             (ret = avformat_write_header(fmt, NULL))                      < 0 ||
index 10b959a..ba3e263 100644 (file)
@@ -437,8 +437,8 @@ concatenate:
         return AVERROR_INVALIDDATA;
 
     if (!info->num_blocks) {
-        int ret;
-        if ((ret = av_copy_packet(&info->pkt, pkt)) < 0)
+        int ret = av_packet_ref(&info->pkt, pkt);
+        if (ret < 0)
             return ret;
         info->num_blocks = num_blocks;
         return 0;
@@ -454,7 +454,8 @@ concatenate:
         if (info->num_blocks != 6)
             return 0;
         av_packet_unref(pkt);
-        if ((ret = av_copy_packet(pkt, &info->pkt)) < 0)
+        ret = av_packet_ref(pkt, &info->pkt);
+        if (ret < 0)
             return ret;
         av_packet_unref(&info->pkt);
         info->num_blocks = 0;
index 3cbf7bd..826878e 100644 (file)
@@ -523,7 +523,7 @@ static int mp3_write_packet(AVFormatContext *s, AVPacket *pkt)
                 return mp3_write_audio_packet(s, pkt);
             }
 
-            ret = av_copy_packet(&pktl->pkt, pkt);
+            ret = av_packet_ref(&pktl->pkt, pkt);
             if (ret < 0) {
                 av_freep(&pktl);
                 return ret;
index 108f909..93c9ef0 100644 (file)
@@ -211,7 +211,7 @@ int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
 
     if (q->current_sub_idx == q->nb_subs)
         return AVERROR_EOF;
-    if (av_copy_packet(pkt, sub) < 0) {
+    if (av_packet_ref(pkt, sub) < 0) {
         return AVERROR(ENOMEM);
     }
 
index 2e0147c..9fb4722 100644 (file)
@@ -158,7 +158,7 @@ static int webp_write_packet(AVFormatContext *s, AVPacket *pkt)
         int ret;
         if ((ret = flush(s, 0, pkt->pts)) < 0)
             return ret;
-        av_copy_packet(&w->last_pkt, pkt);
+        av_packet_ref(&w->last_pkt, pkt);
     }
     ++w->frame_count;
 
index 4925a60..4a68b81 100644 (file)
@@ -464,7 +464,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
     AVStream    *st   = s->streams[pkt->stream_index];
 
     if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG && !wctx->thumbnail.size) {
-        av_copy_packet(&wctx->thumbnail, pkt);
+        av_packet_ref(&wctx->thumbnail, pkt);
         return 0;
     } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
         int ret = ff_check_h264_startcode(s, st, pkt);