From patchwork Thu Aug 1 11:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Araz X-Patchwork-Id: 50851 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:12d6:0:b0:489:2eb3:e4c4 with SMTP id 205csp1065692vqs; Thu, 1 Aug 2024 04:14:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXC3bqOxShN49QrmlKLtfYVV8zR1BNgwW6RT0pgJsv/9tf12lH5l7tnqf0RJCOxeyufg7wCOa9zl3M5UmxX0YOomImy9ga0B/AsGw== X-Google-Smtp-Source: AGHT+IEPvJdDXCfLaBru80MAz11XIC88vZNY0+uDIkI6YmsMG3nGhnO3g8/k4DSv+izhA2iTPDK9 X-Received: by 2002:a05:651c:306:b0:2f0:25dc:1886 with SMTP id 38308e7fff4ca-2f1530e86a8mr16339861fa.10.1722510856863; Thu, 01 Aug 2024 04:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722510856; cv=none; d=google.com; s=arc-20160816; b=D+aBfNoNcrEKzJcN5i9hfZDXyQart0gZIkhNyRgxqjbXogKuhuakpmyrqQ91HXFtCt Y2YmaUu9nSkWBMjHeDxsQReIobhgzq9hr1FFtSrPMpnxDTCQl2Ll/ZzHY6QdlWt2eifB My63fLkxk2VEPtRO5a+Ffw1VJYdjkFi2LONRfjXoHK3QHFDaARNbQFBKg0Tf9ZWOL1JF GwVDMSFqOkOG1A7Qa/kEFVFklJTmIW8UccOX/z5mLJ2hTpop9Zqj0gsyqu7VaSfJZv9t n9FGmuScuPx23ntwtrfohXUCcRyygO3/xWQJyZVM10YdHVI0K/bMTAAgW8jwqcPD4j4o 90xg== 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=3nGglh155NWgC9gVAnECrTT0zXs6qus/eiir4LDPraU=; fh=RrSXaicI7x5SHa2/4czRw6L1sHZRrTfKYm+J2vOmY7E=; b=UMp8zdZnldRNuz1l1h5zZ1kuBj5EDC0E0hCHSzxTwU0sUOxLTSEfkdTCTDcd0n8IO8 mxo9HOuRQUTpnx4c8rcZE0v3pH/sMdKR1mzdJocKUCWqCz+XLwBvlM1I68FiXz4bThr+ YrUmw7ksm6UgShfy+Nr/Lk2cNvVGmyWIsXIQhxZofI4W/VHgEPwUEHZ9SGZ0Z1+pozf2 L3R68unuSfFkhM6NRD2Y3pwSN43fcPfrT1zI2YaxmoeZ0JVkVoA4HagD09AxA/1SnGCD wesQm/POAsoGC7nvw1jC33gQvZXDZVZFdznhxc/ajjGxVmWLhyMZA8EyMgZ8n4JSUdnE 3PXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=im8OUf99; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2f03d187980si42031261fa.593.2024.08.01.04.14.16; Thu, 01 Aug 2024 04:14:16 -0700 (PDT) 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=@gmail.com header.s=20230601 header.b=im8OUf99; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 225AA68D960; Thu, 1 Aug 2024 14:13:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1D55F68D92E for ; Thu, 1 Aug 2024 14:13:48 +0300 (EEST) Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a7aa086b077so611516066b.0 for ; Thu, 01 Aug 2024 04:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722510827; x=1723115627; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=980hQQ6Y8HrqZfKMvEdwwl26AXkiKOvLzNm357frBws=; b=im8OUf99FmUBT8UN4E1rcDHWAeXYVZ9W77b9DBUdY/c14QYv1jhauqmyM7odQgju1n 16o5reXVFAPnt1bS70fgh+zR4xCsc3HnFKoaVvVnqZpyscxYqVzyY2lKDkP9T8xZe2ef HI3G3HLKWd1Okyyt1OGYTRMR/je7WMqcRF993ZydUHCgYnZ4A+7e8EN3HlRvoR17U7fk lh7cPsFwcdjXePqOjHjdsqZ0lLd4zpRYH03ZbANKhz2hbvAjhGZeJhcJunySvCnr7HTr HYEa5IQk8s954ibV2LxQls7oQXVNVy9LJKVgZ53uejrdAxr7fyR36kgbnsDlBn1ZiVZV dGTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722510827; x=1723115627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=980hQQ6Y8HrqZfKMvEdwwl26AXkiKOvLzNm357frBws=; b=B48PLIZwpv7ZI5aTFhdtgdDSiRflaUXabpvd1OMmVmMIcSewogKrvUm89vIAPbtlky eyPStV6h87+hZ+XMYiGixgagU+o4XW3mG4jT8zWmpeobPVfUJ4cZzU12Y1DGUFtMxivA zekU+MYI52SH0iGZQLTt0SGCbtMLqDGDYbWqduHSDh5asarBKMaHgyNoQ74L6BfoPNaM xtu054lsvuaIhF+lAndv4wrUBWeBV4A4fHj0E/A9trXaiLp+ODVqowTugPfetxRCEA1u 3shOPVJ3LuH56WEP+XqXlUROr+B8zvWKbcc8+QxmUpSb+dfdI3MynZHEWfUPeOlRzh42 WHtw== X-Gm-Message-State: AOJu0YwwVfuslAB3E14j/WR9vUKRuvxxYeAIveoyCTFqjdOehfFjuhJE Xeqs5EfyT6IyyupsiPvxVblP5MkyPumj+maEDRmJwgNPW0u8HA8MUkqVTLuvY9hpCA== X-Received: by 2002:a17:907:dac:b0:a7a:a892:8e07 with SMTP id a640c23a62f3a-a7daf50c8edmr211822266b.31.1722510826954; Thu, 01 Aug 2024 04:13:46 -0700 (PDT) Received: from aiusubov.amd.com ([87.116.132.31]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7acada2b1asm887691766b.158.2024.08.01.04.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 04:13:46 -0700 (PDT) From: Araz Iusubov X-Google-Original-From: Araz Iusubov To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 Aug 2024 13:13:37 +0200 Message-ID: <20240801111338.1683-3-Primeadvice@gmail.com> X-Mailer: git-send-email 2.45.2.windows.1 In-Reply-To: <20240801111338.1683-1-Primeadvice@gmail.com> References: <20240801111338.1683-1-Primeadvice@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4, v2] avcodec/amfenc: add 10 bit encoding in av1_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: Evgeny Pavlov , Dmitrii Ovchinnikov , Araz Iusubov Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SzBcJW/L/Q+u From: Evgeny Pavlov v2: refactored after review Signed-off-by: Evgeny Pavlov Co-authored-by: Dmitrii Ovchinnikov Co-authored-by: Araz Iusubov --- libavcodec/amfenc.c | 2 ++ libavcodec/amfenc_av1.c | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index 068bb53002..49dd91c4e0 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -746,6 +746,8 @@ int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_INPUT_HDR_METADATA, hdrmeta_buffer); break; case AV_CODEC_ID_HEVC: AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_INPUT_HDR_METADATA, hdrmeta_buffer); break; + case AV_CODEC_ID_AV1: + AMF_ASSIGN_PROPERTY_INTERFACE(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_INPUT_HDR_METADATA, hdrmeta_buffer); break; } res = amf_set_property_buffer(surface, L"av_frame_hdrmeta", hdrmeta_buffer); AMF_RETURN_IF_FALSE(avctx, res == AMF_OK, AVERROR_UNKNOWN, "SetProperty failed for \"av_frame_hdrmeta\" with error %d\n", res); diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c index 62b9af9da0..e960e5ec81 100644 --- a/libavcodec/amfenc_av1.c +++ b/libavcodec/amfenc_av1.c @@ -170,7 +170,9 @@ static av_cold int amf_encode_init_av1(AVCodecContext* avctx) AMFGuid guid; AMFRate framerate; AMFSize framesize = AMFConstructSize(avctx->width, avctx->height); - + amf_int64 color_depth; + amf_int64 color_profile; + enum AVPixelFormat pix_fmt; //for av1 alignment and crop uint32_t crop_right = 0; @@ -220,6 +222,30 @@ FF_ENABLE_DEPRECATION_WARNINGS AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_PROFILE, profile); } + /// Color profile + color_profile = ff_amf_get_color_profile(avctx); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE, color_profile); + + /// Color Depth + pix_fmt = avctx->hw_frames_ctx ? ((AVHWFramesContext*)avctx->hw_frames_ctx->data)->sw_format + : avctx->pix_fmt; + color_depth = AMF_COLOR_BIT_DEPTH_8; + if (pix_fmt == AV_PIX_FMT_P010) { + color_depth = AMF_COLOR_BIT_DEPTH_10; + } + + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_COLOR_BIT_DEPTH, color_depth); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE, color_profile); + if (color_depth == AMF_COLOR_BIT_DEPTH_8) { + /// Color Transfer Characteristics (AMF matches ISO/IEC) + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_TRANSFER_CHARACTERISTIC, AMF_COLOR_TRANSFER_CHARACTERISTIC_BT709); + /// Color Primaries (AMF matches ISO/IEC) + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PRIMARIES, AMF_COLOR_PRIMARIES_BT709); + } else { + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_TRANSFER_CHARACTERISTIC, AMF_COLOR_TRANSFER_CHARACTERISTIC_SMPTE2084); + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PRIMARIES, AMF_COLOR_PRIMARIES_BT2020); + } + profile_level = avctx->level; if (profile_level == AV_LEVEL_UNKNOWN) { profile_level = ctx->level;