ufodecode.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef LIB_UFODECODE_H
  2. #define LIB_UFODECODE_H
  3. #include <inttypes.h>
  4. typedef struct _UfoDecoder UfoDecoder;
  5. typedef struct {
  6. unsigned dummy1:2;
  7. unsigned fsm_master_readout:4;
  8. unsigned dummy2:4;
  9. unsigned fsm_daq:4;
  10. unsigned pixel_full:1;
  11. unsigned control_lock:1;
  12. unsigned data_lock:16;
  13. } UfoDecoderStatus1;
  14. typedef struct {
  15. unsigned end_of_frames:1;
  16. unsigned busy_or:1;
  17. unsigned busy_ddr:1;
  18. unsigned busy_interl:1;
  19. unsigned error_status:4; /* What the heck? */
  20. unsigned data_fifo_read_count:10;
  21. unsigned data_fifo_full:1;
  22. unsigned data_fifo_empty:1;
  23. unsigned dummy:2;
  24. unsigned ddr_fifo_write_count:8;
  25. unsigned ddr_fifo_full:1;
  26. unsigned ddr_fifo_empty:1;
  27. } UfoDecoderStatus2;
  28. typedef struct {
  29. unsigned dummy:2;
  30. unsigned row_counter:10;
  31. unsigned pixel_counter:8;
  32. unsigned ddr_read:4;
  33. unsigned ddr_write:4;
  34. unsigned ddr_arbiter:4;
  35. } UfoDecoderStatus3;
  36. typedef struct {
  37. uint32_t frame_number;
  38. uint32_t time_stamp;
  39. uint32_t n_rows;
  40. uint8_t n_skipped_rows;
  41. uint16_t cmosis_start_address;
  42. union {
  43. uint32_t bits;
  44. UfoDecoderStatus1 desc;
  45. } status1;
  46. union {
  47. uint32_t bits;
  48. UfoDecoderStatus2 desc;
  49. } status2;
  50. union {
  51. uint32_t bits;
  52. UfoDecoderStatus3 desc;
  53. } status3;
  54. } UfoDecoderMeta;
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. UfoDecoder *ufo_decoder_new (int32_t height,
  59. uint32_t width,
  60. uint32_t *raw,
  61. size_t num_bytes);
  62. void ufo_decoder_free (UfoDecoder *decoder);
  63. size_t ufo_decoder_decode_frame (UfoDecoder *decoder,
  64. uint32_t *raw,
  65. size_t num_bytes,
  66. uint16_t *pixels,
  67. UfoDecoderMeta *meta);
  68. void ufo_decoder_set_raw_data (UfoDecoder *decoder,
  69. uint32_t *raw,
  70. size_t num_bytes);
  71. int ufo_decoder_get_next_frame (UfoDecoder *decoder,
  72. uint16_t **pixels,
  73. UfoDecoderMeta *meta_data);
  74. void ufo_deinterlace_interpolate (const uint16_t *frame_in,
  75. uint16_t *frame_out,
  76. int width,
  77. int height);
  78. void ufo_deinterlace_weave (const uint16_t *in1,
  79. const uint16_t *in2,
  80. uint16_t *out,
  81. int width,
  82. int height);
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif