]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Replace deprecated interlaced_frame, top_field_first and key_frame
authorAndré Apitzsch <git@apitzsch.eu>
Sun, 23 Jun 2024 14:47:51 +0000 (16:47 +0200)
committerFlole <Flole998@users.noreply.github.com>
Tue, 25 Jun 2024 00:02:05 +0000 (02:02 +0200)
src/transcoding/transcode/video.c

index 029157c100a2e2afc1d2cb32e8a9bce8b0210a24..b75e71dc1c4b6ea5dc8f2450592a7d73b4b5dfa9 100644 (file)
@@ -316,6 +316,15 @@ tvh_video_context_encode(TVHContext *self, AVFrame *avframe)
         return AVERROR(EAGAIN);
     }
     self->pts = avframe->pts;
+#if LIBAVUTIL_VERSION_MAJOR > 58 || (LIBAVUTIL_VERSION_MAJOR == 58 && LIBAVUTIL_VERSION_MINOR > 2)
+    if (avframe->flags & AV_FRAME_FLAG_INTERLACED) {
+        self->oavctx->field_order =
+            (avframe->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB : AV_FIELD_BT;
+    }
+    else {
+        self->oavctx->field_order = AV_FIELD_PROGRESSIVE;
+    }
+#else
     if (avframe->interlaced_frame) {
         self->oavctx->field_order =
             avframe->top_field_first ? AV_FIELD_TB : AV_FIELD_BT;
@@ -323,6 +332,7 @@ tvh_video_context_encode(TVHContext *self, AVFrame *avframe)
     else {
         self->oavctx->field_order = AV_FIELD_PROGRESSIVE;
     }
+#endif
     return 0;
 }
 
@@ -347,15 +357,24 @@ tvh_video_context_wrap(TVHContext *self, AVPacket *avpkt, th_pkt_t *pkt)
         pict_type = AV_PICTURE_TYPE_I;
     }
     if (pict_type == AV_PICTURE_TYPE_NONE) {
-        // some codecs do not set pict_type but set key_frame, in this case,
-        // we assume that when key_frame == 1 the frame is an I-frame
+        // some codecs do not set pict_type but set AV_FRAME_FLAG_KEY, in this case,
+        // we assume that when AV_FRAME_FLAG_KEY is set the frame is an I-frame
         // (all the others are assumed to be P-frames)
+#if LIBAVUTIL_VERSION_MAJOR > 58 || (LIBAVUTIL_VERSION_MAJOR == 58 && LIBAVUTIL_VERSION_MINOR > 2)
+        if (self->oavframe->flags & AV_FRAME_FLAG_KEY) {
+            pict_type = AV_PICTURE_TYPE_I;
+        }
+        else {
+            pict_type = AV_PICTURE_TYPE_P;
+        }
+#else
         if (self->oavframe->key_frame) {
             pict_type = AV_PICTURE_TYPE_I;
         }
         else {
             pict_type = AV_PICTURE_TYPE_P;
         }
+#endif
     }
 
     switch (pict_type) {