[FFmpeg-cvslog] lavc/packet: add API for an AVPacket-based AVContainerFifo
Anton Khirnov
git at videolan.org
Sun Dec 15 16:16:39 EET 2024
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Dec 11 07:57:22 2024 +0100| [2ac34d085427a65a9724dda475f5971d005ee29d] | committer: Anton Khirnov
lavc/packet: add API for an AVPacket-based AVContainerFifo
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2ac34d085427a65a9724dda475f5971d005ee29d
---
doc/APIchanges | 3 +++
libavcodec/packet.c | 33 +++++++++++++++++++++++++++++++++
libavcodec/packet.h | 7 +++++++
libavcodec/version.h | 2 +-
4 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index c3dab7fbcf..5c7e82d84f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
API changes, most recent first:
+2024-12-15 - xxxxxxxxxx - lavc 61.27.100 packet.h
+ Add av_container_fifo_alloc_avpacket().
+
2024-12-15 - xxxxxxxxxx - lavu 59.51.100 - refstruct.h container_fifo.h
Add a new public header refstruct.h with new API for
reference-counted objects.
diff --git a/libavcodec/packet.c b/libavcodec/packet.c
index 381001fd65..5104eb98b1 100644
--- a/libavcodec/packet.c
+++ b/libavcodec/packet.c
@@ -23,6 +23,7 @@
#include "libavutil/avassert.h"
#include "libavutil/avutil.h"
+#include "libavutil/container_fifo.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
@@ -752,3 +753,35 @@ void av_packet_side_data_free(AVPacketSideData **psd, int *pnb_sd)
av_freep(psd);
*pnb_sd = 0;
}
+
+static void *container_packet_alloc(void *opaque)
+{
+ return av_packet_alloc();
+}
+
+static void container_packet_reset(void *opaque, void *obj)
+{
+ av_packet_unref(obj);
+}
+
+static void container_packet_free(void *opaque, void *obj)
+{
+ AVPacket *pkt = obj;
+ av_packet_free(&pkt);
+}
+
+static int container_packet_transfer(void *opaque, void *dst, void *src, unsigned flags)
+{
+ if (flags & AV_CONTAINER_FIFO_FLAG_REF)
+ return av_packet_ref(dst, src);
+
+ av_packet_move_ref(dst, src);
+ return 0;
+}
+
+AVContainerFifo *av_container_fifo_alloc_avpacket(unsigned flags)
+{
+ return av_container_fifo_alloc(NULL, container_packet_alloc,
+ container_packet_reset, container_packet_free,
+ container_packet_transfer, 0);
+}
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index bcc1917e8d..c1f1ad7b43 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -880,6 +880,13 @@ int av_packet_make_writable(AVPacket *pkt);
*/
void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);
+/**
+ * Allocate an AVContainerFifo instance for AVPacket.
+ *
+ * @param flags currently unused
+ */
+struct AVContainerFifo *av_container_fifo_alloc_avpacket(unsigned flags);
+
/**
* @}
*/
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 26ee41eb1f..735c8b813c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 26
+#define LIBAVCODEC_VERSION_MINOR 27
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
More information about the ffmpeg-cvslog
mailing list