untabified whitespace

This commit is contained in:
wiredfool 2013-05-13 21:47:35 -07:00
parent 9ac38c1a3a
commit 21e3fd2eb7

86
_webp.c
View File

@ -15,7 +15,7 @@ PyObject* WebPGetFeatures_wrapper(PyObject* self, PyObject* args)
if (!PyArg_ParseTuple(args, "S", &webp_string)) { if (!PyArg_ParseTuple(args, "S", &webp_string)) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyBytes_AsStringAndSize((PyObject *) webp_string, (char**)&webp, &size); PyBytes_AsStringAndSize((PyObject *) webp_string, (char**)&webp, &size);
@ -28,7 +28,7 @@ PyObject* WebPGetFeatures_wrapper(PyObject* self, PyObject* args)
} else { } else {
// TODO: raise some sort of error // TODO: raise some sort of error
printf("Error occured checking webp file with code: %d\n", vp8_status_code); printf("Error occured checking webp file with code: %d\n", vp8_status_code);
Py_RETURN_NONE; Py_RETURN_NONE;
} }
return Py_BuildValue("b", features.has_alpha); return Py_BuildValue("b", features.has_alpha);
@ -48,13 +48,13 @@ PyObject* WebPEncodeRGB_wrapper(PyObject* self, PyObject* args)
size_t ret_size; size_t ret_size;
if (!PyArg_ParseTuple(args, "Siiif", &rgb_string, &width, &height, &stride, &quality_factor)) { if (!PyArg_ParseTuple(args, "Siiif", &rgb_string, &width, &height, &stride, &quality_factor)) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyBytes_AsStringAndSize((PyObject *) rgb_string, (char**)&rgb, &size); PyBytes_AsStringAndSize((PyObject *) rgb_string, (char**)&rgb, &size);
if (stride * height > size) { if (stride * height > size) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
ret_size = WebPEncodeRGB(rgb, width, height, stride, quality_factor, &output); ret_size = WebPEncodeRGB(rgb, width, height, stride, quality_factor, &output);
@ -63,7 +63,7 @@ PyObject* WebPEncodeRGB_wrapper(PyObject* self, PyObject* args)
free(output); free(output);
return ret; return ret;
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -80,13 +80,13 @@ PyObject* WebPEncodeRGBA_wrapper(PyObject* self, PyObject* args)
size_t ret_size; size_t ret_size;
if (!PyArg_ParseTuple(args, "Siiif", &rgba_string, &width, &height, &stride, &quality_factor)) { if (!PyArg_ParseTuple(args, "Siiif", &rgba_string, &width, &height, &stride, &quality_factor)) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyBytes_AsStringAndSize((PyObject *) rgba_string, (char**)&rgba, &size); PyBytes_AsStringAndSize((PyObject *) rgba_string, (char**)&rgba, &size);
if (stride * height > size) { if (stride * height > size) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
ret_size = WebPEncodeRGBA(rgba, width, height, stride, quality_factor, &output); ret_size = WebPEncodeRGBA(rgba, width, height, stride, quality_factor, &output);
@ -95,7 +95,7 @@ PyObject* WebPEncodeRGBA_wrapper(PyObject* self, PyObject* args)
free(output); free(output);
return ret; return ret;
} }
Py_RETURN_NONE; Py_RETURN_NONE;
} }
@ -105,60 +105,60 @@ PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
uint8_t *webp; uint8_t *webp;
Py_ssize_t size; Py_ssize_t size;
PyObject *ret, *bytes, *pymode; PyObject *ret, *bytes, *pymode;
WebPDecoderConfig config; WebPDecoderConfig config;
VP8StatusCode vp8_status_code = VP8_STATUS_OK; VP8StatusCode vp8_status_code = VP8_STATUS_OK;
char* mode = "RGB"; char* mode = "RGB";
if (!PyArg_ParseTuple(args, "S", &webp_string)) { if (!PyArg_ParseTuple(args, "S", &webp_string)) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
if (!WebPInitDecoderConfig(&config)) { if (!WebPInitDecoderConfig(&config)) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
PyBytes_AsStringAndSize((PyObject *) webp_string, (char**)&webp, &size); PyBytes_AsStringAndSize((PyObject *) webp_string, (char**)&webp, &size);
vp8_status_code = WebPGetFeatures(webp, size, &config.input); vp8_status_code = WebPGetFeatures(webp, size, &config.input);
if (vp8_status_code == VP8_STATUS_OK) { if (vp8_status_code == VP8_STATUS_OK) {
// If we don't set it, we don't get alpha. // If we don't set it, we don't get alpha.
// Initialized to MODE_RGB // Initialized to MODE_RGB
if (config.input.has_alpha) { if (config.input.has_alpha) {
config.output.colorspace = MODE_RGBA; config.output.colorspace = MODE_RGBA;
mode = "RGBA"; mode = "RGBA";
} }
vp8_status_code = WebPDecode(webp, size, &config); vp8_status_code = WebPDecode(webp, size, &config);
} }
if (vp8_status_code != VP8_STATUS_OK) { if (vp8_status_code != VP8_STATUS_OK) {
Py_RETURN_NONE; Py_RETURN_NONE;
} }
if (config.output.colorspace < MODE_YUV) { if (config.output.colorspace < MODE_YUV) {
bytes = PyBytes_FromStringAndSize((char *)config.output.u.RGBA.rgba, bytes = PyBytes_FromStringAndSize((char *)config.output.u.RGBA.rgba,
config.output.u.RGBA.size); config.output.u.RGBA.size);
} else { } else {
// Skipping YUV for now. Need Test Images. // Skipping YUV for now. Need Test Images.
// UNDONE -- unclear if we'll ever get here if we set mode_rgb* // UNDONE -- unclear if we'll ever get here if we set mode_rgb*
bytes = PyBytes_FromStringAndSize((char *)config.output.u.YUVA.y, bytes = PyBytes_FromStringAndSize((char *)config.output.u.YUVA.y,
config.output.u.YUVA.y_size); config.output.u.YUVA.y_size);
} }
#if PY_VERSION_HEX >= 0x03000000 #if PY_VERSION_HEX >= 0x03000000
pymode = PyUnicode_FromString(mode); pymode = PyUnicode_FromString(mode);
#else #else
pymode = PyString_FromString(mode); pymode = PyString_FromString(mode);
#endif #endif
ret = Py_BuildValue("SiiS", bytes, config.output.width, ret = Py_BuildValue("SiiS", bytes, config.output.width,
config.output.height, pymode); config.output.height, pymode);
WebPFreeDecBuffer(&config.output); WebPFreeDecBuffer(&config.output);
return ret; return ret;
} }
// Return the decoder's version number, packed in hexadecimal using 8bits for // Return the decoder's version number, packed in hexadecimal using 8bits for
// each of major/minor/revision. E.g: v2.5.7 is 0x020507. // each of major/minor/revision. E.g: v2.5.7 is 0x020507.
PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){ PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){
return Py_BuildValue("i", WebPGetDecoderVersion()); return Py_BuildValue("i", WebPGetDecoderVersion());
} }
/* /*
@ -166,7 +166,7 @@ PyObject* WebPDecoderVersion_wrapper(PyObject* self, PyObject* args){
* Files that are valid with 0.3 are reported as being invalid. * Files that are valid with 0.3 are reported as being invalid.
*/ */
PyObject* WebPDecoderBuggyAlpha_wrapper(PyObject* self, PyObject* args){ PyObject* WebPDecoderBuggyAlpha_wrapper(PyObject* self, PyObject* args){
return Py_BuildValue("i", WebPGetDecoderVersion()==0x0102); return Py_BuildValue("i", WebPGetDecoderVersion()==0x0102);
} }
static PyMethodDef webpMethods[] = static PyMethodDef webpMethods[] =