jcparam.c
/*
 * Default parameter setup for compression.
 *
 * Applications that don't choose to use this routine must do their
 * own setup of all these parameters.  Alternately, you can call this
 * to establish defaults and then alter parameters selectively.  This
 * is the recommended approach since, if we add any new parameters,
 * your code will still work (they'll be set to reasonable defaults).
 */
Default parameter setup for compression.
Applications that don't choose to use this routine must do their
own setup of all these parameters.  Alternately, you can call this
to establish defaults and then alter parameters selectively.  This
is the recommended approach since, if we add any new parameters,
your code will still work (they'll be set to reasonable defaults).
Default parameter setup for compression . Applications that don ' t choose to use this routine must do their own setup of all these parameters . Alternately you can call this to establish defaults and then alter parameters selectively . This is the recommended approach since if we add any new parameters your code will still work ( they ' ll be set to reasonable defaults ) .
GLOBAL(void)
jpeg_set_defaults (j_compress_ptr cinfo)
{
  int i;
  if (cinfo->global_state != CSTATE_START)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  if (cinfo->comp_info == NULL)
    cinfo->comp_info = (jpeg_component_info *)
      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
                                  MAX_COMPONENTS * sizeof(jpeg_component_info));
#if JPEG_LIB_VERSION >= 70
  cinfo->scale_num = 1;         
  cinfo->scale_denom = 1;
#endif
  cinfo->data_precision = BITS_IN_JSAMPLE;
  jpeg_set_quality(cinfo, 75, TRUE);
  std_huff_tables((j_common_ptr) cinfo);
  for (i = 0; i < NUM_ARITH_TBLS; i++) {
    cinfo->arith_dc_L[i] = 0;
    cinfo->arith_dc_U[i] = 1;
    cinfo->arith_ac_K[i] = 5;
  }
  cinfo->scan_info = NULL;
  cinfo->num_scans = 0;
  cinfo->raw_data_in = FALSE;
  cinfo->arith_code = FALSE;
#ifdef ENTROPY_OPT_SUPPORTED
  if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION)
    cinfo->optimize_coding = TRUE;
  else
  cinfo->optimize_coding = FALSE;
#else
  cinfo->optimize_coding = FALSE;
#endif
  if (cinfo->data_precision > 8)
    cinfo->optimize_coding = TRUE;
  cinfo->CCIR601_sampling = FALSE;
#if JPEG_LIB_VERSION >= 70
  cinfo->do_fancy_downsampling = TRUE;
#endif
  cinfo->master->overshoot_deringing =
    cinfo->master->compress_profile == JCP_MAX_COMPRESSION;
  cinfo->smoothing_factor = 0;
  cinfo->dct_method = JDCT_DEFAULT;
  cinfo->restart_interval = 0;
  cinfo->restart_in_rows = 0;
  cinfo->JFIF_major_version = 1; 
  cinfo->JFIF_minor_version = 1;
  cinfo->density_unit = 0;      
  cinfo->X_density = 1;         
  cinfo->Y_density = 1;
  jpeg_default_colorspace(cinfo);
  cinfo->master->dc_scan_opt_mode = 0;
#ifdef C_PROGRESSIVE_SUPPORTED
  if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
    cinfo->master->optimize_scans = TRUE;
    jpeg_simple_progression(cinfo);
  } else
    cinfo->master->optimize_scans = FALSE;
#endif
  cinfo->master->trellis_quant =
    cinfo->master->compress_profile == JCP_MAX_COMPRESSION;
  cinfo->master->lambda_log_scale1 = 14.75;
  cinfo->master->lambda_log_scale2 = 16.5;
  cinfo->master->quant_tbl_master_idx =
    cinfo->master->compress_profile == JCP_MAX_COMPRESSION ? 3 : 0;
  cinfo->master->use_lambda_weight_tbl = TRUE;
  cinfo->master->use_scans_in_trellis = FALSE;
  cinfo->master->trellis_freq_split = 8;
  cinfo->master->trellis_num_loops = 1;
  cinfo->master->trellis_q_opt = FALSE;
  cinfo->master->trellis_quant_dc = TRUE;
  cinfo->master->trellis_delta_dc_weight = 0.0;
}
GLOBAL ( void ) jpeg_set_defaults ( j_compress_ptr cinfo ) { int i ; if ( cinfo -> global_state != CSTATE_START ) ERREXIT1 ( cinfo , JERR_BAD_STATE , cinfo -> global_state ) ; if ( cinfo -> comp_info == NULL ) cinfo -> comp_info = ( jpeg_component_info * ) ( * cinfo -> mem -> alloc_small ) ( ( j_common_ptr ) cinfo , JPOOL_PERMANENT , MAX_COMPONENTS * sizeof ( jpeg_component_info ) ) ; #if JPEG_LIB_VERSION >= 70 cinfo -> scale_num = 1 ; cinfo -> scale_denom = 1 ; #endif cinfo -> data_precision = BITS_IN_JSAMPLE ; jpeg_set_quality ( cinfo , 75 , TRUE ) ; std_huff_tables ( ( j_common_ptr ) cinfo ) ; for ( i = 0 ; i < NUM_ARITH_TBLS ; i ++ ) { cinfo -> arith_dc_L [ i ] = 0 ; cinfo -> arith_dc_U [ i ] = 1 ; cinfo -> arith_ac_K [ i ] = 5 ; } cinfo -> scan_info = NULL ; cinfo -> num_scans = 0 ; cinfo -> raw_data_in = FALSE ; cinfo -> arith_code = FALSE ; #ifdef ENTROPY_OPT_SUPPORTED if ( cinfo -> master -> compress_profile == JCP_MAX_COMPRESSION ) cinfo -> optimize_coding = TRUE ; else cinfo -> optimize_coding = FALSE ; #else cinfo -> optimize_coding = FALSE ; #endif if ( cinfo -> data_precision > 8 ) cinfo -> optimize_coding = TRUE ; cinfo -> CCIR601_sampling = FALSE ; #if JPEG_LIB_VERSION >= 70 cinfo -> do_fancy_downsampling = TRUE ; #endif cinfo -> master -> overshoot_deringing = cinfo -> master -> compress_profile == JCP_MAX_COMPRESSION ; cinfo -> smoothing_factor = 0 ; cinfo -> dct_method = JDCT_DEFAULT ; cinfo -> restart_interval = 0 ; cinfo -> restart_in_rows = 0 ; cinfo -> JFIF_major_version = 1 ; cinfo -> JFIF_minor_version = 1 ; cinfo -> density_unit = 0 ; cinfo -> X_density = 1 ; cinfo -> Y_density = 1 ; jpeg_default_colorspace ( cinfo ) ; cinfo -> master -> dc_scan_opt_mode = 0 ; #ifdef C_PROGRESSIVE_SUPPORTED if ( cinfo -> master -> compress_profile == JCP_MAX_COMPRESSION ) { cinfo -> master -> optimize_scans = TRUE ; jpeg_simple_progression ( cinfo ) ; } else cinfo -> master -> optimize_scans = FALSE ; #endif cinfo -> master -> trellis_quant = cinfo -> master -> compress_profile == JCP_MAX_COMPRESSION ; cinfo -> master -> lambda_log_scale1 = 14.75 ; cinfo -> master -> lambda_log_scale2 = 16.5 ; cinfo -> master -> quant_tbl_master_idx = cinfo -> master -> compress_profile == JCP_MAX_COMPRESSION ? 3 : 0 ; cinfo -> master -> use_lambda_weight_tbl = TRUE ; cinfo -> master -> use_scans_in_trellis = FALSE ; cinfo -> master -> trellis_freq_split = 8 ; cinfo -> master -> trellis_num_loops = 1 ; cinfo -> master -> trellis_q_opt = FALSE ; cinfo -> master -> trellis_quant_dc = TRUE ; cinfo -> master -> trellis_delta_dc_weight = 0.0 ; }
Default parameter setup for compression.
Default parameter setup for compression .
/* Safety check to ensure start_compress not called yet. */ /* Allocate comp_info array large enough for maximum component count.
   * Array is made permanent in case application wants to compress
   * multiple images at same param settings.
   */ /* Initialize everything not dependent on the color space */ /* 1:1 scaling */ /* Set up two quantization tables using default quality of 75 */ /* Set up two Huffman tables */ /* Initialize default arithmetic coding conditioning */ /* Default is no multiple-scan output */ /* Expect normal source image, not raw downsampled data */ /* Use Huffman coding, not arithmetic coding, by default */ /* By default, do extra passes to optimize entropy coding */ /* By default, don't do extra passes to optimize entropy coding */ /* By default, don't do extra passes to optimize entropy coding */ /* The standard Huffman tables are only valid for 8-bit data precision.
   * If the precision is higher, force optimization on so that usable
   * tables will be computed.  This test can be removed if default tables
   * are supplied that are valid for the desired precision.
   */ /* By default, use the simpler non-cosited sampling alignment */ /* By default, apply fancy downsampling */ /* No input smoothing */ /* DCT algorithm preference */ /* No restart markers */ /* Fill in default JFIF marker parameters.  Note that whether the marker
   * will actually be written is determined by jpeg_set_colorspace.
   *
   * By default, the library emits JFIF version code 1.01.
   * An application that wants to emit JFIF 1.02 extension markers should set
   * JFIF_minor_version to 2.  We could probably get away with just defaulting
   * to 1.02, but there may still be some decoders in use that will complain
   * about that; saying 1.01 should minimize compatibility problems.
   */ /* Default JFIF version = 1.01 */ /* Pixel size is unknown by default */ /* Pixel aspect ratio is square by default */ /* Choose JPEG colorspace based on input space, set defaults accordingly */