options: support parsing values into substructs
[mplayer.git] / libmpdemux / stheader.h
blob06f52324e59e60eac60f173434392cac288557b2
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_STHEADER_H
20 #define MPLAYER_STHEADER_H
22 #include <stdbool.h>
24 #include "aviheader.h"
25 #include "ms_hdr.h"
26 struct MPOpts;
27 struct demuxer;
29 // Stream headers:
31 #define SH_COMMON \
32 struct MPOpts *opts; \
33 struct demux_stream *ds; \
34 struct codecs *codec; \
35 unsigned int format; \
36 int initialized; \
37 /* number of seconds stream should be delayed \
38 * (according to dwStart or similar) */ \
39 float stream_delay; \
40 /* things needed for parsing */ \
41 bool needs_parsing; \
42 struct AVCodecContext *avctx; \
43 struct AVCodecParserContext *parser; \
44 /* audio: last known pts value in output from decoder \
45 * video: predicted/interpolated PTS of the current frame */ \
46 double pts; \
47 /* decoder context */ \
48 void *context; \
49 char *lang; /* track language */ \
50 char *title; /* track title */ \
51 bool default_track; \
53 typedef struct sh_common {
54 SH_COMMON
55 } sh_common_t;
57 typedef struct sh_audio {
58 SH_COMMON
59 int aid;
60 // output format:
61 int sample_format;
62 int samplerate;
63 int container_out_samplerate;
64 int samplesize;
65 int channels;
66 int o_bps; // == samplerate*samplesize*channels (uncompr. bytes/sec)
67 int i_bps; // == bitrate (compressed bytes/sec)
68 // in buffers:
69 int audio_in_minsize; // initial size to allocate for a_in_buffer if any
70 char *a_in_buffer; // input buffer used by some decoders
71 int a_in_buffer_len;
72 int a_in_buffer_size;
73 // decoder buffers:
74 int audio_out_minsize; // minimal output from decoder may be this much
75 char *a_buffer; // buffer for decoder output
76 int a_buffer_len;
77 int a_buffer_size;
78 struct af_stream *afilter; // the audio filter stream
79 const struct ad_functions *ad_driver;
80 // win32-compatible codec parameters:
81 AVIStreamHeader audio;
82 WAVEFORMATEX *wf;
83 // note codec extradata may be either under "wf" or "codecdata"
84 unsigned char *codecdata;
85 int codecdata_len;
86 int pts_bytes; // bytes output by decoder after last known pts
87 } sh_audio_t;
89 typedef struct sh_video {
90 SH_COMMON
91 int vid;
92 float timer; // absolute time in video stream, since last start/seek
93 // frame counters:
94 float num_frames; // number of frames played
95 int num_frames_decoded; // number of frames decoded
96 double i_pts; // PTS for the _next_ I/P frame (internal mpeg demuxing)
97 float next_frame_time;
98 double last_pts;
99 double buffered_pts[32];
100 int num_buffered_pts;
101 double codec_reordered_pts;
102 double prev_codec_reordered_pts;
103 int num_reordered_pts_problems;
104 double sorted_pts;
105 double prev_sorted_pts;
106 int num_sorted_pts_problems;
107 int pts_assoc_mode;
108 // output format: (set by demuxer)
109 float fps; // frames per second (set only if constant fps)
110 float frametime; // 1/fps
111 float aspect; // aspect ratio stored in the file (for prescaling)
112 float stream_aspect; // aspect ratio in media headers (DVD IFO files)
113 int i_bps; // == bitrate (compressed bytes/sec)
114 int disp_w, disp_h; // display size (filled by demuxer)
115 // output driver/filters: (set by libmpcodecs core)
116 unsigned int outfmt;
117 unsigned int outfmtidx;
118 struct vf_instance *vfilter; // video filter chain
119 int output_flags; // query_format() results for output filters+vo
120 const struct vd_functions *vd_driver;
121 int vf_initialized; // -1 failed, 0 not done, 1 done
122 // win32-compatible codec parameters:
123 AVIStreamHeader video;
124 BITMAPINFOHEADER *bih;
125 void *ImageDesc; // for quicktime codecs
126 } sh_video_t;
128 typedef struct sh_sub {
129 SH_COMMON
130 int sid;
131 char type; // t = text, v = VobSub, a = SSA/ASS, m, x, b, d, p
132 bool active; // after track switch decoder may stay initialized, not active
133 unsigned char *extradata; // extra header data passed from demuxer
134 int extradata_len;
135 const struct sd_functions *sd_driver;
136 } sh_sub_t;
138 // demuxer.c:
139 #define new_sh_audio(d, i) new_sh_audio_aid(d, i, i)
140 struct sh_audio *new_sh_audio_aid(struct demuxer *demuxer, int id, int aid);
141 #define new_sh_video(d, i) new_sh_video_vid(d, i, i)
142 struct sh_video *new_sh_video_vid(struct demuxer *demuxer, int id, int vid);
143 #define new_sh_sub(d, i) new_sh_sub_sid(d, i, i)
144 struct sh_sub *new_sh_sub_sid(struct demuxer *demuxer, int id, int sid);
145 struct sh_sub *new_sh_sub_sid_lang(struct demuxer *demuxer, int id, int sid,
146 const char *lang);
147 void free_sh_audio(struct demuxer *demuxer, int id);
148 void free_sh_video(struct sh_video *sh);
150 const char *sh_sub_type2str(int type);
152 // video.c:
153 int video_read_properties(struct sh_video *sh_video);
154 int video_read_frame(struct sh_video *sh_video, float *frame_time_ptr,
155 unsigned char **start, int force_fps);
157 #endif /* MPLAYER_STHEADER_H */