Phonon

videoframe2.h
1/* This file is part of the KDE project
2 Copyright (C) 2006,2008 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Nokia Corporation
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22
23#ifndef PHONON_EXPERIMENTAL_VIDEOFRAME2_H
24#define PHONON_EXPERIMENTAL_VIDEOFRAME2_H
25
26#include "export.h"
27#include "videodataoutput.h"
28#include <QImage>
29
30namespace Phonon
31{
32namespace Experimental
33{
34 /**
35 * \brief A single video frame.
36 *
37 * This simple class contains the data of a frame and metadata describing
38 * how to interpret the data.
39 *
40 * \author Matthias Kretz <kretz@kde.org>
41 */
43 {
44 /**
45 * Video frames come in a variety of formats. Depending on the format
46 * you have to process it differently to convert it for displaying or
47 * encoding.
48 */
49 enum Format {
50 /**
51 * The frame is invalid.
52 */
54 /**
55 * The frame is stored in data0 using a 24-bit RGB format (8-8-8).
56 */
58 Format_RGB32 = QImage::Format_RGB32,
59 /**
60 * The frame is stored in data0, data1 and data2 using data0 for the
61 * Y data, data1 for the Cb data and data2 for the Cr data.
62 *
63 * data1 and data2 contain one byte per for adjacent pixels whereas data0
64 * has one byte per pixel.
65 */
66 Format_YCbCr420 = 0x10000,
67 Format_YV12 = Format_YCbCr420,
68 /**
69 * The frame is stored in data0 using a 32-bit Y0-Cb-Y1-Cr format (8-8-8-8).
70 */
71 Format_YCbCr422 = 0x10001,
72 Format_YUY2 = Format_YCbCr422
73 };
74
75 /**
76 * The width of the video frame in number of pixels.
77 */
78 int width;
79
80 /**
81 * The height of the video frame in number of pixels.
82 */
83 int height;
84
85 /**
86 * The aspect ratio the frame should be displayed with.
87 *
88 * Common values are 4/3, 16/9.
89 */
91
92 /**
93 * Convenience function to calculate the aspect corrected width from the
94 * aspectRatio and height values.
95 *
96 * It is recommended to display video frames with aspectCorrectedWidth x height
97 */
98 inline int aspectCorrectedWidth() const { return qRound(aspectRatio * height); }
99
100 /**
101 * Convenience function to calculate the aspect corrected height from the
102 * aspectRatio and width values.
103 *
104 * It is recommended to display video frames with aspectCorrectedWidth x height
105 */
106 inline int aspectCorrectedHeight() const { return qRound(width / aspectRatio); }
107
108 /**
109 * Format of the frame.
110 *
111 * \see Format
112 */
114
115 /**
116 * RGB8, YUY2 or Y-plane
117 *
118 * If format is Format_RGB888 then the data contains each pixel as three
119 * consecutive bytes for red, green and blue.
120 *
121 * If format is Format_YUY2 the data contains every two pixels as four
122 * consecutive bytes for Y0, Cb, Y1, Cr
123 *
124 * If format is Format_YV12 the data contains one byte per pixel with
125 * the Y value.
126 */
128
129 /**
130 * YV12 U-plane
131 *
132 * If format is Format_YV12 the data contains one byte per four adjacent
133 * pixels with the Cb value.
134 */
136
137 /**
138 * YV12 V-plane
139 *
140 * If format is Format_YV12 the data contains one byte per four adjacent
141 * pixels with the Cr value.
142 */
144
145 inline QImage qImage() const
146 {
147 if (format == Format_RGB888) {
148 return QImage(reinterpret_cast<const uchar *>(data0.constData()),
150 }
151 return QImage();
152 }
153 };
154} // namespace Experimental
155} // namespace Phonon
156
157Q_DECLARE_METATYPE(Phonon::Experimental::VideoFrame2)
158
159// vim: sw=4 ts=4 tw=80
160#endif // PHONON_EXPERIMENTAL_VIDEOFRAME2_H
const char * constData() const const
QByteArray data2
YV12 V-plane.
QByteArray data1
YV12 U-plane.
int width
The width of the video frame in number of pixels.
Definition videoframe2.h:78
int height
The height of the video frame in number of pixels.
Definition videoframe2.h:83
QByteArray data0
RGB8, YUY2 or Y-plane.
int aspectCorrectedHeight() const
Convenience function to calculate the aspect corrected height from the aspectRatio and width values.
double aspectRatio
The aspect ratio the frame should be displayed with.
Definition videoframe2.h:90
Format
Video frames come in a variety of formats.
Definition videoframe2.h:49
@ Format_Invalid
The frame is invalid.
Definition videoframe2.h:53
@ Format_YCbCr420
The frame is stored in data0, data1 and data2 using data0 for the Y data, data1 for the Cb data and d...
Definition videoframe2.h:66
@ Format_YCbCr422
The frame is stored in data0 using a 32-bit Y0-Cb-Y1-Cr format (8-8-8-8).
Definition videoframe2.h:71
@ Format_RGB888
The frame is stored in data0 using a 24-bit RGB format (8-8-8).
Definition videoframe2.h:57
int aspectCorrectedWidth() const
Convenience function to calculate the aspect corrected width from the aspectRatio and height values.
Definition videoframe2.h:98
Format format
Format of the frame.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.