OLD | NEW |
1 /* | 1 /* |
2 * jdsample.c | 2 * jdsample.c |
3 * | 3 * |
4 * Copyright (C) 1991-1996, Thomas G. Lane. | 4 * Copyright (C) 1991-1996, Thomas G. Lane. |
5 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB | 5 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 6 * Copyright (C) 2010, D. R. Commander. |
6 * This file is part of the Independent JPEG Group's software. | 7 * This file is part of the Independent JPEG Group's software. |
7 * For conditions of distribution and use, see the accompanying README file. | 8 * For conditions of distribution and use, see the accompanying README file. |
8 * | 9 * |
9 * This file contains upsampling routines. | 10 * This file contains upsampling routines. |
10 * | 11 * |
11 * Upsampling input data is counted in "row groups". A row group | 12 * Upsampling input data is counted in "row groups". A row group |
12 * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) | 13 * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) |
13 * sample rows of each component. Upsampling will normally produce | 14 * sample rows of each component. Upsampling will normally produce |
14 * max_v_samp_factor pixel rows from each row group (but this could vary | 15 * max_v_samp_factor pixel rows from each row group (but this could vary |
15 * if the upsampler is applying a scale factor of its own). | 16 * if the upsampler is applying a scale factor of its own). |
16 * | 17 * |
17 * An excellent reference for image resampling is | 18 * An excellent reference for image resampling is |
18 * Digital Image Warping, George Wolberg, 1990. | 19 * Digital Image Warping, George Wolberg, 1990. |
19 * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. | 20 * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. |
20 */ | 21 */ |
21 | 22 |
22 #define JPEG_INTERNALS | 23 #define JPEG_INTERNALS |
23 #include "jinclude.h" | 24 #include "jinclude.h" |
24 #include "jpeglib.h" | 25 #include "jpeglib.h" |
25 #include "jsimd.h" | 26 #include "jsimd.h" |
| 27 #include "jpegcomp.h" |
26 | 28 |
27 | 29 |
28 /* Pointer to routine to upsample a single component */ | 30 /* Pointer to routine to upsample a single component */ |
29 typedef JMETHOD(void, upsample1_ptr, | 31 typedef JMETHOD(void, upsample1_ptr, |
30 (j_decompress_ptr cinfo, jpeg_component_info * compptr, | 32 (j_decompress_ptr cinfo, jpeg_component_info * compptr, |
31 JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); | 33 JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); |
32 | 34 |
33 /* Private subobject */ | 35 /* Private subobject */ |
34 | 36 |
35 typedef struct { | 37 typedef struct { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 upsample->pub.start_pass = start_pass_upsample; | 415 upsample->pub.start_pass = start_pass_upsample; |
414 upsample->pub.upsample = sep_upsample; | 416 upsample->pub.upsample = sep_upsample; |
415 upsample->pub.need_context_rows = FALSE; /* until we find out differently */ | 417 upsample->pub.need_context_rows = FALSE; /* until we find out differently */ |
416 | 418 |
417 if (cinfo->CCIR601_sampling) /* this isn't supported */ | 419 if (cinfo->CCIR601_sampling) /* this isn't supported */ |
418 ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); | 420 ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); |
419 | 421 |
420 /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, | 422 /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, |
421 * so don't ask for it. | 423 * so don't ask for it. |
422 */ | 424 */ |
423 do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; | 425 do_fancy = cinfo->do_fancy_upsampling && cinfo->_min_DCT_scaled_size > 1; |
424 | 426 |
425 /* Verify we can handle the sampling factors, select per-component methods, | 427 /* Verify we can handle the sampling factors, select per-component methods, |
426 * and create storage as needed. | 428 * and create storage as needed. |
427 */ | 429 */ |
428 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 430 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
429 ci++, compptr++) { | 431 ci++, compptr++) { |
430 /* Compute size of an "input group" after IDCT scaling. This many samples | 432 /* Compute size of an "input group" after IDCT scaling. This many samples |
431 * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. | 433 * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. |
432 */ | 434 */ |
433 h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / | 435 h_in_group = (compptr->h_samp_factor * compptr->_DCT_scaled_size) / |
434 » » cinfo->min_DCT_scaled_size; | 436 » » cinfo->_min_DCT_scaled_size; |
435 v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / | 437 v_in_group = (compptr->v_samp_factor * compptr->_DCT_scaled_size) / |
436 » » cinfo->min_DCT_scaled_size; | 438 » » cinfo->_min_DCT_scaled_size; |
437 h_out_group = cinfo->max_h_samp_factor; | 439 h_out_group = cinfo->max_h_samp_factor; |
438 v_out_group = cinfo->max_v_samp_factor; | 440 v_out_group = cinfo->max_v_samp_factor; |
439 upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ | 441 upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ |
440 need_buffer = TRUE; | 442 need_buffer = TRUE; |
441 if (! compptr->component_needed) { | 443 if (! compptr->component_needed) { |
442 /* Don't bother to upsample an uninteresting component. */ | 444 /* Don't bother to upsample an uninteresting component. */ |
443 upsample->methods[ci] = noop_upsample; | 445 upsample->methods[ci] = noop_upsample; |
444 need_buffer = FALSE; | 446 need_buffer = FALSE; |
445 } else if (h_in_group == h_out_group && v_in_group == v_out_group) { | 447 } else if (h_in_group == h_out_group && v_in_group == v_out_group) { |
446 /* Fullsize components can be processed without any work. */ | 448 /* Fullsize components can be processed without any work. */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); | 487 ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); |
486 if (need_buffer) { | 488 if (need_buffer) { |
487 upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) | 489 upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) |
488 ((j_common_ptr) cinfo, JPOOL_IMAGE, | 490 ((j_common_ptr) cinfo, JPOOL_IMAGE, |
489 (JDIMENSION) jround_up((long) cinfo->output_width, | 491 (JDIMENSION) jround_up((long) cinfo->output_width, |
490 (long) cinfo->max_h_samp_factor), | 492 (long) cinfo->max_h_samp_factor), |
491 (JDIMENSION) cinfo->max_v_samp_factor); | 493 (JDIMENSION) cinfo->max_v_samp_factor); |
492 } | 494 } |
493 } | 495 } |
494 } | 496 } |
OLD | NEW |