* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457': avpacket: Replace av_free_packet with av_packet_unref
Unified · Split
| @@ -15,6 +15,10 @@ libavutil: 2015-08-28 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | API changes, most recent first: |
| 17 | 17 | |
| 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 | + | |
| 18 | 22 | 2015-10-22 - xxxxxxx - lavc 57.9.100 / lavc 57.5.0 - avcodec.h |
| 19 | 23 | Add data and linesize array to AVSubtitleRect, to be used instead of |
| 20 | 24 | the ones from the embedded AVPicture. |
| @@ -225,7 +225,7 @@ static void audio_encode_example(const char *filename) · 224 unmodified lines | ||
| 225 | 225 | |
| 226 | 226 | if (got_output) { |
| 227 | 227 | fwrite(pkt.data, 1, pkt.size, f); |
| 228 | − av_free_packet(&pkt); | |
| 228 | + av_packet_unref(&pkt); | |
| 229 | 229 | } |
| 230 | 230 | } |
| 231 | 231 | fclose(f); |
| @@ -454,7 +454,7 @@ static void video_encode_example(const char *filename, int codec_id) · 222 unmodified lines | ||
| 454 | 454 | if (got_output) { |
| 455 | 455 | printf("Write frame %3d (size=%5d)\n", i, pkt.size); |
| 456 | 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 | 471 | if (got_output) { |
| 472 | 472 | printf("Write frame %3d (size=%5d)\n", i, pkt.size); |
| 473 | 473 | fwrite(pkt.data, 1, pkt.size, f); |
| 474 | − av_free_packet(&pkt); | |
| 474 | + av_packet_unref(&pkt); | |
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | 477 | |
| @@ -332,7 +332,7 @@ static int decode_audio_frame(AVFrame *frame, · 331 unmodified lines | ||
| 332 | 332 | data_present, &input_packet)) < 0) { |
| 333 | 333 | fprintf(stderr, "Could not decode frame (error '%s')\n", |
| 334 | 334 | get_error_text(error)); |
| 335 | − av_free_packet(&input_packet); | |
| 335 | + av_packet_unref(&input_packet); | |
| 336 | 336 | return error; |
| 337 | 337 | } |
| 338 | 338 | |
| @@ -342,7 +342,7 @@ static int decode_audio_frame(AVFrame *frame, · 3 unmodified lines | ||
| 342 | 342 | */ |
| 343 | 343 | if (*finished && *data_present) |
| 344 | 344 | *finished = 0; |
| 345 | − av_free_packet(&input_packet); | |
| 345 | + av_packet_unref(&input_packet); | |
| 346 | 346 | return 0; |
| 347 | 347 | } |
| 348 | 348 | |
| @@ -571,7 +571,7 @@ static int encode_audio_frame(AVFrame *frame, · 222 unmodified lines | ||
| 571 | 571 | frame, data_present)) < 0) { |
| 572 | 572 | fprintf(stderr, "Could not encode frame (error '%s')\n", |
| 573 | 573 | get_error_text(error)); |
| 574 | − av_free_packet(&output_packet); | |
| 574 | + av_packet_unref(&output_packet); | |
| 575 | 575 | return error; |
| 576 | 576 | } |
| 577 | 577 | |
| @@ -580,11 +580,11 @@ static int encode_audio_frame(AVFrame *frame, · 2 unmodified lines | ||
| 580 | 580 | if ((error = av_write_frame(output_format_context, &output_packet)) < 0) { |
| 581 | 581 | fprintf(stderr, "Could not write frame (error '%s')\n", |
| 582 | 582 | get_error_text(error)); |
| 583 | − av_free_packet(&output_packet); | |
| 583 | + av_packet_unref(&output_packet); | |
| 584 | 584 | return error; |
| 585 | 585 | } |
| 586 | 586 | |
| 587 | − av_free_packet(&output_packet); | |
| 587 | + av_packet_unref(&output_packet); | |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | return 0; |
| @@ -1367,15 +1367,19 @@ typedef struct AVPacketSideData { · 1366 unmodified lines | ||
| 1367 | 1367 | * ABI. Thus it may be allocated on stack and no new fields can be added to it |
| 1368 | 1368 | * without libavcodec and libavformat major bump. |
| 1369 | 1369 | * |
| 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. | |
| 1376 | 1374 | * |
| 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 | |
| 1379 | 1383 | */ |
| 1380 | 1384 | typedef struct AVPacket { |
| 1381 | 1385 | /** |
| @@ -3899,7 +3903,7 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); · 2517 unmodified lines | ||
| 3899 | 3903 | * packet is allocated if it was not really allocated. |
| 3900 | 3904 | */ |
| 3901 | 3905 | int av_dup_packet(AVPacket *pkt); |
| 3902 | − | |
| 3906 | +#if FF_API_AVPACKET_OLD_API | |
| 3903 | 3907 | /** |
| 3904 | 3908 | * 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 | 3922 | * Free a packet. |
| 3919 | 3923 | * |
| 3924 | + * @deprecated Use av_packet_unref | |
| 3925 | + * | |
| 3920 | 3926 | * @param pkt packet to free |
| 3921 | 3927 | */ |
| 3928 | +attribute_deprecated | |
| 3922 | 3929 | void av_free_packet(AVPacket *pkt); |
| 3923 | − | |
| 3930 | +#endif | |
| 3924 | 3931 | /** |
| 3925 | 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 | 4570 | * of the output packet. |
| 4564 | 4571 | * |
| 4565 | 4572 | * 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(). | |
| 4568 | 4574 | * @param[in] frame AVFrame containing the raw audio data to be encoded. |
| 4569 | 4575 | * May be NULL when flushing an encoder that has the |
| 4570 | 4576 | * AV_CODEC_CAP_DELAY capability set. |
| @@ -4605,8 +4611,7 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, · 34 unmodified lines | ||
| 4605 | 4611 | * caller, he is responsible for freeing it. |
| 4606 | 4612 | * |
| 4607 | 4613 | * 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(). | |
| 4610 | 4615 | * @param[in] frame AVFrame containing the raw video data to be encoded. |
| 4611 | 4616 | * May be NULL when flushing an encoder that has the |
| 4612 | 4617 | * AV_CODEC_CAP_DELAY capability set. |
| @@ -204,7 +204,7 @@ int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src) · 203 unmodified lines | ||
| 204 | 204 | return 0; |
| 205 | 205 | |
| 206 | 206 | failed_alloc: |
| 207 | − av_free_packet(pkt); | |
| 207 | + av_packet_unref(pkt); | |
| 208 | 208 | return AVERROR(ENOMEM); |
| 209 | 209 | } |
| 210 | 210 | |
| @@ -234,6 +234,8 @@ void av_packet_free_side_data(AVPacket *pkt) · 23 unmodified lines | ||
| 234 | 234 | pkt->side_data_elems = 0; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | +#if FF_API_AVPACKET_OLD_API | |
| 238 | +FF_DISABLE_DEPRECATION_WARNINGS | |
| 237 | 239 | void av_free_packet(AVPacket *pkt) |
| 238 | 240 | { |
| 239 | 241 | if (pkt) { |
| @@ -245,6 +247,8 @@ void av_free_packet(AVPacket *pkt) · 5 unmodified lines | ||
| 245 | 247 | av_packet_free_side_data(pkt); |
| 246 | 248 | } |
| 247 | 249 | } |
| 250 | +FF_ENABLE_DEPRECATION_WARNINGS | |
| 251 | +#endif | |
| 248 | 252 | |
| 249 | 253 | uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, |
| 250 | 254 | int size) |
| @@ -405,7 +405,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 404 unmodified lines | ||
| 405 | 405 | return 0; |
| 406 | 406 | |
| 407 | 407 | memfail: |
| 408 | − av_free_packet(pkt); | |
| 408 | + av_packet_unref(pkt); | |
| 409 | 409 | av_freep(&buf2); |
| 410 | 410 | av_freep(&state); |
| 411 | 411 | av_freep(&zero); |
| @@ -841,7 +841,7 @@ FF_ENABLE_DEPRECATION_WARNINGS · 840 unmodified lines | ||
| 841 | 841 | return 0; |
| 842 | 842 | } else { |
| 843 | 843 | if (!user_packet) |
| 844 | − av_free_packet(pkt); | |
| 844 | + av_packet_unref(pkt); | |
| 845 | 845 | if (!xerr) |
| 846 | 846 | return 0; |
| 847 | 847 | av_log(avctx, AV_LOG_ERROR, |
| @@ -1320,7 +1320,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame) · 1319 unmodified lines | ||
| 1320 | 1320 | return ret; |
| 1321 | 1321 | |
| 1322 | 1322 | ret = pkt.size; |
| 1323 | − av_free_packet(&pkt); | |
| 1323 | + av_packet_unref(&pkt); | |
| 1324 | 1324 | return ret; |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| @@ -1693,7 +1693,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, · 1692 unmodified lines | ||
| 1693 | 1693 | *got_packet_ptr = 0; |
| 1694 | 1694 | |
| 1695 | 1695 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { |
| 1696 | − av_free_packet(avpkt); | |
| 1696 | + av_packet_unref(avpkt); | |
| 1697 | 1697 | av_init_packet(avpkt); |
| 1698 | 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 | 1801 | if (ret < 0 || !*got_packet_ptr) { |
| 1802 | − av_free_packet(avpkt); | |
| 1802 | + av_packet_unref(avpkt); | |
| 1803 | 1803 | av_init_packet(avpkt); |
| 1804 | 1804 | goto end; |
| 1805 | 1805 | } |
| @@ -1839,7 +1839,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, · 33 unmodified lines | ||
| 1839 | 1839 | avctx->stats_out[0] = '\0'; |
| 1840 | 1840 | |
| 1841 | 1841 | if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { |
| 1842 | − av_free_packet(avpkt); | |
| 1842 | + av_packet_unref(avpkt); | |
| 1843 | 1843 | av_init_packet(avpkt); |
| 1844 | 1844 | avpkt->size = 0; |
| 1845 | 1845 | return 0; |
| @@ -1893,7 +1893,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx, · 47 unmodified lines | ||
| 1893 | 1893 | } |
| 1894 | 1894 | |
| 1895 | 1895 | if (ret < 0 || !*got_packet_ptr) |
| 1896 | − av_free_packet(avpkt); | |
| 1896 | + av_packet_unref(avpkt); | |
| 1897 | 1897 | |
| 1898 | 1898 | emms_c(); |
| 1899 | 1899 | return ret; |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 29 | 29 | #include "libavutil/version.h" |
| 30 | 30 | |
| 31 | 31 | #define LIBAVCODEC_VERSION_MAJOR 57 |
| 32 | −#define LIBAVCODEC_VERSION_MINOR 11 | |
| 32 | +#define LIBAVCODEC_VERSION_MINOR 12 | |
| 33 | 33 | #define LIBAVCODEC_VERSION_MICRO 100 |
| 34 | 34 | |
| 35 | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| @@ -191,5 +191,8 @@ · 155 unmodified lines | ||
| 191 | 191 | #ifndef FF_API_AVPICTURE |
| 192 | 192 | #define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59) |
| 193 | 193 | #endif |
| 194 | +#ifndef FF_API_AVPACKET_OLD_API | |
| 195 | +#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59) | |
| 196 | +#endif | |
| 194 | 197 | |
| 195 | 198 | #endif /* AVCODEC_VERSION_H */ |
| @@ -111,14 +111,14 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 110 unmodified lines | ||
| 111 | 111 | |
| 112 | 112 | while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) { |
| 113 | 113 | if (res == -EAGAIN) { |
| 114 | − av_free_packet(pkt); | |
| 114 | + av_packet_unref(pkt); | |
| 115 | 115 | |
| 116 | 116 | return AVERROR(EAGAIN); |
| 117 | 117 | } |
| 118 | 118 | if (ff_alsa_xrun_recover(s1, res) < 0) { |
| 119 | 119 | av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n", |
| 120 | 120 | snd_strerror(res)); |
| 121 | − av_free_packet(pkt); | |
| 121 | + av_packet_unref(pkt); | |
| 122 | 122 | |
| 123 | 123 | return AVERROR(EIO); |
| 124 | 124 | } |
| @@ -218,7 +218,7 @@ static void free_pkt_fifo(AVFifoBuffer **fifo) · 217 unmodified lines | ||
| 218 | 218 | AVPacket pkt; |
| 219 | 219 | while (av_fifo_size(*fifo)) { |
| 220 | 220 | av_fifo_generic_read(*fifo, &pkt, sizeof(pkt), NULL); |
| 221 | − av_free_packet(&pkt); | |
| 221 | + av_packet_unref(&pkt); | |
| 222 | 222 | } |
| 223 | 223 | av_fifo_freep(fifo); |
| 224 | 224 | } |
| @@ -84,7 +84,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 83 unmodified lines | ||
| 84 | 84 | |
| 85 | 85 | ret = read(s->fd, pkt->data, pkt->size); |
| 86 | 86 | if (ret <= 0){ |
| 87 | − av_free_packet(pkt); | |
| 87 | + av_packet_unref(pkt); | |
| 88 | 88 | pkt->size = 0; |
| 89 | 89 | if (ret<0) return AVERROR(errno); |
| 90 | 90 | else return AVERROR_EOF; |
| @@ -67,7 +67,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) · 66 unmodified lines | ||
| 67 | 67 | |
| 68 | 68 | ret = sio_read(s->hdl, pkt->data, pkt->size); |
| 69 | 69 | if (ret == 0 || sio_eof(s->hdl)) { |
| 70 | − av_free_packet(pkt); | |
| 70 | + av_packet_unref(pkt); | |
| 71 | 71 | return AVERROR_EOF; |
| 72 | 72 | } |
| 73 | 73 | |
| @@ -550,7 +550,7 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt) · 549 unmodified lines | ||
| 550 | 550 | |
| 551 | 551 | res = enqueue_buffer(s, &buf); |
| 552 | 552 | if (res) { |
| 553 | − av_free_packet(pkt); | |
| 553 | + av_packet_unref(pkt); | |
| 554 | 554 | return res; |
| 555 | 555 | } |
| 556 | 556 | } else { |
| @@ -234,7 +234,7 @@ static int vfw_read_close(AVFormatContext *s) · 233 unmodified lines | ||
| 234 | 234 | pktl = ctx->pktl; |
| 235 | 235 | while (pktl) { |
| 236 | 236 | AVPacketList *next = pktl->next; |
| 237 | − av_free_packet(&pktl->pkt); | |
| 237 | + av_packet_unref(&pktl->pkt); | |
| 238 | 238 | av_free(pktl); |
| 239 | 239 | pktl = next; |
| 240 | 240 | } |
| @@ -321,7 +321,7 @@ static int fourxm_read_packet(AVFormatContext *s, · 320 unmodified lines | ||
| 321 | 321 | ret = avio_read(s->pb, &pkt->data[8], size); |
| 322 | 322 | |
| 323 | 323 | if (ret < 0) { |
| 324 | − av_free_packet(pkt); | |
| 324 | + av_packet_unref(pkt); | |
| 325 | 325 | } else { |
| 326 | 326 | packet_read = 1; |
| 327 | 327 | av_shrink_packet(pkt, ret + 8); |
| @@ -52,11 +52,11 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt) · 51 unmodified lines | ||
| 52 | 52 | |
| 53 | 53 | ret = av_get_packet(s->pb, pkt, size); |
| 54 | 54 | if (ret != size) { |
| 55 | − av_free_packet(pkt); | |
| 55 | + av_packet_unref(pkt); | |
| 56 | 56 | return ret < 0 ? ret : AVERROR(EIO); |
| 57 | 57 | } |
| 58 | 58 | if (AV_RB16(pkt->data) & 0x8000) { |
| 59 | − av_free_packet(pkt); | |
| 59 | + av_packet_unref(pkt); | |
| 60 | 60 | return AVERROR_EOF; |
| 61 | 61 | } |
| 62 | 62 | pkt->size = size; |
| @@ -155,7 +155,7 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) · 154 unmodified lines | ||
| 155 | 155 | read = avio_read(s->pb, pkt->data + 1, size - 1); |
| 156 | 156 | |
| 157 | 157 | if (read != size - 1) { |
| 158 | − av_free_packet(pkt); | |
| 158 | + av_packet_unref(pkt); | |
| 159 | 159 | return AVERROR(EIO); |
| 160 | 160 | } |
| 161 | 161 | |
| @@ -444,7 +444,7 @@ static int asf_read_picture(AVFormatContext *s, int len) · 443 unmodified lines | ||
| 444 | 444 | |
| 445 | 445 | fail: |
| 446 | 446 | av_freep(&desc); |
| 447 | − av_free_packet(&pkt); | |
| 447 | + av_packet_unref(&pkt); | |
| 448 | 448 | return ret; |
| 449 | 449 | } |
| 450 | 450 | |
| @@ -1128,7 +1128,7 @@ static void reset_packet(ASFPacket *asf_pkt) · 677 unmodified lines | ||
| 1128 | 1128 | asf_pkt->flags = 0; |
| 1129 | 1129 | asf_pkt->dts = 0; |
| 1130 | 1130 | asf_pkt->duration = 0; |
| 1131 | − av_free_packet(&asf_pkt->avpkt); | |
| 1131 | + av_packet_unref(&asf_pkt->avpkt); | |
| 1132 | 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 | 1395 | if (p > asf_pkt->avpkt.data + asf_pkt->data_size) |
| 1396 | 1396 | break; |
| 1397 | 1397 | } |
| 1398 | − av_free_packet(&asf_pkt->avpkt); | |
| 1398 | + av_packet_unref(&asf_pkt->avpkt); | |
| 1399 | 1399 | asf_pkt->avpkt = pkt; |
| 1400 | 1400 | |
| 1401 | 1401 | return 0; |
| @@ -1485,7 +1485,7 @@ static int asf_read_close(AVFormatContext *s) · 83 unmodified lines | ||
| 1485 | 1485 | for (i = 0; i < ASF_MAX_STREAMS; i++) { |
| 1486 | 1486 | av_dict_free(&asf->asf_sd[i].asf_met); |
| 1487 | 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 | 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 | 1521 | pkt->flags = 0; |
| 1522 | 1522 | pkt->dts = 0; |
| 1523 | 1523 | pkt->duration = 0; |
| 1524 | − av_free_packet(&pkt->avpkt); | |
| 1524 | + av_packet_unref(&pkt->avpkt); | |
| 1525 | 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 | 1589 | if (st_found) |
| 1590 | 1590 | break; |
| 1591 | − av_free_packet(&pkt); | |
| 1591 | + av_packet_unref(&pkt); | |
| 1592 | 1592 | } |
| 1593 | 1593 | *pos = pkt_pos; |
| 1594 | 1594 | |
| 1595 | − av_free_packet(&pkt); | |
| 1595 | + av_packet_unref(&pkt); | |
| 1596 | 1596 | return dts; |
| 1597 | 1597 | } |
| 1598 | 1598 | |
| @@ -165,7 +165,7 @@ · 164 unmodified lines | ||
| 165 | 165 | * until the next av_read_frame() call or closing the file. If the caller |
| 166 | 166 | * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy |
| 167 | 167 | * 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 | |
| 169 | 169 | * longer needed. |
| 170 | 170 | * |
| 171 | 171 | * @section lavf_decoding_seek Seeking |
| @@ -2138,7 +2138,7 @@ int av_find_best_stream(AVFormatContext *ic, · 1966 unmodified lines | ||
| 2138 | 2138 | * If pkt->buf is NULL, then the packet is valid until the next |
| 2139 | 2139 | * av_read_frame() or until avformat_close_input(). Otherwise the packet |
| 2140 | 2140 | * 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 | |
| 2142 | 2142 | * exactly one frame. For audio, it contains an integer number of frames if each |
| 2143 | 2143 | * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames |
| 2144 | 2144 | * have a variable size (e.g. MPEG audio), then it contains one frame. |
| @@ -1431,7 +1431,7 @@ resync: · 1430 unmodified lines | ||
| 1431 | 1431 | pkt->buf = avbuf; |
| 1432 | 1432 | pkt->flags |= AV_PKT_FLAG_KEY; |
| 1433 | 1433 | if (size < 0) |
| 1434 | − av_free_packet(pkt); | |
| 1434 | + av_packet_unref(pkt); | |
| 1435 | 1435 | } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && |
| 1436 | 1436 | !st->codec->codec_tag && read_gab2_sub(s, st, pkt)) { |
| 1437 | 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 | 1751 | AVIStream *ast2 = st2->priv_data; |
| 1752 | 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 | 1754 | if (avformat_seek_file(ast2->sub_ctx, 0, INT64_MIN, ts2, ts2, 0) >= 0 || |
| 1755 | 1755 | avformat_seek_file(ast2->sub_ctx, 0, ts2, ts2, INT64_MAX, 0) >= 0) |
| 1756 | 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 | 1888 | avformat_close_input(&ast->sub_ctx); |
| 1889 | 1889 | } |
| 1890 | 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 | |
| @@ -108,7 +108,7 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt, · 107 unmodified lines | ||
| 108 | 108 | pkt->data[palette_size + 3] = (size >> 8) & 0xFF; |
| 109 | 109 | ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4; |
| 110 | 110 | if (ret < size) { |
| 111 | − av_free_packet(pkt); | |
| 111 | + av_packet_unref(pkt); | |
| 112 | 112 | return AVERROR(EIO); |
| 113 | 113 | } |
| 114 | 114 | |
| @@ -188,7 +188,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 187 unmodified lines | ||
| 188 | 188 | return 0; |
| 189 | 189 | |
| 190 | 190 | fail: |
| 191 | − av_free_packet(pkt); | |
| 191 | + av_packet_unref(pkt); | |
| 192 | 192 | return ret; |
| 193 | 193 | } |
| 194 | 194 | |
| @@ -63,7 +63,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 62 unmodified lines | ||
| 63 | 63 | ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE); |
| 64 | 64 | if (ret < 1 || (pkt->data[0] & CDG_MASK) == CDG_COMMAND) |
| 65 | 65 | break; |
| 66 | − av_free_packet(pkt); | |
| 66 | + av_packet_unref(pkt); | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | if (!priv->got_first_packet) { |
| @@ -202,7 +202,7 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt) · 201 unmodified lines | ||
| 202 | 202 | memcpy(pkt->data, cdxl->header, CDXL_HEADER_SIZE); |
| 203 | 203 | ret = avio_read(pb, pkt->data + CDXL_HEADER_SIZE, video_size); |
| 204 | 204 | if (ret < 0) { |
| 205 | − av_free_packet(pkt); | |
| 205 | + av_packet_unref(pkt); | |
| 206 | 206 | return ret; |
| 207 | 207 | } |
| 208 | 208 | av_shrink_packet(pkt, CDXL_HEADER_SIZE + ret); |
| @@ -93,7 +93,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt) · 92 unmodified lines | ||
| 93 | 93 | if (!first) { |
| 94 | 94 | ret = av_append_packet(pb, pkt, 12); |
| 95 | 95 | if (ret < 0) { |
| 96 | − av_free_packet(pkt); | |
| 96 | + av_packet_unref(pkt); | |
| 97 | 97 | return ret; |
| 98 | 98 | } |
| 99 | 99 | } else |
| @@ -114,7 +114,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt) · 14 unmodified lines | ||
| 114 | 114 | } |
| 115 | 115 | ret = av_append_packet(pb, pkt, frame_size); |
| 116 | 116 | if (ret < 0) { |
| 117 | − av_free_packet(pkt); | |
| 117 | + av_packet_unref(pkt); | |
| 118 | 118 | return ret; |
| 119 | 119 | } |
| 120 | 120 | } |
| @@ -200,7 +200,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt) · 199 unmodified lines | ||
| 200 | 200 | |
| 201 | 201 | ret = avio_read(pb, &pkt->data[4], pkt_size); |
| 202 | 202 | if (ret < 0) { |
| 203 | − av_free_packet(pkt); | |
| 203 | + av_packet_unref(pkt); | |
| 204 | 204 | return ret; |
| 205 | 205 | } |
| 206 | 206 | if (ret < pkt_size) |
| @@ -267,7 +267,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt) · 266 unmodified lines | ||
| 267 | 267 | return pkt->size; |
| 268 | 268 | |
| 269 | 269 | error_eof: |
| 270 | − av_free_packet(pkt); | |
| 270 | + av_packet_unref(pkt); | |
| 271 | 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 | 309 | ret = avio_read(s->pb, pkt->data + offset, |
| 310 | 310 | size2 - offset); |
| 311 | 311 | if (ret < size2 - offset) { |
| 312 | − av_free_packet(pkt); | |
| 312 | + av_packet_unref(pkt); | |
| 313 | 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 | 320 | ret = avio_read(s->pb, pkt->data + offset, size - offset); |
| 321 | 321 | if (ret < size - offset) { |
| 322 | − av_free_packet(pkt); | |
| 322 | + av_packet_unref(pkt); | |
| 323 | 323 | return ret < 0 ? ret : AVERROR_EOF; |
| 324 | 324 | } |
| 325 | 325 | |
| @@ -207,7 +207,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt) · 206 unmodified lines | ||
| 207 | 207 | memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE); |
| 208 | 208 | ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size); |
| 209 | 209 | if(ret != size){ |
| 210 | − av_free_packet(pkt); | |
| 210 | + av_packet_unref(pkt); | |
| 211 | 211 | return AVERROR(EIO); |
| 212 | 212 | } |
| 213 | 213 | if(pal_size) memcpy(pkt->data, pal, pal_size); |
| @@ -632,7 +632,7 @@ static int ea_read_packet(AVFormatContext *s, AVPacket *pkt) · 631 unmodified lines | ||
| 632 | 632 | case AV_CODEC_ID_ADPCM_EA_R3: |
| 633 | 633 | if (pkt->size < 4) { |
| 634 | 634 | av_log(s, AV_LOG_ERROR, "Packet is too short\n"); |
| 635 | − av_free_packet(pkt); | |
| 635 | + av_packet_unref(pkt); | |
| 636 | 636 | return AVERROR_INVALIDDATA; |
| 637 | 637 | } |
| 638 | 638 | if (ea->audio_codec == AV_CODEC_ID_ADPCM_EA_R3) |
| @@ -227,7 +227,7 @@ static int flic_read_packet(AVFormatContext *s, · 226 unmodified lines | ||
| 227 | 227 | ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE, |
| 228 | 228 | size - FLIC_PREAMBLE_SIZE); |
| 229 | 229 | if (ret != size - FLIC_PREAMBLE_SIZE) { |
| 230 | − av_free_packet(pkt); | |
| 230 | + av_packet_unref(pkt); | |
| 231 | 231 | ret = AVERROR(EIO); |
| 232 | 232 | } |
| 233 | 233 | packet_read = 1; |
| @@ -245,7 +245,7 @@ static int flic_read_packet(AVFormatContext *s, · 11 unmodified lines | ||
| 245 | 245 | ret = avio_read(pb, pkt->data, size); |
| 246 | 246 | |
| 247 | 247 | if (ret != size) { |
| 248 | − av_free_packet(pkt); | |
| 248 | + av_packet_unref(pkt); | |
| 249 | 249 | ret = AVERROR(EIO); |
| 250 | 250 | } |
| 251 | 251 | |
| @@ -69,7 +69,7 @@ static int g723_1_read_packet(AVFormatContext *s, AVPacket *pkt) · 68 unmodified lines | ||
| 69 | 69 | |
| 70 | 70 | ret = avio_read(s->pb, pkt->data + 1, size - 1); |
| 71 | 71 | if (ret < size - 1) { |
| 72 | − av_free_packet(pkt); | |
| 72 | + av_packet_unref(pkt); | |
| 73 | 73 | return ret < 0 ? ret : AVERROR_EOF; |
| 74 | 74 | } |
| 75 | 75 | |
| @@ -45,7 +45,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines | ||
| 45 | 45 | |
| 46 | 46 | ret = av_get_packet(s->pb, pkt, size); |
| 47 | 47 | if (ret < GSM_BLOCK_SIZE) { |
| 48 | − av_free_packet(pkt); | |
| 48 | + av_packet_unref(pkt); | |
| 49 | 49 | return ret < 0 ? ret : AVERROR(EIO); |
| 50 | 50 | } |
| 51 | 51 | pkt->duration = 1; |
| @@ -243,7 +243,7 @@ static void free_playlist_list(HLSContext *c) · 242 unmodified lines | ||
| 243 | 243 | av_dict_free(&pls->id3_initial); |
| 244 | 244 | ff_id3v2_free_extra_meta(&pls->id3_deferred_extra); |
| 245 | 245 | av_freep(&pls->init_sec_buf); |
| 246 | − av_free_packet(&pls->pkt); | |
| 246 | + av_packet_unref(&pls->pkt); | |
| 247 | 247 | av_freep(&pls->pb.buffer); |
| 248 | 248 | if (pls->input) |
| 249 | 249 | ffurl_close(pls->input); |
| @@ -1824,7 +1824,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) · 1574 unmodified lines | ||
| 1824 | 1824 | break; |
| 1825 | 1825 | } |
| 1826 | 1826 | } |
| 1827 | − av_free_packet(&pls->pkt); | |
| 1827 | + av_packet_unref(&pls->pkt); | |
| 1828 | 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 | 1926 | ffurl_close(pls->input); |
| 1927 | 1927 | pls->input = NULL; |
| 1928 | 1928 | } |
| 1929 | − av_free_packet(&pls->pkt); | |
| 1929 | + av_packet_unref(&pls->pkt); | |
| 1930 | 1930 | reset_packet(&pls->pkt); |
| 1931 | 1931 | pls->pb.eof_reached = 0; |
| 1932 | 1932 | /* Clear any buffered data */ |
| @@ -190,7 +190,7 @@ static int hnm_read_close(AVFormatContext *s) · 189 unmodified lines | ||
| 190 | 190 | Hnm4DemuxContext *hnm = s->priv_data; |
| 191 | 191 | |
| 192 | 192 | if (hnm->vpkt.size > 0) |
| 193 | − av_free_packet(&hnm->vpkt); | |
| 193 | + av_packet_unref(&hnm->vpkt); | |
| 194 | 194 | |
| 195 | 195 | return 0; |
| 196 | 196 | } |
| @@ -313,7 +313,7 @@ static int idcin_read_packet(AVFormatContext *s, · 312 unmodified lines | ||
| 313 | 313 | return ret; |
| 314 | 314 | else if (ret != chunk_size) { |
| 315 | 315 | av_log(s, AV_LOG_ERROR, "incomplete packet\n"); |
| 316 | − av_free_packet(pkt); | |
| 316 | + av_packet_unref(pkt); | |
| 317 | 317 | return AVERROR(EIO); |
| 318 | 318 | } |
| 319 | 319 | if (command == 1) { |
| @@ -322,7 +322,7 @@ static int idcin_read_packet(AVFormatContext *s, · 2 unmodified lines | ||
| 322 | 322 | pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, |
| 323 | 323 | AVPALETTE_SIZE); |
| 324 | 324 | if (!pal) { |
| 325 | − av_free_packet(pkt); | |
| 325 | + av_packet_unref(pkt); | |
| 326 | 326 | return AVERROR(ENOMEM); |
| 327 | 327 | } |
| 328 | 328 | memcpy(pal, palette, AVPALETTE_SIZE); |
| @@ -112,7 +112,7 @@ static int ilbc_read_packet(AVFormatContext *s, · 111 unmodified lines | ||
| 112 | 112 | pkt->pos = avio_tell(s->pb); |
| 113 | 113 | pkt->duration = enc->block_align == 38 ? 160 : 240; |
| 114 | 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 | 116 | return ret < 0 ? ret : AVERROR(EIO); |
| 117 | 117 | } |
| 118 | 118 | |
| @@ -487,7 +487,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt) · 486 unmodified lines | ||
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | if (ret[0] <= 0 || ret[1] < 0 || ret[2] < 0) { |
| 490 | − av_free_packet(pkt); | |
| 490 | + av_packet_unref(pkt); | |
| 491 | 491 | if (ret[0] < 0) { |
| 492 | 492 | res = ret[0]; |
| 493 | 493 | } else if (ret[1] < 0) { |
| @@ -376,7 +376,7 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt); · 375 unmodified lines | ||
| 376 | 376 | * Interleave a packet per dts in an output media file. |
| 377 | 377 | * |
| 378 | 378 | * 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 | 380 | * on them is still safe. |
| 381 | 381 | * |
| 382 | 382 | * @param s media file handle |
| @@ -180,7 +180,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb, · 179 unmodified lines | ||
| 180 | 180 | |
| 181 | 181 | if (avio_read(pb, pkt->data, s->decode_map_chunk_size) != |
| 182 | 182 | s->decode_map_chunk_size) { |
| 183 | − av_free_packet(pkt); | |
| 183 | + av_packet_unref(pkt); | |
| 184 | 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 | 190 | if (avio_read(pb, pkt->data + s->decode_map_chunk_size, |
| 191 | 191 | s->video_chunk_size) != s->video_chunk_size) { |
| 192 | − av_free_packet(pkt); | |
| 192 | + av_packet_unref(pkt); | |
| 193 | 193 | return CHUNK_EOF; |
| 194 | 194 | } |
| 195 | 195 | |
| @@ -92,7 +92,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) · 91 unmodified lines | ||
| 92 | 92 | ret = av_append_packet(s->pb, pkt, size); |
| 93 | 93 | if (ret < 0) { |
| 94 | 94 | av_log(s, AV_LOG_ERROR, "failed to grow packet\n"); |
| 95 | − av_free_packet(pkt); | |
| 95 | + av_packet_unref(pkt); | |
| 96 | 96 | return ret; |
| 97 | 97 | } |
| 98 | 98 | } |
| @@ -317,7 +317,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt) · 316 unmodified lines | ||
| 317 | 317 | return ret2; |
| 318 | 318 | |
| 319 | 319 | if ((ret2 = avio_read(pb, pkt->data, ret)) != ret) { |
| 320 | − av_free_packet(pkt); | |
| 320 | + av_packet_unref(pkt); | |
| 321 | 321 | return ret2 < 0 ? ret2 : AVERROR_EOF; |
| 322 | 322 | } |
| 323 | 323 | |
| @@ -2292,7 +2292,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska) · 2291 unmodified lines | ||
| 2292 | 2292 | if (matroska->packets) { |
| 2293 | 2293 | int n; |
| 2294 | 2294 | for (n = 0; n < matroska->num_packets; n++) { |
| 2295 | − av_free_packet(matroska->packets[n]); | |
| 2295 | + av_packet_unref(matroska->packets[n]); | |
| 2296 | 2296 | av_freep(&matroska->packets[n]); |
| 2297 | 2297 | } |
| 2298 | 2298 | av_freep(&matroska->packets); |
| @@ -1934,7 +1934,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) · 1933 unmodified lines | ||
| 1934 | 1934 | // for DASH audio, a CuePoint has to be added when there is a new cluster. |
| 1935 | 1935 | ret = mkv_write_packet_internal(s, &mkv->cur_audio_pkt, |
| 1936 | 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 | 1938 | if (ret < 0) { |
| 1939 | 1939 | av_log(s, AV_LOG_ERROR, |
| 1940 | 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 | 1993 | // check if we have an audio packet cached |
| 1994 | 1994 | if (mkv->cur_audio_pkt.size > 0) { |
| 1995 | 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 | 1997 | if (ret < 0) { |
| 1998 | 1998 | av_log(s, AV_LOG_ERROR, |
| 1999 | 1999 | "Could not write cached audio packet ret:%d\n", ret); |
| @@ -365,7 +365,7 @@ static int mp3_queue_flush(AVFormatContext *s) · 364 unmodified lines | ||
| 365 | 365 | while ((pktl = mp3->queue)) { |
| 366 | 366 | if (write && (ret = mp3_write_audio_packet(s, &pktl->pkt)) < 0) |
| 367 | 367 | write = 0; |
| 368 | − av_free_packet(&pktl->pkt); | |
| 368 | + av_packet_unref(&pktl->pkt); | |
| 369 | 369 | mp3->queue = pktl->next; |
| 370 | 370 | av_freep(&pktl); |
| 371 | 371 | } |
| @@ -166,7 +166,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) · 165 unmodified lines | ||
| 166 | 166 | if(c->curbits) |
| 167 | 167 | avio_seek(s->pb, -4, SEEK_CUR); |
| 168 | 168 | if(ret < size){ |
| 169 | − av_free_packet(pkt); | |
| 169 | + av_packet_unref(pkt); | |
| 170 | 170 | return ret < 0 ? ret : AVERROR(EIO); |
| 171 | 171 | } |
| 172 | 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 | 217 | c->curframe = lastframe; |
| 218 | 218 | return ret; |
| 219 | 219 | } |
| 220 | − av_free_packet(pkt); | |
| 220 | + av_packet_unref(pkt); | |
| 221 | 221 | } |
| 222 | 222 | return 0; |
| 223 | 223 | } |
| @@ -2611,7 +2611,7 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt) · 2610 unmodified lines | ||
| 2611 | 2611 | ret = read_packet(s, pkt->data, ts->raw_packet_size, &data); |
| 2612 | 2612 | pkt->pos = avio_tell(s->pb); |
| 2613 | 2613 | if (ret < 0) { |
| 2614 | − av_free_packet(pkt); | |
| 2614 | + av_packet_unref(pkt); | |
| 2615 | 2615 | return ret; |
| 2616 | 2616 | } |
| 2617 | 2617 | if (data != pkt->data) |
| @@ -923,7 +923,7 @@ static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, in · 922 unmodified lines | ||
| 923 | 923 | if (s->oformat->interleave_packet) { |
| 924 | 924 | int ret = s->oformat->interleave_packet(s, out, in, flush); |
| 925 | 925 | if (in) |
| 926 | − av_free_packet(in); | |
| 926 | + av_packet_unref(in); | |
| 927 | 927 | return ret; |
| 928 | 928 | } else |
| 929 | 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 | 971 | if (ret >= 0) |
| 972 | 972 | s->streams[opkt.stream_index]->nb_frames++; |
| 973 | 973 | |
| 974 | − av_free_packet(&opkt); | |
| 974 | + av_packet_unref(&opkt); | |
| 975 | 975 | |
| 976 | 976 | if (ret < 0) |
| 977 | 977 | return ret; |
| @@ -999,7 +999,7 @@ int av_write_trailer(AVFormatContext *s) · 21 unmodified lines | ||
| 999 | 999 | if (ret >= 0) |
| 1000 | 1000 | s->streams[pkt.stream_index]->nb_frames++; |
| 1001 | 1001 | |
| 1002 | − av_free_packet(&pkt); | |
| 1002 | + av_packet_unref(&pkt); | |
| 1003 | 1003 | |
| 1004 | 1004 | if (ret < 0) |
| 1005 | 1005 | goto fail; |
| @@ -2589,7 +2589,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket · 2588 unmodified lines | ||
| 2589 | 2589 | |
| 2590 | 2590 | if(s->streams[pktl->pkt.stream_index]->last_in_packet_buffer == pktl) |
| 2591 | 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 | 2593 | av_freep(&pktl); |
| 2594 | 2594 | pktl = next; |
| 2595 | 2595 | } |
| @@ -83,7 +83,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt) · 82 unmodified lines | ||
| 83 | 83 | |
| 84 | 84 | ret = av_get_packet(s->pb, pkt, size); |
| 85 | 85 | if (ret != size) { |
| 86 | − if (ret > 0) av_free_packet(pkt); | |
| 86 | + if (ret > 0) av_packet_unref(pkt); | |
| 87 | 87 | return AVERROR(EIO); |
| 88 | 88 | } |
| 89 | 89 | |
| @@ -713,9 +713,9 @@ static int nsv_read_close(AVFormatContext *s) · 712 unmodified lines | ||
| 713 | 713 | av_freep(&nsv->nsvs_file_offset); |
| 714 | 714 | av_freep(&nsv->nsvs_timestamps); |
| 715 | 715 | if (nsv->ahead[0].data) |
| 716 | − av_free_packet(&nsv->ahead[0]); | |
| 716 | + av_packet_unref(&nsv->ahead[0]); | |
| 717 | 717 | if (nsv->ahead[1].data) |
| 718 | − av_free_packet(&nsv->ahead[1]); | |
| 718 | + av_packet_unref(&nsv->ahead[1]); | |
| 719 | 719 | return 0; |
| 720 | 720 | } |
| 721 | 721 | |
| @@ -275,7 +275,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) · 274 unmodified lines | ||
| 275 | 275 | memcpy(pkt->data, hdr, copyhdrsize); |
| 276 | 276 | ret = avio_read(pb, pkt->data + copyhdrsize, size); |
| 277 | 277 | if (ret < 0) { |
| 278 | − av_free_packet(pkt); | |
| 278 | + av_packet_unref(pkt); | |
| 279 | 279 | return ret; |
| 280 | 280 | } |
| 281 | 281 | if (ret < size) |
| @@ -218,7 +218,7 @@ static int str_read_packet(AVFormatContext *s, · 217 unmodified lines | ||
| 218 | 218 | if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){ |
| 219 | 219 | if(pkt->data) |
| 220 | 220 | av_log(s, AV_LOG_ERROR, "missmatching sector_count\n"); |
| 221 | − av_free_packet(pkt); | |
| 221 | + av_packet_unref(pkt); | |
| 222 | 222 | if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE)) |
| 223 | 223 | return AVERROR(EIO); |
| 224 | 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 | 298 | int i; |
| 299 | 299 | for(i=0; i<32; i++){ |
| 300 | 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 | 304 | return 0; |
| @@ -45,7 +45,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) · 44 unmodified lines | ||
| 45 | 45 | pkt->stream_index = 0; |
| 46 | 46 | ret = ffio_read_partial(s->pb, pkt->data, size); |
| 47 | 47 | if (ret < 0) { |
| 48 | − av_free_packet(pkt); | |
| 48 | + av_packet_unref(pkt); | |
| 49 | 49 | return ret; |
| 50 | 50 | } |
| 51 | 51 | av_shrink_packet(pkt, ret); |
| @@ -240,7 +240,7 @@ static int rl2_read_packet(AVFormatContext *s, · 239 unmodified lines | ||
| 240 | 240 | /** fill the packet */ |
| 241 | 241 | ret = av_get_packet(pb, pkt, sample->size); |
| 242 | 242 | if(ret != sample->size){ |
| 243 | − av_free_packet(pkt); | |
| 243 | + av_packet_unref(pkt); | |
| 244 | 244 | return AVERROR(EIO); |
| 245 | 245 | } |
| 246 | 246 | |
| @@ -120,7 +120,7 @@ RMStream *ff_rm_alloc_rmstream (void) · 119 unmodified lines | ||
| 120 | 120 | |
| 121 | 121 | void ff_rm_free_rmstream (RMStream *rms) |
| 122 | 122 | { |
| 123 | − av_free_packet(&rms->pkt); | |
| 123 | + av_packet_unref(&rms->pkt); | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | 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 | ||
| 799 | 799 | } |
| 800 | 800 | vst->slices = ((hdr & 0x3F) << 1) + 1; |
| 801 | 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 | 803 | if(av_new_packet(&vst->pkt, vst->videobufsize) < 0) |
| 804 | 804 | return AVERROR(ENOMEM); |
| 805 | 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 | 1048 | if( (st->discard >= AVDISCARD_NONKEY && !(flags&2)) |
| 1049 | 1049 | || st->discard >= AVDISCARD_ALL){ |
| 1050 | − av_free_packet(pkt); | |
| 1050 | + av_packet_unref(pkt); | |
| 1051 | 1051 | } else |
| 1052 | 1052 | break; |
| 1053 | 1053 | } |
| @@ -311,7 +311,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) · 310 unmodified lines | ||
| 311 | 311 | if (ret < 0) |
| 312 | 312 | return ret; |
| 313 | 313 | if (ret != frame_size) { |
| 314 | − av_free_packet(pkt); | |
| 314 | + av_packet_unref(pkt); | |
| 315 | 315 | return AVERROR(EIO); |
| 316 | 316 | } |
| 317 | 317 | pkt->duration = 1; |
| @@ -328,7 +328,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt) · 10 unmodified lines | ||
| 328 | 328 | if (ret < 0) |
| 329 | 329 | return ret; |
| 330 | 330 | if (ret != index_entry->size) { |
| 331 | − av_free_packet(pkt); | |
| 331 | + av_packet_unref(pkt); | |
| 332 | 332 | return AVERROR(EIO); |
| 333 | 333 | } |
| 334 | 334 | |
| @@ -289,7 +289,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, · 288 unmodified lines | ||
| 289 | 289 | 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 | 295 | return res == 1 ? -1 : res; |
| @@ -136,7 +136,7 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data, · 135 unmodified lines | ||
| 136 | 136 | data->split_pos = 0; |
| 137 | 137 | if (!data->split_buf) { |
| 138 | 138 | av_log(ctx, AV_LOG_ERROR, "Out of memory.\n"); |
| 139 | − av_free_packet(pkt); | |
| 139 | + av_packet_unref(pkt); | |
| 140 | 140 | return AVERROR(ENOMEM); |
| 141 | 141 | } |
| 142 | 142 | memcpy(data->split_buf, buf, data->split_buf_size); |
| @@ -217,7 +217,7 @@ static int qt_rtp_parse_packet(AVFormatContext *s, PayloadContext *qt, · 216 unmodified lines | ||
| 217 | 217 | av_freep(&qt->pkt.data); |
| 218 | 218 | qt->pkt.data = av_realloc(NULL, qt->remaining * qt->bytes_per_frame); |
| 219 | 219 | if (!qt->pkt.data) { |
| 220 | − av_free_packet(pkt); | |
| 220 | + av_packet_unref(pkt); | |
| 221 | 221 | return AVERROR(ENOMEM); |
| 222 | 222 | } |
| 223 | 223 | qt->pkt.size = qt->remaining * qt->bytes_per_frame; |
| @@ -141,7 +141,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, · 140 unmodified lines | ||
| 141 | 141 | data->split_buf = av_malloc(data->split_buf_size); |
| 142 | 142 | if (!data->split_buf) { |
| 143 | 143 | av_log(ctx, AV_LOG_ERROR, "Out of memory.\n"); |
| 144 | − av_free_packet(pkt); | |
| 144 | + av_packet_unref(pkt); | |
| 145 | 145 | return AVERROR(ENOMEM); |
| 146 | 146 | } |
| 147 | 147 | } |
| @@ -220,7 +220,7 @@ static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) · 219 unmodified lines | ||
| 220 | 220 | int i = s->nb_streams; |
| 221 | 221 | AVStream *st = avformat_new_stream(s, NULL); |
| 222 | 222 | if (!st) { |
| 223 | − av_free_packet(pkt); | |
| 223 | + av_packet_unref(pkt); | |
| 224 | 224 | return AVERROR(ENOMEM); |
| 225 | 225 | } |
| 226 | 226 | st->id = i; |
| @@ -128,7 +128,7 @@ int main(int argc, char **argv) · 127 unmodified lines | ||
| 128 | 128 | ts_str(dts_buf, pkt.dts, st->time_base); |
| 129 | 129 | ts_str(ts_buf, pkt.pts, st->time_base); |
| 130 | 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 | 132 | } else |
| 133 | 133 | printf("ret:%s", ret_str(ret)); // necessary to avoid trailing whitespace |
| 134 | 134 | printf("\n"); |
| @@ -288,7 +288,7 @@ static int vmd_read_packet(AVFormatContext *s, · 287 unmodified lines | ||
| 288 | 288 | frame->frame_size); |
| 289 | 289 | |
| 290 | 290 | if (ret != frame->frame_size) { |
| 291 | − av_free_packet(pkt); | |
| 291 | + av_packet_unref(pkt); | |
| 292 | 292 | ret = AVERROR(EIO); |
| 293 | 293 | } |
| 294 | 294 | pkt->stream_index = frame->stream_index; |
| @@ -193,7 +193,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) · 192 unmodified lines | ||
| 193 | 193 | pkt->pos = avio_tell(pb) - BURST_HEADER_SIZE; |
| 194 | 194 | |
| 195 | 195 | if (avio_read(pb, pkt->data, pkt->size) < pkt->size) { |
| 196 | − av_free_packet(pkt); | |
| 196 | + av_packet_unref(pkt); | |
| 197 | 197 | return AVERROR_EOF; |
| 198 | 198 | } |
| 199 | 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 | 201 | ret = spdif_get_offset_and_codec(s, data_type, pkt->data, |
| 202 | 202 | &offset, &codec_id); |
| 203 | 203 | if (ret) { |
| 204 | − av_free_packet(pkt); | |
| 204 | + av_packet_unref(pkt); | |
| 205 | 205 | return ret; |
| 206 | 206 | } |
| 207 | 207 | |
| @@ -212,7 +212,7 @@ int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt) · 4 unmodified lines | ||
| 212 | 212 | /* first packet, create a stream */ |
| 213 | 213 | AVStream *st = avformat_new_stream(s, NULL); |
| 214 | 214 | if (!st) { |
| 215 | − av_free_packet(pkt); | |
| 215 | + av_packet_unref(pkt); | |
| 216 | 216 | return AVERROR(ENOMEM); |
| 217 | 217 | } |
| 218 | 218 | st->codec->codec_type = AVMEDIA_TYPE_AUDIO; |
| @@ -180,7 +180,7 @@ static int thp_read_packet(AVFormatContext *s, · 179 unmodified lines | ||
| 180 | 180 | if (ret < 0) |
| 181 | 181 | return ret; |
| 182 | 182 | if (ret != size) { |
| 183 | − av_free_packet(pkt); | |
| 183 | + av_packet_unref(pkt); | |
| 184 | 184 | return AVERROR(EIO); |
| 185 | 185 | } |
| 186 | 186 | |
| @@ -190,7 +190,7 @@ static int thp_read_packet(AVFormatContext *s, · 3 unmodified lines | ||
| 190 | 190 | if (ret < 0) |
| 191 | 191 | return ret; |
| 192 | 192 | if (ret != thp->audiosize) { |
| 193 | − av_free_packet(pkt); | |
| 193 | + av_packet_unref(pkt); | |
| 194 | 194 | return AVERROR(EIO); |
| 195 | 195 | } |
| 196 | 196 | |
| @@ -237,7 +237,7 @@ static int append_packet_chunked(AVIOContext *s, AVPacket *pkt, int size) · 236 unmodified lines | ||
| 237 | 237 | |
| 238 | 238 | pkt->pos = orig_pos; |
| 239 | 239 | if (!pkt->size) |
| 240 | − av_free_packet(pkt); | |
| 240 | + av_packet_unref(pkt); | |
| 241 | 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 | 696 | av_log(s, AV_LOG_WARNING, |
| 697 | 697 | "Dropped corrupted packet (stream = %d)\n", |
| 698 | 698 | pkt->stream_index); |
| 699 | − av_free_packet(pkt); | |
| 699 | + av_packet_unref(pkt); | |
| 700 | 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 | 1188 | while (*pkt_buf) { |
| 1189 | 1189 | AVPacketList *pktl = *pkt_buf; |
| 1190 | 1190 | *pkt_buf = pktl->next; |
| 1191 | − av_free_packet(&pktl->pkt); | |
| 1191 | + av_packet_unref(&pktl->pkt); | |
| 1192 | 1192 | av_freep(&pktl); |
| 1193 | 1193 | } |
| 1194 | 1194 | *pkt_buf_end = NULL; |
| @@ -1282,7 +1282,7 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) · 87 unmodified lines | ||
| 1282 | 1282 | goto fail; |
| 1283 | 1283 | |
| 1284 | 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 | 1286 | ret = AVERROR(ENOMEM); |
| 1287 | 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 | |
| 1297 | 1297 | fail: |
| 1298 | − av_free_packet(pkt); | |
| 1298 | + av_packet_unref(pkt); | |
| 1299 | 1299 | return ret; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| @@ -1398,7 +1398,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 96 unmodified lines | ||
| 1398 | 1398 | return ret; |
| 1399 | 1399 | } else { |
| 1400 | 1400 | /* free packet */ |
| 1401 | − av_free_packet(&cur_pkt); | |
| 1401 | + av_packet_unref(&cur_pkt); | |
| 1402 | 1402 | } |
| 1403 | 1403 | if (pkt->flags & AV_PKT_FLAG_KEY) |
| 1404 | 1404 | st->skip_to_keyframe = 0; |
| @@ -2131,7 +2131,7 @@ static int seek_frame_generic(AVFormatContext *s, int stream_index, · 726 unmodified lines | ||
| 2131 | 2131 | } while (read_status == AVERROR(EAGAIN)); |
| 2132 | 2132 | if (read_status < 0) |
| 2133 | 2133 | break; |
| 2134 | − av_free_packet(&pkt); | |
| 2134 | + av_packet_unref(&pkt); | |
| 2135 | 2135 | if (stream_index == pkt.stream_index && pkt.dts > timestamp) { |
| 2136 | 2136 | if (pkt.flags & AV_PKT_FLAG_KEY) |
| 2137 | 2137 | break; |
| @@ -2535,7 +2535,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) · 397 unmodified lines | ||
| 2535 | 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 | 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 | 3664 | av_parser_close(st->parser); |
| 3665 | 3665 | } |
| 3666 | 3666 | if (st->attached_pic.data) |
| 3667 | − av_free_packet(&st->attached_pic); | |
| 3667 | + av_packet_unref(&st->attached_pic); | |
| 3668 | 3668 | av_dict_free(&st->metadata); |
| 3669 | 3669 | av_freep(&st->probe_data.buf); |
| 3670 | 3670 | av_freep(&st->index_entries); |
| @@ -246,7 +246,7 @@ static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt) · 245 unmodified lines | ||
| 246 | 246 | ret = avio_read(s->pb, pkt->data+2, size); |
| 247 | 247 | |
| 248 | 248 | if (ret != size) { |
| 249 | − av_free_packet(pkt); | |
| 249 | + av_packet_unref(pkt); | |
| 250 | 250 | return AVERROR(EIO); |
| 251 | 251 | } |
| 252 | 252 | |
| @@ -295,7 +295,7 @@ static int wc3_read_close(AVFormatContext *s) · 294 unmodified lines | ||
| 295 | 295 | Wc3DemuxContext *wc3 = s->priv_data; |
| 296 | 296 | |
| 297 | 297 | if (wc3->vpkt.size > 0) |
| 298 | − av_free_packet(&wc3->vpkt); | |
| 298 | + av_packet_unref(&wc3->vpkt); | |
| 299 | 299 | |
| 300 | 300 | return 0; |
| 301 | 301 | } |
| @@ -273,25 +273,25 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt) · 272 unmodified lines | ||
| 273 | 273 | memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE); |
| 274 | 274 | ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize); |
| 275 | 275 | if (ret != wc->header.blocksize) { |
| 276 | − av_free_packet(pkt); | |
| 276 | + av_packet_unref(pkt); | |
| 277 | 277 | return AVERROR(EIO); |
| 278 | 278 | } |
| 279 | 279 | while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) { |
| 280 | 280 | if ((ret = wv_read_block_header(s, s->pb)) < 0) { |
| 281 | − av_free_packet(pkt); | |
| 281 | + av_packet_unref(pkt); | |
| 282 | 282 | return ret; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | off = pkt->size; |
| 286 | 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 | 288 | return ret; |
| 289 | 289 | } |
| 290 | 290 | memcpy(pkt->data + off, wc->block_header, WV_HEADER_SIZE); |
| 291 | 291 | |
| 292 | 292 | ret = avio_read(s->pb, pkt->data + off + WV_HEADER_SIZE, wc->header.blocksize); |
| 293 | 293 | if (ret != wc->header.blocksize) { |
| 294 | − av_free_packet(pkt); | |
| 294 | + av_packet_unref(pkt); | |
| 295 | 295 | return (ret < 0) ? ret : AVERROR_EOF; |
| 296 | 296 | } |
| 297 | 297 | } |
| @@ -173,14 +173,14 @@ static int yop_read_packet(AVFormatContext *s, AVPacket *pkt) · 172 unmodified lines | ||
| 173 | 173 | return yop->audio_block_length; |
| 174 | 174 | |
| 175 | 175 | err_out: |
| 176 | − av_free_packet(&yop->video_packet); | |
| 176 | + av_packet_unref(&yop->video_packet); | |
| 177 | 177 | return ret; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | static int yop_read_close(AVFormatContext *s) |
| 181 | 181 | { |
| 182 | 182 | YopDecContext *yop = s->priv_data; |
| 183 | − av_free_packet(&yop->video_packet); | |
| 183 | + av_packet_unref(&yop->video_packet); | |
| 184 | 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 | 205 | if (avio_seek(s->pb, frame_pos, SEEK_SET) < 0) |
| 206 | 206 | return -1; |
| 207 | 207 | |
| 208 | − av_free_packet(&yop->video_packet); | |
| 208 | + av_packet_unref(&yop->video_packet); | |
| 209 | 209 | yop->odd_frame = timestamp & 1; |
| 210 | 210 | |
| 211 | 211 | return 0; |
| @@ -122,7 +122,7 @@ int main(int argc, char **argv) · 121 unmodified lines | ||
| 122 | 122 | } |
| 123 | 123 | close(fd); |
| 124 | 124 | } |
| 125 | − av_free_packet(&pkt); | |
| 125 | + av_packet_unref(&pkt); | |
| 126 | 126 | pktnum++; |
| 127 | 127 | if (maxpkts && (pktnum >= maxpkts)) |
| 128 | 128 | break; |