iff: support seeking with maud
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
3174137d41
commit
7f7f31bfcb
@ -93,9 +93,9 @@ typedef enum {
|
|||||||
} svx8_compression_type;
|
} svx8_compression_type;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t body_pos;
|
int64_t body_pos;
|
||||||
|
int64_t body_end;
|
||||||
uint32_t body_size;
|
uint32_t body_size;
|
||||||
uint32_t sent_bytes;
|
|
||||||
svx8_compression_type svx8_compression;
|
svx8_compression_type svx8_compression;
|
||||||
unsigned maud_bits;
|
unsigned maud_bits;
|
||||||
unsigned maud_compression;
|
unsigned maud_compression;
|
||||||
@ -227,6 +227,7 @@ static int iff_read_header(AVFormatContext *s)
|
|||||||
case ID_DBOD:
|
case ID_DBOD:
|
||||||
case ID_MDAT:
|
case ID_MDAT:
|
||||||
iff->body_pos = avio_tell(pb);
|
iff->body_pos = avio_tell(pb);
|
||||||
|
iff->body_end = iff->body_pos + data_size;
|
||||||
iff->body_size = data_size;
|
iff->body_size = data_size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -434,14 +435,14 @@ static int iff_read_packet(AVFormatContext *s,
|
|||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
AVStream *st = s->streams[0];
|
AVStream *st = s->streams[0];
|
||||||
int ret;
|
int ret;
|
||||||
|
int64_t pos = avio_tell(pb);
|
||||||
|
|
||||||
if(iff->sent_bytes >= iff->body_size)
|
if (pos >= iff->body_end)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
|
||||||
if (st->codec->codec_tag == ID_MAUD) {
|
if (st->codec->codec_tag == ID_MAUD) {
|
||||||
ret = av_get_packet(pb, pkt,
|
ret = av_get_packet(pb, pkt, FFMIN(iff->body_end - pos, 1024 * st->codec->block_align));
|
||||||
FFMIN(iff->body_size - iff->sent_bytes, 1024 * st->codec->block_align));
|
|
||||||
} else {
|
} else {
|
||||||
ret = av_get_packet(pb, pkt, iff->body_size);
|
ret = av_get_packet(pb, pkt, iff->body_size);
|
||||||
}
|
}
|
||||||
@ -459,11 +460,10 @@ static int iff_read_packet(AVFormatContext *s,
|
|||||||
av_assert0(0);
|
av_assert0(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(iff->sent_bytes == 0)
|
if (pos == iff->body_pos)
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
iff->sent_bytes += ret;
|
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -475,4 +475,5 @@ AVInputFormat ff_iff_demuxer = {
|
|||||||
.read_probe = iff_probe,
|
.read_probe = iff_probe,
|
||||||
.read_header = iff_read_header,
|
.read_header = iff_read_header,
|
||||||
.read_packet = iff_read_packet,
|
.read_packet = iff_read_packet,
|
||||||
|
.flags = AVFMT_GENERIC_INDEX,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user