0N/A/*
0N/A * reserved comment block
0N/A * DO NOT REMOVE OR ALTER!
0N/A */
0N/A/*
0N/A * jcsample.c
0N/A *
0N/A * Copyright (C) 1991-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 *
0N/A * This file contains downsampling routines.
0N/A *
0N/A * Downsampling input data is counted in "row groups". A row group
0N/A * is defined to be max_v_samp_factor pixel rows of each component,
0N/A * from which the downsampler produces v_samp_factor sample rows.
0N/A * A single row group is processed in each call to the downsampler module.
0N/A *
0N/A * The downsampler is responsible for edge-expansion of its output data
0N/A * to fill an integral number of DCT blocks horizontally. The source buffer
0N/A * may be modified if it is helpful for this purpose (the source buffer is
0N/A * allocated wide enough to correspond to the desired output width).
0N/A * The caller (the prep controller) is responsible for vertical padding.
0N/A *
0N/A * The downsampler may request "context rows" by setting need_context_rows
0N/A * during startup. In this case, the input arrays will contain at least
0N/A * one row group's worth of pixels above and below the passed-in data;
0N/A * the caller will create dummy rows at image top and bottom by replicating
0N/A * the first or last real pixel row.
0N/A *
0N/A * An excellent reference for image resampling is
0N/A * Digital Image Warping, George Wolberg, 1990.
0N/A * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.
0N/A *
0N/A * The downsampling algorithm used here is a simple average of the source
0N/A * pixels covered by the output pixel. The hi-falutin sampling literature
0N/A * refers to this as a "box filter". In general the characteristics of a box
0N/A * filter are not very good, but for the specific cases we normally use (1:1
0N/A * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not
0N/A * nearly so bad. If you intend to use other sampling ratios, you'd be well
0N/A * advised to improve this code.
0N/A *
0N/A * A simple input-smoothing capability is provided. This is mainly intended
0N/A * for cleaning up color-dithered GIF input files (if you find it inadequate,
0N/A * we suggest using an external filtering program such as pnmconvol). When
0N/A * enabled, each input pixel P is replaced by a weighted sum of itself and its
0N/A * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF,
0N/A * where SF = (smoothing_factor / 1024).
0N/A * Currently, smoothing is only supported for 2h2v sampling factors.
0N/A */
0N/A
0N/A#define JPEG_INTERNALS
0N/A#include "jinclude.h"
0N/A#include "jpeglib.h"
0N/A
0N/A
0N/A/* Pointer to routine to downsample a single component */
0N/Atypedef JMETHOD(void, downsample1_ptr,
0N/A (j_compress_ptr cinfo, jpeg_component_info * compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data));
0N/A
0N/A/* Private subobject */
0N/A
0N/Atypedef struct {
0N/A struct jpeg_downsampler pub; /* public fields */
0N/A
0N/A /* Downsampling method pointers, one per component */
0N/A downsample1_ptr methods[MAX_COMPONENTS];
0N/A} my_downsampler;
0N/A
0N/Atypedef my_downsampler * my_downsample_ptr;
0N/A
0N/A
0N/A/*
0N/A * Initialize for a downsampling pass.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Astart_pass_downsample (j_compress_ptr cinfo)
0N/A{
0N/A /* no work for now */
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Expand a component horizontally from width input_cols to width output_cols,
0N/A * by duplicating the rightmost samples.
0N/A */
0N/A
0N/ALOCAL(void)
0N/Aexpand_right_edge (JSAMPARRAY image_data, int num_rows,
0N/A JDIMENSION input_cols, JDIMENSION output_cols)
0N/A{
0N/A register JSAMPROW ptr;
0N/A register JSAMPLE pixval;
0N/A register int count;
0N/A int row;
0N/A int numcols = (int) (output_cols - input_cols);
0N/A
0N/A if (numcols > 0) {
0N/A for (row = 0; row < num_rows; row++) {
0N/A ptr = image_data[row] + input_cols;
0N/A pixval = ptr[-1]; /* don't need GETJSAMPLE() here */
0N/A for (count = numcols; count > 0; count--)
0N/A *ptr++ = pixval;
0N/A }
0N/A }
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Do downsampling for a whole row group (all components).
0N/A *
0N/A * In this version we simply downsample each component independently.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Asep_downsample (j_compress_ptr cinfo,
0N/A JSAMPIMAGE input_buf, JDIMENSION in_row_index,
0N/A JSAMPIMAGE output_buf, JDIMENSION out_row_group_index)
0N/A{
0N/A my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
0N/A int ci;
0N/A jpeg_component_info * compptr;
0N/A JSAMPARRAY in_ptr, out_ptr;
0N/A
0N/A for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
0N/A ci++, compptr++) {
0N/A in_ptr = input_buf[ci] + in_row_index;
0N/A out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
0N/A (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
0N/A }
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Downsample pixel values of a single component.
0N/A * One row group is processed per call.
0N/A * This version handles arbitrary integral sampling ratios, without smoothing.
0N/A * Note that this version is not actually used for customary sampling ratios.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Aint_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data)
0N/A{
0N/A int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
0N/A JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
0N/A JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
0N/A JSAMPROW inptr, outptr;
0N/A INT32 outvalue;
0N/A
0N/A h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
0N/A v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
0N/A numpix = h_expand * v_expand;
0N/A numpix2 = numpix/2;
0N/A
0N/A /* Expand input data enough to let all the output samples be generated
0N/A * by the standard loop. Special-casing padded output would be more
0N/A * efficient.
0N/A */
0N/A expand_right_edge(input_data, cinfo->max_v_samp_factor,
0N/A cinfo->image_width, output_cols * h_expand);
0N/A
0N/A inrow = 0;
0N/A for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
0N/A outptr = output_data[outrow];
0N/A for (outcol = 0, outcol_h = 0; outcol < output_cols;
0N/A outcol++, outcol_h += h_expand) {
0N/A outvalue = 0;
0N/A for (v = 0; v < v_expand; v++) {
0N/A inptr = input_data[inrow+v] + outcol_h;
0N/A for (h = 0; h < h_expand; h++) {
0N/A outvalue += (INT32) GETJSAMPLE(*inptr++);
0N/A }
0N/A }
0N/A *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
0N/A }
0N/A inrow += v_expand;
0N/A }
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Downsample pixel values of a single component.
0N/A * This version handles the special case of a full-size component,
0N/A * without smoothing.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Afullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data)
0N/A{
0N/A /* Copy the data */
0N/A jcopy_sample_rows(input_data, 0, output_data, 0,
0N/A cinfo->max_v_samp_factor, cinfo->image_width);
0N/A /* Edge-expand */
0N/A expand_right_edge(output_data, cinfo->max_v_samp_factor,
0N/A cinfo->image_width, compptr->width_in_blocks * DCTSIZE);
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Downsample pixel values of a single component.
0N/A * This version handles the common case of 2:1 horizontal and 1:1 vertical,
0N/A * without smoothing.
0N/A *
0N/A * A note about the "bias" calculations: when rounding fractional values to
0N/A * integer, we do not want to always round 0.5 up to the next integer.
0N/A * If we did that, we'd introduce a noticeable bias towards larger values.
0N/A * Instead, this code is arranged so that 0.5 will be rounded up or down at
0N/A * alternate pixel locations (a simple ordered dither pattern).
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Ah2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data)
0N/A{
0N/A int outrow;
0N/A JDIMENSION outcol;
0N/A JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
0N/A register JSAMPROW inptr, outptr;
0N/A register int bias;
0N/A
0N/A /* Expand input data enough to let all the output samples be generated
0N/A * by the standard loop. Special-casing padded output would be more
0N/A * efficient.
0N/A */
0N/A expand_right_edge(input_data, cinfo->max_v_samp_factor,
0N/A cinfo->image_width, output_cols * 2);
0N/A
0N/A for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
0N/A outptr = output_data[outrow];
0N/A inptr = input_data[outrow];
0N/A bias = 0; /* bias = 0,1,0,1,... for successive samples */
0N/A for (outcol = 0; outcol < output_cols; outcol++) {
0N/A *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
0N/A + bias) >> 1);
0N/A bias ^= 1; /* 0=>1, 1=>0 */
0N/A inptr += 2;
0N/A }
0N/A }
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Downsample pixel values of a single component.
0N/A * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
0N/A * without smoothing.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Ah2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data)
0N/A{
0N/A int inrow, outrow;
0N/A JDIMENSION outcol;
0N/A JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
0N/A register JSAMPROW inptr0, inptr1, outptr;
0N/A register int bias;
0N/A
0N/A /* Expand input data enough to let all the output samples be generated
0N/A * by the standard loop. Special-casing padded output would be more
0N/A * efficient.
0N/A */
0N/A expand_right_edge(input_data, cinfo->max_v_samp_factor,
0N/A cinfo->image_width, output_cols * 2);
0N/A
0N/A inrow = 0;
0N/A for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
0N/A outptr = output_data[outrow];
0N/A inptr0 = input_data[inrow];
0N/A inptr1 = input_data[inrow+1];
0N/A bias = 1; /* bias = 1,2,1,2,... for successive samples */
0N/A for (outcol = 0; outcol < output_cols; outcol++) {
0N/A *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
0N/A GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1])
0N/A + bias) >> 2);
0N/A bias ^= 3; /* 1=>2, 2=>1 */
0N/A inptr0 += 2; inptr1 += 2;
0N/A }
0N/A inrow += 2;
0N/A }
0N/A}
0N/A
0N/A
0N/A#ifdef INPUT_SMOOTHING_SUPPORTED
0N/A
0N/A/*
0N/A * Downsample pixel values of a single component.
0N/A * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
0N/A * with smoothing. One row of context is required.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Ah2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data)
0N/A{
0N/A int inrow, outrow;
0N/A JDIMENSION colctr;
0N/A JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
0N/A register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
0N/A INT32 membersum, neighsum, memberscale, neighscale;
0N/A
0N/A /* Expand input data enough to let all the output samples be generated
0N/A * by the standard loop. Special-casing padded output would be more
0N/A * efficient.
0N/A */
0N/A expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,
0N/A cinfo->image_width, output_cols * 2);
0N/A
0N/A /* We don't bother to form the individual "smoothed" input pixel values;
0N/A * we can directly compute the output which is the average of the four
0N/A * smoothed values. Each of the four member pixels contributes a fraction
0N/A * (1-8*SF) to its own smoothed image and a fraction SF to each of the three
0N/A * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final
0N/A * output. The four corner-adjacent neighbor pixels contribute a fraction
0N/A * SF to just one smoothed pixel, or SF/4 to the final output; while the
0N/A * eight edge-adjacent neighbors contribute SF to each of two smoothed
0N/A * pixels, or SF/2 overall. In order to use integer arithmetic, these
0N/A * factors are scaled by 2^16 = 65536.
0N/A * Also recall that SF = smoothing_factor / 1024.
0N/A */
0N/A
0N/A memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */
0N/A neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */
0N/A
0N/A inrow = 0;
0N/A for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
0N/A outptr = output_data[outrow];
0N/A inptr0 = input_data[inrow];
0N/A inptr1 = input_data[inrow+1];
0N/A above_ptr = input_data[inrow-1];
0N/A below_ptr = input_data[inrow+2];
0N/A
0N/A /* Special case for first column: pretend column -1 is same as column 0 */
0N/A membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
0N/A GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);
0N/A neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +
0N/A GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +
0N/A GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) +
0N/A GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]);
0N/A neighsum += neighsum;
0N/A neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) +
0N/A GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);
0N/A membersum = membersum * memberscale + neighsum * neighscale;
0N/A *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
0N/A inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
0N/A
0N/A for (colctr = output_cols - 2; colctr > 0; colctr--) {
0N/A /* sum of pixels directly mapped to this output element */
0N/A membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
0N/A GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);
0N/A /* sum of edge-neighbor pixels */
0N/A neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +
0N/A GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +
0N/A GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) +
0N/A GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]);
0N/A /* The edge-neighbors count twice as much as corner-neighbors */
0N/A neighsum += neighsum;
0N/A /* Add in the corner-neighbors */
0N/A neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) +
0N/A GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]);
0N/A /* form final output scaled up by 2^16 */
0N/A membersum = membersum * memberscale + neighsum * neighscale;
0N/A /* round, descale and output it */
0N/A *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
0N/A inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
0N/A }
0N/A
0N/A /* Special case for last column */
0N/A membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
0N/A GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);
0N/A neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +
0N/A GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +
0N/A GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) +
0N/A GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]);
0N/A neighsum += neighsum;
0N/A neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) +
0N/A GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]);
0N/A membersum = membersum * memberscale + neighsum * neighscale;
0N/A *outptr = (JSAMPLE) ((membersum + 32768) >> 16);
0N/A
0N/A inrow += 2;
0N/A }
0N/A}
0N/A
0N/A
0N/A/*
0N/A * Downsample pixel values of a single component.
0N/A * This version handles the special case of a full-size component,
0N/A * with smoothing. One row of context is required.
0N/A */
0N/A
0N/AMETHODDEF(void)
0N/Afullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
0N/A JSAMPARRAY input_data, JSAMPARRAY output_data)
0N/A{
0N/A int outrow;
0N/A JDIMENSION colctr;
0N/A JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
0N/A register JSAMPROW inptr, above_ptr, below_ptr, outptr;
0N/A INT32 membersum, neighsum, memberscale, neighscale;
0N/A int colsum, lastcolsum, nextcolsum;
0N/A
0N/A /* Expand input data enough to let all the output samples be generated
0N/A * by the standard loop. Special-casing padded output would be more
0N/A * efficient.
0N/A */
0N/A expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,
0N/A cinfo->image_width, output_cols);
0N/A
0N/A /* Each of the eight neighbor pixels contributes a fraction SF to the
0N/A * smoothed pixel, while the main pixel contributes (1-8*SF). In order
0N/A * to use integer arithmetic, these factors are multiplied by 2^16 = 65536.
0N/A * Also recall that SF = smoothing_factor / 1024.
0N/A */
0N/A
0N/A memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */
0N/A neighscale = cinfo->smoothing_factor * 64; /* scaled SF */
0N/A
0N/A for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
0N/A outptr = output_data[outrow];
0N/A inptr = input_data[outrow];
0N/A above_ptr = input_data[outrow-1];
0N/A below_ptr = input_data[outrow+1];
0N/A
0N/A /* Special case for first column */
0N/A colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) +
0N/A GETJSAMPLE(*inptr);
0N/A membersum = GETJSAMPLE(*inptr++);
0N/A nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +
0N/A GETJSAMPLE(*inptr);
0N/A neighsum = colsum + (colsum - membersum) + nextcolsum;
0N/A membersum = membersum * memberscale + neighsum * neighscale;
0N/A *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
0N/A lastcolsum = colsum; colsum = nextcolsum;
0N/A
0N/A for (colctr = output_cols - 2; colctr > 0; colctr--) {
0N/A membersum = GETJSAMPLE(*inptr++);
0N/A above_ptr++; below_ptr++;
0N/A nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +
0N/A GETJSAMPLE(*inptr);
0N/A neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
0N/A membersum = membersum * memberscale + neighsum * neighscale;
0N/A *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
0N/A lastcolsum = colsum; colsum = nextcolsum;
0N/A }
0N/A
0N/A /* Special case for last column */
0N/A membersum = GETJSAMPLE(*inptr);
0N/A neighsum = lastcolsum + (colsum - membersum) + colsum;
0N/A membersum = membersum * memberscale + neighsum * neighscale;
0N/A *outptr = (JSAMPLE) ((membersum + 32768) >> 16);
0N/A
0N/A }
0N/A}
0N/A
0N/A#endif /* INPUT_SMOOTHING_SUPPORTED */
0N/A
0N/A
0N/A/*
0N/A * Module initialization routine for downsampling.
0N/A * Note that we must select a routine for each component.
0N/A */
0N/A
0N/AGLOBAL(void)
0N/Ajinit_downsampler (j_compress_ptr cinfo)
0N/A{
0N/A my_downsample_ptr downsample;
0N/A int ci;
0N/A jpeg_component_info * compptr;
0N/A boolean smoothok = TRUE;
0N/A
0N/A downsample = (my_downsample_ptr)
0N/A (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
0N/A SIZEOF(my_downsampler));
0N/A cinfo->downsample = (struct jpeg_downsampler *) downsample;
0N/A downsample->pub.start_pass = start_pass_downsample;
0N/A downsample->pub.downsample = sep_downsample;
0N/A downsample->pub.need_context_rows = FALSE;
0N/A
0N/A if (cinfo->CCIR601_sampling)
0N/A ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
0N/A
0N/A /* Verify we can handle the sampling factors, and set up method pointers */
0N/A for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
0N/A ci++, compptr++) {
0N/A if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
0N/A compptr->v_samp_factor == cinfo->max_v_samp_factor) {
0N/A#ifdef INPUT_SMOOTHING_SUPPORTED
0N/A if (cinfo->smoothing_factor) {
0N/A downsample->methods[ci] = fullsize_smooth_downsample;
0N/A downsample->pub.need_context_rows = TRUE;
0N/A } else
0N/A#endif
0N/A downsample->methods[ci] = fullsize_downsample;
0N/A } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
0N/A compptr->v_samp_factor == cinfo->max_v_samp_factor) {
0N/A smoothok = FALSE;
0N/A downsample->methods[ci] = h2v1_downsample;
0N/A } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
0N/A compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
0N/A#ifdef INPUT_SMOOTHING_SUPPORTED
0N/A if (cinfo->smoothing_factor) {
0N/A downsample->methods[ci] = h2v2_smooth_downsample;
0N/A downsample->pub.need_context_rows = TRUE;
0N/A } else
0N/A#endif
0N/A downsample->methods[ci] = h2v2_downsample;
0N/A } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
0N/A (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
0N/A smoothok = FALSE;
0N/A downsample->methods[ci] = int_downsample;
0N/A } else
0N/A ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
0N/A }
0N/A
0N/A#ifdef INPUT_SMOOTHING_SUPPORTED
0N/A if (cinfo->smoothing_factor && !smoothok)
0N/A TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
0N/A#endif
0N/A}