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 DD1474A9A9 for ; Mon, 6 May 2024 20:12:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17CC768D69B; Mon, 6 May 2024 23:12:51 +0300 (EEST) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9D9968D625 for ; Mon, 6 May 2024 23:12:44 +0300 (EEST) Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-34de61b7ca4so1559934f8f.2 for ; Mon, 06 May 2024 13:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1715026364; x=1715631164; 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=b7wcT56Gc02jGJj/PPokjc85eDFyc5ukGxp8UV7A308=; b=NEIaKQlYWmQOs/uT1BvrI+gIimGJQvzE9zD4WbAwcdplEaElMzjnJjoCeMRaqxYjjF Bfjkd7g1DIzklUJUl9AhyB/cixW8OnNgdqnWbKJte5RqoLJOVb6zX+XesYFnaRGZiy8v s+AeDQTU+RyI9CH2qV+sjdopRDC0PyiP9CVmqzw5baN/pWcH+wGpPQKgpzGZqA+bskPf P2cawDI6Qma8wi5rIwo9G68wM3w7IC/vcF2TZJ3924DPo5o/A344rg0lvgKdL0923Twe rcLGJ5jYdPvL0DB58tmZTlPxGGoxaQAU+4Mi9d+ywIakxen0UrANs/KGffNAgaVBTlCc i5EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715026364; x=1715631164; 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=b7wcT56Gc02jGJj/PPokjc85eDFyc5ukGxp8UV7A308=; b=pbFyRtInNE5q+GjxHWYFgwZW8YIWVDxyuhrS4yianUsbGzEKr+iqBveaCSzFk2epiW IQNyedkn2HQGZv9DIkoQgaNZTyQUPVdNRSt27tDVX9ewoKhEY2AoxcDFyHpmFqJoB8eh T3QAGxVehuA6hdV8jgmThItDkzbdqXg04RLke5jGStJGAioAEhKLSBvah9EhZYrCLYFs ErdxmR6vTWhvExlv0N/+xEVIr77nKs6HoRMoEu34G1lie40/vW2Q4BUZQK4ws0T7QUeS 7tC16l42WPVkWjG7/I2KEFaYdNJUwlxxHmEnVo/l3C/tvW7tLDBC+OcQYyc6GUBsU9Oh O3+A== X-Gm-Message-State: AOJu0YxVeOQJYHwOUDoKEljvSQE/jpm1foQPACH+67giyMyk84ho+mvu 9G3jy1KHzRTw5vHarRmr44LhTzfhpSopityqbS2r4/OxJh6OaGKfV1cZZVJzSA/sDGQCS33cEoJ a X-Google-Smtp-Source: AGHT+IGCHhSMW8J2wTUIKYHOJ+eAwVCvm7gt/YVGtRZg0dWJD8kF0GRXaPjF9+IHxDTg+wigkV94cg== X-Received: by 2002:a5d:6b8e:0:b0:34c:6299:bafc with SMTP id n14-20020a5d6b8e000000b0034c6299bafcmr9906610wrx.38.1715026364133; Mon, 06 May 2024 13:12:44 -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 s2-20020a5d4242000000b003472489d26fsm11329141wrr.19.2024.05.06.13.12.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 06 May 2024 13:12:43 -0700 (PDT) Message-ID: Date: Mon, 6 May 2024 21:13:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240506184726.826159-1-sw@jkqxz.net> From: Mark Thompson In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v2 1/3] lavc/h265_profile_level: Expand profile compatibility checking 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-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: On 06/05/2024 20:56, Andreas Rheinhardt wrote: > Mark Thompson: >> Replace existing get_profile() with find_profile(), which finds the >> lowest compatible profile rather than requiring an exact match. >> --- >> Series changes since v1: >> * Added H265_PROFILE_INVALID with value zero because it simplifies some code (and the values don't matter). > > What code is simplified by using zero (instead of -1)? I only see that > it leads to the addition of an unnecessary entry to h265_profiles. The large number of empty entries in profile_table in the test work by being zero-initialised. Filling them with -1 would not be fun. (I originally put that table (and the bprint function) in h265_profile_level.c, but when no library caller was using it I moved it to the test.) >> * Fixed the h265-levels test. >> * Added a new h265-profiles test which tests the profile compatibility checking. >> * Fixed missing VAAPI profiles. >> >> >> libavcodec/h265_profile_level.c | 78 +++++++++++++++++++++------------ >> libavcodec/h265_profile_level.h | 71 +++++++++++++++++++++++++++++- >> libavcodec/tests/h265_levels.c | 2 +- >> libavcodec/vaapi_hevc.c | 2 +- >> libavcodec/vdpau_hevc.c | 2 +- >> 5 files changed, 123 insertions(+), 32 deletions(-) >> >> diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c >> index 7ff9681f65..2e4a1c88bf 100644 >> --- a/libavcodec/h265_profile_level.c >> +++ b/libavcodec/h265_profile_level.c >> @@ -40,6 +40,7 @@ static const H265LevelDescriptor h265_levels[] = { >> }; >> >> static const H265ProfileDescriptor h265_profiles[] = { >> + { "Invalid" }, >> // profile_idc 8bit one-picture >> // HT-profile | 422chroma | lower-bit-rate >> // | 14bit | | 420chroma | | CpbVclFactor MinCrScaleFactor >> @@ -119,41 +120,62 @@ static const H265ProfileDescriptor h265_profiles[] = { >> 5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 }, >> }; >> >> +_Static_assert(H265_PROFILE_COUNT == FF_ARRAY_ELEMS(h265_profiles), >> + "Incorrect H.265 profiles table."); >> >> -const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel *ptl) >> + >> +const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl, >> + int profile) > > Why don't you add a tag to this enum and pass a proper enum here? No reason. I can add an explicit type if you prefer that? >> { >> - int i; >> + const H265ProfileDescriptor *desc; >> + >> + av_assert0(profile > H265_PROFILE_INVALID && >> + profile < H265_PROFILE_COUNT); >> >> if (ptl->general_profile_space) >> - return NULL; >> + return 0; >> >> - for (i = 0; i < FF_ARRAY_ELEMS(h265_profiles); i++) { >> - const H265ProfileDescriptor *profile = &h265_profiles[i]; >> + desc = &h265_profiles[profile]; >> >> - if (ptl->general_profile_idc && >> - ptl->general_profile_idc != profile->profile_idc) >> - continue; >> - if (!ptl->general_profile_compatibility_flag[profile->profile_idc]) >> - continue; >> + if (ptl->general_profile_idc && >> + ptl->general_profile_idc != desc->profile_idc) >> + return 0; >> + if (!ptl->general_profile_compatibility_flag[desc->profile_idc]) >> + return 0; >> >> -#define check_flag(name) \ >> - if (profile->name < 2) { \ >> - if (profile->name != ptl->general_ ## name ## _constraint_flag) \ >> - continue; \ >> - } >> - check_flag(max_14bit); >> - check_flag(max_12bit); >> - check_flag(max_10bit); >> - check_flag(max_8bit); >> - check_flag(max_422chroma); >> - check_flag(max_420chroma); >> - check_flag(max_monochrome); >> - check_flag(intra); >> - check_flag(one_picture_only); >> - check_flag(lower_bit_rate); >> +#define check_flag(flag) \ >> + if (desc->flag < 2 && \ >> + desc->flag > ptl->general_ ## flag ## _constraint_flag) \ >> + return 0; >> + check_flag(max_14bit); >> + check_flag(max_12bit); >> + check_flag(max_10bit); >> + check_flag(max_8bit); >> + check_flag(max_422chroma); >> + check_flag(max_420chroma); >> + check_flag(max_monochrome); >> + check_flag(intra); >> + check_flag(one_picture_only); >> + check_flag(lower_bit_rate); >> #undef check_flag >> >> - return profile; >> + return 1; >> +} >> + >> ... 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".