[FFmpeg-devel] [PATCH 5/5] avutil/frame: deprecate key_frame

James Almer jamrial at gmail.com
Thu Apr 13 19:29:40 EEST 2023


Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/decode.c          |  4 ++++
 libavcodec/encode.c          |  4 ++++
 libavfilter/buffersrc.c      |  4 ++++
 libavfilter/vf_coreimage.m   |  2 ++
 libavfilter/vsrc_gradients.c |  5 +++++
 libavfilter/vsrc_testsrc.c   |  4 ++++
 libavutil/frame.c            | 10 +++++++++-
 libavutil/frame.h            |  5 +++++
 libavutil/version.h          |  1 +
 9 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index edc6a6acba..cf7c4c3889 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -572,7 +572,11 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
     if (!ret) {
         if (avctx->codec_type != AVMEDIA_TYPE_VIDEO)
             frame->flags |= AV_FRAME_FLAG_KEY;
+#if FF_API_FRAME_KEY
+FF_DISABLE_DEPRECATION_WARNINGS
         frame->key_frame = !!(frame->flags & AV_FRAME_FLAG_KEY);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         frame->best_effort_timestamp = guess_correct_pts(avctx,
                                                          frame->pts,
                                                          frame->pkt_dts);
diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index d3c0bf6aad..bceb3b50b7 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -192,8 +192,12 @@ int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
 
     av_frame_move_ref(frame, avci->buffer_frame);
 
+#if FF_API_FRAME_KEY
+FF_DISABLE_DEPRECATION_WARNINGS
     if (frame->key_frame)
         frame->flags |= AV_FRAME_FLAG_KEY;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     return 0;
 }
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index a81c331cd5..0ccab4cf3f 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -247,8 +247,12 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+#if FF_API_FRAME_KEY
+FF_DISABLE_DEPRECATION_WARNINGS
     if (frame->key_frame)
         frame->flags |= AV_FRAME_FLAG_KEY;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
     ret = ff_filter_frame(ctx->outputs[0], copy);
     if (ret < 0)
diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index ea43aad275..5db0d39264 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -301,7 +301,9 @@ static int request_frame(AVFilterLink *link)
 
     frame->pts                 = ctx->pts;
     frame->duration            = 1;
+#if FF_API_FRAME_KEY
     frame->key_frame           = 1;
+#endif
     frame->flags              |= AV_FRAME_FLAG_KEY;
     frame->interlaced_frame    = 0;
     frame->pict_type           = AV_PICTURE_TYPE_I;
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index 39e9e226ee..b8d59650d0 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -397,7 +397,12 @@ static int activate(AVFilterContext *ctx)
         if (!frame)
             return AVERROR(ENOMEM);
 
+#if FF_API_FRAME_KEY
+FF_DISABLE_DEPRECATION_WARNINGS
         frame->key_frame           = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
+
         frame->flags              |= AV_FRAME_FLAG_KEY;
         frame->interlaced_frame    = 0;
         frame->pict_type           = AV_PICTURE_TYPE_I;
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 7fb1ef9718..5380c78692 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -184,7 +184,11 @@ static int activate(AVFilterContext *ctx)
         return AVERROR(ENOMEM);
     frame->pts                 = test->pts;
     frame->duration            = 1;
+#if FF_API_PKT_DURATION
+FF_DISABLE_DEPRECATION_WARNINGS
     frame->key_frame           = 1;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     frame->flags              |= AV_FRAME_FLAG_KEY;
     frame->interlaced_frame    = 0;
     frame->pict_type           = AV_PICTURE_TYPE_I;
diff --git a/libavutil/frame.c b/libavutil/frame.c
index c905e8d611..87c7039d50 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -55,7 +55,11 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
     frame->time_base           = (AVRational){ 0, 1 };
-    frame->key_frame           = 1;
+#if FF_API_FRAME_KEY
+FF_DISABLE_DEPRECATION_WARNINGS
+    frame->key_frame           = 0;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     frame->sample_aspect_ratio = (AVRational){ 0, 1 };
     frame->format              = -1; /* unknown */
     frame->extended_data       = frame->data;
@@ -265,7 +269,11 @@ static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy)
 {
     int ret;
 
+#if FF_API_FRAME_KEY
+FF_DISABLE_DEPRECATION_WARNINGS
     dst->key_frame              = src->key_frame;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
     dst->pict_type              = src->pict_type;
     dst->sample_aspect_ratio    = src->sample_aspect_ratio;
     dst->crop_top               = src->crop_top;
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 895e06bbd7..353079fe51 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -416,10 +416,15 @@ typedef struct AVFrame {
      */
     int format;
 
+#if FF_API_FRAME_KEY
     /**
      * 1 -> keyframe, 0-> not
+     *
+     * @deprecated Use AV_FRAME_FLAG_KEY instead
      */
+    attribute_deprecated
     int key_frame;
+#endif
 
     /**
      * Picture type of the frame.
diff --git a/libavutil/version.h b/libavutil/version.h
index 40f92af055..406ba2a619 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -115,6 +115,7 @@
 #define FF_API_FRAME_PICTURE_NUMBER     (LIBAVUTIL_VERSION_MAJOR < 59)
 #define FF_API_HDR_VIVID_THREE_SPLINE   (LIBAVUTIL_VERSION_MAJOR < 59)
 #define FF_API_FRAME_PKT                (LIBAVUTIL_VERSION_MAJOR < 59)
+#define FF_API_FRAME_KEY                (LIBAVUTIL_VERSION_MAJOR < 59)
 
 /**
  * @}
-- 
2.40.0



More information about the ffmpeg-devel mailing list