[vlc-devel] commit: Reduce CDG decoder frame rate down to 25. (Laurent Aimar )

git version control git at videolan.org
Sat Mar 7 17:59:02 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Mar  7 17:19:07 2009 +0100| [c0aeb6ae728d002311a7aa0b9f4b1cb761907705] | committer: Laurent Aimar 

Reduce CDG decoder frame rate down to 25.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c0aeb6ae728d002311a7aa0b9f4b1cb761907705
---

 modules/codec/cdg.c |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/modules/codec/cdg.c b/modules/codec/cdg.c
index 7dca2a5..c1a3e75 100644
--- a/modules/codec/cdg.c
+++ b/modules/codec/cdg.c
@@ -58,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)
@@ -107,6 +109,7 @@ static int Open( vlc_object_t *p_this )
 
     /* Init */
     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 ? */
@@ -141,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 )
     {
@@ -149,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 = 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 > 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;
 }
 
 /*****************************************************************************
@@ -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;




More information about the vlc-devel mailing list