FFmpeg
oggenc.c
Go to the documentation of this file.
1 /*
2  * Ogg muxer
3  * Copyright (c) 2007 Baptiste Coudurier <baptiste dot coudurier at free dot fr>
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/crc.h"
25 #include "libavutil/mathematics.h"
26 #include "libavutil/opt.h"
27 #include "libavutil/random_seed.h"
28 #include "libavcodec/xiph.h"
29 #include "libavcodec/bytestream.h"
30 #include "libavcodec/flac.h"
31 #include "avformat.h"
32 #include "avio_internal.h"
33 #include "internal.h"
34 #include "vorbiscomment.h"
35 
36 #define MAX_PAGE_SIZE 65025
37 
38 typedef struct OGGPage {
39  int64_t start_granule;
40  int64_t granule;
46  uint16_t size;
47 } OGGPage;
48 
49 typedef struct OGGStreamContext {
50  unsigned page_counter;
52  int header_len[3];
53  /** for theora granule */
54  int kfgshift;
55  int64_t last_kf_pts;
56  int vrev;
57  /* for VP8 granule */
58  int isvp8;
59  int eos;
60  unsigned page_count; ///< number of page buffered
61  OGGPage page; ///< current page
62  unsigned serial_num; ///< serial number
63  int64_t last_granule; ///< last packet granule
65 
66 typedef struct OGGPageList {
68  struct OGGPageList *next;
69 } OGGPageList;
70 
71 typedef struct OGGContext {
72  const AVClass *class;
74  int pref_size; ///< preferred page size (0 => fill all segments)
75  int64_t pref_duration; ///< preferred page duration (0 => fill all segments)
77 } OGGContext;
78 
79 #define OFFSET(x) offsetof(OGGContext, x)
80 #define PARAM AV_OPT_FLAG_ENCODING_PARAM
81 
82 static const AVOption options[] = {
83  { "serial_offset", "serial number offset",
84  OFFSET(serial_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, PARAM },
85  { "oggpagesize", "Set preferred Ogg page size.",
86  OFFSET(pref_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, MAX_PAGE_SIZE, PARAM},
87  { "pagesize", "preferred page size in bytes (deprecated)",
88  OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, PARAM },
89  { "page_duration", "preferred page duration, in microseconds",
90  OFFSET(pref_duration), AV_OPT_TYPE_INT64, { .i64 = 1000000 }, 0, INT64_MAX, PARAM },
91  { NULL },
92 };
93 
94 #define OGG_CLASS(flavor, name)\
95 static const AVClass flavor ## _muxer_class = {\
96  .class_name = #name " muxer",\
97  .item_name = av_default_item_name,\
98  .option = options,\
99  .version = LIBAVUTIL_VERSION_INT,\
100 };
101 
102 static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
103 {
104  int64_t pos = avio_tell(pb);
105  uint32_t checksum = ffio_get_checksum(pb);
106  avio_seek(pb, crc_offset, SEEK_SET);
107  avio_wb32(pb, checksum);
108  avio_seek(pb, pos, SEEK_SET);
109 }
110 
111 static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
112 {
113  OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
114  AVIOContext *pb;
115  int64_t crc_offset;
116  int ret, size;
117  uint8_t *buf;
118 
119  ret = avio_open_dyn_buf(&pb);
120  if (ret < 0)
121  return ret;
123  ffio_wfourcc(pb, "OggS");
124  avio_w8(pb, 0);
125  avio_w8(pb, page->flags | extra_flags);
126  avio_wl64(pb, page->granule);
127  avio_wl32(pb, oggstream->serial_num);
128  avio_wl32(pb, oggstream->page_counter++);
129  crc_offset = avio_tell(pb);
130  avio_wl32(pb, 0); // crc
131  avio_w8(pb, page->segments_count);
132  avio_write(pb, page->segments, page->segments_count);
133  avio_write(pb, page->data, page->size);
134 
135  ogg_update_checksum(s, pb, crc_offset);
136  avio_flush(pb);
137 
138  size = avio_close_dyn_buf(pb, &buf);
139  if (size < 0)
140  return size;
141 
142  avio_write(s->pb, buf, size);
143  avio_flush(s->pb);
144  av_free(buf);
145  oggstream->page_count--;
146  return 0;
147 }
148 
149 static int ogg_key_granule(OGGStreamContext *oggstream, int64_t granule)
150 {
151  return (oggstream->kfgshift && !(granule & ((1<<oggstream->kfgshift)-1))) ||
152  (oggstream->isvp8 && !((granule >> 3) & 0x07ffffff));
153 }
154 
155 static int64_t ogg_granule_to_timestamp(OGGStreamContext *oggstream, int64_t granule)
156 {
157  if (oggstream->kfgshift)
158  return (granule>>oggstream->kfgshift) +
159  (granule & ((1<<oggstream->kfgshift)-1));
160  else if (oggstream->isvp8)
161  return granule >> 32;
162  else
163  return granule;
164 }
165 
167 {
168  AVStream *st2 = s->streams[next->stream_index];
169  AVStream *st = s->streams[page->stream_index];
170  int64_t next_granule, cur_granule;
171 
172  if (next->granule == -1 || page->granule == -1)
173  return 0;
174 
175  next_granule = av_rescale_q(ogg_granule_to_timestamp(st2->priv_data, next->granule),
176  st2->time_base, AV_TIME_BASE_Q);
177  cur_granule = av_rescale_q(ogg_granule_to_timestamp(st->priv_data, page->granule),
178  st ->time_base, AV_TIME_BASE_Q);
179  return next_granule > cur_granule;
180 }
181 
182 static int ogg_reset_cur_page(OGGStreamContext *oggstream)
183 {
184  oggstream->page.granule = -1;
185  oggstream->page.flags = 0;
186  oggstream->page.segments_count = 0;
187  oggstream->page.size = 0;
188  return 0;
189 }
190 
192 {
193  OGGContext *ogg = s->priv_data;
194  OGGPageList **p = &ogg->page_list;
195  OGGPageList *l = av_mallocz(sizeof(*l));
196 
197  if (!l)
198  return AVERROR(ENOMEM);
199  l->page = oggstream->page;
200 
201  oggstream->page.start_granule = ogg_granule_to_timestamp(oggstream, oggstream->page.granule);
202  oggstream->page_count++;
203  ogg_reset_cur_page(oggstream);
204 
205  while (*p) {
206  if (ogg_compare_granule(s, &(*p)->page, &l->page))
207  break;
208  p = &(*p)->next;
209  }
210  l->next = *p;
211  *p = l;
212 
213  return 0;
214 }
215 
217  uint8_t *data, unsigned size, int64_t granule,
218  int header)
219 {
220  OGGStreamContext *oggstream = st->priv_data;
221  OGGContext *ogg = s->priv_data;
222  int total_segments = size / 255 + 1;
223  uint8_t *p = data;
224  int i, segments, len, flush = 0;
225 
226  // Handles VFR by flushing page because this frame needs to have a timestamp
227  // For theora and VP8, keyframes also need to have a timestamp to correctly mark
228  // them as such, otherwise seeking will not work correctly at the very
229  // least with old libogg versions.
230  // Do not try to flush header packets though, that will create broken files.
232  (ogg_granule_to_timestamp(oggstream, granule) >
233  ogg_granule_to_timestamp(oggstream, oggstream->last_granule) + 1 ||
234  ogg_key_granule(oggstream, granule))) {
235  if (oggstream->page.granule != -1)
236  ogg_buffer_page(s, oggstream);
237  flush = 1;
238  }
239 
240  // avoid a continued page
241  if (!header && oggstream->page.size > 0 &&
242  MAX_PAGE_SIZE - oggstream->page.size < size) {
243  ogg_buffer_page(s, oggstream);
244  }
245 
246  for (i = 0; i < total_segments; ) {
247  OGGPage *page = &oggstream->page;
248 
249  segments = FFMIN(total_segments - i, 255 - page->segments_count);
250 
251  if (i && !page->segments_count)
252  page->flags |= 1; // continued packet
253 
254  memset(page->segments+page->segments_count, 255, segments - 1);
255  page->segments_count += segments - 1;
256 
257  len = FFMIN(size, segments*255);
258  page->segments[page->segments_count++] = len - (segments-1)*255;
259  memcpy(page->data+page->size, p, len);
260  p += len;
261  size -= len;
262  i += segments;
263  page->size += len;
264 
265  if (i == total_segments)
266  page->granule = granule;
267 
268  {
269  AVStream *st = s->streams[page->stream_index];
270 
271  int64_t start = av_rescale_q(page->start_granule, st->time_base,
273  int64_t next = av_rescale_q(ogg_granule_to_timestamp(oggstream, page->granule),
275 
276  if (page->segments_count == 255) {
277  ogg_buffer_page(s, oggstream);
278  } else if (!header) {
279  if ((ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
280  (ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
281  ogg_buffer_page(s, oggstream);
282  }
283  }
284  }
285  }
286 
287  if (flush && oggstream->page.granule != -1)
288  ogg_buffer_page(s, oggstream);
289 
290  return 0;
291 }
292 
293 static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact,
294  int *header_len, AVDictionary **m, int framing_bit,
295  AVChapter **chapters, unsigned int nb_chapters)
296 {
297  const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
298  int64_t size;
299  uint8_t *p, *p0;
300 
302 
303  size = offset + ff_vorbiscomment_length(*m, vendor, chapters, nb_chapters) + framing_bit;
304  if (size > INT_MAX)
305  return NULL;
306  p = av_mallocz(size);
307  if (!p)
308  return NULL;
309  p0 = p;
310 
311  p += offset;
312  ff_vorbiscomment_write(&p, m, vendor, chapters, nb_chapters);
313  if (framing_bit)
314  bytestream_put_byte(&p, 1);
315 
316  *header_len = size;
317  return p0;
318 }
319 
321  OGGStreamContext *oggstream, int bitexact,
322  AVDictionary **m)
323 {
324  uint8_t *p;
325 
327  return AVERROR(EINVAL);
328 
329  // first packet: STREAMINFO
330  oggstream->header_len[0] = 51;
331  oggstream->header[0] = av_mallocz(51); // per ogg flac specs
332  p = oggstream->header[0];
333  if (!p)
334  return AVERROR(ENOMEM);
335  bytestream_put_byte(&p, 0x7F);
336  bytestream_put_buffer(&p, "FLAC", 4);
337  bytestream_put_byte(&p, 1); // major version
338  bytestream_put_byte(&p, 0); // minor version
339  bytestream_put_be16(&p, 1); // headers packets without this one
340  bytestream_put_buffer(&p, "fLaC", 4);
341  bytestream_put_byte(&p, 0x00); // streaminfo
342  bytestream_put_be24(&p, 34);
344 
345  // second packet: VorbisComment
346  p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m, 0, NULL, 0);
347  if (!p)
348  return AVERROR(ENOMEM);
349  oggstream->header[1] = p;
350  bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment
351  bytestream_put_be24(&p, oggstream->header_len[1] - 4);
352 
353  return 0;
354 }
355 
356 #define SPEEX_HEADER_SIZE 80
357 
359  OGGStreamContext *oggstream, int bitexact,
360  AVDictionary **m)
361 {
362  uint8_t *p;
363 
365  return AVERROR_INVALIDDATA;
366 
367  // first packet: Speex header
369  if (!p)
370  return AVERROR(ENOMEM);
371  oggstream->header[0] = p;
372  oggstream->header_len[0] = SPEEX_HEADER_SIZE;
374  AV_WL32(&oggstream->header[0][68], 0); // set extra_headers to 0
375 
376  // second packet: VorbisComment
377  p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0, NULL, 0);
378  if (!p)
379  return AVERROR(ENOMEM);
380  oggstream->header[1] = p;
381 
382  return 0;
383 }
384 
385 #define OPUS_HEADER_SIZE 19
386 
388  OGGStreamContext *oggstream, int bitexact,
389  AVDictionary **m, AVChapter **chapters,
390  unsigned int nb_chapters)
391 {
392  uint8_t *p;
393 
394  if (par->extradata_size < OPUS_HEADER_SIZE)
395  return AVERROR_INVALIDDATA;
396 
397  /* first packet: Opus header */
398  p = av_mallocz(par->extradata_size);
399  if (!p)
400  return AVERROR(ENOMEM);
401  oggstream->header[0] = p;
402  oggstream->header_len[0] = par->extradata_size;
404 
405  /* second packet: VorbisComment */
406  p = ogg_write_vorbiscomment(8, bitexact, &oggstream->header_len[1], m, 0, chapters, nb_chapters);
407  if (!p)
408  return AVERROR(ENOMEM);
409  oggstream->header[1] = p;
410  bytestream_put_buffer(&p, "OpusTags", 8);
411 
412  return 0;
413 }
414 
415 #define VP8_HEADER_SIZE 26
416 
418  OGGStreamContext *oggstream, int bitexact)
419 {
420  AVCodecParameters *par = st->codecpar;
421  uint8_t *p;
422 
423  /* first packet: VP8 header */
425  if (!p)
426  return AVERROR(ENOMEM);
427  oggstream->header[0] = p;
428  oggstream->header_len[0] = VP8_HEADER_SIZE;
429  bytestream_put_byte(&p, 0x4f); // HDRID
430  bytestream_put_buffer(&p, "VP80", 4); // Identifier
431  bytestream_put_byte(&p, 1); // HDRTYP
432  bytestream_put_byte(&p, 1); // VMAJ
433  bytestream_put_byte(&p, 0); // VMIN
434  bytestream_put_be16(&p, par->width);
435  bytestream_put_be16(&p, par->height);
436  bytestream_put_be24(&p, par->sample_aspect_ratio.num);
437  bytestream_put_be24(&p, par->sample_aspect_ratio.den);
438  if (st->r_frame_rate.num > 0 && st->r_frame_rate.den > 0) {
439  // OggVP8 requires pts to increase by 1 per visible frame, so use the least common
440  // multiple framerate if available.
441  av_log(s, AV_LOG_DEBUG, "Changing time base from %d/%d to %d/%d\n",
442  st->time_base.num, st->time_base.den,
443  st->r_frame_rate.den, st->r_frame_rate.num);
445  }
446  bytestream_put_be32(&p, st->time_base.den);
447  bytestream_put_be32(&p, st->time_base.num);
448 
449  /* optional second packet: VorbisComment */
451  p = ogg_write_vorbiscomment(7, bitexact, &oggstream->header_len[1], &st->metadata, 0, NULL, 0);
452  if (!p)
453  return AVERROR(ENOMEM);
454  oggstream->header[1] = p;
455  bytestream_put_byte(&p, 0x4f); // HDRID
456  bytestream_put_buffer(&p, "VP80", 4); // Identifier
457  bytestream_put_byte(&p, 2); // HDRTYP
458  bytestream_put_byte(&p, 0x20);
459  }
460 
461  oggstream->isvp8 = 1;
462 
463  return 0;
464 }
465 
467 {
468  OGGContext *ogg = s->priv_data;
469  OGGPageList *next, *p;
470 
471  if (!ogg->page_list)
472  return;
473 
474  for (p = ogg->page_list; p; ) {
475  OGGStreamContext *oggstream =
476  s->streams[p->page.stream_index]->priv_data;
477  if (oggstream->page_count < 2 && !flush)
478  break;
479  ogg_write_page(s, &p->page,
480  flush == 1 && oggstream->page_count == 1 ? 4 : 0); // eos
481  next = p->next;
482  av_freep(&p);
483  p = next;
484  }
485  ogg->page_list = p;
486 }
487 
489 {
490  OGGContext *ogg = s->priv_data;
491  OGGStreamContext *oggstream = NULL;
492  int i, j;
493 
494  if (ogg->pref_size)
495  av_log(s, AV_LOG_WARNING, "The pagesize option is deprecated\n");
496 
497  for (i = 0; i < s->nb_streams; i++) {
498  AVStream *st = s->streams[i];
499  unsigned serial_num = i + ogg->serial_offset;
500 
501  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
502  if (st->codecpar->codec_id == AV_CODEC_ID_OPUS)
503  /* Opus requires a fixed 48kHz clock */
504  avpriv_set_pts_info(st, 64, 1, 48000);
505  else
506  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
507  }
508 
509  if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
515  av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
516  return AVERROR(EINVAL);
517  }
518 
519  if ((!st->codecpar->extradata || !st->codecpar->extradata_size) &&
521  av_log(s, AV_LOG_ERROR, "No extradata present\n");
522  return AVERROR_INVALIDDATA;
523  }
524  oggstream = av_mallocz(sizeof(*oggstream));
525  if (!oggstream)
526  return AVERROR(ENOMEM);
527 
528  oggstream->page.stream_index = i;
529 
530  if (!(s->flags & AVFMT_FLAG_BITEXACT))
531  do {
532  serial_num = av_get_random_seed();
533  for (j = 0; j < i; j++) {
534  OGGStreamContext *sc = s->streams[j]->priv_data;
535  if (serial_num == sc->serial_num)
536  break;
537  }
538  } while (j < i);
539  oggstream->serial_num = serial_num;
540 
541  av_dict_copy(&st->metadata, s->metadata, AV_DICT_DONT_OVERWRITE);
542 
543  st->priv_data = oggstream;
544  if (st->codecpar->codec_id == AV_CODEC_ID_FLAC) {
545  int err = ogg_build_flac_headers(st->codecpar, oggstream,
546  s->flags & AVFMT_FLAG_BITEXACT,
547  &st->metadata);
548  if (err) {
549  av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
550  return err;
551  }
552  } else if (st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {
553  int err = ogg_build_speex_headers(st->codecpar, oggstream,
554  s->flags & AVFMT_FLAG_BITEXACT,
555  &st->metadata);
556  if (err) {
557  av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
558  return err;
559  }
560  } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
561  int err = ogg_build_opus_headers(st->codecpar, oggstream,
562  s->flags & AVFMT_FLAG_BITEXACT,
563  &st->metadata, s->chapters, s->nb_chapters);
564  if (err) {
565  av_log(s, AV_LOG_ERROR, "Error writing Opus headers\n");
566  return err;
567  }
568  } else if (st->codecpar->codec_id == AV_CODEC_ID_VP8) {
569  int err = ogg_build_vp8_headers(s, st, oggstream,
570  s->flags & AVFMT_FLAG_BITEXACT);
571  if (err) {
572  av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n");
573  return err;
574  }
575  } else {
576  uint8_t *p;
577  const char *cstr = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
578  int header_type = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
579  int framing_bit = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
580 
582  st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
583  (const uint8_t**)oggstream->header, oggstream->header_len) < 0) {
584  av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
585  oggstream->header[1] = NULL;
586  return AVERROR_INVALIDDATA;
587  }
588 
590  &oggstream->header_len[1], &st->metadata,
591  framing_bit, NULL, 0);
592  oggstream->header[1] = p;
593  if (!p)
594  return AVERROR(ENOMEM);
595 
596  bytestream_put_byte(&p, header_type);
597  bytestream_put_buffer(&p, cstr, 6);
598 
599  if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
600  int den = AV_RB32(oggstream->header[0] + 22), num = AV_RB32(oggstream->header[0] + 26);
601  /* Make sure to use time base stored in the Theora stream header to write
602  correct timestamps */
603  if (st->time_base.num != num || st->time_base.den != den) {
604  av_log(s, AV_LOG_DEBUG, "Changing time base from %d/%d to %d/%d\n",
605  st->time_base.num, st->time_base.den, num, den);
606  avpriv_set_pts_info(st, 64, num, den);
607  }
608  /** KFGSHIFT is the width of the less significant section of the granule position
609  The less significant section is the frame count since the last keyframe */
610  oggstream->kfgshift = ((oggstream->header[0][40]&3)<<3)|(oggstream->header[0][41]>>5);
611  oggstream->vrev = oggstream->header[0][9];
612  av_log(s, AV_LOG_DEBUG, "theora kfgshift %d, vrev %d\n",
613  oggstream->kfgshift, oggstream->vrev);
614  }
615  }
616  }
617 
618  return 0;
619 }
620 
622 {
623  OGGStreamContext *oggstream = NULL;
624  int i, j;
625 
626  for (j = 0; j < s->nb_streams; j++) {
627  oggstream = s->streams[j]->priv_data;
628  ogg_buffer_data(s, s->streams[j], oggstream->header[0],
629  oggstream->header_len[0], 0, 1);
630  oggstream->page.flags |= 2; // bos
631  ogg_buffer_page(s, oggstream);
632  }
633  for (j = 0; j < s->nb_streams; j++) {
634  AVStream *st = s->streams[j];
635  oggstream = st->priv_data;
636  for (i = 1; i < 3; i++) {
637  if (oggstream->header_len[i])
638  ogg_buffer_data(s, st, oggstream->header[i],
639  oggstream->header_len[i], 0, 1);
640  }
641  ogg_buffer_page(s, oggstream);
642  }
643 
644  oggstream->page.start_granule = AV_NOPTS_VALUE;
645 
646  ogg_write_pages(s, 2);
647 
648  return 0;
649 }
650 
652 {
653  AVStream *st = s->streams[pkt->stream_index];
654  OGGStreamContext *oggstream = st->priv_data;
655  int ret;
656  int64_t granule;
657 
658  if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
659  int64_t pts = oggstream->vrev < 1 ? pkt->pts : pkt->pts + pkt->duration;
660  int pframe_count;
661  if (pkt->flags & AV_PKT_FLAG_KEY)
662  oggstream->last_kf_pts = pts;
663  pframe_count = pts - oggstream->last_kf_pts;
664  // prevent frame count from overflow if key frame flag is not set
665  if (pframe_count >= (1<<oggstream->kfgshift)) {
666  oggstream->last_kf_pts += pframe_count;
667  pframe_count = 0;
668  }
669  granule = (oggstream->last_kf_pts<<oggstream->kfgshift) | pframe_count;
670  } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS)
671  granule = pkt->pts + pkt->duration +
673  (AVRational){ 1, st->codecpar->sample_rate },
674  st->time_base);
675  else if (st->codecpar->codec_id == AV_CODEC_ID_VP8) {
676  int64_t pts, invcnt, dist;
677  int visible;
678 
679  visible = (pkt->data[0] >> 4) & 1;
680  pts = pkt->pts + pkt->duration;
681  invcnt = (oggstream->last_granule >> 30) & 3;
682  invcnt = visible ? 3 : (invcnt == 3 ? 0 : invcnt + 1);
683  dist = (pkt->flags & AV_PKT_FLAG_KEY) ? 0 : ((oggstream->last_granule >> 3) & 0x07ffffff) + 1;
684 
685  granule = (pts << 32) | (invcnt << 30) | (dist << 3);
686  } else
687  granule = pkt->pts + pkt->duration;
688 
689  if (oggstream->page.start_granule == AV_NOPTS_VALUE)
690  oggstream->page.start_granule = pkt->pts;
691 
692  ret = ogg_buffer_data(s, st, pkt->data, pkt->size, granule, 0);
693  if (ret < 0)
694  return ret;
695 
696  ogg_write_pages(s, 0);
697 
698  oggstream->last_granule = granule;
699 
700  return 0;
701 }
702 
704 {
705  int i;
706 
707  if (pkt)
709 
710  for (i = 0; i < s->nb_streams; i++) {
711  OGGStreamContext *oggstream = s->streams[i]->priv_data;
712  if (oggstream->page.segments_count)
713  ogg_buffer_page(s, oggstream);
714  }
715 
716  ogg_write_pages(s, 2);
717  return 1;
718 }
719 
721 {
722  int i;
723 
724  /* flush current page if needed */
725  for (i = 0; i < s->nb_streams; i++) {
726  OGGStreamContext *oggstream = s->streams[i]->priv_data;
727 
728  if (oggstream->page.size > 0)
729  ogg_buffer_page(s, oggstream);
730  }
731 
732  ogg_write_pages(s, 1);
733 
734  return 0;
735 }
736 
738 {
739  int i;
740 
741  for (i = 0; i < s->nb_streams; i++) {
742  AVStream *st = s->streams[i];
743  OGGStreamContext *oggstream = st->priv_data;
744  if (!oggstream)
745  continue;
746  if (st->codecpar->codec_id == AV_CODEC_ID_FLAC ||
750  av_freep(&oggstream->header[0]);
751  }
752  av_freep(&oggstream->header[1]);
753  }
754 }
755 
756 #if CONFIG_OGG_MUXER
757 OGG_CLASS(ogg, Ogg)
759  .name = "ogg",
760  .long_name = NULL_IF_CONFIG_SMALL("Ogg"),
761  .mime_type = "application/ogg",
762  .extensions = "ogg"
763 #if !CONFIG_OGV_MUXER
764  ",ogv"
765 #endif
766 #if !CONFIG_SPX_MUXER
767  ",spx"
768 #endif
769 #if !CONFIG_OPUS_MUXER
770  ",opus"
771 #endif
772  ,
773  .priv_data_size = sizeof(OGGContext),
774  .audio_codec = CONFIG_LIBVORBIS_ENCODER ?
776  .video_codec = AV_CODEC_ID_THEORA,
777  .init = ogg_init,
781  .deinit = ogg_free,
783  .priv_class = &ogg_muxer_class,
784 };
785 #endif
786 
787 #if CONFIG_OGA_MUXER
788 OGG_CLASS(oga, Ogg audio)
790  .name = "oga",
791  .long_name = NULL_IF_CONFIG_SMALL("Ogg Audio"),
792  .mime_type = "audio/ogg",
793  .extensions = "oga",
794  .priv_data_size = sizeof(OGGContext),
795  .audio_codec = AV_CODEC_ID_FLAC,
796  .init = ogg_init,
800  .deinit = ogg_free,
802  .priv_class = &oga_muxer_class,
803 };
804 #endif
805 
806 #if CONFIG_OGV_MUXER
807 OGG_CLASS(ogv, Ogg video)
809  .name = "ogv",
810  .long_name = NULL_IF_CONFIG_SMALL("Ogg Video"),
811  .mime_type = "video/ogg",
812  .extensions = "ogv",
813  .priv_data_size = sizeof(OGGContext),
814  .audio_codec = CONFIG_LIBVORBIS_ENCODER ?
816  .video_codec = CONFIG_LIBTHEORA_ENCODER ?
818  .init = ogg_init,
822  .deinit = ogg_free,
824  .priv_class = &ogv_muxer_class,
825 };
826 #endif
827 
828 #if CONFIG_SPX_MUXER
829 OGG_CLASS(spx, Ogg Speex)
831  .name = "spx",
832  .long_name = NULL_IF_CONFIG_SMALL("Ogg Speex"),
833  .mime_type = "audio/ogg",
834  .extensions = "spx",
835  .priv_data_size = sizeof(OGGContext),
836  .audio_codec = AV_CODEC_ID_SPEEX,
837  .init = ogg_init,
841  .deinit = ogg_free,
843  .priv_class = &spx_muxer_class,
844 };
845 #endif
846 
847 #if CONFIG_OPUS_MUXER
848 OGG_CLASS(opus, Ogg Opus)
850  .name = "opus",
851  .long_name = NULL_IF_CONFIG_SMALL("Ogg Opus"),
852  .mime_type = "audio/ogg",
853  .extensions = "opus",
854  .priv_data_size = sizeof(OGGContext),
855  .audio_codec = AV_CODEC_ID_OPUS,
856  .init = ogg_init,
860  .deinit = ogg_free,
862  .priv_class = &opus_muxer_class,
863 };
864 #endif
VP8_HEADER_SIZE
#define VP8_HEADER_SIZE
Definition: oggenc.c:415
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: avcodec.h:3971
LIBAVFORMAT_IDENT
#define LIBAVFORMAT_IDENT
Definition: version.h:46
OGGContext::pref_duration
int64_t pref_duration
preferred page duration (0 => fill all segments)
Definition: oggenc.c:75
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
AVOutputFormat::name
const char * name
Definition: avformat.h:496
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
opt.h
ff_spx_muxer
AVOutputFormat ff_spx_muxer
ogg_write_page
static int ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
Definition: oggenc.c:111
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3953
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
ffio_wfourcc
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
Definition: avio_internal.h:58
ff_oga_muxer
AVOutputFormat ff_oga_muxer
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: avcodec.h:3949
AVStream::priv_data
void * priv_data
Definition: avformat.h:885
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
ogg_compare_granule
static int ogg_compare_granule(AVFormatContext *s, OGGPage *next, OGGPage *page)
Definition: oggenc.c:166
AVPacket::data
uint8_t * data
Definition: avcodec.h:1477
vorbiscomment.h
OGGPageList
Definition: oggenc.c:66
AVOption
AVOption.
Definition: opt.h:246
data
const char data[16]
Definition: mxf.c:91
ogg_write_vorbiscomment
static uint8_t * ogg_write_vorbiscomment(int64_t offset, int bitexact, int *header_len, AVDictionary **m, int framing_bit, AVChapter **chapters, unsigned int nb_chapters)
Definition: oggenc.c:293
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:70
OGGStreamContext::last_granule
int64_t last_granule
last packet granule
Definition: oggenc.c:63
avio_wl64
void avio_wl64(AVIOContext *s, uint64_t val)
Definition: aviobuf.c:457
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1495
mathematics.h
AVDictionary
Definition: dict.c:30
AV_CODEC_ID_FLAC
@ AV_CODEC_ID_FLAC
Definition: avcodec.h:576
ogg
Definition: oggdec.h:101
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1509
OGGPageList::next
struct OGGPageList * next
Definition: oggenc.c:68
ffio_get_checksum
unsigned long ffio_get_checksum(AVIOContext *s)
Definition: aviobuf.c:618
OGGStreamContext::page_count
unsigned page_count
number of page buffered
Definition: oggenc.c:60
av_get_random_seed
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:120
xiph.h
OGGPageList::page
OGGPage page
Definition: oggenc.c:67
crc.h
OGGStreamContext::page
OGGPage page
current page
Definition: oggenc.c:61
AV_CODEC_ID_SPEEX
@ AV_CODEC_ID_SPEEX
Definition: avcodec.h:599
start
void INT64 start
Definition: avisynth_c.h:767
OFFSET
#define OFFSET(x)
Definition: oggenc.c:79
avio_tell
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:557
AVChapter
Definition: avformat.h:1299
ff_ogv_muxer
AVOutputFormat ff_ogv_muxer
ogg_write_header
static int ogg_write_header(AVFormatContext *s)
Definition: oggenc.c:621
pts
static int64_t pts
Definition: transcode_aac.c:647
AVRational::num
int num
Numerator.
Definition: rational.h:59
OGGStreamContext::eos
int eos
Definition: oggenc.c:59
OGGStreamContext::page_counter
unsigned page_counter
Definition: oggenc.c:50
ff_opus_muxer
AVOutputFormat ff_opus_muxer
ogg_write_packet_internal
static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
Definition: oggenc.c:651
ogg_write_pages
static void ogg_write_pages(AVFormatContext *s, int flush)
Definition: oggenc.c:466
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:1415
SPEEX_HEADER_SIZE
#define SPEEX_HEADER_SIZE
Definition: oggenc.c:356
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
buf
void * buf
Definition: avisynth_c.h:766
OGGStreamContext::isvp8
int isvp8
Definition: oggenc.c:58
ogg_init
static int ogg_init(AVFormatContext *s)
Definition: oggenc.c:488
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:1386
ogg_build_vp8_headers
static int ogg_build_vp8_headers(AVFormatContext *s, AVStream *st, OGGStreamContext *oggstream, int bitexact)
Definition: oggenc.c:417
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVCodecParameters::sample_aspect_ratio
AVRational sample_aspect_ratio
Video only.
Definition: avcodec.h:4033
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
OGGStreamContext::last_kf_pts
int64_t last_kf_pts
Definition: oggenc.c:55
AVCodecParameters::width
int width
Video only.
Definition: avcodec.h:4023
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:224
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
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
ff_vorbiscomment_metadata_conv
const AVMetadataConv ff_vorbiscomment_metadata_conv[]
VorbisComment metadata conversion mapping.
Definition: vorbiscomment.c:33
OGGPage::granule
int64_t granule
Definition: oggenc.c:40
ogg_free
static void ogg_free(AVFormatContext *s)
Definition: oggenc.c:737
ogg_buffer_page
static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
Definition: oggenc.c:191
OGGStreamContext
Definition: oggenc.c:49
AVFormatContext
Format I/O context.
Definition: avformat.h:1342
internal.h
OGG_CLASS
#define OGG_CLASS(flavor, name)
Definition: oggenc.c:94
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1017
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
OGGContext::serial_offset
int serial_offset
Definition: oggenc.c:76
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:899
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:500
NULL
#define NULL
Definition: coverity.c:32
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:94
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
ff_vorbiscomment_length
int64_t ff_vorbiscomment_length(AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters)
Calculate the length in bytes of a VorbisComment.
Definition: vorbiscomment.c:41
ff_vorbiscomment_write
int ff_vorbiscomment_write(uint8_t **p, AVDictionary **m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters)
Write a VorbisComment into a buffer.
Definition: vorbiscomment.c:65
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:934
FLAC_STREAMINFO_SIZE
#define FLAC_STREAMINFO_SIZE
Definition: flac.h:34
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:76
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:196
options
static const AVOption options[]
Definition: oggenc.c:82
OGGStreamContext::header
uint8_t * header[3]
Definition: oggenc.c:51
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: avcodec.h:4067
OGGContext::pref_size
int pref_size
preferred page size (0 => fill all segments)
Definition: oggenc.c:74
MAX_PAGE_SIZE
#define MAX_PAGE_SIZE
Definition: oggenc.c:36
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: avcodec.h:3975
OGGPage::segments
uint8_t segments[255]
Definition: oggenc.c:44
AVIOContext
Bytestream IO Context.
Definition: avio.h:161
AVPacket::size
int size
Definition: avcodec.h:1478
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4910
size
int size
Definition: twinvq_data.h:11134
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:92
AVFMT_ALLOW_FLUSH
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:476
PARAM
#define PARAM
Definition: oggenc.c:80
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition: avcodec.h:624
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:626
header
static const uint8_t header[24]
Definition: sdr2.c:67
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:218
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:377
OGGPage::stream_index
int stream_index
Definition: oggenc.c:41
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
avio_wl32
void avio_wl32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:369
offset
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 offset
Definition: writing_filters.txt:86
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1483
OGGPage::data
uint8_t data[MAX_PAGE_SIZE]
Definition: oggenc.c:45
ff_crc04C11DB7_update
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
Definition: aviobuf.c:600
ff_ogg_muxer
AVOutputFormat ff_ogg_muxer
ogg_update_checksum
static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
Definition: oggenc.c:102
write_packet
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
Definition: ffmpeg.c:690
ogg_build_opus_headers
static int ogg_build_opus_headers(AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m, AVChapter **chapters, unsigned int nb_chapters)
Definition: oggenc.c:387
bytestream_put_buffer
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:368
AVOutputFormat
Definition: avformat.h:495
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1470
avio_internal.h
OGGPage::segments_count
uint8_t segments_count
Definition: oggenc.c:43
ogg_build_flac_headers
static int ogg_build_flac_headers(AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
Definition: oggenc.c:320
AV_CODEC_ID_THEORA
@ AV_CODEC_ID_THEORA
Definition: avcodec.h:248
AVCodecParameters::height
int height
Definition: avcodec.h:4024
ff_metadata_conv
void ff_metadata_conv(AVDictionary **pm, const AVMetadataConv *d_conv, const AVMetadataConv *s_conv)
Definition: metadata.c:26
OGGPage::start_granule
int64_t start_granule
Definition: oggenc.c:39
uint8_t
uint8_t
Definition: audio_convert.c:194
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
ogg_write_trailer
static int ogg_write_trailer(AVFormatContext *s)
Definition: oggenc.c:720
len
int len
Definition: vorbis_enc_data.h:452
AVFMT_TS_NEGATIVE
#define AVFMT_TS_NEGATIVE
Format allows muxing negative timestamps.
Definition: avformat.h:480
AVFMT_TS_NONSTRICT
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:477
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1490
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:870
avio_seek
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:246
OGGContext
Definition: oggenc.c:71
OGGPage
Definition: oggenc.c:38
avformat.h
checksum
static volatile int checksum
Definition: adler32.c:30
OGGStreamContext::serial_num
unsigned serial_num
serial number
Definition: oggenc.c:62
random_seed.h
ogg_granule_to_timestamp
static int64_t ogg_granule_to_timestamp(OGGStreamContext *oggstream, int64_t granule)
Definition: oggenc.c:155
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
video
A Quick Description Of Rate Distortion Theory We want to encode a video
Definition: rate_distortion.txt:3
ogg_build_speex_headers
static int ogg_build_speex_headers(AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
Definition: oggenc.c:358
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:994
OGGPage::size
uint16_t size
Definition: oggenc.c:46
OGGPage::flags
uint8_t flags
Definition: oggenc.c:42
OGGContext::page_list
OGGPageList * page_list
Definition: oggenc.c:73
OGGStreamContext::vrev
int vrev
Definition: oggenc.c:56
AVPacket::stream_index
int stream_index
Definition: avcodec.h:1479
avpriv_split_xiph_headers
int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, int first_header_size, const uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use.
Definition: xiph.c:24
avio_flush
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:238
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3957
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1454
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
av_dict_copy
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition: dict.c:217
OGGStreamContext::kfgshift
int kfgshift
for theora granule
Definition: oggenc.c:54
bytestream.h
AV_CODEC_ID_VP8
@ AV_CODEC_ID_VP8
Definition: avcodec.h:358
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
OGGStreamContext::header_len
int header_len[3]
Definition: oggenc.c:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
OPUS_HEADER_SIZE
#define OPUS_HEADER_SIZE
Definition: oggenc.c:385
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: avcodec.h:569
ogg_write_packet
static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: oggenc.c:703
ogg_buffer_data
static int ogg_buffer_data(AVFormatContext *s, AVStream *st, uint8_t *data, unsigned size, int64_t granule, int header)
Definition: oggenc.c:216
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:337
flac.h
AVCodecParameters::initial_padding
int initial_padding
Audio only.
Definition: avcodec.h:4086
ogg_key_granule
static int ogg_key_granule(OGGStreamContext *oggstream, int64_t granule)
Definition: oggenc.c:149
ogg_reset_cur_page
static int ogg_reset_cur_page(OGGStreamContext *oggstream)
Definition: oggenc.c:182