changeset 2419:0c5ceb97815d libavcodec

picture heap corruption fix
author michael
date Mon, 10 Jan 2005 23:41:25 +0000
parents 82af834636c2
children 842e5e7f3b7a
files mpegvideo.c
diffstat 1 files changed, 23 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Sun Jan 09 23:39:32 2005 +0000
+++ b/mpegvideo.c	Mon Jan 10 23:41:25 2005 +0000
@@ -1959,6 +1959,29 @@
     const int encoding_delay= s->max_b_frames;
     int direct=1;
     
+    if(pic_arg){
+        if(pic_arg->pts != AV_NOPTS_VALUE){ 
+            if(s->user_specified_pts != AV_NOPTS_VALUE){
+                int64_t time= av_rescale(pic_arg->pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE);
+                int64_t last= av_rescale(s->user_specified_pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE);
+            
+                if(time <= last){            
+                    av_log(s->avctx, AV_LOG_ERROR, "Error, Invalid timestamp=%Ld, last=%Ld\n", pic_arg->pts, s->user_specified_pts);
+                    return -1;
+                }
+            }
+            s->user_specified_pts= pic_arg->pts;
+        }else{
+            if(s->user_specified_pts != AV_NOPTS_VALUE){
+                s->user_specified_pts= 
+                pic_arg->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate;
+                av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic_arg->pts);
+            }else{
+                pic_arg->pts= av_rescale(pic_arg->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate);
+            }
+        }
+    }
+
   if(pic_arg){
     if(encoding_delay && !(s->flags&CODEC_FLAG_INPUT_PRESERVED)) direct=0;
     if(pic_arg->linesize[0] != s->linesize) direct=0;
@@ -2021,26 +2044,6 @@
     
     pic->display_picture_number= s->input_picture_number++;
  
-    if(pic->pts != AV_NOPTS_VALUE){ 
-        if(s->user_specified_pts != AV_NOPTS_VALUE){
-            int64_t time= av_rescale(pic->pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE);
-            int64_t last= av_rescale(s->user_specified_pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE);
-        
-            if(time <= last){            
-                av_log(s->avctx, AV_LOG_ERROR, "Error, Invalid timestamp=%Ld, last=%Ld\n", pic->pts, s->user_specified_pts);
-                return -1;
-            }
-        }
-        s->user_specified_pts= pic->pts;
-    }else{
-        if(s->user_specified_pts != AV_NOPTS_VALUE){
-            s->user_specified_pts= 
-            pic->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate;
-            av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic->pts);
-        }else{
-            pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate);
-        }
-    }
   }
   
     /* shift buffer entries */