History

Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'

* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457': avpacket: Replace av_free_packet with av_packet_unref

Hendrik Leppkes committed 11 years ago

Commit 7f5af802 parents 856b19d ce70f2873 files · +154 −138Browse files

Unified · Split

73 files
  1. doc/APIchanges +4 −0
  2. doc/examples/decoding_encoding.c +3 −3
  3. doc/examples/transcode_aac.c +5 −5
  4. libavcodec/avcodec.h +19 −14
  5. libavcodec/avpacket.c +5 −1
  6. libavcodec/jpeglsenc.c +1 −1
  7. libavcodec/libxvid.c +1 −1
  8. libavcodec/mpegvideo_enc.c +1 −1
  9. libavcodec/utils.c +4 −4
  10. libavcodec/version.h +4 −1
  11. libavdevice/alsa_dec.c +2 −2
  12. libavdevice/jack.c +1 −1
  13. libavdevice/oss_dec.c +1 −1
  14. libavdevice/sndio_dec.c +1 −1
  15. libavdevice/v4l2.c +1 −1
  16. libavdevice/vfwcap.c +1 −1
  17. libavformat/4xm.c +1 −1
  18. libavformat/adxdec.c +2 −2
  19. libavformat/amr.c +1 −1
  20. libavformat/asfdec_o.c +7 −7
  21. libavformat/avformat.h +2 −2
  22. libavformat/avidec.c +3 −3
  23. libavformat/avs.c +1 −1
  24. libavformat/c93.c +1 −1
  25. libavformat/cdg.c +1 −1
  26. libavformat/cdxl.c +1 −1
  27. libavformat/dfa.c +2 −2
  28. libavformat/dsicin.c +1 −1
  29. libavformat/dss.c +3 −3
  30. libavformat/dxa.c +1 −1
  31. libavformat/electronicarts.c +1 −1
  32. libavformat/flic.c +2 −2
  33. libavformat/g723_1.c +1 −1
  34. libavformat/gsmdec.c +1 −1
  35. libavformat/hls.c +3 −3
  36. libavformat/hnm.c +1 −1
  37. libavformat/idcin.c +2 −2
  38. libavformat/ilbc.c +1 −1
  39. libavformat/img2dec.c +1 −1
  40. libavformat/internal.h +1 −1
  41. libavformat/ipmovie.c +2 −2
  42. libavformat/iv8.c +1 −1
  43. libavformat/lxfdec.c +1 −1
  44. libavformat/matroskadec.c +1 −1
  45. libavformat/matroskaenc.c +2 −2
  46. libavformat/mp3enc.c +1 −1
  47. libavformat/mpc.c +2 −2
  48. libavformat/mpegts.c +1 −1
  49. libavformat/mux.c +3 −3
  50. libavformat/mxfenc.c +1 −1
  51. libavformat/ncdec.c +1 −1
  52. libavformat/nsvdec.c +2 −2
  53. libavformat/nuv.c +1 −1
  54. libavformat/psxstr.c +2 −2
  55. libavformat/rawdec.c +1 −1
  56. libavformat/rl2.c +1 −1
  57. libavformat/rmdec.c +3 −3
  58. libavformat/rpl.c +2 −2
  59. libavformat/rtpdec_asf.c +1 −1
  60. libavformat/rtpdec_mpa_robust.c +1 −1
  61. libavformat/rtpdec_qt.c +1 −1
  62. libavformat/rtpdec_xiph.c +1 −1
  63. libavformat/sapdec.c +1 −1
  64. libavformat/seek-test.c +1 −1
  65. libavformat/sierravmd.c +1 −1
  66. libavformat/spdifdec.c +3 −3
  67. libavformat/thp.c +2 −2
  68. libavformat/utils.c +9 −9
  69. libavformat/vqf.c +1 −1
  70. libavformat/wc3movie.c +1 −1
  71. libavformat/wvdec.c +4 −4
  72. libavformat/yop.c +3 −3
  73. tools/pktdumper.c +1 −1
doc/APIchanges+4−0
@@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182015-10-27 - xxxxxxx - lavc 57.12.100 / 57.8.0 - avcodec.h
19 Deprecate av_free_packet(). Use av_packet_unref() as replacement,
20 it resets the packet in a more consistent way.
21
182015-10-22 - xxxxxxx - lavc 57.9.100 / lavc 57.5.0 - avcodec.h222015-10-22 - xxxxxxx - lavc 57.9.100 / lavc 57.5.0 - avcodec.h
19 Add data and linesize array to AVSubtitleRect, to be used instead of23 Add data and linesize array to AVSubtitleRect, to be used instead of
20 the ones from the embedded AVPicture.24 the ones from the embedded AVPicture.
doc/examples/decoding_encoding.c+3−3
@@ -225,7 +225,7 @@ static void audio_encode_example(const char *filename) · 224 unmodified lines
225 225
226 if (got_output) {226 if (got_output) {
227 fwrite(pkt.data, 1, pkt.size, f);227 fwrite(pkt.data, 1, pkt.size, f);
228 av_free_packet(&pkt);228 av_packet_unref(&pkt);
229 }229 }
230 }230 }
231 fclose(f);231 fclose(f);
@@ -454,7 +454,7 @@ static void video_encode_example(const char *filename, int codec_id) · 222 unmodified lines
454 if (got_output) {454 if (got_output) {
455 printf("Write frame %3d (size=%5d)\n", i, pkt.size);455 printf("Write frame %3d (size=%5d)\n", i, pkt.size);
456 fwrite(pkt.data, 1, pkt.size, f);456 fwrite(pkt.data, 1, pkt.size, f);
457 av_free_packet(&pkt);457 av_packet_unref(&pkt);
458 }458 }
459 }459 }
460 460
@@ -471,7 +471,7 @@ static void video_encode_example(const char *filename, int codec_id) · 10 unmodified lines
471 if (got_output) {471 if (got_output) {
472 printf("Write frame %3d (size=%5d)\n", i, pkt.size);472 printf("Write frame %3d (size=%5d)\n", i, pkt.size);
473 fwrite(pkt.data, 1, pkt.size, f);473 fwrite(pkt.data, 1, pkt.size, f);
474 av_free_packet(&pkt);474 av_packet_unref(&pkt);
475 }475 }
476 }476 }
477 477
doc/examples/transcode_aac.c+5−5
@@ -332,7 +332,7 @@ static int decode_audio_frame(AVFrame *frame, · 331 unmodified lines
332 data_present, &input_packet)) < 0) {332 data_present, &input_packet)) < 0) {
333 fprintf(stderr, "Could not decode frame (error '%s')\n",333 fprintf(stderr, "Could not decode frame (error '%s')\n",
334 get_error_text(error));334 get_error_text(error));
335 av_free_packet(&input_packet);335 av_packet_unref(&input_packet);
336 return error;336 return error;
337 }337 }
338 338
@@ -342,7 +342,7 @@ static int decode_audio_frame(AVFrame *frame, · 3 unmodified lines
342 */342 */
343 if (*finished && *data_present)343 if (*finished && *data_present)
344 *finished = 0;344 *finished = 0;
345 av_free_packet(&input_packet);345 av_packet_unref(&input_packet);
346 return 0;346 return 0;
347}347}
348 348
@@ -571,7 +571,7 @@ static int encode_audio_frame(AVFrame *frame, · 222 unmodified lines
571 frame, data_present)) < 0) {571 frame, data_present)) < 0) {
572 fprintf(stderr, "Could not encode frame (error '%s')\n",572 fprintf(stderr, "Could not encode frame (error '%s')\n",
573 get_error_text(error));573 get_error_text(error));
574 av_free_packet(&output_packet);574 av_packet_unref(&output_packet);
575 return error;575 return error;
576 }576 }
577 577
@@ -580,11 +580,11 @@ static int encode_audio_frame(AVFrame *frame, · 2 unmodified lines
580 if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {580 if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
581 fprintf(stderr, "Could not write frame (error '%s')\n",581 fprintf(stderr, "Could not write frame (error '%s')\n",
582 get_error_text(error));582 get_error_text(error));
583 av_free_packet(&output_packet);583 av_packet_unref(&output_packet);
584 return error;584 return error;
585 }585 }
586 586
587 av_free_packet(&output_packet);587 av_packet_unref(&output_packet);
588 }588 }
589 589
590 return 0;590 return 0;
libavcodec/avcodec.h+19−14
@@ -1367,15 +1367,19 @@ typedef struct AVPacketSideData { · 1366 unmodified lines
1367 * ABI. Thus it may be allocated on stack and no new fields can be added to it1367 * ABI. Thus it may be allocated on stack and no new fields can be added to it
1368 * without libavcodec and libavformat major bump.1368 * without libavcodec and libavformat major bump.
1369 *1369 *
1370 * The semantics of data ownership depends on the buf or destruct (deprecated)1370 * The semantics of data ownership depends on the buf field.
1371 * fields. If either is set, the packet data is dynamically allocated and is1371 * If it is set, the packet data is dynamically allocated and is
1372 * valid indefinitely until av_free_packet() is called (which in turn calls1372 * valid indefinitely until a call to av_packet_unref() reduces the
1373 * av_buffer_unref()/the destruct callback to free the data). If neither is set,1373 * reference count to 0.
1374 * the packet data is typically backed by some static buffer somewhere and is
1375 * only valid for a limited time (e.g. until the next read call when demuxing).
1376 *1374 *
1377 * The side data is always allocated with av_malloc() and is freed in1375 * If the buf field is not set av_packet_ref() would make a copy instead
1378 * av_free_packet().1376 * of increasing the reference count.
1377 *
1378 * The side data is always allocated with av_malloc(), copied by
1379 * av_packet_ref() and freed by av_packet_unref().
1380 *
1381 * @see av_packet_ref
1382 * @see av_packet_unref
1379 */1383 */
1380typedef struct AVPacket {1384typedef struct AVPacket {
1381 /**1385 /**
@@ -3899,7 +3903,7 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); · 2517 unmodified lines
3899 * packet is allocated if it was not really allocated.3903 * packet is allocated if it was not really allocated.
3900 */3904 */
3901int av_dup_packet(AVPacket *pkt);3905int av_dup_packet(AVPacket *pkt);
3902 3906#if FF_API_AVPACKET_OLD_API
3903/**3907/**
3904 * Copy packet, including contents3908 * Copy packet, including contents
3905 *3909 *
@@ -3917,10 +3921,13 @@ int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src); · 11 unmodified lines
3917/**3921/**
3918 * Free a packet.3922 * Free a packet.
3919 *3923 *
3924 * @deprecated Use av_packet_unref
3925 *
3920 * @param pkt packet to free3926 * @param pkt packet to free
3921 */3927 */
3928attribute_deprecated
3922void av_free_packet(AVPacket *pkt);3929void av_free_packet(AVPacket *pkt);
3923 3930#endif
3924/**3931/**
3925 * Allocate new information of a packet.3932 * Allocate new information of a packet.
3926 *3933 *
@@ -4563,8 +4570,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name); · 636 unmodified lines
4563 * of the output packet.4570 * of the output packet.
4564 *4571 *
4565 * If this function fails or produces no output, avpkt will be4572 * If this function fails or produces no output, avpkt will be
4566 * freed using av_free_packet() (i.e. avpkt->destruct will be4573 * freed using av_packet_unref().
4567 * called to free the user supplied buffer).
4568 * @param[in] frame AVFrame containing the raw audio data to be encoded.4574 * @param[in] frame AVFrame containing the raw audio data to be encoded.
4569 * May be NULL when flushing an encoder that has the4575 * May be NULL when flushing an encoder that has the
4570 * AV_CODEC_CAP_DELAY capability set.4576 * AV_CODEC_CAP_DELAY capability set.
@@ -4605,8 +4611,7 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, · 34 unmodified lines
4605 * caller, he is responsible for freeing it.4611 * caller, he is responsible for freeing it.
4606 *4612 *
4607 * If this function fails or produces no output, avpkt will be4613 * If this function fails or produces no output, avpkt will be
4608 * freed using av_free_packet() (i.e. avpkt->destruct will be4614 * freed using av_packet_unref().
4609 * called to free the user supplied buffer).
4610 * @param[in] frame AVFrame containing the raw video data to be encoded.4615 * @param[in] frame AVFrame containing the raw video data to be encoded.
4611 * May be NULL when flushing an encoder that has the4616 * May be NULL when flushing an encoder that has the
4612 * AV_CODEC_CAP_DELAY capability set.4617 * AV_CODEC_CAP_DELAY capability set.
libavcodec/avpacket.c+5−1
@@ -204,7 +204,7 @@ int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src) · 203 unmodified lines
204 return 0;204 return 0;
205 205
206failed_alloc:206failed_alloc:
207 av_free_packet(pkt);207 av_packet_unref(pkt);
208 return AVERROR(ENOMEM);208 return AVERROR(ENOMEM);
209}209}
210 210
@@ -234,6 +234,8 @@ void av_packet_free_side_data(AVPacket *pkt) · 23 unmodified lines
234 pkt->side_data_elems = 0;234 pkt->side_data_elems = 0;
235}235}
236 236
237#if FF_API_AVPACKET_OLD_API
238FF_DISABLE_DEPRECATION_WARNINGS
237void av_free_packet(AVPacket *pkt)239void av_free_packet(AVPacket *pkt)
238{240{
239 if (pkt) {241 if (pkt) {
@@ -245,6 +247,8 @@ void av_free_packet(AVPacket *pkt) · 5 unmodified lines
245 av_packet_free_side_data(pkt);247 av_packet_free_side_data(pkt);
246 }248 }
247}249}
250FF_ENABLE_DEPRECATION_WARNINGS
251#endif
248 252
249uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,253uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
250 int size)254 int size)
libavcodec/jpeglsenc.c+1−1
@@ -405,7 +405,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 404 unmodified lines
405 return 0;405 return 0;
406 406
407memfail:407memfail:
408 av_free_packet(pkt);408 av_packet_unref(pkt);
409 av_freep(&buf2);409 av_freep(&buf2);
410 av_freep(&state);410 av_freep(&state);
411 av_freep(&zero);411 av_freep(&zero);
libavcodec/libxvid.c+1−1
@@ -841,7 +841,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 840 unmodified lines
841 return 0;841 return 0;
842 } else {842 } else {
843 if (!user_packet)843 if (!user_packet)
844 av_free_packet(pkt);844 av_packet_unref(pkt);
845 if (!xerr)845 if (!xerr)
846 return 0;846 return 0;
847 av_log(avctx, AV_LOG_ERROR,847 av_log(avctx, AV_LOG_ERROR,
libavcodec/mpegvideo_enc.c+1−1
@@ -1320,7 +1320,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame) · 1319 unmodified lines
1320 return ret;1320 return ret;
1321 1321
1322 ret = pkt.size;1322 ret = pkt.size;
1323 av_free_packet(&pkt);1323 av_packet_unref(&pkt);
1324 return ret;1324 return ret;
1325}1325}
1326 1326
libavcodec/utils.c+4−4
@@ -1693,7 +1693,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, · 1692 unmodified lines
1693 *got_packet_ptr = 0;1693 *got_packet_ptr = 0;
1694 1694
1695 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {1695 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
1696 av_free_packet(avpkt);1696 av_packet_unref(avpkt);
1697 av_init_packet(avpkt);1697 av_init_packet(avpkt);
1698 return 0;1698 return 0;
1699 }1699 }
@@ -1799,7 +1799,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, · 99 unmodified lines
1799 }1799 }
1800 1800
1801 if (ret < 0 || !*got_packet_ptr) {1801 if (ret < 0 || !*got_packet_ptr) {
1802 av_free_packet(avpkt);1802 av_packet_unref(avpkt);
1803 av_init_packet(avpkt);1803 av_init_packet(avpkt);
1804 goto end;1804 goto end;
1805 }1805 }
@@ -1839,7 +1839,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, · 33 unmodified lines
1839 avctx->stats_out[0] = '\0';1839 avctx->stats_out[0] = '\0';
1840 1840
1841 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {1841 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
1842 av_free_packet(avpkt);1842 av_packet_unref(avpkt);
1843 av_init_packet(avpkt);1843 av_init_packet(avpkt);
1844 avpkt->size = 0;1844 avpkt->size = 0;
1845 return 0;1845 return 0;
@@ -1893,7 +1893,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, · 47 unmodified lines
1893 }1893 }
1894 1894
1895 if (ret < 0 || !*got_packet_ptr)1895 if (ret < 0 || !*got_packet_ptr)
1896 av_free_packet(avpkt);1896 av_packet_unref(avpkt);
1897 1897
1898 emms_c();1898 emms_c();
1899 return ret;1899 return ret;
libavcodec/version.h+4−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29#include "libavutil/version.h"29#include "libavutil/version.h"
30 30
31#define LIBAVCODEC_VERSION_MAJOR 5731#define LIBAVCODEC_VERSION_MAJOR 57
32#define LIBAVCODEC_VERSION_MINOR 1132#define LIBAVCODEC_VERSION_MINOR 12
33#define LIBAVCODEC_VERSION_MICRO 10033#define LIBAVCODEC_VERSION_MICRO 100
34 34
35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -191,5 +191,8 @@ · 155 unmodified lines
191#ifndef FF_API_AVPICTURE191#ifndef FF_API_AVPICTURE
192#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)192#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
193#endif193#endif
194#ifndef FF_API_AVPACKET_OLD_API
195#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
196#endif
194 197
195#endif /* AVCODEC_VERSION_H */198#endif /* AVCODEC_VERSION_H */
libavdevice/alsa_dec.c+2−2
@@ -111,14 +111,14 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 110 unmodified lines
111 111
112 while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) {112 while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) {
113 if (res == -EAGAIN) {113 if (res == -EAGAIN) {
114 av_free_packet(pkt);114 av_packet_unref(pkt);
115 115
116 return AVERROR(EAGAIN);116 return AVERROR(EAGAIN);
117 }117 }
118 if (ff_alsa_xrun_recover(s1, res) < 0) {118 if (ff_alsa_xrun_recover(s1, res) < 0) {
119 av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",119 av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",
120 snd_strerror(res));120 snd_strerror(res));
121 av_free_packet(pkt);121 av_packet_unref(pkt);
122 122
123 return AVERROR(EIO);123 return AVERROR(EIO);
124 }124 }
libavdevice/jack.c+1−1
@@ -218,7 +218,7 @@ static void free_pkt_fifo(AVFifoBuffer **fifo) · 217 unmodified lines
218 AVPacket pkt;218 AVPacket pkt;
219 while (av_fifo_size(*fifo)) {219 while (av_fifo_size(*fifo)) {
220 av_fifo_generic_read(*fifo, &pkt, sizeof(pkt), NULL);220 av_fifo_generic_read(*fifo, &pkt, sizeof(pkt), NULL);
221 av_free_packet(&pkt);221 av_packet_unref(&pkt);
222 }222 }
223 av_fifo_freep(fifo);223 av_fifo_freep(fifo);
224}224}
libavdevice/oss_dec.c+1−1
@@ -84,7 +84,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 83 unmodified lines
84 84
85 ret = read(s->fd, pkt->data, pkt->size);85 ret = read(s->fd, pkt->data, pkt->size);
86 if (ret <= 0){86 if (ret <= 0){
87 av_free_packet(pkt);87 av_packet_unref(pkt);
88 pkt->size = 0;88 pkt->size = 0;
89 if (ret<0) return AVERROR(errno);89 if (ret<0) return AVERROR(errno);
90 else return AVERROR_EOF;90 else return AVERROR_EOF;
libavdevice/sndio_dec.c+1−1
@@ -67,7 +67,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 66 unmodified lines
67 67
68 ret = sio_read(s->hdl, pkt->data, pkt->size);68 ret = sio_read(s->hdl, pkt->data, pkt->size);
69 if (ret == 0 || sio_eof(s->hdl)) {69 if (ret == 0 || sio_eof(s->hdl)) {
70 av_free_packet(pkt);70 av_packet_unref(pkt);
71 return AVERROR_EOF;71 return AVERROR_EOF;
72 }72 }
73 73
libavdevice/v4l2.c+1−1
@@ -550,7 +550,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt) · 549 unmodified lines
550 550
551 res = enqueue_buffer(s, &buf);551 res = enqueue_buffer(s, &buf);
552 if (res) {552 if (res) {
553 av_free_packet(pkt);553 av_packet_unref(pkt);
554 return res;554 return res;
555 }555 }
556 } else {556 } else {
libavdevice/vfwcap.c+1−1
@@ -234,7 +234,7 @@ static int vfw_read_close(AVFormatContext *s) · 233 unmodified lines
234 pktl = ctx->pktl;234 pktl = ctx->pktl;
235 while (pktl) {235 while (pktl) {
236 AVPacketList *next = pktl->next;236 AVPacketList *next = pktl->next;
237 av_free_packet(&pktl->pkt);237 av_packet_unref(&pktl->pkt);
238 av_free(pktl);238 av_free(pktl);
239 pktl = next;239 pktl = next;
240 }240 }
libavformat/4xm.c+1−1
@@ -321,7 +321,7 @@ static int fourxm_read_packet(AVFormatContext *s, · 320 unmodified lines
321 ret = avio_read(s->pb, &pkt->data[8], size);321 ret = avio_read(s->pb, &pkt->data[8], size);
322 322
323 if (ret < 0) {323 if (ret < 0) {
324 av_free_packet(pkt);324 av_packet_unref(pkt);
325 } else {325 } else {
326 packet_read = 1;326 packet_read = 1;
327 av_shrink_packet(pkt, ret + 8);327 av_shrink_packet(pkt, ret + 8);
libavformat/adxdec.c+2−2
@@ -52,11 +52,11 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt) · 51 unmodified lines
52 52
53 ret = av_get_packet(s->pb, pkt, size);53 ret = av_get_packet(s->pb, pkt, size);
54 if (ret != size) {54 if (ret != size) {
55 av_free_packet(pkt);55 av_packet_unref(pkt);
56 return ret < 0 ? ret : AVERROR(EIO);56 return ret < 0 ? ret : AVERROR(EIO);
57 }57 }
58 if (AV_RB16(pkt->data) & 0x8000) {58 if (AV_RB16(pkt->data) & 0x8000) {
59 av_free_packet(pkt);59 av_packet_unref(pkt);
60 return AVERROR_EOF;60 return AVERROR_EOF;
61 }61 }
62 pkt->size = size;62 pkt->size = size;
libavformat/amr.c+1−1
@@ -155,7 +155,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) · 154 unmodified lines
155 read = avio_read(s->pb, pkt->data + 1, size - 1);155 read = avio_read(s->pb, pkt->data + 1, size - 1);
156 156
157 if (read != size - 1) {157 if (read != size - 1) {
158 av_free_packet(pkt);158 av_packet_unref(pkt);
159 return AVERROR(EIO);159 return AVERROR(EIO);
160 }160 }
161 161
libavformat/asfdec_o.c+7−7
@@ -444,7 +444,7 @@ static int asf_read_picture(AVFormatContext *s, int len) · 443 unmodified lines
444 444
445fail:445fail:
446 av_freep(&desc);446 av_freep(&desc);
447 av_free_packet(&pkt);447 av_packet_unref(&pkt);
448 return ret;448 return ret;
449}449}
450 450
@@ -1128,7 +1128,7 @@ static void reset_packet(ASFPacket *asf_pkt) · 677 unmodified lines
1128 asf_pkt->flags = 0;1128 asf_pkt->flags = 0;
1129 asf_pkt->dts = 0;1129 asf_pkt->dts = 0;
1130 asf_pkt->duration = 0;1130 asf_pkt->duration = 0;
1131 av_free_packet(&asf_pkt->avpkt);1131 av_packet_unref(&asf_pkt->avpkt);
1132 av_init_packet(&asf_pkt->avpkt);1132 av_init_packet(&asf_pkt->avpkt);
1133}1133}
1134 1134
@@ -1395,7 +1395,7 @@ static int asf_deinterleave(AVFormatContext *s, ASFPacket *asf_pkt, int st_num) · 260 unmodified lines
1395 if (p > asf_pkt->avpkt.data + asf_pkt->data_size)1395 if (p > asf_pkt->avpkt.data + asf_pkt->data_size)
1396 break;1396 break;
1397 }1397 }
1398 av_free_packet(&asf_pkt->avpkt);1398 av_packet_unref(&asf_pkt->avpkt);
1399 asf_pkt->avpkt = pkt;1399 asf_pkt->avpkt = pkt;
1400 1400
1401 return 0;1401 return 0;
@@ -1485,7 +1485,7 @@ static int asf_read_close(AVFormatContext *s) · 83 unmodified lines
1485 for (i = 0; i < ASF_MAX_STREAMS; i++) {1485 for (i = 0; i < ASF_MAX_STREAMS; i++) {
1486 av_dict_free(&asf->asf_sd[i].asf_met);1486 av_dict_free(&asf->asf_sd[i].asf_met);
1487 if (i < asf->nb_streams) {1487 if (i < asf->nb_streams) {
1488 av_free_packet(&asf->asf_st[i]->pkt.avpkt);1488 av_packet_unref(&asf->asf_st[i]->pkt.avpkt);
1489 av_freep(&asf->asf_st[i]);1489 av_freep(&asf->asf_st[i]);
1490 }1490 }
1491 }1491 }
@@ -1521,7 +1521,7 @@ static void reset_packet_state(AVFormatContext *s) · 29 unmodified lines
1521 pkt->flags = 0;1521 pkt->flags = 0;
1522 pkt->dts = 0;1522 pkt->dts = 0;
1523 pkt->duration = 0;1523 pkt->duration = 0;
1524 av_free_packet(&pkt->avpkt);1524 av_packet_unref(&pkt->avpkt);
1525 av_init_packet(&pkt->avpkt);1525 av_init_packet(&pkt->avpkt);
1526 }1526 }
1527}1527}
@@ -1588,11 +1588,11 @@ static int64_t asf_read_timestamp(AVFormatContext *s, int stream_index, · 60 unmodified lines
1588 }1588 }
1589 if (st_found)1589 if (st_found)
1590 break;1590 break;
1591 av_free_packet(&pkt);1591 av_packet_unref(&pkt);
1592 }1592 }
1593 *pos = pkt_pos;1593 *pos = pkt_pos;
1594 1594
1595 av_free_packet(&pkt);1595 av_packet_unref(&pkt);
1596 return dts;1596 return dts;
1597}1597}
1598 1598
libavformat/avformat.h+2−2
@@ -165,7 +165,7 @@ · 164 unmodified lines
165 * until the next av_read_frame() call or closing the file. If the caller165 * until the next av_read_frame() call or closing the file. If the caller
166 * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy166 * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy
167 * of it.167 * of it.
168 * In both cases, the packet must be freed with av_free_packet() when it is no168 * In both cases, the packet must be freed with av_packet_unref() when it is no
169 * longer needed.169 * longer needed.
170 *170 *
171 * @section lavf_decoding_seek Seeking171 * @section lavf_decoding_seek Seeking
@@ -2138,7 +2138,7 @@ int av_find_best_stream(AVFormatContext *ic, · 1966 unmodified lines
2138 * If pkt->buf is NULL, then the packet is valid until the next2138 * If pkt->buf is NULL, then the packet is valid until the next
2139 * av_read_frame() or until avformat_close_input(). Otherwise the packet2139 * av_read_frame() or until avformat_close_input(). Otherwise the packet
2140 * is valid indefinitely. In both cases the packet must be freed with2140 * is valid indefinitely. In both cases the packet must be freed with
2141 * av_free_packet when it is no longer needed. For video, the packet contains2141 * av_packet_unref when it is no longer needed. For video, the packet contains
2142 * exactly one frame. For audio, it contains an integer number of frames if each2142 * exactly one frame. For audio, it contains an integer number of frames if each
2143 * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames2143 * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames
2144 * have a variable size (e.g. MPEG audio), then it contains one frame.2144 * have a variable size (e.g. MPEG audio), then it contains one frame.
libavformat/avidec.c+3−3
@@ -1431,7 +1431,7 @@ resync: · 1430 unmodified lines
1431 pkt->buf = avbuf;1431 pkt->buf = avbuf;
1432 pkt->flags |= AV_PKT_FLAG_KEY;1432 pkt->flags |= AV_PKT_FLAG_KEY;
1433 if (size < 0)1433 if (size < 0)
1434 av_free_packet(pkt);1434 av_packet_unref(pkt);
1435 } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&1435 } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
1436 !st->codec->codec_tag && read_gab2_sub(s, st, pkt)) {1436 !st->codec->codec_tag && read_gab2_sub(s, st, pkt)) {
1437 ast->frame_offset++;1437 ast->frame_offset++;
@@ -1750,7 +1750,7 @@ static void seek_subtitle(AVStream *st, AVStream *st2, int64_t timestamp) · 312 unmodified lines
1750{1750{
1751 AVIStream *ast2 = st2->priv_data;1751 AVIStream *ast2 = st2->priv_data;
1752 int64_t ts2 = av_rescale_q(timestamp, st->time_base, st2->time_base);1752 int64_t ts2 = av_rescale_q(timestamp, st->time_base, st2->time_base);
1753 av_free_packet(&ast2->sub_pkt);1753 av_packet_unref(&ast2->sub_pkt);
1754 if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||1754 if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||
1755 avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)1755 avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)
1756 ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);1756 ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
@@ -1888,7 +1888,7 @@ static int avi_read_close(AVFormatContext *s) · 131 unmodified lines
1888 avformat_close_input(&ast->sub_ctx);1888 avformat_close_input(&ast->sub_ctx);
1889 }1889 }
1890 av_freep(&ast->sub_buffer);1890 av_freep(&ast->sub_buffer);
1891 av_free_packet(&ast->sub_pkt);1891 av_packet_unref(&ast->sub_pkt);
1892 }1892 }
1893 }1893 }
1894 1894
libavformat/avs.c+1−1
@@ -108,7 +108,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt, · 107 unmodified lines
108 pkt->data[palette_size + 3] = (size >> 8) & 0xFF;108 pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
109 ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;109 ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
110 if (ret < size) {110 if (ret < size) {
111 av_free_packet(pkt);111 av_packet_unref(pkt);
112 return AVERROR(EIO);112 return AVERROR(EIO);
113 }113 }
114 114
libavformat/c93.c+1−1
@@ -188,7 +188,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 187 unmodified lines
188 return 0;188 return 0;
189 189
190 fail:190 fail:
191 av_free_packet(pkt);191 av_packet_unref(pkt);
192 return ret;192 return ret;
193}193}
194 194
libavformat/cdg.c+1−1
@@ -63,7 +63,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 62 unmodified lines
63 ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);63 ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
64 if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND)64 if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND)
65 break;65 break;
66 av_free_packet(pkt);66 av_packet_unref(pkt);
67 }67 }
68 68
69 if (!priv->got_first_packet) {69 if (!priv->got_first_packet) {
libavformat/cdxl.c+1−1
@@ -202,7 +202,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) · 201 unmodified lines
202 memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);202 memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
203 ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);203 ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
204 if (ret < 0) {204 if (ret < 0) {
205 av_free_packet(pkt);205 av_packet_unref(pkt);
206 return ret;206 return ret;
207 }207 }
208 av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);208 av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret);
libavformat/dfa.c+2−2
@@ -93,7 +93,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt) · 92 unmodified lines
93 if (!first) {93 if (!first) {
94 ret = av_append_packet(pb, pkt, 12);94 ret = av_append_packet(pb, pkt, 12);
95 if (ret < 0) {95 if (ret < 0) {
96 av_free_packet(pkt);96 av_packet_unref(pkt);
97 return ret;97 return ret;
98 }98 }
99 } else99 } else
@@ -114,7 +114,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt) · 14 unmodified lines
114 }114 }
115 ret = av_append_packet(pb, pkt, frame_size);115 ret = av_append_packet(pb, pkt, frame_size);
116 if (ret < 0) {116 if (ret < 0) {
117 av_free_packet(pkt);117 av_packet_unref(pkt);
118 return ret;118 return ret;
119 }119 }
120 }120 }
libavformat/dsicin.c+1−1
@@ -200,7 +200,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt) · 199 unmodified lines
200 200
201 ret = avio_read(pb, &pkt->data[4], pkt_size);201 ret = avio_read(pb, &pkt->data[4], pkt_size);
202 if (ret < 0) {202 if (ret < 0) {
203 av_free_packet(pkt);203 av_packet_unref(pkt);
204 return ret;204 return ret;
205 }205 }
206 if (ret < pkt_size)206 if (ret < pkt_size)
libavformat/dss.c+3−3
@@ -267,7 +267,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt) · 266 unmodified lines
267 return pkt->size;267 return pkt->size;
268 268
269error_eof:269error_eof:
270 av_free_packet(pkt);270 av_packet_unref(pkt);
271 return ret < 0 ? ret : AVERROR_EOF;271 return ret < 0 ? ret : AVERROR_EOF;
272}272}
273 273
@@ -309,7 +309,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 35 unmodified lines
309 ret = avio_read(s->pb, pkt->data + offset,309 ret = avio_read(s->pb, pkt->data + offset,
310 size2 - offset);310 size2 - offset);
311 if (ret < size2 - offset) {311 if (ret < size2 - offset) {
312 av_free_packet(pkt);312 av_packet_unref(pkt);
313 return ret < 0 ? ret : AVERROR_EOF;313 return ret < 0 ? ret : AVERROR_EOF;
314 }314 }
315 315
@@ -319,7 +319,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 3 unmodified lines
319 319
320 ret = avio_read(s->pb, pkt->data + offset, size - offset);320 ret = avio_read(s->pb, pkt->data + offset, size - offset);
321 if (ret < size - offset) {321 if (ret < size - offset) {
322 av_free_packet(pkt);322 av_packet_unref(pkt);
323 return ret < 0 ? ret : AVERROR_EOF;323 return ret < 0 ? ret : AVERROR_EOF;
324 }324 }
325 325
libavformat/dxa.c+1−1
@@ -207,7 +207,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) · 206 unmodified lines
207 memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);207 memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
208 ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);208 ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
209 if(ret != size){209 if(ret != size){
210 av_free_packet(pkt);210 av_packet_unref(pkt);
211 return AVERROR(EIO);211 return AVERROR(EIO);
212 }212 }
213 if(pal_size) memcpy(pkt->data, pal, pal_size);213 if(pal_size) memcpy(pkt->data, pal, pal_size);
libavformat/electronicarts.c+1−1
@@ -632,7 +632,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) · 631 unmodified lines
632 case AV_CODEC_ID_ADPCM_EA_R3:632 case AV_CODEC_ID_ADPCM_EA_R3:
633 if (pkt->size < 4) {633 if (pkt->size < 4) {
634 av_log(s, AV_LOG_ERROR, "Packet is too short\n");634 av_log(s, AV_LOG_ERROR, "Packet is too short\n");
635 av_free_packet(pkt);635 av_packet_unref(pkt);
636 return AVERROR_INVALIDDATA;636 return AVERROR_INVALIDDATA;
637 }637 }
638 if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)638 if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3)
libavformat/flic.c+2−2
@@ -227,7 +227,7 @@ static int flic_read_packet(AVFormatContext *s, · 226 unmodified lines
227 ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,227 ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
228 size - FLIC_PREAMBLE_SIZE);228 size - FLIC_PREAMBLE_SIZE);
229 if (ret != size - FLIC_PREAMBLE_SIZE) {229 if (ret != size - FLIC_PREAMBLE_SIZE) {
230 av_free_packet(pkt);230 av_packet_unref(pkt);
231 ret = AVERROR(EIO);231 ret = AVERROR(EIO);
232 }232 }
233 packet_read = 1;233 packet_read = 1;
@@ -245,7 +245,7 @@ static int flic_read_packet(AVFormatContext *s, · 11 unmodified lines
245 ret = avio_read(pb, pkt->data, size);245 ret = avio_read(pb, pkt->data, size);
246 246
247 if (ret != size) {247 if (ret != size) {
248 av_free_packet(pkt);248 av_packet_unref(pkt);
249 ret = AVERROR(EIO);249 ret = AVERROR(EIO);
250 }250 }
251 251
libavformat/g723_1.c+1−1
@@ -69,7 +69,7 @@ static int g723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 68 unmodified lines
69 69
70 ret = avio_read(s->pb, pkt->data + 1, size - 1);70 ret = avio_read(s->pb, pkt->data + 1, size - 1);
71 if (ret < size - 1) {71 if (ret < size - 1) {
72 av_free_packet(pkt);72 av_packet_unref(pkt);
73 return ret < 0 ? ret : AVERROR_EOF;73 return ret < 0 ? ret : AVERROR_EOF;
74 }74 }
75 75
libavformat/gsmdec.c+1−1
@@ -45,7 +45,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines
45 45
46 ret = av_get_packet(s->pb, pkt, size);46 ret = av_get_packet(s->pb, pkt, size);
47 if (ret < GSM_BLOCK_SIZE) {47 if (ret < GSM_BLOCK_SIZE) {
48 av_free_packet(pkt);48 av_packet_unref(pkt);
49 return ret < 0 ? ret : AVERROR(EIO);49 return ret < 0 ? ret : AVERROR(EIO);
50 }50 }
51 pkt->duration = 1;51 pkt->duration = 1;
libavformat/hls.c+3−3
@@ -243,7 +243,7 @@ static void free_playlist_list(HLSContext *c) · 242 unmodified lines
243 av_dict_free(&pls->id3_initial);243 av_dict_free(&pls->id3_initial);
244 ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);244 ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);
245 av_freep(&pls->init_sec_buf);245 av_freep(&pls->init_sec_buf);
246 av_free_packet(&pls->pkt);246 av_packet_unref(&pls->pkt);
247 av_freep(&pls->pb.buffer);247 av_freep(&pls->pb.buffer);
248 if (pls->input)248 if (pls->input)
249 ffurl_close(pls->input);249 ffurl_close(pls->input);
@@ -1824,7 +1824,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) · 1574 unmodified lines
1824 break;1824 break;
1825 }1825 }
1826 }1826 }
1827 av_free_packet(&pls->pkt);1827 av_packet_unref(&pls->pkt);
1828 reset_packet(&pls->pkt);1828 reset_packet(&pls->pkt);
1829 }1829 }
1830 }1830 }
@@ -1926,7 +1926,7 @@ static int hls_read_seek(AVFormatContext *s, int stream_index, · 95 unmodified lines
1926 ffurl_close(pls->input);1926 ffurl_close(pls->input);
1927 pls->input = NULL;1927 pls->input = NULL;
1928 }1928 }
1929 av_free_packet(&pls->pkt);1929 av_packet_unref(&pls->pkt);
1930 reset_packet(&pls->pkt);1930 reset_packet(&pls->pkt);
1931 pls->pb.eof_reached = 0;1931 pls->pb.eof_reached = 0;
1932 /* Clear any buffered data */1932 /* Clear any buffered data */
libavformat/hnm.c+1−1
@@ -190,7 +190,7 @@ static int hnm_read_close(AVFormatContext *s) · 189 unmodified lines
190 Hnm4DemuxContext *hnm = s->priv_data;190 Hnm4DemuxContext *hnm = s->priv_data;
191 191
192 if (hnm->vpkt.size > 0)192 if (hnm->vpkt.size > 0)
193 av_free_packet(&hnm->vpkt);193 av_packet_unref(&hnm->vpkt);
194 194
195 return 0;195 return 0;
196}196}
libavformat/idcin.c+2−2
@@ -313,7 +313,7 @@ static int idcin_read_packet(AVFormatContext *s, · 312 unmodified lines
313 return ret;313 return ret;
314 else if (ret != chunk_size) {314 else if (ret != chunk_size) {
315 av_log(s, AV_LOG_ERROR, "incomplete packet\n");315 av_log(s, AV_LOG_ERROR, "incomplete packet\n");
316 av_free_packet(pkt);316 av_packet_unref(pkt);
317 return AVERROR(EIO);317 return AVERROR(EIO);
318 }318 }
319 if (command == 1) {319 if (command == 1) {
@@ -322,7 +322,7 @@ static int idcin_read_packet(AVFormatContext *s, · 2 unmodified lines
322 pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,322 pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
323 AVPALETTE_SIZE);323 AVPALETTE_SIZE);
324 if (!pal) {324 if (!pal) {
325 av_free_packet(pkt);325 av_packet_unref(pkt);
326 return AVERROR(ENOMEM);326 return AVERROR(ENOMEM);
327 }327 }
328 memcpy(pal, palette, AVPALETTE_SIZE);328 memcpy(pal, palette, AVPALETTE_SIZE);
libavformat/ilbc.c+1−1
@@ -112,7 +112,7 @@ static int ilbc_read_packet(AVFormatContext *s, · 111 unmodified lines
112 pkt->pos = avio_tell(s->pb);112 pkt->pos = avio_tell(s->pb);
113 pkt->duration = enc->block_align == 38 ? 160 : 240;113 pkt->duration = enc->block_align == 38 ? 160 : 240;
114 if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {114 if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
115 av_free_packet(pkt);115 av_packet_unref(pkt);
116 return ret < 0 ? ret : AVERROR(EIO);116 return ret < 0 ? ret : AVERROR(EIO);
117 }117 }
118 118
libavformat/img2dec.c+1−1
@@ -487,7 +487,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) · 486 unmodified lines
487 }487 }
488 488
489 if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {489 if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
490 av_free_packet(pkt);490 av_packet_unref(pkt);
491 if (ret[0] < 0) {491 if (ret[0] < 0) {
492 res = ret[0];492 res = ret[0];
493 } else if (ret[1] < 0) {493 } else if (ret[1] < 0) {
libavformat/internal.h+1−1
@@ -376,7 +376,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt); · 375 unmodified lines
376 * Interleave a packet per dts in an output media file.376 * Interleave a packet per dts in an output media file.
377 *377 *
378 * Packets with pkt->destruct == av_destruct_packet will be freed inside this378 * Packets with pkt->destruct == av_destruct_packet will be freed inside this
379 * function, so they cannot be used after it. Note that calling av_free_packet()379 * function, so they cannot be used after it. Note that calling av_packet_unref()
380 * on them is still safe.380 * on them is still safe.
381 *381 *
382 * @param s media file handle382 * @param s media file handle
libavformat/ipmovie.c+2−2
@@ -180,7 +180,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, · 179 unmodified lines
180 180
181 if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=181 if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
182 s->decode_map_chunk_size) {182 s->decode_map_chunk_size) {
183 av_free_packet(pkt);183 av_packet_unref(pkt);
184 return CHUNK_EOF;184 return CHUNK_EOF;
185 }185 }
186 186
@@ -189,7 +189,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, · 2 unmodified lines
189 189
190 if (avio_read(pb, pkt->data + s->decode_map_chunk_size,190 if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
191 s->video_chunk_size) != s->video_chunk_size) {191 s->video_chunk_size) != s->video_chunk_size) {
192 av_free_packet(pkt);192 av_packet_unref(pkt);
193 return CHUNK_EOF;193 return CHUNK_EOF;
194 }194 }
195 195
libavformat/iv8.c+1−1
@@ -92,7 +92,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 91 unmodified lines
92 ret = av_append_packet(s->pb, pkt, size);92 ret = av_append_packet(s->pb, pkt, size);
93 if (ret < 0) {93 if (ret < 0) {
94 av_log(s, AV_LOG_ERROR, "failed to grow packet\n");94 av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
95 av_free_packet(pkt);95 av_packet_unref(pkt);
96 return ret;96 return ret;
97 }97 }
98 }98 }
libavformat/lxfdec.c+1−1
@@ -317,7 +317,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt) · 316 unmodified lines
317 return ret2;317 return ret2;
318 318
319 if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {319 if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {
320 av_free_packet(pkt);320 av_packet_unref(pkt);
321 return ret2 < 0 ? ret2 : AVERROR_EOF;321 return ret2 < 0 ? ret2 : AVERROR_EOF;
322 }322 }
323 323
libavformat/matroskadec.c+1−1
@@ -2292,7 +2292,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska) · 2291 unmodified lines
2292 if (matroska->packets) {2292 if (matroska->packets) {
2293 int n;2293 int n;
2294 for (n = 0; n < matroska->num_packets; n++) {2294 for (n = 0; n < matroska->num_packets; n++) {
2295 av_free_packet(matroska->packets[n]);2295 av_packet_unref(matroska->packets[n]);
2296 av_freep(&matroska->packets[n]);2296 av_freep(&matroska->packets[n]);
2297 }2297 }
2298 av_freep(&matroska->packets);2298 av_freep(&matroska->packets);
libavformat/matroskaenc.c+2−2
@@ -1934,7 +1934,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) · 1933 unmodified lines
1934 // for DASH audio, a CuePoint has to be added when there is a new cluster.1934 // for DASH audio, a CuePoint has to be added when there is a new cluster.
1935 ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt,1935 ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt,
1936 mkv->is_dash ? start_new_cluster : 0);1936 mkv->is_dash ? start_new_cluster : 0);
1937 av_free_packet(&mkv->cur_audio_pkt);1937 av_packet_unref(&mkv->cur_audio_pkt);
1938 if (ret < 0) {1938 if (ret < 0) {
1939 av_log(s, AV_LOG_ERROR,1939 av_log(s, AV_LOG_ERROR,
1940 "Could not write cached audio packet ret:%d\n", ret);1940 "Could not write cached audio packet ret:%d\n", ret);
@@ -1993,7 +1993,7 @@ static int mkv_write_trailer(AVFormatContext *s) · 52 unmodified lines
1993 // check if we have an audio packet cached1993 // check if we have an audio packet cached
1994 if (mkv->cur_audio_pkt.size > 0) {1994 if (mkv->cur_audio_pkt.size > 0) {
1995 ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);1995 ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, 0);
1996 av_free_packet(&mkv->cur_audio_pkt);1996 av_packet_unref(&mkv->cur_audio_pkt);
1997 if (ret < 0) {1997 if (ret < 0) {
1998 av_log(s, AV_LOG_ERROR,1998 av_log(s, AV_LOG_ERROR,
1999 "Could not write cached audio packet ret:%d\n", ret);1999 "Could not write cached audio packet ret:%d\n", ret);
libavformat/mp3enc.c+1−1
@@ -365,7 +365,7 @@ static int mp3_queue_flush(AVFormatContext *s) · 364 unmodified lines
365 while ((pktl = mp3->queue)) {365 while ((pktl = mp3->queue)) {
366 if (write && (ret = mp3_write_audio_packet(s, &pktl->pkt)) < 0)366 if (write && (ret = mp3_write_audio_packet(s, &pktl->pkt)) < 0)
367 write = 0;367 write = 0;
368 av_free_packet(&pktl->pkt);368 av_packet_unref(&pktl->pkt);
369 mp3->queue = pktl->next;369 mp3->queue = pktl->next;
370 av_freep(&pktl);370 av_freep(&pktl);
371 }371 }
libavformat/mpc.c+2−2
@@ -166,7 +166,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) · 165 unmodified lines
166 if(c->curbits)166 if(c->curbits)
167 avio_seek(s->pb, -4, SEEK_CUR);167 avio_seek(s->pb, -4, SEEK_CUR);
168 if(ret < size){168 if(ret < size){
169 av_free_packet(pkt);169 av_packet_unref(pkt);
170 return ret < 0 ? ret : AVERROR(EIO);170 return ret < 0 ? ret : AVERROR(EIO);
171 }171 }
172 pkt->size = ret + 4;172 pkt->size = ret + 4;
@@ -217,7 +217,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp · 44 unmodified lines
217 c->curframe = lastframe;217 c->curframe = lastframe;
218 return ret;218 return ret;
219 }219 }
220 av_free_packet(pkt);220 av_packet_unref(pkt);
221 }221 }
222 return 0;222 return 0;
223}223}
libavformat/mpegts.c+1−1
@@ -2611,7 +2611,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt) · 2610 unmodified lines
2611 ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);2611 ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);
2612 pkt->pos = avio_tell(s->pb);2612 pkt->pos = avio_tell(s->pb);
2613 if (ret < 0) {2613 if (ret < 0) {
2614 av_free_packet(pkt);2614 av_packet_unref(pkt);
2615 return ret;2615 return ret;
2616 }2616 }
2617 if (data != pkt->data)2617 if (data != pkt->data)
libavformat/mux.c+3−3
@@ -923,7 +923,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in · 922 unmodified lines
923 if (s->oformat->interleave_packet) {923 if (s->oformat->interleave_packet) {
924 int ret = s->oformat->interleave_packet(s, out, in, flush);924 int ret = s->oformat->interleave_packet(s, out, in, flush);
925 if (in)925 if (in)
926 av_free_packet(in);926 av_packet_unref(in);
927 return ret;927 return ret;
928 } else928 } else
929 return ff_interleave_packet_per_dts(s, out, in, flush);929 return ff_interleave_packet_per_dts(s, out, in, flush);
@@ -971,7 +971,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt) · 41 unmodified lines
971 if (ret >= 0)971 if (ret >= 0)
972 s->streams[opkt.stream_index]->nb_frames++;972 s->streams[opkt.stream_index]->nb_frames++;
973 973
974 av_free_packet(&opkt);974 av_packet_unref(&opkt);
975 975
976 if (ret < 0)976 if (ret < 0)
977 return ret;977 return ret;
@@ -999,7 +999,7 @@ int av_write_trailer(AVFormatContext *s) · 21 unmodified lines
999 if (ret >= 0)999 if (ret >= 0)
1000 s->streams[pkt.stream_index]->nb_frames++;1000 s->streams[pkt.stream_index]->nb_frames++;
1001 1001
1002 av_free_packet(&pkt);1002 av_packet_unref(&pkt);
1003 1003
1004 if (ret < 0)1004 if (ret < 0)
1005 goto fail;1005 goto fail;
libavformat/mxfenc.c+1−1
@@ -2589,7 +2589,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket · 2588 unmodified lines
2589 2589
2590 if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)2590 if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
2591 s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;2591 s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
2592 av_free_packet(&pktl->pkt);2592 av_packet_unref(&pktl->pkt);
2593 av_freep(&pktl);2593 av_freep(&pktl);
2594 pktl = next;2594 pktl = next;
2595 }2595 }
libavformat/ncdec.c+1−1
@@ -83,7 +83,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt) · 82 unmodified lines
83 83
84 ret = av_get_packet(s->pb, pkt, size);84 ret = av_get_packet(s->pb, pkt, size);
85 if (ret != size) {85 if (ret != size) {
86 if (ret > 0) av_free_packet(pkt);86 if (ret > 0) av_packet_unref(pkt);
87 return AVERROR(EIO);87 return AVERROR(EIO);
88 }88 }
89 89
libavformat/nsvdec.c+2−2
@@ -713,9 +713,9 @@ static int nsv_read_close(AVFormatContext *s) · 712 unmodified lines
713 av_freep(&nsv->nsvs_file_offset);713 av_freep(&nsv->nsvs_file_offset);
714 av_freep(&nsv->nsvs_timestamps);714 av_freep(&nsv->nsvs_timestamps);
715 if (nsv->ahead[0].data)715 if (nsv->ahead[0].data)
716 av_free_packet(&nsv->ahead[0]);716 av_packet_unref(&nsv->ahead[0]);
717 if (nsv->ahead[1].data)717 if (nsv->ahead[1].data)
718 av_free_packet(&nsv->ahead[1]);718 av_packet_unref(&nsv->ahead[1]);
719 return 0;719 return 0;
720}720}
721 721
libavformat/nuv.c+1−1
@@ -275,7 +275,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) · 274 unmodified lines
275 memcpy(pkt->data, hdr, copyhdrsize);275 memcpy(pkt->data, hdr, copyhdrsize);
276 ret = avio_read(pb, pkt->data + copyhdrsize, size);276 ret = avio_read(pb, pkt->data + copyhdrsize, size);
277 if (ret < 0) {277 if (ret < 0) {
278 av_free_packet(pkt);278 av_packet_unref(pkt);
279 return ret;279 return ret;
280 }280 }
281 if (ret < size)281 if (ret < size)
libavformat/psxstr.c+2−2
@@ -218,7 +218,7 @@ static int str_read_packet(AVFormatContext *s, · 217 unmodified lines
218 if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){218 if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){
219 if(pkt->data)219 if(pkt->data)
220 av_log(s, AV_LOG_ERROR, "missmatching sector_count\n");220 av_log(s, AV_LOG_ERROR, "missmatching sector_count\n");
221 av_free_packet(pkt);221 av_packet_unref(pkt);
222 if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE))222 if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE))
223 return AVERROR(EIO);223 return AVERROR(EIO);
224 memset(pkt->data, 0, sector_count*VIDEO_DATA_CHUNK_SIZE);224 memset(pkt->data, 0, sector_count*VIDEO_DATA_CHUNK_SIZE);
@@ -298,7 +298,7 @@ static int str_read_close(AVFormatContext *s) · 73 unmodified lines
298 int i;298 int i;
299 for(i=0; i<32; i++){299 for(i=0; i<32; i++){
300 if(str->channels[i].tmp_pkt.data)300 if(str->channels[i].tmp_pkt.data)
301 av_free_packet(&str->channels[i].tmp_pkt);301 av_packet_unref(&str->channels[i].tmp_pkt);
302 }302 }
303 303
304 return 0;304 return 0;
libavformat/rawdec.c+1−1
@@ -45,7 +45,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines
45 pkt->stream_index = 0;45 pkt->stream_index = 0;
46 ret = ffio_read_partial(s->pb, pkt->data, size);46 ret = ffio_read_partial(s->pb, pkt->data, size);
47 if (ret < 0) {47 if (ret < 0) {
48 av_free_packet(pkt);48 av_packet_unref(pkt);
49 return ret;49 return ret;
50 }50 }
51 av_shrink_packet(pkt, ret);51 av_shrink_packet(pkt, ret);
libavformat/rl2.c+1−1
@@ -240,7 +240,7 @@ static int rl2_read_packet(AVFormatContext *s, · 239 unmodified lines
240 /** fill the packet */240 /** fill the packet */
241 ret = av_get_packet(pb, pkt, sample->size);241 ret = av_get_packet(pb, pkt, sample->size);
242 if(ret != sample->size){242 if(ret != sample->size){
243 av_free_packet(pkt);243 av_packet_unref(pkt);
244 return AVERROR(EIO);244 return AVERROR(EIO);
245 }245 }
246 246
libavformat/rmdec.c+3−3
@@ -120,7 +120,7 @@ RMStream *ff_rm_alloc_rmstream (void) · 119 unmodified lines
120 120
121void ff_rm_free_rmstream (RMStream *rms)121void ff_rm_free_rmstream (RMStream *rms)
122{122{
123 av_free_packet(&rms->pkt);123 av_packet_unref(&rms->pkt);
124}124}
125 125
126static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,126static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
@@ -799,7 +799,7 @@ static int rm_assemble_video_frame(AVFormatContext *s, AVIOContext *pb, · 672 unmodified lines
799 }799 }
800 vst->slices = ((hdr & 0x3F) << 1) + 1;800 vst->slices = ((hdr & 0x3F) << 1) + 1;
801 vst->videobufsize = len2 + 8*vst->slices + 1;801 vst->videobufsize = len2 + 8*vst->slices + 1;
802 av_free_packet(&vst->pkt); //FIXME this should be output.802 av_packet_unref(&vst->pkt); //FIXME this should be output.
803 if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)803 if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
804 return AVERROR(ENOMEM);804 return AVERROR(ENOMEM);
805 memset(vst->pkt.data, 0, vst->pkt.size);805 memset(vst->pkt.data, 0, vst->pkt.size);
@@ -1047,7 +1047,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) · 241 unmodified lines
1047 1047
1048 if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))1048 if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))
1049 || st->discard >= AVDISCARD_ALL){1049 || st->discard >= AVDISCARD_ALL){
1050 av_free_packet(pkt);1050 av_packet_unref(pkt);
1051 } else1051 } else
1052 break;1052 break;
1053 }1053 }
libavformat/rpl.c+2−2
@@ -311,7 +311,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) · 310 unmodified lines
311 if (ret < 0)311 if (ret < 0)
312 return ret;312 return ret;
313 if (ret != frame_size) {313 if (ret != frame_size) {
314 av_free_packet(pkt);314 av_packet_unref(pkt);
315 return AVERROR(EIO);315 return AVERROR(EIO);
316 }316 }
317 pkt->duration = 1;317 pkt->duration = 1;
@@ -328,7 +328,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) · 10 unmodified lines
328 if (ret < 0)328 if (ret < 0)
329 return ret;329 return ret;
330 if (ret != index_entry->size) {330 if (ret != index_entry->size) {
331 av_free_packet(pkt);331 av_packet_unref(pkt);
332 return AVERROR(EIO);332 return AVERROR(EIO);
333 }333 }
334 334
libavformat/rtpdec_asf.c+1−1
@@ -289,7 +289,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, · 288 unmodified lines
289 return 1; // FIXME: return 0 if last packet289 return 1; // FIXME: return 0 if last packet
290 }290 }
291 }291 }
292 av_free_packet(pkt);292 av_packet_unref(pkt);
293 }293 }
294 294
295 return res == 1 ? -1 : res;295 return res == 1 ? -1 : res;
libavformat/rtpdec_mpa_robust.c+1−1
@@ -136,7 +136,7 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data, · 135 unmodified lines
136 data->split_pos = 0;136 data->split_pos = 0;
137 if (!data->split_buf) {137 if (!data->split_buf) {
138 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");138 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
139 av_free_packet(pkt);139 av_packet_unref(pkt);
140 return AVERROR(ENOMEM);140 return AVERROR(ENOMEM);
141 }141 }
142 memcpy(data->split_buf, buf, data->split_buf_size);142 memcpy(data->split_buf, buf, data->split_buf_size);
libavformat/rtpdec_qt.c+1−1
@@ -217,7 +217,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, · 216 unmodified lines
217 av_freep(&qt->pkt.data);217 av_freep(&qt->pkt.data);
218 qt->pkt.data = av_realloc(NULL, qt->remaining * qt->bytes_per_frame);218 qt->pkt.data = av_realloc(NULL, qt->remaining * qt->bytes_per_frame);
219 if (!qt->pkt.data) {219 if (!qt->pkt.data) {
220 av_free_packet(pkt);220 av_packet_unref(pkt);
221 return AVERROR(ENOMEM);221 return AVERROR(ENOMEM);
222 }222 }
223 qt->pkt.size = qt->remaining * qt->bytes_per_frame;223 qt->pkt.size = qt->remaining * qt->bytes_per_frame;
libavformat/rtpdec_xiph.c+1−1
@@ -141,7 +141,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, · 140 unmodified lines
141 data->split_buf = av_malloc(data->split_buf_size);141 data->split_buf = av_malloc(data->split_buf_size);
142 if (!data->split_buf) {142 if (!data->split_buf) {
143 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");143 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
144 av_free_packet(pkt);144 av_packet_unref(pkt);
145 return AVERROR(ENOMEM);145 return AVERROR(ENOMEM);
146 }146 }
147 }147 }
libavformat/sapdec.c+1−1
@@ -220,7 +220,7 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) · 219 unmodified lines
220 int i = s->nb_streams;220 int i = s->nb_streams;
221 AVStream *st = avformat_new_stream(s, NULL);221 AVStream *st = avformat_new_stream(s, NULL);
222 if (!st) {222 if (!st) {
223 av_free_packet(pkt);223 av_packet_unref(pkt);
224 return AVERROR(ENOMEM);224 return AVERROR(ENOMEM);
225 }225 }
226 st->id = i;226 st->id = i;
libavformat/seek-test.c+1−1
@@ -128,7 +128,7 @@ int main(int argc, char **argv) · 127 unmodified lines
128 ts_str(dts_buf, pkt.dts, st->time_base);128 ts_str(dts_buf, pkt.dts, st->time_base);
129 ts_str(ts_buf, pkt.pts, st->time_base);129 ts_str(ts_buf, pkt.pts, st->time_base);
130 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);130 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);
131 av_free_packet(&pkt);131 av_packet_unref(&pkt);
132 } else132 } else
133 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace133 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
134 printf("\n");134 printf("\n");
libavformat/sierravmd.c+1−1
@@ -288,7 +288,7 @@ static int vmd_read_packet(AVFormatContext *s, · 287 unmodified lines
288 frame->frame_size);288 frame->frame_size);
289 289
290 if (ret != frame->frame_size) {290 if (ret != frame->frame_size) {
291 av_free_packet(pkt);291 av_packet_unref(pkt);
292 ret = AVERROR(EIO);292 ret = AVERROR(EIO);
293 }293 }
294 pkt->stream_index = frame->stream_index;294 pkt->stream_index = frame->stream_index;
libavformat/spdifdec.c+3−3
@@ -193,7 +193,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) · 192 unmodified lines
193 pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;193 pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;
194 194
195 if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {195 if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
196 av_free_packet(pkt);196 av_packet_unref(pkt);
197 return AVERROR_EOF;197 return AVERROR_EOF;
198 }198 }
199 ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);199 ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1);
@@ -201,7 +201,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line
201 ret = spdif_get_offset_and_codec(s, data_type, pkt->data,201 ret = spdif_get_offset_and_codec(s, data_type, pkt->data,
202 &offset, &codec_id);202 &offset, &codec_id);
203 if (ret) {203 if (ret) {
204 av_free_packet(pkt);204 av_packet_unref(pkt);
205 return ret;205 return ret;
206 }206 }
207 207
@@ -212,7 +212,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) · 4 unmodified lines
212 /* first packet, create a stream */212 /* first packet, create a stream */
213 AVStream *st = avformat_new_stream(s, NULL);213 AVStream *st = avformat_new_stream(s, NULL);
214 if (!st) {214 if (!st) {
215 av_free_packet(pkt);215 av_packet_unref(pkt);
216 return AVERROR(ENOMEM);216 return AVERROR(ENOMEM);
217 }217 }
218 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;218 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
libavformat/thp.c+2−2
@@ -180,7 +180,7 @@ static int thp_read_packet(AVFormatContext *s, · 179 unmodified lines
180 if (ret < 0)180 if (ret < 0)
181 return ret;181 return ret;
182 if (ret != size) {182 if (ret != size) {
183 av_free_packet(pkt);183 av_packet_unref(pkt);
184 return AVERROR(EIO);184 return AVERROR(EIO);
185 }185 }
186 186
@@ -190,7 +190,7 @@ static int thp_read_packet(AVFormatContext *s, · 3 unmodified lines
190 if (ret < 0)190 if (ret < 0)
191 return ret;191 return ret;
192 if (ret != thp->audiosize) {192 if (ret != thp->audiosize) {
193 av_free_packet(pkt);193 av_packet_unref(pkt);
194 return AVERROR(EIO);194 return AVERROR(EIO);
195 }195 }
196 196
libavformat/utils.c+9−9
@@ -237,7 +237,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size) · 236 unmodified lines
237 237
238 pkt->pos = orig_pos;238 pkt->pos = orig_pos;
239 if (!pkt->size)239 if (!pkt->size)
240 av_free_packet(pkt);240 av_packet_unref(pkt);
241 return pkt->size > orig_size ? pkt->size - orig_size : ret;241 return pkt->size > orig_size ? pkt->size - orig_size : ret;
242}242}
243 243
@@ -696,7 +696,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) · 452 unmodified lines
696 av_log(s, AV_LOG_WARNING,696 av_log(s, AV_LOG_WARNING,
697 "Dropped corrupted packet (stream = %d)\n",697 "Dropped corrupted packet (stream = %d)\n",
698 pkt->stream_index);698 pkt->stream_index);
699 av_free_packet(pkt);699 av_packet_unref(pkt);
700 continue;700 continue;
701 }701 }
702 702
@@ -1188,7 +1188,7 @@ static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_en · 485 unmodified lines
1188 while (*pkt_buf) {1188 while (*pkt_buf) {
1189 AVPacketList *pktl = *pkt_buf;1189 AVPacketList *pktl = *pkt_buf;
1190 *pkt_buf = pktl->next;1190 *pkt_buf = pktl->next;
1191 av_free_packet(&pktl->pkt);1191 av_packet_unref(&pktl->pkt);
1192 av_freep(&pktl);1192 av_freep(&pktl);
1193 }1193 }
1194 *pkt_buf_end = NULL;1194 *pkt_buf_end = NULL;
@@ -1282,7 +1282,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) · 87 unmodified lines
1282 goto fail;1282 goto fail;
1283 1283
1284 if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {1284 if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) {
1285 av_free_packet(&out_pkt);1285 av_packet_unref(&out_pkt);
1286 ret = AVERROR(ENOMEM);1286 ret = AVERROR(ENOMEM);
1287 goto fail;1287 goto fail;
1288 }1288 }
@@ -1295,7 +1295,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) · 6 unmodified lines
1295 }1295 }
1296 1296
1297fail:1297fail:
1298 av_free_packet(pkt);1298 av_packet_unref(pkt);
1299 return ret;1299 return ret;
1300}1300}
1301 1301
@@ -1398,7 +1398,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 96 unmodified lines
1398 return ret;1398 return ret;
1399 } else {1399 } else {
1400 /* free packet */1400 /* free packet */
1401 av_free_packet(&cur_pkt);1401 av_packet_unref(&cur_pkt);
1402 }1402 }
1403 if (pkt->flags & AV_PKT_FLAG_KEY)1403 if (pkt->flags & AV_PKT_FLAG_KEY)
1404 st->skip_to_keyframe = 0;1404 st->skip_to_keyframe = 0;
@@ -2131,7 +2131,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index, · 726 unmodified lines
2131 } while (read_status == AVERROR(EAGAIN));2131 } while (read_status == AVERROR(EAGAIN));
2132 if (read_status < 0)2132 if (read_status < 0)
2133 break;2133 break;
2134 av_free_packet(&pkt);2134 av_packet_unref(&pkt);
2135 if (stream_index == pkt.stream_index && pkt.dts > timestamp) {2135 if (stream_index == pkt.stream_index && pkt.dts > timestamp) {
2136 if (pkt.flags & AV_PKT_FLAG_KEY)2136 if (pkt.flags & AV_PKT_FLAG_KEY)
2137 break;2137 break;
@@ -2535,7 +2535,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) · 397 unmodified lines
2535 st->info->last_duration = duration;2535 st->info->last_duration = duration;
2536 }2536 }
2537 }2537 }
2538 av_free_packet(pkt);2538 av_packet_unref(pkt);
2539 }2539 }
2540 2540
2541 /* check if all audio/video streams have valid duration */2541 /* check if all audio/video streams have valid duration */
@@ -3664,7 +3664,7 @@ void ff_free_stream(AVFormatContext *s, AVStream *st) { · 1122 unmodified lines
3664 av_parser_close(st->parser);3664 av_parser_close(st->parser);
3665 }3665 }
3666 if (st->attached_pic.data)3666 if (st->attached_pic.data)
3667 av_free_packet(&st->attached_pic);3667 av_packet_unref(&st->attached_pic);
3668 av_dict_free(&st->metadata);3668 av_dict_free(&st->metadata);
3669 av_freep(&st->probe_data.buf);3669 av_freep(&st->probe_data.buf);
3670 av_freep(&st->index_entries);3670 av_freep(&st->index_entries);
libavformat/vqf.c+1−1
@@ -246,7 +246,7 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt) · 245 unmodified lines
246 ret = avio_read(s->pb, pkt->data+2, size);246 ret = avio_read(s->pb, pkt->data+2, size);
247 247
248 if (ret != size) {248 if (ret != size) {
249 av_free_packet(pkt);249 av_packet_unref(pkt);
250 return AVERROR(EIO);250 return AVERROR(EIO);
251 }251 }
252 252
libavformat/wc3movie.c+1−1
@@ -295,7 +295,7 @@ static int wc3_read_close(AVFormatContext *s) · 294 unmodified lines
295 Wc3DemuxContext *wc3 = s->priv_data;295 Wc3DemuxContext *wc3 = s->priv_data;
296 296
297 if (wc3->vpkt.size > 0)297 if (wc3->vpkt.size > 0)
298 av_free_packet(&wc3->vpkt);298 av_packet_unref(&wc3->vpkt);
299 299
300 return 0;300 return 0;
301}301}
libavformat/wvdec.c+4−4
@@ -273,25 +273,25 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt) · 272 unmodified lines
273 memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);273 memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
274 ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);274 ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
275 if (ret != wc->header.blocksize) {275 if (ret != wc->header.blocksize) {
276 av_free_packet(pkt);276 av_packet_unref(pkt);
277 return AVERROR(EIO);277 return AVERROR(EIO);
278 }278 }
279 while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {279 while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
280 if ((ret = wv_read_block_header(s, s->pb)) < 0) {280 if ((ret = wv_read_block_header(s, s->pb)) < 0) {
281 av_free_packet(pkt);281 av_packet_unref(pkt);
282 return ret;282 return ret;
283 }283 }
284 284
285 off = pkt->size;285 off = pkt->size;
286 if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {286 if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {
287 av_free_packet(pkt);287 av_packet_unref(pkt);
288 return ret;288 return ret;
289 }289 }
290 memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);290 memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);
291 291
292 ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);292 ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);
293 if (ret != wc->header.blocksize) {293 if (ret != wc->header.blocksize) {
294 av_free_packet(pkt);294 av_packet_unref(pkt);
295 return (ret < 0) ? ret : AVERROR_EOF;295 return (ret < 0) ? ret : AVERROR_EOF;
296 }296 }
297 }297 }
libavformat/yop.c+3−3
@@ -173,14 +173,14 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt) · 172 unmodified lines
173 return yop->audio_block_length;173 return yop->audio_block_length;
174 174
175err_out:175err_out:
176 av_free_packet(&yop->video_packet);176 av_packet_unref(&yop->video_packet);
177 return ret;177 return ret;
178}178}
179 179
180static int yop_read_close(AVFormatContext *s)180static int yop_read_close(AVFormatContext *s)
181{181{
182 YopDecContext *yop = s->priv_data;182 YopDecContext *yop = s->priv_data;
183 av_free_packet(&yop->video_packet);183 av_packet_unref(&yop->video_packet);
184 return 0;184 return 0;
185}185}
186 186
@@ -205,7 +205,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index, · 18 unmodified lines
205 if (avio_seek(s->pb, frame_pos, SEEK_SET) < 0)205 if (avio_seek(s->pb, frame_pos, SEEK_SET) < 0)
206 return -1;206 return -1;
207 207
208 av_free_packet(&yop->video_packet);208 av_packet_unref(&yop->video_packet);
209 yop->odd_frame = timestamp & 1;209 yop->odd_frame = timestamp & 1;
210 210
211 return 0;211 return 0;
tools/pktdumper.c+1−1
@@ -122,7 +122,7 @@ int main(int argc, char **argv) · 121 unmodified lines
122 }122 }
123 close(fd);123 close(fd);
124 }124 }
125 av_free_packet(&pkt);125 av_packet_unref(&pkt);
126 pktnum++;126 pktnum++;
127 if (maxpkts && (pktnum >= maxpkts))127 if (maxpkts && (pktnum >= maxpkts))
128 break;128 break;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t