u/sink_converter: Remove u_sink_converter::frame

This commit is contained in:
Christoph Haag 2020-11-25 16:05:43 +01:00 committed by Jakob Bornecrantz
parent 5a4df61885
commit 3b992a4508

View file

@ -39,8 +39,6 @@ struct u_sink_converter
struct xrt_frame_sink *downstream; struct xrt_frame_sink *downstream;
struct xrt_frame *frame;
enum xrt_format format; enum xrt_format format;
}; };
@ -371,27 +369,11 @@ create_one_off_with_format(struct xrt_frame *xf,
struct xrt_frame **one_off) struct xrt_frame **one_off)
{ {
u_frame_create_one_off(format, xf->width, xf->height, one_off); u_frame_create_one_off(format, xf->width, xf->height, one_off);
} (*one_off)->timestamp = xf->timestamp;
(*one_off)->source_timestamp = xf->source_timestamp;
static void (*one_off)->source_sequence = xf->source_sequence;
push_data_downstream(struct u_sink_converter *s, struct xrt_frame *xf) (*one_off)->source_id = xf->source_id;
{ (*one_off)->stereo_format = xf->stereo_format;
// The frame has a single reference on it when it's on the converter
// struct, we move it so no need to change the ref count.
struct xrt_frame *frame = s->frame;
s->frame = NULL;
// Copy directly from original frame.
frame->timestamp = xf->timestamp;
frame->source_timestamp = xf->source_timestamp;
frame->source_sequence = xf->source_sequence;
frame->source_id = xf->source_id;
frame->stereo_format = xf->stereo_format;
s->downstream->push_frame(s->downstream, frame);
// Refcount in case it's being held downstream.
xrt_frame_reference(&frame, NULL);
} }
static void static void
@ -399,30 +381,32 @@ receive_frame_r8g8b8_or_l8(struct xrt_frame_sink *xs, struct xrt_frame *xf)
{ {
struct u_sink_converter *s = (struct u_sink_converter *)xs; struct u_sink_converter *s = (struct u_sink_converter *)xs;
struct xrt_frame *converted = NULL;
switch (xf->format) { switch (xf->format) {
case XRT_FORMAT_L8: case XRT_FORMAT_L8:
case XRT_FORMAT_R8G8B8: case XRT_FORMAT_R8G8B8:
s->downstream->push_frame(s->downstream, xf); s->downstream->push_frame(s->downstream, xf);
return; return;
case XRT_FORMAT_YUYV422: case XRT_FORMAT_YUYV422:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
from_YUYV422_to_R8G8B8(s->frame, xf->width, xf->height, from_YUYV422_to_R8G8B8(converted, xf->width, xf->height,
xf->stride, xf->data); xf->stride, xf->data);
break; break;
case XRT_FORMAT_UYVY422: case XRT_FORMAT_UYVY422:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
from_UYVY422_to_R8G8B8(s->frame, xf->width, xf->height, from_UYVY422_to_R8G8B8(converted, xf->width, xf->height,
xf->stride, xf->data); xf->stride, xf->data);
break; break;
case XRT_FORMAT_YUV888: case XRT_FORMAT_YUV888:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
from_YUV888_to_R8G8B8(s->frame, xf->width, xf->height, from_YUV888_to_R8G8B8(converted, xf->width, xf->height,
xf->stride, xf->data); xf->stride, xf->data);
break; break;
#ifdef XRT_HAVE_JPEG #ifdef XRT_HAVE_JPEG
case XRT_FORMAT_MJPEG: case XRT_FORMAT_MJPEG:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
if (!from_MJPEG_to_R8G8B8(s->frame, xf->size, xf->data)) { if (!from_MJPEG_to_R8G8B8(converted, xf->size, xf->data)) {
return; return;
} }
break; break;
@ -433,7 +417,10 @@ receive_frame_r8g8b8_or_l8(struct xrt_frame_sink *xs, struct xrt_frame *xf)
return; return;
} }
push_data_downstream(s, xf); s->downstream->push_frame(s->downstream, converted);
// Refcount in case it's being held downstream.
xrt_frame_reference(&converted, NULL);
} }
static void static void
@ -441,29 +428,31 @@ receive_frame_r8g8b8(struct xrt_frame_sink *xs, struct xrt_frame *xf)
{ {
struct u_sink_converter *s = (struct u_sink_converter *)xs; struct u_sink_converter *s = (struct u_sink_converter *)xs;
struct xrt_frame *converted = NULL;
switch (xf->format) { switch (xf->format) {
case XRT_FORMAT_R8G8B8: case XRT_FORMAT_R8G8B8:
s->downstream->push_frame(s->downstream, xf); s->downstream->push_frame(s->downstream, xf);
return; return;
case XRT_FORMAT_YUYV422: case XRT_FORMAT_YUYV422:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
from_YUYV422_to_R8G8B8(s->frame, xf->width, xf->height, from_YUYV422_to_R8G8B8(converted, xf->width, xf->height,
xf->stride, xf->data); xf->stride, xf->data);
break; break;
case XRT_FORMAT_UYVY422: case XRT_FORMAT_UYVY422:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
from_UYVY422_to_R8G8B8(s->frame, xf->width, xf->height, from_UYVY422_to_R8G8B8(converted, xf->width, xf->height,
xf->stride, xf->data); xf->stride, xf->data);
break; break;
case XRT_FORMAT_YUV888: case XRT_FORMAT_YUV888:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
from_YUV888_to_R8G8B8(s->frame, xf->width, xf->height, from_YUV888_to_R8G8B8(converted, xf->width, xf->height,
xf->stride, xf->data); xf->stride, xf->data);
break; break;
#ifdef XRT_HAVE_JPEG #ifdef XRT_HAVE_JPEG
case XRT_FORMAT_MJPEG: case XRT_FORMAT_MJPEG:
create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_R8G8B8, &converted);
if (!from_MJPEG_to_R8G8B8(s->frame, xf->size, xf->data)) { if (!from_MJPEG_to_R8G8B8(converted, xf->size, xf->data)) {
return; return;
} }
break; break;
@ -474,7 +463,10 @@ receive_frame_r8g8b8(struct xrt_frame_sink *xs, struct xrt_frame *xf)
return; return;
} }
push_data_downstream(s, xf); s->downstream->push_frame(s->downstream, converted);
// Refcount in case it's being held downstream.
xrt_frame_reference(&converted, NULL);
} }
static void static void
@ -483,6 +475,7 @@ receive_frame_yuv_yuyv_uyvy_or_l8(struct xrt_frame_sink *xs,
{ {
struct u_sink_converter *s = (struct u_sink_converter *)xs; struct u_sink_converter *s = (struct u_sink_converter *)xs;
struct xrt_frame *converted = NULL;
switch (xf->format) { switch (xf->format) {
case XRT_FORMAT_L8: case XRT_FORMAT_L8:
@ -493,8 +486,8 @@ receive_frame_yuv_yuyv_uyvy_or_l8(struct xrt_frame_sink *xs,
return; return;
#ifdef XRT_HAVE_JPEG #ifdef XRT_HAVE_JPEG
case XRT_FORMAT_MJPEG: case XRT_FORMAT_MJPEG:
create_one_off_with_format(xf, XRT_FORMAT_YUV888, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_YUV888, &converted);
if (!from_MJPEG_to_YUV888(s->frame, xf->size, xf->data)) { if (!from_MJPEG_to_YUV888(converted, xf->size, xf->data)) {
return; return;
} }
break; break;
@ -507,7 +500,10 @@ receive_frame_yuv_yuyv_uyvy_or_l8(struct xrt_frame_sink *xs,
return; return;
} }
push_data_downstream(s, xf); s->downstream->push_frame(s->downstream, converted);
// Refcount in case it's being held downstream.
xrt_frame_reference(&converted, NULL);
} }
static void static void
@ -515,6 +511,7 @@ receive_frame_yuv_or_yuyv(struct xrt_frame_sink *xs, struct xrt_frame *xf)
{ {
struct u_sink_converter *s = (struct u_sink_converter *)xs; struct u_sink_converter *s = (struct u_sink_converter *)xs;
struct xrt_frame *converted = NULL;
switch (xf->format) { switch (xf->format) {
case XRT_FORMAT_YUYV422: case XRT_FORMAT_YUYV422:
@ -523,8 +520,8 @@ receive_frame_yuv_or_yuyv(struct xrt_frame_sink *xs, struct xrt_frame *xf)
return; return;
#ifdef XRT_HAVE_JPEG #ifdef XRT_HAVE_JPEG
case XRT_FORMAT_MJPEG: case XRT_FORMAT_MJPEG:
create_one_off_with_format(xf, XRT_FORMAT_YUV888, &s->frame); create_one_off_with_format(xf, XRT_FORMAT_YUV888, &converted);
if (!from_MJPEG_to_YUV888(s->frame, xf->size, xf->data)) { if (!from_MJPEG_to_YUV888(converted, xf->size, xf->data)) {
return; return;
} }
break; break;
@ -535,7 +532,10 @@ receive_frame_yuv_or_yuyv(struct xrt_frame_sink *xs, struct xrt_frame *xf)
return; return;
} }
push_data_downstream(s, xf); s->downstream->push_frame(s->downstream, converted);
// Refcount in case it's being held downstream.
xrt_frame_reference(&converted, NULL);
} }
static void static void