FFmpeg
nutdec.c
Go to the documentation of this file.
1 /*
2  * "NUT" Container Format demuxer
3  * Copyright (c) 2004-2006 Michael Niedermayer
4  * Copyright (c) 2003 Alex Beregszaszi
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavutil/avstring.h"
24 #include "libavutil/avassert.h"
25 #include "libavutil/bswap.h"
26 #include "libavutil/dict.h"
27 #include "libavutil/intreadwrite.h"
28 #include "libavutil/mathematics.h"
29 #include "libavutil/tree.h"
30 #include "libavcodec/bytestream.h"
31 #include "avio_internal.h"
32 #include "isom.h"
33 #include "nut.h"
34 #include "riff.h"
35 
36 #define NUT_MAX_STREAMS 256 /* arbitrary sanity check value */
37 
38 static int64_t nut_read_timestamp(AVFormatContext *s, int stream_index,
39  int64_t *pos_arg, int64_t pos_limit);
40 
41 static int get_str(AVIOContext *bc, char *string, unsigned int maxlen)
42 {
43  unsigned int len = ffio_read_varlen(bc);
44 
45  if (len && maxlen)
46  avio_read(bc, string, FFMIN(len, maxlen));
47  while (len > maxlen) {
48  avio_r8(bc);
49  len--;
50  if (bc->eof_reached)
51  len = maxlen;
52  }
53 
54  if (maxlen)
55  string[FFMIN(len, maxlen - 1)] = 0;
56 
57  if (bc->eof_reached)
58  return AVERROR_EOF;
59  if (maxlen == len)
60  return -1;
61  else
62  return 0;
63 }
64 
65 static int64_t get_s(AVIOContext *bc)
66 {
67  int64_t v = ffio_read_varlen(bc) + 1;
68 
69  if (v & 1)
70  return -(v >> 1);
71  else
72  return (v >> 1);
73 }
74 
75 static uint64_t get_fourcc(AVIOContext *bc)
76 {
77  unsigned int len = ffio_read_varlen(bc);
78 
79  if (len == 2)
80  return avio_rl16(bc);
81  else if (len == 4)
82  return avio_rl32(bc);
83  else {
84  av_log(NULL, AV_LOG_ERROR, "Unsupported fourcc length %d\n", len);
85  return -1;
86  }
87 }
88 
90  int calculate_checksum, uint64_t startcode)
91 {
92  int64_t size;
93 
94  startcode = av_be2ne64(startcode);
95  startcode = ff_crc04C11DB7_update(0, (uint8_t*) &startcode, 8);
96 
98  size = ffio_read_varlen(bc);
99  if (size > 4096)
100  avio_rb32(bc);
101  if (ffio_get_checksum(bc) && size > 4096)
102  return -1;
103 
104  ffio_init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
105 
106  return size;
107 }
108 
109 static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos)
110 {
111  uint64_t state = 0;
112 
113  if (pos >= 0)
114  /* Note, this may fail if the stream is not seekable, but that should
115  * not matter, as in this case we simply start where we currently are */
116  avio_seek(bc, pos, SEEK_SET);
117  while (!avio_feof(bc)) {
118  state = (state << 8) | avio_r8(bc);
119  if ((state >> 56) != 'N')
120  continue;
121  switch (state) {
122  case MAIN_STARTCODE:
123  case STREAM_STARTCODE:
124  case SYNCPOINT_STARTCODE:
125  case INFO_STARTCODE:
126  case INDEX_STARTCODE:
127  return state;
128  }
129  }
130 
131  return 0;
132 }
133 
134 /**
135  * Find the given startcode.
136  * @param code the startcode
137  * @param pos the start position of the search, or -1 if the current position
138  * @return the position of the startcode or -1 if not found
139  */
140 static int64_t find_startcode(AVIOContext *bc, uint64_t code, int64_t pos)
141 {
142  for (;;) {
143  uint64_t startcode = find_any_startcode(bc, pos);
144  if (startcode == code)
145  return avio_tell(bc) - 8;
146  else if (startcode == 0)
147  return -1;
148  pos = -1;
149  }
150 }
151 
152 static int nut_probe(const AVProbeData *p)
153 {
154  int i;
155 
156  for (i = 0; i < p->buf_size-8; i++) {
157  if (AV_RB32(p->buf+i) != MAIN_STARTCODE>>32)
158  continue;
159  if (AV_RB32(p->buf+i+4) == (MAIN_STARTCODE & 0xFFFFFFFF))
160  return AVPROBE_SCORE_MAX;
161  }
162  return 0;
163 }
164 
165 #define GET_V(dst, check) \
166  do { \
167  tmp = ffio_read_varlen(bc); \
168  if (!(check)) { \
169  av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp); \
170  ret = AVERROR_INVALIDDATA; \
171  goto fail; \
172  } \
173  dst = tmp; \
174  } while (0)
175 
176 static int skip_reserved(AVIOContext *bc, int64_t pos)
177 {
178  pos -= avio_tell(bc);
179  if (pos < 0) {
180  avio_seek(bc, pos, SEEK_CUR);
181  return AVERROR_INVALIDDATA;
182  } else {
183  while (pos--) {
184  if (bc->eof_reached)
185  return AVERROR_INVALIDDATA;
186  avio_r8(bc);
187  }
188  return 0;
189  }
190 }
191 
193 {
194  AVFormatContext *s = nut->avf;
195  AVIOContext *bc = s->pb;
196  uint64_t tmp, end, length;
197  unsigned int stream_count;
198  int i, j, count, ret;
199  int tmp_stream, tmp_mul, tmp_pts, tmp_size, tmp_res, tmp_head_idx;
200 
201  length = get_packetheader(nut, bc, 1, MAIN_STARTCODE);
202  end = length + avio_tell(bc);
203 
204  nut->version = ffio_read_varlen(bc);
205  if (nut->version < NUT_MIN_VERSION ||
206  nut->version > NUT_MAX_VERSION) {
207  av_log(s, AV_LOG_ERROR, "Version %d not supported.\n",
208  nut->version);
209  return AVERROR(ENOSYS);
210  }
211  if (nut->version > 3)
212  nut->minor_version = ffio_read_varlen(bc);
213 
214  GET_V(stream_count, tmp > 0 && tmp <= NUT_MAX_STREAMS);
215 
216  nut->max_distance = ffio_read_varlen(bc);
217  if (nut->max_distance > 65536) {
218  av_log(s, AV_LOG_DEBUG, "max_distance %d\n", nut->max_distance);
219  nut->max_distance = 65536;
220  }
221 
222  GET_V(nut->time_base_count, tmp > 0 && tmp < INT_MAX / sizeof(AVRational) && tmp < length/2);
223  nut->time_base = av_malloc_array(nut->time_base_count, sizeof(AVRational));
224  if (!nut->time_base)
225  return AVERROR(ENOMEM);
226 
227  for (i = 0; i < nut->time_base_count; i++) {
228  GET_V(nut->time_base[i].num, tmp > 0 && tmp < (1ULL << 31));
229  GET_V(nut->time_base[i].den, tmp > 0 && tmp < (1ULL << 31));
230  if (av_gcd(nut->time_base[i].num, nut->time_base[i].den) != 1) {
231  av_log(s, AV_LOG_ERROR, "invalid time base %d/%d\n",
232  nut->time_base[i].num,
233  nut->time_base[i].den);
235  goto fail;
236  }
237  }
238  tmp_pts = 0;
239  tmp_mul = 1;
240  tmp_stream = 0;
241  tmp_head_idx = 0;
242  for (i = 0; i < 256;) {
243  int tmp_flags = ffio_read_varlen(bc);
244  int tmp_fields = ffio_read_varlen(bc);
245 
246  if (tmp_fields > 0)
247  tmp_pts = get_s(bc);
248  if (tmp_fields > 1)
249  tmp_mul = ffio_read_varlen(bc);
250  if (tmp_fields > 2)
251  tmp_stream = ffio_read_varlen(bc);
252  if (tmp_fields > 3)
253  tmp_size = ffio_read_varlen(bc);
254  else
255  tmp_size = 0;
256  if (tmp_fields > 4)
257  tmp_res = ffio_read_varlen(bc);
258  else
259  tmp_res = 0;
260  if (tmp_fields > 5)
261  count = ffio_read_varlen(bc);
262  else
263  count = tmp_mul - (unsigned)tmp_size;
264  if (tmp_fields > 6)
265  get_s(bc);
266  if (tmp_fields > 7)
267  tmp_head_idx = ffio_read_varlen(bc);
268 
269  while (tmp_fields-- > 8) {
270  if (bc->eof_reached) {
271  av_log(s, AV_LOG_ERROR, "reached EOF while decoding main header\n");
273  goto fail;
274  }
275  ffio_read_varlen(bc);
276  }
277 
278  if (count <= 0 || count > 256 - (i <= 'N') - i) {
279  av_log(s, AV_LOG_ERROR, "illegal count %d at %d\n", count, i);
281  goto fail;
282  }
283  if (tmp_stream >= stream_count) {
284  av_log(s, AV_LOG_ERROR, "illegal stream number %d >= %d\n",
285  tmp_stream, stream_count);
287  goto fail;
288  }
289  if (tmp_size < 0 || tmp_size > INT_MAX - count) {
290  av_log(s, AV_LOG_ERROR, "illegal size\n");
292  goto fail;
293  }
294 
295  for (j = 0; j < count; j++, i++) {
296  if (i == 'N') {
297  nut->frame_code[i].flags = FLAG_INVALID;
298  j--;
299  continue;
300  }
301  nut->frame_code[i].flags = tmp_flags;
302  nut->frame_code[i].pts_delta = tmp_pts;
303  nut->frame_code[i].stream_id = tmp_stream;
304  nut->frame_code[i].size_mul = tmp_mul;
305  nut->frame_code[i].size_lsb = tmp_size + j;
306  nut->frame_code[i].reserved_count = tmp_res;
307  nut->frame_code[i].header_idx = tmp_head_idx;
308  }
309  }
310  av_assert0(nut->frame_code['N'].flags == FLAG_INVALID);
311 
312  if (end > avio_tell(bc) + 4) {
313  int rem = 1024;
314  GET_V(nut->header_count, tmp < 128U);
315  nut->header_count++;
316  for (i = 1; i < nut->header_count; i++) {
317  uint8_t *hdr;
318  GET_V(nut->header_len[i], tmp > 0 && tmp < 256);
319  if (rem < nut->header_len[i]) {
321  "invalid elision header %d : %d > %d\n",
322  i, nut->header_len[i], rem);
324  goto fail;
325  }
326  rem -= nut->header_len[i];
327  hdr = av_malloc(nut->header_len[i]);
328  if (!hdr) {
329  ret = AVERROR(ENOMEM);
330  goto fail;
331  }
332  avio_read(bc, hdr, nut->header_len[i]);
333  nut->header[i] = hdr;
334  }
335  av_assert0(nut->header_len[0] == 0);
336  }
337 
338  // flags had been effectively introduced in version 4
339  if (nut->version > 3 && end > avio_tell(bc) + 4) {
340  nut->flags = ffio_read_varlen(bc);
341  }
342 
343  if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
344  av_log(s, AV_LOG_ERROR, "main header checksum mismatch\n");
346  goto fail;
347  }
348 
349  nut->stream = av_calloc(stream_count, sizeof(StreamContext));
350  if (!nut->stream) {
351  ret = AVERROR(ENOMEM);
352  goto fail;
353  }
354  for (i = 0; i < stream_count; i++)
356 
357  return 0;
358 fail:
359  av_freep(&nut->time_base);
360  for (i = 1; i < nut->header_count; i++) {
361  av_freep(&nut->header[i]);
362  }
363  nut->header_count = 0;
364  return ret;
365 }
366 
368 {
369  AVFormatContext *s = nut->avf;
370  AVIOContext *bc = s->pb;
371  StreamContext *stc;
372  int class, stream_id, ret;
373  uint64_t tmp, end;
374  AVStream *st = NULL;
375 
376  end = get_packetheader(nut, bc, 1, STREAM_STARTCODE);
377  end += avio_tell(bc);
378 
379  GET_V(stream_id, tmp < s->nb_streams && !nut->stream[tmp].time_base);
380  stc = &nut->stream[stream_id];
381  st = s->streams[stream_id];
382  if (!st)
383  return AVERROR(ENOMEM);
384 
385  class = ffio_read_varlen(bc);
386  tmp = get_fourcc(bc);
387  st->codecpar->codec_tag = tmp;
388  switch (class) {
389  case 0:
391  st->codecpar->codec_id = av_codec_get_id((const AVCodecTag * const []) {
395  0
396  },
397  tmp);
398  break;
399  case 1:
401  st->codecpar->codec_id = av_codec_get_id((const AVCodecTag * const []) {
405  0
406  },
407  tmp);
408  break;
409  case 2:
412  break;
413  case 3:
416  break;
417  default:
418  av_log(s, AV_LOG_ERROR, "unknown stream class (%d)\n", class);
419  return AVERROR(ENOSYS);
420  }
421  if (class < 3 && st->codecpar->codec_id == AV_CODEC_ID_NONE)
423  "Unknown codec tag '0x%04x' for stream number %d\n",
424  (unsigned int) tmp, stream_id);
425 
426  GET_V(stc->time_base_id, tmp < nut->time_base_count);
427  GET_V(stc->msb_pts_shift, tmp < 16);
429  GET_V(stc->decode_delay, tmp < 1000); // sanity limit, raise this if Moore's law is true
430  st->codecpar->video_delay = stc->decode_delay;
431  ffio_read_varlen(bc); // stream flags
432 
433  GET_V(st->codecpar->extradata_size, tmp < (1 << 30));
434  if (st->codecpar->extradata_size) {
435  ret = ff_get_extradata(s, st->codecpar, bc,
436  st->codecpar->extradata_size);
437  if (ret < 0)
438  return ret;
439  }
440 
441  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
442  GET_V(st->codecpar->width, tmp > 0);
443  GET_V(st->codecpar->height, tmp > 0);
446  if ((!st->sample_aspect_ratio.num) != (!st->sample_aspect_ratio.den)) {
447  av_log(s, AV_LOG_ERROR, "invalid aspect ratio %d/%d\n",
450  goto fail;
451  }
452  ffio_read_varlen(bc); /* csp type */
453  } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
454  GET_V(st->codecpar->sample_rate, tmp > 0);
455  ffio_read_varlen(bc); // samplerate_den
456  GET_V(st->codecpar->channels, tmp > 0);
457  }
458  if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
460  "stream header %d checksum mismatch\n", stream_id);
462  goto fail;
463  }
464  stc->time_base = &nut->time_base[stc->time_base_id];
465  avpriv_set_pts_info(s->streams[stream_id], 63, stc->time_base->num,
466  stc->time_base->den);
467  return 0;
468 fail:
469  if (st && st->codecpar) {
470  av_freep(&st->codecpar->extradata);
471  st->codecpar->extradata_size = 0;
472  }
473  return ret;
474 }
475 
477  int stream_id)
478 {
479  int flag = 0, i;
480 
481  for (i = 0; ff_nut_dispositions[i].flag; ++i)
482  if (!strcmp(ff_nut_dispositions[i].str, value))
484  if (!flag)
485  av_log(avf, AV_LOG_INFO, "unknown disposition type '%s'\n", value);
486  for (i = 0; i < avf->nb_streams; ++i)
487  if (stream_id == i || stream_id == -1)
488  avf->streams[i]->disposition |= flag;
489 }
490 
492 {
493  AVFormatContext *s = nut->avf;
494  AVIOContext *bc = s->pb;
495  uint64_t tmp, chapter_start, chapter_len;
496  unsigned int stream_id_plus1, count;
497  int chapter_id, i, ret = 0;
498  int64_t value, end;
499  char name[256], str_value[1024], type_str[256];
500  const char *type;
501  int *event_flags = NULL;
502  AVChapter *chapter = NULL;
503  AVStream *st = NULL;
504  AVDictionary **metadata = NULL;
505  int metadata_flag = 0;
506 
507  end = get_packetheader(nut, bc, 1, INFO_STARTCODE);
508  end += avio_tell(bc);
509 
510  GET_V(stream_id_plus1, tmp <= s->nb_streams);
511  chapter_id = get_s(bc);
512  chapter_start = ffio_read_varlen(bc);
513  chapter_len = ffio_read_varlen(bc);
514  count = ffio_read_varlen(bc);
515 
516  if (chapter_id && !stream_id_plus1) {
517  int64_t start = chapter_start / nut->time_base_count;
518  chapter = avpriv_new_chapter(s, chapter_id,
519  nut->time_base[chapter_start %
520  nut->time_base_count],
521  start, start + chapter_len, NULL);
522  if (!chapter) {
523  av_log(s, AV_LOG_ERROR, "Could not create chapter.\n");
524  return AVERROR(ENOMEM);
525  }
526  metadata = &chapter->metadata;
527  } else if (stream_id_plus1) {
528  st = s->streams[stream_id_plus1 - 1];
529  metadata = &st->metadata;
530  event_flags = &st->event_flags;
531  metadata_flag = AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
532  } else {
533  metadata = &s->metadata;
534  event_flags = &s->event_flags;
535  metadata_flag = AVFMT_EVENT_FLAG_METADATA_UPDATED;
536  }
537 
538  for (i = 0; i < count; i++) {
539  ret = get_str(bc, name, sizeof(name));
540  if (ret < 0) {
541  av_log(s, AV_LOG_ERROR, "get_str failed while decoding info header\n");
542  return ret;
543  }
544  value = get_s(bc);
545  str_value[0] = 0;
546 
547  if (value == -1) {
548  type = "UTF-8";
549  ret = get_str(bc, str_value, sizeof(str_value));
550  } else if (value == -2) {
551  ret = get_str(bc, type_str, sizeof(type_str));
552  if (ret < 0) {
553  av_log(s, AV_LOG_ERROR, "get_str failed while decoding info header\n");
554  return ret;
555  }
556  type = type_str;
557  ret = get_str(bc, str_value, sizeof(str_value));
558  } else if (value == -3) {
559  type = "s";
560  value = get_s(bc);
561  } else if (value == -4) {
562  type = "t";
563  value = ffio_read_varlen(bc);
564  } else if (value < -4) {
565  type = "r";
566  get_s(bc);
567  } else {
568  type = "v";
569  }
570 
571  if (ret < 0) {
572  av_log(s, AV_LOG_ERROR, "get_str failed while decoding info header\n");
573  return ret;
574  }
575 
576  if (stream_id_plus1 > s->nb_streams) {
578  "invalid stream id %d for info packet\n",
579  stream_id_plus1);
580  continue;
581  }
582 
583  if (!strcmp(type, "UTF-8")) {
584  if (chapter_id == 0 && !strcmp(name, "Disposition")) {
585  set_disposition_bits(s, str_value, stream_id_plus1 - 1);
586  continue;
587  }
588 
589  if (stream_id_plus1 && !strcmp(name, "r_frame_rate")) {
590  sscanf(str_value, "%d/%d", &st->r_frame_rate.num, &st->r_frame_rate.den);
591  if (st->r_frame_rate.num >= 1000LL*st->r_frame_rate.den ||
592  st->r_frame_rate.num < 0 || st->r_frame_rate.den < 0)
593  st->r_frame_rate.num = st->r_frame_rate.den = 0;
594  continue;
595  }
596 
597  if (metadata && av_strcasecmp(name, "Uses") &&
598  av_strcasecmp(name, "Depends") && av_strcasecmp(name, "Replaces")) {
599  if (event_flags)
600  *event_flags |= metadata_flag;
601  av_dict_set(metadata, name, str_value, 0);
602  }
603  }
604  }
605 
606  if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
607  av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
608  return AVERROR_INVALIDDATA;
609  }
610 fail:
611  return FFMIN(ret, 0);
612 }
613 
614 static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr)
615 {
616  AVFormatContext *s = nut->avf;
617  AVIOContext *bc = s->pb;
618  int64_t end;
619  uint64_t tmp;
620  int ret;
621 
622  nut->last_syncpoint_pos = avio_tell(bc) - 8;
623 
625  end += avio_tell(bc);
626 
627  tmp = ffio_read_varlen(bc);
628  *back_ptr = nut->last_syncpoint_pos - 16 * ffio_read_varlen(bc);
629  if (*back_ptr < 0)
630  return AVERROR_INVALIDDATA;
631 
632  ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count],
633  tmp / nut->time_base_count);
634 
635  if (nut->flags & NUT_BROADCAST) {
636  tmp = ffio_read_varlen(bc);
637  av_log(s, AV_LOG_VERBOSE, "Syncpoint wallclock %"PRId64"\n",
639  nut->time_base[tmp % nut->time_base_count],
640  AV_TIME_BASE_Q));
641  }
642 
643  if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
644  av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
645  return AVERROR_INVALIDDATA;
646  }
647 
648  *ts = tmp / nut->time_base_count *
650 
651  if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts)) < 0)
652  return ret;
653 
654  return 0;
655 }
656 
657 //FIXME calculate exactly, this is just a good approximation.
658 static int64_t find_duration(NUTContext *nut, int64_t filesize)
659 {
660  AVFormatContext *s = nut->avf;
661  int64_t duration = 0;
662 
664 
665  if(duration > 0)
666  s->duration_estimation_method = AVFMT_DURATION_FROM_PTS;
667  return duration;
668 }
669 
671 {
672  AVFormatContext *s = nut->avf;
673  AVIOContext *bc = s->pb;
674  uint64_t tmp, end;
675  int i, j, syncpoint_count;
676  int64_t filesize = avio_size(bc);
677  int64_t *syncpoints = NULL;
678  uint64_t max_pts;
679  int8_t *has_keyframe = NULL;
680  int ret = AVERROR_INVALIDDATA;
681 
682  if(filesize <= 0)
683  return -1;
684 
685  avio_seek(bc, filesize - 12, SEEK_SET);
686  avio_seek(bc, filesize - avio_rb64(bc), SEEK_SET);
687  if (avio_rb64(bc) != INDEX_STARTCODE) {
688  av_log(s, AV_LOG_WARNING, "no index at the end\n");
689 
690  if(s->duration<=0)
691  s->duration = find_duration(nut, filesize);
692  return ret;
693  }
694 
695  end = get_packetheader(nut, bc, 1, INDEX_STARTCODE);
696  end += avio_tell(bc);
697 
698  max_pts = ffio_read_varlen(bc);
699  s->duration = av_rescale_q(max_pts / nut->time_base_count,
700  nut->time_base[max_pts % nut->time_base_count],
702  s->duration_estimation_method = AVFMT_DURATION_FROM_PTS;
703 
704  GET_V(syncpoint_count, tmp < INT_MAX / 8 && tmp > 0);
705  syncpoints = av_malloc_array(syncpoint_count, sizeof(int64_t));
706  has_keyframe = av_malloc_array(syncpoint_count + 1, sizeof(int8_t));
707  if (!syncpoints || !has_keyframe) {
708  ret = AVERROR(ENOMEM);
709  goto fail;
710  }
711  for (i = 0; i < syncpoint_count; i++) {
712  syncpoints[i] = ffio_read_varlen(bc);
713  if (syncpoints[i] <= 0)
714  goto fail;
715  if (i)
716  syncpoints[i] += syncpoints[i - 1];
717  }
718 
719  for (i = 0; i < s->nb_streams; i++) {
720  int64_t last_pts = -1;
721  for (j = 0; j < syncpoint_count;) {
722  uint64_t x = ffio_read_varlen(bc);
723  int type = x & 1;
724  int n = j;
725  x >>= 1;
726  if (type) {
727  int flag = x & 1;
728  x >>= 1;
729  if (n + x >= syncpoint_count + 1) {
730  av_log(s, AV_LOG_ERROR, "index overflow A %d + %"PRIu64" >= %d\n", n, x, syncpoint_count + 1);
731  goto fail;
732  }
733  while (x--)
734  has_keyframe[n++] = flag;
735  has_keyframe[n++] = !flag;
736  } else {
737  if (x <= 1) {
738  av_log(s, AV_LOG_ERROR, "index: x %"PRIu64" is invalid\n", x);
739  goto fail;
740  }
741  while (x != 1) {
742  if (n >= syncpoint_count + 1) {
743  av_log(s, AV_LOG_ERROR, "index overflow B\n");
744  goto fail;
745  }
746  has_keyframe[n++] = x & 1;
747  x >>= 1;
748  }
749  }
750  if (has_keyframe[0]) {
751  av_log(s, AV_LOG_ERROR, "keyframe before first syncpoint in index\n");
752  goto fail;
753  }
754  av_assert0(n <= syncpoint_count + 1);
755  for (; j < n && j < syncpoint_count; j++) {
756  if (has_keyframe[j]) {
757  uint64_t B, A = ffio_read_varlen(bc);
758  if (!A) {
759  A = ffio_read_varlen(bc);
760  B = ffio_read_varlen(bc);
761  // eor_pts[j][i] = last_pts + A + B
762  } else
763  B = 0;
764  av_add_index_entry(s->streams[i], 16 * syncpoints[j - 1],
765  last_pts + A, 0, 0, AVINDEX_KEYFRAME);
766  last_pts += A + B;
767  }
768  }
769  }
770  }
771 
772  if (skip_reserved(bc, end) || ffio_get_checksum(bc)) {
773  av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
774  goto fail;
775  }
776  ret = 0;
777 
778 fail:
779  av_free(syncpoints);
780  av_free(has_keyframe);
781  return ret;
782 }
783 
785 {
786  NUTContext *nut = s->priv_data;
787  int i;
788 
789  av_freep(&nut->time_base);
790  av_freep(&nut->stream);
791  ff_nut_free_sp(nut);
792  for (i = 1; i < nut->header_count; i++)
793  av_freep(&nut->header[i]);
794 
795  return 0;
796 }
797 
799 {
800  NUTContext *nut = s->priv_data;
801  AVIOContext *bc = s->pb;
802  int64_t pos;
803  int initialized_stream_count;
804 
805  nut->avf = s;
806 
807  /* main header */
808  pos = 0;
809  do {
810  pos = find_startcode(bc, MAIN_STARTCODE, pos) + 1;
811  if (pos < 0 + 1) {
812  av_log(s, AV_LOG_ERROR, "No main startcode found.\n");
813  goto fail;
814  }
815  } while (decode_main_header(nut) < 0);
816 
817  /* stream headers */
818  pos = 0;
819  for (initialized_stream_count = 0; initialized_stream_count < s->nb_streams;) {
821  if (pos < 0 + 1) {
822  av_log(s, AV_LOG_ERROR, "Not all stream headers found.\n");
823  goto fail;
824  }
825  if (decode_stream_header(nut) >= 0)
826  initialized_stream_count++;
827  }
828 
829  /* info headers */
830  pos = 0;
831  for (;;) {
832  uint64_t startcode = find_any_startcode(bc, pos);
833  pos = avio_tell(bc);
834 
835  if (startcode == 0) {
836  av_log(s, AV_LOG_ERROR, "EOF before video frames\n");
837  goto fail;
838  } else if (startcode == SYNCPOINT_STARTCODE) {
839  nut->next_startcode = startcode;
840  break;
841  } else if (startcode != INFO_STARTCODE) {
842  continue;
843  }
844 
845  decode_info_header(nut);
846  }
847 
848  s->internal->data_offset = pos - 8;
849 
850  if (bc->seekable & AVIO_SEEKABLE_NORMAL) {
851  int64_t orig_pos = avio_tell(bc);
853  avio_seek(bc, orig_pos, SEEK_SET);
854  }
856 
858 
859  return 0;
860 
861 fail:
862  nut_read_close(s);
863 
864  return AVERROR_INVALIDDATA;
865 }
866 
867 static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
868 {
869  int count = ffio_read_varlen(bc);
870  int skip_start = 0;
871  int skip_end = 0;
872  int channels = 0;
873  int64_t channel_layout = 0;
874  int sample_rate = 0;
875  int width = 0;
876  int height = 0;
877  int i, ret;
878 
879  for (i=0; i<count; i++) {
880  uint8_t name[256], str_value[256], type_str[256];
881  int value;
882  if (avio_tell(bc) >= maxpos)
883  return AVERROR_INVALIDDATA;
884  ret = get_str(bc, name, sizeof(name));
885  if (ret < 0) {
886  av_log(s, AV_LOG_ERROR, "get_str failed while reading sm data\n");
887  return ret;
888  }
889  value = get_s(bc);
890 
891  if (value == -1) {
892  ret = get_str(bc, str_value, sizeof(str_value));
893  if (ret < 0) {
894  av_log(s, AV_LOG_ERROR, "get_str failed while reading sm data\n");
895  return ret;
896  }
897  av_log(s, AV_LOG_WARNING, "Unknown string %s / %s\n", name, str_value);
898  } else if (value == -2) {
899  uint8_t *dst = NULL;
900  int64_t v64, value_len;
901 
902  ret = get_str(bc, type_str, sizeof(type_str));
903  if (ret < 0) {
904  av_log(s, AV_LOG_ERROR, "get_str failed while reading sm data\n");
905  return ret;
906  }
907  value_len = ffio_read_varlen(bc);
908  if (value_len < 0 || value_len >= maxpos - avio_tell(bc))
909  return AVERROR_INVALIDDATA;
910  if (!strcmp(name, "Palette")) {
912  } else if (!strcmp(name, "Extradata")) {
914  } else if (sscanf(name, "CodecSpecificSide%"SCNd64"", &v64) == 1) {
916  if(!dst)
917  return AVERROR(ENOMEM);
918  AV_WB64(dst, v64);
919  dst += 8;
920  } else if (!strcmp(name, "ChannelLayout") && value_len == 8) {
921  channel_layout = avio_rl64(bc);
922  continue;
923  } else {
924  av_log(s, AV_LOG_WARNING, "Unknown data %s / %s\n", name, type_str);
925  avio_skip(bc, value_len);
926  continue;
927  }
928  if(!dst)
929  return AVERROR(ENOMEM);
930  avio_read(bc, dst, value_len);
931  } else if (value == -3) {
932  value = get_s(bc);
933  } else if (value == -4) {
934  value = ffio_read_varlen(bc);
935  } else if (value < -4) {
936  get_s(bc);
937  } else {
938  if (!strcmp(name, "SkipStart")) {
939  skip_start = value;
940  } else if (!strcmp(name, "SkipEnd")) {
941  skip_end = value;
942  } else if (!strcmp(name, "Channels")) {
943  channels = value;
944  } else if (!strcmp(name, "SampleRate")) {
945  sample_rate = value;
946  } else if (!strcmp(name, "Width")) {
947  width = value;
948  } else if (!strcmp(name, "Height")) {
949  height = value;
950  } else {
951  av_log(s, AV_LOG_WARNING, "Unknown integer %s\n", name);
952  }
953  }
954  }
955 
956  if (channels || channel_layout || sample_rate || width || height) {
958  if (!dst)
959  return AVERROR(ENOMEM);
960  bytestream_put_le32(&dst,
962  AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT*(!!channel_layout) +
965  );
966  if (channels)
967  bytestream_put_le32(&dst, channels);
968  if (channel_layout)
969  bytestream_put_le64(&dst, channel_layout);
970  if (sample_rate)
971  bytestream_put_le32(&dst, sample_rate);
972  if (width || height){
973  bytestream_put_le32(&dst, width);
974  bytestream_put_le32(&dst, height);
975  }
976  }
977 
978  if (skip_start || skip_end) {
980  if (!dst)
981  return AVERROR(ENOMEM);
982  AV_WL32(dst, skip_start);
983  AV_WL32(dst+4, skip_end);
984  }
985 
986  if (avio_tell(bc) >= maxpos)
987  return AVERROR_INVALIDDATA;
988 
989  return 0;
990 }
991 
992 static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id,
993  uint8_t *header_idx, int frame_code)
994 {
995  AVFormatContext *s = nut->avf;
996  AVIOContext *bc = s->pb;
997  StreamContext *stc;
998  int size, flags, size_mul, pts_delta, i, reserved_count, ret;
999  uint64_t tmp;
1000 
1001  if (!(nut->flags & NUT_PIPE) &&
1002  avio_tell(bc) > nut->last_syncpoint_pos + nut->max_distance) {
1004  "Last frame must have been damaged %"PRId64" > %"PRId64" + %d\n",
1005  avio_tell(bc), nut->last_syncpoint_pos, nut->max_distance);
1006  return AVERROR_INVALIDDATA;
1007  }
1008 
1009  flags = nut->frame_code[frame_code].flags;
1010  size_mul = nut->frame_code[frame_code].size_mul;
1011  size = nut->frame_code[frame_code].size_lsb;
1012  *stream_id = nut->frame_code[frame_code].stream_id;
1013  pts_delta = nut->frame_code[frame_code].pts_delta;
1014  reserved_count = nut->frame_code[frame_code].reserved_count;
1015  *header_idx = nut->frame_code[frame_code].header_idx;
1016 
1017  if (flags & FLAG_INVALID)
1018  return AVERROR_INVALIDDATA;
1019  if (flags & FLAG_CODED)
1020  flags ^= ffio_read_varlen(bc);
1021  if (flags & FLAG_STREAM_ID) {
1022  GET_V(*stream_id, tmp < s->nb_streams);
1023  }
1024  stc = &nut->stream[*stream_id];
1025  if (flags & FLAG_CODED_PTS) {
1026  int64_t coded_pts = ffio_read_varlen(bc);
1027  // FIXME check last_pts validity?
1028  if (coded_pts < (1LL << stc->msb_pts_shift)) {
1029  *pts = ff_lsb2full(stc, coded_pts);
1030  } else
1031  *pts = coded_pts - (1LL << stc->msb_pts_shift);
1032  } else
1033  *pts = stc->last_pts + pts_delta;
1034  if (flags & FLAG_SIZE_MSB)
1035  size += size_mul * ffio_read_varlen(bc);
1036  if (flags & FLAG_MATCH_TIME)
1037  get_s(bc);
1038  if (flags & FLAG_HEADER_IDX)
1039  *header_idx = ffio_read_varlen(bc);
1040  if (flags & FLAG_RESERVED)
1041  reserved_count = ffio_read_varlen(bc);
1042  for (i = 0; i < reserved_count; i++) {
1043  if (bc->eof_reached) {
1044  av_log(s, AV_LOG_ERROR, "reached EOF while decoding frame header\n");
1045  return AVERROR_INVALIDDATA;
1046  }
1047  ffio_read_varlen(bc);
1048  }
1049 
1050  if (*header_idx >= (unsigned)nut->header_count) {
1051  av_log(s, AV_LOG_ERROR, "header_idx invalid\n");
1052  return AVERROR_INVALIDDATA;
1053  }
1054  if (size > 4096)
1055  *header_idx = 0;
1056  size -= nut->header_len[*header_idx];
1057 
1058  if (flags & FLAG_CHECKSUM) {
1059  avio_rb32(bc); // FIXME check this
1060  } else if (!(nut->flags & NUT_PIPE) &&
1061  size > 2 * nut->max_distance ||
1062  FFABS(stc->last_pts - *pts) > stc->max_pts_distance) {
1063  av_log(s, AV_LOG_ERROR, "frame size > 2max_distance and no checksum\n");
1064  return AVERROR_INVALIDDATA;
1065  }
1066 
1067  stc->last_pts = *pts;
1068  stc->last_flags = flags;
1069 
1070  return size;
1071 fail:
1072  return ret;
1073 }
1074 
1075 static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
1076 {
1077  AVFormatContext *s = nut->avf;
1078  AVIOContext *bc = s->pb;
1079  int size, stream_id, discard, ret;
1080  int64_t pts, last_IP_pts;
1081  StreamContext *stc;
1082  uint8_t header_idx;
1083 
1084  size = decode_frame_header(nut, &pts, &stream_id, &header_idx, frame_code);
1085  if (size < 0)
1086  return size;
1087 
1088  stc = &nut->stream[stream_id];
1089 
1090  if (stc->last_flags & FLAG_KEY)
1091  stc->skip_until_key_frame = 0;
1092 
1093  discard = s->streams[stream_id]->discard;
1094  last_IP_pts = s->streams[stream_id]->last_IP_pts;
1095  if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) ||
1096  (discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE &&
1097  last_IP_pts > pts) ||
1098  discard >= AVDISCARD_ALL ||
1099  stc->skip_until_key_frame) {
1100  avio_skip(bc, size);
1101  return 1;
1102  }
1103 
1104  ret = av_new_packet(pkt, size + nut->header_len[header_idx]);
1105  if (ret < 0)
1106  return ret;
1107  if (nut->header[header_idx])
1108  memcpy(pkt->data, nut->header[header_idx], nut->header_len[header_idx]);
1109  pkt->pos = avio_tell(bc); // FIXME
1110  if (stc->last_flags & FLAG_SM_DATA) {
1111  int sm_size;
1112  if (read_sm_data(s, bc, pkt, 0, pkt->pos + size) < 0) {
1114  goto fail;
1115  }
1116  if (read_sm_data(s, bc, pkt, 1, pkt->pos + size) < 0) {
1118  goto fail;
1119  }
1120  sm_size = avio_tell(bc) - pkt->pos;
1121  size -= sm_size;
1122  pkt->size -= sm_size;
1123  }
1124 
1125  ret = avio_read(bc, pkt->data + nut->header_len[header_idx], size);
1126  if (ret != size) {
1127  if (ret < 0)
1128  goto fail;
1129  }
1130  av_shrink_packet(pkt, nut->header_len[header_idx] + ret);
1131 
1132  pkt->stream_index = stream_id;
1133  if (stc->last_flags & FLAG_KEY)
1135  pkt->pts = pts;
1136 
1137  return 0;
1138 fail:
1140  return ret;
1141 }
1142 
1144 {
1145  NUTContext *nut = s->priv_data;
1146  AVIOContext *bc = s->pb;
1147  int i, frame_code = 0, ret, skip;
1148  int64_t ts, back_ptr;
1149 
1150  for (;;) {
1151  int64_t pos = avio_tell(bc);
1152  uint64_t tmp = nut->next_startcode;
1153  nut->next_startcode = 0;
1154 
1155  if (tmp) {
1156  pos -= 8;
1157  } else {
1158  frame_code = avio_r8(bc);
1159  if (avio_feof(bc))
1160  return AVERROR_EOF;
1161  if (frame_code == 'N') {
1162  tmp = frame_code;
1163  for (i = 1; i < 8; i++)
1164  tmp = (tmp << 8) + avio_r8(bc);
1165  }
1166  }
1167  switch (tmp) {
1168  case MAIN_STARTCODE:
1169  case STREAM_STARTCODE:
1170  case INDEX_STARTCODE:
1171  skip = get_packetheader(nut, bc, 0, tmp);
1172  avio_skip(bc, skip);
1173  break;
1174  case INFO_STARTCODE:
1175  if (decode_info_header(nut) < 0)
1176  goto resync;
1177  break;
1178  case SYNCPOINT_STARTCODE:
1179  if (decode_syncpoint(nut, &ts, &back_ptr) < 0)
1180  goto resync;
1181  frame_code = avio_r8(bc);
1182  case 0:
1183  ret = decode_frame(nut, pkt, frame_code);
1184  if (ret == 0)
1185  return 0;
1186  else if (ret == 1) // OK but discard packet
1187  break;
1188  default:
1189 resync:
1190  av_log(s, AV_LOG_DEBUG, "syncing from %"PRId64"\n", pos);
1192  nut->last_resync_pos = avio_tell(bc);
1193  if (tmp == 0)
1194  return AVERROR_INVALIDDATA;
1195  av_log(s, AV_LOG_DEBUG, "sync\n");
1196  nut->next_startcode = tmp;
1197  }
1198  }
1199 }
1200 
1201 static int64_t nut_read_timestamp(AVFormatContext *s, int stream_index,
1202  int64_t *pos_arg, int64_t pos_limit)
1203 {
1204  NUTContext *nut = s->priv_data;
1205  AVIOContext *bc = s->pb;
1206  int64_t pos, pts, back_ptr;
1207  av_log(s, AV_LOG_DEBUG, "read_timestamp(X,%d,%"PRId64",%"PRId64")\n",
1208  stream_index, *pos_arg, pos_limit);
1209 
1210  pos = *pos_arg;
1211  do {
1213  if (pos < 1) {
1214  av_log(s, AV_LOG_ERROR, "read_timestamp failed.\n");
1215  return AV_NOPTS_VALUE;
1216  }
1217  } while (decode_syncpoint(nut, &pts, &back_ptr) < 0);
1218  *pos_arg = pos - 1;
1219  av_assert0(nut->last_syncpoint_pos == *pos_arg);
1220 
1221  av_log(s, AV_LOG_DEBUG, "return %"PRId64" %"PRId64"\n", pts, back_ptr);
1222  if (stream_index == -2)
1223  return back_ptr;
1224  av_assert0(stream_index == -1);
1225  return pts;
1226 }
1227 
1228 static int read_seek(AVFormatContext *s, int stream_index,
1229  int64_t pts, int flags)
1230 {
1231  NUTContext *nut = s->priv_data;
1232  AVStream *st = s->streams[stream_index];
1233  Syncpoint dummy = { .ts = pts * av_q2d(st->time_base) * AV_TIME_BASE };
1234  Syncpoint nopts_sp = { .ts = AV_NOPTS_VALUE, .back_ptr = AV_NOPTS_VALUE };
1235  Syncpoint *sp, *next_node[2] = { &nopts_sp, &nopts_sp };
1236  int64_t pos, pos2, ts;
1237  int i;
1238 
1239  if (nut->flags & NUT_PIPE) {
1240  return AVERROR(ENOSYS);
1241  }
1242 
1243  if (st->index_entries) {
1245  if (index < 0)
1247  if (index < 0)
1248  return -1;
1249 
1250  pos2 = st->index_entries[index].pos;
1251  ts = st->index_entries[index].timestamp;
1252  } else {
1254  (void **) next_node);
1255  av_log(s, AV_LOG_DEBUG, "%"PRIu64"-%"PRIu64" %"PRId64"-%"PRId64"\n",
1256  next_node[0]->pos, next_node[1]->pos, next_node[0]->ts,
1257  next_node[1]->ts);
1258  pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos,
1259  next_node[1]->pos, next_node[1]->pos,
1260  next_node[0]->ts, next_node[1]->ts,
1262  if (pos < 0)
1263  return pos;
1264 
1265  if (!(flags & AVSEEK_FLAG_BACKWARD)) {
1266  dummy.pos = pos + 16;
1267  next_node[1] = &nopts_sp;
1269  (void **) next_node);
1270  pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos,
1271  next_node[1]->pos, next_node[1]->pos,
1272  next_node[0]->back_ptr, next_node[1]->back_ptr,
1273  flags, &ts, nut_read_timestamp);
1274  if (pos2 >= 0)
1275  pos = pos2;
1276  // FIXME dir but I think it does not matter
1277  }
1278  dummy.pos = pos;
1280  NULL);
1281 
1282  av_assert0(sp);
1283  pos2 = sp->back_ptr - 15;
1284  }
1285  av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2);
1286  pos = find_startcode(s->pb, SYNCPOINT_STARTCODE, pos2);
1287  avio_seek(s->pb, pos, SEEK_SET);
1288  nut->last_syncpoint_pos = pos;
1289  av_log(s, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos);
1290  if (pos2 > pos || pos2 + 15 < pos)
1291  av_log(s, AV_LOG_ERROR, "no syncpoint at backptr pos\n");
1292  for (i = 0; i < s->nb_streams; i++)
1293  nut->stream[i].skip_until_key_frame = 1;
1294 
1295  nut->last_resync_pos = 0;
1296 
1297  return 0;
1298 }
1299 
1301  .name = "nut",
1302  .long_name = NULL_IF_CONFIG_SMALL("NUT"),
1303  .flags = AVFMT_SEEK_TO_PTS,
1304  .priv_data_size = sizeof(NUTContext),
1305  .read_probe = nut_probe,
1309  .read_seek = read_seek,
1310  .extensions = "nut",
1311  .codec_tag = ff_nut_codec_tags,
1312 };
AVStream::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:1094
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:605
nut_read_close
static int nut_read_close(AVFormatContext *s)
Definition: nutdec.c:784
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
av_codec_get_id
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
ff_nut_audio_extra_tags
const AVCodecTag ff_nut_audio_extra_tags[]
Definition: nut.c:209
FrameCode::stream_id
uint8_t stream_id
Definition: nut.h:67
AVChapter::metadata
AVDictionary * metadata
Definition: avformat.h:1296
NUT_PIPE
#define NUT_PIPE
Definition: nut.h:114
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4526
decode_frame
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code)
Definition: nutdec.c:1075
StreamContext::last_flags
int last_flags
Definition: nut.h:76
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:56
NUTContext::time_base_count
unsigned int time_base_count
Definition: nut.h:103
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
last_pts
static int64_t last_pts
Definition: filtering_video.c:52
NUT_MAX_VERSION
#define NUT_MAX_VERSION
Definition: nut.h:39
ff_get_extradata
int ff_get_extradata(AVFormatContext *s, AVCodecParameters *par, AVIOContext *pb, int size)
Allocate extradata with additional AV_INPUT_BUFFER_PADDING_SIZE at end which is always set to 0 and f...
Definition: utils.c:3346
NUTContext::minor_version
int minor_version
Definition: nut.h:117
AV_PKT_DATA_PARAM_CHANGE
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
Definition: packet.h:72
NUTContext::max_distance
unsigned int max_distance
Definition: nut.h:102
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:55
nut_read_packet
static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: nutdec.c:1143
ff_find_last_ts
int ff_find_last_ts(AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos, int64_t(*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t))
Definition: utils.c:2252
ff_nut_data_tags
const AVCodecTag ff_nut_data_tags[]
Definition: nut.c:36
SYNCPOINT_STARTCODE
#define SYNCPOINT_STARTCODE
Definition: nut.h:31
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
av_strcasecmp
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:213
ff_gen_search
int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t(*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t))
Perform a binary search using read_timestamp().
Definition: utils.c:2290
FLAG_RESERVED
@ FLAG_RESERVED
Definition: nut.h:50
STREAM_STARTCODE
#define STREAM_STARTCODE
Definition: nut.h:30
end
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:92
av_be2ne64
#define av_be2ne64(x)
Definition: bswap.h:94
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:26
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1403
AVPacket::data
uint8_t * data
Definition: packet.h:355
ff_nut_dispositions
const Dispositions ff_nut_dispositions[]
Definition: nut.c:322
NUTContext::last_syncpoint_pos
int64_t last_syncpoint_pos
Definition: nut.h:104
AV_PKT_DATA_PALETTE
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
Definition: packet.h:46
NUTContext::header_len
uint8_t header_len[128]
Definition: nut.h:97
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
@ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
Definition: packet.h:412
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
ff_codec_wav_tags
const AVCodecTag ff_codec_wav_tags[]
Definition: riff.c:506
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
find_any_startcode
static uint64_t find_any_startcode(AVIOContext *bc, int64_t pos)
Definition: nutdec.c:109
StreamContext::decode_delay
int decode_delay
Definition: nut.h:83
mathematics.h
ff_nut_reset_ts
void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val)
Definition: nut.c:253
AVDictionary
Definition: dict.c:30
FrameCode::size_lsb
uint16_t size_lsb
Definition: nut.h:69
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:444
nut_probe
static int nut_probe(const AVProbeData *p)
Definition: nutdec.c:152
Syncpoint
Definition: nut.h:58
read_sm_data
static int read_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta, int64_t maxpos)
Definition: nutdec.c:867
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT
@ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT
Definition: packet.h:411
avio_size
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:334
get_fourcc
static uint64_t get_fourcc(AVIOContext *bc)
Definition: nutdec.c:75
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:388
sample_rate
sample_rate
Definition: ffmpeg_filter.c:192
ffio_get_checksum
unsigned long ffio_get_checksum(AVIOContext *s)
Definition: aviobuf.c:596
AV_WB64
#define AV_WB64(p, v)
Definition: intreadwrite.h:433
NUTContext::last_resync_pos
int64_t last_resync_pos
Definition: nut.h:105
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:31
AVINDEX_KEYFRAME
#define AVINDEX_KEYFRAME
Definition: avformat.h:803
av_gcd
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
Definition: mathematics.c:37
A
#define A(x)
Definition: vp56_arith.h:28
ff_nut_sp_pos_cmp
int ff_nut_sp_pos_cmp(const void *a, const void *b)
Definition: nut.c:271
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:453
ff_nut_free_sp
void ff_nut_free_sp(NUTContext *nut)
Definition: nut.c:314
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
get_s
static int64_t get_s(AVIOContext *bc)
Definition: nutdec.c:65
AVFMT_SEEK_TO_PTS
#define AVFMT_SEEK_TO_PTS
Seeking is based on PTS.
Definition: avformat.h:484
U
#define U(x)
Definition: vp56_arith.h:37
fail
#define fail()
Definition: checkasm.h:123
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: avpacket.c:103
av_add_index_entry
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
Definition: utils.c:2052
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
NUTContext::avf
AVFormatContext * avf
Definition: nut.h:93
AVChapter
Definition: avformat.h:1292
AVFMT_DURATION_FROM_PTS
@ AVFMT_DURATION_FROM_PTS
Duration accurately estimated from PTSes.
Definition: avformat.h:1314
skip_reserved
static int skip_reserved(AVIOContext *bc, int64_t pos)
Definition: nutdec.c:176
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
pts
static int64_t pts
Definition: transcode_aac.c:647
NUTContext::header
const uint8_t * header[128]
Definition: nut.h:98
NUT_MAX_STREAMS
#define NUT_MAX_STREAMS
Definition: nutdec.c:36
avio_rl16
unsigned int avio_rl16(AVIOContext *s)
Definition: aviobuf.c:731
Syncpoint::ts
int64_t ts
Definition: nut.h:62
AVRational::num
int num
Numerator.
Definition: rational.h:59
NUTContext::header_count
int header_count
Definition: nut.h:106
avassert.h
avio_rb32
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:778
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
NUTContext
Definition: nut.h:91
AVInputFormat
Definition: avformat.h:636
AVCodecTag
Definition: internal.h:42
duration
int64_t duration
Definition: movenc.c:63
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
Definition: packet.h:413
width
#define width
intreadwrite.h
ff_nut_metadata_conv
const AVMetadataConv ff_nut_metadata_conv[]
Definition: nut.c:332
s
#define s(width, name)
Definition: cbs_vp9.c:257
nut.h
av_new_packet
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
Definition: avpacket.c:88
FrameCode::reserved_count
uint8_t reserved_count
Definition: nut.h:71
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:641
get_str
static int get_str(AVIOContext *bc, char *string, unsigned int maxlen)
Definition: nutdec.c:41
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:443
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
NUTContext::time_base
AVRational * time_base
Definition: nut.h:107
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
find_startcode
static int64_t find_startcode(AVIOContext *bc, uint64_t code, int64_t pos)
Find the given startcode.
Definition: nutdec.c:140
AVIndexEntry::timestamp
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
Definition: avformat.h:797
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
nut_read_timestamp
static int64_t nut_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit)
Definition: nutdec.c:1201
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
StreamContext::last_pts
int64_t last_pts
Definition: nut.h:78
channels
channels
Definition: aptx.h:33
nb_streams
static int nb_streams
Definition: ffprobe.c:282
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
FrameCode::size_mul
uint16_t size_mul
Definition: nut.h:68
FLAG_INVALID
@ FLAG_INVALID
Definition: nut.h:55
AVDISCARD_BIDIR
@ AVDISCARD_BIDIR
discard all bidirectional frames
Definition: avcodec.h:233
av_packet_new_side_data
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
Definition: avpacket.c:332
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
GET_V
#define GET_V(dst, check)
Definition: nutdec.c:165
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: avcodec.h:236
AVFormatContext
Format I/O context.
Definition: avformat.h:1335
ff_metadata_conv_ctx
void ff_metadata_conv_ctx(AVFormatContext *ctx, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition: metadata.c:59
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1012
AVSEEK_FLAG_BACKWARD
#define AVSEEK_FLAG_BACKWARD
Definition: avformat.h:2496
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:527
Dispositions::flag
int flag
Definition: nut.h:130
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:894
NULL
#define NULL
Definition: coverity.c:32
read_probe
static int read_probe(const AVProbeData *pd)
Definition: jvdec.c:55
NUT_BROADCAST
#define NUT_BROADCAST
Definition: nut.h:113
isom.h
ff_nut_sp_pts_cmp
int ff_nut_sp_pts_cmp(const void *a, const void *b)
Definition: nut.c:277
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
avio_rb64
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:899
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:441
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:929
read_seek
static int read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
Definition: nutdec.c:1228
ff_nut_video_tags
const AVCodecTag ff_nut_video_tags[]
Definition: nut.c:41
FLAG_MATCH_TIME
@ FLAG_MATCH_TIME
Definition: nut.h:53
AVSTREAM_EVENT_FLAG_METADATA_UPDATED
#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED
The call resulted in updated metadata.
Definition: avformat.h:979
index
int index
Definition: gxfenc.c:89
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
FLAG_CODED
@ FLAG_CODED
Definition: nut.h:54
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1391
StreamContext
Definition: transcoding.c:47
decode_main_header
static int decode_main_header(NUTContext *nut)
Definition: nutdec.c:192
StreamContext::time_base_id
int time_base_id
Definition: nut.h:79
FLAG_SIZE_MSB
@ FLAG_SIZE_MSB
Definition: nut.h:48
ff_codec_movvideo_tags
const AVCodecTag ff_codec_movvideo_tags[]
Definition: isom.c:75
avio_rl32
unsigned int avio_rl32(AVIOContext *s)
Definition: aviobuf.c:747
AVDISCARD_NONKEY
@ AVDISCARD_NONKEY
discard all frames except keyframes
Definition: avcodec.h:235
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
AVPacket::size
int size
Definition: packet.h:356
FrameCode::pts_delta
int16_t pts_delta
Definition: nut.h:70
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
ff_codec_get_id
enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
Definition: utils.c:3165
AVIOContext::seekable
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:260
sp
#define sp
Definition: regdef.h:63
FFMAX
#define FFMAX(a, b)
Definition: common.h:94
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4948
NUTContext::flags
int flags
Definition: nut.h:115
ff_nut_audio_tags
const AVCodecTag ff_nut_audio_tags[]
Definition: nut.c:219
size
int size
Definition: twinvq_data.h:11134
state
static struct @314 state
NUTContext::stream
StreamContext * stream
Definition: nut.h:100
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:92
AVStream::event_flags
int event_flags
Flags for the user to detect events happening on the stream.
Definition: avformat.h:978
FrameCode::flags
uint16_t flags
Definition: nut.h:66
ffio_init_checksum
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
Definition: aviobuf.c:604
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:927
tree.h
avio_r8
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:616
height
#define height
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:361
ffio_read_varlen
uint64_t ffio_read_varlen(AVIOContext *bc)
Definition: aviobuf.c:907
NUTContext::version
int version
Definition: nut.h:116
StreamContext::msb_pts_shift
int msb_pts_shift
Definition: nut.h:81
ff_crc04C11DB7_update
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
Definition: aviobuf.c:578
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
flag
#define flag(name)
Definition: cbs_av1.c:557
ff_nut_add_sp
int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
Definition: nut.c:283
NUTContext::syncpoints
struct AVTreeNode * syncpoints
Definition: nut.h:108
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:47
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:348
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
avio_internal.h
ff_lsb2full
int64_t ff_lsb2full(StreamContext *stream, int64_t lsb)
Definition: nut.c:264
NUTContext::next_startcode
uint64_t next_startcode
Definition: nut.h:99
find_and_decode_index
static int find_and_decode_index(NUTContext *nut)
Definition: nutdec.c:670
AVCodecParameters::height
int height
Definition: codec_par.h:127
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
resync
static int resync(AVFormatContext *s)
Definition: flvdec.c:974
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
StreamContext::skip_until_key_frame
int skip_until_key_frame
Definition: nut.h:77
avpriv_new_chapter
AVChapter * avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
Definition: utils.c:4654
get_packetheader
static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_checksum, uint64_t startcode)
Definition: nutdec.c:89
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
ff_nut_demuxer
AVInputFormat ff_nut_demuxer
Definition: nutdec.c:1300
uint8_t
uint8_t
Definition: audio_convert.c:194
AV_PKT_DATA_SKIP_SAMPLES
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: packet.h:156
len
int len
Definition: vorbis_enc_data.h:452
NUTContext::frame_code
FrameCode frame_code[256]
Definition: nut.h:96
FLAG_SM_DATA
@ FLAG_SM_DATA
Definition: nut.h:51
decode_frame_header
static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, uint8_t *header_idx, int frame_code)
Definition: nutdec.c:992
AVStream::disposition
int disposition
AV_DISPOSITION_* bit field.
Definition: avformat.h:918
ret
ret
Definition: filter_design.txt:187
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVStream
Stream structure.
Definition: avformat.h:865
bswap.h
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:241
FLAG_STREAM_ID
@ FLAG_STREAM_ID
Definition: nut.h:47
decode_syncpoint
static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr)
Definition: nutdec.c:614
pos
unsigned int pos
Definition: spdifenc.c:412
dict.h
FrameCode::header_idx
uint8_t header_idx
Definition: nut.h:72
set_disposition_bits
static void set_disposition_bits(AVFormatContext *avf, char *value, int stream_id)
Definition: nutdec.c:476
FLAG_CHECKSUM
@ FLAG_CHECKSUM
Definition: nut.h:49
FLAG_KEY
@ FLAG_KEY
Definition: nut.h:44
B
#define B
Definition: huffyuvdsp.h:32
ff_codec_bmp_tags
const AVCodecTag ff_codec_bmp_tags[]
Definition: riff.c:32
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
ff_nut_codec_tags
const AVCodecTag *const ff_nut_codec_tags[]
Definition: nut.c:248
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT
@ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT
Definition: packet.h:410
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
FLAG_HEADER_IDX
@ FLAG_HEADER_IDX
Definition: nut.h:52
AVIO_SEEKABLE_NORMAL
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
Definition: avio.h:40
AV_PKT_DATA_NEW_EXTRADATA
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition: packet.h:55
AVRational::den
int den
Denominator.
Definition: rational.h:60
dummy
int dummy
Definition: motion.c:64
nut_read_header
static int nut_read_header(AVFormatContext *s)
Definition: nutdec.c:798
avio_read
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:625
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:989
AVIndexEntry::pos
int64_t pos
Definition: avformat.h:796
AVIOContext::eof_reached
int eof_reached
true if was unable to read due to error or eof
Definition: avio.h:239
AVPacket::stream_index
int stream_index
Definition: packet.h:357
av_tree_find
void * av_tree_find(const AVTreeNode *t, void *key, int(*cmp)(const void *key, const void *b), void *next[2])
Definition: tree.c:39
avio_skip
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
Definition: aviobuf.c:329
NUT_MIN_VERSION
#define NUT_MIN_VERSION
Definition: nut.h:41
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
Definition: packet.h:191
ff_nut_subtitle_tags
const AVCodecTag ff_nut_subtitle_tags[]
Definition: nut.c:28
AVCodecParameters::video_delay
int video_delay
Video only.
Definition: codec_par.h:155
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
FLAG_CODED_PTS
@ FLAG_CODED_PTS
Definition: nut.h:46
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:60
decode_stream_header
static int decode_stream_header(NUTContext *nut)
Definition: nutdec.c:367
AVPacket
This structure stores compressed data.
Definition: packet.h:332
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:70
riff.h
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:375
avio_rl64
uint64_t avio_rl64(AVIOContext *s)
Definition: aviobuf.c:755
INDEX_STARTCODE
#define INDEX_STARTCODE
Definition: nut.h:32
bytestream.h
convert_header.str
string str
Definition: convert_header.py:20
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
avstring.h
StreamContext::time_base
AVRational time_base
Definition: signature.h:103
find_duration
static int64_t find_duration(NUTContext *nut, int64_t filesize)
Definition: nutdec.c:658
INFO_STARTCODE
#define INFO_STARTCODE
Definition: nut.h:33
MAIN_STARTCODE
#define MAIN_STARTCODE
Definition: nut.h:29
StreamContext::max_pts_distance
int max_pts_distance
Definition: nut.h:82
AVFMT_EVENT_FLAG_METADATA_UPDATED
#define AVFMT_EVENT_FLAG_METADATA_UPDATED
The call resulted in updated metadata.
Definition: avformat.h:1651
decode_info_header
static int decode_info_header(NUTContext *nut)
Definition: nutdec.c:491
av_index_search_timestamp
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
Definition: utils.c:2169
avio_feof
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
Definition: aviobuf.c:356