X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fnutdec.c;h=d1f3496990c14d4e3109c53e199d9d3e0745d983;hb=240aa70b798e99c15191d986261966bdbce59dba;hp=056ef59d009c3940aeeddd255210e49e4275e454;hpb=a024c3ce9a502849013a4aa2c0a6de0c9270261c;p=ffmpeg diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 056ef59d009..d1f3496990c 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -149,7 +149,7 @@ static int64_t find_startcode(AVIOContext *bc, uint64_t code, int64_t pos) } } -static int nut_probe(AVProbeData *p) +static int nut_probe(const AVProbeData *p) { int i; @@ -193,13 +193,13 @@ static int decode_main_header(NUTContext *nut) { AVFormatContext *s = nut->avf; AVIOContext *bc = s->pb; - uint64_t tmp, end; + uint64_t tmp, end, length; unsigned int stream_count; int i, j, count, ret; int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx; - end = get_packetheader(nut, bc, 1, MAIN_STARTCODE); - end += avio_tell(bc); + length = get_packetheader(nut, bc, 1, MAIN_STARTCODE); + end = length + avio_tell(bc); nut->version = ffio_read_varlen(bc); if (nut->version < NUT_MIN_VERSION || @@ -219,7 +219,7 @@ static int decode_main_header(NUTContext *nut) nut->max_distance = 65536; } - GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational)); + GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational) && tmp < length/2); nut->time_base = av_malloc_array(nut->time_base_count, sizeof(AVRational)); if (!nut->time_base) return AVERROR(ENOMEM); @@ -260,7 +260,7 @@ static int decode_main_header(NUTContext *nut) if (tmp_fields > 5) count = ffio_read_varlen(bc); else - count = tmp_mul - tmp_size; + count = tmp_mul - (unsigned)tmp_size; if (tmp_fields > 6) get_s(bc); if (tmp_fields > 7) @@ -427,8 +427,10 @@ static int decode_stream_header(NUTContext *nut) GET_V(st->codecpar->extradata_size, tmp < (1 << 30)); if (st->codecpar->extradata_size) { - if (ff_get_extradata(s, st->codecpar, bc, st->codecpar->extradata_size) < 0) - return AVERROR(ENOMEM); + ret = ff_get_extradata(s, st->codecpar, bc, + st->codecpar->extradata_size); + if (ret < 0) + return ret; } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { @@ -487,8 +489,8 @@ static int decode_info_header(NUTContext *nut) AVIOContext *bc = s->pb; uint64_t tmp, chapter_start, chapter_len; unsigned int stream_id_plus1, count; - int chapter_id, i, ret = 0; - int64_t value, end; + int i, ret = 0; + int64_t chapter_id, value, end; char name[256], str_value[1024], type_str[256]; const char *type; int *event_flags = NULL; @@ -1233,15 +1235,15 @@ static int read_seek(AVFormatContext *s, int stream_index, return AVERROR(ENOSYS); } - if (st->index_entries) { + if (st->internal->index_entries) { int index = av_index_search_timestamp(st, pts, flags); if (index < 0) index = av_index_search_timestamp(st, pts, flags ^ AVSEEK_FLAG_BACKWARD); if (index < 0) return -1; - pos2 = st->index_entries[index].pos; - ts = st->index_entries[index].timestamp; + pos2 = st->internal->index_entries[index].pos; + ts = st->internal->index_entries[index].timestamp; } else { av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pts_cmp, (void **) next_node); @@ -1275,13 +1277,13 @@ static int read_seek(AVFormatContext *s, int stream_index, av_assert0(sp); pos2 = sp->back_ptr - 15; } - av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2); + av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2); pos = find_startcode(s->pb, SYNCPOINT_STARTCODE, pos2); avio_seek(s->pb, pos, SEEK_SET); nut->last_syncpoint_pos = pos; - av_log(NULL, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos); + av_log(s, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos); if (pos2 > pos || pos2 + 15 < pos) - av_log(NULL, AV_LOG_ERROR, "no syncpoint at backptr pos\n"); + av_log(s, AV_LOG_ERROR, "no syncpoint at backptr pos\n"); for (i = 0; i < s->nb_streams; i++) nut->stream[i].skip_until_key_frame = 1;