14 #define JPEG_CJPEG_DJPEG 34 #ifdef DONT_USE_B_MODE 35 #define READ_BINARY "r" 38 #define READ_BINARY "rb", "ctx=stm" 40 #define READ_BINARY "rb" 45 #define EXIT_FAILURE 1 49 #define EXIT_SUCCESS 1 51 #define EXIT_SUCCESS 0 64 #define NEXTBYTE() getc(infile) 68 #define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE)) 79 ERREXIT(
"Premature EOF in JPEG file");
92 ERREXIT(
"Premature EOF in JPEG file");
95 ERREXIT(
"Premature EOF in JPEG file");
96 return (((
unsigned int) c1) << 8) + ((
unsigned int) c2);
141 int discarded_bytes = 0;
156 if (discarded_bytes != 0) {
157 fprintf(stderr,
"Warning: garbage data found in JPEG file\n");
179 if (c1 != 0xFF || c2 !=
M_SOI)
204 ERREXIT(
"Erroneous JPEG marker length");
231 ERREXIT(
"Erroneous JPEG marker length");
243 }
else if (ch ==
'\n') {
246 }
else if (ch ==
'\\') {
248 }
else if (isprint(ch)) {
251 printf(
"\\%03o", ch);
270 int data_precision, num_components;
271 const char * process;
282 case M_SOF0: process =
"Baseline";
break;
283 case M_SOF1: process =
"Extended sequential";
break;
284 case M_SOF2: process =
"Progressive";
break;
285 case M_SOF3: process =
"Lossless";
break;
286 case M_SOF5: process =
"Differential sequential";
break;
287 case M_SOF6: process =
"Differential progressive";
break;
288 case M_SOF7: process =
"Differential lossless";
break;
289 case M_SOF9: process =
"Extended sequential, arithmetic coding";
break;
290 case M_SOF10: process =
"Progressive, arithmetic coding";
break;
291 case M_SOF11: process =
"Lossless, arithmetic coding";
break;
292 case M_SOF13: process =
"Differential sequential, arithmetic coding";
break;
293 case M_SOF14: process =
"Differential progressive, arithmetic coding";
break;
294 case M_SOF15: process =
"Differential lossless, arithmetic coding";
break;
295 default: process =
"Unknown";
break;
298 printf(
"JPEG image is %uw * %uh, %d color components, %d bits per sample\n",
299 image_width, image_height, num_components, data_precision);
300 printf(
"JPEG process: %s\n", process);
302 if (length != (
unsigned int) (8 + num_components * 3))
303 ERREXIT(
"Bogus SOF marker length");
305 for (ci = 0; ci < num_components; ci++) {
330 ERREXIT(
"Expected SOI marker first");
373 printf(
"APP12 contains:\n");
396 fprintf(stderr,
"rdjpgcom displays any textual comments in a JPEG file.\n");
398 fprintf(stderr,
"Usage: %s [switches] [inputfile]\n",
progname);
400 fprintf(stderr,
"Switches (names may be abbreviated):\n");
401 fprintf(stderr,
" -verbose Also display dimensions of JPEG image\n");
414 register int nmatched = 0;
416 while ((ca = *arg++) !=
'\0') {
417 if ((ck = *keyword++) ==
'\0')
426 if (nmatched < minchars)
445 argc = ccommand(&argv);
453 for (argn = 1; argn < argc; argn++) {
467 fprintf(stderr,
"%s: only one input file\n",
progname);
472 fprintf(stderr,
"%s: can't open %s\n",
progname, argv[argn]);
478 setmode(fileno(stdin), O_BINARY);
482 fprintf(stderr,
"%s: can't open stdin\n",
progname);
static void skip_variable(void)
static int keymatch(char *arg, const char *keyword, int minchars)
static int first_marker(void)
static int read_1_byte(void)
static unsigned int read_2_bytes(void)
int main(int argc, char **argv)
png_bytep png_bytep png_size_t length
static int next_marker(void)
static void process_COM(void)
typedef void(PNGAPI *png_error_ptr) PNGARG((png_structp
static int scan_JPEG_header(int verbose)
static void process_SOFn(int marker)
static const char * progname