Commit 6c7682e3 authored by Gildas Bazin's avatar Gildas Bazin

* src/video_output/*, src/libvlc.h, include/video_output.h: added an --align option to allow modifying the alignment of a video inside its window (very useful for the wall filter).
* modules/video_output/x11/xcommon.c: small cosmetic change.
* modules/access/v4l/v4l.c: clean-up (removed old references to encoders).
parent 4fd953bd
......@@ -5,7 +5,7 @@
* thread, and destroy a previously opened video output thread.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.97 2003/08/14 18:21:58 sigmunau Exp $
* $Id: video_output.h,v 1.98 2003/08/28 21:11:54 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -82,6 +82,7 @@ struct vout_thread_t
mtime_t render_time; /**< last picture render time */
unsigned int i_window_width; /**< video window width */
unsigned int i_window_height; /**< video window height */
unsigned int i_alignment; /**< video alignment in window */
/**@}*/
/** \name Plugin used and shortcuts to access its capabilities */
......@@ -156,6 +157,14 @@ struct vout_thread_t
#define VOUT_DEPTH_CHANGE 0x0400 /* depth changed */
#define VOUT_CHROMA_CHANGE 0x0800 /* change chroma tables */
/* Alignment flags */
#define VOUT_ALIGN_LEFT 0x0001
#define VOUT_ALIGN_RIGHT 0x0002
#define VOUT_ALIGN_HMASK 0x0003
#define VOUT_ALIGN_TOP 0x0004
#define VOUT_ALIGN_BOTTOM 0x0008
#define VOUT_ALIGN_VMASK 0x000C
#define MAX_JITTER_SAMPLES 20
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* v4l.c : Video4Linux input module for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: v4l.c,v 1.20 2003/08/17 23:02:51 fenrir Exp $
* $Id: v4l.c,v 1.21 2003/08/28 21:11:55 gbazin Exp $
*
* Author: Laurent Aimar <fenrir@via.ecp.fr>
* Paul Forgey <paulf at aphrodite dot com>
......@@ -109,16 +109,14 @@ struct access_sys_t
char *psz_video_device;
int fd;
vlc_fourcc_t i_codec; // if i_codec != i_chroma then we need a compressor
video_encoder_t *p_encoder;
picture_t pic;
int i_fourcc;
int i_channel;
int i_audio;
int i_norm;
int i_tuner;
int i_frequency;
int i_chroma;
int i_width;
int i_height;
......@@ -234,7 +232,6 @@ static int AccessOpen( vlc_object_t *p_this )
p_sys->i_frame_pos = 0;
p_sys->i_codec = VLC_FOURCC( 0, 0, 0, 0 );
p_sys->i_video_frame_size_allocated = 0;
p_sys->psz_adev = NULL;
p_sys->fd_audio = -1;
......@@ -360,22 +357,6 @@ static int AccessOpen( vlc_object_t *p_this )
p_sys->i_tuner = strtol( psz_parser + strlen( "tuner=" ),
&psz_parser, 0 );
}
else if( !strncmp( psz_parser, "codec=", strlen( "codec=" ) ) )
{
psz_parser += strlen( "codec=" );
if( !strncmp( psz_parser, "mpeg4", strlen( "mpeg4" ) ) )
{
p_sys->i_codec = VLC_FOURCC( 'm', 'p', '4', 'v' );
}
else if( !strncmp( psz_parser, "mpeg1", strlen( "mpeg1" ) ) )
{
p_sys->i_codec = VLC_FOURCC( 'm', 'p', '1', 'v' );
}
else
{
msg_Warn( p_input, "unknow codec" );
}
}
else if( !strncmp( psz_parser, "adev=", strlen( "adev=" ) ) )
{
int i_len;
......@@ -758,11 +739,7 @@ static int AccessOpen( vlc_object_t *p_this )
p_sys->p_video_frame = NULL;
if( p_sys->b_mjpeg )
{
p_sys->i_chroma = VLC_FOURCC( 'I','4','2','0' );
}
else
if( !p_sys->b_mjpeg )
{
/* Find out video format used by device */
if( ioctl( p_sys->fd, VIDIOCGPICT, &p_sys->vid_picture ) == 0 )
......@@ -834,7 +811,7 @@ static int AccessOpen( vlc_object_t *p_this )
i_chroma = VLC_FOURCC( 'I', '4', '1', '1' );
break;
}
p_sys->i_chroma = i_chroma;
p_sys->i_fourcc = i_chroma;
}
else
{
......@@ -866,8 +843,7 @@ static int AccessOpen( vlc_object_t *p_this )
goto failed;
}
p_sys->i_codec = VLC_FOURCC( 'm','j','p','g' );
p_sys->p_encoder = NULL;
p_sys->i_fourcc = VLC_FOURCC( 'm','j','p','g' );
p_sys->i_frame_pos = -1;
/* queue up all the frames */
......@@ -884,7 +860,7 @@ static int AccessOpen( vlc_object_t *p_this )
{
/* 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_chroma );
p_sys->i_width, p_sys->i_height, p_sys->i_fourcc );
if( !p_sys->pic.i_planes )
{
msg_Err( p_input, "unsupported chroma" );
......@@ -900,7 +876,7 @@ static int AccessOpen( vlc_object_t *p_this )
msg_Dbg( p_input, "v4l device uses frame size: %i",
p_sys->i_video_frame_size );
msg_Dbg( p_input, "v4l device uses chroma: %4.4s",
(char*)&p_sys->i_chroma );
(char*)&p_sys->i_fourcc );
/* Allocate mmap buffer */
if( ioctl( p_sys->fd, VIDIOCGMBUF, &p_sys->vid_mbuf ) < 0 )
......@@ -926,64 +902,10 @@ static int AccessOpen( vlc_object_t *p_this )
p_sys->vid_mmap.format = p_sys->vid_picture.palette;
if( ioctl( p_sys->fd, VIDIOCMCAPTURE, &p_sys->vid_mmap ) < 0 )
{
msg_Warn( p_input, "%4.4s refused", (char*)&p_sys->i_chroma );
msg_Warn( p_input, "%4.4s refused", (char*)&p_sys->i_fourcc );
msg_Err( p_input, "chroma selection failed" );
goto failed;
}
/* encoder part */
if( p_sys->i_codec != VLC_FOURCC( 0, 0, 0, 0 ) )
{
msg_Dbg( p_input,
"need a rencoder from %4.4s to %4.4s",
(char*)&p_sys->i_chroma,
(char*)&p_sys->i_codec );
#define p_enc p_sys->p_encoder
p_enc = vlc_object_create( p_input, sizeof( video_encoder_t ) );
p_enc->i_codec = p_sys->i_codec;
p_enc->i_chroma= p_sys->i_chroma;
p_enc->i_width = p_sys->i_width;
p_enc->i_height= p_sys->i_height;
p_enc->i_aspect= 0;
p_enc->p_module = module_Need( p_enc, "video encoder",
"$video-encoder" );
if( !p_enc->p_module )
{
msg_Warn( p_input, "no suitable encoder to %4.4s",
(char*)&p_enc->i_codec );
vlc_object_destroy( p_enc );
goto failed;
}
/* *** init the codec *** */
if( p_enc->pf_init( p_enc ) )
{
msg_Err( p_input, "failed to initialize video encoder plugin" );
vlc_object_destroy( p_enc );
goto failed;
}
/* *** alloacted buffer *** */
if( p_enc->i_buffer_size <= 0 )
{
p_enc->i_buffer_size = 1024 * 1024;// * p_enc->i_width * p_enc->i_height;
}
p_sys->i_video_frame_size = p_enc->i_buffer_size;
p_sys->i_video_frame_size_allocated = p_enc->i_buffer_size;
if( !( p_sys->p_video_frame = malloc( p_enc->i_buffer_size ) ) )
{
msg_Err( p_input, "out of memory" );
goto failed;
}
#undef p_enc
}
else
{
p_sys->i_codec = p_sys->i_chroma;
p_sys->p_encoder = NULL;
}
}
p_input->pf_read = Read;
......@@ -1015,7 +937,7 @@ static int AccessOpen( vlc_object_t *p_this )
SetDWBE( &p_sys->p_header[4], 1 );
memcpy( &p_sys->p_header[ 8], "vids", 4 );
memcpy( &p_sys->p_header[12], &p_sys->i_codec, 4 );
memcpy( &p_sys->p_header[12], &p_sys->i_fourcc, 4 );
SetDWBE( &p_sys->p_header[16], p_sys->i_width );
SetDWBE( &p_sys->p_header[20], p_sys->i_height );
SetDWBE( &p_sys->p_header[24], 0 );
......@@ -1076,16 +998,6 @@ static void AccessClose( vlc_object_t *p_this )
close( p_sys->fd_audio );
}
if( p_sys->p_encoder )
{
p_sys->p_encoder->pf_end( p_sys->p_encoder );
module_Unneed( p_sys->p_encoder,
p_sys->p_encoder->p_module );
vlc_object_destroy( p_sys->p_encoder );
free( p_sys->p_video_frame );
}
free( p_sys );
}
......@@ -1257,28 +1169,7 @@ static int GrabVideo( input_thread_t * p_input,
if( !p_frame )
return -1;
if( p_sys->p_encoder )
{
int i;
/* notice we can't get here if we are using mjpeg */
p_sys->pic.p[0].p_pixels = p_frame;
for( i = 1; i < p_sys->pic.i_planes; i++ )
{
p_sys->pic.p[i].p_pixels = p_sys->pic.p[i-1].p_pixels +
p_sys->pic.p[i-1].i_pitch * p_sys->pic.p[i-1].i_lines;
}
p_sys->i_video_frame_size = p_sys->i_video_frame_size_allocated;
p_sys->p_encoder->pf_encode( p_sys->p_encoder, &p_sys->pic,
p_sys->p_video_frame,
&p_sys->i_video_frame_size );
}
else
{
p_sys->p_video_frame = p_frame;
}
p_sys->p_video_frame = p_frame;
*pp_data = p_sys->p_video_frame;
*pi_data = p_sys->i_video_frame_size;
......
......@@ -2,7 +2,7 @@
* xcommon.c: Functions common to the X11 and XVideo plugins
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xcommon.c,v 1.29 2003/08/13 18:39:52 gbazin Exp $
* $Id: xcommon.c,v 1.30 2003/08/28 21:11:55 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -882,11 +882,9 @@ static int ManageVideo( vout_thread_t *p_vout )
p_vout->p_sys->p_win->i_height,
&i_x, &i_y, &i_width, &i_height );
XResizeWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->video_window, i_width, i_height );
XMoveWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->video_window, i_x, i_y );
XMoveResizeWindow( p_vout->p_sys->p_display,
p_vout->p_sys->p_win->video_window,
i_x, i_y, i_width, i_height );
}
/* Autohide Cursour */
......
......@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.82 2003/08/19 13:20:27 hartman Exp $
* $Id: libvlc.h,v 1.83 2003/08/28 21:11:54 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -175,6 +175,12 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja",
"You can enforce the video height here. By default (-1) VLC will " \
"adapt to the video characteristics.")
#define ALIGN_TEXT N_("Video alignment")
#define ALIGN_LONGTEXT N_( \
"You can enforce the video alignement in its window. By default (0) it " \
"will be centered (0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
"also use combinations of these values).")
#define ZOOM_TEXT N_("Zoom video")
#define ZOOM_LONGTEXT N_( \
"You can zoom the video by the specified factor.")
......@@ -540,6 +546,7 @@ vlc_module_begin();
add_bool( "video", 1, NULL, VIDEO_TEXT, VIDEO_LONGTEXT, VLC_TRUE );
add_integer( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
add_integer( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, VLC_TRUE );
add_integer( "align", -1, NULL, ALIGN_TEXT, ALIGN_LONGTEXT, VLC_TRUE );
add_float( "zoom", 1, NULL, ZOOM_TEXT, ZOOM_LONGTEXT, VLC_TRUE );
add_bool( "grayscale", 0, NULL, GRAYSCALE_TEXT, GRAYSCALE_LONGTEXT, VLC_TRUE );
add_bool( "fullscreen", 0, NULL, FULLSCREEN_TEXT, FULLSCREEN_LONGTEXT, VLC_FALSE );
......
......@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread.
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: video_output.c,v 1.231 2003/07/29 22:20:53 gbazin Exp $
* $Id: video_output.c,v 1.232 2003/08/28 21:11:54 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -268,6 +268,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
p_vout->b_interface = 0;
p_vout->b_scale = 1;
p_vout->b_fullscreen = 0;
p_vout->i_alignment = 0;
p_vout->render_time = 10;
p_vout->c_fps_samples = 0;
p_vout->b_filter_change = 0;
......@@ -297,6 +298,7 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
var_Create( p_vout, "width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_vout, "zoom", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
p_vout->b_override_aspect = VLC_FALSE;
......@@ -1178,6 +1180,9 @@ static void InitWindowSize( vout_thread_t *p_vout, int *pi_width,
#define FP_FACTOR 1000 /* our fixed point factor */
var_Get( p_vout, "align", &val );
p_vout->i_alignment = val.i_int;
var_Get( p_vout, "width", &val );
i_width = val.i_int;
var_Get( p_vout, "height", &val );
......
......@@ -2,7 +2,7 @@
* vout_pictures.c : picture management functions
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: vout_pictures.c,v 1.41 2003/06/26 12:19:59 sam Exp $
* $Id: vout_pictures.c,v 1.42 2003/08/28 21:11:54 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -422,8 +422,29 @@ void vout_PlacePicture( vout_thread_t *p_vout,
*pi_width = *pi_height * p_vout->render.i_aspect / VOUT_ASPECT_FACTOR;
}
*pi_x = ( i_width - *pi_width ) / 2;
*pi_y = ( i_height - *pi_height ) / 2;
switch( p_vout->i_alignment & VOUT_ALIGN_HMASK )
{
case VOUT_ALIGN_LEFT:
*pi_x = 0;
break;
case VOUT_ALIGN_RIGHT:
*pi_x = i_width - *pi_width;
break;
default:
*pi_x = ( i_width - *pi_width ) / 2;
}
switch( p_vout->i_alignment & VOUT_ALIGN_VMASK )
{
case VOUT_ALIGN_TOP:
*pi_y = 0;
break;
case VOUT_ALIGN_BOTTOM:
*pi_y = i_height - *pi_height;
break;
default:
*pi_y = ( i_height - *pi_height ) / 2;
}
}
/*****************************************************************************
......
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