From: uknunknown Date: Fri, 14 Apr 2023 17:25:41 +0000 (-0700) Subject: update pict_type from AVPacket to AVFrame X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e10f98601b8bfee4c6b0093012ce45654666f501;p=thirdparty%2Ftvheadend.git update pict_type from AVPacket to AVFrame - 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 --- diff --git a/Makefile.ffmpeg b/Makefile.ffmpeg index 6581e9064..6ed6eaa3c 100644 --- a/Makefile.ffmpeg +++ b/Makefile.ffmpeg @@ -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 diff --git a/src/transcoding/transcode/video.c b/src/transcoding/transcode/video.c index 6a98784da..029157c10 100644 --- a/src/transcoding/transcode/video.c +++ b/src/transcoding/transcode/video.c @@ -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 index ef862789d..000000000 --- a/support/patches/ffmpeg.vaapi_encode.diff +++ /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: "