From 3831db7044118ee948d7203421628628c2c7dc76 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Fri, 9 Dec 2011 15:02:43 +0100 Subject: Support new footer --- src/ufodecode.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src') 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 #include #include @@ -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<> 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<