QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgcVideoFormats.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtMultimedia/QVideoFrameFormat>
4#include <gst/video/video-format.h>
5#include <string>
6
7namespace GstQgc {
8
14{
15 GstVideoFormat gst;
16 QVideoFrameFormat::PixelFormat qt;
17 const char* capsToken;
18};
19
20inline constexpr VideoFormatEntry kVideoFormatTable[] = {
21 // Advertised set — order is preserved in the generated caps string (negotiation preference order).
22 {GST_VIDEO_FORMAT_NV12, QVideoFrameFormat::Format_NV12, "NV12"},
23 {GST_VIDEO_FORMAT_NV21, QVideoFrameFormat::Format_NV21, "NV21"},
24 {GST_VIDEO_FORMAT_I420, QVideoFrameFormat::Format_YUV420P, "I420"},
25 {GST_VIDEO_FORMAT_YV12, QVideoFrameFormat::Format_YV12, "YV12"},
26 {GST_VIDEO_FORMAT_Y42B, QVideoFrameFormat::Format_YUV422P, "Y42B"},
27 {GST_VIDEO_FORMAT_P010_10LE, QVideoFrameFormat::Format_P010, "P010_10LE"},
28 {GST_VIDEO_FORMAT_AYUV, QVideoFrameFormat::Format_AYUV, "AYUV"},
29 {GST_VIDEO_FORMAT_YUY2, QVideoFrameFormat::Format_YUYV, "YUY2"},
30 {GST_VIDEO_FORMAT_UYVY, QVideoFrameFormat::Format_UYVY, "UYVY"},
31 {GST_VIDEO_FORMAT_GRAY8, QVideoFrameFormat::Format_Y8, "GRAY8"},
32 {GST_VIDEO_FORMAT_GRAY16_LE, QVideoFrameFormat::Format_Y16, "GRAY16_LE"},
33 {GST_VIDEO_FORMAT_BGRA, QVideoFrameFormat::Format_BGRA8888, "BGRA"},
34 {GST_VIDEO_FORMAT_RGBA, QVideoFrameFormat::Format_RGBA8888, "RGBA"},
35 // Accepted but not advertised: mapped defensively if upstream or a GPU path delivers them anyway.
36 {GST_VIDEO_FORMAT_BGRx, QVideoFrameFormat::Format_BGRX8888, nullptr},
37 {GST_VIDEO_FORMAT_RGBx, QVideoFrameFormat::Format_RGBX8888, nullptr},
38 {GST_VIDEO_FORMAT_ARGB, QVideoFrameFormat::Format_ARGB8888, nullptr},
39 {GST_VIDEO_FORMAT_xRGB, QVideoFrameFormat::Format_XRGB8888, nullptr},
40 {GST_VIDEO_FORMAT_I420_10LE, QVideoFrameFormat::Format_YUV420P10, nullptr},
41 {GST_VIDEO_FORMAT_P016_LE, QVideoFrameFormat::Format_P016, nullptr},
42 // GST_VIDEO_FORMAT_BGR/RGB intentionally absent: Qt6 has no 24-bit packed format, so they resolve to
43 // Format_Invalid (the lookup default) rather than corrupting stride arithmetic.
44};
45
47inline std::string advertisedFormatList()
48{
49 std::string out = "{ ";
50 bool first = true;
51 for (const auto& e : kVideoFormatTable) {
52 if (!e.capsToken) {
53 continue;
54 }
55 if (!first) {
56 out += ", ";
57 }
58 out += e.capsToken;
59 first = false;
60 }
61 out += " }";
62 return out;
63}
64
65} // namespace GstQgc
std::string advertisedFormatList()
"{ NV12, NV21, ... }" — the advertised format list for a caps string. Built once at caps setup.
constexpr VideoFormatEntry kVideoFormatTable[]
const char * capsToken
non-null: advertised in negotiation caps; null: accepted-only (defensive map).
QVideoFrameFormat::PixelFormat qt