Mercurial > libavformat.hg
comparison ffm.c @ 85:25062c9b1f86 libavformat
per context frame_rate_base, this should finally fix frame_rate related av sync issues
author | michaelni |
---|---|
date | Wed, 12 Mar 2003 15:16:19 +0000 |
parents | 8bdaec4e3e4b |
children | 2fa5e94ba716 |
comparison
equal
deleted
inserted
replaced
84:0068a6902911 | 85:25062c9b1f86 |
---|---|
138 } | 138 } |
139 put_be32(pb, bit_rate); | 139 put_be32(pb, bit_rate); |
140 | 140 |
141 /* list of streams */ | 141 /* list of streams */ |
142 for(i=0;i<s->nb_streams;i++) { | 142 for(i=0;i<s->nb_streams;i++) { |
143 int gcd; | |
144 | |
145 st = s->streams[i]; | 143 st = s->streams[i]; |
146 fst = av_mallocz(sizeof(FFMStream)); | 144 fst = av_mallocz(sizeof(FFMStream)); |
147 if (!fst) | 145 if (!fst) |
148 goto fail; | 146 goto fail; |
149 st->priv_data = fst; | 147 st->priv_data = fst; |
156 put_be32(pb, st->quality); | 154 put_be32(pb, st->quality); |
157 put_be32(pb, codec->flags); | 155 put_be32(pb, codec->flags); |
158 /* specific info */ | 156 /* specific info */ |
159 switch(codec->codec_type) { | 157 switch(codec->codec_type) { |
160 case CODEC_TYPE_VIDEO: | 158 case CODEC_TYPE_VIDEO: |
161 gcd= av_gcd(FRAME_RATE_BASE, codec->frame_rate); | 159 put_be32(pb, codec->frame_rate_base); |
162 put_be32(pb, FRAME_RATE_BASE / gcd); | 160 put_be32(pb, codec->frame_rate); |
163 put_be32(pb, codec->frame_rate / gcd); | |
164 put_be16(pb, codec->width); | 161 put_be16(pb, codec->width); |
165 put_be16(pb, codec->height); | 162 put_be16(pb, codec->height); |
166 put_be16(pb, codec->gop_size); | 163 put_be16(pb, codec->gop_size); |
167 put_byte(pb, codec->qmin); | 164 put_byte(pb, codec->qmin); |
168 put_byte(pb, codec->qmax); | 165 put_byte(pb, codec->qmax); |
227 int duration; | 224 int duration; |
228 | 225 |
229 if (st->codec.codec_type == CODEC_TYPE_AUDIO) { | 226 if (st->codec.codec_type == CODEC_TYPE_AUDIO) { |
230 duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); | 227 duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); |
231 } else { | 228 } else { |
232 duration = (1000000.0 * FRAME_RATE_BASE / (float)st->codec.frame_rate); | 229 duration = (1000000.0 * st->codec.frame_rate_base / (float)st->codec.frame_rate); |
233 } | 230 } |
234 | 231 |
235 pts = fst->pts; | 232 pts = fst->pts; |
236 /* packet size & key_frame */ | 233 /* packet size & key_frame */ |
237 header[0] = stream_index; | 234 header[0] = stream_index; |
392 s->nb_streams = get_be32(pb); | 389 s->nb_streams = get_be32(pb); |
393 get_be32(pb); /* total bitrate */ | 390 get_be32(pb); /* total bitrate */ |
394 /* read each stream */ | 391 /* read each stream */ |
395 for(i=0;i<s->nb_streams;i++) { | 392 for(i=0;i<s->nb_streams;i++) { |
396 char rc_eq_buf[128]; | 393 char rc_eq_buf[128]; |
397 int rate, scale; | |
398 | 394 |
399 st = av_mallocz(sizeof(AVStream)); | 395 st = av_mallocz(sizeof(AVStream)); |
400 if (!st) | 396 if (!st) |
401 goto fail; | 397 goto fail; |
402 avcodec_get_context_defaults(&st->codec); | 398 avcodec_get_context_defaults(&st->codec); |
414 st->quality = get_be32(pb); | 410 st->quality = get_be32(pb); |
415 codec->flags = get_be32(pb); | 411 codec->flags = get_be32(pb); |
416 /* specific info */ | 412 /* specific info */ |
417 switch(codec->codec_type) { | 413 switch(codec->codec_type) { |
418 case CODEC_TYPE_VIDEO: | 414 case CODEC_TYPE_VIDEO: |
419 scale= get_be32(pb); | 415 codec->frame_rate_base = get_be32(pb); |
420 rate= get_be32(pb); | 416 codec->frame_rate = get_be32(pb); |
421 codec->frame_rate = (rate * (int64_t)FRAME_RATE_BASE) / scale; | |
422 codec->width = get_be16(pb); | 417 codec->width = get_be16(pb); |
423 codec->height = get_be16(pb); | 418 codec->height = get_be16(pb); |
424 codec->gop_size = get_be16(pb); | 419 codec->gop_size = get_be16(pb); |
425 codec->qmin = get_byte(pb); | 420 codec->qmin = get_byte(pb); |
426 codec->qmax = get_byte(pb); | 421 codec->qmax = get_byte(pb); |