Commits

Anonymous committed 6933dad

Fixed surface issue. Surfaces now don't get resized. It is recommended
to make sure that the surface you use is the same aspect ratio as the
original video.

Comments (0)

Files changed (3)

 import sys
 #sys.exit()
 print "Surface time..."
-screen = pygame.display.set_mode((640, 348))
-m.surface=screen
-time.sleep(1)
-#This will move the movie player from overlay mode to blitting to the surface 
-# we've given it. This means it is our responsibility to update the display on 
-# time.
-#while not m.finished:
-#    time.sleep(0.1)
-#    pygame.display.update()
-m.stop()
-time.sleep(5)
-del m
-
+screen = pygame.display.set_mode((800, 340))
+##m.surface=screen
+##time.sleep(1)
+###This will move the movie player from overlay mode to blitting to the surface 
+### we've given it. This means it is our responsibility to update the display on 
+### time.
+###while not m.finished:
+###    time.sleep(0.1)
+###    pygame.display.update()
+##m.stop()
+##time.sleep(5)
+##del m
 
 m=movie.Movie(filename, screen)
 counter = 0
 	uint8_t blue  = picture->data[0][ix+2];
 	//skip the alpha... we don't care
     /* shift components to the correct place in pixel */
+    	
     *rgb = ( red   << (long) surface->format->Rshift) | /* red */
             ( blue  << (long) surface->format->Bshift ) | /* green */
             ( green << (long) surface->format->Gshift ) | /* blue */
     }
     x = (vp->width - width) / 2;
     y = (vp->height - height) / 2;
-
+	
 	//we set the rect to have the values we need for blitting/overlay display
     vp->dest_rect.x = vp->xleft + x;
     vp->dest_rect.y = vp->ytop  + y;
-    vp->dest_rect.w = width;
-    vp->dest_rect.h = height;
-
+  
+	vp->dest_rect.w=w;
+	vp->dest_rect.h=h;
+	
     if (vp->dest_overlay && vp->overlay>0 && !movie->skip_frame)
     {
     	//SDL_Delay(10);
     int w=0;
     int h=0;
     get_height_width(movie, &h, &w);
-
+    int pw, ph;
+    
+    if(vp->dest_surface)
+	{
+		pw=vp->dest_surface->w;
+		ph=vp->dest_surface->h;
+	}
+   
     /*if(
     	( !vp->dest_overlay && vp->overlay>0 )  ||
     	( !vp->dest_surface && vp->overlay<=0 ) ||
 	    {
 	    	dst_pix_fmt = PIX_FMT_RGBA;
 	    }
-        avpicture_alloc(&pict, dst_pix_fmt, w, h);
+        avpicture_alloc(&pict, dst_pix_fmt, pw, ph);
         SDL_LockSurface(vp->dest_surface);
     }
     int sws_flags = SWS_BICUBIC;
     }
     movie->img_convert_ctx = img_convert_ctx;
 	
-    if(movie->resize_w||movie->resize_h)
+    if((movie->resize_w||movie->resize_h) && !vp->dest_surface)
     {
         sws_scale(img_convert_ctx, 
         		  src_frame->data, 
                   pict.data, 
                   pict.linesize);
     }
-    else
+    else if(vp->dest_surface)
     {
-        sws_scale(img_convert_ctx, 
+    	sws_scale(img_convert_ctx, 
         		  src_frame->data, 
         		  src_frame->linesize,
                   0, 
-                  movie->video_st->codec->height, 
+                  ph, 
                   pict.data, 
                   pict.linesize);
     }
     }
     else if(vp->dest_surface)
     {
-    	int pw=vp->dest_surface->w;
-    	int ph=vp->dest_surface->h;
-    	if(w<vp->dest_surface->w)
-    		{pw=w;}
-    	if(h<vp->dest_surface->h)
-    		{ph=h;}
-        WritePicture2Surface(&pict, vp->dest_surface, pw, ph);
+    	 WritePicture2Surface(&pict, vp->dest_surface, pw, ph);
         SDL_UnlockSurface(vp->dest_surface);
-        avpicture_free(&pict);
+        //avpicture_free(&pict);
     }
     #ifdef PROFILE
     	TimeSampleNode *sample = (TimeSampleNode *)PyMem_Malloc(sizeof(TimeSampleNode));
 	            }
 	            
 	        }
-	        if (SDL_WasInit (SDL_INIT_VIDEO))
-        		SDL_QuitSubSystem (SDL_INIT_VIDEO);	
+	        /*if (SDL_WasInit (SDL_INIT_VIDEO))
+        		SDL_QuitSubSystem (SDL_INIT_VIDEO);*/	
     	}
     }
     GRABGIL
 	if(movie->_tstate)
 	{
 		PyThreadState_Clear(movie->_tstate);
-	}
-	if(!movie->stop)
-	{
-		_movie_stop(movie);	
+		//PyThreadState_Delete(movie->_tstate);
 	}
 	#ifdef PROFILE
 		TimeSampleNode *cur = movie->istats->first;
     	}
     	PyMem_Free(movie->istats);
     #endif
+    SDL_DestroyMutex(movie->commands->q_mutex);
+    PyMem_Free(movie->commands);
+    movie->commands=NULL;
 	stream_close(movie, 0);
     movie->ob_type->tp_free((PyObject *) movie);
 }