aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/mm.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2024-06-26 09:07:29 +0200
committerPeter Ross <pross@xvid.org>2024-12-08 09:32:35 +1100
commit8050a7955e37ddcf9f85004955db595f8b29f611 (patch)
tree5817ee8860a055cea8ee7e6081f27cc7531b9f80 /libavformat/mm.c
parent790270276225921b4d4a6e0c3ccc5fe42e9efd88 (diff)
downloadffmpeg-8050a7955e37ddcf9f85004955db595f8b29f611.tar.gz
avformat/mm: fix packets pts generation and add seek support
Signed-off-by: Peter Ross <pross@xvid.org>
Diffstat (limited to 'libavformat/mm.c')
-rw-r--r--libavformat/mm.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/libavformat/mm.c b/libavformat/mm.c
index 07ba6ac4f5..13717b3254 100644
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -58,10 +58,6 @@
#define MM_PALETTE_COUNT 128
#define MM_PALETTE_SIZE (MM_PALETTE_COUNT*3)
-typedef struct MmDemuxContext {
- unsigned int audio_pts, video_pts;
-} MmDemuxContext;
-
static int probe(const AVProbeData *p)
{
int len, type, fps, w, h;
@@ -88,7 +84,6 @@ static int probe(const AVProbeData *p)
static int read_header(AVFormatContext *s)
{
- MmDemuxContext *mm = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
@@ -133,30 +128,29 @@ static int read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, 1, 8000); /* 8000 hz */
}
- mm->audio_pts = 0;
- mm->video_pts = 0;
return 0;
}
static int read_packet(AVFormatContext *s,
AVPacket *pkt)
{
- MmDemuxContext *mm = s->priv_data;
AVIOContext *pb = s->pb;
unsigned char preamble[MM_PREAMBLE_SIZE];
unsigned int type, length;
+ int64_t pos = avio_tell(pb);
int ret;
- while(1) {
+ while (1) {
+ if (avio_feof(pb))
+ return AVERROR_EOF;
- if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE) {
+ if (avio_read(pb, preamble, MM_PREAMBLE_SIZE) != MM_PREAMBLE_SIZE)
return AVERROR(EIO);
- }
type = AV_RL16(&preamble[0]);
length = AV_RL16(&preamble[2]);
- switch(type) {
+ switch (type) {
case MM_TYPE_RAW :
case MM_TYPE_PALETTE :
case MM_TYPE_INTER :
@@ -173,9 +167,12 @@ static int read_packet(AVFormatContext *s,
return AVERROR(EIO);
pkt->size = length + MM_PREAMBLE_SIZE;
pkt->stream_index = 0;
- pkt->pts = mm->video_pts;
if (type!=MM_TYPE_PALETTE)
- mm->video_pts++;
+ pkt->duration = 1;
+ if (type == MM_TYPE_RAW ||
+ type == MM_TYPE_INTRA)
+ pkt->flags |= AV_PKT_FLAG_KEY;
+ pkt->pos = pos;
return 0;
case MM_TYPE_AUDIO :
@@ -184,8 +181,8 @@ static int read_packet(AVFormatContext *s,
if ((ret = av_get_packet(s->pb, pkt, length)) < 0)
return ret;
pkt->stream_index = 1;
- pkt->pts = mm->audio_pts;
- mm->audio_pts += length;
+ pkt->duration = length;
+ pkt->pos = pos;
return 0;
default :
@@ -200,7 +197,7 @@ static int read_packet(AVFormatContext *s,
const FFInputFormat ff_mm_demuxer = {
.p.name = "mm",
.p.long_name = NULL_IF_CONFIG_SMALL("American Laser Games MM"),
- .priv_data_size = sizeof(MmDemuxContext),
+ .p.flags = AVFMT_GENERIC_INDEX,
.read_probe = probe,
.read_header = read_header,
.read_packet = read_packet,