Skip to content

Commit 7f75faa

Browse files
authored
Add NV12 to color formats (#253)
Signed-off-by: Lukas Schäper <[email protected]>
1 parent c0c0bc5 commit 7f75faa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sensor_msgs/include/sensor_msgs/image_encodings.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ const char YUYV[] = "yuyv";
103103
const char YUV422_YUY2[] = "yuv422_yuy2"; // deprecated
104104

105105
// YUV 4:2:0 encodings with an 8-bit depth
106-
// NV21: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-yuv-planar.html#nv12-nv21-nv12m-and-nv21m
106+
// NV12 & NV21: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/pixfmt-yuv-planar.html#nv12-nv21-nv12m-and-nv21m
107+
const char NV12[] = "nv12";
107108
const char NV21[] = "nv21";
108109

109110
// YUV 4:4:4 encodings with 8-bit depth
@@ -126,7 +127,8 @@ static inline bool isColor(const std::string & encoding)
126127
encoding == RGBA16 || encoding == BGRA16 ||
127128
encoding == YUV422 || encoding == YUV422_YUY2 ||
128129
encoding == UYVY || encoding == YUYV ||
129-
encoding == NV21 || encoding == NV24;
130+
encoding == NV12 || encoding == NV21 ||
131+
encoding == NV24;
130132
}
131133

132134
static inline bool isMono(const std::string & encoding)
@@ -193,6 +195,7 @@ static inline int numChannels(const std::string & encoding)
193195
encoding == YUV422_YUY2 ||
194196
encoding == UYVY ||
195197
encoding == YUYV ||
198+
encoding == NV12 ||
196199
encoding == NV21 ||
197200
encoding == NV24)
198201
{
@@ -245,6 +248,7 @@ static inline int bitDepth(const std::string & encoding)
245248
encoding == YUV422_YUY2 ||
246249
encoding == UYVY ||
247250
encoding == YUYV ||
251+
encoding == NV12 ||
248252
encoding == NV21 ||
249253
encoding == NV24)
250254
{

0 commit comments

Comments
 (0)