2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Copyright (C) <2006> Nokia Corporation (contact <stefan.kost@nokia.com>)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __GST_AVI_DEMUX_H__
22 #define __GST_AVI_DEMUX_H__
27 #include "gst/riff/riff-ids.h"
28 #include "gst/riff/riff-read.h"
29 #include <gst/base/gstadapter.h>
39 #define GST_TYPE_AVI_DEMUX \
40 (gst_avi_demux_get_type ())
41 #define GST_AVI_DEMUX(obj) \
42 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_AVI_DEMUX, GstAviDemux))
43 #define GST_AVI_DEMUX_CLASS(klass) \
44 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_AVI_DEMUX, GstAviDemuxClass))
45 #define GST_IS_AVI_DEMUX(obj) \
46 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_AVI_DEMUX))
47 #define GST_IS_AVI_DEMUX_CLASS(klass) \
48 (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_AVI_DEMUX))
50 #define GST_AVI_DEMUX_MAX_STREAMS 16
52 #define AVIDEMUX_MODIFICATION
54 #define CHUNKID_TO_STREAMNR(chunkid) \
55 ((((chunkid) & 0xff) - '0') * 10 + \
56 (((chunkid) >> 8) & 0xff) - '0')
59 /* new index entries 24 bytes */
62 guint32 size; /* bytes of the data */
63 guint64 offset; /* data offset in file */
64 guint64 total; /* total bytes before */
68 /* index of this streamcontext */
75 /* stream info and headers */
78 gst_riff_strf_vids *vids;
79 gst_riff_strf_auds *auds;
80 gst_riff_strf_iavs *iavs;
83 GstBuffer *extradata, *initdata;
86 /* the start/step/stop entries */
91 #ifdef AVIDEMUX_MODIFICATION
95 guint32 total_samples_bet_2_keyframes;
96 GstClockTime avg_duration_bet_2_keyframes;
97 GstClockTime start_timestamp;
98 guint32 samples_to_show_bet_kframes;
99 guint32 audio_frame_count;
102 /* current index entry */
104 /* position (byte, frame, time) for current_entry */
106 GstClockTime current_timestamp;
107 GstClockTime current_ts_end;
108 guint64 current_offset;
109 guint64 current_offset_end;
111 GstFlowReturn last_flow;
116 guint32 total_blocks;
118 /* stream length according to index */
119 GstClockTime idx_duration;
120 /* stream length according to header */
121 GstClockTime hdr_duration;
122 /* stream length based on header/index */
123 GstClockTime duration;
128 /* openDML support (for files >4GB) */
133 GstAviIndexEntry *index; /* array with index entries */
134 guint idx_n; /* number of entries */
135 guint idx_max; /* max allocated size of entries */
144 GST_AVI_DEMUX_HEADER,
150 GST_AVI_DEMUX_HEADER_TAG_LIST,
151 GST_AVI_DEMUX_HEADER_AVIH,
152 GST_AVI_DEMUX_HEADER_ELEMENTS,
153 GST_AVI_DEMUX_HEADER_INFO,
154 GST_AVI_DEMUX_HEADER_JUNK,
155 GST_AVI_DEMUX_HEADER_DATA
156 } GstAviDemuxHeaderState;
158 typedef struct _GstAviDemux {
164 /* AVI decoding state */
165 GstAviDemuxState state;
166 GstAviDemuxHeaderState header_state;
168 gboolean abort_buffering;
170 /* when we loaded the indexes */
172 /* index offset in the file */
173 guint64 index_offset;
176 GstAviStream stream[GST_AVI_DEMUX_MAX_STREAMS];
180 guint num_t_streams; /* subtitle text streams */
182 guint main_stream; /* used for seeking */
184 /* for streaming mode */
190 /* some stream info for length */
192 GstClockTime duration;
194 /* segment in TIME */
196 gboolean segment_running;
198 /* pending tags/events */
200 GstEvent *close_seg_event;
201 GstTagList *globaltags;
204 /* gst index support */
205 GstIndex *element_index;
212 uint8_t* (*divx_init) (uint8_t*, int*);
213 int (*divx_commit) (uint8_t *);
214 int (*divx_decrypt_audio) (uint8_t *, uint8_t *, uint32_t);
215 int (*divx_prepare_video_bitstream) (uint8_t *, uint8_t * , uint32_t , uint8_t * , uint32_t * );
216 int (*divx_finalize) (uint8_t *);
219 guint64 first_movi_offset;
220 guint64 idx1_offset; /* offset in file of list/chunk after movi */
221 GstEvent *seek_event;
223 gboolean building_index;
226 guint64 *odml_subidxs;
228 guint64 seek_kf_offset; /* offset of the keyframe to which we want to seek */
231 typedef struct _GstAviDemuxClass {
232 GstElementClass parent_class;
235 GType gst_avi_demux_get_type (void);
239 #endif /* __GST_AVI_DEMUX_H__ */