The open imaging DSP library
Loading...
Searching...
No Matches
zephyr.h
1
7#ifndef MPIX_ZEPHYR_H
8#define MPIX_ZEPHYR_H
9
10#include <zephyr/drivers/video.h>
11#include <mpix/image.h>
12#include <mpix/types.h>
13
21static inline void mpix_zephyr_set_format(struct mpix_image *img, struct video_format *vfmt)
22{
23 img->fmt.width = vfmt->width;
24 img->fmt.height = vfmt->height;
25
26 img->fmt.fourcc =
27 /* Zephyr 3.6 compat */
28 (vfmt->pixelformat == MPIX_FOURCC('B', 'G', 'G', 'R')) ? MPIX_FMT_SBGGR8 :
29 (vfmt->pixelformat == MPIX_FOURCC('R', 'G', 'G', 'B')) ? MPIX_FMT_SRGGB8 :
30 (vfmt->pixelformat == MPIX_FOURCC('G', 'R', 'B', 'G')) ? MPIX_FMT_SGRBG8 :
31 (vfmt->pixelformat == MPIX_FOURCC('G', 'B', 'R', 'G')) ? MPIX_FMT_SGBRG8 :
32 /* Fourcc are standards so direct match is possible */
33 vfmt->pixelformat;
34}
35
43static inline void mpix_image_from_vbuf(struct mpix_image *img, struct video_buffer *vbuf,
44 struct video_format *vfmt)
45{
46 mpix_zephyr_set_format(img, vfmt);
47 mpix_image_from_buf(img, vbuf->buffer, vbuf->bytesused, &img->fmt);
48}
49
57static inline int mpix_image_to_vbuf(struct mpix_image *img, struct video_buffer *vbuf)
58{
59 int err = mpix_image_to_buf(img, vbuf->buffer, vbuf->size);
60 vbuf->bytesused = mpix_ring_used_size(&img->last_op->ring);
61 return err;
62}
63
64#endif
#define MPIX_FMT_SRGGB8
Definition formats.h:273
#define MPIX_FMT_SGRBG8
Definition formats.h:264
#define MPIX_FMT_SGBRG8
Definition formats.h:255
#define MPIX_FMT_SBGGR8
Definition formats.h:246
#define MPIX_FOURCC(a, b, c, d)
Define a new pixel format, with defaults for most common values.
Definition formats.h:40
static void mpix_image_from_buf(struct mpix_image *img, const uint8_t *buffer, size_t size, const struct mpix_format *fmt)
Initialize an image from a memory buffer.
Definition image.h:30
static int mpix_image_to_buf(struct mpix_image *img, uint8_t *buffer, size_t size)
Convert an image and store it into the output buffer.
Definition image.h:46
static int mpix_image_to_vbuf(struct mpix_image *img, struct video_buffer *vbuf)
Initialize an image from a memory buffer.
Definition zephyr.h:57
static void mpix_image_from_vbuf(struct mpix_image *img, struct video_buffer *vbuf, struct video_format *vfmt)
Initialize an image from a zephyr video buffer.
Definition zephyr.h:43
static void mpix_zephyr_set_format(struct mpix_image *img, struct video_format *vfmt)
Initialize an image with Zephyr native types.
Definition zephyr.h:21
struct mpix_ring ring
Definition types.h:121
uint16_t height
Definition types.h:78
uint16_t width
Definition types.h:76
uint32_t fourcc
Definition types.h:74
Represent the image currently being processed.
Definition types.h:136
struct mpix_base_op * last_op
Definition types.h:140
const uint8_t * buffer
Definition types.h:142
struct mpix_format fmt
Definition types.h:146