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