]> git.sesse.net Git - ffmpeg/commitdiff
avpacket: Replace av_free_packet with av_packet_unref
authorLuca Barbato <lu_zero@gentoo.org>
Fri, 23 Oct 2015 09:11:31 +0000 (11:11 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Mon, 26 Oct 2015 17:00:55 +0000 (18:00 +0100)
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.

80 files changed:
avconv.c
avplay.c
doc/APIchanges
doc/examples/avcodec.c
doc/examples/transcode_aac.c
libavcodec/avcodec.h
libavcodec/avpacket.c
libavcodec/jpeglsenc.c
libavcodec/libxvid.c
libavcodec/mpegvideo_enc.c
libavcodec/utils.c
libavcodec/version.h
libavdevice/alsa_dec.c
libavdevice/jack.c
libavdevice/oss_dec.c
libavdevice/pulse.c
libavdevice/sndio_dec.c
libavdevice/v4l2.c
libavdevice/vfwcap.c
libavfilter/vsrc_movie.c
libavformat/4xm.c
libavformat/adxdec.c
libavformat/amr.c
libavformat/asfdec.c
libavformat/avformat.h
libavformat/avidec.c
libavformat/avs.c
libavformat/c93.c
libavformat/cdg.c
libavformat/cdxl.c
libavformat/dfa.c
libavformat/dsicin.c
libavformat/dss.c
libavformat/dxa.c
libavformat/electronicarts.c
libavformat/flic.c
libavformat/g723_1.c
libavformat/gsmdec.c
libavformat/hls.c
libavformat/hnm.c
libavformat/idcin.c
libavformat/ilbc.c
libavformat/img2dec.c
libavformat/ingenientdec.c
libavformat/internal.h
libavformat/ipmovie.c
libavformat/iv8.c
libavformat/lxfdec.c
libavformat/matroskadec.c
libavformat/matroskaenc.c
libavformat/mmf.c
libavformat/mp3enc.c
libavformat/mpc.c
libavformat/mpegts.c
libavformat/mux.c
libavformat/mxfenc.c
libavformat/ncdec.c
libavformat/nsvdec.c
libavformat/nuv.c
libavformat/psxstr.c
libavformat/rawdec.c
libavformat/rl2.c
libavformat/rmdec.c
libavformat/rpl.c
libavformat/rtpdec_asf.c
libavformat/rtpdec_mpa_robust.c
libavformat/rtpdec_qt.c
libavformat/rtpdec_xiph.c
libavformat/sapdec.c
libavformat/seek-test.c
libavformat/sierravmd.c
libavformat/spdifdec.c
libavformat/thp.c
libavformat/utils.c
libavformat/vqf.c
libavformat/wc3movie.c
libavformat/westwood_vqa.c
libavformat/wvdec.c
libavformat/yop.c
tools/pktdumper.c

index f6bcb02e221bd5cdd4f4f3ef34d8ebaf6313207a..ed0a3dd84f77c7cf67a644017434d0317b30c4be 100644 (file)
--- a/avconv.c
+++ b/avconv.c
@@ -270,7 +270,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
      */
     if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) {
         if (ost->frame_number >= ost->max_frames) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return;
         }
         ost->frame_number++;
@@ -288,7 +288,7 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
                                            pkt->data, pkt->size,
                                            pkt->flags & AV_PKT_FLAG_KEY);
         if (a > 0) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size,
                                            av_buffer_default_free, NULL, 0);
             if (!new_pkt.buf)
@@ -2158,7 +2158,7 @@ static void free_input_threads(void)
         pthread_mutex_lock(&f->fifo_lock);
         while (av_fifo_size(f->fifo)) {
             av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL);
-            av_free_packet(&pkt);
+            av_packet_unref(&pkt);
         }
         pthread_cond_signal(&f->fifo_cond);
         pthread_mutex_unlock(&f->fifo_lock);
@@ -2168,7 +2168,7 @@ static void free_input_threads(void)
 
         while (av_fifo_size(f->fifo)) {
             av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL);
-            av_free_packet(&pkt);
+            av_packet_unref(&pkt);
         }
         av_fifo_free(f->fifo);
     }
@@ -2483,7 +2483,7 @@ static int process_input(void)
     process_input_packet(ist, &pkt, 0);
 
 discard_packet:
-    av_free_packet(&pkt);
+    av_packet_unref(&pkt);
 
     return 0;
 }
index 55e018a896936eaaf5a67fa6c30a85f61a32f210..56ec7316e5c7e71bc06074589da64ae55971d1ed 100644 (file)
--- a/avplay.c
+++ b/avplay.c
@@ -299,7 +299,7 @@ static void packet_queue_flush(PacketQueue *q)
     SDL_LockMutex(q->mutex);
     for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) {
         pkt1 = pkt->next;
-        av_free_packet(&pkt->pkt);
+        av_packet_unref(&pkt->pkt);
         av_freep(&pkt);
     }
     q->last_pkt = NULL;
@@ -1617,7 +1617,7 @@ static int video_thread(void *arg)
         while (is->paused && !is->videoq.abort_request)
             SDL_Delay(10);
 
-        av_free_packet(&pkt);
+        av_packet_unref(&pkt);
 
         ret = get_video_frame(is, frame, &pts_int, &pkt);
         if (ret < 0)
@@ -1684,7 +1684,7 @@ static int video_thread(void *arg)
     av_freep(&vfilters);
     avfilter_graph_free(&graph);
 #endif
-    av_free_packet(&pkt);
+    av_packet_unref(&pkt);
     av_frame_free(&frame);
     return 0;
 }
@@ -1753,7 +1753,7 @@ static int subtitle_thread(void *arg)
             is->subpq_size++;
             SDL_UnlockMutex(is->subpq_mutex);
         }
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
     }
     return 0;
 }
@@ -1984,7 +1984,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr)
 
         /* free the current packet */
         if (pkt->data)
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
         memset(pkt_temp, 0, sizeof(*pkt_temp));
 
         if (is->paused || is->audioq.abort_request) {
@@ -2181,7 +2181,7 @@ static void stream_component_close(VideoState *is, int stream_index)
         SDL_CloseAudio();
 
         packet_queue_end(&is->audioq);
-        av_free_packet(&is->audio_pkt);
+        av_packet_unref(&is->audio_pkt);
         if (is->avr)
             avresample_free(&is->avr);
         av_freep(&is->audio_buf1);
@@ -2490,7 +2490,7 @@ static int decode_thread(void *arg)
         } else if (pkt->stream_index == is->subtitle_stream && pkt_in_play_range) {
             packet_queue_put(&is->subtitleq, pkt);
         } else {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
         }
     }
     /* wait until the end */
index f9297406ada766eb5bbe16b234bb04a5294002ab..590f192a4688380ef26b35450940c1be27b2ff52 100644 (file)
@@ -13,6 +13,10 @@ libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2015-xx-xx - xxxxxxx - lavc 57.7.0 - avcodec.h
+  Deprecate av_free_packet(). Use av_packet_unref() as replacement,
+  it resets the packet in a more consistent way.
+
 2015-xx-xx - xxxxxxx - lavc 57.5.0 - avcodec.h
   Add data and linesize array to AVSubtitleRect, to be used instead of
   the ones from the embedded AVPicture.
index f801bed2d060eac539bf93f762e854c710124d29..df0af4b1eaf3291ad0bd03fa7879004965a3b206 100644 (file)
@@ -206,7 +206,7 @@ static void audio_encode_example(const char *filename)
         }
         if (got_output) {
             fwrite(pkt.data, 1, pkt.size, f);
-            av_free_packet(&pkt);
+            av_packet_unref(&pkt);
         }
     }
     fclose(f);
@@ -403,7 +403,7 @@ static void video_encode_example(const char *filename)
         if (got_output) {
             printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
             fwrite(pkt.data, 1, pkt.size, f);
-            av_free_packet(&pkt);
+            av_packet_unref(&pkt);
         }
     }
 
@@ -420,7 +420,7 @@ static void video_encode_example(const char *filename)
         if (got_output) {
             printf("encoding frame %3d (size=%5d)\n", i, pkt.size);
             fwrite(pkt.data, 1, pkt.size, f);
-            av_free_packet(&pkt);
+            av_packet_unref(&pkt);
         }
     }
 
index 30e618994204ba5f38c23b2b99ed9b58d7e44c33..3eebfb9d0200f75ce48773d1657357caf99854a6 100644 (file)
@@ -337,7 +337,7 @@ static int decode_audio_frame(AVFrame *frame,
                                        data_present, &input_packet)) < 0) {
         fprintf(stderr, "Could not decode frame (error '%s')\n",
                 get_error_text(error));
-        av_free_packet(&input_packet);
+        av_packet_unref(&input_packet);
         return error;
     }
 
@@ -347,7 +347,7 @@ static int decode_audio_frame(AVFrame *frame,
      */
     if (*finished && *data_present)
         *finished = 0;
-    av_free_packet(&input_packet);
+    av_packet_unref(&input_packet);
     return 0;
 }
 
@@ -585,7 +585,7 @@ static int encode_audio_frame(AVFrame *frame,
                                        frame, data_present)) < 0) {
         fprintf(stderr, "Could not encode frame (error '%s')\n",
                 get_error_text(error));
-        av_free_packet(&output_packet);
+        av_packet_unref(&output_packet);
         return error;
     }
 
@@ -594,11 +594,11 @@ static int encode_audio_frame(AVFrame *frame,
         if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
             fprintf(stderr, "Could not write frame (error '%s')\n",
                     get_error_text(error));
-            av_free_packet(&output_packet);
+            av_packet_unref(&output_packet);
             return error;
         }
 
-        av_free_packet(&output_packet);
+        av_packet_unref(&output_packet);
     }
 
     return 0;
index cf8cc5a5d7958b2652fdbe2f0c700800d4a5be79..dfd18ba866628e1e362395bc158bb3abd7173c2f 100644 (file)
@@ -1151,15 +1151,19 @@ typedef struct AVPacketSideData {
  * ABI. Thus it may be allocated on stack and no new fields can be added to it
  * without libavcodec and libavformat major bump.
  *
- * The semantics of data ownership depends on the buf or destruct (deprecated)
- * fields. If either is set, the packet data is dynamically allocated and is
- * valid indefinitely until av_free_packet() is called (which in turn calls
- * av_buffer_unref()/the destruct callback to free the data). If neither is set,
- * the packet data is typically backed by some static buffer somewhere and is
- * only valid for a limited time (e.g. until the next read call when demuxing).
+ * The semantics of data ownership depends on the buf field.
+ * If it is set, the packet data is dynamically allocated and is
+ * valid indefinitely until a call to av_packet_unref() reduces the
+ * reference count to 0.
  *
- * The side data is always allocated with av_malloc() and is freed in
- * av_free_packet().
+ * If the buf field is not set av_packet_ref() would make a copy instead
+ * of increasing the reference count.
+ *
+ * The side data is always allocated with av_malloc(), copied by
+ * av_packet_ref() and freed by av_packet_unref().
+ *
+ * @see av_packet_ref
+ * @see av_packet_unref
  */
 typedef struct AVPacket {
     /**
@@ -3477,14 +3481,17 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
  * packet is allocated if it was not really allocated.
  */
 int av_dup_packet(AVPacket *pkt);
-
+#if FF_API_AVPACKET_OLD_API
 /**
  * Free a packet.
  *
+ * @deprecated Use av_packet_unref
+ *
  * @param pkt packet to free
  */
+attribute_deprecated
 void av_free_packet(AVPacket *pkt);
-
+#endif
 /**
  * Allocate new information of a packet.
  *
@@ -4070,8 +4077,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name);
  *                  output packet.
  *
  *                  If this function fails or produces no output, avpkt will be
- *                  freed using av_free_packet() (i.e. avpkt->destruct will be
- *                  called to free the user supplied buffer).
+ *                  freed using av_packet_unref().
  * @param[in] frame AVFrame containing the raw audio data to be encoded.
  *                  May be NULL when flushing an encoder that has the
  *                  AV_CODEC_CAP_DELAY capability set.
@@ -4112,8 +4118,7 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
  *                  caller, he is responsible for freeing it.
  *
  *                  If this function fails or produces no output, avpkt will be
- *                  freed using av_free_packet() (i.e. avpkt->destruct will be
- *                  called to free the user supplied buffer).
+ *                  freed using av_packet_unref().
  * @param[in] frame AVFrame containing the raw video data to be encoded.
  *                  May be NULL when flushing an encoder that has the
  *                  AV_CODEC_CAP_DELAY capability set.
index e762a8782a2a14786e1b2dca497b2d38ed77a2ab..eaea061c5434ad5d423e5d6be61290042a9482a0 100644 (file)
@@ -184,7 +184,7 @@ int av_dup_packet(AVPacket *pkt)
     return 0;
 
 failed_alloc:
-    av_free_packet(pkt);
+    av_packet_unref(pkt);
     return AVERROR(ENOMEM);
 }
 
@@ -197,6 +197,8 @@ void av_packet_free_side_data(AVPacket *pkt)
     pkt->side_data_elems = 0;
 }
 
+#if FF_API_AVPACKET_OLD_API
+FF_DISABLE_DEPRECATION_WARNINGS
 void av_free_packet(AVPacket *pkt)
 {
     if (pkt) {
@@ -208,6 +210,8 @@ void av_free_packet(AVPacket *pkt)
         av_packet_free_side_data(pkt);
     }
 }
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
                                  int size)
index 7fb4bde23846b2e0e03f6a4313ba738c0f545c23..1f32928cb346b7a06f507125d153e20355ad732f 100644 (file)
@@ -406,7 +406,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
     return 0;
 
 memfail:
-    av_free_packet(pkt);
+    av_packet_unref(pkt);
     av_freep(&buf2);
     av_freep(&state);
     av_freep(&zero);
index 4b24ca6292b379a2384e71941197875f98282e80..e7473748c1afad7dd8a9995cffeaf5301f9b3bfe 100644 (file)
@@ -811,7 +811,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         return 0;
     } else {
         if (!user_packet)
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
         if (!xerr)
             return 0;
         av_log(avctx, AV_LOG_ERROR,
index 44c93953c3d6a0a4e8e1ab398e224997f36f2843..ab4fb32bed7eac5979ab8add8b88962729856ee7 100644 (file)
@@ -1146,7 +1146,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame)
         return ret;
 
     ret = pkt.size;
-    av_free_packet(&pkt);
+    av_packet_unref(&pkt);
     return ret;
 }
 
index 63f09ff15b550d275142816a39ed78c8e81b2f05..ad00a9215aaa4c1452154c7b22f0b080ea5108e5 100644 (file)
@@ -1200,7 +1200,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
     *got_packet_ptr = 0;
 
     if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
-        av_free_packet(avpkt);
+        av_packet_unref(avpkt);
         av_init_packet(avpkt);
         return 0;
     }
@@ -1276,7 +1276,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
     }
 
     if (ret < 0 || !*got_packet_ptr) {
-        av_free_packet(avpkt);
+        av_packet_unref(avpkt);
         av_init_packet(avpkt);
         goto end;
     }
@@ -1307,7 +1307,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
     *got_packet_ptr = 0;
 
     if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
-        av_free_packet(avpkt);
+        av_packet_unref(avpkt);
         av_init_packet(avpkt);
         avpkt->size = 0;
         return 0;
@@ -1335,7 +1335,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
     }
 
     if (ret < 0 || !*got_packet_ptr)
-        av_free_packet(avpkt);
+        av_packet_unref(avpkt);
 
     emms_c();
     return ret;
index 22b0f3df57cd45c45a7ecf2304e15ee27dca0ff5..bd75525ec61cbf8fc965f65f1df2c332a5825f0d 100644 (file)
@@ -29,7 +29,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR  7
+#define LIBAVCODEC_VERSION_MINOR  8
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
 #ifndef FF_API_AVPICTURE
 #define FF_API_AVPICTURE         (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_AVPACKET_OLD_API
+#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
index 2cc5b7d5746e338024b899c181b925ce70020de7..e7819ec18a78d83d7b700d7f0bfff4a127c63446 100644 (file)
@@ -128,14 +128,14 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
 
     while ((res = snd_pcm_readi(s->h, pkt->data, pkt->size / s->frame_size)) < 0) {
         if (res == -EAGAIN) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
 
             return AVERROR(EAGAIN);
         }
         if (ff_alsa_xrun_recover(s1, res) < 0) {
             av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",
                    snd_strerror(res));
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
 
             return AVERROR(EIO);
         }
index aa9348df092755cabb9d4c1d9f25a41fe9482c8d..24c23e8c8415a52c8aad1566b28aac49e14380ff 100644 (file)
@@ -220,7 +220,7 @@ static void free_pkt_fifo(AVFifoBuffer *fifo)
     AVPacket pkt;
     while (av_fifo_size(fifo)) {
         av_fifo_generic_read(fifo, &pkt, sizeof(pkt), NULL);
-        av_free_packet(&pkt);
+        av_packet_unref(&pkt);
     }
     av_fifo_free(fifo);
 }
index 3f786cc356b6db94055adac56667915a75ec4647..24d357110c789569f4581ee690bfddef9da1263c 100644 (file)
@@ -82,7 +82,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
 
     ret = read(s->fd, pkt->data, pkt->size);
     if (ret <= 0){
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         pkt->size = 0;
         if (ret<0)  return AVERROR(errno);
         else        return AVERROR_EOF;
index aaff4478d43f0e4d6a9e2eb455b7f83cd1f8409e..0e8bd09e15bd7599cfa059ae4c0b2e188f316b16 100644 (file)
@@ -133,7 +133,7 @@ static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
     if ((pa_simple_read(pd->s, pkt->data, pkt->size, &res)) < 0) {
         av_log(s, AV_LOG_ERROR, "pa_simple_read failed: %s\n",
                pa_strerror(res));
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index 7ebb8c3ccc19bb5adf367cd58db621e4b701df5e..5d40a7a5e2f74c033a18aa0dc171f6721de75005 100644 (file)
@@ -67,7 +67,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
 
     ret = sio_read(s->hdl, pkt->data, pkt->size);
     if (ret == 0 || sio_eof(s->hdl)) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR_EOF;
     }
 
index 40eabc4f214cb6c6e8df93b98f6ea2f783ce8814..41dc0a12f8e3c447137225d3dc9fd9f7f2edbb13 100644 (file)
@@ -508,7 +508,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
         if (res < 0) {
             res = AVERROR(errno);
             av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF)\n");
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return res;
         }
         avpriv_atomic_int_add_and_fetch(&s->buffers_queued, 1);
index 154f550b0099e8c8965d30c1f744fbe515bcd4ee..cc73e82bd00dfcb0232714cecbee9fdc74fb01c6 100644 (file)
@@ -233,7 +233,7 @@ static int vfw_read_close(AVFormatContext *s)
     pktl = ctx->pktl;
     while (pktl) {
         AVPacketList *next = pktl->next;
-        av_free_packet(&pktl->pkt);
+        av_packet_unref(&pktl->pkt);
         av_free(pktl);
         pktl = next;
     }
index a99be3975880734bd4cdde96aea369ba15a081be..850788c12be42ad0f2b6bcf58490a4cb352e1c88 100644 (file)
@@ -230,13 +230,13 @@ static int movie_get_frame(AVFilterLink *outlink)
                         movie->frame->sample_aspect_ratio.num,
                         movie->frame->sample_aspect_ratio.den);
                 // We got it. Free the packet since we are returning
-                av_free_packet(&pkt);
+                av_packet_unref(&pkt);
 
                 return 0;
             }
         }
         // Free the packet that was allocated by av_read_frame
-        av_free_packet(&pkt);
+        av_packet_unref(&pkt);
     }
 
     // On multi-frame source we should stop the mixing process when
index 2952a2172abb67d2c00c71c2fc43a58e2924c550..5eaf9851b7b96380d4159553e6b39a79f24f9a8f 100644 (file)
@@ -308,7 +308,7 @@ static int fourxm_read_packet(AVFormatContext *s,
             ret = avio_read(s->pb, &pkt->data[8], size);
 
             if (ret < 0) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
             } else
                 packet_read = 1;
             break;
index bce0493b799ea517cbacae6ec0c73653fbc9aeaa..c7bd33ab8be10874b2b168e31372773ac10e5a8a 100644 (file)
@@ -47,11 +47,11 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret != size) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
     if (AV_RB16(pkt->data) & 0x8000) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR_EOF;
     }
     pkt->size     = size;
index afd062ee36f47c5bbf3ab1bdc8d8ba73f2e5d7ca..b57a5685258377f60b2f446197f0c34231cf14fb 100644 (file)
@@ -148,7 +148,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
     read              = avio_read(s->pb, pkt->data + 1, size - 1);
 
     if (read != size - 1) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index a39f6d4c219e12ec69ce1a5ea169bc5d8574da50..e1b0b8c67bd78f465ec64931ff53314f92fc3a84 100644 (file)
@@ -444,7 +444,7 @@ static int asf_read_picture(AVFormatContext *s, int len)
 
 fail:
     av_freep(&desc);
-    av_free_packet(&pkt);
+    av_packet_unref(&pkt);
     return ret;
 }
 
@@ -1128,7 +1128,7 @@ static void reset_packet(ASFPacket *asf_pkt)
     asf_pkt->flags     = 0;
     asf_pkt->dts       = 0;
     asf_pkt->duration  = 0;
-    av_free_packet(&asf_pkt->avpkt);
+    av_packet_unref(&asf_pkt->avpkt);
     av_init_packet(&asf_pkt->avpkt);
 }
 
@@ -1395,7 +1395,7 @@ static int asf_deinterleave(AVFormatContext *s, ASFPacket *asf_pkt, int st_num)
         if (p > asf_pkt->avpkt.data + asf_pkt->data_size)
             break;
     }
-    av_free_packet(&asf_pkt->avpkt);
+    av_packet_unref(&asf_pkt->avpkt);
     asf_pkt->avpkt = pkt;
 
     return 0;
@@ -1485,7 +1485,7 @@ static int asf_read_close(AVFormatContext *s)
     for (i = 0; i < ASF_MAX_STREAMS; i++) {
         av_dict_free(&asf->asf_sd[i].asf_met);
         if (i < asf->nb_streams) {
-            av_free_packet(&asf->asf_st[i]->pkt.avpkt);
+            av_packet_unref(&asf->asf_st[i]->pkt.avpkt);
             av_freep(&asf->asf_st[i]);
         }
     }
@@ -1521,7 +1521,7 @@ static void reset_packet_state(AVFormatContext *s)
         pkt->flags     = 0;
         pkt->dts       = 0;
         pkt->duration  = 0;
-        av_free_packet(&pkt->avpkt);
+        av_packet_unref(&pkt->avpkt);
         av_init_packet(&pkt->avpkt);
     }
 }
@@ -1588,11 +1588,11 @@ static int64_t asf_read_timestamp(AVFormatContext *s, int stream_index,
         }
         if (st_found)
             break;
-        av_free_packet(&pkt);
+        av_packet_unref(&pkt);
     }
     *pos = pkt_pos;
 
-    av_free_packet(&pkt);
+    av_packet_unref(&pkt);
     return dts;
 }
 
index 143a98639cc3644f9b59e54d2396fc5ced71ca8a..470bbc60172ba927303acf791c97ad0637b51eac 100644 (file)
  * until the next av_read_frame() call or closing the file. If the caller
  * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy
  * of it.
- * In both cases, the packet must be freed with av_free_packet() when it is no
+ * In both cases, the packet must be freed with av_packet_unref() when it is no
  * longer needed.
  *
  * @section lavf_decoding_seek Seeking
@@ -1491,7 +1491,7 @@ int av_find_best_stream(AVFormatContext *ic,
  * If pkt->buf is NULL, then the packet is valid until the next
  * av_read_frame() or until avformat_close_input(). Otherwise the packet
  * is valid indefinitely. In both cases the packet must be freed with
- * av_free_packet when it is no longer needed. For video, the packet contains
+ * av_packet_unref when it is no longer needed. For video, the packet contains
  * exactly one frame. For audio, it contains an integer number of frames if each
  * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames
  * have a variable size (e.g. MPEG audio), then it contains one frame.
index 63afe2f397dc73c4d756c7f99ba735bed55e9575..659bfa7b6d60e557d5457d069009db65532e04b4 100644 (file)
@@ -1215,7 +1215,7 @@ resync:
             pkt->buf    = avbuf;
             pkt->flags |= AV_PKT_FLAG_KEY;
             if (size < 0)
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
         } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
                    !st->codec->codec_tag && read_gab2_sub(st, pkt)) {
             ast->frame_offset++;
@@ -1470,7 +1470,7 @@ static void seek_subtitle(AVStream *st, AVStream *st2, int64_t timestamp)
 {
     AVIStream *ast2 = st2->priv_data;
     int64_t ts2     = av_rescale_q(timestamp, st->time_base, st2->time_base);
-    av_free_packet(&ast2->sub_pkt);
+    av_packet_unref(&ast2->sub_pkt);
     if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||
         avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)
         ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
@@ -1587,7 +1587,7 @@ static int avi_read_close(AVFormatContext *s)
                 avformat_close_input(&ast->sub_ctx);
             }
             av_free(ast->sub_buffer);
-            av_free_packet(&ast->sub_pkt);
+            av_packet_unref(&ast->sub_pkt);
         }
     }
 
index d8042c51f9b05c1bec9b2d27e6064d8bde1fc274..74721b63c4b6c014f8e27e7bd0831934fd2c6ad9 100644 (file)
@@ -108,7 +108,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
     pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
     ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
     if (ret < size) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index fdb7a87a2a1116117313b914b69db317ecefe919..3ae99fcfc92015406047b6d31c4d692c4f82ccf6 100644 (file)
@@ -188,7 +188,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     return 0;
 
     fail:
-    av_free_packet(pkt);
+    av_packet_unref(pkt);
     return ret;
 }
 
index e6996919252f6e8cdc94f38626abe4d1651b1cf8..285bfaf35b271a1958d7e9df7558752b7eb0484b 100644 (file)
@@ -62,7 +62,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
         if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND)
             break;
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
     }
 
     if (!priv->got_first_packet) {
index a2cba526ca6b1a438556f6403e74a054f57a9ce2..366da4bf7c72765e885715a9dff44701257bc3a8 100644 (file)
@@ -146,7 +146,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
         memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
         ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
         if (ret < 0) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return ret;
         }
         av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);
index c097d72cf88df55a234972cb858eb63665fe76f0..03dca4f5c3e53a7adead6d09b02925b040e35785 100644 (file)
@@ -82,7 +82,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (!first) {
             ret = av_append_packet(pb, pkt, 12);
             if (ret < 0) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return ret;
             }
         } else
@@ -103,7 +103,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
         }
         ret = av_append_packet(pb, pkt, frame_size);
         if (ret < 0) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return ret;
         }
     }
index 6a7c8b948acc41ba305f2fb6e4bfad77ad292e4e..612289fd4f0c0d2e0abf09faf0edea52920a7860 100644 (file)
@@ -197,7 +197,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         ret = avio_read(pb, &pkt->data[4], pkt_size);
         if (ret < 0) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return ret;
         }
         if (ret < pkt_size)
index f7d0ead1c21c138e3eca98c370511c29054ab8a7..e9610dd1a1f80101b7cf9193e7c75220c75a97e1 100644 (file)
@@ -256,7 +256,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
     return pkt->size;
 
 error_eof:
-    av_free_packet(pkt);
+    av_packet_unref(pkt);
     return ret < 0 ? ret : AVERROR_EOF;
 }
 
@@ -294,7 +294,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
         ret = avio_read(s->pb, pkt->data + offset,
                         size2 - offset);
         if (ret < size2 - offset) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return ret < 0 ? ret : AVERROR_EOF;
         }
 
@@ -304,7 +304,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = avio_read(s->pb, pkt->data + offset, size - offset);
     if (ret < size - offset) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR_EOF;
     }
 
index 34085cf446fc106aee855bb0c15dd428b3913cab..7d04e7bfaad7c364314e3e924ba78016370ab710 100644 (file)
@@ -201,7 +201,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
             memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
             ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
             if(ret != size){
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return AVERROR(EIO);
             }
             if(pal_size) memcpy(pkt->data, pal, pal_size);
index 7c1fabee0f3dd64012b2bd76c5985407bd4c55ea..b3855b69a585d36c6095ee146da2d8222ee3abed 100644 (file)
@@ -567,7 +567,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt)
             case AV_CODEC_ID_ADPCM_EA_R3:
                 if (pkt->size < 4) {
                     av_log(s, AV_LOG_ERROR, "Packet is too short\n");
-                    av_free_packet(pkt);
+                    av_packet_unref(pkt);
                     return AVERROR_INVALIDDATA;
                 }
                 if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)
index 2eb6f057b40296faf95866490a427aef8222c917..277e12b20ce450469ef407ad0949c463fac52372 100644 (file)
@@ -228,7 +228,7 @@ static int flic_read_packet(AVFormatContext *s,
             ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
                 size - FLIC_PREAMBLE_SIZE);
             if (ret != size - FLIC_PREAMBLE_SIZE) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 ret = AVERROR(EIO);
             }
             packet_read = 1;
@@ -246,7 +246,7 @@ static int flic_read_packet(AVFormatContext *s,
             ret = avio_read(pb, pkt->data, size);
 
             if (ret != size) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 ret = AVERROR(EIO);
             }
 
index b67c07c4045c9afcbe45bba657c5f9b759fa6e65..716fbb9dd275ebee79657173c86249b8fd7c1934 100644 (file)
@@ -69,7 +69,7 @@ static int g723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = avio_read(s->pb, pkt->data + 1, size - 1);
     if (ret < size - 1) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR_EOF;
     }
 
index e73aa0ddab10d7f67ce663d961d03eff5453eeed..1bc7eed856bbfed392adb0a1877997e8544252f9 100644 (file)
@@ -45,7 +45,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret < GSM_BLOCK_SIZE) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
     pkt->size     = ret;
index be4720789b57563939c3d7607a35f8b9c5fece76..dc3ab87b8a9b511cdc3f4b91973dff3eb88f9ad1 100644 (file)
@@ -129,7 +129,7 @@ static void free_variant_list(HLSContext *c)
     for (i = 0; i < c->n_variants; i++) {
         struct variant *var = c->variants[i];
         free_segment_list(var);
-        av_free_packet(&var->pkt);
+        av_packet_unref(&var->pkt);
         av_free(var->pb.buffer);
         if (var->input)
             ffurl_close(var->input);
@@ -724,7 +724,7 @@ start:
                     c->seek_timestamp = AV_NOPTS_VALUE;
                     break;
                 }
-                av_free_packet(&var->pkt);
+                av_packet_unref(&var->pkt);
                 reset_packet(&var->pkt);
             }
         }
@@ -815,7 +815,7 @@ static int hls_read_seek(AVFormatContext *s, int stream_index,
             ffurl_close(var->input);
             var->input = NULL;
         }
-        av_free_packet(&var->pkt);
+        av_packet_unref(&var->pkt);
         reset_packet(&var->pkt);
         var->pb.eof_reached = 0;
         /* Clear any buffered data */
index 54ac6c2ce41113634c7e7a297f31640651663a98..31fc42e05d2268a10648dc58eb109b2d0a4b6439 100644 (file)
@@ -190,7 +190,7 @@ static int hnm_read_close(AVFormatContext *s)
     Hnm4DemuxContext *hnm = s->priv_data;
 
     if (hnm->vpkt.size > 0)
-        av_free_packet(&hnm->vpkt);
+        av_packet_unref(&hnm->vpkt);
 
     return 0;
 }
index 3aa0e3ea501de51be5c7eb4a0a3c90c6d9de80e8..32cba3adbafe6b63a1ac7110b75614d11b6cf673 100644 (file)
@@ -309,7 +309,7 @@ static int idcin_read_packet(AVFormatContext *s,
             return ret;
         else if (ret != chunk_size) {
             av_log(s, AV_LOG_ERROR, "incomplete packet\n");
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         if (command == 1) {
@@ -318,7 +318,7 @@ static int idcin_read_packet(AVFormatContext *s,
             pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
                                           AVPALETTE_SIZE);
             if (!pal) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             memcpy(pal, palette, AVPALETTE_SIZE);
index e44af487b24196eb447f85dd8cdc1a44a95cd780..5ed8899a9e0590f88e07131f55305d3ab6138cde 100644 (file)
@@ -112,7 +112,7 @@ static int ilbc_read_packet(AVFormatContext *s,
     pkt->pos = avio_tell(s->pb);
     pkt->duration = enc->block_align == 38 ? 160 : 240;
     if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
 
index fc6da1b7fe80dc80f4fa72b611415d22b82dacd7..eb2508738e23731ca37d098a3f07a678656a8e99 100644 (file)
@@ -280,7 +280,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
     }
 
     if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO); /* signal EOF */
     } else {
         s->img_count++;
index 42b29ef6e3cee87935c28d3cbf2661f567897bd7..2bb70e721f034a60e83e8c15eb3d91e5d07d8e1e 100644 (file)
@@ -51,7 +51,7 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->stream_index = 0;
     ret = avio_read(s->pb, pkt->data, size);
     if (ret < 0) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret;
     }
     pkt->size = ret;
index f08ad90038034557eda4a6eec1ad0480cc0e1db0..a65a3b7f1312c00f9e5712c4c851bd45e1d03172 100644 (file)
@@ -348,7 +348,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt);
  * Interleave a packet per dts in an output media file.
  *
  * Packets with pkt->destruct == av_destruct_packet will be freed inside this
- * function, so they cannot be used after it. Note that calling av_free_packet()
+ * function, so they cannot be used after it. Note that calling av_packet_unref()
  * on them is still safe.
  *
  * @param s media file handle
index fe8d97b548711f2c1eca12074ad7926e74af44e8..fb5124d68516824b4a01794ceefcbaba61490a0d 100644 (file)
@@ -180,7 +180,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
 
         if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
             s->decode_map_chunk_size) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return CHUNK_EOF;
         }
 
@@ -189,7 +189,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
 
         if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
             s->video_chunk_size) != s->video_chunk_size) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return CHUNK_EOF;
         }
 
index 56909e3a229ec8c0faead419e01fbe03337736ea..ad630b3eb4d80f8f004b9d975014eb277dd0decb 100644 (file)
@@ -92,7 +92,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
             ret = av_append_packet(s->pb, pkt, size);
             if (ret < 0) {
                 av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return ret;
             }
         }
index e25f82e0af33742bf5583da18adb442f37b5191e..2bbf0336640c87110674aa5f6fd8094b71e489dc 100644 (file)
@@ -315,7 +315,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
         return ret2;
 
     if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret2 < 0 ? ret2 : AVERROR_EOF;
     }
 
index caf127ff20646a27f1e408653465c84a2f351e4c..8296a41559661adcca62b065c662ac156b910dec 100644 (file)
@@ -1227,7 +1227,7 @@ static int matroska_merge_packets(AVPacket *out, AVPacket *in)
 
     memcpy(out->data + old_size, in->data, in->size);
 
-    av_free_packet(in);
+    av_packet_unref(in);
     av_free(in);
     return 0;
 }
@@ -1997,7 +1997,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska)
     if (matroska->packets) {
         int n;
         for (n = 0; n < matroska->num_packets; n++) {
-            av_free_packet(matroska->packets[n]);
+            av_packet_unref(matroska->packets[n]);
             av_free(matroska->packets[n]);
         }
         av_freep(&matroska->packets);
index 2e4d277ae96e6ea81de9892e91f200980aca5963..f1bd2726729699d5f301cdd00dcb59ce90c1db9b 100644 (file)
@@ -1597,7 +1597,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
     // check if we have an audio packet cached
     if (mkv->cur_audio_pkt.size > 0) {
         ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
-        av_free_packet(&mkv->cur_audio_pkt);
+        av_packet_unref(&mkv->cur_audio_pkt);
         if (ret < 0) {
             av_log(s, AV_LOG_ERROR,
                    "Could not write cached audio packet ret:%d\n", ret);
@@ -1653,7 +1653,7 @@ static int mkv_write_trailer(AVFormatContext *s)
     // check if we have an audio packet cached
     if (mkv->cur_audio_pkt.size > 0) {
         ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt);
-        av_free_packet(&mkv->cur_audio_pkt);
+        av_packet_unref(&mkv->cur_audio_pkt);
         if (ret < 0) {
             av_log(s, AV_LOG_ERROR,
                    "Could not write cached audio packet ret:%d\n", ret);
index 6fb63bf9ab4595c0759e62454a3d00553e702cc9..2150bd59115a0646a4ecbed281521829a5edb0cd 100644 (file)
@@ -292,7 +292,7 @@ static int mmf_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = avio_read(s->pb, pkt->data, pkt->size);
     if (ret < 0)
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
 
     mmf->data_size -= ret;
 
index 9cff9d33e77484465d5189f17b7663ea9d0ad66d..e4c6dbb2233c72cae65cce06f195eaf2454b354a 100644 (file)
@@ -341,7 +341,7 @@ static int mp3_queue_flush(AVFormatContext *s)
     while ((pktl = mp3->queue)) {
         if (write && (ret = mp3_write_audio_packet(s, &pktl->pkt)) < 0)
             write = 0;
-        av_free_packet(&pktl->pkt);
+        av_packet_unref(&pktl->pkt);
         mp3->queue = pktl->next;
         av_freep(&pktl);
     }
index ed8d73f7b0642aeef191d85e912b7b49e9836f51..e92cab62425a3fc38ea9e2a16ef2c9dc835a4c60 100644 (file)
@@ -167,7 +167,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
     if(c->curbits)
         avio_seek(s->pb, -4, SEEK_CUR);
     if(ret < size){
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret < 0 ? ret : AVERROR(EIO);
     }
     pkt->size = ret + 4;
@@ -218,7 +218,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
             c->curframe = lastframe;
             return ret;
         }
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
     }
     return 0;
 }
index e9e328882005d52035569a664305ccd9011d1ee2..01af597894f1c55199d14d26b7b52d7dc42ea5a6 100644 (file)
@@ -2162,7 +2162,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);
     pkt->pos = avio_tell(s->pb);
     if (ret < 0) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret;
     }
     if (data != pkt->data)
index 4bba970c9284c5e7130ad886041e8e95c129d791..e86d202713f3ff0434ed77accaa4ac46ff3fec54 100644 (file)
@@ -544,7 +544,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in
     if (s->oformat->interleave_packet) {
         int ret = s->oformat->interleave_packet(s, out, in, flush);
         if (in)
-            av_free_packet(in);
+            av_packet_unref(in);
         return ret;
     } else
         return ff_interleave_packet_per_dts(s, out, in, flush);
@@ -590,7 +590,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
         if (ret >= 0)
             s->streams[opkt.stream_index]->nb_frames++;
 
-        av_free_packet(&opkt);
+        av_packet_unref(&opkt);
 
         if (ret < 0)
             return ret;
@@ -616,7 +616,7 @@ int av_write_trailer(AVFormatContext *s)
         if (ret >= 0)
             s->streams[pkt.stream_index]->nb_frames++;
 
-        av_free_packet(&pkt);
+        av_packet_unref(&pkt);
 
         if (ret < 0)
             goto fail;
index f434b4a1a352bdd77b8690ca545d15acb34a861f..0f4155ab87fb02d66edc2cc226bf6bdd1c55fad9 100644 (file)
@@ -1855,7 +1855,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket
 
                 if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
                     s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
-                av_free_packet(&pktl->pkt);
+                av_packet_unref(&pktl->pkt);
                 av_freep(&pktl);
                 pktl = next;
             }
index 40d8dac3a7796f46e14c3282226318e707243c53..ee2aee36645ee5476e9b3deb4f290be0cda20876 100644 (file)
@@ -83,7 +83,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     ret = av_get_packet(s->pb, pkt, size);
     if (ret != size) {
-        if (ret > 0) av_free_packet(pkt);
+        if (ret > 0) av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index 7c8f9e3ad9858e2dd8509d3995968cfb61338bba..6e31d9b0b82b176ed36771a6383ffc8ce5e3e2f1 100644 (file)
@@ -711,9 +711,9 @@ static int nsv_read_close(AVFormatContext *s)
     av_freep(&nsv->nsvs_file_offset);
     av_freep(&nsv->nsvs_timestamps);
     if (nsv->ahead[0].data)
-        av_free_packet(&nsv->ahead[0]);
+        av_packet_unref(&nsv->ahead[0]);
     if (nsv->ahead[1].data)
-        av_free_packet(&nsv->ahead[1]);
+        av_packet_unref(&nsv->ahead[1]);
     return 0;
 }
 
index c9fa38aa5b96e5ee9b5ed2cb302ba76984c5ef93..aeb2fae46626172de32c0f043d5080021a58cc76 100644 (file)
@@ -276,7 +276,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt)
             memcpy(pkt->data, hdr, copyhdrsize);
             ret = avio_read(pb, pkt->data + copyhdrsize, size);
             if (ret < 0) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return ret;
             }
             if (ret < size)
index 573ef0a346649520009c5a80ae03116e203fbbf1..e1371c089e5b070882baca6447fed37912848f3e 100644 (file)
@@ -184,7 +184,7 @@ static int str_read_packet(AVFormatContext *s,
                 if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){
                     if(pkt->data)
                         av_log(s, AV_LOG_ERROR, "missmatching sector_count\n");
-                    av_free_packet(pkt);
+                    av_packet_unref(pkt);
                     if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE))
                         return AVERROR(EIO);
 
@@ -263,7 +263,7 @@ static int str_read_close(AVFormatContext *s)
     int i;
     for(i=0; i<32; i++){
         if(str->channels[i].tmp_pkt.data)
-            av_free_packet(&str->channels[i].tmp_pkt);
+            av_packet_unref(&str->channels[i].tmp_pkt);
     }
 
     return 0;
index 74ca27230094212ae3c568d9fce74ba68c7271f5..5f2a39801a09f11362f101ec985ff36e98486b3d 100644 (file)
@@ -44,7 +44,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->stream_index = 0;
     ret = ffio_read_partial(s->pb, pkt->data, size);
     if (ret < 0) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret;
     } else if (ret < size) {
         /* initialize end of packet for partial reads to avoid reading
index a6544c3a60dfb5476aec29c0d9d796dcd7089254..51de3473da98d55d46efd9d933adbf04c36a7b4e 100644 (file)
@@ -245,7 +245,7 @@ static int rl2_read_packet(AVFormatContext *s,
     /** fill the packet */
     ret = av_get_packet(pb, pkt, sample->size);
     if(ret != sample->size){
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index 54ffc15a93a9e566a397c8c2daf3c0ab0f64e1f7..5110b0369c223e0e9439d1430c61c4e40a5aac18 100644 (file)
@@ -117,7 +117,7 @@ RMStream *ff_rm_alloc_rmstream (void)
 
 void ff_rm_free_rmstream (RMStream *rms)
 {
-    av_free_packet(&rms->pkt);
+    av_packet_unref(&rms->pkt);
 }
 
 static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
@@ -659,7 +659,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb,
     if((seq & 0x7F) == 1 || vst->curpic_num != pic_num){
         vst->slices = ((hdr & 0x3F) << 1) + 1;
         vst->videobufsize = len2 + 8*vst->slices + 1;
-        av_free_packet(&vst->pkt); //FIXME this should be output.
+        av_packet_unref(&vst->pkt); //FIXME this should be output.
         if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
             return AVERROR(ENOMEM);
         vst->videobufpos = 8*vst->slices + 1;
@@ -879,7 +879,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         if(  (st->discard >= AVDISCARD_NONKEY && !(flags&2))
            || st->discard >= AVDISCARD_ALL){
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
         } else
             break;
     }
index b72b8d0691e1180f17bab02e6602976a2655f662..fdcefdbf728484a5e15f28f719f2e29eea1cd1ee 100644 (file)
@@ -310,7 +310,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
 
         ret = av_get_packet(pb, pkt, frame_size);
         if (ret != frame_size) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
         pkt->duration = 1;
@@ -325,7 +325,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
     } else {
         ret = av_get_packet(pb, pkt, index_entry->size);
         if (ret != index_entry->size) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
 
index 597f29fae3338f47463692411676eca38177d6d0..10a4dcd8ab7970da3a1b9777d4c4687c93bd2738 100644 (file)
@@ -274,7 +274,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf,
                 return 1; // FIXME: return 0 if last packet
             }
         }
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
     }
 
     return res == 1 ? -1 : res;
index 022cfec31351ed0c4bbf837d2330082643e1d42b..a65e139cfcd76a74a0e5df3b1e1099abcfe5f605 100644 (file)
@@ -136,7 +136,7 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data,
             data->split_pos = 0;
             if (!data->split_buf) {
                 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             memcpy(data->split_buf, buf, data->split_buf_size);
index 002413dec22cdab6f3d4d85098cadf6c35c2899e..f87e8affc90822ef3ef14cf5efca04de4dad9cf7 100644 (file)
@@ -217,7 +217,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt,
             av_freep(&qt->pkt.data);
             qt->pkt.data = av_realloc(NULL, qt->remaining * qt->bytes_per_frame);
             if (!qt->pkt.data) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             qt->pkt.size = qt->remaining * qt->bytes_per_frame;
index 5e17181ff34df779637d008bbef8b8be4695e73b..c79cfeb7b531e73172013098ae15d69c4c35b6a5 100644 (file)
@@ -141,7 +141,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data,
                 data->split_buf = av_malloc(data->split_buf_size);
                 if (!data->split_buf) {
                     av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
-                    av_free_packet(pkt);
+                    av_packet_unref(pkt);
                     return AVERROR(ENOMEM);
                 }
             }
index 0280cead9cad3b741de91ada8aadca577f856747..f09222df3c731cecf5ec65e9183602a22d3b7b16 100644 (file)
@@ -215,7 +215,7 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
             int i = s->nb_streams;
             AVStream *st = avformat_new_stream(s, NULL);
             if (!st) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return AVERROR(ENOMEM);
             }
             st->id = i;
index 143f0b5ace46043c7b1d7284aec13ae5e454160b..97062d5dfca304ddc091a133f03780ff5a741e5e 100644 (file)
@@ -102,7 +102,7 @@ int main(int argc, char **argv)
                 ts_str(dts_buf, pkt.dts, st->time_base);
                 ts_str(ts_buf,  pkt.pts, st->time_base);
                 printf("ret:%-10s st:%2d flags:%d dts:%s pts:%s pos:%7" PRId64 " size:%6d", ret_str(ret), pkt.stream_index, pkt.flags, dts_buf, ts_buf, pkt.pos, pkt.size);
-                av_free_packet(&pkt);
+                av_packet_unref(&pkt);
             } else
                 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
             printf("\n");
index c6f9c035c586aab9ca913134cbc79712d3a1bbf7..9be07cbdfa54cbf186255692fcc45bd10eccbd7a 100644 (file)
@@ -271,7 +271,7 @@ static int vmd_read_packet(AVFormatContext *s,
             frame->frame_size);
 
     if (ret != frame->frame_size) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         ret = AVERROR(EIO);
     }
     pkt->stream_index = frame->stream_index;
index 2fb94773a56f8429d934a200ba25ee3686fe319f..a28adf8224671982d3b42454d8599bb50fabfc7d 100644 (file)
@@ -188,7 +188,7 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
     pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;
 
     if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR_EOF;
     }
     ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
@@ -196,7 +196,7 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret = spdif_get_offset_and_codec(s, data_type, pkt->data,
                                      &offset, &codec_id);
     if (ret) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return ret;
     }
 
@@ -207,7 +207,7 @@ static int spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
         /* first packet, create a stream */
         AVStream *st = avformat_new_stream(s, NULL);
         if (!st) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return AVERROR(ENOMEM);
         }
         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
index e8ca04f939e68f194f99af77f53dc4be65714692..18d4afea24d333acab5f2b61b7b840d43aa05714 100644 (file)
@@ -168,7 +168,7 @@ static int thp_read_packet(AVFormatContext *s,
 
         ret = av_get_packet(pb, pkt, size);
         if (ret != size) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
 
@@ -176,7 +176,7 @@ static int thp_read_packet(AVFormatContext *s,
     } else {
         ret = av_get_packet(pb, pkt, thp->audiosize);
         if (ret != thp->audiosize) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return AVERROR(EIO);
         }
 
index fd96b9d959af707feb05b080c8c70272c4e2feaf..94ee9d92f175ba0cf6a9fb668b9c21e815b20dc3 100644 (file)
@@ -110,7 +110,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size)
 
     pkt->pos = orig_pos;
     if (!pkt->size)
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
     return pkt->size > orig_size ? pkt->size - orig_size : ret;
 }
 
@@ -426,7 +426,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
             av_log(s, AV_LOG_WARNING,
                    "Dropped corrupted packet (stream = %d)\n",
                    pkt->stream_index);
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             continue;
         }
 
@@ -756,7 +756,7 @@ static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_en
     while (*pkt_buf) {
         AVPacketList *pktl = *pkt_buf;
         *pkt_buf = pktl->next;
-        av_free_packet(&pktl->pkt);
+        av_packet_unref(&pktl->pkt);
         av_freep(&pktl);
     }
     *pkt_buf_end = NULL;
@@ -845,7 +845,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
             goto fail;
 
         if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {
-            av_free_packet(&out_pkt);
+            av_packet_unref(&out_pkt);
             ret = AVERROR(ENOMEM);
             goto fail;
         }
@@ -858,7 +858,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
     }
 
 fail:
-    av_free_packet(pkt);
+    av_packet_unref(pkt);
     return ret;
 }
 
@@ -949,7 +949,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                 return ret;
         } else {
             /* free packet */
-            av_free_packet(&cur_pkt);
+            av_packet_unref(&cur_pkt);
         }
     }
 
@@ -1450,7 +1450,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index,
             } while (read_status == AVERROR(EAGAIN));
             if (read_status < 0)
                 break;
-            av_free_packet(&pkt);
+            av_packet_unref(&pkt);
             if (stream_index == pkt.stream_index)
                 if ((pkt.flags & AV_PKT_FLAG_KEY) && pkt.dts > timestamp)
                     break;
@@ -1752,7 +1752,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
                         st->duration = duration;
                 }
             }
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
         }
     } while (end_time == AV_NOPTS_VALUE &&
              filesize > (DURATION_MAX_READ_SIZE << retry) &&
@@ -2461,7 +2461,7 @@ void avformat_free_context(AVFormatContext *s)
             av_parser_close(st->parser);
         }
         if (st->attached_pic.data)
-            av_free_packet(&st->attached_pic);
+            av_packet_unref(&st->attached_pic);
         av_dict_free(&st->metadata);
         av_freep(&st->probe_data.buf);
         av_free(st->index_entries);
index 49895c03a8c68de177cd8b416fd6c4fb03bf617f..baff8fcb53ae16319a42458deea6fb3da756261b 100644 (file)
@@ -243,7 +243,7 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
     ret = avio_read(s->pb, pkt->data+2, size);
 
     if (ret<=0) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
 
index c8942537cb281764e07ceda804ba4beb807dd8a8..c673fad6df5662d17b5f2a4dfc4e980fa0bc1892 100644 (file)
@@ -288,7 +288,7 @@ static int wc3_read_close(AVFormatContext *s)
     Wc3DemuxContext *wc3 = s->priv_data;
 
     if (wc3->vpkt.size > 0)
-        av_free_packet(&wc3->vpkt);
+        av_packet_unref(&wc3->vpkt);
 
     return 0;
 }
index 1f2359e83da2a9684b4bef4370acdbc71fc02c50..4323914675a33c4dabee46357756eae8a79dfa5c 100644 (file)
@@ -184,7 +184,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
                 return AVERROR(EIO);
             ret = avio_read(pb, pkt->data, chunk_size);
             if (ret != chunk_size) {
-                av_free_packet(pkt);
+                av_packet_unref(pkt);
                 return AVERROR(EIO);
             }
 
index 75eddd2f50a3695759d7af41372c427f8f9e2406..e9a2a6227e5519e582aa47c1d53c20c51c46eae3 100644 (file)
@@ -269,25 +269,25 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt)
     memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
     ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
     if (ret != wc->header.blocksize) {
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
         return AVERROR(EIO);
     }
     while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
         if ((ret = wv_read_block_header(s, s->pb)) < 0) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return ret;
         }
 
         off = pkt->size;
         if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return ret;
         }
         memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);
 
         ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);
         if (ret != wc->header.blocksize) {
-            av_free_packet(pkt);
+            av_packet_unref(pkt);
             return (ret < 0) ? ret : AVERROR_EOF;
         }
     }
@@ -334,7 +334,7 @@ static int wv_read_seek(AVFormatContext *s, int stream_index,
             return ret;
         }
         pts = pkt->pts;
-        av_free_packet(pkt);
+        av_packet_unref(pkt);
     } while(pts < timestamp);
     return 0;
 }
index 1e429d344a5aef1d1847d0f131f5019113eafb7b..933c57d7577e17cac4aaea617b3a4ce75cd45c7a 100644 (file)
@@ -168,14 +168,14 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
     return yop->audio_block_length;
 
 err_out:
-    av_free_packet(&yop->video_packet);
+    av_packet_unref(&yop->video_packet);
     return ret;
 }
 
 static int yop_read_close(AVFormatContext *s)
 {
     YopDecContext *yop = s->priv_data;
-    av_free_packet(&yop->video_packet);
+    av_packet_unref(&yop->video_packet);
     return 0;
 }
 
@@ -200,7 +200,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index,
     if (avio_seek(s->pb, frame_pos, SEEK_SET) < 0)
         return -1;
 
-    av_free_packet(&yop->video_packet);
+    av_packet_unref(&yop->video_packet);
     yop->odd_frame = timestamp & 1;
 
     return 0;
index c6398fe517a3b556f4c5f0f5eea1dc8d11b6a83f..d71a6b5742cad40ae5a719dfd623ece9d8cf77da 100644 (file)
@@ -122,7 +122,7 @@ int main(int argc, char **argv)
             }
             close(fd);
         }
-        av_free_packet(&pkt);
+        av_packet_unref(&pkt);
         pktnum++;
         if (maxpkts && (pktnum >= maxpkts))
             break;