summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-12-01 11:01:51 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-12-01 11:01:51 +0100
commit845a638d4c7183ed91b223fbd5047a9cc27b47c8 (patch)
treea485127fbe01f0b407c96670565a1546a7e8a5c3
parentff3390720f5f3d37995986665e38f189a49d514e (diff)
downloadufodecode-845a638d4c7183ed91b223fbd5047a9cc27b47c8.tar.gz
ufodecode-845a638d4c7183ed91b223fbd5047a9cc27b47c8.tar.bz2
ufodecode-845a638d4c7183ed91b223fbd5047a9cc27b47c8.tar.xz
ufodecode-845a638d4c7183ed91b223fbd5047a9cc27b47c8.zip
Set frame number/timestamp and write results
-rw-r--r--src/libipe.c15
-rw-r--r--test/ipedec.c6
2 files changed, 8 insertions, 13 deletions
diff --git a/src/libipe.c b/src/libipe.c
index 7b919d5..b0db74d 100644
--- a/src/libipe.c
+++ b/src/libipe.c
@@ -73,7 +73,6 @@ void ipe_decoder_set_raw_data(ipe_decoder decoder, uint32_t *raw, size_t num_byt
decoder->current_pos = 0;
}
-
static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows, int *offset)
{
static int channel_order[IPECAMERA_NUM_CHANNELS] = { 15, 13, 14, 12, 10, 8, 11, 7, 9, 6, 5, 2, 4, 3, 0, 1 };
@@ -83,14 +82,14 @@ static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
int channel = 0;
int pos = 0;
uint32_t data;
+ const int bytes = 43;
do {
info = raw[0];
- channel = info & 0x0F;
row = (info >> 4) & 0x7FF;
int pixels = (info >> 20) & 0xFF;
- channel = channel_order[channel];
+ channel = channel_order[info & 0x0F];
int base = row * IPECAMERA_WIDTH + channel * IPECAMERA_PIXELS_PER_CHANNEL;
#ifdef DEBUG
@@ -112,12 +111,6 @@ static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
CHECK_FLAG("number of pixels, %i is expected", pixels == IPECAMERA_PIXELS_PER_CHANNEL, pixels, IPECAMERA_PIXELS_PER_CHANNEL);
#endif
- int bytes = 43;
- /* bytes = pixels / 3; */
- /* int ppw = pixels - bytes * 3; */
- /* if (ppw) */
- /* ++bytes; */
-
for (int i = 1; i < bytes; i++) {
data = raw[i];
@@ -259,11 +252,13 @@ int ipe_decoder_get_next_frame(ipe_decoder decoder, uint16_t **pixels, uint32_t
if (err)
return EILSEQ;
#else
+ *frame_number = raw[pos + 6] & 0xF0000000;
+ *time_stamp = raw[pos + 7] & 0xF0000000;
pos += 8;
#endif
err = ipe_decode_frame(*pixels, raw + pos, decoder->height, &advance);
- if (err)
+ if (err)
return EILSEQ;
pos += advance;
diff --git a/test/ipedec.c b/test/ipedec.c
index 1aef1d6..2b44ddd 100644
--- a/test/ipedec.c
+++ b/test/ipedec.c
@@ -55,7 +55,7 @@ int main(int argc, char const* argv[])
struct timeval start, end;
long seconds = 0L, useconds = 0L;
- /* FILE *fp = fopen("test.raw", "wb"); */
+ FILE *fp = fopen("test.raw", "wb");
while (!err) {
gettimeofday(&start, NULL);
@@ -66,10 +66,10 @@ int main(int argc, char const* argv[])
num_frames++;
seconds += end.tv_sec - start.tv_sec;
useconds += end.tv_usec - start.tv_usec;
- /* fwrite(pixels, sizeof(uint16_t), 2048 * 1088, fp); */
+ fwrite(pixels, sizeof(uint16_t), 2048 * 1088, fp);
}
}
- /* fclose(fp); */
+ fclose(fp);
float mtime = seconds * 1000.0 + useconds / 1000.0;
printf("Decoded %i frames in %.5fms\n", num_frames, mtime);