summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-12-09 09:36:41 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-12-09 09:36:41 +0100
commitabe088c58aeb876d1471fa99e0fc5c1d85cb1403 (patch)
tree025db8dd920e416dc6252b0a9bacfd630134d1cc /src
parente8b824dac6a2ce4d56c7d08f74f3e80bf1c01d3a (diff)
downloadlibufodecode-abe088c58aeb876d1471fa99e0fc5c1d85cb1403.tar.gz
libufodecode-abe088c58aeb876d1471fa99e0fc5c1d85cb1403.tar.bz2
libufodecode-abe088c58aeb876d1471fa99e0fc5c1d85cb1403.tar.xz
libufodecode-abe088c58aeb876d1471fa99e0fc5c1d85cb1403.zip
Fix: wrong order of pixels when using SSE
Diffstat (limited to 'src')
-rw-r--r--src/ufodecode.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/ufodecode.c b/src/ufodecode.c
index a6a89dc..d1a3984 100644
--- a/src/ufodecode.c
+++ b/src/ufodecode.c
@@ -135,34 +135,37 @@ static int ufo_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
tmp1 = _mm_srli_epi32(packed, 20);
tmp2 = _mm_and_si128(tmp1, mask);
_mm_storeu_si128((__m128i*) result, tmp2);
- pixel_buffer[base] = result[0];
- pixel_buffer[base+3] = result[1];
- pixel_buffer[base+6] = result[2];
- pixel_buffer[base+9] = result[3];
+
+ 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[0];
- pixel_buffer[base+4] = result[1];
- pixel_buffer[base+7] = result[2];
- pixel_buffer[base+10] = result[3];
+ 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[0];
- pixel_buffer[base+5] = result[1];
- pixel_buffer[base+8] = result[2];
- pixel_buffer[base+11] = result[3];
+ 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 the usual way */
- for (int i = bytes-4; i < bytes; i++) {
- data = raw[i];
- pixel_buffer[base++] = (data >> 20) & 0x3FF;
- pixel_buffer[base++] = (data >> 10) & 0x3FF;
- pixel_buffer[base++] = data & 0x3FF;
- }
+ /* 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];
@@ -298,14 +301,14 @@ int ufo_decoder_get_next_frame(ufo_decoder decoder, uint16_t **pixels, uint32_t
CHECK_VALUE(raw[pos++], 0x55555555);
CHECK_VALUE(raw[pos++], 0x56666666);
CHECK_VALUE(raw[pos] >> 28, 0x5);
- *frame_number = raw[pos++] & 0xF0000000;
+ *frame_number = raw[pos++] & 0xFFFFFFF;
CHECK_VALUE(raw[pos] >> 28, 0x5);
- *time_stamp = raw[pos++] & 0xF0000000;
+ *time_stamp = raw[pos++] & 0xFFFFFFF;
if (err)
return EILSEQ;
#else
- *frame_number = raw[pos + 6] & 0xF0000000;
- *time_stamp = raw[pos + 7] & 0xF0000000;
+ *frame_number = raw[pos + 6] & 0xFFFFFFF;
+ *time_stamp = raw[pos + 7] & 0xFFFFFFF;
pos += 8;
#endif
@@ -318,9 +321,8 @@ 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);
- CHECK_VALUE(raw[pos++], 0x0CCCCCCC);
- CHECK_VALUE(raw[pos++], 0x0DDDDDDD);
- CHECK_VALUE(raw[pos++], 0x0EEEEEEE);
+ /* TODO: what should we check? */
+ pos += 3;
CHECK_VALUE(raw[pos++], 0x0FFFFFFF);
CHECK_VALUE(raw[pos++], 0x00000000);
CHECK_VALUE(raw[pos++], 0x01111111);