1 /* 2 * This file is part of MPlayer. 3 * 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. 8 * 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. 13 * 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. 17 */ 18 19 #ifndef MPLAYER_STHEADER_H 20 #define MPLAYER_STHEADER_H 21 22 #include "demuxer.h" 23 #include "aviheader.h" 24 #include "ms_hdr.h" 25 26 // Stream headers: 27 28 #define SH_COMMON \ 29 demux_stream_t *ds; \ 30 struct codecs *codec; \ 31 unsigned int format; \ 32 int initialized; \ 33 float stream_delay; /* number of seconds stream should be delayed (according to dwStart or similar) */ \ 34 /* things needed for parsing */ \ 35 int needs_parsing; \ 36 struct AVCodecContext *avctx; \ 37 struct AVCodecParserContext *parser; \ 38 /* audio: last known pts value in output from decoder \ 39 * video: predicted/interpolated PTS of the current frame */ \ 40 double pts; \ 41 double endpts; \ 42 /* codec-specific: */ \ 43 void* context; /* codec-specific stuff (usually HANDLE or struct pointer) */ \ 44 char* lang; /* track language */ \ 45 int default_track; \ 46 47 typedef struct sh_common { 48 SH_COMMON 49 } sh_common_t; 50 51 typedef struct sh_audio { 52 SH_COMMON 53 int aid; 54 // output format: 55 int sample_format; 56 int samplerate; 57 int samplesize; 58 int channels; 59 int channel_layout; 60 int o_bps; // == samplerate*samplesize*channels (uncompr. bytes/sec) 61 int i_bps; // == bitrate (compressed bytes/sec) 62 // in buffers: 63 int audio_in_minsize; // max. compressed packet size (== min. in buffer size) 64 char* a_in_buffer; 65 int a_in_buffer_len; 66 int a_in_buffer_size; 67 // decoder buffers: 68 int audio_out_minsize; // max. uncompressed packet size (==min. out buffsize) 69 char* a_buffer; 70 int a_buffer_len; 71 int a_buffer_size; 72 int a_buffer_format_change; // audio data in the input buffer is subject 73 // to a format change but data in the old 74 // format is still present in the out buffer 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; 93 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[64]; 106 double buffered_endpts[64]; 107 int num_buffered_pts; 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; // current aspect ratio (for prescaling) 112 float original_aspect; // original aspect ratio stored in the file 113 float stream_aspect; // aspect ratio stored in the media headers (e.g. in DVD IFO files) 114 int i_bps; // == bitrate (compressed bytes/sec) 115 int disp_w,disp_h; // display size (filled by fileformat parser) 116 int flipped_input; 117 // output driver/filters: (set by libmpcodecs core) 118 unsigned int outfmtidx; 119 struct vf_instance *vfilter; // the video filter chain, used for this video stream 120 int vf_initialized; 121 #ifdef CONFIG_DYNAMIC_PLUGINS 122 void *dec_handle; 123 #endif 124 // win32-compatible codec parameters: 125 AVIStreamHeader video; 126 BITMAPINFOHEADER* bih; 127 int bih_size; 128 void* ImageDesc; // for quicktime codecs 129 } sh_video_t; 130 131 typedef struct sh_sub { 132 SH_COMMON 133 int sid; 134 char type; // t = text, v = VobSub, a = SSA/ASS 135 unsigned char* extradata; // extra header data passed from demuxer 136 int extradata_len; 137 #ifdef CONFIG_ASS 138 ASS_Track* ass_track; // for SSA/ASS streams (type == 'a') 139 #endif 140 } sh_sub_t; 141 142 // demuxer.c: 143 #define new_sh_audio(d, i, l) new_sh_audio_aid(d, i, i, l) 144 sh_audio_t* new_sh_audio_aid(demuxer_t *demuxer,int id,int aid, const char *lang); 145 #define new_sh_video(d, i) new_sh_video_vid(d, i, i) 146 sh_video_t* new_sh_video_vid(demuxer_t *demuxer,int id,int vid); 147 #define new_sh_sub(d, i, l) new_sh_sub_sid(d, i, i, l) 148 sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid, const char *lang); 149 void free_sh_audio(demuxer_t *demuxer, int id); 150 void free_sh_video(sh_video_t *sh); 151 152 const char *sh_sub_type2str(int type); 153 154 // video.c: 155 int video_read_properties(sh_video_t *sh_video); 156 int video_read_frame(sh_video_t* sh_video,float* frame_time_ptr,unsigned char** start,int force_fps); 157 158 #endif /* MPLAYER_STHEADER_H */ 159