CVS: main mplayer.c,1.54,1.55
Update of /cvsroot/mplayer/main In directory usw-pr-cvs1:/tmp/cvs-serv8434 Modified Files: mplayer.c Log Message: more cleanup of video decoding Index: mplayer.c =================================================================== RCS file: /cvsroot/mplayer/main/mplayer.c,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -r1.54 -r1.55 *** mplayer.c 2001/04/13 23:37:40 1.54 --- mplayer.c 2001/04/14 03:12:06 1.55 *************** *** 4,10 **** //#define SIMULATE_ALSA - // Define, if you want to run libmpeg2 in a new process (using codec-ctrl) - //#define HAVE_CODECCTRL - #ifdef USE_XMMP_AUDIO #define OUTBURST 4096 --- 4,7 ---- *************** *** 89,92 **** --- 86,91 ---- int verbose=0; + #define ABS(x) (((x)>=0)?(x):(-(x))) + //**************************************************************************// // .SUB *************** *** 307,315 **** #include "fifo.c" - // MPEG video codec process controller: - #ifdef HAVE_CODECCTRL - #include "codecctrl.c" - #endif - //**************************************************************************// --- 306,309 ---- *************** *** 323,346 **** // restore terminal: getch2_disable(); ! #ifdef HAVE_CODECCTRL ! if(child_pid){ ! // MPEG ! // printf("\n\n"); ! //send_cmd(data_fifo,0);usleep(50000); // EOF request ! DEBUG_SIG { printf("Sending TERM signal to CTRL...\n");DEBUG_SIGNALS_SLEEP} ! kill(child_pid,SIGTERM); ! usleep(10000); // kill & wait 10ms ! DEBUG_SIG { printf("Closing PIPEs...\n");DEBUG_SIGNALS_SLEEP} ! close(control_fifo); ! close(data_fifo); ! DEBUG_SIG { printf("Freeing shmem...\n");DEBUG_SIGNALS_SLEEP} ! if(videobuffer) shmem_free(videobuffer); ! DEBUG_SIG { printf("Exiting...\n");DEBUG_SIGNALS_SLEEP} ! } else ! #endif ! { ! // AVI ! video_out->uninit(); ! } #ifdef USE_XMMP_AUDIO if(verbose) printf("XMM: closing audio driver...\n"); --- 317,321 ---- // restore terminal: getch2_disable(); ! video_out->uninit(); #ifdef USE_XMMP_AUDIO if(verbose) printf("XMM: closing audio driver...\n"); *************** *** 400,404 **** int delay_corrected=1; float force_fps=0; - float default_fps=25; float audio_delay=0; int vcd_track=0; --- 375,378 ---- *************** *** 422,427 **** int screen_size_xy=0; // movie info: - int movie_size_x=0; - int movie_size_y=0; int out_fmt=0; char *dsp="/dev/dsp"; --- 396,399 ---- *************** *** 699,708 **** } else sh_audio->format=sh_audio->wf.wFormatTag; } // calculating video bitrate: - default_fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8; if(sh_audio) avi_header.bitrate-=sh_audio->audio.dwLength; if(verbose) printf("AVI video length=%d\n",avi_header.bitrate); ! avi_header.bitrate=((float)avi_header.bitrate/(float)sh_video->video.dwLength)*default_fps; printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", &sh_video->bih.biCompression, --- 671,682 ---- } else sh_audio->format=sh_audio->wf.wFormatTag; } + // calc. FPS: + sh_video->fps=(float)sh_video->video.dwRate/(float)sh_video->video.dwScale; + sh_video->frametime=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; // calculating video bitrate: avi_header.bitrate=avi_header.movi_end-avi_header.movi_start-avi_header.idx_size*8; if(sh_audio) avi_header.bitrate-=sh_audio->audio.dwLength; if(verbose) printf("AVI video length=%d\n",avi_header.bitrate); ! avi_header.bitrate=((float)avi_header.bitrate/(float)sh_video->video.dwLength)*sh_video->fps; printf("VIDEO: [%.4s] %dx%d %dbpp %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", &sh_video->bih.biCompression, *************** *** 710,714 **** sh_video->bih.biHeight, sh_video->bih.biBitCount, ! default_fps, avi_header.bitrate*0.008f, avi_header.bitrate/1024.0f ); --- 684,688 ---- sh_video->bih.biHeight, sh_video->bih.biBitCount, ! sh_video->fps, avi_header.bitrate*0.008f, avi_header.bitrate/1024.0f ); *************** *** 733,736 **** --- 707,711 ---- } else sh_audio->format=sh_audio->wf.wFormatTag; } + sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms printf("VIDEO: [%.4s] %dx%d %dbpp\n", &sh_video->bih.biCompression, *************** *** 769,774 **** // display info: sh_video->format=sh_video->bih.biCompression; ! movie_size_x=sh_video->bih.biWidth; ! movie_size_y=abs(sh_video->bih.biHeight); break; } --- 744,749 ---- // display info: sh_video->format=sh_video->bih.biCompression; ! sh_video->disp_w=sh_video->bih.biWidth; ! sh_video->disp_h=abs(sh_video->bih.biHeight); break; } *************** *** 805,818 **** } // display info: ! default_fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; ! movie_size_x=picture->display_picture_width; ! movie_size_y=picture->display_picture_height; // info: if(verbose) printf("mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate); printf("VIDEO: %s %dx%d (aspect %d) %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", picture->mpeg1?"MPEG1":"MPEG2", ! movie_size_x,movie_size_y, picture->aspect_ratio_information, ! default_fps, picture->bitrate*0.5f, picture->bitrate/16.0f ); --- 780,794 ---- } // display info: ! sh_video->fps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; ! sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; ! sh_video->disp_w=picture->display_picture_width; ! sh_video->disp_h=picture->display_picture_height; // info: if(verbose) printf("mpeg bitrate: %d (%X)\n",picture->bitrate,picture->bitrate); printf("VIDEO: %s %dx%d (aspect %d) %4.2f fps %5.1f kbps (%4.1f kbyte/s)\n", picture->mpeg1?"MPEG1":"MPEG2", ! sh_video->disp_w,sh_video->disp_h, picture->aspect_ratio_information, ! sh_video->fps, picture->bitrate*0.5f, picture->bitrate/16.0f ); *************** *** 823,826 **** --- 799,807 ---- if(verbose) printf("file successfully opened (has_audio=%d)\n",has_audio); + printf("[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", + file_format,sh_video->format,sh_video->disp_w,sh_video->disp_h, + sh_video->fps,sh_video->frametime + ); + fflush(stdout); *************** *** 957,961 **** return 0; } ! write_avi_header_1(encode_file,mmioFOURCC('d', 'i', 'v', 'x'),default_fps,movie_size_x,movie_size_y); fclose(encode_file); encode_index_name=malloc(strlen(encode_name)+8); --- 938,942 ---- return 0; } ! write_avi_header_1(encode_file,mmioFOURCC('d', 'i', 'v', 'x'),sh_video->fps,sh_video->disp_w,sh_video->disp_h); fclose(encode_file); encode_index_name=malloc(strlen(encode_name)+8); *************** *** 972,976 **** make_pipe(&keyb_fifo_get,&keyb_fifo_put); ! // ========== Init display (movie_size_x*movie_size_y/out_fmt) ============ #ifdef X11_FULLSCREEN --- 953,957 ---- make_pipe(&keyb_fifo_get,&keyb_fifo_put); ! // ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============ #ifdef X11_FULLSCREEN *************** *** 985,1004 **** if(screen_size_xy>0){ if(screen_size_xy<=8){ ! screen_size_x=screen_size_xy*movie_size_x; ! screen_size_y=screen_size_xy*movie_size_y; } else { screen_size_x=screen_size_xy; ! screen_size_y=screen_size_xy*movie_size_y/movie_size_x; } } else if(!vidmode){ if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; ! if(screen_size_x<=8) screen_size_x*=movie_size_x; ! if(screen_size_y<=8) screen_size_y*=movie_size_y; } { const vo_info_t *info = video_out->get_info(); printf("VO: [%s] %dx%d => %dx%d %s%s%s ",info->short_name, ! movie_size_x,movie_size_y, screen_size_x,screen_size_y, fullscreen?"fs ":"", --- 966,985 ---- if(screen_size_xy>0){ if(screen_size_xy<=8){ ! screen_size_x=screen_size_xy*sh_video->disp_w; ! screen_size_y=screen_size_xy*sh_video->disp_h; } else { screen_size_x=screen_size_xy; ! screen_size_y=screen_size_xy*sh_video->disp_h/sh_video->disp_w; } } else if(!vidmode){ if(!screen_size_x) screen_size_x=SCREEN_SIZE_X; if(!screen_size_y) screen_size_y=SCREEN_SIZE_Y; ! if(screen_size_x<=8) screen_size_x*=sh_video->disp_w; ! if(screen_size_y<=8) screen_size_y*=sh_video->disp_h; } { const vo_info_t *info = video_out->get_info(); printf("VO: [%s] %dx%d => %dx%d %s%s%s ",info->short_name, ! sh_video->disp_w,sh_video->disp_h, screen_size_x,screen_size_y, fullscreen?"fs ":"", *************** *** 1019,1028 **** if(verbose) printf("video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", ! movie_size_x,movie_size_y, screen_size_x,screen_size_y, fullscreen|(vidmode<<1)|(softzoom<<2), title,out_fmt); ! if(video_out->init(movie_size_x,movie_size_y, screen_size_x,screen_size_y, fullscreen|(vidmode<<1)|(softzoom<<2), --- 1000,1009 ---- if(verbose) printf("video_out->init(%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", ! sh_video->disp_w,sh_video->disp_h, screen_size_x,screen_size_y, fullscreen|(vidmode<<1)|(softzoom<<2), title,out_fmt); ! if(video_out->init(sh_video->disp_w,sh_video->disp_h, screen_size_x,screen_size_y, fullscreen|(vidmode<<1)|(softzoom<<2), *************** *** 1050,1054 **** int force_redraw=0; float num_frames=0; // number of frames played - //int real_num_frames=0; // number of frames readed double video_time_usage=0; double vout_time_usage=0; --- 1031,1034 ---- *************** *** 1176,1183 **** if(file_format==DEMUXER_TYPE_AVI){ a_pts=d_audio->pts-(buffer_delay+audio_delay); ! audio_delay-=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps; // audio_delay-=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps; if(verbose){ ! printf("AVI Initial frame delay: %5.3f\n",(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps); printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n", audio_delay,buffer_delay,a_pts,a_frame); --- 1156,1163 ---- if(file_format==DEMUXER_TYPE_AVI){ a_pts=d_audio->pts-(buffer_delay+audio_delay); ! audio_delay-=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime; // audio_delay-=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)/default_fps; if(verbose){ ! printf("AVI Initial frame delay: %5.3f\n",(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime); printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n", audio_delay,buffer_delay,a_pts,a_frame); *************** *** 1186,1191 **** delay_corrected=0; // has to correct PTS diffs d_video->pts=0;d_audio->pts=0; // PTS is outdated now! } - if(force_fps) default_fps=force_fps; printf("Start playing...\n");fflush(stdout); --- 1166,1174 ---- delay_corrected=0; // has to correct PTS diffs d_video->pts=0;d_audio->pts=0; // PTS is outdated now! + } + if(force_fps){ + sh_video->fps=force_fps; + sh_video->frametime=1.0f/sh_video->fps; } printf("Start playing...\n");fflush(stdout); *************** *** 1260,1282 **** time_frame+=OUTBURST/(float)(sh_audio->o_bps); time_frame-=GetRelativeTime(); - // printf("time_frame=%5.3f\n",time_frame); if(time_frame<-0.1 || time_frame>0.1){ time_frame=0; } else { ! // if(time_frame>0.01) usleep(1000000*(time_frame-0.01)); // sleeping ! // if(time_frame>0.019) usleep(1000000*(time_frame-0.019)); // sleeping ! // if(time_frame>0.001) usleep(1000000*(time_frame)); // sleeping ! // if(time_frame>0.02) usleep(1000000*(time_frame)); // sleeping if >20ms while(time_frame>0.007){ ! // printf("TIMER %8.3f -> ",time_frame*1000); ! // if(time_frame>0.021) ! // usleep(time_frame-0.12); ! // else ! usleep(1000); time_frame-=GetRelativeTime(); - // printf("%8.3f \n",time_frame*1000); } ! } ! } --- 1243,1258 ---- time_frame+=OUTBURST/(float)(sh_audio->o_bps); time_frame-=GetRelativeTime(); if(time_frame<-0.1 || time_frame>0.1){ time_frame=0; } else { ! while(time_frame>0.022){ ! usleep(time_frame-0.22); ! time_frame-=GetRelativeTime(); ! } while(time_frame>0.007){ ! usleep(0); time_frame-=GetRelativeTime(); } ! } } *************** *** 1286,1289 **** --- 1262,1268 ---- if(1) while(v_frame<a_frame || force_redraw){ + + float frame_time=1; + float pts1=d_video->pts; current_module="decode_video"; *************** *** 1303,1307 **** dec_frame.length = in_size; dec_frame.bitstream = start; - //dec_frame.bmp = video_out; dec_frame.render_flag = 1; decore(0x123, 0, &dec_frame, NULL); --- 1282,1285 ---- *************** *** 1310,1323 **** if(opendivx_src[0]){ video_out->draw_slice(opendivx_src,opendivx_stride, ! movie_size_x,movie_size_y,0,0); ! // video_out->flip_page(); opendivx_src[0]=NULL; } - t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; - ++num_frames; - v_frame+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; - break; } --- 1288,1296 ---- if(opendivx_src[0]){ video_out->draw_slice(opendivx_src,opendivx_stride, ! sh_video->disp_w,sh_video->disp_h,0,0); opendivx_src[0]=NULL; } t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; break; } *************** *** 1327,1354 **** unsigned int t=GetTimer(); unsigned int t2; - float pts1=d_video->pts; int in_size=ds_get_packet(d_video,&start); - float pts2=d_video->pts; if(in_size<0){ eof=1;break;} if(in_size>max_framesize) max_framesize=in_size; - // printf("frame len = %5.4f\n",pts2-pts1); - DS_VideoDecoder_DecodeFrame(start, in_size, 0, 1); - t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); - // video_out->flip_page(); t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; - - ++num_frames; - - if(file_format==DEMUXER_TYPE_ASF){ - float d=pts2-pts1; - if(d>0 && d<0.2) v_frame+=d; - } else - v_frame+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; - //v_pts+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; - break; } --- 1300,1311 ---- *************** *** 1359,1399 **** unsigned int t=GetTimer(); unsigned int t2; - float pts1=d_video->pts; int in_size=ds_get_packet(d_video,&start); - float pts2=d_video->pts; if(in_size<0){ eof=1;break;} if(in_size>max_framesize) max_framesize=in_size; - // printf("frame len = %5.4f\n",pts2-pts1); - - //if(in_size>0){ sh_video->bih.biSizeImage = in_size; - ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME, // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), &sh_video->bih, start, &sh_video->o_bih, sh_video->our_out_buffer); if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; } - //} t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); - // video_out->flip_page(); t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; - ++num_frames; - - if(file_format==DEMUXER_TYPE_ASF){ - float d=pts2-pts1; - if(d>0 && d<0.2) v_frame+=d; - } else - v_frame+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; - //v_pts+=1.0f/default_fps; //(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; - break; } case 1: { - #ifndef HAVE_CODECCTRL - int in_frame=0; videobuf_len=0; while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ --- 1316,1340 ---- unsigned int t=GetTimer(); unsigned int t2; int in_size=ds_get_packet(d_video,&start); if(in_size<0){ eof=1;break;} if(in_size>max_framesize) max_framesize=in_size; sh_video->bih.biSizeImage = in_size; // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), + ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME, &sh_video->bih, start, &sh_video->o_bih, sh_video->our_out_buffer); if(ret){ printf("Error decompressing frame, err=%d\n",ret);break; } t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer); t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f; break; } case 1: { int in_frame=0; + int t=0; + float newfps; videobuf_len=0; while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ *************** *** 1401,1406 **** if(in_frame){ if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame - // send END OF FRAME code: #if 1 videobuffer[videobuf_len+0]=0; videobuffer[videobuf_len+1]=0; --- 1342,1347 ---- if(in_frame){ if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame #if 1 + // send END OF FRAME code: videobuffer[videobuf_len+0]=0; videobuffer[videobuf_len+1]=0; *************** *** 1429,1545 **** fclose(f); } - ++dbg_es_sent; - //if(videobuf_len>4) - //my_write(data_fifo,(char*) &videobuf_len,4); ! { int t=0; ! int x; ! float l; ! t-=GetTimer(); mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len); ! t+=GetTimer(); ! //*** CMD=0 : Frame completed *** ! //send_cmd(control_fifo2,0); // FRAME_COMPLETED command ! x=frameratecode2framerate[picture->frame_rate_code]; //fps ! ++dbg_es_rcvd; ! l=(100+picture->repeat_count)*0.01f; ! num_frames+=l; ! picture->repeat_count=0; ! video_time_usage+=t*0.000001; ! if(x && !force_fps) default_fps=x*0.0001f; ! if(!force_redraw){ ! // increase video timers: ! v_frame+=l/default_fps; ! v_pts+=l/default_fps; ! } ! } ! //if(eof) break; ! #else ! while(1){ ! int x; ! while(1){ ! x=-1; // paranoia ! if(4==read(control_fifo,&x,4)) break; // status/command ! usleep(5000); // do not eat 100% CPU (waiting for codec restart) ! } ! if(x==0x3030303){ ! //*** CMD=3030303 : Video packet requested *** ! // read a single compressed frame: ! int in_frame=0; ! videobuf_len=0; ! while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ ! int i=sync_video_packet(d_video); ! if(in_frame){ ! if(i<0x101 || i>=0x1B0){ // not slice code -> end of frame ! // send END OF FRAME code: ! #if 1 ! videobuffer[videobuf_len+0]=0; ! videobuffer[videobuf_len+1]=0; ! videobuffer[videobuf_len+2]=1; ! videobuffer[videobuf_len+3]=0xFF; ! videobuf_len+=4; ! #endif ! if(!i) eof=1; // EOF ! break; ! } ! } else { ! //if(i==0x100) in_frame=1; // picture startcode ! if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode ! else if(!i){ eof=1; break;} // EOF ! } ! if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1; ! if(!read_video_packet(d_video)){ eof=1; break;} // EOF ! //printf("read packet 0x%X, len=%d\n",i,videobuf_len); } ! if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug ! //printf("--- SEND %d bytes\n",videobuf_len); ! if(grab_frames==1){ ! FILE *f=fopen("grab.mpg","ab"); ! fwrite(videobuffer,videobuf_len-4,1,f); ! fclose(f); ! } ! ++dbg_es_sent; ! //if(videobuf_len>4) ! my_write(data_fifo,(char*) &videobuf_len,4); ! if(eof) break; ! } else ! if(x==0){ ! //*** CMD=0 : Frame completed *** ! int l=100; ! int t=0; ! read(control_fifo,&x,4); // FPS ! read(control_fifo,&l,4); // Length*100 ! read(control_fifo,&t,4); // Time*1000000 ! //printf("+++ FRAME COMPLETED fps=%d len=%d time=%d\n",x,l,t); ! ++dbg_es_rcvd; ! num_frames+=l/100.0f; ! video_time_usage+=t*0.000001; ! if(x && !force_fps) default_fps=x*0.0001f; ! if(!force_redraw){ ! // increase video timers: ! v_frame+=l*0.01f/default_fps; ! v_pts+=l*0.01f/default_fps; ! } ! break; // frame OK. ! } else ! if(x==0x22222222){ ! //*** CMD=22222222 : codec reset/restart *** ! read(control_fifo,&codec_pid,4); // PID ! printf("\nVideo codec started... (pid %d)\n",codec_pid); ! send_cmd(data_fifo,0x22222222); // send response (syncword) ! dbg_es_sent=dbg_es_rcvd=0; ! //printf(" [ReSync-VIDEO] \n"); ! while(1){ ! int id=sync_video_packet(d_video); ! if(id==0x100 || id>=0x1B0) break; // header chunk ! if(!id || !skip_video_packet(d_video)){ eof=1; break;} // EOF ! } ! if(eof) break; ! max_pts_correction=0.2; ! } else ! printf("invalid cmd: 0x%X\n",x); ! } ! #endif break; } --- 1370,1388 ---- fclose(f); } ! t-=GetTimer(); mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len); ! t+=GetTimer(); video_time_usage+=t*0.000001; ! newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; ! if(ABS(sh_video->fps-newfps)>0.01f){ ! printf("Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video->fps,newfps,sh_video->fps-newfps,picture->frame_rate_code); ! sh_video->fps=newfps; ! sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; } ! ! frame_time=(100+picture->repeat_count)*0.01f; ! picture->repeat_count=0; ! break; } *************** *** 1547,1554 **** //------------------------ frame decoded. -------------------- ! current_module="flip_page"; video_out->flip_page(); - current_module=NULL; --- 1390,1406 ---- //------------------------ frame decoded. -------------------- ! // Increase video timers: ! num_frames+=frame_time; ! frame_time*=sh_video->frametime; ! if(file_format==DEMUXER_TYPE_ASF){ ! // .ASF files has no fixed FPS - just frame durations! ! float d=d_video->pts-pts1; ! if(d>=0 && d<5) frame_time=d; ! } ! v_frame+=frame_time; ! v_pts+=frame_time; + current_module="flip_page"; video_out->flip_page(); current_module=NULL; *************** *** 1591,1603 **** if(frame_corr_num==5){ float x=(frame_correction/5.0f); ! if(!delay_corrected){ ! #if 0 ! printf("Initial PTS delay: %5.3f sec\n",x); ! delay_corrected=1; ! audio_delay+=x; ! a_pts-=x; ! #endif ! } else ! { printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts,v_pts,x); x*=0.5f; --- 1443,1447 ---- if(frame_corr_num==5){ float x=(frame_correction/5.0f); ! if(delay_corrected){ printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts,v_pts,x); x*=0.5f; *************** *** 1606,1613 **** max_pts_correction=default_max_pts_correction; a_frame+=x; c_total+=x; - #if 0 - printf(" ct:%7.3f a=%d v=%d \r",c_total, - d_audio->pos,d_video->pos); - #else printf(" ct:%7.3f %3d %2d%% %2d%% %3.1f%% %d \r",c_total, (int)num_frames, --- 1450,1453 ---- *************** *** 1617,1626 **** dbg_es_sent-dbg_es_rcvd ); - #endif fflush(stdout); - // printf("\n"); } - //force_fps+=1*force_fps*x; - // printf(" ct:%7.3f fps:%5.2f nf:%2.1f/%d t:%d.%03d\r",c_total,default_fps,num_frames,real_num_frames,codec_time_usage_sec,codec_time_usage/1000);fflush(stdout); frame_corr_num=0; frame_correction=0; } --- 1457,1462 ---- *************** *** 1702,1725 **** case 'q': exit_player("Quit"); case 'g': grab_frames=2;break; - // restart codec - #ifdef HAVE_CODECCTRL - case 'k': kill(codec_pid,SIGKILL);break; - // case 'k': kill(child_pid,SIGKILL);break; - #endif // pause case 'p': case ' ': osd_function=OSD_PAUSE; - #if 0 - printf("\n------ PAUSED -------\r");fflush(stdout); - while( - #ifdef HAVE_LIRC - lirc_mp_getinput()<=0 && - #endif - getch2(20)<=0 && mplayer_get_key()<=0){ - video_out->check_events(); - } - osd_function=OSD_PLAY; - #endif break; case 'o': // toggle OSD --- 1538,1545 ---- *************** *** 1745,1749 **** case DEMUXER_TYPE_AVI: { //================= seek in AVI ========================== ! int rel_seek_frames=rel_seek_secs*default_fps; int curr_audio_pos=0; int audio_chunk_pos=-1; --- 1565,1569 ---- case DEMUXER_TYPE_AVI: { //================= seek in AVI ========================== ! int rel_seek_frames=rel_seek_secs*sh_video->fps; int curr_audio_pos=0; int audio_chunk_pos=-1; *************** *** 1892,1896 **** // Set OSD: if(osd_level){ ! osd_visible=default_fps; vo_osd_progbar_type=0; vo_osd_progbar_value=(demuxer->filepos)/((avi_header.movi_end-avi_header.movi_start)>>8); --- 1712,1716 ---- // Set OSD: if(osd_level){ ! osd_visible=sh_video->fps; // 1 sec vo_osd_progbar_type=0; vo_osd_progbar_value=(demuxer->filepos)/((avi_header.movi_end-avi_header.movi_start)>>8); *************** *** 2020,2024 **** // find sub if(subtitles){ ! if(sub_fps==0) sub_fps=default_fps; find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter... } --- 1840,1844 ---- // find sub if(subtitles){ ! if(sub_fps==0) sub_fps=sh_video->fps; find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter... } _______________________________________________ Mplayer-cvslog mailing list Mplayer-cvslog@lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
participants (1)
-
GEREOFFY