Mercurial > cpython-lru_cache-weakref
annotate Modules/svmodule.c @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | fd25030223b0 |
| children |
| rev | line source |
|---|---|
| 1179 | 1 /* SV module -- interface to the Indigo video board */ |
| 2 | |
|
4762
f926263fb654
Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents:
4712
diff
changeset
|
3 /* WARNING! This module is for hardware that we don't have any more, |
|
f926263fb654
Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents:
4712
diff
changeset
|
4 so it hasn't been tested. It has been converted to the new coding |
|
f926263fb654
Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents:
4712
diff
changeset
|
5 style, and it is possible that this conversion has broken something |
|
f926263fb654
Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents:
4712
diff
changeset
|
6 -- user beware! */ |
|
f926263fb654
Corrected two errors introduced by the renaming (and the subsequent
Guido van Rossum <guido@python.org>
parents:
4712
diff
changeset
|
7 |
| 1179 | 8 #include <sys/time.h> |
| 9 #include <svideo.h> | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
10 #include "Python.h" |
| 1179 | 11 #include "compile.h" |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
12 #include "yuv.h" /* for YUV conversion functions */ |
| 1179 | 13 |
| 14 typedef struct { | |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
15 PyObject_HEAD |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
16 SV_nodeP ob_svideo; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
17 svCaptureInfo ob_info; |
| 1179 | 18 } svobject; |
| 19 | |
| 20 typedef struct { | |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
21 PyObject_HEAD |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
22 void *ob_capture; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
23 int ob_mustunlock; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
24 svCaptureInfo ob_info; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
25 svobject *ob_svideo; |
| 1179 | 26 } captureobject; |
| 27 | |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
28 static PyObject *SvError; /* exception sv.error */ |
| 1179 | 29 |
|
13447
a89f7f268de4
Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents:
13256
diff
changeset
|
30 static PyObject *newcaptureobject(svobject *, void *, int); |
| 1179 | 31 |
| 32 /* Set a SV-specific error from svideo_errno and return NULL */ | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
33 static PyObject * |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13503
diff
changeset
|
34 sv_error(void) |
| 1179 | 35 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
36 PyErr_SetString(SvError, svStrerror(svideo_errno)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
37 return NULL; |
| 1179 | 38 } |
| 39 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
40 static PyObject * |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
41 svc_conversion(captureobject *self, PyObject *args, void (*function)(), float factor) |
| 1179 | 42 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
43 PyObject *output; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
44 int invert; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
45 char* outstr; |
| 1179 | 46 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
47 if (!PyArg_Parse(args, "i", &invert)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
48 return NULL; |
| 1179 | 49 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
50 if (!(output = PyString_FromStringAndSize( |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
51 NULL, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
52 (int)(self->ob_info.width * self->ob_info.height * factor)))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
53 { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
54 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
55 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
56 if (!(outstr = PyString_AsString(output))) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
57 Py_DECREF(output); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
58 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
59 } |
| 1179 | 60 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
61 (*function)((boolean)invert, self->ob_capture, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
62 outstr, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
63 self->ob_info.width, self->ob_info.height); |
| 1179 | 64 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
65 return output; |
| 1179 | 66 } |
| 67 | |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
68 /* |
|
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
69 * 3 functions to convert from Starter Video YUV 4:1:1 format to |
|
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
70 * Compression Library 4:2:2 Duplicate Chroma format. |
|
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
71 */ |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
72 static PyObject * |
| 13503 | 73 svc_YUVtoYUV422DC(captureobject *self, PyObject *args) |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
74 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
75 if (self->ob_info.format != SV_YUV411_FRAMES) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
76 PyErr_SetString(SvError, "data has bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
77 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
78 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
79 return svc_conversion(self, args, yuv_sv411_to_cl422dc, 2.0); |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
80 } |
|
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
81 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
82 static PyObject * |
| 13503 | 83 svc_YUVtoYUV422DC_quarter(captureobject *self, PyObject *args) |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
84 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
85 if (self->ob_info.format != SV_YUV411_FRAMES) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
86 PyErr_SetString(SvError, "data has bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
87 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
88 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
89 return svc_conversion(self, args, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
90 yuv_sv411_to_cl422dc_quartersize, 0.5); |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
91 } |
|
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
92 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
93 static PyObject * |
| 13503 | 94 svc_YUVtoYUV422DC_sixteenth(captureobject *self, PyObject *args) |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
95 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
96 if (self->ob_info.format != SV_YUV411_FRAMES) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
97 PyErr_SetString(SvError, "data has bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
98 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
99 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
100 return svc_conversion(self, args, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
101 yuv_sv411_to_cl422dc_sixteenthsize, 0.125); |
|
1253
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
102 } |
|
685b31fe89c6
Added conversion routines to sv module.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1207
diff
changeset
|
103 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
104 static PyObject * |
| 13503 | 105 svc_YUVtoRGB(captureobject *self, PyObject *args) |
| 1179 | 106 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
107 switch (self->ob_info.format) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
108 case SV_YUV411_FRAMES: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
109 case SV_YUV411_FRAMES_AND_BLANKING_BUFFER: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
110 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
111 default: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
112 PyErr_SetString(SvError, "data had bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
113 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
114 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
115 return svc_conversion(self, args, svYUVtoRGB, (float) sizeof(long)); |
| 1179 | 116 } |
| 117 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
118 static PyObject * |
| 13503 | 119 svc_RGB8toRGB32(captureobject *self, PyObject *args) |
| 1179 | 120 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
121 if (self->ob_info.format != SV_RGB8_FRAMES) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
122 PyErr_SetString(SvError, "data has bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
123 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
124 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
125 return svc_conversion(self, args, svRGB8toRGB32, (float) sizeof(long)); |
| 1179 | 126 } |
| 127 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
128 static PyObject * |
| 13503 | 129 svc_InterleaveFields(captureobject *self, PyObject *args) |
| 1179 | 130 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
131 if (self->ob_info.format != SV_RGB8_FRAMES) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
132 PyErr_SetString(SvError, "data has bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
133 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
134 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
135 return svc_conversion(self, args, svInterleaveFields, 1.0); |
| 1179 | 136 } |
| 137 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
138 static PyObject * |
| 13503 | 139 svc_GetFields(captureobject *self, PyObject *args) |
| 1179 | 140 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
141 PyObject *f1 = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
142 PyObject *f2 = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
143 PyObject *ret = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
144 int fieldsize; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
145 char* obcapture; |
| 1179 | 146 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
147 if (self->ob_info.format != SV_RGB8_FRAMES) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
148 PyErr_SetString(SvError, "data has bad format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
149 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
150 } |
| 1179 | 151 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
152 fieldsize = self->ob_info.width * self->ob_info.height / 2; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
153 obcapture = (char*)self->ob_capture; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
154 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
155 if (!(f1 = PyString_FromStringAndSize(obcapture, fieldsize))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
156 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
157 if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
158 fieldsize))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
159 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
160 ret = PyTuple_Pack(2, f1, f2); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
161 |
|
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
162 finally: |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
163 Py_XDECREF(f1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
164 Py_XDECREF(f2); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
165 return ret; |
| 1179 | 166 } |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
167 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
168 static PyObject * |
| 13503 | 169 svc_UnlockCaptureData(captureobject *self, PyObject *args) |
| 1179 | 170 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
171 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
172 return NULL; |
| 1179 | 173 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
174 if (!self->ob_mustunlock) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
175 PyErr_SetString(SvError, "buffer should not be unlocked"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
176 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
177 } |
| 1179 | 178 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
179 if (svUnlockCaptureData(self->ob_svideo->ob_svideo, self->ob_capture)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
180 return sv_error(); |
| 1179 | 181 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
182 self->ob_mustunlock = 0; |
| 1179 | 183 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
184 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
185 return Py_None; |
| 1179 | 186 } |
| 187 | |
| 188 #ifdef USE_GL | |
| 189 #include <gl.h> | |
| 190 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
191 static PyObject * |
| 13503 | 192 svc_lrectwrite(captureobject *self, PyObject *args) |
| 1179 | 193 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
194 Screencoord x1, x2, y1, y2; |
| 1179 | 195 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
196 if (!PyArg_Parse(args, "(hhhh)", &x1, &x2, &y1, &y2)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
197 return NULL; |
| 1179 | 198 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
199 lrectwrite(x1, x2, y1, y2, (unsigned long *) self->ob_capture); |
| 1179 | 200 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
201 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
202 return Py_None; |
| 1179 | 203 } |
| 204 #endif | |
| 205 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
206 static PyObject * |
| 13503 | 207 svc_writefile(captureobject *self, PyObject *args) |
| 1179 | 208 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
209 PyObject *file; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
210 int size; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
211 FILE* fp; |
| 1179 | 212 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
213 if (!PyArg_Parse(args, "O", &file)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
214 return NULL; |
| 1179 | 215 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
216 if (!PyFile_Check(file)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
217 PyErr_SetString(SvError, "not a file object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
218 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
219 } |
| 1179 | 220 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
221 if (!(fp = PyFile_AsFile(file))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
222 return NULL; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
223 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
224 size = self->ob_info.width * self->ob_info.height; |
| 1179 | 225 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
226 if (fwrite(self->ob_capture, sizeof(long), size, fp) != size) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
227 PyErr_SetString(SvError, "writing failed"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
228 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
229 } |
| 1179 | 230 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
231 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
232 return Py_None; |
| 1179 | 233 } |
| 234 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
235 static PyObject * |
| 13503 | 236 svc_FindVisibleRegion(captureobject *self, PyObject *args) |
| 1179 | 237 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
238 void *visible; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
239 int width; |
| 1179 | 240 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
241 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
242 return NULL; |
| 1179 | 243 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
244 if (svFindVisibleRegion(self->ob_svideo->ob_svideo, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
245 self->ob_capture, &visible, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
246 self->ob_info.width)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
247 return sv_error(); |
| 1179 | 248 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
249 if (visible == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
250 PyErr_SetString(SvError, "data in wrong format"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
251 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
252 } |
| 1179 | 253 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
254 return newcaptureobject(self->ob_svideo, visible, 0); |
| 1179 | 255 } |
| 256 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
257 static PyMethodDef capture_methods[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
258 {"YUVtoRGB", (PyCFunction)svc_YUVtoRGB, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
259 {"RGB8toRGB32", (PyCFunction)svc_RGB8toRGB32, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
260 {"InterleaveFields", (PyCFunction)svc_InterleaveFields, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
261 {"UnlockCaptureData", (PyCFunction)svc_UnlockCaptureData, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
262 {"FindVisibleRegion", (PyCFunction)svc_FindVisibleRegion, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
263 {"GetFields", (PyCFunction)svc_GetFields, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
264 {"YUVtoYUV422DC", (PyCFunction)svc_YUVtoYUV422DC, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
265 {"YUVtoYUV422DC_quarter",(PyCFunction)svc_YUVtoYUV422DC_quarter, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
266 {"YUVtoYUV422DC_sixteenth",(PyCFunction)svc_YUVtoYUV422DC_sixteenth, METH_OLDARGS}, |
| 1179 | 267 #ifdef USE_GL |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
268 {"lrectwrite", (PyCFunction)svc_lrectwrite, METH_OLDARGS}, |
| 1179 | 269 #endif |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
270 {"writefile", (PyCFunction)svc_writefile, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
271 {NULL, NULL} /* sentinel */ |
| 1179 | 272 }; |
| 273 | |
| 274 static void | |
| 13503 | 275 capture_dealloc(captureobject *self) |
| 1179 | 276 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
277 if (self->ob_capture != NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
278 if (self->ob_mustunlock) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
279 (void)svUnlockCaptureData(self->ob_svideo->ob_svideo, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
280 self->ob_capture); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
281 self->ob_capture = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
282 Py_DECREF(self->ob_svideo); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
283 self->ob_svideo = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
284 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
285 PyObject_Del(self); |
| 1179 | 286 } |
| 287 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
288 static PyObject * |
| 13503 | 289 capture_getattr(svobject *self, char *name) |
| 1179 | 290 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
291 return Py_FindMethod(capture_methods, (PyObject *)self, name); |
| 1179 | 292 } |
| 293 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
294 PyTypeObject Capturetype = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
295 PyObject_HEAD_INIT(&PyType_Type) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
296 0, /*ob_size*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
297 "sv.capture", /*tp_name*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
298 sizeof(captureobject), /*tp_size*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
299 0, /*tp_itemsize*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
300 /* methods */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
301 (destructor)capture_dealloc, /*tp_dealloc*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
302 0, /*tp_print*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
303 (getattrfunc)capture_getattr, /*tp_getattr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
304 0, /*tp_setattr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
305 0, /*tp_compare*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
306 0, /*tp_repr*/ |
| 1179 | 307 }; |
| 308 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
309 static PyObject * |
| 13503 | 310 newcaptureobject(svobject *self, void *ptr, int mustunlock) |
| 1179 | 311 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
312 captureobject *p; |
| 1179 | 313 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
314 p = PyObject_New(captureobject, &Capturetype); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
315 if (p == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
316 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
317 p->ob_svideo = self; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
318 Py_INCREF(self); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
319 p->ob_capture = ptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
320 p->ob_mustunlock = mustunlock; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
321 p->ob_info = self->ob_info; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
322 return (PyObject *) p; |
| 1179 | 323 } |
| 324 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
325 static PyObject * |
| 13503 | 326 sv_GetCaptureData(svobject *self, PyObject *args) |
| 1179 | 327 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
328 void *ptr; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
329 long fieldID; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
330 PyObject *res, *c; |
| 1179 | 331 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
332 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
333 return NULL; |
| 1179 | 334 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
335 if (svGetCaptureData(self->ob_svideo, &ptr, &fieldID)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
336 return sv_error(); |
| 1179 | 337 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
338 if (ptr == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
339 PyErr_SetString(SvError, "no data available"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
340 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
341 } |
| 1179 | 342 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
343 c = newcaptureobject(self, ptr, 1); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
344 if (c == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
345 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
346 res = Py_BuildValue("(Oi)", c, fieldID); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
347 Py_DECREF(c); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
348 return res; |
| 1179 | 349 } |
| 350 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
351 static PyObject * |
| 13503 | 352 sv_BindGLWindow(svobject *self, PyObject *args) |
| 1179 | 353 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
354 long wid; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
355 int mode; |
| 1179 | 356 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
357 if (!PyArg_Parse(args, "(ii)", &wid, &mode)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
358 return NULL; |
| 1179 | 359 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
360 if (svBindGLWindow(self->ob_svideo, wid, mode)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
361 return sv_error(); |
| 1179 | 362 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
363 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
364 return Py_None; |
| 1179 | 365 } |
| 366 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
367 static PyObject * |
| 13503 | 368 sv_EndContinuousCapture(svobject *self, PyObject *args) |
| 1179 | 369 { |
| 370 | |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
371 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
372 return NULL; |
| 1179 | 373 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
374 if (svEndContinuousCapture(self->ob_svideo)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
375 return sv_error(); |
| 1179 | 376 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
377 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
378 return Py_None; |
| 1179 | 379 } |
| 380 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
381 static PyObject * |
| 13503 | 382 sv_IsVideoDisplayed(svobject *self, PyObject *args) |
| 1179 | 383 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
384 int v; |
| 1179 | 385 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
386 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
387 return NULL; |
| 1179 | 388 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
389 v = svIsVideoDisplayed(self->ob_svideo); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
390 if (v == -1) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
391 return sv_error(); |
| 1179 | 392 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
393 return PyInt_FromLong((long) v); |
| 1179 | 394 } |
| 395 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
396 static PyObject * |
| 13503 | 397 sv_OutputOffset(svobject *self, PyObject *args) |
| 1179 | 398 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
399 int x_offset; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
400 int y_offset; |
| 1179 | 401 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
402 if (!PyArg_Parse(args, "(ii)", &x_offset, &y_offset)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
403 return NULL; |
| 1179 | 404 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
405 if (svOutputOffset(self->ob_svideo, x_offset, y_offset)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
406 return sv_error(); |
| 1179 | 407 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
408 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
409 return Py_None; |
| 1179 | 410 } |
| 411 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
412 static PyObject * |
| 13503 | 413 sv_PutFrame(svobject *self, PyObject *args) |
| 1179 | 414 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
415 char *buffer; |
| 1179 | 416 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
417 if (!PyArg_Parse(args, "s", &buffer)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
418 return NULL; |
| 1179 | 419 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
420 if (svPutFrame(self->ob_svideo, buffer)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
421 return sv_error(); |
| 1179 | 422 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
423 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
424 return Py_None; |
| 1179 | 425 } |
| 426 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
427 static PyObject * |
| 13503 | 428 sv_QuerySize(svobject *self, PyObject *args) |
| 1179 | 429 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
430 int w; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
431 int h; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
432 int rw; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
433 int rh; |
| 1179 | 434 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
435 if (!PyArg_Parse(args, "(ii)", &w, &h)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
436 return NULL; |
| 1179 | 437 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
438 if (svQuerySize(self->ob_svideo, w, h, &rw, &rh)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
439 return sv_error(); |
| 1179 | 440 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
441 return Py_BuildValue("(ii)", (long) rw, (long) rh); |
| 1179 | 442 } |
| 443 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
444 static PyObject * |
| 13503 | 445 sv_SetSize(svobject *self, PyObject *args) |
| 1179 | 446 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
447 int w; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
448 int h; |
| 1179 | 449 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
450 if (!PyArg_Parse(args, "(ii)", &w, &h)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
451 return NULL; |
| 1179 | 452 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
453 if (svSetSize(self->ob_svideo, w, h)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
454 return sv_error(); |
| 1179 | 455 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
456 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
457 return Py_None; |
| 1179 | 458 } |
| 459 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
460 static PyObject * |
| 13503 | 461 sv_SetStdDefaults(svobject *self, PyObject *args) |
| 1179 | 462 { |
| 463 | |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
464 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
465 return NULL; |
| 1179 | 466 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
467 if (svSetStdDefaults(self->ob_svideo)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
468 return sv_error(); |
| 1179 | 469 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
470 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
471 return Py_None; |
| 1179 | 472 } |
| 473 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
474 static PyObject * |
| 13503 | 475 sv_UseExclusive(svobject *self, PyObject *args) |
| 1179 | 476 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
477 boolean onoff; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
478 int mode; |
| 1179 | 479 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
480 if (!PyArg_Parse(args, "(ii)", &onoff, &mode)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
481 return NULL; |
| 1179 | 482 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
483 if (svUseExclusive(self->ob_svideo, onoff, mode)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
484 return sv_error(); |
| 1179 | 485 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
486 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
487 return Py_None; |
| 1179 | 488 } |
| 489 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
490 static PyObject * |
| 13503 | 491 sv_WindowOffset(svobject *self, PyObject *args) |
| 1179 | 492 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
493 int x_offset; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
494 int y_offset; |
| 1179 | 495 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
496 if (!PyArg_Parse(args, "(ii)", &x_offset, &y_offset)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
497 return NULL; |
| 1179 | 498 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
499 if (svWindowOffset(self->ob_svideo, x_offset, y_offset)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
500 return sv_error(); |
| 1179 | 501 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
502 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
503 return Py_None; |
| 1179 | 504 } |
| 505 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
506 static PyObject * |
| 13503 | 507 sv_CaptureBurst(svobject *self, PyObject *args) |
| 1179 | 508 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
509 int bytes, i; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
510 svCaptureInfo info; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
511 void *bitvector = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
512 PyObject *videodata = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
513 PyObject *bitvecobj = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
514 PyObject *res = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
515 static PyObject *evenitem, *odditem; |
| 1179 | 516 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
517 if (!PyArg_Parse(args, "(iiiii)", &info.format, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
518 &info.width, &info.height, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
519 &info.size, &info.samplingrate)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
520 return NULL; |
| 1179 | 521 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
522 switch (info.format) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
523 case SV_RGB8_FRAMES: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
524 bitvector = malloc(SV_BITVEC_SIZE(info.size)); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
525 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
526 case SV_YUV411_FRAMES_AND_BLANKING_BUFFER: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
527 break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
528 default: |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
529 PyErr_SetString(SvError, "illegal format specified"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
530 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
531 } |
| 1179 | 532 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
533 if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
534 res = sv_error(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
535 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
536 } |
| 1179 | 537 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
538 if (!(videodata = PyString_FromStringAndSize(NULL, bytes))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
539 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
540 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
541 /* XXX -- need to do something about the bitvector */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
542 { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
543 char* str = PyString_AsString(videodata); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
544 if (!str) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
545 goto finally; |
| 1179 | 546 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
547 if (svCaptureBurst(self->ob_svideo, &info, str, bitvector)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
548 res = sv_error(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
549 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
550 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
551 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
552 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
553 if (bitvector) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
554 if (evenitem == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
555 if (!(evenitem = PyInt_FromLong(0))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
556 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
557 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
558 if (odditem == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
559 if (!(odditem = PyInt_FromLong(1))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
560 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
561 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
562 if (!(bitvecobj = PyTuple_New(2 * info.size))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
563 goto finally; |
| 1179 | 564 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
565 for (i = 0; i < 2 * info.size; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
566 int sts; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
567 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
568 if (SV_GET_FIELD(bitvector, i) == SV_EVEN_FIELD) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
569 Py_INCREF(evenitem); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
570 sts = PyTuple_SetItem(bitvecobj, i, evenitem); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
571 } else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
572 Py_INCREF(odditem); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
573 sts = PyTuple_SetItem(bitvecobj, i, odditem); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
574 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
575 if (sts < 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
576 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
577 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
578 } else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
579 bitvecobj = Py_None; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
580 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
581 } |
| 1179 | 582 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
583 res = Py_BuildValue("((iiiii)OO)", info.format, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
584 info.width, info.height, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
585 info.size, info.samplingrate, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
586 videodata, bitvecobj); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
587 |
|
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
588 finally: |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
589 if (bitvector) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
590 free(bitvector); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
591 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
592 Py_XDECREF(videodata); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
593 Py_XDECREF(bitvecobj); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
594 return res; |
| 1179 | 595 } |
| 596 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
597 static PyObject * |
| 13503 | 598 sv_CaptureOneFrame(svobject *self, PyObject *args) |
| 1179 | 599 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
600 svCaptureInfo info; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
601 int format, width, height; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
602 int bytes; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
603 PyObject *videodata = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
604 PyObject *res = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
605 char *str; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
606 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
607 if (!PyArg_Parse(args, "(iii)", &format, &width, &height)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
608 return NULL; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
609 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
610 info.format = format; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
611 info.width = width; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
612 info.height = height; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
613 info.size = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
614 info.samplingrate = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
615 if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
616 return sv_error(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
617 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
618 if (!(videodata = PyString_FromStringAndSize(NULL, bytes))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
619 return NULL; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
620 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
621 str = PyString_AsString(videodata); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
622 if (!str) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
623 goto finally; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
624 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
625 if (svCaptureOneFrame(self->ob_svideo, format, &width, &height, str)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
626 res = sv_error(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
627 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
628 } |
| 1179 | 629 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
630 res = Py_BuildValue("(iiO)", width, height, videodata); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
631 |
|
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
632 finally: |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
633 Py_XDECREF(videodata); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
634 return res; |
| 1179 | 635 } |
| 636 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
637 static PyObject * |
| 13503 | 638 sv_InitContinuousCapture(svobject *self, PyObject *args) |
| 1179 | 639 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
640 svCaptureInfo info; |
| 1179 | 641 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
642 if (!PyArg_Parse(args, "(iiiii)", &info.format, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
643 &info.width, &info.height, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
644 &info.size, &info.samplingrate)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
645 return NULL; |
| 1179 | 646 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
647 if (svInitContinuousCapture(self->ob_svideo, &info)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
648 return sv_error(); |
| 1179 | 649 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
650 self->ob_info = info; |
| 1179 | 651 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
652 return Py_BuildValue("(iiiii)", info.format, info.width, info.height, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
653 info.size, info.samplingrate); |
| 1179 | 654 } |
| 655 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
656 static PyObject * |
| 13503 | 657 sv_LoadMap(svobject *self, PyObject *args) |
| 1179 | 658 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
659 PyObject *rgb; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
660 PyObject *res = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
661 rgb_tuple *mapp = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
662 int maptype; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
663 int i, j; /* indices */ |
| 1179 | 664 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
665 if (!PyArg_Parse(args, "(iO)", &maptype, &rgb)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
666 return NULL; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
667 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
668 if (!PyList_Check(rgb) || PyList_Size(rgb) != 256) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
669 PyErr_BadArgument(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
670 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
671 } |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
672 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
673 if (!(mapp = PyMem_NEW(rgb_tuple, 256))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
674 return PyErr_NoMemory(); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
675 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
676 for (i = 0; i < 256; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
677 PyObject* v = PyList_GetItem(rgb, i); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
678 if (!v) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
679 goto finally; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
680 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
681 if (!PyTuple_Check(v) || PyTuple_Size(v) != 3) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
682 PyErr_BadArgument(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
683 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
684 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
685 for (j = 0; j < 3; j++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
686 PyObject* cell = PyTuple_GetItem(v, j); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
687 if (!cell) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
688 goto finally; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
689 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
690 if (!PyInt_Check(cell)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
691 PyErr_BadArgument(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
692 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
693 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
694 switch (j) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
695 case 0: mapp[i].red = PyInt_AsLong(cell); break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
696 case 1: mapp[i].blue = PyInt_AsLong(cell); break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
697 case 2: mapp[i].green = PyInt_AsLong(cell); break; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
698 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
699 if (PyErr_Occurred()) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
700 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
701 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
702 } |
| 1179 | 703 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
704 if (svLoadMap(self->ob_svideo, maptype, mapp)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
705 res = sv_error(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
706 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
707 } |
| 1179 | 708 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
709 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
710 res = Py_None; |
| 1179 | 711 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
712 finally: |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
713 PyMem_DEL(mapp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
714 return res; |
| 1179 | 715 } |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
716 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
717 static PyObject * |
| 13503 | 718 sv_CloseVideo(svobject *self, PyObject *args) |
| 1179 | 719 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
720 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
721 return NULL; |
| 1179 | 722 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
723 if (svCloseVideo(self->ob_svideo)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
724 return sv_error(); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
725 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
726 self->ob_svideo = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
727 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
728 return Py_None; |
| 1179 | 729 } |
| 730 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
731 static PyObject * |
| 13503 | 732 doParams(svobject *self, PyObject *args, |
| 733 int (*func)(SV_nodeP, long *, int), int modified) | |
| 1179 | 734 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
735 PyObject *list; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
736 PyObject *res = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
737 long *PVbuffer = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
738 long length; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
739 int i; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
740 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
741 if (!PyArg_Parse(args, "O", &list)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
742 return NULL; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
743 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
744 if (!PyList_Check(list)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
745 PyErr_BadArgument(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
746 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
747 } |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
748 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
749 if ((length = PyList_Size(list)) < 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
750 return NULL; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
751 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
752 PVbuffer = PyMem_NEW(long, length); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
753 if (PVbuffer == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
754 return PyErr_NoMemory(); |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
755 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
756 for (i = 0; i < length; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
757 PyObject *v = PyList_GetItem(list, i); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
758 if (!v) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
759 goto finally; |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
760 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
761 if (!PyInt_Check(v)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
762 PyErr_BadArgument(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
763 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
764 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
765 PVbuffer[i] = PyInt_AsLong(v); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
766 /* can't just test the return value, because what if the |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
767 value was -1?! |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
768 */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
769 if (PVbuffer[i] == -1 && PyErr_Occurred()) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
770 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
771 } |
| 1179 | 772 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
773 if ((*func)(self->ob_svideo, PVbuffer, length)) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
774 res = sv_error(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
775 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
776 } |
| 1179 | 777 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
778 if (modified) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
779 for (i = 0; i < length; i++) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
780 PyObject* v = PyInt_FromLong(PVbuffer[i]); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
781 if (!v || PyList_SetItem(list, i, v) < 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
782 goto finally; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
783 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
784 } |
| 1179 | 785 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
786 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
787 res = Py_None; |
| 1179 | 788 |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
789 finally: |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
790 PyMem_DEL(PVbuffer); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
791 return res; |
| 1179 | 792 } |
| 793 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
794 static PyObject * |
| 13503 | 795 sv_GetParam(PyObject *self, PyObject *args) |
| 1179 | 796 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
797 return doParams(self, args, svGetParam, 1); |
| 1179 | 798 } |
| 799 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
800 static PyObject * |
| 13503 | 801 sv_GetParamRange(PyObject *self, PyObject *args) |
| 1179 | 802 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
803 return doParams(self, args, svGetParamRange, 1); |
| 1179 | 804 } |
| 805 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
806 static PyObject * |
| 13503 | 807 sv_SetParam(PyObject *self, PyObject *args) |
| 1179 | 808 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
809 return doParams(self, args, svSetParam, 0); |
| 1179 | 810 } |
| 811 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
812 static PyMethodDef svideo_methods[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
813 {"BindGLWindow", (PyCFunction)sv_BindGLWindow, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
814 {"EndContinuousCapture",(PyCFunction)sv_EndContinuousCapture, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
815 {"IsVideoDisplayed", (PyCFunction)sv_IsVideoDisplayed, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
816 {"OutputOffset", (PyCFunction)sv_OutputOffset, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
817 {"PutFrame", (PyCFunction)sv_PutFrame, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
818 {"QuerySize", (PyCFunction)sv_QuerySize, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
819 {"SetSize", (PyCFunction)sv_SetSize, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
820 {"SetStdDefaults", (PyCFunction)sv_SetStdDefaults, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
821 {"UseExclusive", (PyCFunction)sv_UseExclusive, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
822 {"WindowOffset", (PyCFunction)sv_WindowOffset, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
823 {"InitContinuousCapture",(PyCFunction)sv_InitContinuousCapture, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
824 {"CaptureBurst", (PyCFunction)sv_CaptureBurst, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
825 {"CaptureOneFrame", (PyCFunction)sv_CaptureOneFrame, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
826 {"GetCaptureData", (PyCFunction)sv_GetCaptureData, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
827 {"CloseVideo", (PyCFunction)sv_CloseVideo, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
828 {"LoadMap", (PyCFunction)sv_LoadMap, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
829 {"GetParam", (PyCFunction)sv_GetParam, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
830 {"GetParamRange", (PyCFunction)sv_GetParamRange, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
831 {"SetParam", (PyCFunction)sv_SetParam, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
832 {NULL, NULL} /* sentinel */ |
| 1179 | 833 }; |
| 834 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
835 static PyObject * |
| 13503 | 836 sv_conversion(PyObject *self, PyObject *args, void (*function)(), |
| 837 int inputfactor, float factor) | |
| 1179 | 838 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
839 int invert, width, height, inputlength; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
840 char *input, *str; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
841 PyObject *output; |
| 1179 | 842 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
843 if (!PyArg_Parse(args, "(is#ii)", &invert, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
844 &input, &inputlength, &width, &height)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
845 return NULL; |
| 1179 | 846 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
847 if (width * height * inputfactor > inputlength) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
848 PyErr_SetString(SvError, "input buffer not long enough"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
849 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
850 } |
| 1179 | 851 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
852 if (!(output = PyString_FromStringAndSize(NULL, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
853 (int)(width * height * factor)))) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
854 return NULL; |
| 1179 | 855 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
856 str = PyString_AsString(output); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
857 if (!str) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
858 Py_DECREF(output); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
859 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
860 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
861 (*function)(invert, input, str, width, height); |
| 1179 | 862 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
863 return output; |
| 1179 | 864 } |
| 865 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
866 static PyObject * |
| 13503 | 867 sv_InterleaveFields(PyObject *self, PyObject *args) |
| 1179 | 868 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
869 return sv_conversion(self, args, svInterleaveFields, 1, 1.0); |
| 1179 | 870 } |
| 871 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
872 static PyObject * |
| 13503 | 873 sv_RGB8toRGB32(PyObject *self, PyObject *args) |
| 1179 | 874 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
875 return sv_conversion(self, args, svRGB8toRGB32, 1, (float) sizeof(long)); |
| 1179 | 876 } |
| 877 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
878 static PyObject * |
| 13503 | 879 sv_YUVtoRGB(PyObject *self, PyObject *args) |
| 1179 | 880 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
881 return sv_conversion(self, args, svYUVtoRGB, 2, (float) sizeof(long)); |
| 1179 | 882 } |
| 883 | |
| 884 static void | |
| 13503 | 885 svideo_dealloc(svobject *self) |
| 1179 | 886 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
887 if (self->ob_svideo != NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
888 (void) svCloseVideo(self->ob_svideo); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
889 PyObject_Del(self); |
| 1179 | 890 } |
| 891 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
892 static PyObject * |
| 13503 | 893 svideo_getattr(svobject *self, char *name) |
| 1179 | 894 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
895 return Py_FindMethod(svideo_methods, (PyObject *)self, name); |
| 1179 | 896 } |
| 897 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
898 PyTypeObject Svtype = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
899 PyObject_HEAD_INIT(&PyType_Type) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
900 0, /*ob_size*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
901 "sv.sv", /*tp_name*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
902 sizeof(svobject), /*tp_size*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
903 0, /*tp_itemsize*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
904 /* methods */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
905 (destructor)svideo_dealloc, /*tp_dealloc*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
906 0, /*tp_print*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
907 (getattrfunc)svideo_getattr, /*tp_getattr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
908 0, /*tp_setattr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
909 0, /*tp_compare*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
910 0, /*tp_repr*/ |
| 1179 | 911 }; |
| 912 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
913 static PyObject * |
| 13503 | 914 newsvobject(SV_nodeP svp) |
| 1179 | 915 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
916 svobject *p; |
| 1179 | 917 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
918 p = PyObject_New(svobject, &Svtype); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
919 if (p == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
920 return NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
921 p->ob_svideo = svp; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
922 p->ob_info.format = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
923 p->ob_info.size = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
924 p->ob_info.width = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
925 p->ob_info.height = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
926 p->ob_info.samplingrate = 0; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
927 return (PyObject *) p; |
| 1179 | 928 } |
| 929 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
930 static PyObject * |
| 13503 | 931 sv_OpenVideo(PyObject *self, PyObject *args) |
| 1179 | 932 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
933 SV_nodeP svp; |
| 1179 | 934 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
935 if (!PyArg_Parse(args, "")) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
936 return NULL; |
| 1179 | 937 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
938 svp = svOpenVideo(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
939 if (svp == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
940 return sv_error(); |
| 1179 | 941 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
942 return newsvobject(svp); |
| 1179 | 943 } |
| 944 | |
|
4712
0253ef267b68
Renamed, and scrutinized for missed potential error conditions.
Barry Warsaw <barry@python.org>
parents:
4503
diff
changeset
|
945 static PyMethodDef sv_methods[] = { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
946 {"InterleaveFields", (PyCFunction)sv_InterleaveFields, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
947 {"RGB8toRGB32", (PyCFunction)sv_RGB8toRGB32, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
948 {"YUVtoRGB", (PyCFunction)sv_YUVtoRGB, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
949 {"OpenVideo", (PyCFunction)sv_OpenVideo, METH_OLDARGS}, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
950 {NULL, NULL} /* Sentinel */ |
| 1179 | 951 }; |
| 952 | |
| 953 void | |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13503
diff
changeset
|
954 initsv(void) |
| 1179 | 955 { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
956 PyObject *m, *d; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
957 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
958 if (PyErr_WarnPy3k("the sv module has been removed in " |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
959 "Python 3.0", 2) < 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
960 return; |
| 1179 | 961 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
962 m = Py_InitModule("sv", sv_methods); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
963 if (m == NULL) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
964 return; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
965 d = PyModule_GetDict(m); |
| 1179 | 966 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
967 SvError = PyErr_NewException("sv.error", NULL, NULL); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
968 if (SvError == NULL || PyDict_SetItemString(d, "error", SvError) != 0) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
47527
diff
changeset
|
969 return; |
| 1179 | 970 } |
