Exemplo n.º 1
0
bool
CommonHandler::set_temporal_noise_reduction_level (double level)
{
    XCAM_FAIL_RETURN (
        ERROR,
        level >= -1.0 && level < 1.0,
        false,
        "set TNR levlel(%.03f) out of range[-1.0, 1.0]", level);

    AnalyzerHandler::HanlderLock lock(this);
    _params.tnr_level = level;

    XCAM_LOG_DEBUG ("common 3A set TNR level:%.03f", level);
    return true;
}
Exemplo n.º 2
0
bool
AwbHandler::set_speed (double speed)
{
    XCAM_FAIL_RETURN (
        ERROR,
        (0.0 < speed) && (speed <= 1.0),
        false,
        "awb speed(%f) is out of range, suggest (0.0, 1.0]", speed);

    AnalyzerHandler::HanlderLock lock(this);
    _params.speed = speed;

    XCAM_LOG_DEBUG ("awb set speed [%f]", speed);
    return true;
}
Exemplo n.º 3
0
void
CLContext::context_pfn_notify (
    const char* erro_info,
    const void *private_info,
    size_t cb,
    void *user_data
)
{
    CLContext *context = (CLContext*) user_data;
    XCAM_UNUSED (context);
    XCAM_UNUSED (erro_info);
    XCAM_UNUSED (private_info);
    XCAM_UNUSED (cb);
    XCAM_LOG_DEBUG ("cl context pfn error:%s", XCAM_STR (erro_info));
}
Exemplo n.º 4
0
bool
CommonHandler::set_manual_brightness (double level)
{
    XCAM_FAIL_RETURN (
        ERROR,
        level >= -1.0 && level < 1.0,
        false,
        "set brightness levlel(%.03f) out of range[-1.0, 1.0]", level);

    AnalyzerHandler::HanlderLock lock(this);
    _params.brightness = level;

    XCAM_LOG_DEBUG ("common 3A set brightness level:%.03f", level);
    return true;
}
Exemplo n.º 5
0
XCamReturn
PollThread::poll_buffer_loop ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    int poll_ret = 0;
    SmartPtr<V4l2Buffer> buf;

    poll_ret = _capture_dev->poll_event (PollThread::default_capture_event_timeout);

    if (poll_ret < 0) {
        XCAM_LOG_DEBUG ("poll buffer event got error but continue");
        ::usleep (100000); // 100ms
        return XCAM_RETURN_ERROR_TIMEOUT;
    }

    /* timeout */
    if (poll_ret == 0) {
        XCAM_LOG_DEBUG ("poll buffer timeout and continue");
        return XCAM_RETURN_ERROR_TIMEOUT;
    }

    ret = _capture_dev->dequeue_buffer (buf);
    if (ret != XCAM_RETURN_NO_ERROR) {
        XCAM_LOG_WARNING ("capture buffer failed");
        return ret;
    }
    XCAM_ASSERT (buf.ptr());
    XCAM_ASSERT (_poll_callback);

    SmartPtr<V4l2BufferProxy> buf_proxy = new V4l2BufferProxy (buf, _capture_dev);

    if (_poll_callback)
        return _poll_callback->poll_buffer_ready (buf_proxy);

    return ret;
}
Exemplo n.º 6
0
CL3aImageProcessor::CL3aImageProcessor ()
    : CLImageProcessor ("CL3aImageProcessor")
    , _output_fourcc (V4L2_PIX_FMT_NV12)
    , _out_smaple_type (OutSampleYuv)
    , _pipeline_profile (BasicPipelineProfile)
    , _capture_stage (TonemappingStage)
    , _hdr_mode (0)
    , _tnr_mode (0)
    , _enable_gamma (true)
    , _enable_tonemapping (false)
    , _enable_macc (true)
    , _enable_dpc (false)
    , _snr_mode (0)
{
    XCAM_LOG_DEBUG ("CL3aImageProcessor constructed");
}
Exemplo n.º 7
0
bool
AwbHandler::set_color_temperature_range (uint32_t cct_min, uint32_t cct_max)
{
    XCAM_FAIL_RETURN (
        ERROR,
        (cct_min <= cct_max),
        false,
        "awb set wrong cct(%u, %u) parameters", cct_min, cct_max);

    AnalyzerHandler::HanlderLock lock(this);
    _params.cct_min = cct_min;
    _params.cct_max = cct_max;

    XCAM_LOG_DEBUG ("awb set cct range [%u, %u]", cct_min, cct_max);
    return true;
}
Exemplo n.º 8
0
XCamReturn
V4l2Device::queue_buffer (SmartPtr<V4l2Buffer> &buf)
{
    XCAM_ASSERT (buf.ptr());
    buf->reset ();

    struct v4l2_buffer v4l2_buf = buf->get_buf ();
    XCAM_ASSERT (v4l2_buf.index < _buf_count);

    XCAM_LOG_DEBUG ("device(%s) queue buffer index:%d", XCAM_STR (_name), v4l2_buf.index);
    if (io_control (VIDIOC_QBUF, &v4l2_buf) < 0) {
        XCAM_LOG_ERROR("fail to enqueue buffer index:%d.", v4l2_buf.index);
        return XCAM_RETURN_ERROR_IOCTL;
    }
    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 9
0
XCamReturn
PipeManager::stop ()
{
    _is_running = false;

    if (_smart_analyzer.ptr ()) {
        _smart_analyzer->stop ();
        _smart_analyzer->deinit ();
    }

    if (_processor_center.ptr ())
        _processor_center->stop ();

    XCAM_LOG_DEBUG ("pipe manager stopped");
    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 10
0
XCamReturn
VKDevice::wait_for_fence (VkFence fence, uint64_t timeout)
{
    XCAM_ASSERT (XCAM_IS_VALID_VK_ID (_dev_id));
    XCAM_ASSERT (XCAM_IS_VALID_VK_ID (fence));

    VkResult ret = vkWaitForFences (_dev_id, 1,  &fence, VK_TRUE, timeout);
    if (ret == VK_TIMEOUT) {
        XCAM_LOG_DEBUG ("VKDevice wait for fence timeout");
        return XCAM_RETURN_ERROR_TIMEOUT;
    }

    XCAM_FAIL_RETURN (
        ERROR, ret == VK_SUCCESS,
        XCAM_RETURN_ERROR_VULKAN, "VKDevice wait for fence failed.");
    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 11
0
bool
AwbHandler::set_manual_gain (double gr, double r, double b, double gb)
{
    XCAM_FAIL_RETURN (
        ERROR,
        gr >= 0.0 && r >= 0.0 && b >= 0.0 && gb >= 0.0,
        false,
        "awb manual gain value must >= 0.0");

    AnalyzerHandler::HanlderLock lock(this);
    _params.gr_gain = gr;
    _params.r_gain = r;
    _params.b_gain = b;
    _params.gb_gain = gb;
    XCAM_LOG_DEBUG ("awb set manual gain value(gr:%.03f, r:%.03f, b:%.03f, gb:%.03f)", gr, r, b, gb);
    return true;
}
Exemplo n.º 12
0
bool
CLContext::insert_kernel (SmartPtr<CLKernel> &kernel)
{
    std::string kernel_name = kernel->get_kernel_name ();
    CLKernelMap::iterator i_pos = _kernel_map.lower_bound (kernel_name);

    XCAM_ASSERT (!kernel_name.empty());
    if (i_pos != _kernel_map.end () && !_kernel_map.key_comp ()(kernel_name, i_pos->first)) {
        // need update
        i_pos->second = kernel;
        XCAM_LOG_DEBUG ("kernel:%s already exist in context, now update to new one", kernel_name.c_str());
        return true;
    }

    _kernel_map.insert (i_pos, std::make_pair (kernel_name, kernel));
    return true;
}
Exemplo n.º 13
0
bool
CLDevice::init ()
{
    cl_platform_id platform_id = NULL;
    cl_device_id   device_id = NULL;
    cl_uint num_platform = 0;
    cl_uint num_device = 0;
    CLDevieInfo device_info;

    if (clGetPlatformIDs (1, &platform_id, &num_platform) != CL_SUCCESS)
    {
        XCAM_LOG_WARNING ("get cl platform ID failed");
        return false;
    }
    XCAM_ASSERT (num_platform >= 1);

    if (clGetDeviceIDs (platform_id, CL_DEVICE_TYPE_GPU, 1, &device_id, &num_device) != CL_SUCCESS)
    {
        XCAM_LOG_WARNING ("get cl device ID failed");
        return false;
    }
    XCAM_ASSERT (num_device >= 1);

    // only query first device info
    if (!query_device_info (device_id, device_info)) {
        //continue
        XCAM_LOG_WARNING ("cl get device info failed but continue");
    } else {
        XCAM_LOG_DEBUG (
            "cl get device info,\n"
            "\tmax_compute_unit:%d"
            "\tmax_work_item_dims:%d"
            "\tmax_work_item_sizes:{%d, %d, %d}"
            "\tmax_work_group_size:%d",
            device_info.max_compute_unit,
            device_info.max_work_item_dims,
            device_info.max_work_item_sizes[0], device_info.max_work_item_sizes[1], device_info.max_work_item_sizes[2],
            device_info.max_work_group_size);
    }

    _platform_id = platform_id;
    _device_id = device_id;
    _device_info = device_info;
    _inited = true;
    return true;
}
Exemplo n.º 14
0
bool
AiqCompositor::set_3a_stats (SmartPtr<X3aIspStatistics> &stats)
{
    ia_aiq_statistics_input_params aiq_stats_input;
    ia_aiq_rgbs_grid *rgbs_grids = NULL;
    ia_aiq_af_grid *af_grids = NULL;

    xcam_mem_clear (&aiq_stats_input);
    aiq_stats_input.frame_timestamp = stats->get_timestamp();
    aiq_stats_input.frame_id = stats->get_timestamp() + 1;
    aiq_stats_input.rgbs_grids = (const ia_aiq_rgbs_grid **)&rgbs_grids;
    aiq_stats_input.num_rgbs_grids = 1;
    aiq_stats_input.af_grids = (const ia_aiq_af_grid **)(&af_grids);
    aiq_stats_input.num_af_grids = 1;

    aiq_stats_input.frame_af_parameters = NULL;
    aiq_stats_input.external_histograms = NULL;
    aiq_stats_input.num_external_histograms = 0;
    aiq_stats_input.camera_orientation = ia_aiq_camera_orientation_unknown;

    if (_pa_result)
        aiq_stats_input.frame_pa_parameters = _pa_result;
    if (_ae_handler->is_started())
        aiq_stats_input.frame_ae_parameters = _ae_handler->get_result ();
    //if (_awb_handler->is_started())
    //    aiq_stats_input.frame_awb_parameters = _awb_handler->get_result();

    if (!_adaptor->convert_statistics (stats->get_3a_stats(), &rgbs_grids, &af_grids)) {
        XCAM_LOG_WARNING ("ia isp adaptor convert 3a stats failed");
        return false;
    }

    XCAM_LOG_DEBUG ("statistics grid info, width:%u, height:%u, blk_r:%u, blk_b:%u, blk_gr:%u, blk_gb:%u",
                    aiq_stats_input.rgbs_grids[0]->grid_width,
                    aiq_stats_input.rgbs_grids[0]->grid_height,
                    aiq_stats_input.rgbs_grids[0]->blocks_ptr->avg_r,
                    aiq_stats_input.rgbs_grids[0]->blocks_ptr->avg_b,
                    aiq_stats_input.rgbs_grids[0]->blocks_ptr->avg_gr,
                    aiq_stats_input.rgbs_grids[0]->blocks_ptr->avg_gb);

    if (ia_aiq_statistics_set(get_handle (), &aiq_stats_input) != ia_err_none) {
        XCAM_LOG_ERROR ("Aiq set statistic failed");
        return false;
    }
    return true;
}
Exemplo n.º 15
0
XCamReturn
V4l2SubDevice::unsubscribe_event (int event)
{
    struct v4l2_event_subscription sub;
    int ret = 0;

    XCAM_ASSERT (is_opened());

    xcam_mem_clear (sub);
    sub.type = event;

    ret = this->io_control (VIDIOC_UNSUBSCRIBE_EVENT, &sub);
    if (ret < 0) {
        XCAM_LOG_DEBUG ("subdev(%s) unsubscribe event(%d) failed", XCAM_STR(_name), event);
        return XCAM_RETURN_ERROR_IOCTL;
    }
    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 16
0
int
V4l2Device::poll_event (int timeout_msec)
{
    struct pollfd poll_fd;
    int ret = 0;

    XCAM_ASSERT (_fd > 0);

    xcam_mem_clear (poll_fd);
    poll_fd.fd = _fd;
    poll_fd.events = (POLLPRI | POLLIN | POLLERR | POLLNVAL | POLLHUP);

    ret = poll (&poll_fd, 1, timeout_msec);
    if (ret > 0 && (poll_fd.revents & (POLLERR | POLLNVAL | POLLHUP))) {
        XCAM_LOG_DEBUG ("v4l2 subdev(%s) polled error", XCAM_STR(_name));
        return -1;
    }
    return ret;

}
Exemplo n.º 17
0
CL3aImageProcessor::CL3aImageProcessor ()
    : CLImageProcessor ("CL3aImageProcessor")
    , _output_fourcc (V4L2_PIX_FMT_NV12)
    , _3a_stats_bits (8)
    , _scaler_factor (1.0)
    , _pipeline_profile (BasicPipelineProfile)
    , _capture_stage (TonemappingStage)
    , _wdr_mode (WDRdisabled)
    , _hdr_mode (0)
    , _tnr_mode (0)
    , _enable_gamma (true)
    , _enable_macc (true)
    , _enable_dpc (false)
    , _enable_scaler (false)
    , _enable_wireframe (false)
    , _wavelet_basis (CL_WAVELET_DISABLED)
    , _wavelet_channel (CL_IMAGE_CHANNEL_UV)
    , _wavelet_bayes_shrink (false)
    , _snr_mode (0)
{
    keep_attached_buf (true);
    XCAM_LOG_DEBUG ("CL3aImageProcessor constructed");
}
Exemplo n.º 18
0
void
AiqCompositor::close ()
{
    _adaptor.release ();
    if (_ia_handle) {
        ia_aiq_deinit (_ia_handle);
        _ia_handle = NULL;
    }

    if (_ia_mkn) {
        ia_mkn_uninit (_ia_mkn);
        _ia_mkn = NULL;
    }

    _ae_handler.release ();
    _awb_handler.release ();
    _af_handler.release ();
    _common_handler.release ();

    _pa_result = NULL;

    XCAM_LOG_DEBUG ("Aiq compositor closed");
}
Exemplo n.º 19
0
std::list<struct v4l2_fmtdesc>
V4l2Device::enum_formats ()
{
    std::list<struct v4l2_fmtdesc> formats;
    struct v4l2_fmtdesc format;
    uint32_t i = 0;

    while (1) {
        xcam_mem_clear (format);
        format.index = i++;
        format.type = _capture_buf_type;
        if (this->io_control (VIDIOC_ENUM_FMT, &format) < 0) {
            if (errno == EINVAL)
                break;
            else { // error
                XCAM_LOG_DEBUG ("enum formats failed");
                return formats;
            }
        }
        formats.push_back (format);
    }

    return formats;
}
Exemplo n.º 20
0
XCamReturn
X3aCiqTnrTuningHandler::analyze (X3aResultList &output)
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    const X3aCiqTnrTuningStaticData* tuning = imx185_tuning;
    if (NULL != _tuning_data) {
        tuning = (X3aCiqTnrTuningStaticData*)_tuning_data;;
    }

    XCam3aResultTemporalNoiseReduction config;
    SmartPtr<X3aTemporalNoiseReduction> rgb_result = new X3aTemporalNoiseReduction (XCAM_3A_RESULT_TEMPORAL_NOISE_REDUCTION_RGB);
    SmartPtr<X3aTemporalNoiseReduction> yuv_result = new X3aTemporalNoiseReduction (XCAM_3A_RESULT_TEMPORAL_NOISE_REDUCTION_YUV);

    double analog_gain = get_current_analog_gain ();
    double max_analog_gain = get_max_analog_gain ();
    XCAM_LOG_DEBUG ("get current AG = (%f), max AG = (%f)", analog_gain, max_analog_gain);

    uint8_t i_curr = 0;
    uint8_t i_prev = 0;
    for (i_curr = 0; i_curr < X3A_CIQ_GAIN_STEPS; i_curr++) {
        if (analog_gain <= tuning[i_curr].analog_gain) {
            break;
        }
        i_prev = i_curr;
    }
    if (i_curr >= X3A_CIQ_GAIN_STEPS) {
        i_curr = X3A_CIQ_GAIN_STEPS - 1;
    }

    //Calculate YUV config
    xcam_mem_clear (config);
    config.gain = linear_interpolate_p2 (tuning[i_prev].yuv_gain, tuning[i_curr].yuv_gain,
                                         tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    config.threshold[0] = linear_interpolate_p2 (tuning[i_prev].y_threshold, tuning[i_curr].y_threshold,
                          tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    config.threshold[1] = linear_interpolate_p2 (tuning[i_prev].uv_threshold, tuning[i_curr].uv_threshold,
                          tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    config.threshold[2] = 0.0;
    XCAM_LOG_DEBUG ("Calculate YUV temporal noise reduction config: yuv_gain(%f), y_threshold(%f), uv_threshold(%f)",
                    config.gain, config.threshold[0], config.threshold[1]);

    yuv_result->set_standard_result (config);
    output.push_back (yuv_result);

    //Calculate RGB config
    xcam_mem_clear (config);
    config.gain = linear_interpolate_p2 (tuning[i_prev].rgb_gain, tuning[i_curr].rgb_gain,
                                         tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    config.threshold[0] = linear_interpolate_p2 (tuning[i_prev].r_threshold, tuning[i_curr].r_threshold,
                          tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    config.threshold[1] = linear_interpolate_p2 (tuning[i_prev].g_threshold, tuning[i_curr].g_threshold,
                          tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    config.threshold[2] = linear_interpolate_p2 (tuning[i_prev].b_threshold, tuning[i_curr].b_threshold,
                          tuning[i_prev].analog_gain, tuning[i_curr].analog_gain, analog_gain);

    XCAM_LOG_DEBUG ("Calculate RGB temporal noise reduction config: rgb_gain(%f), r_threshold(%f), g_threshold(%f), b_threshold(%f)",
                    config.gain, config.threshold[0], config.threshold[1], config.threshold[2]);

    rgb_result->set_standard_result (config);
    output.push_back (rgb_result);

    return ret;
}
Exemplo n.º 21
0
CLContext::~CLContext ()
{
    destroy_context ();
    XCAM_LOG_DEBUG ("CLContext destructed");
}
Exemplo n.º 22
0
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;
}
Exemplo n.º 23
0
X3aAnalyzerManager::X3aAnalyzerManager ()
{
    XCAM_LOG_DEBUG ("X3aAnalyzerManager construction");
}
Exemplo n.º 24
0
X3aAnalyzerManager::~X3aAnalyzerManager ()
{
    XCAM_LOG_DEBUG ("X3aAnalyzerManager destruction");
}
Exemplo n.º 25
0
XCamReturn
CL3aImageProcessor::create_handlers ()
{
    SmartPtr<CLImageHandler> image_handler;
    SmartPtr<CLContext> context = get_cl_context ();

    XCAM_ASSERT (context.ptr ());

    /* bayer pipeline */
    image_handler = create_cl_bayer_basic_image_handler (context, _enable_gamma, _3a_stats_bits);
    _bayer_basic_pipe = image_handler.dynamic_cast_ptr<CLBayerBasicImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _bayer_basic_pipe.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create bayer basic pipe handler failed");
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    _bayer_basic_pipe->set_stats_callback (_stats_callback);
    add_handler (image_handler);

    /* tone mapping */
    switch(_wdr_mode) {
    case Gaussian: {
        image_handler = create_cl_tonemapping_image_handler (context);
        _tonemapping = image_handler.dynamic_cast_ptr<CLTonemappingImageHandler> ();
        XCAM_FAIL_RETURN (
            WARNING,
            _tonemapping.ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create tonemapping handler failed");
        _tonemapping->set_kernels_enable (true);
        image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
        add_handler (image_handler);
        break;
    }
    case Haleq: {
        image_handler = create_cl_newtonemapping_image_handler (context);
        _newtonemapping = image_handler.dynamic_cast_ptr<CLNewTonemappingImageHandler> ();
        XCAM_FAIL_RETURN (
            WARNING,
            _newtonemapping.ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create tonemapping handler failed");
        _newtonemapping->set_kernels_enable (true);
        image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
        add_handler (image_handler);
        break;
    }
    default:
        XCAM_LOG_DEBUG ("WDR disabled");
        break;
    }

    /* bayer pipe */
    image_handler = create_cl_bayer_pipe_image_handler (context);
    _bayer_pipe = image_handler.dynamic_cast_ptr<CLBayerPipeImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        image_handler.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create bayer pipe handler failed");

    _bayer_pipe->enable_denoise (XCAM_DENOISE_TYPE_BNR & _snr_mode);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE * 2);
    //image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    add_handler (image_handler);
    if(_capture_stage == BasicbayerStage)
        return XCAM_RETURN_NO_ERROR;

    image_handler = create_cl_yuv_pipe_image_handler (context);
    _yuv_pipe = image_handler.dynamic_cast_ptr<CLYuvPipeImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _yuv_pipe.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create yuv pipe handler failed");
    _yuv_pipe->set_tnr_enable (_tnr_mode & CL_TNR_TYPE_YUV);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE * 2);
    add_handler (image_handler);

#if ENABLE_YEENR_HANDLER
    /* ee */
    image_handler = create_cl_ee_image_handler (context);
    _ee = image_handler.dynamic_cast_ptr<CLEeImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _ee.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create ee handler failed");
    _ee->set_kernels_enable (XCAM_DENOISE_TYPE_EE & _snr_mode);
    image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);
#endif

    /* wavelet denoise */
    switch (_wavelet_basis) {
    case CL_WAVELET_HAT: {
        image_handler = create_cl_wavelet_denoise_image_handler (context, _wavelet_channel);
        _wavelet = image_handler.dynamic_cast_ptr<CLWaveletDenoiseImageHandler> ();
        XCAM_FAIL_RETURN (
            WARNING,
            _wavelet.ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create wavelet denoise handler failed");
        _wavelet->set_kernels_enable (true);
        image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
        image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
        add_handler (image_handler);
        break;
    }
    case CL_WAVELET_HAAR: {
        image_handler = create_cl_newwavelet_denoise_image_handler (context, _wavelet_channel, _wavelet_bayes_shrink);
        _newwavelet = image_handler.dynamic_cast_ptr<CLNewWaveletDenoiseImageHandler> ();
        XCAM_FAIL_RETURN (
            WARNING,
            _newwavelet.ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create new wavelet denoise handler failed");
        _newwavelet->set_kernels_enable (true);
        image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
        image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
        add_handler (image_handler);
        break;
    }
    case CL_WAVELET_DISABLED:
    default :
        XCAM_LOG_DEBUG ("unknown or disable wavelet (%d)", _wavelet_basis);
        break;
    }

    /* image scaler */
    image_handler = create_cl_image_scaler_handler (context, V4L2_PIX_FMT_NV12);
    _scaler = image_handler.dynamic_cast_ptr<CLImageScaler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _scaler.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create scaler handler failed");
    _scaler->set_scaler_factor (_scaler_factor);
    _scaler->set_buffer_callback (_stats_callback);
    image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    image_handler->set_kernels_enable (_enable_scaler);
    add_handler (image_handler);

    /* wire frame */
    image_handler = create_cl_wire_frame_image_handler (context);
    _wire_frame = image_handler.dynamic_cast_ptr<CLWireFrameImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _wire_frame.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create wire frame handler failed");
    _wire_frame->set_kernels_enable (_enable_wireframe);
    image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);

    XCAM_FAIL_RETURN (
        WARNING,
        post_config (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor post_config failed");

    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 26
0
XCamReturn
X3aAnalyzerAiq::configure_3a ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;
    X3aResultList first_results;

    if (!_sensor_data_ready) {
        struct atomisp_sensor_mode_data sensor_mode_data;
        xcam_mem_clear (sensor_mode_data);
        XCAM_ASSERT (_isp.ptr());

        ret = _isp->get_sensor_mode_data (sensor_mode_data);
        XCAM_FAIL_RETURN (WARNING, ret == XCAM_RETURN_NO_ERROR, ret, "get sensor mode data failed");
        _sensor_mode_data = sensor_mode_data;
        _sensor_data_ready = true;
    }

    if (!_aiq_compositor->set_sensor_mode_data (&_sensor_mode_data)) {
        XCAM_LOG_WARNING ("AIQ configure 3a failed");
        return XCAM_RETURN_ERROR_AIQ;
    }

    XCAM_LOG_DEBUG ("X3aAnalyzerAiq got sensor mode data, coarse_time_min:%u, "
                    "coarse_time_max_margin:%u, "
                    "fine_time_min:%u, fine_time_max_margin:%u, "
                    "fine_time_def:%u, "
                    "frame_length_lines:%u, line_length_pck:%u, "
                    "vt_pix_clk_freq_mhz:%u, "
                    "crop_horizontal_start:%u, crop_vertical_start:%u, "
                    "crop_horizontal_end:%u, crop_vertical_end:%u, "
                    "output_width:%u, output_height:%u, "
                    "binning_factor_x:%u, binning_factor_y:%u",
                    _sensor_mode_data.coarse_integration_time_min,
                    _sensor_mode_data.coarse_integration_time_max_margin,
                    _sensor_mode_data.fine_integration_time_min,
                    _sensor_mode_data.fine_integration_time_max_margin,
                    _sensor_mode_data.fine_integration_time_def,
                    _sensor_mode_data.frame_length_lines,
                    _sensor_mode_data.line_length_pck,
                    _sensor_mode_data.vt_pix_clk_freq_mhz,
                    _sensor_mode_data.crop_horizontal_start,
                    _sensor_mode_data.crop_vertical_start,
                    _sensor_mode_data.crop_horizontal_end,
                    _sensor_mode_data.crop_vertical_end,
                    _sensor_mode_data.output_width,
                    _sensor_mode_data.output_height,
                    (uint32_t)_sensor_mode_data.binning_factor_x,
                    (uint32_t)_sensor_mode_data.binning_factor_y);

    // initialize ae and awb
    get_ae_handler ()->analyze (first_results);
    get_awb_handler ()->analyze (first_results);

    ret = _aiq_compositor->integrate (first_results);
    XCAM_FAIL_RETURN (WARNING, ret == XCAM_RETURN_NO_ERROR, ret, "AIQ configure_3a failed on integrate results");

    if (!first_results.empty()) {
        notify_calculation_done (first_results);
    }

    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 27
0
CL3aImageProcessor::~CL3aImageProcessor ()
{
    XCAM_LOG_DEBUG ("CL3aImageProcessor destructed");
}
Exemplo n.º 28
0
XCamReturn
DeviceManager::start ()
{
    XCamReturn ret = XCAM_RETURN_NO_ERROR;

    // start device
    XCAM_ASSERT (_device->is_opened());
    if (!_device.ptr() || !_device->is_opened()) {
        XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_FILE, "capture device not ready");
    }
    XCAM_FAILED_STOP (ret = _device->start(), "capture device start failed");

    //start subdevice
    //XCAM_ASSERT (_subdevice->is_opened());
    if (_subdevice.ptr()) {
        if (!_subdevice->is_opened())
            XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_FILE, "event device not ready");
        XCAM_FAILED_STOP (ret = _subdevice->start(), "start event device failed");
    }

    //suppose _device and _subdevice already started
    if (!_isp_controller.ptr ())
        _isp_controller = new IspController (_device);
    XCAM_ASSERT (_isp_controller.ptr());

    if (_has_3a) {
        // Initialize and start analyzer
        uint32_t width = 0, height = 0;
        uint32_t fps_n = 0, fps_d = 0;
        double framerate = 30.0;

        if (!_3a_analyzer.ptr()) {
            _3a_analyzer = X3aAnalyzerManager::instance()->create_analyzer();
            if (!_3a_analyzer.ptr()) {
                XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_PARAM, "create analyzer failed");
            }
        }
        if (_3a_analyzer->prepare_handlers () != XCAM_RETURN_NO_ERROR) {
            XCAM_FAILED_STOP (ret = XCAM_RETURN_ERROR_PARAM, "prepare analyzer handler failed");
        }
        _3a_analyzer->set_results_callback (this);

        _device->get_size (width, height);
        _device->get_framerate (fps_n, fps_d);
        if (fps_d)
            framerate = (double)fps_n / (double)fps_d;
        XCAM_FAILED_STOP (
            ret = _3a_analyzer->init (width, height, framerate),
            "initialize analyzer failed");

        XCAM_FAILED_STOP (ret = _3a_analyzer->start (), "start analyzer failed");

        if (_smart_analyzer.ptr()) {
            if (_smart_analyzer->prepare_handlers () != XCAM_RETURN_NO_ERROR) {
                XCAM_LOG_INFO ("prepare smart analyzer handler failed");
            }
            //_smart_analyzer->set_results_callback (this);
            if (_smart_analyzer->init (width, height, framerate) != XCAM_RETURN_NO_ERROR) {
                XCAM_LOG_INFO ("initialize smart analyzer failed");
            }
            if (_smart_analyzer->start () != XCAM_RETURN_NO_ERROR) {
                XCAM_LOG_INFO ("start smart analyzer failed");
            }
        }

        // Initialize and start image processors
        if (!_3a_process_center->has_processors()) {
            // default processor
            SmartPtr<ImageProcessor> default_processor = new IspImageProcessor (_isp_controller);
            XCAM_ASSERT (default_processor.ptr ());
            _3a_process_center->insert_processor (default_processor);
        }

        _3a_process_center->set_image_callback(this);
        XCAM_FAILED_STOP (ret = _3a_process_center->start (), "3A process center start failed");

    }

    //Initialize and start poll thread
    _poll_thread = new PollThread;
    _poll_thread->set_capture_device (_device);
    if (_subdevice.ptr ())
        _poll_thread->set_event_device (_subdevice);
    _poll_thread->set_isp_controller (_isp_controller);
    _poll_thread->set_poll_callback (this);
    _poll_thread->set_stats_callback (this);

    XCAM_FAILED_STOP (ret = _poll_thread->start(), "start poll failed");

    _is_running = true;

    XCAM_LOG_DEBUG ("Device manager started");
    return XCAM_RETURN_NO_ERROR;
}
DnnSemanticSegmentation::DnnSemanticSegmentation (DnnInferConfig& config)
    : DnnInferenceEngine (config)
{
    XCAM_LOG_DEBUG ("DnnSemanticSegmentation::DnnSemanticSegmentation");
    set_output_layer_type ("ArgMax");
}
Exemplo n.º 30
0
DeviceManager::~DeviceManager()
{
    XCAM_LOG_DEBUG ("~DeviceManager destruction");
}