Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/libjpeg/jdmaster.c

    r2 r846  
    33 *
    44 * Copyright (C) 1991-1997, Thomas G. Lane.
     5 * Modified 2002-2009 by Guido Vollbeding.
    56 * This file is part of the Independent JPEG Group's software.
    67 * For conditions of distribution and use, see the accompanying README file.
     
    6263    return FALSE;
    6364  /* furthermore, it doesn't work if we've scaled the IDCTs differently */
    64   if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
    65       cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size ||
    66       cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size)
     65  if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
     66      cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
     67      cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
     68      cinfo->comp_info[0].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
     69      cinfo->comp_info[1].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
     70      cinfo->comp_info[2].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size)
    6771    return FALSE;
    6872  /* ??? also need to test for upsample-time rescaling, when & if supported */
     
    8387GLOBAL(void)
    8488jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
    85 /* Do computations that are needed before master selection phase */
     89/* Do computations that are needed before master selection phase.
     90 * This function is used for full decompression.
     91 */
    8692{
    8793#ifdef IDCT_SCALING_SUPPORTED
     
    94100    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
    95101
     102  /* Compute core output image dimensions and DCT scaling choices. */
     103  jpeg_core_output_dimensions(cinfo);
     104
    96105#ifdef IDCT_SCALING_SUPPORTED
    97106
    98   /* Compute actual output image dimensions and DCT scaling choices. */
    99   if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
    100     /* Provide 1/8 scaling */
    101     cinfo->output_width = (JDIMENSION)
    102       jdiv_round_up((long) cinfo->image_width, 8L);
    103     cinfo->output_height = (JDIMENSION)
    104       jdiv_round_up((long) cinfo->image_height, 8L);
    105     cinfo->min_DCT_scaled_size = 1;
    106   } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
    107     /* Provide 1/4 scaling */
    108     cinfo->output_width = (JDIMENSION)
    109       jdiv_round_up((long) cinfo->image_width, 4L);
    110     cinfo->output_height = (JDIMENSION)
    111       jdiv_round_up((long) cinfo->image_height, 4L);
    112     cinfo->min_DCT_scaled_size = 2;
    113   } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
    114     /* Provide 1/2 scaling */
    115     cinfo->output_width = (JDIMENSION)
    116       jdiv_round_up((long) cinfo->image_width, 2L);
    117     cinfo->output_height = (JDIMENSION)
    118       jdiv_round_up((long) cinfo->image_height, 2L);
    119     cinfo->min_DCT_scaled_size = 4;
    120   } else {
    121     /* Provide 1/1 scaling */
    122     cinfo->output_width = cinfo->image_width;
    123     cinfo->output_height = cinfo->image_height;
    124     cinfo->min_DCT_scaled_size = DCTSIZE;
    125   }
    126107  /* In selecting the actual DCT scaling for each component, we try to
    127108   * scale up the chroma components via IDCT scaling rather than upsampling.
    128109   * This saves time if the upsampler gets to use 1:1 scaling.
    129    * Note this code assumes that the supported DCT scalings are powers of 2.
     110   * Note this code adapts subsampling ratios which are powers of 2.
    130111   */
    131112  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
    132113       ci++, compptr++) {
    133     int ssize = cinfo->min_DCT_scaled_size;
    134     while (ssize < DCTSIZE &&
    135            (compptr->h_samp_factor * ssize * 2 <=
    136             cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) &&
    137            (compptr->v_samp_factor * ssize * 2 <=
    138             cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) {
     114    int ssize = 1;
     115    while (cinfo->min_DCT_h_scaled_size * ssize <=
     116           (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
     117           (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
    139118      ssize = ssize * 2;
    140119    }
    141     compptr->DCT_scaled_size = ssize;
     120    compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
     121    ssize = 1;
     122    while (cinfo->min_DCT_v_scaled_size * ssize <=
     123           (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
     124           (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
     125      ssize = ssize * 2;
     126    }
     127    compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
     128
     129    /* We don't support IDCT ratios larger than 2. */
     130    if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2)
     131        compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
     132    else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
     133        compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
    142134  }
    143135
     
    150142    compptr->downsampled_width = (JDIMENSION)
    151143      jdiv_round_up((long) cinfo->image_width *
    152                     (long) (compptr->h_samp_factor * compptr->DCT_scaled_size),
    153                     (long) (cinfo->max_h_samp_factor * DCTSIZE));
     144                    (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size),
     145                    (long) (cinfo->max_h_samp_factor * cinfo->block_size));
    154146    compptr->downsampled_height = (JDIMENSION)
    155147      jdiv_round_up((long) cinfo->image_height *
    156                     (long) (compptr->v_samp_factor * compptr->DCT_scaled_size),
    157                     (long) (cinfo->max_v_samp_factor * DCTSIZE));
    158   }
    159 
    160 #else /* !IDCT_SCALING_SUPPORTED */
    161 
    162   /* Hardwire it to "no scaling" */
    163   cinfo->output_width = cinfo->image_width;
    164   cinfo->output_height = cinfo->image_height;
    165   /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
    166    * and has computed unscaled downsampled_width and downsampled_height.
    167    */
     148                    (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
     149                    (long) (cinfo->max_v_samp_factor * cinfo->block_size));
     150  }
    168151
    169152#endif /* IDCT_SCALING_SUPPORTED */
     
    373356  jinit_inverse_dct(cinfo);
    374357  /* Entropy decoding: either Huffman or arithmetic coding. */
    375   if (cinfo->arith_code) {
    376     ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
    377   } else {
    378     if (cinfo->progressive_mode) {
    379 #ifdef D_PROGRESSIVE_SUPPORTED
    380       jinit_phuff_decoder(cinfo);
    381 #else
    382       ERREXIT(cinfo, JERR_NOT_COMPILED);
    383 #endif
    384     } else
    385       jinit_huff_decoder(cinfo);
     358  if (cinfo->arith_code)
     359    jinit_arith_decoder(cinfo);
     360  else {
     361    jinit_huff_decoder(cinfo);
    386362  }
    387363
Note: See TracChangeset for help on using the changeset viewer.