Browse Source

Rename to `ufodecode`

Matthias Vogelgesang 12 years ago
parent
commit
57f2f8976b
7 changed files with 73 additions and 71 deletions
  1. 13 13
      CMakeLists.txt
  2. 0 27
      src/libipe.h
  3. 3 3
      src/ufodecode-private.h
  4. 24 22
      src/ufodecode.c
  5. 27 0
      src/ufodecode.h
  6. 4 4
      test/ipedec.c
  7. 2 2
      ufodecode.pc.in

+ 13 - 13
CMakeLists.txt

@@ -1,9 +1,9 @@
 cmake_minimum_required(VERSION 2.8)
-set(TARNAME "libipe")
+set(TARNAME "libufodecode")
 
-set(LIBIPE_API_VERSION "0.1.0")
-set(LIBIPE_ABI_VERSION "0.1.0")
-set(LIBIPE_ABI_MAJOR_VERSION "0")
+set(LIBUFODECODE_API_VERSION "0.1.0")
+set(LIBUFODECODE_ABI_VERSION "0.1.0")
+set(LIBUFODECODE_ABI_MAJOR_VERSION "0")
 
 set(PACKAGE_VERSION "0.1.0")
 set(PACKAGE_NAME "${TARNAME}")
@@ -63,23 +63,23 @@ include_directories(
 
 add_definitions("--std=c99 -Wall -O2 ${SSE_FLAGS}")
 
-add_library(ipe SHARED src/libipe.c)
+add_library(ufodecode SHARED src/ufodecode.c)
 
-set_target_properties(ipe PROPERTIES
-    VERSION ${LIBIPE_ABI_VERSION}
-    SOVERSION ${LIBIPE_ABI_MAJOR_VERSION}
+set_target_properties(ufodecode PROPERTIES
+    VERSION ${LIBUFODECODE_ABI_VERSION}
+    SOVERSION ${LIBUFODECODE_ABI_MAJOR_VERSION}
 )
 
-install(TARGETS ipe
+install(TARGETS ufodecode
     LIBRARY DESTINATION lib${LIB_SUFFIX}
 )
 
 install(FILES
-    src/libipe.h 
+    src/ufodecode.h
     DESTINATION include
 )
 
-configure_file(ipe.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ipe.pc)
+configure_file(ufodecode.pc.in ${CMAKE_CURRENT_BINARY_DIR}/ufodecode.pc)
 
 if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
     set(DEBUG "1")
@@ -87,12 +87,12 @@ endif()
 configure_file(src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 
 install(FILES 
-    ${CMAKE_CURRENT_BINARY_DIR}/ipe.pc 
+    ${CMAKE_CURRENT_BINARY_DIR}/ufodecode.pc 
     DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
 
 # --- Build test executable -------------------------------------------------
 add_executable(ipedec test/ipedec.c)
-target_link_libraries(ipedec ipe)
+target_link_libraries(ipedec ufodecode)
 
 install(TARGETS ipedec DESTINATION ${BIN_INSTALL_DIR})

+ 0 - 27
src/libipe.h

@@ -1,27 +0,0 @@
-#ifndef LIB_IPE_H
-#define LIB_IPE_H
-
-#include <inttypes.h>
-
-typedef struct ipe_decoder_t *ipe_decoder;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-ipe_decoder ipe_decoder_new(uint32_t height, uint32_t *raw, size_t num_bytes);
-void ipe_decoder_free(ipe_decoder decoder);
-void ipe_decoder_set_raw_data(ipe_decoder decoder, uint32_t *raw, size_t num_bytes);
-int ipe_decoder_get_next_frame(ipe_decoder decoder, uint16_t **pixels, uint32_t *frame_number, uint32_t *time_stamp);
-
-void ipe_deinterlace_interpolate(const uint16_t *frame_in, uint16_t *frame_out, int width, int height);
-void ipe_deinterlace_weave(const uint16_t *in1, const uint16_t *in2, uint16_t *out, int width, int height);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-

+ 3 - 3
src/libipe-private.h → src/ufodecode-private.h

@@ -1,9 +1,9 @@
-#ifndef LIB_IPE_PRIVATE_H
-#define LIB_IPE_PRIVATE_H
+#ifndef LIB_UFODECODE_PRIVATE_H
+#define LIB_UFODECODE_PRIVATE_H
 
 #include <stdbool.h>
 
-struct ipe_decoder_t {
+struct ufo_decoder_t {
     uint32_t height;
     uint32_t *raw;
     size_t num_bytes; 

+ 24 - 22
src/libipe.c → src/ufodecode.c

@@ -3,10 +3,13 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include "libipe.h"
-#include "libipe-private.h"
+#include "ufodecode.h"
+#include "ufodecode-private.h"
 #include "config.h"
+
+#ifdef HAVE_SSE
 #include <xmmintrin.h>
+#endif
 
 #define IPECAMERA_NUM_CHANNELS 16
 #define IPECAMERA_PIXELS_PER_CHANNEL 128
@@ -31,20 +34,20 @@
  *
  * \param height Number of rows that are expected in the data stream
  * \param raw The data stream from the camera or NULL if set later with
- * ipe_decoder_set_raw_data.
+ * ufo_decoder_set_raw_data.
  * \param num_bytes Size of the data stream buffer in bytes
  *
  * \return A new decoder instance that can be used to iterate over the frames
- * using ipe_decoder_get_next_frame.
+ * using ufo_decoder_get_next_frame.
  */
-ipe_decoder ipe_decoder_new(uint32_t height, uint32_t *raw, size_t num_bytes)
+ufo_decoder ufo_decoder_new(uint32_t height, uint32_t *raw, size_t num_bytes)
 {
-    ipe_decoder decoder = malloc(sizeof(struct ipe_decoder_t));
+    ufo_decoder decoder = malloc(sizeof(struct ufo_decoder_t));
     if (decoder == NULL)
         return NULL;
 
     decoder->height = height;
-    ipe_decoder_set_raw_data(decoder, raw, num_bytes);
+    ufo_decoder_set_raw_data(decoder, raw, num_bytes);
     return decoder;
 }
 
@@ -52,9 +55,9 @@ ipe_decoder ipe_decoder_new(uint32_t height, uint32_t *raw, size_t num_bytes)
 /**
  * \brief Release decoder instance
  *
- * \param decoder An ipe_decoder instance
+ * \param decoder An ufo_decoder instance
  */
-void ipe_decoder_free(ipe_decoder decoder)
+void ufo_decoder_free(ufo_decoder decoder)
 {
     free(decoder);
 }
@@ -63,18 +66,18 @@ void ipe_decoder_free(ipe_decoder decoder)
 /**
  * \brief Set raw data stream
  *
- * \param decoder An ipe_decoder instance
+ * \param decoder An ufo_decoder instance
  * \param raw Raw data stream
  * \param num_bytes Size of data stream buffer in bytes
  */
-void ipe_decoder_set_raw_data(ipe_decoder decoder, uint32_t *raw, size_t num_bytes)
+void ufo_decoder_set_raw_data(ufo_decoder decoder, uint32_t *raw, size_t num_bytes)
 {
     decoder->raw = raw;
     decoder->num_bytes = num_bytes;
     decoder->current_pos = 0;
 }
 
-static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows, int *offset)
+static int ufo_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 };
 
@@ -86,8 +89,7 @@ static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
     const int bytes = 43;
 
 #ifdef HAVE_SSE
-    const uint32_t mask = 0x3FF;
-    __m128i mmask = _mm_set_epi32(mask, mask, mask, mask);
+    __m128i mask = _mm_set_epi32(0x3FF, 0x3FF, 0x3FF, 0x3FF);
     __m128i packed;
     __m128i tmp1, tmp2;
     uint32_t result[4] __attribute__ ((aligned (16))) = {0};
@@ -125,7 +127,7 @@ static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
             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, mmask);
+            tmp2 = _mm_and_si128(tmp1, mask);
             _mm_storeu_si128((__m128i*) result, tmp2);
             pixel_buffer[base] = result[0];
             pixel_buffer[base+3] = result[1];
@@ -133,14 +135,14 @@ static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
             pixel_buffer[base+9] = result[3];
 
             tmp1 = _mm_srli_epi32(packed, 10);
-            tmp2 = _mm_and_si128(tmp1, mmask);
+            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];
 
-            tmp1 = _mm_and_si128(packed, mmask);
+            tmp1 = _mm_and_si128(packed, mask);
             _mm_storeu_si128((__m128i*) result, tmp1);
             pixel_buffer[base+2] = result[0];
             pixel_buffer[base+5] = result[1];
@@ -200,7 +202,7 @@ static int ipe_decode_frame(uint16_t *pixel_buffer, uint32_t *raw, int num_rows,
  * \param width Width of frame in pixels
  * \param heigh Height of frame in pixels
  */
-void ipe_deinterlace_interpolate(const uint16_t *in, uint16_t *out, int width, int height)
+void ufo_deinterlace_interpolate(const uint16_t *in, uint16_t *out, int width, int height)
 {
     const size_t row_size_bytes = width * sizeof(uint16_t);
 
@@ -230,7 +232,7 @@ void ipe_deinterlace_interpolate(const uint16_t *in, uint16_t *out, int width, i
  * \param width Width of frame in pixels
  * \param heigh Height of frame in pixels
  */
-void ipe_deinterlace_weave(const uint16_t *in1, const uint16_t *in2, uint16_t *out, int width, int height)
+void ufo_deinterlace_weave(const uint16_t *in1, const uint16_t *in2, uint16_t *out, int width, int height)
 {
     const size_t row_size_bytes = width * sizeof(uint16_t);
     for (int row = 0; row < height; row++) {
@@ -248,7 +250,7 @@ void ipe_deinterlace_weave(const uint16_t *in1, const uint16_t *in2, uint16_t *o
  * This function tries to decode the next frame in the currently set raw data
  * stream. 
  *
- * \param decoder An ipe_decoder instance
+ * \param decoder An ufo_decoder instance
  * \param pixels If pointer with NULL content is passed, a new buffer is
  * allocated otherwise, this user-supplied buffer is used.
  * \param frame_number Frame number as reported in the header
@@ -258,7 +260,7 @@ void ipe_deinterlace_weave(const uint16_t *in1, const uint16_t *in2, uint16_t *o
  * NULL was passed but no memory could be allocated, EILSEQ if data stream is
  * corrupt and EFAULT if pixels is a NULL-pointer.
  */
-int ipe_decoder_get_next_frame(ipe_decoder decoder, uint16_t **pixels, uint32_t *frame_number, uint32_t *time_stamp)
+int ufo_decoder_get_next_frame(ufo_decoder decoder, uint16_t **pixels, uint32_t *frame_number, uint32_t *time_stamp)
 {
 
     uint32_t *raw = decoder->raw;
@@ -301,7 +303,7 @@ int ipe_decoder_get_next_frame(ipe_decoder decoder, uint16_t **pixels, uint32_t
     pos += 8;
 #endif
 
-    err = ipe_decode_frame(*pixels, raw + pos, decoder->height, &advance);
+    err = ufo_decode_frame(*pixels, raw + pos, decoder->height, &advance);
     if (err)
         return EILSEQ;
 

+ 27 - 0
src/ufodecode.h

@@ -0,0 +1,27 @@
+#ifndef LIB_UFODECODE_H
+#define LIB_UFODECODE_H
+
+#include <inttypes.h>
+
+typedef struct ufo_decoder_t *ufo_decoder;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+ufo_decoder ufo_decoder_new(uint32_t height, uint32_t *raw, size_t num_bytes);
+void ufo_decoder_free(ufo_decoder decoder);
+void ufo_decoder_set_raw_data(ufo_decoder decoder, uint32_t *raw, size_t num_bytes);
+int ufo_decoder_get_next_frame(ufo_decoder decoder, uint16_t **pixels, uint32_t *frame_number, uint32_t *time_stamp);
+
+void ufo_deinterlace_interpolate(const uint16_t *frame_in, uint16_t *frame_out, int width, int height);
+void ufo_deinterlace_weave(const uint16_t *in1, const uint16_t *in2, uint16_t *out, int width, int height);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+

+ 4 - 4
test/ipedec.c

@@ -4,7 +4,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <errno.h>
-#include <libipe.h>
+#include <ufodecode.h>
 
 
 int read_raw_file(const char *filename, char **buffer, size_t *length)
@@ -47,7 +47,7 @@ int main(int argc, char const* argv[])
 
     const int rows = atoi(argv[2]);
 
-    ipe_decoder decoder = ipe_decoder_new(rows, (uint32_t *) buffer, num_bytes);
+    ufo_decoder decoder = ufo_decoder_new(rows, (uint32_t *) buffer, num_bytes);
     int err = 0;
     uint16_t *pixels = (uint16_t *) malloc(2048 * rows * sizeof(uint16_t));
     uint32_t frame_number, time_stamp;
@@ -59,7 +59,7 @@ int main(int argc, char const* argv[])
 
     while (!err) {
         gettimeofday(&start, NULL);
-        err = ipe_decoder_get_next_frame(decoder, &pixels, &frame_number, &time_stamp);
+        err = ufo_decoder_get_next_frame(decoder, &pixels, &frame_number, &time_stamp);
         gettimeofday(&end, NULL);
 
         if (!err) {
@@ -75,7 +75,7 @@ int main(int argc, char const* argv[])
     printf("Decoded %i frames in %.5fms\n", num_frames, mtime);
 
     free(pixels);
-    ipe_decoder_free(decoder);
+    ufo_decoder_free(decoder);
     free(buffer);
 
     return 0;

+ 2 - 2
ipe.pc.in → ufodecode.pc.in

@@ -3,8 +3,8 @@ exec_prefix=${BIN_INSTALL_DIR}
 libdir=${LIB_INSTALL_DIR}
 includedir=${INCLUDE_INSTALL_DIR}
 
-Name: libipe
+Name: ${TARNAME}
 Description: Decoding routines for the UFO camera
 Version: ${PACKAGE_VERSION}
-Libs: -L${LIB_INSTALL_DIR} -lipe
+Libs: -L${LIB_INSTALL_DIR} -lufodecode
 Cflags: -I${INCLUDE_INSTALL_DIR}