|
| 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 | +} |
0 commit comments