FFmpeg
nutenc.c
Go to the documentation of this file.
1 /*
2  * nut muxer
3  * Copyright (c) 2004-2007 Michael Niedermayer
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <stdint.h>
23 
24 #include "libavutil/intreadwrite.h"
25 #include "libavutil/mathematics.h"
26 #include "libavutil/tree.h"
27 #include "libavutil/dict.h"
28 #include "libavutil/avassert.h"
29 #include "libavutil/time.h"
30 #include "libavutil/opt.h"
31 #include "libavcodec/bytestream.h"
33 #include "nut.h"
34 #include "internal.h"
35 #include "avio_internal.h"
36 #include "riff.h"
37 
38 static int find_expected_header(AVCodecParameters *p, int size, int key_frame,
39  uint8_t out[64])
40 {
41  int sample_rate = p->sample_rate;
42 
43  if (size > 4096)
44  return 0;
45 
46  AV_WB24(out, 1);
47 
48  if (p->codec_id == AV_CODEC_ID_MPEG4) {
49  if (key_frame) {
50  return 3;
51  } else {
52  out[3] = 0xB6;
53  return 4;
54  }
55  } else if (p->codec_id == AV_CODEC_ID_MPEG1VIDEO ||
57  return 3;
58  } else if (p->codec_id == AV_CODEC_ID_H264) {
59  return 3;
60  } else if (p->codec_id == AV_CODEC_ID_MP3 ||
61  p->codec_id == AV_CODEC_ID_MP2) {
62  int lsf, mpeg25, sample_rate_index, bitrate_index, frame_size;
63  int layer = p->codec_id == AV_CODEC_ID_MP3 ? 3 : 2;
64  unsigned int header = 0xFFF00000;
65 
66  lsf = sample_rate < (24000 + 32000) / 2;
67  mpeg25 = sample_rate < (12000 + 16000) / 2;
68  sample_rate <<= lsf + mpeg25;
69  if (sample_rate < (32000 + 44100) / 2) sample_rate_index = 2;
70  else if (sample_rate < (44100 + 48000) / 2) sample_rate_index = 0;
71  else sample_rate_index = 1;
72 
73  sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25);
74 
75  for (bitrate_index = 2; bitrate_index < 30; bitrate_index++) {
76  frame_size =
77  avpriv_mpa_bitrate_tab[lsf][layer - 1][bitrate_index >> 1];
78  frame_size = (frame_size * 144000) / (sample_rate << lsf) +
79  (bitrate_index & 1);
80 
81  if (frame_size == size)
82  break;
83  }
84 
85  header |= (!lsf) << 19;
86  header |= (4 - layer) << 17;
87  header |= 1 << 16; //no crc
88  AV_WB32(out, header);
89  if (size <= 0)
90  return 2; //we guess there is no crc, if there is one the user clearly does not care about overhead
91  if (bitrate_index == 30)
92  return -1; //something is wrong ...
93 
94  header |= (bitrate_index >> 1) << 12;
95  header |= sample_rate_index << 10;
96  header |= (bitrate_index & 1) << 9;
97 
98  return 2; //FIXME actually put the needed ones in build_elision_headers()
99  //return 3; //we guess that the private bit is not set
100 //FIXME the above assumptions should be checked, if these turn out false too often something should be done
101  }
102  return 0;
103 }
104 
106  int frame_type)
107 {
108  NUTContext *nut = s->priv_data;
109  uint8_t out[64];
110  int i;
112 
113  for (i = 1; i < nut->header_count; i++) {
114  if (len == nut->header_len[i] && !memcmp(out, nut->header[i], len)) {
115  return i;
116  }
117  }
118 
119  return 0;
120 }
121 
123 {
124  NUTContext *nut = s->priv_data;
125  int i;
126  //FIXME this is lame
127  //FIXME write a 2pass mode to find the maximal headers
128  static const uint8_t headers[][5] = {
129  { 3, 0x00, 0x00, 0x01 },
130  { 4, 0x00, 0x00, 0x01, 0xB6},
131  { 2, 0xFF, 0xFA }, //mp3+crc
132  { 2, 0xFF, 0xFB }, //mp3
133  { 2, 0xFF, 0xFC }, //mp2+crc
134  { 2, 0xFF, 0xFD }, //mp2
135  };
136 
137  nut->header_count = 7;
138  for (i = 1; i < nut->header_count; i++) {
139  nut->header_len[i] = headers[i - 1][0];
140  nut->header[i] = &headers[i - 1][1];
141  }
142 }
143 
145 {
146  NUTContext *nut = s->priv_data;
147  int key_frame, index, pred, stream_id;
148  int start = 1;
149  int end = 254;
150  int keyframe_0_esc = s->nb_streams > 2;
151  int pred_table[10];
152  FrameCode *ft;
153 
154  ft = &nut->frame_code[start];
155  ft->flags = FLAG_CODED;
156  ft->size_mul = 1;
157  ft->pts_delta = 1;
158  start++;
159 
160  if (keyframe_0_esc) {
161  /* keyframe = 0 escape */
162  FrameCode *ft = &nut->frame_code[start];
164  ft->size_mul = 1;
165  start++;
166  }
167 
168  for (stream_id = 0; stream_id < s->nb_streams; stream_id++) {
169  int start2 = start + (end - start) * stream_id / s->nb_streams;
170  int end2 = start + (end - start) * (stream_id + 1) / s->nb_streams;
171  AVCodecParameters *par = s->streams[stream_id]->codecpar;
172  int is_audio = par->codec_type == AVMEDIA_TYPE_AUDIO;
173  int intra_only = /*codec->intra_only || */ is_audio;
174  int pred_count;
175  int frame_size = 0;
176 
177  if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
179  if (par->codec_id == AV_CODEC_ID_VORBIS && !frame_size)
180  frame_size = 64;
181  } else {
182  AVRational f = av_div_q(av_inv_q(s->streams[stream_id]->avg_frame_rate), *nut->stream[stream_id].time_base);
183  if (f.den == 1 && f.num>0)
184  frame_size = f.num;
185  }
186  if (!frame_size)
187  frame_size = 1;
188 
189  for (key_frame = 0; key_frame < 2; key_frame++) {
190  if (!intra_only || !keyframe_0_esc || key_frame != 0) {
191  FrameCode *ft = &nut->frame_code[start2];
192  ft->flags = FLAG_KEY * key_frame;
194  ft->stream_id = stream_id;
195  ft->size_mul = 1;
196  if (is_audio)
197  ft->header_idx = find_header_idx(s, par, -1, key_frame);
198  start2++;
199  }
200  }
201 
202  key_frame = intra_only;
203 #if 1
204  if (is_audio) {
205  int frame_bytes;
206  int pts;
207 
208  if (par->block_align > 0) {
209  frame_bytes = par->block_align;
210  } else {
212  frame_bytes = frame_size * (int64_t)par->bit_rate / (8 * par->sample_rate);
213  }
214 
215  for (pts = 0; pts < 2; pts++) {
216  for (pred = 0; pred < 2; pred++) {
217  FrameCode *ft = &nut->frame_code[start2];
218  ft->flags = FLAG_KEY * key_frame;
219  ft->stream_id = stream_id;
220  ft->size_mul = frame_bytes + 2;
221  ft->size_lsb = frame_bytes + pred;
222  ft->pts_delta = pts * frame_size;
223  ft->header_idx = find_header_idx(s, par, frame_bytes + pred, key_frame);
224  start2++;
225  }
226  }
227  } else {
228  FrameCode *ft = &nut->frame_code[start2];
229  ft->flags = FLAG_KEY | FLAG_SIZE_MSB;
230  ft->stream_id = stream_id;
231  ft->size_mul = 1;
232  ft->pts_delta = frame_size;
233  start2++;
234  }
235 #endif
236 
237  if (par->video_delay) {
238  pred_count = 5;
239  pred_table[0] = -2;
240  pred_table[1] = -1;
241  pred_table[2] = 1;
242  pred_table[3] = 3;
243  pred_table[4] = 4;
244  } else if (par->codec_id == AV_CODEC_ID_VORBIS) {
245  pred_count = 3;
246  pred_table[0] = 2;
247  pred_table[1] = 9;
248  pred_table[2] = 16;
249  } else {
250  pred_count = 1;
251  pred_table[0] = 1;
252  }
253 
254  for (pred = 0; pred < pred_count; pred++) {
255  int start3 = start2 + (end2 - start2) * pred / pred_count;
256  int end3 = start2 + (end2 - start2) * (pred + 1) / pred_count;
257 
258  pred_table[pred] *= frame_size;
259 
260  for (index = start3; index < end3; index++) {
261  FrameCode *ft = &nut->frame_code[index];
262  ft->flags = FLAG_KEY * key_frame;
263  ft->flags |= FLAG_SIZE_MSB;
264  ft->stream_id = stream_id;
265 //FIXME use single byte size and pred from last
266  ft->size_mul = end3 - start3;
267  ft->size_lsb = index - start3;
268  ft->pts_delta = pred_table[pred];
269  if (is_audio)
270  ft->header_idx = find_header_idx(s, par, -1, key_frame);
271  }
272  }
273  }
274  memmove(&nut->frame_code['N' + 1], &nut->frame_code['N'], sizeof(FrameCode) * (255 - 'N'));
275  nut->frame_code[0].flags =
276  nut->frame_code[255].flags =
277  nut->frame_code['N'].flags = FLAG_INVALID;
278 }
279 
280 /**
281  * Get the length in bytes which is needed to store val as v.
282  */
283 static int get_v_length(uint64_t val)
284 {
285  int i = 1;
286 
287  while (val >>= 7)
288  i++;
289 
290  return i;
291 }
292 
293 /**
294  * Put val using a variable number of bytes.
295  */
296 static void put_v(AVIOContext *bc, uint64_t val)
297 {
298  int i = get_v_length(val);
299 
300  while (--i > 0)
301  avio_w8(bc, 128 | (uint8_t)(val >> (7*i)));
302 
303  avio_w8(bc, val & 127);
304 }
305 
306 static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val)
307 {
308  val *= nut->time_base_count;
309  val += time_base - nut->time_base;
310  put_v(bc, val);
311 }
312 /**
313  * Store a string as vb.
314  */
315 static void put_str(AVIOContext *bc, const char *string)
316 {
317  size_t len = strlen(string);
318 
319  put_v(bc, len);
320  avio_write(bc, string, len);
321 }
322 
323 static void put_s(AVIOContext *bc, int64_t val)
324 {
325  put_v(bc, 2 * FFABS(val) - (val > 0));
326 }
327 
328 static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc,
329  uint64_t startcode)
330 {
331  uint8_t *dyn_buf = NULL;
332  int dyn_size = avio_get_dyn_buf(dyn_bc, &dyn_buf);
333  int forw_ptr = dyn_size + 4;
334 
335  if (forw_ptr > 4096)
337  avio_wb64(bc, startcode);
338  put_v(bc, forw_ptr);
339  if (forw_ptr > 4096)
340  avio_wl32(bc, ffio_get_checksum(bc));
341 
343  avio_write(bc, dyn_buf, dyn_size);
344  avio_wl32(bc, ffio_get_checksum(bc));
345 
346  ffio_reset_dyn_buf(dyn_bc);
347 }
348 
350 {
351  int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields,
352  tmp_head_idx;
353  int64_t tmp_match;
354 
355  put_v(bc, nut->version);
356  if (nut->version > 3)
357  put_v(bc, nut->minor_version = 1);
358  put_v(bc, nut->avf->nb_streams);
359  put_v(bc, nut->max_distance);
360  put_v(bc, nut->time_base_count);
361 
362  for (i = 0; i < nut->time_base_count; i++) {
363  put_v(bc, nut->time_base[i].num);
364  put_v(bc, nut->time_base[i].den);
365  }
366 
367  tmp_pts = 0;
368  tmp_mul = 1;
369  tmp_stream = 0;
370  tmp_match = 1 - (1LL << 62);
371  tmp_head_idx = 0;
372  for (i = 0; i < 256; ) {
373  tmp_fields = 0;
374  tmp_size = 0;
375 // tmp_res=0;
376  if (tmp_pts != nut->frame_code[i].pts_delta ) tmp_fields = 1;
377  if (tmp_mul != nut->frame_code[i].size_mul ) tmp_fields = 2;
378  if (tmp_stream != nut->frame_code[i].stream_id ) tmp_fields = 3;
379  if (tmp_size != nut->frame_code[i].size_lsb ) tmp_fields = 4;
380 // if (tmp_res != nut->frame_code[i].res ) tmp_fields=5;
381  if (tmp_head_idx != nut->frame_code[i].header_idx) tmp_fields = 8;
382 
383  tmp_pts = nut->frame_code[i].pts_delta;
384  tmp_flags = nut->frame_code[i].flags;
385  tmp_stream = nut->frame_code[i].stream_id;
386  tmp_mul = nut->frame_code[i].size_mul;
387  tmp_size = nut->frame_code[i].size_lsb;
388 // tmp_res = nut->frame_code[i].res;
389  tmp_head_idx = nut->frame_code[i].header_idx;
390 
391  for (j = 0; i < 256; j++, i++) {
392  if (i == 'N') {
393  j--;
394  continue;
395  }
396  if (nut->frame_code[i].pts_delta != tmp_pts ||
397  nut->frame_code[i].flags != tmp_flags ||
398  nut->frame_code[i].stream_id != tmp_stream ||
399  nut->frame_code[i].size_mul != tmp_mul ||
400  nut->frame_code[i].size_lsb != tmp_size + j ||
401 // nut->frame_code[i].res != tmp_res ||
402  nut->frame_code[i].header_idx != tmp_head_idx)
403  break;
404  }
405  if (j != tmp_mul - tmp_size)
406  tmp_fields = 6;
407 
408  put_v(bc, tmp_flags);
409  put_v(bc, tmp_fields);
410  if (tmp_fields > 0) put_s(bc, tmp_pts);
411  if (tmp_fields > 1) put_v(bc, tmp_mul);
412  if (tmp_fields > 2) put_v(bc, tmp_stream);
413  if (tmp_fields > 3) put_v(bc, tmp_size);
414  if (tmp_fields > 4) put_v(bc, 0 /*tmp_res*/);
415  if (tmp_fields > 5) put_v(bc, j);
416  if (tmp_fields > 6) put_v(bc, tmp_match);
417  if (tmp_fields > 7) put_v(bc, tmp_head_idx);
418  }
419  put_v(bc, nut->header_count - 1);
420  for (i = 1; i < nut->header_count; i++) {
421  put_v(bc, nut->header_len[i]);
422  avio_write(bc, nut->header[i], nut->header_len[i]);
423  }
424  // flags had been effectively introduced in version 4
425  if (nut->version > 3)
426  put_v(bc, nut->flags);
427 }
428 
430  AVStream *st, int i)
431 {
432  NUTContext *nut = avctx->priv_data;
433  AVCodecParameters *par = st->codecpar;
434 
435  put_v(bc, i);
436  switch (par->codec_type) {
437  case AVMEDIA_TYPE_VIDEO: put_v(bc, 0); break;
438  case AVMEDIA_TYPE_AUDIO: put_v(bc, 1); break;
439  case AVMEDIA_TYPE_SUBTITLE: put_v(bc, 2); break;
440  default: put_v(bc, 3); break;
441  }
442  put_v(bc, 4);
443 
444  if (par->codec_tag) {
445  avio_wl32(bc, par->codec_tag);
446  } else {
447  av_log(avctx, AV_LOG_ERROR, "No codec tag defined for stream %d\n", i);
448  return AVERROR(EINVAL);
449  }
450 
451  put_v(bc, nut->stream[i].time_base - nut->time_base);
452  put_v(bc, nut->stream[i].msb_pts_shift);
453  put_v(bc, nut->stream[i].max_pts_distance);
454  put_v(bc, par->video_delay);
455  avio_w8(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
456 
457  put_v(bc, par->extradata_size);
458  avio_write(bc, par->extradata, par->extradata_size);
459 
460  switch (par->codec_type) {
461  case AVMEDIA_TYPE_AUDIO:
462  put_v(bc, par->sample_rate);
463  put_v(bc, 1);
464  put_v(bc, par->channels);
465  break;
466  case AVMEDIA_TYPE_VIDEO:
467  put_v(bc, par->width);
468  put_v(bc, par->height);
469 
470  if (st->sample_aspect_ratio.num <= 0 ||
471  st->sample_aspect_ratio.den <= 0) {
472  put_v(bc, 0);
473  put_v(bc, 0);
474  } else {
475  put_v(bc, st->sample_aspect_ratio.num);
476  put_v(bc, st->sample_aspect_ratio.den);
477  }
478  put_v(bc, 0); /* csp type -- unknown */
479  break;
480  default:
481  break;
482  }
483  return 0;
484 }
485 
486 static int add_info(AVIOContext *bc, const char *type, const char *value)
487 {
488  put_str(bc, type);
489  put_s(bc, -1);
490  put_str(bc, value);
491  return 1;
492 }
493 
495 {
496  AVFormatContext *s = nut->avf;
497  AVDictionaryEntry *t = NULL;
498  AVIOContext *dyn_bc;
499  uint8_t *dyn_buf = NULL;
500  int count = 0, dyn_size;
501  int ret = avio_open_dyn_buf(&dyn_bc);
502  if (ret < 0)
503  return ret;
504 
506  while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
507  count += add_info(dyn_bc, t->key, t->value);
508 
509  put_v(bc, 0); //stream_if_plus1
510  put_v(bc, 0); //chapter_id
511  put_v(bc, 0); //timestamp_start
512  put_v(bc, 0); //length
513 
514  put_v(bc, count);
515 
516  dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
517  avio_write(bc, dyn_buf, dyn_size);
518  av_free(dyn_buf);
519  return 0;
520 }
521 
522 static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id) {
523  AVFormatContext *s= nut->avf;
524  AVStream* st = s->streams[stream_id];
525  AVDictionaryEntry *t = NULL;
526  AVIOContext *dyn_bc;
527  uint8_t *dyn_buf=NULL;
528  int count=0, dyn_size, i;
529  int ret = avio_open_dyn_buf(&dyn_bc);
530  if (ret < 0)
531  return ret;
532 
533  while ((t = av_dict_get(st->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
534  count += add_info(dyn_bc, t->key, t->value);
535  for (i=0; ff_nut_dispositions[i].flag; ++i) {
537  count += add_info(dyn_bc, "Disposition", ff_nut_dispositions[i].str);
538  }
539  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
540  uint8_t buf[256];
541  if (st->r_frame_rate.num>0 && st->r_frame_rate.den>0)
542  snprintf(buf, sizeof(buf), "%d/%d", st->r_frame_rate.num, st->r_frame_rate.den);
543  else
544  snprintf(buf, sizeof(buf), "%d/%d", st->avg_frame_rate.num, st->avg_frame_rate.den);
545  count += add_info(dyn_bc, "r_frame_rate", buf);
546  }
547  dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
548 
549  if (count) {
550  put_v(bc, stream_id + 1); //stream_id_plus1
551  put_v(bc, 0); //chapter_id
552  put_v(bc, 0); //timestamp_start
553  put_v(bc, 0); //length
554 
555  put_v(bc, count);
556 
557  avio_write(bc, dyn_buf, dyn_size);
558  }
559 
560  av_free(dyn_buf);
561  return count;
562 }
563 
564 static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
565 {
566  AVIOContext *dyn_bc;
567  uint8_t *dyn_buf = NULL;
568  AVDictionaryEntry *t = NULL;
569  AVChapter *ch = nut->avf->chapters[id];
570  int ret, dyn_size, count = 0;
571 
572  ret = avio_open_dyn_buf(&dyn_bc);
573  if (ret < 0)
574  return ret;
575 
576  put_v(bc, 0); // stream_id_plus1
577  put_s(bc, id + 1); // chapter_id
578  put_tt(nut, nut->chapter[id].time_base, bc, ch->start); // chapter_start
579  put_v(bc, ch->end - ch->start); // chapter_len
580 
581  while ((t = av_dict_get(ch->metadata, "", t, AV_DICT_IGNORE_SUFFIX)))
582  count += add_info(dyn_bc, t->key, t->value);
583 
584  put_v(bc, count);
585 
586  dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
587  avio_write(bc, dyn_buf, dyn_size);
588  av_freep(&dyn_buf);
589  return 0;
590 }
591 
592 static int write_index(NUTContext *nut, AVIOContext *bc) {
593  int i;
594  Syncpoint dummy= { .pos= 0 };
595  Syncpoint *next_node[2] = { NULL };
596  int64_t startpos = avio_tell(bc);
597  int64_t payload_size;
598 
599  put_tt(nut, nut->max_pts_tb, bc, nut->max_pts);
600 
601  put_v(bc, nut->sp_count);
602 
603  for (i=0; i<nut->sp_count; i++) {
604  av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, (void**)next_node);
605  put_v(bc, (next_node[1]->pos >> 4) - (dummy.pos>>4));
606  dummy.pos = next_node[1]->pos;
607  }
608 
609  for (i=0; i<nut->avf->nb_streams; i++) {
610  StreamContext *nus= &nut->stream[i];
611  int64_t last_pts= -1;
612  int j, k;
613  for (j=0; j<nut->sp_count; j++) {
614  int flag;
615  int n = 0;
616 
617  if (j && nus->keyframe_pts[j] == nus->keyframe_pts[j-1]) {
618  av_log(nut->avf, AV_LOG_WARNING, "Multiple keyframes with same PTS\n");
619  nus->keyframe_pts[j] = AV_NOPTS_VALUE;
620  }
621 
622  flag = (nus->keyframe_pts[j] != AV_NOPTS_VALUE) ^ (j+1 == nut->sp_count);
623  for (; j<nut->sp_count && (nus->keyframe_pts[j] != AV_NOPTS_VALUE) == flag; j++)
624  n++;
625 
626  put_v(bc, 1 + 2 * flag + 4 * n);
627  for (k= j - n; k<=j && k<nut->sp_count; k++) {
628  if (nus->keyframe_pts[k] == AV_NOPTS_VALUE)
629  continue;
630  av_assert0(nus->keyframe_pts[k] > last_pts);
631  put_v(bc, nus->keyframe_pts[k] - last_pts);
632  last_pts = nus->keyframe_pts[k];
633  }
634  }
635  }
636 
637  payload_size = avio_tell(bc) - startpos + 8 + 4;
638 
639  avio_wb64(bc, 8 + payload_size + av_log2(payload_size) / 7 + 1 + 4*(payload_size > 4096));
640 
641  return 0;
642 }
643 
645 {
646  NUTContext *nut = avctx->priv_data;
647  AVIOContext *dyn_bc;
648  int i, ret;
649 
651 
652  ret = avio_open_dyn_buf(&dyn_bc);
653  if (ret < 0)
654  return ret;
655  write_mainheader(nut, dyn_bc);
656  put_packet(nut, bc, dyn_bc, MAIN_STARTCODE);
657 
658  for (i = 0; i < nut->avf->nb_streams; i++) {
659  ret = write_streamheader(avctx, dyn_bc, nut->avf->streams[i], i);
660  if (ret < 0) {
661  goto fail;
662  }
663  put_packet(nut, bc, dyn_bc, STREAM_STARTCODE);
664  }
665 
666  write_globalinfo(nut, dyn_bc);
667  put_packet(nut, bc, dyn_bc, INFO_STARTCODE);
668 
669  for (i = 0; i < nut->avf->nb_streams; i++) {
670  ret = write_streaminfo(nut, dyn_bc, i);
671  if (ret > 0)
672  put_packet(nut, bc, dyn_bc, INFO_STARTCODE);
673  else if (ret < 0) {
674  goto fail;
675  }
676  }
677 
678  for (i = 0; i < nut->avf->nb_chapters; i++) {
679  ret = write_chapter(nut, dyn_bc, i);
680  if (ret < 0) {
681  goto fail;
682  }
683  put_packet(nut, bc, dyn_bc, INFO_STARTCODE);
684  }
685 
686  nut->last_syncpoint_pos = INT_MIN;
687  nut->header_count++;
688 
689  ret = 0;
690 fail:
691  ffio_free_dyn_buf(&dyn_bc);
692 
693  return ret;
694 }
695 
697 {
698  NUTContext *nut = s->priv_data;
699  AVIOContext *bc = s->pb;
700  int i, j, ret;
701 
702  nut->avf = s;
703 
704  nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags);
705  if (nut->version > 3 && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
707  "The additional syncpoint modes require version %d, "
708  "that is currently not finalized, "
709  "please set -f_strict experimental in order to enable it.\n",
710  nut->version);
711  return AVERROR_EXPERIMENTAL;
712  }
713 
714  nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream ));
715  nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter));
716  nut->time_base= av_calloc(s->nb_streams +
717  s->nb_chapters, sizeof(*nut->time_base));
718  if (!nut->stream || !nut->chapter || !nut->time_base)
719  return AVERROR(ENOMEM);
720 
721  for (i = 0; i < s->nb_streams; i++) {
722  AVStream *st = s->streams[i];
723  int ssize;
724  AVRational time_base;
725  ff_parse_specific_params(st, &time_base.den, &ssize, &time_base.num);
726 
728  time_base = (AVRational) {1, st->codecpar->sample_rate};
729  } else {
730  time_base = ff_choose_timebase(s, st, 48000);
731  }
732 
733  avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
734 
735  for (j = 0; j < nut->time_base_count; j++)
736  if (!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))) {
737  break;
738  }
739  nut->time_base[j] = time_base;
740  nut->stream[i].time_base = &nut->time_base[j];
741  if (j == nut->time_base_count)
742  nut->time_base_count++;
743 
744  if (INT64_C(1000) * time_base.num >= time_base.den)
745  nut->stream[i].msb_pts_shift = 7;
746  else
747  nut->stream[i].msb_pts_shift = 14;
748  nut->stream[i].max_pts_distance =
749  FFMAX(time_base.den, time_base.num) / time_base.num;
750  }
751 
752  for (i = 0; i < s->nb_chapters; i++) {
753  AVChapter *ch = s->chapters[i];
754 
755  for (j = 0; j < nut->time_base_count; j++)
756  if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational)))
757  break;
758 
759  nut->time_base[j] = ch->time_base;
760  nut->chapter[i].time_base = &nut->time_base[j];
761  if (j == nut->time_base_count)
762  nut->time_base_count++;
763  }
764 
765  nut->max_distance = MAX_DISTANCE;
768  av_assert0(nut->frame_code['N'].flags == FLAG_INVALID);
769 
770  avio_write(bc, ID_STRING, strlen(ID_STRING));
771  avio_w8(bc, 0);
772 
773  if ((ret = write_headers(s, bc)) < 0)
774  return ret;
775 
776  if (s->avoid_negative_ts < 0)
777  s->avoid_negative_ts = 1;
778 
779  return 0;
780 }
781 
783  AVPacket *pkt)
784 {
785  int flags = 0;
786 
787  if (pkt->flags & AV_PKT_FLAG_KEY)
788  flags |= FLAG_KEY;
789  if (pkt->stream_index != fc->stream_id)
791  if (pkt->size / fc->size_mul)
792  flags |= FLAG_SIZE_MSB;
793  if (pkt->pts - nus->last_pts != fc->pts_delta)
795  if (pkt->side_data_elems && nut->version > 3)
796  flags |= FLAG_SM_DATA;
797  if (pkt->size > 2 * nut->max_distance)
798  flags |= FLAG_CHECKSUM;
799  if (FFABS(pkt->pts - nus->last_pts) > nus->max_pts_distance)
800  flags |= FLAG_CHECKSUM;
801  if (fc->header_idx)
802  if (pkt->size < nut->header_len[fc->header_idx] ||
803  pkt->size > 4096 ||
804  memcmp(pkt->data, nut->header [fc->header_idx],
805  nut->header_len[fc->header_idx]))
807 
808  return flags | (fc->flags & FLAG_CODED);
809 }
810 
812 {
813  int i;
814  int best_i = 0;
815  int best_len = 0;
816 
817  if (pkt->size > 4096)
818  return 0;
819 
820  for (i = 1; i < nut->header_count; i++)
821  if (pkt->size >= nut->header_len[i]
822  && nut->header_len[i] > best_len
823  && !memcmp(pkt->data, nut->header[i], nut->header_len[i])) {
824  best_i = i;
825  best_len = nut->header_len[i];
826  }
827  return best_i;
828 }
829 
830 static int write_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta)
831 {
832  int ret, i, dyn_size;
833  unsigned flags;
834  AVIOContext *dyn_bc;
835  int sm_data_count = 0;
836  uint8_t tmp[256];
837  uint8_t *dyn_buf;
838 
839  ret = avio_open_dyn_buf(&dyn_bc);
840  if (ret < 0)
841  return ret;
842 
843  for (i = 0; i<pkt->side_data_elems; i++) {
844  const uint8_t *data = pkt->side_data[i].data;
845  int size = pkt->side_data[i].size;
846  const uint8_t *data_end = data + size;
847 
848  if (is_meta) {
851  if (!size || data[size-1]) {
852  ret = AVERROR(EINVAL);
853  goto fail;
854  }
855  while (data < data_end) {
856  const uint8_t *key = data;
857  const uint8_t *val = data + strlen(key) + 1;
858 
859  if(val >= data_end) {
860  ret = AVERROR(EINVAL);
861  goto fail;
862  }
863  put_str(dyn_bc, key);
864  put_s(dyn_bc, -1);
865  put_str(dyn_bc, val);
866  data = val + strlen(val) + 1;
867  sm_data_count++;
868  }
869  }
870  } else {
871  switch (pkt->side_data[i].type) {
872  case AV_PKT_DATA_PALETTE:
875  default:
877  put_str(dyn_bc, "Palette");
878  } else if(pkt->side_data[i].type == AV_PKT_DATA_NEW_EXTRADATA) {
879  put_str(dyn_bc, "Extradata");
881  snprintf(tmp, sizeof(tmp), "CodecSpecificSide%"PRId64"", AV_RB64(data));
882  put_str(dyn_bc, tmp);
883  } else {
884  snprintf(tmp, sizeof(tmp), "UserData%s-SD-%d",
885  (s->flags & AVFMT_FLAG_BITEXACT) ? "Lavf" : LIBAVFORMAT_IDENT,
886  pkt->side_data[i].type);
887  put_str(dyn_bc, tmp);
888  }
889  put_s(dyn_bc, -2);
890  put_str(dyn_bc, "bin");
891  put_v(dyn_bc, pkt->side_data[i].size);
892  avio_write(dyn_bc, data, pkt->side_data[i].size);
893  sm_data_count++;
894  break;
896  flags = bytestream_get_le32(&data);
898  put_str(dyn_bc, "Channels");
899  put_s(dyn_bc, bytestream_get_le32(&data));
900  sm_data_count++;
901  }
903  put_str(dyn_bc, "ChannelLayout");
904  put_s(dyn_bc, -2);
905  put_str(dyn_bc, "u64");
906  put_v(dyn_bc, 8);
907  avio_write(dyn_bc, data, 8); data+=8;
908  sm_data_count++;
909  }
911  put_str(dyn_bc, "SampleRate");
912  put_s(dyn_bc, bytestream_get_le32(&data));
913  sm_data_count++;
914  }
916  put_str(dyn_bc, "Width");
917  put_s(dyn_bc, bytestream_get_le32(&data));
918  put_str(dyn_bc, "Height");
919  put_s(dyn_bc, bytestream_get_le32(&data));
920  sm_data_count+=2;
921  }
922  break;
924  if (AV_RL32(data)) {
925  put_str(dyn_bc, "SkipStart");
926  put_s(dyn_bc, (unsigned)AV_RL32(data));
927  sm_data_count++;
928  }
929  if (AV_RL32(data+4)) {
930  put_str(dyn_bc, "SkipEnd");
931  put_s(dyn_bc, (unsigned)AV_RL32(data+4));
932  sm_data_count++;
933  }
934  break;
938  // belongs into meta, not side data
939  break;
940  }
941  }
942  }
943 
944 fail:
945  put_v(bc, sm_data_count);
946  dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
947  avio_write(bc, dyn_buf, dyn_size);
948  av_freep(&dyn_buf);
949 
950  return ret;
951 }
952 
954 {
955  NUTContext *nut = s->priv_data;
956  StreamContext *nus = &nut->stream[pkt->stream_index];
957  AVIOContext *bc = s->pb, *dyn_bc, *sm_bc = NULL;
958  FrameCode *fc;
959  int64_t coded_pts;
960  int best_length, frame_code, flags, needed_flags, i, header_idx;
961  int best_header_idx;
962  int key_frame = !!(pkt->flags & AV_PKT_FLAG_KEY);
963  int store_sp = 0;
964  int ret = 0;
965  int sm_size = 0;
966  int data_size = pkt->size;
967  uint8_t *sm_buf = NULL;
968 
969  if (pkt->pts < 0) {
971  "Negative pts not supported stream %d, pts %"PRId64"\n",
972  pkt->stream_index, pkt->pts);
973  if (pkt->pts == AV_NOPTS_VALUE)
974  av_log(s, AV_LOG_ERROR, "Try to enable the genpts flag\n");
975  return AVERROR(EINVAL);
976  }
977 
978  if (pkt->side_data_elems && nut->version > 3) {
979  ret = avio_open_dyn_buf(&sm_bc);
980  if (ret < 0)
981  return ret;
982  ret = write_sm_data(s, sm_bc, pkt, 0);
983  if (ret >= 0)
984  ret = write_sm_data(s, sm_bc, pkt, 1);
985  sm_size = avio_close_dyn_buf(sm_bc, &sm_buf);
986  if (ret < 0)
987  goto fail;
988  data_size += sm_size;
989  }
990 
991  if (1LL << (20 + 3 * nut->header_count) <= avio_tell(bc))
992  write_headers(s, bc);
993 
994  if (key_frame && !(nus->last_flags & FLAG_KEY))
995  store_sp = 1;
996 
997  if (data_size + 30 /*FIXME check*/ + avio_tell(bc) >= nut->last_syncpoint_pos + nut->max_distance)
998  store_sp = 1;
999 
1000 //FIXME: Ensure store_sp is 1 in the first place.
1001 
1002  if (store_sp &&
1003  (!(nut->flags & NUT_PIPE) || nut->last_syncpoint_pos == INT_MIN)) {
1004  int64_t sp_pos = INT64_MAX;
1005 
1006  ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
1007  for (i = 0; i < s->nb_streams; i++) {
1008  AVStream *st = s->streams[i];
1009  int64_t dts_tb = av_rescale_rnd(pkt->dts,
1010  nus->time_base->num * (int64_t)nut->stream[i].time_base->den,
1011  nus->time_base->den * (int64_t)nut->stream[i].time_base->num,
1012  AV_ROUND_DOWN);
1013  int index = av_index_search_timestamp(st, dts_tb,
1015  if (index >= 0) {
1016  sp_pos = FFMIN(sp_pos, st->internal->index_entries[index].pos);
1017  if (!nut->write_index && 2*index > st->internal->nb_index_entries) {
1018  memmove(st->internal->index_entries,
1019  st->internal->index_entries + index,
1020  sizeof(*st->internal->index_entries) * (st->internal->nb_index_entries - index));
1022  }
1023  }
1024  }
1025 
1026  nut->last_syncpoint_pos = avio_tell(bc);
1027  ret = avio_open_dyn_buf(&dyn_bc);
1028  if (ret < 0)
1029  goto fail;
1030  put_tt(nut, nus->time_base, dyn_bc, pkt->dts);
1031  put_v(dyn_bc, sp_pos != INT64_MAX ? (nut->last_syncpoint_pos - sp_pos) >> 4 : 0);
1032 
1033  if (nut->flags & NUT_BROADCAST) {
1034  put_tt(nut, nus->time_base, dyn_bc,
1036  }
1037  put_packet(nut, bc, dyn_bc, SYNCPOINT_STARTCODE);
1038  ffio_free_dyn_buf(&dyn_bc);
1039 
1040  if (nut->write_index) {
1041  if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0)
1042  goto fail;
1043 
1044  if ((1ll<<60) % nut->sp_count == 0)
1045  for (i=0; i<s->nb_streams; i++) {
1046  int j;
1047  StreamContext *nus = &nut->stream[i];
1048  av_reallocp_array(&nus->keyframe_pts, 2*nut->sp_count, sizeof(*nus->keyframe_pts));
1049  if (!nus->keyframe_pts) {
1050  ret = AVERROR(ENOMEM);
1051  goto fail;
1052  }
1053  for (j=nut->sp_count == 1 ? 0 : nut->sp_count; j<2*nut->sp_count; j++)
1054  nus->keyframe_pts[j] = AV_NOPTS_VALUE;
1055  }
1056  }
1057  }
1059 
1060  coded_pts = pkt->pts & ((1 << nus->msb_pts_shift) - 1);
1061  if (ff_lsb2full(nus, coded_pts) != pkt->pts)
1062  coded_pts = pkt->pts + (1 << nus->msb_pts_shift);
1063 
1064  best_header_idx = find_best_header_idx(nut, pkt);
1065 
1066  best_length = INT_MAX;
1067  frame_code = -1;
1068  for (i = 0; i < 256; i++) {
1069  int length = 0;
1070  FrameCode *fc = &nut->frame_code[i];
1071  int flags = fc->flags;
1072 
1073  if (flags & FLAG_INVALID)
1074  continue;
1075  needed_flags = get_needed_flags(nut, nus, fc, pkt);
1076 
1077  if (flags & FLAG_CODED) {
1078  length++;
1079  flags = needed_flags;
1080  }
1081 
1082  if ((flags & needed_flags) != needed_flags)
1083  continue;
1084 
1085  if ((flags ^ needed_flags) & FLAG_KEY)
1086  continue;
1087 
1088  if (flags & FLAG_STREAM_ID)
1089  length += get_v_length(pkt->stream_index);
1090 
1091  if (data_size % fc->size_mul != fc->size_lsb)
1092  continue;
1093  if (flags & FLAG_SIZE_MSB)
1094  length += get_v_length(data_size / fc->size_mul);
1095 
1096  if (flags & FLAG_CHECKSUM)
1097  length += 4;
1098 
1099  if (flags & FLAG_CODED_PTS)
1100  length += get_v_length(coded_pts);
1101 
1102  if ( (flags & FLAG_CODED)
1103  && nut->header_len[best_header_idx] > nut->header_len[fc->header_idx] + 1) {
1105  }
1106 
1107  if (flags & FLAG_HEADER_IDX) {
1108  length += 1 - nut->header_len[best_header_idx];
1109  } else {
1110  length -= nut->header_len[fc->header_idx];
1111  }
1112 
1113  length *= 4;
1114  length += !(flags & FLAG_CODED_PTS);
1115  length += !(flags & FLAG_CHECKSUM);
1116 
1117  if (length < best_length) {
1118  best_length = length;
1119  frame_code = i;
1120  }
1121  }
1122  av_assert0(frame_code != -1);
1123 
1124  fc = &nut->frame_code[frame_code];
1125  flags = fc->flags;
1126  needed_flags = get_needed_flags(nut, nus, fc, pkt);
1127  header_idx = fc->header_idx;
1128 
1130  avio_w8(bc, frame_code);
1131  if (flags & FLAG_CODED) {
1132  put_v(bc, (flags ^ needed_flags) & ~(FLAG_CODED));
1133  flags = needed_flags;
1134  }
1135  if (flags & FLAG_STREAM_ID) put_v(bc, pkt->stream_index);
1136  if (flags & FLAG_CODED_PTS) put_v(bc, coded_pts);
1137  if (flags & FLAG_SIZE_MSB ) put_v(bc, data_size / fc->size_mul);
1138  if (flags & FLAG_HEADER_IDX) put_v(bc, header_idx = best_header_idx);
1139 
1141  else ffio_get_checksum(bc);
1142 
1143  if (flags & FLAG_SM_DATA) {
1144  avio_write(bc, sm_buf, sm_size);
1145  }
1146  avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
1147 
1148  nus->last_flags = flags;
1149  nus->last_pts = pkt->pts;
1150 
1151  //FIXME just store one per syncpoint
1152  if (flags & FLAG_KEY && !(nut->flags & NUT_PIPE)) {
1154  s->streams[pkt->stream_index],
1155  nut->last_syncpoint_pos,
1156  pkt->pts,
1157  0,
1158  0,
1160  if (nus->keyframe_pts && nus->keyframe_pts[nut->sp_count] == AV_NOPTS_VALUE)
1161  nus->keyframe_pts[nut->sp_count] = pkt->pts;
1162  }
1163 
1164  if (!nut->max_pts_tb || av_compare_ts(nut->max_pts, *nut->max_pts_tb, pkt->pts, *nus->time_base) < 0) {
1165  nut->max_pts = pkt->pts;
1166  nut->max_pts_tb = nus->time_base;
1167  }
1168 
1169 fail:
1170  av_freep(&sm_buf);
1171 
1172  return ret;
1173 }
1174 
1176 {
1177  NUTContext *nut = s->priv_data;
1178  AVIOContext *bc = s->pb, *dyn_bc;
1179  int ret;
1180 
1181  while (nut->header_count < 3)
1182  write_headers(s, bc);
1183 
1184  if (!nut->sp_count)
1185  return 0;
1186 
1187  ret = avio_open_dyn_buf(&dyn_bc);
1188  if (ret >= 0) {
1189  av_assert1(nut->write_index); // sp_count should be 0 if no index is going to be written
1190  write_index(nut, dyn_bc);
1191  put_packet(nut, bc, dyn_bc, INDEX_STARTCODE);
1192  ffio_free_dyn_buf(&dyn_bc);
1193  }
1194 
1195  return 0;
1196 }
1197 
1199 {
1200  NUTContext *nut = s->priv_data;
1201  int i;
1202 
1203  ff_nut_free_sp(nut);
1204  if (nut->stream)
1205  for (i=0; i<s->nb_streams; i++)
1206  av_freep(&nut->stream[i].keyframe_pts);
1207 
1208  av_freep(&nut->stream);
1209  av_freep(&nut->chapter);
1210  av_freep(&nut->time_base);
1211 }
1212 
1213 #define OFFSET(x) offsetof(NUTContext, x)
1214 #define E AV_OPT_FLAG_ENCODING_PARAM
1215 static const AVOption options[] = {
1216  { "syncpoints", "NUT syncpoint behaviour", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, E, "syncpoints" },
1217  { "default", "", 0, AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX, E, "syncpoints" },
1218  { "none", "Disable syncpoints, low overhead and unseekable", 0, AV_OPT_TYPE_CONST, {.i64 = NUT_PIPE}, INT_MIN, INT_MAX, E, "syncpoints" },
1219  { "timestamped", "Extend syncpoints with a wallclock timestamp", 0, AV_OPT_TYPE_CONST, {.i64 = NUT_BROADCAST}, INT_MIN, INT_MAX, E, "syncpoints" },
1220  { "write_index", "Write index", OFFSET(write_index), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, E, },
1221  { NULL },
1222 };
1223 
1224 static const AVClass class = {
1225  .class_name = "nutenc",
1226  .item_name = av_default_item_name,
1227  .option = options,
1229 };
1230 
1232  .name = "nut",
1233  .long_name = NULL_IF_CONFIG_SMALL("NUT"),
1234  .mime_type = "video/x-nut",
1235  .extensions = "nut",
1236  .priv_data_size = sizeof(NUTContext),
1237  .audio_codec = CONFIG_LIBVORBIS ? AV_CODEC_ID_VORBIS :
1238  CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_MP2,
1239  .video_codec = AV_CODEC_ID_MPEG4,
1243  .deinit = nut_write_deinit,
1245  .codec_tag = ff_nut_codec_tags,
1246  .priv_class = &class,
1247 };
write_streaminfo
static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id)
Definition: nutenc.c:522
intra_only
int intra_only
Definition: mxfenc.c:2209
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
LIBAVFORMAT_IDENT
#define LIBAVFORMAT_IDENT
Definition: version.h:46
AVERROR_EXPERIMENTAL
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
Definition: error.h:72
FrameCode::stream_id
uint8_t stream_id
Definition: nut.h:67
write_mainheader
static void write_mainheader(NUTContext *nut, AVIOContext *bc)
Definition: nutenc.c:349
AVOutputFormat::name
const char * name
Definition: avformat.h:496
AVChapter::metadata
AVDictionary * metadata
Definition: avformat.h:1068
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
write_globalinfo
static int write_globalinfo(NUTContext *nut, AVIOContext *bc)
Definition: nutenc.c:494
get_v_length
static int get_v_length(uint64_t val)
Get the length in bytes which is needed to store val as v.
Definition: nutenc.c:283
opt.h
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_compare_ts
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
Definition: mathematics.c:146
last_pts
static int64_t last_pts
Definition: filtering_video.c:52
out
FILE * out
Definition: movenc.c:54
NUTContext::minor_version
int minor_version
Definition: nut.h:117
FF_COMPLIANCE_EXPERIMENTAL
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
Definition: avcodec.h:1281
get_needed_flags
static int get_needed_flags(NUTContext *nut, StreamContext *nus, FrameCode *fc, AVPacket *pkt)
Definition: nutenc.c:782
AVFormatContext::nb_chapters
unsigned int nb_chapters
Number of chapters in AVChapter array.
Definition: avformat.h:1325
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:52
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
nut_write_trailer
static int nut_write_trailer(AVFormatContext *s)
Definition: nutenc.c:1175
AVFMT_VARIABLE_FPS
#define AVFMT_VARIABLE_FPS
Format allows variable fps.
Definition: avformat.h:470
av_div_q
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition: rational.c:88
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_CODEC_ID_MPEG4
@ AV_CODEC_ID_MPEG4
Definition: codec_id.h:62
STREAM_STARTCODE
#define STREAM_STARTCODE
Definition: nut.h:30
avpriv_mpa_freq_tab
const uint16_t avpriv_mpa_freq_tab[3]
Definition: mpegaudiodata.c:40
avpriv_mpa_bitrate_tab
const uint16_t avpriv_mpa_bitrate_tab[2][3][15]
Definition: mpegaudiodata.c:30
NUTContext::write_index
int write_index
Definition: nut.h:110
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:1175
index
fg index
Definition: ffmpeg_filter.c:168
nut_write_packet
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: nutenc.c:953
AVPacket::data
uint8_t * data
Definition: packet.h:373
ff_nut_dispositions
const Dispositions ff_nut_dispositions[]
Definition: nut.c:324
NUTContext::last_syncpoint_pos
int64_t last_syncpoint_pos
Definition: nut.h:104
AVStream::internal
AVStreamInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1009
AVOption
AVOption.
Definition: opt.h:247
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
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:914
AVChapter::start
int64_t start
Definition: avformat.h:1067
data
const char data[16]
Definition: mxf.c:143
NUTContext::header_len
uint8_t header_len[128]
Definition: nut.h:97
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:68
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
@ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
Definition: packet.h:428
fc
#define fc(width, name, range_min, range_max)
Definition: cbs_av1.c:551
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:64
mathematics.h
ff_nut_reset_ts
void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val)
Definition: nut.c:255
write_chapter
static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
Definition: nutenc.c:564
FrameCode::size_lsb
uint16_t size_lsb
Definition: nut.h:69
Syncpoint
Definition: nut.h:58
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT
@ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT
Definition: packet.h:427
avio_get_dyn_buf
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1374
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:404
sample_rate
sample_rate
Definition: ffmpeg_filter.c:156
ffio_get_checksum
unsigned long ffio_get_checksum(AVIOContext *s)
Definition: aviobuf.c:587
AVINDEX_KEYFRAME
#define AVINDEX_KEYFRAME
Definition: avformat.h:785
av_get_audio_frame_duration2
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
Definition: utils.c:820
ff_nut_sp_pos_cmp
int ff_nut_sp_pos_cmp(const void *a, const void *b)
Definition: nut.c:273
ff_nut_free_sp
void ff_nut_free_sp(NUTContext *nut)
Definition: nut.c:316
AVPacketSideData::size
size_t size
Definition: packet.h:316
AVCodecParameters::channels
int channels
Audio only.
Definition: codec_par.h:166
find_best_header_idx
static int find_best_header_idx(NUTContext *nut, AVPacket *pkt)
Definition: nutenc.c:811
fail
#define fail()
Definition: checkasm.h:136
nut_write_header
static int nut_write_header(AVFormatContext *s)
Definition: nutenc.c:696
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:1940
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:538
NUTContext::avf
AVFormatContext * avf
Definition: nut.h:93
AVChapter
Definition: avformat.h:1064
val
static double val(void *priv, double ch)
Definition: aeval.c:75
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:653
NUTContext::header
const uint8_t * header[128]
Definition: nut.h:98
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:423
AVRational::num
int num
Numerator.
Definition: rational.h:59
AV_PKT_DATA_STRINGS_METADATA
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
Definition: packet.h:172
NUTContext::sp_count
int sp_count
Definition: nut.h:109
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1407
NUTContext::header_count
int header_count
Definition: nut.h:106
avassert.h
put_str
static void put_str(AVIOContext *bc, const char *string)
Store a string as vb.
Definition: nutenc.c:315
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
NUTContext
Definition: nut.h:91
ChapterContext::time_base
AVRational * time_base
Definition: nut.h:88
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1362
E
#define E
Definition: nutenc.c:1214
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
Definition: packet.h:429
AVChapter::end
int64_t end
chapter start/end time in time_base units
Definition: avformat.h:1067
intreadwrite.h
ff_nut_metadata_conv
const AVMetadataConv ff_nut_metadata_conv[]
Definition: nut.c:334
s
#define s(width, name)
Definition: cbs_vp9.c:257
nut.h
AVFormatContext::chapters
AVChapter ** chapters
Definition: avformat.h:1326
AVDictionaryEntry::key
char * key
Definition: dict.h:80
frame_size
int frame_size
Definition: mxfenc.c:2206
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:126
AV_CODEC_ID_MP2
@ AV_CODEC_ID_MP2
Definition: codec_id.h:422
NUTContext::time_base
AVRational * time_base
Definition: nut.h:107
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
write_streamheader
static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i)
Definition: nutenc.c:429
AVPacketSideData::data
uint8_t * data
Definition: packet.h:315
StreamContext::last_pts
int64_t last_pts
Definition: nut.h:78
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:141
write_index
static int write_index(NUTContext *nut, AVIOContext *bc)
Definition: nutenc.c:592
put_packet
static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, uint64_t startcode)
Definition: nutenc.c:328
key
const char * key
Definition: hwcontext_opencl.c:168
FrameCode::size_mul
uint16_t size_mul
Definition: nut.h:68
FLAG_INVALID
@ FLAG_INVALID
Definition: nut.h:55
f
#define f(width, name)
Definition: cbs_vp9.c:255
find_expected_header
static int find_expected_header(AVCodecParameters *p, int size, int key_frame, uint8_t out[64])
Definition: nutenc.c:38
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:77
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
if
if(ret)
Definition: filter_design.txt:179
options
static const AVOption options[]
Definition: nutenc.c:1215
AVFormatContext
Format I/O context.
Definition: avformat.h:1107
internal.h
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:994
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVSEEK_FLAG_BACKWARD
#define AVSEEK_FLAG_BACKWARD
Definition: avformat.h:2167
Dispositions::flag
int flag
Definition: nut.h:130
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
NUT_BROADCAST
#define NUT_BROADCAST
Definition: nut.h:113
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:98
ff_choose_timebase
AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precision)
Chooses a timebase for muxing the specified stream.
Definition: mux.c:91
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVPacketSideData::type
enum AVPacketSideDataType type
Definition: packet.h:317
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
NUTContext::chapter
ChapterContext * chapter
Definition: nut.h:101
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:905
time.h
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:193
build_elision_headers
static void build_elision_headers(AVFormatContext *s)
Definition: nutenc.c:122
write_headers
static int write_headers(AVFormatContext *avctx, AVIOContext *bc)
Definition: nutenc.c:644
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:170
AV_CODEC_ID_MPEG1VIDEO
@ AV_CODEC_ID_MPEG1VIDEO
Definition: codec_id.h:51
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
AV_WB32
#define AV_WB32(p, v)
Definition: intreadwrite.h:419
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1163
StreamContext
Definition: transcoding.c:51
put_tt
static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val)
Definition: nutenc.c:306
av_rescale_rnd
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
Definition: mathematics.c:57
FLAG_SIZE_MSB
@ FLAG_SIZE_MSB
Definition: nut.h:48
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
put_s
static void put_s(AVIOContext *bc, int64_t val)
Definition: nutenc.c:323
ffio_reset_dyn_buf
void ffio_reset_dyn_buf(AVIOContext *s)
Reset a dynamic buffer.
Definition: aviobuf.c:1396
AVPacket::size
int size
Definition: packet.h:374
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:116
id
enum AVCodecID id
Definition: extract_extradata_bsf.c:325
add_info
static int add_info(AVIOContext *bc, const char *type, const char *value)
Definition: nutenc.c:486
NUTContext::max_pts_tb
AVRational * max_pts_tb
Definition: nut.h:112
FFMAX
#define FFMAX(a, b)
Definition: common.h:103
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:4799
NUTContext::flags
int flags
Definition: nut.h:115
size
int size
Definition: twinvq_data.h:10344
NUTContext::stream
StreamContext * stream
Definition: nut.h:100
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
FrameCode::flags
uint16_t flags
Definition: nut.h:66
NUT_STABLE_VERSION
#define NUT_STABLE_VERSION
Definition: nut.h:40
AVStreamInternal::nb_index_entries
int nb_index_entries
Definition: internal.h:260
build_frame_code
static void build_frame_code(AVFormatContext *s)
Definition: nutenc.c:144
AV_WB24
#define AV_WB24(p, d)
Definition: intreadwrite.h:450
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:595
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:903
tree.h
header
static const uint8_t header[24]
Definition: sdr2.c:67
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:372
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:215
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
av_reallocp_array
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
Definition: mem.c:212
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:365
AVStreamInternal::index_entries
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: internal.h:258
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:379
find_header_idx
static int find_header_idx(AVFormatContext *s, AVCodecParameters *p, int size, int frame_type)
Definition: nutenc.c:105
NUTContext::version
int version
Definition: nut.h:116
StreamContext::msb_pts_shift
int msb_pts_shift
Definition: nut.h:81
AV_PKT_DATA_METADATA_UPDATE
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
Definition: packet.h:209
ff_crc04C11DB7_update
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
Definition: aviobuf.c:569
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:729
flag
#define flag(name)
Definition: cbs_av1.c:553
ff_standardize_creation_time
int ff_standardize_creation_time(AVFormatContext *s)
Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string.
Definition: utils.c:5481
ff_nut_add_sp
int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
Definition: nut.c:285
i
int i
Definition: input.c:406
NUTContext::syncpoints
struct AVTreeNode * syncpoints
Definition: nut.h:108
AVFMT_GLOBALHEADER
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:466
AVOutputFormat
Definition: avformat.h:495
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:366
frame_type
frame_type
Definition: jpeg2000_parser.c:31
avio_internal.h
ff_lsb2full
int64_t ff_lsb2full(StreamContext *stream, int64_t lsb)
Definition: nut.c:266
AVCodecParameters::height
int height
Definition: codec_par.h:127
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
AV_ROUND_DOWN
@ AV_ROUND_DOWN
Round toward -infinity.
Definition: mathematics.h:82
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
NUTContext::max_pts
int64_t max_pts
Definition: nut.h:111
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
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:426
NUTContext::frame_code
FrameCode frame_code[256]
Definition: nut.h:96
StreamContext::keyframe_pts
int64_t * keyframe_pts
Definition: nut.h:84
FLAG_SM_DATA
@ FLAG_SM_DATA
Definition: nut.h:51
AVStream::disposition
int disposition
AV_DISPOSITION_* bit field.
Definition: avformat.h:894
ffio_free_dyn_buf
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
Definition: aviobuf.c:1437
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1242
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:847
pred
static const float pred[4]
Definition: siprdata.h:259
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
FLAG_STREAM_ID
@ FLAG_STREAM_ID
Definition: nut.h:47
ff_parse_specific_params
void ff_parse_specific_params(AVStream *st, int *au_rate, int *au_ssize, int *au_scale)
Definition: riffenc.c:273
pos
unsigned int pos
Definition: spdifenc.c:412
dict.h
AVPacket::side_data
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: packet.h:384
FrameCode::header_idx
uint8_t header_idx
Definition: nut.h:72
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
FLAG_CHECKSUM
@ FLAG_CHECKSUM
Definition: nut.h:49
FLAG_KEY
@ FLAG_KEY
Definition: nut.h:44
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:251
ff_nut_codec_tags
const AVCodecTag *const ff_nut_codec_tags[]
Definition: nut.c:250
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT
@ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT
Definition: packet.h:426
FLAG_HEADER_IDX
@ FLAG_HEADER_IDX
Definition: nut.h:52
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:65
headers
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test note that you must have installed it fate list List all fate regression test targets install Install headers
Definition: build_system.txt:34
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:983
AVIndexEntry::pos
int64_t pos
Definition: avformat.h:778
AVPacket::stream_index
int stream_index
Definition: packet.h:375
write_sm_data
static int write_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta)
Definition: nutenc.c:830
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
mpegaudiodata.h
OFFSET
#define OFFSET(x)
Definition: nutenc.c:1213
avio_wb64
void avio_wb64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:439
av_gettime
int64_t av_gettime(void)
Get the current time in microseconds.
Definition: time.c:39
MAX_DISTANCE
#define MAX_DISTANCE
Definition: nut.h:37
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
AVCodecParameters::video_delay
int video_delay
Video only.
Definition: codec_par.h:155
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVDictionaryEntry
Definition: dict.h:79
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
FrameCode
Definition: nut.h:65
AVPacket
This structure stores compressed data.
Definition: packet.h:350
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
riff.h
nut_write_deinit
static void nut_write_deinit(AVFormatContext *s)
Definition: nutenc.c:1198
INDEX_STARTCODE
#define INDEX_STARTCODE
Definition: nut.h:32
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:223
bytestream.h
convert_header.str
string str
Definition: convert_header.py:20
AV_PKT_DATA_QUALITY_STATS
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
Definition: packet.h:132
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:427
AVDictionaryEntry::value
char * value
Definition: dict.h:81
StreamContext::time_base
AVRational time_base
Definition: signature.h:103
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:347
ff_nut_muxer
const AVOutputFormat ff_nut_muxer
Definition: nutenc.c:1231
AVChapter::time_base
AVRational time_base
time base in which the start/end timestamps are specified
Definition: avformat.h:1066
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:52
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
snprintf
#define snprintf
Definition: snprintf.h:34
INFO_STARTCODE
#define INFO_STARTCODE
Definition: nut.h:33
MAIN_STARTCODE
#define MAIN_STARTCODE
Definition: nut.h:29
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1135
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
StreamContext::max_pts_distance
int max_pts_distance
Definition: nut.h:82
AV_RB64
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
Definition: bytestream.h:95
put_v
static void put_v(AVIOContext *bc, uint64_t val)
Put val using a variable number of bytes.
Definition: nutenc.c:296
ID_STRING
#define ID_STRING
Definition: ffmeta.h:25
AVPacket::side_data_elems
int side_data_elems
Definition: packet.h:385
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:2057