Commits

illume committed 085d62d

Made saving jpeg release the GIL. seems ok on windows.

Comments (0)

Files changed (1)

 
 #define NUM_LINES_TO_WRITE 500
 
-static int
-write_jpeg (char *file_name, unsigned char** image_buffer,  int image_width,
-            int image_height, int quality)
-{
+
+int write_jpeg (char *file_name, unsigned char** image_buffer,  int image_width,
+            int image_height, int quality) {
+
     struct jpeg_compress_struct cinfo;
     struct jpeg_error_mgr jerr;
     FILE * outfile;
     cinfo.in_color_space = JCS_RGB;
     /* cinfo.optimize_coding = FALSE;
      */
-    
+
 
 
     jpeg_set_defaults (&cinfo);
     return 0;
 }
 
-static int
-SaveJPEG (SDL_Surface *surface, char *file)
-{
+
+
+int SaveJPEG (SDL_Surface *surface, char *file) {
+
     static unsigned char** ss_rows;
     static int ss_size;
     static int ss_w, ss_h;
               (name[namelen - 3]=='j' || name[namelen - 3]=='J'))))
         {
 #ifdef JPEGLIB_H
-            /* Png, and jpg save functions are not thread safe. */
-            /*Py_BEGIN_ALLOW_THREADS; */
+            /* jpg save functions seem thread safe on windows. */
+            Py_BEGIN_ALLOW_THREADS;
             result = SaveJPEG (surf, name);
-            /*Py_END_ALLOW_THREADS; */
+            Py_END_ALLOW_THREADS;
 #else
             return RAISE (PyExc_SDLError, "No support for jpg compiled in.");
 #endif