changeset 8967:95f0a0d006c5

telecine detection
author arpi
date Thu, 16 Jan 2003 23:40:31 +0000
parents ec8af5150ea2
children 973bd8b405f8
files libmpdemux/video.c
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/video.c	Thu Jan 16 23:03:06 2003 +0000
+++ b/libmpdemux/video.c	Thu Jan 16 23:40:31 2003 +0000
@@ -27,6 +27,9 @@
 
 static mp_mpeg_header_t picture;
 
+static int telecine=0;
+static float telecine_cnt=-2.5;
+
 int video_read_properties(sh_video_t *sh_video){
 demux_stream_t *d_video=sh_video->ds;
 
@@ -92,6 +95,7 @@
 //mpeg_header_parser:
    // Find sequence_header first:
    videobuf_len=0; videobuf_code_len=0;
+   telecine=0; telecine_cnt=-2.5;
    mp_msg(MSGT_DECVIDEO,MSGL_V,"Searching for sequence header... ");fflush(stdout);
    while(1){
       int i=sync_video_packet(d_video);
@@ -282,7 +286,7 @@
 #if 1
     // get mpeg fps:
     //newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;
-    if((int)(sh_video->fps*10000+0.5)!=picture.fps) if(!force_fps){
+    if((int)(sh_video->fps*10000+0.5)!=picture.fps) if(!force_fps && !telecine){
             mp_msg(MSGT_CPLAYER,MSGL_WARN,"Warning! FPS changed %5.3f -> %5.3f  (%f) [%d]  \n",sh_video->fps,picture.fps*0.0001,sh_video->fps-picture.fps*0.0001,picture.frame_rate_code);
             sh_video->fps=picture.fps*0.0001;
             sh_video->frametime=10000.0f/(float)picture.fps;
@@ -294,6 +298,24 @@
     picture.display_time=100;
     videobuf_len=0;
 
+    telecine_cnt*=0.9; // drift out error
+    telecine_cnt+=frame_time-5.0/4.0;
+//    printf("\r telecine = %5.3f     \n",telecine_cnt);
+    
+    if(telecine){
+	frame_time=1;
+	if(telecine_cnt<-1.5 || telecine_cnt>1.5){
+	    mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_LeaveTelecineMode);
+	    telecine=0;
+	}
+    } else
+	if(telecine_cnt>-0.5 && telecine_cnt<0.5 && !force_fps){
+	    sh_video->fps=sh_video->fps*4/5;
+	    sh_video->frametime=sh_video->frametime*5/4;
+	    mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_EnterTelecineMode,sh_video->fps);
+	    telecine=1;
+	}
+
   } else {
       // frame-based file formats: (AVI,ASF,MOV)
     in_size=ds_get_packet(d_video,start);