comparison 4xm.c @ 317:5cd41ae1debf libavformat

set frame rate information, for good measure
author melanson
date Sun, 16 Nov 2003 14:26:50 +0000
parents 9aa23c6d396e
children c152849ee643
comparison
equal deleted inserted replaced
316:9aa23c6d396e 317:5cd41ae1debf
84 int selected_track; 84 int selected_track;
85 85
86 int64_t audio_pts; 86 int64_t audio_pts;
87 int64_t video_pts; 87 int64_t video_pts;
88 int video_pts_inc; 88 int video_pts_inc;
89 float fps;
89 } FourxmDemuxContext; 90 } FourxmDemuxContext;
90 91
91 static float get_le_float(unsigned char *buffer) 92 static float get_le_float(unsigned char *buffer)
92 { 93 {
93 float f; 94 float f;
130 FourxmDemuxContext *fourxm = (FourxmDemuxContext *)s->priv_data; 131 FourxmDemuxContext *fourxm = (FourxmDemuxContext *)s->priv_data;
131 unsigned char *header; 132 unsigned char *header;
132 int i; 133 int i;
133 int current_track = -1; 134 int current_track = -1;
134 AVStream *st; 135 AVStream *st;
135 float fps;
136 136
137 fourxm->track_count = 0; 137 fourxm->track_count = 0;
138 fourxm->tracks = NULL; 138 fourxm->tracks = NULL;
139 fourxm->selected_track = 0; 139 fourxm->selected_track = 0;
140 fourxm->fps = 1.0;
140 141
141 /* skip the first 3 32-bit numbers */ 142 /* skip the first 3 32-bit numbers */
142 url_fseek(pb, 12, SEEK_CUR); 143 url_fseek(pb, 12, SEEK_CUR);
143 144
144 /* check for LIST-HEAD */ 145 /* check for LIST-HEAD */
158 for (i = 0; i < header_size - 8; i++) { 159 for (i = 0; i < header_size - 8; i++) {
159 fourcc_tag = LE_32(&header[i]); 160 fourcc_tag = LE_32(&header[i]);
160 size = LE_32(&header[i + 4]); 161 size = LE_32(&header[i + 4]);
161 162
162 if (fourcc_tag == std__TAG) { 163 if (fourcc_tag == std__TAG) {
163 fps = get_le_float(&header[i + 12]); 164 fourxm->fps = get_le_float(&header[i + 12]);
164 fourxm->video_pts_inc = (int)(90000.0 / fps); 165 fourxm->video_pts_inc = (int)(90000.0 / fourxm->fps);
165 } else if (fourcc_tag == vtrk_TAG) { 166 } else if (fourcc_tag == vtrk_TAG) {
166 /* check that there is enough data */ 167 /* check that there is enough data */
167 if (size != vtrk_SIZE) { 168 if (size != vtrk_SIZE) {
168 av_free(header); 169 av_free(header);
169 return AVERROR_INVALIDDATA; 170 return AVERROR_INVALIDDATA;
177 if (!st) 178 if (!st)
178 return AVERROR_NOMEM; 179 return AVERROR_NOMEM;
179 180
180 fourxm->video_stream_index = st->index; 181 fourxm->video_stream_index = st->index;
181 182
183 st->codec.frame_rate = fourxm->fps;
184 st->codec.frame_rate_base = 1.0;
182 st->codec.codec_type = CODEC_TYPE_VIDEO; 185 st->codec.codec_type = CODEC_TYPE_VIDEO;
183 st->codec.codec_id = CODEC_ID_4XM; 186 st->codec.codec_id = CODEC_ID_4XM;
184 st->codec.codec_tag = 0; /* no fourcc */ 187 st->codec.codec_tag = 0; /* no fourcc */
185 st->codec.width = fourxm->width; 188 st->codec.width = fourxm->width;
186 st->codec.height = fourxm->height; 189 st->codec.height = fourxm->height;