# HG changeset patch # User arpi # Date 1042760431 0 # Node ID 95f0a0d006c5c88d0e57cd1684fdf12e10cc9be3 # Parent ec8af5150ea279e39b2902d6b6d1daa69f68d529 telecine detection diff -r ec8af5150ea2 -r 95f0a0d006c5 libmpdemux/video.c --- 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);