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 3 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-y16y16.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_y16y16>(); }
);

pid_hex_str = hexify(_pid);

if ((_pid == RS416_PID || _pid == RS416_RGB_PID) && _fw_version >= firmware_version("5.12.0.1"))
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-y16y16.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-y16y16.h"
"${CMAKE_CURRENT_LIST_DIR}/identity-processing-block.h"
"${CMAKE_CURRENT_LIST_DIR}/threshold.h"
"${CMAKE_CURRENT_LIST_DIR}/rates-printer.h"
Expand Down
39 changes: 39 additions & 0 deletions src/proc/y16i-to-y16y16.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.

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

namespace librealsense
{
struct y16i_pixel { uint8_t rl : 8, rh : 4, ll : 8, lh : 4; int l() const { return lh << 8 | ll; } int r() const { return rh << 8 | rl; } };
void unpack_y16_y16_from_y16i(byte* const dest[], const byte* source, int width, int height, int actual_size)
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
{
auto count = width * height;
// CUDA TODO
//#ifdef RS2_USE_CUDA
// rscuda::split_frame_y16_y16_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 static_cast<uint16_t>(p.l()); },
[](const y16i_pixel& p) -> uint16_t { return static_cast<uint16_t>(p.r()); });
//#endif
}

y16i_to_y16y16::y16i_to_y16y16(int left_idx, int right_idx)
: y16i_to_y16y16("Y16I to Y16L Y16R Transform", left_idx, right_idx) {}

y16i_to_y16y16::y16i_to_y16y16(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_y16y16::process_function(byte* const dest[], const byte* source, int width, int height, int actual_size, int input_size)
{
unpack_y16_y16_from_y16i(dest, source, width, height, actual_size);
}
}
22 changes: 22 additions & 0 deletions src/proc/y16i-to-y16y16.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_y16y16 : public interleaved_functional_processing_block
{
public:
y16i_to_y16y16(int left_idx = 1, int right_idx = 2);

protected:
y16i_to_y16y16(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 @@ -32,6 +32,7 @@ public enum StreamFormat {
Z16H(28),
FG(29),
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>12-bit per pixel interleaved. 12-bit left, 12-bit right. Each pixel is stored in a 24-bit word in little-endian order.</summary>
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
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