Skip to content

Commit 1d1c294

Browse files
mark YUV encodings as deprecated (#247)
* mark encodings YUV422 and YUV422_YUY2 as deprecated * replace deprecated encodings in encoding test * ignore deprecation warning inside the encoding header Signed-off-by: Christian Rauch <[email protected]>
1 parent 0163014 commit 1d1c294

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

sensor_msgs/include/sensor_msgs/image_encodings.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ const char BAYER_GRBG16[] = "bayer_grbg16";
9797
// https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-packed-yuv.html#id1
9898
// fourcc: UYVY
9999
const char UYVY[] = "uyvy";
100+
[[deprecated("use sensor_msgs::image_encodings::UYVY")]]
100101
const char YUV422[] = "yuv422"; // deprecated
101102
// fourcc: YUYV
102103
const char YUYV[] = "yuyv";
104+
[[deprecated("use sensor_msgs::image_encodings::YUYV")]]
103105
const char YUV422_YUY2[] = "yuv422_yuy2"; // deprecated
104106

105107
// YUV 4:2:0 encodings with an 8-bit depth
@@ -120,13 +122,16 @@ const std::regex cv_type_regex("(8|16|32|64)(U|S|F)C([0-9]*)");
120122
// Utility functions for inspecting an encoding string
121123
static inline bool isColor(const std::string & encoding)
122124
{
125+
#pragma GCC diagnostic push
126+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
123127
return encoding == RGB8 || encoding == BGR8 ||
124128
encoding == RGBA8 || encoding == BGRA8 ||
125129
encoding == RGB16 || encoding == BGR16 ||
126130
encoding == RGBA16 || encoding == BGRA16 ||
127131
encoding == YUV422 || encoding == YUV422_YUY2 ||
128132
encoding == UYVY || encoding == YUYV ||
129133
encoding == NV21 || encoding == NV24;
134+
#pragma GCC diagnostic pop
130135
}
131136

132137
static inline bool isMono(const std::string & encoding)
@@ -189,6 +194,8 @@ static inline int numChannels(const std::string & encoding)
189194
return (m[3] == "") ? 1 : std::atoi(m[3].str().c_str());
190195
}
191196

197+
#pragma GCC diagnostic push
198+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
192199
if (encoding == YUV422 ||
193200
encoding == YUV422_YUY2 ||
194201
encoding == UYVY ||
@@ -198,6 +205,7 @@ static inline int numChannels(const std::string & encoding)
198205
{
199206
return 2;
200207
}
208+
#pragma GCC diagnostic pop
201209

202210
throw std::runtime_error("Unknown encoding " + encoding);
203211
return -1;
@@ -241,6 +249,8 @@ static inline int bitDepth(const std::string & encoding)
241249
return std::atoi(m[0].str().c_str());
242250
}
243251

252+
#pragma GCC diagnostic push
253+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
244254
if (encoding == YUV422 ||
245255
encoding == YUV422_YUY2 ||
246256
encoding == UYVY ||
@@ -250,6 +260,7 @@ static inline int bitDepth(const std::string & encoding)
250260
{
251261
return 8;
252262
}
263+
#pragma GCC diagnostic pop
253264

254265
throw std::runtime_error("Unknown encoding " + encoding);
255266
return -1;

sensor_msgs/test/test_image_encodings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ TEST(sensor_msgs, NumChannels)
4848
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC"), 1);
4949
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC3"), 3);
5050
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("64FC10"), 10);
51-
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("yuv422"), 2);
52-
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("yuv422_yuy2"), 2);
51+
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("uyvy"), 2);
52+
ASSERT_EQ(sensor_msgs::image_encodings::numChannels("yuyv"), 2);
5353
}
5454

5555
TEST(sensor_msgs, bitDepth)
@@ -68,6 +68,6 @@ TEST(sensor_msgs, bitDepth)
6868
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC"), 64);
6969
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC3"), 64);
7070
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("64FC10"), 64);
71-
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("yuv422"), 8);
72-
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("yuv422_yuy2"), 8);
71+
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("uyvy"), 8);
72+
ASSERT_EQ(sensor_msgs::image_encodings::bitDepth("yuyv"), 8);
7373
}

0 commit comments

Comments
 (0)