annotate demuxer.c @ 1247:429aacbe23a7

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