5
5
#include " cap_mfx_common.hpp"
6
6
7
7
// Linux specific
8
+ #ifdef __linux__
8
9
#include < unistd.h>
9
10
#include < sys/types.h>
10
11
#include < sys/stat.h>
11
12
#include < fcntl.h>
13
+ #endif
12
14
13
15
using namespace std ;
14
16
using namespace cv ;
@@ -36,6 +38,8 @@ bool DeviceHandler::init(MFXVideoSession &session)
36
38
37
39
// ==================================================================================================
38
40
41
+ #ifdef __linux__
42
+
39
43
VAHandle::VAHandle () {
40
44
// TODO: provide a way of modifying this path
41
45
const string filename = " /dev/dri/card0" ;
@@ -68,6 +72,19 @@ bool VAHandle::initDeviceSession(MFXVideoSession &session) {
68
72
return false ;
69
73
}
70
74
75
+ #endif // __linux__
76
+
77
+ DeviceHandler * createDeviceHandler ()
78
+ {
79
+ #if defined __linux__
80
+ return new VAHandle ();
81
+ #elif defined _WIN32
82
+ return new DXHandle ();
83
+ #else
84
+ return 0 ;
85
+ #endif
86
+ }
87
+
71
88
// ==================================================================================================
72
89
73
90
SurfacePool::SurfacePool (ushort width_, ushort height_, ushort count, const mfxFrameInfo &frameInfo, uchar bpp)
@@ -85,7 +102,8 @@ SurfacePool::SurfacePool(ushort width_, ushort height_, ushort count, const mfxF
85
102
surface.Info = frameInfo;
86
103
surface.Data .Y = dataPtr;
87
104
surface.Data .UV = dataPtr + width * height;
88
- surface.Data .Pitch = width;
105
+ surface.Data .PitchLow = width & 0xFFFF ;
106
+ surface.Data .PitchHigh = (width >> 16 ) & 0xFFFF ;
89
107
DBG (cout << " allocate surface " << (void *)&surface << " , Y = " << (void *)dataPtr << " (" << width << " x" << height << " )" << endl);
90
108
}
91
109
DBG (cout << " Allocated: " << endl
@@ -112,7 +130,7 @@ ReadBitstream::ReadBitstream(const char *filename, size_t maxSize) : drain(false
112
130
input.open (filename, std::ios::in | std::ios::binary);
113
131
DBG (cout << " Open " << filename << " -> " << input.is_open () << std::endl);
114
132
memset (&stream, 0 , sizeof (stream));
115
- stream.MaxLength = maxSize;
133
+ stream.MaxLength = (mfxU32) maxSize;
116
134
stream.Data = new mfxU8[stream.MaxLength ];
117
135
CV_Assert (stream.Data );
118
136
}
@@ -139,7 +157,7 @@ bool ReadBitstream::read()
139
157
input.read ((char *)(stream.Data + stream.DataLength ), stream.MaxLength - stream.DataLength );
140
158
if (input.eof () || input.good ())
141
159
{
142
- mfxU32 bytesRead = input.gcount ();
160
+ mfxU32 bytesRead = (mfxU32) input.gcount ();
143
161
if (bytesRead > 0 )
144
162
{
145
163
stream.DataLength += bytesRead;
@@ -157,7 +175,7 @@ WriteBitstream::WriteBitstream(const char * filename, size_t maxSize)
157
175
output.open (filename, std::ios::out | std::ios::binary);
158
176
DBG (cout << " BS Open " << filename << " -> " << output.is_open () << std::endl);
159
177
memset (&stream, 0 , sizeof (stream));
160
- stream.MaxLength = maxSize;
178
+ stream.MaxLength = (mfxU32) maxSize;
161
179
stream.Data = new mfxU8[stream.MaxLength ];
162
180
DBG (cout << " BS Allocate " << maxSize << " bytes (" << ((float )maxSize / (1 << 20 )) << " Mb)" << endl);
163
181
CV_Assert (stream.Data );
0 commit comments