/* first is true if we read the frame header */
static int ffm_read_data(AVFormatContext *s,
- uint8_t *buf, int size, int first)
+ uint8_t *buf, int size, int header)
{
FFMContext *ffm = s->priv_data;
ByteIOContext *pb = s->pb;
return 0;
}
ffm->first_packet = 0;
- if ((frame_offset & 0x7ffff) < FFM_HEADER_SIZE)
+ if ((frame_offset & 0x7fff) < FFM_HEADER_SIZE)
return -1;
ffm->packet_ptr = ffm->packet + (frame_offset & 0x7fff) - FFM_HEADER_SIZE;
- if (!first)
+ if (!header)
break;
} else {
ffm->packet_ptr = ffm->packet;
buf += len;
ffm->packet_ptr += len;
size -= len;
- first = 0;
+ header = 0;
}
return size1 - size;
}
if (pos >= ffm->file_size)
pos -= (ffm->file_size - FFM_PACKET_SIZE);
#ifdef DEBUG_SEEK
- printf("seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
+ av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
#endif
url_fseek(pb, pos, SEEK_SET);
}
url_fskip(pb, 4);
pts = get_be64(pb);
#ifdef DEBUG_SEEK
- printf("pts=%0.6f\n", pts / 1000000.0);
+ av_log(s, AV_LOG_DEBUG, "pts=%0.6f\n", pts / 1000000.0);
#endif
return pts;
}
{
FFMContext *ffm = s->priv_data;
AVStream *st;
- FFMStream *fst;
ByteIOContext *pb = s->pb;
AVCodecContext *codec;
int i, nb_streams;
st = av_new_stream(s, 0);
if (!st)
goto fail;
- fst = av_mallocz(sizeof(FFMStream));
- if (!fst)
- goto fail;
s->streams[i] = st;
av_set_pts_info(st, 64, 1, 1000000);
- st->priv_data = fst;
-
codec = st->codec;
/* generic info */
codec->codec_id = get_be32(pb);
FRAME_HEADER_SIZE)
return AVERROR(EAGAIN);
#if 0
- {
- int i;
- for(i=0;i<FRAME_HEADER_SIZE;i++)
- printf("%02x ", ffm->header[i]);
- printf("\n");
- }
+ av_hexdump_log(s, AV_LOG_DEBUG, ffm->header, FRAME_HEADER_SIZE);
#endif
ffm->read_state = READ_DATA;
/* fall thru */
double pos1;
#ifdef DEBUG_SEEK
- printf("wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
+ av_log(s, AV_LOG_DEBUG, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0);
#endif
/* find the position using linear interpolation (better than
dichotomy in typical cases) */
pos -= FFM_PACKET_SIZE;
found:
ffm_seek1(s, pos);
+
+ /* reset read state */
+ ffm->read_state = READ_HEADER;
+ ffm->packet_ptr = ffm->packet;
+ ffm->packet_end = ffm->packet;
+ ffm->first_packet = 1;
+
return 0;
}
AVInputFormat ffm_demuxer = {
"ffm",
- "ffm format",
+ NULL_IF_CONFIG_SMALL("ffm format"),
sizeof(FFMContext),
ffm_probe,
ffm_read_header,