Miam-Player  0.8.0
A nice music player
VideoFormat.h
Go to the documentation of this file.
1 /******************************************************************************
2  QtAV: Multimedia framework based on Qt and FFmpeg
3  Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
4 
5 * This file is part of QtAV
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 ******************************************************************************/
21 
22 #ifndef QTAV_VIDEOFORMAT_H
23 #define QTAV_VIDEOFORMAT_H
24 
25 #include <QtCore/QSharedDataPointer>
26 #include <QtCore/QString>
27 #include <QtGui/QImage>
28 #include <QtAV/QtAV_Global.h>
29 
30 QT_BEGIN_NAMESPACE
31 class QDebug;
32 QT_END_NAMESPACE
33 namespace QtAV {
34 class VideoFormatPrivate;
40 {
41 public:
51  enum PixelFormat {
52  Format_Invalid = -1,
53  Format_ARGB32, // AARRGGBB or 00RRGGBB, check hasAlpha is required
54  Format_BGRA32, //BBGGRRAA
55  Format_ABGR32, // QImage.RGBA8888 le
56  Format_RGBA32, // QImage. no
57  Format_RGB32, // 0xAARRGGBB native endian. same as QImage::Format_ARGB32. be: ARGB32, le: BGRA32
58  Format_BGR32, // 0xAABBGGRR native endian
65 
66  //http://www.fourcc.org/yuv.php
74  Format_UYVY, //422
75  Format_VYUY, //not in ffmpeg. OMX_COLOR_FormatCrYCbY
76  Format_YUYV, //422, aka yuy2
77  Format_YVYU, //422
82  Format_IMC3, //same as IMC1, swap U V
83  Format_IMC4, //same as IMC2, swap U V
84  Format_Y8, //GREY. single 8 bit Y plane
85  Format_Y16, //single 16 bit Y plane. LE
86 
87  Format_Jpeg, //yuvj
88 
89  //Format_CameraRaw,
90  //Format_AdobeDng,
91 
122 
123  Format_RGB48, // native endian
129  Format_RGBA64, //native endian
132  Format_BGRA64, //native endian
135 
136  Format_VYU, // for rgb422_apple texture, the layout is like rgb24: (v, y, u, )
137  Format_User
138  };
139 
140  static PixelFormat pixelFormatFromImageFormat(QImage::Format format);
145  static QImage::Format imageFormatFromPixelFormat(PixelFormat format);
146  static PixelFormat pixelFormatFromFFmpeg(int ff); //AVPixelFormat
147  static int pixelFormatToFFmpeg(PixelFormat fmt);
148  static QVector<int> pixelFormatsFFmpeg();
149 
150  VideoFormat(PixelFormat format = Format_Invalid);
151  VideoFormat(int formatFF);
152  VideoFormat(QImage::Format fmt);
153  VideoFormat(const QString& name);
154  VideoFormat(const VideoFormat &other);
155  ~VideoFormat();
156 
157  VideoFormat& operator=(const VideoFormat &other);
158  VideoFormat& operator=(VideoFormat::PixelFormat pixfmt);
159  VideoFormat& operator=(QImage::Format qpixfmt);
160  VideoFormat& operator=(int ffpixfmt);
161  bool operator==(const VideoFormat &other) const;
162  bool operator==(VideoFormat::PixelFormat pixfmt) const;
163  bool operator==(QImage::Format qpixfmt) const;
164  bool operator==(int ffpixfmt) const;
165  bool operator!=(const VideoFormat &other) const;
166  bool operator!=(VideoFormat::PixelFormat pixfmt) const;
167  bool operator!=(QImage::Format qpixfmt) const;
168  bool operator!=(int ffpixfmt) const;
169 
170  bool isValid() const;
171 
172  PixelFormat pixelFormat() const;
173  int pixelFormatFFmpeg() const;
174  QImage::Format imageFormat() const;
175  QString name() const;
180  void setPixelFormat(PixelFormat format);
181  void setPixelFormatFFmpeg(int format);
182 
187  int channels() const;
193  int channels(int plane) const;
198  int planeCount() const;
206  int bitsPerPixel() const;
208  int bitsPerPixel(int plane) const;
210  int bitsPerPixelPadded() const;
211  int bytesPerPixel() const;
212  int bytesPerPixel(int plane) const;
217  int bitsPerComponent() const;
218 
219  // return line size with given width
220  int bytesPerLine(int width, int plane) const;
226  int chromaWidth(int lumaWidth) const;
227  int chromaHeight(int lumaHeight) const;
233  int width(int lumaWidth, int plane) const;
234  int height(int lumaHeight, int plane) const;
239  qreal normalizedWidth(int plane) const;
240  qreal normalizedHeight(int plane) const;
241  //TODO: add planeWidth()/planeHeight()
242  // test AV_PIX_FMT_FLAG_XXX
243  bool isBigEndian() const;
244  bool hasPalette() const;
245  bool isPseudoPaletted() const;
249  bool isBitStream() const;
253  bool isHWAccelerated() const;
263  bool isPlanar() const;
264  bool isRGB() const;
265  bool hasAlpha() const;
266 
267  static bool isPlanar(PixelFormat pixfmt);
268  static bool isRGB(PixelFormat pixfmt);
269  static bool hasAlpha(PixelFormat pixfmt);
270 
271 private:
272  QSharedDataPointer<VideoFormatPrivate> d;
273 };
274 
275 #ifndef QT_NO_DEBUG_STREAM
276 Q_AV_EXPORT QDebug operator<<(QDebug debug, const VideoFormat &fmt);
277 Q_AV_EXPORT QDebug operator<<(QDebug debug, VideoFormat::PixelFormat pixFmt);
278 #endif
279 
280 } //namespace QtAV
281 
282 Q_DECLARE_METATYPE(QtAV::VideoFormat)
283 Q_DECLARE_METATYPE(QtAV::VideoFormat::PixelFormat)
284 
285 #endif // QTAV_VIDEOFORMAT_H
Definition: VideoFormat.h:101
Definition: VideoFormat.h:127
Definition: VideoFormat.h:76
Definition: VideoFormat.h:56
Definition: VideoFormat.h:124
Definition: VideoFormat.h:58
Definition: VideoFormat.h:93
Definition: VideoFormat.h:75
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
The VideoFormat class Describes the layout of video data.
Definition: VideoFormat.h:39
Definition: VideoFormat.h:87
Definition: VideoFormat.h:133
Definition: VideoFormat.h:83
Definition: VideoFormat.h:73
Definition: VideoFormat.h:70
Definition: VideoFormat.h:120
Definition: VideoFormat.h:64
Definition: VideoFormat.h:96
Definition: VideoFormat.h:103
Definition: VideoFormat.h:77
Definition: VideoFormat.h:63
Definition: VideoFormat.h:97
Definition: VideoFormat.h:117
Definition: VideoFormat.h:72
Definition: VideoFormat.h:121
Definition: VideoFormat.h:60
Definition: VideoFormat.h:62
Definition: VideoFormat.h:106
Definition: VideoFormat.h:54
Definition: VideoFormat.h:108
Definition: VideoFormat.h:99
Definition: VideoFormat.h:68
Definition: VideoFormat.h:102
Definition: VideoFormat.h:125
Q_AV_EXPORT QDebug operator<<(QDebug debug, const AudioFormat &fmt)
Definition: VideoFormat.h:129
Definition: VideoFormat.h:67
Definition: VideoFormat.h:111
PixelFormat
The PixelFormat enum 32 bit rgba format enum name indicates it&#39;s channel layout.
Definition: VideoFormat.h:51
Definition: VideoFormat.h:98
Definition: VideoFormat.h:114
Definition: VideoFormat.h:82
Definition: VideoFormat.h:109
Definition: VideoFormat.h:78
Definition: VideoFormat.h:95
Definition: VideoFormat.h:113
Definition: VideoFormat.h:100
Definition: VideoFormat.h:107
bool operator==(const TagButton &t1, const TagButton &t2)
Definition: tagbutton.h:61
Definition: VideoFormat.h:104
Definition: VideoFormat.h:55
Definition: VideoFormat.h:126
Definition: VideoFormat.h:112
Definition: VideoFormat.h:94
Definition: VideoFormat.h:53
Definition: VideoFormat.h:74
Definition: VideoFormat.h:118
Definition: VideoFormat.h:57
Definition: VideoFormat.h:134
Definition: VideoFormat.h:59
Definition: VideoFormat.h:69
Definition: VideoFormat.h:71
Definition: VideoFormat.h:136
Definition: VideoFormat.h:119
Definition: VideoFormat.h:123
Definition: VideoFormat.h:131
Definition: VideoFormat.h:115
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
Definition: VideoFormat.h:105
Definition: VideoFormat.h:92
Definition: VideoFormat.h:128
Definition: VideoFormat.h:79
Definition: VideoFormat.h:116
Definition: VideoFormat.h:132
Definition: VideoFormat.h:61
Definition: VideoFormat.h:80
Definition: VideoFormat.h:85
Definition: VideoFormat.h:84
Definition: VideoFormat.h:130
Definition: VideoFormat.h:110
Definition: VideoFormat.h:81