[FFmpeg-cvslog] r20640 - trunk/libavcodec/mpeg12.c

michael subversion
Sat Nov 28 15:17:28 CET 2009


Author: michael
Date: Sat Nov 28 15:17:28 2009
New Revision: 20640

Log:
Simplify mpeg_decode_user_data()

Modified:
   trunk/libavcodec/mpeg12.c

Modified: trunk/libavcodec/mpeg12.c
==============================================================================
--- trunk/libavcodec/mpeg12.c	Sat Nov 28 11:58:07 2009	(r20639)
+++ trunk/libavcodec/mpeg12.c	Sat Nov 28 15:17:28 2009	(r20640)
@@ -2113,28 +2113,21 @@ static int vcr2_init_sequence(AVCodecCon
 
 
 static void mpeg_decode_user_data(AVCodecContext *avctx,
-                                  const uint8_t *buf, int buf_size)
+                                  const uint8_t *p, int buf_size)
 {
-    const uint8_t *p;
-    int len, flags;
-    p = buf;
-    len = buf_size;
+    const uint8_t *buf_end = p+buf_size;
 
     /* we parse the DTG active format information */
-    if (len >= 5 &&
+    if (buf_end - p >= 5 &&
         p[0] == 'D' && p[1] == 'T' && p[2] == 'G' && p[3] == '1') {
-        flags = p[4];
+        int flags = p[4];
         p += 5;
-        len -= 5;
         if (flags & 0x80) {
             /* skip event id */
-            if (len < 2)
-                return;
             p += 2;
-            len -= 2;
         }
         if (flags & 0x40) {
-            if (len < 1)
+            if (buf_end - p < 1)
                 return;
             avctx->dtg_active_format = p[0] & 0x0f;
         }



More information about the ffmpeg-cvslog mailing list