Only compile fastmemcpybench on x86.
[mplayer/glamo.git] / libmpdemux / muxer.h
blob68bdedcfd3c125bbf686030fbf8d0913e8d346fd
1 #ifndef MPLAYER_MUXER_H
2 #define MPLAYER_MUXER_H
4 #include <stdint.h>
5 #include <sys/types.h>
6 #include "aviheader.h"
7 #include "ms_hdr.h"
8 #include "stream/stream.h"
10 #define MUXER_MAX_STREAMS 16
12 #define MUXER_TYPE_VIDEO 0
13 #define MUXER_TYPE_AUDIO 1
15 #define MUXER_TYPE_AVI 0
16 #define MUXER_TYPE_MPEG 1
17 #define MUXER_TYPE_RAWVIDEO 2
18 #define MUXER_TYPE_LAVF 3
19 #define MUXER_TYPE_RAWAUDIO 4
22 typedef struct {
23 // muxer data:
24 int type; // audio or video
25 int id; // stream no
26 uint32_t ckid; // chunk id (00dc 01wb etc)
27 double timer;
28 off_t size;
29 float aspect; // aspect ratio of this stream (set by ve_*.c)
30 // buffering:
31 unsigned char *buffer;
32 unsigned int buffer_size;
33 unsigned int buffer_len;
34 // mpeg block buffer:
35 unsigned char *b_buffer;
36 unsigned int b_buffer_size; //size of b_buffer
37 unsigned int b_buffer_ptr; //index to next data to write
38 unsigned int b_buffer_len; //len of next data to write
39 // muxer frame buffer:
40 unsigned int muxbuf_seen;
41 // source stream:
42 void* source; // sh_audio or sh_video
43 int codec; // codec used for encoding. 0 means copy
44 // avi stream header:
45 AVIStreamHeader h; // Rate/Scale and SampleSize must be filled by caller!
46 // stream specific:
47 WAVEFORMATEX *wf;
48 BITMAPINFOHEADER *bih; // in format
49 int encoder_delay; // in number of frames
50 int decoder_delay; // in number of frames
51 int imgfmt;
52 // mpeg specific:
53 size_t ipb[3]; // sizes of I/P/B frames
54 // muxer of that stream
55 struct muxer_t *muxer;
56 void *priv; // private stream specific data stored by the muxer
58 int vbv_size;
59 int max_rate;
60 int avg_rate;
61 } muxer_stream_t;
63 typedef struct {
64 uint32_t id;
65 char *text;
66 } muxer_info_t;
68 typedef struct muxer_t{
69 // encoding:
70 MainAVIHeader avih;
71 off_t movi_start;
72 off_t movi_end;
73 off_t file_end; // for MPEG it's system timestamp in 1/90000 s
74 float audio_delay_fix;
75 // index:
76 AVIINDEXENTRY *idx;
77 int idx_pos;
78 int idx_size;
79 // streams:
80 int num_videos; // for MPEG recalculations
81 int num_audios;
82 unsigned int sysrate; // max rate in bytes/s
83 //int num_streams;
84 muxer_stream_t* def_v; // default video stream (for general headers)
85 muxer_stream_t* streams[MUXER_MAX_STREAMS];
86 // muxer frame buffer:
87 struct muxbuf_t * muxbuf;
88 int muxbuf_num;
89 int muxbuf_skip_buffer;
90 // functions:
91 stream_t *stream;
92 void (*fix_stream_parameters)(muxer_stream_t *);
93 void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int, double dts, double pts);
94 void (*cont_write_header)(struct muxer_t *);
95 void (*cont_write_index)(struct muxer_t *);
96 muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
97 void *priv;
98 } muxer_t;
100 /* muxer frame buffer */
101 typedef struct muxbuf_t {
102 muxer_stream_t *stream; /* pointer back to corresponding stream */
103 double dts; /* decode timestamp / time at which this packet should be feeded into the decoder */
104 double pts; /* presentation timestamp / time at which the data in this packet will be presented to the user */
105 unsigned char *buffer;
106 size_t len;
107 unsigned int flags;
108 } muxbuf_t;
110 extern char *force_fourcc;
112 muxer_t *muxer_new_muxer(int type,stream_t *stream);
113 #define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
114 #define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
115 void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts);
116 #define muxer_write_header(muxer) muxer->cont_write_header(muxer)
117 #define muxer_write_index(muxer) muxer->cont_write_index(muxer)
119 int muxer_init_muxer_avi(muxer_t *);
120 int muxer_init_muxer_mpeg(muxer_t *);
121 int muxer_init_muxer_rawvideo(muxer_t *);
122 int muxer_init_muxer_lavf(muxer_t *);
123 int muxer_init_muxer_rawaudio(muxer_t *);
125 #endif /* MPLAYER_MUXER_H */