From patchwork Wed Jan 12 23:17:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Fabian 'Xaymar' Dirks X-Patchwork-Id: 33285 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5065091iog; Wed, 12 Jan 2022 15:18:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwcFSy5UpbbxYyHrNZyzihR/8TqRJoh2e9AROuQjT3xXip2n7cZ4HlFR6zcMnHCHhKwxnU X-Received: by 2002:aa7:c1c1:: with SMTP id d1mr1718721edp.416.1642029487245; Wed, 12 Jan 2022 15:18:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642029487; cv=none; d=google.com; s=arc-20160816; b=EIEE8Z5/kPSWxDA6pdgvAd3wTtfC+I/8Bw1Z7ZiqQzg5xz1mMXblAMOWkjxizfUxEm +L3n3/YpLAQ1eOTBV4jk8hAP8YIPItDKBCC6dHGKQxqcxDaPEhDgglVYXR6is7kjxBMJ AOhA9kznEMfC+uCVlZtEAyKGfuD5xTbnv5EVSxUqu5FQeUb+IYmrpmxaj7eSIfgHidX1 O3y3GasKkg5Aljm4VTjhanacXspqbhuGzvrePdhWomeCUh39XYWRC/TnPMxvpHw8j3fk m6oo3uwez5cKWFw/NiK9MN5xGS1/uja/Pxpds/K2TIiOa5r4kaFRBT15CF+S7h8MJ61v QShw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=98m8tv7fu4iHM/NP1dE3XuiWL/+qPlEiXwCsIFRfMFA=; b=ROgK7AIS+UqEozcK9i9QmGNmmzj/gMGu7FKbAAtWDnfCr5v53XlvH69bXV23p1IcWZ dftirU+vnZKzsUTdL5GI27KhQisLkAJe1T/nJu5BwByQblrF189OeHsVa8NwxIMdqEbQ 1QIxKcXcAx1jJHOw/En+0OYxlOqs2K2M2TyMgCEutBR4YK+YA5LhH50B4YjQRQFANJuS dcFZKW9wxaE2Cm18iv8ri2NGDSs6DFypR9ulnpuyjJ66i7hwmQ7KKjT0BaDkQnbB3BmQ AK1wb669PyFiqskxr6hfTkZiPPZqVamXWI0Xss8ckTAfAzZiPXFAywNrYUdYg8mJbwfh LKkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=DothbqSt; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m3si652967edp.10.2022.01.12.15.18.06; Wed, 12 Jan 2022 15:18:07 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=DothbqSt; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 14ECB68AE87; Thu, 13 Jan 2022 01:17:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.xaymar.com (xaymar.com [95.217.118.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0DB9C68AD96 for ; Thu, 13 Jan 2022 01:17:51 +0200 (EET) Received: from localhost.localdomain (unknown [IPv6:2a02:8106:c:6a00:ccbc:cf2c:5bb9:d3cf]) by mail.xaymar.com (Postfix) with ESMTPSA id 15FDE6132E; Thu, 13 Jan 2022 00:17:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xaymar.com; s=2021; t=1642029470; bh=+8BewyxLhZubik3LUzfPUtTES8Eal7WYVHgJA2tfjiM=; h=From:To:Cc:Subject:Date:From; b=DothbqSt8Pz4UO6I2+E8gXYT/bKGCXx4jyq6Lfy/DS2iWRf2w5gfJLWVOyb+SkKT0 rvbjGjYD/BwPJcuSL6i+pUP0UJoSoXO9758QL72uhr91/+r3DGUi2dWnvuUxAM+zht rmJz8zId5DYkrHLPatM0yM8it0bLx5HSEvXNqkD+Lcn6QXclGoMtdHfbMMVeBpBVTj FP6dd2X93rRmNcbtEQMUoLBWN23b4s3HTnAsWvnwFA2LnABk0CWRIpo6na7o35EzNx 7MLgnuXGo54+TpjvYMLlM5P5ZcCnbnUBs5M0Vy4MeTLe/NWu6OEyUxuTz0H2QxkFjq kWZG3XP0N+JPMyCl5bf57FjdPpzXG3nWEjgEznAQVA6sJA2I5PPXBZXNTDN3B5EXxI XUVD5g+MF3W8AHelVxMefXwEtivM/FMvvqOVzN82Fp4Jvqpwuf8WKWHUZr7l4eJgSE S78HIa2rQrtGaRDJXT1CsnslT6zcJlNfw3IhYPB5Ke5RMbhDom7jrT0AtO5Uwgf4os nDp8rhQRC1tP2fVmxEvLJDXP+vEIgTZMqO+rcZ5ofhi5tbj6axBYLsde6jwLs6K5BH 3+2VHeXVQ+2+EuVsLQSd6uLdP+Bqq5GNYhGxJxa+S8g1apG2l1gVdv02jSjUPWbYQo FopYojpsHrV1qpTOR/64= From: Michael Fabian 'Xaymar' Dirks To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jan 2022 00:17:20 +0100 Message-Id: X-Mailer: git-send-email 2.34.1.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avcodec: Require AMF SDK v1.4.23 or newer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Fabian 'Xaymar' Dirks Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: JuWmB+hioOMf From: Michael Fabian 'Xaymar' Dirks Increasing the minimum AMF SDK version allows us to support more recent hardware and drivers, which is necessary to fix some of the discrepancies between older and newer drivers on AMD hardware with FFmpeg. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 1413122d87..515ec1a50f 100755 --- a/configure +++ b/configure @@ -6969,7 +6969,7 @@ fi enabled amf && check_cpp_condition amf "AMF/core/Version.h" \ - "(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x0001000400090000" + "AMF_FULL_VERSION >= AMF_MAKE_FULL_VERSION(1, 4, 23, 0)" # Funny iconv installations are not unusual, so check it after all flags have been set if enabled libc_iconv; then From patchwork Wed Jan 12 23:17:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Fabian 'Xaymar' Dirks X-Patchwork-Id: 33286 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5065186iog; Wed, 12 Jan 2022 15:18:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4gFCx5Wtvm/6n26YirTqYJ7hDURumUtPLIJpmttsieLHzuj9oKmUB9SpFN4SOqtWxtugw X-Received: by 2002:a05:6402:3554:: with SMTP id f20mr1681668edd.343.1642029496356; Wed, 12 Jan 2022 15:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642029496; cv=none; d=google.com; s=arc-20160816; b=B/7B2/95nogxTvLX9xiek4tVaLY1GfgxYsPvGFydgsjcP+ya29i9H3229cy+2TBaee 5AboDAL9NL9boXKtUW3eb+aKrfBhh0cOclRnVFCLUEbSHPuDLEUamsyy4efozijG8s29 8/53WPFiv+KjpnFeliixd3UUZbTrs1cSOGgGUaYIOKz9N6udyU313IpSkBHZ51TWTi1L qCd+aiHAHXzJwq7gvDtTvyl8k0ZmbFHxHUCVCH5MqAY+Q9bnsADx+f0kiHnIoD6BPkNI wCq6RlqfxL9SR8FmuJrAlqhjPihRqPIP/rv5u2djFAGEVcyXYtzqcfeV3qERhsrTnRa0 ywDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=3KMYfKGbDYpRblfCXKdassNOE1bmgCk0xRwqoD6/p04=; b=aafA5a2zMwJdIyBACnFoACoWQiYrP+JDnappOdwyCDj3yJ41Lu1uTreE8HiJvTwt1c Yc125YE8szaF+U6ykV8Pr9um5svDAxFECMFx/bYzzQ9L9rQpxRmZpotPYyYUznZO4GCu luPls6BaFo2ZlUCira1Mv1ufKKnoXMjK2SJeyZ/8ZYveezpthwcQleT2mqiiP1i9Wz4Q M+7mPqYrqN2P1GEKWPvYeEX3Giu92Fq0muFlR8STkOhnEunY2pCJqFKbfy+imW/oAAq4 Voluve/U00wOhfqzGD8kTlo1wStYrnVA+GUbW29Vgw1Il+2SEw/FE8HRepMU4gsQO873 NA7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=AFUuzUe+; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a15si638294edn.5.2022.01.12.15.18.16; Wed, 12 Jan 2022 15:18:16 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=AFUuzUe+; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0CD8968AEC1; Thu, 13 Jan 2022 01:17:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.xaymar.com (xaymar.com [95.217.118.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 45ACD68AD96 for ; Thu, 13 Jan 2022 01:17:51 +0200 (EET) Received: from localhost.localdomain (unknown [IPv6:2a02:8106:c:6a00:ccbc:cf2c:5bb9:d3cf]) by mail.xaymar.com (Postfix) with ESMTPSA id 660BC61332; Thu, 13 Jan 2022 00:17:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xaymar.com; s=2021; t=1642029470; bh=QGEEnvQRRKpGEJ0aw6Siu1qWwGxn6mlQZ0K5wokFI6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AFUuzUe+bwrVMjzWWS6lJZ7Xfvuqh2OSS0kGc8zFX8vz3qer0O0YIHy+l338KWjzK smMJuWTtbleypc0lLMF67e54zesFl9d5+9Htj5zFeDAHenns7UTUQwmHtICkzczuEU SaubaOV3DkL1ElGpvtrUvdTUZKaxP6DQK0Gtf4QrNgLH9spQS5ClaoiEy44fEfk8eo TVhHW6Aetga7ZDD9+2XQMX9kIZB/igb2vJeaoj5+tWRSXs9fj5lLshomw/eom5puAH e+ye/+wvvyGedW31D2wN5LdIJ5Bu2/M4XpdNBGfqmswiu40EAt0Q6dB9H321JHQk++ aZTtuAZ62diOVrbJ7oBKNqYKaZ4w5UXrhwhKSntDu1yQFKZbqqF1NK4QVyIiyG52OI kUiufDJbYGp/SwUNEYtVkRrobqYeueyREUa8Kq3zZ14cX8V8pSKOOVVBzYgEJn8vm0 sYvlsWEAt3oORQyUz8s7EkXv0QY6lEEjzvBHUCmPV0jvoINogmYGFUXh0Ay1v1HFbe vvRWAmM9MsBlxHxf6rtJxGvRwvqzINwKasvbJ+wRf2EVW/BM/K1YI7PuedzS3azIHL Hn1MTXbIfFiT1heSdyn7YejSn/FBq7S0QuVbjwKrJQc8H/OMMWHeg4t+4VlbEuNzsK 5AdwwPH30IyLjQez14tQ= From: Michael Fabian 'Xaymar' Dirks To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jan 2022 00:17:21 +0100 Message-Id: X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/amfenc: Set all color metadata for AMF X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Fabian 'Xaymar' Dirks Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RTAPKYDRRAW0 From: Michael Fabian 'Xaymar' Dirks Fixes the color information in the output from the AMD encoder being wrong, which led to weird transcoding results. This problem appeared out of thin air, and I've been unable to tie it to a specific driver that supports my hardware. Unfortunately this requires AMF SDK version 1.4.23 or later, but it should still work fine on older drivers. Theoretical support for HDR encoding is also now possible, although the implementation is not complete. I have no clear idea on how to generate AMFs HDR metadata structure, or where to even take this information from. --- libavcodec/amfenc.h | 1 + libavcodec/amfenc_h264.c | 48 +++++++++++++++++++++++++++++++++++++- libavcodec/amfenc_hevc.c | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h index 358b2ef778..951e529362 100644 --- a/libavcodec/amfenc.h +++ b/libavcodec/amfenc.h @@ -21,6 +21,7 @@ #include +#include #include #include diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index aeca99f7c6..009378e9f1 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -137,6 +137,8 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx) AMFRate framerate; AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0; + amf_int64 color_depth; + amf_int64 color_profile; if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den); @@ -194,10 +196,54 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx) AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_ASPECT_RATIO, ratio); } - /// Color Range (Partial/TV/MPEG or Full/PC/JPEG) + // Color Metadata + /// Color Range (Support for older Drivers) if (avctx->color_range == AVCOL_RANGE_JPEG) { AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 1); + } else { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FULL_RANGE_COLOR, 0); + } + /// Color Space & Depth + color_depth = AMF_COLOR_BIT_DEPTH_8; + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; + switch (avctx->colorspace) { + case AVCOL_SPC_SMPTE170M: + if (avctx->color_range == AVCOL_RANGE_JPEG) { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; + } else { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; + } + break; + case AVCOL_SPC_BT709: + if (avctx->color_range == AVCOL_RANGE_JPEG) { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; + } else { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; + } + break; + case AVCOL_SPC_BT2020_NCL: + case AVCOL_SPC_BT2020_CL: + // !FIXME: Verify that this is correct on Hardware supporting it. + // !FIXME: Figure out how to decide on bit depth. + if (avctx->color_range == AVCOL_RANGE_JPEG) { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020; + color_depth = AMF_COLOR_BIT_DEPTH_10; + } else { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; + color_depth = AMF_COLOR_BIT_DEPTH_10; + } + break; } + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_COLOR_BIT_DEPTH, color_depth); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_COLOR_PROFILE, color_profile); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_COLOR_PROFILE, color_profile); + /// Color Transfer Characteristics (AMF matches ISO/IEC) + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); + /// Color Primaries (AMF matches ISO/IEC) + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); + /// !TODO: AMF HDR Metadata generation // autodetect rate control method if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_UNKNOWN) { diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 79541b9b2f..900e1482b4 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -104,6 +104,8 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx) AMFRate framerate; AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); int deblocking_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0; + amf_int64 color_depth; + amf_int64 color_profile; if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { framerate = AMFConstructRate(avctx->framerate.num, avctx->framerate.den); @@ -152,6 +154,54 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx) AMFRatio ratio = AMFConstructRatio(avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den); AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ASPECT_RATIO, ratio); } + + // Color Metadata + /// Color Range (Support for older Drivers) + if (avctx->color_range == AVCOL_RANGE_JPEG) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE, 1); + } else { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NOMINAL_RANGE, 0); + } + /// Color Space & Depth + color_depth = AMF_COLOR_BIT_DEPTH_8; + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; + switch (avctx->colorspace) { + case AVCOL_SPC_SMPTE170M: + if (avctx->color_range == AVCOL_RANGE_JPEG) { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; + } else { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; + } + break; + case AVCOL_SPC_BT709: + if (avctx->color_range == AVCOL_RANGE_JPEG) { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; + } else { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; + } + break; + case AVCOL_SPC_BT2020_NCL: + case AVCOL_SPC_BT2020_CL: + // !FIXME: Verify that this is correct on Hardware supporting it. + // !FIXME: Figure out how to decide on bit depth. + if (avctx->color_range == AVCOL_RANGE_JPEG) { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_2020; + color_depth = AMF_COLOR_BIT_DEPTH_10; + } else { + color_profile = AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; + color_depth = AMF_COLOR_BIT_DEPTH_10; + } + break; + } + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_COLOR_BIT_DEPTH, color_depth); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_COLOR_PROFILE, color_profile); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_OUTPUT_COLOR_PROFILE, color_profile); + /// Color Transfer Characteristics (AMF matches ISO/IEC) + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); + /// Color Primaries (AMF matches ISO/IEC) + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_OUTPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); // Picture control properties AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_NUM_GOPS_PER_IDR, ctx->gops_per_idr); From patchwork Wed Jan 12 23:17:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Fabian 'Xaymar' Dirks X-Patchwork-Id: 33287 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5065284iog; Wed, 12 Jan 2022 15:18:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwX7cYDxSxK0mcopYglEz0aIxNFhyDiStQeqPcK6alY+kqizhXYmu23FB7bCer8peIWkhaw X-Received: by 2002:aa7:cada:: with SMTP id l26mr1785086edt.376.1642029505830; Wed, 12 Jan 2022 15:18:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642029505; cv=none; d=google.com; s=arc-20160816; b=HkBzYkOhbrMur8+9JoOWvxLXQKUxPRdf0Hcu5TMWMe1y74tc6rSPRvwfLaJWouUUc+ NryTkwBsF2tab3dzj9mXhFwN/+unKVPyQiTkUK5zexTw9DzwzRXJ222AEU97VrFW8K5R ymAJ/VLiryMhLxvq/B3MFwD267nb1pQdVS4A+T6em9YTfBifOJRKotb+kOJe5T5HQ0C/ MLnbkWmOGtF4tjR45763H1XPMZyOC2wOpmHsrOnPTuWxJ6v2pPqqht08lDgvjmeXQR0I oijYnEN8eQ4lPhtkN3F3Rzl/DcW1pETjHM3p0tO7x2Yg5T6+BsmriwhgVQcS0SIPRXU3 UHbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=yW2zcScpUMa9UFPVAQ6Fvb8bN6zgx9BzGD7xwJv4Icc=; b=ZSldFa8/ndFm7xSThnRQM50yOApy2Y7hsf4IU6ZuwlIP147YwZbiJio/B0glRw3JNW q2Z5XYoKerp8guHv/IUtFwvTStqZ8h3k8QSFTp//mMmlnqH4Otl2UmhrOncZuZV4wU/Q UMhI/q86Bz1XnYql/giMDjdtN9jTFV6U75G8NwvyM9a3kyAANH75f+KYQqD4+63S8GSQ ncLLp0oAQWRhtwQ9QXYMGIzu9L1uHo76X9LwLe1uLT3kQTJWi3PPMDq6hqIogB2rYXkh 0p9iAHNZAH+QPIGePzt08qFFvrwq8emLjBT88e3r3UG4dQJaTPT8CmVPTTSKPKzgNxFz mZNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=DXxtVCCy; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cr12si637660ejc.707.2022.01.12.15.18.25; Wed, 12 Jan 2022 15:18:25 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=DXxtVCCy; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D864368A636; Thu, 13 Jan 2022 01:17:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.xaymar.com (xaymar.com [95.217.118.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 737BC68AD96 for ; Thu, 13 Jan 2022 01:17:51 +0200 (EET) Received: from localhost.localdomain (unknown [IPv6:2a02:8106:c:6a00:ccbc:cf2c:5bb9:d3cf]) by mail.xaymar.com (Postfix) with ESMTPSA id B5B496133A; Thu, 13 Jan 2022 00:17:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xaymar.com; s=2021; t=1642029470; bh=ejOV3RaNmTija3F0Yt/miPpdXJ0+3uPvo1W5xU8iqSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXxtVCCyuS3xygn2Xiw9P8GV10bCqVI7eiVUyjmpeCmonrglxIcJS5TEUBY4Y0mct vpM6i0xuEQJOENmLzdGlhTnHjITcqR5UVBNYj6XhEhpgqgWu83V4Hal1CVNrTVzmjf V2j4sAWxxkr2EAns7+N/BxSOJ05YGl0YIuSk5apajzxj9btACFOwHMnTrq1WJsx6Sr apT/vCBADYpPg39+XpxDUQFWeNZe42d1ylSgSeca/pdjm0XYPWCgdhB7qVHjIM4Yj9 T2/TfxbU+flW6U2nlZEEKMkhNQtaE8x5vEdDcPtmm0YcmrwemdDYxuIQT87ozxD1MO 5xWMd6B9KuawWGhh0kwHFlg8LzyTD28XgdzUz4CcM3Zsy4SqyiD+rm8c736+KlGbOs iBpCkTrm4pgFg8Qb91+Sf5UhNU8h5Sn6urqMdPxXPfFXnPCyVY7MHGclxzM4PPUEXo cGKOKo1g8w8CmV3YWhX13X6TFFFqKHbWK0DhgovSWtxcNTlcOp2l10EWQzfkEJaEnL 1L6ioJPJiylLFSAYQb+UbQKSp0tyIs4WUIIR6X5nlu0iJnPdMMVdRpdOA1JJBz9jjd MFO398+TgBG4x2VVwd+i3OS8XG9TmnPJW/FKJZf4XG0APcISLrFY6CIcnQLPxlIS0L uNG0BnPijRwJu01TiV/A= From: Michael Fabian 'Xaymar' Dirks To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jan 2022 00:17:22 +0100 Message-Id: X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/amfenc: Add the new usage presets X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Fabian 'Xaymar' Dirks Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DkdNRTwFzKBi From: Michael Fabian 'Xaymar' Dirks These enable some new features that otherwise require another AMF component to be loaded. Requires AMF SDK 1.4.23 or newer. --- libavcodec/amfenc_h264.c | 12 +++++++----- libavcodec/amfenc_hevc.c | 6 ++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index 009378e9f1..afac97a968 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -28,11 +28,13 @@ static const AVOption options[] = { // Static /// Usage - { "usage", "Encoder Usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_USAGE_TRANSCONDING }, AMF_VIDEO_ENCODER_USAGE_TRANSCONDING, AMF_VIDEO_ENCODER_USAGE_WEBCAM, VE, "usage" }, - { "transcoding", "Generic Transcoding", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_TRANSCONDING }, 0, 0, VE, "usage" }, - { "ultralowlatency","", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY }, 0, 0, VE, "usage" }, - { "lowlatency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY }, 0, 0, VE, "usage" }, - { "webcam", "Webcam", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_WEBCAM }, 0, 0, VE, "usage" }, + { "usage", "Encoder Usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_USAGE_TRANSCODING }, AMF_VIDEO_ENCODER_USAGE_TRANSCODING, AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY_HIGH_QUALITY, VE, "usage" }, + { "transcoding", "Generic Transcoding", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_TRANSCODING }, 0, 0, VE, "usage" }, + { "ultralowlatency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY }, 0, 0, VE, "usage" }, + { "lowlatency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY }, 0, 0, VE, "usage" }, + { "webcam", "Webcam", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_WEBCAM }, 0, 0, VE, "usage" }, + { "highquality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_HIGH_QUALITY }, 0, 0, VE, "usage" }, + { "lowlatency_highqquality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY_HIGH_QUALITY }, 0, 0, VE, "usage" }, /// Profile, { "profile", "Profile", OFFSET(profile),AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, AMF_VIDEO_ENCODER_PROFILE_BASELINE, AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_HIGH, VE, "profile" }, diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 900e1482b4..b7fee950f6 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -24,11 +24,13 @@ #define OFFSET(x) offsetof(AmfContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "usage", "Set the encoding usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING }, AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING, AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM, VE, "usage" }, - { "transcoding", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCONDING }, 0, 0, VE, "usage" }, + { "usage", "Set the encoding usage", OFFSET(usage), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING }, AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING, AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY, VE, "usage" }, + { "transcoding", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING }, 0, 0, VE, "usage" }, { "ultralowlatency","", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY }, 0, 0, VE, "usage" }, { "lowlatency", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY }, 0, 0, VE, "usage" }, { "webcam", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM }, 0, 0, VE, "usage" }, + { "highquality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_HIGH_QUALITY }, 0, 0, VE, "usage" }, + { "lowlatency_highqquality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY }, 0, 0, VE, "usage" }, { "profile", "Set the profile (default main)", OFFSET(profile), AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, VE, "profile" }, { "main", "", 0, AV_OPT_TYPE_CONST,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, 0, 0, VE, "profile" }, From patchwork Wed Jan 12 23:17:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Fabian 'Xaymar' Dirks X-Patchwork-Id: 33288 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5065381iog; Wed, 12 Jan 2022 15:18:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmVMyUh1fN2EGX/PxXZ2jzieftHh3S+bgtYoNyOS3LZzb12osqJW9RrpBwF1o/vMFKM9E+ X-Received: by 2002:a17:906:7945:: with SMTP id l5mr1540423ejo.82.1642029515255; Wed, 12 Jan 2022 15:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642029515; cv=none; d=google.com; s=arc-20160816; b=wh3oG4xQhCYBLi4DsGiFjRbAk9ad+GJWa0bO+ct580+UO3gSfE8OfC2MsL09Rkch+Z LWiQqpDyvFelrr1qv8KTZQ9xqpp5hxPCPKIxGtHeM2ly6PRrE7udYKaKuwm3ovGqYJvk e2WXA823CWXmJMMMsXhizkGIUocPQqJjNuUk47ypB0UgI4EKpc2Ox8BZ9L2Js7WTtsG2 7ZtZEpPLhXsGCnNhFkOkWZke/T6RoJhp+/T4TFzkakLyPAJomrNJKd0n1fNuW6EikTgK k7qrmrG7o02HwbyipYMS5QMymk2AQU4Lh3R1zqjF9SmQUxwfLmT3V9UITxNWzo1z0g3A WO7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=DqaS+PIgkjvb7YOQA5B2nmZrR70ME/00nWc7BCAXQ6k=; b=j+O1K5qqBTrHfIO+2EkQbMFwueLyfYv1iHfAYRNdKmBU510h015E5HA/cQENishnCo 9MgSt5sXc5Grjf9hmxa5rISrFcI+Zd0iSj+Pp/9uSoEtGyNwFw7Gr/mnNwxrEqzPHByQ rsWLP/al5t7sZUO7IP9f8ux4q9Z0knquYLCO0TQ+HzGlqm/ju/HKYfGmVvJrdNQGdhF2 ObzBDXTdU6VUJzPB5jvLeqyEDL/7yxtPjzPVihcLDxoLITppEzpQ1+pyVV5KHmuQXzOa huulySiQKlt40k/xWHdZTc1z//i/xZqRf2ina2rWYc3Bl/oObWlDkS2B+pd5vtgP3Ake JITw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=DrOq9PFK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hd35si510516ejc.678.2022.01.12.15.18.34; Wed, 12 Jan 2022 15:18:35 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=DrOq9PFK; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C076F68AEE4; Thu, 13 Jan 2022 01:18:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.xaymar.com (xaymar.com [95.217.118.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFF4768AD96 for ; Thu, 13 Jan 2022 01:17:51 +0200 (EET) Received: from localhost.localdomain (unknown [IPv6:2a02:8106:c:6a00:ccbc:cf2c:5bb9:d3cf]) by mail.xaymar.com (Postfix) with ESMTPSA id 101556133D; Thu, 13 Jan 2022 00:17:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xaymar.com; s=2021; t=1642029471; bh=i9Bt8IO17xYrrcbKVVwfin6Qs0C56MpA2vEyhxl2HCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DrOq9PFKiXQV/l5N95VI03zRqSZYLElbkKYwK3fWIRhslCTdzKP6kqbKxIQUXu++r We/7HDWVxzmVPX1y2ir1OVwXDDIo7VAXL00HmNwZ2qW9Dx+Zyye2YYSHf0Jb+Dvb5O O28uxZlQ/U7F3B+3GE3YY05O+BU2pqxY65aezy7PnhMdQNauDv9Q602PGPYlhl2jFs uG0jPkkPAtVEf5v/lCQXc++CAUOyC6VYuOcgVMmDcA6myt8lwOZCcHsWmfE0dNTTeg N6ypH/jPkYDP3MUA8wAZ13eZWC8+gn+Psni02HHo+bzTpQPibqVpjvHUiMFkWxaAE4 NKwFpBaqMdKRRsrmLrhaEBQPkrgp7bmrFJm60XRFswgepY5BCFfuvNeEe/nfnc7ZUc VsLNyHhnIpK/SnpbbHZo2ZtKN6ntJ6xC8Msrwi3RYA9jRGGnNbV+JtWC+70ZmswoQK Pml1OKoKISUL2LAegpmyIE2l/Z+zOC4iheg8aQN1rAcVyzwJsYYiEt28t2D+fnWmmN h+H+WVcW9S1yT7tit2CpkGgOuh8p6qrmYLQ2vcHahUaOJY9tZst5iHlkECx3KWshhL YPouAyPGE/kf1V9yZ73oUlcqI3AQ6+6laeBbwSa1MjOvv5tP52EZil0e96D4sxr0SZ QHZ4r5vGfOAxjjw5/THI= From: Michael Fabian 'Xaymar' Dirks To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jan 2022 00:17:23 +0100 Message-Id: <9cbaf2a700356682713bd01b2a6df3bc8d85c228.1642029358.git.info@xaymar.com> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/amfenc: Add "High Motion Quality Boost" option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Fabian 'Xaymar' Dirks Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mWXzHDQwP5k+ From: Michael Fabian 'Xaymar' Dirks This option was missing from amfenc, and is now available. --- libavcodec/amfenc.h | 3 +++ libavcodec/amfenc_h264.c | 2 ++ libavcodec/amfenc_hevc.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h index 951e529362..f47e6a1200 100644 --- a/libavcodec/amfenc.h +++ b/libavcodec/amfenc.h @@ -108,6 +108,9 @@ typedef struct AmfContext { int me_quarter_pel; int aud; + // Unclear options, have different behavior based on codec. + int hmqb; + // HEVC - specific options int gops_per_idr; diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index afac97a968..87a3bb6a73 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -86,6 +86,7 @@ static const AVOption options[] = { { "filler_data", "Filler Data Enable", OFFSET(filler_data), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "vbaq", "Enable VBAQ", OFFSET(enable_vbaq), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "frame_skipping", "Rate Control Based Frame Skip", OFFSET(skip_frame), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "hmqb", "High Motion Quality Boost", OFFSET(hmqb), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, /// QP Values { "qp_i", "Quantization Parameter for I-Frame", OFFSET(qp_i), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE }, @@ -331,6 +332,7 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx) AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_ENFORCE_HRD, !!ctx->enforce_hrd); AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FILLER_DATA_ENABLE, !!ctx->filler_data); AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_RATE_CONTROL_SKIP_FRAME_ENABLE, !!ctx->skip_frame); + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HIGH_MOTION_QUALITY_BOOST_ENABLE, !!ctx->hmqb); if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP) { AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_ENABLE_VBAQ, 0); if (ctx->enable_vbaq) diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index b7fee950f6..565be9bad9 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -74,6 +74,7 @@ static const AVOption options[] = { { "gops_per_idr", "GOPs per IDR 0-no IDR will be inserted", OFFSET(gops_per_idr), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX, VE }, { "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, { "vbaq", "Enable VBAQ", OFFSET(enable_vbaq), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, + { "hmqb", "High Motion Quality Boost", OFFSET(hmqb), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, { "enforce_hrd", "Enforce HRD", OFFSET(enforce_hrd), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, { "filler_data", "Filler Data Enable", OFFSET(filler_data), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE}, { "max_au_size", "Maximum Access Unit Size for rate control (in bits)", OFFSET(max_au_size), AV_OPT_TYPE_INT,{ .i64 = 0 }, 0, INT_MAX, VE}, @@ -231,7 +232,6 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx) } } - AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD, ctx->rate_control_mode); if (avctx->rc_buffer_size) { AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_VBV_BUFFER_SIZE, avctx->rc_buffer_size); @@ -253,6 +253,7 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx) } else { AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENABLE_VBAQ, !!ctx->enable_vbaq); } + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_HIGH_MOTION_QUALITY_BOOST_ENABLE, !!ctx->hmqb); AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MOTION_HALF_PIXEL, ctx->me_half_pel); AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_MOTION_QUARTERPIXEL, ctx->me_quarter_pel); From patchwork Wed Jan 12 23:17:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Fabian 'Xaymar' Dirks X-Patchwork-Id: 33289 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5065457iog; Wed, 12 Jan 2022 15:18:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJx72wju+Z1uQJ3DLQbvY1iRsnata6Aw8smvaN5SPKKYGVBubPKLfvCTenIEgUjMYzXrSq7z X-Received: by 2002:a17:907:e93:: with SMTP id ho19mr1491650ejc.169.1642029525077; Wed, 12 Jan 2022 15:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642029525; cv=none; d=google.com; s=arc-20160816; b=NqFqQp3Jy3Y21DQBkarFcp5u4T2ACH9/46ZgT1j1CTIjyIr1FcE/IcJw7UDG0467gN 0WUBlgmTaLFyC3scfgqc7J7720qn3eB2AKQ7kod+l74zs5jwGqIYKTsAYEn6osoMriIx DNCk3p5MH7NdN3Jkao9fvVbrIQ0GXLuPOQiQ4XYUPN3RbWbw93zMSoZJiDeQZeU51SN8 JCGVBIi/MpI8jfDY4TPbHB8lNbkpCmKXBv7FJzSNtgqnXRhHvFHikRNSswvfTU+/sGTN K7mlwqrguGqGQ2uU3z7i3EXS+c32gPOADWmip/yndeWbLev1Dr1v2+82QQ+8S97YjrTO CBKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=3FfP6EPjihpGdk6fVlDph9xQUCCJJIaIw+0y7aZLaFE=; b=0ixvbBkvgWbEqWos4yCV0GHoA9Q4pMDBFzivFMVOwc61n1CXKtVr2DeOAsaq//BCfq lo7oRANGNP8uSsP/i7m/fBFkunzDUuKyX7Pe4xKViNxKF+trjtSl2mbwUlEPC7b+k/q7 I2BTjexonH/5HxiF69ZpIH4efxdbT3hc2j3Z+D/cPxn+0hL2srQ2wLQlmurpe6mQYo+b Bd4hODgPMBE4dcI/di9Wfe8MtECgg1a/Yb9/A/vwhfA02AvwsgKSPK0hYmzUT7/iLJnH G+bAQ3+2LjW2cDvU2U6xoHOn+1v/KXn2nEoMcWe8cf9OIc5o2oZ5qMcL7qJkUAHaYhpc EC4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=Cjv5bLah; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z30si670844edi.581.2022.01.12.15.18.44; Wed, 12 Jan 2022 15:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@xaymar.com header.s=2021 header.b=Cjv5bLah; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=xaymar.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 99F1E68AEF0; Thu, 13 Jan 2022 01:18:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.xaymar.com (xaymar.com [95.217.118.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D12668AE46 for ; Thu, 13 Jan 2022 01:17:52 +0200 (EET) Received: from localhost.localdomain (unknown [IPv6:2a02:8106:c:6a00:ccbc:cf2c:5bb9:d3cf]) by mail.xaymar.com (Postfix) with ESMTPSA id 5FB436133E; Thu, 13 Jan 2022 00:17:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xaymar.com; s=2021; t=1642029471; bh=+tTu36pm9h+PPFEiIHwdXKefHAGF5N8FwSsIfDCJtcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cjv5bLahcRce2a8kAn4sGqZYsiAzani9uBGsXlBF1I6mpiprREBaG89RTbkvIgEDV W69jBKLcV0M5quLAsg1IqxpyV4kdqmmmtMwvGzuUysuW3IXTyLE3Ds+x6zTQJNM/+q ChOM1lefXAsixTWCZgHaKRL3l/v/6NzKMl/NeWe4RwPLt1QJgrhGZwJhbNbMyXiZZx PALaBTD5NZny1u94W/6lURF9Wy8gvzDq45NUgcc2I/OLi7h5HF2roL50oMDS7Abt5A Ko5E9pnS3V9toGo4nMW4qX9SfHs+/IA/4yk/HfnGjd6lZbRyeJcwKmIK5Cq3S4Tr7D qc2tvCRuNSq0s+wtTkBu6tX41eH44maTX0rQSKnmTyZQiBnqARNYQUGaZtPs19YLbU leLw/wC/5xVHipI6mzQ8vHSIfvM0SRMui27rN3TzGkpuxq2R8ueaGpZbL9t8UoimSr 2C1EawPBSnPrtdXbRCNWLLoS1BuzobEXPkiYtZxMbLRlekDnjNh/t85z47VRx4PNJJ 0AUEZI4vMsUUF8vtGtdr0Pe/+UhOrBD7DFoXenCxyH8vxP+Du8rKrXCEanuJRYYUuy +PPBkbMpX25J3HNgO3ErLZJjnaEKzQlvuz+SfzKfwazfaGR+Q5e5EMTkdlmId/dL4E WcWVji6WOGpLOZmqkkBk= From: Michael Fabian 'Xaymar' Dirks To: ffmpeg-devel@ffmpeg.org Date: Thu, 13 Jan 2022 00:17:24 +0100 Message-Id: X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/amfenc: Add missing profiles X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Michael Fabian 'Xaymar' Dirks Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8DZ7kAPgkqEQ From: Michael Fabian 'Xaymar' Dirks Adds the missing profiles to the '-help encoder=xxx_amf' list, even if the user may never need these. --- libavcodec/amfenc_h264.c | 11 ++++++----- libavcodec/amfenc_hevc.c | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index 87a3bb6a73..ae21c60357 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -37,11 +37,12 @@ static const AVOption options[] = { { "lowlatency_highqquality", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY_HIGH_QUALITY }, 0, 0, VE, "usage" }, /// Profile, - { "profile", "Profile", OFFSET(profile),AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, AMF_VIDEO_ENCODER_PROFILE_BASELINE, AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_HIGH, VE, "profile" }, - { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, 0, 0, VE, "profile" }, - { "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_HIGH }, 0, 0, VE, "profile" }, - { "constrained_baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_BASELINE }, 0, 0, VE, "profile" }, - { "constrained_high", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_HIGH }, 0, 0, VE, "profile" }, + { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, AMF_VIDEO_ENCODER_PROFILE_BASELINE, AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_HIGH, VE, "profile" }, + { "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_BASELINE }, 0, 0, VE, "profile" }, + { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_MAIN }, 0, 0, VE, "profile" }, + { "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_HIGH }, 0, 0, VE, "profile" }, + { "constrained_baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_BASELINE }, 0, 0, VE, "profile" }, + { "constrained_high", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_PROFILE_CONSTRAINED_HIGH }, 0, 0, VE, "profile" }, /// Profile Level { "level", "Profile Level", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 62, VE, "level" }, diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 565be9bad9..a69f37e7b1 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -34,6 +34,7 @@ static const AVOption options[] = { { "profile", "Set the profile (default main)", OFFSET(profile), AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN, VE, "profile" }, { "main", "", 0, AV_OPT_TYPE_CONST,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN }, 0, 0, VE, "profile" }, + { "main10", "", 0, AV_OPT_TYPE_CONST,{ .i64 = AMF_VIDEO_ENCODER_HEVC_PROFILE_MAIN_10 }, 0, 0, VE, "profile" }, { "profile_tier", "Set the profile tier (default main)", OFFSET(tier), AV_OPT_TYPE_INT,{ .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN }, AMF_VIDEO_ENCODER_HEVC_TIER_MAIN, AMF_VIDEO_ENCODER_HEVC_TIER_HIGH, VE, "tier" }, { "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_ENCODER_HEVC_TIER_MAIN }, 0, 0, VE, "tier" },