This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Functions | |
bool | getJPEGSize (const char *filename, int &width, int &height) |
|
Definition at line 65 of file jpegSize.cpp. References first_marker(), height, infile, M_EOI, M_SOF0, M_SOF1, M_SOF10, M_SOF11, M_SOF13, M_SOF14, M_SOF15, M_SOF2, M_SOF3, M_SOF5, M_SOF6, M_SOF7, M_SOF9, M_SOS, next_marker(), process_SOFn(), READ_BINARY, skip_variable(), and width. Referenced by getImageSize(), and isJpeg(). 00066 { 00067 //open file 00068 if ((infile = fopen(filename, READ_BINARY)) == NULL) 00069 return false; 00070 00071 //this is scan_JPEG_header (int verbose) 00072 //Parse the marker stream until SOFn is seen; 00073 int marker; 00074 00075 //Expect SOI at start of file 00076 if (!first_marker(&marker)) 00077 { 00078 fclose(infile); 00079 return false; 00080 } 00081 00082 /* Scan miscellaneous markers until we reach SOFn. */ 00083 for (;;) 00084 { 00085 if(!next_marker(&marker)) 00086 { 00087 fclose(infile); 00088 return false; 00089 } 00090 00091 switch (marker) 00092 { 00093 /* Note that marker codes 0xC4, 0xC8, 0xCC are not, and must not be, 00094 * treated as SOFn. C4 in particular is actually DHT. 00095 */ 00096 case M_SOF0: /* Baseline */ 00097 case M_SOF1: /* Extended sequential, Huffman */ 00098 case M_SOF2: /* Progressive, Huffman */ 00099 case M_SOF3: /* Lossless, Huffman */ 00100 case M_SOF5: /* Differential sequential, Huffman */ 00101 case M_SOF6: /* Differential progressive, Huffman */ 00102 case M_SOF7: /* Differential lossless, Huffman */ 00103 case M_SOF9: /* Extended sequential, arithmetic */ 00104 case M_SOF10: /* Progressive, arithmetic */ 00105 case M_SOF11: /* Lossless, arithmetic */ 00106 case M_SOF13: /* Differential sequential, arithmetic */ 00107 case M_SOF14: /* Differential progressive, arithmetic */ 00108 case M_SOF15: /* Differential lossless, arithmetic */ 00109 if(!process_SOFn(width, height)) 00110 { 00111 fclose(infile); 00112 return false; 00113 } 00114 else 00115 { 00116 fclose(infile); 00117 return true; 00118 } 00119 case M_SOS: /* stop before hitting compressed data */ 00120 { 00121 fclose(infile); 00122 return false; 00123 } 00124 case M_EOI: /* in case it's a tables-only JPEG stream */ 00125 { 00126 fclose(infile); 00127 return false; 00128 } 00129 default: /* Anything else just gets skipped */ 00130 skip_variable(); /* we assume it has a parameter count... */ 00131 break; 00132 } 00133 } /* end loop */ 00134 00135 00136 //cout << "ERROR!\n"; 00137 return false; 00138 00139 }
|