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
1515
1616 API changes, most recent first:
1717
18+2015-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+
1822 2015-10-22 - xxxxxxx - lavc 57.9.100 / lavc 57.5.0 - avcodec.h
1923 Add data and linesize array to AVSubtitleRect, to be used instead of
2024 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
225225
226226 if (got_output) {
227227 fwrite(pkt.data, 1, pkt.size, f);
228− av_free_packet(&pkt);
228+ av_packet_unref(&pkt);
229229 }
230230 }
231231 fclose(f);
@@ -454,7 +454,7 @@ static void video_encode_example(const char *filename, int codec_id) · 222 unmodified lines
454454 if (got_output) {
455455 printf("Write frame %3d (size=%5d)\n", i, pkt.size);
456456 fwrite(pkt.data, 1, pkt.size, f);
457− av_free_packet(&pkt);
457+ av_packet_unref(&pkt);
458458 }
459459 }
460460
@@ -471,7 +471,7 @@ static void video_encode_example(const char *filename, int codec_id) · 10 unmodified lines
471471 if (got_output) {
472472 printf("Write frame %3d (size=%5d)\n", i, pkt.size);
473473 fwrite(pkt.data, 1, pkt.size, f);
474− av_free_packet(&pkt);
474+ av_packet_unref(&pkt);
475475 }
476476 }
477477
doc/examples/transcode_aac.c+5−5
@@ -332,7 +332,7 @@ static int decode_audio_frame(AVFrame *frame, · 331 unmodified lines
332332 data_present, &input_packet)) < 0) {
333333 fprintf(stderr, "Could not decode frame (error '%s')\n",
334334 get_error_text(error));
335− av_free_packet(&input_packet);
335+ av_packet_unref(&input_packet);
336336 return error;
337337 }
338338
@@ -342,7 +342,7 @@ static int decode_audio_frame(AVFrame *frame, · 3 unmodified lines
342342 */
343343 if (*finished && *data_present)
344344 *finished = 0;
345− av_free_packet(&input_packet);
345+ av_packet_unref(&input_packet);
346346 return 0;
347347 }
348348
@@ -571,7 +571,7 @@ static int encode_audio_frame(AVFrame *frame, · 222 unmodified lines
571571 frame, data_present)) < 0) {
572572 fprintf(stderr, "Could not encode frame (error '%s')\n",
573573 get_error_text(error));
574− av_free_packet(&output_packet);
574+ av_packet_unref(&output_packet);
575575 return error;
576576 }
577577
@@ -580,11 +580,11 @@ static int encode_audio_frame(AVFrame *frame, · 2 unmodified lines
580580 if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
581581 fprintf(stderr, "Could not write frame (error '%s')\n",
582582 get_error_text(error));
583− av_free_packet(&output_packet);
583+ av_packet_unref(&output_packet);
584584 return error;
585585 }
586586
587− av_free_packet(&output_packet);
587+ av_packet_unref(&output_packet);
588588 }
589589
590590 return 0;
libavcodec/avcodec.h+19−14
@@ -1367,15 +1367,19 @@ typedef struct AVPacketSideData { · 1366 unmodified lines
13671367 * ABI. Thus it may be allocated on stack and no new fields can be added to it
13681368 * without libavcodec and libavformat major bump.
13691369 *
1370− * The semantics of data ownership depends on the buf or destruct (deprecated)
1371− * fields. If either is set, the packet data is dynamically allocated and is
1372− * valid indefinitely until av_free_packet() is called (which in turn calls
1373− * av_buffer_unref()/the destruct callback to free the data). If neither is set,
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).
1370+ * The semantics of data ownership depends on the buf field.
1371+ * If it is set, the packet data is dynamically allocated and is
1372+ * valid indefinitely until a call to av_packet_unref() reduces the
1373+ * reference count to 0.
13761374 *
1377− * The side data is always allocated with av_malloc() and is freed in
1378− * av_free_packet().
1375+ * If the buf field is not set av_packet_ref() would make a copy instead
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
13791383 */
13801384 typedef struct AVPacket {
13811385 /**
@@ -3899,7 +3903,7 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); · 2517 unmodified lines
38993903 * packet is allocated if it was not really allocated.
39003904 */
39013905 int av_dup_packet(AVPacket *pkt);
3902−
3906+#if FF_API_AVPACKET_OLD_API
39033907 /**
39043908 * Copy packet, including contents
39053909 *
@@ -3917,10 +3921,13 @@ int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src); · 11 unmodified lines
39173921 /**
39183922 * Free a packet.
39193923 *
3924+ * @deprecated Use av_packet_unref
3925+ *
39203926 * @param pkt packet to free
39213927 */
3928+attribute_deprecated
39223929 void av_free_packet(AVPacket *pkt);
3923−
3930+#endif
39243931 /**
39253932 * Allocate new information of a packet.
39263933 *
@@ -4563,8 +4570,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name); · 636 unmodified lines
45634570 * of the output packet.
45644571 *
45654572 * If this function fails or produces no output, avpkt will be
4566− * freed using av_free_packet() (i.e. avpkt->destruct will be
4567− * called to free the user supplied buffer).
4573+ * freed using av_packet_unref().
45684574 * @param[in] frame AVFrame containing the raw audio data to be encoded.
45694575 * May be NULL when flushing an encoder that has the
45704576 * AV_CODEC_CAP_DELAY capability set.
@@ -4605,8 +4611,7 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, · 34 unmodified lines
46054611 * caller, he is responsible for freeing it.
46064612 *
46074613 * If this function fails or produces no output, avpkt will be
4608− * freed using av_free_packet() (i.e. avpkt->destruct will be
4609− * called to free the user supplied buffer).
4614+ * freed using av_packet_unref().
46104615 * @param[in] frame AVFrame containing the raw video data to be encoded.
46114616 * May be NULL when flushing an encoder that has the
46124617 * 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
204204 return 0;
205205
206206 failed_alloc:
207− av_free_packet(pkt);
207+ av_packet_unref(pkt);
208208 return AVERROR(ENOMEM);
209209 }
210210
@@ -234,6 +234,8 @@ void av_packet_free_side_data(AVPacket *pkt) · 23 unmodified lines
234234 pkt->side_data_elems = 0;
235235 }
236236
237+#if FF_API_AVPACKET_OLD_API
238+FF_DISABLE_DEPRECATION_WARNINGS
237239 void av_free_packet(AVPacket *pkt)
238240 {
239241 if (pkt) {
@@ -245,6 +247,8 @@ void av_free_packet(AVPacket *pkt) · 5 unmodified lines
245247 av_packet_free_side_data(pkt);
246248 }
247249 }
250+FF_ENABLE_DEPRECATION_WARNINGS
251+#endif
248252
249253 uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
250254 int size)
libavcodec/jpeglsenc.c+1−1
@@ -405,7 +405,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 404 unmodified lines
405405 return 0;
406406
407407 memfail:
408− av_free_packet(pkt);
408+ av_packet_unref(pkt);
409409 av_freep(&buf2);
410410 av_freep(&state);
411411 av_freep(&zero);
libavcodec/libxvid.c+1−1
@@ -841,7 +841,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 840 unmodified lines
841841 return 0;
842842 } else {
843843 if (!user_packet)
844− av_free_packet(pkt);
844+ av_packet_unref(pkt);
845845 if (!xerr)
846846 return 0;
847847 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
13201320 return ret;
13211321
13221322 ret = pkt.size;
1323− av_free_packet(&pkt);
1323+ av_packet_unref(&pkt);
13241324 return ret;
13251325 }
13261326
libavcodec/utils.c+4−4
@@ -1693,7 +1693,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, · 1692 unmodified lines
16931693 *got_packet_ptr = 0;
16941694
16951695 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
1696− av_free_packet(avpkt);
1696+ av_packet_unref(avpkt);
16971697 av_init_packet(avpkt);
16981698 return 0;
16991699 }
@@ -1799,7 +1799,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, · 99 unmodified lines
17991799 }
18001800
18011801 if (ret < 0 || !*got_packet_ptr) {
1802− av_free_packet(avpkt);
1802+ av_packet_unref(avpkt);
18031803 av_init_packet(avpkt);
18041804 goto end;
18051805 }
@@ -1839,7 +1839,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, · 33 unmodified lines
18391839 avctx->stats_out[0] = '\0';
18401840
18411841 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
1842− av_free_packet(avpkt);
1842+ av_packet_unref(avpkt);
18431843 av_init_packet(avpkt);
18441844 avpkt->size = 0;
18451845 return 0;
@@ -1893,7 +1893,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, · 47 unmodified lines
18931893 }
18941894
18951895 if (ret < 0 || !*got_packet_ptr)
1896− av_free_packet(avpkt);
1896+ av_packet_unref(avpkt);
18971897
18981898 emms_c();
18991899 return ret;
libavcodec/version.h+4−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
2929 #include "libavutil/version.h"
3030
3131 #define LIBAVCODEC_VERSION_MAJOR 57
32−#define LIBAVCODEC_VERSION_MINOR 11
32+#define LIBAVCODEC_VERSION_MINOR 12
3333 #define LIBAVCODEC_VERSION_MICRO 100
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -191,5 +191,8 @@ · 155 unmodified lines
191191 #ifndef FF_API_AVPICTURE
192192 #define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
193193 #endif
194+#ifndef FF_API_AVPACKET_OLD_API
195+#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
196+#endif
194197
195198 #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
111111
112112 while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) {
113113 if (res == -EAGAIN) {
114− av_free_packet(pkt);
114+ av_packet_unref(pkt);
115115
116116 return AVERROR(EAGAIN);
117117 }
118118 if (ff_alsa_xrun_recover(s1, res) < 0) {
119119 av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",
120120 snd_strerror(res));
121− av_free_packet(pkt);
121+ av_packet_unref(pkt);
122122
123123 return AVERROR(EIO);
124124 }
libavdevice/jack.c+1−1
@@ -218,7 +218,7 @@ static void free_pkt_fifo(AVFifoBuffer **fifo) · 217 unmodified lines
218218 AVPacket pkt;
219219 while (av_fifo_size(*fifo)) {
220220 av_fifo_generic_read(*fifo, &pkt, sizeof(pkt), NULL);
221− av_free_packet(&pkt);
221+ av_packet_unref(&pkt);
222222 }
223223 av_fifo_freep(fifo);
224224 }
libavdevice/oss_dec.c+1−1
@@ -84,7 +84,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 83 unmodified lines
8484
8585 ret = read(s->fd, pkt->data, pkt->size);
8686 if (ret <= 0){
87− av_free_packet(pkt);
87+ av_packet_unref(pkt);
8888 pkt->size = 0;
8989 if (ret<0) return AVERROR(errno);
9090 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
6767
6868 ret = sio_read(s->hdl, pkt->data, pkt->size);
6969 if (ret == 0 || sio_eof(s->hdl)) {
70− av_free_packet(pkt);
70+ av_packet_unref(pkt);
7171 return AVERROR_EOF;
7272 }
7373
libavdevice/v4l2.c+1−1
@@ -550,7 +550,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt) · 549 unmodified lines
550550
551551 res = enqueue_buffer(s, &buf);
552552 if (res) {
553− av_free_packet(pkt);
553+ av_packet_unref(pkt);
554554 return res;
555555 }
556556 } else {
libavdevice/vfwcap.c+1−1
@@ -234,7 +234,7 @@ static int vfw_read_close(AVFormatContext *s) · 233 unmodified lines
234234 pktl = ctx->pktl;
235235 while (pktl) {
236236 AVPacketList *next = pktl->next;
237− av_free_packet(&pktl->pkt);
237+ av_packet_unref(&pktl->pkt);
238238 av_free(pktl);
239239 pktl = next;
240240 }
libavformat/4xm.c+1−1
@@ -321,7 +321,7 @@ static int fourxm_read_packet(AVFormatContext *s, · 320 unmodified lines
321321 ret = avio_read(s->pb, &pkt->data[8], size);
322322
323323 if (ret < 0) {
324− av_free_packet(pkt);
324+ av_packet_unref(pkt);
325325 } else {
326326 packet_read = 1;
327327 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
5252
5353 ret = av_get_packet(s->pb, pkt, size);
5454 if (ret != size) {
55− av_free_packet(pkt);
55+ av_packet_unref(pkt);
5656 return ret < 0 ? ret : AVERROR(EIO);
5757 }
5858 if (AV_RB16(pkt->data) & 0x8000) {
59− av_free_packet(pkt);
59+ av_packet_unref(pkt);
6060 return AVERROR_EOF;
6161 }
6262 pkt->size = size;
libavformat/amr.c+1−1
@@ -155,7 +155,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) · 154 unmodified lines
155155 read = avio_read(s->pb, pkt->data + 1, size - 1);
156156
157157 if (read != size - 1) {
158− av_free_packet(pkt);
158+ av_packet_unref(pkt);
159159 return AVERROR(EIO);
160160 }
161161
libavformat/asfdec_o.c+7−7
@@ -444,7 +444,7 @@ static int asf_read_picture(AVFormatContext *s, int len) · 443 unmodified lines
444444
445445 fail:
446446 av_freep(&desc);
447− av_free_packet(&pkt);
447+ av_packet_unref(&pkt);
448448 return ret;
449449 }
450450
@@ -1128,7 +1128,7 @@ static void reset_packet(ASFPacket *asf_pkt) · 677 unmodified lines
11281128 asf_pkt->flags = 0;
11291129 asf_pkt->dts = 0;
11301130 asf_pkt->duration = 0;
1131− av_free_packet(&asf_pkt->avpkt);
1131+ av_packet_unref(&asf_pkt->avpkt);
11321132 av_init_packet(&asf_pkt->avpkt);
11331133 }
11341134
@@ -1395,7 +1395,7 @@ static int asf_deinterleave(AVFormatContext *s, ASFPacket *asf_pkt, int st_num) · 260 unmodified lines
13951395 if (p > asf_pkt->avpkt.data + asf_pkt->data_size)
13961396 break;
13971397 }
1398− av_free_packet(&asf_pkt->avpkt);
1398+ av_packet_unref(&asf_pkt->avpkt);
13991399 asf_pkt->avpkt = pkt;
14001400
14011401 return 0;
@@ -1485,7 +1485,7 @@ static int asf_read_close(AVFormatContext *s) · 83 unmodified lines
14851485 for (i = 0; i < ASF_MAX_STREAMS; i++) {
14861486 av_dict_free(&asf->asf_sd[i].asf_met);
14871487 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);
14891489 av_freep(&asf->asf_st[i]);
14901490 }
14911491 }
@@ -1521,7 +1521,7 @@ static void reset_packet_state(AVFormatContext *s) · 29 unmodified lines
15211521 pkt->flags = 0;
15221522 pkt->dts = 0;
15231523 pkt->duration = 0;
1524− av_free_packet(&pkt->avpkt);
1524+ av_packet_unref(&pkt->avpkt);
15251525 av_init_packet(&pkt->avpkt);
15261526 }
15271527 }
@@ -1588,11 +1588,11 @@ static int64_t asf_read_timestamp(AVFormatContext *s, int stream_index, · 60 unmodified lines
15881588 }
15891589 if (st_found)
15901590 break;
1591− av_free_packet(&pkt);
1591+ av_packet_unref(&pkt);
15921592 }
15931593 *pos = pkt_pos;
15941594
1595− av_free_packet(&pkt);
1595+ av_packet_unref(&pkt);
15961596 return dts;
15971597 }
15981598
libavformat/avformat.h+2−2
@@ -165,7 +165,7 @@ · 164 unmodified lines
165165 * until the next av_read_frame() call or closing the file. If the caller
166166 * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy
167167 * of it.
168− * In both cases, the packet must be freed with av_free_packet() when it is no
168+ * In both cases, the packet must be freed with av_packet_unref() when it is no
169169 * longer needed.
170170 *
171171 * @section lavf_decoding_seek Seeking
@@ -2138,7 +2138,7 @@ int av_find_best_stream(AVFormatContext *ic, · 1966 unmodified lines
21382138 * If pkt->buf is NULL, then the packet is valid until the next
21392139 * av_read_frame() or until avformat_close_input(). Otherwise the packet
21402140 * 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 contains
2141+ * av_packet_unref when it is no longer needed. For video, the packet contains
21422142 * exactly one frame. For audio, it contains an integer number of frames if each
21432143 * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames
21442144 * 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
14311431 pkt->buf = avbuf;
14321432 pkt->flags |= AV_PKT_FLAG_KEY;
14331433 if (size < 0)
1434− av_free_packet(pkt);
1434+ av_packet_unref(pkt);
14351435 } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
14361436 !st->codec->codec_tag && read_gab2_sub(s, st, pkt)) {
14371437 ast->frame_offset++;
@@ -1750,7 +1750,7 @@ static void seek_subtitle(AVStream *st, AVStream *st2, int64_t timestamp) · 312 unmodified lines
17501750 {
17511751 AVIStream *ast2 = st2->priv_data;
17521752 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);
17541754 if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 ||
17551755 avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0)
17561756 ff_read_packet(ast2->sub_ctx, &ast2->sub_pkt);
@@ -1888,7 +1888,7 @@ static int avi_read_close(AVFormatContext *s) · 131 unmodified lines
18881888 avformat_close_input(&ast->sub_ctx);
18891889 }
18901890 av_freep(&ast->sub_buffer);
1891− av_free_packet(&ast->sub_pkt);
1891+ av_packet_unref(&ast->sub_pkt);
18921892 }
18931893 }
18941894
libavformat/avs.c+1−1
@@ -108,7 +108,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt, · 107 unmodified lines
108108 pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
109109 ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
110110 if (ret < size) {
111− av_free_packet(pkt);
111+ av_packet_unref(pkt);
112112 return AVERROR(EIO);
113113 }
114114
libavformat/c93.c+1−1
@@ -188,7 +188,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 187 unmodified lines
188188 return 0;
189189
190190 fail:
191− av_free_packet(pkt);
191+ av_packet_unref(pkt);
192192 return ret;
193193 }
194194
libavformat/cdg.c+1−1
@@ -63,7 +63,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 62 unmodified lines
6363 ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE);
6464 if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND)
6565 break;
66− av_free_packet(pkt);
66+ av_packet_unref(pkt);
6767 }
6868
6969 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
202202 memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE);
203203 ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size);
204204 if (ret < 0) {
205− av_free_packet(pkt);
205+ av_packet_unref(pkt);
206206 return ret;
207207 }
208208 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
9393 if (!first) {
9494 ret = av_append_packet(pb, pkt, 12);
9595 if (ret < 0) {
96− av_free_packet(pkt);
96+ av_packet_unref(pkt);
9797 return ret;
9898 }
9999 } else
@@ -114,7 +114,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt) · 14 unmodified lines
114114 }
115115 ret = av_append_packet(pb, pkt, frame_size);
116116 if (ret < 0) {
117− av_free_packet(pkt);
117+ av_packet_unref(pkt);
118118 return ret;
119119 }
120120 }
libavformat/dsicin.c+1−1
@@ -200,7 +200,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt) · 199 unmodified lines
200200
201201 ret = avio_read(pb, &pkt->data[4], pkt_size);
202202 if (ret < 0) {
203− av_free_packet(pkt);
203+ av_packet_unref(pkt);
204204 return ret;
205205 }
206206 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
267267 return pkt->size;
268268
269269 error_eof:
270− av_free_packet(pkt);
270+ av_packet_unref(pkt);
271271 return ret < 0 ? ret : AVERROR_EOF;
272272 }
273273
@@ -309,7 +309,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 35 unmodified lines
309309 ret = avio_read(s->pb, pkt->data + offset,
310310 size2 - offset);
311311 if (ret < size2 - offset) {
312− av_free_packet(pkt);
312+ av_packet_unref(pkt);
313313 return ret < 0 ? ret : AVERROR_EOF;
314314 }
315315
@@ -319,7 +319,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 3 unmodified lines
319319
320320 ret = avio_read(s->pb, pkt->data + offset, size - offset);
321321 if (ret < size - offset) {
322− av_free_packet(pkt);
322+ av_packet_unref(pkt);
323323 return ret < 0 ? ret : AVERROR_EOF;
324324 }
325325
libavformat/dxa.c+1−1
@@ -207,7 +207,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) · 206 unmodified lines
207207 memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
208208 ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
209209 if(ret != size){
210− av_free_packet(pkt);
210+ av_packet_unref(pkt);
211211 return AVERROR(EIO);
212212 }
213213 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
632632 case AV_CODEC_ID_ADPCM_EA_R3:
633633 if (pkt->size < 4) {
634634 av_log(s, AV_LOG_ERROR, "Packet is too short\n");
635− av_free_packet(pkt);
635+ av_packet_unref(pkt);
636636 return AVERROR_INVALIDDATA;
637637 }
638638 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
227227 ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
228228 size - FLIC_PREAMBLE_SIZE);
229229 if (ret != size - FLIC_PREAMBLE_SIZE) {
230− av_free_packet(pkt);
230+ av_packet_unref(pkt);
231231 ret = AVERROR(EIO);
232232 }
233233 packet_read = 1;
@@ -245,7 +245,7 @@ static int flic_read_packet(AVFormatContext *s, · 11 unmodified lines
245245 ret = avio_read(pb, pkt->data, size);
246246
247247 if (ret != size) {
248− av_free_packet(pkt);
248+ av_packet_unref(pkt);
249249 ret = AVERROR(EIO);
250250 }
251251
libavformat/g723_1.c+1−1
@@ -69,7 +69,7 @@ static int g723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 68 unmodified lines
6969
7070 ret = avio_read(s->pb, pkt->data + 1, size - 1);
7171 if (ret < size - 1) {
72− av_free_packet(pkt);
72+ av_packet_unref(pkt);
7373 return ret < 0 ? ret : AVERROR_EOF;
7474 }
7575
libavformat/gsmdec.c+1−1
@@ -45,7 +45,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines
4545
4646 ret = av_get_packet(s->pb, pkt, size);
4747 if (ret < GSM_BLOCK_SIZE) {
48− av_free_packet(pkt);
48+ av_packet_unref(pkt);
4949 return ret < 0 ? ret : AVERROR(EIO);
5050 }
5151 pkt->duration = 1;
libavformat/hls.c+3−3
@@ -243,7 +243,7 @@ static void free_playlist_list(HLSContext *c) · 242 unmodified lines
243243 av_dict_free(&pls->id3_initial);
244244 ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);
245245 av_freep(&pls->init_sec_buf);
246− av_free_packet(&pls->pkt);
246+ av_packet_unref(&pls->pkt);
247247 av_freep(&pls->pb.buffer);
248248 if (pls->input)
249249 ffurl_close(pls->input);
@@ -1824,7 +1824,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) · 1574 unmodified lines
18241824 break;
18251825 }
18261826 }
1827− av_free_packet(&pls->pkt);
1827+ av_packet_unref(&pls->pkt);
18281828 reset_packet(&pls->pkt);
18291829 }
18301830 }
@@ -1926,7 +1926,7 @@ static int hls_read_seek(AVFormatContext *s, int stream_index, · 95 unmodified lines
19261926 ffurl_close(pls->input);
19271927 pls->input = NULL;
19281928 }
1929− av_free_packet(&pls->pkt);
1929+ av_packet_unref(&pls->pkt);
19301930 reset_packet(&pls->pkt);
19311931 pls->pb.eof_reached = 0;
19321932 /* Clear any buffered data */
libavformat/hnm.c+1−1
@@ -190,7 +190,7 @@ static int hnm_read_close(AVFormatContext *s) · 189 unmodified lines
190190 Hnm4DemuxContext *hnm = s->priv_data;
191191
192192 if (hnm->vpkt.size > 0)
193− av_free_packet(&hnm->vpkt);
193+ av_packet_unref(&hnm->vpkt);
194194
195195 return 0;
196196 }
libavformat/idcin.c+2−2
@@ -313,7 +313,7 @@ static int idcin_read_packet(AVFormatContext *s, · 312 unmodified lines
313313 return ret;
314314 else if (ret != chunk_size) {
315315 av_log(s, AV_LOG_ERROR, "incomplete packet\n");
316− av_free_packet(pkt);
316+ av_packet_unref(pkt);
317317 return AVERROR(EIO);
318318 }
319319 if (command == 1) {
@@ -322,7 +322,7 @@ static int idcin_read_packet(AVFormatContext *s, · 2 unmodified lines
322322 pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
323323 AVPALETTE_SIZE);
324324 if (!pal) {
325− av_free_packet(pkt);
325+ av_packet_unref(pkt);
326326 return AVERROR(ENOMEM);
327327 }
328328 memcpy(pal, palette, AVPALETTE_SIZE);
libavformat/ilbc.c+1−1
@@ -112,7 +112,7 @@ static int ilbc_read_packet(AVFormatContext *s, · 111 unmodified lines
112112 pkt->pos = avio_tell(s->pb);
113113 pkt->duration = enc->block_align == 38 ? 160 : 240;
114114 if ((ret = avio_read(s->pb, pkt->data, enc->block_align)) != enc->block_align) {
115− av_free_packet(pkt);
115+ av_packet_unref(pkt);
116116 return ret < 0 ? ret : AVERROR(EIO);
117117 }
118118
libavformat/img2dec.c+1−1
@@ -487,7 +487,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) · 486 unmodified lines
487487 }
488488
489489 if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) {
490− av_free_packet(pkt);
490+ av_packet_unref(pkt);
491491 if (ret[0] < 0) {
492492 res = ret[0];
493493 } 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
376376 * Interleave a packet per dts in an output media file.
377377 *
378378 * 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()
380380 * on them is still safe.
381381 *
382382 * @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
180180
181181 if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
182182 s->decode_map_chunk_size) {
183− av_free_packet(pkt);
183+ av_packet_unref(pkt);
184184 return CHUNK_EOF;
185185 }
186186
@@ -189,7 +189,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, · 2 unmodified lines
189189
190190 if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
191191 s->video_chunk_size) != s->video_chunk_size) {
192− av_free_packet(pkt);
192+ av_packet_unref(pkt);
193193 return CHUNK_EOF;
194194 }
195195
libavformat/iv8.c+1−1
@@ -92,7 +92,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 91 unmodified lines
9292 ret = av_append_packet(s->pb, pkt, size);
9393 if (ret < 0) {
9494 av_log(s, AV_LOG_ERROR, "failed to grow packet\n");
95− av_free_packet(pkt);
95+ av_packet_unref(pkt);
9696 return ret;
9797 }
9898 }
libavformat/lxfdec.c+1−1
@@ -317,7 +317,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt) · 316 unmodified lines
317317 return ret2;
318318
319319 if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) {
320− av_free_packet(pkt);
320+ av_packet_unref(pkt);
321321 return ret2 < 0 ? ret2 : AVERROR_EOF;
322322 }
323323
libavformat/matroskadec.c+1−1
@@ -2292,7 +2292,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska) · 2291 unmodified lines
22922292 if (matroska->packets) {
22932293 int n;
22942294 for (n = 0; n < matroska->num_packets; n++) {
2295− av_free_packet(matroska->packets[n]);
2295+ av_packet_unref(matroska->packets[n]);
22962296 av_freep(&matroska->packets[n]);
22972297 }
22982298 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
19341934 // for DASH audio, a CuePoint has to be added when there is a new cluster.
19351935 ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt,
19361936 mkv->is_dash ? start_new_cluster : 0);
1937− av_free_packet(&mkv->cur_audio_pkt);
1937+ av_packet_unref(&mkv->cur_audio_pkt);
19381938 if (ret < 0) {
19391939 av_log(s, AV_LOG_ERROR,
19401940 "Could not write cached audio packet ret:%d\n", ret);
@@ -1993,7 +1993,7 @@ static int mkv_write_trailer(AVFormatContext *s) · 52 unmodified lines
19931993 // check if we have an audio packet cached
19941994 if (mkv->cur_audio_pkt.size > 0) {
19951995 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);
19971997 if (ret < 0) {
19981998 av_log(s, AV_LOG_ERROR,
19991999 "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
365365 while ((pktl = mp3->queue)) {
366366 if (write && (ret = mp3_write_audio_packet(s, &pktl->pkt)) < 0)
367367 write = 0;
368− av_free_packet(&pktl->pkt);
368+ av_packet_unref(&pktl->pkt);
369369 mp3->queue = pktl->next;
370370 av_freep(&pktl);
371371 }
libavformat/mpc.c+2−2
@@ -166,7 +166,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) · 165 unmodified lines
166166 if(c->curbits)
167167 avio_seek(s->pb, -4, SEEK_CUR);
168168 if(ret < size){
169− av_free_packet(pkt);
169+ av_packet_unref(pkt);
170170 return ret < 0 ? ret : AVERROR(EIO);
171171 }
172172 pkt->size = ret + 4;
@@ -217,7 +217,7 @@ static int mpc_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp · 44 unmodified lines
217217 c->curframe = lastframe;
218218 return ret;
219219 }
220− av_free_packet(pkt);
220+ av_packet_unref(pkt);
221221 }
222222 return 0;
223223 }
libavformat/mpegts.c+1−1
@@ -2611,7 +2611,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt) · 2610 unmodified lines
26112611 ret = read_packet(s, pkt->data, ts->raw_packet_size, &data);
26122612 pkt->pos = avio_tell(s->pb);
26132613 if (ret < 0) {
2614− av_free_packet(pkt);
2614+ av_packet_unref(pkt);
26152615 return ret;
26162616 }
26172617 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
923923 if (s->oformat->interleave_packet) {
924924 int ret = s->oformat->interleave_packet(s, out, in, flush);
925925 if (in)
926− av_free_packet(in);
926+ av_packet_unref(in);
927927 return ret;
928928 } else
929929 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
971971 if (ret >= 0)
972972 s->streams[opkt.stream_index]->nb_frames++;
973973
974− av_free_packet(&opkt);
974+ av_packet_unref(&opkt);
975975
976976 if (ret < 0)
977977 return ret;
@@ -999,7 +999,7 @@ int av_write_trailer(AVFormatContext *s) · 21 unmodified lines
999999 if (ret >= 0)
10001000 s->streams[pkt.stream_index]->nb_frames++;
10011001
1002− av_free_packet(&pkt);
1002+ av_packet_unref(&pkt);
10031003
10041004 if (ret < 0)
10051005 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
25892589
25902590 if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl)
25912591 s->streams[pktl->pkt.stream_index]->last_in_packet_buffer= NULL;
2592− av_free_packet(&pktl->pkt);
2592+ av_packet_unref(&pktl->pkt);
25932593 av_freep(&pktl);
25942594 pktl = next;
25952595 }
libavformat/ncdec.c+1−1
@@ -83,7 +83,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt) · 82 unmodified lines
8383
8484 ret = av_get_packet(s->pb, pkt, size);
8585 if (ret != size) {
86− if (ret > 0) av_free_packet(pkt);
86+ if (ret > 0) av_packet_unref(pkt);
8787 return AVERROR(EIO);
8888 }
8989
libavformat/nsvdec.c+2−2
@@ -713,9 +713,9 @@ static int nsv_read_close(AVFormatContext *s) · 712 unmodified lines
713713 av_freep(&nsv->nsvs_file_offset);
714714 av_freep(&nsv->nsvs_timestamps);
715715 if (nsv->ahead[0].data)
716− av_free_packet(&nsv->ahead[0]);
716+ av_packet_unref(&nsv->ahead[0]);
717717 if (nsv->ahead[1].data)
718− av_free_packet(&nsv->ahead[1]);
718+ av_packet_unref(&nsv->ahead[1]);
719719 return 0;
720720 }
721721
libavformat/nuv.c+1−1
@@ -275,7 +275,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) · 274 unmodified lines
275275 memcpy(pkt->data, hdr, copyhdrsize);
276276 ret = avio_read(pb, pkt->data + copyhdrsize, size);
277277 if (ret < 0) {
278− av_free_packet(pkt);
278+ av_packet_unref(pkt);
279279 return ret;
280280 }
281281 if (ret < size)
libavformat/psxstr.c+2−2
@@ -218,7 +218,7 @@ static int str_read_packet(AVFormatContext *s, · 217 unmodified lines
218218 if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){
219219 if(pkt->data)
220220 av_log(s, AV_LOG_ERROR, "missmatching sector_count\n");
221− av_free_packet(pkt);
221+ av_packet_unref(pkt);
222222 if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE))
223223 return AVERROR(EIO);
224224 memset(pkt->data, 0, sector_count*VIDEO_DATA_CHUNK_SIZE);
@@ -298,7 +298,7 @@ static int str_read_close(AVFormatContext *s) · 73 unmodified lines
298298 int i;
299299 for(i=0; i<32; i++){
300300 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);
302302 }
303303
304304 return 0;
libavformat/rawdec.c+1−1
@@ -45,7 +45,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines
4545 pkt->stream_index = 0;
4646 ret = ffio_read_partial(s->pb, pkt->data, size);
4747 if (ret < 0) {
48− av_free_packet(pkt);
48+ av_packet_unref(pkt);
4949 return ret;
5050 }
5151 av_shrink_packet(pkt, ret);
libavformat/rl2.c+1−1
@@ -240,7 +240,7 @@ static int rl2_read_packet(AVFormatContext *s, · 239 unmodified lines
240240 /** fill the packet */
241241 ret = av_get_packet(pb, pkt, sample->size);
242242 if(ret != sample->size){
243− av_free_packet(pkt);
243+ av_packet_unref(pkt);
244244 return AVERROR(EIO);
245245 }
246246
libavformat/rmdec.c+3−3
@@ -120,7 +120,7 @@ RMStream *ff_rm_alloc_rmstream (void) · 119 unmodified lines
120120
121121 void ff_rm_free_rmstream (RMStream *rms)
122122 {
123− av_free_packet(&rms->pkt);
123+ av_packet_unref(&rms->pkt);
124124 }
125125
126126 static 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
799799 }
800800 vst->slices = ((hdr & 0x3F) << 1) + 1;
801801 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.
803803 if(av_new_packet(&vst->pkt, vst->videobufsize) < 0)
804804 return AVERROR(ENOMEM);
805805 memset(vst->pkt.data, 0, vst->pkt.size);
@@ -1047,7 +1047,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) · 241 unmodified lines
10471047
10481048 if( (st->discard >= AVDISCARD_NONKEY && !(flags&2))
10491049 || st->discard >= AVDISCARD_ALL){
1050− av_free_packet(pkt);
1050+ av_packet_unref(pkt);
10511051 } else
10521052 break;
10531053 }
libavformat/rpl.c+2−2
@@ -311,7 +311,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) · 310 unmodified lines
311311 if (ret < 0)
312312 return ret;
313313 if (ret != frame_size) {
314− av_free_packet(pkt);
314+ av_packet_unref(pkt);
315315 return AVERROR(EIO);
316316 }
317317 pkt->duration = 1;
@@ -328,7 +328,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) · 10 unmodified lines
328328 if (ret < 0)
329329 return ret;
330330 if (ret != index_entry->size) {
331− av_free_packet(pkt);
331+ av_packet_unref(pkt);
332332 return AVERROR(EIO);
333333 }
334334
libavformat/rtpdec_asf.c+1−1
@@ -289,7 +289,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, · 288 unmodified lines
289289 return 1; // FIXME: return 0 if last packet
290290 }
291291 }
292− av_free_packet(pkt);
292+ av_packet_unref(pkt);
293293 }
294294
295295 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
136136 data->split_pos = 0;
137137 if (!data->split_buf) {
138138 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
139− av_free_packet(pkt);
139+ av_packet_unref(pkt);
140140 return AVERROR(ENOMEM);
141141 }
142142 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
217217 av_freep(&qt->pkt.data);
218218 qt->pkt.data = av_realloc(NULL, qt->remaining * qt->bytes_per_frame);
219219 if (!qt->pkt.data) {
220− av_free_packet(pkt);
220+ av_packet_unref(pkt);
221221 return AVERROR(ENOMEM);
222222 }
223223 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
141141 data->split_buf = av_malloc(data->split_buf_size);
142142 if (!data->split_buf) {
143143 av_log(ctx, AV_LOG_ERROR, "Out of memory.\n");
144− av_free_packet(pkt);
144+ av_packet_unref(pkt);
145145 return AVERROR(ENOMEM);
146146 }
147147 }
libavformat/sapdec.c+1−1
@@ -220,7 +220,7 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) · 219 unmodified lines
220220 int i = s->nb_streams;
221221 AVStream *st = avformat_new_stream(s, NULL);
222222 if (!st) {
223− av_free_packet(pkt);
223+ av_packet_unref(pkt);
224224 return AVERROR(ENOMEM);
225225 }
226226 st->id = i;
libavformat/seek-test.c+1−1
@@ -128,7 +128,7 @@ int main(int argc, char **argv) · 127 unmodified lines
128128 ts_str(dts_buf, pkt.dts, st->time_base);
129129 ts_str(ts_buf, pkt.pts, st->time_base);
130130 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);
132132 } else
133133 printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace
134134 printf("\n");
libavformat/sierravmd.c+1−1
@@ -288,7 +288,7 @@ static int vmd_read_packet(AVFormatContext *s, · 287 unmodified lines
288288 frame->frame_size);
289289
290290 if (ret != frame->frame_size) {
291− av_free_packet(pkt);
291+ av_packet_unref(pkt);
292292 ret = AVERROR(EIO);
293293 }
294294 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
193193 pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE;
194194
195195 if (avio_read(pb, pkt->data, pkt->size) < pkt->size) {
196− av_free_packet(pkt);
196+ av_packet_unref(pkt);
197197 return AVERROR_EOF;
198198 }
199199 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
201201 ret = spdif_get_offset_and_codec(s, data_type, pkt->data,
202202 &offset, &codec_id);
203203 if (ret) {
204− av_free_packet(pkt);
204+ av_packet_unref(pkt);
205205 return ret;
206206 }
207207
@@ -212,7 +212,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) · 4 unmodified lines
212212 /* first packet, create a stream */
213213 AVStream *st = avformat_new_stream(s, NULL);
214214 if (!st) {
215− av_free_packet(pkt);
215+ av_packet_unref(pkt);
216216 return AVERROR(ENOMEM);
217217 }
218218 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
180180 if (ret < 0)
181181 return ret;
182182 if (ret != size) {
183− av_free_packet(pkt);
183+ av_packet_unref(pkt);
184184 return AVERROR(EIO);
185185 }
186186
@@ -190,7 +190,7 @@ static int thp_read_packet(AVFormatContext *s, · 3 unmodified lines
190190 if (ret < 0)
191191 return ret;
192192 if (ret != thp->audiosize) {
193− av_free_packet(pkt);
193+ av_packet_unref(pkt);
194194 return AVERROR(EIO);
195195 }
196196
libavformat/utils.c+9−9
@@ -237,7 +237,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size) · 236 unmodified lines
237237
238238 pkt->pos = orig_pos;
239239 if (!pkt->size)
240− av_free_packet(pkt);
240+ av_packet_unref(pkt);
241241 return pkt->size > orig_size ? pkt->size - orig_size : ret;
242242 }
243243
@@ -696,7 +696,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) · 452 unmodified lines
696696 av_log(s, AV_LOG_WARNING,
697697 "Dropped corrupted packet (stream = %d)\n",
698698 pkt->stream_index);
699− av_free_packet(pkt);
699+ av_packet_unref(pkt);
700700 continue;
701701 }
702702
@@ -1188,7 +1188,7 @@ static void free_packet_buffer(AVPacketList **pkt_buf, AVPacketList **pkt_buf_en · 485 unmodified lines
11881188 while (*pkt_buf) {
11891189 AVPacketList *pktl = *pkt_buf;
11901190 *pkt_buf = pktl->next;
1191− av_free_packet(&pktl->pkt);
1191+ av_packet_unref(&pktl->pkt);
11921192 av_freep(&pktl);
11931193 }
11941194 *pkt_buf_end = NULL;
@@ -1282,7 +1282,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) · 87 unmodified lines
12821282 goto fail;
12831283
12841284 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);
12861286 ret = AVERROR(ENOMEM);
12871287 goto fail;
12881288 }
@@ -1295,7 +1295,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) · 6 unmodified lines
12951295 }
12961296
12971297 fail:
1298− av_free_packet(pkt);
1298+ av_packet_unref(pkt);
12991299 return ret;
13001300 }
13011301
@@ -1398,7 +1398,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 96 unmodified lines
13981398 return ret;
13991399 } else {
14001400 /* free packet */
1401− av_free_packet(&cur_pkt);
1401+ av_packet_unref(&cur_pkt);
14021402 }
14031403 if (pkt->flags & AV_PKT_FLAG_KEY)
14041404 st->skip_to_keyframe = 0;
@@ -2131,7 +2131,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index, · 726 unmodified lines
21312131 } while (read_status == AVERROR(EAGAIN));
21322132 if (read_status < 0)
21332133 break;
2134− av_free_packet(&pkt);
2134+ av_packet_unref(&pkt);
21352135 if (stream_index == pkt.stream_index && pkt.dts > timestamp) {
21362136 if (pkt.flags & AV_PKT_FLAG_KEY)
21372137 break;
@@ -2535,7 +2535,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) · 397 unmodified lines
25352535 st->info->last_duration = duration;
25362536 }
25372537 }
2538− av_free_packet(pkt);
2538+ av_packet_unref(pkt);
25392539 }
25402540
25412541 /* check if all audio/video streams have valid duration */
@@ -3664,7 +3664,7 @@ void ff_free_stream(AVFormatContext *s, AVStream *st) { · 1122 unmodified lines
36643664 av_parser_close(st->parser);
36653665 }
36663666 if (st->attached_pic.data)
3667− av_free_packet(&st->attached_pic);
3667+ av_packet_unref(&st->attached_pic);
36683668 av_dict_free(&st->metadata);
36693669 av_freep(&st->probe_data.buf);
36703670 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
246246 ret = avio_read(s->pb, pkt->data+2, size);
247247
248248 if (ret != size) {
249− av_free_packet(pkt);
249+ av_packet_unref(pkt);
250250 return AVERROR(EIO);
251251 }
252252
libavformat/wc3movie.c+1−1
@@ -295,7 +295,7 @@ static int wc3_read_close(AVFormatContext *s) · 294 unmodified lines
295295 Wc3DemuxContext *wc3 = s->priv_data;
296296
297297 if (wc3->vpkt.size > 0)
298− av_free_packet(&wc3->vpkt);
298+ av_packet_unref(&wc3->vpkt);
299299
300300 return 0;
301301 }
libavformat/wvdec.c+4−4
@@ -273,25 +273,25 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt) · 272 unmodified lines
273273 memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
274274 ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
275275 if (ret != wc->header.blocksize) {
276− av_free_packet(pkt);
276+ av_packet_unref(pkt);
277277 return AVERROR(EIO);
278278 }
279279 while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
280280 if ((ret = wv_read_block_header(s, s->pb)) < 0) {
281− av_free_packet(pkt);
281+ av_packet_unref(pkt);
282282 return ret;
283283 }
284284
285285 off = pkt->size;
286286 if ((ret = av_grow_packet(pkt, WV_HEADER_SIZE + wc->header.blocksize)) < 0) {
287− av_free_packet(pkt);
287+ av_packet_unref(pkt);
288288 return ret;
289289 }
290290 memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE);
291291
292292 ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize);
293293 if (ret != wc->header.blocksize) {
294− av_free_packet(pkt);
294+ av_packet_unref(pkt);
295295 return (ret < 0) ? ret : AVERROR_EOF;
296296 }
297297 }
libavformat/yop.c+3−3
@@ -173,14 +173,14 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt) · 172 unmodified lines
173173 return yop->audio_block_length;
174174
175175 err_out:
176− av_free_packet(&yop->video_packet);
176+ av_packet_unref(&yop->video_packet);
177177 return ret;
178178 }
179179
180180 static int yop_read_close(AVFormatContext *s)
181181 {
182182 YopDecContext *yop = s->priv_data;
183− av_free_packet(&yop->video_packet);
183+ av_packet_unref(&yop->video_packet);
184184 return 0;
185185 }
186186
@@ -205,7 +205,7 @@ static int yop_read_seek(AVFormatContext *s, int stream_index, · 18 unmodified lines
205205 if (avio_seek(s->pb, frame_pos, SEEK_SET) < 0)
206206 return -1;
207207
208− av_free_packet(&yop->video_packet);
208+ av_packet_unref(&yop->video_packet);
209209 yop->odd_frame = timestamp & 1;
210210
211211 return 0;
tools/pktdumper.c+1−1
@@ -122,7 +122,7 @@ int main(int argc, char **argv) · 121 unmodified lines
122122 }
123123 close(fd);
124124 }
125− av_free_packet(&pkt);
125+ av_packet_unref(&pkt);
126126 pktnum++;
127127 if (maxpkts && (pktnum >= maxpkts))
128128 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