History

lavc: add avcodec_free_frame().

Since an AVFrame now has malloced members (extended_data), it must have a destructor.

Anton Khirnov committed 14 years ago

Commit a42aada1 parent b437cec4 files · +33 −2Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavcodec/avcodec.h +13 −1
  3. libavcodec/utils.c +15 −0
  4. libavcodec/version.h +1 −1
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
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+
1620 2012-09-12 - xxxxxxx - lavu 51.41.0 - audioconvert.h
1721 Added AV_CH_LOW_FREQUENCY_2 channel mask value.
1822
libavcodec/avcodec.h+13−1
@@ -3257,7 +3257,7 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); · 3256 unmodified lines
32573257
32583258 /**
32593259 * 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().
32613261 *
32623262 * @return An AVFrame filled with default values or NULL on failure.
32633263 * @see avcodec_get_frame_defaults
@@ -3271,6 +3271,18 @@ AVFrame *avcodec_alloc_frame(void); · 7 unmodified lines
32713271 */
32723272 void avcodec_get_frame_defaults(AVFrame *frame);
32733273
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+
32743286 /**
32753287 * Initialize the AVCodecContext to use the given AVCodec. Prior to using this
32763288 * function the context has to be allocated with avcodec_alloc_context3().
libavcodec/utils.c+15−0
@@ -659,6 +659,21 @@ AVFrame *avcodec_alloc_frame(void) · 658 unmodified lines
659659 return frame;
660660 }
661661
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+
662677 int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
663678 {
664679 int ret = 0;
libavcodec/version.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 */
2828
2929 #define LIBAVCODEC_VERSION_MAJOR 54
30−#define LIBAVCODEC_VERSION_MINOR 27
30+#define LIBAVCODEC_VERSION_MINOR 28
3131 #define LIBAVCODEC_VERSION_MICRO 0
3232
3333 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

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