Skip to content

Commit 8366f5f

Browse files
committed
wa added in frame size assertion, and proc block added for Y16 via mipi
1 parent 54153a7 commit 8366f5f

File tree

6 files changed

+86
-14
lines changed

6 files changed

+86
-14
lines changed

src/ds5/ds5-device.cpp

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "proc/temporal-filter.h"
3030
#include "proc/y8i-to-y8y8.h"
3131
#include "proc/y12i-to-y16y16.h"
32+
#include "proc/y12i-to-y16y16-mipi.h"
3233
#include "proc/color-formats-converter.h"
3334
#include "proc/syncer-processing-block.h"
3435
#include "proc/hole-filling-filter.h"
@@ -858,11 +859,23 @@ namespace librealsense
858859
[]() { return std::make_shared<y8i_to_y8y8>(); }
859860
); // L+R
860861

861-
depth_sensor.register_processing_block(
862-
{ RS2_FORMAT_Y12I },
863-
{ {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 1}, {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 2} },
864-
[]() {return std::make_shared<y12i_to_y16y16>(); }
865-
);
862+
if (!mipi_sensor)
863+
{
864+
depth_sensor.register_processing_block(
865+
{ RS2_FORMAT_Y12I },
866+
{ {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 1}, {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 2} },
867+
[]() {return std::make_shared<y12i_to_y16y16>(); }
868+
);
869+
}
870+
else
871+
{
872+
depth_sensor.register_processing_block(
873+
{ RS2_FORMAT_Y12I },
874+
{ {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 1}, {RS2_FORMAT_Y16, RS2_STREAM_INFRARED, 2} },
875+
[]() {return std::make_shared<y12i_to_y16y16_mipi>(); }
876+
);
877+
}
878+
866879
pid_hex_str = hexify(_pid);
867880

868881
if ((_pid == RS416_PID || _pid == RS416_RGB_PID) && _fw_version >= firmware_version("5.12.0.1"))

src/proc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ target_sources(${LRS_TARGET}
2626
"${CMAKE_CURRENT_LIST_DIR}/disparity-transform.cpp"
2727
"${CMAKE_CURRENT_LIST_DIR}/y8i-to-y8y8.cpp"
2828
"${CMAKE_CURRENT_LIST_DIR}/y12i-to-y16y16.cpp"
29+
"${CMAKE_CURRENT_LIST_DIR}/y12i-to-y16y16-mipi.cpp"
2930
"${CMAKE_CURRENT_LIST_DIR}/identity-processing-block.cpp"
3031
"${CMAKE_CURRENT_LIST_DIR}/threshold.cpp"
3132
"${CMAKE_CURRENT_LIST_DIR}/rates-printer.cpp"
@@ -55,6 +56,7 @@ target_sources(${LRS_TARGET}
5556
"${CMAKE_CURRENT_LIST_DIR}/disparity-transform.h"
5657
"${CMAKE_CURRENT_LIST_DIR}/y8i-to-y8y8.h"
5758
"${CMAKE_CURRENT_LIST_DIR}/y12i-to-y16y16.h"
59+
"${CMAKE_CURRENT_LIST_DIR}/y12i-to-y16y16-mipi.h"
5860
"${CMAKE_CURRENT_LIST_DIR}/identity-processing-block.h"
5961
"${CMAKE_CURRENT_LIST_DIR}/threshold.h"
6062
"${CMAKE_CURRENT_LIST_DIR}/rates-printer.h"

src/proc/y12i-to-y16y16-mipi.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// License: Apache 2.0. See LICENSE file in root directory.
2+
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.
3+
4+
#include "y12i-to-y16y16-mipi.h"
5+
#include "stream.h"
6+
#ifdef RS2_USE_CUDA
7+
#include "cuda/cuda-conversion.cuh"
8+
#endif
9+
10+
namespace librealsense
11+
{
12+
//D457 dev - padding of 8 bits added after each bits, should be removed after it is corrected in SerDes
13+
struct y12i_pixel_mipi { uint8_t rl : 8, rh : 4, ll : 4, lh : 8, padding : 8; int l() const { return lh << 4 | ll; } int r() const { return rh << 8 | rl; } };
14+
15+
void unpack_y16_y16_from_y12i_10_mipi(byte * const dest[], const byte * source, int width, int height, int actual_size)
16+
{
17+
auto count = width * height;
18+
#ifdef RS2_USE_CUDA
19+
rscuda::split_frame_y16_y16_from_y12i_cuda(dest, count, reinterpret_cast<const y12i_pixel *>(source));
20+
#else
21+
split_frame(dest, count, reinterpret_cast<const y12i_pixel_mipi*>(source),
22+
[](const y12i_pixel_mipi& p) -> uint16_t { return p.l() << 6 | p.l() >> 4; }, // We want to convert 10-bit data to 16-bit data
23+
[](const y12i_pixel_mipi& p) -> uint16_t { return p.r() << 6 | p.r() >> 4; }); // Multiply by 64 1/16 to efficiently approximate 65535/1023
24+
#endif
25+
}
26+
27+
y12i_to_y16y16_mipi::y12i_to_y16y16_mipi(int left_idx, int right_idx)
28+
: y12i_to_y16y16_mipi("Y12I to Y16L Y16R Transform", left_idx, right_idx) {}
29+
30+
y12i_to_y16y16_mipi::y12i_to_y16y16_mipi(const char * name, int left_idx, int right_idx)
31+
: interleaved_functional_processing_block(name, RS2_FORMAT_Y12I, RS2_FORMAT_Y16, RS2_STREAM_INFRARED, RS2_EXTENSION_VIDEO_FRAME, 1,
32+
RS2_FORMAT_Y16, RS2_STREAM_INFRARED, RS2_EXTENSION_VIDEO_FRAME, 2)
33+
{}
34+
35+
void y12i_to_y16y16_mipi::process_function(byte * const dest[], const byte * source, int width, int height, int actual_size, int input_size)
36+
{
37+
unpack_y16_y16_from_y12i_10_mipi(dest, source, width, height, actual_size);
38+
}
39+
}

src/proc/y12i-to-y16y16-mipi.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// License: Apache 2.0. See LICENSE file in root directory.
2+
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.
3+
4+
#pragma once
5+
6+
#include "synthetic-stream.h"
7+
#include "option.h"
8+
#include "image.h"
9+
10+
namespace librealsense
11+
{
12+
class y12i_to_y16y16_mipi : public interleaved_functional_processing_block
13+
{
14+
public:
15+
y12i_to_y16y16_mipi(int left_idx = 1, int right_idx = 2);
16+
17+
protected:
18+
y12i_to_y16y16_mipi(const char* name, int left_idx, int right_idx);
19+
void process_function(byte * const dest[], const byte * source, int width, int height, int actual_size, int input_size) override;
20+
};
21+
}

src/proc/y12i-to-y16y16.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,10 @@
77
#include "cuda/cuda-conversion.cuh"
88
#endif
99

10-
#define D457
11-
1210
namespace librealsense
1311
{
14-
//D457 dev - padding of 8 bits added after each bits, should be removed after it is corrected in SerDes
15-
#ifndef D457
1612
struct y12i_pixel { uint8_t rl : 8, rh : 4, ll : 4, lh : 8; int l() const { return lh << 4 | ll; } int r() const { return rh << 8 | rl; } };
17-
#else
18-
struct y12i_pixel { uint8_t rl : 8, rh : 4, ll : 4, lh : 8, padding : 8; int l() const { return lh << 4 | ll; } int r() const { return rh << 8 | rl; } };
19-
#endif
13+
2014
void unpack_y16_y16_from_y12i_10(byte * const dest[], const byte * source, int width, int height, int actual_size)
2115
{
2216
auto count = width * height;

src/sensor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,11 @@ void log_callback_end( uint32_t fps,
476476
}
477477
else
478478
{
479-
assert( expected_size == sizeof(byte) * f.frame_size );
480-
memcpy( (void *)fh->get_frame_data(), f.pixels, expected_size );
479+
if (req_profile_base->get_format() == RS2_FORMAT_Y12I)
480+
expected_size *= (expected_size * 3 / 4 == sizeof(byte) * f.frame_size) ? 3 / 4 : 1;
481+
482+
assert(expected_size == sizeof(byte) * f.frame_size);
483+
memcpy((void*)fh->get_frame_data(), f.pixels, expected_size);
481484
}
482485

483486
auto&& video = dynamic_cast<video_frame*>(fh.frame);

0 commit comments

Comments
 (0)