annotate Modules/svmodule.c @ 16798:258dcafe2d0b legacy-trunk

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