aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-31 12:27:28 +0100
committerAnton Khirnov <anton@khirnov.net>2023-02-04 13:40:20 +0100
commitbdc76f467f5caaa15b3bd11cbe6c52cc8f2f45b1 (patch)
treebd2d15177f5ffc9681d609be283826eaa721b041
parentd02340b9e3e72f401cddbeb3bcc3cb584902b886 (diff)
downloadffmpeg-bdc76f467f5caaa15b3bd11cbe6c52cc8f2f45b1.tar.gz
lavu/frame: deprecate reordered_opaque
It is only used in libavcodec, where it's been superseded by AV_CODEC_CAP_COPY_OPAQUE.
-rw-r--r--libavcodec/avcodec.h5
-rw-r--r--libavcodec/codec.h6
-rw-r--r--libavcodec/decode.c4
-rw-r--r--libavcodec/encode.c4
-rw-r--r--libavcodec/libdav1d.c15
-rw-r--r--libavcodec/librav1e.c10
-rw-r--r--libavcodec/libwebpenc_animencoder.c10
-rw-r--r--libavcodec/libx264.c14
-rw-r--r--libavcodec/libx265.c17
-rw-r--r--libavcodec/nvenc.c10
-rw-r--r--libavcodec/options.c4
-rw-r--r--libavcodec/pthread_frame.c4
-rw-r--r--libavutil/frame.c4
-rw-r--r--libavutil/frame.h5
-rw-r--r--libavutil/version.h1
15 files changed, 108 insertions, 5 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index eba9ea73d7..755e543fac 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1392,6 +1392,7 @@ typedef struct AVCodecContext {
*/
int err_recognition;
+#if FF_API_REORDERED_OPAQUE
/**
* opaque 64-bit number (generally a PTS) that will be reordered and
* output in AVFrame.reordered_opaque
@@ -1400,8 +1401,12 @@ typedef struct AVCodecContext {
* supported by encoders with the
* AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability.
* - decoding: Set by user.
+ *
+ * @deprecated Use AV_CODEC_FLAG_COPY_OPAQUE instead
*/
+ attribute_deprecated
int64_t reordered_opaque;
+#endif
/**
* Hardware accelerator in use
diff --git a/libavcodec/codec.h b/libavcodec/codec.h
index 77a1a3f5a2..67f9120b44 100644
--- a/libavcodec/codec.h
+++ b/libavcodec/codec.h
@@ -169,9 +169,9 @@
#define AV_CODEC_CAP_HYBRID (1 << 19)
/**
- * This codec takes the reordered_opaque field from input AVFrames
- * and returns it in the corresponding field in AVCodecContext after
- * encoding.
+ * This encoder can reorder user opaque values from input AVFrames and return
+ * them with corresponding output packets.
+ * @see AV_CODEC_FLAG_COPY_OPAQUE
*/
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20)
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 17b398e933..03ae27ecdf 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1357,7 +1357,11 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
return ret;
frame->pkt_size = (int)(intptr_t)pkt->opaque;
}
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
frame->reordered_opaque = avctx->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED)
frame->color_primaries = avctx->color_primaries;
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index c92beaf8e1..b0a9625ca9 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -193,7 +193,11 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
int ff_encode_reordered_opaque(AVCodecContext *avctx,
AVPacket *pkt, const AVFrame *frame)
{
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = frame->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
int ret = av_buffer_replace(&pkt->opaque_ref, frame->opaque_ref);
diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index f7d75f9439..2488a709c7 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -290,7 +290,9 @@ static void libdav1d_flush(AVCodecContext *c)
typedef struct OpaqueData {
void *pkt_orig_opaque;
+#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
+#endif
} OpaqueData;
static void libdav1d_data_free(const uint8_t *data, void *opaque) {
@@ -340,7 +342,11 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
pkt->buf = NULL;
- if (c->reordered_opaque != AV_NOPTS_VALUE ||
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (
+#if FF_API_REORDERED_OPAQUE
+ c->reordered_opaque != AV_NOPTS_VALUE ||
+#endif
(pkt->opaque && (c->flags & AV_CODEC_FLAG_COPY_OPAQUE))) {
od = av_mallocz(sizeof(*od));
if (!od) {
@@ -349,7 +355,10 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
return AVERROR(ENOMEM);
}
od->pkt_orig_opaque = pkt->opaque;
+#if FF_API_REORDERED_OPAQUE
od->reordered_opaque = c->reordered_opaque;
+#endif
+FF_ENABLE_DEPRECATION_WARNINGS
}
pkt->opaque = od;
@@ -432,10 +441,14 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
pkt = (AVPacket *)p->m.user_data.data;
od = pkt->opaque;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
if (od && od->reordered_opaque != AV_NOPTS_VALUE)
frame->reordered_opaque = od->reordered_opaque;
else
frame->reordered_opaque = AV_NOPTS_VALUE;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
// restore the original user opaque value for
// ff_decode_frame_props_from_pkt()
diff --git a/libavcodec/librav1e.c b/libavcodec/librav1e.c
index 00d69328fb..08affabe3e 100644
--- a/libavcodec/librav1e.c
+++ b/libavcodec/librav1e.c
@@ -57,7 +57,9 @@ typedef struct librav1eContext {
typedef struct FrameData {
int64_t pts;
int64_t duration;
+#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
+#endif
void *frame_opaque;
AVBufferRef *frame_opaque_ref;
@@ -465,7 +467,11 @@ static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
}
fd->pts = frame->pts;
fd->duration = frame->duration;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
fd->reordered_opaque = frame->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
fd->frame_opaque = frame->opaque;
@@ -572,7 +578,11 @@ retry:
fd = rpkt->opaque;
pkt->pts = pkt->dts = fd->pts;
pkt->duration = fd->duration;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = fd->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
pkt->opaque = fd->frame_opaque;
diff --git a/libavcodec/libwebpenc_animencoder.c b/libavcodec/libwebpenc_animencoder.c
index 440cae1de5..72d704f490 100644
--- a/libavcodec/libwebpenc_animencoder.c
+++ b/libavcodec/libwebpenc_animencoder.c
@@ -39,7 +39,9 @@ typedef struct LibWebPAnimContext {
int64_t first_frame_pts; // pts of the first encoded frame.
int64_t end_pts; // pts + duration of the last frame
+#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
+#endif
void *first_frame_opaque;
AVBufferRef *first_frame_opaque_ref;
@@ -90,7 +92,11 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (pkt->pts != AV_NOPTS_VALUE && s->end_pts > pkt->pts)
pkt->duration = s->end_pts - pkt->pts;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = s->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
pkt->opaque = s->first_frame_opaque;
pkt->opaque_ref = s->first_frame_opaque_ref;
@@ -128,7 +134,11 @@ static int libwebp_anim_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
if (!avctx->frame_number) {
s->first_frame_pts = frame->pts;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
s->reordered_opaque = frame->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
s->first_frame_opaque = frame->opaque;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 2742fb11a0..f65ac5dacc 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -50,7 +50,9 @@
#define MB_SIZE 16
typedef struct X264Opaque {
+#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
+#endif
int64_t wallclock;
int64_t duration;
@@ -459,7 +461,11 @@ static int setup_frame(AVCodecContext *ctx, const AVFrame *frame,
goto fail;
}
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
opaque->reordered_opaque = frame->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
opaque->duration = frame->duration;
opaque->wallclock = wallclock;
if (ctx->export_side_data & AV_CODEC_EXPORT_DATA_PRFT)
@@ -612,7 +618,11 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
out_opaque = pic_out.opaque;
if (out_opaque >= x4->reordered_opaque &&
out_opaque < &x4->reordered_opaque[x4->nb_reordered_opaque]) {
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
ctx->reordered_opaque = out_opaque->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
wallclock = out_opaque->wallclock;
pkt->duration = out_opaque->duration;
@@ -627,7 +637,11 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
// Unexpected opaque pointer on picture output
av_log(ctx, AV_LOG_ERROR, "Unexpected opaque pointer; "
"this is a bug, please report it.\n");
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
ctx->reordered_opaque = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
}
switch (pic_out.i_type) {
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 6fc189f1b5..6a2600c5e7 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -42,7 +42,9 @@
#include "sei.h"
typedef struct ReorderedData {
+#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
+#endif
int64_t duration;
void *frame_opaque;
@@ -618,7 +620,11 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
rd = &ctx->rd[rd_idx];
rd->duration = pic->duration;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
rd->reordered_opaque = pic->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
rd->frame_opaque = pic->opaque;
ret = av_buffer_replace(&rd->frame_opaque_ref, pic->opaque_ref);
@@ -756,7 +762,11 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int idx = (int)(intptr_t)x265pic_out.userData - 1;
ReorderedData *rd = &ctx->rd[idx];
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = rd->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
pkt->duration = rd->duration;
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
@@ -766,8 +776,13 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
}
rd_release(ctx, idx);
- } else
+ }
+#if FF_API_REORDERED_OPAQUE
+ else
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
*got_packet = 1;
return 0;
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index ab42dc9690..8a28454042 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -166,7 +166,9 @@ static int nvenc_print_error(AVCodecContext *avctx, NVENCSTATUS err,
typedef struct FrameData {
int64_t pts;
int64_t duration;
+#if FF_API_REORDERED_OPAQUE
int64_t reordered_opaque;
+#endif
void *frame_opaque;
AVBufferRef *frame_opaque_ref;
@@ -2203,7 +2205,11 @@ static void reorder_queue_enqueue(AVFifo *queue, const AVCodecContext *avctx,
fd.pts = frame->pts;
fd.duration = frame->duration;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
fd.reordered_opaque = frame->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
fd.frame_opaque = frame->opaque;
fd.frame_opaque_ref = *opaque_ref;
@@ -2222,7 +2228,11 @@ static int64_t reorder_queue_dequeue(AVFifo *queue, AVCodecContext *avctx,
return AV_NOPTS_VALUE;
if (pkt) {
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
avctx->reordered_opaque = fd.reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
pkt->duration = fd.duration;
if (avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 2e05d29e1e..9090c94e9c 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -124,7 +124,11 @@ static int init_context_defaults(AVCodecContext *s, const AVCodec *codec)
s->sw_pix_fmt = AV_PIX_FMT_NONE;
s->sample_fmt = AV_SAMPLE_FMT_NONE;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
s->reordered_opaque = AV_NOPTS_VALUE;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
if(codec && codec2->priv_data_size){
s->priv_data = av_mallocz(codec2->priv_data_size);
if (!s->priv_data)
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 62a0b18a8a..ae8d051acd 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -390,7 +390,11 @@ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
dst->skip_frame = src->skip_frame;
dst->frame_number = src->frame_number;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
dst->reordered_opaque = src->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
#if FF_API_THREAD_SAFE_CALLBACKS
FF_DISABLE_DEPRECATION_WARNINGS
dst->thread_safe_callbacks = src->thread_safe_callbacks;
diff --git a/libavutil/frame.c b/libavutil/frame.c
index fa9b11aa54..2d81de8b0d 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -304,7 +304,11 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
#endif
dst->time_base = src->time_base;
+#if FF_API_REORDERED_OPAQUE
+FF_DISABLE_DEPRECATION_WARNINGS
dst->reordered_opaque = src->reordered_opaque;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
dst->quality = src->quality;
dst->best_effort_timestamp = src->best_effort_timestamp;
dst->coded_picture_number = src->coded_picture_number;
diff --git a/libavutil/frame.h b/libavutil/frame.h
index bbe909ee2d..911af515f4 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -491,6 +491,7 @@ typedef struct AVFrame {
*/
int palette_has_changed;
+#if FF_API_REORDERED_OPAQUE
/**
* reordered opaque 64 bits (generally an integer or a double precision float
* PTS but can be anything).
@@ -498,8 +499,12 @@ typedef struct AVFrame {
* that time,
* the decoder reorders values as needed and sets AVFrame.reordered_opaque
* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
+ *
+ * @deprecated Use AV_CODEC_FLAG_COPY_OPAQUE instead
*/
+ attribute_deprecated
int64_t reordered_opaque;
+#endif
/**
* Sample rate of the audio data.
diff --git a/libavutil/version.h b/libavutil/version.h
index 60f96af5df..43daf8cd5a 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -115,6 +115,7 @@
#define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_AV_FOPEN_UTF8 (LIBAVUTIL_VERSION_MAJOR < 58)
#define FF_API_PKT_DURATION (LIBAVUTIL_VERSION_MAJOR < 58)
+#define FF_API_REORDERED_OPAQUE (LIBAVUTIL_VERSION_MAJOR < 59)
/**
* @}