diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-07 19:13:39 -0400 |
| commit | 386b7d3366f1359a265da207a9cafa3edf553b64 (patch) | |
| tree | c76120c2c138faed822e4ae386be6ef22a738a78 /all_pairs/source/cjpeg_wrbmp/cjpeg_wrbmp.c | |
| parent | 54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff) | |
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'all_pairs/source/cjpeg_wrbmp/cjpeg_wrbmp.c')
| -rw-r--r-- | all_pairs/source/cjpeg_wrbmp/cjpeg_wrbmp.c | 225 |
1 files changed, 225 insertions, 0 deletions
diff --git a/all_pairs/source/cjpeg_wrbmp/cjpeg_wrbmp.c b/all_pairs/source/cjpeg_wrbmp/cjpeg_wrbmp.c new file mode 100644 index 0000000..7bef7ab --- /dev/null +++ b/all_pairs/source/cjpeg_wrbmp/cjpeg_wrbmp.c | |||
| @@ -0,0 +1,225 @@ | |||
| 1 | /* | ||
| 2 | |||
| 3 | This program is part of the TACLeBench benchmark suite. | ||
| 4 | Version V 1.x | ||
| 5 | |||
| 6 | Name: cjpeg_jpeg6b_wrbmp.c | ||
| 7 | |||
| 8 | Author: Thomas G. Lane. | ||
| 9 | |||
| 10 | Function: This file contains routines to write output images in Microsoft "BMP" | ||
| 11 | format (MS Windows 3.x and OS/2 1.x flavors). | ||
| 12 | Either 8-bit colormapped or 24-bit full-color format can be written. | ||
| 13 | No compression is supported. | ||
| 14 | |||
| 15 | These routines may need modification for non-Unix environments or | ||
| 16 | specialized applications. As they stand, they assume output to | ||
| 17 | an ordinary stdio stream. | ||
| 18 | |||
| 19 | Source: Independent JPEG Group's software | ||
| 20 | |||
| 21 | Changes: a brief summary of major functional changes (not formatting) | ||
| 22 | |||
| 23 | License: See the accompanying README file | ||
| 24 | |||
| 25 | */ | ||
| 26 | |||
| 27 | #include "../extra.h" | ||
| 28 | #include "cdjpeg.h" | ||
| 29 | |||
| 30 | #ifdef CJPEG_WRBMP_BMP_SUPPORTED | ||
| 31 | |||
| 32 | /* | ||
| 33 | Declaration of global variables | ||
| 34 | */ | ||
| 35 | typedef struct { | ||
| 36 | struct cjpeg_wrbmp_djpeg_dest_struct pub; /* public fields */ | ||
| 37 | cjpeg_wrbmp_boolean is_os2; /* saves the OS2 format request flag */ | ||
| 38 | cjpeg_wrbmp_jvirt_sarray_ptr | ||
| 39 | whole_image; /* needed to reverse row order */ | ||
| 40 | CJPEG_WRBMP_JDIMENSION data_width; /* JSAMPLEs per row */ | ||
| 41 | CJPEG_WRBMP_JDIMENSION | ||
| 42 | row_width; /* physical width of one row in the BMP file */ | ||
| 43 | int pad_bytes; /* number of padding bytes needed per row */ | ||
| 44 | CJPEG_WRBMP_JDIMENSION | ||
| 45 | cur_output_row; /* next row# to write to virtual array */ | ||
| 46 | } cjpeg_wrbmp_bmp_dest_struct; | ||
| 47 | |||
| 48 | typedef cjpeg_wrbmp_bmp_dest_struct *cjpeg_wrbmp_bmp_dest_ptr; | ||
| 49 | extern unsigned char cjpeg_wrbmp_colormap[3][256]; | ||
| 50 | unsigned char cjpeg_wrbmp_output_array[6144]; | ||
| 51 | unsigned char *cjpeg_wrbmp_jpeg_stream /*= cjpeg_jpeg6b_wrbmp_output_array*/; | ||
| 52 | int cjpeg_wrbmp_checksum; | ||
| 53 | |||
| 54 | struct cjpeg_wrbmp_jpeg_decompress_struct | ||
| 55 | cjpeg_wrbmp_jpeg_dec_1; | ||
| 56 | struct cjpeg_wrbmp_jpeg_decompress_struct | ||
| 57 | cjpeg_wrbmp_jpeg_dec_2; | ||
| 58 | struct cjpeg_wrbmp_djpeg_dest_struct | ||
| 59 | cjpeg_wrbmp_djpeg_dest; | ||
| 60 | cjpeg_wrbmp_bmp_dest_struct cjpeg_wrbmp_bmp_dest; | ||
| 61 | |||
| 62 | /* | ||
| 63 | Forward declaration of functions | ||
| 64 | */ | ||
| 65 | void cjpeg_wrbmp_initInput( void ); | ||
| 66 | void cjpeg_wrbmp_finish_output_bmp( cjpeg_wrbmp_j_decompress_ptr cinfo); | ||
| 67 | void cjpeg_wrbmp_write_colormap( cjpeg_wrbmp_j_decompress_ptr | ||
| 68 | cinfo, | ||
| 69 | int map_colors, int map_entry_size, | ||
| 70 | int cMap ); | ||
| 71 | int cjpeg_wrbmp_putc_modified( int character ); | ||
| 72 | void cjpeg_wrbmp_init(); | ||
| 73 | void cjpeg_wrbmp_main(); | ||
| 74 | int cjpeg_wrbmp_return(); | ||
| 75 | //int main(); | ||
| 76 | |||
| 77 | /* | ||
| 78 | Initialization functions | ||
| 79 | */ | ||
| 80 | void cjpeg_wrbmp_init() | ||
| 81 | { | ||
| 82 | cjpeg_wrbmp_initInput(); | ||
| 83 | |||
| 84 | cjpeg_wrbmp_jpeg_dec_1.progress = 0; | ||
| 85 | cjpeg_wrbmp_jpeg_dec_1.output_height = 30; | ||
| 86 | cjpeg_wrbmp_jpeg_dec_1.actual_number_of_colors = 256; | ||
| 87 | cjpeg_wrbmp_jpeg_dec_1.out_color_components = 2; | ||
| 88 | |||
| 89 | cjpeg_wrbmp_jpeg_dec_2.progress = 0; | ||
| 90 | cjpeg_wrbmp_jpeg_dec_2.output_height = 30; | ||
| 91 | cjpeg_wrbmp_jpeg_dec_2.actual_number_of_colors = 256; | ||
| 92 | cjpeg_wrbmp_jpeg_dec_2.out_color_components = 3; | ||
| 93 | |||
| 94 | cjpeg_wrbmp_jpeg_stream = cjpeg_wrbmp_output_array; | ||
| 95 | |||
| 96 | cjpeg_wrbmp_checksum = 0; | ||
| 97 | } | ||
| 98 | |||
| 99 | /* | ||
| 100 | Calculation functions | ||
| 101 | */ | ||
| 102 | int cjpeg_wrbmp_putc_modified( int character ) | ||
| 103 | { | ||
| 104 | *( cjpeg_wrbmp_jpeg_stream ) = character; | ||
| 105 | |||
| 106 | ++cjpeg_wrbmp_jpeg_stream; | ||
| 107 | |||
| 108 | cjpeg_wrbmp_checksum += character; | ||
| 109 | |||
| 110 | return character; | ||
| 111 | } | ||
| 112 | |||
| 113 | void cjpeg_wrbmp_finish_output_bmp( cjpeg_wrbmp_j_decompress_ptr cinfo ) | ||
| 114 | { | ||
| 115 | CJPEG_WRBMP_JDIMENSION row; | ||
| 116 | cjpeg_wrbmp_cd_progress_ptr progress = | ||
| 117 | ( cjpeg_wrbmp_cd_progress_ptr ) cinfo->progress; | ||
| 118 | |||
| 119 | // Write the file body from our virtual array | ||
| 120 | _Pragma( "loopbound min 30 max 30" ) | ||
| 121 | for ( row = cinfo->output_height; row > 0; --row ) { | ||
| 122 | if ( progress != 0 ) { | ||
| 123 | progress->pub.pass_counter = ( long )( cinfo->output_height - row ); | ||
| 124 | progress->pub.pass_limit = ( long ) cinfo->output_height; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | if ( progress != 0 ) | ||
| 129 | progress->completed_extra_passes++; | ||
| 130 | } | ||
| 131 | |||
| 132 | void cjpeg_wrbmp_write_colormap( cjpeg_wrbmp_j_decompress_ptr | ||
| 133 | cinfo, | ||
| 134 | int map_colors, int map_entry_size, int cMap ) | ||
| 135 | { | ||
| 136 | |||
| 137 | int num_colors = cinfo->actual_number_of_colors; | ||
| 138 | int i; | ||
| 139 | |||
| 140 | if ( cMap != 0 ) { | ||
| 141 | |||
| 142 | if ( cinfo->out_color_components == 3 ) { | ||
| 143 | // Normal case with RGB colormap | ||
| 144 | _Pragma( "loopbound min 256 max 256" ) | ||
| 145 | for ( i = 0; i < num_colors; i++ ) { | ||
| 146 | cjpeg_wrbmp_putc_modified( CJPEG_WRBMP_GETJSAMPLE( | ||
| 147 | cjpeg_wrbmp_colormap[2][i] ) ); | ||
| 148 | cjpeg_wrbmp_putc_modified( CJPEG_WRBMP_GETJSAMPLE( | ||
| 149 | cjpeg_wrbmp_colormap[1][i] ) ); | ||
| 150 | cjpeg_wrbmp_putc_modified( CJPEG_WRBMP_GETJSAMPLE( | ||
| 151 | cjpeg_wrbmp_colormap[0][i] ) ); | ||
| 152 | |||
| 153 | if ( map_entry_size == 4 ) | ||
| 154 | cjpeg_wrbmp_putc_modified( 0 ); | ||
| 155 | } | ||
| 156 | } else { | ||
| 157 | // Grayscale colormap (only happens with grayscale quantization) | ||
| 158 | _Pragma( "loopbound min 256 max 256" ) | ||
| 159 | for ( i = 0; i < num_colors; i++ ) { | ||
| 160 | |||
| 161 | cjpeg_wrbmp_putc_modified( CJPEG_WRBMP_GETJSAMPLE( | ||
| 162 | cjpeg_wrbmp_colormap[2][i] ) ); | ||
| 163 | cjpeg_wrbmp_putc_modified( CJPEG_WRBMP_GETJSAMPLE( | ||
| 164 | cjpeg_wrbmp_colormap[1][i] ) ); | ||
| 165 | cjpeg_wrbmp_putc_modified( CJPEG_WRBMP_GETJSAMPLE( | ||
| 166 | cjpeg_wrbmp_colormap[0][i] ) ); | ||
| 167 | |||
| 168 | if ( map_entry_size == 4 ) | ||
| 169 | cjpeg_wrbmp_putc_modified( 0 ); | ||
| 170 | } | ||
| 171 | } | ||
| 172 | } else { | ||
| 173 | // If no colormap, must be grayscale data. Generate a linear "map". | ||
| 174 | _Pragma( "loopbound min 256 max 256" ) | ||
| 175 | for ( i = 0; i < 256; i++ ) { | ||
| 176 | cjpeg_wrbmp_putc_modified( i ); | ||
| 177 | cjpeg_wrbmp_putc_modified( i ); | ||
| 178 | cjpeg_wrbmp_putc_modified( i ); | ||
| 179 | |||
| 180 | if ( map_entry_size == 4 ) | ||
| 181 | cjpeg_wrbmp_putc_modified( 0 ); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | // Pad colormap with zeros to ensure specified number of colormap entries. | ||
| 186 | _Pragma( "loopbound min 512 max 512" ) | ||
| 187 | for ( ; i < map_colors; i++ ) { | ||
| 188 | cjpeg_wrbmp_putc_modified( 0 ); | ||
| 189 | cjpeg_wrbmp_putc_modified( 0 ); | ||
| 190 | cjpeg_wrbmp_putc_modified( 0 ); | ||
| 191 | |||
| < | |||
