Changeset 3165
- Timestamp:
- Oct 31, 2008, 4:24:27 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpipi/trunk/pipi/codec/modular/jpeg.c
r3088 r3165 19 19 20 20 #include "../modular.h" 21 #include <setjmp.h> 21 22 22 23 static int pipi_free_jpeg(pipi_image_t *img); 23 24 24 25 26 27 28 struct my_error_mgr { 29 struct jpeg_error_mgr pub; 30 jmp_buf setjmp_buffer; 31 }; 32 33 typedef struct my_error_mgr * my_error_ptr; 34 25 35 static void format_msg(j_common_ptr cinfo, char *buf) 26 36 { … … 31 41 static void error_msg(j_common_ptr cinfo) 32 42 { 43 my_error_ptr myerr = (my_error_ptr) cinfo->err; 33 44 cinfo->client_data = (void*)0x1; 45 longjmp(myerr->setjmp_buffer, 1); 34 46 } 35 47 static void output_msg(j_common_ptr cinfo) … … 40 52 { 41 53 struct jpeg_decompress_struct cinfo; 42 struct jpeg_error_mgr jerr;54 struct my_error_mgr jerr; 43 55 unsigned char *image = NULL, *scanline = NULL; 44 56 pipi_image_t *img = NULL; … … 48 60 if(!fp) goto end; 49 61 50 /* Set callbacks */ 51 cinfo.err = jpeg_std_error(&jerr); 52 jerr.error_exit = error_msg; 53 jerr.emit_message = emit_msg; 54 jerr.output_message = output_msg; 55 jerr.format_message = format_msg; 62 63 if (setjmp(jerr.setjmp_buffer)) { 64 goto end; 65 } 66 cinfo.err = jpeg_std_error(&jerr.pub); 67 jerr.pub.error_exit = error_msg; 68 jerr.pub.emit_message = emit_msg; 69 jerr.pub.output_message = output_msg; 70 jerr.pub.format_message = format_msg; 56 71 57 72 /* Initialize libjpeg */ … … 125 140 126 141 struct jpeg_compress_struct cinfo; 127 struct jpeg_error_mgr jerr;142 struct my_error_mgr jerr; 128 143 unsigned char *data = NULL; 129 144 unsigned char *line = NULL; … … 145 160 return 0; 146 161 } 147 148 jerr.error_exit = error_msg; 149 jerr.emit_message = emit_msg; 150 jerr.output_message = output_msg; 151 152 cinfo.err = jpeg_std_error(&(jerr)); 162 163 if (setjmp(jerr.setjmp_buffer)) { 164 goto end; 165 } 166 167 jerr.pub.error_exit = error_msg; 168 jerr.pub.emit_message = emit_msg; 169 jerr.pub.output_message = output_msg; 170 171 cinfo.err = jpeg_std_error(&(jerr.pub)); 153 172 154 173 jpeg_create_compress(&cinfo); … … 182 201 183 202 jpeg_finish_compress(&cinfo); 203 end: 184 204 jpeg_destroy_compress(&cinfo); 185 205 free(line);
Note: See TracChangeset
for help on using the changeset viewer.