Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2015-10-27 16:28:56 +0300
committerHendrik Leppkes <h.leppkes@gmail.com>2015-10-27 16:28:56 +0300
commit7f5af80ba42bbd82da53dfd95236e9d47159a96a (patch)
treef85abbee087fa12065f02278c710ea4830c2cae5 /libavcodec
parent856b19d5935b544e96156f8e75e23b28c0a9f318 (diff)
parentce70f28a1732c74a9cd7fec2d56178750bd6e457 (diff)
Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'
* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457': avpacket: Replace av_free_packet with av_packet_unref Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h33
-rw-r--r--libavcodec/avpacket.c6
-rw-r--r--libavcodec/jpeglsenc.c2
-rw-r--r--libavcodec/libxvid.c2
-rw-r--r--libavcodec/mpegvideo_enc.c2
-rw-r--r--libavcodec/utils.c8
-rw-r--r--libavcodec/version.h5
7 files changed, 35 insertions, 23 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 9099093531..c4104cfa6c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1367,15 +1367,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 {
/**
@@ -3899,7 +3903,7 @@ 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
/**
* Copy packet, including contents
*
@@ -3917,10 +3921,13 @@ int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src);
/**
* 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.
*
@@ -4563,8 +4570,7 @@ AVCodec *avcodec_find_encoder_by_name(const char *name);
* of the 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.
@@ -4605,8 +4611,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.
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 0496254cf4..648dc10076 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -204,7 +204,7 @@ int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
return 0;
failed_alloc:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
@@ -234,6 +234,8 @@ void av_packet_free_side_data(AVPacket *pkt)
pkt->side_data_elems = 0;
}
+#if FF_API_AVPACKET_OLD_API
+FF_DISABLE_DEPRECATION_WARNINGS
void av_free_packet(AVPacket *pkt)
{
if (pkt) {
@@ -245,6 +247,8 @@ void av_free_packet(AVPacket *pkt)
av_packet_free_side_data(pkt);
}
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
uint8_t *av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
int size)
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
index 1e1a22bed2..71e87e7748 100644
--- a/libavcodec/jpeglsenc.c
+++ b/libavcodec/jpeglsenc.c
@@ -405,7 +405,7 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
return 0;
memfail:
- av_free_packet(pkt);
+ av_packet_unref(pkt);
av_freep(&buf2);
av_freep(&state);
av_freep(&zero);
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index cbb72c2227..b3cf57fe84 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -841,7 +841,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0;
} else {
if (!user_packet)
- av_free_packet(pkt);
+ av_packet_unref(pkt);
if (!xerr)
return 0;
av_log(avctx, AV_LOG_ERROR,
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index e87f4258fe..8b32c87c79 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1320,7 +1320,7 @@ static int encode_frame(AVCodecContext *c, AVFrame *frame)
return ret;
ret = pkt.size;
- av_free_packet(&pkt);
+ av_packet_unref(&pkt);
return ret;
}
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index dfac790705..b4709cb3cb 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1693,7 +1693,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
*got_packet_ptr = 0;
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
av_init_packet(avpkt);
return 0;
}
@@ -1799,7 +1799,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
}
if (ret < 0 || !*got_packet_ptr) {
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
av_init_packet(avpkt);
goto end;
}
@@ -1839,7 +1839,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
avctx->stats_out[0] = '\0';
if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) {
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
av_init_packet(avpkt);
avpkt->size = 0;
return 0;
@@ -1893,7 +1893,7 @@ int attribute_align_arg avcodec_encode_video2(AVCodecContext *avctx,
}
if (ret < 0 || !*got_packet_ptr)
- av_free_packet(avpkt);
+ av_packet_unref(avpkt);
emms_c();
return ret;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 155b1c8c6b..2724729799 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 57
-#define LIBAVCODEC_VERSION_MINOR 11
+#define LIBAVCODEC_VERSION_MINOR 12
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -191,5 +191,8 @@
#ifndef FF_API_AVPICTURE
#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
+#ifndef FF_API_AVPACKET_OLD_API
+#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
#endif /* AVCODEC_VERSION_H */