| OLD | NEW |
| 1 /* | 1 /* |
| 2 * jdsample.c | 2 * jdsample.c |
| 3 * | 3 * |
| 4 * This file was part of the Independent JPEG Group's software: | 4 * This file was part of the Independent JPEG Group's software: |
| 5 * Copyright (C) 1991-1996, Thomas G. Lane. | 5 * Copyright (C) 1991-1996, Thomas G. Lane. |
| 6 * libjpeg-turbo Modifications: | 6 * libjpeg-turbo Modifications: |
| 7 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB | 7 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 8 * Copyright (C) 2010, D. R. Commander. | 8 * Copyright (C) 2010, D. R. Commander. |
| 9 * For conditions of distribution and use, see the accompanying README file. | 9 * For conditions of distribution and use, see the accompanying README file. |
| 10 * | 10 * |
| 11 * This file contains upsampling routines. | 11 * This file contains upsampling routines. |
| 12 * | 12 * |
| 13 * Upsampling input data is counted in "row groups". A row group | 13 * Upsampling input data is counted in "row groups". A row group |
| 14 * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) | 14 * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) |
| 15 * sample rows of each component. Upsampling will normally produce | 15 * sample rows of each component. Upsampling will normally produce |
| 16 * max_v_samp_factor pixel rows from each row group (but this could vary | 16 * max_v_samp_factor pixel rows from each row group (but this could vary |
| 17 * if the upsampler is applying a scale factor of its own). | 17 * if the upsampler is applying a scale factor of its own). |
| 18 * | 18 * |
| 19 * An excellent reference for image resampling is | 19 * An excellent reference for image resampling is |
| 20 * Digital Image Warping, George Wolberg, 1990. | 20 * Digital Image Warping, George Wolberg, 1990. |
| 21 * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. | 21 * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. |
| 22 */ | 22 */ |
| 23 | 23 |
| 24 #define JPEG_INTERNALS | 24 #include "jdsample.h" |
| 25 #include "jinclude.h" | |
| 26 #include "jpeglib.h" | |
| 27 #include "jsimd.h" | 25 #include "jsimd.h" |
| 28 #include "jpegcomp.h" | 26 #include "jpegcomp.h" |
| 29 | 27 |
| 30 | 28 |
| 31 /* Pointer to routine to upsample a single component */ | |
| 32 typedef JMETHOD(void, upsample1_ptr, | |
| 33 (j_decompress_ptr cinfo, jpeg_component_info * compptr, | |
| 34 JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); | |
| 35 | |
| 36 /* Private subobject */ | |
| 37 | |
| 38 typedef struct { | |
| 39 struct jpeg_upsampler pub; /* public fields */ | |
| 40 | |
| 41 /* Color conversion buffer. When using separate upsampling and color | |
| 42 * conversion steps, this buffer holds one upsampled row group until it | |
| 43 * has been color converted and output. | |
| 44 * Note: we do not allocate any storage for component(s) which are full-size, | |
| 45 * ie do not need rescaling. The corresponding entry of color_buf[] is | |
| 46 * simply set to point to the input data array, thereby avoiding copying. | |
| 47 */ | |
| 48 JSAMPARRAY color_buf[MAX_COMPONENTS]; | |
| 49 | |
| 50 /* Per-component upsampling method pointers */ | |
| 51 upsample1_ptr methods[MAX_COMPONENTS]; | |
| 52 | |
| 53 int next_row_out; /* counts rows emitted from color_buf */ | |
| 54 JDIMENSION rows_to_go; /* counts rows remaining in image */ | |
| 55 | |
| 56 /* Height of an input row group for each component. */ | |
| 57 int rowgroup_height[MAX_COMPONENTS]; | |
| 58 | |
| 59 /* These arrays save pixel expansion factors so that int_expand need not | |
| 60 * recompute them each time. They are unused for other upsampling methods. | |
| 61 */ | |
| 62 UINT8 h_expand[MAX_COMPONENTS]; | |
| 63 UINT8 v_expand[MAX_COMPONENTS]; | |
| 64 } my_upsampler; | |
| 65 | |
| 66 typedef my_upsampler * my_upsample_ptr; | |
| 67 | |
| 68 | 29 |
| 69 /* | 30 /* |
| 70 * Initialize for an upsampling pass. | 31 * Initialize for an upsampling pass. |
| 71 */ | 32 */ |
| 72 | 33 |
| 73 METHODDEF(void) | 34 METHODDEF(void) |
| 74 start_pass_upsample (j_decompress_ptr cinfo) | 35 start_pass_upsample (j_decompress_ptr cinfo) |
| 75 { | 36 { |
| 76 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; | 37 my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; |
| 77 | 38 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); | 449 ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); |
| 489 if (need_buffer) { | 450 if (need_buffer) { |
| 490 upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) | 451 upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) |
| 491 ((j_common_ptr) cinfo, JPOOL_IMAGE, | 452 ((j_common_ptr) cinfo, JPOOL_IMAGE, |
| 492 (JDIMENSION) jround_up((long) cinfo->output_width, | 453 (JDIMENSION) jround_up((long) cinfo->output_width, |
| 493 (long) cinfo->max_h_samp_factor), | 454 (long) cinfo->max_h_samp_factor), |
| 494 (JDIMENSION) cinfo->max_v_samp_factor); | 455 (JDIMENSION) cinfo->max_v_samp_factor); |
| 495 } | 456 } |
| 496 } | 457 } |
| 497 } | 458 } |
| OLD | NEW |