From 2d0bcfb412a618e8130fbfea15df76eb0f7dac45 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Sat, 13 Jan 2007 02:45:05 +0000
Subject: [PATCH] some interlaced direct sanity checks

Originally committed as revision 7442 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavcodec/h263.c      | 4 ++++
 libavcodec/mpegvideo.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index af5fa50e679..27b66a0c812 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -5928,6 +5928,10 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
                            - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
         s->pb_field_time= (  ROUNDED_DIV(s->time, s->t_frame)
                            - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
+        if(!s->progressive_sequence){
+            if(s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1)
+                return FRAME_SKIPPED;
+        }
     }
 //av_log(s->avctx, AV_LOG_DEBUG, "last nonb %"PRId64" last_base %d time %"PRId64" pp %d pb %d t %d ppf %d pbf %d\n", s->last_non_b_time, s->last_time_base, s->time, s->pp_time, s->pb_time, s->t_frame, s->pp_field_time, s->pb_field_time);
 
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 7b9a3e0f4a0..9c6b9f12050 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -4630,6 +4630,7 @@ void ff_mpeg_flush(AVCodecContext *avctx){
     s->parse_context.index= 0;
     s->parse_context.last_index= 0;
     s->bitstream_buffer_size=0;
+    s->pp_time=0;
 }
 
 #ifdef CONFIG_ENCODERS
-- 
GitLab