mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
Restore compatibility with ISO C
This commit is contained in:
parent
988c28cf92
commit
61879e217d
31
_webp.c
31
_webp.c
|
@ -44,7 +44,14 @@ PyObject* WebPEncode_wrapper(PyObject* self, PyObject* args)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_WEBPMUX
|
||||
#ifndef HAVE_WEBPMUX
|
||||
if (ret_size > 0) {
|
||||
PyObject *ret = PyBytes_FromStringAndSize((char*)output, ret_size);
|
||||
free(output);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
{
|
||||
WebPData output_data = {0};
|
||||
WebPData image = { output, ret_size };
|
||||
|
||||
|
@ -69,19 +76,13 @@ PyObject* WebPEncode_wrapper(PyObject* self, PyObject* args)
|
|||
|
||||
output = (uint8_t*)output_data.bytes;
|
||||
ret_size = output_data.size;
|
||||
#endif
|
||||
|
||||
if (ret_size > 0) {
|
||||
PyObject *ret = PyBytes_FromStringAndSize((char*)output, ret_size);
|
||||
|
||||
#ifdef HAVE_WEBPMUX
|
||||
WebPDataClear(&output_data);
|
||||
#else
|
||||
free(output);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
@ -115,33 +116,35 @@ PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
|
|||
mode = "RGBA";
|
||||
}
|
||||
|
||||
#ifdef HAVE_WEBPMUX
|
||||
#ifndef HAVE_WEBPMUX
|
||||
vp8_status_code = WebPDecode(webp, size, &config);
|
||||
#else
|
||||
{
|
||||
int copy_data = 0;
|
||||
WebPData data = { webp, size };
|
||||
WebPMuxFrameInfo image;
|
||||
WebPData icc_profile_data = {0};
|
||||
WebPData exif_data = {0};
|
||||
|
||||
WebPMux* mux = WebPMuxCreate(&data, copy_data);
|
||||
WebPMuxGetFrame(mux, 1, &image);
|
||||
webp = (uint8_t*)image.bitstream.bytes;
|
||||
size = image.bitstream.size;
|
||||
#endif
|
||||
|
||||
vp8_status_code = WebPDecode(webp, size, &config);
|
||||
|
||||
#ifdef HAVE_WEBPMUX
|
||||
WebPData icc_profile_data = {0};
|
||||
WebPMuxGetChunk(mux, "ICCP", &icc_profile_data);
|
||||
if (icc_profile_data.size > 0) {
|
||||
icc_profile = PyBytes_FromStringAndSize((const char*)icc_profile_data.bytes, icc_profile_data.size);
|
||||
}
|
||||
|
||||
WebPData exif_data = {0};
|
||||
WebPMuxGetChunk(mux, "EXIF", &exif_data);
|
||||
if (exif_data.size > 0) {
|
||||
exif = PyBytes_FromStringAndSize((const char*)exif_data.bytes, exif_data.size);
|
||||
}
|
||||
|
||||
WebPMuxDelete(mux);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user