2315
|
1 extern "C"
|
|
2 {
|
|
3 #include "lib/libavcodec/avcodec.h"
|
|
4 #include "lib/libavformat/avformat.h"
|
|
5 #include "lib/libavutil/avutil.h"
|
|
6 #include "lib/libavutil/imgutils.h"
|
|
7 #include "lib/libswscale/swscale.h"
|
|
8 #include "lib/libswresample/swresample.h"
|
|
9 #include "lib/libavutil/opt.h"
|
|
10 }
|
|
11 #pragma comment(lib, "avcodec.lib")
|
|
12 #pragma comment(lib, "avformat.lib")
|
|
13 #pragma comment(lib, "avutil.lib")
|
|
14 #pragma comment(lib, "swscale.lib")
|
|
15 #pragma comment(lib, "swresample.lib")
|
|
16
|
|
17 #include <vector>
|
|
18 #include <deque>
|
|
19
|
|
20 #include "stuff.h"
|
|
21 #include "OpenALSoundProvider.h"
|
|
22
|
|
23 #include "MediaPlayer.h"
|
|
24 using namespace Media;
|
2356
|
25
|
|
26 Media::MPlayer *pMediaPlayer;
|
|
27 Media::IMovie *pMovie;
|
|
28 Media::ITrack *pTrack;
|
2360
|
29 Movie *movie;
|
2356
|
30
|
2359
|
31 int mSourceID;
|
|
32
|
2356
|
33 void PlayMovie(const wchar_t * pFilename);
|
|
34 void PlayAudio(const wchar_t * pFilename);
|
|
35 void LoadMovie(const char *);
|
2347
|
36
|
2315
|
37 class MemoryStream
|
|
38 {
|
|
39 public:
|
|
40 inline MemoryStream(void *data, size_t data_size)
|
|
41 {
|
|
42 this->data_size = data_size;
|
|
43 this->data = data;
|
|
44 this->current_pos = 0;
|
|
45 }
|
|
46 inline MemoryStream()
|
|
47 {
|
|
48 this->data_size = 0;
|
|
49 this->data = nullptr;
|
|
50 this->current_pos = 0;
|
|
51 }
|
|
52
|
|
53 inline ~MemoryStream()
|
|
54 {
|
|
55 if (data)
|
|
56 delete [] data;
|
|
57 }
|
|
58
|
|
59 inline size_t Write(void *buffer, size_t num_bytes)
|
|
60 {
|
|
61 if (!data)
|
|
62 {
|
|
63 data_size = 32 + num_bytes;
|
|
64 data = new char[data_size];
|
|
65 current_pos = 0;
|
|
66 }
|
|
67 else if (current_pos + num_bytes >= data_size)
|
|
68 {
|
|
69 int new_data_size = data_size + num_bytes + data_size / 8 + 4;
|
|
70 auto new_data = new char[new_data_size];
|
|
71
|
|
72 memcpy(new_data, data, data_size);
|
|
73 delete [] data;
|
|
74
|
|
75 data_size = new_data_size;
|
|
76 data = new_data;
|
|
77 }
|
|
78 memcpy((char *)data + current_pos, buffer, num_bytes);
|
|
79 current_pos += num_bytes;
|
|
80 return num_bytes;
|
|
81 }
|
|
82
|
|
83 inline size_t Read(void *buffer, size_t num_bytes)
|
|
84 {
|
|
85 size_t read_size = min(num_bytes, data_size - current_pos);
|
|
86 if (read_size)
|
|
87 {
|
|
88 memcpy(buffer, (char *)data + current_pos, read_size);
|
|
89 current_pos += read_size;
|
|
90 }
|
|
91 return read_size;
|
|
92 }
|
|
93
|
|
94 inline void Reset()
|
|
95 {
|
|
96 current_pos = 0;
|
|
97 }
|
|
98 inline void SeekToEnd()
|
|
99 {
|
|
100 current_pos = data_size;
|
|
101 }
|
|
102
|
2347
|
103 inline size_t Unwind(size_t bytes)//???
|
2315
|
104 {
|
|
105 if (bytes > current_pos)
|
|
106 current_pos = 0;
|
|
107 else
|
|
108 current_pos -= bytes;
|
|
109 return current_pos;
|
|
110 }
|
|
111
|
|
112 inline size_t Rewind(size_t bytes)
|
|
113 {
|
|
114 if (current_pos + bytes >= data_size)
|
|
115 current_pos = data_size;
|
|
116 else
|
|
117 current_pos += bytes;
|
|
118 return current_pos;
|
|
119 }
|
|
120
|
|
121 inline size_t Size() const {return data_size;}
|
|
122 inline size_t Current() const {return current_pos;}
|
|
123 inline void *Ptr() const {return data;}
|
|
124
|
|
125 private:
|
|
126 void *data;
|
|
127 size_t data_size;
|
|
128 size_t current_pos;
|
|
129 };
|
|
130
|
2345
|
131 bool end_current_file;
|
|
132 bool loop_current_file;
|
|
133 DWORD time_video_begin;
|
|
134 int current_movie_width;
|
|
135 int current_movie_height;
|
2315
|
136
|
|
137 OpenALSoundProvider *provider = nullptr;
|
|
138
|
|
139 static int av_num_bytes_per_sample(AVSampleFormat sample_fmt)
|
|
140 {
|
|
141 switch (sample_fmt)
|
|
142 {
|
|
143 case AV_SAMPLE_FMT_U8:
|
|
144 case AV_SAMPLE_FMT_U8P:
|
|
145 return 1;
|
|
146
|
|
147 case AV_SAMPLE_FMT_S16:
|
|
148 case AV_SAMPLE_FMT_S16P:
|
|
149 return 2;
|
|
150
|
|
151 case AV_SAMPLE_FMT_S32:
|
|
152 case AV_SAMPLE_FMT_S32P:
|
|
153 case AV_SAMPLE_FMT_FLT:
|
|
154 case AV_SAMPLE_FMT_FLTP:
|
|
155 return 4;
|
|
156
|
|
157 case AV_SAMPLE_FMT_DBL:
|
|
158 case AV_SAMPLE_FMT_DBLP:
|
|
159 return 8;
|
|
160
|
|
161 default:
|
|
162 case AV_SAMPLE_FMT_NONE:
|
|
163 Error("Invalid av sample format: %u", sample_fmt);
|
|
164 }
|
|
165 return 0;
|
|
166 }
|
|
167
|
|
168 struct AVStreamWrapper
|
|
169 {
|
|
170 inline AVStreamWrapper()
|
|
171 {
|
|
172 this->type = AVMEDIA_TYPE_UNKNOWN;
|
|
173 this->stream_idx = -1;
|
|
174 this->stream = nullptr;
|
|
175 this->dec = nullptr;
|
|
176 this->dec_ctx = nullptr;
|
|
177 }
|
|
178
|
|
179 inline void Release()
|
|
180 {
|
|
181 type = AVMEDIA_TYPE_UNKNOWN;
|
|
182 stream_idx = -1;
|
|
183 stream = nullptr;
|
|
184 dec = nullptr;
|
|
185 if (dec_ctx)
|
|
186 {
|
2347
|
187 // Close the codec
|
2345
|
188 //
|
2315
|
189 avcodec_close(dec_ctx);
|
|
190 dec_ctx = nullptr;
|
|
191 }
|
|
192 }
|
|
193
|
|
194 AVMediaType type;
|
|
195 int stream_idx;
|
|
196 AVStream *stream;
|
|
197 AVCodec *dec;
|
|
198 AVCodecContext *dec_ctx;
|
|
199 };
|
|
200
|
|
201 struct AVAudioStream: public AVStreamWrapper
|
|
202 {
|
|
203 inline AVAudioStream():
|
|
204 AVStreamWrapper()
|
|
205 {
|
|
206 this->bytes_per_sample = 0;
|
|
207 this->bytes_per_second = 0;
|
|
208 }
|
|
209
|
|
210 int bytes_per_sample;
|
|
211 int bytes_per_second;
|
|
212 };
|
|
213
|
|
214 struct AVVideoStream: public AVStreamWrapper
|
|
215 {
|
|
216 inline AVVideoStream():
|
|
217 AVStreamWrapper()
|
|
218 {
|
|
219 this->frames_per_second = 0.0;
|
|
220 }
|
|
221
|
|
222 double frames_per_second;
|
|
223 };
|
|
224
|
|
225 static bool av_open_stream(AVFormatContext *format_ctx, AVMediaType type, AVStreamWrapper *out_stream)
|
|
226 {
|
2347
|
227 // stream
|
2315
|
228 int stream_idx = av_find_best_stream(format_ctx, type, -1, -1, nullptr, 0);
|
|
229 if (stream_idx >= 0)
|
|
230 {
|
|
231 auto stream = format_ctx->streams[stream_idx];
|
2347
|
232 // (AVCodecContext).
|
|
233 // , (AVCodec) .
|
|
234 //
|
2315
|
235 auto dec_ctx = stream->codec;
|
2347
|
236
|
|
237 // Find the decoder for the video stream
|
2345
|
238 //
|
2315
|
239 auto dec = avcodec_find_decoder(dec_ctx->codec_id);
|
|
240 if (dec)
|
|
241 {
|
2347
|
242 // Open codec
|
|
243 //
|
2315
|
244 if (avcodec_open2(dec_ctx, dec, nullptr) >= 0)
|
|
245 {
|
|
246 out_stream->type = type;
|
|
247 out_stream->stream_idx = stream_idx;
|
|
248 out_stream->stream = stream;
|
|
249 out_stream->dec = dec;
|
|
250 out_stream->dec_ctx = dec_ctx;
|
|
251 return true;
|
|
252 }
|
2347
|
253 fprintf(stderr, "ffmpeg: Could not open codec\n");//
|
|
254 return false;
|
2315
|
255 }
|
2347
|
256 fprintf(stderr, "ffmpeg: Unable to open codec\n");//
|
|
257 return false;
|
2315
|
258 }
|
2347
|
259 fprintf(stderr, "ffmpeg: Didn't find a stream\n");// stream
|
|
260 return false;
|
2315
|
261 }
|
|
262
|
|
263 static bool av_open_audio_stream(AVFormatContext *format_ctx, AVAudioStream *out_stream)
|
|
264 {
|
|
265 if (!av_open_stream(format_ctx, AVMEDIA_TYPE_AUDIO, out_stream))
|
|
266 return Error("Audio stream not found"), false;
|
|
267
|
|
268 // we support only 2-channel audio for now
|
2345
|
269 //if (out_stream->dec_ctx->channels != 2)// jvc.bik
|
|
270 //{
|
|
271 // out_stream->Release();
|
|
272 // return Error("Unsupported number of channels: %u", out_stream->dec_ctx->channels), false;
|
|
273 //}
|
2315
|
274
|
|
275 out_stream->bytes_per_sample = av_num_bytes_per_sample(out_stream->dec_ctx->sample_fmt);
|
|
276 out_stream->bytes_per_second = out_stream->dec_ctx->channels * out_stream->dec_ctx->sample_rate * out_stream->bytes_per_sample;
|
|
277
|
|
278 return true;
|
|
279 }
|
|
280
|
|
281 static bool av_open_video_stream(AVFormatContext *format_ctx, AVVideoStream *out_stream)
|
|
282 {
|
|
283 if (!av_open_stream(format_ctx, AVMEDIA_TYPE_VIDEO, out_stream))
|
|
284 return Error("Video stream not found"), false;
|
|
285
|
|
286 out_stream->frames_per_second = (double)out_stream->dec_ctx->time_base.den / (double)out_stream->dec_ctx->time_base.num;
|
|
287 return true;
|
|
288 }
|
|
289
|
|
290 void InterleaveAudioData(MemoryStream *stream, AVSampleFormat src_format, int num_channels, int num_samples, uint8_t **channels)
|
|
291 {
|
|
292 unsigned int bytes_per_sample;
|
|
293 switch (src_format)
|
|
294 {
|
|
295 case AV_SAMPLE_FMT_U8:
|
|
296 case AV_SAMPLE_FMT_U8P:
|
|
297 __debugbreak();
|
|
298
|
|
299 case AV_SAMPLE_FMT_S16:
|
|
300 bytes_per_sample = sizeof(__int16);
|
|
301 stream->Write(channels[0], num_channels * num_samples * bytes_per_sample);
|
|
302 break;
|
|
303
|
|
304 case AV_SAMPLE_FMT_S16P:
|
|
305 {
|
|
306 bytes_per_sample = sizeof(__int16);
|
|
307 for (int i = 0; i < num_samples; ++i)
|
|
308 for (int j = 0; j < num_channels; ++j)
|
|
309 stream->Write(channels[j] + i * bytes_per_sample, bytes_per_sample);
|
|
310 }
|
|
311 break;
|
|
312
|
|
313 case AV_SAMPLE_FMT_FLT:
|
|
314 {
|
|
315 SwrContext *converter = swr_alloc();
|
|
316 av_opt_set_int(converter, "in_channel_layout", av_get_default_channel_layout(2), 0);
|
|
317 //av_opt_set_int(converter, "in_sample_rate", sample_ra, 0);
|
|
318 av_opt_set_sample_fmt(converter, "in_sample_fmt", AV_SAMPLE_FMT_FLT, 0);
|
|
319
|
|
320 av_opt_set_int(converter, "out_channel_layout", av_get_default_channel_layout(2), 0);
|
|
321 //av_opt_set_int(converter, "out_sample_rate", dst_sample_rate, 0);
|
|
322 av_opt_set_sample_fmt(converter, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
|
|
323
|
|
324 if (swr_init(converter) < 0)
|
|
325 {
|
|
326 __debugbreak();
|
|
327 swr_free(&converter);
|
|
328 return;
|
|
329 }
|
|
330
|
|
331 uint8_t **dst_channels;
|
|
332 int dst_linesize[8];
|
|
333 //int dst_nb_channels = av_get_channel_layout_nb_channels(dst_channel_layout);
|
|
334 if (av_samples_alloc_array_and_samples(&dst_channels, dst_linesize, 2, num_channels * num_samples, AV_SAMPLE_FMT_S16, 0) < 0)
|
|
335 {
|
|
336 __debugbreak();
|
|
337 swr_free(&converter);
|
|
338 return;
|
|
339 }
|
|
340
|
|
341 if (swr_convert(converter, dst_channels, num_channels * num_samples, (const uint8_t **)channels, num_channels * num_samples) >= 0)
|
|
342 stream->Write(dst_channels[0], num_channels * num_samples * sizeof(__int16));
|
|
343 else
|
|
344 __debugbreak();
|
|
345
|
|
346 av_free(dst_channels[0]);
|
|
347 swr_free(&converter);
|
|
348 }
|
|
349 break;
|
|
350
|
|
351 default:
|
|
352 __debugbreak();
|
|
353 //if (Resample(next_frame->avframe, next_frame->avframe->channel_layout, next_frame->avframe->sample_rate,
|
|
354 // av_get_default_channel_layout(2), next_frame->avframe->sample_rate, AV_SAMPLE_FMT_S16P, resampled_data))
|
|
355 }
|
|
356 }
|
|
357
|
2356
|
358 const uint16_t ff_wma_critical_freqs[25] = {
|
|
359 100, 200, 300, 400, 510, 630, 770, 920,
|
|
360 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150,
|
|
361 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500,
|
|
362 24500,
|
|
363 };
|
|
364 extern const uint16_t ff_wma_critical_freqs[25];
|
|
365 static float quant_table[96];
|
|
366
|
2315
|
367 bool DecodeAudioFrame(AVCodecContext *dec_ctx, AVPacket *avpacket, AVFrame *avframe, MemoryStream *out_audio_data, int *out_num_audio_samples)
|
|
368 {
|
|
369 volatile int decoded = false;
|
|
370 do
|
|
371 {
|
2347
|
372 // - avcodec_decode_audio4
|
2315
|
373 if (avcodec_decode_audio4(dec_ctx, avframe, (int *)&decoded, avpacket) < 0)
|
|
374 {
|
|
375 log("Cannot decode audio frame\n");
|
|
376 return false;
|
|
377 }
|
|
378
|
|
379 if (!decoded)
|
|
380 log("Cannot decode audio frame in one piece\n");
|
|
381 } while (!decoded);
|
|
382
|
|
383 switch (dec_ctx->codec_id)
|
|
384 {
|
2356
|
385 case AV_CODEC_ID_BINKAUDIO_DCT:
|
|
386 {
|
|
387 __debugbreak();
|
|
388 }
|
2315
|
389 case AV_CODEC_ID_BINKAUDIO_RDFT:
|
|
390 {//pts samples dpts
|
|
391 // 0 960
|
|
392 //17280 960 17280 18x960
|
|
393 //18240 960 960 1x960
|
|
394 //20160 960 1920 2x960
|
|
395 //21120 960 960 1x960
|
|
396 //23040 960 1920 2x960
|
2356
|
397 /*static int bink_next_pts = 0;
|
2315
|
398
|
|
399 // there's a gap in the sound - fill empty samples in
|
|
400 if (bink_next_pts < avpacket->pts)
|
|
401 {
|
|
402 short silence[1024];
|
|
403 memset(silence, 0, sizeof(silence));
|
|
404
|
2356
|
405 int samples_to_fill = /*dec_ctx->channels * (avpacket->pts - bink_next_pts);
|
2315
|
406 while (samples_to_fill > 0)
|
|
407 {
|
|
408 int samples_to_fill_this_step = samples_to_fill >= 1024 ? 1024 : samples_to_fill;
|
|
409 out_audio_data->Write(silence, samples_to_fill_this_step * sizeof(short));
|
|
410
|
|
411 samples_to_fill -= samples_to_fill_this_step;
|
|
412 }
|
|
413 }
|
|
414
|
2356
|
415 bink_next_pts = avpacket->pts + /*dec_ctx->channels * avframe->nb_samples; */
|
|
416
|
|
417 AVFrame frame;
|
|
418 int first;
|
|
419 int version_b;
|
|
420 int frame_len;
|
|
421 int overlap_len;
|
|
422 int block_size;
|
|
423 int num_bands;
|
|
424 unsigned int *bands;
|
|
425 float root;
|
|
426 int sample_rate = dec_ctx->sample_rate;
|
|
427 int sample_rate_half;
|
|
428 int i;
|
|
429 int frame_len_bits;
|
|
430 int channels;
|
|
431
|
|
432 //compresses audio in chunks of varying sizes depending on sample rate:
|
|
433 // if sample rate < 22050, frame size is 2048 samples
|
|
434 // if sample rate < 44100, frame size is 4096 samples
|
|
435 // else, frame size is 8192 samples
|
|
436
|
|
437 // :
|
|
438 // < 22050, 2048
|
|
439 // < 44100, 4096
|
|
440 //, 8192
|
|
441
|
|
442 /* determine frame length */
|
|
443 if (dec_ctx->sample_rate < 22050)
|
|
444 frame_len_bits = 9;
|
|
445 else if (dec_ctx->sample_rate < 44100)
|
|
446 frame_len_bits = 10;
|
|
447 else
|
|
448 frame_len_bits = 11;
|
|
449
|
|
450 // ( 1 2)
|
|
451 if (dec_ctx->channels < 1 || dec_ctx->channels > 2)
|
|
452 {
|
|
453 av_log(dec_ctx, AV_LOG_ERROR, "invalid number of channels: %d\n", dec_ctx->channels);
|
|
454 return AVERROR_INVALIDDATA;
|
|
455 }
|
|
456
|
|
457 version_b = dec_ctx->extradata_size >= 4 && dec_ctx->extradata[3] == 'b';
|
|
458 if (version_b)
|
|
459 __debugbreak();
|
|
460
|
|
461 if (dec_ctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
|
|
462 {
|
|
463 // audio is already interleaved for the RDFT format variant
|
|
464 dec_ctx->sample_fmt = AV_SAMPLE_FMT_FLT;
|
|
465 sample_rate *= dec_ctx->channels;
|
|
466 channels = 1;
|
|
467 if (!version_b)
|
|
468 frame_len_bits += av_log2(dec_ctx->channels);
|
|
469 }
|
|
470 else
|
|
471 {
|
|
472 channels = dec_ctx->channels;
|
|
473 dec_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
|
|
474 }
|
|
475
|
|
476 frame_len = 1 << frame_len_bits; //2048
|
|
477
|
|
478 //a frame is windowed with the previous frame; the size of the window is frame size / 16
|
|
479 // ; = / 16
|
|
480 overlap_len = frame_len / 16; //128
|
|
481 block_size = (frame_len - overlap_len) * channels; //1920
|
|
482
|
|
483 //compute half the sample rate as (sample rate + 1) / 2;
|
|
484 //initialize an array of band frequencies corresponding to an array of 25 critical frequencies (same as WMA, apparently),
|
|
485 // any for which the critical frequencies are less than half the sample rate
|
|
486
|
|
487 // ( + 1) / 2;
|
|
488 // , 25 ( WMA, ),
|
|
489 // ,
|
|
490 sample_rate_half = (sample_rate + 1) / 2; //22050
|
|
491 if (dec_ctx->codec->id == AV_CODEC_ID_BINKAUDIO_RDFT)
|
2375
|
492 root = 2.0 / (sqrt(float(frame_len)) * 32768.0);
|
2356
|
493 else
|
2375
|
494 root = frame_len / (sqrt(float(frame_len)) * 32768.0);
|
2356
|
495 for (i = 0; i < 96; i++)
|
|
496 {
|
|
497 /* constant is result of 0.066399999/log10(M_E) */
|
|
498 quant_table[i] = expf(i * 0.15289164787221953823f) * root;
|
|
499 }
|
|
500
|
|
501 /* calculate number of bands */
|
|
502 //bands calculation:
|
|
503 //bands[0] = 1;
|
|
504 //foreach (i in 1..# of bands-1):
|
|
505 //bands[i] = crit_freq[i-1] * (frame length / 2) / (sample rate / 2);
|
|
506 //bands[# of bands] = frame length / 2
|
|
507 for (num_bands = 1; num_bands < 25; num_bands++)
|
|
508 if (sample_rate_half <= ff_wma_critical_freqs[num_bands - 1])
|
|
509 break;
|
|
510
|
|
511 bands = (unsigned int *)(av_malloc((num_bands + 1) * sizeof(*bands)));
|
|
512 if (!bands)
|
|
513 return AVERROR(ENOMEM);
|
|
514
|
|
515 /* populate bands data */
|
|
516 bands[0] = 2;
|
|
517 for (i = 1; i < num_bands; i++)
|
|
518 bands[i] = (ff_wma_critical_freqs[i - 1] * frame_len / sample_rate_half) & ~1;
|
|
519 bands[num_bands] = frame_len;
|
|
520
|
|
521 first = 1;
|
|
522
|
|
523 //ff_rdft_init(&trans.rdft, frame_len_bits, DFT_C2R);
|
|
524
|
|
525 avcodec_get_frame_defaults(&frame);
|
|
526 dec_ctx->coded_frame = &frame;
|
2315
|
527 }
|
|
528 break;
|
|
529 /*
|
|
530 case AV_CODEC_ID_SMACKAUDIO:
|
|
531 {
|
|
532 static int smack_debug_next_audio_time = 0;
|
|
533 if (smack_debug_next_audio_time != packet->pts)
|
|
534 {
|
|
535 Error("There's a gap in the sound before frame %u\n", num_audio_frames);
|
|
536 __debugbreak(); // there's a gap in the sound
|
|
537 }
|
|
538
|
|
539 int num_actual_data_channels = 0;
|
|
540 switch (dec_ctx->sample_fmt)
|
|
541 {
|
|
542 case AV_SAMPLE_FMT_U8:
|
|
543 case AV_SAMPLE_FMT_S16:
|
|
544 case AV_SAMPLE_FMT_S32:
|
|
545 case AV_SAMPLE_FMT_FLT:
|
|
546 case AV_SAMPLE_FMT_DBL:
|
|
547 num_actual_data_channels = 1;
|
|
548 break;
|
|
549
|
|
550 case AV_SAMPLE_FMT_U8P:
|
|
551 case AV_SAMPLE_FMT_S16P:
|
|
552 case AV_SAMPLE_FMT_S32P:
|
|
553 case AV_SAMPLE_FMT_FLTP:
|
|
554 case AV_SAMPLE_FMT_DBLP:
|
|
555 num_actual_data_channels = dec_ctx->channels;
|
|
556 break;
|
|
557
|
|
558 default:
|
|
559 case AV_SAMPLE_FMT_NONE:
|
|
560 case AV_SAMPLE_FMT_NB:
|
|
561 __debugbreak();
|
|
562 }
|
|
563
|
|
564 smack_debug_next_audio_time += dec_ctx->channels * frame->nb_samples * bytes_per_sample;
|
|
565 Assert(frame->avframe->linesize[0] == audio.dec_ctx->channels * frame->avframe->nb_samples * audio.bytes_per_sample / num_actual_data_channels,
|
|
566 "Smack audio size mismatch in frame %u in %s\n", audio_num_read_frames, movie_filename);
|
|
567
|
|
568 frame->play_time = (double)frame->avpacket->pts / (double)audio.bytes_per_second;
|
|
569 }
|
|
570 break;
|
|
571
|
|
572 case AV_CODEC_ID_MP3:
|
|
573 {
|
|
574 static int mp3_samples_decoded_so_far = 0;
|
|
575 static int mp3_prev_samples_count = frame->avframe->nb_samples; // mp3 seems to always feed same amount of samples
|
|
576 frame->play_time = (double)mp3_samples_decoded_so_far / (double)audio.dec_ctx->sample_rate;
|
|
577
|
|
578 mp3_samples_decoded_so_far += frame->avframe->nb_samples;
|
|
579 Assert(mp3_prev_samples_count == frame->avframe->nb_samples,
|
|
580 "MP3 audio have variable sample count in frame %u in %s\n", audio_num_read_frames, movie_filename);
|
|
581 }
|
|
582 break;
|
|
583
|
|
584 default:
|
|
585 {
|
|
586 __debugbreak();
|
|
587 double samples_per_second = (double)audio.dec_ctx->time_base.den / (double)audio.dec_ctx->time_base.num;
|
|
588 double play_length = frame->avframe->nb_samples / samples_per_second;
|
|
589 frame->play_time = (double)frame->avpacket->pts / samples_per_second;
|
|
590 }
|
|
591 break;*/
|
|
592 }
|
|
593
|
|
594 if (!avframe->channel_layout)
|
|
595 {
|
|
596 log("Audio channel layout not specified, rolling back to default\n");
|
|
597 avframe->channel_layout = av_get_default_channel_layout(dec_ctx->channels);
|
|
598 }
|
|
599
|
|
600 *out_num_audio_samples = dec_ctx->channels * avframe->nb_samples;
|
|
601 InterleaveAudioData(out_audio_data, dec_ctx->sample_fmt,
|
|
602 dec_ctx->channels, avframe->nb_samples, avframe->data);
|
|
603 return true;
|
|
604 }
|
|
605
|
|
606 bool LoadAudioTrack(AVFormatContext *format_ctx, AVCodecContext *dec_ctx, int audio_stream_idx, MemoryStream *out_audio_stream, int *out_num_audio_frames, int *out_num_audio_samples)
|
|
607 {
|
|
608 out_audio_stream->Reset();
|
|
609
|
2347
|
610 // .
|
|
611 // (AVPacket), (AVFrame).
|
|
612
|
|
613 //
|
2315
|
614 AVFrame *frame = avcodec_alloc_frame();
|
2347
|
615
|
2315
|
616 AVPacket *packet = new AVPacket;
|
|
617 av_init_packet(packet);
|
|
618
|
|
619 int num_audio_frames = 0;
|
|
620 int num_audio_samples = 0;
|
2347
|
621
|
2345
|
622 //
|
2315
|
623 while (av_read_frame(format_ctx, packet) >= 0)
|
|
624 {
|
2347
|
625 // Is this a packet from the audio stream?
|
2345
|
626 //
|
2315
|
627 if (packet->stream_index != audio_stream_idx)
|
|
628 {
|
|
629 //log("Suspicious stream id %u in %s", packet->stream_index, filenamea);
|
|
630 continue;
|
|
631 }
|
|
632
|
2347
|
633 // Decode audio frame
|
|
634 //
|
2315
|
635 int num_samples_decoded;
|
|
636 DecodeAudioFrame(dec_ctx, packet, frame, out_audio_stream, &num_samples_decoded);
|
|
637
|
|
638 num_audio_samples += num_samples_decoded;
|
|
639 num_audio_frames++;
|
|
640 }
|
|
641 *out_num_audio_frames = num_audio_frames;
|
|
642 *out_num_audio_samples = num_audio_samples;
|
|
643
|
2347
|
644 //
|
2315
|
645 avcodec_free_frame(&frame);
|
2361
|
646 delete frame;
|
|
647 av_free_packet(packet);
|
2315
|
648 delete packet;
|
|
649
|
|
650 return true;
|
|
651 }
|
|
652
|
|
653 class Track: public Media::ITrack
|
|
654 {
|
|
655 public:
|
|
656 inline Track()
|
|
657 {
|
|
658 this->format_ctx = nullptr;
|
|
659 this->audio_num_samples = 0;
|
|
660 }
|
|
661
|
|
662 void Release()
|
|
663 {
|
|
664 ReleaseAvcodec();
|
|
665 }
|
|
666
|
|
667 void ReleaseAvcodec()
|
|
668 {
|
|
669 audio.Release();
|
|
670 if (format_ctx)
|
|
671 {
|
2345
|
672 //
|
2315
|
673 av_close_input_file(format_ctx);
|
|
674 format_ctx = nullptr;
|
|
675 }
|
|
676 }
|
|
677
|
2347
|
678 bool LoadAudio(const wchar_t *filename) // mp3
|
2315
|
679 {
|
|
680 char filenamea[1024];
|
|
681 sprintf(filenamea, "%S", filename);
|
2347
|
682 // Open audio file
|
|
683 // ( 2)
|
|
684 // avformat_open_input
|
|
685 //AVFormatContext. NULL, libavformat
|
|
686 // .
|
2315
|
687 if (avformat_open_input(&format_ctx, filenamea, nullptr, nullptr) >= 0)
|
|
688 {
|
2347
|
689 // Retrieve stream information
|
|
690 //.. avformat_open_input ,
|
|
691 // . avformat_find_stream_info.
|
2315
|
692 if (avformat_find_stream_info(format_ctx, nullptr) >= 0)
|
|
693 {
|
2347
|
694 // Dump information about file onto standard error
|
|
695 // format_context->streams .
|
|
696 // format_context->nb_streams.
|
|
697 // av_dump_format.
|
2315
|
698 av_dump_format(format_ctx, 0, filenamea, 0);
|
|
699
|
2347
|
700 //
|
2315
|
701 if (!av_open_audio_stream(format_ctx, &audio))
|
|
702 {
|
|
703 Error("Cannot open strack: %s", filenamea);
|
|
704 return Release(), false;
|
|
705 }
|
|
706
|
|
707 MemoryStream audio_plain_data;
|
|
708 int num_audio_frames;
|
|
709 int num_audio_samples;
|
2347
|
710
|
|
711 //
|
2315
|
712 if (LoadAudioTrack(format_ctx, audio.dec_ctx, audio.stream_idx, &audio_plain_data, &num_audio_frames, &num_audio_samples))
|
|
713 {
|
|
714 /*#ifdef _DEBUG
|
|
715 char debug_filename[1024];
|
|
716 sprintf(debug_filename, "%s.wav", filenamea);
|
|
717 FILE *wav = fopen(debug_filename, "w+b");
|
|
718
|
|
719 extern void write_wav_header(FILE *wav, int channel_count = 2, int sample_rate = 22050, int bytes_per_sample = 2);
|
|
720 write_wav_header(wav, audio.dec_ctx->channels, audio.dec_ctx->sample_rate, audio.bytes_per_sample);
|
|
721
|
|
722 fwrite(audio_plain_data.Ptr(), audio_plain_data.Current(), 1, wav);
|
|
723
|
|
724 extern void fix_wav_header(FILE *wav, int wav_bytes_in_stream);
|
|
725 fix_wav_header(wav, audio_plain_data.Current());
|
|
726 #endif*/
|
|
727
|
|
728 device_buffer = provider->CreateTrack16(audio.dec_ctx->channels, audio.dec_ctx->sample_rate, 2, num_audio_samples, audio_plain_data.Ptr());
|
|
729
|
|
730 ReleaseAvcodec();
|
|
731 return true;
|
|
732 }
|
|
733 }
|
|
734 Release();
|
2347
|
735 fprintf(stderr, "ffmpeg: Unable to find stream info\n"); //
|
2345
|
736 return false;
|
2315
|
737 }
|
2347
|
738 fprintf(stderr, "ffmpeg: Unable to open input file\n"); //
|
2315
|
739 return false;
|
|
740 }
|
|
741
|
|
742 virtual void Play(bool loop)
|
|
743 {
|
|
744 provider->PlayTrack16(device_buffer, loop);
|
2359
|
745 mSourceID = device_buffer->source_id;
|
2315
|
746 }
|
2347
|
747
|
2315
|
748 protected:
|
|
749 AVFormatContext *format_ctx;
|
|
750 AVAudioStream audio;
|
|
751 int audio_num_samples;
|
|
752
|
2345
|
753 bool stopped;
|
|
754
|
2315
|
755 OpenALSoundProvider::TrackBuffer *device_buffer;
|
|
756 };
|
|
757
|
|
758 class Movie: public Media::IMovie
|
|
759 {
|
|
760 public:
|
|
761 inline Movie()
|
|
762 {
|
|
763 this->movie_filename[0] = 0;
|
|
764 this->width = 0;
|
|
765 this->height = 0;
|
|
766 this->format_ctx = nullptr;
|
|
767 this->end_of_file = false;
|
|
768 this->playback_time = 0.0;
|
|
769
|
|
770 this->num_audio_frames = 0;
|
|
771 this->num_audio_samples = 0;
|
|
772
|
|
773 this->last_resampled_frame_num = -1;
|
|
774 memset(last_resampled_frame_data, 0, sizeof(last_resampled_frame_data));
|
|
775 memset(last_resampled_frame_linesize, 0, sizeof(last_resampled_frame_linesize));
|
2345
|
776
|
2361
|
777 decoding_packet = nullptr;
|
2345
|
778 ioBuffer = nullptr;
|
|
779 format_ctx = nullptr;
|
|
780 avioContext = nullptr;
|
2315
|
781 }
|
2347
|
782
|
2315
|
783 inline void Release()
|
|
784 {
|
|
785 ReleaseAVCodec();
|
|
786 }
|
|
787
|
|
788 inline void ReleaseAVCodec()
|
|
789 {
|
|
790 audio.Release();
|
|
791 video.Release();
|
2361
|
792
|
2315
|
793 if (format_ctx)
|
|
794 {
|
2347
|
795 // Close the video file
|
|
796 // ( )
|
2315
|
797 av_close_input_file(format_ctx);
|
|
798 format_ctx = nullptr;
|
2360
|
799 }
|
|
800 if(avioContext)
|
|
801 {
|
|
802 av_free(avioContext);
|
|
803 avioContext = nullptr;
|
|
804 }
|
|
805 if (ioBuffer)
|
|
806 {
|
2361
|
807 //av_free(ioBuffer);
|
2360
|
808 ioBuffer = nullptr;
|
2315
|
809 }
|
2361
|
810 av_free_packet(decoding_packet);
|
2360
|
811 delete decoding_packet;
|
2361
|
812 avcodec_free_frame(&decoding_frame);
|
|
813 delete decoding_frame;
|
|
814 if (last_resampled_frame_data[0])
|
|
815 av_freep(&last_resampled_frame_data[0]);
|
2315
|
816 }
|
|
817
|
2347
|
818 bool Load(const wchar_t *filename, int dst_width, int dst_height, int cache_ms) //
|
2315
|
819 {
|
|
820 char filenamea[1024];
|
|
821 sprintf(filenamea, "%S", filename);
|
|
822 sprintf(movie_filename, "%S", filename);
|
|
823
|
|
824 width = dst_width;
|
|
825 height = dst_height;
|
2347
|
826 // Open video file
|
|
827 // ( 2)
|
|
828 // avformat_open_input
|
|
829 //AVFormatContext. NULL, libavformat
|
|
830 // . 2 .
|
2315
|
831 if (avformat_open_input(&format_ctx, filenamea, nullptr, nullptr) >= 0)
|
|
832 {
|
2347
|
833 // Retrieve stream information
|
|
834 //
|
|
835 //.. avformat_open_input ,
|
|
836 // . avformat_find_stream_info.( 3)
|
2315
|
837 if (avformat_find_stream_info(format_ctx, nullptr) >= 0)
|
|
838 {
|
2347
|
839 // Dump information about file onto standard error
|
|
840 // pFormatCtx->streams
|
|
841 // format_context->streams .
|
|
842 // format_context->nb_streams.
|
|
843 // av_dump_format.
|
2315
|
844 av_dump_format(format_ctx, 0, filenamea, 0);
|
|
845
|
2347
|
846 //pFormatCtx->streams - , pFormatCtx->nb_streams, .
|
2315
|
847 if (!av_open_audio_stream(format_ctx, &audio))
|
|
848 {
|
|
849 Error("Cannot open audio stream: %s", filenamea);
|
|
850 return Release(), false;
|
|
851 }
|
|
852
|
|
853 if (!av_open_video_stream(format_ctx, &video))
|
|
854 {
|
|
855 Error("Cannot open video stream: %s", filenamea);
|
|
856 return Release(), false;
|
|
857 }
|
2347
|
858
|
|
859 //Ritor1: include
|
|
860 if (_stricmp("binkvideo", video.dec->name) )
|
|
861 {
|
2345
|
862 current_movie_width = video.dec_ctx->width;
|
|
863 current_movie_height = video.dec_ctx->height;
|
2347
|
864 }
|
|
865 else
|
|
866 {
|
2345
|
867 current_movie_width = width;
|
|
868 current_movie_height = height;
|
2347
|
869 }
|
|
870 //
|
2315
|
871 decoding_packet = new AVPacket;
|
|
872 av_init_packet(decoding_packet);
|
|
873
|
2347
|
874 // Allocate video frame
|
|
875 //
|
2315
|
876 decoding_frame = avcodec_alloc_frame();
|
|
877
|
|
878 audio_data_in_device = provider->CreateStreamingTrack16(audio.dec_ctx->channels, audio.dec_ctx->sample_rate, 2);
|
|
879
|
|
880 return true;
|
|
881 }
|
2345
|
882 fprintf(stderr, "ffmpeg: Unable to find stream info\n");
|
2347
|
883 return Release(), false; //
|
2315
|
884 }
|
2345
|
885 fprintf(stderr, "ffmpeg: Unable to open input file\n");
|
2347
|
886 return Release(), false; //
|
2315
|
887 }
|
2347
|
888
|
2345
|
889 bool LoadFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height)
|
|
890 {
|
|
891 if (!ioBuffer)
|
2360
|
892 ioBuffer = (unsigned char *)av_malloc(0x4000 + FF_INPUT_BUFFER_PADDING_SIZE); // can get av_free()ed by libav
|
2345
|
893 if (!avioContext)
|
2360
|
894 avioContext = avio_alloc_context(ioBuffer, 0x4000, 0, h, readFunction, NULL, seekFunction);
|
2345
|
895 if (!format_ctx)
|
|
896 format_ctx = avformat_alloc_context();
|
|
897 format_ctx->pb = avioContext;
|
|
898 return Load(L"dummyFilename", width, height, 0);
|
|
899 }
|
|
900
|
2347
|
901 virtual void GetNextFrame(double dt, void *dst_surface)//
|
2315
|
902 {
|
2319
|
903 playback_time += dt;//
|
2315
|
904
|
2347
|
905 // (AVPacket), (AVFrame).
|
2315
|
906 AVPacket *avpacket = decoding_packet;
|
|
907 AVFrame *avframe = decoding_frame;
|
2347
|
908
|
2360
|
909 // avframe
|
2315
|
910 avcodec_get_frame_defaults(avframe);
|
|
911
|
|
912 int desired_frame_number = floor(playback_time * video.dec_ctx->time_base.den / video.dec_ctx->time_base.num + 0.5);
|
|
913 if (last_resampled_frame_num == desired_frame_number)
|
|
914 {
|
2360
|
915 memcpy(dst_surface, last_resampled_frame_data[0], current_movie_height * last_resampled_frame_linesize[0]);
|
2315
|
916 return;
|
|
917 }
|
|
918
|
2347
|
919 volatile int frameFinished = false;
|
2360
|
920
|
|
921 //
|
|
922 // keep reading packets until we hit the end or find a video packet
|
2359
|
923 do
|
2315
|
924 {
|
2360
|
925 if (loop_current_file)
|
|
926 {
|
|
927 //Now seek back to the beginning of the stream
|
|
928 if (video.dec_ctx->frame_number >= video.stream->duration - 1 )
|
2361
|
929 end_current_file = true;
|
2360
|
930 }
|
2359
|
931 if (av_read_frame(format_ctx, avpacket) < 0) //
|
|
932 {
|
|
933 // probably movie is finished
|
2360
|
934 end_current_file = true;
|
2361
|
935 av_free_packet(avpacket);
|
2360
|
936 return;
|
2359
|
937 }
|
2360
|
938 // Is this a packet from the video stream?
|
|
939 // audio packet - queue into playing
|
|
940 //
|
2315
|
941 if (avpacket->stream_index == audio.stream_idx)
|
|
942 {
|
|
943 MemoryStream audio_data;
|
|
944 if (DecodeAudioFrame(audio.dec_ctx, avpacket, avframe, &audio_data, &num_audio_samples))
|
2359
|
945 provider->Stream16(audio_data_in_device, num_audio_samples, audio_data.Ptr());
|
|
946 //continue;
|
2315
|
947 }
|
2360
|
948
|
|
949 // Decode video frame
|
|
950 //
|
2359
|
951 // video packet - decode & maybe show
|
2315
|
952 else if (avpacket->stream_index == video.stream_idx)
|
|
953 {
|
2359
|
954 do
|
2315
|
955 {
|
2360
|
956 // avcodec_decode_video2 ,
|
|
957 // (codec_context). frame_finished
|
|
958 // ( frame_finished
|
|
959 // ).
|
2359
|
960 if (avcodec_decode_video2(video.dec_ctx, avframe, (int *)&frameFinished, avpacket) < 0)
|
|
961 __debugbreak();
|
|
962 } while (!frameFinished);
|
|
963 }
|
|
964 }
|
|
965 while (avpacket->stream_index != video.stream_idx ||
|
|
966 avpacket->pts != desired_frame_number);
|
|
967
|
|
968 if (frameFinished)
|
|
969 {
|
|
970 if (last_resampled_frame_data[0])
|
|
971 av_freep(&last_resampled_frame_data[0]);
|
2315
|
972
|
2359
|
973 AVPixelFormat rescaled_format = AV_PIX_FMT_RGB32;
|
|
974 uint8_t *rescaled_data[4] = {nullptr, nullptr, nullptr, nullptr};
|
|
975 int rescaled_linesize[4] = {0, 0, 0, 0};
|
2361
|
976
|
2359
|
977 if (av_image_alloc(rescaled_data, rescaled_linesize, current_movie_width, current_movie_height, rescaled_format, 1) >= 0)
|
|
978 {
|
|
979 //
|
|
980 SwsContext *converter = sws_getContext(avframe->width, avframe->height, (AVPixelFormat)avframe->format,
|
|
981 current_movie_width, current_movie_height, rescaled_format,
|
|
982 SWS_BICUBIC, nullptr, nullptr, nullptr);
|
|
983 // ()
|
|
984 sws_scale(converter, avframe->data, avframe->linesize, 0, avframe->height, rescaled_data, rescaled_linesize);
|
|
985 sws_freeContext(converter);
|
2315
|
986
|
2359
|
987 //
|
|
988 memcpy(dst_surface, rescaled_data[0], current_movie_height * rescaled_linesize[0]);
|
|
989
|
|
990 last_resampled_frame_num = desired_frame_number;
|
|
991 memcpy(last_resampled_frame_data, rescaled_data, sizeof(rescaled_data));
|
|
992 memcpy(last_resampled_frame_linesize, rescaled_linesize, sizeof(rescaled_linesize));
|
2361
|
993 // av_freep(&rescaled_data[0]);
|
2315
|
994 }
|
|
995 }
|
|
996 else
|
2359
|
997 memset(dst_surface, 0, width * current_movie_height * 4);
|
2361
|
998
|
|
999 // Free the packet that was allocated by av_read_frame
|
|
1000 av_free_packet(avpacket);
|
2315
|
1001 }
|
|
1002
|
2347
|
1003 virtual void Play()
|
|
1004 {
|
|
1005 }
|
2345
|
1006
|
2315
|
1007 protected:
|
|
1008 char movie_filename[256];
|
|
1009 int width;
|
|
1010 int height;
|
2345
|
1011 bool stopped;
|
2315
|
1012 AVFormatContext *format_ctx;
|
|
1013 double playback_time;
|
|
1014 bool end_of_file;
|
|
1015
|
|
1016 AVPacket *decoding_packet;
|
|
1017 AVFrame *decoding_frame;
|
|
1018
|
|
1019 AVAudioStream audio;
|
|
1020 int num_audio_frames;
|
|
1021 int num_audio_samples;
|
2345
|
1022 unsigned char * ioBuffer;
|
|
1023 AVIOContext *avioContext;
|
2315
|
1024 OpenALSoundProvider::StreamingTrackBuffer *audio_data_in_device;
|
|
1025
|
|
1026 AVVideoStream video;
|
|
1027 int last_resampled_frame_num;
|
|
1028 uint8_t *last_resampled_frame_data[4];
|
|
1029 int last_resampled_frame_linesize[4];
|
2347
|
1030 };
|
2315
|
1031
|
2356
|
1032 ITrack *MPlayer::LoadTrack(const wchar_t *filename) // mp3
|
2315
|
1033 {
|
|
1034 auto track = new Track;
|
2347
|
1035 if (!track->LoadAudio(filename))
|
2315
|
1036 {
|
|
1037 delete track;
|
|
1038 track = nullptr;
|
|
1039 }
|
|
1040 return track;
|
|
1041 }
|
|
1042
|
2356
|
1043 IMovie *MPlayer::LoadMovie(const wchar_t *filename, int width, int height, int cache_ms) //
|
2315
|
1044 {
|
2360
|
1045 movie = new Movie;
|
2315
|
1046 if (!movie->Load(filename, width, height, cache_ms))
|
|
1047 {
|
|
1048 delete movie;
|
|
1049 movie = nullptr;
|
|
1050 }
|
|
1051 return movie;
|
|
1052 }
|
|
1053
|
2356
|
1054 IMovie *MPlayer::LoadMovieFromLOD(HANDLE h, int readFunction(void*, uint8_t*, int), int64_t seekFunction(void*, int64_t, int), int width, int height)
|
2347
|
1055 {
|
2360
|
1056 movie = new Movie;
|
2347
|
1057 if (movie)
|
|
1058 {
|
|
1059 if (movie->LoadFromLOD(h, readFunction, seekFunction, width, height))
|
|
1060 return movie;
|
|
1061 delete movie;
|
|
1062 }
|
|
1063 return nullptr;
|
|
1064 }
|
2315
|
1065
|
|
1066 void av_logger(void *, int, const char *format, va_list args)
|
|
1067 {
|
|
1068 va_list va;
|
|
1069 va_start(va, format);
|
|
1070 char msg[256];
|
|
1071 vsprintf(msg, format, va);
|
|
1072 va_end(va);
|
|
1073
|
|
1074 log("av: %s", msg);
|
|
1075 }
|
|
1076
|
2356
|
1077 MPlayer::MPlayer()
|
2315
|
1078 {
|
|
1079 static int libavcodec_initialized = false;
|
|
1080
|
|
1081 if (!libavcodec_initialized)
|
|
1082 {
|
|
1083 av_log_set_callback(av_logger);
|
|
1084 avcodec_register_all();
|
2345
|
1085
|
2347
|
1086 // Register all available file formats and codecs
|
|
1087 // ffmpeg( 1)
|
|
1088 // .
|
|
1089 // .
|
2315
|
1090 av_register_all();
|
|
1091
|
|
1092 libavcodec_initialized = true;
|
|
1093 }
|
|
1094
|
|
1095 if (!provider)
|
|
1096 {
|
|
1097 provider = new OpenALSoundProvider;
|
|
1098 provider->Initialize();
|
|
1099 }
|
|
1100 }
|
|
1101
|
2356
|
1102 MPlayer::~MPlayer()
|
2315
|
1103 {
|
2345
|
1104 }
|
2356
|
1105
|
|
1106 void PlayAudio(const wchar_t * pFilename)
|
|
1107 {
|
|
1108 pTrack = pMediaPlayer->LoadTrack(pFilename);
|
|
1109 pTrack->Play();
|
|
1110 }
|
|
1111
|
|
1112 void PlayMovie(const wchar_t * pFilename)
|
|
1113 {
|
|
1114 Media::IMovie *track = pMediaPlayer->LoadMovie(pFilename, 640, 480, 0);
|
|
1115 track->Play();
|
|
1116 }
|
|
1117
|
2360
|
1118 void MovieRelease()
|
|
1119 {
|
|
1120 movie->Release();
|
|
1121 delete movie;
|
|
1122 movie = nullptr;
|
|
1123 }
|
|
1124
|
2356
|
1125 //////////////////////////////////////////////////////////////////////////
|
|
1126 //Included from a VideoPlayer.cpp file/ VideoPlayer.cpp/
|
|
1127 //////////////////////////////////////////////////////////////////////////
|
|
1128
|
|
1129 //used in void VideoPlayer::Initialize(OSWindow *target_window) for open .vid files
|
|
1130 MovieHeader *pMightVideoHeaders;
|
|
1131 MovieHeader *pMagicVideoHeaders;
|
|
1132 HANDLE hMightVid;
|
|
1133 HANDLE hMagicVid;
|
|
1134 unsigned __int64 uBinkVersion;
|
|
1135 unsigned int uNumMightVideoHeaders;
|
|
1136 unsigned int uNumMagicVideoHeaders;
|
|
1137 //
|
|
1138
|