diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llimage/llimagejpeg.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llimage/llimagejpeg.cpp')
-rw-r--r-- | linden/indra/llimage/llimagejpeg.cpp | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/linden/indra/llimage/llimagejpeg.cpp b/linden/indra/llimage/llimagejpeg.cpp index 0ffa838..68529b6 100644 --- a/linden/indra/llimage/llimagejpeg.cpp +++ b/linden/indra/llimage/llimagejpeg.cpp | |||
@@ -35,12 +35,13 @@ | |||
35 | 35 | ||
36 | #include "llerror.h" | 36 | #include "llerror.h" |
37 | 37 | ||
38 | LLImageJPEG::LLImageJPEG() | 38 | jmp_buf LLImageJPEG::sSetjmpBuffer ; |
39 | LLImageJPEG::LLImageJPEG(S32 quality) | ||
39 | : | 40 | : |
40 | LLImageFormatted(IMG_CODEC_JPEG), | 41 | LLImageFormatted(IMG_CODEC_JPEG), |
41 | mOutputBuffer( NULL ), | 42 | mOutputBuffer( NULL ), |
42 | mOutputBufferSize( 0 ), | 43 | mOutputBufferSize( 0 ), |
43 | mEncodeQuality( 75 ) // on a scale from 1 to 100 | 44 | mEncodeQuality( quality ) // on a scale from 1 to 100 |
44 | { | 45 | { |
45 | } | 46 | } |
46 | 47 | ||
@@ -76,7 +77,16 @@ BOOL LLImageJPEG::updateData() | |||
76 | jerr.error_exit = &LLImageJPEG::errorExit; // Error exit handler: does not return to caller | 77 | jerr.error_exit = &LLImageJPEG::errorExit; // Error exit handler: does not return to caller |
77 | jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message | 78 | jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message |
78 | jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message | 79 | jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message |
79 | 80 | ||
81 | // | ||
82 | //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error | ||
83 | //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao | ||
84 | // | ||
85 | if(setjmp(sSetjmpBuffer)) | ||
86 | { | ||
87 | jpeg_destroy_decompress(&cinfo); | ||
88 | return FALSE; | ||
89 | } | ||
80 | try | 90 | try |
81 | { | 91 | { |
82 | // Now we can initialize the JPEG decompression object. | 92 | // Now we can initialize the JPEG decompression object. |
@@ -208,7 +218,15 @@ BOOL LLImageJPEG::decode(LLImageRaw* raw_image, F32 decode_time) | |||
208 | jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message | 218 | jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message |
209 | jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message | 219 | jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message |
210 | 220 | ||
211 | 221 | // | |
222 | //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error | ||
223 | //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao | ||
224 | // | ||
225 | if(setjmp(sSetjmpBuffer)) | ||
226 | { | ||
227 | jpeg_destroy_decompress(&cinfo); | ||
228 | return FALSE; | ||
229 | } | ||
212 | try | 230 | try |
213 | { | 231 | { |
214 | // Now we can initialize the JPEG decompression object. | 232 | // Now we can initialize the JPEG decompression object. |
@@ -402,7 +420,7 @@ void LLImageJPEG::errorExit( j_common_ptr cinfo ) | |||
402 | jpeg_destroy(cinfo); | 420 | jpeg_destroy(cinfo); |
403 | 421 | ||
404 | // Return control to the setjmp point | 422 | // Return control to the setjmp point |
405 | throw 1; | 423 | longjmp(sSetjmpBuffer, 1) ; |
406 | } | 424 | } |
407 | 425 | ||
408 | // Decide whether to emit a trace or warning message. | 426 | // Decide whether to emit a trace or warning message. |
@@ -500,8 +518,11 @@ BOOL LLImageJPEG::encode( const LLImageRaw* raw_image, F32 encode_time ) | |||
500 | jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message | 518 | jerr.emit_message = &LLImageJPEG::errorEmitMessage; // Conditionally emit a trace or warning message |
501 | jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message | 519 | jerr.output_message = &LLImageJPEG::errorOutputMessage; // Routine that actually outputs a trace or error message |
502 | 520 | ||
503 | // Establish the setjmp return context mSetjmpBuffer. Used by library to abort. | 521 | // |
504 | if( setjmp(mSetjmpBuffer) ) | 522 | //try/catch will crash on Mac and Linux if LLImageJPEG::errorExit throws an error |
523 | //so as instead, we use setjmp/longjmp to avoid this crash, which is the best we can get. --bao | ||
524 | // | ||
525 | if( setjmp(sSetjmpBuffer) ) | ||
505 | { | 526 | { |
506 | // If we get here, the JPEG code has signaled an error. | 527 | // If we get here, the JPEG code has signaled an error. |
507 | // We need to clean up the JPEG object, close the input file, and return. | 528 | // We need to clean up the JPEG object, close the input file, and return. |