void AnalyzerCallback::x3a_calculation_failed (X3aAnalyzer *analyzer, int64_t timestamp, const char *msg) { XCAM_UNUSED (analyzer); XCAM_LOG_WARNING ( "Calculate 3a result failed, ts(" XCAM_TIMESTAMP_FORMAT "), msg:%s", XCAM_TIMESTAMP_ARGS (timestamp), XCAM_STR (msg)); }
void X3aAnalyzer::notify_calculation_failed (AnalyzerHandler *handler, int64_t timestamp, const char *msg) { XCAM_UNUSED (handler); if (_callback) _callback->x3a_calculation_failed (this, timestamp, msg); XCAM_LOG_DEBUG ( "calculation failed on ts:" XCAM_TIMESTAMP_FORMAT ", reason:%s", XCAM_TIMESTAMP_ARGS (timestamp), XCAM_STR (msg)); }
void AnalyzerCallback::x3a_calculation_done (X3aAnalyzer *analyzer, X3aResultList &results) { XCAM_UNUSED (analyzer); for (X3aResultList::iterator i_res = results.begin(); i_res != results.end(); ++i_res) { SmartPtr<X3aResult> res = *i_res; if (res.ptr() == NULL) continue; XCAM_LOG_DEBUG ( "calculated 3a result(type:%d, timestamp:" XCAM_TIMESTAMP_FORMAT ")", res->get_type (), XCAM_TIMESTAMP_ARGS (res->get_timestamp ())); } }
XCamReturn CLKernel::build_kernel (const XCamKernelInfo& info, const char* options) { KernelMap::iterator i_kernel; SmartPtr<CLKernel> single_kernel; char key_str[1024]; uint8_t body_key[8]; std::string key; XCamReturn ret = XCAM_RETURN_NO_ERROR; XCAM_FAIL_RETURN (ERROR, info.kernel_name, XCAM_RETURN_ERROR_PARAM, "build kernel failed since kernel name null"); xcam_mem_clear (body_key); get_string_key_id (info.kernel_body, info.kernel_body_len, body_key); snprintf ( key_str, sizeof(key_str), "%s#%02x%02x%02x%02x%02x%02x%02x%02x#%s", info.kernel_name, body_key[0], body_key[1], body_key[2], body_key[3], body_key[4], body_key[5], body_key[6], body_key[7], XCAM_STR(options)); key = key_str; char temp_filename[XCAM_MAX_STR_SIZE] = {0}; char cache_filename[XCAM_MAX_STR_SIZE] = {0}; FileHandle temp_file; FileHandle cache_file; size_t read_cache_size = 0; size_t write_cache_size = 0; uint8_t *kernel_cache = NULL; bool load_cache = false; struct timeval ts; std::string cache_path = _kernel_cache_path; const char *env = std::getenv ("XCAM_CL_KERNEL_CACHE_PATH"); if (env) cache_path.assign (env, strlen (env)); snprintf ( cache_filename, XCAM_MAX_STR_SIZE - 1, "%s/%s", cache_path.c_str (), key_str); { SmartLock locker (_kernel_map_mutex); i_kernel = _kernel_map.find (key); if (i_kernel == _kernel_map.end ()) { SmartPtr<CLContext> context = get_context (); single_kernel = new CLKernel (context, info.kernel_name); XCAM_ASSERT (single_kernel.ptr ()); if (access (cache_path.c_str (), F_OK) == -1) { mkdir (cache_path.c_str (), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); } ret = cache_file.open (cache_filename, "r"); if (ret == XCAM_RETURN_NO_ERROR) { cache_file.get_file_size (read_cache_size); if (read_cache_size > 0) { kernel_cache = (uint8_t*) xcam_malloc0 (sizeof (uint8_t) * (read_cache_size + 1)); if (NULL != kernel_cache) { cache_file.read_file (kernel_cache, read_cache_size); cache_file.close (); ret = single_kernel->load_from_binary (kernel_cache, read_cache_size); xcam_free (kernel_cache); kernel_cache = NULL; XCAM_FAIL_RETURN ( ERROR, ret == XCAM_RETURN_NO_ERROR, ret, "build kernel(%s) from binary failed", key_str); load_cache = true; } } } else { XCAM_LOG_DEBUG ("open kernel cache file to read failed ret(%d)", ret); } if (load_cache == false) { ret = single_kernel->load_from_source (info.kernel_body, strlen (info.kernel_body), &kernel_cache, &write_cache_size, options); XCAM_FAIL_RETURN ( ERROR, ret == XCAM_RETURN_NO_ERROR, ret, "build kernel(%s) from source failed", key_str); } _kernel_map.insert (std::make_pair (key, single_kernel)); //_kernel_map[key] = single_kernel; } else { single_kernel = i_kernel->second; } } if (load_cache == false && NULL != kernel_cache) { gettimeofday (&ts, NULL); snprintf ( temp_filename, XCAM_MAX_STR_SIZE - 1, "%s." XCAM_TIMESTAMP_FORMAT, cache_filename, XCAM_TIMESTAMP_ARGS (XCAM_TIMEVAL_2_USEC (ts))); ret = temp_file.open (temp_filename, "wb"); if (ret == XCAM_RETURN_NO_ERROR) { ret = temp_file.write_file (kernel_cache, write_cache_size); temp_file.close (); if (ret == XCAM_RETURN_NO_ERROR && write_cache_size > 0) { rename (temp_filename, cache_filename); } else { remove (temp_filename); } } else { XCAM_LOG_ERROR ("open kernel cache file to write failed ret(%d)", ret); } xcam_free (kernel_cache); kernel_cache = NULL; } XCAM_FAIL_RETURN ( ERROR, (single_kernel.ptr () && single_kernel->is_valid ()), XCAM_RETURN_ERROR_UNKNOWN, "build kernel(%s) failed, unknown error", key_str); ret = this->clone (single_kernel); XCAM_FAIL_RETURN ( ERROR, ret == XCAM_RETURN_NO_ERROR, ret, "load kernel(%s) from kernel failed", key_str); return ret; }