X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fcdg.c;h=c1a3e754a014daecd5def969713962d1d3070999;hb=0bafd9ff09406c8ddb180502cac2a8688bdc621d;hp=a7695d046e67a701cb9a40c7b31b96f42c89b379;hpb=bc265de2d5dbc611c3247eaf18aea32272616a1e;p=vlc diff --git a/modules/codec/cdg.c b/modules/codec/cdg.c index a7695d046e..c1a3e754a0 100644 --- a/modules/codec/cdg.c +++ b/modules/codec/cdg.c @@ -2,7 +2,7 @@ * cdg.c: CDG decoder module ***************************************************************************** * Copyright (C) 2007 Laurent Aimar - * $Id: $ + * $Id$ * * Authors: Laurent Aimar * @@ -24,7 +24,12 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include @@ -53,6 +58,8 @@ struct decoder_sys_t int i_offsetv; uint8_t screen[CDG_SCREEN_PITCH*CDG_SCREEN_HEIGHT]; uint8_t *p_screen; + + int i_packet; }; #define CDG_PACKET_SIZE (24) @@ -75,14 +82,14 @@ static int Render( decoder_sys_t *p_cdg, picture_t *p_picture ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_VCODEC ); - set_description( _("CDG video decoder") ); - set_capability( "decoder", 1000 ); - set_callbacks( Open, Close ); - add_shortcut( "cdg" ); -vlc_module_end(); +vlc_module_begin () + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_VCODEC ) + set_description( N_("CDG video decoder") ) + set_capability( "decoder", 1000 ) + set_callbacks( Open, Close ) + add_shortcut( "cdg" ) +vlc_module_end () /***************************************************************************** * Open: probe the decoder and return score @@ -96,18 +103,13 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; /* Allocate the memory needed to store the decoder's structure */ - p_dec->p_sys = p_sys = malloc(sizeof(decoder_sys_t)); + p_dec->p_sys = p_sys = calloc( 1, sizeof(decoder_sys_t) ); if( !p_sys ) - { - msg_Err( p_dec, "out of memory" ); - return VLC_EGENERIC; - } + return VLC_ENOMEM; /* Init */ - memset( p_sys, 0, sizeof(*p_sys) ); - p_sys->i_offseth = 0; - p_sys->i_offsetv = 0; p_sys->p_screen = p_sys->screen; + p_sys->i_packet = 0; /* Set output properties * TODO maybe it would be better to use RV16 or RV24 ? */ @@ -142,6 +144,12 @@ static picture_t *Decode( decoder_t *p_dec, block_t **pp_block ) return NULL; p_block = *pp_block; + if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) + { + p_sys->i_packet = 0; + goto exit; + } + /* Decode packet */ while( p_block->i_buffer >= CDG_PACKET_SIZE ) { @@ -150,20 +158,21 @@ static picture_t *Decode( decoder_t *p_dec, block_t **pp_block ) p_block->p_buffer += CDG_PACKET_SIZE; } - /* Get a new picture */ - p_pic = p_dec->pf_vout_buffer_new( p_dec ); - if( !p_pic ) - goto error; + /* Only display 25 frame per second (there is 75 packets per second) */ + if( (p_sys->i_packet%3) == 1 ) + { + /* Get a new picture */ + p_pic = decoder_NewPicture( p_dec ); + if( !p_pic ) + goto exit; - Render( p_sys, p_pic ); - p_pic->date = p_block->i_pts > 0 ? p_block->i_pts : p_block->i_dts; + Render( p_sys, p_pic ); + p_pic->date = p_block->i_pts > 0 ? p_block->i_pts : p_block->i_dts; + } +exit: block_Release( p_block ); *pp_block = NULL; return p_pic; - -error: - block_Release( p_block ); *pp_block = NULL; - return NULL; } /***************************************************************************** @@ -190,8 +199,9 @@ static void ScreenFill( decoder_sys_t *p_cdg, int sx, int sy, int dx, int dy, in static int DecodeMemoryPreset( decoder_sys_t *p_cdg, const uint8_t *p_data ) { const int i_color = p_data[0]&0x0f; +#if 0 const int i_repeat= p_data[1]&0x0f; - +#endif /* if i_repeat > 0 we could ignore it if we have a reliable stream */ ScreenFill( p_cdg, 0, 0, CDG_SCREEN_WIDTH, CDG_SCREEN_HEIGHT, i_color ); return 0; @@ -336,6 +346,8 @@ static int DecodePacket( decoder_sys_t *p_cdg, uint8_t *p_buffer, int i_buffer ) if( i_buffer != CDG_PACKET_SIZE ) return -1; + p_cdg->i_packet++; + /* Handle CDG command only */ if( i_cmd != 0x09 ) return 0;