summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-06-18 16:03:04 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-06-18 16:03:04 +0200
commit17f24dff1dc95ae42aa9be5f201f02253c304f9e (patch)
tree2c9e57d3639b95f5984af947b55c19db3d2d3730
parenteaf8eb26a4f9f017241897a8b8d33774827c6641 (diff)
downloadufodecode-17f24dff1dc95ae42aa9be5f201f02253c304f9e.tar.gz
ufodecode-17f24dff1dc95ae42aa9be5f201f02253c304f9e.tar.bz2
ufodecode-17f24dff1dc95ae42aa9be5f201f02253c304f9e.tar.xz
ufodecode-17f24dff1dc95ae42aa9be5f201f02253c304f9e.zip
Remove support for version 0 and 4
-rw-r--r--src/ufodecode.c298
1 files changed, 0 insertions, 298 deletions
diff --git a/src/ufodecode.c b/src/ufodecode.c
index 66db000..f05549d 100644
--- a/src/ufodecode.c
+++ b/src/ufodecode.c
@@ -120,282 +120,6 @@ ufo_decoder_set_raw_data(UfoDecoder *decoder, uint32_t *raw, size_t num_bytes)
}
static int
-ufo_decode_frame_channels_v0(UfoDecoder *decoder,
- uint16_t *pixel_buffer,
- uint32_t *raw,
- size_t num_words,
- size_t *offset)
-{
- static int channel_order[IPECAMERA_NUM_CHANNELS] = { 15, 13, 14, 12, 10, 8, 11, 7, 9, 6, 5, 2, 4, 3, 0, 1 };
- static int channel_size = (2 + IPECAMERA_PIXELS_PER_CHANNEL / 3);
-
- const int bytes = channel_size - 1;
- const int num_rows = decoder->height;
- const size_t cpl = (decoder->width / IPECAMERA_PIXELS_PER_CHANNEL);
- const size_t cpi = num_rows * cpl;
- int pos = 0;
- uint32_t data;
-#if defined(DEBUG) || defined(CHECKS)
- int err;
-#endif
-
-#if defined(HAVE_SSE) && !defined(DEBUG)
- __m128i mask = _mm_set_epi32(0x3FF, 0x3FF, 0x3FF, 0x3FF);
- __m128i packed;
- __m128i tmp1, tmp2;
- uint32_t result[4] __attribute__ ((aligned (16))) = {0};
-#endif
-
- 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 (size_t c = 0; c < cpi; c++) {
- const int info = raw[0];
- int row = (info >> 4) & 0x7FF;
- int channel = info & 0x0F;
- int pixels = (info >> 20) & 0xFF;
-
-#ifdef CHECKS
- int header = (info >> 30) & 0x03;
- const int bpp = (info >> 16) & 0x0F;
- CHECK_FLAG("raw header magick", header == 2, header);
- CHECK_FLAG("row number, only %i rows requested", row < num_rows, row, num_rows);
- CHECK_FLAG("pixel size, only 10 bits are supported", bpp == 10, bpp);
- CHECK_FLAG("channel, limited by %zu output channels", channel < cpl, channel, cpl);
-#endif
-
- if ((row > num_rows) || (channel > cpl) || (pixels > IPECAMERA_PIXELS_PER_CHANNEL))
- return EILSEQ;
-
- 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;
- /* base++; */
- }
-#ifdef CHECKS
- else
- CHECK_FLAG("number of pixels, %i is expected", pixels == IPECAMERA_PIXELS_PER_CHANNEL, pixels, IPECAMERA_PIXELS_PER_CHANNEL);
-#endif
-
-#if defined(HAVE_SSE) && !defined(DEBUG)
- for (int i = 1 ; i < bytes-4; i += 4, base += 12) {
- packed = _mm_set_epi32(raw[i], raw[i+1], raw[i+2], raw[i+3]);
-
- tmp1 = _mm_srli_epi32(packed, 20);
- tmp2 = _mm_and_si128(tmp1, mask);
- _mm_storeu_si128((__m128i*) result, tmp2);
-
- pixel_buffer[base+0] = result[3];
- pixel_buffer[base+3] = result[2];
- pixel_buffer[base+6] = result[1];
- pixel_buffer[base+9] = result[0];
-
- tmp1 = _mm_srli_epi32(packed, 10);
- tmp2 = _mm_and_si128(tmp1, mask);
- _mm_storeu_si128((__m128i*) result, tmp2);
- pixel_buffer[base+1] = result[3];
- pixel_buffer[base+4] = result[2];
- pixel_buffer[base+7] = result[1];
- pixel_buffer[base+10] = result[0];
-
- tmp1 = _mm_and_si128(packed, mask);
- _mm_storeu_si128((__m128i*) result, tmp1);
- pixel_buffer[base+2] = result[3];
- pixel_buffer[base+5] = result[2];
- pixel_buffer[base+8] = result[1];
- pixel_buffer[base+11] = result[0];
- }
-
- /* Compute last pixels by hand */
- data = raw[41];
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
-
- data = raw[42];
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
-#else
- for (int i = 1 ; i < bytes; i++) {
- data = raw[i];
-#ifdef DEBUG
- header = (data >> 30) & 0x03;
- CHECK_FLAG("raw data magic", header == 3, header);
- if (err)
- return err;
-#endif
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
- }
-#endif
-
- data = raw[bytes];
-#ifdef DEBUG
- header = (data >> 30) & 0x03;
- CHECK_FLAG("raw data magic", header == 3, header);
- CHECK_FLAG("raw footer magic", (data & 0x3FF) == 0x55, (data & 0x3FF));
-#endif
-
-#if defined(DEBUG) || defined(CHECKS)
- if (err)
- return err;
-#endif
-
- int ppw = pixels >> 6;
- for (int j = 0; j < ppw; j++)
- pixel_buffer[base++] = (data >> (10 * (ppw - j))) & 0x3FF;
-
- pos += channel_size;
- raw += channel_size;
- }
-
- *offset = pos;
- return 0;
-}
-
-static int
-ufo_decode_frame_channels_v4(UfoDecoder *decoder,
- uint16_t *pixel_buffer,
- uint32_t *raw,
- size_t num_words,
- size_t num_rows,
- size_t *offset)
-{
- static const int channel_order[IPECAMERA_NUM_CHANNELS] = { 15, 13, 14, 12, 10, 8, 11, 7, 9, 6, 5, 2, 4, 3, 0, 1 };
- static const int channel_size = (2 + IPECAMERA_PIXELS_PER_CHANNEL / 3);
-
- const int bytes = channel_size - 1;
- const size_t channels_per_row = (decoder->width / IPECAMERA_PIXELS_PER_CHANNEL);
- const size_t cpi = num_rows * channels_per_row;
- int pos = 0;
- uint32_t data;
-
-#if defined(HAVE_SSE) && !defined(DEBUG)
- __m128i mask = _mm_set_epi32(0x3FF, 0x3FF, 0x3FF, 0x3FF);
- __m128i packed;
- __m128i tmp1, tmp2;
- uint32_t result[4] __attribute__ ((aligned (16))) = {0};
-#endif
-
- 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 (size_t c = 0; c < cpi; c++) {
- const int info = raw[0];
- int row = (info >> 4) & 0x7FF;
- int channel = info & 0x0F;
- int pixels = (info >> 20) & 0xFF;
-
-#ifdef DEBUG
- int err = 0;
- int header = (info >> 30) & 0x03;
- const int bpp = (info >> 16) & 0x0F;
- CHECK_FLAG("raw header magick", header == 2, header);
- CHECK_FLAG("pixel size, only 10 bits are supported", bpp == 10, bpp);
- CHECK_FLAG("channel, limited by %zu output channels", channel < channels_per_row, channel, channels_per_row);
-#endif
-
- if ((channel > channels_per_row) || (pixels > IPECAMERA_PIXELS_PER_CHANNEL))
- return EILSEQ;
-
- 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;
- /* base++; */
- }
-
-#if defined(HAVE_SSE) && !defined(DEBUG)
- for (int i = 1 ; i < bytes-4; i += 4, base += 12) {
- packed = _mm_set_epi32(raw[i], raw[i+1], raw[i+2], raw[i+3]);
-
- tmp1 = _mm_srli_epi32(packed, 20);
- tmp2 = _mm_and_si128(tmp1, mask);
- _mm_storeu_si128((__m128i*) result, tmp2);
-
- pixel_buffer[base+0] = result[3];
- pixel_buffer[base+3] = result[2];
- pixel_buffer[base+6] = result[1];
- pixel_buffer[base+9] = result[0];
-
- tmp1 = _mm_srli_epi32(packed, 10);
- tmp2 = _mm_and_si128(tmp1, mask);
- _mm_storeu_si128((__m128i*) result, tmp2);
- pixel_buffer[base+1] = result[3];
- pixel_buffer[base+4] = result[2];
- pixel_buffer[base+7] = result[1];
- pixel_buffer[base+10] = result[0];
-
- tmp1 = _mm_and_si128(packed, mask);
- _mm_storeu_si128((__m128i*) result, tmp1);
- pixel_buffer[base+2] = result[3];
- pixel_buffer[base+5] = result[2];
- pixel_buffer[base+8] = result[1];
- pixel_buffer[base+11] = result[0];
- }
-
- /* Compute last pixels by hand */
- data = raw[41];
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
-
- data = raw[42];
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
-#else
- for (int i = 1 ; i < bytes; i++) {
- data = raw[i];
-#ifdef DEBUG
- header = (data >> 30) & 0x03;
- CHECK_FLAG("raw data magic", header == 3, header);
- if (err)
- return err;
-#endif
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
- }
-#endif
-
- data = raw[bytes];
-#ifdef DEBUG
- header = (data >> 30) & 0x03;
- CHECK_FLAG("raw data magic", header == 3, header);
- CHECK_FLAG("raw footer magic", (data & 0x3FF) == 0x55, (data & 0x3FF));
- if (err)
- return err;
-#endif
-
- int ppw = pixels >> 6;
- for (int j = 0; j < ppw; j++)
- pixel_buffer[base++] = (data >> (10 * (ppw - j))) & 0x3FF;
-
- pos += channel_size;
- raw += channel_size;
- }
-
- *offset = pos;
- return 0;
-}
-
-static int
ufo_decode_frame_channels_v5(UfoDecoder *decoder,
uint16_t *pixel_buffer,
uint32_t *raw,
@@ -557,16 +281,6 @@ size_t ufo_decoder_decode_frame(UfoDecoder *decoder,
CHECK_VALUE(raw[pos++], 0x55555555);
switch (version) {
- case 0:
- CHECK_VALUE(raw[pos++], 0x56666666);
- CHECK_VALUE(raw[pos] >> 28, 0x5);
- meta->frame_number = raw[pos++] & 0xFFFFFFF;
- CHECK_VALUE(raw[pos] >> 28, 0x5);
- meta->time_stamp = raw[pos++] & 0xFFFFFFF;
- meta->n_rows = 1088;
- break;
-
- case 4:
case 5:
CHECK_VALUE(raw[pos] >> 28, 0x5);
meta->cmosis_start_address = (raw[pos] >> 21) & 0x1FF;
@@ -607,12 +321,6 @@ size_t ufo_decoder_decode_frame(UfoDecoder *decoder,
}
#else
switch (version) {
- case 0:
- meta->n_rows = 1088;
- meta->frame_number = raw[pos + 6] & 0xFFFFFFF;
- meta->time_stamp = raw[pos + 7] & 0xFFFFFFF;
- break;
- case 4:
case 5:
meta->n_rows = rows_per_frame = raw[pos + 5] & 0x7FF;
meta->frame_number = raw[pos + 6] & 0x1FFFFFF;
@@ -630,12 +338,6 @@ size_t ufo_decoder_decode_frame(UfoDecoder *decoder,
#endif
switch (version) {
- case 0:
- err = ufo_decode_frame_channels_v0(decoder, pixels, raw + pos, num_words - pos - 8, &advance);
- break;
- case 4:
- err = ufo_decode_frame_channels_v4(decoder, pixels, raw + pos, num_words - pos - 8, rows_per_frame, &advance);
- break;
case 5:
err = ufo_decode_frame_channels_v5(decoder, pixels, raw + pos, rows_per_frame, &advance, meta->output_mode);
break;