Exemplo n.º 1
0
XCamReturn
CL3aImageProcessor::create_handlers ()
{
    SmartPtr<CLImageHandler> image_handler;
    SmartPtr<CLContext> context = get_cl_context ();

    XCAM_ASSERT (context.ptr ());

    /* black leve as first */
    image_handler = create_cl_blc_image_handler (context);
    _black_level = image_handler;
    XCAM_FAIL_RETURN (
        WARNING,
        image_handler.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create blc handler failed");
    add_handler (image_handler);

    /* hdr */
    if (_enable_hdr) {
        image_handler = create_cl_hdr_image_handler (context, CL_HDR_TYPE_RGB);
        _hdr = image_handler;
        XCAM_FAIL_RETURN (
            WARNING,
            _hdr.ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create hdr handler failed");
        add_handler (image_handler);
    }

    /* demosaic */
    image_handler = create_cl_demosaic_image_handler (context);
    _demosaic = image_handler.dynamic_cast_ptr<CLBayer2RGBImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _demosaic.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create demosaic handler failed");
    add_handler (image_handler);

    /* color space conversion */
    if (_out_smaple_type == OutSampleYuv) {
        image_handler = create_cl_csc_image_handler (context, CL_CSC_TYPE_RGBATONV12);
        _csc = image_handler.dynamic_cast_ptr<CLCscImageHandler> ();
        XCAM_FAIL_RETURN (
            WARNING,
            _csc .ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create csc handler failed");
        add_handler (image_handler);
    } else if (_out_smaple_type == OutSampleRGB) {
        _demosaic->set_output_format (_output_fourcc);
    }

    return XCAM_RETURN_NO_ERROR;
}
Exemplo n.º 2
0
XCamReturn
CL3aImageProcessor::create_handlers ()
{
    SmartPtr<CLImageHandler> image_handler;
    SmartPtr<CLContext> context = get_cl_context ();

    XCAM_ASSERT (context.ptr ());

#if 1
    /* bayer pipeline */
    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->set_stats_callback (_stats_callback);
#if 0
    if (get_profile () >= AdvancedPipelineProfile) {
        _bayer_pipe->set_output_format (V4L2_PIX_FMT_ABGR32);
    }
#endif
    _bayer_pipe->enable_denoise (XCAM_DENOISE_TYPE_BNR & _snr_mode);
    _bayer_pipe->enable_gamma (_enable_gamma);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE * 2);
    add_handler (image_handler);
    if(_capture_stage == BasicbayerStage)
        return XCAM_RETURN_NO_ERROR;

#else
    /* black leve as first */
    image_handler = create_cl_blc_image_handler (context);
    _black_level = image_handler.dynamic_cast_ptr<CLBlcImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        image_handler.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create blc handler failed");
    add_handler (image_handler);

    image_handler = create_cl_dpc_image_handler (context);
    _dpc = image_handler.dynamic_cast_ptr<CLDpcImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        image_handler.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create dpc handler failed");
    _dpc->set_kernels_enable(_enable_dpc);
    add_handler (image_handler);

    image_handler = create_cl_bnr_image_handler (context);
    _bnr = image_handler.dynamic_cast_ptr<CLBnrImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _bnr.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create bnr handler failed");
    _bnr->set_kernels_enable (XCAM_DENOISE_TYPE_BNR & _snr_mode);
    add_handler (image_handler);

    image_handler = create_cl_3a_stats_image_handler (context);
    _x3a_stats_calculator = image_handler.dynamic_cast_ptr<CL3AStatsCalculator> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _x3a_stats_calculator.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create 3a stats calculator failed");
    _x3a_stats_calculator->set_stats_callback (_stats_callback);
    add_handler (image_handler);

    image_handler = create_cl_wb_image_handler (context);
    _wb = image_handler.dynamic_cast_ptr<CLWbImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _wb.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create whitebalance handler failed");
    add_handler (image_handler);

    /* gamma */
    image_handler = create_cl_gamma_image_handler (context);
    _gamma = image_handler.dynamic_cast_ptr<CLGammaImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _gamma.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create gamma handler failed");
    _gamma->set_kernels_enable (_enable_gamma);
    add_handler (image_handler);

    /* hdr */
    image_handler = create_cl_hdr_image_handler (context, CL_HDR_DISABLE);
    _hdr = image_handler.dynamic_cast_ptr<CLHdrImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _hdr.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create hdr handler failed");
    if(_hdr_mode == CL_HDR_TYPE_RGB)
        _hdr->set_mode (_hdr_mode);
    add_handler (image_handler);

    /* demosaic */
    image_handler = create_cl_demosaic_image_handler (context);
    _demosaic = image_handler.dynamic_cast_ptr<CLBayer2RGBImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _demosaic.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create demosaic handler failed");
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);
#endif

    /* hdr-lab*/
    image_handler = create_cl_hdr_image_handler (context, CL_HDR_DISABLE);
    _hdr = image_handler.dynamic_cast_ptr<CLHdrImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _hdr.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create hdr handler failed");
    if(_hdr_mode == CL_HDR_TYPE_LAB)
        _hdr->set_mode (_hdr_mode);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);

    /* bilateral noise reduction */
    image_handler = create_cl_denoise_image_handler (context);
    _binr = image_handler.dynamic_cast_ptr<CLDenoiseImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _binr.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create denoise handler failed");
    _binr->set_kernels_enable (XCAM_DENOISE_TYPE_BILATERAL & _snr_mode);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);

#if 0
    image_handler = create_cl_rgb_pipe_image_handler (context);
    _rgb_pipe = image_handler.dynamic_cast_ptr<CLRgbPipeImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _rgb_pipe.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create rgb pipe handler failed");
    _rgb_pipe->set_kernels_enable (get_profile () >= AdvancedPipelineProfile);
    add_handler (image_handler);
    /* Temporal Noise Reduction (RGB domain) */
    image_handler = create_cl_tnr_image_handler(context, CL_TNR_TYPE_RGB);
    _tnr_rgb = image_handler.dynamic_cast_ptr<CLTnrImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _tnr_rgb.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create tnr handler failed");
    _tnr_rgb->set_mode (CL_TNR_TYPE_RGB & _tnr_mode);
    add_handler (image_handler);
#else

    /* simple noise reduction */
    image_handler = create_cl_snr_image_handler (context);
    _snr = image_handler.dynamic_cast_ptr<CLSnrImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _snr.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create snr handler failed");
    _snr->set_kernels_enable (XCAM_DENOISE_TYPE_SIMPLE & _snr_mode);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);
#endif

    /* tone mapping*/
    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 (_enable_tonemapping);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);

#if 1
    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 macc handler failed");
    _yuv_pipe->set_tnr_enable (_tnr_mode & CL_TNR_TYPE_RGB, _tnr_mode & CL_TNR_TYPE_YUV);
    image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
    add_handler (image_handler);
#else
    /* macc */
    image_handler = create_cl_macc_image_handler (context);
    _macc = image_handler.dynamic_cast_ptr<CLMaccImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _macc.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create macc handler failed");
    _macc->set_kernels_enable (_enable_macc);
    add_handler (image_handler);

    /* color space conversion */
    image_handler = create_cl_csc_image_handler (context, CL_CSC_TYPE_RGBATONV12);
    _csc = image_handler.dynamic_cast_ptr<CLCscImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _csc .ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create csc handler failed");
    image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    add_handler (image_handler);


    /* Temporal Noise Reduction (YUV domain) */
    image_handler = create_cl_tnr_image_handler(context, CL_TNR_TYPE_YUV);
    _tnr_yuv = image_handler.dynamic_cast_ptr<CLTnrImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _tnr_yuv.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create tnr handler failed");
    _tnr_yuv->set_mode (CL_TNR_TYPE_YUV & _tnr_mode);
    image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    add_handler (image_handler);
#endif

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


    /* biyuv */
    image_handler = create_cl_biyuv_image_handler (context);
    _biyuv = image_handler.dynamic_cast_ptr<CLBiyuvImageHandler> ();
    XCAM_FAIL_RETURN (
        WARNING,
        _biyuv.ptr (),
        XCAM_RETURN_ERROR_CL,
        "CL3aImageProcessor create biyuv handler failed");
    _biyuv->set_kernels_enable (XCAM_DENOISE_TYPE_BIYUV & _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);

    /* 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 (XCAM_CL_3A_IMAGE_SCALER_FACTOR);
    _scaler->set_buffer_callback (_stats_callback);
    image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
    image_handler->set_kernels_enable (false);
    add_handler (image_handler);

    if (_out_smaple_type == OutSampleRGB) {
        image_handler = create_cl_csc_image_handler (context, CL_CSC_TYPE_NV12TORGBA);
        _csc = image_handler.dynamic_cast_ptr<CLCscImageHandler> ();
        XCAM_FAIL_RETURN (
            WARNING,
            _csc .ptr (),
            XCAM_RETURN_ERROR_CL,
            "CL3aImageProcessor create csc handler failed");
        image_handler->set_pool_type (CLImageHandler::DrmBoPoolType);
        image_handler->set_pool_size (XCAM_CL_3A_IMAGE_MAX_POOL_SIZE);
        add_handler (image_handler);
    }

    return XCAM_RETURN_NO_ERROR;
}