[vlc-devel] commit: libmpeg2: fix division by zero (fixes #2920) ( Rémi Denis-Courmont )

git version control git at videolan.org
Thu Jul 2 18:02:37 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul  2 19:01:06 2009 +0300| [34ad999e7d0be9054b00d15158d91ebbf9c40def] | committer: Rémi Denis-Courmont 

libmpeg2: fix division by zero (fixes #2920)
(cherry picked from commit 40486dcf6638fe85d7860790e28196e8df7ad418)

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

 modules/codec/libmpeg2.c |   33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/modules/codec/libmpeg2.c b/modules/codec/libmpeg2.c
index 1551e91..ad41575 100644
--- a/modules/codec/libmpeg2.c
+++ b/modules/codec/libmpeg2.c
@@ -279,9 +279,12 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             if( p_sys->p_synchro )
                 decoder_SynchroRelease( p_sys->p_synchro );
 
-            p_sys->p_synchro =
-                decoder_SynchroInit( p_dec, (uint32_t)((uint64_t)1001000000 * 27 /
-                                     p_sys->p_info->sequence->frame_period) );
+            if( p_sys->p_info->sequence->frame_period <= 0 )
+                p_sys->p_synchro = NULL;
+            else
+                p_sys->p_synchro =
+                decoder_SynchroInit( p_dec, (uint32_t)(UINT64_C(1001000000) *
+                                27 / p_sys->p_info->sequence->frame_period) );
             p_sys->b_after_sequence_header = true;
             break;
         }
@@ -720,16 +723,20 @@ static void GetAR( decoder_t *p_dec )
         }
     }
 
-    msg_Dbg( p_dec, "%dx%d (display %d,%d), aspect %d, sar %i:%i, %u.%03u fps",
-             p_sys->p_info->sequence->picture_width,
-             p_sys->p_info->sequence->picture_height,
-             p_sys->p_info->sequence->display_width,
-             p_sys->p_info->sequence->display_height,
-             p_sys->i_aspect, p_sys->i_sar_num, p_sys->i_sar_den,
-             (uint32_t)((uint64_t)1001000000 * 27 /
-                 p_sys->p_info->sequence->frame_period / 1001),
-             (uint32_t)((uint64_t)1001000000 * 27 /
-                 p_sys->p_info->sequence->frame_period % 1001) );
+    if( p_sys->p_info->sequence->frame_period > 0 )
+        msg_Dbg( p_dec,
+                 "%dx%d (display %d,%d), aspect %d, sar %i:%i, %u.%03u fps",
+                 p_sys->p_info->sequence->picture_width,
+                 p_sys->p_info->sequence->picture_height,
+                 p_sys->p_info->sequence->display_width,
+                 p_sys->p_info->sequence->display_height,
+                 p_sys->i_aspect, p_sys->i_sar_num, p_sys->i_sar_den,
+                 (uint32_t)((uint64_t)1001000000 * 27 /
+                     p_sys->p_info->sequence->frame_period / 1001),
+                 (uint32_t)((uint64_t)1001000000 * 27 /
+                     p_sys->p_info->sequence->frame_period % 1001) );
+    else
+        msg_Dbg( p_dec, "bad frame period" );
 }
 
 /*****************************************************************************




More information about the vlc-devel mailing list