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 DD8404987B for ; Thu, 21 Mar 2024 17:03:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ABE7C68D564; Thu, 21 Mar 2024 19:03:02 +0200 (EET) Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C4A668D4CF for ; Thu, 21 Mar 2024 19:02:56 +0200 (EET) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-56845954ffeso1554099a12.2 for ; Thu, 21 Mar 2024 10:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711040575; x=1711645375; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XKiHX4bneKsSfGYaKcI7/XL45aBBtGdA9hB4uvh/Lbw=; b=aaotH54rPBAFmQvCUXRK/wG0IsvfYdCgy4hYglIMYvbTdE6UY4rRd2PErGH5ebOHV2 ezUElFN/Cki/fCkCd5EIZRkqt3Vdu82ddzSsVsK9wE2waIkOSnyIlUfv7DtVsDf+sIBl V6IhWp6+R8PWdntLupGBvq6PZ1Ok98XIYENwrrnrRx5gM+jFa0/z49IDG5hvEOV0dmfG AHKPyT7Uc++hr1HpttHykfpLC9JIj4yVygAB4RjOyXyuAUqhCC4hAxaYmNvkE9M4lHpS qHWJlEvi7j1g3vmjprSLx3YEAM4/IhQafoUYCEV2SYt97ZNnDlUCTLnl1vOCYy10iBws y4jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711040575; x=1711645375; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XKiHX4bneKsSfGYaKcI7/XL45aBBtGdA9hB4uvh/Lbw=; b=XwXnDDnhwnQMsGcP9+9i+JWoFBzWwwA6PqqPDFMNBRMSm/lJAItwkKoZio23RJnOpM h4G0pvEjUVeY8IfgLsYmpNS4KX+LPLy1tb9AmCU2W3yjNhI8JUIBoWF+B2RLzHBxhaxl YXmqbO9jlz/WEfjKUBCWrJmrV6/LoE29GGYzvbhdVF8vhF1bjGZeIveXb5/95mQYAbTc oAqsTuj9acynjVgusd0fHjWWdXwWmbA1efiRGkiZr3MiMDzqIr6oMuTeJwALugM8hS9u p534l1YBer5J+xgjhAu+oxHeElX3ke6+k7l5XQkZA0rVTpCP7v/vu82RQuVl33PD/Bbd WSSw== X-Gm-Message-State: AOJu0YxZfh8gE9ek/ejfqU5WYUS/zuCcUZecQxI4/K6vpWZPGIcgUPgx WqElzwSdNYrNhzxjFrPWYiR48c0DL6jYtj3g9oB0MAoneSSViE017+Egb83C5VwW2w== X-Google-Smtp-Source: AGHT+IGCd+4GCpMGz3DMgH6Udb2djVbBEQmleClog/8TLkRHAvm9SnsVUrcq958JnQXGyBOrF962WA== X-Received: by 2002:a17:906:6958:b0:a46:a662:e567 with SMTP id c24-20020a170906695800b00a46a662e567mr15643ejs.3.1711040575091; Thu, 21 Mar 2024 10:02:55 -0700 (PDT) Received: from aiusubov.amd.com ([87.116.135.17]) by smtp.gmail.com with ESMTPSA id q4-20020a1709060e4400b00a46d001a259sm113524eji.52.2024.03.21.10.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:02:54 -0700 (PDT) From: Araz Iusubov X-Google-Original-From: Araz Iusubov To: ffmpeg-devel@ffmpeg.org Date: Thu, 21 Mar 2024 18:02:19 +0100 Message-ID: <20240321170219.1487-1-Primeadvice@gmail.com> X-Mailer: git-send-email 2.43.0.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] [v4] avcodec/vaapi_encode: add customized surface alignment 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: Araz Iusubov 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: This commit fixes issues with AMD HEVC encoding. By default AMD hevc encoder asks for the alignment 64x16, while FFMPEG VAAPI has 16x16. Adding support for customized surface size from VASurfaceAttribAlignmentSize in VAAPI version 1.21.0 Signed-off-by: Araz Iusubov --- libavcodec/vaapi_encode.c | 11 +++++++++++ libavutil/hwcontext.h | 7 +++++++ libavutil/hwcontext_vaapi.c | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 940f0678a5..2a74db23b1 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -2711,6 +2711,17 @@ static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "Using %s as format of " "reconstructed frames.\n", av_get_pix_fmt_name(recon_format)); + if (constraints->log2_alignment) { + ctx->surface_width = FFALIGN(avctx->width, + 1 << (constraints->log2_alignment & 0xf)); + ctx->surface_height = FFALIGN(avctx->height, + 1 << ((constraints->log2_alignment & 0xf0) >> 4)); + av_log(avctx, AV_LOG_VERBOSE, "Using customized alignment size " + "[%dx%d].\n", + (1 << (constraints->log2_alignment & 0xf)), + (1 << ((constraints->log2_alignment & 0xf0) >> 4))); + } + if (ctx->surface_width < constraints->min_width || ctx->surface_height < constraints->min_height || ctx->surface_width > constraints->max_width || diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index bac30debae..1eb56aff78 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -465,6 +465,13 @@ typedef struct AVHWFramesConstraints { */ int max_width; int max_height; + + /** + * The frame width/height log2 alignment when available + * the lower 4 bits, width; another 4 bits, height + * (Zero is not applied, use the default value) + */ + int log2_alignment; } AVHWFramesConstraints; /** diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 56d03aa4cd..6cda0fd811 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -294,6 +294,11 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, case VASurfaceAttribMaxHeight: constraints->max_height = attr_list[i].value.value.i; break; +#if VA_CHECK_VERSION(1, 21, 0) + case VASurfaceAttribAlignmentSize: + constraints->log2_alignment = attr_list[i].value.value.i; + break; +#endif } } if (pix_fmt_count == 0) { -- 2.43.0.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".