aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/avcodec.h
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-03-08 17:28:42 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-03-08 19:12:03 +0100
commit2653e125204569b1e9439ee2671c6ebb23a94b80 (patch)
tree4176f76bccc8cdd1c85b9d329a82867eda37d397 /libavcodec/avcodec.h
parent532f31a695c9530ce67a847be00d72e6e8acfd11 (diff)
parent1afddbe59e96af75f1c07605afc95615569f388f (diff)
downloadffmpeg-2653e125204569b1e9439ee2671c6ebb23a94b80.tar.gz
Merge commit '1afddbe59e96af75f1c07605afc95615569f388f'
* commit '1afddbe59e96af75f1c07605afc95615569f388f': avpacket: use AVBuffer to allow refcounting the packets. Conflicts: libavcodec/avpacket.c libavcodec/utils.c libavdevice/v4l2.c libavformat/avidec.c libavformat/flacdec.c libavformat/id3v2.c libavformat/matroskaenc.c libavformat/mux.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/avcodec.h')
-rw-r--r--libavcodec/avcodec.h42
1 files changed, 36 insertions, 6 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c4db4d761f..2d338f0a45 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -29,6 +29,7 @@
#include <errno.h>
#include "libavutil/samplefmt.h"
#include "libavutil/avutil.h"
+#include "libavutil/buffer.h"
#include "libavutil/cpu.h"
#include "libavutil/channel_layout.h"
#include "libavutil/dict.h"
@@ -1009,18 +1010,24 @@ enum AVPacketSideDataType {
* 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 destruct field.
- * If it is set, the packet data is dynamically allocated and is valid
- * indefinitely until av_free_packet() is called (which in turn calls the
- * destruct callback to free the data). If destruct is not 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 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 side data is always allocated with av_malloc() and is freed in
* av_free_packet().
*/
typedef struct AVPacket {
/**
+ * A reference to the reference-counted buffer where the packet data is
+ * stored.
+ * May be NULL, then the packet data is not reference-counted.
+ */
+ AVBufferRef *buf;
+ /**
* Presentation timestamp in AVStream->time_base units; the time at which
* the decompressed packet will be presented to the user.
* Can be AV_NOPTS_VALUE if it is not stored in the file.
@@ -1059,8 +1066,12 @@ typedef struct AVPacket {
* Equals next_pts - this_pts in presentation order.
*/
int duration;
+#if FF_API_DESTRUCT_PACKET
+ attribute_deprecated
void (*destruct)(struct AVPacket *);
+ attribute_deprecated
void *priv;
+#endif
int64_t pos; ///< byte position in stream, -1 if unknown
/**
@@ -3776,10 +3787,14 @@ void avsubtitle_free(AVSubtitle *sub);
* @{
*/
+#if FF_API_DESTRUCT_PACKET
/**
* Default packet destructor.
+ * @deprecated use the AVBuffer API instead
*/
+attribute_deprecated
void av_destruct_packet(AVPacket *pkt);
+#endif
/**
* Initialize optional fields of a packet with default values.
@@ -3818,6 +3833,21 @@ void av_shrink_packet(AVPacket *pkt, int size);
int av_grow_packet(AVPacket *pkt, int grow_by);
/**
+ * Initialize a reference-counted packet from av_malloc()ed data.
+ *
+ * @param pkt packet to be initialized. This function will set the data, size,
+ * buf and destruct fields, all others are left untouched.
+ * @param data Data allocated by av_malloc() to be used as packet data. If this
+ * function returns successfully, the data is owned by the underlying AVBuffer.
+ * The caller may not access the data through other means.
+ * @param size size of data in bytes, without the padding. I.e. the full buffer
+ * size is assumed to be size + FF_INPUT_BUFFER_PADDING_SIZE.
+ *
+ * @return 0 on success, a negative AVERROR on error
+ */
+int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
+
+/**
* @warning This is a hack - the packet memory allocation stuff is broken. The
* packet is allocated if it was not really allocated.
*/