summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2021-01-23 19:56:18 +0100
committerLynne <dev@lynne.ee>2021-08-02 14:30:52 +0200
commita1a0fddfd05c1dd0c03e5aa4d51baedad59fa117 (patch)
treeb7afb886c06165f2a0de852ee4a9ecee3942f278 /libavcodec
parenta27853a7300bb3c2752256b2fc02f2439619f6f8 (diff)
avpacket: ABI bump additions
This commit adds a long-requested by API users opaque fields for AVPacket, as well as a time_base field.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avpacket.c17
-rw-r--r--libavcodec/packet.h21
-rw-r--r--libavcodec/version.h4
3 files changed, 38 insertions, 4 deletions
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 800bee3489..075b219475 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 "libavutil/rational.h"
#include "bytestream.h"
#include "internal.h"
@@ -44,6 +45,9 @@ void av_init_packet(AVPacket *pkt)
pkt->buf = NULL;
pkt->side_data = NULL;
pkt->side_data_elems = 0;
+ pkt->opaque = NULL;
+ pkt->opaque_ref = NULL;
+ pkt->time_base = av_make_q(0, 0);
}
#endif
@@ -374,7 +378,7 @@ int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
{
- int i;
+ int i, ret;
dst->pts = src->pts;
dst->dts = src->dts;
@@ -382,9 +386,16 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
dst->duration = src->duration;
dst->flags = src->flags;
dst->stream_index = src->stream_index;
-
+ dst->opaque = src->opaque;
+ dst->time_base = src->time_base;
+ dst->opaque_ref = NULL;
dst->side_data = NULL;
dst->side_data_elems = 0;
+
+ ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref);
+ if (ret < 0)
+ return ret;
+
for (i = 0; i < src->side_data_elems; i++) {
enum AVPacketSideDataType type = src->side_data[i].type;
size_t size = src->side_data[i].size;
@@ -392,6 +403,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
uint8_t *dst_data = av_packet_new_side_data(dst, type, size);
if (!dst_data) {
+ av_buffer_unref(&dst->opaque_ref);
av_packet_free_side_data(dst);
return AVERROR(ENOMEM);
}
@@ -404,6 +416,7 @@ int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
void av_packet_unref(AVPacket *pkt)
{
av_packet_free_side_data(pkt);
+ av_buffer_unref(&pkt->opaque_ref);
av_buffer_unref(&pkt->buf);
get_packet_defaults(pkt);
}
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index a9d3a9b596..9baff24635 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -391,6 +391,27 @@ typedef struct AVPacket {
int64_t duration;
int64_t pos; ///< byte position in stream, -1 if unknown
+
+ /**
+ * for some private data of the user
+ */
+ void *opaque;
+
+ /**
+ * AVBufferRef for free use by the API user. FFmpeg will never check the
+ * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
+ * the packet is unreferenced. av_packet_copy_props() calls create a new
+ * reference with av_buffer_ref() for the target packet's opaque_ref field.
+ *
+ * This is unrelated to the opaque field, although it serves a similar
+ * purpose.
+ */
+ AVBufferRef *opaque_ref;
+
+ /**
+ * Time base of the packet's timestamps.
+ */
+ AVRational time_base;
} AVPacket;
#if FF_API_INIT_PACKET
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 91325ce4e7..554f293aad 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 59
-#define LIBAVCODEC_VERSION_MINOR 3
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MINOR 4
+#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \