[FFmpeg-cvslog] fftools: use the new AVFrame interlace flags

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


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Apr 12 11:42:35 2023 -0300| [3675dd0e0c8892151441a02ed0c5dee72a111c81] | committer: James Almer

fftools: use the new AVFrame interlace flags

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

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

 fftools/ffmpeg.c     |  2 +-
 fftools/ffmpeg_enc.c | 11 +++++++----
 fftools/ffprobe.c    |  4 ++--
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index be9a3b2e34..23aa343bbc 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1098,7 +1098,7 @@ static int decode_video(InputStream *ist, const AVPacket *pkt, int *got_output,
         return ret;
 
     if(ist->top_field_first>=0)
-        decoded_frame->top_field_first = ist->top_field_first;
+        decoded_frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
 
     ist->frames_decoded++;
 
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 5707199ac5..f2af81bacc 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -257,13 +257,16 @@ int enc_open(OutputStream *ost, AVFrame *frame)
         if (frame) {
             if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
                 ost->top_field_first >= 0)
-                frame->top_field_first = !!ost->top_field_first;
+                if (ost->top_field_first)
+                    frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+                else
+                    frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
 
-            if (frame->interlaced_frame) {
+            if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
                 if (enc->id == AV_CODEC_ID_MJPEG)
-                    enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TT:AV_FIELD_BB;
+                    enc_ctx->field_order = (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TT:AV_FIELD_BB;
                 else
-                    enc_ctx->field_order = frame->top_field_first ? AV_FIELD_TB:AV_FIELD_BT;
+                    enc_ctx->field_order = (frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB:AV_FIELD_BT;
             } else
                 enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
         }
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 6e72c37721..10492011d7 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2640,8 +2640,8 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
         print_int("display_picture_number", frame->display_picture_number);
     )
 #endif
-        print_int("interlaced_frame",       frame->interlaced_frame);
-        print_int("top_field_first",        frame->top_field_first);
+        print_int("interlaced_frame",       !!(frame->flags & AV_FRAME_FLAG_INTERLACED));
+        print_int("top_field_first",        !!(frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST));
         print_int("repeat_pict",            frame->repeat_pict);
 
         print_color_range(w, frame->color_range);



More information about the ffmpeg-cvslog mailing list