From patchwork Fri Mar 8 08:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Fei W" X-Patchwork-Id: 46898 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c995:b0:1a1:738b:6bc0 with SMTP id gy21csp805585pzb; Fri, 8 Mar 2024 00:47:23 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWyXDoJ4a2KIDOOWeSqAMIanC4bt7m/m1GJU8l4iukDW5QHwCsBdndzsF6w/ngje2Z1OcLg3bVO5f2KO/i9rLJ+KoHeBbVsdpmzdQ== X-Google-Smtp-Source: AGHT+IEPclGqGnFeDaU8pzKrSBCnUGIKIanwU0RDuEm0Ye3uRhcg50iuNpViOlNmimErXT6V2BvF X-Received: by 2002:a05:6402:4485:b0:567:156e:7893 with SMTP id er5-20020a056402448500b00567156e7893mr1095270edb.4.1709887643204; Fri, 08 Mar 2024 00:47:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709887643; cv=none; d=google.com; s=arc-20160816; b=LmtVPNFyfZhP03bPAmoJueA73H8Q3fPm0DBZ6syDcoaurzBBUaXjhsZS+r53YUFGcX d4omhvPZ5OCSos57p4g+hW4l5nSTENRyJLhQiD0/kSnq9tqtsYoPwoc5diwpykuYf5bd e02+XLKuwfMLRTPKocBNIEYhTaD2sSlcDMaAdVCPE+98BFg7crRvZ2tYS/KWgl/wOAz5 N8Xik7PjINZmKhBvEXbrFSQ4SI3EOzMhnw+LMlrv5zBXrstXPCtBy4vKEhaWa01PxeQa nfUdZ2jZbEX3CqWoXWCNIMsKkfkRFpIzFThUtsjBob/XhGWldAvnO3CSVmuUvz3CBu9X I3YA== 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=vs9vzfTrHrkJlGPlsUqcG1oipoaXc9FanSEAeyU4j5E=; fh=i4ESP4ZRFDcfYfwXKWpOXjc2YhmIGuOsCfZUnwNO0gc=; b=Ir5X7PL+S0wF0nMyUB2stO1hZWiE4SXdckt3evIzLetheEyznNPRPKN7ejfP2vGKYB wTdL53ROmXdGgVVhV1NJqH/wuX/bv49JRt6eS59W9xsO13D0kc7C+ypnfS3fxktIUoGa l2YwW1FeQIVAeu4tkgTOR9Z2oEHX2rEDUIePx6KxRsyBuWPo9HqK4NxkrZYr2Y/m0eIp xER87CoMQy2jvLCJDQMuhoyqoc3mQaZhf275hBsXlOTxo0yScscSaq6KBzaVFwlPrepw 6F1LSRWVVWgtUdjutC0Q0sOJQPClIkXnqmJIlWdfgfSZqOgHK/ob2XS8sI2563AF7Wap FXIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=aaUnSBsK; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z15-20020a05640235cf00b00568307aba2asi146544edc.681.2024.03.08.00.47.22; Fri, 08 Mar 2024 00:47:23 -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=@intel.com header.s=Intel header.b=aaUnSBsK; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ECF8068CD00; Fri, 8 Mar 2024 10:47:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 055D568C7DA for ; Fri, 8 Mar 2024 10:47:13 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709887639; x=1741423639; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=vHwPfk9A7ckXrRn+uMw6w+c6DDo6FuPLY7SNa6Ffl9U=; b=aaUnSBsKWUFF9RD8t768/xkKIJ2wO5ah14F4CjI6njWkmbqFzdKbxLAg W2ARTk24aky7d8vpTDYxxt8zNRejHEZlZz7iDlNHOLIKMEgIL1kES2DD9 pJOcnbHRW3wpxtgZyV2zU6+gI3WSiWXAn2UOrAzsDa0vSoOFk6or/KkSK zRHer04+bnWdrO0cnVI8UpRSUuEK+9zu4WmtQsTFqguaPE8W0PWLKhhxR n22l5mpvYW3l7q6loRfTSMEP5mFCtFOxp2TS5KeeNz38zo2DwNmUb9WBS 4e1igh9is7V5OqXN98QKu3DPASXYHCJoc9H8vNC9yy0dg8sIEQ1enl0s2 A==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="8417615" X-IronPort-AV: E=Sophos;i="6.07,109,1708416000"; d="scan'208";a="8417615" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 00:47:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,109,1708416000"; d="scan'208";a="10485848" Received: from t-dg2.sh.intel.com ([10.239.159.57]) by fmviesa008.fm.intel.com with ESMTP; 08 Mar 2024 00:47:11 -0800 From: fei.w.wang-at-intel.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Mar 2024 16:47:22 +0800 Message-Id: <20240308084723.70916-1-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile 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: fei.w.wang@intel.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pn9BuUSbJt5w From: Fei Wang There is no Main8/10 profile defined in HEVC REXT profiles. Use Main12 which is compatible with 8/10bit. Signed-off-by: Fei Wang --- update: Add more explanation in commit log. libavcodec/vaapi_encode_h265.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index c4aabbf5ed..43755e2188 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1305,12 +1305,12 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { { AV_PROFILE_HEVC_MAIN, 8, 3, 1, 1, VAProfileHEVCMain }, - { AV_PROFILE_HEVC_REXT, 8, 3, 1, 1, VAProfileHEVCMain }, #if VA_CHECK_VERSION(0, 37, 0) { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10 }, - { AV_PROFILE_HEVC_REXT, 10, 3, 1, 1, VAProfileHEVCMain10 }, #endif #if VA_CHECK_VERSION(1, 2, 0) + { AV_PROFILE_HEVC_REXT, 8, 3, 1, 1, VAProfileHEVCMain12 }, + { AV_PROFILE_HEVC_REXT, 10, 3, 1, 1, VAProfileHEVCMain12 }, { AV_PROFILE_HEVC_REXT, 12, 3, 1, 1, VAProfileHEVCMain12 }, { AV_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 }, { AV_PROFILE_HEVC_REXT, 10, 3, 1, 0, VAProfileHEVCMain422_10 }, From patchwork Fri Mar 8 08:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Fei W" X-Patchwork-Id: 46899 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c995:b0:1a1:738b:6bc0 with SMTP id gy21csp805643pzb; Fri, 8 Mar 2024 00:47:32 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWyExWwWFpYIg1R0H144qS3ldhrtw7Zp56eTTK6DK1d5oe9K6Hm7wqEsjatXlE0YKTOgsYjj2QuQPLIM87dI7AbVkwaR4XuViJvYQ== X-Google-Smtp-Source: AGHT+IGZ5l8uDENZ/01nHPsY9ocrKhg1vbnayXFMpYDaeH3wt44zIQqLt4X0Q0wFPB8qucLBsVfk X-Received: by 2002:a05:6402:158b:b0:565:a4dc:b288 with SMTP id ij11-20020a056402158b00b00565a4dcb288mr790943edb.4.1709887651725; Fri, 08 Mar 2024 00:47:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709887651; cv=none; d=google.com; s=arc-20160816; b=BfCYttjoXqpXCxjG0IqMxHJVwlEle9mkX73/jqEHdCIhxtCi0udmWcG4UIx0a02ZFg xfREC/hRn1ISW6JVg54V6jKNH9S3+/jPNnEAVWJWblk4z9HjNlySHVaKOECmIYAkK1/k jZoETPE1nKQfWgpRjwJPd7Y1ycHTsGkYYkUKL8G/na1PrrIW8xhNyP3/g8rd7+b4mPeJ jERh3v2ypw31zYNH6m95K78CkseW1i8L3iHoQ2wSgVveupiG36sDPuaX9BaPpS5vnlgt F3/7MXW8N9ocRR2UuBY27k8fcsmY1JRCwj0uPo0mHvl+vIDqQQtqBm358J1i8wlPnjOv JHYQ== 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=n1o974Dfh/C72dN/zRKPAMqo34h65r+9gj2f3+plG+w=; fh=i4ESP4ZRFDcfYfwXKWpOXjc2YhmIGuOsCfZUnwNO0gc=; b=e5wMMXjqy/jAPV3roAtGTIpdpg6ITgD4TmvNedqFiYNUHjyqRF0gC6IXhWfFK1Z1Av RZgPXi572ADhYaj0LZJSREAmmTdNdnzQovzjbhXb2sgL07J5I569n5j8SCGR4pMKKdn5 CoY+s9oyDg7EroBV1mEoXrkTLvi3zjm8hQoHmVh2aK+Qsut0lS6IzLjmuNQqelUXkAJP Tg1Y1m/CDnSalzmnwBnyj/b3Tcvb5rQlWkCeUdsizPIVIpNjmaaAXfn7dfKFBulU9VdO QnR/R7C6QxzYjBvuptNz2Enr/Caxmftea+JZ91YuV49kq692LKWfpUs0vsWPvgWHj4lo Y0dg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=enNsMlGt; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t33-20020a056402242100b00568335fe4f8si20044eda.623.2024.03.08.00.47.30; Fri, 08 Mar 2024 00:47:31 -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=@intel.com header.s=Intel header.b=enNsMlGt; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0984068CDBE; Fri, 8 Mar 2024 10:47:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 25DBF68C9F8 for ; Fri, 8 Mar 2024 10:47:19 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709887645; x=1741423645; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zypl6DwsPOHSDiSkC06YfU2RwUcH/gjcxKic+GoA/Kk=; b=enNsMlGtm/h6y960bkrbTo32apmpKgkdT3l135aIBuHlkV/Yp3KaAVy7 kAuf+em+ludyVvbXZiNZ6tVNw12xLkpYNnd18+FCq25V5D/i1zU9fNta9 Fl5jqu4zOf4kJRUAvqpL3YVyz+Qagps61qDFSoMkM3MNC21yYDm9eusyk ukGsH3XaUMeOklT4eG/ht+7zKp5bjigPi2csjBwrbBZNmNs/QQ6NDQkfS 5NuKGiqZnsAKvg5X6hywRpQvtPMPDL6az1x8ar/NgZIeh3LJXLGFsT3cd Ixhyjcc+YfyQo2NsHI32sLMjgEBpdcL9snwQonDN7FYwh+lIb/GkmB3wU w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="8417617" X-IronPort-AV: E=Sophos;i="6.07,109,1708416000"; d="scan'208";a="8417617" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2024 00:47:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,109,1708416000"; d="scan'208";a="10485855" Received: from t-dg2.sh.intel.com ([10.239.159.57]) by fmviesa008.fm.intel.com with ESMTP; 08 Mar 2024 00:47:12 -0800 From: fei.w.wang-at-intel.com@ffmpeg.org To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Mar 2024 16:47:23 +0800 Message-Id: <20240308084723.70916-2-fei.w.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240308084723.70916-1-fei.w.wang@intel.com> References: <20240308084723.70916-1-fei.w.wang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile 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: fei.w.wang@intel.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DNvQLOg9XOg7 From: Fei Wang According to Table A.2 in spec. Signed-off-by: Fei Wang --- libavcodec/vaapi_encode_h265.c | 181 +++++++++++++++++++++++---------- 1 file changed, 128 insertions(+), 53 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 43755e2188..7c9916eac8 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -258,6 +258,129 @@ fail: return err; } +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx) +{ + VAAPIEncodeContext *ctx = avctx->priv_data; + VAAPIEncodeH265Context *priv = avctx->priv_data; + H265RawVPS *vps = &priv->raw_vps; + H265RawProfileTierLevel *ptl = &vps->profile_tier_level; + + ptl->general_profile_space = 0; + ptl->general_profile_idc = avctx->profile; + ptl->general_tier_flag = priv->tier; + + ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1; + + if (ptl->general_profile_compatibility_flag[1]) + ptl->general_profile_compatibility_flag[2] = 1; + if (ptl->general_profile_compatibility_flag[3]) { + ptl->general_profile_compatibility_flag[1] = 1; + ptl->general_profile_compatibility_flag[2] = 1; + } + + ptl->general_progressive_source_flag = 1; + ptl->general_interlaced_source_flag = 0; + ptl->general_non_packed_constraint_flag = 1; + ptl->general_frame_only_constraint_flag = 1; + + if (avctx->profile >= 4) { + ptl->general_intra_constraint_flag = ctx->gop_size == 1; + ptl->general_one_picture_only_constraint_flag = 0; + ptl->general_lower_bit_rate_constraint_flag = 1; + + switch (ctx->va_profile) { +#if VA_CHECK_VERSION(1, 2, 0) + case VAProfileHEVCMain12: + // Main 12 + ptl->general_max_14bit_constraint_flag = 0; + ptl->general_max_12bit_constraint_flag = 1; + ptl->general_max_10bit_constraint_flag = 0; + ptl->general_max_8bit_constraint_flag = 0; + ptl->general_max_422chroma_constraint_flag = 1; + ptl->general_max_420chroma_constraint_flag = 1; + ptl->general_max_monochrome_constraint_flag = 0; + break; + case VAProfileHEVCMain422_10: + // Main 4:2:2 10 + ptl->general_max_14bit_constraint_flag = 0; + ptl->general_max_12bit_constraint_flag = 1; + ptl->general_max_10bit_constraint_flag = 1; + ptl->general_max_8bit_constraint_flag = 0; + ptl->general_max_422chroma_constraint_flag = 1; + ptl->general_max_420chroma_constraint_flag = 0; + ptl->general_max_monochrome_constraint_flag = 0; + break; + case VAProfileHEVCMain422_12: + // Main 4:2:2 12 + ptl->general_max_14bit_constraint_flag = 0; + ptl->general_max_12bit_constraint_flag = 1; + ptl->general_max_10bit_constraint_flag = 0; + ptl->general_max_8bit_constraint_flag = 0; + ptl->general_max_422chroma_constraint_flag = 1; + ptl->general_max_420chroma_constraint_flag = 0; + ptl->general_max_monochrome_constraint_flag = 0; + break; + case VAProfileHEVCMain444: + // Main 4:4:4 + ptl->general_max_14bit_constraint_flag = 0; + ptl->general_max_12bit_constraint_flag = 1; + ptl->general_max_10bit_constraint_flag = 1; + ptl->general_max_8bit_constraint_flag = 1; + ptl->general_max_422chroma_constraint_flag = 0; + ptl->general_max_420chroma_constraint_flag = 0; + ptl->general_max_monochrome_constraint_flag = 0; + break; + case VAProfileHEVCMain444_10: + // Main 4:4:4 10 + ptl->general_max_14bit_constraint_flag = 0; + ptl->general_max_12bit_constraint_flag = 1; + ptl->general_max_10bit_constraint_flag = 1; + ptl->general_max_8bit_constraint_flag = 0; + ptl->general_max_422chroma_constraint_flag = 0; + ptl->general_max_420chroma_constraint_flag = 0; + ptl->general_max_monochrome_constraint_flag = 0; + break; + case VAProfileHEVCMain444_12: + // Main 4:4:4 12 + ptl->general_max_14bit_constraint_flag = 0; + ptl->general_max_12bit_constraint_flag = 1; + ptl->general_max_10bit_constraint_flag = 0; + ptl->general_max_8bit_constraint_flag = 0; + ptl->general_max_422chroma_constraint_flag = 0; + ptl->general_max_420chroma_constraint_flag = 0; + ptl->general_max_monochrome_constraint_flag = 0; + break; +#endif + default: + av_log(avctx, AV_LOG_ERROR, "Unknown profile to init PTL.\n"); + return AVERROR(EINVAL); + } + } + + if (avctx->level != AV_LEVEL_UNKNOWN) { + ptl->general_level_idc = avctx->level; + } else { + const H265LevelDescriptor *level; + + level = ff_h265_guess_level(ptl, avctx->bit_rate, + ctx->surface_width, ctx->surface_height, + ctx->nb_slices, ctx->tile_rows, ctx->tile_cols, + (ctx->b_per_p > 0) + 1); + if (level) { + av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name); + ptl->general_level_idc = level->level_idc; + } else { + av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to " + "any normal level; using level 8.5.\n"); + ptl->general_level_idc = 255; + // The tier flag must be set in level 8.5. + ptl->general_tier_flag = 1; + } + } + + return 0; +} + static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; @@ -265,13 +388,12 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) H265RawVPS *vps = &priv->raw_vps; H265RawSPS *sps = &priv->raw_sps; H265RawPPS *pps = &priv->raw_pps; - H265RawProfileTierLevel *ptl = &vps->profile_tier_level; H265RawVUI *vui = &sps->vui; VAEncSequenceParameterBufferHEVC *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferHEVC *vpic = ctx->codec_picture_params; const AVPixFmtDescriptor *desc; int chroma_format, bit_depth; - int i; + int i, err; memset(vps, 0, sizeof(*vps)); memset(sps, 0, sizeof(*sps)); @@ -314,57 +436,10 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) vps->vps_max_sub_layers_minus1 = 0; vps->vps_temporal_id_nesting_flag = 1; - ptl->general_profile_space = 0; - ptl->general_profile_idc = avctx->profile; - ptl->general_tier_flag = priv->tier; - - ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1; - - if (ptl->general_profile_compatibility_flag[1]) - ptl->general_profile_compatibility_flag[2] = 1; - if (ptl->general_profile_compatibility_flag[3]) { - ptl->general_profile_compatibility_flag[1] = 1; - ptl->general_profile_compatibility_flag[2] = 1; - } - - ptl->general_progressive_source_flag = 1; - ptl->general_interlaced_source_flag = 0; - ptl->general_non_packed_constraint_flag = 1; - ptl->general_frame_only_constraint_flag = 1; - - ptl->general_max_14bit_constraint_flag = bit_depth <= 14; - ptl->general_max_12bit_constraint_flag = bit_depth <= 12; - ptl->general_max_10bit_constraint_flag = bit_depth <= 10; - ptl->general_max_8bit_constraint_flag = bit_depth == 8; - - ptl->general_max_422chroma_constraint_flag = chroma_format <= 2; - ptl->general_max_420chroma_constraint_flag = chroma_format <= 1; - ptl->general_max_monochrome_constraint_flag = chroma_format == 0; - - ptl->general_intra_constraint_flag = ctx->gop_size == 1; - ptl->general_one_picture_only_constraint_flag = 0; - - ptl->general_lower_bit_rate_constraint_flag = 1; - - if (avctx->level != AV_LEVEL_UNKNOWN) { - ptl->general_level_idc = avctx->level; - } else { - const H265LevelDescriptor *level; - - level = ff_h265_guess_level(ptl, avctx->bit_rate, - ctx->surface_width, ctx->surface_height, - ctx->nb_slices, ctx->tile_rows, ctx->tile_cols, - (ctx->b_per_p > 0) + 1); - if (level) { - av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name); - ptl->general_level_idc = level->level_idc; - } else { - av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to " - "any normal level; using level 8.5.\n"); - ptl->general_level_idc = 255; - // The tier flag must be set in level 8.5. - ptl->general_tier_flag = 1; - } + err = vaapi_encode_h265_init_ptl(avctx); + if (err < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to init PTL.\n"); + return err; } vps->vps_sub_layer_ordering_info_present_flag = 0;