annotate demuxer.c @ 2100:6f6eb4f8e7a0

finished mov header and index processing
author arpi
date Fri, 05 Oct 2001 23:13:26 +0000
parents 18f4dd5d568f
children 0ad08f8e49b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 //=================== DEMUXER v2.5 =========================
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
1430
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1428
diff changeset
3 #include <stdio.h>
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1428
diff changeset
4 #include <stdlib.h>
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1428
diff changeset
5 #include <unistd.h>
1728d249c783 missing unistd.h (requires for off_t under freebsd)
arpi
parents: 1428
diff changeset
6
1428
a90d889eb649 largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents: 1421
diff changeset
7 #include <sys/types.h>
a90d889eb649 largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents: 1421
diff changeset
8 #include <sys/stat.h>
a90d889eb649 largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents: 1421
diff changeset
9
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
10 #include "config.h"
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
11 #include "mp_msg.h"
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
12 #include "help_mp.h"
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
13
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
14 #include "stream.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
15 #include "demuxer.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
17 #include "wine/mmreg.h"
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
18 #include "wine/avifmt.h"
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
19 #include "wine/vfw.h"
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
20
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
21 #include "codec-cfg.h"
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
22 #include "stheader.h"
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
23
1643
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
24 void free_demuxer_stream(demux_stream_t *ds){
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
25 ds_free_packs(ds);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
26 free(ds);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
27 }
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
28
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 demux_stream_t* ds=malloc(sizeof(demux_stream_t));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 ds->buffer_pos=ds->buffer_size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 ds->buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 ds->pts=0;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
34 ds->pts_bytes=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 ds->eof=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 ds->pos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 ds->dpos=0;
889
1b905517c684 AVI -bps desync problem solved
arpi_esp
parents: 828
diff changeset
38 ds->pack_no=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 //---------------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 ds->packs=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 ds->bytes=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 ds->first=ds->last=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 ds->id=id;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 ds->demuxer=demuxer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 //----------------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 ds->asf_seq=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 ds->asf_packet=NULL;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 1
diff changeset
48 //----------------
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 1
diff changeset
49 ds->sh=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 return ds;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 291
diff changeset
53 demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 demuxer_t *d=malloc(sizeof(demuxer_t));
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
55 memset(d,0,sizeof(demuxer_t));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 d->stream=stream;
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
57 d->movi_start=stream->start_pos;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
58 d->movi_end=stream->end_pos;
1623
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
59 d->seekable=1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 d->synced=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 d->filepos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 d->audio=new_demuxer_stream(d,a_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 d->video=new_demuxer_stream(d,v_id);
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 291
diff changeset
64 d->sub=new_demuxer_stream(d,s_id);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 d->type=type;
1497
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
66 stream_reset(stream);
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
67 stream_seek(stream,stream->start_pos);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 return d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
71 sh_audio_t* new_sh_audio(demuxer_t *demuxer,int id){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
72 if(demuxer->a_streams[id]){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
73 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_AudioStreamRedefined,id);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
74 } else {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
75 mp_msg(MSGT_DEMUXER,MSGL_V,"==> Found audio stream: %d\n",id);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
76 demuxer->a_streams[id]=malloc(sizeof(sh_audio_t));
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
77 memset(demuxer->a_streams[id],0,sizeof(sh_audio_t));
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
78 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
79 return demuxer->a_streams[id];
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
80 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
81
1643
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
82 void free_sh_audio(sh_audio_t* sh){
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
83 if(sh->a_in_buffer) free(sh->a_in_buffer);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
84 if(sh->a_buffer) free(sh->a_buffer);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
85 if(sh->wf) free(sh->wf);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
86 free(sh);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
87 }
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
88
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
89 sh_video_t* new_sh_video(demuxer_t *demuxer,int id){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
90 if(demuxer->v_streams[id]){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
91 mp_msg(MSGT_DEMUXER,MSGL_WARN,MSGTR_VideoStreamRedefined,id);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
92 } else {
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
93 mp_msg(MSGT_DEMUXER,MSGL_V,"==> Found video stream: %d\n",id);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
94 demuxer->v_streams[id]=malloc(sizeof(sh_video_t));
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
95 memset(demuxer->v_streams[id],0,sizeof(sh_video_t));
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
96 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
97 return demuxer->v_streams[id];
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
98 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
99
1643
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
100 void free_sh_video(sh_video_t* sh){
1657
f6d3c1287748 freeing video buffer
arpi
parents: 1643
diff changeset
101 if(sh->our_out_buffer) free(sh->our_out_buffer);
f6d3c1287748 freeing video buffer
arpi
parents: 1643
diff changeset
102 if(sh->bih) free(sh->bih);
1643
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
103 free(sh);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
104 }
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
105
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
106 void free_demuxer(demuxer_t *demuxer){
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
107 int i;
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
108 // free streams:
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
109 for(i=0;i<256;i++){
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
110 if(demuxer->a_streams[i]) free_sh_audio(demuxer->a_streams[i]);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
111 if(demuxer->v_streams[i]) free_sh_video(demuxer->v_streams[i]);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
112 }
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
113 //if(sh_audio) free_sh_audio(sh_audio);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
114 //if(sh_video) free_sh_video(sh_video);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
115 // free demuxers:
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
116 free_demuxer_stream(demuxer->audio);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
117 free_demuxer_stream(demuxer->video);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
118 free(demuxer);
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
119 }
76835bed88ca free demux/ds/sh
arpi
parents: 1631
diff changeset
120
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
121
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
122 void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 // demux_packet_t* dp=new_demux_packet(len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 // stream_read(stream,dp->buffer,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 // dp->pts=pts; //(float)pts/90000.0f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 // dp->pos=pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 // append packet to DS stream:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 ++ds->packs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 ds->bytes+=dp->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 if(ds->last){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 // next packet in stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 ds->last->next=dp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 ds->last=dp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 // first packet in stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 ds->first=ds->last=dp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 }
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
138 mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%u [packs: A=%d V=%d]\n",
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 (ds==ds->demuxer->audio)?"d_audio":"d_video",
1428
a90d889eb649 largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents: 1421
diff changeset
140 dp->len,dp->pts,(unsigned int)dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142
1428
a90d889eb649 largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents: 1421
diff changeset
143 void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 demux_packet_t* dp=new_demux_packet(len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 stream_read(stream,dp->buffer,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 dp->pts=pts; //(float)pts/90000.0f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 dp->pos=pos;
979
3bcc435cd5a2 keyframe flag added
arpi_esp
parents: 889
diff changeset
148 dp->flags=flags;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 // append packet to DS stream:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 ds_add_packet(ds,dp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 // return value:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 // 0 = EOF or no stream found or invalid type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 // 1 = successfully read a packet
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 int demux_mpg_es_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 int demux_mpg_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 int demux_avi_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t *ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t *ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 int demux_asf_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 // Note: parameter 'ds' can be NULL!
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
165 // printf("demux->type=%d\n",demux->type);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 switch(demux->type){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 case DEMUXER_TYPE_AVI: return demux_avi_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 case DEMUXER_TYPE_AVI_NI: return demux_avi_fill_buffer_ni(demux,ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 case DEMUXER_TYPE_AVI_NINI: return demux_avi_fill_buffer_nini(demux,ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 case DEMUXER_TYPE_ASF: return demux_asf_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 // return value:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 // 0 = EOF
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 // 1 = succesfull
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
180 int ds_fill_buffer(demux_stream_t *ds){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 demuxer_t *demux=ds->demuxer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 if(ds->buffer) free(ds->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 if(verbose>2){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
184 if(ds==demux->audio) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_audio) called\n");else
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
185 if(ds==demux->video) mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(d_video) called\n");else
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
186 mp_dbg(MSGT_DEMUXER,MSGL_DBG3,"ds_fill_buffer(unknown 0x%X) called\n",(unsigned int)ds);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 while(1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 if(ds->packs){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 demux_packet_t *p=ds->first;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 // copy useful data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 ds->buffer=p->buffer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 ds->buffer_pos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 ds->buffer_size=p->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 ds->pos=p->pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 ds->dpos+=p->len; // !!!
889
1b905517c684 AVI -bps desync problem solved
arpi_esp
parents: 828
diff changeset
197 ++ds->pack_no;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
198 if(p->pts){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
199 ds->pts=p->pts;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
200 ds->pts_bytes=0;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
201 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
202 ds->pts_bytes+=p->len; // !!!
979
3bcc435cd5a2 keyframe flag added
arpi_esp
parents: 889
diff changeset
203 ds->flags=p->flags;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 // free packet:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 ds->bytes-=p->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 ds->first=p->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 if(!ds->first) ds->last=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 free(p);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 --ds->packs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 return 1; //ds->buffer_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 if(demux->audio->packs>=MAX_PACKS || demux->audio->bytes>=MAX_PACK_BYTES){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
213 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyAudioInBuffer,demux->audio->packs,demux->audio->bytes);
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
214 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 if(demux->video->packs>=MAX_PACKS || demux->video->bytes>=MAX_PACK_BYTES){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
218 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_TooManyVideoInBuffer,demux->video->packs,demux->video->bytes);
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
219 mp_msg(MSGT_DEMUXER,MSGL_HINT,MSGTR_MaybeNI);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 }
1421
ea0a0b9e6fbc nosound avi seeking fixed
arpi
parents: 1401
diff changeset
222 if(!demux_fill_buffer(demux,ds)){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
223 mp_dbg(MSGT_DEMUXER,MSGL_DBG2,"ds_fill_buffer()->demux_fill_buffer() failed\n");
1421
ea0a0b9e6fbc nosound avi seeking fixed
arpi
parents: 1401
diff changeset
224 break; // EOF
ea0a0b9e6fbc nosound avi seeking fixed
arpi
parents: 1401
diff changeset
225 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 ds->buffer_pos=ds->buffer_size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 ds->buffer=NULL;
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
229 mp_msg(MSGT_DEMUXER,MSGL_V,"ds_fill_buffer: EOF reached (stream: %s) \n",ds==demux->audio?"audio":"video");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 ds->eof=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
234 int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 int x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 int bytes=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 while(len>0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 x=ds->buffer_size-ds->buffer_pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 if(x==0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 if(!ds_fill_buffer(ds)) return bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 if(x>len) x=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 if(mem) memcpy(mem+bytes,&ds->buffer[ds->buffer_pos],x);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 bytes+=x;len-=x;ds->buffer_pos+=x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 return bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
250 int demux_read_data_pack(demux_stream_t *ds,unsigned char* mem,int len){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
251 int x;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
252 int bytes=0;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
253 while(len>0){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
254 x=ds->buffer_size-ds->buffer_pos;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
255 if(x==0){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
256 if(!ds_fill_buffer(ds)) return bytes;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
257 } else {
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
258 if(x>len) x=len;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
259 if(mem) memcpy(mem+bytes,&ds->buffer[ds->buffer_pos],x);
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
260 bytes+=x;len-=x;ds->buffer_pos+=x;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
261 return bytes; // stop at end of package! (for correct timestamping)
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
262 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
263 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
264 return bytes;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
265 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
266
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
267
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 void ds_free_packs(demux_stream_t *ds){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 demux_packet_t *dp=ds->first;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 while(dp){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 demux_packet_t *dn=dp->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 free(dp->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 free(dp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 dp=dn;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 if(ds->asf_packet){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 // free unfinished .asf fragments:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 free(ds->asf_packet->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 free(ds->asf_packet);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 ds->asf_packet=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 ds->first=ds->last=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 ds->packs=0; // !!!!!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 ds->bytes=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 if(ds->buffer) free(ds->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 ds->buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 ds->buffer_pos=ds->buffer_size;
828
c71695c30006 added pts_bytes=0 to ds_free_packs
arpi_esp
parents: 746
diff changeset
288 ds->pts=0; ds->pts_bytes=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
291 int ds_get_packet(demux_stream_t *ds,unsigned char **start){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 while(1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 if(ds->buffer_pos>=ds->buffer_size){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 if(!ds_fill_buffer(ds)){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 // EOF
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 *start = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 len=ds->buffer_size-ds->buffer_pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 *start = &ds->buffer[ds->buffer_pos];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 ds->buffer_pos+=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 return len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 }
554
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
307
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
308 int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start){
554
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
309 while(1){
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
310 int len;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
311 if(ds->buffer_pos>=ds->buffer_size){
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
312 *start = NULL;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
313 if(!ds->packs) return -1; // no sub
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
314 if(!ds_fill_buffer(ds)) return -1; // EOF
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
315 }
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
316 len=ds->buffer_size-ds->buffer_pos;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
317 *start = &ds->buffer[ds->buffer_pos];
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
318 ds->buffer_pos+=len;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
319 return len;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
320 }
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
321 }
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
322
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
323 // ====================================================================
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
324
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
325 // feed-back from demuxers:
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
326 extern int num_elementary_packets100; // for MPEG-ES fileformat detection
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
327 extern int num_elementary_packets101;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
328 extern int num_elementary_packetsPES;
1659
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
329 extern int num_elementary_packets1B6;
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
330
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
331 // commandline options, flags:
1497
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
332 //extern int seek_to_byte;
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
333 extern int force_ni;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
334 extern int pts_from_bps;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
335
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
336 extern int audio_id;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
337 extern int video_id;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
338 extern int dvdsub_id;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
339
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
340 void read_avi_header(demuxer_t *demuxer,int index_mode);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
341 int asf_check_header(demuxer_t *demuxer);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
342 int read_asf_header(demuxer_t *demuxer);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
343 demux_stream_t* demux_avi_select_stream(demuxer_t *demux,unsigned int id);
2050
18f4dd5d568f -Wall warnings fixed
arpi
parents: 1973
diff changeset
344 demuxer_t* demux_open_avi(demuxer_t* demuxer);
18f4dd5d568f -Wall warnings fixed
arpi
parents: 1973
diff changeset
345 int mov_check_file(demuxer_t* demuxer);
18f4dd5d568f -Wall warnings fixed
arpi
parents: 1973
diff changeset
346 int mov_read_header(demuxer_t* demuxer);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
347
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
348
1496
8c3e93ef116d cleanup...
arpi
parents: 1490
diff changeset
349 demuxer_t* demux_open(stream_t *stream,int file_format,int audio_id,int video_id,int dvdsub_id){
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
350
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
351 //int file_format=(*file_format_ptr);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
352
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
353 demuxer_t *demuxer=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
354
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
355 demux_stream_t *d_audio=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
356 demux_stream_t *d_video=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
357
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
358 sh_audio_t *sh_audio=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
359 sh_video_t *sh_video=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
360
1659
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
361 //printf("demux_open(%p,%d,%d,%d,%d) \n",stream,file_format,audio_id,video_id,dvdsub_id);
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
362
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
363 //=============== Try to open as AVI file: =================
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
364 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AVI){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
365 demuxer=new_demuxer(stream,DEMUXER_TYPE_AVI,audio_id,video_id,dvdsub_id);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
366 { //---- RIFF header:
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
367 int id=stream_read_dword_le(demuxer->stream); // "RIFF"
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
368 if(id==mmioFOURCC('R','I','F','F')){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
369 stream_read_dword_le(demuxer->stream); //filesize
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
370 id=stream_read_dword_le(demuxer->stream); // "AVI "
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
371 if(id==formtypeAVI){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
372 mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedAVIfile);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
373 file_format=DEMUXER_TYPE_AVI;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
374 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
375 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
376 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
377 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
378 //=============== Try to open as ASF file: =================
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
379 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_ASF){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
380 demuxer=new_demuxer(stream,DEMUXER_TYPE_ASF,audio_id,video_id,dvdsub_id);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
381 if(asf_check_header(demuxer)){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
382 mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedASFfile);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
383 file_format=DEMUXER_TYPE_ASF;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
384 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
385 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
386 //=============== Try to open as MPEG-PS file: =================
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
387 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPEG_PS){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
388 int pes=1;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
389 while(pes>=0){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
390 demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_PS,audio_id,video_id,dvdsub_id);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
391 if(!pes) demuxer->synced=1; // hack!
1659
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
392 num_elementary_packets100=0;
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
393 num_elementary_packets101=0;
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
394 num_elementary_packets1B6=0;
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
395 num_elementary_packetsPES=0;
6b71bbf515e4 num_elementary_packets1xx reset
arpi
parents: 1657
diff changeset
396
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
397 if(ds_fill_buffer(demuxer->video)){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
398 if(!pes)
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
399 mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedMPEGPESfile);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
400 else
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
401 mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedMPEGPSfile);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
402 file_format=DEMUXER_TYPE_MPEG_PS;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
403 } else {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
404 // some hack to get meaningfull error messages to our unhappy users:
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
405 if(num_elementary_packets100>=2 && num_elementary_packets101>=2 &&
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
406 abs(num_elementary_packets101-num_elementary_packets100)<8){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
407 if(num_elementary_packetsPES>=4 && num_elementary_packetsPES>=num_elementary_packets100-4){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
408 --pes;continue; // tricky...
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
409 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
410 file_format=DEMUXER_TYPE_MPEG_ES; // <-- hack is here :)
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
411 } else {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
412 if(demuxer->synced==2)
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1659
diff changeset
413 mp_msg(MSGT_DEMUXER,MSGL_ERR,"MPEG: " MSGTR_MissingVideoStreamBug);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
414 else
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
415 mp_msg(MSGT_DEMUXER,MSGL_V,"Not MPEG System Stream format... (maybe Transport Stream?)\n");
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
416 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
417 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
418 break;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
419 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
420 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
421 //=============== Try to open as MPEG-ES file: =================
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
422 if(file_format==DEMUXER_TYPE_MPEG_ES){ // little hack, see above!
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
423 demuxer=new_demuxer(stream,DEMUXER_TYPE_MPEG_ES,audio_id,video_id,dvdsub_id);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
424 if(!ds_fill_buffer(demuxer->video)){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
425 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_InvalidMPEGES);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
426 file_format=DEMUXER_TYPE_UNKNOWN;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
427 } else {
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
428 mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedMPEGESfile);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
429 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
430 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
431 //=============== Try to open as MOV file: =================
1490
71424eb2b282 MOV file support - not works yet
arpi
parents: 1485
diff changeset
432 #if 1
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
433 if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MOV){
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
434 demuxer=new_demuxer(stream,DEMUXER_TYPE_MOV,audio_id,video_id,dvdsub_id);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
435 if(mov_check_file(demuxer)){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
436 mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedQTMOVfile);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
437 file_format=DEMUXER_TYPE_MOV;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
438 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
439 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
440 #endif
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
441 //=============== Unknown, exiting... ===========================
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
442 if(file_format==DEMUXER_TYPE_UNKNOWN){
1584
e49b3927c793 more messages for translator :)
arpi
parents: 1567
diff changeset
443 mp_msg(MSGT_DEMUXER,MSGL_ERR,MSGTR_FormatNotRecognized);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
444 return NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
445 // GUI_MSG( mplUnknowFileType )
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
446 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
447 //====== File format recognized, set up these for compatibility: =========
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
448 d_audio=demuxer->audio;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
449 d_video=demuxer->video;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
450 //d_dvdsub=demuxer->sub;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
451
1485
b895f95e7657 AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents: 1456
diff changeset
452 demuxer->file_format=file_format;
b895f95e7657 AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents: 1456
diff changeset
453
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
454 switch(file_format){
1490
71424eb2b282 MOV file support - not works yet
arpi
parents: 1485
diff changeset
455 case DEMUXER_TYPE_MOV: {
71424eb2b282 MOV file support - not works yet
arpi
parents: 1485
diff changeset
456 mov_read_header(demuxer);
71424eb2b282 MOV file support - not works yet
arpi
parents: 1485
diff changeset
457 break;
71424eb2b282 MOV file support - not works yet
arpi
parents: 1485
diff changeset
458 }
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
459 case DEMUXER_TYPE_AVI: {
1623
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
460 return (demuxer_t*) demux_open_avi(demuxer);
1485
b895f95e7657 AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents: 1456
diff changeset
461 // break;
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
462 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
463 case DEMUXER_TYPE_ASF: {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
464 //---- ASF header:
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
465 read_asf_header(demuxer);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
466 stream_reset(demuxer->stream);
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
467 stream_seek(demuxer->stream,demuxer->movi_start);
1485
b895f95e7657 AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents: 1456
diff changeset
468 // demuxer->idx_pos=0;
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
469 // demuxer->endpos=avi_header.movi_end;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
470 if(!ds_fill_buffer(d_video)){
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1659
diff changeset
471 mp_msg(MSGT_DEMUXER,MSGL_WARN,"ASF: " MSGTR_MissingVideoStream);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
472 sh_video=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
473 //printf("ASF: missing video stream!? contact the author, it may be a bug :(\n");
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
474 //GUI_MSG( mplASFErrorMissingVideoStream )
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
475 } else {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
476 sh_video=d_video->sh;sh_video->ds=d_video;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
477 sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
478 mp_msg(MSGT_DEMUXER,MSGL_INFO,"VIDEO: [%.4s] %ldx%ld %dbpp\n",
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
479 (char *)&sh_video->bih->biCompression,
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
480 sh_video->bih->biWidth,
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
481 sh_video->bih->biHeight,
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
482 sh_video->bih->biBitCount);
1401
c11f2a77ff70 using sh_video->i_bps...
arpi
parents: 1375
diff changeset
483 // sh_video->i_bps=10*asf_packetsize; // FIXME!
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
484 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
485 if(audio_id!=-2){
1567
5c7760aa4f94 printf->mp_msg/mp_dbg
arpi
parents: 1497
diff changeset
486 mp_msg(MSGT_DEMUXER,MSGL_V,"ASF: Searching for audio stream (id:%d)\n",d_audio->id);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
487 if(!ds_fill_buffer(d_audio)){
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1659
diff changeset
488 mp_msg(MSGT_DEMUXER,MSGL_INFO,"ASF: " MSGTR_MissingAudioStream);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
489 sh_audio=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
490 } else {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
491 sh_audio=d_audio->sh;sh_audio->ds=d_audio;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
492 sh_audio->format=sh_audio->wf->wFormatTag;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
493 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
494 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
495 break;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
496 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
497 case DEMUXER_TYPE_MPEG_ES: {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
498 sh_audio=NULL; // ES streams has no audio channel
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
499 d_video->sh=new_sh_video(demuxer,0); // create dummy video stream header, id=0
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
500 sh_video=d_video->sh;sh_video->ds=d_video;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
501 break;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
502 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
503 case DEMUXER_TYPE_MPEG_PS: {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
504 sh_video=d_video->sh;sh_video->ds=d_video;
1628
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1623
diff changeset
505 if(demuxer->stream->type!=STREAMTYPE_VCD) demuxer->movi_start=0; // for VCD
bd1ef18cdf33 seeking flags implemented: 0x1=rel/abs and 0x2=time/percent
arpi
parents: 1623
diff changeset
506
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
507 if(audio_id!=-2) {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
508 if(!ds_fill_buffer(d_audio)){
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1659
diff changeset
509 mp_msg(MSGT_DEMUXER,MSGL_INFO,"MPEG: " MSGTR_MissingAudioStream);
1375
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
510 sh_audio=NULL;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
511 } else {
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
512 sh_audio=d_audio->sh;sh_audio->ds=d_audio;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
513 switch(d_audio->id & 0xE0){ // 1110 0000 b (high 3 bit: type low 5: id)
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
514 case 0x00: sh_audio->format=0x50;break; // mpeg
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
515 case 0xA0: sh_audio->format=0x10001;break; // dvd pcm
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
516 case 0x80: sh_audio->format=0x2000;break; // ac3
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
517 default: sh_audio=NULL; // unknown type
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
518 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
519 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
520 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
521 break;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
522 }
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
523 } // switch(file_format)
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
524
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
525 return demuxer;
dbcb5b5e1fae file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents: 1331
diff changeset
526 }
1497
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
527
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
528 int demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags);
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
529 int demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags);
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
530 int demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags);
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
531
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
532 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
533 demux_stream_t *d_audio=demuxer->audio;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
534 demux_stream_t *d_video=demuxer->video;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
535 sh_audio_t *sh_audio=d_audio->sh;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
536 sh_video_t *sh_video=d_video->sh;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
537
1623
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
538 if(!demuxer->seekable){
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
539 if(demuxer->file_format==DEMUXER_TYPE_AVI)
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1659
diff changeset
540 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekRawAVI);
1623
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
541 else
1973
5216f108cb4f all error/warn/info messages moved to help_mp-en.h for translation
arpi
parents: 1659
diff changeset
542 mp_msg(MSGT_SEEK,MSGL_WARN,MSGTR_CantSeekFile);
1623
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
543 return 0;
5908dd344067 added demuxer->seekable flag to generalize seeking ability test
arpi
parents: 1584
diff changeset
544 }
1497
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
545
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
546 // clear demux buffers:
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
547 if(sh_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;}
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
548 ds_free_packs(d_video);
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
549
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
550 demuxer->stream->eof=0; // clear eof flag
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
551
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
552 if(sh_audio) sh_audio->timer=0;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
553 sh_video->timer=0; // !!!!!!
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
554
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
555 switch(demuxer->file_format){
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
556
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
557 case DEMUXER_TYPE_AVI:
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
558 demux_seek_avi(demuxer,rel_seek_secs,flags); break;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
559
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
560 case DEMUXER_TYPE_ASF:
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
561 demux_seek_asf(demuxer,rel_seek_secs,flags); break;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
562
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
563 case DEMUXER_TYPE_MPEG_ES:
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
564 case DEMUXER_TYPE_MPEG_PS:
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
565 demux_seek_mpg(demuxer,rel_seek_secs,flags); break;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
566
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
567 } // switch(demuxer->file_format)
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
568
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
569 return 1;
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
570 }
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
571
ad4d402b3d29 seek.c moved to demuxer.c, stream_reset in new_demuxer()
arpi
parents: 1496
diff changeset
572