Source

pygame / src / gmovie.c

Full commit
zeroth 13725f8 

zeroth afc0e11 
zeroth 13725f8 
zeroth 95110a5 


zeroth cdd6aaf 





zeroth 95110a5 









zeroth 4e0f348 





















zeroth 95110a5 

zeroth 7386f74 
zeroth 95110a5 


zeroth 13725f8 
zeroth afc0e11 
zeroth fd164a2 
zeroth 95110a5 


zeroth 13725f8 

zeroth b5d1562 
zeroth 2031a59 
zeroth 13725f8 
zeroth 95110a5 



zeroth 13725f8 

zeroth 95110a5 
zeroth bbc6278 
zeroth cdd6aaf 
zeroth 37e8f95 
zeroth bbc6278 
zeroth 95110a5 

zeroth bbc6278 


zeroth 95110a5 
zeroth bbc6278 
zeroth 95110a5 
zeroth 13725f8 
zeroth fd164a2 
zeroth 13725f8 



zeroth fd164a2 
zeroth 13725f8 







zeroth 23c6a90 
zeroth 13725f8 
zeroth 95110a5 
zeroth 13725f8 
zeroth 94d0920 
zeroth 13725f8 
zeroth 8480a42 
zeroth db1a1b8 


zeroth 6933dad 
zeroth 8480a42 











zeroth 6933dad 


zeroth db1a1b8 
zeroth 13725f8 


zeroth 94d0920 

zeroth 95110a5 






































zeroth 94d0920 


zeroth 13725f8 


zeroth 94d0920 


zeroth fd164a2 
zeroth db1a1b8 
zeroth fd164a2 
zeroth 13725f8 
zeroth 2031a59 
zeroth 13725f8 
zeroth 95110a5 









zeroth db1a1b8 
zeroth 95110a5 







zeroth 23c6a90 
zeroth 13725f8 


zeroth 95110a5 
zeroth 13725f8 
zeroth 95110a5 
zeroth 7dd4689 

zeroth 93e070f 

zeroth cdd6aaf 
zeroth 7dd4689 
zeroth 95110a5 
zeroth 13725f8 

zeroth cc50f85 
zeroth 13725f8 

zeroth 95110a5 


zeroth 13725f8 



zeroth 2031a59 
zeroth 13725f8 
zeroth 48a2aa6 
zeroth 71090b3 
zeroth cdd6aaf 
zeroth 13725f8 
zeroth 95110a5 
zeroth 13725f8 
zeroth 2031a59 
zeroth 13725f8 
zeroth 95110a5 

zeroth 13725f8 


zeroth 2031a59 
zeroth 13725f8 




zeroth cdea134 

zeroth 95110a5 








zeroth 176b671 



zeroth 71090b3 
zeroth cdd6aaf 



zeroth 95110a5 

zeroth cdea134 
zeroth 91ba9c5 
zeroth 3d4d167 







zeroth 71090b3 
zeroth 3d4d167 





zeroth 71090b3 
zeroth 91ba9c5 
zeroth 19252bb 




zeroth ec60de7 
zeroth 71090b3 

zeroth 19252bb 

























zeroth 91ba9c5 
zeroth 19252bb 
zeroth 2031a59 
zeroth 13725f8 
zeroth bb2ba31 
zeroth 13725f8 
zeroth 76c23a6 
zeroth 13725f8 

zeroth bb2ba31 
zeroth 13725f8 


zeroth 0d198d6 




zeroth 76c23a6 


zeroth 62a1d67 

zeroth 95110a5 














zeroth 62a1d67 


zeroth 95110a5 
zeroth 62a1d67 
zeroth 76c23a6 


zeroth cdea134 

zeroth 95110a5 
zeroth 176b671 
zeroth 95110a5 

zeroth 71090b3 
zeroth cdd6aaf 



zeroth 95110a5 






zeroth cdea134 

zeroth 76c23a6 


zeroth 62a1d67 

zeroth 95110a5 







zeroth 62a1d67 


zeroth 95110a5 
zeroth 62a1d67 
zeroth 76c23a6 

zeroth cdea134 

zeroth 95110a5 
zeroth 176b671 
zeroth 95110a5 

zeroth 71090b3 

zeroth cdd6aaf 


zeroth 95110a5 






zeroth cdea134 

zeroth b2de91d 


















zeroth 71090b3 
zeroth ad8a925 


zeroth b2de91d 


























zeroth 71090b3 
zeroth ad8a925 


zeroth b2de91d 







zeroth 76c23a6 
zeroth bbc6278 

zeroth 95110a5 




zeroth bbc6278 



zeroth 95110a5 
zeroth 3d4d167 
zeroth 95110a5 

zeroth ad8a925 

zeroth 3d4d167 

zeroth ad8a925 

zeroth 95110a5 

zeroth ad8a925 

zeroth 3d4d167 

zeroth ad8a925 



zeroth 95110a5 
zeroth bbc6278 

zeroth 1e7047f 
zeroth 74fd9b7 






zeroth 95110a5 

zeroth 13725f8 
zeroth 1e7047f 
zeroth 95110a5 



zeroth 2031a59 
zeroth 95110a5 
zeroth 74fd9b7 








zeroth 95110a5 
zeroth 13725f8 
zeroth 2031a59 
zeroth 95110a5 



















































zeroth 13725f8 

zeroth bbc6278 
zeroth 13725f8 





zeroth 37e8f95 
zeroth 95110a5 

zeroth 13725f8 



zeroth 95110a5 














zeroth 13725f8 
zeroth 95110a5 
zeroth 13725f8 
zeroth 95110a5 



















zeroth 13725f8 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
#include "gmovie.h"

void _movie_init_internal(PyMovie *self, const char *filename, SDL_Surface *surf)
{
    Py_INCREF(self);
    //already malloced memory for PyMovie.
    self->_backend="FFMPEG_WRAPPER";
    self->commands = (CommandQueue *)PyMem_Malloc(sizeof(CommandQueue));
    self->commands->q_mutex = SDL_CreateMutex();
	self->commands->size=0;
	self->commands->reg_ix=0;
	registerCommands(self);
    self->commands->size=0;
    if(!surf)
    {
        //set overlay to true
        self->overlay = 1;
    }
    else
    {
        self->overlay = 0;
        self->canon_surf=surf;
    }
    /* filename checking... */
    PyObject *path = PyImport_ImportModule("os.path");
    Py_INCREF(path);
    PyObject *dict = PyModule_GetDict(path);
    PyObject *key = Py_BuildValue("s", "exists");
    Py_INCREF(key);
	PyObject *existsFunc  = PyDict_GetItem(dict, key);
	PyObject *boolean = PyObject_CallFunction(existsFunc, "s", filename);
	Py_INCREF(boolean);
	if(boolean==Py_False)
	{
		Py_DECREF(boolean);
		Py_DECREF(key);
		Py_DECREF(path);
		RAISE(PyExc_ValueError, "This filename does not exist.");
		return;
		//Py_RETURN_NONE;
	}
	Py_DECREF(boolean);
	Py_DECREF(key);
	Py_DECREF(path);    
    
    self->start_time = AV_NOPTS_VALUE;
    stream_open(self, filename, NULL, 0);
    //PySys_WriteStdout("Time-base-a: %f\n", av_q2d(self->audio_st->codec->time_base));
    if(!self)
    {
        PyErr_SetString(PyExc_IOError, "stream_open failed");
        Py_DECREF(self);
        return;
    }
    //PySys_WriteStdout("Movie->filename: %s\n", self->filename);
    Py_DECREF(self);
    return;
}


int _movie_init(PyObject *self, PyObject *args, PyObject *kwds)
{
    Py_INCREF(self);
    const char *c;
    PyObject *surf;
    if (!PyArg_ParseTuple (args, "s|O", &c, &surf))
    {
        PyErr_SetString(PyExc_TypeError, "No valid arguments");
        return -1;
    }
	
    if(surf && PySurface_Check(surf))
    {
        SDL_Surface *target = PySurface_AsSurface(surf);
        _movie_init_internal((PyMovie *)self, c, target);
    }
    else
    {
        _movie_init_internal((PyMovie *)self, c, NULL);
    }
    PyObject *er;
    er = PyErr_Occurred();
    Py_XINCREF(er);
    if(er)
    {
        PyErr_Print();
    }
    Py_XDECREF(er);
    if(!self)
    {
        PyErr_SetString(PyExc_IOError, "No movie object created.");
        PyErr_Print();
        Py_DECREF(self);
        return -1;
    }
    Py_DECREF(self);
    //PySys_WriteStdout("Returning from _movie_init\n");
    return 0;
}

void _movie_dealloc(PyMovie *movie)
{
	//PySys_WriteStdout("Deleting\n");
	if(movie->_tstate)
	{
		PyThreadState_Clear(movie->_tstate);
		//PyThreadState_Delete(movie->_tstate);
	}
	#ifdef PROFILE
		TimeSampleNode *cur = movie->istats->first;
		TimeSampleNode *prev;
		while(cur!=NULL) 
    	{
    		prev=cur;
    		cur=cur->next;
			PyMem_Free(prev);
    	}
    	PyMem_Free(movie->istats);
    #endif
    SDL_DestroyMutex(movie->commands->q_mutex);
    PyMem_Free(movie->commands);
    movie->commands=NULL;
	stream_close(movie, 0);
    movie->ob_type->tp_free((PyObject *) movie);
}

char *format_timestamp(double pts, char *buf)
{
    int h, m;
    double s;
    if(pts/60 > 60)
    {
        h = (int)pts/3600;
        pts = pts-h*3600;
    }
    else
    {
        h=0;
    }
    m=(int)pts/60;
    if(m>0)
    {
        s = pts-m*60;
    }
    else
    {
        s = pts;
        m=0;
    }
    //char buf[50];
    if(h>0 && m>0)
    {
        PyOS_snprintf(buf, sizeof(buf), "%i:%i:%fs", h, m, s);
    }
    else if (m>0)
    {
        PyOS_snprintf(buf, sizeof(buf), "%i:%fs", m, s);
    }
    else if(s>0)
    {
        PyOS_snprintf(buf, sizeof(buf), "%fs", s);
    }
    else
    {
        PyOS_snprintf(buf, sizeof(buf), "0.0s");
    }
    return buf;
}

PyObject* _movie_repr (PyMovie *movie)
{
    /*Eventually add a time-code call */
    Py_INCREF(movie);
    char buf[150];
    char buf2[50];
    PyOS_snprintf(buf, sizeof(buf), "(Movie: %s, %s)", movie->filename, format_timestamp(movie->pts, buf2));
    PyObject *buffer = PyString_FromString(buf);
    Py_DECREF(movie);
    return buffer;
}
PyObject* _movie_play(PyMovie *movie, PyObject* args)
{
    PyEval_InitThreads();
    if(movie->playing)
    {
        if(movie->paused)
        {
            //if we've called this after we paused n times where n is odd, then we unpause the movie
            _movie_pause(movie);
        }
        //indicating we've called play again before its finished
    }
    else if(movie->_tstate==NULL)
    {
        PyInterpreterState *interp;
        PyThreadState *thread;
        thread=PyThreadState_Get();
        interp = thread->interp;
        movie->_tstate = PyThreadState_New(interp);
    }
    Py_INCREF(movie);
    //PySys_WriteStdout("Inside .play\n");
    int loops;
    if(!PyArg_ParseTuple(args, "i", &loops))
    {
        loops = 0;
    }
    //movie has been stopped, need to close down streams and that.
    if(movie->stop)
    {
    	//first we release the GIL, then we release all the resources associated with the streams, if they exist.
    	PyEval_ReleaseLock();
		_movie_stop(movie);
    }

    SDL_LockMutex(movie->dest_mutex);
    movie->loops =loops;
    movie->paused = 0;
    movie->playing = 1;
    SDL_UnlockMutex(movie->dest_mutex);
    Py_BEGIN_ALLOW_THREADS
    movie->parse_tid = SDL_CreateThread(decoder_wrapper, movie);
    Py_END_ALLOW_THREADS
    Py_DECREF(movie);
    Py_RETURN_NONE;
}

PyObject* _movie_stop(PyMovie *movie)
{
    //stream_pause(movie);
    ALLOC_COMMAND(stopCommand, stop);
    addCommand(movie->commands, (Command *)stop);
    Py_RETURN_NONE;
}

PyObject* _movie_pause(PyMovie *movie)
{

    stream_pause(movie);
    Py_RETURN_NONE;
}

PyObject* _movie_rewind(PyMovie *movie, PyObject* args)
{
    /* For now, just alias rewind to stop */
    return _movie_stop(movie);
}

PyObject* _movie_resize       (PyMovie *movie, PyObject* args)
{
    int w, h;
    if(PyArg_ParseTuple(args, "ii", &w, &h)<0)
    {
        return NULL;
    }
    if(w<0 || h<0)
    {
        return RAISE (PyExc_SDLError, "Cannot set negative sized display mode");
    }
    if(movie->canon_surf)
    {
    	Py_RETURN_NONE;
    }
    ALLOC_COMMAND(resizeCommand, resize);
    
    resize->h = h;
    resize->w  = w;
    addCommand(movie->commands, (Command *)resize);
    Py_RETURN_NONE;

}

PyObject *_movie_shift(PyMovie *movie, PyObject*args)
{
	int x=0;
	int y=0;
	if(PyArg_ParseTuple(args, "ii", &x, &y)<0)
	{
		return NULL;	
	}
	ALLOC_COMMAND(shiftCommand, shift);
	shift->xleft=x;
	shift->ytop=y;
	addCommand(movie->commands, (Command *)shift);
	Py_RETURN_NONE;
}

PyObject* _movie_easy_seek (PyMovie *movie, PyObject* args)
{
	int64_t pos=0;
	int hour=0;
	int minute=0;
	int second=0;
	int reverse=0;
	//int relative=0;
	//char *keywords[4] = {"second", "minute", "hour", "reverse"};
	if(!PyArg_ParseTuple(args, "iiii", &second, &minute, &hour, &reverse))
	{
		Py_RETURN_NONE;
	}
	if(second)
	{
		pos+=(int64_t)second;
	}
	if(minute)
	{
		pos+=60*(int64_t)minute;
	}
	if(hour)
	{
		pos+=3600*(int64_t)hour;
	}
	if(reverse)
	{
		reverse=-1;
	}
	else
	{
		reverse=1;
	}
	pos *= AV_TIME_BASE;
	stream_seek(movie, pos, reverse);
	Py_RETURN_NONE;
}

PyObject* _movie_get_paused (PyMovie *movie, void *closure)
{
    return PyBool_FromLong((long)movie->paused);
}
PyObject* _movie_get_playing (PyMovie *movie, void *closure)
{
    PyObject *pyo;
    pyo= PyBool_FromLong((long)movie->playing);
    return pyo;
}

PyObject* _movie_get_finished(PyMovie *movie,  void *closure)
{
	return PyBool_FromLong((long)movie->finished);	
}

PyObject* _movie_get_width (PyMovie *movie, void *closure)
{
    PyObject *pyo;
    if(movie->video_st)
    {
        if(movie->resize_w)
        {
            pyo = PyInt_FromLong((long)movie->width);
        }
        else
        {
            if(movie->video_st->codec)
            {
                pyo= PyInt_FromLong((long)movie->video_st->codec->width);
            }
            else
            {
                pyo = PyInt_FromLong((long)0);
            }
        }
    }
    else
    {
        pyo = PyInt_FromLong((long)0);
    }
    return pyo;
}

int _movie_set_width (PyMovie *movie, PyObject *width, void *closure)
{
    int w;
    if(PyInt_Check(width) && !movie->canon_surf)
    {
        w = (int)PyInt_AsLong(width);
        ALLOC_COMMAND(resizeCommand, resize);
    
    	resize->h = 0;
    	resize->w  = w;
		addCommand(movie->commands, (Command *)resize);
        return 0;
    }
    else
    {
        return -1;
    }

}

PyObject* _movie_get_height (PyMovie *movie, void *closure)
{
    PyObject *pyo;
    if(movie->video_st)
    {
        if(movie->resize_h)
        {
            pyo=PyInt_FromLong((long)movie->height);
        }
        else
        {
            pyo= PyInt_FromLong((long)movie->video_st->codec->height);
        }
    }
    else
    {
        pyo = PyInt_FromLong((long)0);
    }
    return pyo;
}
int _movie_set_height (PyMovie *movie, PyObject *height, void *closure)
{
    int h;
    if(PyInt_Check(height)  && !movie->canon_surf)
    {
        h = (int)PyInt_AsLong(height);
    	
        ALLOC_COMMAND(resizeCommand, resize);
    	resize->h = h;
    	resize->w  = 0;
		addCommand(movie->commands, (Command *)resize);
        return 0;
    }
    else
    {
        return -1;
    }

}

PyObject* _movie_get_ytop (PyMovie *movie, void *closure)
{
    PyObject *pyo;
    if(movie->video_st)
    {
        pyo= PyInt_FromLong((long)movie->ytop);
    }
    else
    {
        pyo = PyInt_FromLong((long)0);
    }
    return pyo;
}
int _movie_set_ytop (PyMovie *movie, PyObject *ytop, void *closure)
{
    int y;
    if(PyInt_Check(ytop))
    {
        y = (int)PyInt_AsLong(ytop);
        ALLOC_COMMAND(shiftCommand, shift);
        shift->ytop = y;
        shift->xleft = 0;
        addCommand(movie->commands, (Command *)shift);
        return 0;
    }
    else
    {
        return -1;
    }
}

PyObject* _movie_get_xleft (PyMovie *movie, void *closure)
{
    PyObject *pyo;
    if(movie->video_st)
    {
        pyo= PyInt_FromLong((long)movie->xleft);
    }
    else
    {
        pyo = PyInt_FromLong((long)0);
    }
    return pyo;
}
int _movie_set_xleft (PyMovie *movie, PyObject *xleft, void *closure)
{
    int x;
    if(PyInt_Check(xleft))
    {
        x = (int)PyInt_AsLong(xleft);
        ALLOC_COMMAND(shiftCommand, shift);
        shift->ytop = 0;
        shift->xleft = x;
        addCommand(movie->commands, (Command *)shift);
        return 0;
    }
    else
    {
        return -1;
    }

}

PyObject *_movie_get_surface(PyMovie *movie, void *closure)
{
    if(movie->canon_surf)
    {
        return (PyObject *)PySurface_New(movie->canon_surf);
    }
    Py_RETURN_NONE;
}

int _movie_set_surface(PyObject *mov, PyObject *surface, void *closure)
{
    PyMovie *movie = (PyMovie *)mov;
    surfaceCommand *surf;
    if(PySurface_Check(surface))
    {
        /*movie->canon_surf=PySurface_AsSurface(surface);
        movie->overlay=0;*/
        surf = (surfaceCommand *)PyMem_Malloc(sizeof(surfaceCommand));
        surf->type = movie->surfaceCommandType;
        surf->surface = PySurface_AsSurface(surface);
        addCommand(movie->commands, (Command *)surf);
        return 0;
    }
    else if(surface == Py_None)
    {
    	surf = (surfaceCommand *)PyMem_Malloc(sizeof(surfaceCommand));
        surf->type = movie->surfaceCommandType;
        surf->surface = NULL;
        addCommand(movie->commands, (Command *)surf);
    	return 0;
    }
    return -1;
}

static PyMethodDef _movie_methods[] = {
                                          { "play",      (PyCFunction) _movie_play,      METH_VARARGS, DOC_GMOVIEMOVIEPLAY},
                                          { "stop",      (PyCFunction) _movie_stop,      METH_NOARGS,  DOC_GMOVIEMOVIESTOP},
                                          { "pause",     (PyCFunction) _movie_pause,     METH_NOARGS,  DOC_GMOVIEMOVIEPAUSE},
                                          { "rewind",    (PyCFunction) _movie_rewind,    METH_VARARGS, DOC_GMOVIEMOVIEREWIND},
                                          { "resize",    (PyCFunction) _movie_resize,    METH_VARARGS, DOC_GMOVIEMOVIERESIZE},
                                          { "easy_seek", (PyCFunction) _movie_easy_seek, METH_VARARGS, DOC_GMOVIEMOVIEEASY_SEEK},
                                          { "shift",     (PyCFunction) _movie_shift,     METH_VARARGS, DOC_GMOVIEMOVIESHIFT},
                                          { NULL,     NULL,                        0,            NULL }
                                      };

static PyMemberDef _movie_members[] = {
                                          { "_backend", T_STRING, offsetof(struct PyMovie, _backend), 0,    "Lists which backend this movie object belongs to."},
                                          { NULL}
                                      };

static PyGetSetDef _movie_getsets[] =
    {
        { "paused",   (getter) _movie_get_paused,   NULL,                       DOC_GMOVIEMOVIEPAUSE,    NULL },
        { "playing",  (getter) _movie_get_playing,  NULL,                       DOC_GMOVIEMOVIEPLAYING,  NULL },
        { "finished", (getter) _movie_get_finished, NULL,                       DOC_GMOVIEMOVIEFINISHED, NULL },
        { "height",   (getter) _movie_get_height,  (setter) _movie_set_height,  DOC_GMOVIEMOVIEHEIGHT,   NULL },
        { "width",    (getter) _movie_get_width,   (setter) _movie_set_width,   DOC_GMOVIEMOVIEWIDTH,    NULL },
        { "surface",  (getter) _movie_get_surface, (setter) _movie_set_surface, DOC_GMOVIEMOVIESURFACE,  NULL },
        { "ytop",     (getter) _movie_get_ytop,    (setter) _movie_set_ytop,    DOC_GMOVIEMOVIEYTOP,     NULL },
        { "xleft",    (getter) _movie_get_xleft,   (setter) _movie_set_xleft,   DOC_GMOVIEMOVIEXLEFT,    NULL },
        { NULL,       NULL,                        NULL,                        NULL,                    NULL }
    };

static PyTypeObject PyMovie_Type =
    {
        PyObject_HEAD_INIT(NULL)
        0,
        "pygame._movie.Movie",          /* tp_name */
        sizeof (PyMovie),           /* tp_basicsize */
        0,                          /* tp_itemsize */
        (destructor) _movie_dealloc,/* tp_dealloc */
        0,                          /* tp_print */
        0,                          /* tp_getattr */
        0,                          /* tp_setattr */
        0,                          /* tp_compare */
        (reprfunc) _movie_repr,     /* tp_repr */
        0,                          /* tp_as_number */
        0,                          /* tp_as_sequence */
        0,                          /* tp_as_mapping */
        0,                          /* tp_hash */
        0,                          /* tp_call */
        0,      /* tp_str */
        0,                          /* tp_getattro */
        0,                          /* tp_setattro */
        0,                          /* tp_as_buffer */
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
        DOC_GMOVIE,                 /* tp_doc */
        0,                          /* tp_traverse */
        0,                          /* tp_clear */
        0,                          /* tp_richcompare */
        0,                          /* tp_weaklistoffset */
        0,                          /* tp_iter */
        0,                          /* tp_iternext */
        _movie_methods,             /* tp_methods */
        _movie_members,             /* tp_members */
        _movie_getsets,             /* tp_getset */
        0,                          /* tp_base */
        0,                          /* tp_dict */
        0,                          /* tp_descr_get */
        0,                          /* tp_descr_set */
        0,                          /* tp_dictoffset */
        (initproc) _movie_init,                          /* tp_init */
        0,                          /* tp_alloc */
        0,                 /* tp_new */
        0,                          /* tp_free */
        0,                          /* tp_is_gc */
        0,                          /* tp_bases */
        0,                          /* tp_mro */
        0,                          /* tp_cache */
        0,                          /* tp_subclasses */
        0,                          /* tp_weaklist */
        0                           /* tp_del */
    };
/*DOC*/
static char _movie_doc[] =
    /*DOC*/    "ffmpeg wrapper module for pygame";

PyMODINIT_FUNC
init_movie(void)
{
    PyObject* module;

    /* imported needed apis; Do this first so if there is an error
       the module is not loaded.
    */
    import_pygame_base ();
    if (PyErr_Occurred ())
    {
        MODINIT_ERROR;
    }

    // Fill in some slots in the type, and make it ready
    PyMovie_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&PyMovie_Type) < 0)
    {
        MODINIT_ERROR;
    }
    /*
    PyAudioStream_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&PyAudioStream_Type) < 0) {
       MODINIT_ERROR;
}
    PyVideoStream_Type.tp_new = PyType_GenericNew;
    if (PyType_Ready(&PyVideoStream_Type) < 0) {
       MODINIT_ERROR;
}*/
    // Create the module

    module = Py_InitModule3 ("_movie", NULL, _movie_doc); //movie doc needed

    if (module == NULL)
    {
        return;
    }



    //Register all the fun stuff for movies.
    avcodec_register_all();
    av_register_all();
    //import stuff we need
    import_pygame_surface();
    //initialize our flush marker for the queues.
    av_init_packet(&flush_pkt);
    uint8_t *s = (uint8_t *)"FLUSH";
    flush_pkt.data= s;

    // Add the type to the module.
    Py_INCREF(&PyMovie_Type);
    PyModule_AddObject(module, "Movie", (PyObject*)&PyMovie_Type);
}