FFMStream *fst = st->priv_data;
int64_t pts;
uint8_t header[FRAME_HEADER_SIZE];
- int duration;
int size= pkt->size;
- //XXX/FIXME use duration from pkt
- if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
- duration = ((float)st->codec->frame_size / st->codec->sample_rate * 1000000.0);
- } else {
- duration = (1000000.0 * st->codec->time_base.num / (float)st->codec->time_base.den);
- }
-
pts = fst->pts;
/* packet size & key_frame */
header[0] = pkt->stream_index;
header[1] = 0;
if (pkt->flags & PKT_FLAG_KEY)
header[1] |= FLAG_KEY_FRAME;
- header[2] = (size >> 16) & 0xff;
- header[3] = (size >> 8) & 0xff;
- header[4] = size & 0xff;
- header[5] = (duration >> 16) & 0xff;
- header[6] = (duration >> 8) & 0xff;
- header[7] = duration & 0xff;
+ AV_WB24(header+2, size);
+ AV_WB24(header+5, pkt->duration);
ffm_write_data(s, header, FRAME_HEADER_SIZE, pts, 1);
ffm_write_data(s, pkt->data, size, pts, 0);
av_new_packet(pkt, size);
pkt->stream_index = ffm->header[0];
+ if ((unsigned)pkt->stream_index >= s->nb_streams) {
+ av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
+ av_free_packet(pkt);
+ ffm->read_state = READ_HEADER;
+ return AVERROR(EAGAIN);
+ }
pkt->pos = url_ftell(s->pb);
if (ffm->header[1] & FLAG_KEY_FRAME)
pkt->flags |= PKT_FLAG_KEY;
}
/* seek to a given time in the file. The file read pointer is
- positionned at or before pts. XXX: the following code is quite
+ positioned at or before pts. XXX: the following code is quite
approximative */
static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags)
{