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 $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 )
{
decoder_sys_t *p_sys = p_dec->p_sys;
/* **** fill p_pic **** */
FillPicture( p_pes, p_pic );
sout_buffer_t *p_sout_buffer =
sout_BufferNew( p_sys->p_sout_input->p_sout, p_block->i_buffer );
/* **** display p_pic **** */
vout_DatePicture( p_vdec->p_vout, p_pic, p_pes->i_pts);
vout_DisplayPicture( p_vdec->p_vout, p_pic );
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 );
input_DeletePES( p_vdec->p_fifo->p_packets_mgt, p_pes );
}
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 @@
* vout_dummy.c: Dummy video output display method for testing purposes
*****************************************************************************
* 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>
*
......@@ -133,9 +133,9 @@ static int Init( vout_thread_t *p_vout )
break;
}
vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_width,
p_vout->output.i_height,
p_vout->output.i_chroma );
vout_AllocatePicture( p_vout, p_pic, p_vout->output.i_chroma,
p_vout->output.i_width, p_vout->output.i_height,
p_vout->output.i_aspect );
if( p_pic->i_planes == 0 )
{
......
......@@ -2,7 +2,7 @@
* transcode.c
*****************************************************************************
* 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>
*
......@@ -1661,8 +1661,10 @@ static int transcode_video_ffmpeg_process( sout_stream_t *p_stream,
int i_plane;
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->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++ )
{
......
......@@ -2,7 +2,7 @@
* filter_common.h: Common filter functions
*****************************************************************************
* 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>
*
......@@ -43,10 +43,10 @@
} \
\
/* 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_height, \
p_vout->output.i_chroma ); \
p_vout->output.i_aspect ); \
\
if( !p_pic->i_planes ) \
{ \
......
......@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins
*****************************************************************************
* 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>
* Samuel Hocevar <sam@zoy.org>
......@@ -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 )
{
#ifdef MODULE_NAME_IS_xvideo
int i_plane;
#endif
/* We know the chroma, allocate a buffer which will be used
* directly by the decoder */
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 )
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
if( p_vout->p_sys->b_shm )
{
......@@ -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,
#ifdef MODULE_NAME_IS_xvideo
p_vout->p_sys->i_xvport, p_vout->output.i_chroma,
p_pic->format.i_bits_per_pixel,
#else
p_vout->p_sys->p_visual,
p_vout->p_sys->i_screen_depth,
......@@ -1196,148 +1206,50 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{
#ifdef MODULE_NAME_IS_xvideo
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'):
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'):
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('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'):
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','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
+ 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;
for( i_plane = 0; i_plane < p_pic->p_sys->p_image->num_planes;
i_plane++ )
{
p_pic->p[i_plane].p_pixels = p_pic->p_sys->p_image->data
+ p_pic->p_sys->p_image->offsets[i_plane];
p_pic->p[i_plane].i_pitch =
p_pic->p_sys->p_image->pitches[i_plane];
}
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;
#else
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','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','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_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 = 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;
#endif
......@@ -2148,7 +2060,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
/* Allocate memory for image */
#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
i_bytes_per_line = i_width * i_bytes_per_pixel;
p_data = (byte_t *) malloc( i_bytes_per_line * i_height );
......
......@@ -2,7 +2,7 @@
* xcommon.h: Defines common to the X11 and XVideo plugins
*****************************************************************************
* 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>
* Samuel Hocevar <sam@zoy.org>
......@@ -29,7 +29,7 @@
*****************************************************************************/
#ifdef MODULE_NAME_IS_xvideo
# 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 DATA_SIZE(p) (p)->data_size
# define IMAGE_FREE XFree /* There is nothing like XvDestroyImage */
......
......@@ -2,7 +2,7 @@
* vout_pictures.c : picture management functions
*****************************************************************************
* 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>
* Samuel Hocevar <sam@zoy.org>
......@@ -44,8 +44,8 @@ static void CopyPicture( vout_thread_t *, picture_t *, picture_t * );
/*****************************************************************************
* vout_DisplayPicture: display a picture
*****************************************************************************
* Remove the reservation flag of a picture, which will cause it to be ready for
* display. The picture won't be displayed until vout_DatePicture has been
* Remove the reservation flag of a picture, which will cause it to be ready
* for display. The picture won't be displayed until vout_DatePicture has been
* called.
*****************************************************************************/
void vout_DisplayPicture( vout_thread_t *p_vout, picture_t *p_pic )
......@@ -102,8 +102,9 @@ void vout_DatePicture( vout_thread_t *p_vout,
*****************************************************************************
* This function creates a reserved image in the video output heap.
* 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
* since several pictures can be created by several producers threads.
* already allocated zone of memory in the picture data fields.
* It needs locking since several pictures can be created by several producers
* threads.
*****************************************************************************/
picture_t *vout_CreatePicture( vout_thread_t *p_vout,
vlc_bool_t b_progressive,
......@@ -164,9 +165,9 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout,
*/
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_chroma );
p_vout->render.i_aspect );
if( p_freepic->i_planes )
{
......@@ -250,7 +251,7 @@ void vout_LinkPicture( vout_thread_t *p_vout, picture_t *p_pic )
/*****************************************************************************
* 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 )
{
......@@ -455,17 +456,17 @@ void vout_PlacePicture( vout_thread_t *p_vout,
* how it gets displayed.
*****************************************************************************/
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;
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 */
for( i_bytes = 0, i_index = 0; i_index < p_pic->i_planes; i_index++ )
{
i_bytes += p_pic->p[ i_index ].i_lines * p_pic->p[ i_index ].i_pitch;
}
i_bytes = p_pic->format.i_bits_per_pixel *
p_pic->format.i_width * p_pic->format.i_height / 8;
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,
}
}
/*****************************************************************************
* 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.
*****************************************************************************
......@@ -493,7 +564,8 @@ void vout_AllocatePicture( vout_thread_t *p_vout, picture_t *p_pic,
* size. It makes the assumption that stride == width.
*****************************************************************************/
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;
......@@ -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;
}
vout_InitFormat( &p_pic->format, i_chroma, i_width, i_height, i_aspect );
/* Calculate coordinates */
switch( i_chroma )
{
......@@ -624,9 +698,17 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
case FOURCC_RV24:
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_visible_pitch = p_pic->p->i_pitch;
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
p_pic->p_heap->i_rmask = 0xff0000;
p_pic->p_heap->i_gmask = 0x00ff00;
......@@ -652,14 +734,13 @@ void vout_InitPicture( vlc_object_t *p_this, picture_t *p_pic,
p_pic->i_planes = 0;
return;
}
}
/*****************************************************************************
* vout_ChromaCmp: compare two chroma values
*****************************************************************************
* 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 )
{
......
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