Mercurial > mplayer.hg
comparison mplayer.c @ 1327:b12e1817bcc2
some cleanup - fixed warnings, removed old stuff, moved audio resync to dec_audio
author | arpi |
---|---|
date | Mon, 16 Jul 2001 12:53:48 +0000 |
parents | 2460ebcb6e69 |
children | 8940480b3856 |
comparison
equal
deleted
inserted
replaced
1326:76478d16903d | 1327:b12e1817bcc2 |
---|---|
28 #define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" | 28 #define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" |
29 #else | 29 #else |
30 #define DEFAULT_CDROM_DEVICE "/dev/cdrom" | 30 #define DEFAULT_CDROM_DEVICE "/dev/cdrom" |
31 #endif | 31 #endif |
32 | 32 |
33 #ifndef MAX_OUTBURST | |
34 #error "=============================================" | |
35 #error "Please re-run ./configure and then try again!" | |
36 #error "=============================================" | |
37 #endif | |
38 | |
39 #include "cfgparser.h" | 33 #include "cfgparser.h" |
40 #include "cfg-mplayer-def.h" | 34 #include "cfg-mplayer-def.h" |
41 | 35 |
42 #include "subreader.h" | 36 #include "subreader.h" |
43 | 37 |
44 #include "libvo/video_out.h" | 38 #include "libvo/video_out.h" |
45 #include "libvo/sub.h" | 39 #include "libvo/sub.h" |
46 | 40 |
47 #include "libao2/audio_out.h" | 41 #include "libao2/audio_out.h" |
48 | 42 |
49 // CODECS: | |
50 #include "mp3lib/mp3.h" | |
51 #include "libac3/ac3.h" | |
52 #include "libmpeg2/mpeg2.h" | 43 #include "libmpeg2/mpeg2.h" |
53 #include "libmpeg2/mpeg2_internal.h" | 44 #include "libmpeg2/mpeg2_internal.h" |
54 | 45 |
55 #include "loader.h" | 46 #include "loader.h" |
56 #include "wine/avifmt.h" | 47 #include "wine/avifmt.h" |
58 #include "codec-cfg.h" | 49 #include "codec-cfg.h" |
59 | 50 |
60 #include "dvdauth.h" | 51 #include "dvdauth.h" |
61 #include "spudec.h" | 52 #include "spudec.h" |
62 | 53 |
63 #ifdef USE_DIRECTSHOW | |
64 //#include "DirectShow/DS_VideoDec.h" | |
65 //#include "DirectShow/DS_AudioDec.h" | |
66 #endif | |
67 | |
68 //#include "opendivx/decore.h" | |
69 | |
70 extern char* win32_codec_name; // must be set before calling DrvOpen() !!! | 54 extern char* win32_codec_name; // must be set before calling DrvOpen() !!! |
71 | |
72 // extern int errno; | |
73 | 55 |
74 #include "linux/getch2.h" | 56 #include "linux/getch2.h" |
75 #include "linux/keycodes.h" | 57 #include "linux/keycodes.h" |
76 #include "linux/timer.h" | 58 #include "linux/timer.h" |
77 #include "linux/shmem.h" | 59 #include "linux/shmem.h" |
151 //**************************************************************************// | 133 //**************************************************************************// |
152 // Input media streaming & demultiplexer: | 134 // Input media streaming & demultiplexer: |
153 //**************************************************************************// | 135 //**************************************************************************// |
154 | 136 |
155 static int max_framesize=0; | 137 static int max_framesize=0; |
156 //static int show_packets=0; | |
157 | 138 |
158 #include "stream.h" | 139 #include "stream.h" |
159 #include "demuxer.h" | 140 #include "demuxer.h" |
160 | 141 |
161 #include "stheader.h" | 142 #include "stheader.h" |
162 | 143 |
163 static int avi_bitrate=0; | 144 static int avi_bitrate=0; |
164 | |
165 //#include "aviprint.c" | |
166 | 145 |
167 sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){ | 146 sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){ |
168 if(demuxer->a_streams[id]){ | 147 if(demuxer->a_streams[id]){ |
169 printf("Warning! Audio stream header %d redefined!\n",id); | 148 printf("Warning! Audio stream header %d redefined!\n",id); |
170 } else { | 149 } else { |
259 int audio_family=-1; // override audio codec family | 238 int audio_family=-1; // override audio codec family |
260 int video_family=-1; // override video codec family | 239 int video_family=-1; // override video codec family |
261 | 240 |
262 // IMHO this stuff is no longer of use, or is there a special | 241 // IMHO this stuff is no longer of use, or is there a special |
263 // reason why dshow should be completely disabled? - atmos :: | 242 // reason why dshow should be completely disabled? - atmos :: |
243 // yes, people without working c++ compiler can disable it - A'rpi | |
264 #ifdef USE_DIRECTSHOW | 244 #ifdef USE_DIRECTSHOW |
265 int allow_dshow=1; | 245 int allow_dshow=1; |
266 #else | 246 #else |
267 int allow_dshow=0; | 247 int allow_dshow=0; |
268 #endif | 248 #endif |
393 #endif | 373 #endif |
394 exit_player(NULL); | 374 exit_player(NULL); |
395 } | 375 } |
396 | 376 |
397 extern int vcd_get_track_end(int fd,int track); | 377 extern int vcd_get_track_end(int fd,int track); |
378 extern int init_video_codec(sh_video_t *sh_video); | |
379 //extern void mpeg2_allocate_image_buffers(picture_t * picture); | |
380 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); | |
381 | |
382 // dec_audio.c: | |
398 extern int init_audio(sh_audio_t *sh_audio); | 383 extern int init_audio(sh_audio_t *sh_audio); |
399 extern int init_video_codec(sh_video_t *sh_video); | |
400 extern void mpeg2_allocate_image_buffers(picture_t * picture); | |
401 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); | |
402 extern int vo_init(void); | |
403 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); | 384 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); |
404 | 385 extern void resync_audio_stream(sh_audio_t *sh_audio); |
386 extern void skip_audio_frame(sh_audio_t *sh_audio); | |
387 | |
388 // dec_video.c: | |
389 extern int init_video(sh_video_t *sh_video); | |
390 extern int decode_video(vo_functions_t *video_out,sh_video_t *sh_video,unsigned char *start,int in_size,int drop_frame); | |
405 | 391 |
406 #include "mixer.h" | 392 #include "mixer.h" |
407 #include "cfg-mplayer.h" | 393 #include "cfg-mplayer.h" |
408 | 394 |
409 void parse_cfgfiles( void ) | 395 void parse_cfgfiles( void ) |
1515 | 1501 |
1516 //-------------------- Decode a frame: ----------------------- | 1502 //-------------------- Decode a frame: ----------------------- |
1517 | 1503 |
1518 if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){ | 1504 if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){ |
1519 int in_frame=0; | 1505 int in_frame=0; |
1520 int t=0; | |
1521 float newfps; | 1506 float newfps; |
1522 videobuf_len=0; | 1507 videobuf_len=0; |
1523 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ | 1508 while(videobuf_len<VIDEOBUFFER_SIZE-MAX_VIDEO_PACKET_SIZE){ |
1524 int i=sync_video_packet(d_video); | 1509 int i=sync_video_packet(d_video); |
1525 void* buffer=&videobuffer[videobuf_len+4]; | 1510 void* buffer=&videobuffer[videobuf_len+4]; |
2104 demux_read_data(d_audio,NULL,skip_audio_bytes); | 2089 demux_read_data(d_audio,NULL,skip_audio_bytes); |
2105 //d_audio->pts=0; // PTS is outdated because of the raw data skipping | 2090 //d_audio->pts=0; // PTS is outdated because of the raw data skipping |
2106 } | 2091 } |
2107 | 2092 |
2108 current_module="resync_audio"; | 2093 current_module="resync_audio"; |
2109 | 2094 resync_audio_stream(sh_audio); |
2110 switch(sh_audio->codec->driver){ | |
2111 case 1: | |
2112 MP3_DecodeFrame(NULL,-2); // resync | |
2113 MP3_DecodeFrame(NULL,-2); // resync | |
2114 MP3_DecodeFrame(NULL,-2); // resync | |
2115 break; | |
2116 case 3: | |
2117 ac3_bitstream_reset(); // reset AC3 bitstream buffer | |
2118 // if(verbose){ printf("Resyncing AC3 audio...");fflush(stdout);} | |
2119 sh_audio->ac3_frame=ac3_decode_frame(); // resync | |
2120 // if(verbose) printf(" OK!\n"); | |
2121 break; | |
2122 case 4: | |
2123 case 7: | |
2124 sh_audio->a_in_buffer_len=0; // reset ACM/DShow audio buffer | |
2125 break; | |
2126 } | |
2127 | 2095 |
2128 // re-sync PTS (MPEG-PS only!!!) | 2096 // re-sync PTS (MPEG-PS only!!!) |
2129 if(file_format==DEMUXER_TYPE_MPEG_PS) | 2097 if(file_format==DEMUXER_TYPE_MPEG_PS) |
2130 if(d_video->pts && d_audio->pts){ | 2098 if(d_video->pts && d_audio->pts){ |
2131 if (d_video->pts < d_audio->pts){ | 2099 if (d_video->pts < d_audio->pts){ |
2132 | 2100 |
2133 } else { | 2101 } else { |
2134 while(d_video->pts > d_audio->pts){ | 2102 while(d_video->pts > d_audio->pts){ |
2135 switch(sh_audio->codec->driver){ | 2103 skip_audio_frame(sh_audio); |
2136 case 1: MP3_DecodeFrame(NULL,-2);break; // skip MPEG frame | |
2137 case 3: sh_audio->ac3_frame=ac3_decode_frame();break; // skip AC3 frame | |
2138 default: ds_fill_buffer(d_audio); // skip PCM frame | |
2139 } | |
2140 } | 2104 } |
2141 } | 2105 } |
2142 } | 2106 } |
2143 | 2107 |
2144 current_module=NULL; | 2108 current_module=NULL; |