13#include <mpix/formats.h>
16#include <mpix/types.h>
17#include <mpix/pipeline.h>
28#define MPIX_REGISTER_OP(name, ...) MPIX_REGISTER_NB(name, ## __VA_ARGS__, P_NB)
29#define MPIX_REGISTER_NB(name, ...) enum { __VA_ARGS__ }; const size_t mpix_params_nb_##name = P_NB
32#define MPIX_OP_PARAMS_NB(X, x) extern const size_t mpix_params_nb_##x;
33MPIX_FOR_EACH_OP(MPIX_OP_PARAMS_NB)
36#define MPIX_OP_ADD(X, x) int mpix_add_##x(struct mpix_image *img, const int32_t *params);
37MPIX_FOR_EACH_OP(MPIX_OP_ADD)
40#define MPIX_OP_RUN(X, x) int mpix_run_##x(struct mpix_base_op *op);
41MPIX_FOR_EACH_OP(MPIX_OP_RUN)
44#define MPIX_OP_INPUT_LINES(...) { int e = mpix_op_input_lines(__VA_ARGS__); if (e) return e; }
47#define MPIX_OP_INPUT_BYTES(...) { int e = mpix_op_input_bytes(__VA_ARGS__); if (e) return e; }
50#define MPIX_OP_INPUT_DONE(...) { int e = mpix_op_input_done(__VA_ARGS__); if (e) return e; }
53#define MPIX_OP_INPUT_PEEK(...) { int e = mpix_op_input_peek(__VA_ARGS__); if (e) return e; }
56#define MPIX_OP_INPUT_FLUSH(...) { int e = mpix_op_input_flush(__VA_ARGS__); if (e) return e; }
59#define MPIX_OP_OUTPUT_LINE(...) { int e = mpix_op_output_line(__VA_ARGS__); if (e) return e; }
62#define MPIX_OP_OUTPUT_DONE(...) { int e = mpix_op_output_done(__VA_ARGS__); if (e) return e; }
65#define MPIX_OP_OUTPUT_PEEK(...) { int e = mpix_op_output_peek(__VA_ARGS__); if (e) return e; }
68#define MPIX_OP_OUTPUT_FLUSH(...) { int e = mpix_op_output_flush(__VA_ARGS__); if (e) return e; }
70static inline int mpix_op_input_lines(
struct mpix_base_op *op,
const uint8_t **src,
size_t num)
73 mpix_ring_reset_peek(&op->
ring);
76 for (
size_t i = 0; i < num; i++) {
78 if (src[i] == NULL)
return -EAGAIN;
84static inline int mpix_op_input_bytes(
struct mpix_base_op *op,
const uint8_t **src,
size_t bytes)
87 *src = mpix_ring_peek(&op->
ring, bytes);
89 return (*src == NULL) ? -EAGAIN : 0;
92static inline int mpix_op_input_done(
struct mpix_base_op *op,
size_t lines)
100 return (src == NULL) ? -EIO : 0;
103static inline int mpix_op_input_peek(
struct mpix_base_op *op,
const uint8_t **src,
size_t *sz)
106 *sz = mpix_ring_used_size(&op->
ring);
109 *src = mpix_ring_peek(&op->
ring, *sz);
111 return (*src == NULL) ? -EIO : 0;
114static inline int mpix_op_input_flush(
struct mpix_base_op *op,
size_t bytes)
117 const uint8_t *src = mpix_ring_read(&op->
ring, bytes);
119 return (src == NULL) ? -EIO : 0;
122static inline void mpix_op_input_all(
struct mpix_base_op *op,
const uint8_t **src,
size_t *sz)
125 *sz = mpix_ring_used_size(&op->
ring);
128 *src = mpix_ring_read(&op->
ring, *sz);
134static inline int mpix_op_output_peek(
struct mpix_base_op *op, uint8_t **dst,
size_t *sz)
136 if (op->
next == NULL)
return -ENODEV;
139 *sz = mpix_ring_free_size(&op->
next->
ring);
142 return (*dst == NULL) ? -EIO : 0;
145static inline int mpix_op_output_done(
struct mpix_base_op *op)
147 if (op->
next == NULL)
return -ENODEV;
153 int err = mpix_pipeline_run_once(op->
next);
161static inline int mpix_op_output_line(
struct mpix_base_op *op, uint8_t **dst)
163 if (op->
next == NULL)
return -ENODEV;
168 return (*dst == NULL) ? -ENOBUFS : 0;
171static inline int mpix_op_output_flush(
struct mpix_base_op *op,
size_t bytes)
173 if (op->
next == NULL)
return -ENODEV;
176 uint8_t *dst = mpix_ring_write(&op->
next->
ring, bytes);
178 return (dst == NULL) ? -ENOBUFS : 0;
197 memset(op, 0x00, op_sz);
static void * mpix_op_append(struct mpix_image *img, enum mpix_op_type op_type, size_t op_sz, size_t buf_sz)
Allocate a new operation and add it to an image pipeline.
Definition operation.h:188
uint32_t mpix_port_get_uptime_us(void)
Get the uptime in microsecond, used to compute performance statistics.
void * mpix_port_alloc(size_t size)
Allocate a buffer to use with libmpix.
mpix_op_type
MPIX operation type identifying an operation family.
Definition types.h:21
One step of a line operation pipeline.
Definition types.h:111
struct mpix_base_op * next
Definition types.h:113
uint16_t line_offset
Definition types.h:119
struct mpix_ring ring
Definition types.h:121
uint32_t total_time_us
Definition types.h:125
uint32_t start_time_us
Definition types.h:123
enum mpix_op_type type
Definition types.h:115
struct mpix_format fmt
Definition types.h:117
Represent the image currently being processed.
Definition types.h:136
struct mpix_base_op * first_op
Definition types.h:138
struct mpix_base_op * last_op
Definition types.h:140
struct mpix_format fmt
Definition types.h:146
size_t peek
Definition types.h:96
uint8_t * buffer
Definition types.h:88
size_t head
Definition types.h:92
size_t size
Definition types.h:90
size_t tail
Definition types.h:94