#include "avformat.h"
/* For codec_get_bmp_id and codec_get_wav_id. */
-#include "avi.h"
+#include "riff.h"
#include "intfloat_readwrite.h"
/* EBML version supported */
*/
typedef struct CodecTags{
- char *str;
+ const char *str;
enum CodecID id;
}CodecTags;
#define MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC "V_MS/VFW/FOURCC"
#define MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM"
-CodecTags codec_tags[]={
+static CodecTags codec_tags[]={
// {"V_MS/VFW/FOURCC" , CODEC_ID_NONE},
{"V_UNCOMPRESSED" , CODEC_ID_RAWVIDEO},
{"V_MPEG4/ISO/SP" , CODEC_ID_MPEG4},
st = av_new_stream(s, track->stream_index);
if (st == NULL)
return AVERROR_NOMEM;
- av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
+ av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
st->codec->codec_id = codec_id;
case MATROSKA_ID_BLOCK: {
uint8_t *data, *origdata;
int size;
- uint64_t block_time;
+ int16_t block_time;
uint32_t *lace_size = NULL;
int n, track, flags, laces = 0;
uint64_t num;
}
/* block_time (relative to cluster time) */
- block_time = ((data[0] << 8) | data[1]) * matroska->time_scale;
+ block_time = (data[0] << 8) | data[1];
data += 2;
size -= 2;
flags = *data;
if (res == 0) {
for (n = 0; n < laces; n++) {
- uint64_t timecode = 0;
+ uint64_t timecode = AV_NOPTS_VALUE;
pkt = av_mallocz(sizeof(AVPacket));
/* XXX: prevent data copy... */
res = AVERROR_NOMEM;
break;
}
- if (cluster_time != (uint64_t)-1) {
- if (block_time < 0 && (-block_time) > cluster_time)
- timecode = cluster_time;
- else
+ if (cluster_time != (uint64_t)-1 && n == 0) {
+ if (cluster_time + block_time >= 0)
timecode = cluster_time + block_time;
}
/* FIXME: duration */
pkt->stream_index =
matroska->tracks[track]->stream_index;
- pkt->pts = timecode / 1000000; /* ns to ms */
+ pkt->pts = timecode;
pkt->pos= pos;
matroska_queue_packet(matroska, pkt);
uint64_t num;
if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
break;
- cluster_time = num * matroska->time_scale;
+ cluster_time = num;
break;
}
av_free(track);
}
- for (n = 0; n < s->nb_streams; n++) {
- av_free(s->streams[n]->codec->extradata);
- }
-
memset(matroska, 0, sizeof(MatroskaDemuxContext));
return 0;
}
-static AVInputFormat matroska_iformat = {
+AVInputFormat matroska_demuxer = {
"matroska",
"Matroska file format",
sizeof(MatroskaDemuxContext),
matroska_read_packet,
matroska_read_close,
};
-
-int
-matroska_init(void)
-{
- av_register_input_format(&matroska_iformat);
- return 0;
-}