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 B9D9049040 for ; Mon, 1 Apr 2024 20:02:08 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3CF4E68CF25; Mon, 1 Apr 2024 23:02:07 +0300 (EEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4CBA268C934 for ; Mon, 1 Apr 2024 23:02:01 +0300 (EEST) Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-415446af364so21500155e9.0 for ; Mon, 01 Apr 2024 13:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1712001720; x=1712606520; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=exi51ZGdBHaq+3XG4P8o4Jioc1YewO4EVBNy8Kh7394=; b=Nn9Vf6q+4J/JjKzCemVbLQ/DquYR+j43LRcyHnquEnjvM9lXEIjFtOP8XU7HnXH9B+ yhcKsTAac3cxrGsfBY9wWjkC1DxxcNPmBJ6iS0HuVQtuY1jiAICkYKT5vB0EDqkekY+5 MWSuknfU2MqPAQvnXRR18+ILOJVkwqgtZniHK9GIYwZ+r07vq3yRZr0DyNNJeXOQ0P8R +N5GKo7JgAgT1FW6m2MVNH932JS6yW5qZunv7Unsa7+r+IywgujZWJ6liGwUctY1emJG 3Ncf0paywg4XL2QJwi61m9kDJ4pYb05PAhFsOMju/HpEdW/C3RWMf7r5XMOf98n4Bk/r tL6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712001720; x=1712606520; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=exi51ZGdBHaq+3XG4P8o4Jioc1YewO4EVBNy8Kh7394=; b=Z1E/PGnHPgxCr5MJm6PyQRbyOMkapqp9eB468FDgRAO7x5e6X5fx4GFHwS2wgRjRZ/ e8Yh6NT57UkvR0iqE6P6sRa3O2gC4yZg+SU6/bqJj9gLbWPV7lnV+qnvXapGqyMVem8r 5DaDs495flJMS+qeKdltKsm6Fhuc/4yxU5FWwmwIfS6sxyI453tzLEv3dCWqNDCDtJAo uxirRt+RbovGXr8AnM2s2KQLIzAaeFiyDm1oSlye1mfL8hUvARAYcBopkdfwtyjyBlcO IUhrkMekgx7apfnzM0hvavyy7hMyDDbS3075jK42CTHCozotLcWdbAHailPyOQM/bfIF OEwg== X-Gm-Message-State: AOJu0Yz/qXYAc5h1Bvr9GvXQakcqPVx0Anr6FgFtr6HwlMV1+R5n9VrN gE3ZLVKTwjUHxN8cTY2sCu+8kAbTOLOtZPSVyrNOIQydXYxrA+4f5V0J1K7DHq+oFAAFdrbDyFX Q X-Google-Smtp-Source: AGHT+IFgxPTNVguLlzKv08vUPXAdTvF0KkWP+6LOpxoIz8ROpAeRc9ucClZ10mr/Ztj5jB5HDqgZLg== X-Received: by 2002:a05:600c:4e94:b0:413:fdc2:d9da with SMTP id f20-20020a05600c4e9400b00413fdc2d9damr8541363wmq.12.1712001720521; Mon, 01 Apr 2024 13:02:00 -0700 (PDT) Received: from [192.168.0.15] (cpc92302-cmbg19-2-0-cust1183.5-4.cable.virginm.net. [82.1.212.160]) by smtp.gmail.com with ESMTPSA id bo14-20020a056000068e00b0034354c3cb66sm1869130wrb.59.2024.04.01.13.02.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Apr 2024 13:02:00 -0700 (PDT) Message-ID: <7c92fb71-5033-4607-9269-cbba01b9d552@jkqxz.net> Date: Mon, 1 Apr 2024 21:02:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240318042111.21983-1-fei.w.wang@intel.com> <20240318042111.21983-2-fei.w.wang@intel.com> <4cdd5a84-8547-48ea-b0e5-62ca20da39a3@jkqxz.net> <2632f0803eef7becfaff4458547f967a4578a997.camel@intel.com> From: Mark Thompson In-Reply-To: <2632f0803eef7becfaff4458547f967a4578a997.camel@intel.com> Subject: Re: [FFmpeg-devel] [PATCH v3 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 20/03/2024 08:44, Wang, Fei W wrote: > On Mon, 2024-03-18 at 21:22 +0000, Mark Thompson wrote: >> On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote: >>> From: Fei Wang >>> >>> According to Table A.2 in spec. >>> >>> Signed-off-by: Fei Wang >>> --- >>> libavcodec/vaapi_encode_h265.c | 176 +++++++++++++++++++++++----- >>> ----- >>> 1 file changed, 123 insertions(+), 53 deletions(-) >>> >>> diff --git a/libavcodec/vaapi_encode_h265.c >>> b/libavcodec/vaapi_encode_h265.c >>> index 43755e2188..5ed317ce11 100644 >>> --- a/libavcodec/vaapi_encode_h265.c >>> +++ b/libavcodec/vaapi_encode_h265.c >>> @@ -258,6 +258,124 @@ 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; >>> + ptl->general_max_14bit_constraint_flag = 0; >>> + >>> + switch (ctx->va_profile) { >>> +#if VA_CHECK_VERSION(1, 2, 0) >>> + case VAProfileHEVCMain12: >>> + // Main 12 >>> + 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_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_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_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_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_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); >>> + } >>> + } >> >> Why is this an improvement over the current code which sets the >> constraint flags based on the actual content of the stream? >> >> Note the requirement in A.3.5 for decoder support: >> >> general_profile_idc is equal to 4 or >> general_profile_compatibility_flag[ 4 ] is equal to 1 for the >> bitstream, and >> the value of each constraint flag listed in Table A.2 is greater than >> or equal to the value(s) specified in the row >> of Table A.2 for the format range extensions profile for which the >> decoder conformance is evaluated. >> >> which says that decoders must be able to support streams which set >> additional constraint flags beyond those which are specified for a >> particular profile (in particular, an 8-bit 4:2:2 stream must be >> decodable by any decoder supporting either "Main 4:2:2 10" or "Main >> 4:4:4", so ideally it shouldn't be marked to require one of those in >> particular). > > That's a capability request for decoder. For encoder side, I'd prefer > to use the most typical values. The constraint flags in Table A.2/3/5 > are strictly checked to get rext profile in ff_h265_get_profile(), and > seems the constraint flags is the only way to distinguish profiles in > rext(all the rext profiles shares same general_profile_idc or > general_profile_compatibility_flag[ 4 ]). Hmm. I was missing that the VAAPI decoder has fixed matching - it only accepts things which exactly match the hull of each profile, not ones inside it which are compatible. That seems worth fixing. Do other decoder implementations do the same thing with strict matching? libavcodec's software decoder doesn't - the profile isn't really relevant to it. nvdec doesn't obviously do anything there either because it accepts all rext streams, though presumably some of them fail later. Thanks, - Mark _______________________________________________ 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".