jcsample.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. /*
  2. * jcsample.c
  3. *
  4. * Copyright (C) 1991-1994, Thomas G. Lane.
  5. * This file is part of the Independent JPEG Group's software.
  6. * For conditions of distribution and use, see the accompanying README file.
  7. *
  8. * This file contains downsampling routines.
  9. *
  10. * Downsampling input data is counted in "row groups". A row group
  11. * is defined to be max_v_samp_factor pixel rows of each component,
  12. * from which the downsampler produces v_samp_factor sample rows.
  13. * A single row group is processed in each call to the downsampler module.
  14. *
  15. * The downsampler is responsible for edge-expansion of its output data
  16. * to fill an integral number of DCT blocks horizontally. The source buffer
  17. * may be modified if it is helpful for this purpose (the source buffer is
  18. * allocated wide enough to correspond to the desired output width).
  19. * The caller (the prep controller) is responsible for vertical padding.
  20. *
  21. * The downsampler may request "context rows" by setting need_context_rows
  22. * during startup. In this case, the input arrays will contain at least
  23. * one row group's worth of pixels above and below the passed-in data;
  24. * the caller will create dummy rows at image top and bottom by replicating
  25. * the first or last real pixel row.
  26. *
  27. * An excellent reference for image resampling is
  28. * Digital Image Warping, George Wolberg, 1990.
  29. * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.
  30. *
  31. * The downsampling algorithm used here is a simple average of the source
  32. * pixels covered by the output pixel. The hi-falutin sampling literature
  33. * refers to this as a "box filter". In general the characteristics of a box
  34. * filter are not very good, but for the specific cases we normally use (1:1
  35. * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not
  36. * nearly so bad. If you intend to use other sampling ratios, you'd be well
  37. * advised to improve this code.
  38. *
  39. * A simple input-smoothing capability is provided. This is mainly intended
  40. * for cleaning up color-dithered GIF input files (if you find it inadequate,
  41. * we suggest using an external filtering program such as pnmconvol). When
  42. * enabled, each input pixel P is replaced by a weighted sum of itself and its
  43. * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF,
  44. * where SF = (smoothing_factor / 1024).
  45. * Currently, smoothing is only supported for 2h2v sampling factors.
  46. */
  47. // leave this as first line for PCH reasons...
  48. //
  49. #include "../server/exe_headers.h"
  50. #define JPEG_INTERNALS
  51. #include "jinclude.h"
  52. #include "jpeglib.h"
  53. /* Pointer to routine to downsample a single component */
  54. typedef JMETHOD(void, downsample1_ptr,
  55. (j_compress_ptr cinfo, jpeg_component_info * compptr,
  56. JSAMPARRAY input_data, JSAMPARRAY output_data));
  57. /* Private subobject */
  58. typedef struct {
  59. struct jpeg_downsampler pub; /* public fields */
  60. /* Downsampling method pointers, one per component */
  61. downsample1_ptr methods[MAX_COMPONENTS];
  62. } my_downsampler;
  63. typedef my_downsampler * my_downsample_ptr;
  64. /*
  65. * Initialize for a downsampling pass.
  66. */
  67. METHODDEF void
  68. start_pass_downsample (j_compress_ptr cinfo)
  69. {
  70. /* no work for now */
  71. }
  72. /*
  73. * Expand a component horizontally from width input_cols to width output_cols,
  74. * by duplicating the rightmost samples.
  75. */
  76. LOCAL void
  77. expand_right_edge (JSAMPARRAY image_data, int num_rows,
  78. JDIMENSION input_cols, JDIMENSION output_cols)
  79. {
  80. register JSAMPROW ptr;
  81. register JSAMPLE pixval;
  82. register int count;
  83. int row;
  84. int numcols = (int) (output_cols - input_cols);
  85. if (numcols > 0) {
  86. for (row = 0; row < num_rows; row++) {
  87. ptr = image_data[row] + input_cols;
  88. pixval = ptr[-1]; /* don't need GETJSAMPLE() here */
  89. for (count = numcols; count > 0; count--)
  90. *ptr++ = pixval;
  91. }
  92. }
  93. }
  94. /*
  95. * Do downsampling for a whole row group (all components).
  96. *
  97. * In this version we simply downsample each component independently.
  98. */
  99. METHODDEF void
  100. sep_downsample (j_compress_ptr cinfo,
  101. JSAMPIMAGE input_buf, JDIMENSION in_row_index,
  102. JSAMPIMAGE output_buf, JDIMENSION out_row_group_index)
  103. {
  104. my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
  105. int ci;
  106. jpeg_component_info * compptr;
  107. JSAMPARRAY in_ptr, out_ptr;
  108. for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  109. ci++, compptr++) {
  110. in_ptr = input_buf[ci] + in_row_index;
  111. out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor);
  112. (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
  113. }
  114. }
  115. /*
  116. * Downsample pixel values of a single component.
  117. * One row group is processed per call.
  118. * This version handles arbitrary integral sampling ratios, without smoothing.
  119. * Note that this version is not actually used for customary sampling ratios.
  120. */
  121. METHODDEF void
  122. int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
  123. JSAMPARRAY input_data, JSAMPARRAY output_data)
  124. {
  125. int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
  126. JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
  127. JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
  128. JSAMPROW inptr, outptr;
  129. INT32 outvalue;
  130. h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor;
  131. v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor;
  132. numpix = h_expand * v_expand;
  133. numpix2 = numpix/2;
  134. /* Expand input data enough to let all the output samples be generated
  135. * by the standard loop. Special-casing padded output would be more
  136. * efficient.
  137. */
  138. expand_right_edge(input_data, cinfo->max_v_samp_factor,
  139. cinfo->image_width, output_cols * h_expand);
  140. inrow = 0;
  141. for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  142. outptr = output_data[outrow];
  143. for (outcol = 0, outcol_h = 0; outcol < output_cols;
  144. outcol++, outcol_h += h_expand) {
  145. outvalue = 0;
  146. for (v = 0; v < v_expand; v++) {
  147. inptr = input_data[inrow+v] + outcol_h;
  148. for (h = 0; h < h_expand; h++) {
  149. outvalue += (INT32) GETJSAMPLE(*inptr++);
  150. }
  151. }
  152. *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
  153. }
  154. inrow += v_expand;
  155. }
  156. }
  157. /*
  158. * Downsample pixel values of a single component.
  159. * This version handles the special case of a full-size component,
  160. * without smoothing.
  161. */
  162. METHODDEF void
  163. fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
  164. JSAMPARRAY input_data, JSAMPARRAY output_data)
  165. {
  166. /* Copy the data */
  167. jcopy_sample_rows(input_data, 0, output_data, 0,
  168. cinfo->max_v_samp_factor, cinfo->image_width);
  169. /* Edge-expand */
  170. expand_right_edge(output_data, cinfo->max_v_samp_factor,
  171. cinfo->image_width, compptr->width_in_blocks * DCTSIZE);
  172. }
  173. /*
  174. * Downsample pixel values of a single component.
  175. * This version handles the common case of 2:1 horizontal and 1:1 vertical,
  176. * without smoothing.
  177. *
  178. * A note about the "bias" calculations: when rounding fractional values to
  179. * integer, we do not want to always round 0.5 up to the next integer.
  180. * If we did that, we'd introduce a noticeable bias towards larger values.
  181. * Instead, this code is arranged so that 0.5 will be rounded up or down at
  182. * alternate pixel locations (a simple ordered dither pattern).
  183. */
  184. METHODDEF void
  185. h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
  186. JSAMPARRAY input_data, JSAMPARRAY output_data)
  187. {
  188. int outrow;
  189. JDIMENSION outcol;
  190. JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
  191. register JSAMPROW inptr, outptr;
  192. register int bias;
  193. /* Expand input data enough to let all the output samples be generated
  194. * by the standard loop. Special-casing padded output would be more
  195. * efficient.
  196. */
  197. expand_right_edge(input_data, cinfo->max_v_samp_factor,
  198. cinfo->image_width, output_cols * 2);
  199. for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  200. outptr = output_data[outrow];
  201. inptr = input_data[outrow];
  202. bias = 0; /* bias = 0,1,0,1,... for successive samples */
  203. for (outcol = 0; outcol < output_cols; outcol++) {
  204. *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
  205. + bias) >> 1);
  206. bias ^= 1; /* 0=>1, 1=>0 */
  207. inptr += 2;
  208. }
  209. }
  210. }
  211. /*
  212. * Downsample pixel values of a single component.
  213. * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
  214. * without smoothing.
  215. */
  216. METHODDEF void
  217. h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
  218. JSAMPARRAY input_data, JSAMPARRAY output_data)
  219. {
  220. int inrow, outrow;
  221. JDIMENSION outcol;
  222. JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
  223. register JSAMPROW inptr0, inptr1, outptr;
  224. register int bias;
  225. /* Expand input data enough to let all the output samples be generated
  226. * by the standard loop. Special-casing padded output would be more
  227. * efficient.
  228. */
  229. expand_right_edge(input_data, cinfo->max_v_samp_factor,
  230. cinfo->image_width, output_cols * 2);
  231. inrow = 0;
  232. for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  233. outptr = output_data[outrow];
  234. inptr0 = input_data[inrow];
  235. inptr1 = input_data[inrow+1];
  236. bias = 1; /* bias = 1,2,1,2,... for successive samples */
  237. for (outcol = 0; outcol < output_cols; outcol++) {
  238. *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
  239. GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1])
  240. + bias) >> 2);
  241. bias ^= 3; /* 1=>2, 2=>1 */
  242. inptr0 += 2; inptr1 += 2;
  243. }
  244. inrow += 2;
  245. }
  246. }
  247. #ifdef INPUT_SMOOTHING_SUPPORTED
  248. /*
  249. * Downsample pixel values of a single component.
  250. * This version handles the standard case of 2:1 horizontal and 2:1 vertical,
  251. * with smoothing. One row of context is required.
  252. */
  253. METHODDEF void
  254. h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
  255. JSAMPARRAY input_data, JSAMPARRAY output_data)
  256. {
  257. int inrow, outrow;
  258. JDIMENSION colctr;
  259. JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
  260. register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
  261. INT32 membersum, neighsum, memberscale, neighscale;
  262. /* Expand input data enough to let all the output samples be generated
  263. * by the standard loop. Special-casing padded output would be more
  264. * efficient.
  265. */
  266. expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,
  267. cinfo->image_width, output_cols * 2);
  268. /* We don't bother to form the individual "smoothed" input pixel values;
  269. * we can directly compute the output which is the average of the four
  270. * smoothed values. Each of the four member pixels contributes a fraction
  271. * (1-8*SF) to its own smoothed image and a fraction SF to each of the three
  272. * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final
  273. * output. The four corner-adjacent neighbor pixels contribute a fraction
  274. * SF to just one smoothed pixel, or SF/4 to the final output; while the
  275. * eight edge-adjacent neighbors contribute SF to each of two smoothed
  276. * pixels, or SF/2 overall. In order to use integer arithmetic, these
  277. * factors are scaled by 2^16 = 65536.
  278. * Also recall that SF = smoothing_factor / 1024.
  279. */
  280. memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */
  281. neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */
  282. inrow = 0;
  283. for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  284. outptr = output_data[outrow];
  285. inptr0 = input_data[inrow];
  286. inptr1 = input_data[inrow+1];
  287. above_ptr = input_data[inrow-1];
  288. below_ptr = input_data[inrow+2];
  289. /* Special case for first column: pretend column -1 is same as column 0 */
  290. membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
  291. GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);
  292. neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +
  293. GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +
  294. GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) +
  295. GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]);
  296. neighsum += neighsum;
  297. neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) +
  298. GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]);
  299. membersum = membersum * memberscale + neighsum * neighscale;
  300. *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
  301. inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
  302. for (colctr = output_cols - 2; colctr > 0; colctr--) {
  303. /* sum of pixels directly mapped to this output element */
  304. membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
  305. GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);
  306. /* sum of edge-neighbor pixels */
  307. neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +
  308. GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +
  309. GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) +
  310. GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]);
  311. /* The edge-neighbors count twice as much as corner-neighbors */
  312. neighsum += neighsum;
  313. /* Add in the corner-neighbors */
  314. neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) +
  315. GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]);
  316. /* form final output scaled up by 2^16 */
  317. membersum = membersum * memberscale + neighsum * neighscale;
  318. /* round, descale and output it */
  319. *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
  320. inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2;
  321. }
  322. /* Special case for last column */
  323. membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) +
  324. GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]);
  325. neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) +
  326. GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) +
  327. GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) +
  328. GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]);
  329. neighsum += neighsum;
  330. neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) +
  331. GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]);
  332. membersum = membersum * memberscale + neighsum * neighscale;
  333. *outptr = (JSAMPLE) ((membersum + 32768) >> 16);
  334. inrow += 2;
  335. }
  336. }
  337. /*
  338. * Downsample pixel values of a single component.
  339. * This version handles the special case of a full-size component,
  340. * with smoothing. One row of context is required.
  341. */
  342. METHODDEF void
  343. fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
  344. JSAMPARRAY input_data, JSAMPARRAY output_data)
  345. {
  346. int outrow;
  347. JDIMENSION colctr;
  348. JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE;
  349. register JSAMPROW inptr, above_ptr, below_ptr, outptr;
  350. INT32 membersum, neighsum, memberscale, neighscale;
  351. int colsum, lastcolsum, nextcolsum;
  352. /* Expand input data enough to let all the output samples be generated
  353. * by the standard loop. Special-casing padded output would be more
  354. * efficient.
  355. */
  356. expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2,
  357. cinfo->image_width, output_cols);
  358. /* Each of the eight neighbor pixels contributes a fraction SF to the
  359. * smoothed pixel, while the main pixel contributes (1-8*SF). In order
  360. * to use integer arithmetic, these factors are multiplied by 2^16 = 65536.
  361. * Also recall that SF = smoothing_factor / 1024.
  362. */
  363. memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */
  364. neighscale = cinfo->smoothing_factor * 64; /* scaled SF */
  365. for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) {
  366. outptr = output_data[outrow];
  367. inptr = input_data[outrow];
  368. above_ptr = input_data[outrow-1];
  369. below_ptr = input_data[outrow+1];
  370. /* Special case for first column */
  371. colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) +
  372. GETJSAMPLE(*inptr);
  373. membersum = GETJSAMPLE(*inptr++);
  374. nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +
  375. GETJSAMPLE(*inptr);
  376. neighsum = colsum + (colsum - membersum) + nextcolsum;
  377. membersum = membersum * memberscale + neighsum * neighscale;
  378. *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
  379. lastcolsum = colsum; colsum = nextcolsum;
  380. for (colctr = output_cols - 2; colctr > 0; colctr--) {
  381. membersum = GETJSAMPLE(*inptr++);
  382. above_ptr++; below_ptr++;
  383. nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) +
  384. GETJSAMPLE(*inptr);
  385. neighsum = lastcolsum + (colsum - membersum) + nextcolsum;
  386. membersum = membersum * memberscale + neighsum * neighscale;
  387. *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16);
  388. lastcolsum = colsum; colsum = nextcolsum;
  389. }
  390. /* Special case for last column */
  391. membersum = GETJSAMPLE(*inptr);
  392. neighsum = lastcolsum + (colsum - membersum) + colsum;
  393. membersum = membersum * memberscale + neighsum * neighscale;
  394. *outptr = (JSAMPLE) ((membersum + 32768) >> 16);
  395. }
  396. }
  397. #endif /* INPUT_SMOOTHING_SUPPORTED */
  398. /*
  399. * Module initialization routine for downsampling.
  400. * Note that we must select a routine for each component.
  401. */
  402. GLOBAL void
  403. jinit_downsampler (j_compress_ptr cinfo)
  404. {
  405. my_downsample_ptr downsample;
  406. int ci;
  407. jpeg_component_info * compptr;
  408. boolean smoothok = TRUE;
  409. downsample = (my_downsample_ptr)
  410. (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
  411. SIZEOF(my_downsampler));
  412. cinfo->downsample = (struct jpeg_downsampler *) downsample;
  413. downsample->pub.start_pass = start_pass_downsample;
  414. downsample->pub.downsample = sep_downsample;
  415. downsample->pub.need_context_rows = FALSE;
  416. if (cinfo->CCIR601_sampling)
  417. ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
  418. /* Verify we can handle the sampling factors, and set up method pointers */
  419. for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  420. ci++, compptr++) {
  421. if (compptr->h_samp_factor == cinfo->max_h_samp_factor &&
  422. compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  423. #ifdef INPUT_SMOOTHING_SUPPORTED
  424. if (cinfo->smoothing_factor) {
  425. downsample->methods[ci] = fullsize_smooth_downsample;
  426. downsample->pub.need_context_rows = TRUE;
  427. } else
  428. #endif
  429. downsample->methods[ci] = fullsize_downsample;
  430. } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  431. compptr->v_samp_factor == cinfo->max_v_samp_factor) {
  432. smoothok = FALSE;
  433. downsample->methods[ci] = h2v1_downsample;
  434. } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor &&
  435. compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) {
  436. #ifdef INPUT_SMOOTHING_SUPPORTED
  437. if (cinfo->smoothing_factor) {
  438. downsample->methods[ci] = h2v2_smooth_downsample;
  439. downsample->pub.need_context_rows = TRUE;
  440. } else
  441. #endif
  442. downsample->methods[ci] = h2v2_downsample;
  443. } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 &&
  444. (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) {
  445. smoothok = FALSE;
  446. downsample->methods[ci] = int_downsample;
  447. } else
  448. ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
  449. }
  450. #ifdef INPUT_SMOOTHING_SUPPORTED
  451. if (cinfo->smoothing_factor && !smoothok)
  452. TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL);
  453. #endif
  454. }