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/jdsample.c

    r2 r846  
    33 *
    44 * Copyright (C) 1991-1996, Thomas G. Lane.
     5 * Modified 2002-2008 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.
     
    910 *
    1011 * Upsampling input data is counted in "row groups".  A row group
    11  * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size)
     12 * is defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size)
    1213 * sample rows of each component.  Upsampling will normally produce
    1314 * max_v_samp_factor pixel rows from each row group (but this could vary
     
    238239  register JSAMPLE invalue;
    239240  JSAMPROW outend;
    240   int inrow;
    241 
    242   for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
    243     inptr = input_data[inrow];
    244     outptr = output_data[inrow];
     241  int outrow;
     242
     243  for (outrow = 0; outrow < cinfo->max_v_samp_factor; outrow++) {
     244    inptr = input_data[outrow];
     245    outptr = output_data[outrow];
    245246    outend = outptr + cinfo->output_width;
    246247    while (outptr < outend) {
     
    287288
    288289/*
    289  * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
    290  *
    291  * The upsampling algorithm is linear interpolation between pixel centers,
    292  * also known as a "triangle filter".  This is a good compromise between
    293  * speed and visual quality.  The centers of the output pixels are 1/4 and 3/4
    294  * of the way between input pixel centers.
    295  *
    296  * A note about the "bias" calculations: when rounding fractional values to
    297  * integer, we do not want to always round 0.5 up to the next integer.
    298  * If we did that, we'd introduce a noticeable bias towards larger values.
    299  * Instead, this code is arranged so that 0.5 will be rounded up or down at
    300  * alternate pixel locations (a simple ordered dither pattern).
    301  */
    302 
    303 METHODDEF(void)
    304 h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    305                      JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
    306 {
    307   JSAMPARRAY output_data = *output_data_ptr;
    308   register JSAMPROW inptr, outptr;
    309   register int invalue;
    310   register JDIMENSION colctr;
    311   int inrow;
    312 
    313   for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
    314     inptr = input_data[inrow];
    315     outptr = output_data[inrow];
    316     /* Special case for first column */
    317     invalue = GETJSAMPLE(*inptr++);
    318     *outptr++ = (JSAMPLE) invalue;
    319     *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);
    320 
    321     for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
    322       /* General case: 3/4 * nearer pixel + 1/4 * further pixel */
    323       invalue = GETJSAMPLE(*inptr++) * 3;
    324       *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);
    325       *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2);
    326     }
    327 
    328     /* Special case for last column */
    329     invalue = GETJSAMPLE(*inptr);
    330     *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);
    331     *outptr++ = (JSAMPLE) invalue;
    332   }
    333 }
    334 
    335 
    336 /*
    337  * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
    338  * Again a triangle filter; see comments for h2v1 case, above.
    339  *
    340  * It is OK for us to reference the adjacent input rows because we demanded
    341  * context from the main buffer controller (see initialization code).
    342  */
    343 
    344 METHODDEF(void)
    345 h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
    346                      JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
    347 {
    348   JSAMPARRAY output_data = *output_data_ptr;
    349   register JSAMPROW inptr0, inptr1, outptr;
    350 #if BITS_IN_JSAMPLE == 8
    351   register int thiscolsum, lastcolsum, nextcolsum;
    352 #else
    353   register INT32 thiscolsum, lastcolsum, nextcolsum;
    354 #endif
    355   register JDIMENSION colctr;
    356   int inrow, outrow, v;
    357 
    358   inrow = outrow = 0;
    359   while (outrow < cinfo->max_v_samp_factor) {
    360     for (v = 0; v < 2; v++) {
    361       /* inptr0 points to nearest input row, inptr1 points to next nearest */
    362       inptr0 = input_data[inrow];
    363       if (v == 0)               /* next nearest is row above */
    364         inptr1 = input_data[inrow-1];
    365       else                      /* next nearest is row below */
    366         inptr1 = input_data[inrow+1];
    367       outptr = output_data[outrow++];
    368 
    369       /* Special case for first column */
    370       thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
    371       nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
    372       *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);
    373       *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
    374       lastcolsum = thiscolsum; thiscolsum = nextcolsum;
    375 
    376       for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
    377         /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
    378         /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
    379         nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
    380         *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
    381         *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
    382         lastcolsum = thiscolsum; thiscolsum = nextcolsum;
    383       }
    384 
    385       /* Special case for last column */
    386       *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
    387       *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);
    388     }
    389     inrow++;
    390   }
    391 }
    392 
    393 
    394 /*
    395290 * Module initialization routine for upsampling.
    396291 */
     
    402297  int ci;
    403298  jpeg_component_info * compptr;
    404   boolean need_buffer, do_fancy;
     299  boolean need_buffer;
    405300  int h_in_group, v_in_group, h_out_group, v_out_group;
    406301
     
    415310  if (cinfo->CCIR601_sampling)  /* this isn't supported */
    416311    ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
    417 
    418   /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
    419    * so don't ask for it.
    420    */
    421   do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1;
    422312
    423313  /* Verify we can handle the sampling factors, select per-component methods,
     
    429319     * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
    430320     */
    431     h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) /
    432                  cinfo->min_DCT_scaled_size;
    433     v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) /
    434                  cinfo->min_DCT_scaled_size;
     321    h_in_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) /
     322                 cinfo->min_DCT_h_scaled_size;
     323    v_in_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
     324                 cinfo->min_DCT_v_scaled_size;
    435325    h_out_group = cinfo->max_h_samp_factor;
    436326    v_out_group = cinfo->max_v_samp_factor;
     
    447337    } else if (h_in_group * 2 == h_out_group &&
    448338               v_in_group == v_out_group) {
    449       /* Special cases for 2h1v upsampling */
    450       if (do_fancy && compptr->downsampled_width > 2)
    451         upsample->methods[ci] = h2v1_fancy_upsample;
    452       else
    453         upsample->methods[ci] = h2v1_upsample;
     339      /* Special case for 2h1v upsampling */
     340      upsample->methods[ci] = h2v1_upsample;
    454341    } else if (h_in_group * 2 == h_out_group &&
    455342               v_in_group * 2 == v_out_group) {
    456       /* Special cases for 2h2v upsampling */
    457       if (do_fancy && compptr->downsampled_width > 2) {
    458         upsample->methods[ci] = h2v2_fancy_upsample;
    459         upsample->pub.need_context_rows = TRUE;
    460       } else
    461         upsample->methods[ci] = h2v2_upsample;
     343      /* Special case for 2h2v upsampling */
     344      upsample->methods[ci] = h2v2_upsample;
    462345    } else if ((h_out_group % h_in_group) == 0 &&
    463346               (v_out_group % v_in_group) == 0) {
Note: See TracChangeset for help on using the changeset viewer.