[mmap] partial revert of 8cef8db4 to disable using mmap file reader
[videoplayer.git] / videoData.h
blob071ffb90288c3900b9f8b3645d1959d61a66b964
1 /* ***** BEGIN LICENSE BLOCK *****
3 * The MIT License
5 * Copyright (c) 2008 BBC Research
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
25 * ***** END LICENSE BLOCK ***** */
27 #ifndef VIDEODATA_H_
28 #define VIDEODATA_H_
30 #include <GL/glew.h>
32 class VideoData {
33 public:
35 enum DataFmt {
36 V8P0 = 0,
37 V8P2,
38 V8P4,
39 YV12,
40 V16P0,
41 V16P2,
42 V16P4,
43 UYVY,
44 V216,
45 V210,
46 Unknown}; //how is the data packed?
48 VideoData();
49 void resize(int w, int h, DataFmt f);
50 ~VideoData();
52 void convertV210();
53 void convertPlanar16();
55 unsigned long frameNum;
56 bool isLastFrame; //mark the first and last frames in a sequence
57 bool isFirstFrame;
59 DataFmt diskFormat; //enumerated format read from the disk
60 DataFmt renderFormat; //pixel packing used for openGL rendering
62 bool isPlanar; //flag to indicate that we have a seperate texture for each component to copy to the GPU
64 GLenum glInternalFormat; //format used to describe which components of the texture are applied to the texels
65 GLenum glFormat; //format of the texture data, GL_LUMINANCE or GL_RGBA in these applications
66 GLenum glType; //the data type for the texture, GL_UNSIGNED_BYTE, GL_INT etc...
67 int glMinMaxFilter; //filter type for scaling the pixel data GL_LINEAR for planar, or GL_NEAREST for packed
68 int glYTextureWidth; //the width of the Y texture, which may actually be UYVY data packed as RGBA. There
69 //will be half the number of RGBA quads as Y pixels across the image as each quad
70 //stores two luminance samples
72 int Ywidth; //luminance dimensions in pixels
73 int Yheight;
75 int Cwidth; //chrominance dimensions in pixels
76 int Cheight;
78 int dataSize; //total allocation at *data
79 int YdataSize; //number of bytes for each component
80 int UdataSize;
81 int VdataSize;
83 unsigned char *data; //pointer to allocated block
84 unsigned char *Ydata; //pointer to luminance, or multiplexed YCbCr
85 unsigned char *Udata; //pointers to planar chrominance components, if format is planar
86 unsigned char *Vdata;
88 private:
89 VideoData(const VideoData&);
90 void operator= (const VideoData&);
91 void allocate(int w, int h, DataFmt f);
94 #endif