X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmatroskadec.c;h=5b919449f5adaecf3e51a53411a8658374ff628a;hb=dac56d9ce01eb9963f28f26b97a81db5cbd46c1c;hp=237e9295e08a14cab631ad42dfecde19a53afa2d;hpb=723229c11f1400e6a09c8a1c9c27193f376eb1d1;p=ffmpeg diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 237e9295e08..5b919449f5a 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -22,10 +22,10 @@ /** * @file * Matroska file demuxer - * by Ronald Bultje - * with a little help from Moritz Bunkus - * totally reworked by Aurelien Jacobs - * Specs available on the Matroska project page: http://www.matroska.org/. + * @author Ronald Bultje + * @author with a little help from Moritz Bunkus + * @author totally reworked by Aurelien Jacobs + * @see specs available on the Matroska project page: http://www.matroska.org/ */ #include @@ -38,7 +38,7 @@ #include "rm.h" #include "matroska.h" #include "libavcodec/mpeg4audio.h" -#include "libavutil/intfloat_readwrite.h" +#include "libavutil/intfloat.h" #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" #include "libavutil/lzo.h" @@ -624,9 +624,9 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num) if (size == 0) { *num = 0; } else if (size == 4) { - *num= av_int2flt(avio_rb32(pb)); - } else if(size==8){ - *num= av_int2dbl(avio_rb64(pb)); + *num = av_int2float(avio_rb32(pb)); + } else if (size == 8){ + *num = av_int2double(avio_rb64(pb)); } else return AVERROR_INVALIDDATA; @@ -1188,7 +1188,6 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, int idx static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) { EbmlList *seekhead_list = &matroska->seekhead; - MatroskaSeekhead *seekhead = seekhead_list->elem; int64_t before_pos = avio_tell(matroska->ctx->pb); int i; @@ -1198,6 +1197,7 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska) return; for (i = 0; i < seekhead_list->nb_elem; i++) { + MatroskaSeekhead *seekhead = seekhead_list->elem; if (seekhead[i].pos <= before_pos) continue; @@ -1263,8 +1263,8 @@ static int matroska_aac_sri(int samplerate) { int sri; - for (sri=0; sristream = av_new_stream(s, 0); + st = track->stream = avformat_new_stream(s, NULL); if (st == NULL) return AVERROR(ENOMEM); @@ -1440,7 +1440,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) } else if (codec_id == CODEC_ID_AAC && !track->codec_priv.size) { int profile = matroska_aac_profile(track->codec_id); int sri = matroska_aac_sri(track->audio.samplerate); - extradata = av_malloc(5); + extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE); if (extradata == NULL) return AVERROR(ENOMEM); extradata[0] = (profile << 3) | ((sri&0x0E) >> 1); @@ -1506,7 +1506,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (track->time_scale < 0.01) track->time_scale = 1.0; - av_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */ + avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */ st->codec->codec_id = codec_id; st->start_time = 0; @@ -1519,10 +1519,6 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (track->flag_forced) st->disposition |= AV_DISPOSITION_FORCED; - if (track->default_duration) - av_reduce(&st->codec->time_base.num, &st->codec->time_base.den, - track->default_duration, 1000000000, 30000); - if (!st->codec->extradata) { if(extradata){ st->codec->extradata = extradata; @@ -1570,7 +1566,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) attachements[j].bin.data && attachements[j].bin.size > 0)) { av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n"); } else { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (st == NULL) break; av_dict_set(&st->metadata, "filename",attachements[j].filename, 0); @@ -1599,7 +1595,7 @@ static int matroska_read_header(AVFormatContext *s, AVFormatParameters *ap) if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid && (max_start==0 || chapters[i].start > max_start)) { chapters[i].chapter = - ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, + avpriv_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, chapters[i].start, chapters[i].end, chapters[i].title); av_dict_set(&chapters[i].chapter->metadata, @@ -1679,11 +1675,12 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, size -= n; track = matroska_find_track_by_num(matroska, num); - if (size <= 3 || !track || !track->stream) { + if (!track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); return AVERROR_INVALIDDATA; - } + } else if (size <= 3) + return 0; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; @@ -2002,7 +1999,7 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); matroska->skip_to_timecode = st->index_entries[index].timestamp; matroska->done = 0; - av_update_cur_dts(s, st, st->index_entries[index].timestamp); + ff_update_cur_dts(s, st, st->index_entries[index].timestamp); return 0; }