This is an RFC about the upcoming additions to the AVPacket structure (whose size is still part of the ABI, so we need to plan for any changes).
The current RFC patch adds 3 fields: - "void *opaque;" for the user to use as they wish, same as AVFrame.opaque - "void *opaque_ref;" for more permanent and propagating user data, same as AVFrame.opaque_ref - "AVRational time_base;" which will be set to indicate the time base of the packet's timestamps Some devs (JEEB) wanted reception timestamps and original, overflowed timestamps for MPEG-TS. I'd be willing to add a reception timestamp as long as we add an additional time_base field and make it independent of the packet's pts field, since those timestamps are usually on highly precise system clock time bases, and reducing their precision would be undesirable. I'm not sure about overflowed original timestamps or how they would help. Perhaps we should introduce an AVBufferRef *internal_ref like with AVFrame to store such single library-only data?
>From e46f0aeb78928e06c14fac5dfe6c4b11c4b75c42 Mon Sep 17 00:00:00 2001 From: Lynne <d...@lynne.ee> Date: Sat, 23 Jan 2021 19:56:18 +0100 Subject: [PATCH] avpacket: RFC for ABI bump additions --- doc/APIchanges | 3 +++ libavcodec/avpacket.c | 9 +++++++++ libavcodec/packet.h | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index bbf56a5385..d239ef7627 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2021-xx-xx - xxxxxxxxxx - lavc 59.100.100 - avpacket.h + Add AVPacket.opaque, AVPacket.opaque_ref and AVPacket.time_base + 2021-01-11 - xxxxxxxxxx - lavc 58.116.100 - avcodec.h Add FF_PROFILE_VVC_MAIN_10 and FF_PROFILE_VVC_MAIN_10_444. diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index e4ba403cf6..cf2c5efb66 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -585,6 +585,12 @@ FF_ENABLE_DEPRECATION_WARNINGS dst->flags = src->flags; dst->stream_index = src->stream_index; +#if LIBAVCODEC_VERSION_MAJOR > 58 + i = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); + if (i < 0) + return i; +#endif + dst->side_data = NULL; dst->side_data_elems = 0; for (i = 0; i < src->side_data_elems; i++) { @@ -606,6 +612,9 @@ FF_ENABLE_DEPRECATION_WARNINGS void av_packet_unref(AVPacket *pkt) { av_packet_free_side_data(pkt); +#if LIBAVCODEC_VERSION_MAJOR > 58 + av_buffer_unref(&pkt->opaque_ref); +#endif av_buffer_unref(&pkt->buf); av_init_packet(pkt); pkt->data = NULL; diff --git a/libavcodec/packet.h b/libavcodec/packet.h index b9d4c9c2c8..8e3f95e6ae 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -391,6 +391,29 @@ typedef struct AVPacket { attribute_deprecated int64_t convergence_duration; #endif + +#if LIBAVCODEC_VERSION_MAJOR > 58 + /** + * 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; +#endif } AVPacket; typedef struct AVPacketList { -- 2.30.0
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".