annotate demuxer.c @ 664:50cca1591b15

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