comparison mplayer.c @ 452:416612e8cf5d

add mixer support
author pontscho
date Sun, 15 Apr 2001 22:34:09 +0000
parents 198b46b739d8
children 49b0474b2e26
comparison
equal deleted inserted replaced
451:e27a365b0303 452:416612e8cf5d
86 int verbose=0; 86 int verbose=0;
87 87
88 #define ABS(x) (((x)>=0)?(x):(-(x))) 88 #define ABS(x) (((x)>=0)?(x):(-(x)))
89 89
90 //**************************************************************************// 90 //**************************************************************************//
91 // .SUB 91 // .SUB
92 //**************************************************************************// 92 //**************************************************************************//
93 93
94 static current_sub=0; 94 static current_sub=0;
95 95
96 static subtitle* subtitles=NULL; 96 static subtitle* subtitles=NULL;
125 ++verbose; 125 ++verbose;
126 return 0; 126 return 0;
127 } 127 }
128 128
129 static int cfg_include(struct config *conf, char *filename){ 129 static int cfg_include(struct config *conf, char *filename){
130 return parse_config_file(conf, filename); 130 return parse_config_file(conf, filename);
131 } 131 }
132 132
133 char *get_path(char *filename){ 133 char *get_path(char *filename){
134 char *homedir; 134 char *homedir;
135 char *buff; 135 char *buff;
136 static char *config_dir = "/.mplayer"; 136 static char *config_dir = "/.mplayer";
137 int len; 137 int len;
138 138
139 if ((homedir = getenv("HOME")) == NULL) 139 if ((homedir = getenv("HOME")) == NULL)
140 return NULL; 140 return NULL;
141 len = strlen(homedir) + strlen(config_dir) + 1; 141 len = strlen(homedir) + strlen(config_dir) + 1;
142 if (filename == NULL) { 142 if (filename == NULL) {
143 if ((buff = (char *) malloc(len)) == NULL) 143 if ((buff = (char *) malloc(len)) == NULL)
144 return NULL; 144 return NULL;
145 sprintf(buff, "%s%s", homedir, config_dir); 145 sprintf(buff, "%s%s", homedir, config_dir);
146 } else { 146 } else {
147 len += strlen(filename) + 1; 147 len += strlen(filename) + 1;
148 if ((buff = (char *) malloc(len)) == NULL) 148 if ((buff = (char *) malloc(len)) == NULL)
149 return NULL; 149 return NULL;
150 sprintf(buff, "%s%s/%s", homedir, config_dir, filename); 150 sprintf(buff, "%s%s/%s", homedir, config_dir, filename);
151 } 151 }
152 return buff; 152 return buff;
153 } 153 }
154 154
155 static int max_framesize=0; 155 static int max_framesize=0;
156 156
157 //static int dbg_es_sent=0; 157 //static int dbg_es_sent=0;
272 unsigned char *opendivx_src[3]; 272 unsigned char *opendivx_src[3];
273 int opendivx_stride[3]; 273 int opendivx_stride[3];
274 274
275 // callback, the opendivx decoder calls this for each frame: 275 // callback, the opendivx decoder calls this for each frame:
276 void convert_linux(unsigned char *puc_y, int stride_y, 276 void convert_linux(unsigned char *puc_y, int stride_y,
277 unsigned char *puc_u, unsigned char *puc_v, int stride_uv, 277 unsigned char *puc_u, unsigned char *puc_v, int stride_uv,
278 unsigned char *bmp, int width_y, int height_y){ 278 unsigned char *bmp, int width_y, int height_y){
279 279
280 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv); 280 // printf("convert_yuv called %dx%d stride: %d,%d\n",width_y,height_y,stride_y,stride_uv);
281 281
282 opendivx_src[0]=puc_y; 282 opendivx_src[0]=puc_y;
283 opendivx_src[1]=puc_u; 283 opendivx_src[1]=puc_u;
284 opendivx_src[2]=puc_v; 284 opendivx_src[2]=puc_v;
285 285
286 opendivx_stride[0]=stride_y; 286 opendivx_stride[0]=stride_y;
287 opendivx_stride[1]=stride_uv; 287 opendivx_stride[1]=stride_uv;
288 opendivx_stride[2]=stride_uv; 288 opendivx_stride[2]=stride_uv;
289 } 289 }
290 290
428 float font_factor=0.75; 428 float font_factor=0.75;
429 char *sub_name=NULL; 429 char *sub_name=NULL;
430 float sub_delay=0; 430 float sub_delay=0;
431 float sub_fps=0; 431 float sub_fps=0;
432 //int user_bpp=0; 432 //int user_bpp=0;
433 433 extern int vo_dbpp;
434 // --- NEW
435 #include "mixer.h"
436 // ---
434 #include "cfg-mplayer.h" 437 #include "cfg-mplayer.h"
435 438
436 printf("%s",banner_text); 439 printf("%s",banner_text);
437 440
438 if (parse_config_file(conf, "/etc/mplayer.conf") < 0) 441 if (parse_config_file(conf, "/etc/mplayer.conf") < 0)
468 if(video_driver && strcmp(video_driver,"help")==0){ 471 if(video_driver && strcmp(video_driver,"help")==0){
469 printf("Available video output drivers:\n"); 472 printf("Available video output drivers:\n");
470 i=0; 473 i=0;
471 while (video_out_drivers[i]) { 474 while (video_out_drivers[i]) {
472 const vo_info_t *info = video_out_drivers[i++]->get_info (); 475 const vo_info_t *info = video_out_drivers[i++]->get_info ();
473 printf("\t%s\t%s\n", info->short_name, info->name); 476 printf("\t%s\t%s\n", info->short_name, info->name);
474 } 477 }
475 printf("\n"); 478 printf("\n");
476 exit(0); 479 exit(0);
477 } 480 }
478 481
555 { //---- RIFF header: 558 { //---- RIFF header:
556 int id=stream_read_dword_le(demuxer->stream); // "RIFF" 559 int id=stream_read_dword_le(demuxer->stream); // "RIFF"
557 if(id==mmioFOURCC('R','I','F','F')){ 560 if(id==mmioFOURCC('R','I','F','F')){
558 stream_read_dword_le(demuxer->stream); //filesize 561 stream_read_dword_le(demuxer->stream); //filesize
559 id=stream_read_dword_le(demuxer->stream); // "AVI " 562 id=stream_read_dword_le(demuxer->stream); // "AVI "
560 if(id==formtypeAVI){ 563 if(id==formtypeAVI){
561 printf("Detected AVI file format!\n"); 564 printf("Detected AVI file format!\n");
562 file_format=DEMUXER_TYPE_AVI; 565 file_format=DEMUXER_TYPE_AVI;
563 } 566 }
564 } 567 }
565 } 568 }
639 else 642 else
640 avi_header.idx_offset=0; 643 avi_header.idx_offset=0;
641 if(verbose) printf("AVI index offset: %d\n",avi_header.idx_offset); 644 if(verbose) printf("AVI index offset: %d\n",avi_header.idx_offset);
642 } 645 }
643 demuxer->endpos=avi_header.movi_end; 646 demuxer->endpos=avi_header.movi_end;
644 647
645 if(avi_header.idx_size>0){ 648 if(avi_header.idx_size>0){
646 // check that file is non-interleaved: 649 // check that file is non-interleaved:
647 int i; 650 int i;
648 int a_pos=-1; 651 int a_pos=-1;
649 int v_pos=-1; 652 int v_pos=-1;
669 has_audio=0; 672 has_audio=0;
670 } else { 673 } else {
671 if(force_ni || abs(a_pos-v_pos)>0x100000){ // distance > 1MB 674 if(force_ni || abs(a_pos-v_pos)>0x100000){ // distance > 1MB
672 printf("Detected NON-INTERLEAVED AVI file-format!\n"); 675 printf("Detected NON-INTERLEAVED AVI file-format!\n");
673 demuxer->type=DEMUXER_TYPE_AVI_NI; // HACK!!!! 676 demuxer->type=DEMUXER_TYPE_AVI_NI; // HACK!!!!
674 pts_from_bps=1; // force BPS sync! 677 pts_from_bps=1; // force BPS sync!
675 } 678 }
676 } 679 }
677 } else { 680 } else {
678 // no index 681 // no index
679 if(force_ni){ 682 if(force_ni){
680 printf("Using NON-INTERLEAVED Broken AVI file-format!\n"); 683 printf("Using NON-INTERLEAVED Broken AVI file-format!\n");
681 demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!! 684 demuxer->type=DEMUXER_TYPE_AVI_NINI; // HACK!!!!
682 avi_header.idx_pos_a= 685 avi_header.idx_pos_a=
683 avi_header.idx_pos_v=avi_header.movi_start; 686 avi_header.idx_pos_v=avi_header.movi_start;
684 pts_from_bps=1; // force BPS sync! 687 pts_from_bps=1; // force BPS sync!
685 } 688 }
686 } 689 }
687 if(!ds_fill_buffer(d_video)){ 690 if(!ds_fill_buffer(d_video)){
688 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n"); 691 printf("AVI: missing video stream!? contact the author, it may be a bug :(\n");
689 exit(1); 692 exit(1);
905 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n"); 908 printf("Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
906 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n"); 909 printf("package from: ftp://thot.banki.hu/esp-team/linux/MPlayer/w32codec.zip !\n");
907 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n"); 910 printf("Or you should disable DShow support: make distclean;make -f Makefile.No-DS\n");
908 exit(1); 911 exit(1);
909 } 912 }
910 913
911 if(out_fmt==IMGFMT_YUY2) 914 if(out_fmt==IMGFMT_YUY2)
912 DS_VideoDecoder_SetDestFmt(16,mmioFOURCC('Y', 'U', 'Y', '2')); 915 DS_VideoDecoder_SetDestFmt(16,mmioFOURCC('Y', 'U', 'Y', '2'));
913 // DS_VideoDecoder_SetDestFmt(16,mmioFOURCC('Y', 'V', '1', '2')); 916 // DS_VideoDecoder_SetDestFmt(16,mmioFOURCC('Y', 'V', '1', '2'));
914 else 917 else
915 DS_VideoDecoder_SetDestFmt(out_fmt&255,0); 918 DS_VideoDecoder_SetDestFmt(out_fmt&255,0);
916 919
917 DS_VideoDecoder_Start(); 920 DS_VideoDecoder_Start();
918 921
919 printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) ); 922 printf("DivX setting result = %d\n", DS_SetAttr_DivX("Quality",divx_quality) );
920 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) ); 923 // printf("DivX setting result = %d\n", DS_SetValue_DivX("Brightness",60) );
921 924
922 if(verbose) printf("INFO: Win32/DShow video codec init OK!\n"); 925 if(verbose) printf("INFO: Win32/DShow video codec init OK!\n");
923 break; 926 break;
924 #endif 927 #endif
925 } 928 }
926 case 3: { // OpenDivX 929 case 3: { // OpenDivX
1041 printf("FATAL: Cannot initialize video driver!\n");exit(1); 1044 printf("FATAL: Cannot initialize video driver!\n");exit(1);
1042 } 1045 }
1043 if(verbose) printf("INFO: Video OUT driver init OK!\n"); 1046 if(verbose) printf("INFO: Video OUT driver init OK!\n");
1044 1047
1045 fflush(stdout); 1048 fflush(stdout);
1046 1049
1047 //================== MAIN: ========================== 1050 //================== MAIN: ==========================
1048 { 1051 {
1049 int audio_fd=-1; 1052 int audio_fd=-1;
1050 float buffer_delay=0; 1053 float buffer_delay=0;
1051 float frame_correction=0; // A-V timestamp kulonbseg atlagolas 1054 float frame_correction=0; // A-V timestamp kulonbseg atlagolas
1290 1293
1291 /*========================== PLAY VIDEO ============================*/ 1294 /*========================== PLAY VIDEO ============================*/
1292 1295
1293 if(1) 1296 if(1)
1294 while(v_frame<a_frame || force_redraw){ 1297 while(v_frame<a_frame || force_redraw){
1295 1298
1296 float frame_time=1; 1299 float frame_time=1;
1297 float pts1=d_video->pts; 1300 float pts1=d_video->pts;
1298 1301
1299 current_module="decode_video"; 1302 current_module="decode_video";
1300 1303
1309 int in_size=ds_get_packet(d_video,&start); 1312 int in_size=ds_get_packet(d_video,&start);
1310 if(in_size<0){ eof=1;break;} 1313 if(in_size<0){ eof=1;break;}
1311 if(in_size>max_framesize) max_framesize=in_size; 1314 if(in_size>max_framesize) max_framesize=in_size;
1312 // let's decode 1315 // let's decode
1313 dec_frame.length = in_size; 1316 dec_frame.length = in_size;
1314 dec_frame.bitstream = start; 1317 dec_frame.bitstream = start;
1315 dec_frame.render_flag = 1; 1318 dec_frame.render_flag = 1;
1316 decore(0x123, 0, &dec_frame, NULL); 1319 decore(0x123, 0, &dec_frame, NULL);
1317 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f; 1320 t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
1318 1321
1319 if(opendivx_src[0]){ 1322 if(opendivx_src[0]){
1320 video_out->draw_slice(opendivx_src,opendivx_stride, 1323 video_out->draw_slice(opendivx_src,opendivx_stride,
1321 sh_video->disp_w,sh_video->disp_h,0,0); 1324 sh_video->disp_w,sh_video->disp_h,0,0);
1347 unsigned int t=GetTimer(); 1350 unsigned int t=GetTimer();
1348 unsigned int t2; 1351 unsigned int t2;
1349 int in_size=ds_get_packet(d_video,&start); 1352 int in_size=ds_get_packet(d_video,&start);
1350 if(in_size<0){ eof=1;break;} 1353 if(in_size<0){ eof=1;break;}
1351 if(in_size>max_framesize) max_framesize=in_size; 1354 if(in_size>max_framesize) max_framesize=in_size;
1352
1353 if(in_size){ 1355 if(in_size){
1354 sh_video->bih->biSizeImage = in_size; 1356 sh_video->bih->biSizeImage = in_size;
1355 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL), 1357 // ret = ICDecompress(avi_header.hic, ICDECOMPRESS_NOTKEYFRAME|(ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL),
1356 ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME, 1358 ret = ICDecompress(sh_video->hic, ICDECOMPRESS_NOTKEYFRAME,
1357 sh_video->bih, start, 1359 sh_video->bih, start,
1387 } else { 1389 } else {
1388 //if(i==0x100) in_frame=1; // picture startcode 1390 //if(i==0x100) in_frame=1; // picture startcode
1389 if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode 1391 if(i>=0x101 && i<0x1B0) in_frame=1; // picture startcode
1390 else if(!i){ eof=1; break;} // EOF 1392 else if(!i){ eof=1; break;} // EOF
1391 } 1393 }
1392 if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1; 1394 if(grab_frames==2 && (i==0x1B3 || i==0x1B8)) grab_frames=1;
1393 if(!read_video_packet(d_video)){ eof=1; break;} // EOF 1395 if(!read_video_packet(d_video)){ eof=1; break;} // EOF
1394 //printf("read packet 0x%X, len=%d\n",i,videobuf_len); 1396 //printf("read packet 0x%X, len=%d\n",i,videobuf_len);
1395 } 1397 }
1396 1398
1397 if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug 1399 if(videobuf_len>max_framesize) max_framesize=videobuf_len; // debug
1398 //printf("--- SEND %d bytes\n",videobuf_len); 1400 //printf("--- SEND %d bytes\n",videobuf_len);
1399 if(grab_frames==1){ 1401 if(grab_frames==1){
1400 FILE *f=fopen("grab.mpg","ab"); 1402 FILE *f=fopen("grab.mpg","ab");
1401 fwrite(videobuffer,videobuf_len-4,1,f); 1403 fwrite(videobuffer,videobuf_len-4,1,f);
1402 fclose(f); 1404 fclose(f);
1403 } 1405 }
1404 1406
1405 t-=GetTimer(); 1407 t-=GetTimer();
1406 mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len); 1408 mpeg2_decode_data(video_out, videobuffer, videobuffer+videobuf_len);
1407 t+=GetTimer(); video_time_usage+=t*0.000001; 1409 t+=GetTimer(); video_time_usage+=t*0.000001;
1408 1410
1409 newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f; 1411 newfps=frameratecode2framerate[picture->frame_rate_code]*0.0001f;
1410 if(ABS(sh_video->fps-newfps)>0.01f) if(!force_fps){ 1412 if(ABS(sh_video->fps-newfps)>0.01f) if(!force_fps){
1411 printf("Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video->fps,newfps,sh_video->fps-newfps,picture->frame_rate_code); 1413 printf("Warning! FPS changed %5.3f -> %5.3f (%f) [%d] \n",sh_video->fps,newfps,sh_video->fps-newfps,picture->frame_rate_code);
1412 sh_video->fps=newfps; 1414 sh_video->fps=newfps;
1413 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code]; 1415 sh_video->frametime=10000.0f/(float)frameratecode2framerate[picture->frame_rate_code];
1414 } 1416 }
1415 1417
1416 frame_time=(100+picture->repeat_count)*0.01f; 1418 frame_time=(100+picture->repeat_count)*0.01f;
1417 picture->repeat_count=0; 1419 picture->repeat_count=0;
1418 1420
1419 break; 1421 break;
1420 } 1422 }
1523 while( 1525 while(
1524 #ifdef HAVE_LIRC 1526 #ifdef HAVE_LIRC
1525 lirc_mp_getinput()<=0 && 1527 lirc_mp_getinput()<=0 &&
1526 #endif 1528 #endif
1527 getch2(20)<=0 && mplayer_get_key()<=0){ 1529 getch2(20)<=0 && mplayer_get_key()<=0){
1528 video_out->check_events(); 1530 video_out->check_events();
1529 } 1531 }
1530 osd_function=OSD_PLAY; 1532 osd_function=OSD_PLAY;
1531 } 1533 }
1532 1534
1533 } // while(v_frame<a_frame || force_redraw) 1535 } // while(v_frame<a_frame || force_redraw)
1576 osd_function=OSD_PAUSE; 1578 osd_function=OSD_PAUSE;
1577 break; 1579 break;
1578 case 'o': // toggle OSD 1580 case 'o': // toggle OSD
1579 osd_level=(osd_level+1)%3; 1581 osd_level=(osd_level+1)%3;
1580 break; 1582 break;
1583 // --- NEW
1584 case '*':
1585 mixer_incvolume();
1586 break;
1587 case '/':
1588 mixer_decvolume();
1589 break;
1590 case 'm':
1591 mixer_usemaster=1;
1592 break;;
1593 case 'c':
1594 mixer_usemaster=0;
1595 break;
1596 // ---
1581 } 1597 }
1582 if(rel_seek_secs) 1598 if(rel_seek_secs)
1583 if(file_format==DEMUXER_TYPE_AVI && avi_header.idx_size<=0){ 1599 if(file_format==DEMUXER_TYPE_AVI && avi_header.idx_size<=0){
1584 printf("Can't seek in raw .AVI streams! (index required) \n"); 1600 printf("Can't seek in raw .AVI streams! (index required) \n");
1585 } else { 1601 } else {
1587 float skip_audio_secs=0; 1603 float skip_audio_secs=0;
1588 1604
1589 // clear demux buffers: 1605 // clear demux buffers:
1590 if(has_audio) ds_free_packs(d_audio); 1606 if(has_audio) ds_free_packs(d_audio);
1591 ds_free_packs(d_video); 1607 ds_free_packs(d_video);
1592 1608
1593 // printf("sh_audio->a_buffer_len=%d \n",sh_audio->a_buffer_len); 1609 // printf("sh_audio->a_buffer_len=%d \n",sh_audio->a_buffer_len);
1594 sh_audio->a_buffer_len=0; 1610 sh_audio->a_buffer_len=0;
1595 1611
1596 switch(file_format){ 1612 switch(file_format){
1597 1613
1599 //================= seek in AVI ========================== 1615 //================= seek in AVI ==========================
1600 int rel_seek_frames=rel_seek_secs*sh_video->fps; 1616 int rel_seek_frames=rel_seek_secs*sh_video->fps;
1601 int curr_audio_pos=0; 1617 int curr_audio_pos=0;
1602 int audio_chunk_pos=-1; 1618 int audio_chunk_pos=-1;
1603 int video_chunk_pos=d_video->pos; 1619 int video_chunk_pos=d_video->pos;
1604 1620
1605 skip_video_frames=0; 1621 skip_video_frames=0;
1606 1622
1607 // SEEK streams 1623 // SEEK streams
1608 // if(d_video->pts) avi_video_pts=d_video->pts; 1624 // if(d_video->pts) avi_video_pts=d_video->pts;
1609 avi_audio_pts=0; 1625 avi_audio_pts=0;
1719 #endif 1735 #endif
1720 } 1736 }
1721 // now: audio_chunk_pos=pos in index 1737 // now: audio_chunk_pos=pos in index
1722 // skip_audio_bytes=bytes to skip from that chunk 1738 // skip_audio_bytes=bytes to skip from that chunk
1723 // skip_audio_secs=time to play audio before video (if can't skip) 1739 // skip_audio_secs=time to play audio before video (if can't skip)
1724 1740
1725 // calc skip_video_frames & adjust video pts counter: 1741 // calc skip_video_frames & adjust video pts counter:
1726 // i=last; 1742 // i=last;
1727 i=avi_header.idx_pos; 1743 i=avi_header.idx_pos;
1728 while(i<video_chunk_pos){ 1744 while(i<video_chunk_pos){
1729 int id=avi_header.idx[i].ckid; 1745 int id=avi_header.idx[i].ckid;
1733 // requires for correct audio pts calculation (demuxer): 1749 // requires for correct audio pts calculation (demuxer):
1734 avi_video_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; 1750 avi_video_pts-=(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
1735 } 1751 }
1736 ++i; 1752 ++i;
1737 } 1753 }
1738 1754
1739 } 1755 }
1740 1756
1741 if(verbose) printf("SEEK: idx=%d (a:%d v:%d) v.skip=%d a.skip=%d/%4.3f \n", 1757 if(verbose) printf("SEEK: idx=%d (a:%d v:%d) v.skip=%d a.skip=%d/%4.3f \n",
1742 avi_header.idx_pos,audio_chunk_pos,video_chunk_pos, 1758 avi_header.idx_pos,audio_chunk_pos,video_chunk_pos,
1743 skip_video_frames,skip_audio_bytes,skip_audio_secs); 1759 skip_video_frames,skip_audio_bytes,skip_audio_secs);
1766 newpos=demuxer->filepos+rel_seek_bytes; 1782 newpos=demuxer->filepos+rel_seek_bytes;
1767 if(newpos<0) newpos=0; 1783 if(newpos<0) newpos=0;
1768 stream_seek(demuxer->stream,newpos); 1784 stream_seek(demuxer->stream,newpos);
1769 } 1785 }
1770 break; 1786 break;
1771 1787
1772 case DEMUXER_TYPE_MPEG_ES: 1788 case DEMUXER_TYPE_MPEG_ES:
1773 case DEMUXER_TYPE_MPEG_PS: { 1789 case DEMUXER_TYPE_MPEG_PS: {
1774 //================= seek in MPEG ========================== 1790 //================= seek in MPEG ==========================
1775 int newpos; 1791 int newpos;
1776 if(picture->bitrate==0x3FFFF) // unspecified? 1792 if(picture->bitrate==0x3FFFF) // unspecified?
1800 1816
1801 if(skip_audio_bytes){ 1817 if(skip_audio_bytes){
1802 demux_read_data(d_audio,NULL,skip_audio_bytes); 1818 demux_read_data(d_audio,NULL,skip_audio_bytes);
1803 d_audio->pts=0; // PTS is outdated because of the raw data skipping 1819 d_audio->pts=0; // PTS is outdated because of the raw data skipping
1804 } 1820 }
1805 1821
1806 current_module="resync_audio"; 1822 current_module="resync_audio";
1807 1823
1808 switch(sh_audio->codec->driver){ 1824 switch(sh_audio->codec->driver){
1809 case 1: 1825 case 1:
1810 MP3_DecodeFrame(NULL,-2); // resync 1826 MP3_DecodeFrame(NULL,-2); // resync
1825 1841
1826 // re-sync PTS (MPEG-PS only!!!) 1842 // re-sync PTS (MPEG-PS only!!!)
1827 if(file_format==DEMUXER_TYPE_MPEG_PS) 1843 if(file_format==DEMUXER_TYPE_MPEG_PS)
1828 if(d_video->pts && d_audio->pts){ 1844 if(d_video->pts && d_audio->pts){
1829 if (d_video->pts < d_audio->pts){ 1845 if (d_video->pts < d_audio->pts){
1830 1846
1831 } else { 1847 } else {
1832 while(d_video->pts > d_audio->pts){ 1848 while(d_video->pts > d_audio->pts){
1833 switch(sh_audio->codec->driver){ 1849 switch(sh_audio->codec->driver){
1834 case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame 1850 case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame
1835 case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame 1851 case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame
1867 } else { 1883 } else {
1868 vo_osd_text=NULL; 1884 vo_osd_text=NULL;
1869 } 1885 }
1870 // for(i=1;i<=11;i++) osd_text_buffer[10+i]=i;osd_text_buffer[10+i]=0; 1886 // for(i=1;i<=11;i++) osd_text_buffer[10+i]=i;osd_text_buffer[10+i]=0;
1871 // vo_osd_text=osd_text_buffer; 1887 // vo_osd_text=osd_text_buffer;
1872 1888
1873 // find sub 1889 // find sub
1874 if(subtitles){ 1890 if(subtitles){
1875 if(sub_fps==0) sub_fps=sh_video->fps; 1891 if(sub_fps==0) sub_fps=sh_video->fps;
1876 find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter... 1892 find_sub(sub_uses_time?(100*(v_pts+sub_delay)):((v_pts+sub_delay)*sub_fps)); // FIXME! frame counter...
1877 } 1893 }