Miam-Player  0.8.0
A nice music player
VideoFrame.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_VIDEOFRAME_H
23 #define QTAV_VIDEOFRAME_H
24 
25 #include <QtAV/Frame.h>
26 #include <QtAV/VideoFormat.h>
27 #include <QtCore/QSize>
29 namespace QtAV {
30 
31 class VideoFramePrivate;
33 {
34  Q_DECLARE_PRIVATE(VideoFrame)
35 public:
48  static VideoFrame fromGPU(const VideoFormat& fmt, int width, int height, int surface_h, quint8 *src[], int pitch[], bool optimized = true, bool swapUV = false);
49  static void copyPlane(quint8 *dst, size_t dst_stride, const quint8 *src, size_t src_stride, unsigned byteWidth, unsigned height);
50 
51  VideoFrame();
52  //must set planes and linesize manually if data is empty
53  // must set planes and linesize manually
54  VideoFrame(int width, int height, const VideoFormat& format, const QByteArray& data = QByteArray());
55  VideoFrame(const QImage& image);
56  VideoFrame(const VideoFrame &other);
57  ~VideoFrame();
58 
59  VideoFrame &operator =(const VideoFrame &other);
60 
61  int channelCount() const Q_DECL_OVERRIDE;
65  VideoFrame clone() const;
66  VideoFormat format() const;
67  VideoFormat::PixelFormat pixelFormat() const;
68  QImage::Format imageFormat() const;
69  int pixelFormatFFmpeg() const;
70 
71  bool isValid() const;
72  operator bool() const { return isValid();}
73 
74  QSize size() const;
75  //int width(int plane = 0) const?
76  int width() const;
77  int height() const;
78  // plane width without padded bytes.
79  int effectivePlaneWidth(int plane) const;
80  // plane width with padded bytes for alignment.
81  int planeWidth(int plane) const;
82  int planeHeight(int plane) const;
83  // display attributes
84  float displayAspectRatio() const;
85  void setDisplayAspectRatio(float displayAspectRatio);
86  // TODO: pixel aspect ratio
87  ColorSpace colorSpace() const;
88  void setColorSpace(ColorSpace value);
89  ColorRange colorRange() const;
90  void setColorRange(ColorRange value);
95  int effectiveBytesPerLine(int plane) const;
103  QImage toImage(QImage::Format fmt = QImage::Format_ARGB32, const QSize& dstSize = QSize(), const QRectF& roi = QRect()) const;
111  VideoFrame to(VideoFormat::PixelFormat pixfmt, const QSize& dstSize = QSize(), const QRectF& roi = QRect()) const;
112  VideoFrame to(const VideoFormat& fmt, const QSize& dstSize = QSize(), const QRectF& roi = QRect()) const;
113  bool to(VideoFormat::PixelFormat pixfmt, quint8 *const dst[], const int dstStride[], const QSize& dstSize = QSize(), const QRectF& roi = QRect()) const;
114  bool to(const VideoFormat& fmt, quint8 *const dst[], const int dstStride[], const QSize& dstSize = QSize(), const QRectF& roi = QRect()) const;
120  void* map(SurfaceType type, void* handle, int plane = 0);
121  void* map(SurfaceType type, void* handle, const VideoFormat& fmt, int plane = 0);
122  void unmap(void* handle);
128  void* createInteropHandle(void* handle, SurfaceType type, int plane);
129 };
130 
131 class ImageConverter;
133 {
134 public:
138  void setEq(int brightness, int contrast, int saturation);
143  VideoFrame convert(const VideoFrame& frame, const VideoFormat& fmt) const;
144  VideoFrame convert(const VideoFrame& frame, VideoFormat::PixelFormat fmt) const;
145  VideoFrame convert(const VideoFrame& frame, QImage::Format fmt) const;
146  VideoFrame convert(const VideoFrame& frame, int fffmt) const;
147 private:
148  mutable ImageConverter *m_cvt;
149  int m_eq[3];
150 };
151 } //namespace QtAV
152 
153 Q_DECLARE_METATYPE(QtAV::VideoFrame)
154 #endif // QTAV_VIDEOFRAME_H
Definition: Frame.h:33
#define Q_AV_EXPORT
Definition: QtAV_Global.h:40
The VideoFormat class Describes the layout of video data.
Definition: VideoFormat.h:39
size_t size
Definition: mem.h:207
Definition: VideoFrame.h:132
ColorSpace
Definition: QtAV_Global.h:122
PixelFormat
The PixelFormat enum 32 bit rgba format enum name indicates it&#39;s channel layout.
Definition: VideoFormat.h:51
Definition: VideoFrame.h:32
SurfaceType
The SurfaceType enum HostMemorySurface: Map the decoded frame to host memory GLTextureSurface: Map th...
Definition: QtAV_Global.h:152
ColorRange
The ColorRange enum YUV or RGB color range.
Definition: QtAV_Global.h:134
AudioOutput ao; ao.setAudioFormat(fmt); ao.open(); while (has_data) { data = read_data(ao->bufferSize...
Definition: AudioDecoder.h:31
#define Q_DECL_OVERRIDE
Definition: QtAV_Global.h:177