diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-09 15:02:43 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-12-09 15:02:43 +0100 |
commit | 3831db7044118ee948d7203421628628c2c7dc76 (patch) | |
tree | fbfa146004910f9ef8bac268f7dfd18d864c218d /src/ufodecode.c | |
parent | 03e18760a68cadaae307c72ed756973047db3ea2 (diff) | |
download | libufodecode-3831db7044118ee948d7203421628628c2c7dc76.tar.gz libufodecode-3831db7044118ee948d7203421628628c2c7dc76.tar.bz2 libufodecode-3831db7044118ee948d7203421628628c2c7dc76.tar.xz libufodecode-3831db7044118ee948d7203421628628c2c7dc76.zip |
Support new footer
Diffstat (limited to 'src/ufodecode.c')
-rw-r--r-- | src/ufodecode.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/ufodecode.c b/src/ufodecode.c index d65ad32..a2d9ae7 100644 --- a/src/ufodecode.c +++ b/src/ufodecode.c @@ -1,4 +1,3 @@ - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -112,24 +111,19 @@ static int ufo_decode_frame(ufo_decoder decoder, uint16_t *pixel_buffer, uint16_ uint32_t result[4] __attribute__ ((aligned (16))) = {0}; #endif - if (cpi * channel_size > num_words) + if (cpi * channel_size > num_words) { +#ifdef DEBUG + fprintf(stderr, "Not enough data to decode frame, expected %lu bytes, but received %lu\n", cpi * channel_size * sizeof(uint32_t), num_words * sizeof(uint32_t)); +#endif return EILSEQ; - + } + for (c = 0; c < cpi; c++) { info = raw[0]; row = (info >> 4) & 0x7FF; channel = info & 0x0F; pixels = (info >> 20) & 0xFF; - if ((row > num_rows)||(channel > cpl)||(pixels>IPECAMERA_PIXELS_PER_CHANNEL)) - return EILSEQ; - - if (cmask) cmask[row] |= (1<<channel); - - channel = channel_order[channel]; - - int base = row * IPECAMERA_WIDTH + channel * IPECAMERA_PIXELS_PER_CHANNEL; - #ifdef DEBUG int err = 0; int header = (info >> 30) & 0x03; // 2 bits @@ -139,6 +133,16 @@ static int ufo_decode_frame(ufo_decoder decoder, uint16_t *pixel_buffer, uint16_ CHECK_FLAG("channel, limited by %i output channels", channel < IPECAMERA_NUM_CHANNELS, channel, IPECAMERA_NUM_CHANNELS); #endif + + if ((row > num_rows)||(channel > cpl)||(pixels>IPECAMERA_PIXELS_PER_CHANNEL)) + return EILSEQ; + + if (cmask) cmask[row] |= (1<<channel); + + channel = channel_order[channel]; + + int base = row * IPECAMERA_WIDTH + channel * IPECAMERA_PIXELS_PER_CHANNEL; + /* "Correct" missing pixel */ if ((row < 2) && (pixels == (IPECAMERA_PIXELS_PER_CHANNEL - 1))) { pixel_buffer[base] = 0; @@ -340,9 +344,15 @@ int ufo_decoder_get_next_frame(ufo_decoder decoder, uint16_t **pixels, uint32_t #ifdef DEBUG CHECK_VALUE(raw[pos++], 0x0AAAAAAA); CHECK_VALUE(raw[pos++], 0x0BBBBBBB); + // Statuses of previous! frame is following + pos++; // status1 0x840dffff is expected + pos++; // status2 0x0f001001 is expected + pos++; // status3 0x28000111 explains problems if status2 is wrong +/* CHECK_VALUE(raw[pos++], 0x0CCCCCCC); CHECK_VALUE(raw[pos++], 0x0DDDDDDD); CHECK_VALUE(raw[pos++], 0x0EEEEEEE); +*/ CHECK_VALUE(raw[pos++], 0x0FFFFFFF); CHECK_VALUE(raw[pos++], 0x00000000); CHECK_VALUE(raw[pos++], 0x01111111); |