Mercurial > mplayer.hg
annotate demuxer.h @ 1356:e9242766474a
argh. -d fixed. fixed?
author | arpi |
---|---|
date | Fri, 20 Jul 2001 00:31:51 +0000 |
parents | b4457de47804 |
children | dbcb5b5e1fae |
rev | line source |
---|---|
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
1 |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
2 #include "config.h" |
589 | 3 |
647 | 4 #define MAX_PACKS 4096 |
5 #define MAX_PACK_BYTES 0x800000 | |
589 | 6 |
7 #define DEMUXER_TYPE_UNKNOWN 0 | |
8 #define DEMUXER_TYPE_MPEG_ES 1 | |
9 #define DEMUXER_TYPE_MPEG_PS 2 | |
10 #define DEMUXER_TYPE_AVI 3 | |
11 #define DEMUXER_TYPE_AVI_NI 4 | |
12 #define DEMUXER_TYPE_AVI_NINI 5 | |
13 #define DEMUXER_TYPE_ASF 6 | |
14 | |
15 #define DEMUXER_TIME_NONE 0 | |
16 #define DEMUXER_TIME_PTS 1 | |
17 #define DEMUXER_TIME_FILE 2 | |
18 #define DEMUXER_TIME_BPS 3 | |
19 | |
20 | |
21 typedef struct demux_packet_st { | |
22 int len; | |
23 float pts; | |
24 int pos; // pozicio indexben (AVI) ill. fileban (MPG) | |
25 unsigned char* buffer; | |
979 | 26 int flags; // keyframe, etc |
589 | 27 struct demux_packet_st* next; |
28 } demux_packet_t; | |
29 | |
30 typedef struct { | |
31 int buffer_pos; // current buffer position | |
32 int buffer_size; // current buffer size | |
33 unsigned char* buffer; // current buffer | |
34 float pts; // current buffer's pts | |
746 | 35 int pts_bytes; // number of bytes read after last pts stamp |
589 | 36 int eof; // end of demuxed stream? (true if all buffer empty) |
37 int pos; // position in the input stream (file) | |
38 int dpos; // position in the demuxed stream | |
889 | 39 int pack_no; // serial number of packet |
979 | 40 int flags; // flags of current packet (keyframe etc) |
589 | 41 //--------------- |
42 int packs; // number of packets in buffer | |
43 int bytes; // total bytes of packets in buffer | |
44 demux_packet_t *first; // read to current buffer from here | |
45 demux_packet_t *last; // append new packets from input stream to here | |
46 int id; // stream ID (for multiple audio/video streams) | |
47 struct demuxer_st *demuxer; // parent demuxer structure (stream handler) | |
48 // ---- asf ----- | |
49 demux_packet_t *asf_packet; // read asf fragments here | |
50 int asf_seq; | |
51 // ---- stream header ---- | |
52 void* sh; | |
53 } demux_stream_t; | |
54 | |
55 typedef struct demuxer_st { | |
56 stream_t *stream; | |
57 int synced; // stream synced (used by mpeg) | |
58 int filepos; // input stream current pos. | |
59 // int endpos; // input stream end pos. (return EOF fi filepos>endpos) | |
60 int type; // mpeg system stream, mpeg elementary s., avi raw, avi indexed | |
61 // int time_src;// time source (pts/file/bps) | |
62 unsigned int movi_start; | |
63 unsigned int movi_end; | |
64 // | |
65 demux_stream_t *audio; | |
66 demux_stream_t *video; | |
67 demux_stream_t *sub; | |
68 | |
69 // index: | |
70 // AVIINDEXENTRY* idx; | |
71 void* idx; | |
72 int idx_size; | |
73 int idx_pos; | |
74 int idx_pos_a; | |
75 int idx_pos_v; | |
76 int idx_offset; // ennyit kell hozzaadni az index offset ertekekhez | |
77 | |
78 // stream headers: | |
79 // sh_audio_t* a_streams[256]; | |
80 // sh_video_t* v_streams[256]; | |
81 void* a_streams[256]; | |
82 void* v_streams[256]; | |
83 char s_streams[32]; // dvd subtitles | |
84 } demuxer_t; | |
85 | |
86 inline static demux_packet_t* new_demux_packet(int len){ | |
87 demux_packet_t* dp=malloc(sizeof(demux_packet_t)); | |
88 dp->len=len; | |
89 dp->buffer=malloc(len); | |
90 dp->next=NULL; | |
91 dp->pts=0; | |
92 dp->pos=0; | |
979 | 93 dp->flags=0; |
589 | 94 return dp; |
95 } | |
96 | |
97 inline static void free_demux_packet(demux_packet_t* dp){ | |
98 free(dp->buffer); | |
99 free(dp); | |
100 } | |
101 | |
102 demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id); | |
103 demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id); | |
104 | |
105 void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp); | |
979 | 106 void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,int pos,int flags); |
589 | 107 |
108 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds); | |
109 int ds_fill_buffer(demux_stream_t *ds); | |
110 | |
111 inline static int ds_tell(demux_stream_t *ds){ | |
112 return (ds->dpos-ds->buffer_size)+ds->buffer_pos; | |
113 } | |
114 | |
746 | 115 inline static int ds_tell_pts(demux_stream_t *ds){ |
116 return (ds->pts_bytes-ds->buffer_size)+ds->buffer_pos; | |
117 } | |
118 | |
589 | 119 int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len); |
746 | 120 int demux_read_data_pack(demux_stream_t *ds,unsigned char* mem,int len); |
589 | 121 |
122 #if 1 | |
123 #define demux_getc(ds) (\ | |
124 (ds->buffer_pos<ds->buffer_size) ? ds->buffer[ds->buffer_pos++] \ | |
125 :((!ds_fill_buffer(ds))? (-1) : ds->buffer[ds->buffer_pos++] ) ) | |
126 #else | |
127 inline static int demux_getc(demux_stream_t *ds){ | |
128 if(ds->buffer_pos>=ds->buffer_size){ | |
129 if(!ds_fill_buffer(ds)){ | |
130 // printf("DEMUX_GETC: EOF reached!\n"); | |
131 return -1; // EOF | |
132 } | |
133 } | |
134 // printf("[%02X]",ds->buffer[ds->buffer_pos]); | |
135 return ds->buffer[ds->buffer_pos++]; | |
136 } | |
137 #endif | |
138 | |
139 void ds_free_packs(demux_stream_t *ds); | |
140 int ds_get_packet(demux_stream_t *ds,unsigned char **start); | |
141 int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start); | |
142 | |
143 | |
144 static inline int avi_stream_id(unsigned int id){ | |
145 unsigned char *p=(unsigned char *)&id; | |
146 unsigned char a,b; | |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
147 #if WORDS_BIGENDIAN |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
148 a=p[3]-'0'; b=p[2]-'0'; |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
149 #else |
589 | 150 a=p[0]-'0'; b=p[1]-'0'; |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
151 #endif |
589 | 152 if(a>9 || b>9) return 100; // invalid ID |
153 return a*10+b; | |
154 } | |
155 | |
156 | |
157 |