Skip to content

Commit

Permalink
move fourcc to rsutils
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Oct 7, 2024
1 parent 9bba62e commit d65c42c
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 111 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ target_sources(${LRS_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/environment.h"
"${CMAKE_CURRENT_LIST_DIR}/firmware-version.h"
"${CMAKE_CURRENT_LIST_DIR}/float3.h"
"${CMAKE_CURRENT_LIST_DIR}/fourcc.h"
"${CMAKE_CURRENT_LIST_DIR}/log.h"
"${CMAKE_CURRENT_LIST_DIR}/error-handling.h"
"${CMAKE_CURRENT_LIST_DIR}/firmware_logger_device.h"
Expand Down
9 changes: 5 additions & 4 deletions src/ds/d400/d400-color.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2016 Intel Corporation. All Rights Reserved.
// Copyright(c) 2016-24 Intel Corporation. All Rights Reserved.

#include <cstddef>
#include "metadata.h"
Expand All @@ -11,23 +11,24 @@
#include "d400-info.h"
#include <src/backend.h>
#include <src/platform/platform-utils.h>
#include <src/fourcc.h>
#include <src/metadata-parser.h>

#include <src/ds/features/auto-exposure-roi-feature.h>

#include <rsutils/string/from.h>
#include <rsutils/type/fourcc.h>
using rs_fourcc = rsutils::type::fourcc;

namespace librealsense
{
std::map<uint32_t, rs2_format> d400_color_fourcc_to_rs2_format = {
std::map<rs_fourcc::value_type, rs2_format> d400_color_fourcc_to_rs2_format = {
{rs_fourcc('Y','U','Y','2'), RS2_FORMAT_YUYV},
{rs_fourcc('Y','U','Y','V'), RS2_FORMAT_YUYV},
{rs_fourcc('U','Y','V','Y'), RS2_FORMAT_UYVY},
{rs_fourcc('M','J','P','G'), RS2_FORMAT_MJPEG},
{rs_fourcc('B','Y','R','2'), RS2_FORMAT_RAW16}
};
std::map<uint32_t, rs2_stream> d400_color_fourcc_to_rs2_stream = {
std::map<rs_fourcc::value_type, rs2_stream> d400_color_fourcc_to_rs2_stream = {
{rs_fourcc('Y','U','Y','2'), RS2_STREAM_COLOR},
{rs_fourcc('Y','U','Y','V'), RS2_STREAM_COLOR},
{rs_fourcc('U','Y','V','Y'), RS2_STREAM_COLOR},
Expand Down
62 changes: 32 additions & 30 deletions src/ds/d400/d400-device.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2016 Intel Corporation. All Rights Reserved.
// Copyright(c) 2016-24 Intel Corporation. All Rights Reserved.

#include <librealsense2/h/rs_internal.h>
#include <src/device.h>
Expand All @@ -19,7 +19,6 @@
#include "d400-color.h"
#include "d400-nonmonochrome.h"
#include <src/platform/platform-utils.h>
#include <src/fourcc.h>

#include <src/ds/features/amplitude-factor-feature.h>
#include <src/ds/features/emitter-frequency-feature.h>
Expand All @@ -37,6 +36,9 @@
#include <common/fw/firmware-version.h>
#include <src/fw-update/fw-update-unsigned.h>

#include <rsutils/type/fourcc.h>
using rsutils::type::fourcc;

#include <rsutils/string/hexdump.h>
#include <regex>
#include <iterator>
Expand All @@ -52,36 +54,36 @@ constexpr bool hw_mon_over_xu = false;

namespace librealsense
{
std::map<uint32_t, rs2_format> d400_depth_fourcc_to_rs2_format = {
{rs_fourcc('Y','U','Y','2'), RS2_FORMAT_YUYV},
{rs_fourcc('Y','U','Y','V'), RS2_FORMAT_YUYV},
{rs_fourcc('U','Y','V','Y'), RS2_FORMAT_UYVY},
{rs_fourcc('G','R','E','Y'), RS2_FORMAT_Y8},
{rs_fourcc('Y','8','I',' '), RS2_FORMAT_Y8I},
{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('Z','1','6',' '), RS2_FORMAT_Z16},
{rs_fourcc('Z','1','6','H'), RS2_FORMAT_Z16H},
{rs_fourcc('R','G','B','2'), RS2_FORMAT_BGR8},
{rs_fourcc('M','J','P','G'), RS2_FORMAT_MJPEG},
{rs_fourcc('B','Y','R','2'), RS2_FORMAT_RAW16}
std::map<fourcc::value_type, rs2_format> d400_depth_fourcc_to_rs2_format = {
{fourcc('Y','U','Y','2'), RS2_FORMAT_YUYV},
{fourcc('Y','U','Y','V'), RS2_FORMAT_YUYV},
{fourcc('U','Y','V','Y'), RS2_FORMAT_UYVY},
{fourcc('G','R','E','Y'), RS2_FORMAT_Y8},
{fourcc('Y','8','I',' '), RS2_FORMAT_Y8I},
{fourcc('W','1','0',' '), RS2_FORMAT_W10},
{fourcc('Y','1','6',' '), RS2_FORMAT_Y16},
{fourcc('Y','1','2','I'), RS2_FORMAT_Y12I},
{fourcc('Z','1','6',' '), RS2_FORMAT_Z16},
{fourcc('Z','1','6','H'), RS2_FORMAT_Z16H},
{fourcc('R','G','B','2'), RS2_FORMAT_BGR8},
{fourcc('M','J','P','G'), RS2_FORMAT_MJPEG},
{fourcc('B','Y','R','2'), RS2_FORMAT_RAW16}

};
std::map<uint32_t, rs2_stream> d400_depth_fourcc_to_rs2_stream = {
{rs_fourcc('Y','U','Y','2'), RS2_STREAM_COLOR},
{rs_fourcc('Y','U','Y','V'), RS2_STREAM_COLOR},
{rs_fourcc('U','Y','V','Y'), RS2_STREAM_INFRARED},
{rs_fourcc('G','R','E','Y'), RS2_STREAM_INFRARED},
{rs_fourcc('Y','8','I',' '), RS2_STREAM_INFRARED},
{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('R','G','B','2'), RS2_STREAM_INFRARED},
{rs_fourcc('Z','1','6',' '), RS2_STREAM_DEPTH},
{rs_fourcc('Z','1','6','H'), RS2_STREAM_DEPTH},
{rs_fourcc('B','Y','R','2'), RS2_STREAM_COLOR},
{rs_fourcc('M','J','P','G'), RS2_STREAM_COLOR}
std::map<fourcc::value_type, rs2_stream> d400_depth_fourcc_to_rs2_stream = {
{fourcc('Y','U','Y','2'), RS2_STREAM_COLOR},
{fourcc('Y','U','Y','V'), RS2_STREAM_COLOR},
{fourcc('U','Y','V','Y'), RS2_STREAM_INFRARED},
{fourcc('G','R','E','Y'), RS2_STREAM_INFRARED},
{fourcc('Y','8','I',' '), RS2_STREAM_INFRARED},
{fourcc('W','1','0',' '), RS2_STREAM_INFRARED},
{fourcc('Y','1','6',' '), RS2_STREAM_INFRARED},
{fourcc('Y','1','2','I'), RS2_STREAM_INFRARED},
{fourcc('R','G','B','2'), RS2_STREAM_INFRARED},
{fourcc('Z','1','6',' '), RS2_STREAM_DEPTH},
{fourcc('Z','1','6','H'), RS2_STREAM_DEPTH},
{fourcc('B','Y','R','2'), RS2_STREAM_COLOR},
{fourcc('M','J','P','G'), RS2_STREAM_COLOR}
};

std::vector<uint8_t> d400_device::send_receive_raw_data(const std::vector<uint8_t>& input)
Expand Down
17 changes: 10 additions & 7 deletions src/ds/d400/d400-motion.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2016 Intel Corporation. All Rights Reserved.
// Copyright(c) 2016-24 Intel Corporation. All Rights Reserved.

#include "d400-motion.h"

Expand All @@ -19,18 +19,21 @@
#include "stream.h"
#include "proc/motion-transform.h"
#include "proc/auto-exposure-processor.h"
#include <src/fourcc.h>
#include <src/metadata-parser.h>
#include <src/hid-sensor.h>
using namespace librealsense;

#include <rsutils/type/fourcc.h>
using rsutils::type::fourcc;


namespace librealsense
{
// D457 development
const std::map<uint32_t, rs2_format> motion_fourcc_to_rs2_format = {
{rs_fourcc('G','R','E','Y'), RS2_FORMAT_MOTION_XYZ32F},
const std::map<fourcc::value_type, rs2_format> motion_fourcc_to_rs2_format = {
{fourcc('G','R','E','Y'), RS2_FORMAT_MOTION_XYZ32F},
};
const std::map<uint32_t, rs2_stream> motion_fourcc_to_rs2_stream = {
{rs_fourcc('G','R','E','Y'), RS2_STREAM_ACCEL},
const std::map<fourcc::value_type, rs2_stream> motion_fourcc_to_rs2_stream = {
{fourcc('G','R','E','Y'), RS2_STREAM_ACCEL},
};

rs2_motion_device_intrinsic d400_motion_base::get_motion_intrinsics(rs2_stream stream) const
Expand Down
34 changes: 18 additions & 16 deletions src/ds/d500/d500-color.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.
// Copyright(c) 2022-4 Intel Corporation. All Rights Reserved.

#include <cstddef>
#include "metadata.h"
Expand All @@ -11,29 +11,31 @@
#include "d500-info.h"
#include "backend.h"
#include "platform/platform-utils.h"
#include <src/fourcc.h>
#include <src/metadata-parser.h>
#include <src/ds/ds-thermal-monitor.h>

#include <src/ds/features/auto-exposure-roi-feature.h>

#include <rsutils/type/fourcc.h>
using rsutils::type::fourcc;

namespace librealsense
{
std::map<uint32_t, rs2_format> d500_color_fourcc_to_rs2_format = {
{rs_fourcc('Y','U','Y','2'), RS2_FORMAT_YUYV},
{rs_fourcc('Y','U','Y','V'), RS2_FORMAT_YUYV},
{rs_fourcc('U','Y','V','Y'), RS2_FORMAT_UYVY},
{rs_fourcc('M','J','P','G'), RS2_FORMAT_MJPEG},
{rs_fourcc('B','Y','R','2'), RS2_FORMAT_RAW16},
{rs_fourcc('M','4','2','0'), RS2_FORMAT_M420}
std::map<fourcc::value_type, rs2_format> d500_color_fourcc_to_rs2_format = {
{fourcc('Y','U','Y','2'), RS2_FORMAT_YUYV},
{fourcc('Y','U','Y','V'), RS2_FORMAT_YUYV},
{fourcc('U','Y','V','Y'), RS2_FORMAT_UYVY},
{fourcc('M','J','P','G'), RS2_FORMAT_MJPEG},
{fourcc('B','Y','R','2'), RS2_FORMAT_RAW16},
{fourcc('M','4','2','0'), RS2_FORMAT_M420}
};
std::map<uint32_t, rs2_stream> d500_color_fourcc_to_rs2_stream = {
{rs_fourcc('Y','U','Y','2'), RS2_STREAM_COLOR},
{rs_fourcc('Y','U','Y','V'), RS2_STREAM_COLOR},
{rs_fourcc('U','Y','V','Y'), RS2_STREAM_COLOR},
{rs_fourcc('B','Y','R','2'), RS2_STREAM_COLOR},
{rs_fourcc('M','J','P','G'), RS2_STREAM_COLOR},
{rs_fourcc('M','4','2','0'), RS2_STREAM_COLOR}
std::map<fourcc::value_type, rs2_stream> d500_color_fourcc_to_rs2_stream = {
{fourcc('Y','U','Y','2'), RS2_STREAM_COLOR},
{fourcc('Y','U','Y','V'), RS2_STREAM_COLOR},
{fourcc('U','Y','V','Y'), RS2_STREAM_COLOR},
{fourcc('B','Y','R','2'), RS2_STREAM_COLOR},
{fourcc('M','J','P','G'), RS2_STREAM_COLOR},
{fourcc('M','4','2','0'), RS2_STREAM_COLOR}
};

d500_color::d500_color( std::shared_ptr< const d500_info > const & dev_info, rs2_format native_format )
Expand Down
5 changes: 3 additions & 2 deletions src/ds/d500/d500-device.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.
// Copyright(c) 2022-4 Intel Corporation. All Rights Reserved.

#include "metadata-parser.h"
#include "metadata.h"
Expand All @@ -24,7 +24,8 @@
#include "proc/y8i-to-y8y8.h"
#include "proc/y16i-to-y10msby10msb.h"

#include <src/fourcc.h>
#include <rsutils/type/fourcc.h>
using rs_fourcc = rsutils::type::fourcc;

#include <rsutils/string/hexdump.h>
#include <rsutils/version.h>
Expand Down
17 changes: 9 additions & 8 deletions src/ds/ds-motion-common.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2022 Intel Corporation. All Rights Reserved.
// Copyright(c) 2022-4 Intel Corporation. All Rights Reserved.

#include "ds-motion-common.h"

Expand All @@ -22,22 +22,23 @@
#include "ds-options.h"
#include "ds-private.h"
#include <src/stream.h>
#include <src/fourcc.h>
#include <src/metadata-parser.h>

#include <rsutils/type/fourcc.h>
using rsutils::type::fourcc;
#include <cstddef>

namespace librealsense
{
using namespace ds;

const std::map<uint32_t, rs2_format> fisheye_fourcc_to_rs2_format = {
{rs_fourcc('R','A','W','8'), RS2_FORMAT_RAW8},
{rs_fourcc('G','R','E','Y'), RS2_FORMAT_RAW8},
const std::map<fourcc::value_type, rs2_format> fisheye_fourcc_to_rs2_format = {
{fourcc('R','A','W','8'), RS2_FORMAT_RAW8},
{fourcc('G','R','E','Y'), RS2_FORMAT_RAW8},
};
const std::map<uint32_t, rs2_stream> fisheye_fourcc_to_rs2_stream = {
{rs_fourcc('R','A','W','8'), RS2_STREAM_FISHEYE},
{rs_fourcc('G','R','E','Y'), RS2_STREAM_FISHEYE},
const std::map<fourcc::value_type, rs2_stream> fisheye_fourcc_to_rs2_stream = {
{fourcc('R','A','W','8'), RS2_STREAM_FISHEYE},
{fourcc('G','R','E','Y'), RS2_STREAM_FISHEYE},
};

void fisheye_auto_exposure_roi_method::set(const region_of_interest& roi)
Expand Down
23 changes: 0 additions & 23 deletions src/fourcc.h

This file was deleted.

14 changes: 8 additions & 6 deletions src/hid-sensor.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.
// Copyright(c) 2023-4 Intel Corporation. All Rights Reserved.

#include "hid-sensor.h"
#include "device.h"
#include "stream.h"
#include "global_timestamp_reader.h"
#include "metadata.h"
#include "platform/stream-profile-impl.h"
#include "fourcc.h"
#include <src/metadata-parser.h>
#include <src/core/time-service.h>

#include <rsutils/type/fourcc.h>
using rsutils::type::fourcc;


namespace librealsense {


static const std::map< rs2_stream, uint32_t > stream_and_fourcc
= { { RS2_STREAM_GYRO, rs_fourcc( 'G', 'Y', 'R', 'O' ) },
{ RS2_STREAM_ACCEL, rs_fourcc( 'A', 'C', 'C', 'L' ) },
{ RS2_STREAM_GPIO, rs_fourcc( 'G', 'P', 'I', 'O' ) } };
static const std::map< rs2_stream, fourcc::value_type > stream_and_fourcc
= { { RS2_STREAM_GYRO, fourcc( 'G', 'Y', 'R', 'O' ) },
{ RS2_STREAM_ACCEL, fourcc( 'A', 'C', 'C', 'L' ) },
{ RS2_STREAM_GPIO, fourcc( 'G', 'P', 'I', 'O' ) } };

/*For gyro sensitivity - FW gets 0 for 61 millidegree/s/LSB resolution
0.1 for 30.5 millidegree/s/LSB
Expand Down
13 changes: 9 additions & 4 deletions src/mf/mf-uvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ The library will be compiled without the metadata support!\n")
#include <src/backend.h> // monotonic_to_realtime
#include <rsutils/string/from.h>
#include <rsutils/type/fourcc.h>
using rsutils::type::fourcc;
#include "Shlwapi.h"
#include <Windows.h>
Expand Down Expand Up @@ -970,10 +972,13 @@ namespace librealsense
throw std::runtime_error("Device must be powered to query supported profiles!");

std::vector<stream_profile> results;
foreach_profile([&results](const mf_profile& mfp, CComPtr<IMFMediaType> media_type, bool& quit)
{
results.push_back(mfp.profile);
});
foreach_profile(
[&results]( const mf_profile & mfp, CComPtr< IMFMediaType > media_type, bool & quit )
{
//LOG_DEBUG( mfp.profile.width << 'x' << mfp.profile.height << ' ' << fourcc( mfp.profile.format )
// << " @ " << mfp.profile.fps << " Hz" );
results.push_back( mfp.profile );
} );

return results;
}
Expand Down
Loading

0 comments on commit d65c42c

Please sign in to comment.