Libav
gxfenc.c
Go to the documentation of this file.
1 /*
2  * GXF muxer.
3  * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
4  *
5  * This file is part of Libav.
6  *
7  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/intfloat.h"
23 #include "libavutil/mathematics.h"
24 #include "avformat.h"
25 #include "internal.h"
26 #include "gxf.h"
27 #include "audiointerleave.h"
28 
29 #define GXF_AUDIO_PACKET_SIZE 65536
30 
31 typedef struct GXFStreamContext {
33  uint32_t track_type;
34  uint32_t sample_size;
35  uint32_t sample_rate;
36  uint16_t media_type;
37  uint16_t media_info;
40  int fields;
41  int iframes;
42  int pframes;
43  int bframes;
44  int p_per_gop;
47  unsigned order;
49 
50 typedef struct GXFContext {
51  uint32_t nb_fields;
52  uint16_t audio_tracks;
53  uint16_t mpeg_tracks;
54  int64_t creation_time;
55  uint32_t umf_start_offset;
56  uint32_t umf_track_offset;
57  uint32_t umf_media_offset;
58  uint32_t umf_length;
59  uint16_t umf_track_size;
60  uint16_t umf_media_size;
62  int flags;
64  unsigned *flt_entries;
65  unsigned flt_entries_nb;
66  uint64_t *map_offsets;
67  unsigned map_offsets_nb;
68  unsigned packet_count;
69 } GXFContext;
70 
71 static const struct {
72  int height, index;
73 } gxf_lines_tab[] = {
74  { 480, 1 }, /* NTSC */
75  { 512, 1 }, /* NTSC + VBI */
76  { 576, 2 }, /* PAL */
77  { 608, 2 }, /* PAL + VBI */
78  { 1080, 4 },
79  { 720, 6 },
80 };
81 
82 static const AVCodecTag gxf_media_types[] = {
83  { AV_CODEC_ID_MJPEG , 3 }, /* NTSC */
84  { AV_CODEC_ID_MJPEG , 4 }, /* PAL */
85  { AV_CODEC_ID_PCM_S24LE , 9 },
86  { AV_CODEC_ID_PCM_S16LE , 10 },
87  { AV_CODEC_ID_MPEG2VIDEO, 11 }, /* NTSC */
88  { AV_CODEC_ID_MPEG2VIDEO, 12 }, /* PAL */
89  { AV_CODEC_ID_DVVIDEO , 13 }, /* NTSC */
90  { AV_CODEC_ID_DVVIDEO , 14 }, /* PAL */
91  { AV_CODEC_ID_DVVIDEO , 15 }, /* 50M NTSC */
92  { AV_CODEC_ID_DVVIDEO , 16 }, /* 50M PAL */
93  { AV_CODEC_ID_AC3 , 17 },
94  //{ AV_CODEC_ID_NONE, , 18 }, /* Non compressed 24 bit audio */
95  { AV_CODEC_ID_MPEG2VIDEO, 20 }, /* MPEG HD */
96  { AV_CODEC_ID_MPEG1VIDEO, 22 }, /* NTSC */
97  { AV_CODEC_ID_MPEG1VIDEO, 23 }, /* PAL */
98  { AV_CODEC_ID_NONE, 0 },
99 };
100 
101 #define SERVER_PATH "EXT:/PDR/default/"
102 #define ES_NAME_PATTERN "EXT:/PDR/default/ES."
103 
105 {
106  GXFStreamContext *sc = st->priv_data;
107  int i;
108 
109  for (i = 0; i < 6; ++i) {
110  if (st->codec->height == gxf_lines_tab[i].height) {
111  sc->lines_index = gxf_lines_tab[i].index;
112  return 0;
113  }
114  }
115  return -1;
116 }
117 
118 static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
119 {
120  for (; to_pad > 0; to_pad--) {
121  avio_w8(pb, 0);
122  }
123 }
124 
125 static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
126 {
127  int64_t curpos;
128  int size;
129 
130  size = avio_tell(pb) - pos;
131  if (size % 4) {
132  gxf_write_padding(pb, 4 - size % 4);
133  size = avio_tell(pb) - pos;
134  }
135  curpos = avio_tell(pb);
136  avio_seek(pb, pos + 6, SEEK_SET);
137  avio_wb32(pb, size);
138  avio_seek(pb, curpos, SEEK_SET);
139  return curpos - pos;
140 }
141 
142 static int64_t updateSize(AVIOContext *pb, int64_t pos)
143 {
144  int64_t curpos;
145 
146  curpos = avio_tell(pb);
147  avio_seek(pb, pos, SEEK_SET);
148  avio_wb16(pb, curpos - pos - 2);
149  avio_seek(pb, curpos, SEEK_SET);
150  return curpos - pos;
151 }
152 
154 {
155  avio_wb32(pb, 0); /* packet leader for synchro */
156  avio_w8(pb, 1);
157  avio_w8(pb, type); /* map packet */
158  avio_wb32(pb, 0); /* size */
159  avio_wb32(pb, 0); /* reserved */
160  avio_w8(pb, 0xE1); /* trailer 1 */
161  avio_w8(pb, 0xE2); /* trailer 2 */
162 }
163 
165 {
166  GXFStreamContext *sc = st->priv_data;
167  char buffer[1024];
168  int size, starting_line;
169 
170  if (sc->iframes) {
171  sc->p_per_gop = sc->pframes / sc->iframes;
172  if (sc->pframes % sc->iframes)
173  sc->p_per_gop++;
174  if (sc->pframes) {
175  sc->b_per_i_or_p = sc->bframes / sc->pframes;
176  if (sc->bframes % sc->pframes)
177  sc->b_per_i_or_p++;
178  }
179  if (sc->p_per_gop > 9)
180  sc->p_per_gop = 9; /* ensure value won't take more than one char */
181  if (sc->b_per_i_or_p > 9)
182  sc->b_per_i_or_p = 9; /* ensure value won't take more than one char */
183  }
184  if (st->codec->height == 512 || st->codec->height == 608)
185  starting_line = 7; // VBI
186  else if (st->codec->height == 480)
187  starting_line = 20;
188  else
189  starting_line = 23; // default PAL
190 
191  size = snprintf(buffer, 1024, "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
192  "Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
193  (float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
194  st->codec->pix_fmt == AV_PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
195  starting_line, (st->codec->height + 15) / 16);
196  avio_w8(pb, TRACK_MPG_AUX);
197  avio_w8(pb, size + 1);
198  avio_write(pb, (uint8_t *)buffer, size + 1);
199  return size + 3;
200 }
201 
203 {
204  avio_w8(pb, 0); /* fields */
205  avio_w8(pb, 0); /* seconds */
206  avio_w8(pb, 0); /* minutes */
207  avio_w8(pb, 0); /* flags + hours */
208  /* reserved */
209  avio_wb32(pb, 0);
210  return 8;
211 }
212 
214 {
215  AVIOContext *pb = s->pb;
216  int64_t pos;
217  int mpeg = sc->track_type == 4 || sc->track_type == 9;
218 
219  /* track description section */
220  avio_w8(pb, sc->media_type + 0x80);
221  avio_w8(pb, index + 0xC0);
222 
223  pos = avio_tell(pb);
224  avio_wb16(pb, 0); /* size */
225 
226  /* media file name */
227  avio_w8(pb, TRACK_NAME);
228  avio_w8(pb, strlen(ES_NAME_PATTERN) + 3);
229  avio_write(pb, ES_NAME_PATTERN, sizeof(ES_NAME_PATTERN) - 1);
230  avio_wb16(pb, sc->media_info);
231  avio_w8(pb, 0);
232 
233  if (!mpeg) {
234  /* auxiliary information */
235  avio_w8(pb, TRACK_AUX);
236  avio_w8(pb, 8);
237  if (sc->track_type == 3)
239  else
240  avio_wl64(pb, 0);
241  }
242 
243  /* file system version */
244  avio_w8(pb, TRACK_VER);
245  avio_w8(pb, 4);
246  avio_wb32(pb, 0);
247 
248  if (mpeg)
249  gxf_write_mpeg_auxiliary(pb, s->streams[index]);
250 
251  /* frame rate */
252  avio_w8(pb, TRACK_FPS);
253  avio_w8(pb, 4);
254  avio_wb32(pb, sc->frame_rate_index);
255 
256  /* lines per frame */
257  avio_w8(pb, TRACK_LINES);
258  avio_w8(pb, 4);
259  avio_wb32(pb, sc->lines_index);
260 
261  /* fields per frame */
262  avio_w8(pb, TRACK_FPF);
263  avio_w8(pb, 4);
264  avio_wb32(pb, sc->fields);
265 
266  return updateSize(pb, pos);
267 }
268 
270 {
271  GXFContext *gxf = s->priv_data;
272  AVIOContext *pb = s->pb;
273  int64_t pos;
274  int len;
275  const char *filename = strrchr(s->filename, '/');
276 
277  pos = avio_tell(pb);
278  avio_wb16(pb, 0); /* size */
279 
280  /* name */
281  if (filename)
282  filename++;
283  else
284  filename = s->filename;
285  len = strlen(filename);
286 
287  avio_w8(pb, MAT_NAME);
288  avio_w8(pb, strlen(SERVER_PATH) + len + 1);
289  avio_write(pb, SERVER_PATH, sizeof(SERVER_PATH) - 1);
290  avio_write(pb, filename, len);
291  avio_w8(pb, 0);
292 
293  /* first field */
295  avio_w8(pb, 4);
296  avio_wb32(pb, 0);
297 
298  /* last field */
299  avio_w8(pb, MAT_LAST_FIELD);
300  avio_w8(pb, 4);
301  avio_wb32(pb, gxf->nb_fields);
302 
303  /* reserved */
304  avio_w8(pb, MAT_MARK_IN);
305  avio_w8(pb, 4);
306  avio_wb32(pb, 0);
307 
308  avio_w8(pb, MAT_MARK_OUT);
309  avio_w8(pb, 4);
310  avio_wb32(pb, gxf->nb_fields);
311 
312  /* estimated size */
313  avio_w8(pb, MAT_SIZE);
314  avio_w8(pb, 4);
315  avio_wb32(pb, avio_size(pb) / 1024);
316 
317  return updateSize(pb, pos);
318 }
319 
321 {
322  GXFContext *gxf = s->priv_data;
323  AVIOContext *pb = s->pb;
324  int64_t pos;
325  int i;
326 
327  pos = avio_tell(pb);
328  avio_wb16(pb, 0); /* size */
329  for (i = 0; i < s->nb_streams; ++i)
331 
333 
334  return updateSize(pb, pos);
335 }
336 
337 static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
338 {
339  GXFContext *gxf = s->priv_data;
340  AVIOContext *pb = s->pb;
341  int64_t pos = avio_tell(pb);
342 
343  if (!rewrite) {
344  if (!(gxf->map_offsets_nb % 30)) {
345  int err;
346  if ((err = av_reallocp_array(&gxf->map_offsets,
347  gxf->map_offsets_nb + 30,
348  sizeof(*gxf->map_offsets))) < 0) {
349  gxf->map_offsets_nb = 0;
350  av_log(s, AV_LOG_ERROR, "could not realloc map offsets\n");
351  return err;
352  }
353  }
354  gxf->map_offsets[gxf->map_offsets_nb++] = pos; // do not increment here
355  }
356 
358 
359  /* preamble */
360  avio_w8(pb, 0xE0); /* version */
361  avio_w8(pb, 0xFF); /* reserved */
362 
365 
366  return updatePacketSize(pb, pos);
367 }
368 
370 {
371  GXFContext *gxf = s->priv_data;
372  AVIOContext *pb = s->pb;
373  int64_t pos = avio_tell(pb);
374  int fields_per_flt = (gxf->nb_fields+1) / 1000 + 1;
375  int flt_entries = gxf->nb_fields / fields_per_flt;
376  int i = 0;
377 
379 
380  avio_wl32(pb, fields_per_flt); /* number of fields */
381  avio_wl32(pb, flt_entries); /* number of active flt entries */
382 
383  if (gxf->flt_entries) {
384  for (i = 0; i < flt_entries; i++)
385  avio_wl32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
386  }
387 
388  for (; i < 1000; i++)
389  avio_wl32(pb, 0);
390 
391  return updatePacketSize(pb, pos);
392 }
393 
395 {
396  GXFContext *gxf = s->priv_data;
397  AVIOContext *pb = s->pb;
398  int timecode_base = gxf->time_base.den == 60000 ? 60 : 50;
399  int64_t timestamp = 0;
401  uint32_t timecode;
402 
403  if (t = av_dict_get(s->metadata, "creation_time", NULL, 0))
404  timestamp = ff_iso8601_to_unix_time(t->value);
405 
406  // XXX drop frame
407  timecode =
408  gxf->nb_fields / (timecode_base * 3600) % 24 << 24 | // hours
409  gxf->nb_fields / (timecode_base * 60) % 60 << 16 | // minutes
410  gxf->nb_fields / timecode_base % 60 << 8 | // seconds
411  gxf->nb_fields % timecode_base; // fields
412 
413  avio_wl32(pb, gxf->flags);
414  avio_wl32(pb, gxf->nb_fields); /* length of the longest track */
415  avio_wl32(pb, gxf->nb_fields); /* length of the shortest track */
416  avio_wl32(pb, 0); /* mark in */
417  avio_wl32(pb, gxf->nb_fields); /* mark out */
418  avio_wl32(pb, 0); /* timecode mark in */
419  avio_wl32(pb, timecode); /* timecode mark out */
420  avio_wl64(pb, timestamp); /* modification time */
421  avio_wl64(pb, timestamp); /* creation time */
422  avio_wl16(pb, 0); /* reserved */
423  avio_wl16(pb, 0); /* reserved */
424  avio_wl16(pb, gxf->audio_tracks);
425  avio_wl16(pb, 1); /* timecode track count */
426  avio_wl16(pb, 0); /* reserved */
427  avio_wl16(pb, gxf->mpeg_tracks);
428  return 48;
429 }
430 
432 {
433  GXFContext *gxf = s->priv_data;
434  AVIOContext *pb = s->pb;
435 
436  avio_wl32(pb, gxf->umf_length); /* total length of the umf data */
437  avio_wl32(pb, 3); /* version */
438  avio_wl32(pb, s->nb_streams+1);
439  avio_wl32(pb, gxf->umf_track_offset); /* umf track section offset */
440  avio_wl32(pb, gxf->umf_track_size);
441  avio_wl32(pb, s->nb_streams+1);
442  avio_wl32(pb, gxf->umf_media_offset);
443  avio_wl32(pb, gxf->umf_media_size);
444  avio_wl32(pb, gxf->umf_length); /* user data offset */
445  avio_wl32(pb, 0); /* user data size */
446  avio_wl32(pb, 0); /* reserved */
447  avio_wl32(pb, 0); /* reserved */
448  return 48;
449 }
450 
452 {
453  AVIOContext *pb = s->pb;
454  GXFContext *gxf = s->priv_data;
455  int64_t pos = avio_tell(pb);
456  int i;
457 
458  gxf->umf_track_offset = pos - gxf->umf_start_offset;
459  for (i = 0; i < s->nb_streams; ++i) {
460  GXFStreamContext *sc = s->streams[i]->priv_data;
461  avio_wl16(pb, sc->media_info);
462  avio_wl16(pb, 1);
463  }
464 
466  avio_wl16(pb, 1);
467 
468  return avio_tell(pb) - pos;
469 }
470 
472 {
473  GXFStreamContext *sc = st->priv_data;
474 
475  if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P)
476  avio_wl32(pb, 2);
477  else
478  avio_wl32(pb, 1); /* default to 420 */
479  avio_wl32(pb, sc->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
480  avio_wl32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
481  avio_wl32(pb, 1); /* I picture per GOP */
482  avio_wl32(pb, sc->p_per_gop);
483  avio_wl32(pb, sc->b_per_i_or_p);
485  avio_wl32(pb, 2);
486  else if (st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO)
487  avio_wl32(pb, 1);
488  else
489  avio_wl32(pb, 0);
490  avio_wl32(pb, 0); /* reserved */
491  return 32;
492 }
493 
495 {
496  avio_wl32(pb, 1); /* non drop frame */
497  avio_wl32(pb, 0); /* reserved */
498  avio_wl32(pb, 0); /* reserved */
499  avio_wl32(pb, 0); /* reserved */
500  avio_wl32(pb, 0); /* reserved */
501  avio_wl32(pb, 0); /* reserved */
502  avio_wl32(pb, 0); /* reserved */
503  avio_wl32(pb, 0); /* reserved */
504  return 32;
505 }
506 
508 {
509  int i;
510 
511  for (i = 0; i < 8; i++) {
512  avio_wb32(pb, 0);
513  }
514  return 32;
515 }
516 
518 {
519  avio_wl64(pb, av_double2int(1)); /* sound level to begin to */
520  avio_wl64(pb, av_double2int(1)); /* sound level to begin to */
521  avio_wl32(pb, 0); /* number of fields over which to ramp up sound level */
522  avio_wl32(pb, 0); /* number of fields over which to ramp down sound level */
523  avio_wl32(pb, 0); /* reserved */
524  avio_wl32(pb, 0); /* reserved */
525  return 32;
526 }
527 
529 {
530  GXFContext *gxf = s->priv_data;
531  AVIOContext *pb = s->pb;
532  int64_t pos;
533  int i, j;
534 
535  pos = avio_tell(pb);
536  gxf->umf_media_offset = pos - gxf->umf_start_offset;
537  for (i = 0; i <= s->nb_streams; ++i) {
538  GXFStreamContext *sc;
539  int64_t startpos, curpos;
540 
541  if (i == s->nb_streams)
542  sc = &gxf->timecode_track;
543  else
544  sc = s->streams[i]->priv_data;
545 
546  startpos = avio_tell(pb);
547  avio_wl16(pb, 0); /* length */
548  avio_wl16(pb, sc->media_info);
549  avio_wl16(pb, 0); /* reserved */
550  avio_wl16(pb, 0); /* reserved */
551  avio_wl32(pb, gxf->nb_fields);
552  avio_wl32(pb, 0); /* attributes rw, ro */
553  avio_wl32(pb, 0); /* mark in */
554  avio_wl32(pb, gxf->nb_fields); /* mark out */
556  avio_wb16(pb, sc->media_info);
557  for (j = strlen(ES_NAME_PATTERN)+2; j < 88; j++)
558  avio_w8(pb, 0);
559  avio_wl32(pb, sc->track_type);
560  avio_wl32(pb, sc->sample_rate);
561  avio_wl32(pb, sc->sample_size);
562  avio_wl32(pb, 0); /* reserved */
563 
564  if (sc == &gxf->timecode_track)
565  gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
566  else {
567  AVStream *st = s->streams[i];
568  switch (st->codec->codec_id) {
571  gxf_write_umf_media_mpeg(pb, st);
572  break;
575  break;
576  case AV_CODEC_ID_DVVIDEO:
577  gxf_write_umf_media_dv(pb, sc);
578  break;
579  }
580  }
581 
582  curpos = avio_tell(pb);
583  avio_seek(pb, startpos, SEEK_SET);
584  avio_wl16(pb, curpos - startpos);
585  avio_seek(pb, curpos, SEEK_SET);
586  }
587  return avio_tell(pb) - pos;
588 }
589 
591 {
592  GXFContext *gxf = s->priv_data;
593  AVIOContext *pb = s->pb;
594  int64_t pos = avio_tell(pb);
595 
597 
598  /* preamble */
599  avio_w8(pb, 3); /* first and last (only) packet */
600  avio_wb32(pb, gxf->umf_length); /* data length */
601 
602  gxf->umf_start_offset = avio_tell(pb);
607  gxf->umf_length = avio_tell(pb) - gxf->umf_start_offset;
608  return updatePacketSize(pb, pos);
609 }
610 
611 static const int GXF_samples_per_frame[] = { 32768, 0 };
612 
614 {
615  if (!vsc)
616  return;
617 
618  sc->media_type = vsc->sample_rate == 60 ? 7 : 8;
619  sc->sample_rate = vsc->sample_rate;
620  sc->media_info = ('T'<<8) | '0';
621  sc->track_type = 3;
623  sc->lines_index = vsc->lines_index;
624  sc->sample_size = 16;
625  sc->fields = vsc->fields;
626 }
627 
629 {
630  AVIOContext *pb = s->pb;
631  GXFContext *gxf = s->priv_data;
632  GXFStreamContext *vsc = NULL;
633  uint8_t tracks[255] = {0};
634  int i, media_info = 0;
635 
636  if (!pb->seekable) {
637  av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome");
638  return -1;
639  }
640 
641  gxf->flags |= 0x00080000; /* material is simple clip */
642  for (i = 0; i < s->nb_streams; ++i) {
643  AVStream *st = s->streams[i];
644  GXFStreamContext *sc = av_mallocz(sizeof(*sc));
645  if (!sc)
646  return AVERROR(ENOMEM);
647  st->priv_data = sc;
648 
649  sc->media_type = ff_codec_get_tag(gxf_media_types, st->codec->codec_id);
650  if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
651  if (st->codec->codec_id != AV_CODEC_ID_PCM_S16LE) {
652  av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
653  return -1;
654  }
655  if (st->codec->sample_rate != 48000) {
656  av_log(s, AV_LOG_ERROR, "only 48000hz sampling rate is allowed\n");
657  return -1;
658  }
659  if (st->codec->channels != 1) {
660  av_log(s, AV_LOG_ERROR, "only mono tracks are allowed\n");
661  return -1;
662  }
663  sc->track_type = 2;
664  sc->sample_rate = st->codec->sample_rate;
665  avpriv_set_pts_info(st, 64, 1, sc->sample_rate);
666  sc->sample_size = 16;
667  sc->frame_rate_index = -2;
668  sc->lines_index = -2;
669  sc->fields = -2;
670  gxf->audio_tracks++;
671  gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
672  media_info = 'A';
673  } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
674  if (i != 0) {
675  av_log(s, AV_LOG_ERROR, "video stream must be the first track\n");
676  return -1;
677  }
678  /* FIXME check from time_base ? */
679  if (st->codec->height == 480 || st->codec->height == 512) { /* NTSC or NTSC+VBI */
680  sc->frame_rate_index = 5;
681  sc->sample_rate = 60;
682  gxf->flags |= 0x00000080;
683  gxf->time_base = (AVRational){ 1001, 60000 };
684  } else if (st->codec->height == 576 || st->codec->height == 608) { /* PAL or PAL+VBI */
685  sc->frame_rate_index = 6;
686  sc->media_type++;
687  sc->sample_rate = 50;
688  gxf->flags |= 0x00000040;
689  gxf->time_base = (AVRational){ 1, 50 };
690  } else {
691  av_log(s, AV_LOG_ERROR, "unsupported video resolution, "
692  "gxf muxer only accepts PAL or NTSC resolutions currently\n");
693  return -1;
694  }
695  avpriv_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den);
696  if (gxf_find_lines_index(st) < 0)
697  sc->lines_index = -1;
698  sc->sample_size = st->codec->bit_rate;
699  sc->fields = 2; /* interlaced */
700 
701  vsc = sc;
702 
703  switch (st->codec->codec_id) {
704  case AV_CODEC_ID_MJPEG:
705  sc->track_type = 1;
706  gxf->flags |= 0x00004000;
707  media_info = 'J';
708  break;
710  sc->track_type = 9;
711  gxf->mpeg_tracks++;
712  media_info = 'L';
713  break;
715  sc->first_gop_closed = -1;
716  sc->track_type = 4;
717  gxf->mpeg_tracks++;
718  gxf->flags |= 0x00008000;
719  media_info = 'M';
720  break;
721  case AV_CODEC_ID_DVVIDEO:
722  if (st->codec->pix_fmt == AV_PIX_FMT_YUV422P) {
723  sc->media_type += 2;
724  sc->track_type = 6;
725  gxf->flags |= 0x00002000;
726  media_info = 'E';
727  } else {
728  sc->track_type = 5;
729  gxf->flags |= 0x00001000;
730  media_info = 'D';
731  }
732  break;
733  default:
734  av_log(s, AV_LOG_ERROR, "video codec not supported\n");
735  return -1;
736  }
737  }
738  /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */
739  sc->media_info = media_info<<8 | ('0'+tracks[media_info]++);
740  sc->order = s->nb_streams - st->index;
741  }
742 
743  if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 48000 }) < 0)
744  return -1;
745 
747  gxf->flags |= 0x200000; // time code track is non-drop frame
748 
749  gxf_write_map_packet(s, 0);
752 
753  gxf->packet_count = 3;
754 
755  avio_flush(pb);
756  return 0;
757 }
758 
760 {
761  int64_t pos = avio_tell(pb);
762 
764  return updatePacketSize(pb, pos);
765 }
766 
768 {
769  GXFContext *gxf = s->priv_data;
770  AVIOContext *pb = s->pb;
771  int64_t end;
772  int i;
773 
775 
777  end = avio_tell(pb);
778  avio_seek(pb, 0, SEEK_SET);
779  /* overwrite map, flt and umf packets with new values */
780  gxf_write_map_packet(s, 1);
783  avio_flush(pb);
784  /* update duration in all map packets */
785  for (i = 1; i < gxf->map_offsets_nb; i++) {
786  avio_seek(pb, gxf->map_offsets[i], SEEK_SET);
787  gxf_write_map_packet(s, 1);
788  avio_flush(pb);
789  }
790 
791  avio_seek(pb, end, SEEK_SET);
792 
793  av_freep(&gxf->flt_entries);
794  av_freep(&gxf->map_offsets);
795 
796  return 0;
797 }
798 
799 static int gxf_parse_mpeg_frame(GXFStreamContext *sc, const uint8_t *buf, int size)
800 {
801  uint32_t c=-1;
802  int i;
803  for(i=0; i<size-4 && c!=0x100; i++){
804  c = (c<<8) + buf[i];
805  if(c == 0x1B8 && sc->first_gop_closed == -1) /* GOP start code */
806  sc->first_gop_closed= (buf[i+4]>>6)&1;
807  }
808  return (buf[i+1]>>3)&7;
809 }
810 
812 {
813  GXFContext *gxf = s->priv_data;
814  AVIOContext *pb = s->pb;
815  AVStream *st = s->streams[pkt->stream_index];
816  GXFStreamContext *sc = st->priv_data;
817  unsigned field_nb;
818  /* If the video is frame-encoded, the frame numbers shall be represented by
819  * even field numbers.
820  * see SMPTE360M-2004 6.4.2.1.3 Media field number */
821  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
822  field_nb = gxf->nb_fields;
823  } else {
824  field_nb = av_rescale_rnd(pkt->dts, gxf->time_base.den,
825  (int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
826  }
827 
828  avio_w8(pb, sc->media_type);
829  avio_w8(pb, st->index);
830  avio_wb32(pb, field_nb);
831  if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
832  avio_wb16(pb, 0);
833  avio_wb16(pb, size / 2);
834  } else if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
835  int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
836  if (frame_type == AV_PICTURE_TYPE_I) {
837  avio_w8(pb, 0x0d);
838  sc->iframes++;
839  } else if (frame_type == AV_PICTURE_TYPE_B) {
840  avio_w8(pb, 0x0f);
841  sc->bframes++;
842  } else {
843  avio_w8(pb, 0x0e);
844  sc->pframes++;
845  }
846  avio_wb24(pb, size);
847  } else if (st->codec->codec_id == AV_CODEC_ID_DVVIDEO) {
848  avio_w8(pb, size / 4096);
849  avio_wb24(pb, 0);
850  } else
851  avio_wb32(pb, size);
852  avio_wb32(pb, field_nb);
853  avio_w8(pb, 1); /* flags */
854  avio_w8(pb, 0); /* reserved */
855  return 16;
856 }
857 
859 {
860  GXFContext *gxf = s->priv_data;
861  AVIOContext *pb = s->pb;
862  AVStream *st = s->streams[pkt->stream_index];
863  int64_t pos = avio_tell(pb);
864  int padding = 0;
865  int packet_start_offset = avio_tell(pb) / 1024;
866 
868  if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
869  padding = 4 - pkt->size % 4;
870  else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
871  padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
872  gxf_write_media_preamble(s, pkt, pkt->size + padding);
873  avio_write(pb, pkt->data, pkt->size);
874  gxf_write_padding(pb, padding);
875 
876  if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
877  if (!(gxf->flt_entries_nb % 500)) {
878  int err;
879  if ((err = av_reallocp_array(&gxf->flt_entries,
880  gxf->flt_entries_nb + 500,
881  sizeof(*gxf->flt_entries))) < 0) {
882  gxf->flt_entries_nb = 0;
883  av_log(s, AV_LOG_ERROR, "could not reallocate flt entries\n");
884  return err;
885  }
886  }
887  gxf->flt_entries[gxf->flt_entries_nb++] = packet_start_offset;
888  gxf->nb_fields += 2; // count fields
889  }
890 
891  updatePacketSize(pb, pos);
892 
893  gxf->packet_count++;
894  if (gxf->packet_count == 100) {
895  gxf_write_map_packet(s, 0);
896  gxf->packet_count = 0;
897  }
898 
899  return 0;
900 }
901 
903 {
904  GXFContext *gxf = s->priv_data;
905  AVPacket *pkt[2] = { cur, next };
906  int i, field_nb[2];
907  GXFStreamContext *sc[2];
908 
909  for (i = 0; i < 2; i++) {
910  AVStream *st = s->streams[pkt[i]->stream_index];
911  sc[i] = st->priv_data;
912  if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
913  field_nb[i] = av_rescale_rnd(pkt[i]->dts, gxf->time_base.den,
914  (int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
915  field_nb[i] &= ~1; // compare against even field number because audio must be before video
916  } else
917  field_nb[i] = pkt[i]->dts; // dts are field based
918  }
919 
920  return field_nb[1] > field_nb[0] ||
921  (field_nb[1] == field_nb[0] && sc[1]->order > sc[0]->order);
922 }
923 
925 {
926  if (pkt && s->streams[pkt->stream_index]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
927  pkt->duration = 2; // enforce 2 fields
928  return ff_audio_rechunk_interleave(s, out, pkt, flush,
930 }
931 
933  .name = "gxf",
934  .long_name = NULL_IF_CONFIG_SMALL("GXF (General eXchange Format)"),
935  .extensions = "gxf",
936  .priv_data_size = sizeof(GXFContext),
937  .audio_codec = AV_CODEC_ID_PCM_S16LE,
938  .video_codec = AV_CODEC_ID_MPEG2VIDEO,
943 };
unsigned packet_count
Definition: gxfenc.c:68
GXFPktType
Definition: gxf.h:25
void avio_wl16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:336
Bytestream IO Context.
Definition: avio.h:68
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:241
static int gxf_write_header(AVFormatContext *s)
Definition: gxfenc.c:628
int size
AVRational time_base
Definition: gxfenc.c:61
static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc)
Definition: gxfenc.c:507
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:61
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:2800
static int64_t updatePacketSize(AVIOContext *pb, int64_t pos)
Definition: gxfenc.c:125
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: assenc.c:58
static int gxf_write_umf_media_mpeg(AVIOContext *pb, AVStream *st)
Definition: gxfenc.c:471
static const int GXF_samples_per_frame[]
Definition: gxfenc.c:611
int num
numerator
Definition: rational.h:44
int index
stream index in AVFormatContext
Definition: avformat.h:700
int size
Definition: avcodec.h:968
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:186
static const AVCodecTag gxf_media_types[]
Definition: gxfenc.c:82
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1248
Definition: gxf.h:29
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
Definition: intfloat.h:70
void * priv_data
Definition: avformat.h:719
unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id)
Definition: utils.c:1912
int b_per_i_or_p
number of B frames per I frame or P frame
Definition: gxfenc.c:45
static const struct @106 gxf_lines_tab[]
GXFStreamContext timecode_track
Definition: gxfenc.c:63
Definition: gxf.h:43
unsigned map_offsets_nb
Definition: gxfenc.c:67
uint32_t umf_start_offset
Definition: gxfenc.c:55
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:198
Definition: gxf.h:39
Definition: gxf.h:34
Format I/O context.
Definition: avformat.h:922
uint32_t umf_length
Definition: gxfenc.c:58
AVOutputFormat ff_gxf_muxer
Definition: gxfenc.c:932
unsigned flt_entries_nb
Definition: gxfenc.c:65
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:260
uint8_t
Round toward +infinity.
Definition: mathematics.h:53
uint32_t umf_track_offset
Definition: gxfenc.c:56
Definition: gxf.h:49
int ff_audio_interleave_init(AVFormatContext *s, const int *samples_per_frame, AVRational time_base)
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:990
AudioInterleaveContext aic
Definition: gxfenc.c:32
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:38
uint8_t * data
Definition: avcodec.h:967
int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
Interleave a packet per dts in an output media file.
Definition: mux.c:449
static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc)
Definition: gxfenc.c:613
static int gxf_write_timecode_auxiliary(AVIOContext *pb, GXFStreamContext *sc)
Definition: gxfenc.c:202
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:219
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:165
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: mux.c:522
static int gxf_find_lines_index(AVStream *st)
Definition: gxfenc.c:104
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:985
static int write_trailer(AVFormatContext *s)
Definition: assenc.c:64
static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cur)
Definition: gxfenc.c:902
void avio_wl64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:324
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:167
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:123
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1130
static int64_t updateSize(AVIOContext *pb, int64_t pos)
Definition: gxfenc.c:142
#define AVERROR(e)
Definition: error.h:43
Definition: gxf.h:44
int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush, int(*get_packet)(AVFormatContext *, AVPacket *, AVPacket *, int), int(*compare_ts)(AVFormatContext *, AVPacket *, AVPacket *))
Rechunk audio PCM packets per AudioInterleaveContext->samples_per_frame and interleave them correctly...
uint16_t umf_track_size
Definition: gxfenc.c:59
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:150
static void gxf_write_padding(AVIOContext *pb, int64_t to_pad)
Definition: gxfenc.c:118
uint32_t sample_size
Definition: gxfenc.c:34
uint32_t umf_media_offset
Definition: gxfenc.c:57
static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc)
Definition: gxfenc.c:517
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:168
int first_gop_closed
Definition: gxfenc.c:46
Definition: gxf.h:27
static int gxf_write_umf_payload(AVFormatContext *s)
Definition: gxfenc.c:431
static int gxf_write_umf_material_description(AVFormatContext *s)
Definition: gxfenc.c:394
Definition: gxf.h:28
uint32_t nb_fields
Definition: gxfenc.c:51
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:69
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:718
static int gxf_write_umf_media_timecode(AVIOContext *pb, GXFStreamContext *sc)
Definition: gxfenc.c:494
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:978
static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
Definition: gxfenc.c:811
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
Definition: avio.h:117
int bit_rate
the average bitrate
Definition: avcodec.h:1108
int void avio_flush(AVIOContext *s)
Definition: aviobuf.c:180
static int gxf_parse_mpeg_frame(GXFStreamContext *sc, const uint8_t *buf, int size)
Definition: gxfenc.c:799
static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
Definition: gxfenc.c:924
char filename[1024]
input or output filename
Definition: avformat.h:998
int64_t ff_iso8601_to_unix_time(const char *datestr)
Convert a date string in ISO8601 format to Unix timestamp.
Definition: utils.c:2886
void avio_wb24(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:354
const char * name
Definition: avformat.h:446
int64_t creation_time
Definition: gxfenc.c:54
static char buffer[20]
Definition: seek-test.c:31
#define GXF_AUDIO_PACKET_SIZE
Definition: gxfenc.c:29
static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
Definition: gxfenc.c:337
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:110
unsigned order
interleaving order
Definition: gxfenc.c:47
#define ES_NAME_PATTERN
Definition: gxfenc.c:102
Stream structure.
Definition: avformat.h:699
static int gxf_write_material_data_section(AVFormatContext *s)
Definition: gxfenc.c:269
unsigned * flt_entries
offsets of packets /1024, starts after 2nd video field
Definition: gxfenc.c:64
NULL
Definition: eval.c:55
uint16_t media_info
Definition: gxfenc.c:37
enum AVMediaType codec_type
Definition: avcodec.h:1052
enum AVCodecID codec_id
Definition: avcodec.h:1061
int sample_rate
samples per second
Definition: avcodec.h:1785
AVIOContext * pb
I/O context.
Definition: avformat.h:964
int frame_rate_index
Definition: gxfenc.c:38
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:144
static int gxf_write_track_description_section(AVFormatContext *s)
Definition: gxfenc.c:320
int index
Definition: gxfenc.c:72
static int gxf_write_eos_packet(AVIOContext *pb)
Definition: gxfenc.c:759
rational number numerator/denominator
Definition: rational.h:43
Definition: gxf.h:45
static int gxf_write_trailer(AVFormatContext *s)
Definition: gxfenc.c:767
Definition: gxf.h:26
static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, int index)
Definition: gxfenc.c:213
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:342
uint16_t umf_media_size
Definition: gxfenc.c:60
int height
Definition: gxfenc.c:72
static void gxf_write_packet_header(AVIOContext *pb, GXFPktType type)
Definition: gxfenc.c:153
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
#define SERVER_PATH
Definition: gxfenc.c:101
Main libavformat public API header.
static int gxf_write_flt_packet(AVFormatContext *s)
Definition: gxfenc.c:369
void ff_audio_interleave_close(AVFormatContext *s)
uint64_t * map_offsets
offset of map packets
Definition: gxfenc.c:66
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1771
Bi-dir predicted.
Definition: avutil.h:255
static int gxf_write_umf_track_description(AVFormatContext *s)
Definition: gxfenc.c:451
uint16_t mpeg_tracks
Definition: gxfenc.c:53
int den
denominator
Definition: rational.h:45
uint16_t audio_tracks
Definition: gxfenc.c:52
int lines_index
Definition: gxfenc.c:39
Definition: gxf.h:30
char * value
Definition: dict.h:76
int len
int channels
number of audio channels
Definition: avcodec.h:1786
void * priv_data
Format private data.
Definition: avformat.h:950
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:380
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:966
Definition: gxf.h:47
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:268
uint32_t track_type
Definition: gxfenc.c:33
static int gxf_write_umf_packet(AVFormatContext *s)
Definition: gxfenc.c:590
uint16_t media_type
Definition: gxfenc.c:36
int flags
Definition: gxfenc.c:62
int stream_index
Definition: avcodec.h:969
This structure stores compressed data.
Definition: avcodec.h:944
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:205
uint32_t sample_rate
Definition: gxfenc.c:35
static int gxf_write_umf_media_description(AVFormatContext *s)
Definition: gxfenc.c:528
static int gxf_write_mpeg_auxiliary(AVIOContext *pb, AVStream *st)
Definition: gxfenc.c:164
static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: gxfenc.c:858