1.aosp 会声明video所包含的profile和level,可以从aosp源码中查询到
下面列举了hevc所包含的profile和level
frameworks/av/media/codec2/core/include/C2Config.h
//Android S以后用的是codec2的架构,用的是codec2的一套参数,omx使用可以在OMX_VideoExt.h中查找
profile:
enum C2Config::profile_t : uint32_t {
// HEVC profiles
PROFILE_HEVC_MAIN = _C2_PL_HEVC_BASE, ///< HEVC (H.265) Main
PROFILE_HEVC_MAIN_10, ///< HEVC (H.265) Main 10
PROFILE_HEVC_MAIN_STILL, ///< HEVC (H.265) Main Still Picture
PROFILE_HEVC_MONO = _C2_PL_HEVC_BASE + 0x100, ///< HEVC (H.265) Monochrome
PROFILE_HEVC_MONO_12, ///< HEVC (H.265) Monochrome 12
PROFILE_HEVC_MONO_16, ///< HEVC (H.265) Monochrome 16
PROFILE_HEVC_MAIN_12, ///< HEVC (H.265) Main 12
PROFILE_HEVC_MAIN_422_10, ///< HEVC (H.265) Main 4:2:2 10
PROFILE_HEVC_MAIN_422_12, ///< HEVC (H.265) Main 4:2:2 12
PROFILE_HEVC_MAIN_444, ///< HEVC (H.265) Main 4:4:4
PROFILE_HEVC_MAIN_444_10, ///< HEVC (H.265) Main 4:4:4 10
PROFILE_HEVC_MAIN_444_12, ///< HEVC (H.265) Main 4:4:4 12
PROFILE_HEVC_MAIN_INTRA, ///< HEVC (H.265) Main Intra
PROFILE_HEVC_MAIN_10_INTRA, ///< HEVC (H.265) Main 10 Intra
PROFILE_HEVC_MAIN_12_INTRA, ///< HEVC (H.265) Main 12 Intra
PROFILE_HEVC_MAIN_422_10_INTRA, ///< HEVC (H.265) Main 4:2:2 10 Intra
PROFILE_HEVC_MAIN_422_12_INTRA, ///< HEVC (H.265) Main 4:2:2 12 Intra
PROFILE_HEVC_MAIN_444_INTRA, ///< HEVC (H.265) Main 4:4:4 Intra
PROFILE_HEVC_MAIN_444_10_INTRA, ///< HEVC (H.265) Main 4:4:4 10 Intra
PROFILE_HEVC_MAIN_444_12_INTRA, ///< HEVC (H.265) Main 4:4:4 12 Intra
PROFILE_HEVC_MAIN_444_16_INTRA, ///< HEVC (H.265) Main 4:4:4 16 Intra
PROFILE_HEVC_MAIN_444_STILL, ///< HEVC (H.265) Main 4:4:4 Still Picture
PROFILE_HEVC_MAIN_444_16_STILL, ///< HEVC (H.265) Main 4:4:4 16 Still Picture
PROFILE_HEVC_HIGH_444 = _C2_PL_HEVC_BASE + 0x200, ///< HEVC (H.265) High Throughput 4:4:4
PROFILE_HEVC_HIGH_444_10, ///< HEVC (H.265) High Throughput 4:4:4 10
PROFILE_HEVC_HIGH_444_14, ///< HEVC (H.265) High Throughput 4:4:4 14
PROFILE_HEVC_HIGH_444_16_INTRA, ///< HEVC (H.265) High Throughput 4:4:4 16 Intra
PROFILE_HEVC_SX_MAIN = _C2_PL_HEVC_BASE + 0x300, ///< HEVC (H.265) Screen-Extended Main
PROFILE_HEVC_SX_MAIN_10, ///< HEVC (H.265) Screen-Extended Main 10
}
Level:
enum C2Config::level_t : uint32_t {
// HEVC (H.265) tiers and levels
LEVEL_HEVC_MAIN_1 = _C2_PL_HEVC_BASE, ///< HEVC (H.265) Main Tier Level 1
LEVEL_HEVC_MAIN_2, ///< HEVC (H.265) Main Tier Level 2
LEVEL_HEVC_MAIN_2_1, ///< HEVC (H.265) Main Tier Level 2.1
LEVEL_HEVC_MAIN_3, ///< HEVC (H.265) Main Tier Level 3
LEVEL_HEVC_MAIN_3_1, ///< HEVC (H.265) Main Tier Level 3.1
LEVEL_HEVC_MAIN_4, ///< HEVC (H.265) Main Tier Level 4
LEVEL_HEVC_MAIN_4_1, ///< HEVC (H.265) Main Tier Level 4.1
LEVEL_HEVC_MAIN_5, ///< HEVC (H.265) Main Tier Level 5
LEVEL_HEVC_MAIN_5_1, ///< HEVC (H.265) Main Tier Level 5.1
LEVEL_HEVC_MAIN_5_2, ///< HEVC (H.265) Main Tier Level 5.2
LEVEL_HEVC_MAIN_6, ///< HEVC (H.265) Main Tier Level 6
LEVEL_HEVC_MAIN_6_1, ///< HEVC (H.265) Main Tier Level 6.1
LEVEL_HEVC_MAIN_6_2, ///< HEVC (H.265) Main Tier Level 6.2
LEVEL_HEVC_HIGH_4 = _C2_PL_HEVC_BASE + 0x100, ///< HEVC (H.265) High Tier Level 4
LEVEL_HEVC_HIGH_4_1, ///< HEVC (H.265) High Tier Level 4.1
LEVEL_HEVC_HIGH_5, ///< HEVC (H.265) High Tier Level 5
LEVEL_HEVC_HIGH_5_1, ///< HEVC (H.265) High Tier Level 5.1
LEVEL_HEVC_HIGH_5_2, ///< HEVC (H.265) High Tier Level 5.2
LEVEL_HEVC_HIGH_6, ///< HEVC (H.265) High Tier Level 6
LEVEL_HEVC_HIGH_6_1, ///< HEVC (H.265) High Tier Level 6.1
LEVEL_HEVC_HIGH_6_2, ///< HEVC (H.265) High Tier Level 6.2
}
2.上面列举的是编解码包含的profile和level的参数,相对于单个编解码起来说,他们有各自能够支持的profile和level(codec的能力).我们参考了一部android设备。从dumpsys media.player中我们可以获悉各个codec所能够支持的profile和level的范围
下面我们列举一下我们选用设备的hevc软解的数据
Decoder "c2.android.hevc.decoder" supports
aliases: [
"OMX.google.hevc.decoder" ]
attributes: 0x4: [
encoder: 0,
vendor: 0,
software-only: 1,
hw-accelerated: 0 ]
owner: "codec2::software"
rank: 512
profile/levels: [
1/524288 (Main/High 5.2),
4/524288 (MainStill/High 5.2) ] //hevc所支持的profile PROFILE_HEVC_MAIN
//PROFILE_HEVC_MAIN_STILL
//Level LEVEL_HEVC_HIGH_5_1
colors: [
0x7f420888 (YUV420Flexible),
0x13 (YUV420Planar),
0x15 (YUV420SemiPlanar),
0x14 (YUV420PackedPlanar),
0x27 (YUV420PackedSemiPlanar),
0x7f000789 (Surface) ]
details: AMessage(what = 0x00000000) = {
string alignment = "2x2"
string bitrate-range = "1-10000000"
string block-count-range = "1-196608"
string block-size = "8x8"
string blocks-per-second-range = "1-2000000"
int32_t feature-adaptive-playback = 0
string size-range = "2x2-4096x4096"
string measured-frame-rate-1280x720-range = "41-200"
string measured-frame-rate-1920x1080-range = "25-100"
string measured-frame-rate-352x288-range = "220-950"
string measured-frame-rate-640x360-range = "120-830"
string measured-frame-rate-720x480-range = "129-563"
}
3.如何设置codecprofile和level的能力,下面的例子只贴了hevc 软件解码的设置
frameworks/av/media/codec2/components/hevc/C2SoftHevcDec.cpp
class C2SoftHevcDec::IntfImpl : public SimpleInterface<void>::BaseParams {
addParameter(
DefineParam(mProfileLevel, C2_PARAMKEY_PROFILE_LEVEL)
.withDefault(new C2StreamProfileLevelInfo::input(0u,
C2Config::PROFILE_HEVC_MAIN, C2Config::LEVEL_HEVC_MAIN_5_1))
.withFields({
C2F(mProfileLevel, profile).oneOf({
C2Config::PROFILE_HEVC_MAIN,
C2Config::PROFILE_HEVC_MAIN_STILL}),
C2F(mProfileLevel, level).oneOf({
C2Config::LEVEL_HEVC_MAIN_1,
C2Config::LEVEL_HEVC_MAIN_2, C2Config::LEVEL_HEVC_MAIN_2_1,
C2Config::LEVEL_HEVC_MAIN_3, C2Config::LEVEL_HEVC_MAIN_3_1,
C2Config::LEVEL_HEVC_MAIN_4, C2Config::LEVEL_HEVC_MAIN_4_1,
C2Config::LEVEL_HEVC_MAIN_5, C2Config::LEVEL_HEVC_MAIN_5_1,
C2Config::LEVEL_HEVC_MAIN_5_2, C2Config::LEVEL_HEVC_HIGH_4,
C2Config::LEVEL_HEVC_HIGH_4_1, C2Config::LEVEL_HEVC_HIGH_5 ,
C2Config::LEVEL_HEVC_HIGH_5_1, C2Config::LEVEL_HEVC_HIGH_5_2
})
})
.withSetter(ProfileLevelSetter, mSize)
.build());
}