超分,目前超分指在原来基础上宽和高同时扩张两倍。
注意:iOS11以下机器不支持除插帧外画质相关的算法。
iOS端模型依赖:videovrsr.bundle
支持平台 | Android、iOS |
---|---|
支持分辨率 | 目前需要分辨率小于720p |
ios平台依赖 | 需要ios 11及以上的版本, 支持iPhone7以上的设备 |
android平台依赖 | 设备支持高通660及以上处理器,也支持 mail g51及以上处理器 |
ios 支持输入格式 | PixelBuffer输入,支持yuv420p 和yuv420f, (未来支持metal texture) |
android 支持输入格式 | 纹理输入 |
检测速度 | 32ms(测试处理器高通660 oppo r11 720p 输入) |
详解接口文档, bef_ai_image_quality_enhancement_video_sr.h
/** * @brief Create effect handle. * @param handle handle that will be created. * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h. */ BEF_SDK_API bef_effect_result_t bef_ai_image_quality_enhancement_video_sr_create(bef_image_quality_enhancement_handle* handle, const char* dir);
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 创建超分的句柄 |
dir | char* | android 下为可读写的路径,保存初始化的内容 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
/** * set the input property * @param handle * @param width Input width of the buffer or texture * @param height Input height of the buffer or texture * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h. */ BEF_SDK_API bef_effect_result_t bef_ai_image_quality_enhancement_video_sr_set_width_and_height(bef_image_quality_enhancement_handle handle, int width , int height);
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 超分的句柄 |
width | int | 输入的宽 |
height | int | 输入的高 |
/** * @param handle Created effect detect handle * 已创建的句柄 * @param license_path licese path under the dircetory * license 在文件系统中的绝对路径 * @param result If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h. * */ BEF_SDK_API bef_effect_result_t bef_ai_image_quality_enhancement_video_sr_check_license(bef_image_quality_enhancement_handle handle, const char* license_path);
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 画质的句柄 |
licensePath | const char * | 授权文件字符串 |
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
/** * process the input and get the resoult * @param handle * @param input input infomation of texture or pixelbuffer * Android的输入只支持texture2D纹理, 需要传入纹理的宽高,纹理需要放在input->data.texture[0] * ios 目前只支持yuv420p, 420f 的pixelbuffer输入,输出为对应格式pixelbuffer 无需手动释放, pixelbuffer 放在input->data.buffer 处 * @param output output infomation of texture or pixelbuffer * Android的输出只支持texture2D纹理,返回纹理的宽和高,纹理结果放在output->data.texture[0] * ios 的输出为pixelbuffer, pixelbuffer 放在output->data.buffer 处 * @return If succeed return BEF_EFFECT_RESULT_SUC, other value please see bef_effect_ai_public_define.h. */ BEF_SDK_API bef_effect_result_t bef_ai_image_quality_enhancement_video_sr_process(bef_image_quality_enhancement_handle handle, const bef_ai_video_sr_input* input, bef_ai_video_sr_output *output);
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 画质的句柄 |
input | ef_ai_video_sr_input * | 授权文件字符串 |
output | bef_ai_video_sr_output * | 授权文件字符串 |
input input information of texture or pixelbuffer
Android的输入只支持texture2D纹理, 需要传入纹理的宽高,纹理需要放在input->data.texture[0]
ios 目前只支持yuv420p, 420f 的pixelbuffer输入, pixelbuffer 放在input->data.buffer 处
output output information of texture or pixelbuffer
Android的输出只支持texture2D纹理,返回纹理的宽和高,纹理结果放在output->data.texture[0]
ios 的输出为pixelbuffer, pixelbuffer 放在output->data.buffer 处,输出为对应格式pixelbuffer 无需手动释放,拿到buffer后需要先对buffer进行retain,防止内部的内存是对pixelbuffer 进行回收
返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h
/** * @param handle handle that will destroy */ BEF_SDK_API bef_effect_result_t bef_ai_image_quality_enhancement_vidoe_sr_destory(bef_image_quality_enhancement_handle handle);
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
handle | bef_image_quality_enhancement_handle | 创建的画质句柄 |
typedef struct bef_ai_video_sr_init_config { const char* model_path; // 模型文件的路径,详细说明请查看附录算法模型的说明部分 int model_data_length; // 目前不需要传入 const char* metal_path; // 目前不需要传入 bool enable_mem_pool; // 是否使用内存池,短视频场景下使用 bef_ai_lens_data_type input_type; // 输入目前只有pixelbuffer格式 bef_ai_lens_data_type output_type; // 输出为pixelbuffer和 metal texture两种 float float_thresh; // 暂时不用设置 int srType; // 1.5x 用15表示,2.0x 用 20表示 }bef_ai_video_sr_init_config;
创建画质超分的句柄
public int init(String rwDir, String licensePath){ int ret = nativeCreate(rwDir, licensePath); if (ret != BytedEffectConstants.BytedResultCode.BEF_RESULT_SUC){ mInited = false; return ret; } mInited = true; return ret; }
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
rwDir | String | 可读写的路径 |
licensePath | String | 授权文件路径 |
返回值
成功返回BEF_RESULT_SUC,否则返回对应的错误码
public BefVideoSRInfo process(int srcTextureId ,int width, int height){ if (!mInited){ return null; } BefVideoSRInfo srInfo = new BefVideoSRInfo(); int ret = nativeProcess(srcTextureId, width, height, srInfo); if (ret != BytedEffectConstants.BytedResultCode.BEF_RESULT_SUC) { Log.e(BytedEffectConstants.TAG, "nativeVideoSrProcess " + ret); return null; } return srInfo; }
参数说明
参数名 | 参数类型 | 参数说明 |
---|---|---|
srcTextureId | int | 源纹理 |
width | int | 输入纹理宽度 |
height | int | 输入纹理高度 |
返回值
成功返回超分的结果,否则返回空
public void release() { if (mInited){ nativeRelease(); } mInited = false; }
public static enum LensVideoAlgType { SR_R_TYPE(0), // 2x超分 SR_A_TYPE(1), SR_G_TYPE(2), SR_N_TYPE(3), SR_R15_TYPE(4), // 1.5x超分 SR_U_UNKNOW(5);
安卓与iOS因为实现方式不同的原因,安卓无需使用算法模型,iOS必须使用算法模型
Sample写法 超分算法依赖了videovrsr.bundle文件,需要把bundle文件放在主工程下,从而拷贝到安装app的根目录中。 直接用sample中的core文件来initTask,并且不做任何其他修改的话,就需要在mainBundle下默认找模型文件,无需传入路径,但必须放置在这里。 如图:
C接口
如果想要自己传入路径,除去使用sample中的core文件外,可以修改模型路径参数。 440及以上版本的超分,可以通过修改BEVideoSRTask.m
文件中bef_ai_video_sr_init_config.model_path
来传路径参数。
如图:
答:建议首先查看以下tag输出Error类型的日志:
bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK
答:android 下面检测OpenGL环境是否正确,且输入纹理是否正确 ios,xcode查看pixelbuffer的返回结果是否正确