It sets the supplied AVFormatContext pointer to NULL after freeing it, which is safer and its name is consistent with other lavf functions. Also deprecate av_close_input_file().
Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2011-xx-xx - xxxxxxx - lavf 53.17.0 | |
| 17 | + Add avformat_open_input(). | |
| 18 | + Deprecate av_close_input_file() and av_close_input_stream(). | |
| 19 | + | |
| 16 | 20 | 2011-xx-xx - xxxxxxx - lavc 53.25.0 |
| 17 | 21 | Add nb_samples and extended_data fields to AVFrame. |
| 18 | 22 | Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE. |
| @@ -1570,12 +1570,22 @@ attribute_deprecated · 1569 unmodified lines | ||
| 1570 | 1570 | void av_close_input_stream(AVFormatContext *s); |
| 1571 | 1571 | #endif |
| 1572 | 1572 | |
| 1573 | +#if FF_API_CLOSE_INPUT_FILE | |
| 1573 | 1574 | /** |
| 1575 | + * @deprecated use avformat_close_input() | |
| 1574 | 1576 | * Close a media file (but not its codecs). |
| 1575 | 1577 | * |
| 1576 | 1578 | * @param s media file handle |
| 1577 | 1579 | */ |
| 1580 | +attribute_deprecated | |
| 1578 | 1581 | void av_close_input_file(AVFormatContext *s); |
| 1582 | +#endif | |
| 1583 | + | |
| 1584 | +/** | |
| 1585 | + * Close an opened input AVFormatContext. Free it and all its contents | |
| 1586 | + * and set *s to NULL. | |
| 1587 | + */ | |
| 1588 | +void avformat_close_input(AVFormatContext **s); | |
| 1579 | 1589 | /** |
| 1580 | 1590 | * @} |
| 1581 | 1591 | */ |
| @@ -2684,14 +2684,23 @@ void avformat_free_context(AVFormatContext *s) · 2683 unmodified lines | ||
| 2684 | 2684 | av_free(s); |
| 2685 | 2685 | } |
| 2686 | 2686 | |
| 2687 | +#if FF_API_CLOSE_INPUT_FILE | |
| 2687 | 2688 | void av_close_input_file(AVFormatContext *s) |
| 2688 | 2689 | { |
| 2690 | + avformat_close_input(&s); | |
| 2691 | +} | |
| 2692 | +#endif | |
| 2693 | + | |
| 2694 | +void avformat_close_input(AVFormatContext **ps) | |
| 2695 | +{ | |
| 2696 | + AVFormatContext *s = *ps; | |
| 2689 | 2697 | AVIOContext *pb = (s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO) ? |
| 2690 | 2698 | NULL : s->pb; |
| 2691 | 2699 | flush_packet_queue(s); |
| 2692 | 2700 | if (s->iformat->read_close) |
| 2693 | 2701 | s->iformat->read_close(s); |
| 2694 | 2702 | avformat_free_context(s); |
| 2703 | + *ps = NULL; | |
| 2695 | 2704 | if (pb) |
| 2696 | 2705 | avio_close(pb); |
| 2697 | 2706 | } |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/avutil.h" |
| 31 | 31 | |
| 32 | 32 | #define LIBAVFORMAT_VERSION_MAJOR 53 |
| 33 | −#define LIBAVFORMAT_VERSION_MINOR 16 | |
| 33 | +#define LIBAVFORMAT_VERSION_MINOR 17 | |
| 34 | 34 | #define LIBAVFORMAT_VERSION_MICRO 0 |
| 35 | 35 | |
| 36 | 36 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| @@ -122,5 +122,8 @@ · 85 unmodified lines | ||
| 122 | 122 | #ifndef FF_API_SET_PTS_INFO |
| 123 | 123 | #define FF_API_SET_PTS_INFO (LIBAVFORMAT_VERSION_MAJOR < 54) |
| 124 | 124 | #endif |
| 125 | +#ifndef FF_API_CLOSE_INPUT_FILE | |
| 126 | +#define FF_API_CLOSE_INPUT_FILE (LIBAVFORMAT_VERSION_MAJOR < 54) | |
| 127 | +#endif | |
| 125 | 128 | |
| 126 | 129 | #endif /* AVFORMAT_VERSION_H */ |