1
0
Fork 0

matroskadec_haali: parse CodecDelay and SeekPreRoll

This commit is contained in:
Hendrik Leppkes 2013-11-29 18:06:19 +01:00
parent fcf1105b40
commit 0a2a75e085
Signed by: hendrik
GPG Key ID: 846079A4B0A7C1B5
3 changed files with 16 additions and 2 deletions

View File

@ -1397,6 +1397,12 @@ static void parseTrackEntry(MatroskaFile *mf,ulonglong toplen) {
errorjmp(mf,"Track number in TrackOverlay is too large: %d",(int)v);
t.TrackOverlay = (unsigned char)v;
break;
case 0x56aa: // CodecDelay
t.CodecDelay = readUInt(mf, (unsigned)len);
break;
case 0x56bb: // SeekPreRoll
t.SeekPreRoll = readUInt(mf, (unsigned)len);
break;
case 0xe0: // VideoInfo
parseVideoInfo(mf,len,&t);
break;

View File

@ -121,6 +121,8 @@ struct TrackInfo {
ulonglong MinCache;
ulonglong MaxCache;
ulonglong DefaultDuration;
ulonglong CodecDelay;
ulonglong SeekPreRoll;
MKFLOAT TimecodeScale;
void *CodecPrivate;
unsigned CodecPrivateSize;

View File

@ -1170,6 +1170,12 @@ static int mkv_read_header(AVFormatContext *s)
st->codec->channels = info->AV.Audio.Channels;
if (st->codec->codec_id != AV_CODEC_ID_AAC && st->codec->codec_id != AV_CODEC_ID_MLP && st->codec->codec_id != AV_CODEC_ID_TRUEHD)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (track->info->CodecDelay > 0) {
st->codec->delay = av_rescale_q(track->info->CodecDelay, (AVRational){1, 1000000000}, (AVRational){1, st->codec->sample_rate});
}
if (track->info->SeekPreRoll > 0) {
av_codec_set_seek_preroll(st->codec, av_rescale_q(track->info->SeekPreRoll, (AVRational){1, 1000000000}, (AVRational){1, st->codec->sample_rate}));
}
} else if (info->Type == TT_SUB) {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
if (st->codec->codec_id == AV_CODEC_ID_SSA) {
@ -1543,9 +1549,9 @@ again:
if (!(flags & FRAME_UNKNOWN_START)) {
if (track->ms_compat)
pkt->dts = start_time;
pkt->dts = start_time - track->info->CodecDelay;
else
pkt->pts = start_time;
pkt->pts = start_time - track->info->CodecDelay;
if (track->info->Type == TT_SUB)
pkt->convergence_duration = end_time - start_time;