Esempio n. 1
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;
}
Esempio n. 2
0
/* Main loop for processing the configuration file */
int
schd_get_config(char *filename)
  {
  char   *id = "schd_get_config";

  char    line[MAX_LINE_SIZE];
  char    cfg_option[MAX_LINE_SIZE];
  char    cfg_arg[MAX_LINE_SIZE];
  FILE   *cfgfd = NULL;

  char   *comment;
  int     linenum = 0, error = 0;
  size_t  linelen;

  cfgfd = fopen(filename, "r");

  if (cfgfd == NULL)
    {
    (void)sprintf(log_buffer,
                  "Opening '%s': %s", filename, strerror(errno));

    log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);
    DBPRT(("%s: %s\n", id, log_buffer));

    return (-1);
    }

  /* Walk through the configuration file line by line. */
  while (fgets(line, sizeof(line), cfgfd))
    {
    linenum++;

    linelen = strlen(line);

    if (linelen == (sizeof(line) - 1))
      {
      (void)sprintf(log_buffer,
                    "Error in config file %s, line %d: Line too long",
                    filename, linenum);
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);
      DBPRT(("%s\n", log_buffer));

      error = -1;
      break;
      }
    else
      {
      linelen--;   /* Move back to newline. */
      line[linelen] = '\0'; /* And remove it. */
      }

    /* If there is a comment on this line, remove it from view. */
    if ((comment = strchr(line, '#')) != NULL)
      * comment = '\0';

    if (strlen(line) < 2)
      continue;  /* skip blank lines */

    /* Split the option and the argument. */
    if (sscanf(line, "%s %s", cfg_option, cfg_arg) != 2)
      {
      /* Unable to read a cfg_option and cfg_arg */
      (void)sprintf(log_buffer, "Error in config file %s, line %d",
                    filename, linenum);
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);
      DBPRT(("%s\n", log_buffer));

      error = -1;
      break;
      }

    /* Set the configurable options */
    if (set_cfg_opt(cfg_option, cfg_arg))
      {
      /* Unable to parse the option. */
      (void)sprintf(log_buffer,
                    "Error parsing option '%s' in config file %s, line %d",
                    cfg_option, filename, linenum);
      log_record(PBSEVENT_SYSTEM, PBS_EVENTCLASS_SERVER, id, log_buffer);
      DBPRT(("%s\n", log_buffer));

      error = -1;
      break;
      }
    }

  /* Close the config file */

  fclose(cfgfd);

  if (error)
    return (error);

  /* Do any post-configuration necessary. */
  if (!post_config())
    return (-1);

  if (!validate_config())
    return (-1);

  print_config();

  return (0);
  }