annotate VideoPlayer.h @ 2279:a01d3cf9ff83

mm7 game sound
author Ritor1
date Fri, 14 Mar 2014 22:26:52 +0600
parents c69013c186c7
children d65414f65bd4
rev   line source
0
Ritor1
parents:
diff changeset
1 #pragma once
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
2 #include "OSWindow.h"
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
3 #include "Texture.h"
0
Ritor1
parents:
diff changeset
4
Ritor1
parents:
diff changeset
5
Ritor1
parents:
diff changeset
6
Ritor1
parents:
diff changeset
7
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
8
0
Ritor1
parents:
diff changeset
9 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
10
Ritor1
parents:
diff changeset
11
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13 struct _BINK
Ritor1
parents:
diff changeset
14 {
Ritor1
parents:
diff changeset
15 int uWidth;
Ritor1
parents:
diff changeset
16 int uHeight;
Ritor1
parents:
diff changeset
17 };
Ritor1
parents:
diff changeset
18
Ritor1
parents:
diff changeset
19 struct _BINK_1_5_21_0: public _BINK
Ritor1
parents:
diff changeset
20 {
Ritor1
parents:
diff changeset
21 int uNumFrames;
Ritor1
parents:
diff changeset
22 int uCurrentFrame;
Ritor1
parents:
diff changeset
23 int Data1;
Ritor1
parents:
diff changeset
24 int uFrameRate;
Ritor1
parents:
diff changeset
25 int field_18[3];
Ritor1
parents:
diff changeset
26 int uFlags;
Ritor1
parents:
diff changeset
27 };
Ritor1
parents:
diff changeset
28
Ritor1
parents:
diff changeset
29 struct _BINK_3_0_0_0: public _BINK
Ritor1
parents:
diff changeset
30 {
Ritor1
parents:
diff changeset
31 int unk_0;
Ritor1
parents:
diff changeset
32 int unk_1;
Ritor1
parents:
diff changeset
33 int uNumFrames;
Ritor1
parents:
diff changeset
34 int uCurrentFrame;
Ritor1
parents:
diff changeset
35 int _unk2;
Ritor1
parents:
diff changeset
36 int _unk_[10];
Ritor1
parents:
diff changeset
37 };
Ritor1
parents:
diff changeset
38
Ritor1
parents:
diff changeset
39
Ritor1
parents:
diff changeset
40 struct _BINKBUF
Ritor1
parents:
diff changeset
41 {
Ritor1
parents:
diff changeset
42 int uWidth;
Ritor1
parents:
diff changeset
43 int uHeight;
Ritor1
parents:
diff changeset
44 int field_8;
Ritor1
parents:
diff changeset
45 int field_C;
Ritor1
parents:
diff changeset
46 int uBinkDDSurfaceType;
Ritor1
parents:
diff changeset
47 void *pDDrawSurfaceData;
Ritor1
parents:
diff changeset
48 int uDDrawSurfacePitch;
Ritor1
parents:
diff changeset
49 int field_1C;
Ritor1
parents:
diff changeset
50 int field_20;
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
51 int target_width;
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
52 int target_height;
0
Ritor1
parents:
diff changeset
53 int field_2C;
Ritor1
parents:
diff changeset
54 int field_30;
Ritor1
parents:
diff changeset
55 int field_34;
Ritor1
parents:
diff changeset
56 int field_38;
Ritor1
parents:
diff changeset
57 int field_3C;
Ritor1
parents:
diff changeset
58 int field_40;
Ritor1
parents:
diff changeset
59 int field_44;
Ritor1
parents:
diff changeset
60 struct IDirectDrawSurface *pTargetDDrawSurface;
Ritor1
parents:
diff changeset
61 int field_4C;
Ritor1
parents:
diff changeset
62 int uRectX;
Ritor1
parents:
diff changeset
63 int uRectY;
Ritor1
parents:
diff changeset
64 HWND hWnd;
Ritor1
parents:
diff changeset
65 int field_5C;
Ritor1
parents:
diff changeset
66 float field_60;
Ritor1
parents:
diff changeset
67 float field_64;
Ritor1
parents:
diff changeset
68 int field_68;
Ritor1
parents:
diff changeset
69 int field_6C;
Ritor1
parents:
diff changeset
70 void *pDDrawSurfaceData_;
Ritor1
parents:
diff changeset
71 int field_74;
Ritor1
parents:
diff changeset
72 int field_78;
Ritor1
parents:
diff changeset
73 };
Ritor1
parents:
diff changeset
74 struct _BINKBUF_1_5_21_0: public _BINKBUF
Ritor1
parents:
diff changeset
75 {
Ritor1
parents:
diff changeset
76 int field_7C;
Ritor1
parents:
diff changeset
77 int field_80;
Ritor1
parents:
diff changeset
78 int field_84;
Ritor1
parents:
diff changeset
79 int field_88;
Ritor1
parents:
diff changeset
80 int field_8C;
Ritor1
parents:
diff changeset
81 int field_90;
Ritor1
parents:
diff changeset
82 int field_94;
Ritor1
parents:
diff changeset
83 int field_98;
Ritor1
parents:
diff changeset
84 int field_9C;
Ritor1
parents:
diff changeset
85 int field_A0;
Ritor1
parents:
diff changeset
86 };
Ritor1
parents:
diff changeset
87
Ritor1
parents:
diff changeset
88 struct _BINKBUF_3_0_0_0: public _BINKBUF
Ritor1
parents:
diff changeset
89 {
Ritor1
parents:
diff changeset
90 };
Ritor1
parents:
diff changeset
91 #pragma pack(pop)
Ritor1
parents:
diff changeset
92
Ritor1
parents:
diff changeset
93
Ritor1
parents:
diff changeset
94
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
97 struct MovieHeader
Ritor1
parents:
diff changeset
98 {
Ritor1
parents:
diff changeset
99 char pVideoName[40];
Ritor1
parents:
diff changeset
100 unsigned int uFileOffset;
Ritor1
parents:
diff changeset
101 };
Ritor1
parents:
diff changeset
102 #pragma pack(pop)
Ritor1
parents:
diff changeset
103
Ritor1
parents:
diff changeset
104
Ritor1
parents:
diff changeset
105
Ritor1
parents:
diff changeset
106
Ritor1
parents:
diff changeset
107
1458
934074e7fcc1 ModalWindow
Nomad
parents: 1262
diff changeset
108 void ShowIntroVideo_and_LoadingScreen();
0
Ritor1
parents:
diff changeset
109
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
110 extern "C"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
111 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
112 #include "lib/libavcodec/avcodec.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
113 #include "lib/libavformat/avformat.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
114 #include "lib/libavutil/avutil.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
115 #include "lib/libavutil/imgutils.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
116 #include "lib/libswscale/swscale.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
117 #include "lib/libswresample/swresample.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
118 #include "lib/libavutil/opt.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
119 //#include "libavutil/samplefmt.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
120 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
121 #pragma comment(lib, "avcodec.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
122 #pragma comment(lib, "avformat.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
123 #pragma comment(lib, "avutil.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
124 #pragma comment(lib, "swscale.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
125 #pragma comment(lib, "swresample.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
126
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
127 #include "lib/OpenAL/al.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
128 #include "lib/OpenAL/alc.h"
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
129 #pragma comment(lib, "OpenAL32.lib")
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
130
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
131
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
132
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
133 template<int MAX_SAMPLES_BUFFERS>
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
134 class OpenALSoundProviderGeneric
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
135 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
136 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
137 inline OpenALSoundProviderGeneric()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
138 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
139 this->device = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
140 this->context = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
141 this->samples_current_buffer = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
142
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
143 this->samples_source_id = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
144 for (int i = 0; i < MAX_SAMPLES_BUFFERS; ++i)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
145 samples_buffer_id[i] = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
146 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
147
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
148 inline bool Initialize()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
149 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
150 auto device_names = alcGetString(nullptr, ALC_ALL_DEVICES_SPECIFIER);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
151 if (!device_names)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
152 device_names = alcGetString(nullptr, ALC_DEVICE_SPECIFIER);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
153 if (device_names)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
154 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
155 for (auto device_name = device_names; device_name[0]; device_name += strlen(device_name))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
156 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
157 continue;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
158 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
159 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
160
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
161 device = alcOpenDevice(nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
162 if (!device || CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
163 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
164
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
165 context = alcCreateContext(device, nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
166 if (!context || CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
167 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
168
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
169 alcMakeContextCurrent(context);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
170
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
171 bool eax2 = alIsExtensionPresent("EAX2.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
172 bool eax3 = alIsExtensionPresent("EAX3.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
173 bool eax4 = alIsExtensionPresent("EAX4.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
174 bool eax5 = alIsExtensionPresent("EAX5.0");
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
175
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
176 auto vendor = alGetString(AL_VERSION);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
177 auto version = alGetString(AL_VERSION);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
178 auto extensions = alcGetString(device, ALC_EXTENSIONS);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
179
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
180 alGenBuffers(MAX_SAMPLES_BUFFERS, samples_buffer_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
181 if (CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
182 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
183
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
184 alGenSources(1, &samples_source_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
185 if (CheckError())
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
186 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
187
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
188 float sound_pos[] = { 0.0f, 0.0f, 0.0f };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
189 alSourcefv(samples_source_id, AL_POSITION, sound_pos);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
190 alSourcei(samples_source_id, AL_LOOPING, AL_FALSE);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
191
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
192 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
193 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
194
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
195 void Release()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
196 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
197 if (samples_source_id != -1)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
198 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
199 alDeleteSources(1, &samples_source_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
200 samples_source_id = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
201 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
202
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
203 for (int i = 0; i < MAX_SAMPLES_BUFFERS; ++i)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
204 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
205 if (samples_buffer_id[i] != -1)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
206 alDeleteBuffers(1, &samples_buffer_id[i]);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
207 samples_buffer_id[i] = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
208 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
209
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
210 alcMakeContextCurrent(nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
211 if (context)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
212 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
213 alcDestroyContext(context);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
214 context = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
215 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
216 if (device)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
217 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
218 alcCloseDevice(device);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
219 device = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
220 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
221 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
222
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
223
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
224
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
225
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
226
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
227
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
228
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
229
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
230 void PlaySample(int num_channels, int sample_rate, int num_samples, void *samples)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
231 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
232 //char msg[256];sprintf(msg, "chan %u rate %5u num %5u ptr %p\n", num_channels, sample_rate, num_samples, samples);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
233 //log(msg);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
234 ALenum sound_format;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
235 switch (num_channels)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
236 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
237 case 1: sound_format = AL_FORMAT_MONO16; break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
238 case 2: sound_format = AL_FORMAT_STEREO16; break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
239 default:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
240 if (bool multichannel = alIsExtensionPresent("AL_EXT_MCFORMATS"))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
241 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
242 switch (num_channels)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
243 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
244 case 4: sound_format = alGetEnumValue("AL_FORMAT_QUAD16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
245 case 6: sound_format = alGetEnumValue("AL_FORMAT_51CHN16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
246 case 7: sound_format = alGetEnumValue("AL_FORMAT_61CHN16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
247 case 8: sound_format = alGetEnumValue("AL_FORMAT_71CHN16"); break;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
248 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
249 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
250 __debugbreak();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
251 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
252
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
253 float listener_pos[] = { 0.0f, 0.0f, 0.0f };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
254 float listener_vel[] = { 0.0f, 0.0f, 0.0f };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
255 float listener_orientation[] = { 0.0f, 0.0f, -1.0f, // direction
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
256 0.0f, 1.0f, 0.0f }; // up vector
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
257 alListenerfv(AL_POSITION, listener_pos);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
258 alListenerfv(AL_VELOCITY, listener_vel);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
259 alListenerfv(AL_ORIENTATION, listener_orientation);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
260
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
261 unsigned int *next_buffer = samples_buffer_id + samples_current_buffer;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
262
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
263 alBufferData(*next_buffer, sound_format, samples, num_samples * sizeof(__int16), sample_rate);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
264 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
265
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
266
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
267 int num_processed_buffers;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
268 alGetSourcei(samples_source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers);
2208
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
269 /*while (num_processed_buffers)
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
270 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
271 unsigned int processed_buffers_id[4];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
272 alSourceUnqueueBuffers(samples_source_id, min(4, num_processed_buffers), processed_buffers_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
273 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
274 alGetSourcei(samples_source_id, AL_BUFFERS_PROCESSED, &num_processed_buffers);
2208
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
275 }*/
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
276 for (int i = 0; i < num_processed_buffers; ++i)
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
277 {
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
278 unsigned int processed_buffer_id;
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
279 alSourceUnqueueBuffers(samples_source_id, 1, &processed_buffer_id);
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
280 if (!CheckError())
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
281 alDeleteBuffers(1, &processed_buffer_id);
0b2eea6f80c9 for video in homes
Ritor1
parents: 2142
diff changeset
282 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
283
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
284 int num_queued_buffers;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
285 alGetSourcei(samples_source_id, AL_BUFFERS_QUEUED, &num_queued_buffers);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
286 if (num_queued_buffers >= MAX_SAMPLES_BUFFERS)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
287 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
288 __debugbreak();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
289 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
290
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
291 alSourceQueueBuffers(samples_source_id, 1, next_buffer);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
292 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
293
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
294 int status;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
295 alGetSourcei(samples_source_id, AL_SOURCE_STATE, &status);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
296 if (status != AL_PLAYING)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
297 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
298 alSourcePlay(samples_source_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
299 CheckError();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
300 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
301
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
302 if (++samples_current_buffer >= MAX_SAMPLES_BUFFERS)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
303 samples_current_buffer = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
304 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
305
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
306
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
307
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
308 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
309 ALCdevice *device;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
310 ALCcontext *context;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
311 unsigned int samples_buffer_id[MAX_SAMPLES_BUFFERS];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
312 unsigned int samples_source_id;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
313 int samples_current_buffer;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
314
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
315
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
316 bool CheckError()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
317 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
318 ALenum code = alcGetError(device);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
319 if (code != ALC_NO_ERROR)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
320 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
321 DWORD w;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
322 const char *message = alcGetString(device, code);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
323 WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), message, lstrlenA(message), &w, nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
324 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
325 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
326 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
327 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
328 };
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
329 typedef OpenALSoundProviderGeneric<64> OpenALSoundProvider;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
330
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
331
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
332
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
333 void av_logger(void *, int, const char *format, va_list args);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
334
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
335
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
336
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
337 #include <memory>
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
338 using std::tr1::shared_ptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
339 using std::tr1::make_shared;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
340
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
341 class MultimediaFrame
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
342 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
343 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
344 typedef shared_ptr<MultimediaFrame> Ptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
345 inline MultimediaFrame(AVMediaType type, AVPacket *packet, AVCodecContext *dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
346 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
347 this->type = type;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
348 this->f = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
349 this->p = packet;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
350 this->dec_ctx = dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
351 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
352 virtual ~MultimediaFrame() { return; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
353
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
354
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
355 AVMediaType Type() const { return type; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
356 AVFrame *GetAVFrame() { return f; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
357
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
358 virtual int Decode() = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
359 virtual void *GetData() = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
360 virtual int GetDataPitch() = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
361
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
362
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
363 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
364 AVMediaType type;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
365 AVFrame *f;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
366 AVPacket *p;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
367 AVCodecContext *dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
368 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
369
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
370
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
371
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
372 class MultimediaVideoFrame : public MultimediaFrame
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
373 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
374 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
375 inline MultimediaVideoFrame(AVMediaType type, AVPacket *packet, AVCodecContext *dec_ctx, int width, int height) :
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
376 MultimediaFrame(type, packet, dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
377 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
378 this->width = width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
379 this->height = height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
380 this->rescaled_data[0] = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
381 this->rescaled_linesize[0] = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
382 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
383 virtual ~MultimediaVideoFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
384 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
385 av_freep(&rescaled_data);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
386 av_frame_free(&f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
387 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
388
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
389 int Decode() override
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
390 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
391 f = avcodec_alloc_frame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
392 avcodec_get_frame_defaults(f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
393
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
394 volatile int done = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
395 do
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
396 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
397 int ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
398 if ((ret = avcodec_decode_video2(dec_ctx, f, (int *)&done, p)) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
399 return ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
400 } while (!done);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
401 if (Rescale(f, width, height, AV_PIX_FMT_RGB32, rescaled_data, rescaled_linesize))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
402 return 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
403 else return -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
404 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
405
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
406 virtual void *GetData() { return rescaled_data[0]; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
407 virtual int GetDataPitch() { return rescaled_linesize[0]; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
408
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
409 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
410 int width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
411 int height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
412 uint8_t *rescaled_data[8];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
413 int rescaled_linesize[8];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
414
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
415 bool Rescale(AVFrame *frame, int dst_width, int dst_height, AVPixelFormat format, uint8_t **out_data, int *out_linesize)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
416 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
417 if (av_image_alloc(out_data, out_linesize, dst_width, dst_height, format, 1) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
418 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
419
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
420 SwsContext *converter = sws_getContext(frame->width, frame->height, (AVPixelFormat)frame->format,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
421 dst_width, dst_height, format,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
422 SWS_BICUBIC, nullptr, nullptr, nullptr);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
423 sws_scale(converter, frame->data, frame->linesize, 0, frame->height, out_data, out_linesize);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
424 sws_freeContext(converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
425
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
426 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
427 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
428 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
429
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
430
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
431
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
432 class MultimediaAudioFrame : public MultimediaFrame
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
433 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
434 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
435 inline MultimediaAudioFrame(AVMediaType type, AVPacket *packet, AVCodecContext *dec_ctx) :
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
436 MultimediaFrame(type, packet, dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
437 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
438 this->resampled_data = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
439 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
440 virtual ~MultimediaAudioFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
441 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
442 av_free(resampled_data);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
443 av_frame_free(&f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
444 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
445
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
446 int Decode() override
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
447 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
448 f = avcodec_alloc_frame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
449 avcodec_get_frame_defaults(f);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
450
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
451 volatile int done = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
452 do
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
453 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
454 int ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
455 if ((ret = avcodec_decode_audio4(dec_ctx, f, (int *)&done, p)) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
456 return ret;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
457 } while (!done);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
458 if (Resample(f, f->channel_layout, f->sample_rate,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
459 f->channel_layout, f->sample_rate, AV_SAMPLE_FMT_S16, &resampled_data))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
460 return 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
461 else return -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
462 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
463
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
464 virtual void *GetData() { return resampled_data; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
465 virtual int GetDataPitch() { return 2 * f->nb_samples; }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
466
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
467 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
468 uint8_t *resampled_data;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
469
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
470 bool Resample(AVFrame *frame,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
471 int64_t src_channel_layout, int src_sample_rate,
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
472 int64_t dst_channel_layout, int dst_sample_rate, AVSampleFormat dst_format, uint8_t **out_data)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
473 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
474 SwrContext *converter = swr_alloc();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
475
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
476 av_opt_set_int(converter, "in_channel_layout", src_channel_layout, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
477 av_opt_set_int(converter, "in_sample_rate", src_sample_rate, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
478 av_opt_set_sample_fmt(converter, "in_sample_fmt", (AVSampleFormat)frame->format, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
479
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
480 av_opt_set_int(converter, "out_channel_layout", dst_channel_layout, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
481 av_opt_set_int(converter, "out_sample_rate", dst_sample_rate, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
482 av_opt_set_sample_fmt(converter, "out_sample_fmt", dst_format, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
483
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
484 if (swr_init(converter) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
485 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
486
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
487 int dst_nb_samples;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
488 int max_dst_nb_samples = dst_nb_samples = av_rescale_rnd(frame->nb_samples, dst_sample_rate, src_channel_layout, AV_ROUND_UP);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
489
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
490 uint8_t **dst_data;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
491 int dst_linesize;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
492 int dst_nb_channels = av_get_channel_layout_nb_channels(dst_channel_layout);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
493 if (av_samples_alloc_array_and_samples(&dst_data, &dst_linesize, dst_nb_channels, dst_nb_samples, dst_format, 0) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
494 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
495 swr_free(&converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
496 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
497 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
498
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
499 dst_nb_samples = av_rescale_rnd(swr_get_delay(converter, src_sample_rate) + frame->nb_samples, dst_sample_rate, src_sample_rate, AV_ROUND_UP);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
500 if (dst_nb_samples > max_dst_nb_samples)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
501 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
502 av_free(dst_data[0]);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
503 if (av_samples_alloc(dst_data, &dst_linesize, dst_nb_channels, dst_nb_samples, dst_format, 1) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
504 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
505 swr_free(&converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
506 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
507 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
508 max_dst_nb_samples = dst_nb_samples;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
509 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
510
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
511
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
512 if (swr_convert(converter, dst_data, dst_nb_samples, (const uint8_t **)frame->data, frame->nb_samples) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
513 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
514 av_free(dst_data[0]);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
515 swr_free(&converter);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
516 return false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
517 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
518
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
519 *out_data = dst_data[0];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
520 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
521 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
522 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
523
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
524 int readFunction(void* opaque, uint8_t* buf, int buf_size);
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
525
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
526 int64_t seekFunction(void* opaque, int64_t offset, int whence);
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
527
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
528 template<int NUM_PRECACHED_FRAMES>
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
529 class MovieCached
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
530 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
531 public:
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
532 bool Stopped() { return stopped; }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
533 int GetWidth() { return width; }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
534 int GetHeight() { return height; }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
535 inline ~MovieCached()
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
536 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
537 Release();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
538 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
539 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
540 friend class MultimediaPlayer;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
541 inline MovieCached(OpenALSoundProvider *sound_provider)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
542 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
543 this->format_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
544 this->sound_provider = sound_provider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
545 this->stopped = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
546
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
547 this->video_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
548 this->video_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
549 this->video_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
550 this->video_stream_dec_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
551
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
552 this->audio_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
553 this->audio_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
554 this->audio_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
555 this->audio_stream_dec_ctx = nullptr;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
556
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
557 packet = nullptr;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
558 ioBuffer = nullptr;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
559 format_ctx = nullptr;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
560 avioContext = nullptr;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
561 }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
562
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
563 bool LoadFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
564 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
565 if (!ioBuffer)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
566 ioBuffer = (unsigned char *)av_malloc(16384 + FF_INPUT_BUFFER_PADDING_SIZE); // can get av_free()ed by libav
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
567 if (!avioContext)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
568 avioContext = avio_alloc_context(ioBuffer, 16384, 0, h, &readFunction, NULL, &seekFunction);
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
569 if (!format_ctx)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
570 format_ctx = avformat_alloc_context();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
571 format_ctx->pb = avioContext;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
572 return Load("dummyFilename", width, height);
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
573 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
574
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
575 bool Load(const char *video_filename, int width, int height)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
576 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
577 this->width = width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
578 this->height = height;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
579
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
580 if (avformat_open_input(&format_ctx, video_filename, nullptr, nullptr) >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
581 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
582 if (avformat_find_stream_info(format_ctx, nullptr) >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
583 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
584 av_dump_format(format_ctx, 0, video_filename, 0);
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
585
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
586 video_stream_idx = OpenStream(AVMEDIA_TYPE_VIDEO, &video_stream, &video_stream_dec, &video_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
587 if (video_stream_idx < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
588 return Release(), false;
2221
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
589 if (_stricmp("binkvideo", video_stream_dec->name) )//Ritor1: include
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
590 {
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
591 this->width = video_stream_dec_ctx->width;
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
592 this->height = video_stream_dec_ctx->height;
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
593 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
594
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
595 audio_stream_idx = OpenStream(AVMEDIA_TYPE_AUDIO, &audio_stream, &audio_stream_dec, &audio_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
596 if (audio_stream_idx < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
597 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
598
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
599 strcpy(movie_name, video_filename);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
600 packet = new AVPacket;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
601 av_init_packet(packet);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
602 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
603 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
604 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
605 return Release(), false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
606 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
607
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
608 bool Release()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
609 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
610 if (packet)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
611 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
612 av_free_packet(packet);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
613 delete packet;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
614 packet = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
615 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
616
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
617 if (video_stream_idx >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
618 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
619 video_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
620 video_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
621 video_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
622 avcodec_close(video_stream_dec_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
623 video_stream_dec_ctx = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
624 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
625
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
626 if (audio_stream_idx >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
627 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
628 audio_stream_idx = -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
629 audio_stream = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
630 audio_stream_dec = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
631 avcodec_close(audio_stream_dec_ctx);
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
632
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
633 }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
634 if (avioContext)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
635 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
636 av_free(avioContext);
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
637 avioContext = nullptr;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
638 }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
639 if (format_ctx)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
640 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
641 avformat_free_context(format_ctx);
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
642 format_ctx = nullptr;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
643 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
644 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
645 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
646
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
647
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
648 int OpenStream(AVMediaType type, AVStream **out_stream, AVCodec **out_dec, AVCodecContext **out_dec_ctx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
649 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
650 int stream_idx = av_find_best_stream(format_ctx, type, -1, -1, nullptr, 0);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
651 if (stream_idx < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
652 return stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
653
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
654 auto stream = format_ctx->streams[stream_idx];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
655 auto dec_ctx = stream->codec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
656 auto dec = avcodec_find_decoder(dec_ctx->codec_id);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
657 if (dec)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
658 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
659 if (avcodec_open2(dec_ctx, dec, nullptr) >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
660 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
661 *out_stream = stream;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
662 *out_dec = dec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
663 *out_dec_ctx = dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
664 return stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
665 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
666 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
667 return -1;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
668 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
669
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
670 MultimediaFrame::Ptr GetNextFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
671 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
672 packet->data = nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
673 packet->size = 0;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
674
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
675 volatile int got_frame = false;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
676 do
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
677 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
678 if (av_read_frame(format_ctx, packet) < 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
679 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
680 stopped = true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
681 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
682 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
683 } while (packet->stream_index != video_stream_idx &&
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
684 packet->stream_index != audio_stream_idx);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
685
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
686 if (packet->stream_index == video_stream_idx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
687 return MultimediaFrame::Ptr(new MultimediaVideoFrame(AVMEDIA_TYPE_VIDEO, packet, video_stream_dec_ctx, width, height));
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
688 else if (packet->stream_index == audio_stream_idx)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
689 return MultimediaFrame::Ptr(new MultimediaAudioFrame(AVMEDIA_TYPE_AUDIO, packet, audio_stream_dec_ctx));
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
690 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
691 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
692
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
693
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
694
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
695 char movie_name[256];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
696 int width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
697 int height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
698 bool stopped;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
699 AVFormatContext *format_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
700 //AVFrame *frame;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
701 AVPacket *packet;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
702 //MultimediaFrame *frames[NUM_PRECACHED_FRAMES];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
703 OpenALSoundProvider *sound_provider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
704
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
705 int video_stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
706 AVStream *video_stream;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
707 AVCodec *video_stream_dec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
708 AVCodecContext *video_stream_dec_ctx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
709
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
710 int audio_stream_idx;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
711 AVStream *audio_stream;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
712 AVCodec *audio_stream_dec;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
713 AVCodecContext *audio_stream_dec_ctx;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
714 unsigned char * ioBuffer;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
715 AVIOContext *avioContext;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
716 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
717 typedef MovieCached<10> Movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
718
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
719
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
720
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
721
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
722 class MultimediaPlayer
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
723 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
724 public:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
725 inline MultimediaPlayer()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
726 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
727 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
728
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
729 bool Initialize()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
730 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
731 if (!libavcodec_initialized)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
732 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
733 av_log_set_callback(Logger);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
734 avcodec_register_all();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
735 av_register_all();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
736
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
737 libavcodec_initialized = true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
738 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
739
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
740 sound_provider = new OpenALSoundProvider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
741 sound_provider->Initialize();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
742
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
743 return true;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
744 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
745
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
746 Movie *LoadMovieFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
747 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
748 auto movie = new Movie(sound_provider);
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
749 if (movie)
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
750 {
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
751 if (movie->LoadFromLOD(h, readFunction, seekFunction, width, height))
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
752 {
2221
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
753 if (_stricmp("binkvideo", movie->video_stream_dec->name) )
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
754 {
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
755 current_movie_width = movie->video_stream_dec_ctx->width;
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
756 current_movie_height = movie->video_stream_dec_ctx->height;
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
757 }
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
758 else
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
759 {
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
760 current_movie_width = width;
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
761 current_movie_height = height;
c69013c186c7 for video
Ritor1
parents: 2208
diff changeset
762 }
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
763 return current_movie = movie;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
764 }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
765 delete movie;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
766 }
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
767 return nullptr;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
768 }
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
769
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
770 Movie *LoadMovie(const char *filename, int width, int height)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
771 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
772 auto movie = new Movie(sound_provider);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
773 if (movie)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
774 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
775 if (movie->Load(filename, width, height))
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
776 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
777 current_movie_width = width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
778 current_movie_height = height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
779 return current_movie = movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
780 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
781 delete movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
782 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
783 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
784 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
785
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
786 inline char *DoFrame()
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
787 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
788 if (!current_movie)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
789 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
790
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
791 while (true)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
792 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
793 auto frame = current_movie->GetNextFrame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
794 if (!frame)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
795 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
796
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
797 if (frame->Type() == AVMEDIA_TYPE_AUDIO)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
798 {
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
799 //continue;
2134
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
800 uint8_t *data;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
801 if (frame->Decode() >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
802 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
803 auto f = frame->GetAVFrame();
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
804 sound_provider->PlaySample(f->channels, f->sample_rate, f->nb_samples, frame->GetData());
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
805 Sleep(20);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
806 continue;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
807 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
808 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
809 else if (frame->Type() == AVMEDIA_TYPE_VIDEO)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
810 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
811 uint8_t *dst_data[4] = { 0 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
812 int dst_linesize[4] = { 0 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
813 if (frame->Decode() >= 0)
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
814 {
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
815 auto image = new char[current_movie_width * current_movie_height * 4];
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
816 memcpy(image, frame->GetData(), current_movie_height * frame->GetDataPitch());
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
817
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
818 return image;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
819 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
820 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
821 return nullptr;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
822 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
823 }
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
824
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
825
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
826
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
827 protected:
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
828 static void Logger(void *, int, const char *format, va_list args);
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
829
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
830 OpenALSoundProvider *sound_provider;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
831 Movie *current_movie;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
832 int current_movie_width;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
833 int current_movie_height;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
834
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
835 static bool libavcodec_initialized;
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
836 };
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
837
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
838
992d2e6f907d preparation for libavcodec
zipi
parents: 1802
diff changeset
839
0
Ritor1
parents:
diff changeset
840
Ritor1
parents:
diff changeset
841
Ritor1
parents:
diff changeset
842
Ritor1
parents:
diff changeset
843 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
844 struct VideoPlayer
Ritor1
parents:
diff changeset
845 {
1262
0aeac0b9ca30 included header cleanup
Grumpy7
parents: 1253
diff changeset
846 VideoPlayer();
0
Ritor1
parents:
diff changeset
847 //----- (004BECBD) --------------------------------------------------------
Ritor1
parents:
diff changeset
848 virtual ~VideoPlayer()
Ritor1
parents:
diff changeset
849 {
Ritor1
parents:
diff changeset
850 bStopBeforeSchedule = false;
165
Ritor1
parents: 0
diff changeset
851 pResetflag = 0;
0
Ritor1
parents:
diff changeset
852 pVideoFrame.Release();
Ritor1
parents:
diff changeset
853 }
Ritor1
parents:
diff changeset
854
Ritor1
parents:
diff changeset
855 void PlayDeathMovie();
Ritor1
parents:
diff changeset
856 unsigned int SmackCheckSurfaceFromat();
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
857 void Initialize(OSWindow *window);
0
Ritor1
parents:
diff changeset
858 void Prepare();
Ritor1
parents:
diff changeset
859 void Unload();
Ritor1
parents:
diff changeset
860 void FastForwardToFrame(unsigned int uFrameNum);
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
861 void BinkDrawFrame(int a3, int a4);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
862 void BinkUpdatePalette() {}
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
863 void SmackDrawFrame(int a3, int a4);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
864 void SmackUpdatePalette();
0
Ritor1
parents:
diff changeset
865 _BINK *OpenBink(const char *pName);
Ritor1
parents:
diff changeset
866 struct _SMACK *OpenSmack(const char *pFilename);
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 323
diff changeset
867 void OpenHouseMovie(const char *pMovieName, unsigned int a3_1);//0x4BF28F
0
Ritor1
parents:
diff changeset
868 bool AnyMovieLoaded();
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 323
diff changeset
869 void OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4);
0
Ritor1
parents:
diff changeset
870 void _4BF5B2();
898
10fa7dad1391 DrawPaperdoll clean
Ritor1
parents: 323
diff changeset
871 void SelectMovieType();//0x4BF73A
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
872 _BINKBUF *CreateBinkBuffer(unsigned int uWidth, unsigned int uHeight, char a4);
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
873 void _inlined_in_463149();
0
Ritor1
parents:
diff changeset
874
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
875 void MovieLoop(const char *pMovieName, int a2, int a3, int a4);
0
Ritor1
parents:
diff changeset
876
Ritor1
parents:
diff changeset
877
Ritor1
parents:
diff changeset
878 RGBTexture pVideoFrame;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
879 //struct _SMACK *pSmackerMovie;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
880 //struct _SMACKBUF *pSmackerBuffer;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
881 //char *pSomeSmackerBuffer;
0
Ritor1
parents:
diff changeset
882 int field_34;
Ritor1
parents:
diff changeset
883 MovieHeader *pMightVideoHeaders;
Ritor1
parents:
diff changeset
884 MovieHeader *pMagicVideoHeaders;
165
Ritor1
parents: 0
diff changeset
885 int pResetflag;
0
Ritor1
parents:
diff changeset
886 int field_44;
Ritor1
parents:
diff changeset
887 unsigned int uNumMightVideoHeaders;
Ritor1
parents:
diff changeset
888 unsigned int uNumMagicVideoHeaders;
Ritor1
parents:
diff changeset
889 int uBinkDirectDrawSurfaceType;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
890 int bBufferLoaded;
0
Ritor1
parents:
diff changeset
891 unsigned int bPlayingMovie;
Ritor1
parents:
diff changeset
892 unsigned int bFirstFrame;
Ritor1
parents:
diff changeset
893 unsigned int bUsingSmackerMMX;
Ritor1
parents:
diff changeset
894 unsigned int bLoopPlaying;
Ritor1
parents:
diff changeset
895 int field_68;
Ritor1
parents:
diff changeset
896 unsigned int bStopBeforeSchedule;
1802
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
897 //HWND hWindow;
633f81bb3ae7 HWND -> class OSWindow
Nomad
parents: 1458
diff changeset
898 OSWindow *window;
0
Ritor1
parents:
diff changeset
899 struct _SMACKBLIT *pSmackMovieBlit;
Ritor1
parents:
diff changeset
900 HANDLE hMightVid;
Ritor1
parents:
diff changeset
901 HANDLE hMagicVid;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
902 //_BINK *pBinkMovie;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
903 //_BINKBUF *pBinkBuffer;
0
Ritor1
parents:
diff changeset
904 char field_88[20];
Ritor1
parents:
diff changeset
905 unsigned int uMovieFormat;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
906 int uMovieFormatSwapped;
0
Ritor1
parents:
diff changeset
907 char pCurrentMovieName[64];
Ritor1
parents:
diff changeset
908 char pVideoFrameTextureFilename[32];
323
d720a13e2273 Very basic picking & entering houses
Nomad
parents: 165
diff changeset
909 int field_104;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
910 MultimediaPlayer *pPlayer;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
911 Movie *pMovie;
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
912 HANDLE hVidFile;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
913 int uSize;
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
914 int uOffset;
2142
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
915 void UpdatePalette();
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
916 static int readFunction(void *, uint8_t *, int);
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
917 static int64_t seekFunction(void *, int64_t, int);
ca548138d6aa some code cleaning in video playing, loops play but there is a memory leak
zipi
parents: 2137
diff changeset
918 void LoadMovie(const char *);
0
Ritor1
parents:
diff changeset
919 };
Ritor1
parents:
diff changeset
920 #pragma pack(pop)
Ritor1
parents:
diff changeset
921
Ritor1
parents:
diff changeset
922
Ritor1
parents:
diff changeset
923
Ritor1
parents:
diff changeset
924
Ritor1
parents:
diff changeset
925
Ritor1
parents:
diff changeset
926 extern VideoPlayer *pVideoPlayer;
2137
d24ee391fd1f libavcodec playing movies and houses, loops not working yet
zipi
parents: 2134
diff changeset
927 extern LRESULT __stdcall wWinProc(HWND hwnd, unsigned int msg, WPARAM wparam, LPARAM lparam);