X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmatroskadec.c;h=fd1001ef8e0326dfb4867898c0d9101c8fd014b5;hb=dfa77dead2c97ec84092066102b14a2524d4d88b;hp=8faa3cc167478855a6c20ebd855a4042464f6c44;hpb=2822361ed1fe18b03a35dfdbda811de6bd919e0a;p=ffmpeg diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 8faa3cc1674..fd1001ef8e0 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" @@ -652,9 +652,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; @@ -1303,8 +1303,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); @@ -1554,7 +1554,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; @@ -1567,10 +1567,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; @@ -1639,7 +1635,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); @@ -1668,7 +1664,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, @@ -1750,11 +1746,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; - } + return res; + } else if (size <= 3) + return 0; st = track->stream; if (st->discard >= AVDISCARD_ALL) return res; @@ -1990,7 +1987,7 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) res = ebml_parse(matroska, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; - for (i=0; inb_elem && !res; i++) + for (i=0; inb_elem; i++) if (blocks[i].bin.size > 0 && blocks[i].bin.data) { int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; res=matroska_parse_block(matroska, @@ -2007,15 +2004,14 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska) static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; - int ret = 0; - while (!ret && matroska_deliver_packet(matroska, pkt)) { + while (matroska_deliver_packet(matroska, pkt)) { if (matroska->done) return AVERROR_EOF; - ret = matroska_parse_cluster(matroska); + matroska_parse_cluster(matroska); } - return ret; + return 0; } static int matroska_read_seek(AVFormatContext *s, int stream_index, @@ -2071,7 +2067,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; }