/*****************************************************************************
* spudec.c : SPU decoder thread
*****************************************************************************
- * Copyright (C) 2000-2001 the VideoLAN team
+ * Copyright (C) 2000-2001, 2006 the VideoLAN team
* $Id$
*
- * Authors: Samuel Hocevar <sam@zoy.org>
+ * Authors: Sam Hocevar <sam@zoy.org>
* Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <vlc/vlc.h>
-#include <vlc/decoder.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_codec.h>
#include "spudec.h"
static int PacketizerOpen( vlc_object_t * );
static void Close ( vlc_object_t * );
-vlc_module_begin();
- set_description( _("DVD subtitles decoder") );
- set_capability( "decoder", 50 );
- set_category( CAT_INPUT );
- set_subcategory( SUBCAT_INPUT_SCODEC );
- set_callbacks( DecoderOpen, Close );
+vlc_module_begin ()
+ set_description( N_("DVD subtitles decoder") )
+ set_capability( "decoder", 50 )
+ set_category( CAT_INPUT )
+ set_subcategory( SUBCAT_INPUT_SCODEC )
+ set_callbacks( DecoderOpen, Close )
- add_submodule();
- set_description( _("DVD subtitles packetizer") );
- set_capability( "packetizer", 50 );
- set_callbacks( PacketizerOpen, Close );
-vlc_module_end();
+ add_submodule ()
+ set_description( N_("DVD subtitles packetizer") )
+ set_capability( "packetizer", 50 )
+ set_callbacks( PacketizerOpen, Close )
+vlc_module_end ()
/*****************************************************************************
* Local prototypes
p_dec->p_sys = p_sys = malloc( sizeof( decoder_sys_t ) );
- p_sys->b_packetizer = VLC_FALSE;
+ p_sys->b_packetizer = false;
p_sys->i_spu_size = 0;
p_sys->i_spu = 0;
p_sys->p_block = NULL;
return VLC_EGENERIC;
}
p_dec->pf_packetize = Packetize;
- p_dec->p_sys->b_packetizer = VLC_TRUE;
+ p_dec->p_sys->b_packetizer = true;
es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
p_dec->fmt_out.i_codec = VLC_FOURCC( 's','p','u',' ' );
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys = p_dec->p_sys;
- if( p_sys->p_block ) block_ChainRelease( p_sys->p_block );
+ if( p_sys->p_block )
+ {
+ block_ChainRelease( p_sys->p_block );
+ }
+
free( p_sys );
}
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_spu_block;
+ subpicture_t *p_spu;
- if( (p_spu_block = Reassemble( p_dec, pp_block )) )
- {
- subpicture_t *p_spu;
+ p_spu_block = Reassemble( p_dec, pp_block );
- p_sys->i_spu = block_ChainExtract( p_spu_block, p_sys->buffer, 65536 );
- p_sys->i_pts = p_spu_block->i_pts;
- block_ChainRelease( p_spu_block );
+ if( ! p_spu_block )
+ {
+ return NULL;
+ }
- /* Parse and decode */
- p_spu = E_(ParsePacket)( p_dec );
+ /* FIXME: what the, we shouldn’t need to allocate 64k of buffer --sam. */
+ p_sys->i_spu = block_ChainExtract( p_spu_block, p_sys->buffer, 65536 );
+ p_sys->i_pts = p_spu_block->i_pts;
+ block_ChainRelease( p_spu_block );
- /* reinit context */
- p_sys->i_spu_size = 0;
- p_sys->i_rle_size = 0;
- p_sys->i_spu = 0;
- p_sys->p_block = NULL;
+ /* Parse and decode */
+ p_spu = ParsePacket( p_dec );
- return p_spu;
- }
+ /* reinit context */
+ p_sys->i_spu_size = 0;
+ p_sys->i_rle_size = 0;
+ p_sys->i_spu = 0;
+ p_sys->p_block = NULL;
- return NULL;
+ return p_spu;
}
/*****************************************************************************
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_spu = Reassemble( p_dec, pp_block );
- if( p_spu )
+ if( ! p_spu )
{
- p_spu->i_dts = p_spu->i_pts;
- p_spu->i_length = 0;
+ return NULL;
+ }
- /* reinit context */
- p_sys->i_spu_size = 0;
- p_sys->i_rle_size = 0;
- p_sys->i_spu = 0;
- p_sys->p_block = NULL;
+ p_spu->i_dts = p_spu->i_pts;
+ p_spu->i_length = 0;
- return block_ChainGather( p_spu );
- }
+ /* reinit context */
+ p_sys->i_spu_size = 0;
+ p_sys->i_rle_size = 0;
+ p_sys->i_spu = 0;
+ p_sys->p_block = NULL;
- return NULL;
+ return block_ChainGather( p_spu );
}
/*****************************************************************************
( p_block->i_pts <= 0 || p_block->i_buffer < 4 ) )
{
msg_Dbg( p_dec, "invalid starting packet (size < 4 or pts <=0)" );
- msg_Dbg( p_dec, "spu size: %d, i_pts: "I64Fd" i_buffer: %d",
+ msg_Dbg( p_dec, "spu size: %d, i_pts: %"PRId64" i_buffer: %zu",
p_sys->i_spu_size, p_block->i_pts, p_block->i_buffer );
block_Release( p_block );
return NULL;
if( p_sys->i_spu >= p_sys->i_spu_size )
{
/* We have a complete sub */
- msg_Dbg( p_dec, "SPU packets size=%d should be %d",
- p_sys->i_spu, p_sys->i_spu_size );
+ if( p_sys->i_spu > p_sys->i_spu_size )
+ msg_Dbg( p_dec, "SPU packets size=%d should be %d",
+ p_sys->i_spu, p_sys->i_spu_size );
return p_sys->p_block;
}