< prev index next >

modules/javafx.graphics/src/main/native-iio/libjpeg7/jdapimin.c

Print this page


   1 /*
   2  * jdapimin.c
   3  *
   4  * Copyright (C) 1994-1998, Thomas G. Lane.
   5  * Modified 2009 by Guido Vollbeding.
   6  * This file is part of the Independent JPEG Group's software.
   7  * For conditions of distribution and use, see the accompanying README file.
   8  *
   9  * This file contains application interface code for the decompression half
  10  * of the JPEG library.  These are the "minimum" API routines that may be
  11  * needed in either the normal full-decompression case or the
  12  * transcoding-only case.
  13  *
  14  * Most of the routines intended to be called directly by an application
  15  * are in this file or in jdapistd.c.  But also see jcomapi.c for routines
  16  * shared by compression and decompression, and jdtrans.c for the transcoding
  17  * case.
  18  */
  19 
  20 #define JPEG_INTERNALS
  21 #include "jinclude.h"
  22 #include "jpeglib.h"
  23 
  24 
  25 /*


  97 
  98 /*
  99  * Abort processing of a JPEG decompression operation,
 100  * but don't destroy the object itself.
 101  */
 102 
 103 GLOBAL(void)
 104 jpeg_abort_decompress (j_decompress_ptr cinfo)
 105 {
 106   jpeg_abort((j_common_ptr) cinfo); /* use common routine */
 107 }
 108 
 109 
 110 /*
 111  * Set default decompression parameters.
 112  */
 113 
 114 LOCAL(void)
 115 default_decompress_parms (j_decompress_ptr cinfo)
 116 {


 117   /* Guess the input colorspace, and set output colorspace accordingly. */
 118   /* (Wish JPEG committee had provided a real way to specify this...) */
 119   /* Note application may override our guesses. */
 120   switch (cinfo->num_components) {
 121   case 1:
 122     cinfo->jpeg_color_space = JCS_GRAYSCALE;
 123     cinfo->out_color_space = JCS_GRAYSCALE;
 124     break;
 125 
 126   case 3:
 127     if (cinfo->saw_JFIF_marker) {
 128       cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
 129     } else if (cinfo->saw_Adobe_marker) {













 130       switch (cinfo->Adobe_transform) {
 131       case 0:
 132         cinfo->jpeg_color_space = JCS_RGB;
 133         break;
 134       case 1:
 135         cinfo->jpeg_color_space = JCS_YCbCr;
 136         break;
 137       default:
 138         WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
 139         cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
 140         break;
 141       }
 142     } else {
 143       /* Saw no special markers, try to guess from the component IDs */
 144       int cid0 = cinfo->comp_info[0].component_id;
 145       int cid1 = cinfo->comp_info[1].component_id;
 146       int cid2 = cinfo->comp_info[2].component_id;
 147 
 148       if (cid0 == 1 && cid1 == 2 && cid2 == 3)
 149         cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
 150       else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
 151         cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
 152       else {
 153         TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
 154         cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
 155       }
 156     }
 157     /* Always guess RGB is proper output colorspace. */
 158     cinfo->out_color_space = JCS_RGB;
 159     break;
 160 
 161   case 4:
 162     if (cinfo->saw_Adobe_marker) {
 163       switch (cinfo->Adobe_transform) {
 164       case 0:
 165         cinfo->jpeg_color_space = JCS_CMYK;
 166         break;
 167       case 2:
 168         cinfo->jpeg_color_space = JCS_YCCK;
 169         break;
 170       default:
 171         WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
 172         cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
 173         break;
 174       }
 175     } else {
 176       /* No special markers, assume straight CMYK. */
 177       cinfo->jpeg_color_space = JCS_CMYK;
 178     }
 179     cinfo->out_color_space = JCS_CMYK;
 180     break;
 181 
 182   default:
 183     cinfo->jpeg_color_space = JCS_UNKNOWN;
 184     cinfo->out_color_space = JCS_UNKNOWN;
 185     break;
 186   }
 187 
 188   /* Set defaults for other decompression parameters. */
 189   cinfo->scale_num = DCTSIZE;           /* 1:1 scaling */
 190   cinfo->scale_denom = DCTSIZE;
 191   cinfo->output_gamma = 1.0;
 192   cinfo->buffered_image = FALSE;
 193   cinfo->raw_data_out = FALSE;
 194   cinfo->dct_method = JDCT_DEFAULT;
 195   cinfo->do_fancy_upsampling = TRUE;
 196   cinfo->do_block_smoothing = TRUE;
 197   cinfo->quantize_colors = FALSE;
 198   /* We set these in case application only sets quantize_colors. */
 199   cinfo->dither_mode = JDITHER_FS;
 200 #ifdef QUANT_2PASS_SUPPORTED
 201   cinfo->two_pass_quantize = TRUE;
 202 #else
 203   cinfo->two_pass_quantize = FALSE;
 204 #endif
 205   cinfo->desired_number_of_colors = 256;
 206   cinfo->colormap = NULL;
 207   /* Initialize for no mode change in buffered-image mode. */
 208   cinfo->enable_1pass_quant = FALSE;
 209   cinfo->enable_external_quant = FALSE;
 210   cinfo->enable_2pass_quant = FALSE;


   1 /*
   2  * jdapimin.c
   3  *
   4  * Copyright (C) 1994-1998, Thomas G. Lane.
   5  * Modified 2009-2013 by Guido Vollbeding.
   6  * This file is part of the Independent JPEG Group's software.
   7  * For conditions of distribution and use, see the accompanying README file.
   8  *
   9  * This file contains application interface code for the decompression half
  10  * of the JPEG library.  These are the "minimum" API routines that may be
  11  * needed in either the normal full-decompression case or the
  12  * transcoding-only case.
  13  *
  14  * Most of the routines intended to be called directly by an application
  15  * are in this file or in jdapistd.c.  But also see jcomapi.c for routines
  16  * shared by compression and decompression, and jdtrans.c for the transcoding
  17  * case.
  18  */
  19 
  20 #define JPEG_INTERNALS
  21 #include "jinclude.h"
  22 #include "jpeglib.h"
  23 
  24 
  25 /*


  97 
  98 /*
  99  * Abort processing of a JPEG decompression operation,
 100  * but don't destroy the object itself.
 101  */
 102 
 103 GLOBAL(void)
 104 jpeg_abort_decompress (j_decompress_ptr cinfo)
 105 {
 106   jpeg_abort((j_common_ptr) cinfo); /* use common routine */
 107 }
 108 
 109 
 110 /*
 111  * Set default decompression parameters.
 112  */
 113 
 114 LOCAL(void)
 115 default_decompress_parms (j_decompress_ptr cinfo)
 116 {
 117   int cid0, cid1, cid2;
 118 
 119   /* Guess the input colorspace, and set output colorspace accordingly. */

 120   /* Note application may override our guesses. */
 121   switch (cinfo->num_components) {
 122   case 1:
 123     cinfo->jpeg_color_space = JCS_GRAYSCALE;
 124     cinfo->out_color_space = JCS_GRAYSCALE;
 125     break;
 126     
 127   case 3:
 128     cid0 = cinfo->comp_info[0].component_id;
 129     cid1 = cinfo->comp_info[1].component_id;
 130     cid2 = cinfo->comp_info[2].component_id;
 131 
 132     /* First try to guess from the component IDs */
 133     if      (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03)
 134       cinfo->jpeg_color_space = JCS_YCbCr;
 135     else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23)
 136       cinfo->jpeg_color_space = JCS_BG_YCC;
 137     else if (cid0 == 0x52 && cid1 == 0x47 && cid2 == 0x42)
 138       cinfo->jpeg_color_space = JCS_RGB;     /* ASCII 'R', 'G', 'B' */
 139     else if (cid0 == 0x72 && cid1 == 0x67 && cid2 == 0x62)
 140       cinfo->jpeg_color_space = JCS_BG_RGB;  /* ASCII 'r', 'g', 'b' */
 141     else if (cinfo->saw_JFIF_marker)
 142       cinfo->jpeg_color_space = JCS_YCbCr;   /* assume it's YCbCr */
 143     else if (cinfo->saw_Adobe_marker) {
 144       switch (cinfo->Adobe_transform) {
 145       case 0:
 146         cinfo->jpeg_color_space = JCS_RGB;
 147         break;
 148       case 1:
 149         cinfo->jpeg_color_space = JCS_YCbCr;
 150         break;
 151       default:
 152         WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
 153         cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
 154         break;
 155       }
 156     } else {










 157       TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
 158       cinfo->jpeg_color_space = JCS_YCbCr;   /* assume it's YCbCr */
 159     }

 160     /* Always guess RGB is proper output colorspace. */
 161     cinfo->out_color_space = JCS_RGB;
 162     break;
 163     
 164   case 4:
 165     if (cinfo->saw_Adobe_marker) {
 166       switch (cinfo->Adobe_transform) {
 167       case 0:
 168         cinfo->jpeg_color_space = JCS_CMYK;
 169         break;
 170       case 2:
 171         cinfo->jpeg_color_space = JCS_YCCK;
 172         break;
 173       default:
 174         WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
 175         cinfo->jpeg_color_space = JCS_YCCK;  /* assume it's YCCK */
 176         break;
 177       }
 178     } else {
 179       /* No special markers, assume straight CMYK. */
 180       cinfo->jpeg_color_space = JCS_CMYK;
 181     }
 182     cinfo->out_color_space = JCS_CMYK;
 183     break;
 184     
 185   default:
 186     cinfo->jpeg_color_space = JCS_UNKNOWN;
 187     cinfo->out_color_space = JCS_UNKNOWN;
 188     break;
 189   }
 190 
 191   /* Set defaults for other decompression parameters. */
 192   cinfo->scale_num = cinfo->block_size;           /* 1:1 scaling */
 193   cinfo->scale_denom = cinfo->block_size;
 194   cinfo->output_gamma = 1.0;
 195   cinfo->buffered_image = FALSE;
 196   cinfo->raw_data_out = FALSE;
 197   cinfo->dct_method = JDCT_DEFAULT;
 198   cinfo->do_fancy_upsampling = TRUE;
 199   cinfo->do_block_smoothing = TRUE;
 200   cinfo->quantize_colors = FALSE;
 201   /* We set these in case application only sets quantize_colors. */
 202   cinfo->dither_mode = JDITHER_FS;
 203 #ifdef QUANT_2PASS_SUPPORTED
 204   cinfo->two_pass_quantize = TRUE;
 205 #else
 206   cinfo->two_pass_quantize = FALSE;
 207 #endif
 208   cinfo->desired_number_of_colors = 256;
 209   cinfo->colormap = NULL;
 210   /* Initialize for no mode change in buffered-image mode. */
 211   cinfo->enable_1pass_quant = FALSE;
 212   cinfo->enable_external_quant = FALSE;
 213   cinfo->enable_2pass_quant = FALSE;


< prev index next >