Commit 1a674481 authored by gbazin's avatar gbazin
Browse files

* 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 $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)
......@@ -2779,6 +2779,7 @@ 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.])
fi
AC_LANG_PUSH(C++)
AX_ADD_CXXFLAGS([wxwindows],[`${WX_CONFIG} --cxxflags`])
AX_ADD_LDFLAGS([wxwindows],[`${WX_CONFIG} --libs`])
# now look for the wxprec.h header
......@@ -2794,6 +2795,7 @@ then
ALIASES="${ALIASES} wxvlc"
fi
CPPFLAGS="${CPPFLAGS_save}"
AC_LANG_POP(C++)
fi
fi
......
......@@ -2,7 +2,7 @@
* video_output.h : video output thread
*****************************************************************************
* 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>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -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( 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_AllocatePicture,( vout_thread_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_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_DisplayPicture, ( vout_thread_t *, picture_t * ) );
VLC_EXPORT( void, vout_DatePicture, ( vout_thread_t *, picture_t *, mtime_t ) );
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* 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>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -250,9 +250,9 @@ typedef struct audio_date_t audio_date_t;
/* Video */
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 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_sys_t picture_sys_t;
typedef struct picture_heap_t picture_heap_t;
......
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* 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>
*
......@@ -28,14 +28,21 @@
/**
* 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 */
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
......@@ -66,6 +73,12 @@ typedef struct plane_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
* NEVER be modified. A direct buffer can be handled as the plugin
* wishes, it can even swap p_pixels buffers. */
......@@ -224,22 +237,6 @@ struct subpicture_t
int i_width; /**< picture width */
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 */
void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * );
......
......@@ -2,7 +2,7 @@
* v4l.c : Video4Linux input module for vlc
*****************************************************************************
* 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>
* Paul Forgey <paulf at aphrodite dot com>
......@@ -858,8 +858,9 @@ static int AccessOpen( vlc_object_t *p_this )
else
{
/* Fill in picture_t fields */
vout_InitPicture( VLC_OBJECT(p_input), &p_sys->pic,
p_sys->i_width, p_sys->i_height, p_sys->i_fourcc );
vout_InitPicture( VLC_OBJECT(p_input), &p_sys->pic, 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 )
{
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
* $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>
*
......@@ -24,49 +24,74 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include <vlc/vlc.h>
#include <vlc/vout.h>
#include <vlc/decoder.h>
#include <vlc/input.h>
#include <vlc/sout.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#include "codecs.h"
/*****************************************************************************
* Local prototypes
* decoder_sys_t : raw video decoder descriptor
*****************************************************************************/
typedef struct
struct decoder_sys_t
{
/* Input properties */
decoder_fifo_t *p_fifo;
int i_raw_size;
/* Module mode */
vlc_bool_t b_packetizer;
/*
* Input properties
*/
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;
};
static int OpenDecoder ( vlc_object_t * );
/****************************************************************************
* Local prototypes
****************************************************************************/
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 InitThread ( vdec_thread_t * );
static void DecodeThread ( vdec_thread_t * );
static void EndThread ( vdec_thread_t * );
static int DecodeFrame ( decoder_t *, block_t * );
static int SendFrame ( decoder_t *, block_t * );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin();
set_description( _("Pseudo Raw Video decoder") );
set_capability( "decoder", 50 );
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
......@@ -89,233 +114,262 @@ static int OpenDecoder( vlc_object_t *p_this )
case VLC_FOURCC('I','4','1','1'):
case VLC_FOURCC('I','4','1','0'):
/* Packed YUV */
/* Packed YUV */
case VLC_FOURCC('Y','U','Y','2'):
case VLC_FOURCC('U','Y','V','Y'):
/* RGB */
/* RGB */
case VLC_FOURCC('R','V','3','2'):
case VLC_FOURCC('R','V','2','4'):
case VLC_FOURCC('R','V','1','6'):
case VLC_FOURCC('R','V','1','5'):
p_dec->pf_run = RunDecoder;
return VLC_SUCCESS;
break;
default:
return VLC_EGENERIC;
}
p_dec->pf_init = InitDecoder;
p_dec->pf_decode = RunDecoder;
p_dec->pf_end = EndDecoder;
/* Allocate the memory needed to store the decoder's structure */
if( ( p_dec->p_sys =
(decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return VLC_EGENERIC;
}
p_dec->p_sys->b_packetizer = VLC_FALSE;
return VLC_SUCCESS;
}
static int OpenPacketizer( vlc_object_t *p_this )
{
decoder_t *p_dec = (decoder_t*)p_this;
int i_ret = OpenDecoder( p_this );
if( i_ret == VLC_SUCCESS ) p_dec->p_sys->b_packetizer = VLC_TRUE;
return i_ret;
}
/*****************************************************************************
* RunDecoder: this function is called just after the thread is created
* InitDecoder: Initalize the decoder
*****************************************************************************/
static int RunDecoder( decoder_fifo_t *p_fifo )
static int InitDecoder( decoder_t *p_dec )
{
vdec_thread_t *p_vdec;
int b_error;
decoder_sys_t *p_sys = p_dec->p_sys;
video_frame_format_t format;
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_sys->i_pts = 0;
p_vdec->p_fifo = p_fifo;
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;
if( InitThread( p_vdec ) != 0 )
#define bih ((BITMAPINFOHEADER*)p_dec->p_fifo->p_bitmapinfoheader)
if( bih == NULL )
{
DecoderError( p_fifo );
return( -1 );
msg_Err( p_dec, "info missing, fatal" );
return VLC_EGENERIC;
}
while( ( !p_vdec->p_fifo->b_die )&&( !p_vdec->p_fifo->b_error ) )
if( bih->biWidth <= 0 || bih->biHeight <= 0 )
{
DecodeThread( p_vdec );
msg_Err( p_dec, "invalid display size %dx%d",
bih->biWidth, bih->biHeight );
return VLC_EGENERIC;
}
if( ( b_error = p_vdec->p_fifo->b_error ) )
if( p_sys->b_packetizer )
{
DecoderError( p_vdec->p_fifo );
}
/* 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 );
EndThread( p_vdec );
if( b_error )
if( !p_sys->p_sout_input )
{
msg_Err( p_dec, "cannot add a new stream" );
return VLC_EGENERIC;
}
}
else
{
return( -1 );
/* Initialize video output */
p_sys->p_vout = vout_Request( p_dec, NULL,
bih->biWidth, bih->biHeight,
p_dec->p_fifo->i_fourcc,
VOUT_ASPECT_FACTOR * bih->biWidth /
bih->biHeight );
if( p_sys->p_vout == NULL )
{
msg_Err( p_dec, "failed to create vout" );
return VLC_EGENERIC;
}
}
return( 0 );
}
#define FREE( p ) if( p ) { free( p ); p = NULL; }
/* 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
return VLC_SUCCESS;
}
/*****************************************************************************
* InitThread: initialize data before entering main loop
*****************************************************************************/
static int InitThread( vdec_thread_t * p_vdec )
/****************************************************************************
* RunDecoder: the whole thing
****************************************************************************
* This function must be fed with ogg packets.
****************************************************************************/
static int RunDecoder( decoder_t *p_dec, block_t *p_block )
{
picture_t pic;
int i;
decoder_sys_t *p_sys = p_dec->p_sys;
int i_ret;
#define bih ((BITMAPINFOHEADER*)p_vdec->p_fifo->p_bitmapinfoheader)
if( bih == NULL )
#if 0
if( !aout_DateGet( &p_sys->end_date ) && !p_block->i_pts )
{
msg_Err( p_vdec->p_fifo,
"info missing, fatal" );
return( VLC_EGENERIC );
/* We've just started the stream, wait for the first PTS. */
block_Release( p_block );
return VLC_SUCCESS;
}
if( bih->biWidth <= 0 || bih->biHeight <= 0 )
#endif
/* Date management */
if( p_block->i_pts > 0 && p_block->i_pts != p_sys->i_pts )
{
msg_Err( p_vdec->p_fifo,
"invalid display size %dx%d",
bih->biWidth, bih->biHeight );
return( VLC_EGENERIC );
p_sys->i_pts = p_block->i_pts;
}
p_vdec->p_vout = vout_Request( p_vdec->p_fifo, NULL,
bih->biWidth, bih->biHeight,
p_vdec->p_fifo->i_fourcc,
VOUT_ASPECT_FACTOR * bih->biWidth /
bih->biHeight );
if( p_vdec->p_vout == NULL )
if( p_block->i_buffer < p_sys->i_raw_size )
{
msg_Err( p_vdec->p_fifo, "failed created vout" );
return( VLC_EGENERIC );
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;
}
/* 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++ )
if( p_sys->b_packetizer )
{
i_ret = SendFrame( p_dec, p_block );
}
else
{
p_vdec->i_raw_size += pic.p[i].i_lines * pic.p[i].i_visible_pitch;
i_ret = DecodeFrame( p_dec, p_block );
}
return( VLC_SUCCESS );
#undef bih
}
/* Date management: 1 frame per packet */
p_sys->i_pts += ( I64C(1000000) * 1.0 / 25 /*FIXME*/ );
block_Release( p_block );
return i_ret;
}
static void FillPicture( pes_packet_t *p_pes, picture_t *p_pic )
/*****************************************************************************
* FillPicture:
*****************************************************************************/
static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
{
int i_plane;
uint8_t *p_src, *p_dst;
int i_src, i_plane, i_line, i_width;
data_packet_t *p_data;
uint8_t *p_src;
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;
p_src = p_block->p_buffer;
i_src = p_block->i_buffer;
for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )
{
uint8_t *p_dst;
int i_dst;
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;
i_width = p_pic->p[i_plane].i_visible_pitch;
while( i_dst > 0 )
for( i_line = 0; i_line < p_pic->p[i_plane].i_lines; i_line++ )
{
int i_copy;
i_copy = __MIN( i_src, i_dst );
if( i_copy > 0 )
{
memcpy( p_dst, p_src, i_copy );
}
i_dst -= i_copy;
p_dst += i_copy;
i_src -= i_copy;
p_src += i_copy;
if( i_src <= 0 )
{
do
{
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 );
}
p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_width );
p_src += i_width;
p_dst += p_pic->p[i_plane].i_pitch;
}
}
}
/*****************************************************************************
* DecodeThread: decodes a frame
* DecodeFrame: decodes a video frame.
*****************************************************************************/
static void DecodeThread( vdec_thread_t *p_vdec )
static int DecodeFrame( decoder_t *p_dec, block_t *p_block )
{
int i_size;
pes_packet_t *p_pes;
picture_t *p_pic;
/* **** get frame **** */
input_ExtractPES( p_vdec->p_fifo, &p_pes );
if( !p_pes )
{
p_vdec->p_fifo->b_error = 1;
return;
}
i_size = p_pes->i_pes_size;
decoder_sys_t *p_sys = p_dec->p_sys;
picture_t *p_pic;
if( i_size < p_vdec->i_raw_size )
/* Get a new picture */
while( !(p_pic = vout_CreatePicture( p_sys->p_vout, 0, 0, 0 ) ) )
{
msg_Warn( p_vdec->p_fifo, "invalid frame size (%d < %d)",
i_size, p_vdec->i_raw_size );
//input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
return;
}
/* **** get video picture **** */
while( !(p_pic = vout_CreatePicture( p_vdec->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 );
}
if( !p_pic ) return VLC_EGENERIC;
FillPicture( p_dec, p_block, p_pic );
vout_DatePicture( p_sys->p_vout, p_pic, p_sys->i_pts );
vout_DisplayPicture( p_sys->p_vout, p_pic );
return VLC_SUCCESS;
}
/*****************************************************************************
* SendFrame: send a video frame to the stream output.
*****************************************************************************/
static int SendFrame( decoder_t *p_dec, block_t *p_block )
{