Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding support for y16i - 10 MSB #10737

Merged
merged 6 commits into from
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/librealsense2/h/rs_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ typedef enum rs2_format
RS2_FORMAT_Z16H , /**< Variable-length Huffman-compressed 16-bit depth values. */
RS2_FORMAT_FG , /**< 16-bit per-pixel frame grabber format. */
RS2_FORMAT_Y411 , /**< 12-bit per-pixel. */
RS2_FORMAT_Y16I , /**< 12-bit per pixel interleaved. 12-bit left, 12-bit right. */
RS2_FORMAT_COUNT /**< Number of enumeration values. Not a valid input: intended to be used in for-loops. */
} rs2_format;
const char* rs2_format_to_string(rs2_format format);
Expand Down
9 changes: 9 additions & 0 deletions src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "proc/temporal-filter.h"
#include "proc/y8i-to-y8y8.h"
#include "proc/y12i-to-y16y16.h"
#include "proc/y16i-to-y10msby10msb.h"
#include "proc/color-formats-converter.h"
#include "proc/syncer-processing-block.h"
#include "proc/hole-filling-filter.h"
Expand Down Expand Up @@ -59,6 +60,7 @@ namespace librealsense
{rs_fourcc('W','1','0',' '), RS2_FORMAT_W10},
{rs_fourcc('Y','1','6',' '), RS2_FORMAT_Y16},
{rs_fourcc('Y','1','2','I'), RS2_FORMAT_Y12I},
{rs_fourcc('Y','1','6','I'), RS2_FORMAT_Y16I},
{rs_fourcc('Z','1','6',' '), RS2_FORMAT_Z16},
{rs_fourcc('Z','1','6','H'), RS2_FORMAT_Z16H},
{rs_fourcc('R','G','B','2'), RS2_FORMAT_BGR8},
Expand All @@ -75,6 +77,7 @@ namespace librealsense
{rs_fourcc('W','1','0',' '), RS2_STREAM_INFRARED},
{rs_fourcc('Y','1','6',' '), RS2_STREAM_INFRARED},
{rs_fourcc('Y','1','2','I'), RS2_STREAM_INFRARED},
{rs_fourcc('Y','1','6','I'), RS2_STREAM_INFRARED},
{rs_fourcc('R','G','B','2'), RS2_STREAM_INFRARED},
{rs_fourcc('Z','1','6',' '), RS2_STREAM_DEPTH},
{rs_fourcc('Z','1','6','H'), RS2_STREAM_DEPTH},
Expand Down Expand Up @@ -855,6 +858,12 @@ namespace librealsense
[]() {return std::make_shared<y12i_to_y16y16>(); }
);

depth_sensor.register_processing_block(
{ RS2_FORMAT_Y16I },
{ {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 1}, {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 2} },
[]() {return std::make_shared<y16i_to_y10msby10msb>(); }
);

pid_hex_str = hexify(_pid);

if ((_pid == RS416_PID || _pid == RS416_RGB_PID) && _fw_version >= firmware_version("5.12.0.1"))
Expand Down
1 change: 1 addition & 0 deletions src/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ namespace librealsense
case RS2_FORMAT_Z16H: return 16;
case RS2_FORMAT_FG: return 16;
case RS2_FORMAT_Y411: return 12;
case RS2_FORMAT_Y16I: return 32;
default: assert(false); return 0;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/proc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/disparity-transform.cpp"
"${CMAKE_CURRENT_LIST_DIR}/y8i-to-y8y8.cpp"
"${CMAKE_CURRENT_LIST_DIR}/y12i-to-y16y16.cpp"
"${CMAKE_CURRENT_LIST_DIR}/y16i-to-y10msby10msb.cpp"
"${CMAKE_CURRENT_LIST_DIR}/identity-processing-block.cpp"
"${CMAKE_CURRENT_LIST_DIR}/threshold.cpp"
"${CMAKE_CURRENT_LIST_DIR}/rates-printer.cpp"
Expand Down Expand Up @@ -55,6 +56,7 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/disparity-transform.h"
"${CMAKE_CURRENT_LIST_DIR}/y8i-to-y8y8.h"
"${CMAKE_CURRENT_LIST_DIR}/y12i-to-y16y16.h"
"${CMAKE_CURRENT_LIST_DIR}/y16i-to-y10msby10msb.h"
"${CMAKE_CURRENT_LIST_DIR}/identity-processing-block.h"
"${CMAKE_CURRENT_LIST_DIR}/threshold.h"
"${CMAKE_CURRENT_LIST_DIR}/rates-printer.h"
Expand Down
43 changes: 43 additions & 0 deletions src/proc/y16i-to-y10msby10msb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.

#include "y16i-to-y10msby10msb.h"
#include "stream.h"
// CUDA TODO
//#ifdef RS2_USE_CUDA
//#include "cuda/cuda-conversion.cuh"
//#endif

namespace librealsense
{
struct y16i_pixel { uint16_t left : 16, right : 16;
// left and right data are shifted 6 times so that the MSB 10 bit will hold the data
// data should be in MSB because OpenGL then uses the MSB byte
uint16_t l() const { return left << 6; }
uint16_t r() const { return right << 6; } };
void unpack_y10msb_y10msb_from_y16i(byte* const dest[], const byte* source, int width, int height, int actual_size)
{
auto count = width * height;
// CUDA TODO
//#ifdef RS2_USE_CUDA
// rscuda::split_frame_y10msb_y10msb_from_y16i_cuda(dest, count, reinterpret_cast<const y12i_pixel*>(source));
//#else
split_frame(dest, count, reinterpret_cast<const y16i_pixel*>(source),
[](const y16i_pixel& p) -> uint16_t { return (p.l()); },
[](const y16i_pixel& p) -> uint16_t { return (p.r()); });
//#endif
}

y16i_to_y10msby10msb::y16i_to_y10msby10msb(int left_idx, int right_idx)
: y16i_to_y10msby10msb("Y16I to Y10msbL Y10msbR Transform", left_idx, right_idx) {}

y16i_to_y10msby10msb::y16i_to_y10msby10msb(const char* name, int left_idx, int right_idx)
: interleaved_functional_processing_block(name, RS2_FORMAT_Y16I, RS2_FORMAT_Y16, RS2_STREAM_INFRARED, RS2_EXTENSION_VIDEO_FRAME, 1,
RS2_FORMAT_Y16, RS2_STREAM_INFRARED, RS2_EXTENSION_VIDEO_FRAME, 2)
{}

void y16i_to_y10msby10msb::process_function(byte* const dest[], const byte* source, int width, int height, int actual_size, int input_size)
{
unpack_y10msb_y10msb_from_y16i(dest, source, width, height, actual_size);
}
}
22 changes: 22 additions & 0 deletions src/proc/y16i-to-y10msby10msb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.

#pragma once

#include "synthetic-stream.h"
#include "option.h"
#include "image.h"

namespace librealsense
{
class y16i_to_y10msby10msb : public interleaved_functional_processing_block
{
public:
y16i_to_y10msby10msb(int left_idx = 1, int right_idx = 2);

protected:
y16i_to_y10msby10msb(const char* name, int left_idx, int right_idx);
void process_function(byte* const dest[], const byte* source, int width, int height, int actual_size, int input_size) override;
};
}

1 change: 1 addition & 0 deletions src/to-string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ const char * get_string( rs2_format value )
CASE( Z16H )
CASE( FG )
CASE( Y411 )
CASE( Y16I )
default:
assert( ! is_valid( value ) );
return UNKNOWN_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public enum StreamFormat {
W10(27),
Z16H(28),
FG(29),
Y411(30);
Y411(30),
Y16I(31);
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
private final int mValue;

private StreamFormat(int value) { mValue = value; }
Expand Down
5 changes: 4 additions & 1 deletion wrappers/csharp/Intel.RealSense/Types/Enums/Format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public enum Format
FG = 29,

/// <summary>12-bit per-pixel. 4 pixel data stream taking 6 bytes.</summary>
Y411 = 30
Y411 = 30,

/// <summary>16-bit per pixel interleaved. 16-bit left, 16-bit right. Each pixel is stored in a 32-bit word in little-endian order.</summary>
Y16i = 31
}
}
1 change: 1 addition & 0 deletions wrappers/nodejs/src/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4703,6 +4703,7 @@ void InitModule(v8::Local<v8::Object> exports) {
_FORCE_SET_ENUM(RS2_FORMAT_Z16H);
_FORCE_SET_ENUM(RS2_FORMAT_FG);
_FORCE_SET_ENUM(RS2_FORMAT_Y411);
_FORCE_SET_ENUM(RS2_FORMAT_Y16I);
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
_FORCE_SET_ENUM(RS2_FORMAT_COUNT);

// rs2_frame_metadata_value
Expand Down