Release GIL while calling WebPAnimDecoderGetNext

This commit is contained in:
Evan Miller 2024-02-06 15:41:08 -05:00
parent 3e04ca5794
commit 469db5114c

View File

@ -450,12 +450,16 @@ _anim_decoder_get_next(PyObject *self) {
int timestamp; int timestamp;
PyObject *bytes; PyObject *bytes;
PyObject *ret; PyObject *ret;
ImagingSectionCookie cookie;
WebPAnimDecoderObject *decp = (WebPAnimDecoderObject *)self; WebPAnimDecoderObject *decp = (WebPAnimDecoderObject *)self;
ImagingSectionEnter(&cookie);
if (!WebPAnimDecoderGetNext(decp->dec, &buf, &timestamp)) { if (!WebPAnimDecoderGetNext(decp->dec, &buf, &timestamp)) {
ImagingSectionLeave(&cookie);
PyErr_SetString(PyExc_OSError, "failed to read next frame"); PyErr_SetString(PyExc_OSError, "failed to read next frame");
return NULL; return NULL;
} }
ImagingSectionLeave(&cookie);
bytes = PyBytes_FromStringAndSize( bytes = PyBytes_FromStringAndSize(
(char *)buf, decp->info.canvas_width * 4 * decp->info.canvas_height); (char *)buf, decp->info.canvas_width * 4 * decp->info.canvas_height);