]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
update pict_type from AVPacket to AVFrame
authoruknunknown <alin_gherghescu@yahoo.com>
Fri, 14 Apr 2023 17:25:41 +0000 (10:25 -0700)
committerFlole998 <Flole998@users.noreply.github.com>
Mon, 17 Apr 2023 23:41:45 +0000 (01:41 +0200)
- remove deprecated FF_API_CODED_FRAME
- remove pict_type from AVPacket_SideData
- use AVFrame->pict_type (same like ffmpeg 5.1.2 - ffprobe.c line 2595)
- remove patch for vaapi_encode

Makefile.ffmpeg
src/transcoding/transcode/video.c
support/patches/ffmpeg.vaapi_encode.diff [deleted file]

index 6581e906441457a9942c04d5ba7917b19497e8df..6ed6eaa3c2313856b23dfa8cb9102f4163f3a14a 100644 (file)
@@ -614,7 +614,6 @@ EXTLIBS  += vaapi
 ENCODERS += h264_vaapi hevc_vaapi vp8_vaapi vp9_vaapi
 HWACCELS += mpeg2_vaapi h264_vaapi hevc_vaapi vp9_vaapi
 FILTERS  += deinterlace_vaapi scale_vaapi denoise_vaapi sharpness_vaapi
-FFMPEG_DIFFS += ffmpeg.vaapi_encode.diff
 
 endif
 
index 6a98784da1eb2a7bef51462cc736c9c74f204b67..029157c100a2e2afc1d2cb32e8a9bce8b0210a24 100644 (file)
@@ -340,41 +340,24 @@ tvh_video_context_ship(TVHContext *self, AVPacket *avpkt)
 
 static int
 tvh_video_context_wrap(TVHContext *self, AVPacket *avpkt, th_pkt_t *pkt)
-{
-    uint8_t *qsdata = NULL;
-#if LIBAVCODEC_VERSION_MAJOR < 59
-    int qsdata_size = 0;
-#else
-    size_t qsdata_size = 0;
-#endif
-    
-    enum AVPictureType pict_type = AV_PICTURE_TYPE_NONE;
+{   
+    enum AVPictureType pict_type = self->oavframe->pict_type;
 
-    if (avpkt->flags & AV_PKT_FLAG_KEY) {
+    if (pict_type == AV_PICTURE_TYPE_NONE && avpkt->flags & AV_PKT_FLAG_KEY) {
         pict_type = AV_PICTURE_TYPE_I;
     }
-    else {
-        qsdata = av_packet_get_side_data(avpkt, AV_PKT_DATA_QUALITY_STATS,
-                                         &qsdata_size);
-        if (qsdata && qsdata_size >= 5) {
-            pict_type = qsdata[4];
+    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
+        // (all the others are assumed to be P-frames)
+        if (self->oavframe->key_frame) {
+            pict_type = AV_PICTURE_TYPE_I;
         }
-#if FF_API_CODED_FRAME
-        else if (self->oavctx->coded_frame) {
-            // 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
-            // (all the others are assumed to be P-frames)
-            if (!(pict_type = self->oavctx->coded_frame->pict_type)) {
-                if (self->oavctx->coded_frame->key_frame) {
-                    pict_type = AV_PICTURE_TYPE_I;
-                }
-                else {
-                    pict_type = AV_PICTURE_TYPE_P;
-                }
-            }
+        else {
+            pict_type = AV_PICTURE_TYPE_P;
         }
-#endif
     }
+
     switch (pict_type) {
         case AV_PICTURE_TYPE_I:
             pkt->v.pkt_frametype = PKT_I_FRAME;
@@ -385,6 +368,8 @@ tvh_video_context_wrap(TVHContext *self, AVPacket *avpkt, th_pkt_t *pkt)
         case AV_PICTURE_TYPE_B:
             pkt->v.pkt_frametype = PKT_B_FRAME;
             break;
+        case AV_PICTURE_TYPE_NONE:
+            break;
         default:
             tvh_context_log(self, LOG_WARNING, "unknown picture type: %d",
                             pict_type);
diff --git a/support/patches/ffmpeg.vaapi_encode.diff b/support/patches/ffmpeg.vaapi_encode.diff
deleted file mode 100644 (file)
index ef86278..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-diff -urN ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode.c ./libavcodec/vaapi_encode.c
---- ../ffmpeg-3.1.3.orig/libavcodec/vaapi_encode.c     2016-06-27 01:54:29.000000000 +0200
-+++ ./libavcodec/vaapi_encode.c        2016-08-31 11:53:21.159413291 +0200
-@@ -26,6 +26,8 @@
- #include "vaapi_encode.h"
- #include "avcodec.h"
-+#include "internal.h"
-+#include "packet_internal.h"
- const AVCodecHWConfigInternal *ff_vaapi_encode_hw_configs[] = {
-     HW_CONFIG_ENCODER_FRAMES(VAAPI, VAAPI),
-@@ -586,7 +588,7 @@ static int vaapi_encode_output(AVCodecCo
-     VAStatus vas;
-     int total_size = 0;
-     uint8_t *ptr;
--    int err;
-+    int err, pict_type;
-     err = vaapi_encode_wait(avctx, pic);
-     if (err < 0)
-@@ -624,6 +626,28 @@ static int vaapi_encode_output(AVCodecCo
-     pkt->pts = pic->pts;
-+    switch (pic->type) {
-+    case PICTURE_TYPE_IDR:
-+    case PICTURE_TYPE_I:
-+        pict_type = AV_PICTURE_TYPE_I;
-+        break;
-+    case PICTURE_TYPE_P:
-+        pict_type = AV_PICTURE_TYPE_P;
-+        break;
-+    case PICTURE_TYPE_B:
-+        pict_type = AV_PICTURE_TYPE_B;
-+        break;
-+    default:
-+        pict_type = AV_PICTURE_TYPE_NONE;
-+        break;
-+    }
-+#if FF_API_CODED_FRAME
-+FF_DISABLE_DEPRECATION_WARNINGS
-+    avctx->coded_frame->pict_type = pict_type;
-+FF_ENABLE_DEPRECATION_WARNINGS
-+#endif
-+    ff_side_data_set_encoder_stats(pkt, -1, NULL, 0, pict_type);
-+
-     vas = vaUnmapBuffer(ctx->hwctx->display, pic->output_buffer);
-     if (vas != VA_STATUS_SUCCESS) {
-         av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "