mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Move some more declarations to top of block
This commit is contained in:
parent
e32fb4f777
commit
c9258d6cdb
16
_webp.c
16
_webp.c
|
@ -35,6 +35,7 @@ static const char* const kErrorMessages[-WEBP_MUX_NOT_ENOUGH_DATA + 1] = {
|
||||||
|
|
||||||
PyObject* HandleMuxError(WebPMuxError err, char* chunk) {
|
PyObject* HandleMuxError(WebPMuxError err, char* chunk) {
|
||||||
char message[100];
|
char message[100];
|
||||||
|
int message_len;
|
||||||
assert(err <= WEBP_MUX_NOT_FOUND && err >= WEBP_MUX_NOT_ENOUGH_DATA);
|
assert(err <= WEBP_MUX_NOT_FOUND && err >= WEBP_MUX_NOT_ENOUGH_DATA);
|
||||||
|
|
||||||
// Check for a memory error first
|
// Check for a memory error first
|
||||||
|
@ -44,9 +45,13 @@ PyObject* HandleMuxError(WebPMuxError err, char* chunk) {
|
||||||
|
|
||||||
// Create the error message
|
// Create the error message
|
||||||
if (chunk == NULL) {
|
if (chunk == NULL) {
|
||||||
sprintf(message, "could not assemble chunks: %s", kErrorMessages[-err]);
|
message_len = sprintf_s(message, 100, "could not assemble chunks: %s", kErrorMessages[-err]);
|
||||||
} else {
|
} else {
|
||||||
sprintf(message, "could not set %.4s chunk: %s", chunk, kErrorMessages[-err]);
|
message_len = sprintf_s(message, 100, "could not set %.4s chunk: %s", chunk, kErrorMessages[-err]);
|
||||||
|
}
|
||||||
|
if (message_len < 0) {
|
||||||
|
PyErr_SetString(PyExc_RuntimeError, "failed to construct error message");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the proper error type
|
// Set the proper error type
|
||||||
|
@ -171,6 +176,7 @@ PyObject* _anim_encoder_add(PyObject* self, PyObject* args)
|
||||||
int lossless;
|
int lossless;
|
||||||
float quality_factor;
|
float quality_factor;
|
||||||
int method;
|
int method;
|
||||||
|
WebPConfig config;
|
||||||
WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self;
|
WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self;
|
||||||
WebPAnimEncoder* enc = encp->enc;
|
WebPAnimEncoder* enc = encp->enc;
|
||||||
WebPPicture* frame = &(encp->frame);
|
WebPPicture* frame = &(encp->frame);
|
||||||
|
@ -188,7 +194,6 @@ PyObject* _anim_encoder_add(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup config for this frame
|
// Setup config for this frame
|
||||||
WebPConfig config;
|
|
||||||
if (!WebPConfigInit(&config)) {
|
if (!WebPConfigInit(&config)) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "failed to initialize config!");
|
PyErr_SetString(PyExc_RuntimeError, "failed to initialize config!");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -230,6 +235,7 @@ PyObject* _anim_encoder_assemble(PyObject* self, PyObject* args)
|
||||||
Py_ssize_t icc_size;
|
Py_ssize_t icc_size;
|
||||||
Py_ssize_t exif_size;
|
Py_ssize_t exif_size;
|
||||||
Py_ssize_t xmp_size;
|
Py_ssize_t xmp_size;
|
||||||
|
WebPData webp_data;
|
||||||
WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self;
|
WebPAnimEncoderObject* encp = (WebPAnimEncoderObject*)self;
|
||||||
WebPAnimEncoder* enc = encp->enc;
|
WebPAnimEncoder* enc = encp->enc;
|
||||||
WebPMux* mux = NULL;
|
WebPMux* mux = NULL;
|
||||||
|
@ -241,7 +247,6 @@ PyObject* _anim_encoder_assemble(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init the output buffer
|
// Init the output buffer
|
||||||
WebPData webp_data;
|
|
||||||
WebPDataInit(&webp_data);
|
WebPDataInit(&webp_data);
|
||||||
|
|
||||||
// Assemble everything into the output buffer
|
// Assemble everything into the output buffer
|
||||||
|
@ -316,6 +321,7 @@ PyObject* _anim_decoder_new(PyObject* self, PyObject* args)
|
||||||
const uint8_t *webp;
|
const uint8_t *webp;
|
||||||
Py_ssize_t size;
|
Py_ssize_t size;
|
||||||
WebPData webp_src;
|
WebPData webp_src;
|
||||||
|
char* mode;
|
||||||
WebPDecoderConfig config;
|
WebPDecoderConfig config;
|
||||||
WebPAnimDecoderObject* decp = NULL;
|
WebPAnimDecoderObject* decp = NULL;
|
||||||
WebPAnimDecoder* dec = NULL;
|
WebPAnimDecoder* dec = NULL;
|
||||||
|
@ -328,7 +334,7 @@ PyObject* _anim_decoder_new(PyObject* self, PyObject* args)
|
||||||
webp_src.size = size;
|
webp_src.size = size;
|
||||||
|
|
||||||
// Sniff the mode, since the decoder API doesn't tell us
|
// Sniff the mode, since the decoder API doesn't tell us
|
||||||
char* mode = "RGBA";
|
mode = "RGBA";
|
||||||
if (WebPGetFeatures(webp, size, &config.input) == VP8_STATUS_OK) {
|
if (WebPGetFeatures(webp, size, &config.input) == VP8_STATUS_OK) {
|
||||||
if (!config.input.has_alpha) {
|
if (!config.input.has_alpha) {
|
||||||
mode = "RGBX";
|
mode = "RGBX";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user