xref: /aosp_15_r20/external/webrtc/api/video_codecs/av1_profile.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #ifndef API_VIDEO_CODECS_AV1_PROFILE_H_
12*d9f75844SAndroid Build Coastguard Worker #define API_VIDEO_CODECS_AV1_PROFILE_H_
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #include <string>
15*d9f75844SAndroid Build Coastguard Worker 
16*d9f75844SAndroid Build Coastguard Worker #include "absl/strings/string_view.h"
17*d9f75844SAndroid Build Coastguard Worker #include "absl/types/optional.h"
18*d9f75844SAndroid Build Coastguard Worker #include "api/video_codecs/sdp_video_format.h"
19*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/system/rtc_export.h"
20*d9f75844SAndroid Build Coastguard Worker 
21*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
22*d9f75844SAndroid Build Coastguard Worker 
23*d9f75844SAndroid Build Coastguard Worker // Profile information for AV1 video.
24*d9f75844SAndroid Build Coastguard Worker extern RTC_EXPORT const char kAV1FmtpProfile[];
25*d9f75844SAndroid Build Coastguard Worker 
26*d9f75844SAndroid Build Coastguard Worker // Profiles can be found at:
27*d9f75844SAndroid Build Coastguard Worker // https://aomedia.org/av1/specification/annex-a/#profiles
28*d9f75844SAndroid Build Coastguard Worker // The enum values match the number specified in the SDP.
29*d9f75844SAndroid Build Coastguard Worker enum class AV1Profile {
30*d9f75844SAndroid Build Coastguard Worker   kProfile0 = 0,
31*d9f75844SAndroid Build Coastguard Worker   kProfile1 = 1,
32*d9f75844SAndroid Build Coastguard Worker   kProfile2 = 2,
33*d9f75844SAndroid Build Coastguard Worker };
34*d9f75844SAndroid Build Coastguard Worker 
35*d9f75844SAndroid Build Coastguard Worker // Helper function which converts an AV1Profile to std::string. Returns "0" if
36*d9f75844SAndroid Build Coastguard Worker // an unknown value is passed in.
37*d9f75844SAndroid Build Coastguard Worker RTC_EXPORT absl::string_view AV1ProfileToString(AV1Profile profile);
38*d9f75844SAndroid Build Coastguard Worker 
39*d9f75844SAndroid Build Coastguard Worker // Helper function which converts a std::string to AV1Profile. Returns null if
40*d9f75844SAndroid Build Coastguard Worker // |profile| is not a valid profile string.
41*d9f75844SAndroid Build Coastguard Worker absl::optional<AV1Profile> StringToAV1Profile(absl::string_view profile);
42*d9f75844SAndroid Build Coastguard Worker 
43*d9f75844SAndroid Build Coastguard Worker // Parses an SDP key-value map of format parameters to retrive an AV1 profile.
44*d9f75844SAndroid Build Coastguard Worker // Returns an AV1Profile if one has been specified, `kProfile0` if no profile is
45*d9f75844SAndroid Build Coastguard Worker // specified and an empty value if the profile key is present but contains an
46*d9f75844SAndroid Build Coastguard Worker // invalid value.
47*d9f75844SAndroid Build Coastguard Worker RTC_EXPORT absl::optional<AV1Profile> ParseSdpForAV1Profile(
48*d9f75844SAndroid Build Coastguard Worker     const SdpVideoFormat::Parameters& params);
49*d9f75844SAndroid Build Coastguard Worker 
50*d9f75844SAndroid Build Coastguard Worker // Returns true if the parameters have the same AV1 profile or neither contains
51*d9f75844SAndroid Build Coastguard Worker // an AV1 profile, otherwise false.
52*d9f75844SAndroid Build Coastguard Worker bool AV1IsSameProfile(const SdpVideoFormat::Parameters& params1,
53*d9f75844SAndroid Build Coastguard Worker                       const SdpVideoFormat::Parameters& params2);
54*d9f75844SAndroid Build Coastguard Worker 
55*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
56*d9f75844SAndroid Build Coastguard Worker 
57*d9f75844SAndroid Build Coastguard Worker #endif  // API_VIDEO_CODECS_AV1_PROFILE_H_
58