sd_ass: initialize structs for external tracks properly
[mplayer.git] / libmpdemux / stheader.h
blob9c1efb23f1a50565acb72bfce578287fd1c42c9e
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 libav_codec_id; \
37 int initialized; \
38 /* number of seconds stream should be delayed \
39 * (according to dwStart or similar) */ \
40 float stream_delay; \
41 /* things needed for parsing */ \
42 bool needs_parsing; \
43 struct AVCodecContext *avctx; \
44 struct AVCodecParserContext *parser; \
45 /* audio: last known pts value in output from decoder \
46 * video: predicted/interpolated PTS of the current frame */ \
47 double pts; \
48 /* decoder context */ \
49 void *context; \
50 const char *codecname; \
51 char *lang; /* track language */ \
52 char *title; /* track title */ \
53 bool default_track; \
55 typedef struct sh_common {
56 SH_COMMON
57 } sh_common_t;
59 typedef struct sh_audio {
60 SH_COMMON
61 int aid;
62 // output format:
63 int sample_format;
64 int samplerate;
65 int container_out_samplerate;
66 int samplesize;
67 int channels;
68 int o_bps; // == samplerate*samplesize*channels (uncompr. bytes/sec)
69 int i_bps; // == bitrate (compressed bytes/sec)
70 // in buffers:
71 int audio_in_minsize; // initial size to allocate for a_in_buffer if any
72 char *a_in_buffer; // input buffer used by some decoders
73 int a_in_buffer_len;
74 int a_in_buffer_size;
75 // decoder buffers:
76 int audio_out_minsize; // minimal output from decoder may be this much
77 char *a_buffer; // buffer for decoder output
78 int a_buffer_len;
79 int a_buffer_size;
80 struct af_stream *afilter; // the audio filter stream
81 const struct ad_functions *ad_driver;
82 // win32-compatible codec parameters:
83 AVIStreamHeader audio;
84 WAVEFORMATEX *wf;
85 // note codec extradata may be either under "wf" or "codecdata"
86 unsigned char *codecdata;
87 int codecdata_len;
88 int pts_bytes; // bytes output by decoder after last known pts
89 } sh_audio_t;
91 typedef struct sh_video {
92 SH_COMMON
93 int vid;
94 float timer; // absolute time in video stream, since last start/seek
95 // frame counters:
96 float num_frames; // number of frames played
97 int num_frames_decoded; // number of frames decoded
98 double i_pts; // PTS for the _next_ I/P frame (internal mpeg demuxing)
99 float next_frame_time;
100 double last_pts;
101 double buffered_pts[32];
102 int num_buffered_pts;
103 double codec_reordered_pts;
104 double prev_codec_reordered_pts;
105 int num_reordered_pts_problems;
106 double sorted_pts;
107 double prev_sorted_pts;
108 int num_sorted_pts_problems;
109 int pts_assoc_mode;
110 // output format: (set by demuxer)
111 float fps; // frames per second (set only if constant fps)
112 float frametime; // 1/fps
113 float aspect; // aspect ratio stored in the file (for prescaling)
114 float stream_aspect; // aspect ratio in media headers (DVD IFO files)
115 int i_bps; // == bitrate (compressed bytes/sec)
116 int disp_w, disp_h; // display size (filled by demuxer)
117 int colorspace; // enum mp_csp
118 int color_range; // enum mp_csp_levels
119 // output driver/filters: (set by libmpcodecs core)
120 unsigned int outfmt;
121 unsigned int outfmtidx;
122 struct vf_instance *vfilter; // video filter chain
123 int output_flags; // query_format() results for output filters+vo
124 const struct vd_functions *vd_driver;
125 int vf_initialized; // -1 failed, 0 not done, 1 done
126 // win32-compatible codec parameters:
127 AVIStreamHeader video;
128 BITMAPINFOHEADER *bih;
129 void *ImageDesc; // for quicktime codecs
130 bool is_attached_pic;
131 } sh_video_t;
133 typedef struct sh_sub {
134 SH_COMMON
135 int sid;
136 char type; // t = text, v = VobSub, a = SSA/ASS, m, x, b, d, p
137 bool active; // after track switch decoder may stay initialized, not active
138 unsigned char *extradata; // extra header data passed from demuxer
139 int extradata_len;
140 const struct sd_functions *sd_driver;
141 } sh_sub_t;
143 // demuxer.c:
144 #define new_sh_audio(d, i) new_sh_audio_aid(d, i, i)
145 struct sh_audio *new_sh_audio_aid(struct demuxer *demuxer, int id, int aid);
146 #define new_sh_video(d, i) new_sh_video_vid(d, i, i)
147 struct sh_video *new_sh_video_vid(struct demuxer *demuxer, int id, int vid);
148 #define new_sh_sub(d, i) new_sh_sub_sid(d, i, i)
149 struct sh_sub *new_sh_sub_sid(struct demuxer *demuxer, int id, int sid);
150 struct sh_sub *new_sh_sub_sid_lang(struct demuxer *demuxer, int id, int sid,
151 const char *lang);
152 void free_sh_audio(struct demuxer *demuxer, int id);
153 void free_sh_video(struct sh_video *sh);
155 const char *sh_sub_type2str(int type);
157 // video.c:
158 int video_read_properties(struct sh_video *sh_video);
159 int video_read_frame(struct sh_video *sh_video, float *frame_time_ptr,
160 unsigned char **start, int force_fps);
162 #endif /* MPLAYER_STHEADER_H */