From nobody Sun Apr 24 00:31:44 2022 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 962E6199D616; Sun, 24 Apr 2022 00:31:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Km8GS2n9cz3lk7; Sun, 24 Apr 2022 00:31:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650760304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iPzZnrt2hFPBKYwouHxKQZgsrrXleypQaPUfiojzQtY=; b=j5qVB1gUYn2chwDwnvdwxx91TplONLQGUzbV+mF/f1WnPnhXCn9RcIyL9tZjPvHnFRLjBs eaIam05jsTgFGd9Y/1pKib9zFon1nCYPh2lEb21QFxw7oVnaf3D+seOJCol++Hn0oqyzhU v4JMkN702hlbuQcMzq9AtAEIZWA5cW9tzRW1mt74kRAS0CeWsBDmA+p6GitnzJ/Uvsekss Tg54Ph0ANo/qGCpFpaQtuu5STJoXWMwEqSTDxHlVGua2G+W+kdw374qpBe+0Ms1wsqK7W9 lmLMiYH11LnnPKUQmUXpMxxKOoGxA43azvwqVcUqxoEGGsuNZGNl5ANX0Mk/jQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2EFBA1C0DB; Sun, 24 Apr 2022 00:31:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23O0Vi8j067612; Sun, 24 Apr 2022 00:31:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23O0Vi03067611; Sun, 24 Apr 2022 00:31:44 GMT (envelope-from git) Date: Sun, 24 Apr 2022 00:31:44 GMT Message-Id: <202204240031.23O0Vi03067611@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Jan Beich Subject: git: c4014afccfc5 - main - multimedia/ffmpeg: backport one more SVTAV1 fix List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jbeich X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c4014afccfc5663942be640d0e753aee8d152a83 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650760304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iPzZnrt2hFPBKYwouHxKQZgsrrXleypQaPUfiojzQtY=; b=k5iR0tyM4Wx4J0nularmX6oBsoYYwspM2kuxKeRLQnm6CrDjE5kKEOwG240MS7AJyUa3pC auhNRuJo4jj1iasvipXbBf4PObcJ4wTeBmUfh7cqPurhjUIsIr8+82qnO+NUmos+FwU0W3 77bWp6pMceeiWe1drfvG3BhMFod6MEykDV1576NtVQcdVQPZWhfD0BPcaweXs5aXrS53i2 M8Tf7VW41OugN9m7/K6uK8+Qy2yt0SU99D3EpNbyzihcD1dDm8Ey17o54gnEHAVUj4vHhl 9izzPiATPCKH1khVetqCOffz83y9YUSkY/+Gx3xsP6H1F/pMNxcMUSls2wOhOQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650760304; a=rsa-sha256; cv=none; b=u/0ZeaE+ONr9peWelp6MKKROjCtBkpX9sm9ieG2QE5b2lXjyi9ig25b82CcJTaAacf40Ze UUBGolvzVFkBQSj2bidoCK+SZnG8n7zh3EijHFLrQxFqpCQkWJIkMlL2r4DONIRynz4X4R hXwrZ7HSM2imJyg02VWqrsXlo4UCS8iM8U34bS6MfZjar3np4TAYF6Thn9qdy/yx7Xx1Au DDj9M/3YYLGZ+dAp7o1OirH3McVK70dv7KLrKlr1M7Am/A8xSiTzQpDiRnSu8K+g7DsefH 7vee/yKyMnhYykaxspT70nkJh6RuRKccny2dXBue3hG9y7ppxQ5+cWsS6OM83g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jbeich: URL: https://cgit.FreeBSD.org/ports/commit/?id=c4014afccfc5663942be640d0e753aee8d152a83 commit c4014afccfc5663942be640d0e753aee8d152a83 Author: Jan Beich AuthorDate: 2022-04-24 00:00:09 +0000 Commit: Jan Beich CommitDate: 2022-04-24 00:10:13 +0000 multimedia/ffmpeg: backport one more SVTAV1 fix https://gitlab.com/AOMediaCodec/SVT-AV1/-/issues/1858 --- multimedia/ffmpeg/Makefile | 1 + multimedia/ffmpeg/files/patch-svtav1 | 138 ++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 49 deletions(-) diff --git a/multimedia/ffmpeg/Makefile b/multimedia/ffmpeg/Makefile index 765ec58b8f61..b570f016d5c4 100644 --- a/multimedia/ffmpeg/Makefile +++ b/multimedia/ffmpeg/Makefile @@ -2,6 +2,7 @@ PORTNAME= ffmpeg PORTVERSION= 4.4.2 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= multimedia audio net MASTER_SITES= https://ffmpeg.org/releases/ diff --git a/multimedia/ffmpeg/files/patch-svtav1 b/multimedia/ffmpeg/files/patch-svtav1 index 5cb3b47c42eb..9ee7e8ff3271 100644 --- a/multimedia/ffmpeg/files/patch-svtav1 +++ b/multimedia/ffmpeg/files/patch-svtav1 @@ -9,6 +9,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/4e47ebf38b97 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/50bc87263576 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/d794b36a7788 https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be +https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a --- configure.orig 2021-10-24 20:47:11 UTC +++ configure @@ -102,12 +103,14 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be } SvtContext; static const struct { -@@ -151,7 +154,62 @@ static int config_enc_params(EbSvtAv1EncConfiguration +@@ -151,49 +154,62 @@ static int config_enc_params(EbSvtAv1EncConfiguration { SvtContext *svt_enc = avctx->priv_data; const AVPixFmtDescriptor *desc; + AVDictionaryEntry *en = NULL; +- param->source_width = avctx->width; +- param->source_height = avctx->height; + // Update param from options +#if FF_API_SVTAV1_OPTS + param->hierarchical_levels = svt_enc->hierarchical_level; @@ -115,11 +118,22 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be + param->scene_change_detection = svt_enc->scd; + param->tile_columns = svt_enc->tile_columns; + param->tile_rows = svt_enc->tile_rows; -+ + +- desc = av_pix_fmt_desc_get(avctx->pix_fmt); +- param->encoder_bit_depth = desc->comp[0].depth; + if (svt_enc->la_depth >= 0) + param->look_ahead_distance = svt_enc->la_depth; +#endif -+ + +- if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1) +- param->encoder_color_format = EB_YUV420; +- else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0) +- param->encoder_color_format = EB_YUV422; +- else if (!desc->log2_chroma_w && !desc->log2_chroma_h) +- param->encoder_color_format = EB_YUV444; +- else { +- av_log(avctx, AV_LOG_ERROR , "Unsupported pixel format\n"); +- return AVERROR(EINVAL); + if (svt_enc->enc_mode >= 0) + param->enc_mode = svt_enc->enc_mode; + @@ -129,10 +143,13 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be + param->rate_control_mode = 1; + else + param->rate_control_mode = 2; -+ } ++ ++ param->max_qp_allowed = avctx->qmax; ++ param->min_qp_allowed = avctx->qmin; + } + param->max_bit_rate = avctx->rc_max_rate; + param->vbv_bufsize = avctx->rc_buffer_size; -+ + + if (svt_enc->crf > 0) { + param->qp = svt_enc->crf; + param->rate_control_mode = 0; @@ -142,33 +159,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be + param->enable_adaptive_quantization = 0; + } + -+#if SVT_AV1_CHECK_VERSION(0, 9, 1) -+ while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) { -+ EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value); -+ if (ret != EB_ErrorNone) { -+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING; -+ av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value); -+ if (avctx->err_recognition & AV_EF_EXPLODE) -+ return AVERROR(EINVAL); -+ } -+ } -+#else -+ if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { -+ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING; -+ av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 " -+ "headers >= 0.9.1.\n"); -+ if (avctx->err_recognition & AV_EF_EXPLODE) -+ return AVERROR(ENOSYS); -+ } -+#endif -+ - param->source_width = avctx->width; - param->source_height = avctx->height; - -@@ -169,6 +227,16 @@ static int config_enc_params(EbSvtAv1EncConfiguration - return AVERROR(EINVAL); - } - ++ desc = av_pix_fmt_desc_get(avctx->pix_fmt); + param->color_primaries = avctx->color_primaries; + param->matrix_coefficients = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? + AVCOL_SPC_RGB : avctx->colorspace; @@ -182,10 +173,18 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be if (avctx->profile != FF_PROFILE_UNKNOWN) param->profile = avctx->profile; -@@ -184,16 +252,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration - param->profile = FF_PROFILE_AV1_HIGH; - } - + if (avctx->level != FF_LEVEL_UNKNOWN) + param->level = avctx->level; + +- if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10) +- && param->profile != FF_PROFILE_AV1_PROFESSIONAL ) { +- av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n"); +- param->profile = FF_PROFILE_AV1_PROFESSIONAL; +- } else if (param->encoder_color_format == EB_YUV444 && param->profile != FF_PROFILE_AV1_HIGH) { +- av_log(avctx, AV_LOG_WARNING, "Forcing High profile\n"); +- param->profile = FF_PROFILE_AV1_HIGH; +- } +- - // Update param from options - param->hierarchical_levels = svt_enc->hierarchical_level; - param->enc_mode = svt_enc->enc_mode; @@ -199,31 +198,72 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be if (avctx->gop_size > 0) param->intra_period_length = avctx->gop_size - 1; -@@ -205,19 +263,15 @@ static int config_enc_params(EbSvtAv1EncConfiguration +@@ -205,19 +221,56 @@ static int config_enc_params(EbSvtAv1EncConfiguration param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame; } - if (param->rate_control_mode) { -+ avctx->bit_rate = param->target_bit_rate; -+ if (avctx->bit_rate) { - param->max_qp_allowed = avctx->qmax; - param->min_qp_allowed = avctx->qmin; +- param->max_qp_allowed = avctx->qmax; +- param->min_qp_allowed = avctx->qmin; ++ /* 2 = IDR, closed GOP, 1 = CRA, open GOP */ ++ param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1; ++ ++#if SVT_AV1_CHECK_VERSION(0, 9, 1) ++ while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) { ++ EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value); ++ if (ret != EB_ErrorNone) { ++ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING; ++ av_log(avctx, level, "Error parsing option %s: %s.\n", en->key, en->value); ++ if (avctx->err_recognition & AV_EF_EXPLODE) ++ return AVERROR(EINVAL); ++ } } ++#else ++ if ((en = av_dict_get(svt_enc->svtav1_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) { ++ int level = (avctx->err_recognition & AV_EF_EXPLODE) ? AV_LOG_ERROR : AV_LOG_WARNING; ++ av_log(avctx, level, "svt-params needs libavcodec to be compiled with SVT-AV1 " ++ "headers >= 0.9.1.\n"); ++ if (avctx->err_recognition & AV_EF_EXPLODE) ++ return AVERROR(ENOSYS); ++ } ++#endif - param->intra_refresh_type = 2; /* Real keyframes only */ -+ /* 2 = IDR, closed GOP, 1 = CRA, open GOP */ -+ param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1; ++ param->source_width = avctx->width; ++ param->source_height = avctx->height; - if (svt_enc->la_depth >= 0) - param->look_ahead_distance = svt_enc->la_depth; -- ++ param->encoder_bit_depth = desc->comp[0].depth; + - param->tile_columns = svt_enc->tile_columns; - param->tile_rows = svt_enc->tile_rows; -- ++ if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1) ++ param->encoder_color_format = EB_YUV420; ++ else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0) ++ param->encoder_color_format = EB_YUV422; ++ else if (!desc->log2_chroma_w && !desc->log2_chroma_h) ++ param->encoder_color_format = EB_YUV444; ++ else { ++ av_log(avctx, AV_LOG_ERROR , "Unsupported pixel format\n"); ++ return AVERROR(EINVAL); ++ } + ++ if ((param->encoder_color_format == EB_YUV422 || param->encoder_bit_depth > 10) ++ && param->profile != FF_PROFILE_AV1_PROFESSIONAL ) { ++ av_log(avctx, AV_LOG_WARNING, "Forcing Professional profile\n"); ++ param->profile = FF_PROFILE_AV1_PROFESSIONAL; ++ } else if (param->encoder_color_format == EB_YUV444 && param->profile != FF_PROFILE_AV1_HIGH) { ++ av_log(avctx, AV_LOG_WARNING, "Forcing High profile\n"); ++ param->profile = FF_PROFILE_AV1_HIGH; ++ } ++ ++ avctx->bit_rate = param->target_bit_rate; ++ return 0; } -@@ -472,21 +526,22 @@ static const AVOption options[] = { +@@ -472,21 +525,22 @@ static const AVOption options[] = { #define OFFSET(x) offsetof(SvtContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { @@ -255,7 +295,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be FF_AV1_PROFILE_OPTS -@@ -518,21 +573,20 @@ static const AVOption options[] = { +@@ -518,21 +572,20 @@ static const AVOption options[] = { { LEVEL("7.3", 73) }, #undef LEVEL @@ -288,7 +328,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be {NULL}, }; -@@ -544,9 +598,10 @@ static const AVCodecDefault eb_enc_defaults[] = { +@@ -544,9 +597,10 @@ static const AVCodecDefault eb_enc_defaults[] = { }; static const AVCodecDefault eb_enc_defaults[] = { @@ -301,7 +341,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/51c0b9e829be { "qmax", "63" }, { NULL }, }; -@@ -561,12 +616,11 @@ AVCodec ff_libsvtav1_encoder = { +@@ -561,12 +615,11 @@ AVCodec ff_libsvtav1_encoder = { .receive_packet = eb_receive_packet, .close = eb_enc_close, .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,