QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgcFrameMap.cc File Reference
#include "GstQgcFrameMap.h"
#include <algorithm>
#include <atomic>
#include <cmath>
#include <gst/gst.h>
#include <gst/video/gstvideoaffinetransformationmeta.h>
#include <gst/video/gstvideometa.h>
#include <gst/video/video-hdr.h>
#include <utility>
#include <QtCore/QtNumeric>
#include <QtMultimedia/QAbstractVideoBuffer>
#include <QtMultimedia/QVideoFrame>
#include "GstQgcVideoFormats.h"
#include "HwBuffers/common/CpuVideoFramePool.h"
#include "HwBuffers/common/GstHwVideoInfo.h"
#include "QGCLoggingCategory.h"
Include dependency graph for GstQgcFrameMap.cc:

Go to the source code of this file.

Functions

QVideoFrameFormat::ColorSpace toQtColorSpace (GstVideoColorMatrix matrix)
 Sample-to-frame helpers for qgcqvideosink's show_frame; pure functions, streaming-thread safe.
QVideoFrameFormat::ColorTransfer toQtColorTransfer (GstVideoTransferFunction transfer)
QVideoFrameFormat::PixelFormat toQtPixelFormat (GstVideoFormat fmt)
QVideoFrameFormat::ColorRange toQtColorRange (GstVideoColorRange range)
void applyOrientationToFrame (QVideoFrame &frame, GstVideoOrientationMethod method)
 Apply rotation + mirror flags derived from GstVideoOrientationMethod.
void applyOrientationAndTiming (QVideoFrame &frame, GstBuffer *buffer, int streamOrientation)
 The stream's orientation + PTS/duration timing; streamOrientation is GstVideoOrientationMethod cast to int.
void applyColorimetry (QVideoFrameFormat &format, const GstVideoInfo &info, GstCaps *caps)
FrameGeometry frameGeometry (GstBuffer *buffer, const GstVideoInfo &capsInfo)
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 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)

Function Documentation

◆ applyColorimetry()

void applyColorimetry ( QVideoFrameFormat & format,
const GstVideoInfo & info,
GstCaps * caps )

Set color-space/transfer/range from gst-video colorimetry + HDR (MaxCLL preferred); infers BT.601/709 from height when caps omit it.

Definition at line 147 of file GstQgcFrameMap.cc.

References toQtColorRange(), toQtColorSpace(), and toQtColorTransfer().

Referenced by gst_qgc_q_video_sink_set_caps().

◆ applyFlips()

void applyFlips ( QVideoFrame & frame,
const FrameGeometry & geometry )

Flips frame's picture as geometry tells, ahead of the rotation and mirroring the frame already has.

Definition at line 259 of file GstQgcFrameMap.cc.

References FrameGeometry::flipHorizontally, and FrameGeometry::flipVertically.

Referenced by gst_qgc_q_video_sink_show_frame().

◆ applyOrientationAndTiming()

void applyOrientationAndTiming ( QVideoFrame & frame,
GstBuffer * buffer,
int streamOrientation )

The stream's orientation + PTS/duration timing; streamOrientation is GstVideoOrientationMethod cast to int.

Definition at line 133 of file GstQgcFrameMap.cc.

References applyOrientationToFrame().

Referenced by gst_qgc_q_video_sink_show_frame().

◆ applyOrientationToFrame()

void applyOrientationToFrame ( QVideoFrame & frame,
GstVideoOrientationMethod method )

Apply rotation + mirror flags derived from GstVideoOrientationMethod.

Definition at line 102 of file GstQgcFrameMap.cc.

Referenced by applyOrientationAndTiming().

◆ frameGeometry()

FrameGeometry frameGeometry ( GstBuffer * buffer,
const GstVideoInfo & capsInfo )

buffer's geometry under caps of capsInfo; the caps' own without any of those metas. An affine meta that also turns, shears or projects is left out.

Definition at line 233 of file GstQgcFrameMap.cc.

References FrameGeometry::frameSize, FrameGeometry::picture, and FrameGeometry::pictureSize.

Referenced by gst_qgc_q_video_sink_show_frame().

◆ mapSampleToFrame()

MappedFrame mapSampleToFrame ( GstBuffer * buffer,
GstCaps * caps,
const GstVideoInfo & info,
const QVideoFrameFormat & format,
const HwVideoBufferContext & hwContext,
const CpuVideoFramePool::PinnedFrameCounter & pinnedCpuFrames,
HwResolvedPathCache * pathCache )

◆ toQtColorRange()

QVideoFrameFormat::ColorRange toQtColorRange ( GstVideoColorRange range)

Definition at line 90 of file GstQgcFrameMap.cc.

Referenced by applyColorimetry().

◆ toQtColorSpace()

QVideoFrameFormat::ColorSpace toQtColorSpace ( GstVideoColorMatrix matrix)

Sample-to-frame helpers for qgcqvideosink's show_frame; pure functions, streaming-thread safe.

Definition at line 27 of file GstQgcFrameMap.cc.

References toQtColorSpace().

Referenced by applyColorimetry(), and toQtColorSpace().

◆ toQtColorTransfer()

QVideoFrameFormat::ColorTransfer toQtColorTransfer ( GstVideoTransferFunction transfer)

Definition at line 46 of file GstQgcFrameMap.cc.

Referenced by applyColorimetry().

◆ toQtPixelFormat()

QVideoFrameFormat::PixelFormat toQtPixelFormat ( GstVideoFormat fmt)

Definition at line 80 of file GstQgcFrameMap.cc.

References GstQgc::kVideoFormatTable.

Referenced by gst_qgc_q_video_sink_set_caps().

◆ withFrameGeometry()

QVideoFrameFormat withFrameGeometry ( QVideoFrameFormat format,
const FrameGeometry & geometry )

format for frames of geometry: its frame size, with the picture as the viewport.

Definition at line 280 of file GstQgcFrameMap.cc.

References FrameGeometry::frameSize, and FrameGeometry::picture.

Referenced by gst_qgc_q_video_sink_show_frame().