QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgcFrameMap.h
Go to the documentation of this file.
1#pragma once
2
3#include <gst/gst.h>
4#include <gst/video/video-info.h>
5#include <gst/video/video.h>
6
7#include <QtCore/QRect>
8#include <QtCore/QSize>
9#include <QtMultimedia/QVideoFrame>
10#include <QtMultimedia/QVideoFrameFormat>
11
12#include "HwBuffers/HwBuffers.h"
14
16
17QVideoFrameFormat::ColorSpace toQtColorSpace(GstVideoColorMatrix matrix);
18QVideoFrameFormat::ColorTransfer toQtColorTransfer(GstVideoTransferFunction transfer);
19QVideoFrameFormat::PixelFormat toQtPixelFormat(GstVideoFormat fmt);
20QVideoFrameFormat::ColorRange toQtColorRange(GstVideoColorRange range);
21
23void applyOrientationToFrame(QVideoFrame& frame, GstVideoOrientationMethod method);
24
26void applyOrientationAndTiming(QVideoFrame& frame, GstBuffer* buffer, int streamOrientation);
27
30void applyColorimetry(QVideoFrameFormat& format, const GstVideoInfo& info, GstCaps* caps);
31
40{
41 QSize frameSize;
42 QRect picture;
44 bool flipHorizontally = false;
45 bool flipVertically = false;
46
47 friend bool operator==(const FrameGeometry&, const FrameGeometry&) = default;
48};
49
52FrameGeometry frameGeometry(GstBuffer* buffer, const GstVideoInfo& capsInfo);
53
55void applyFlips(QVideoFrame& frame, const FrameGeometry& geometry);
56
58QVideoFrameFormat withFrameGeometry(QVideoFrameFormat format, const FrameGeometry& geometry);
59
64{
65 QVideoFrame frame;
67 bool demoted = false;
68 bool noCpuLayout = false;
69};
70
71MappedFrame mapSampleToFrame(GstBuffer* buffer, GstCaps* caps, const GstVideoInfo& info,
72 const QVideoFrameFormat& format, const HwVideoBufferContext& hwContext,
73 const CpuVideoFramePool::PinnedFrameCounter& pinnedCpuFrames,
74 HwResolvedPathCache* pathCache = nullptr);
HwVideoBufferPath
GPU zero-copy path a frame is imported through; None means the frame takes the CPU path.
Definition GstHwTypes.h:7
QVideoFrameFormat::PixelFormat toQtPixelFormat(GstVideoFormat fmt)
QVideoFrameFormat::ColorTransfer toQtColorTransfer(GstVideoTransferFunction transfer)
void applyColorimetry(QVideoFrameFormat &format, const GstVideoInfo &info, GstCaps *caps)
FrameGeometry frameGeometry(GstBuffer *buffer, const GstVideoInfo &capsInfo)
QVideoFrameFormat withFrameGeometry(QVideoFrameFormat format, const FrameGeometry &geometry)
format for frames of geometry: its frame size, with the picture as the viewport.
MappedFrame mapSampleToFrame(GstBuffer *buffer, GstCaps *caps, const GstVideoInfo &info, const QVideoFrameFormat &format, const HwVideoBufferContext &hwContext, const CpuVideoFramePool::PinnedFrameCounter &pinnedCpuFrames, HwResolvedPathCache *pathCache=nullptr)
void applyFlips(QVideoFrame &frame, const FrameGeometry &geometry)
Flips frame's picture as geometry tells, ahead of the rotation and mirroring the frame already has.
QVideoFrameFormat::ColorSpace toQtColorSpace(GstVideoColorMatrix matrix)
Sample-to-frame helpers for qgcqvideosink's show_frame; pure functions, streaming-thread safe.
void applyOrientationAndTiming(QVideoFrame &frame, GstBuffer *buffer, int streamOrientation)
The stream's orientation + PTS/duration timing; streamOrientation is GstVideoOrientationMethod cast t...
void applyOrientationToFrame(QVideoFrame &frame, GstVideoOrientationMethod method)
Apply rotation + mirror flags derived from GstVideoOrientationMethod.
QVideoFrameFormat::ColorRange toQtColorRange(GstVideoColorRange range)
std::shared_ptr< std::atomic< int > > PinnedFrameCounter
Live zero-copy frames of one sink; shared so frames Qt still holds after the sink is gone can release...
friend bool operator==(const FrameGeometry &, const FrameGeometry &)=default
HwVideoBufferPath gpuPath
None for a CPU frame, and for one that failed to map.
bool demoted
A GPU path was requested for this stream but this frame fell back to CPU.
QVideoFrame frame
bool noCpuLayout
Dropped instead of read as linear rows, which would show it scrambled.