diff --git a/python/src/ustreamer.c b/python/src/ustreamer.c index 676be82e5..bbd551ac3 100644 --- a/python/src/ustreamer.c +++ b/python/src/ustreamer.c @@ -130,7 +130,7 @@ static int _wait_frame(_MemsinkObject *self) { if (mem->magic == US_MEMSINK_MAGIC && mem->version == US_MEMSINK_VERSION && mem->id != self->frame_id) { if (self->drop_same_frames > 0) { if ( - US_FRAME_COMPARE_META_USED_NOTS(self->mem, self->frame) + US_FRAME_COMPARE_GEOMETRY(self->mem, self->frame) && (self->frame_ts + self->drop_same_frames > now_ts) && !memcmp(self->frame->data, mem->data, mem->used) ) { diff --git a/src/libs/frame.c b/src/libs/frame.c index 6a53725ae..3c2062dac 100644 --- a/src/libs/frame.c +++ b/src/libs/frame.c @@ -74,7 +74,7 @@ void us_frame_copy(const us_frame_s *src, us_frame_s *dest) { bool us_frame_compare(const us_frame_s *a, const us_frame_s *b) { return ( a->allocated && b->allocated - && US_FRAME_COMPARE_META_USED_NOTS(a, b) + && US_FRAME_COMPARE_GEOMETRY(a, b) && !memcmp(a->data, b->data, b->used) ); } @@ -99,6 +99,10 @@ uint us_frame_get_padding(const us_frame_s *frame) { return 0; } +bool us_is_jpeg(uint format) { + return (format == V4L2_PIX_FMT_JPEG || format == V4L2_PIX_FMT_MJPEG); +} + const char *us_fourcc_to_string(uint format, char *buf, uz size) { assert(size >= 8); buf[0] = format & 0x7F; diff --git a/src/libs/frame.h b/src/libs/frame.h index 5a15e28b2..efb3cb1cf 100644 --- a/src/libs/frame.h +++ b/src/libs/frame.h @@ -22,8 +22,6 @@ #pragma once -#include - #include "types.h" #include "tools.h" @@ -41,7 +39,6 @@ typedef struct { // Stride is a bytesperline in V4L2 // https://www.kernel.org/doc/html/v4.14/media/uapi/v4l/pixfmt-v4l2.html // https://medium.com/@oleg.shipitko/what-does-stride-mean-in-image-processing-bba158a72bcd - bool online; bool key; uint gop; @@ -65,11 +62,8 @@ typedef struct { x_dest->encode_end_ts = x_src->encode_end_ts; \ } -static inline void us_frame_copy_meta(const us_frame_s *src, us_frame_s *dest) { - US_FRAME_COPY_META(src, dest); -} - -#define US_FRAME_COMPARE_META_USED_NOTS(x_a, x_b) ( \ +#define US_FRAME_COMPARE_GEOMETRY(x_a, x_b) ( \ + /* Compare the used size and significant meta (no timings) */ \ x_a->used == x_b->used \ && x_a->width == x_b->width \ && x_a->height == x_b->height \ @@ -83,7 +77,7 @@ static inline void us_frame_copy_meta(const us_frame_s *src, us_frame_s *dest) { static inline void us_frame_encoding_begin(const us_frame_s *src, us_frame_s *dest, uint format) { assert(src->used > 0); - us_frame_copy_meta(src, dest); + US_FRAME_COPY_META(src, dest); dest->encode_begin_ts = us_get_now_monotonic(); dest->format = format; dest->stride = 0; @@ -108,8 +102,5 @@ bool us_frame_compare(const us_frame_s *a, const us_frame_s *b); uint us_frame_get_padding(const us_frame_s *frame); +bool us_is_jpeg(uint format); const char *us_fourcc_to_string(uint format, char *buf, uz size); - -static inline bool us_is_jpeg(uint format) { - return (format == V4L2_PIX_FMT_JPEG || format == V4L2_PIX_FMT_MJPEG); -} diff --git a/src/libs/memsink.c b/src/libs/memsink.c index a7c23b589..a7454c006 100644 --- a/src/libs/memsink.c +++ b/src/libs/memsink.c @@ -129,7 +129,7 @@ bool us_memsink_server_check(us_memsink_s *sink, const us_frame_s *frame) { US_LOG_PERROR("%s-sink: Can't unlock memory", sink->name); return false; } - return (has_clients || !US_FRAME_COMPARE_META_USED_NOTS(sink->mem, frame));; + return (has_clients || !US_FRAME_COMPARE_GEOMETRY(sink->mem, frame));; } int us_memsink_server_put(us_memsink_s *sink, const us_frame_s *frame, bool *key_requested) { diff --git a/src/libs/unjpeg.c b/src/libs/unjpeg.c index ffd0f213a..0af2f31a0 100644 --- a/src/libs/unjpeg.c +++ b/src/libs/unjpeg.c @@ -68,7 +68,7 @@ int us_unjpeg(const us_frame_s *src, us_frame_s *dest, bool decode) { jpeg_start_decompress(&jpeg); - us_frame_copy_meta(src, dest); + US_FRAME_COPY_META(src, dest); dest->format = V4L2_PIX_FMT_RGB24; dest->width = jpeg.output_width; dest->height = jpeg.output_height; diff --git a/src/v4p/drm.c b/src/v4p/drm.c index 4fd1609ea..fc4093562 100644 --- a/src/v4p/drm.c +++ b/src/v4p/drm.c @@ -30,6 +30,8 @@ #include #include +#include + #include #include #include