diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-05-29 01:09:51 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-05-29 01:13:59 +0200 |
commit | a8499cbbe87d00456c391f41207e1981bd7f746a (patch) | |
tree | fdfc491b412384196ec02fcf305db586a92d2c83 /libavformat/nutdec.c | |
parent | d858ee717bed6307b8e772bd5039ab001aeae03f (diff) | |
parent | c94e2e85cb6af8a570d8542a830556243bd32873 (diff) |
Merge commit 'c94e2e85cb6af8a570d8542a830556243bd32873'
* commit 'c94e2e85cb6af8a570d8542a830556243bd32873':
nut: Support experimental NUT 4 features
Conflicts:
doc/nut.texi
libavformat/nut.h
libavformat/nutdec.c
libavformat/nutenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/nutdec.c')
-rw-r--r-- | libavformat/nutdec.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 5d08a8e80b..5fd2a40f42 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -229,7 +229,7 @@ static int decode_main_header(NUTContext *nut) end += avio_tell(bc); tmp = ffio_read_varlen(bc); - if (tmp < 2 && tmp > 4) { + if (tmp < NUT_MIN_VERSION && tmp > NUT_MAX_VERSION) { av_log(s, AV_LOG_ERROR, "Version %"PRId64" not supported.\n", tmp); return AVERROR(ENOSYS); @@ -340,6 +340,11 @@ static int decode_main_header(NUTContext *nut) av_assert0(nut->header_len[0] == 0); } + // flags had been effectively introduced in version 4 + if (nut->version > NUT_STABLE_VERSION) { + nut->flags = ffio_read_varlen(bc); + } + if (skip_reserved(bc, end) || ffio_get_checksum(bc)) { av_log(s, AV_LOG_ERROR, "main header checksum mismatch\n"); return AVERROR_INVALIDDATA; @@ -578,6 +583,14 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr) ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count); + if (nut->flags & NUT_BROADCAST) { + tmp = ffio_read_varlen(bc); + av_log(s, AV_LOG_VERBOSE, "Syncpoint wallclock %"PRId64"\n", + av_rescale_q(tmp / nut->time_base_count, + nut->time_base[tmp % nut->time_base_count], + AV_TIME_BASE_Q)); + } + if (skip_reserved(bc, end) || ffio_get_checksum(bc)) { av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n"); return AVERROR_INVALIDDATA; @@ -898,7 +911,8 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, int size, flags, size_mul, pts_delta, i, reserved_count; uint64_t tmp; - if (avio_tell(bc) > nut->last_syncpoint_pos + nut->max_distance) { + if (!(nut->flags & NUT_PIPE) && + avio_tell(bc) > nut->last_syncpoint_pos + nut->max_distance) { av_log(s, AV_LOG_ERROR, "Last frame must have been damaged %"PRId64" > %"PRId64" + %d\n", avio_tell(bc), nut->last_syncpoint_pos, nut->max_distance); @@ -951,8 +965,9 @@ static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, if (flags & FLAG_CHECKSUM) { avio_rb32(bc); // FIXME check this - } else if (size > 2 * nut->max_distance || FFABS(stc->last_pts - *pts) > - stc->max_pts_distance) { + } else if (!(nut->flags & NUT_PIPE) && + size > 2 * nut->max_distance || + FFABS(stc->last_pts - *pts) > stc->max_pts_distance) { av_log(s, AV_LOG_ERROR, "frame size > 2max_distance and no checksum\n"); return AVERROR_INVALIDDATA; } @@ -1118,6 +1133,10 @@ static int read_seek(AVFormatContext *s, int stream_index, int64_t pos, pos2, ts; int i; + if (nut->flags & NUT_PIPE) { + return AVERROR(ENOSYS); + } + if (st->index_entries) { int index = av_index_search_timestamp(st, pts, flags); if (index < 0) |