Any changes are to allow conversion to BMP
Dependents: Color_Targeting_Catapult
Fork of BaseJpegDecode by
Diff: BaseJpegDecode.cpp
- Revision:
- 5:85e99ec2e7b5
- Parent:
- 4:e243fa781e5c
- Child:
- 7:5010d93af0b6
--- a/BaseJpegDecode.cpp Wed Dec 05 12:38:56 2012 +0000 +++ b/BaseJpegDecode.cpp Sun Jan 27 11:00:50 2013 +0000 @@ -1,3 +1,4 @@ +// BaseJpegDecode.cpp 2013/1/27 #include "mbed.h" #include "BaseJpegDecode.h" @@ -33,12 +34,14 @@ #define MARK_APP 0xe0 #define SEQ_INIT 0 -#define SEQ_MARK 1 -#define SEQ_SEG_LEN 2 -#define SEQ_SEG_LEN2 3 -#define SEQ_SEG_BODY 4 -#define SEQ_SOS 5 -#define SEQ_SOS2 6 +#define SEQ_SOI 1 +#define SEQ_FRAME 2 +#define SEQ_MARK 3 +#define SEQ_SEG_LEN 4 +#define SEQ_SEG_LEN2 5 +#define SEQ_SEG_BODY 6 +#define SEQ_SOS 7 +#define SEQ_SOS2 8 #define HT_DC 0 #define HT_AC 1 @@ -127,12 +130,30 @@ switch(m_seq) { case SEQ_INIT: if (c == 0xff) { + m_seq = SEQ_SOI; + } + break; + case SEQ_SOI: + if (c == MARK_SOI) { + outputMARK(c); + m_seq = SEQ_FRAME; + } else { + m_seq = SEQ_INIT; + } + break; + case SEQ_FRAME: + if (c == 0xff) { m_seq = SEQ_MARK; + } else { + m_seq = SEQ_INIT; } break; case SEQ_MARK: outputMARK(c); - if (c == MARK_SOI || c == MARK_EOI) { + if (c == MARK_SOI) { + m_seq = SEQ_FRAME; + break; + } else if (c == MARK_EOI || c == 0x00) { m_seq = SEQ_INIT; break; } @@ -165,7 +186,7 @@ restart(); break; } - m_seq = SEQ_INIT; + m_seq = SEQ_FRAME; break; case SEQ_SOS: if (c == 0xff) {