Add support for JPEGs with reset markers

This commit is contained in:
Philip Heron 2012-02-21 22:07:14 +00:00
parent a59b41add0
commit 59bffac801
2 changed files with 30 additions and 0 deletions

29
ssdv.c
View File

@ -471,6 +471,13 @@ static char ssdv_process(ssdv_t *s)
s->packet_mcu_offset = s->packet_mcu_offset =
(SSDV_PKT_SIZE_PAYLOAD - s->out_len) * 8 + s->outlen; (SSDV_PKT_SIZE_PAYLOAD - s->out_len) * 8 + s->outlen;
} }
/* Test for a reset marker */
if(s->dri > 0 && s->mcu_id > 0 && s->mcu_id % s->dri == 0)
{
s->state = S_MARKER;
return(SSDV_FEED_ME);
}
} }
if(s->mcupart < 4) s->component = 0; if(s->mcupart < 4) s->component = 0;
@ -500,6 +507,7 @@ static char ssdv_have_marker(ssdv_t *s)
{ {
case J_SOF0: case J_SOF0:
case J_SOS: case J_SOS:
case J_DRI:
/* Copy the data before processing */ /* Copy the data before processing */
if(s->marker_len > HBUFF_LEN) if(s->marker_len > HBUFF_LEN)
{ {
@ -529,6 +537,21 @@ static char ssdv_have_marker(ssdv_t *s)
s->state = S_EOI; s->state = S_EOI;
break; break;
case J_RST0:
case J_RST1:
case J_RST2:
case J_RST3:
case J_RST4:
case J_RST5:
case J_RST6:
case J_RST7:
s->dc[0] = s->dc[1] = s->dc[2] = 0;
s->mcupart = s->acpart = s->component = 0;
s->acrle = s->accrle = 0;
s->workbits = s->worklen = 0;
s->state = S_HUFF;
break;
default: default:
/* Ignore other marks, skipping any associated data */ /* Ignore other marks, skipping any associated data */
s->in_skip = s->marker_len; s->in_skip = s->marker_len;
@ -667,6 +690,7 @@ static char ssdv_have_marker_data(ssdv_t *s)
d += s; d += s;
} }
break; break;
case J_DQT: case J_DQT:
while(l > 0) while(l > 0)
{ {
@ -681,6 +705,11 @@ static char ssdv_have_marker_data(ssdv_t *s)
d += 65; d += 65;
} }
break; break;
case J_DRI:
s->dri = (d[0] << 8) + d[1];
fprintf(stderr, "Reset interval: %i blocks\n", s->dri);
break;
} }
s->state = S_MARKER; s->state = S_MARKER;

1
ssdv.h
View File

@ -92,6 +92,7 @@ typedef struct
int adc[COMPONENTS];/* DC adjusted value for each component */ int adc[COMPONENTS];/* DC adjusted value for each component */
uint8_t acrle; /* RLE value for current AC value */ uint8_t acrle; /* RLE value for current AC value */
uint8_t accrle; /* Accumulative RLE value */ uint8_t accrle; /* Accumulative RLE value */
uint16_t dri; /* Reset interval */
enum { enum {
S_ENCODING = 0, S_ENCODING = 0,
S_DECODING, S_DECODING,