src/3rdparty/libjpeg/jcparam.c
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
     1 /*
     1 /*
     2  * jcparam.c
     2  * jcparam.c
     3  *
     3  *
     4  * Copyright (C) 1991-1998, Thomas G. Lane.
     4  * Copyright (C) 1991-1998, Thomas G. Lane.
       
     5  * Modified 2003-2008 by Guido Vollbeding.
     5  * This file is part of the Independent JPEG Group's software.
     6  * This file is part of the Independent JPEG Group's software.
     6  * For conditions of distribution and use, see the accompanying README file.
     7  * For conditions of distribution and use, see the accompanying README file.
     7  *
     8  *
     8  * This file contains optional default-setting code for the JPEG compressor.
     9  * This file contains optional default-setting code for the JPEG compressor.
     9  * Applications do not have to use this file, but those that don't use it
    10  * Applications do not have to use this file, but those that don't use it
    58   /* Initialize sent_table FALSE so table will be written to JPEG file. */
    59   /* Initialize sent_table FALSE so table will be written to JPEG file. */
    59   (*qtblptr)->sent_table = FALSE;
    60   (*qtblptr)->sent_table = FALSE;
    60 }
    61 }
    61 
    62 
    62 
    63 
       
    64 /* These are the sample quantization tables given in JPEG spec section K.1.
       
    65  * The spec says that the values given produce "good" quality, and
       
    66  * when divided by 2, "very good" quality.
       
    67  */
       
    68 static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
       
    69   16,  11,  10,  16,  24,  40,  51,  61,
       
    70   12,  12,  14,  19,  26,  58,  60,  55,
       
    71   14,  13,  16,  24,  40,  57,  69,  56,
       
    72   14,  17,  22,  29,  51,  87,  80,  62,
       
    73   18,  22,  37,  56,  68, 109, 103,  77,
       
    74   24,  35,  55,  64,  81, 104, 113,  92,
       
    75   49,  64,  78,  87, 103, 121, 120, 101,
       
    76   72,  92,  95,  98, 112, 100, 103,  99
       
    77 };
       
    78 static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
       
    79   17,  18,  24,  47,  99,  99,  99,  99,
       
    80   18,  21,  26,  66,  99,  99,  99,  99,
       
    81   24,  26,  56,  99,  99,  99,  99,  99,
       
    82   47,  66,  99,  99,  99,  99,  99,  99,
       
    83   99,  99,  99,  99,  99,  99,  99,  99,
       
    84   99,  99,  99,  99,  99,  99,  99,  99,
       
    85   99,  99,  99,  99,  99,  99,  99,  99,
       
    86   99,  99,  99,  99,  99,  99,  99,  99
       
    87 };
       
    88 
       
    89 
       
    90 GLOBAL(void)
       
    91 jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
       
    92 /* Set or change the 'quality' (quantization) setting, using default tables
       
    93  * and straight percentage-scaling quality scales.
       
    94  * This entry point allows different scalings for luminance and chrominance.
       
    95  */
       
    96 {
       
    97   /* Set up two quantization tables using the specified scaling */
       
    98   jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
       
    99 		       cinfo->q_scale_factor[0], force_baseline);
       
   100   jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
       
   101 		       cinfo->q_scale_factor[1], force_baseline);
       
   102 }
       
   103 
       
   104 
    63 GLOBAL(void)
   105 GLOBAL(void)
    64 jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
   106 jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
    65 			 boolean force_baseline)
   107 			 boolean force_baseline)
    66 /* Set or change the 'quality' (quantization) setting, using default tables
   108 /* Set or change the 'quality' (quantization) setting, using default tables
    67  * and a straight percentage-scaling quality scale.  In most cases it's better
   109  * and a straight percentage-scaling quality scale.  In most cases it's better
    68  * to use jpeg_set_quality (below); this entry point is provided for
   110  * to use jpeg_set_quality (below); this entry point is provided for
    69  * applications that insist on a linear percentage scaling.
   111  * applications that insist on a linear percentage scaling.
    70  */
   112  */
    71 {
   113 {
    72   /* These are the sample quantization tables given in JPEG spec section K.1.
       
    73    * The spec says that the values given produce "good" quality, and
       
    74    * when divided by 2, "very good" quality.
       
    75    */
       
    76   static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
       
    77     16,  11,  10,  16,  24,  40,  51,  61,
       
    78     12,  12,  14,  19,  26,  58,  60,  55,
       
    79     14,  13,  16,  24,  40,  57,  69,  56,
       
    80     14,  17,  22,  29,  51,  87,  80,  62,
       
    81     18,  22,  37,  56,  68, 109, 103,  77,
       
    82     24,  35,  55,  64,  81, 104, 113,  92,
       
    83     49,  64,  78,  87, 103, 121, 120, 101,
       
    84     72,  92,  95,  98, 112, 100, 103,  99
       
    85   };
       
    86   static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
       
    87     17,  18,  24,  47,  99,  99,  99,  99,
       
    88     18,  21,  26,  66,  99,  99,  99,  99,
       
    89     24,  26,  56,  99,  99,  99,  99,  99,
       
    90     47,  66,  99,  99,  99,  99,  99,  99,
       
    91     99,  99,  99,  99,  99,  99,  99,  99,
       
    92     99,  99,  99,  99,  99,  99,  99,  99,
       
    93     99,  99,  99,  99,  99,  99,  99,  99,
       
    94     99,  99,  99,  99,  99,  99,  99,  99
       
    95   };
       
    96 
       
    97   /* Set up two quantization tables using the specified scaling */
   114   /* Set up two quantization tables using the specified scaling */
    98   jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
   115   jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
    99 		       scale_factor, force_baseline);
   116 		       scale_factor, force_baseline);
   100   jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
   117   jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
   101 		       scale_factor, force_baseline);
   118 		       scale_factor, force_baseline);
   282       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
   299       (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
   283 				  MAX_COMPONENTS * SIZEOF(jpeg_component_info));
   300 				  MAX_COMPONENTS * SIZEOF(jpeg_component_info));
   284 
   301 
   285   /* Initialize everything not dependent on the color space */
   302   /* Initialize everything not dependent on the color space */
   286 
   303 
       
   304   cinfo->scale_num = 1;		/* 1:1 scaling */
       
   305   cinfo->scale_denom = 1;
   287   cinfo->data_precision = BITS_IN_JSAMPLE;
   306   cinfo->data_precision = BITS_IN_JSAMPLE;
   288   /* Set up two quantization tables using default quality of 75 */
   307   /* Set up two quantization tables using default quality of 75 */
   289   jpeg_set_quality(cinfo, 75, TRUE);
   308   jpeg_set_quality(cinfo, 75, TRUE);
   290   /* Set up two Huffman tables */
   309   /* Set up two Huffman tables */
   291   std_huff_tables(cinfo);
   310   std_huff_tables(cinfo);
   317   if (cinfo->data_precision > 8)
   336   if (cinfo->data_precision > 8)
   318     cinfo->optimize_coding = TRUE;
   337     cinfo->optimize_coding = TRUE;
   319 
   338 
   320   /* By default, use the simpler non-cosited sampling alignment */
   339   /* By default, use the simpler non-cosited sampling alignment */
   321   cinfo->CCIR601_sampling = FALSE;
   340   cinfo->CCIR601_sampling = FALSE;
       
   341 
       
   342   /* By default, apply fancy downsampling */
       
   343   cinfo->do_fancy_downsampling = TRUE;
   322 
   344 
   323   /* No input smoothing */
   345   /* No input smoothing */
   324   cinfo->smoothing_factor = 0;
   346   cinfo->smoothing_factor = 0;
   325 
   347 
   326   /* DCT algorithm preference */
   348   /* DCT algorithm preference */