comparison mplayer.c @ 940:108ac8795d19

-fps 1 fixed
author arpi_esp
date Sat, 02 Jun 2001 01:00:22 +0000
parents ac9237ee06e1
children 3a3304cd9fd5
comparison
equal deleted inserted replaced
939:ac9237ee06e1 940:108ac8795d19
1575 pts_from_bps=0; // it must be 0 for mpeg/asf ! 1575 pts_from_bps=0; // it must be 0 for mpeg/asf !
1576 } 1576 }
1577 if(force_fps){ 1577 if(force_fps){
1578 sh_video->fps=force_fps; 1578 sh_video->fps=force_fps;
1579 sh_video->frametime=1.0f/sh_video->fps; 1579 sh_video->frametime=1.0f/sh_video->fps;
1580 printf("FPS forced to be %5.3 (ftime: %5.3f)\n",sh_video->fps,sh_video->frametime);
1580 } 1581 }
1581 1582
1582 printf("Start playing...\n");fflush(stdout); 1583 printf("Start playing...\n");fflush(stdout);
1583 1584
1584 InitTimer(); 1585 InitTimer();
1898 v_frame+=frame_time; 1899 v_frame+=frame_time;
1899 //v_pts+=frame_time; 1900 //v_pts+=frame_time;
1900 time_frame+=frame_time; // for nosound 1901 time_frame+=frame_time; // for nosound
1901 1902
1902 if(file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time; 1903 if(file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time;
1904
1905 if(verbose>1) printf("*** ftime=%5.3f ***\n",frame_time);
1903 1906
1904 if(drop_frame){ 1907 if(drop_frame){
1905 1908
1906 if(has_audio){ 1909 if(has_audio){
1907 int delay=get_audio_delay(audio_fd); 1910 int delay=get_audio_delay(audio_fd);
1908 if(verbose>1)printf("delay=%d\n",delay); 1911 if(verbose>1)printf("delay=%d\n",delay);
1909 time_frame=v_frame; 1912 time_frame=v_frame;
1910 time_frame-=a_frame-(float)delay/(float)sh_audio->o_bps; 1913 time_frame-=a_frame-(float)delay/(float)sh_audio->o_bps;
1911 if(time_frame>-0.1) drop_frame=0; // stop dropping frames 1914 if(time_frame>-2*frame_time) drop_frame=0; // stop dropping frames
1912 } 1915 }
1913 1916
1914 } else { 1917 } else {
1915 // It's time to sleep... 1918 // It's time to sleep...
1916 current_module="sleep"; 1919 current_module="sleep";
1921 int delay=get_audio_delay(audio_fd); 1924 int delay=get_audio_delay(audio_fd);
1922 if(verbose>1)printf("delay=%d\n",delay); 1925 if(verbose>1)printf("delay=%d\n",delay);
1923 time_frame=v_frame; 1926 time_frame=v_frame;
1924 time_frame-=a_frame-(float)delay/(float)sh_audio->o_bps; 1927 time_frame-=a_frame-(float)delay/(float)sh_audio->o_bps;
1925 // we are out of time... drop next frame! 1928 // we are out of time... drop next frame!
1926 if(time_frame<-0.1){ 1929 if(time_frame<-2*frame_time){
1927 drop_frame=frame_dropping; // tricky! 1930 drop_frame=frame_dropping; // tricky!
1928 ++drop_frame_cnt; 1931 ++drop_frame_cnt;
1929 } 1932 }
1930 } else { 1933 } else {
1931 if(time_frame<-0.1 || time_frame>0.1) time_frame=0; 1934 if(time_frame<-3*frame_time || time_frame>3*frame_time) time_frame=0;
1932 } 1935 }
1933 1936
1934 if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,a_frame,v_frame); 1937 if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,a_frame,v_frame);
1935 1938
1936 while(time_frame>0.005){ 1939 while(time_frame>0.005){
2194 int rel_seek_frames=rel_seek_secs*sh_video->fps; 2197 int rel_seek_frames=rel_seek_secs*sh_video->fps;
2195 int curr_audio_pos=0; 2198 int curr_audio_pos=0;
2196 int audio_chunk_pos=-1; 2199 int audio_chunk_pos=-1;
2197 int video_chunk_pos=d_video->pos; 2200 int video_chunk_pos=d_video->pos;
2198 2201
2199 skip_video_frames=0; 2202 skip_video_frames=0;
2200
2201 // SEEK streams
2202 // if(d_video->pts) avi_video_pts=d_video->pts;
2203 avi_audio_pts=0; 2203 avi_audio_pts=0;
2204 2204
2205 // Done by ds_free_packs(): 2205 // find nearest video keyframe chunk pos:
2206 //d_video->pts=0;
2207 //d_audio->pts=0;
2208
2209 // find video chunk pos:
2210 if(rel_seek_frames>0){ 2206 if(rel_seek_frames>0){
2211 // seek forward 2207 // seek forward
2212 while(video_chunk_pos<demuxer->idx_size){ 2208 while(video_chunk_pos<demuxer->idx_size){
2213 int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid; 2209 int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid;
2214 // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame
2215 if(avi_stream_id(id)==d_video->id){ // video frame 2210 if(avi_stream_id(id)==d_video->id){ // video frame
2216 if((--rel_seek_frames)<0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; 2211 if((--rel_seek_frames)<0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break;
2217 //v_pts+=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
2218 ++skip_audio_bytes; 2212 ++skip_audio_bytes;
2219 } 2213 }
2220 ++video_chunk_pos; 2214 ++video_chunk_pos;
2221 } 2215 }
2222 } else { 2216 } else {
2223 // seek backward 2217 // seek backward
2224 while(video_chunk_pos>=0){ 2218 while(video_chunk_pos>=0){
2225 int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid; 2219 int id=((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].ckid;
2226 // if(LOWORD(id)==aviTWOCC('0','0')){ // video frame
2227 if(avi_stream_id(id)==d_video->id){ // video frame 2220 if(avi_stream_id(id)==d_video->id){ // video frame
2228 if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break; 2221 if((++rel_seek_frames)>0 && ((AVIINDEXENTRY *)demuxer->idx)[video_chunk_pos].dwFlags&AVIIF_KEYFRAME) break;
2229 //v_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
2230 --skip_audio_bytes; 2222 --skip_audio_bytes;
2231 } 2223 }
2232 --video_chunk_pos; 2224 --video_chunk_pos;
2233 } 2225 }
2234 } 2226 }
2235 demuxer->idx_pos_a=demuxer->idx_pos_v=demuxer->idx_pos=video_chunk_pos; 2227 demuxer->idx_pos_a=demuxer->idx_pos_v=demuxer->idx_pos=video_chunk_pos;
2236 // printf("%d frames skipped\n",skip_audio_bytes); 2228 // printf("%d frames skipped\n",skip_audio_bytes);
2237 2229
2238 #if 1
2239 // re-calc video pts: 2230 // re-calc video pts:
2240 d_video->pack_no=0; 2231 d_video->pack_no=0;
2241 for(i=0;i<video_chunk_pos;i++){ 2232 for(i=0;i<video_chunk_pos;i++){
2242 int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid; 2233 int id=((AVIINDEXENTRY *)demuxer->idx)[i].ckid;
2243 if(avi_stream_id(id)==d_video->id) ++d_video->pack_no; 2234 if(avi_stream_id(id)==d_video->id) ++d_video->pack_no;
2244 } 2235 }
2245 avi_video_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; 2236 avi_video_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
2246
2247 //printf("v-pts recalc! %5.3f -> %5.3f \n",v_pts,avi_video_pts);
2248 //v_pts=avi_video_pts;
2249 //#else
2250 //avi_video_pts=v_pts;
2251 #endif
2252 //a_pts=avi_video_pts;
2253 //a_pts=v_pts; //-(buffer_delay+audio_delay);
2254 2237
2255 if(has_audio){ 2238 if(has_audio){
2256 int i; 2239 int i;
2257 int apos=0; 2240 int apos=0;
2258 int last=0; 2241 int last=0;
2439 max_pts_correction=0.1; 2422 max_pts_correction=0.1;
2440 frame_corr_num=0; // -5 2423 frame_corr_num=0; // -5
2441 frame_correction=0; 2424 frame_correction=0;
2442 force_redraw=5; 2425 force_redraw=5;
2443 a_frame=-skip_audio_secs; 2426 a_frame=-skip_audio_secs;
2444 // a_frame=-audio_delay-buffer_delay-skip_audio_secs;
2445 v_frame=0; // !!!!!! 2427 v_frame=0; // !!!!!!
2446 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; 2428 audio_time_usage=0; video_time_usage=0; vout_time_usage=0;
2447 // num_frames=real_num_frames=0; 2429 // num_frames=real_num_frames=0;
2448 2430
2449 } 2431 }
2490 2472
2491 } 2473 }
2492 2474
2493 } // while(!eof) 2475 } // while(!eof)
2494 2476
2495 //printf("\nEnd of file.\n");
2496 exit_player("End of file"); 2477 exit_player("End of file");
2497 } 2478 }
2498 return 1; 2479 return 1;
2499 } 2480 }