因为考虑到一些异常场景,您在使用时需要做一些场景限定:
HiVideoKitDisplaySdk mHiVideoKitDisplaySdk = new HiVideoKitDisplaySdk(this);
boolean isSupport = mHiVideoKitDisplaySdk.getSupported();
若返回false,则表示当前用户的手机不支持电影级调色特性(EMUI版本低于11.0/手机硬件不支持),请直接终止流程。
在使用HiVideoKitDisplaySdk调用滤镜效果之前,需要先查询当前设备中预置的电影级调色引擎APK(以下简称Engine)是否与SDK版本兼容。
返回true为完全兼容,返回false为手机设备预置的Engine的版本过低,会导致SDK中的新增特性无法使用,可提示用户更新Engine版本(Engine会在华为应用市场上架,可跳转到应用市场对应链接),或直接终止流程。
boolean ret = mHiVideoKitDisplaySdk.checkHiVideoKitStatus();
String kitEngineVersion = mHiVideoKitDisplaySdk.getKitEngineVersion(); String kitSdkVersion = mHiVideoKitDisplaySdk.getKitSdkversion();
对于未预置Engine的手机,Engine版本号为空。
返回的版本号格式为“a.b.c”,对应的版本修改描述为:
例如:
List<String> filters = new ArrayList<>(); filters = mHiVideoKitDisplaySdk.getEffectList();
如果filters不为空,其中包含的预设滤镜代号与中文名称的对应关系为:
滤镜代号 |
中文名称 |
|---|---|
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_OR |
默认 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_A1 |
阳光 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_A2 |
清凉 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_A3 |
暖意 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_B1 |
动人 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_B2 |
焦糖 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_B3 |
复古 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_F1 |
青橙 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_F2 |
琥珀 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_F3 |
黑白 |
HiVideoKitDisplaySdk.ACTION_FILM_COLOR_FILTER_O1 |
色彩还原 |
int filterRangeMax = mHiVideoKitDisplaySdk.getEffectRangeMax();
int applyFilterNo = 0; // 拿到的filters滤镜的index int level = 90; // 应用滤镜强度 int ret = mHiVideoKitDisplaySdk.setDefaultEffect(filters.get(applyFilterNo), level);
int[] gmpLutHigh = {…}; // 17 * 17 * 17的数组
int[] gmpLutLow = {…}; // 17 * 17 * 17的数组
int ret = mHiVideoKitDisplaySdk.set3DLutEffect(gmpLutHigh, gmpLutLow);
每一套3D-LUT配置参数对应一种调色滤镜。一套3D- LUT由17x17x17个(RGB)节点数据组成。使用gmpLutHigh和gmpLutLow共同拼接一套3D-lut输入。其中,一个节点数据的RGB对应方式为:
R: gmpLutHigh[i] 的 0~3 bit+ gmpLutLow[i] 的 24~31bit
G: gmpLutLow[i] 的 12~23 bit
B: gmpLutLow[i] 的 0~11 bit
例如:
输入:RGB f35 f12 e56
节点数据i对应的RGB为:
int gmpLutHigh[i] = 0xf; // 0000 0000 0000 0000 0000 0000 0000 1111 int gmpLutLow[i] = 0x35f12e56; // 0011 0101 1111 0001 0010 1110 0101 0110
R: 1111 0011 0101
G: 1111 0001 0010
B: 1110 0101 0110
传递3D-LUT表给SDK接口时,3D-LUT表为4913(17*17*17)长度的数组,其中存放的每个元素为36bit的整型,其排列格式如下:
Index |
Item |
Default Value |
|---|---|---|
0 |
R0G0B0 |
0x000000000 |
1 |
R0G0B1 |
0x000000100 |
2 |
R0G0B2 |
0x000000200 |
3 |
R0G0B3 |
0x000000300 |
4 |
R0G0B4 |
0x000000400 |
5 |
R0G0B5 |
0x000000500 |
6 |
R0G0B6 |
0x000000600 |
7 |
R0G0B7 |
0x000000700 |
8 |
R0G0B8 |
0x000000800 |
9 |
R0G0B9 |
0x000000900 |
10 |
R0G0B10 |
0x000000a00 |
11 |
R0G0B11 |
0x000000b00 |
12 |
R0G0B12 |
0x000000c00 |
13 |
R0G0B13 |
0x000000d00 |
14 |
R0G0B14 |
0x000000e00 |
15 |
R0G0B15 |
0x000000f00 |
16 |
R0G0B16 |
0x000000fff |
17 |
R0G1B0 |
0x000100000 |
18 |
R0G1B1 |
0x000100100 |
19 |
R0G1B2 |
0x000100200 |
… |
… |
… |
32 |
R0G1B15 |
0x000100f00 |
33 |
R0G1B16 |
0x000100fff |
34 |
R0G2B0 |
0x000200000 |
35 |
R0G2B1 |
0x000200100 |
36 |
R0G2B2 |
0x000200200 |
… |
… |
… |
49 |
R0G2B15 |
0x000200f00 |
50 |
R0G2B16 |
0x000200fff |
… |
… |
… |
271 |
R0G15B16 |
0x000f00fff |
… |
… |
… |
288 |
R0G16B16 |
0x000ffffff |
289 |
R1G0B0 |
0x100000000 |
290 |
R1G0B1 |
0x100000100 |
291 |
R1G0B2 |
0x100000200 |
… |
… |
… |
577 |
R1G16B16 |
0x100ffffff |
578 |
R2G0B0 |
0x200000000 |
579 |
R2G0B1 |
0x200000100 |
580 |
R2G0B2 |
0x200000200 |
… |
… |
… |
4912 |
R16G16B16 |
0xfffffffff |