annotate libmpdemux/muxer.h @ 33514:30e54bd66d39

vobsub: simplify origin parsing.
author cboesch
date Sun, 12 Jun 2011 10:56:03 +0000
parents 801dc49c6f33
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29238
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
1 /*
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
2 * This file is part of MPlayer.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
3 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
5 * it under the terms of the GNU General Public License as published by
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
7 * (at your option) any later version.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
8 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
12 * GNU General Public License for more details.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
13 *
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
14 * You should have received a copy of the GNU General Public License along
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
17 */
d643e4643313 Add standard license header to all files in libmpdemux.
diego
parents: 26143
diff changeset
18
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25553
diff changeset
19 #ifndef MPLAYER_MUXER_H
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25553
diff changeset
20 #define MPLAYER_MUXER_H
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
21
26143
268ecf0e1ba4 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
22 #include <stdint.h>
268ecf0e1ba4 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
23 #include <sys/types.h>
268ecf0e1ba4 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
24 #include "aviheader.h"
31452
435530ed1a33 Move lavfopts_conf/mpegopts_conf/nuvopts_conf extern declarations to muxer.h.
diego
parents: 29238
diff changeset
25 #include "m_option.h"
26143
268ecf0e1ba4 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
26 #include "ms_hdr.h"
268ecf0e1ba4 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
27 #include "stream/stream.h"
268ecf0e1ba4 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
28
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
29 #define MUXER_MAX_STREAMS 16
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
30
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
31 #define MUXER_TYPE_VIDEO 0
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
32 #define MUXER_TYPE_AUDIO 1
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
33
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
34 #define MUXER_TYPE_AVI 0
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
35 #define MUXER_TYPE_MPEG 1
12016
b962aaad2940 rawvideo muxer patch by John Earl <jwe21@cam.ac.uk>
ranma
parents: 11222
diff changeset
36 #define MUXER_TYPE_RAWVIDEO 2
14757
7a2adc5e8928 initial, extremely experimental, libavformat muxer; don't expect anything to work yet
nicodvb
parents: 14753
diff changeset
37 #define MUXER_TYPE_LAVF 3
15754
7b0599d9614a rawaudio muxer
ranma
parents: 14955
diff changeset
38 #define MUXER_TYPE_RAWAUDIO 4
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
39
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
40
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
41 typedef struct {
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
42 // muxer data:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
43 int type; // audio or video
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
44 int id; // stream no
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
45 uint32_t ckid; // chunk id (00dc 01wb etc)
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
46 double timer;
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 2652
diff changeset
47 off_t size;
12061
656a1b45b309 Use aspect from encoder for AVI vprp header
ranma
parents: 12036
diff changeset
48 float aspect; // aspect ratio of this stream (set by ve_*.c)
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
49 // buffering:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
50 unsigned char *buffer;
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
51 unsigned int buffer_size;
2592
2efa0d20e4c4 buffer_len added
arpi
parents: 2529
diff changeset
52 unsigned int buffer_len;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
53 // mpeg block buffer:
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
54 unsigned char *b_buffer;
14753
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
55 unsigned int b_buffer_size; //size of b_buffer
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
56 unsigned int b_buffer_ptr; //index to next data to write
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
57 unsigned int b_buffer_len; //len of next data to write
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
58 // muxer frame buffer:
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
59 unsigned int muxbuf_seen;
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
60 // source stream:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
61 void* source; // sh_audio or sh_video
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
62 int codec; // codec used for encoding. 0 means copy
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
63 // avi stream header:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
64 AVIStreamHeader h; // Rate/Scale and SampleSize must be filled by caller!
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
65 // stream specific:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
66 WAVEFORMATEX *wf;
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
67 BITMAPINFOHEADER *bih; // in format
17660
fbff80473a6d Fix video delay when encoding with B-frames.
corey
parents: 17648
diff changeset
68 int encoder_delay; // in number of frames
fbff80473a6d Fix video delay when encoding with B-frames.
corey
parents: 17648
diff changeset
69 int decoder_delay; // in number of frames
23308
f63408f61f0f Add imgfmt (AKA pixel format) to muxer_stream_t so that encoders can
corey
parents: 21960
diff changeset
70 int imgfmt;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
71 // mpeg specific:
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
72 size_t ipb[3]; // sizes of I/P/B frames
9007
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
73 // muxer of that stream
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
74 struct muxer_t *muxer;
11222
b82e3ecb11e0 some updates in muxer api
alex
parents: 9007
diff changeset
75 void *priv; // private stream specific data stored by the muxer
17480
3993a5fad89a pass vbv_size & max_rate from encoder to muxer over muxer_stream_t (if this is wrong/silly/10000000l then dont hesitate to flame / reverse)
michael
parents: 17023
diff changeset
76
3993a5fad89a pass vbv_size & max_rate from encoder to muxer over muxer_stream_t (if this is wrong/silly/10000000l then dont hesitate to flame / reverse)
michael
parents: 17023
diff changeset
77 int vbv_size;
3993a5fad89a pass vbv_size & max_rate from encoder to muxer over muxer_stream_t (if this is wrong/silly/10000000l then dont hesitate to flame / reverse)
michael
parents: 17023
diff changeset
78 int max_rate;
19360
d4d72e5eea07 pass average bitrate from encoder to (lavf) muxer
michael
parents: 18241
diff changeset
79 int avg_rate;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
80 } muxer_stream_t;
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
81
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
82 typedef struct {
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
83 uint32_t id;
7145
3854945aefbb new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents: 5572
diff changeset
84 char *text;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
85 } muxer_info_t;
7145
3854945aefbb new mencoder option -info, to store copyright, title, encoder version etc in AVI
arpi
parents: 5572
diff changeset
86
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
87 typedef struct muxer_t{
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
88 // encoding:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
89 MainAVIHeader avih;
12036
846ed866f86c OpenDML read/write support
ranma
parents: 12016
diff changeset
90 off_t movi_start;
846ed866f86c OpenDML read/write support
ranma
parents: 12016
diff changeset
91 off_t movi_end;
846ed866f86c OpenDML read/write support
ranma
parents: 12016
diff changeset
92 off_t file_end; // for MPEG it's system timestamp in 1/90000 s
17648
5963b50c2178 dwStart support for mencoder.
corey
parents: 17487
diff changeset
93 float audio_delay_fix;
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
94 // index:
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
95 AVIINDEXENTRY *idx;
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
96 int idx_pos;
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
97 int idx_size;
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
98 // streams:
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
99 int num_videos; // for MPEG recalculations
14753
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
100 int num_audios;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
101 unsigned int sysrate; // max rate in bytes/s
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
102 //int num_streams;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
103 muxer_stream_t* def_v; // default video stream (for general headers)
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
104 muxer_stream_t* streams[MUXER_MAX_STREAMS];
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
105 // muxer frame buffer:
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
106 struct muxbuf_t * muxbuf;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
107 int muxbuf_num;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
108 int muxbuf_skip_buffer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
109 // functions:
21660
ca9da45d13e9 muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents: 19360
diff changeset
110 stream_t *stream;
14753
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
111 void (*fix_stream_parameters)(muxer_stream_t *);
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17480
diff changeset
112 void (*cont_write_chunk)(muxer_stream_t *,size_t,unsigned int, double dts, double pts);
9007
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
113 void (*cont_write_header)(struct muxer_t *);
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
114 void (*cont_write_index)(struct muxer_t *);
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
115 muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int);
14753
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
116 void *priv;
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
117 } muxer_t;
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
118
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
119 /* muxer frame buffer */
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
120 typedef struct muxbuf_t {
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
121 muxer_stream_t *stream; /* pointer back to corresponding stream */
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17480
diff changeset
122 double dts; /* decode timestamp / time at which this packet should be feeded into the decoder */
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17480
diff changeset
123 double pts; /* presentation timestamp / time at which the data in this packet will be presented to the user */
17023
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
124 unsigned char *buffer;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
125 size_t len;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
126 unsigned int flags;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
127 } muxbuf_t;
dd5be8f8d16d buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents: 15754
diff changeset
128
21960
0b4d2b0e8722 support -ffourcc with -of lavf
reimar
parents: 21660
diff changeset
129 extern char *force_fourcc;
0b4d2b0e8722 support -ffourcc with -of lavf
reimar
parents: 21660
diff changeset
130
31452
435530ed1a33 Move lavfopts_conf/mpegopts_conf/nuvopts_conf extern declarations to muxer.h.
diego
parents: 29238
diff changeset
131 extern const m_option_t lavfopts_conf[];
435530ed1a33 Move lavfopts_conf/mpegopts_conf/nuvopts_conf extern declarations to muxer.h.
diego
parents: 29238
diff changeset
132 extern const m_option_t mpegopts_conf[];
435530ed1a33 Move lavfopts_conf/mpegopts_conf/nuvopts_conf extern declarations to muxer.h.
diego
parents: 29238
diff changeset
133 extern const m_option_t nuvopts_conf[];
435530ed1a33 Move lavfopts_conf/mpegopts_conf/nuvopts_conf extern declarations to muxer.h.
diego
parents: 29238
diff changeset
134
21660
ca9da45d13e9 muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents: 19360
diff changeset
135 muxer_t *muxer_new_muxer(int type,stream_t *stream);
32795
801dc49c6f33 Fix muxer memory leak.
ranma
parents: 31452
diff changeset
136 void muxer_flush(muxer_t *m);
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 7145
diff changeset
137 #define muxer_new_stream(muxer,a) muxer->cont_new_stream(muxer,a)
14753
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
138 #define muxer_stream_fix_parameters(muxer, a) muxer->fix_stream_parameters(a)
17487
fa17424b4c7b change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents: 17480
diff changeset
139 void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts);
9007
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
140 #define muxer_write_header(muxer) muxer->cont_write_header(muxer)
12fc55eb3373 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8585
diff changeset
141 #define muxer_write_index(muxer) muxer->cont_write_index(muxer)
2529
266dab71162b AVI muxer rewritten
arpi
parents:
diff changeset
142
14753
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
143 int muxer_init_muxer_avi(muxer_t *);
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
144 int muxer_init_muxer_mpeg(muxer_t *);
70c446099f40 new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents: 12061
diff changeset
145 int muxer_init_muxer_rawvideo(muxer_t *);
14955
081167e3d000 missing declaration, fixes:
rathann
parents: 14757
diff changeset
146 int muxer_init_muxer_lavf(muxer_t *);
15754
7b0599d9614a rawaudio muxer
ranma
parents: 14955
diff changeset
147 int muxer_init_muxer_rawaudio(muxer_t *);
25553
6ac1ece1f9fe Add multiple inclusion guards to all header files that lack them.
diego
parents: 23308
diff changeset
148
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25553
diff changeset
149 #endif /* MPLAYER_MUXER_H */