X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fspudec%2Fspudec.c;h=f527a9c2b379c0ed5fc6cc6ff48cc353859719ef;hb=7a4f28303162b32b456d4f09f75a6f15a1de805b;hp=ed3231075b1a5e6180b203a8439ffc8bd88f4fa9;hpb=2cb472dba008f7d877ffe6bae9c5575253365282;p=vlc diff --git a/modules/codec/spudec/spudec.c b/modules/codec/spudec/spudec.c index ed3231075b..f527a9c2b3 100644 --- a/modules/codec/spudec/spudec.c +++ b/modules/codec/spudec/spudec.c @@ -1,10 +1,10 @@ /***************************************************************************** * spudec.c : SPU decoder thread ***************************************************************************** - * Copyright (C) 2000-2001 the VideoLAN team + * Copyright (C) 2000-2001, 2006 the VideoLAN team * $Id$ * - * Authors: Samuel Hocevar + * Authors: Sam Hocevar * Laurent Aimar * * This program is free software; you can redistribute it and/or modify @@ -25,8 +25,13 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include #include "spudec.h" @@ -37,18 +42,18 @@ static int DecoderOpen ( vlc_object_t * ); 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 @@ -76,7 +81,7 @@ static int DecoderOpen( vlc_object_t *p_this ) 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; @@ -104,7 +109,7 @@ static int PacketizerOpen( vlc_object_t *p_this ) 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',' ' ); @@ -119,7 +124,11 @@ static void Close( vlc_object_t *p_this ) 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 ); } @@ -130,28 +139,30 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) { 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; } /***************************************************************************** @@ -162,21 +173,21 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block ) 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 ); } /***************************************************************************** @@ -195,7 +206,7 @@ static block_t *Reassemble( decoder_t *p_dec, block_t **pp_block ) ( 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; @@ -229,8 +240,9 @@ static block_t *Reassemble( decoder_t *p_dec, block_t **pp_block ) 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; }