Commit 1a674481 authored by Gildas Bazin's avatar Gildas Bazin

* configure.ac: fix for wxWindows headers detection.
* all: changed the prototype of vout_AllocatePicture() and vout_InitPicture().
* src/video_output/vout_pictures.c: new vout_InitFormat() function that initialises a video_frame_format_t structure.
* include/vlc_video.h: extended video_frame_format_t.
* modules/codec/rawvideo.c: ported to the new decoder api.
* modules/video_output/x11/*: simplifications.
parent 170d7aa6
dnl Autoconf settings for vlc dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.93 2003/10/24 16:34:30 sam Exp $ dnl $Id: configure.ac,v 1.94 2003/10/24 21:27:06 gbazin Exp $
AC_INIT(vlc,0.6.3-cvs) AC_INIT(vlc,0.6.3-cvs)
...@@ -2779,6 +2779,7 @@ then ...@@ -2779,6 +2779,7 @@ then
then then
AC_MSG_ERROR([Your development package for wxWindows is too old, you need at least version 2.3.0. Please upgrade and try again. Alternatively you can also configure with --disable-wxwindows.]) AC_MSG_ERROR([Your development package for wxWindows is too old, you need at least version 2.3.0. Please upgrade and try again. Alternatively you can also configure with --disable-wxwindows.])
fi fi
AC_LANG_PUSH(C++)
AX_ADD_CXXFLAGS([wxwindows],[`${WX_CONFIG} --cxxflags`]) AX_ADD_CXXFLAGS([wxwindows],[`${WX_CONFIG} --cxxflags`])
AX_ADD_LDFLAGS([wxwindows],[`${WX_CONFIG} --libs`]) AX_ADD_LDFLAGS([wxwindows],[`${WX_CONFIG} --libs`])
# now look for the wxprec.h header # now look for the wxprec.h header
...@@ -2794,6 +2795,7 @@ then ...@@ -2794,6 +2795,7 @@ then
ALIASES="${ALIASES} wxvlc" ALIASES="${ALIASES} wxvlc"
fi fi
CPPFLAGS="${CPPFLAGS_save}" CPPFLAGS="${CPPFLAGS_save}"
AC_LANG_POP(C++)
fi fi
fi fi
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_output.h : video output thread * video_output.h : video output thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.99 2003/10/04 15:51:22 sigmunau Exp $ * $Id: video_output.h,v 1.100 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -200,8 +200,9 @@ VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t, ...@@ -200,8 +200,9 @@ VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t,
VLC_EXPORT( int, vout_ChromaCmp, ( uint32_t, uint32_t ) ); VLC_EXPORT( int, vout_ChromaCmp, ( uint32_t, uint32_t ) );
VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, vlc_bool_t, vlc_bool_t, unsigned int ) ); VLC_EXPORT( picture_t *, vout_CreatePicture, ( vout_thread_t *, vlc_bool_t, vlc_bool_t, unsigned int ) );
VLC_EXPORT( void, vout_InitPicture, ( vlc_object_t *, picture_t *, int, int, uint32_t ) ); VLC_EXPORT( void, vout_InitFormat, ( video_frame_format_t *, uint32_t, int, int, int ) );
VLC_EXPORT( void, vout_AllocatePicture,( vout_thread_t *, picture_t *, int, int, uint32_t ) ); VLC_EXPORT( void, vout_InitPicture, ( vlc_object_t *, picture_t *, uint32_t, int, int, int ) );
VLC_EXPORT( void, vout_AllocatePicture,( vout_thread_t *, picture_t *, uint32_t, int, int, int ) );
VLC_EXPORT( void, vout_DestroyPicture, ( vout_thread_t *, picture_t * ) ); VLC_EXPORT( void, vout_DestroyPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_DisplayPicture, ( vout_thread_t *, picture_t * ) ); VLC_EXPORT( void, vout_DisplayPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_DatePicture, ( vout_thread_t *, picture_t *, mtime_t ) ); VLC_EXPORT( void, vout_DatePicture, ( vout_thread_t *, picture_t *, mtime_t ) );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.81 2003/10/08 19:40:42 gbazin Exp $ * $Id: vlc_common.h,v 1.82 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@via.ecp.fr> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -250,9 +250,9 @@ typedef struct audio_date_t audio_date_t; ...@@ -250,9 +250,9 @@ typedef struct audio_date_t audio_date_t;
/* Video */ /* Video */
typedef struct vout_thread_t vout_thread_t; typedef struct vout_thread_t vout_thread_t;
typedef struct vout_font_t vout_font_t;
typedef struct vout_sys_t vout_sys_t; typedef struct vout_sys_t vout_sys_t;
typedef struct chroma_sys_t chroma_sys_t; typedef struct chroma_sys_t chroma_sys_t;
typedef struct video_frame_format_t video_frame_format_t;
typedef struct picture_t picture_t; typedef struct picture_t picture_t;
typedef struct picture_sys_t picture_sys_t; typedef struct picture_sys_t picture_sys_t;
typedef struct picture_heap_t picture_heap_t; typedef struct picture_heap_t picture_heap_t;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* includes all common video types and constants. * includes all common video types and constants.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vlc_video.h,v 1.4 2003/10/08 21:01:07 gbazin Exp $ * $Id: vlc_video.h,v 1.5 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* *
...@@ -28,14 +28,21 @@ ...@@ -28,14 +28,21 @@
/** /**
* Description of a video frame * Description of a video frame
*/ */
typedef struct video_frame_format_t struct video_frame_format_t
{ {
unsigned int i_width; /**< picture width */
unsigned int i_height; /**< picture height */
vlc_fourcc_t i_chroma; /**< picture chroma */ vlc_fourcc_t i_chroma; /**< picture chroma */
unsigned int i_aspect; /**< aspect ratio */ unsigned int i_aspect; /**< aspect ratio */
} video_frame_format_t; unsigned int i_width; /**< picture width */
unsigned int i_height; /**< picture height */
unsigned int i_x_offset; /**< start offset of visible area */
unsigned int i_y_offset; /**< start offset of visible area */
unsigned int i_visible_width; /**< width of visible area */
unsigned int i_visible_height; /**< height of visible area */
unsigned int i_bits_per_pixel; /**< number of bits per pixel */
};
/** /**
* Description of a planar graphic field * Description of a planar graphic field
...@@ -66,6 +73,12 @@ typedef struct plane_t ...@@ -66,6 +73,12 @@ typedef struct plane_t
*/ */
struct picture_t struct picture_t
{ {
/** \name Picture format
* Describes the properties of the picture
* @{*/
video_frame_format_t format;
/**@}*/
/** Picture data - data can always be freely modified, but p_data may /** Picture data - data can always be freely modified, but p_data may
* NEVER be modified. A direct buffer can be handled as the plugin * NEVER be modified. A direct buffer can be handled as the plugin
* wishes, it can even swap p_pixels buffers. */ * wishes, it can even swap p_pixels buffers. */
...@@ -224,22 +237,6 @@ struct subpicture_t ...@@ -224,22 +237,6 @@ struct subpicture_t
int i_width; /**< picture width */ int i_width; /**< picture width */
int i_height; /**< picture height */ int i_height; /**< picture height */
/**@}*/ /**@}*/
#if 0
/* Additionnal properties depending of the subpicture type */
union
{
/* Text subpictures properties - text is stored in data area, in ASCIIZ
* format */
struct
{
vout_font_t * p_font; /* font, NULL for default */
int i_style; /* text style */
uint32_t i_char_color; /* character color */
uint32_t i_border_color; /* border color */
uint32_t i_bg_color; /* background color */
} text;
} type;
#endif
/** Pointer to function that renders this subtitle in a picture */ /** Pointer to function that renders this subtitle in a picture */
void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * ); void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* v4l.c : Video4Linux input module for vlc * v4l.c : Video4Linux input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: v4l.c,v 1.24 2003/09/07 22:49:05 fenrir Exp $ * $Id: v4l.c,v 1.25 2003/10/24 21:27:06 gbazin Exp $
* *
* Author: Laurent Aimar <fenrir@via.ecp.fr> * Author: Laurent Aimar <fenrir@via.ecp.fr>
* Paul Forgey <paulf at aphrodite dot com> * Paul Forgey <paulf at aphrodite dot com>
...@@ -858,8 +858,9 @@ static int AccessOpen( vlc_object_t *p_this ) ...@@ -858,8 +858,9 @@ static int AccessOpen( vlc_object_t *p_this )
else else
{ {
/* Fill in picture_t fields */ /* Fill in picture_t fields */
vout_InitPicture( VLC_OBJECT(p_input), &p_sys->pic, vout_InitPicture( VLC_OBJECT(p_input), &p_sys->pic, p_sys->i_fourcc,
p_sys->i_width, p_sys->i_height, p_sys->i_fourcc ); p_sys->i_width, p_sys->i_height, p_sys->i_width *
VOUT_ASPECT_FACTOR / p_sys->i_height );
if( !p_sys->pic.i_planes ) if( !p_sys->pic.i_planes )
{ {
msg_Err( p_input, "unsupported chroma" ); msg_Err( p_input, "unsupported chroma" );
......
/***************************************************************************** /*****************************************************************************
* rawvideo.c: Pseudo audio decoder; for raw video data * rawvideo.c: Pseudo video decoder/packetizer for raw video data
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: rawvideo.c,v 1.6 2003/09/02 20:19:25 gbazin Exp $ * $Id: rawvideo.c,v 1.7 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -24,49 +24,74 @@ ...@@ -24,49 +24,74 @@
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/vout.h> #include <vlc/vout.h>
#include <vlc/decoder.h> #include <vlc/decoder.h>
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc/sout.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include "codecs.h" #include "codecs.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * decoder_sys_t : raw video decoder descriptor
*****************************************************************************/ *****************************************************************************/
struct decoder_sys_t
typedef struct
{ {
/* Input properties */ /* Module mode */
decoder_fifo_t *p_fifo; vlc_bool_t b_packetizer;
/*
* Input properties
*/
int i_raw_size; int i_raw_size;
/* Output properties */ /*
* Output properties
*/
vout_thread_t *p_vout;
mtime_t pts; /*
* Packetizer output properties
*/
sout_packetizer_input_t *p_sout_input;
sout_format_t sout_format;
vout_thread_t *p_vout; /*
* Common properties
*/
mtime_t i_pts;
} vdec_thread_t; };
/****************************************************************************
* Local prototypes
****************************************************************************/
static int OpenDecoder ( vlc_object_t * ); static int OpenDecoder ( vlc_object_t * );
static int OpenPacketizer( vlc_object_t * );
static int InitDecoder ( decoder_t * );
static int RunDecoder ( decoder_t *, block_t * );
static int EndDecoder ( decoder_t * );
static int RunDecoder ( decoder_fifo_t * ); static int DecodeFrame ( decoder_t *, block_t * );
static int InitThread ( vdec_thread_t * ); static int SendFrame ( decoder_t *, block_t * );
static void DecodeThread ( vdec_thread_t * );
static void EndThread ( vdec_thread_t * );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
set_description( _("Pseudo Raw Video decoder") ); set_description( _("Pseudo Raw Video decoder") );
set_capability( "decoder", 50 ); set_capability( "decoder", 50 );
set_callbacks( OpenDecoder, NULL ); set_callbacks( OpenDecoder, NULL );
vlc_module_end();
add_submodule();
set_description( _("Pseudo Raw Video packetizer") );
set_capability( "packetizer", 100 );
set_callbacks( OpenPacketizer, NULL );
vlc_module_end();
/***************************************************************************** /*****************************************************************************
* OpenDecoder: probe the decoder and return score * OpenDecoder: probe the decoder and return score
...@@ -98,224 +123,253 @@ static int OpenDecoder( vlc_object_t *p_this ) ...@@ -98,224 +123,253 @@ static int OpenDecoder( vlc_object_t *p_this )
case VLC_FOURCC('R','V','2','4'): case VLC_FOURCC('R','V','2','4'):
case VLC_FOURCC('R','V','1','6'): case VLC_FOURCC('R','V','1','6'):
case VLC_FOURCC('R','V','1','5'): case VLC_FOURCC('R','V','1','5'):
break;
p_dec->pf_run = RunDecoder;
return VLC_SUCCESS;
default: default:
return VLC_EGENERIC; return VLC_EGENERIC;
} }
}
/*****************************************************************************
* RunDecoder: this function is called just after the thread is created
*****************************************************************************/
static int RunDecoder( decoder_fifo_t *p_fifo )
{
vdec_thread_t *p_vdec;
int b_error;
if( !( p_vdec = malloc( sizeof( vdec_thread_t ) ) ) )
{
msg_Err( p_fifo, "out of memory" );
DecoderError( p_fifo );
return( -1 );
}
memset( p_vdec, 0, sizeof( vdec_thread_t ) );
p_vdec->p_fifo = p_fifo; p_dec->pf_init = InitDecoder;
p_dec->pf_decode = RunDecoder;
p_dec->pf_end = EndDecoder;
if( InitThread( p_vdec ) != 0 ) /* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{ {
DecoderError( p_fifo ); msg_Err( p_dec, "out of memory" );
return( -1 ); return VLC_EGENERIC;
} }
p_dec->p_sys->b_packetizer = VLC_FALSE;
while( ( !p_vdec->p_fifo->b_die )&&( !p_vdec->p_fifo->b_error ) ) return VLC_SUCCESS;
{ }
DecodeThread( p_vdec );
}
static int OpenPacketizer( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
if( ( b_error = p_vdec->p_fifo->b_error ) ) int i_ret = OpenDecoder( p_this );
{
DecoderError( p_vdec->p_fifo );
}
EndThread( p_vdec ); if( i_ret == VLC_SUCCESS ) p_dec->p_sys->b_packetizer = VLC_TRUE;
if( b_error )
{
return( -1 );
}
return( 0 ); return i_ret;
} }
#define FREE( p ) if( p ) { free( p ); p = NULL; }
/***************************************************************************** /*****************************************************************************
* InitThread: initialize data before entering main loop * InitDecoder: Initalize the decoder
*****************************************************************************/ *****************************************************************************/
static int InitThread( vdec_thread_t * p_vdec ) static int InitDecoder( decoder_t *p_dec )
{ {
picture_t pic; decoder_sys_t *p_sys = p_dec->p_sys;
int i; video_frame_format_t format;
p_sys->i_pts = 0;
p_sys->p_sout_input = NULL;
p_sys->sout_format.i_cat = VIDEO_ES;
p_sys->sout_format.i_block_align = 0;
p_sys->sout_format.i_bitrate = 0;
p_sys->sout_format.i_extra_data = 0;
p_sys->sout_format.p_extra_data = NULL;
#define bih ((BITMAPINFOHEADER*)p_vdec->p_fifo->p_bitmapinfoheader) #define bih ((BITMAPINFOHEADER*)p_dec->p_fifo->p_bitmapinfoheader)
if( bih == NULL ) if( bih == NULL )
{ {
msg_Err( p_vdec->p_fifo, msg_Err( p_dec, "info missing, fatal" );
"info missing, fatal" ); return VLC_EGENERIC;
return( VLC_EGENERIC );
} }
if( bih->biWidth <= 0 || bih->biHeight <= 0 ) if( bih->biWidth <= 0 || bih->biHeight <= 0 )
{ {
msg_Err( p_vdec->p_fifo, msg_Err( p_dec, "invalid display size %dx%d",
"invalid display size %dx%d",
bih->biWidth, bih->biHeight ); bih->biWidth, bih->biHeight );
return( VLC_EGENERIC ); return VLC_EGENERIC;
} }
p_vdec->p_vout = vout_Request( p_vdec->p_fifo, NULL, if( p_sys->b_packetizer )
{
/* add an input for the stream ouput */
p_sys->sout_format.i_width = bih->biWidth;
p_sys->sout_format.i_height = bih->biHeight;
p_sys->sout_format.i_fourcc = p_dec->p_fifo->i_fourcc;
p_sys->p_sout_input =
sout_InputNew( p_dec, &p_sys->sout_format );
if( !p_sys->p_sout_input )
{
msg_Err( p_dec, "cannot add a new stream" );
return VLC_EGENERIC;
}
}
else
{
/* Initialize video output */
p_sys->p_vout = vout_Request( p_dec, NULL,
bih->biWidth, bih->biHeight, bih->biWidth, bih->biHeight,
p_vdec->p_fifo->i_fourcc, p_dec->p_fifo->i_fourcc,
VOUT_ASPECT_FACTOR * bih->biWidth / VOUT_ASPECT_FACTOR * bih->biWidth /
bih->biHeight ); bih->biHeight );
if( p_sys->p_vout == NULL )
if( p_vdec->p_vout == NULL )
{ {
msg_Err( p_vdec->p_fifo, "failed created vout" ); msg_Err( p_dec, "failed to create vout" );
return( VLC_EGENERIC ); return VLC_EGENERIC;
} }
/* Find out p_vdec->i_raw_size */
vout_InitPicture( VLC_OBJECT(p_vdec->p_fifo), &pic,
bih->biWidth, bih->biHeight, p_vdec->p_fifo->i_fourcc );
p_vdec->i_raw_size = 0;
for( i = 0; i < pic.i_planes; i++ )
{
p_vdec->i_raw_size += pic.p[i].i_lines * pic.p[i].i_visible_pitch;
} }
return( VLC_SUCCESS ); /* Find out p_vdec->i_raw_size */
vout_InitFormat( &format, p_dec->p_fifo->i_fourcc,
bih->biWidth, bih->biHeight,
bih->biWidth * VOUT_ASPECT_FACTOR / bih->biHeight );
p_sys->i_raw_size = format.i_bits_per_pixel *
format.i_width * format.i_height / 8;
#undef bih #undef bih
}
return VLC_SUCCESS;
}
static void FillPicture( pes_packet_t *p_pes, picture_t *p_pic ) /****************************************************************************
* RunDecoder: the whole thing
****************************************************************************
* This function must be fed with ogg packets.
****************************************************************************/
static int RunDecoder( decoder_t *p_dec, block_t *p_block )
{ {
int i_plane; decoder_sys_t *p_sys = p_dec->p_sys;
int i_ret;
data_packet_t *p_data; #if 0
uint8_t *p_src; if( !aout_DateGet( &p_sys->end_date ) && !p_block->i_pts )
int i_src;
p_data = p_pes->p_first;
p_src = p_data->p_payload_start;
i_src = p_data->p_payload_end - p_data->p_payload_start;
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{ {
/* We've just started the stream, wait for the first PTS. */
block_Release( p_block );
return VLC_SUCCESS;
}
#endif
uint8_t *p_dst; /* Date management */
int i_dst; if( p_block->i_pts > 0 && p_block->i_pts != p_sys->i_pts )
p_dst = p_pic->p[i_plane].p_pixels;
i_dst = p_pic->p[i_plane].i_pitch * p_pic->p[i_plane].i_lines;
while( i_dst > 0 )
{ {
int i_copy; p_sys->i_pts = p_block->i_pts;
}
i_copy = __MIN( i_src, i_dst ); if( p_block->i_buffer < p_sys->i_raw_size )
if( i_copy > 0 )
{ {
memcpy( p_dst, p_src, i_copy ); msg_Warn( p_dec, "invalid frame size (%d < %d)",
p_block->i_buffer, p_sys->i_raw_size );
block_Release( p_block );
return VLC_EGENERIC;
} }
i_dst -= i_copy;
p_dst += i_copy;
i_src -= i_copy; if( p_sys->b_packetizer )
p_src += i_copy;
if( i_src <= 0 )
{ {
do i_ret = SendFrame( p_dec, p_block );
{
p_data = p_data->p_next;
if( p_data == NULL )
{
return;
}
p_src = p_data->p_payload_start;
i_src = p_data->p_payload_end - p_data->p_payload_start;
} while( i_src <= 0 );
}
} }
else
{
i_ret = DecodeFrame( p_dec, p_block );
} }
/* Date management: 1 frame per packet */
p_sys->i_pts += ( I64C(1000000) * 1.0 / 25 /*FIXME*/ );
block_Release( p_block );
return i_ret;
} }
/***************************************************************************** /*****************************************************************************
* DecodeThread: decodes a frame * FillPicture:
*****************************************************************************/ *****************************************************************************/
static void DecodeThread( vdec_thread_t *p_vdec ) static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
{ {
int i_size; uint8_t *p_src, *p_dst;
pes_packet_t *p_pes; int i_src, i_plane, i_line, i_width;
picture_t *p_pic;
p_src = p_block->p_buffer;
i_src = p_block->i_buffer;
/* **** get frame **** */ for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
input_ExtractPES( p_vdec->p_fifo, &p_pes );
if( !p_pes )
{ {
p_vdec->p_fifo->b_error = 1; p_dst = p_pic->p[i_plane].p_pixels;
return; i_width = p_pic->p[i_plane].i_visible_pitch;
}
i_size = p_pes->i_pes_size;
if( i_size < p_vdec->i_raw_size ) for( i_line = 0; i_line < p_pic->p[i_plane].i_lines; i_line++ )
{ {
msg_Warn( p_vdec->p_fifo, "invalid frame size (%d < %d)", p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_width );
i_size, p_vdec->i_raw_size ); p_src += i_width;
//input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes ); p_dst += p_pic->p[i_plane].i_pitch;
return;
} }
}
}
/*****************************************************************************
* DecodeFrame: decodes a video frame.
*****************************************************************************/
static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
picture_t *p_pic;
/* **** get video picture **** */ /* Get a new picture */
while( !(p_pic = vout_CreatePicture( p_vdec->p_vout, 0, 0, 0 ) ) ) while( !(p_pic = vout_CreatePicture( p_sys->p_vout, 0, 0, 0 ) ) )
{ {
if( p_vdec->p_fifo->b_die || p_vdec->p_fifo->b_error ) if( p_dec->p_fifo->b_die || p_dec->p_fifo->b_error )
{ {
return; return VLC_EGENERIC;
} }
msleep( VOUT_OUTMEM_SLEEP ); msleep( VOUT_OUTMEM_SLEEP );
} }
if( !p_pic ) return VLC_EGENERIC;
FillPicture( p_dec, p_block, p_pic );
/* **** fill p_pic **** */ vout_DatePicture( p_sys->p_vout, p_pic, p_sys->i_pts );
FillPicture( p_pes, p_pic ); vout_DisplayPicture( p_sys->p_vout, p_pic );
/* **** display p_pic **** */ return VLC_SUCCESS;
vout_DatePicture( p_vdec->p_vout, p_pic, p_pes->i_pts); }
vout_DisplayPicture( p_vdec->p_vout, p_pic );
/*****************************************************************************
* SendFrame: send a video frame to the stream output.
*****************************************************************************/
static int SendFrame( decoder_t *p_dec, block_t *p_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes ); sout_buffer_t *p_sout_buffer =
} sout_BufferNew( p_sys->p_sout_input->p_sout, p_block->i_buffer );
if( !p_sout_buffer ) return VLC_EGENERIC;
p_dec->p_vlc->pf_memcpy( p_sout_buffer->p_buffer,
p_block->p_buffer, p_block->i_buffer );
p_sout_buffer->i_dts = p_sout_buffer->i_pts = p_sys->i_pts;
sout_InputSendBuffer( p_sys->p_sout_input, p_sout_buffer );
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* EndThread : faad decoder thread destruction * EndDecoder: decoder destruction
*****************************************************************************/ *****************************************************************************/
static void EndThread (vdec_thread_t *p_vdec) static int EndDecoder( decoder_t *p_dec )
{ {
if( p_vdec->p_vout ) decoder_sys_t *p_sys = p_dec->p_sys;
if( !p_sys->b_packetizer )
{
vout_Request( p_dec, p_sys->p_vout, 0, 0, 0, 0 );
}
if( p_sys->p_sout_input != NULL )
{ {
vout_Request( p_vdec->p_fifo, p_vdec->p_vout, 0, 0, 0, 0 ); sout_InputDelete( p_sys->p_sout_input );
} }
msg_Dbg( p_vdec->p_fifo, "raw video decoder closed" ); free( p_sys );
free( p_vdec ); return VLC_SUCCESS;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_dummy.c: Dummy video output display method for testing purposes * vout_dummy.c: Dummy video output display method for testing purposes
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: vout.c,v 1.4 2003/03/28 11:34:52 sigmunau Exp $ * $Id: vout.c,v 1.5 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -133,9 +133,9 @@ static int Init( vout_thread_t *p_vout ) ...@@ -133,9 +133,9 @@ static int Init( vout_thread_t *p_vout )
break; break;
} }
vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_width, vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_chroma,
p_vout->output.i_height, p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_chroma ); p_vout->output.i_aspect );
if( p_pic->i_planes == 0 ) if( p_pic->i_planes == 0 )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* transcode.c * transcode.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * Copyright (C) 2001, 2002 VideoLAN
* $Id: transcode.c,v 1.42 2003/10/09 19:40:29 gbazin Exp $ * $Id: transcode.c,v 1.43 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -1661,8 +1661,10 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream, ...@@ -1661,8 +1661,10 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
int i_plane; int i_plane;
vout_InitPicture( VLC_OBJECT(p_stream), &pic, vout_InitPicture( VLC_OBJECT(p_stream), &pic,
id->p_encoder->format.video.i_chroma,
id->f_dst.i_width, id->f_dst.i_height, id->f_dst.i_width, id->f_dst.i_height,
id->p_encoder->format.video.i_chroma ); id->f_dst.i_width * VOUT_ASPECT_FACTOR /
id->f_dst.i_height );
for( i_plane = 0; i_plane < pic.i_planes; i_plane++ ) for( i_plane = 0; i_plane < pic.i_planes; i_plane++ )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* filter_common.h: Common filter functions * filter_common.h: Common filter functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002, 2003 VideoLAN * Copyright (C) 2001, 2002, 2003 VideoLAN
* $Id: filter_common.h,v 1.3 2003/10/15 22:49:48 gbazin Exp $ * $Id: filter_common.h,v 1.4 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -43,10 +43,10 @@ ...@@ -43,10 +43,10 @@
} \ } \
\ \
/* Allocate the picture */ \ /* Allocate the picture */ \
vout_AllocatePicture( p_vout, p_pic, \ vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_chroma, \
p_vout->output.i_width, \ p_vout->output.i_width, \
p_vout->output.i_height, \ p_vout->output.i_height, \
p_vout->output.i_chroma ); \ p_vout->output.i_aspect ); \
\ \
if( !p_pic->i_planes ) \ if( !p_pic->i_planes ) \
{ \ { \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins * xcommon.c: Functions common to the X11 and XVideo plugins
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.32 2003/10/08 21:03:35 gbazin Exp $ * $Id: xcommon.c,v 1.33 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -1146,6 +1146,10 @@ static void DestroyWindow( vout_thread_t *p_vout, x11_window_t *p_win ) ...@@ -1146,6 +1146,10 @@ static void DestroyWindow( vout_thread_t *p_vout, x11_window_t *p_win )
*****************************************************************************/ *****************************************************************************/
static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
#ifdef MODULE_NAME_IS_xvideo
int i_plane;
#endif
/* We know the chroma, allocate a buffer which will be used /* We know the chroma, allocate a buffer which will be used
* directly by the decoder */ * directly by the decoder */
p_pic->p_sys = malloc( sizeof( picture_sys_t ) ); p_pic->p_sys = malloc( sizeof( picture_sys_t ) );
...@@ -1155,6 +1159,11 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1155,6 +1159,11 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
return -1; return -1;
} }
/* Fill in picture_t fields */
vout_InitPicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,
p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_aspect );
#ifdef HAVE_SYS_SHM_H #ifdef HAVE_SYS_SHM_H
if( p_vout->p_sys->b_shm ) if( p_vout->p_sys->b_shm )
{ {
...@@ -1178,6 +1187,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1178,6 +1187,7 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
CreateImage( p_vout, p_vout->p_sys->p_display, CreateImage( p_vout, p_vout->p_sys->p_display,
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
p_vout->p_sys->i_xvport, p_vout->output.i_chroma, p_vout->p_sys->i_xvport, p_vout->output.i_chroma,
p_pic->format.i_bits_per_pixel,
#else #else
p_vout->p_sys->p_visual, p_vout->p_sys->p_visual,
p_vout->p_sys->i_screen_depth, p_vout->p_sys->i_screen_depth,
...@@ -1196,148 +1206,50 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1196,148 +1206,50 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
case VLC_FOURCC('I','4','2','0'): case VLC_FOURCC('I','4','2','0'):
p_pic->Y_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[0];
p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_image->pitches[0];
p_pic->p[Y_PLANE].i_pixel_pitch = 1;
p_pic->p[Y_PLANE].i_visible_pitch = p_vout->output.i_width;
p_pic->U_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[1];
p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_image->pitches[1];
p_pic->p[U_PLANE].i_pixel_pitch = 1;
p_pic->p[U_PLANE].i_visible_pitch = p_vout->output.i_width / 2;
p_pic->V_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[2];
p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_image->pitches[2];
p_pic->p[V_PLANE].i_pixel_pitch = 1;
p_pic->p[V_PLANE].i_visible_pitch = p_vout->output.i_width / 2;
p_pic->i_planes = 3;
break;
case VLC_FOURCC('Y','V','1','2'): case VLC_FOURCC('Y','V','1','2'):
p_pic->Y_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[0];
p_pic->p[Y_PLANE].i_lines = p_vout->output.i_height;
p_pic->p[Y_PLANE].i_pitch = p_pic->p_sys->p_image->pitches[0];
p_pic->p[Y_PLANE].i_pixel_pitch = 1;
p_pic->p[Y_PLANE].i_visible_pitch = p_pic->p[Y_PLANE].i_pitch;
p_pic->p[Y_PLANE].i_visible_pitch = p_vout->output.i_width;
p_pic->U_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[2];
p_pic->p[U_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[U_PLANE].i_pitch = p_pic->p_sys->p_image->pitches[2];
p_pic->p[U_PLANE].i_pixel_pitch = 1;
p_pic->p[U_PLANE].i_visible_pitch = p_vout->output.i_width / 2;
p_pic->V_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[1];
p_pic->p[V_PLANE].i_lines = p_vout->output.i_height / 2;
p_pic->p[V_PLANE].i_pitch = p_pic->p_sys->p_image->pitches[1];
p_pic->p[V_PLANE].i_pixel_pitch = 1;
p_pic->p[V_PLANE].i_visible_pitch = p_vout->output.i_width / 2;
p_pic->i_planes = 3;
break;
case VLC_FOURCC('Y','2','1','1'): case VLC_FOURCC('Y','2','1','1'):
p_pic->p->p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[0];
p_pic->p->i_lines = p_vout->output.i_height;
/* XXX: this just looks so plain wrong... check it out ! */
p_pic->p->i_pitch = p_pic->p_sys->p_image->pitches[0] / 4;
p_pic->p->i_pixel_pitch = 4;
p_pic->p->i_visible_pitch = p_vout->output.i_width * 4;
p_pic->i_planes = 1;
break;
case VLC_FOURCC('Y','U','Y','2'): case VLC_FOURCC('Y','U','Y','2'):
case VLC_FOURCC('U','Y','V','Y'): case VLC_FOURCC('U','Y','V','Y'):
p_pic->p->p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[0];
p_pic->p->i_lines = p_vout->output.i_height;
p_pic->p->i_pitch = p_pic->p_sys->p_image->pitches[0];
p_pic->p->i_pixel_pitch = 2;
p_pic->p->i_visible_pitch = p_vout->output.i_width * 2;
p_pic->i_planes = 1;
break;
case VLC_FOURCC('R','V','1','5'): case VLC_FOURCC('R','V','1','5'):
p_pic->p->p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[0];
p_pic->p->i_lines = p_vout->output.i_height;
p_pic->p->i_pitch = p_pic->p_sys->p_image->pitches[0];
p_pic->p->i_pixel_pitch = 2;
p_pic->p->i_visible_pitch = p_vout->output.i_width * 2;
p_pic->i_planes = 1;
break;
case VLC_FOURCC('R','V','1','6'): case VLC_FOURCC('R','V','1','6'):
case VLC_FOURCC('R','V','2','4'): /* Fixme: pixel pitch == 4 ? */
case VLC_FOURCC('R','V','3','2'):
p_pic->p->p_pixels = p_pic->p_sys->p_image->data for( i_plane = 0; i_plane < p_pic->p_sys->p_image->num_planes;
+ p_pic->p_sys->p_image->offsets[0]; i_plane++ )
p_pic->p->i_lines = p_vout->output.i_height; {
p_pic->p->i_pitch = p_pic->p_sys->p_image->pitches[0]; p_pic->p[i_plane].p_pixels = p_pic->p_sys->p_image->data
p_pic->p->i_pixel_pitch = 2; + p_pic->p_sys->p_image->offsets[i_plane];
p_pic->p->i_visible_pitch = p_vout->output.i_width * 2; p_pic->p[i_plane].i_pitch =
p_pic->p_sys->p_image->pitches[i_plane];
p_pic->i_planes = 1; }
if( p_vout->output.i_chroma == VLC_FOURCC('Y','V','1','2') )
{
/* U and V inverted compared to I420
* Fixme: this should be handled by the vout core */
p_pic->U_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[2];
p_pic->V_PIXELS = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[1];
}
break; break;
#else #else
case VLC_FOURCC('R','G','B','2'): case VLC_FOURCC('R','G','B','2'):
p_pic->p->p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->xoffset;
p_pic->p->i_lines = p_pic->p_sys->p_image->height;
p_pic->p->i_pitch = p_pic->p_sys->p_image->bytes_per_line;
p_pic->p->i_pixel_pitch = p_pic->p_sys->p_image->depth;
p_pic->p->i_visible_pitch = p_pic->p_sys->p_image->width;
p_pic->i_planes = 1;
break;
case VLC_FOURCC('R','V','1','6'): case VLC_FOURCC('R','V','1','6'):
case VLC_FOURCC('R','V','1','5'): case VLC_FOURCC('R','V','1','5'):
p_pic->p->p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->xoffset;
p_pic->p->i_lines = p_pic->p_sys->p_image->height;
p_pic->p->i_pitch = p_pic->p_sys->p_image->bytes_per_line;
p_pic->p->i_pixel_pitch = p_pic->p_sys->p_image->depth;
p_pic->p->i_visible_pitch = 2 * p_pic->p_sys->p_image->width;
p_pic->i_planes = 1;
break;
case VLC_FOURCC('R','V','3','2'):
case VLC_FOURCC('R','V','2','4'): case VLC_FOURCC('R','V','2','4'):
case VLC_FOURCC('R','V','3','2'):
p_pic->p->i_lines = p_pic->p_sys->p_image->height;
p_pic->p->p_pixels = p_pic->p_sys->p_image->data p_pic->p->p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->xoffset; + p_pic->p_sys->p_image->xoffset;
p_pic->p->i_lines = p_pic->p_sys->p_image->height;
p_pic->p->i_pitch = p_pic->p_sys->p_image->bytes_per_line; p_pic->p->i_pitch = p_pic->p_sys->p_image->bytes_per_line;
p_pic->p->i_pixel_pitch = p_pic->p_sys->p_image->depth;
p_pic->p->i_visible_pitch = 4 * p_pic->p_sys->p_image->width;
p_pic->i_planes = 1;
/* p_pic->p->i_pixel_pitch = 4 for RV24 but this should be set
* properly by vout_InitPicture() */
p_pic->p->i_visible_pitch = p_pic->p->i_pixel_pitch
* p_pic->p_sys->p_image->width;
break; break;
#endif #endif
...@@ -2148,7 +2060,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout, ...@@ -2148,7 +2060,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
/* Allocate memory for image */ /* Allocate memory for image */
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
p_data = (byte_t *) malloc( i_width * i_height * 2 ); /* XXX */ p_data = (byte_t *) malloc( i_width * i_height * i_bits_per_pixel / 8 );
#else #else
i_bytes_per_line = i_width * i_bytes_per_pixel; i_bytes_per_line = i_width * i_bytes_per_pixel;
p_data = (byte_t *) malloc( i_bytes_per_line * i_height ); p_data = (byte_t *) malloc( i_bytes_per_line * i_height );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* xcommon.h: Defines common to the X11 and XVideo plugins * xcommon.h: Defines common to the X11 and XVideo plugins
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.h,v 1.8 2003/08/03 23:11:21 gbazin Exp $ * $Id: xcommon.h,v 1.9 2003/10/24 21:27:06 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
*****************************************************************************/ *****************************************************************************/
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
# define IMAGE_TYPE XvImage # define IMAGE_TYPE XvImage
# define EXTRA_ARGS int i_xvport, int i_chroma # define EXTRA_ARGS int i_xvport, int i_chroma, int i_bits_per_pixel
# define EXTRA_ARGS_SHM int i_xvport, int i_chroma, XShmSegmentInfo *p_shm # define EXTRA_ARGS_SHM int i_xvport, int i_chroma, XShmSegmentInfo *p_shm
# define DATA_SIZE(p) (p)->data_size # define DATA_SIZE(p) (p)->data_size
# define IMAGE_FREE XFree /* There is nothing like XvDestroyImage */ # define IMAGE_FREE XFree /* There is nothing like XvDestroyImage */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_pictures.c : picture management functions * vout_pictures.c : picture management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2000 VideoLAN * Copyright (C) 2000 VideoLAN
* $Id: vout_pictures.c,v 1.42 2003/08/28 21:11:54 gbazin Exp $ * $Id: vout_pictures.c,v 1.43 2003/10/24 21:27:07 gbazin Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -44,8 +44,8 @@ static void CopyPicture( vout_thread_t *, picture_t *, picture_t * ); ...@@ -44,8 +44,8 @@ static void CopyPicture( vout_thread_t *, picture_t *, picture_t * );
/***************************************************************************** /*****************************************************************************
* vout_DisplayPicture: display a picture * vout_DisplayPicture: display a picture
***************************************************************************** *****************************************************************************
* Remove the reservation flag of a picture, which will cause it to be ready for * Remove the reservation flag of a picture, which will cause it to be ready
* display. The picture won't be displayed until vout_DatePicture has been * for display. The picture won't be displayed until vout_DatePicture has been
* called. * called.
*****************************************************************************/ *****************************************************************************/
void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic ) void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
...@@ -102,8 +102,9 @@ void vout_DatePicture( vout_thread_t *p_vout, ...@@ -102,8 +102,9 @@ void vout_DatePicture( vout_thread_t *p_vout,
***************************************************************************** *****************************************************************************
* This function creates a reserved image in the video output heap. * This function creates a reserved image in the video output heap.
* A null pointer is returned if the function fails. This method provides an * A null pointer is returned if the function fails. This method provides an
* already allocated zone of memory in the picture data fields. It needs locking * already allocated zone of memory in the picture data fields.
* since several pictures can be created by several producers threads. * It needs locking since several pictures can be created by several producers
* threads.
*****************************************************************************/ *****************************************************************************/
picture_t *vout_CreatePicture( vout_thread_t *p_vout, picture_t *vout_CreatePicture( vout_thread_t *p_vout,
vlc_bool_t b_progressive, vlc_bool_t b_progressive,
...@@ -164,9 +165,9 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, ...@@ -164,9 +165,9 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
*/ */
if( p_freepic != NULL ) if( p_freepic != NULL )
{ {
vout_AllocatePicture( p_vout, p_freepic, vout_AllocatePicture( p_vout, p_freepic, p_vout->render.i_chroma,
p_vout->render.i_width, p_vout->render.i_height, p_vout->render.i_width, p_vout->render.i_height,
p_vout->render.i_chroma ); p_vout->render.i_aspect );
if( p_freepic->i_planes ) if( p_freepic->i_planes )
{ {
...@@ -250,7 +251,7 @@ void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -250,7 +251,7 @@ void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
/***************************************************************************** /*****************************************************************************
* vout_UnlinkPicture: decrement reference counter of a picture * vout_UnlinkPicture: decrement reference counter of a picture
***************************************************************************** *****************************************************************************
* This function decrement the reference counter of a picture in the video heap. * This function decrement the reference counter of a picture in the video heap
*****************************************************************************/ *****************************************************************************/
void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic ) void vout_UnlinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
...@@ -455,17 +456,17 @@ void vout_PlacePicture( vout_thread_t *p_vout, ...@@ -455,17 +456,17 @@ void vout_PlacePicture( vout_thread_t *p_vout,
* how it gets displayed. * how it gets displayed.
*****************************************************************************/ *****************************************************************************/
void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic, void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic,
int i_width, int i_height, vlc_fourcc_t i_chroma ) vlc_fourcc_t i_chroma,
int i_width, int i_height, int i_aspect )
{ {
int i_bytes, i_index; int i_bytes, i_index;
vout_InitPicture( VLC_OBJECT(p_vout), p_pic, i_width, i_height, i_chroma ); vout_InitPicture( VLC_OBJECT(p_vout), p_pic, i_chroma,
i_width, i_height, i_aspect );
/* Calculate how big the new image should be */ /* Calculate how big the new image should be */
for( i_bytes = 0, i_index = 0; i_index < p_pic->i_planes; i_index++ ) i_bytes = p_pic->format.i_bits_per_pixel *
{ p_pic->format.i_width * p_pic->format.i_height / 8;
i_bytes += p_pic->p[ i_index ].i_lines * p_pic->p[ i_index ].i_pitch;
}
p_pic->p_data = vlc_memalign( &p_pic->p_data_orig, 16, i_bytes ); p_pic->p_data = vlc_memalign( &p_pic->p_data_orig, 16, i_bytes );
...@@ -486,6 +487,76 @@ void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -486,6 +487,76 @@ void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic,
} }
} }
/*****************************************************************************
* vout_InitFormat: initialise the video format fields given chroma/size.
*****************************************************************************
* This function initializes all the video_frame_format_t fields given the
* static properties of a picture (chroma and size).
*****************************************************************************/
void vout_InitFormat( video_frame_format_t *p_format, vlc_fourcc_t i_chroma,
int i_width, int i_height, int i_aspect )
{
p_format->i_chroma = i_chroma;
p_format->i_width = p_format->i_visible_width = i_width;
p_format->i_height = p_format->i_visible_height = i_height;
p_format->i_x_offset = p_format->i_y_offset = 0;
p_format->i_aspect = i_aspect;
#if 0
/* Assume we have square pixels */
if( i_width && i_height )
p_format->i_aspect = i_width * VOUT_ASPECT_FACTOR / i_height;
else
p_format->i_aspect = 0;
#endif
switch( i_chroma )
{
case FOURCC_I444:
p_format->i_bits_per_pixel = 24;
break;
case FOURCC_I422:
case FOURCC_YUY2:
p_format->i_bits_per_pixel = 16;
p_format->i_bits_per_pixel = 16;
break;
case FOURCC_I411:
case FOURCC_YV12:
case FOURCC_I420:
case FOURCC_IYUV:
p_format->i_bits_per_pixel = 12;
break;
case FOURCC_I410:
p_format->i_bits_per_pixel = 9;
break;
case FOURCC_Y211:
p_format->i_bits_per_pixel = 8;
break;
case FOURCC_RV32:
p_format->i_bits_per_pixel = 32;
break;
case FOURCC_RV24:
/* FIXME: Should be 24 here but x11 and our chroma conversion
* routines assume 32. */
#ifdef WIN32
p_format->i_bits_per_pixel = 24;
#else
p_format->i_bits_per_pixel = 32;
#endif
break;
case FOURCC_RV15:
case FOURCC_RV16:
p_format->i_bits_per_pixel = 16;
break;
case FOURCC_RGB2:
p_format->i_bits_per_pixel = 8;
break;
default:
p_format->i_bits_per_pixel = 0;
break;
}
}
/***************************************************************************** /*****************************************************************************
* vout_InitPicture: initialise the picture_t fields given chroma/size. * vout_InitPicture: initialise the picture_t fields given chroma/size.
***************************************************************************** *****************************************************************************
...@@ -493,7 +564,8 @@ void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic, ...@@ -493,7 +564,8 @@ void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic,
* size. It makes the assumption that stride == width. * size. It makes the assumption that stride == width.
*****************************************************************************/ *****************************************************************************/
void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic, void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
int i_width, int i_height, vlc_fourcc_t i_chroma ) vlc_fourcc_t i_chroma,
int i_width, int i_height, int i_aspect )
{ {
int i_index; int i_index;
...@@ -504,6 +576,8 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic, ...@@ -504,6 +576,8 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
p_pic->p[i_index].i_pixel_pitch = 1; p_pic->p[i_index].i_pixel_pitch = 1;
} }
vout_InitFormat( &p_pic->format, i_chroma, i_width, i_height, i_aspect );
/* Calculate coordinates */ /* Calculate coordinates */
switch( i_chroma ) switch( i_chroma )
{ {
...@@ -624,9 +698,17 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic, ...@@ -624,9 +698,17 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
case FOURCC_RV24: case FOURCC_RV24:
p_pic->p->i_lines = i_height; p_pic->p->i_lines = i_height;
/* FIXME: Should be 3 here but x11 and our chroma conversion
* routines assume 4. */
#ifdef WIN32
p_pic->p->i_pitch = i_width * 3; 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; p_pic->p->i_pixel_pitch = 3;
#else
p_pic->p->i_pitch = i_width * 4;
p_pic->p->i_pixel_pitch = 4;
#endif
p_pic->p->i_visible_pitch = p_pic->p->i_pitch;
/* FIXME: p_heap isn't always reachable /* FIXME: p_heap isn't always reachable
p_pic->p_heap->i_rmask = 0xff0000; p_pic->p_heap->i_rmask = 0xff0000;
p_pic->p_heap->i_gmask = 0x00ff00; p_pic->p_heap->i_gmask = 0x00ff00;
...@@ -652,14 +734,13 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic, ...@@ -652,14 +734,13 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
p_pic->i_planes = 0; p_pic->i_planes = 0;
return; return;
} }
} }
/***************************************************************************** /*****************************************************************************
* vout_ChromaCmp: compare two chroma values * vout_ChromaCmp: compare two chroma values
***************************************************************************** *****************************************************************************
* This function returns 1 if the two fourcc values given as argument are * This function returns 1 if the two fourcc values given as argument are
* the same format (eg. UYVY / UYNV) or almost the same format (eg. I420/YV12) * the same format (eg. UYVY/UYNV) or almost the same format (eg. I420/YV12)
*****************************************************************************/ *****************************************************************************/
int vout_ChromaCmp( vlc_fourcc_t i_chroma, vlc_fourcc_t i_amorhc ) int vout_ChromaCmp( vlc_fourcc_t i_chroma, vlc_fourcc_t i_amorhc )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment