Add a private API to manipulate AVPacketLists.
---
doc/APIchanges | 4 ++++
libavcodec/avcodec.h | 5 +++++
libavcodec/avpacket.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
libavcodec/internal.h | 36 ++++++++++++++++++++++++++++++++
libavcodec/version.h | 2 +-
libavformat/avformat.h | 6 ------
libavformat/version.h | 2 +-
7 files changed, 103 insertions(+), 8 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 0818a48..c318908 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2014-08-09
API changes, most recent first:
+2014-10-xx - xxxxxxx - lavc 56.4.0 - avcodec.h
+2014-10-xx - xxxxxxx - lavf 56.7.0 - avformat.h
+ Move AVPacketList to avcodec.
+
2014-10-xx - xxxxxxx - lavc 56.3.0 - avcodec.h
Add AVHWAccel.decode and AVHWAccel.flush callbacks to support
bitstream oriented hardware acceleration frameworks.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 72a5618..c5ed0f1 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1019,6 +1019,11 @@ typedef struct AVPacket {
#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe
#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
+typedef struct AVPacketList {
+ AVPacket pkt;
+ struct AVPacketList *next;
+} AVPacketList;
+
enum AVSideDataParamChangeFlags {
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001,
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 25eabdb..bea12df 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -26,6 +26,7 @@
#include "libavutil/internal.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
+#include "internal.h"
#include "avcodec.h"
#if FF_API_DESTRUCT_PACKET
@@ -393,3 +394,58 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational
src_tb, AVRational dst_tb)
if (pkt->convergence_duration > 0)
pkt->convergence_duration = av_rescale_q(pkt->convergence_duration,
src_tb, dst_tb);
}
+
+int ff_packet_list_put(AVPacketList **head, AVPacketList **tail,
+ AVPacket *pkt)
+{
+ AVPacketList *pl = av_mallocz(sizeof(AVPacketList));
+ int ret;
+
+ if (!pl)
+ return AVERROR(ENOMEM);
+
+ if ((ret = av_packet_ref(&pl->pkt, pkt)) < 0) {
+ av_free(pl);
+ return ret;
+ }
+
+ if (*head)
+ (*tail)->next = pl;
+ else
+ *head = pl;
+
+ *tail = pl;
+
+ return 0;
+}
+
+int ff_packet_list_get(AVPacketList **head, AVPacketList **tail,
+ AVPacket *pkt)
+{
+ AVPacketList *pl = *head;
+ if (!pl)
+ return AVERROR_EOF;
+
+ av_packet_move_ref(pkt, &pl->pkt);
+
+ *head = pl->next;
+
+ if (!pl->next)
+ tail = NULL;
+
+ av_free(pl);
+
+ return 0;
+}
+
+void ff_packet_list_free(AVPacketList **head, AVPacketList **tail)
+{
+ AVPacketList *pl;
+
+ while (pl = *head) {
+ *head = pl->next;
+ av_packet_unref(&pl->pkt);
+ av_free(pl);
+ }
+ *tail = NULL;
+}
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 3b2ae40..c13862d 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -200,4 +200,40 @@ int ff_get_format(AVCodecContext *avctx, const enum
AVPixelFormat *fmt);
*/
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame);
+/*
+ * Append an AVPacket to the list creating a new reference
+ * to it.
+ *
+ * @param head List head
+ * @param tail List tail
+ * @param pkt The packet being appended
+ * @return < 0 on failure and 0 on success.
+ */
+int ff_packet_list_put(AVPacketList **head, AVPacketList **tail,
+ AVPacket *pkt);
+
+/**
+ * Remove the oldest AVPacket in the list and return it.
+ *
+ * @note The pkt will be overwritten completely. The caller
+ * owns the packet and must unref it by itself.
+ *
+ * @see av_packet_unref av_packet_ref
+ *
+ * @param head List head.
+ * @param tail List tail.
+ * @param pkt Pointer to an initialized AVPacket struct
+ * @return < 0 on failure and 0 on success.
+ */
+int ff_packet_list_get(AVPacketList **head, AVPacketList **tail,
+ AVPacket *pkt);
+
+/**
+ * Wipe the list and unref all the packets in it.
+ *
+ * @param head List head.
+ * @param tail List tail.
+ */
+void ff_packet_list_free(AVPacketList **head, AVPacketList **tail);
+
#endif /* AVCODEC_INTERNAL_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d9c4500..2535818 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR 3
+#define LIBAVCODEC_VERSION_MINOR 4
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f28186f..5a5221f 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1254,12 +1254,6 @@ typedef struct AVFormatContext {
AVFormatInternal *internal;
} AVFormatContext;
-typedef struct AVPacketList {
- AVPacket pkt;
- struct AVPacketList *next;
-} AVPacketList;
-
-
/**
* @defgroup lavf_core Core functions
* @ingroup libavf
diff --git a/libavformat/version.h b/libavformat/version.h
index 18444cd..6692777 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR 6
+#define LIBAVFORMAT_VERSION_MINOR 7
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
--
2.1.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel