aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mmf.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-12-03 18:26:43 +0000
committerPaul B Mahol <onemda@gmail.com>2012-12-06 11:56:00 +0000
commit3bb3cddd96d3aae6909be710652ee6f5c4638a65 (patch)
tree219051969e96ff30fdc98167bba215ec860db5d0 /libavformat/mmf.c
parent1e85fd6a479ca987f8a3720018a63b359068d379 (diff)
downloadffmpeg-3bb3cddd96d3aae6909be710652ee6f5c4638a65.tar.gz
mmfdec: fix seeking
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavformat/mmf.c')
-rw-r--r--libavformat/mmf.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 4aada19ac7..46705acb21 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -28,7 +28,7 @@
typedef struct {
int64_t atrpos, atsqpos, awapos;
- int64_t data_size;
+ int64_t data_end;
} MMFContext;
static const int mmf_rates[] = { 4000, 8000, 11025, 22050, 44100 };
@@ -241,7 +241,7 @@ static int mmf_read_header(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "Unexpected SMAF chunk %08x\n", tag);
return AVERROR_INVALIDDATA;
}
- mmf->data_size = size;
+ mmf->data_end = avio_tell(pb) + size;
st = avformat_new_stream(s, NULL);
if (!st)
@@ -266,19 +266,19 @@ static int mmf_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
MMFContext *mmf = s->priv_data;
- int ret, size;
+ int64_t left, size;
+ int ret;
- if (url_feof(s->pb) || !mmf->data_size)
+ left = mmf->data_end - avio_tell(s->pb);
+ size = FFMIN(left, MAX_SIZE);
+ if (url_feof(s->pb) || size <= 0)
return AVERROR_EOF;
- size = FFMIN(MAX_SIZE, mmf->data_size);
-
ret = av_get_packet(s->pb, pkt, size);
if (ret < 0)
return ret;
pkt->stream_index = 0;
- mmf->data_size -= ret;
return ret;
}
@@ -291,7 +291,7 @@ AVInputFormat ff_mmf_demuxer = {
.read_probe = mmf_probe,
.read_header = mmf_read_header,
.read_packet = mmf_read_packet,
- .read_seek = ff_pcm_read_seek,
+ .flags = AVFMT_GENERIC_INDEX,
};
#endif
#if CONFIG_MMF_MUXER