0N/A * reserved comment block 0N/A * DO NOT REMOVE OR ALTER! 0N/A * Copyright (C) 1994-1996, Thomas G. Lane. 0N/A * This file is part of the Independent JPEG Group's software. 0N/A * For conditions of distribution and use, see the accompanying README file. 0N/A * read those files first to understand what's going on. 0N/A * When the chroma components are to be upsampled by simple replication 0N/A * (ie, box filtering), we can save some work in color conversion by 0N/A * calculating all the output pixels corresponding to a pair of chroma 0N/A * samples at one time. In the conversion equations 0N/A * G = Y + K2 * Cb + K3 * Cr 0N/A * only the Y term varies among the group of pixels corresponding to a pair 0N/A * of chroma samples, so the rest of the terms can be calculated just once. 0N/A * At typical sampling ratios, this eliminates half or three-quarters of the 0N/A * multiplications needed for color conversion. 0N/A * This file currently provides implementations for the following cases: 0N/A * YCbCr => RGB color conversion only. 0N/A * Sampling ratios of 2h1v or 2h2v. 0N/A * No scaling needed at upsample time. 0N/A * Corner-aligned (non-CCIR601) sampling alignment. 0N/A * Other special cases could be added, but in most applications these are 0N/A * the only common cases. (For uncommon cases we fall back on the more 0N/A/* Private subobject */ 0N/A /* Private state for YCC->RGB conversion */ 0N/A /* For 2:1 vertical sampling, we produce two output rows at a time. 0N/A * We need a "spare" row buffer to hold the second output row if the 0N/A * application provides just a one-row buffer; we also use the spare 0N/A * to discard the dummy last row if the image height is odd. 0N/A#
define SCALEBITS 16 /* speediest right-shift on some machines */ 0N/A * Initialize tables for YCC->RGB colorspace conversion. 0N/A * This is taken directly from jdcolor.c; see that file for more info. 0N/A /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ 0N/A /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ 0N/A /* Cr=>R value is nearest int to 1.40200 * x */ 0N/A /* Cb=>B value is nearest int to 1.77200 * x */ 0N/A /* Cr=>G value is scaled-up -0.71414 * x */ 0N/A /* Cb=>G value is scaled-up -0.34414 * x */ 0N/A /* We also add in ONE_HALF so that need not do it in inner loop */ 0N/A * Initialize for an upsampling pass. 0N/A /* Mark the spare buffer empty */ 0N/A /* Initialize total-height counter for detecting bottom of image */ 0N/A * Control routine to do upsampling (and color conversion). 0N/A * The control routine just handles the row buffering considerations. 0N/A/* 2:1 vertical sampling case: may need a spare row. */ 0N/A /* If we have a spare row saved from a previous cycle, just return it. */ 0N/A /* Figure number of rows to return to caller. */ 0N/A /* Not more than the distance to the end of the image. */ 0N/A /* And not more than what the client can accept: */ 0N/A /* Create output pointer array for upsampler. */ 0N/A /* Now do the upsampling. */ 0N/A /* When the buffer is emptied, declare this input row group consumed */ 0N/A/* 1:1 vertical sampling case: much easier, never need a spare row. */ 0N/A /* Just do the upsampling. */ 0N/A * These are the routines invoked by the control routines to do 0N/A * Note: since we may be writing directly into application-supplied buffers, 0N/A * we have to be honest about the output width; we can't assume the buffer 0N/A * has been rounded up to an even width. 0N/A * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. 0N/A /* copy these pointers into registers if possible */ 0N/A /* Loop for each pair of output pixels */ 0N/A /* Do the chroma part of the calculation */ 0N/A /* Fetch 2 Y values and emit 2 pixels */ 0N/A /* If image width is odd, do the last output column separately */ 0N/A * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. 0N/A /* copy these pointers into registers if possible */ 0N/A /* Loop for each group of output pixels */ 0N/A /* Do the chroma part of the calculation */ 0N/A /* Fetch 4 Y values and emit 4 pixels */ 0N/A /* If image width is odd, do the last output column separately */ 0N/A * NB: this is called under the conditions determined by use_merged_upsample() 0N/A * in jdmaster.c. That routine MUST correspond to the actual capabilities 0N/A * of this module; no safety checks are made here. 0N/A /* Allocate a spare row buffer */ 0N/A /* No spare row needed */ 0N/A#
endif /* UPSAMPLE_MERGING_SUPPORTED */