summaryrefslogtreecommitdiff
path: root/libavcodec/avcodec.h
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2015-10-23 11:11:31 +0200
committerLuca Barbato <lu_zero@gentoo.org>2015-10-26 18:00:55 +0100
commitce70f28a1732c74a9cd7fec2d56178750bd6e457 (patch)
tree4e23c0b8181685ce4901250c8ee8468955bc362a /libavcodec/avcodec.h
parenta5d42043093a39636a1f4021a37dd9c612479f6f (diff)
avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as a drop in replacement. Deprecate `av_free_packet`.
Diffstat (limited to 'libavcodec/avcodec.h')
-rw-r--r--libavcodec/avcodec.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index cf8cc5a5d7..dfd18ba866 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1151,15 +1151,19 @@ typedef struct AVPacketSideData {
* ABI. Thus it may be allocated on stack and no new fields can be added to it
* without libavcodec and libavformat major bump.
*
- * The semantics of data ownership depends on the buf or destruct (deprecated)
- * fields. If either is set, the packet data is dynamically allocated and is
- * valid indefinitely until av_free_packet() is called (which in turn calls
- * av_buffer_unref()/the destruct callback to free the data). If neither is set,
- * the packet data is typically backed by some static buffer somewhere and is
- * only valid for a limited time (e.g. until the next read call when demuxing).
+ * The semantics of data ownership depends on the buf field.
+ * If it is set, the packet data is dynamically allocated and is
+ * valid indefinitely until a call to av_packet_unref() reduces the
+ * reference count to 0.
*
- * The side data is always allocated with av_malloc() and is freed in
- * av_free_packet().
+ * If the buf field is not set av_packet_ref() would make a copy instead
+ * of increasing the reference count.
+ *
+ * The side data is always allocated with av_malloc(), copied by
+ * av_packet_ref() and freed by av_packet_unref().
+ *
+ * @see av_packet_ref
+ * @see av_packet_unref
*/
typedef struct AVPacket {
/**
@@ -3477,14 +3481,17 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
* packet is allocated if it was not really allocated.
*/
int av_dup_packet(AVPacket *pkt);
-
+#if FF_API_AVPACKET_OLD_API
/**
* Free a packet.
*
+ * @deprecated Use av_packet_unref
+ *
* @param pkt packet to free
*/
+attribute_deprecated
void av_free_packet(AVPacket *pkt);
-
+#endif
/**
* Allocate new information of a packet.
*
@@ -4070,8 +4077,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name);
* output packet.
*
* If this function fails or produces no output, avpkt will be
- * freed using av_free_packet() (i.e. avpkt->destruct will be
- * called to free the user supplied buffer).
+ * freed using av_packet_unref().
* @param[in] frame AVFrame containing the raw audio data to be encoded.
* May be NULL when flushing an encoder that has the
* AV_CODEC_CAP_DELAY capability set.
@@ -4112,8 +4118,7 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt,
* caller, he is responsible for freeing it.
*
* If this function fails or produces no output, avpkt will be
- * freed using av_free_packet() (i.e. avpkt->destruct will be
- * called to free the user supplied buffer).
+ * freed using av_packet_unref().
* @param[in] frame AVFrame containing the raw video data to be encoded.
* May be NULL when flushing an encoder that has the
* AV_CODEC_CAP_DELAY capability set.