Mercurial > mplayer.hg
annotate libmpdemux/demuxer.h @ 2694:2924350d92ed
bgr32to16, bgr32to15 (needed for palette stuff)
paletteto 32,16,15bgr
all in c, will be optimized as soon as they are tested (assuming opt. is possible)
author | michael |
---|---|
date | Sun, 04 Nov 2001 19:36:24 +0000 |
parents | 8c75a9a639c1 |
children | 98769cea155c |
rev | line source |
---|---|
589 | 1 |
647 | 2 #define MAX_PACKS 4096 |
3 #define MAX_PACK_BYTES 0x800000 | |
589 | 4 |
5 #define DEMUXER_TYPE_UNKNOWN 0 | |
6 #define DEMUXER_TYPE_MPEG_ES 1 | |
7 #define DEMUXER_TYPE_MPEG_PS 2 | |
8 #define DEMUXER_TYPE_AVI 3 | |
9 #define DEMUXER_TYPE_AVI_NI 4 | |
10 #define DEMUXER_TYPE_AVI_NINI 5 | |
11 #define DEMUXER_TYPE_ASF 6 | |
1490 | 12 #define DEMUXER_TYPE_MOV 7 |
2687 | 13 #define DEMUXER_TYPE_VIVO 8 |
589 | 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 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
21 // Holds one packet/frame/whatever |
589 | 22 typedef struct demux_packet_st { |
23 int len; | |
24 float pts; | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
25 off_t pos; // position in index (AVI) or file (MPG) |
589 | 26 unsigned char* buffer; |
979 | 27 int flags; // keyframe, etc |
589 | 28 struct demux_packet_st* next; |
29 } demux_packet_t; | |
30 | |
31 typedef struct { | |
32 int buffer_pos; // current buffer position | |
33 int buffer_size; // current buffer size | |
34 unsigned char* buffer; // current buffer | |
35 float pts; // current buffer's pts | |
746 | 36 int pts_bytes; // number of bytes read after last pts stamp |
589 | 37 int eof; // end of demuxed stream? (true if all buffer empty) |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
38 off_t pos; // position in the input stream (file) |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
39 off_t dpos; // position in the demuxed stream |
889 | 40 int pack_no; // serial number of packet |
979 | 41 int flags; // flags of current packet (keyframe etc) |
589 | 42 //--------------- |
43 int packs; // number of packets in buffer | |
44 int bytes; // total bytes of packets in buffer | |
45 demux_packet_t *first; // read to current buffer from here | |
46 demux_packet_t *last; // append new packets from input stream to here | |
47 int id; // stream ID (for multiple audio/video streams) | |
48 struct demuxer_st *demuxer; // parent demuxer structure (stream handler) | |
49 // ---- asf ----- | |
50 demux_packet_t *asf_packet; // read asf fragments here | |
51 int asf_seq; | |
2419 | 52 // ---- mov ----- |
53 unsigned int ss_mul,ss_div; | |
589 | 54 // ---- stream header ---- |
55 void* sh; | |
56 } demux_stream_t; | |
57 | |
58 typedef struct demuxer_st { | |
59 stream_t *stream; | |
60 int synced; // stream synced (used by mpeg) | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
61 off_t filepos; // input stream current pos. |
1375
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
62 int type; // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf |
dbcb5b5e1fae
file-format detection stuff moved out from mplayer.c to demuxer.c and dec_video.c
arpi
parents:
1331
diff
changeset
|
63 int file_format; // file format: mpeg/avi/asf |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
64 off_t movi_start; |
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
65 off_t movi_end; |
1623
5908dd344067
added demuxer->seekable flag to generalize seeking ability test
arpi
parents:
1496
diff
changeset
|
66 int seekable; // flag |
589 | 67 // |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
68 demux_stream_t *audio; // audio buffer/demuxer |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
69 demux_stream_t *video; // video buffer/demuxer |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
70 demux_stream_t *sub; // dvd subtitle buffer/demuxer |
589 | 71 |
72 // stream headers: | |
1485
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
73 void* a_streams[256]; // audio streams (sh_audio_t) |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
74 void* v_streams[256]; // video sterams (sh_video_t) |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
75 char s_streams[32]; // dvd subtitles (flag) |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
76 |
b895f95e7657
AVI demuxer cleanups, fileformat-dependent stuff moved to priv_t
arpi
parents:
1428
diff
changeset
|
77 void* priv; // fileformat-dependent data |
589 | 78 } demuxer_t; |
79 | |
80 inline static demux_packet_t* new_demux_packet(int len){ | |
81 demux_packet_t* dp=malloc(sizeof(demux_packet_t)); | |
82 dp->len=len; | |
83 dp->buffer=malloc(len); | |
84 dp->next=NULL; | |
85 dp->pts=0; | |
86 dp->pos=0; | |
979 | 87 dp->flags=0; |
589 | 88 return dp; |
89 } | |
90 | |
91 inline static void free_demux_packet(demux_packet_t* dp){ | |
92 free(dp->buffer); | |
93 free(dp); | |
94 } | |
95 | |
96 demux_stream_t* new_demuxer_stream(struct demuxer_st *demuxer,int id); | |
97 demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id); | |
1643 | 98 void free_demuxer_stream(demux_stream_t *ds); |
99 void free_demuxer(demuxer_t *demuxer); | |
589 | 100 |
101 void ds_add_packet(demux_stream_t *ds,demux_packet_t* dp); | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
102 void ds_read_packet(demux_stream_t *ds,stream_t *stream,int len,float pts,off_t pos,int flags); |
589 | 103 |
104 int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds); | |
105 int ds_fill_buffer(demux_stream_t *ds); | |
106 | |
1428
a90d889eb649
largefile patch by Stephen Davies <steve@daviesfam.org>
arpi
parents:
1375
diff
changeset
|
107 inline static off_t ds_tell(demux_stream_t *ds){ |
589 | 108 return (ds->dpos-ds->buffer_size)+ds->buffer_pos; |
109 } | |
110 | |
746 | 111 inline static int ds_tell_pts(demux_stream_t *ds){ |
112 return (ds->pts_bytes-ds->buffer_size)+ds->buffer_pos; | |
113 } | |
114 | |
589 | 115 int demux_read_data(demux_stream_t *ds,unsigned char* mem,int len); |
746 | 116 int demux_read_data_pack(demux_stream_t *ds,unsigned char* mem,int len); |
589 | 117 |
118 #if 1 | |
119 #define demux_getc(ds) (\ | |
120 (ds->buffer_pos<ds->buffer_size) ? ds->buffer[ds->buffer_pos++] \ | |
121 :((!ds_fill_buffer(ds))? (-1) : ds->buffer[ds->buffer_pos++] ) ) | |
122 #else | |
123 inline static int demux_getc(demux_stream_t *ds){ | |
124 if(ds->buffer_pos>=ds->buffer_size){ | |
125 if(!ds_fill_buffer(ds)){ | |
126 // printf("DEMUX_GETC: EOF reached!\n"); | |
127 return -1; // EOF | |
128 } | |
129 } | |
130 // printf("[%02X]",ds->buffer[ds->buffer_pos]); | |
131 return ds->buffer[ds->buffer_pos++]; | |
132 } | |
133 #endif | |
134 | |
135 void ds_free_packs(demux_stream_t *ds); | |
136 int ds_get_packet(demux_stream_t *ds,unsigned char **start); | |
137 int ds_get_packet_sub(demux_stream_t *ds,unsigned char **start); | |
138 | |
139 | |
140 static inline int avi_stream_id(unsigned int id){ | |
141 unsigned char *p=(unsigned char *)&id; | |
142 unsigned char a,b; | |
1309
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
143 #if WORDS_BIGENDIAN |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
144 a=p[3]-'0'; b=p[2]-'0'; |
598e3047ce13
Add some preliminary support for non-x86 architectures to mplayer
jkeil
parents:
979
diff
changeset
|
145 #else |
589 | 146 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
|
147 #endif |
589 | 148 if(a>9 || b>9) return 100; // invalid ID |
149 return a*10+b; | |
150 } | |
151 | |
1496 | 152 demuxer_t* demux_open(stream_t *stream,int file_format,int aid,int vid,int sid); |
153 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); | |
589 | 154 |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2419
diff
changeset
|
155 // AVI demuxer params: |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2419
diff
changeset
|
156 extern int index_mode; // -1=untouched 0=don't use index 1=use (geneate) index |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2419
diff
changeset
|
157 extern int force_ni; |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2419
diff
changeset
|
158 extern int pts_from_bps; |
589 | 159 |
1643 | 160 |
2555
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2419
diff
changeset
|
161 |
66837325b929
config.h cleanup, few things added to steram/demuxer headers
arpi
parents:
2419
diff
changeset
|
162 |