annotate demuxer.c @ 848:738dc5a2bb39

Changed some #ifdef to include modify ASF structs definition when STREAMING is defined.
author bertrand
date Mon, 21 May 2001 13:04:34 +0000
parents c71695c30006
children 1b905517c684
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
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
3 #include <stdio.h>
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
4 #include <stdlib.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
6 extern int verbose; // defined in mplayer.c
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
8 #include "stream.h"
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
9 #include "demuxer.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 demux_stream_t* ds=malloc(sizeof(demux_stream_t));
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 ds->buffer_pos=ds->buffer_size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 ds->buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 ds->pts=0;
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
16 ds->pts_bytes=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 ds->eof=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 ds->pos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 ds->dpos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 //---------------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 ds->packs=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 ds->bytes=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 ds->first=ds->last=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 ds->id=id;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 ds->type=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 ds->demuxer=demuxer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 //----------------
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 ds->asf_seq=-1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 ds->asf_packet=NULL;
291
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 1
diff changeset
30 //----------------
da98e96499bb sh_audio/sh_video added, general codec cleanup
arpi_esp
parents: 1
diff changeset
31 ds->sh=NULL;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 return ds;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 291
diff changeset
35 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
36 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
37 memset(d,0,sizeof(demuxer_t));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 d->stream=stream;
598
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
39 d->movi_start=stream->start_pos;
c7117e17e20b OSD seekbar fixed for mpeg/VCD
arpi_esp
parents: 587
diff changeset
40 d->movi_end=stream->end_pos;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 d->synced=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 d->filepos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 d->audio=new_demuxer_stream(d,a_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 d->video=new_demuxer_stream(d,v_id);
552
c2a449f90087 dvd sub support reading
arpi_esp
parents: 291
diff changeset
45 d->sub=new_demuxer_stream(d,s_id);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 d->type=type;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 return d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
50 void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 // demux_packet_t* dp=new_demux_packet(len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 // stream_read(stream,dp->buffer,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 // dp->pts=pts; //(float)pts/90000.0f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 // dp->pos=pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 // append packet to DS stream:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 ++ds->packs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 ds->bytes+=dp->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 if(ds->last){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 // next packet in stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 ds->last->next=dp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 ds->last=dp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 // first packet in stream
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 ds->first=ds->last=dp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 if(verbose>=2)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 printf("DEMUX: Append packet to %s, len=%d pts=%5.3f pos=%d [packs: A=%d V=%d]\n",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 (ds==ds->demuxer->audio)?"d_audio":"d_video",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 dp->len,dp->pts,dp->pos,ds->demuxer->audio->packs,ds->demuxer->video->packs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
72 void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,int pos){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 demux_packet_t* dp=new_demux_packet(len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 stream_read(stream,dp->buffer,len);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 dp->pts=pts; //(float)pts/90000.0f;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 dp->pos=pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 // append packet to DS stream:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 ds_add_packet(ds,dp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 // return value:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 // 0 = EOF or no stream found or invalid type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 // 1 = successfully read a packet
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 int demux_mpg_es_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 int demux_mpg_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 int demux_avi_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 int demux_avi_fill_buffer_ni(demuxer_t *demux,demux_stream_t *ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 int demux_avi_fill_buffer_nini(demuxer_t *demux,demux_stream_t *ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 int demux_asf_fill_buffer(demuxer_t *demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 // Note: parameter 'ds' can be NULL!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 switch(demux->type){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 case DEMUXER_TYPE_MPEG_ES: return demux_mpg_es_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 case DEMUXER_TYPE_MPEG_PS: return demux_mpg_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 case DEMUXER_TYPE_AVI: return demux_avi_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 case DEMUXER_TYPE_AVI_NI: return demux_avi_fill_buffer_ni(demux,ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 case DEMUXER_TYPE_AVI_NINI: return demux_avi_fill_buffer_nini(demux,ds);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 case DEMUXER_TYPE_ASF: return demux_asf_fill_buffer(demux);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 // return value:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 // 0 = EOF
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 // 1 = succesfull
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
107 int ds_fill_buffer(demux_stream_t *ds){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 demuxer_t *demux=ds->demuxer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 if(ds->buffer) free(ds->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 if(verbose>2){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 if(ds==demux->audio) printf("ds_fill_buffer(d_audio) called\n");else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 if(ds==demux->video) printf("ds_fill_buffer(d_video) called\n");else
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
113 printf("ds_fill_buffer(unknown 0x%X) called\n",(unsigned int)ds);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 while(1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 if(ds->packs){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 demux_packet_t *p=ds->first;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 // copy useful data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 ds->buffer=p->buffer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 ds->buffer_pos=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121 ds->buffer_size=p->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 ds->pos=p->pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 ds->dpos+=p->len; // !!!
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
124 if(p->pts){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
125 ds->pts=p->pts;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
126 ds->pts_bytes=0;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
127 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
128 ds->pts_bytes+=p->len; // !!!
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 // free packet:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 ds->bytes-=p->len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 ds->first=p->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 if(!ds->first) ds->last=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 free(p);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 --ds->packs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 return 1; //ds->buffer_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 if(demux->audio->packs>=MAX_PACKS || demux->audio->bytes>=MAX_PACK_BYTES){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 printf("\nDEMUXER: Too many (%d in %d bytes) audio packets in the buffer!\n",demux->audio->packs,demux->audio->bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 printf("(maybe you play a non-interleaved stream/file or audio codec failed)\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 if(demux->video->packs>=MAX_PACKS || demux->video->bytes>=MAX_PACK_BYTES){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 printf("\nDEMUXER: Too many (%d in %d bytes) video packets in the buffer!\n",demux->video->packs,demux->video->bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 printf("(maybe you play a non-interleaved stream/file or video codec failed)\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 if(!demux_fill_buffer(demux,ds)) break; // EOF
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 ds->buffer_pos=ds->buffer_size=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 ds->buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 if(verbose) printf("ds_fill_buffer: EOF reached (stream: %s) \n",ds==demux->audio?"audio":"video");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 ds->eof=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
156 int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 int x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 int bytes=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 while(len>0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 x=ds->buffer_size-ds->buffer_pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 if(x==0){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 if(!ds_fill_buffer(ds)) return bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 if(x>len) x=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 if(mem) memcpy(mem+bytes,&ds->buffer[ds->buffer_pos],x);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 bytes+=x;len-=x;ds->buffer_pos+=x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 return bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171
746
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
172 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
173 int x;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
174 int bytes=0;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
175 while(len>0){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
176 x=ds->buffer_size-ds->buffer_pos;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
177 if(x==0){
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
178 if(!ds_fill_buffer(ds)) return bytes;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
179 } else {
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
180 if(x>len) x=len;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
181 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
182 bytes+=x;len-=x;ds->buffer_pos+=x;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
183 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
184 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
185 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
186 return bytes;
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
187 }
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
188
cd1f0d4de0b8 new audio playback and A-V sync code
arpi_esp
parents: 598
diff changeset
189
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 void ds_free_packs(demux_stream_t *ds){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 demux_packet_t *dp=ds->first;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 while(dp){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 demux_packet_t *dn=dp->next;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 free(dp->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 free(dp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 dp=dn;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 if(ds->asf_packet){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 // free unfinished .asf fragments:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 free(ds->asf_packet->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 free(ds->asf_packet);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 ds->asf_packet=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 ds->first=ds->last=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 ds->packs=0; // !!!!!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 ds->bytes=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 if(ds->buffer) free(ds->buffer);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 ds->buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 ds->buffer_pos=ds->buffer_size;
828
c71695c30006 added pts_bytes=0 to ds_free_packs
arpi_esp
parents: 746
diff changeset
210 ds->pts=0; ds->pts_bytes=0;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
213 int ds_get_packet(demux_stream_t *ds,unsigned char **start){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 while(1){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 int len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 if(ds->buffer_pos>=ds->buffer_size){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 if(!ds_fill_buffer(ds)){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 // EOF
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 *start = NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 len=ds->buffer_size-ds->buffer_pos;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 *start = &ds->buffer[ds->buffer_pos];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 ds->buffer_pos+=len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 return len;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 }
554
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
229
587
8511095c5283 stage#1 completed: c files no more included from mplayer.c
arpi_esp
parents: 554
diff changeset
230 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
231 while(1){
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
232 int len;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
233 if(ds->buffer_pos>=ds->buffer_size){
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
234 *start = NULL;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
235 if(!ds->packs) return -1; // no sub
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
236 if(!ds_fill_buffer(ds)) return -1; // EOF
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
237 }
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
238 len=ds->buffer_size-ds->buffer_pos;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
239 *start = &ds->buffer[ds->buffer_pos];
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
240 ds->buffer_pos+=len;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
241 return len;
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
242 }
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
243 }
d8b3c80604e3 dvd sub parser move dto mplayer.c
arpi_esp
parents: 552
diff changeset
244