Commit 4910755e authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/extras.c: removed a duplicate calculation inside a macro.

  * ./src/libvlc.c: fixed a bug causing all commandline targets to be ignored
    for playback except the last one.
  * ./modules/codec/dv.c: we detach p_vout before quitting.
  * ./modules/codec/xvid.c: fixed image corruption, added a direct rendering
    option which doesn't work yet.
parent 7358af1b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dv.c: a decoder for DV video * dv.c: a decoder for DV video
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: dv.c,v 1.1 2002/11/05 14:52:28 sam Exp $ * $Id: dv.c,v 1.2 2002/11/06 09:26:25 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -267,6 +267,7 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -267,6 +267,7 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
if( p_vout ) if( p_vout )
{ {
vlc_object_detach( p_vout );
vout_DestroyThread( p_vout ); vout_DestroyThread( p_vout );
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* xvid.c: a decoder for libxvidcore, the Xvid video codec * xvid.c: a decoder for libxvidcore, the Xvid video codec
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: xvid.c,v 1.1 2002/11/05 22:53:21 sam Exp $ * $Id: xvid.c,v 1.2 2002/11/06 09:26:25 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -48,12 +48,14 @@ vlc_module_begin(); ...@@ -48,12 +48,14 @@ vlc_module_begin();
set_description( _("Xvid video decoder") ); set_description( _("Xvid video decoder") );
set_capability( "decoder", 50 ); set_capability( "decoder", 50 );
set_callbacks( OpenDecoder, NULL ); set_callbacks( OpenDecoder, NULL );
add_bool( "xvid-direct-render", 0, NULL, "direct rendering",
"Use libxvidcore's direct rendering feature." );
vlc_module_end(); vlc_module_end();
/***************************************************************************** /*****************************************************************************
* OpenDecoder: probe the decoder and return score * OpenDecoder: probe the decoder and return score
***************************************************************************** *****************************************************************************
* The fourcc format for DV is "dvsd" * FIXME: find fourcc formats supported by xvid
*****************************************************************************/ *****************************************************************************/
static int OpenDecoder ( vlc_object_t *p_this ) static int OpenDecoder ( vlc_object_t *p_this )
{ {
...@@ -87,7 +89,9 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -87,7 +89,9 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
uint8_t * p_buffer, * p_image; uint8_t * p_buffer, * p_image;
int i_ret; int i_ret;
int i_width, i_height, i_chroma, i_aspect; int i_width, i_height, i_chroma, i_aspect;
int i_size, i_offset; int i_size, i_offset, i_image_size;
vlc_bool_t b_direct = config_GetInt( p_fifo, "xvid-direct-render" );
if( InitBitstream( &bit_stream, p_fifo, NULL, NULL ) != VLC_SUCCESS ) if( InitBitstream( &bit_stream, p_fifo, NULL, NULL ) != VLC_SUCCESS )
{ {
...@@ -107,9 +111,11 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -107,9 +111,11 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
/* XXX: Completely arbitrary buffer size */ /* XXX: Completely arbitrary buffer size */
i_size = i_width * i_height / 4; i_size = i_width * i_height / 4;
i_image_size = b_direct ? 0 : i_width * i_height * 4;
i_offset = 0; i_offset = 0;
p_buffer = malloc( i_size + 4 * i_width * i_height );
p_image = p_buffer + 4 * i_width * i_height; p_buffer = malloc( i_size + i_image_size );
p_image = p_buffer + i_size;
if( !p_buffer ) if( !p_buffer )
{ {
...@@ -192,7 +198,9 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -192,7 +198,9 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
while( !p_fifo->b_die && !p_fifo->b_error ) while( !p_fifo->b_die && !p_fifo->b_error )
{ {
XVID_DEC_FRAME xframe; XVID_DEC_FRAME xframe;
XVID_DEC_PICTURE xpic;
mtime_t i_pts = 0; mtime_t i_pts = 0;
picture_t *p_pic;
GetChunk( &bit_stream, p_buffer + i_offset, i_size - i_offset ); GetChunk( &bit_stream, p_buffer + i_offset, i_size - i_offset );
...@@ -214,19 +222,6 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -214,19 +222,6 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
break; break;
} }
/* Decode the stuff */
xframe.bitstream = p_buffer;
xframe.length = i_size;
xframe.image = p_image;
xframe.stride = i_width;
xframe.colorspace = XVID_CSP_YV12;
i_ret = xvid_decore( p_xvid, XVID_DEC_DECODE, &xframe, NULL );
/* FIXME: check i_ret */
if( p_vout )
{
picture_t *p_pic;
while( !(p_pic = vout_CreatePicture( p_vout, 0, 0, 0 ) ) ) while( !(p_pic = vout_CreatePicture( p_vout, 0, 0, 0 ) ) )
{ {
if( p_fifo->b_die || p_fifo->b_error ) if( p_fifo->b_die || p_fifo->b_error )
...@@ -241,6 +236,27 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -241,6 +236,27 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
break; break;
} }
if( b_direct )
{
xpic.y = p_pic->p[0].p_pixels;
xpic.u = p_pic->p[1].p_pixels;
xpic.v = p_pic->p[2].p_pixels;
xpic.stride_y = p_pic->p[0].i_pitch;
xpic.stride_u = p_pic->p[1].i_pitch;
xpic.stride_v = p_pic->p[2].i_pitch;
}
/* Decode the stuff */
xframe.bitstream = p_buffer;
xframe.length = i_size;
xframe.image = b_direct ? (void*)&xpic : p_image;
xframe.stride = i_width;
xframe.colorspace = b_direct ? XVID_CSP_EXTERN : XVID_CSP_YV12;
i_ret = xvid_decore( p_xvid, XVID_DEC_DECODE, &xframe, NULL );
/* FIXME: check i_ret */
if( !b_direct )
{
/* TODO: use pf_memcpy when this is stable. */ /* TODO: use pf_memcpy when this is stable. */
memcpy( p_pic->p[0].p_pixels, memcpy( p_pic->p[0].p_pixels,
p_image, p_image,
...@@ -251,10 +267,10 @@ static int RunDecoder ( decoder_fifo_t *p_fifo ) ...@@ -251,10 +267,10 @@ static int RunDecoder ( decoder_fifo_t *p_fifo )
memcpy( p_pic->p[1].p_pixels, memcpy( p_pic->p[1].p_pixels,
p_image + i_width * i_height + i_width * i_height / 4, p_image + i_width * i_height + i_width * i_height / 4,
i_width * i_height / 4 ); i_width * i_height / 4 );
}
vout_DatePicture( p_vout, p_pic, i_pts ); vout_DatePicture( p_vout, p_pic, i_pts );
vout_DisplayPicture( p_vout, p_pic ); vout_DisplayPicture( p_vout, p_pic );
}
/* Move the remaining data. TODO: only do this when necessary. */ /* Move the remaining data. TODO: only do this when necessary. */
memmove( p_buffer, p_buffer + xframe.length, i_size - xframe.length ); memmove( p_buffer, p_buffer + xframe.length, i_size - xframe.length );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source * libvlc.c: main libvlc source
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.42 2002/10/16 15:10:39 sam Exp $ * $Id: libvlc.c,v 1.43 2002/11/06 09:26:25 sam 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>
...@@ -956,12 +956,19 @@ static int GetFilenames( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] ) ...@@ -956,12 +956,19 @@ static int GetFilenames( vlc_t *p_vlc, int i_argc, char *ppsz_argv[] )
int i_opt; int i_opt;
/* We assume that the remaining parameters are filenames */ /* We assume that the remaining parameters are filenames */
for( i_opt = optind; i_opt < i_argc; i_opt++ ) for( i_opt = i_argc - 1; i_opt > optind; i_opt-- )
{ {
/* TODO: write an internal function of this one, to avoid /* TODO: write an internal function of this one, to avoid
* unnecessary lookups. */ * unnecessary lookups. */
VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[ i_opt ], VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[ i_opt ],
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); PLAYLIST_INSERT, 0 );
}
/* If there is at least one target, play it */
if( i_argc > optind )
{
VLC_AddTarget( p_vlc->i_object_id, ppsz_argv[ optind ],
PLAYLIST_INSERT | PLAYLIST_GO, 0 );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* extras.c: Extra libc functions for some systems. * extras.c: Extra libc functions for some systems.
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: extras.c,v 1.1 2002/07/05 11:18:56 sam Exp $ * $Id: extras.c,v 1.2 2002/11/06 09:26:25 sam Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* *
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
char *strndup( const char *string, size_t n ) char *strndup( const char *string, size_t n )
{ {
char *psz; char *psz;
size_t len; size_t len = strlen( string );
len = __MIN( strlen( string ), n ); len = __MIN( len, n );
psz = (char*)malloc( len + 1 ); psz = (char*)malloc( len + 1 );
if( psz != NULL ) if( psz != NULL )
......
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