mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 09:57:43 +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;
 | 
							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 output_data = {0};
 | 
				
			||||||
    WebPData image = { output, ret_size };
 | 
					    WebPData image = { output, ret_size };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,19 +76,13 @@ PyObject* WebPEncode_wrapper(PyObject* self, PyObject* args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    output = (uint8_t*)output_data.bytes;
 | 
					    output = (uint8_t*)output_data.bytes;
 | 
				
			||||||
    ret_size = output_data.size;
 | 
					    ret_size = output_data.size;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (ret_size > 0) {
 | 
					    if (ret_size > 0) {
 | 
				
			||||||
        PyObject *ret = PyBytes_FromStringAndSize((char*)output, ret_size);
 | 
					        PyObject *ret = PyBytes_FromStringAndSize((char*)output, ret_size);
 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef HAVE_WEBPMUX
 | 
					 | 
				
			||||||
        WebPDataClear(&output_data);
 | 
					        WebPDataClear(&output_data);
 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
        free(output);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return ret;
 | 
					        return ret;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    Py_RETURN_NONE;
 | 
					    Py_RETURN_NONE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -115,33 +116,35 @@ PyObject* WebPDecode_wrapper(PyObject* self, PyObject* args)
 | 
				
			||||||
            mode = "RGBA";
 | 
					            mode = "RGBA";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_WEBPMUX
 | 
					#ifndef HAVE_WEBPMUX
 | 
				
			||||||
 | 
					        vp8_status_code = WebPDecode(webp, size, &config);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					       {
 | 
				
			||||||
        int copy_data = 0;
 | 
					        int copy_data = 0;
 | 
				
			||||||
        WebPData data = { webp, size };
 | 
					        WebPData data = { webp, size };
 | 
				
			||||||
        WebPMuxFrameInfo image;
 | 
					        WebPMuxFrameInfo image;
 | 
				
			||||||
 | 
					        WebPData icc_profile_data = {0};
 | 
				
			||||||
 | 
					        WebPData exif_data = {0};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        WebPMux* mux = WebPMuxCreate(&data, copy_data);
 | 
					        WebPMux* mux = WebPMuxCreate(&data, copy_data);
 | 
				
			||||||
        WebPMuxGetFrame(mux, 1, &image);
 | 
					        WebPMuxGetFrame(mux, 1, &image);
 | 
				
			||||||
        webp = (uint8_t*)image.bitstream.bytes;
 | 
					        webp = (uint8_t*)image.bitstream.bytes;
 | 
				
			||||||
        size = image.bitstream.size;
 | 
					        size = image.bitstream.size;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        vp8_status_code = WebPDecode(webp, size, &config);
 | 
					        vp8_status_code = WebPDecode(webp, size, &config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_WEBPMUX
 | 
					 | 
				
			||||||
        WebPData icc_profile_data = {0};
 | 
					 | 
				
			||||||
        WebPMuxGetChunk(mux, "ICCP", &icc_profile_data);
 | 
					        WebPMuxGetChunk(mux, "ICCP", &icc_profile_data);
 | 
				
			||||||
        if (icc_profile_data.size > 0) {
 | 
					        if (icc_profile_data.size > 0) {
 | 
				
			||||||
            icc_profile = PyBytes_FromStringAndSize((const char*)icc_profile_data.bytes, icc_profile_data.size);
 | 
					            icc_profile = PyBytes_FromStringAndSize((const char*)icc_profile_data.bytes, icc_profile_data.size);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        WebPData exif_data = {0};
 | 
					 | 
				
			||||||
        WebPMuxGetChunk(mux, "EXIF", &exif_data);
 | 
					        WebPMuxGetChunk(mux, "EXIF", &exif_data);
 | 
				
			||||||
        if (exif_data.size > 0) {
 | 
					        if (exif_data.size > 0) {
 | 
				
			||||||
            exif = PyBytes_FromStringAndSize((const char*)exif_data.bytes, exif_data.size);
 | 
					            exif = PyBytes_FromStringAndSize((const char*)exif_data.bytes, exif_data.size);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        WebPMuxDelete(mux);
 | 
					        WebPMuxDelete(mux);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user