ufodecode.h 3.3 KB

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