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