The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/sink: Add support for XRT_FORMAT_UYVY422

authored by

Jakob Bornecrantz and committed by
Jakob Bornecrantz
c7903e2d 1de7eb7c

+70 -12
+2 -2
src/xrt/auxiliary/tracking/t_calibration.cpp
··· 1310 1310 ret = t_debug_hsv_viewer_create(xfctx, *out_sink, out_sink); 1311 1311 } 1312 1312 1313 - // Ensure we only get yuv, yuyv or l8 frames. 1314 - u_sink_create_to_yuv_yuyv_or_l8(xfctx, *out_sink, out_sink); 1313 + // Ensure we only get yuv, yuyv, uyvy or l8 frames. 1314 + u_sink_create_to_yuv_yuyv_uyvy_or_l8(xfctx, *out_sink, out_sink); 1315 1315 1316 1316 1317 1317 // Build the board model.
+3 -3
src/xrt/auxiliary/util/u_sink.h
··· 35 35 struct xrt_frame_sink **out_xfs); 36 36 37 37 void 38 - u_sink_create_to_yuv_yuyv_or_l8(struct xrt_frame_context *xfctx, 39 - struct xrt_frame_sink *downstream, 40 - struct xrt_frame_sink **out_xfs); 38 + u_sink_create_to_yuv_yuyv_uyvy_or_l8(struct xrt_frame_context *xfctx, 39 + struct xrt_frame_sink *downstream, 40 + struct xrt_frame_sink **out_xfs); 41 41 42 42 void 43 43 u_sink_create_to_yuv_or_yuyv(struct xrt_frame_context *xfctx,
+65 -7
src/xrt/auxiliary/util/u_sink_converter.c
··· 141 141 } 142 142 143 143 inline static void 144 + UYVY422_to_R8G8B8(const uint8_t *input, uint8_t *dst) 145 + { 146 + uint8_t u = input[0]; 147 + uint8_t y0 = input[1]; 148 + uint8_t v = input[2]; 149 + uint8_t y1 = input[3]; 150 + 151 + #ifdef USE_TABLE 152 + uint8_t *rgb1 = (uint8_t *)&lookup_YUV_to_RGBX[y0][u][v]; 153 + uint8_t *rgb2 = (uint8_t *)&lookup_YUV_to_RGBX[y1][u][v]; 154 + #else 155 + uint32_t rgb1v = YUV444_to_RGBX8888(y0, u, v); 156 + uint32_t rgb2v = YUV444_to_RGBX8888(y1, u, v); 157 + uint8_t *rgb1 = (uint8_t *)&rgb1v; 158 + uint8_t *rgb2 = (uint8_t *)&rgb2v; 159 + #endif 160 + 161 + dst[0] = rgb1[0]; 162 + dst[1] = rgb1[1]; 163 + dst[2] = rgb1[2]; 164 + dst[3] = rgb2[0]; 165 + dst[4] = rgb2[1]; 166 + dst[5] = rgb2[2]; 167 + } 168 + 169 + inline static void 144 170 YUV444_to_R8G8B8(const uint8_t *input, uint8_t *dst) 145 171 { 146 172 uint8_t y = input[0]; ··· 179 205 } 180 206 181 207 static void 208 + from_UYVY422_to_R8G8B8(struct u_sink_converter *s, 209 + uint32_t w, 210 + uint32_t h, 211 + size_t stride, 212 + const uint8_t *data) 213 + { 214 + for (uint32_t y = 0; y < h; y++) { 215 + for (uint32_t x = 0; x < w; x += 2) { 216 + const uint8_t *src = data; 217 + uint8_t *dst = s->frame->data; 218 + 219 + src = src + (y * stride) + (x * 2); 220 + dst = dst + (y * s->frame->stride) + (x * 3); 221 + UYVY422_to_R8G8B8(src, dst); 222 + } 223 + } 224 + } 225 + 226 + 227 + static void 182 228 from_YUV888_to_R8G8B8(struct u_sink_converter *s, 183 229 uint32_t w, 184 230 uint32_t h, ··· 360 406 from_YUYV422_to_R8G8B8(s, xf->width, xf->height, xf->stride, 361 407 xf->data); 362 408 break; 409 + case XRT_FORMAT_UYVY422: 410 + ensure_data(s, XRT_FORMAT_R8G8B8, xf->width, xf->height); 411 + from_UYVY422_to_R8G8B8(s, xf->width, xf->height, xf->stride, 412 + xf->data); 413 + break; 363 414 case XRT_FORMAT_YUV888: 364 415 ensure_data(s, XRT_FORMAT_R8G8B8, xf->width, xf->height); 365 416 from_YUV888_to_R8G8B8(s, xf->width, xf->height, xf->stride, ··· 397 448 from_YUYV422_to_R8G8B8(s, xf->width, xf->height, xf->stride, 398 449 xf->data); 399 450 break; 451 + case XRT_FORMAT_UYVY422: 452 + ensure_data(s, XRT_FORMAT_R8G8B8, xf->width, xf->height); 453 + from_UYVY422_to_R8G8B8(s, xf->width, xf->height, xf->stride, 454 + xf->data); 455 + break; 400 456 case XRT_FORMAT_YUV888: 401 457 ensure_data(s, XRT_FORMAT_R8G8B8, xf->width, xf->height); 402 458 from_YUV888_to_R8G8B8(s, xf->width, xf->height, xf->stride, ··· 420 476 } 421 477 422 478 static void 423 - receive_frame_yuv_yuyv_or_l8(struct xrt_frame_sink *xs, struct xrt_frame *xf) 479 + receive_frame_yuv_yuyv_uyvy_or_l8(struct xrt_frame_sink *xs, 480 + struct xrt_frame *xf) 424 481 { 425 482 struct u_sink_converter *s = (struct u_sink_converter *)xs; 426 483 ··· 428 485 switch (xf->format) { 429 486 case XRT_FORMAT_L8: 430 487 case XRT_FORMAT_YUYV422: 488 + case XRT_FORMAT_UYVY422: 431 489 case XRT_FORMAT_YUV888: 432 490 s->downstream->push_frame(s->downstream, xf); 433 491 return; ··· 441 499 #endif 442 500 default: 443 501 fprintf(stderr, 444 - "error: Can not convert from '%s' to either YUV, YUYV " 445 - "or L8!\n", 502 + "error: Can not convert from '%s' to either YUV, YUYV, " 503 + "UYVY or L8!\n", 446 504 u_format_str(xf->format)); 447 505 return; 448 506 } ··· 548 606 } 549 607 550 608 void 551 - u_sink_create_to_yuv_yuyv_or_l8(struct xrt_frame_context *xfctx, 552 - struct xrt_frame_sink *downstream, 553 - struct xrt_frame_sink **out_xfs) 609 + u_sink_create_to_yuv_yuyv_uyvy_or_l8(struct xrt_frame_context *xfctx, 610 + struct xrt_frame_sink *downstream, 611 + struct xrt_frame_sink **out_xfs) 554 612 { 555 613 struct u_sink_converter *s = U_TYPED_CALLOC(struct u_sink_converter); 556 - s->base.push_frame = receive_frame_yuv_yuyv_or_l8; 614 + s->base.push_frame = receive_frame_yuv_yuyv_uyvy_or_l8; 557 615 s->node.break_apart = break_apart; 558 616 s->node.destroy = destroy; 559 617 s->downstream = downstream;