]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_pictures.c
* all: modified files for video transcoding. Still needed configure.ac.in
[vlc] / src / video_output / vout_pictures.c
index aba7ae901486843bd1f495183aba862df4eac75c..19c07e6f6368209bee59c1b3ff3427e7f87807cb 100644 (file)
@@ -2,7 +2,7 @@
  * vout_pictures.c : picture management functions
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
- * $Id: vout_pictures.c,v 1.28 2002/07/23 00:39:17 sam Exp $
+ * $Id: vout_pictures.c,v 1.34 2003/01/22 10:44:50 fenrir Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -25,7 +25,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
 #include <stdlib.h>                                                /* free() */
 #include <stdio.h>                                              /* sprintf() */
 #include <string.h>                                            /* strerror() */
@@ -119,22 +118,12 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
     vlc_mutex_lock( &p_vout->picture_lock );
 
     /*
-     * Look for an empty place. We start at 1 because the first
-     * directbuffer is reserved for memcpy()ed pictures.
+     * Look for an empty place in the picture heap.
      */
-    for( i_pic = 0; i_pic < I_RENDERPICTURES && p_freepic == NULL; i_pic++ )
+    for( i_pic = 0; i_pic < I_RENDERPICTURES; i_pic++ )
     {
-        p_pic = PP_RENDERPICTURE[ i_pic ];
-
-        /* If the picture we found is a memory buffer, and we have enough
-         * pictures in the stack, and we might have enough room later for
-         * a direct buffer, skip it. If no other pictures are found, the
-         * video decoder will try again later. */
-        if( p_vout->b_direct && ( p_vout->output.i_pictures > 5 )
-             && ( p_pic->i_type != DIRECT_PICTURE ) )
-        {
-            break;
-        }
+        p_pic = PP_RENDERPICTURE[(p_vout->render.i_last_used_pic + i_pic + 1)
+                                 % I_RENDERPICTURES];
 
         switch( p_pic->i_status )
         {
@@ -151,11 +140,17 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
                 p_pic->b_top_field_first    = b_top_field_first;
 
                 p_vout->i_heap_size++;
+                p_vout->render.i_last_used_pic =
+                    ( p_vout->render.i_last_used_pic + i_pic + 1 )
+                    % I_RENDERPICTURES;
                 vlc_mutex_unlock( &p_vout->picture_lock );
                 return( p_pic );
 
             case FREE_PICTURE:
                 /* Picture is empty and ready for allocation */
+                p_vout->render.i_last_used_pic =
+                    ( p_vout->render.i_last_used_pic + i_pic + 1 )
+                    % I_RENDERPICTURES;
                 p_freepic = p_pic;
                 break;
 
@@ -297,7 +292,7 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
 
     if( p_pic->i_type == DIRECT_PICTURE )
     {
-        if( p_pic->i_refcount )
+        if( !p_vout->render.b_allow_modify_pics || p_pic->i_refcount )
         {
             /* Picture is in a direct buffer and is still in use,
              * we need to copy it to another direct buffer before
@@ -362,8 +357,10 @@ picture_t * vout_RenderPicture( vout_thread_t *p_vout, picture_t *p_pic,
  * This function will be accessed by plugins. It calculates the relative
  * position of the output window and the image window.
  *****************************************************************************/
-void vout_PlacePicture( vout_thread_t *p_vout, int i_width, int i_height,
-                        int *pi_x, int *pi_y, int *pi_width, int *pi_height )
+void vout_PlacePicture( vout_thread_t *p_vout,
+                        unsigned int i_width, unsigned int i_height,
+                        unsigned int *pi_x, unsigned int *pi_y,
+                        unsigned int *pi_width, unsigned int *pi_height )
 {
     if( (i_width <= 0) || (i_height <=0) )
     {
@@ -500,6 +497,14 @@ void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic,
             p_pic->i_planes = 1;
             break;
 
+        case FOURCC_RGB2:
+            p_pic->p->i_lines = i_height;
+            p_pic->p->i_pitch = i_width;
+            p_pic->p->i_visible_pitch = p_pic->p->i_pitch;
+            p_pic->p->i_pixel_pitch = 1;
+            p_pic->i_planes = 1;
+            break;
+
         case FOURCC_RV15:
             p_pic->p->i_lines = i_height;
             p_pic->p->i_pitch = i_width * 2;
@@ -656,7 +661,8 @@ static void CopyPicture( vout_thread_t * p_vout,
         else
         {
             /* We need to proceed line by line */
-            u8 *p_in = p_src->p[i].p_pixels, *p_out = p_dest->p[i].p_pixels;
+            uint8_t *p_in = p_src->p[i].p_pixels;
+            uint8_t *p_out = p_dest->p[i].p_pixels;
             int i_line;
 
             for( i_line = p_src->p[i].i_lines; i_line--; )
@@ -668,5 +674,5 @@ static void CopyPicture( vout_thread_t * p_vout,
             }
         }
     }
+    p_dest->date = p_src->date;
 }
-