File indexing completed on 2025-01-19 03:57:06

0001 /*********************************************************
0002  * Copyright (C) 2020, Val Doroshchuk <valbok@gmail.com> *
0003  *                                                       *
0004  * This file is part of QtAVPlayer.                      *
0005  * Free Qt Media Player based on FFmpeg.                 *
0006  *********************************************************/
0007 
0008 #ifndef QAVFVIDEORAME_H
0009 #define QAVFVIDEORAME_H
0010 
0011 #include <QtAVPlayer/qavframe.h>
0012 #include <QVariant>
0013 #ifdef QT_AVPLAYER_MULTIMEDIA
0014 #include <QVideoFrame>
0015 #endif
0016 
0017 extern "C" {
0018 #include <libavutil/frame.h>
0019 }
0020 
0021 QT_BEGIN_NAMESPACE
0022 
0023 class QAVVideoFramePrivate;
0024 class QAVCodec;
0025 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0026 class QRhi;
0027 #endif
0028 class QAVVideoFrame : public QAVFrame
0029 {
0030 public:
0031     enum HandleType
0032     {
0033         NoHandle,
0034         GLTextureHandle,
0035         MTLTextureHandle,
0036         D3D11Texture2DHandle
0037     };
0038 
0039     QAVVideoFrame();
0040     QAVVideoFrame(const QAVFrame &other);
0041     QAVVideoFrame(const QAVVideoFrame &other);
0042     QAVVideoFrame(const QSize &size, AVPixelFormat fmt);
0043 
0044     QAVVideoFrame &operator=(const QAVFrame &other);
0045     QAVVideoFrame &operator=(const QAVVideoFrame &other);
0046 
0047     QSize size() const;
0048 
0049     struct MapData
0050     {
0051         int size = 0;
0052         int bytesPerLine[4] = {0};
0053         uchar *data[4] = {nullptr};
0054         AVPixelFormat format = AV_PIX_FMT_NONE;
0055     };
0056 
0057     MapData map() const;
0058     HandleType handleType() const;
0059 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
0060     QVariant handle(QRhi *rhi = nullptr) const;
0061 #else
0062     QVariant handle() const;
0063 #endif
0064     AVPixelFormat format() const;
0065     QString formatName() const;
0066     QAVVideoFrame convertTo(AVPixelFormat fmt) const;
0067 #ifdef QT_AVPLAYER_MULTIMEDIA
0068     operator QVideoFrame() const;
0069 #endif
0070 
0071 protected:
0072     Q_DECLARE_PRIVATE(QAVVideoFrame)
0073 };
0074 
0075 Q_DECLARE_METATYPE(QAVVideoFrame)
0076 Q_DECLARE_METATYPE(AVPixelFormat)
0077 
0078 QT_END_NAMESPACE
0079 
0080 #endif