summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2018-10-08 18:59:17 +0200
committerSuren A. Chilingaryan <csa@suren.me>2018-10-08 18:59:17 +0200
commit0ed858e99a22c4d39a8fee910eb7376cc6384b76 (patch)
treeaa8d30593cca64997c88eb9978a0461ec385479b
parent6fa8f175914263649a17c1063ebf8e9f734c8d8e (diff)
downloadlibufodecode-0ed858e99a22c4d39a8fee910eb7376cc6384b76.tar.gz
libufodecode-0ed858e99a22c4d39a8fee910eb7376cc6384b76.tar.bz2
libufodecode-0ed858e99a22c4d39a8fee910eb7376cc6384b76.tar.xz
libufodecode-0ed858e99a22c4d39a8fee910eb7376cc6384b76.zip
Fix frame size computation; don't check frame tail as it is broken in HZG camera
-rw-r--r--src/ufodecode.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ufodecode.c b/src/ufodecode.c
index ea189d6..7d65d28 100644
--- a/src/ufodecode.c
+++ b/src/ufodecode.c
@@ -10,6 +10,11 @@
#include <xmmintrin.h>
#endif
+#define DEBUG
+//#define DEBUG_BLOCKS
+
+#define IPECAMERA_BUG_BROKEN_TAIL
+
#define IPECAMERA_NUM_ROWS 1088
#define IPECAMERA_NUM_CHANNELS 16 /**< Number of channels per row */
#define IPECAMERA_PIXELS_PER_CHANNEL 128 /**< Number of pixels per channel */
@@ -241,6 +246,10 @@ ufo_decode_frame_channels_v6 (UfoDecoder *decoder, uint16_t *pixel_buffer, uint3
const size_t row_number = (raw[base] & 0xfff) - start_offset;
const size_t pixel_number = (raw[base + 1] >> 16) & 0xfff;
+#ifdef DEBUG_BLOCKS
+ printf("Row: %i Pixel: %i / %i\n", row_number, pixel_number, base * 4);
+#endif
+
base += 2;
index = row_number * IPECAMERA_WIDTH + pixel_number;
@@ -464,11 +473,11 @@ ufo_decoder_decode_frame (UfoDecoder *decoder, uint32_t *raw, size_t num_bytes,
switch (dataformat_version) {
case 5:
- advance = ufo_decode_frame_channels_v5 (decoder, pixels, raw + pos, num_bytes - pos, rows_per_frame, meta->output_mode);
+ advance = ufo_decode_frame_channels_v5 (decoder, pixels, raw + pos, num_bytes - 4 * (pos + 8), rows_per_frame, meta->output_mode);
break;
case 6:
- advance = ufo_decode_frame_channels_v6 (decoder, pixels, raw + pos, num_bytes - pos, rows_per_frame, meta->cmosis_start_address);
+ advance = ufo_decode_frame_channels_v6 (decoder, pixels, raw + pos, num_bytes - 4 * (pos + 8), rows_per_frame, meta->cmosis_start_address);
break;
default:
@@ -494,8 +503,14 @@ ufo_decoder_decode_frame (UfoDecoder *decoder, uint32_t *raw, size_t num_bytes,
CHECK_VALUE(raw[pos], 0x01111111);
pos++;
+#ifdef IPECAMERA_BUG_BROKEN_TAIL
+ meta->status1.bits = 0;
+ meta->status2.bits = 0;
+ meta->status3.bits = 0;
+#else
if (err)
return 0;
+#endif
return pos;
}
@@ -528,7 +543,7 @@ ufo_decoder_get_next_frame (UfoDecoder *decoder, uint16_t **pixels, UfoDecoderMe
if (pixels == NULL)
return 0;
- if ((pos >= num_words) || ((num_words - pos) < 4096))
+ if ((pos >= num_words) || ((num_words - pos) < 1024))
return EIO;
if (num_words < 16)