Since an AVFrame now has malloced members (extended_data), it must have a destructor.
Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | API changes, most recent first: | 14 | API changes, most recent first: |
| 15 | 15 | ||
| 16 | 2012-09-23 - xxxxxxx - lavc 54.28.0 - avcodec.h | ||
| 17 | Add avcodec_free_frame(). This function must now | ||
| 18 | be used for freeing an AVFrame. | ||
| 19 | |||
| 16 | 2012-09-12 - xxxxxxx - lavu 51.41.0 - audioconvert.h | 20 | 2012-09-12 - xxxxxxx - lavu 51.41.0 - audioconvert.h |
| 17 | Added AV_CH_LOW_FREQUENCY_2 channel mask value. | 21 | Added AV_CH_LOW_FREQUENCY_2 channel mask value. |
| 18 | 22 | ||
| @@ -3257,7 +3257,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); · 3256 unmodified lines | |||
| 3257 | 3257 | ||
| 3258 | /** | 3258 | /** |
| 3259 | * Allocate an AVFrame and set its fields to default values. The resulting | 3259 | * Allocate an AVFrame and set its fields to default values. The resulting |
| 3260 | * struct can be deallocated by simply calling av_free(). | 3260 | * struct must be freed using avcodec_free_frame(). |
| 3261 | * | 3261 | * |
| 3262 | * @return An AVFrame filled with default values or NULL on failure. | 3262 | * @return An AVFrame filled with default values or NULL on failure. |
| 3263 | * @see avcodec_get_frame_defaults | 3263 | * @see avcodec_get_frame_defaults |
| @@ -3271,6 +3271,18 @@ AVFrame *avcodec_alloc_frame(void); · 7 unmodified lines | |||
| 3271 | */ | 3271 | */ |
| 3272 | void avcodec_get_frame_defaults(AVFrame *frame); | 3272 | void avcodec_get_frame_defaults(AVFrame *frame); |
| 3273 | 3273 | ||
| 3274 | /** | ||
| 3275 | * Free the frame and any dynamically allocated objects in it, | ||
| 3276 | * e.g. extended_data. | ||
| 3277 | * | ||
| 3278 | * @param frame frame to be freed. The pointer will be set to NULL. | ||
| 3279 | * | ||
| 3280 | * @warning this function does NOT free the data buffers themselves | ||
| 3281 | * (it does not know how, since they might have been allocated with | ||
| 3282 | * a custom get_buffer()). | ||
| 3283 | */ | ||
| 3284 | void avcodec_free_frame(AVFrame **frame); | ||
| 3285 | |||
| 3274 | /** | 3286 | /** |
| 3275 | * Initialize the AVCodecContext to use the given AVCodec. Prior to using this | 3287 | * Initialize the AVCodecContext to use the given AVCodec. Prior to using this |
| 3276 | * function the context has to be allocated with avcodec_alloc_context3(). | 3288 | * function the context has to be allocated with avcodec_alloc_context3(). |
| @@ -659,6 +659,21 @@ AVFrame *avcodec_alloc_frame(void) · 658 unmodified lines | |||
| 659 | return frame; | 659 | return frame; |
| 660 | } | 660 | } |
| 661 | 661 | ||
| 662 | void avcodec_free_frame(AVFrame **frame) | ||
| 663 | { | ||
| 664 | AVFrame *f; | ||
| 665 | |||
| 666 | if (!frame || !*frame) | ||
| 667 | return; | ||
| 668 | |||
| 669 | f = *frame; | ||
| 670 | |||
| 671 | if (f->extended_data != f->data) | ||
| 672 | av_freep(&f->extended_data); | ||
| 673 | |||
| 674 | av_freep(frame); | ||
| 675 | } | ||
| 676 | |||
| 662 | int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) | 677 | int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) |
| 663 | { | 678 | { |
| 664 | int ret = 0; | 679 | int ret = 0; |
| @@ -27,7 +27,7 @@ · 26 unmodified lines | |||
| 27 | */ | 27 | */ |
| 28 | 28 | ||
| 29 | #define LIBAVCODEC_VERSION_MAJOR 54 | 29 | #define LIBAVCODEC_VERSION_MAJOR 54 |
| 30 | #define LIBAVCODEC_VERSION_MINOR 27 | 30 | #define LIBAVCODEC_VERSION_MINOR 28 |
| 31 | #define LIBAVCODEC_VERSION_MICRO 0 | 31 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 32 | 32 | ||
| 33 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 33 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |