From nobody Wed May 18 15:34:16 2022 X-Original-To: dev-commits-ports-main@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 33DB41ADD4B8; Wed, 18 May 2022 15:34:17 +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 4L3H8n0jMnz4s4m; Wed, 18 May 2022 15:34:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652888057; 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=guJT/UiHpfxs9VhcvvCrzgVbzHnCAqG3BiQofcFkU54=; b=Paft2GzFoLrzjoqHA+dmGJjG3MSXXNNjPbqcHC5x3tnfPgIj7msbH9Lp3tr7e9ZGGKDkYb 1ECu8mg7ERIkNvnOIFk03orICmdxw7L6FPzLmb4DtIuFR965+Ip1QeYc7iHW03VXQWFrvj 8eZwti0kS/jFM719LKDuOayptdCbirgU0GEzKLcVjSjFBmx4Nz/bAO+qdZ+5L87UQJPo9x NjpI2JdBzZOjJqDi7jVngazF8ofi2ThwvS0R3dLP852oNZ68KYskhdTw5Rx0uCw4rJ/Id/ 1ThokU4x8qn7N299AUd6S8kQDYaGOwsiPKmTFpjoTY+maxR5NfxOuTD31mXbrw== 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 E4F383BCA; Wed, 18 May 2022 15:34:16 +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 24IFYGOn005234; Wed, 18 May 2022 15:34:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24IFYGo1005233; Wed, 18 May 2022 15:34:16 GMT (envelope-from git) Date: Wed, 18 May 2022 15:34:16 GMT Message-Id: <202205181534.24IFYGo1005233@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: 04363fa19ecf - main - multimedia/ffmpeg: backport more SVTAV1 fixes List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@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: 04363fa19ecf6ffc10e9bf58cfeed090bd7abdba Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652888057; 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=guJT/UiHpfxs9VhcvvCrzgVbzHnCAqG3BiQofcFkU54=; b=GEwD/W7RoDuMPnsaD6633Bup4858KNw/XWX+IL/EX1w6kUwNoTDhZ4CDoxu9uBJSEDfCi/ WY8eTP5qiX5ZWVDXuPgqAFKXgI68KrGdn0VLONHCKjeRXV+kMNGs7qnfIMI+jjRuM//vKl ESLNveM80MbNSRPRZJ1i7hAqumYAJ4dVKAc1BWpxzmFjslTrdT48Nw3hoZutLar4E2leLe f3lv73zxpdLHtL6zlKZUerHUvjUA0LnrCBBISUI4AwfZeOm40aoQtphETP3JG4IbLWI5UG Q4kdv5zJAawyTbQV3Z4LCRQEi6J6sOfpMlqFYYQ9kzxLnZHAm/fZQwtZ6+1w6A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652888057; a=rsa-sha256; cv=none; b=AJY9hZmYe9frM8fIHRCmyPiqHZbW/JMlk7at4dxN51Pdgn9I39TP4m9ttMojkE5JIn63SF gdy8DPDOuYWXd+6aPNPlmr/R5yOHODs53DQEoCvYFmdtz6igEFYSXuPddG90K0JAqAjqrH hiDfudd9NYRdiNTRHRraVeAsKno1T4WSeTKg7PQulleLUC6UP3ArpeXMA6pnehKvtIBHx1 EAYV9X7eD5ictOp0yhcwnZ7NTDXsGTZjnf4cFUOw/ZVRyxRTVlwaZKVflGm4BquSMJi/WI WWIlO3t2MU4PTcETDn3ByoF5vPC4jGs3Wlcz1xdj7xoe63xALFOUyRAykDYKIA== 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=04363fa19ecf6ffc10e9bf58cfeed090bd7abdba commit 04363fa19ecf6ffc10e9bf58cfeed090bd7abdba Author: Jan Beich AuthorDate: 2022-05-18 15:18:38 +0000 Commit: Jan Beich CommitDate: 2022-05-18 15:33:29 +0000 multimedia/ffmpeg: backport more SVTAV1 fixes Bump PORTREVISION twice to catch up with 2022Q2 branch. --- multimedia/ffmpeg/Makefile | 2 +- multimedia/ffmpeg/files/patch-svtav1 | 222 ++++++++++++++++++++++------------- 2 files changed, 139 insertions(+), 85 deletions(-) diff --git a/multimedia/ffmpeg/Makefile b/multimedia/ffmpeg/Makefile index 513635181915..250249f9ac1e 100644 --- a/multimedia/ffmpeg/Makefile +++ b/multimedia/ffmpeg/Makefile @@ -2,7 +2,7 @@ PORTNAME= ffmpeg PORTVERSION= 4.4.2 -PORTREVISION= 2 +PORTREVISION= 4 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 9ee7e8ff3271..8fc0711e3511 100644 --- a/multimedia/ffmpeg/files/patch-svtav1 +++ b/multimedia/ffmpeg/files/patch-svtav1 @@ -10,6 +10,10 @@ 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 +https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/6fd1533057ff +https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/ded0334d214f +https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/70887d44ffa3 +https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/fe100bc556d7 --- configure.orig 2021-10-24 20:47:11 UTC +++ configure @@ -103,14 +107,12 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a } SvtContext; static const struct { -@@ -151,49 +154,62 @@ static int config_enc_params(EbSvtAv1EncConfiguration +@@ -151,11 +154,126 @@ 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; @@ -118,22 +120,11 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a + 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; + @@ -146,10 +137,10 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a + + 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; @@ -170,41 +161,50 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a + else + param->color_range = !!(desc->flags & AV_PIX_FMT_FLAG_RGB); + - if (avctx->profile != FF_PROFILE_UNKNOWN) - param->profile = avctx->profile; - - 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; -- param->tier = svt_enc->tier; -- param->rate_control_mode = svt_enc->rc_mode; -- param->scene_change_detection = svt_enc->scd; -- param->qp = svt_enc->qp; -- -- param->target_bit_rate = avctx->bit_rate; -- - if (avctx->gop_size > 0) - param->intra_period_length = avctx->gop_size - 1; - -@@ -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) { -- param->max_qp_allowed = avctx->qmax; -- param->min_qp_allowed = avctx->qmin; ++#if SVT_AV1_CHECK_VERSION(1, 0, 0) ++ if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) { ++ const char *name = ++ av_chroma_location_name(avctx->chroma_sample_location); ++ ++ switch (avctx->chroma_sample_location) { ++ case AVCHROMA_LOC_LEFT: ++ param->chroma_sample_position = EB_CSP_VERTICAL; ++ break; ++ case AVCHROMA_LOC_TOPLEFT: ++ param->chroma_sample_position = EB_CSP_COLOCATED; ++ break; ++ default: ++ if (!name) ++ break; ++ ++ av_log(avctx, AV_LOG_WARNING, ++ "Specified chroma sample location %s is unsupported " ++ "on the AV1 bit stream level. Usage of a container that " ++ "allows passing this information - such as Matroska - " ++ "is recommended.\n", ++ name); ++ break; ++ } ++ } ++#endif ++ ++ if (avctx->profile != FF_PROFILE_UNKNOWN) ++ param->profile = avctx->profile; ++ ++ if (avctx->level != FF_LEVEL_UNKNOWN) ++ param->level = avctx->level; ++ ++ if (avctx->gop_size > 0) ++ param->intra_period_length = avctx->gop_size - 1; ++ ++ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { ++ param->frame_rate_numerator = avctx->framerate.num; ++ param->frame_rate_denominator = avctx->framerate.den; ++ } else { ++ param->frame_rate_numerator = avctx->time_base.den; ++ param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame; ++ } ++ + /* 2 = IDR, closed GOP, 1 = CRA, open GOP */ + param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1; + @@ -217,7 +217,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a + 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; @@ -227,43 +227,97 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a + return AVERROR(ENOSYS); + } +#endif ++ + param->source_width = avctx->width; + param->source_height = avctx->height; -- param->intra_refresh_type = 2; /* Real keyframes only */ -+ param->source_width = avctx->width; -+ param->source_height = avctx->height; +- desc = av_pix_fmt_desc_get(avctx->pix_fmt); + param->encoder_bit_depth = desc->comp[0].depth; + + if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1) +@@ -169,12 +287,6 @@ static int config_enc_params(EbSvtAv1EncConfiguration + return AVERROR(EINVAL); + } + +- if (avctx->profile != FF_PROFILE_UNKNOWN) +- param->profile = avctx->profile; +- +- 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"); +@@ -184,40 +296,21 @@ static int config_enc_params(EbSvtAv1EncConfiguration + param->profile = FF_PROFILE_AV1_HIGH; + } + +- // Update param from options +- param->hierarchical_levels = svt_enc->hierarchical_level; +- param->enc_mode = svt_enc->enc_mode; +- param->tier = svt_enc->tier; +- param->rate_control_mode = svt_enc->rc_mode; +- param->scene_change_detection = svt_enc->scd; +- param->qp = svt_enc->qp; ++ avctx->bit_rate = param->rate_control_mode > 0 ? ++ param->target_bit_rate : 0; ++ avctx->rc_max_rate = param->max_bit_rate; ++ avctx->rc_buffer_size = param->vbv_bufsize; +- param->target_bit_rate = avctx->bit_rate; ++ if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) { ++ AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx); ++ if (!cpb_props) ++ return AVERROR(ENOMEM); + +- if (avctx->gop_size > 0) +- param->intra_period_length = avctx->gop_size - 1; +- +- if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { +- param->frame_rate_numerator = avctx->framerate.num; +- param->frame_rate_denominator = avctx->framerate.den; +- } else { +- param->frame_rate_numerator = avctx->time_base.den; +- param->frame_rate_denominator = avctx->time_base.num * avctx->ticks_per_frame; ++ cpb_props->buffer_size = avctx->rc_buffer_size; ++ cpb_props->max_bitrate = avctx->rc_max_rate; ++ cpb_props->avg_bitrate = avctx->bit_rate; + } + +- if (param->rate_control_mode) { +- param->max_qp_allowed = avctx->qmax; +- param->min_qp_allowed = avctx->qmin; +- } +- +- param->intra_refresh_type = 2; /* Real keyframes only */ +- - 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); -+ } +- + return 0; + } -+ 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; +@@ -350,6 +443,16 @@ static int eb_send_frame(AVCodecContext *avctx, const + headerPtr->p_app_private = NULL; + headerPtr->pts = frame->pts; + ++ switch (frame->pict_type) { ++ case AV_PICTURE_TYPE_I: ++ headerPtr->pic_type = EB_AV1_KEY_PICTURE; ++ break; ++ default: ++ // Actually means auto, or default. ++ headerPtr->pic_type = EB_AV1_INVALID_PICTURE; ++ break; + } + -+ avctx->bit_rate = param->target_bit_rate; -+ - return 0; - } + svt_av1_enc_send_picture(svt_enc->svt_handle, headerPtr); -@@ -472,21 +525,22 @@ static const AVOption options[] = { + return 0; +@@ -472,21 +575,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[] = { @@ -295,7 +349,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a FF_AV1_PROFILE_OPTS -@@ -518,21 +572,20 @@ static const AVOption options[] = { +@@ -518,21 +622,20 @@ static const AVOption options[] = { { LEVEL("7.3", 73) }, #undef LEVEL @@ -328,7 +382,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a {NULL}, }; -@@ -544,9 +597,10 @@ static const AVCodecDefault eb_enc_defaults[] = { +@@ -544,9 +647,10 @@ static const AVCodecDefault eb_enc_defaults[] = { }; static const AVCodecDefault eb_enc_defaults[] = { @@ -341,7 +395,7 @@ https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/e3c4442b249a { "qmax", "63" }, { NULL }, }; -@@ -561,12 +615,11 @@ AVCodec ff_libsvtav1_encoder = { +@@ -561,12 +665,11 @@ AVCodec ff_libsvtav1_encoder = { .receive_packet = eb_receive_packet, .close = eb_enc_close, .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS,