* 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.38 2003/04/27 17:53:21 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* free() */
#include <stdio.h> /* sprintf() */
#include <string.h> /* strerror() */
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 )
{
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;
if( p_pic->i_refcount < 0 )
{
- msg_Err( p_vout, "picture refcount is %i", p_pic->i_refcount );
+ msg_Err( p_vout, "picture %p refcount is %i",
+ p_pic, p_pic->i_refcount );
p_pic->i_refcount = 0;
}
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
/* Picture is not in a direct buffer, but is exactly the
* same size as the direct buffers. A memcpy() is enough,
* then render the subtitles. */
+
+ if( PP_OUTPUTPICTURE[0]->pf_lock )
+ if( PP_OUTPUTPICTURE[0]->pf_lock( p_vout, PP_OUTPUTPICTURE[0] ) )
+ {
+ if( PP_OUTPUTPICTURE[0]->pf_unlock )
+ PP_OUTPUTPICTURE[0]->pf_unlock( p_vout, PP_OUTPUTPICTURE[0] );
+
+ return NULL;
+ }
+
CopyPicture( p_vout, p_pic, PP_OUTPUTPICTURE[0] );
vout_RenderSubPictures( p_vout, PP_OUTPUTPICTURE[0], p_subpic );
+ if( PP_OUTPUTPICTURE[0]->pf_unlock )
+ PP_OUTPUTPICTURE[0]->pf_unlock( p_vout, PP_OUTPUTPICTURE[0] );
+
return PP_OUTPUTPICTURE[0];
}
* well. This usually means software YUV, or hardware YUV with a
* different chroma. */
+ if( p_vout->p_picture[0].pf_lock )
+ if( p_vout->p_picture[0].pf_lock( p_vout, &p_vout->p_picture[0] ) )
+ return NULL;
+
/* Convert image to the first direct buffer */
p_vout->chroma.pf_convert( p_vout, p_pic, &p_vout->p_picture[0] );
/* Render subpictures on the first direct buffer */
vout_RenderSubPictures( p_vout, &p_vout->p_picture[0], p_subpic );
+ if( p_vout->p_picture[0].pf_unlock )
+ p_vout->p_picture[0].pf_unlock( p_vout, &p_vout->p_picture[0] );
+
return &p_vout->p_picture[0];
}
* 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) )
{
/* Calculate coordinates */
switch( i_chroma )
{
+ case FOURCC_I411:
+ p_pic->p[ Y_PLANE ].i_lines = i_height;
+ p_pic->p[ Y_PLANE ].i_pitch = i_width;
+ p_pic->p[ Y_PLANE ].i_visible_pitch = p_pic->p[ Y_PLANE ].i_pitch;
+ p_pic->p[ U_PLANE ].i_lines = i_height;
+ p_pic->p[ U_PLANE ].i_pitch = i_width / 4;
+ p_pic->p[ U_PLANE ].i_visible_pitch = p_pic->p[ U_PLANE ].i_pitch;
+ p_pic->p[ V_PLANE ].i_lines = i_height;
+ p_pic->p[ V_PLANE ].i_pitch = i_width / 4;
+ p_pic->p[ V_PLANE ].i_visible_pitch = p_pic->p[ V_PLANE ].i_pitch;
+ p_pic->i_planes = 3;
+ break;
+
case FOURCC_I410:
p_pic->p[ Y_PLANE ].i_lines = i_height;
p_pic->p[ Y_PLANE ].i_pitch = i_width;
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;
p_pic->i_planes = 1;
break;
+ case FOURCC_RV24:
+ p_pic->p->i_lines = i_height;
+ p_pic->p->i_pitch = i_width * 3;
+ p_pic->p->i_visible_pitch = p_pic->p->i_pitch;
+ p_pic->p->i_pixel_pitch = 3;
+/* FIXME: p_heap isn't always reachable
+ p_pic->p_heap->i_rmask = 0xff0000;
+ p_pic->p_heap->i_gmask = 0x00ff00;
+ p_pic->p_heap->i_bmask = 0x0000ff; */
+ p_pic->i_planes = 1;
+ break;
+
case FOURCC_RV32:
p_pic->p->i_lines = i_height;
p_pic->p->i_pitch = i_width * 4;
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--; )
}
}
}
+ p_dest->date = p_src->date;
}
-