From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0462F48F8F for ; Wed, 1 May 2024 18:39:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 654B768D719; Wed, 1 May 2024 21:38:33 +0300 (EEST) Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16F7968D701 for ; Wed, 1 May 2024 21:38:22 +0300 (EEST) Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a58d0aea14cso713365266b.2 for ; Wed, 01 May 2024 11:38:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714588701; x=1715193501; 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=FB+xkIZAK0Ta8G0mP47ML47wYzZvqx3U1zO2LtbScX8=; b=i409Nx4B9KXBQQjph0PL2npNh6Z46nBjUo77XJ3Hz7Wr1cVn2dCakQ7dDXnTkpdykm Kw23R7tyN6bjYfJsYZJpi7OAUlk7PrxqHYHzhFNZ0dF9YCIGmCN5cXTa/LAxj8eEAyTI WumGAoMYkOzZaLKdzUkeKE4PmhQ8inPJh0TmttSEzy+SSbP6m/V7bkrQL0a7NvT9Va9o fTx14ckk1o01X/f3FvH7A/WOvPsfUMn3zJaM5HcpF8xrmqObz8On5LeB0SHgTSLsJhEm n8V1qe27AOmo5hp+8gozei57Esj3Xvp2s5Zr41xvPEmiomckqdfbxlHXKjNZ0b1TQeqT igmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714588701; x=1715193501; 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=FB+xkIZAK0Ta8G0mP47ML47wYzZvqx3U1zO2LtbScX8=; b=beemssnxYLn5CDKDzzhg0tcrpUVApcQipR7oufWrSBtmNC8e9haeFRnNNnBkhY1nq/ AcMBRBLIi812kDKSI93B8CjUlIZEnMp8jIehST7boHBxK2Di1inGCGGT7KO+u6s6FsCO LY8uj3xOfkRi9oxREdMyqLfMGkSxUWaDyUthU2FACxReAbgZ/4GACzKxFTJOtfQZ41kT iKN6wIz6fdZlSax7RZv2ZKxjJA59k6+SBqZuMiCWv4AklT7LYdSp6Bv2YYGtehnSr9oo qg23BBSKgexR3Sf58e11X+Ua8vE7seFlIj3q+2vYS2kgiPBcGXs2cCWXloDKEvwnEHo4 A6EQ== X-Gm-Message-State: AOJu0Yz/ZP4lTqhGDnxiQffRRQVvRz9WP37NOKysajZYiKZ9ISX6gm0P umtw++DQSMPVEicdl3YhxRaRgNFkektEiGYqCwrAZnLXcvFBlWmG8WFtxj+t X-Google-Smtp-Source: AGHT+IEhlxPixTiI1ZexCms2O3lvuG5NF6Qqq1Ssc5OQad1e7Bl1XHu4yX2lbcYEY+TIlWOryfdVpg== X-Received: by 2002:a17:906:3c15:b0:a46:3ce4:5acb with SMTP id h21-20020a1709063c1500b00a463ce45acbmr2418028ejg.75.1714588701038; Wed, 01 May 2024 11:38:21 -0700 (PDT) Received: from dovchinn.amd.com (cable-178-148-16-149.dynamic.sbb.rs. [178.148.16.149]) by smtp.gmail.com with ESMTPSA id kh20-20020a170906f81400b00a58bf434876sm7367337ejb.58.2024.05.01.11.38.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 11:38:20 -0700 (PDT) From: Dmitrii Ovchinnikov To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 May 2024 20:38:06 +0200 Message-Id: <20240501183809.1060-7-ovchinnikov.dmitrii@gmail.com> X-Mailer: git-send-email 2.38.1.windows.1 In-Reply-To: <20240501183809.1060-1-ovchinnikov.dmitrii@gmail.com> References: <20240501183809.1060-1-ovchinnikov.dmitrii@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/10, v2] avcodec/amfenc: add smart access video 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: Evgeny Pavlov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Evgeny Pavlov This commit adds option for enabling SmartAccess Video (SAV) in AMF encoders. SAV is an AMD hardware-specific feature which enables the parallelization of encode and decode streams across multiple Video Codec Engine (VCN) hardware instances. Signed-off-by: Evgeny Pavlov --- libavcodec/amfenc.h | 1 + libavcodec/amfenc_av1.c | 18 ++++++++++++++++++ libavcodec/amfenc_h264.c | 18 ++++++++++++++++++ libavcodec/amfenc_hevc.c | 18 ++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h index 62736ef579..1bda0136bd 100644 --- a/libavcodec/amfenc.h +++ b/libavcodec/amfenc.h @@ -90,6 +90,7 @@ typedef struct AmfContext { int quality; int b_frame_delta_qp; int ref_b_frame_delta_qp; + int smart_access_video; // Dynamic options, can be set after Init() call diff --git a/libavcodec/amfenc_av1.c b/libavcodec/amfenc_av1.c index cc48e93fcb..7d37a242fc 100644 --- a/libavcodec/amfenc_av1.c +++ b/libavcodec/amfenc_av1.c @@ -104,6 +104,8 @@ static const AVOption options[] = { { "log_to_dbg", "Enable AMF logging to debug output", OFFSET(log_to_dbg), AV_OPT_TYPE_BOOL,{.i64 = 0 }, 0, 1, VE }, + { "smart_access_video", "Enable Smart Access Video", OFFSET(smart_access_video), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE}, + //Pre Analysis options { "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE }, @@ -265,6 +267,22 @@ FF_ENABLE_DEPRECATION_WARNINGS } } + if (ctx->smart_access_video != -1) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_ENABLE_SMART_ACCESS_VIDEO, ctx->smart_access_video != 0); + if (res != AMF_OK) { + av_log(avctx, AV_LOG_ERROR, "The Smart Access Video is not supported by AMF.\n"); + if (ctx->smart_access_video != 0) + return AVERROR(ENOSYS); + } else { + av_log(avctx, AV_LOG_INFO, "The Smart Access Video (%d) is set.\n", ctx->smart_access_video); + // Set low latency mode if Smart Access Video is enabled + if (ctx->smart_access_video != 0) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_ENCODING_LATENCY_MODE, AMF_VIDEO_ENCODER_AV1_ENCODING_LATENCY_MODE_LOWEST_LATENCY); + av_log(avctx, AV_LOG_INFO, "The Smart Access Video set low latency mode.\n"); + } + } + } + // Pre-Pass, Pre-Analysis, Two-Pass if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_CONSTANT_QP) { AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_PREENCODE, 0); diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index ad5fcc9ecb..a26a6dbef8 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -136,6 +136,8 @@ static const AVOption options[] = { { "log_to_dbg", "Enable AMF logging to debug output", OFFSET(log_to_dbg) , AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, + { "smart_access_video", "Enable Smart Access Video", OFFSET(smart_access_video), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE}, + //Pre Analysis options { "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE }, @@ -369,6 +371,22 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(ctx, AV_LOG_WARNING, "rate control mode is PEAK_CONSTRAINED_VBR but rc_max_rate is not set\n"); } + if (ctx->smart_access_video != -1) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_ENABLE_SMART_ACCESS_VIDEO, ctx->smart_access_video != 0); + if (res != AMF_OK) { + av_log(avctx, AV_LOG_ERROR, "The Smart Access Video is not supported by AMF.\n"); + if (ctx->smart_access_video != 0) + return AVERROR(ENOSYS); + } else { + av_log(avctx, AV_LOG_INFO, "The Smart Access Video (%d) is set.\n", ctx->smart_access_video); + // Set low latency mode if Smart Access Video is enabled + if (ctx->smart_access_video != 0) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_LOWLATENCY_MODE, true); + av_log(avctx, AV_LOG_INFO, "The Smart Access Video set low latency mode.\n"); + } + } + } + if (ctx->preanalysis != -1) { AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_PRE_ANALYSIS_ENABLE, !!((ctx->preanalysis == 0) ? false : true)); } diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index a89a3cf20c..8c26956513 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -100,6 +100,8 @@ static const AVOption options[] = { { "log_to_dbg", "Enable AMF logging to debug output", OFFSET(log_to_dbg), AV_OPT_TYPE_BOOL,{ .i64 = 0 }, 0, 1, VE }, + { "smart_access_video", "Enable Smart Access Video", OFFSET(smart_access_video), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE}, + //Pre Analysis options { "preanalysis", "Enable preanalysis", OFFSET(preanalysis), AV_OPT_TYPE_BOOL, {.i64 = -1 }, -1, 1, VE }, @@ -265,6 +267,22 @@ FF_ENABLE_DEPRECATION_WARNINGS } } + if (ctx->smart_access_video != -1) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_ENABLE_SMART_ACCESS_VIDEO, ctx->smart_access_video != 0); + if (res != AMF_OK) { + av_log(avctx, AV_LOG_ERROR, "The Smart Access Video is not supported by AMF.\n"); + if (ctx->smart_access_video != 0) + return AVERROR(ENOSYS); + } else { + av_log(avctx, AV_LOG_INFO, "The Smart Access Video (%d) is set.\n", ctx->smart_access_video); + // Set low latency mode if Smart Access Video is enabled + if (ctx->smart_access_video != 0) { + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_LOWLATENCY_MODE, true); + av_log(avctx, AV_LOG_INFO, "The Smart Access Video set low latency mode.\n"); + } + } + } + // Pre-Pass, Pre-Analysis, Two-Pass if (ctx->rate_control_mode == AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP) { AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_PREENCODE_ENABLE, 0); -- 2.38.1.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".