1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2015 The Qt Company Ltd. 4 ** Contact: http://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtMultimedia module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see http://www.qt.io/terms-conditions. For further 15 ** information use the contact form at http://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 2.1 or version 3 as published by the Free 20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and 21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the 22 ** following information to ensure the GNU Lesser General Public License 23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and 24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 25 ** 26 ** As a special exception, The Qt Company gives you certain additional 27 ** rights. These rights are described in The Qt Company LGPL Exception 28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 29 ** 30 ** GNU General Public License Usage 31 ** Alternatively, this file may be used under the terms of the GNU 32 ** General Public License version 3.0 as published by the Free Software 33 ** Foundation and appearing in the file LICENSE.GPL included in the 34 ** packaging of this file. Please review the following information to 35 ** ensure the GNU General Public License version 3.0 requirements will be 36 ** met: http://www.gnu.org/copyleft/gpl.html. 37 ** 38 ** $QT_END_LICENSE$ 39 ** 40 ****************************************************************************/ 41 42 #ifndef QVIDEOFRAME_H 43 #define QVIDEOFRAME_H 44 45 #include <QtCore/qmetatype.h> 46 #include <QtCore/qshareddata.h> 47 #include <QtGui/qimage.h> 48 #include <QtMultimedia/qabstractvideobuffer.h> 49 50 QT_BEGIN_HEADER 51 52 QT_BEGIN_NAMESPACE 53 54 QT_MODULE(Multimedia) 55 56 class QSize; 57 class QVariant; 58 59 class QVideoFramePrivate; 60 61 class Q_MULTIMEDIA_EXPORT QVideoFrame 62 { 63 public: 64 enum FieldType 65 { 66 ProgressiveFrame, 67 TopField, 68 BottomField, 69 InterlacedFrame 70 }; 71 72 enum PixelFormat 73 { 74 Format_Invalid, 75 Format_ARGB32, 76 Format_ARGB32_Premultiplied, 77 Format_RGB32, 78 Format_RGB24, 79 Format_RGB565, 80 Format_RGB555, 81 Format_ARGB8565_Premultiplied, 82 Format_BGRA32, 83 Format_BGRA32_Premultiplied, 84 Format_BGR32, 85 Format_BGR24, 86 Format_BGR565, 87 Format_BGR555, 88 Format_BGRA5658_Premultiplied, 89 90 Format_AYUV444, 91 Format_AYUV444_Premultiplied, 92 Format_YUV444, 93 Format_YUV420P, 94 Format_YV12, 95 Format_UYVY, 96 Format_YUYV, 97 Format_NV12, 98 Format_NV21, 99 Format_IMC1, 100 Format_IMC2, 101 Format_IMC3, 102 Format_IMC4, 103 Format_Y8, 104 Format_Y16, 105 106 Format_User = 1000 107 }; 108 109 QVideoFrame(); 110 QVideoFrame(QAbstractVideoBuffer *buffer, const QSize &size, PixelFormat format); 111 QVideoFrame(int bytes, const QSize &size, int bytesPerLine, PixelFormat format); 112 QVideoFrame(const QImage &image); 113 QVideoFrame(const QVideoFrame &other); 114 ~QVideoFrame(); 115 116 QVideoFrame &operator =(const QVideoFrame &other); 117 118 bool isValid() const; 119 120 PixelFormat pixelFormat() const; 121 122 QAbstractVideoBuffer::HandleType handleType() const; 123 124 QSize size() const; 125 int width() const; 126 int height() const; 127 128 FieldType fieldType() const; 129 void setFieldType(FieldType); 130 131 bool isMapped() const; 132 bool isReadable() const; 133 bool isWritable() const; 134 135 QAbstractVideoBuffer::MapMode mapMode() const; 136 137 bool map(QAbstractVideoBuffer::MapMode mode); 138 void unmap(); 139 140 int bytesPerLine() const; 141 142 uchar *bits(); 143 const uchar *bits() const; 144 int mappedBytes() const; 145 146 QVariant handle() const; 147 148 qint64 startTime() const; 149 void setStartTime(qint64 time); 150 151 qint64 endTime() const; 152 void setEndTime(qint64 time); 153 154 static PixelFormat pixelFormatFromImageFormat(QImage::Format format); 155 static QImage::Format imageFormatFromPixelFormat(PixelFormat format); 156 157 private: 158 QExplicitlySharedDataPointer<QVideoFramePrivate> d; 159 }; 160 161 QT_END_NAMESPACE 162 163 Q_DECLARE_METATYPE(QVideoFrame::FieldType) 164 Q_DECLARE_METATYPE(QVideoFrame::PixelFormat) 165 166 QT_END_HEADER 167 168 #endif 169 170