You need to enable JavaScript to run this app.
导航

画质超分

最近更新时间2022.02.25 17:16:51

首次发布时间2022.02.25 17:16:51

简介

超分,目前超分指在原来基础上宽和高同时扩张两倍。

技术规格
支持平台Android、iOS
支持分辨率目前需要分辨率小于720p
ios平台依赖需要ios 11及以上的版本, 支持iPhone7以上的设备
android平台依赖设备需要为高通处理器,且处理器需要高通660及以上
ios 支持输入格式PixelBuffer输入,支持yuv420p 和yuv420f, (未来支持metal texture)
android 支持输入格式纹理输入
检测速度32ms(测试处理器高通660 oppo r11 720p 输入)
C接口说明

详解接口文档, bef_ai_image_quality_enhancement_video_sr.h

1.创建超分句柄

/**
 * @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);

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle创建超分的句柄
dirchar*android 下为可读写的路径,保存初始化的内容


返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

2.设置输入的属性

/**
 *  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);

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle超分的句柄
widthint输入的宽
heightint输入的高

3.检测画质超分授权

/**
 * @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);

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle画质的句柄
licensePathconst char *授权文件字符串

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

4.检测画质超分授权

/**
 * process the input and get the resoult
 * @param handle
 * @param input input infomation of texture or pixelbuffer 
 *              Android的输入需要为oes 纹理, 需要传入纹理的宽高,纹理需要放在input->data.texture[0]
 *              ios 目前只支持yuv420p, 420f 的pixelbuffer输入,输出为对应格式pixelbuffer 无需手动释放, pixelbuffer 放在input->data.buffer 处
 * @param output output infomation of texture or pixelbuffer
 *              Android的输出为oes 纹理,返回纹理的宽和高,纹理结果放在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);

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle画质的句柄
inputef_ai_video_sr_input *授权文件字符串
outputbef_ai_video_sr_output *授权文件字符串

input input infomation of texture or pixelbuffer
Android的输入需要为oes 纹理, 需要传入纹理的宽高,纹理需要放在input->data.texture[0]
ios 目前只支持yuv420p, 420f 的pixelbuffer输入, pixelbuffer 放在input->data.buffer 处
output output infomation of texture or pixelbuffer
Android的输出为oes 纹理,返回纹理的宽和高,纹理结果放在output->data.texture[0]
ios 的输出为pixelbuffer, pixelbuffer 放在output->data.buffer 处,输出为对应格式pixelbuffer 无需手动释放,拿到buffer后需要先对buffer进行retain,防止内部的内存是对pixelbuffer 进行回收

返回值
成功返回 BEF_RESULT_SUC, 失败返回相应错误码, 具体请参考 bef_effect_ai_public_define.h

5.画质超分句柄的释放

/**
 * @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);

参数说明

参数名参数类型参数说明
handlebef_image_quality_enhancement_handle创建的画质句柄
Java 接口

1. 创建画质超分句柄

创建画质超分的句柄

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;
    }

参数说明

参数名参数类型参数说明
rwDirString可读写的路径
licensePathString授权文件路径

返回值

成功返回BEF_RESULT_SUC,否则返回对应的错误码

2. 创建进行超分处理

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;
    }

参数说明

参数名参数类型参数说明
srcTextureIdint源纹理
widthint输入纹理宽度
heightint输入纹理高度

返回值

成功返回超分的结果,否则返回空

3. 释放超分的资源

public void release() {
        if (mInited){
            nativeRelease();
        }
        mInited = false;
    }

FAQ

1.如果出现任何异常,请查看是否有以下类型日志

答:建议首先查看以下tag输出Error类型的日志:

bef_effect_ai 和SMASH_E_LOG 以及 EffectSDK

2. 如果没有结果,或者结果不正确

android 下面检测OpenGL环境是否正确,且输入纹理是否正确

ios,xcode查看pixelbuffer的返回结果是否正确