| 19 | namespace bmf_lite_demo { |
| 20 | |
| 21 | Algorithm::Algorithm(EGLDisplay eglDisplay, EGLSurface surface, |
| 22 | EGLContext eglContext, int algorithmType) |
| 23 | : eglDisplay_(eglDisplay), eglSurface_(surface), eglContext_(eglContext), |
| 24 | algorithmType_(algorithmType) { |
| 25 | algorithm_ = bmf_lite::AlgorithmFactory::createAlgorithmInterface(); |
| 26 | bmf_lite::Param init_param; |
| 27 | // init param |
| 28 | init_param.setInt("change_mode", |
| 29 | bmf_lite::ModsMode::CREATE_AND_PROCESS_MODE); |
| 30 | init_param.setString("instance_id", "i"); |
| 31 | init_param.setInt("algorithm_type", algorithmType_); |
| 32 | init_param.setInt("algorithm_version", 0); |
| 33 | init_param.setInt("backend", 3); |
| 34 | init_param.setInt("scale_mode", 0); |
| 35 | init_param.setInt("process_mode", 0); |
| 36 | init_param.setInt("max_width", 1920); |
| 37 | init_param.setInt("max_height", 1080); |
| 38 | init_param.setString("license_module_name", ""); |
| 39 | init_param.setString("program_cache_dir", ""); |
| 40 | init_param.setInt("sharp_levels", 0); // for super_resolution only |
| 41 | init_param.setString("weight_path", ""); // for super_resolution only |
| 42 | |
| 43 | int init_result = algorithm_->setParam(init_param); |
| 44 | if (init_result != 0) { |
| 45 | bmf_lite::AlgorithmFactory::releaseAlgorithmInterface(algorithm_); |
| 46 | algorithm_ = nullptr; |
| 47 | valid_ = false; |
| 48 | } |
| 49 | valid_ = true; |
| 50 | } |
| 51 | |
| 52 | int Algorithm::processVideoFrame(GLuint textureId, size_t width, |
| 53 | size_t height) { |