#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
-#include <vlc_vout.h>
/*****************************************************************************
* decoder_sys_t : decoder descriptor
int i_offsetv;
uint8_t screen[CDG_SCREEN_PITCH*CDG_SCREEN_HEIGHT];
uint8_t *p_screen;
+
+ int i_packet;
};
#define CDG_PACKET_SIZE (24)
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-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();
+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
decoder_t *p_dec = (decoder_t*)p_this;
decoder_sys_t *p_sys;
- if( p_dec->fmt_in.i_codec != VLC_FOURCC('C','D','G',' ') )
+ if( p_dec->fmt_in.i_codec != VLC_CODEC_CDG )
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 )
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 ? */
p_dec->fmt_out.i_cat = VIDEO_ES;
- p_dec->fmt_out.i_codec = VLC_FOURCC('R','V','3','2');
+ p_dec->fmt_out.i_codec = VLC_CODEC_RGB32;
p_dec->fmt_out.video.i_width = CDG_DISPLAY_WIDTH;
p_dec->fmt_out.video.i_height = CDG_DISPLAY_HEIGHT;
- p_dec->fmt_out.video.i_aspect =
- VOUT_ASPECT_FACTOR * p_dec->fmt_out.video.i_width / p_dec->fmt_out.video.i_height;
+ p_dec->fmt_out.video.i_sar_num = 1;
+ p_dec->fmt_out.video.i_sar_den = 1;
p_dec->fmt_out.video.i_rmask = 0xff << CDG_COLOR_R_SHIFT;
p_dec->fmt_out.video.i_gmask = 0xff << CDG_COLOR_G_SHIFT;
p_dec->fmt_out.video.i_bmask = 0xff << CDG_COLOR_B_SHIFT;
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 )
{
p_block->p_buffer += CDG_PACKET_SIZE;
}
- /* Get a new picture */
- p_pic = decoder_NewPicture( 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 > VLC_TS_INVALID ? 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;
}
/*****************************************************************************
if( i_buffer != CDG_PACKET_SIZE )
return -1;
+ p_cdg->i_packet++;
+
/* Handle CDG command only */
if( i_cmd != 0x09 )
return 0;