From: André Apitzsch Date: Sun, 23 Jun 2024 14:47:51 +0000 (+0200) Subject: Replace deprecated interlaced_frame, top_field_first and key_frame X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=128d6861fac67ea6638c2956d092a46e23eb8988;p=thirdparty%2Ftvheadend.git Replace deprecated interlaced_frame, top_field_first and key_frame --- diff --git a/src/transcoding/transcode/video.c b/src/transcoding/transcode/video.c index 029157c10..b75e71dc1 100644 --- a/src/transcoding/transcode/video.c +++ b/src/transcoding/transcode/video.c @@ -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) {