From f2ca02d18e037c42c278a24c68e9bdf216d9bf6b Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Thu, 18 Jun 2015 16:50:25 +0200 Subject: Start using the common pre-header --- src/ufodecode.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/ufodecode.c') diff --git a/src/ufodecode.c b/src/ufodecode.c index 25ed02c..aecb554 100644 --- a/src/ufodecode.c +++ b/src/ufodecode.c @@ -24,6 +24,13 @@ #define IPECAMERA_MODE_11_BIT_ADC 1 #define IPECAMERA_MODE_10_BIT_ADC 0 +typedef struct { + unsigned no_ext_header : 1; + unsigned version: 3; + unsigned ones : 24; + unsigned five: 4; +} pre_header_t; + typedef struct { unsigned int pixel_number : 8; unsigned int row_number : 12; @@ -260,12 +267,18 @@ ufo_decoder_decode_frame(UfoDecoder *decoder, uint32_t *raw, size_t num_bytes, u size_t pos = 0; size_t advance = 0; const size_t num_words = num_bytes / 4; + const pre_header_t *pre_header; if ((pixels == NULL) || (num_words < 16)) return 0; + pre_header = (pre_header_t *) raw; + + CHECK_VALUE(pre_header->five, 0x5); + CHECK_VALUE(pre_header->ones, 0x111111); + size_t rows_per_frame = decoder->height; - const int version = (raw[pos+6] >> 24) & 0xF; + const int version = pre_header->version + 5; /* it starts with 0 */ #ifdef DEBUG CHECK_VALUE(raw[pos++], 0x51111111); -- cgit v1.2.3