changeset 14894:bd6d709d13fb

recalculate frame duration after soft telecine
author nicodvb
date Thu, 03 Mar 2005 07:48:54 +0000
parents faa87d404b0a
children 7515d2e33076
files libmpdemux/muxer_mpeg.c
diffstat 1 files changed, 25 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/muxer_mpeg.c	Thu Mar 03 03:11:44 2005 +0000
+++ b/libmpdemux/muxer_mpeg.c	Thu Mar 03 07:48:54 2005 +0000
@@ -1821,6 +1821,7 @@
 			return 0;
 		}
 		*fps_ptr = (*fps_ptr & 0xf0) | (fps + 3);
+		vpriv->nom_delta_pts = parse_fps((fps + 3) == FRAMERATE_2997 ? 299700 : 300000);
 	}
 	
 	//in pce_ptr starting from bit 0 bit 24 is tff, bit 30 is rff, 
@@ -1831,6 +1832,8 @@
 		return 0;
 	}
 
+	vpriv->picture.progressive_sequence = 0;
+	vpriv->picture.progressive_frame = 1;
 	if(se_ptr)
 		se_ptr[1] &= 0xf7;
 	
@@ -1936,27 +1939,6 @@
 			temp_ref = (s->buffer[ptr+4]<<2)+(s->buffer[ptr+5]>>6);
 			if(!spriv->vframes)
 				spriv->last_tr = spriv->max_tr = temp_ref;
-			mp_msg(MSGT_MUXER, MSGL_V, "Video frame type: %c, TR: %d\n", FTYPE(pt), temp_ref);
-			if(spriv->picture.mpeg1 == 0) 
-			{
-				size_t tmp = ptr;
-			
-				while (ptr < len-5 && 
-					(s->buffer[ptr] != 0 || s->buffer[ptr+1] != 0 || s->buffer[ptr+2] != 1 || s->buffer[ptr+3] != 0xb5)) 
-						ptr++;
-				if(ptr < len-5) 
-				{
-					pce_ptr = &(s->buffer[ptr+4]);
-					mp_header_process_extension(&(spriv->picture), &(s->buffer[ptr+4]));
-					if(spriv->picture.display_time >= 50 && spriv->picture.display_time <= 300) 
-						spriv->delta_pts = (spriv->nom_delta_pts * spriv->picture.display_time) / 100;
-				}
-				else 
-					spriv->delta_pts = spriv->nom_delta_pts;
-			
-				ptr = tmp;
-			}
-			
 			d1 = temp_ref - spriv->last_tr;
 			if(d1 < -6)	//there's a wraparound
 				frames_diff = spriv->max_tr + 1 + temp_ref - spriv->last_tr;
@@ -1972,6 +1954,28 @@
 				spriv->max_tr = temp_ref;
 			
 			spriv->last_tr = temp_ref;
+			mp_msg(MSGT_MUXER, MSGL_V, "Video frame type: %c, TR: %d\n", FTYPE(pt), temp_ref);
+			if(spriv->picture.mpeg1 == 0) 
+			{
+				size_t tmp = ptr;
+			
+				while (ptr < len-5 && 
+					(s->buffer[ptr] != 0 || s->buffer[ptr+1] != 0 || s->buffer[ptr+2] != 1 || s->buffer[ptr+3] != 0xb5)) 
+						ptr++;
+				if(ptr < len-5) 
+				{
+					pce_ptr = &(s->buffer[ptr+4]);
+					if(spriv->telecine)
+						soft_telecine(spriv, fps_ptr, se_ptr, pce_ptr, frames_diff);
+					mp_header_process_extension(&(spriv->picture), &(s->buffer[ptr+4]));
+					if(spriv->picture.display_time >= 50 && spriv->picture.display_time <= 300) 
+						spriv->delta_pts = (spriv->nom_delta_pts * spriv->picture.display_time) / 100;
+				}
+				else 
+					spriv->delta_pts = spriv->nom_delta_pts;
+			
+				ptr = tmp;
+			}
 		}
 		
 		switch (pt) {
@@ -1997,9 +2001,6 @@
 			  sz = len; // no extra buffer for it...
 		}
 
-		if(spriv->telecine)
-			soft_telecine(spriv, fps_ptr, se_ptr, pce_ptr, frames_diff);
-
 		spriv->vframes++;
 		reorder_frame(spriv, s->buffer, len, pt, temp_ref, spriv->delta_pts);
 	}