15#define JPEG_CJPEG_DJPEG
39#define READ_BINARY "r"
42#define READ_BINARY "rb", "ctx=stm"
44#define READ_BINARY "rb"
68#define NEXTBYTE() getc(infile)
72#define ERREXIT(msg) (fprintf(stderr, "%s\n", msg), exit(EXIT_FAILURE))
83 ERREXIT(
"Premature EOF in JPEG file");
96 ERREXIT(
"Premature EOF in JPEG file");
99 ERREXIT(
"Premature EOF in JPEG file");
100 return (((
unsigned int) c1) << 8) + ((
unsigned int) c2);
145 int discarded_bytes = 0;
160 if (discarded_bytes != 0) {
161 fprintf(
stderr,
"Warning: garbage data found in JPEG file\n");
183 if (c1 != 0xFF || c2 !=
M_SOI)
208 ERREXIT(
"Erroneous JPEG marker length");
240 ERREXIT(
"Erroneous JPEG marker length");
252 }
else if (ch ==
'\r') {
254 }
else if (ch ==
'\n') {
257 }
else if (ch ==
'\\') {
286 int data_precision, num_components;
305 case M_SOF9:
process =
"Extended sequential, arithmetic coding";
break;
308 case M_SOF13:
process =
"Differential sequential, arithmetic coding";
break;
309 case M_SOF14:
process =
"Differential progressive, arithmetic coding";
break;
310 case M_SOF15:
process =
"Differential lossless, arithmetic coding";
break;
311 default:
process =
"Unknown";
break;
314 printf(
"JPEG image is %uw * %uh, %d color components, %d bits per sample\n",
318 if (
length != (
unsigned int) (8 + num_components * 3))
319 ERREXIT(
"Bogus SOF marker length");
321 for (ci = 0; ci < num_components; ci++) {
346 ERREXIT(
"Expected SOI marker first");
389 printf(
"APP12 contains:\n");
412 fprintf(
stderr,
"rdjpgcom displays any textual comments in a JPEG file.\n");
417 fprintf(
stderr,
" -raw Display non-printable characters in comments (unsafe)\n");
418 fprintf(
stderr,
" -verbose Also display dimensions of JPEG image\n");
431 register int nmatched = 0;
433 while ((
ca = *
arg++) !=
'\0') {
470 for (argn = 1; argn <
argc; argn++) {
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLuint GLsizei GLsizei * length
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)
static void process_COM(int raw)
static int scan_JPEG_header(int verbose, int raw)
static void skip_variable(void)
static void process_SOFn(int marker)
static unsigned int read_2_bytes(void)
static int keymatch(char *arg, const char *keyword, int minchars)
static const char * progname
static int read_1_byte(void)
static int first_marker(void)
static int next_marker(void)