[FFmpeg-cvslog] avfilter: use the new AVFrame key_frame flag in all filters

James Almer git at videolan.org
Fri May 5 02:50:54 EEST 2023


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Apr 12 19:35:56 2023 -0300| [af8db9106c27a1ef11ec69ecbbe7a57462c14367] | committer: James Almer

avfilter: use the new AVFrame key_frame flag in all filters

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af8db9106c27a1ef11ec69ecbbe7a57462c14367
---

 libavfilter/avfilter.c       | 2 +-
 libavfilter/buffersrc.c      | 3 +++
 libavfilter/f_select.c       | 4 ++--
 libavfilter/vf_blackframe.c  | 2 +-
 libavfilter/vf_coreimage.m   | 1 +
 libavfilter/vf_showinfo.c    | 2 +-
 libavfilter/vsrc_gradients.c | 1 +
 libavfilter/vsrc_testsrc.c   | 1 +
 8 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 889808c580..0141b64cbc 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -59,7 +59,7 @@ static void tlog_ref(void *ctx, AVFrame *ref, int end)
                 ref->width, ref->height,
                 !(ref->flags & AV_FRAME_FLAG_INTERLACED) ? 'P' : /* Progressive  */
                 (ref->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B', /* Top / Bottom */
-                ref->key_frame,
+                !!(ref->flags & AV_FRAME_FLAG_KEY),
                 av_get_picture_type_char(ref->pict_type));
     }
     if (ref->nb_samples) {
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index 1d2f357bbc..8d5a08995b 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -256,6 +256,9 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+    if (copy->key_frame)
+        copy->flags |= AV_FRAME_FLAG_KEY;
+
     ret = ff_filter_frame(ctx->outputs[0], copy);
     if (ret < 0)
         return ret;
diff --git a/libavfilter/f_select.c b/libavfilter/f_select.c
index 6eab92b32f..49fcdc31ff 100644
--- a/libavfilter/f_select.c
+++ b/libavfilter/f_select.c
@@ -346,7 +346,7 @@ FF_DISABLE_DEPRECATION_WARNINGS
     select->var_values[VAR_POS] = frame->pkt_pos == -1 ? NAN : frame->pkt_pos;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-    select->var_values[VAR_KEY] = frame->key_frame;
+    select->var_values[VAR_KEY] = !!(frame->flags & AV_FRAME_FLAG_KEY);
     select->var_values[VAR_CONCATDEC_SELECT] = get_concatdec_select(frame, av_rescale_q(frame->pts, inlink->time_base, AV_TIME_BASE_Q));
 
     switch (inlink->type) {
@@ -375,7 +375,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
            select->var_values[VAR_N],
            select->var_values[VAR_PTS],
            select->var_values[VAR_T],
-           frame->key_frame);
+           !!(frame->flags & AV_FRAME_FLAG_KEY));
 
     switch (inlink->type) {
     case AVMEDIA_TYPE_VIDEO:
diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c
index e5e185dbea..4bcec86688 100644
--- a/libavfilter/vf_blackframe.c
+++ b/libavfilter/vf_blackframe.c
@@ -72,7 +72,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
         p += frame->linesize[0];
     }
 
-    if (frame->key_frame)
+    if (frame->flags & AV_FRAME_FLAG_KEY)
         s->last_keyframe = s->frame;
 
     pblack = s->nblack * 100 / (inlink->w * inlink->h);
diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index a2e3dbea46..aa0c90f537 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -302,6 +302,7 @@ static int request_frame(AVFilterLink *link)
     frame->pts                 = ctx->pts;
     frame->duration            = 1;
     frame->key_frame           = 1;
+    frame->flags              |= AV_FRAME_FLAG_KEY
 #if FF_API_INTERLACED_FRAME
     frame->interlaced_frame    = 0;
 #endif
diff --git a/libavfilter/vf_showinfo.c b/libavfilter/vf_showinfo.c
index 6ecab2bf71..bf8580bc8d 100644
--- a/libavfilter/vf_showinfo.c
+++ b/libavfilter/vf_showinfo.c
@@ -724,7 +724,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
            frame->width, frame->height,
            !(frame->flags & AV_FRAME_FLAG_INTERLACED)     ? 'P' :         /* Progressive  */
            (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? 'T' : 'B',    /* Top / Bottom */
-           frame->key_frame,
+           !!(frame->flags & AV_FRAME_FLAG_KEY),
            av_get_picture_type_char(frame->pict_type));
 
     if (s->calculate_checksums) {
diff --git a/libavfilter/vsrc_gradients.c b/libavfilter/vsrc_gradients.c
index f50b4d3cc7..bc2cfb024c 100644
--- a/libavfilter/vsrc_gradients.c
+++ b/libavfilter/vsrc_gradients.c
@@ -398,6 +398,7 @@ static int activate(AVFilterContext *ctx)
             return AVERROR(ENOMEM);
 
         frame->key_frame           = 1;
+        frame->flags              |= AV_FRAME_FLAG_KEY;
 #if FF_API_INTERLACED_FRAME
 FF_DISABLE_DEPRECATION_WARNINGS
         frame->interlaced_frame    = 0;
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index c358f9ada2..d4037c6da8 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -185,6 +185,7 @@ static int activate(AVFilterContext *ctx)
     frame->pts                 = test->pts;
     frame->duration            = 1;
     frame->key_frame           = 1;
+    frame->flags              |= AV_FRAME_FLAG_KEY;
 #if FF_API_INTERLACED_FRAME
 FF_DISABLE_DEPRECATION_WARNINGS
     frame->interlaced_frame    = 0;



More information about the ffmpeg-cvslog mailing list