Commit e356487f authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos

lavf/img2dec: Use jpeg constants in jpeg_probe().

parent aebfbe5c
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "avio_internal.h" #include "avio_internal.h"
#include "internal.h" #include "internal.h"
#include "img2.h" #include "img2.h"
#include "libavcodec/mjpeg.h"
#if HAVE_GLOB #if HAVE_GLOB
/* Locally define as 0 (bitwise-OR no-op) any missing glob options that /* Locally define as 0 (bitwise-OR no-op) any missing glob options that
...@@ -687,7 +688,7 @@ static int j2k_probe(AVProbeData *p) ...@@ -687,7 +688,7 @@ static int j2k_probe(AVProbeData *p)
static int jpeg_probe(AVProbeData *p) static int jpeg_probe(AVProbeData *p)
{ {
const uint8_t *b = p->buf; const uint8_t *b = p->buf;
int i, state = 0xD8; int i, state = SOI;
if (AV_RB16(b) != 0xFFD8 || if (AV_RB16(b) != 0xFFD8 ||
AV_RB32(b) == 0xFFD8FFF7) AV_RB32(b) == 0xFFD8FFF7)
...@@ -700,57 +701,57 @@ static int jpeg_probe(AVProbeData *p) ...@@ -700,57 +701,57 @@ static int jpeg_probe(AVProbeData *p)
continue; continue;
c = b[i + 1]; c = b[i + 1];
switch (c) { switch (c) {
case 0xD8: case SOI:
return 0; return 0;
case 0xC0: case SOF0:
case 0xC1: case SOF1:
case 0xC2: case SOF2:
case 0xC3: case SOF3:
case 0xC5: case SOF5:
case 0xC6: case SOF6:
case 0xC7: case SOF7:
i += AV_RB16(&b[i + 2]) + 1; i += AV_RB16(&b[i + 2]) + 1;
if (state != 0xD8) if (state != SOI)
return 0; return 0;
state = 0xC0; state = SOF0;
break; break;
case 0xDA: case SOS:
i += AV_RB16(&b[i + 2]) + 1; i += AV_RB16(&b[i + 2]) + 1;
if (state != 0xC0 && state != 0xDA) if (state != SOF0 && state != SOS)
return 0; return 0;
state = 0xDA; state = SOS;
break; break;
case 0xD9: case EOI:
if (state != 0xDA) if (state != SOS)
return 0; return 0;
state = 0xD9; state = EOI;
break; break;
case 0xE0: case APP0:
case 0xE1: case APP1:
case 0xE2: case APP2:
case 0xE3: case APP3:
case 0xE4: case APP4:
case 0xE5: case APP5:
case 0xE6: case APP6:
case 0xE7: case APP7:
case 0xE8: case APP8:
case 0xE9: case APP9:
case 0xEA: case APP10:
case 0xEB: case APP11:
case 0xEC: case APP12:
case 0xED: case APP13:
case 0xEE: case APP14:
case 0xEF: case APP15:
i += AV_RB16(&b[i + 2]) + 1; i += AV_RB16(&b[i + 2]) + 1;
break; break;
default: default:
if ( (c >= 0x02 && c <= 0xBF) if ( (c > TEM && c < SOF0)
|| c == 0xC8) || c == JPG)
return 0; return 0;
} }
} }
if (state == 0xD9) if (state == EOI)
return AVPROBE_SCORE_EXTENSION + 1; return AVPROBE_SCORE_EXTENSION + 1;
return AVPROBE_SCORE_EXTENSION / 8; return AVPROBE_SCORE_EXTENSION / 8;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment