| 1 | /* |
| 2 | * |
| 3 | * Performance-critical functions that should be inlined, based on |
| 4 | * measurements. |
| 5 | * |
| 6 | * Copyright 1997-2003 Michael Sweet ([email protected]) and |
| 7 | * Robert Krawitz ([email protected]) |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 17 | * for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 21 | * |
| 22 | * Revision History: |
| 23 | * |
| 24 | * See ChangeLog |
| 25 | */ |
| 26 | |
| 27 | #ifndef GUTENPRINT_INTERNAL_DITHER_INLINED_FUNCTIONS_H |
| 28 | #define GUTENPRINT_INTERNAL_DITHER_INLINED_FUNCTIONS_Hcxx . . $ `src/main/dither-inlined-functions.h:28:9`! |
| 29 | |
| 30 | /* |
| 31 | * Inlining has yielded significant (measured) speedup, even with the |
| 32 | * more complicated dither function. --rlk 20011219 |
| 33 | */ |
| 34 | |
| 35 | static inlinecxx . . $ `src/main/dither-impl.h:41:9`! unsigned |
| 36 | ditherpointcxx . . $ ditherpoint(44214aea3cf6f5be).(const stpi_dither_tcxx . . $ stpi_dither_t# *d, stp_dither_matrix_impl_tcxx . . $ stp_dither_matrix_impl_t# *mat, int x) |
| 37 | { |
| 38 | (void)d; |
| 39 | if (mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask.) |
| 40 | return mat->matrixcxx . . $ dither_matrix_impl#matrix.[(mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod. + |
| 41 | ((x + mat->x_offsetcxx . . $ dither_matrix_impl#x_offset.) & mat->fast_maskcxx . . $ dither_matrix_impl#fast_mask.))]; |
| 42 | /* |
| 43 | * This rather bizarre code is an attempt to avoid having to compute a lot |
| 44 | * of modulus and multiplication operations, which are typically slow. |
| 45 | */ |
| 46 | |
| 47 | if (x == mat->last_xcxx . . $ dither_matrix_impl#last_x. + 1) |
| 48 | { |
| 49 | mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod.++; |
| 50 | mat->indexcxx . . $ dither_matrix_impl#index.++; |
| 51 | if (mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. >= mat->x_sizecxx . . $ dither_matrix_impl#x_size.) |
| 52 | { |
| 53 | mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. -= mat->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 54 | mat->indexcxx . . $ dither_matrix_impl#index. -= mat->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 55 | } |
| 56 | } |
| 57 | else if (x == mat->last_xcxx . . $ dither_matrix_impl#last_x. - 1) |
| 58 | { |
| 59 | mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod.--; |
| 60 | mat->indexcxx . . $ dither_matrix_impl#index.--; |
| 61 | if (mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. < 0) |
| 62 | { |
| 63 | mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. += mat->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 64 | mat->indexcxx . . $ dither_matrix_impl#index. += mat->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 65 | } |
| 66 | } |
| 67 | else if (x != mat->last_xcxx . . $ dither_matrix_impl#last_x.) |
| 68 | { |
| 69 | mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. = (x + mat->x_offsetcxx . . $ dither_matrix_impl#x_offset.) % mat->x_sizecxx . . $ dither_matrix_impl#x_size.; |
| 70 | mat->indexcxx . . $ dither_matrix_impl#index. = mat->last_x_modcxx . . $ dither_matrix_impl#last_x_mod. + mat->last_y_modcxx . . $ dither_matrix_impl#last_y_mod.; |
| 71 | } |
| 72 | mat->last_xcxx . . $ dither_matrix_impl#last_x. = x; |
| 73 | return mat->matrixcxx . . $ dither_matrix_impl#matrix.[mat->indexcxx . . $ dither_matrix_impl#index.]; |
| 74 | } |
| 75 | |
| 76 | static inlinecxx . . $ `src/main/dither-impl.h:41:9`! void |
| 77 | set_row_endscxx . . $ set_row_ends(64d265e6bb66a9f0).(stpi_dither_channel_tcxx . . $ stpi_dither_channel_t# *dc, int x) |
| 78 | { |
| 79 | if (dc->row_endscxx . . $ dither_channel#row_ends.[0] == -1) |
| 80 | dc->row_endscxx . . $ dither_channel#row_ends.[0] = x; |
| 81 | dc->row_endscxx . . $ dither_channel#row_ends.[1] = x; |
| 82 | } |
| 83 | |
| 84 | #endif /* GUTENPRINT_INTERNAL_DITHER_INLINED_FUNCTIONS_H */ |