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 "config_components.h"
23 
24 #include <stdint.h>
25 
26 #include "libavutil/crc.h"
27 #include "libavutil/mathematics.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/random_seed.h"
30 #include "libavcodec/xiph.h"
31 #include "libavcodec/bytestream.h"
32 #include "libavcodec/flac.h"
33 #include "avformat.h"
34 #include "avio_internal.h"
35 #include "internal.h"
36 #include "version.h"
37 #include "vorbiscomment.h"
38 
39 #define MAX_PAGE_SIZE 65025
40 
41 typedef struct OGGPage {
42  int64_t start_granule;
43  int64_t granule;
45  uint8_t flags;
46  uint8_t segments_count;
47  uint8_t segments[255];
48  uint8_t data[MAX_PAGE_SIZE];
49  uint16_t size;
50 } OGGPage;
51 
52 typedef struct OGGStreamContext {
53  unsigned page_counter;
54  uint8_t *header[3];
55  int header_len[3];
56  /** for theora granule */
57  int kfgshift;
58  int64_t last_kf_pts;
59  int vrev;
60  /* for VP8 granule */
61  int isvp8;
62  int eos;
63  unsigned page_count; ///< number of page buffered
64  OGGPage page; ///< current page
65  unsigned serial_num; ///< serial number
66  int64_t last_granule; ///< last packet granule
68 
69 typedef struct OGGPageList {
71  struct OGGPageList *next;
72 } OGGPageList;
73 
74 typedef struct OGGContext {
75  const AVClass *class;
77  int pref_size; ///< preferred page size (0 => fill all segments)
78  int64_t pref_duration; ///< preferred page duration (0 => fill all segments)
80 } OGGContext;
81 
82 #define OFFSET(x) offsetof(OGGContext, x)
83 #define PARAM AV_OPT_FLAG_ENCODING_PARAM
84 
85 static const AVOption options[] = {
86  { "serial_offset", "serial number offset",
87  OFFSET(serial_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, PARAM },
88  { "oggpagesize", "Set preferred Ogg page size.",
89  OFFSET(pref_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, MAX_PAGE_SIZE, PARAM},
90  { "pagesize", "preferred page size in bytes (deprecated)",
91  OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, PARAM },
92  { "page_duration", "preferred page duration, in microseconds",
93  OFFSET(pref_duration), AV_OPT_TYPE_INT64, { .i64 = 1000000 }, 0, INT64_MAX, PARAM },
94  { NULL },
95 };
96 
97 static const AVClass ogg_muxer_class = {
98  .class_name = "Ogg (audio/video/Speex/Opus) muxer",
99  .item_name = av_default_item_name,
100  .option = options,
101  .version = LIBAVUTIL_VERSION_INT,
102 };
103 
104 static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
105 {
106  OGGStreamContext *oggstream = s->streams[page->stream_index]->priv_data;
107  uint8_t buf[4 + 1 + 1 + 8 + 4 + 4 + 4 + 1 + 255], *ptr = buf, *crc_pos;
108  const AVCRC *crc_table = av_crc_get_table(AV_CRC_32_IEEE);
109  uint32_t crc;
110 
111  bytestream_put_le32(&ptr, MKTAG('O', 'g', 'g', 'S'));
112  bytestream_put_byte(&ptr, 0);
113  bytestream_put_byte(&ptr, page->flags | extra_flags);
114  bytestream_put_le64(&ptr, page->granule);
115  bytestream_put_le32(&ptr, oggstream->serial_num);
116  bytestream_put_le32(&ptr, oggstream->page_counter++);
117  crc_pos = ptr;
118  bytestream_put_le32(&ptr, 0);
119  bytestream_put_byte(&ptr, page->segments_count);
120  bytestream_put_buffer(&ptr, page->segments, page->segments_count);
121 
122  crc = av_crc(crc_table, 0, buf, ptr - buf);
123  crc = av_crc(crc_table, crc, page->data, page->size);
124  bytestream_put_be32(&crc_pos, crc);
125 
126  avio_write(s->pb, buf, ptr - buf);
127  avio_write(s->pb, page->data, page->size);
129  oggstream->page_count--;
130 }
131 
132 static int ogg_key_granule(OGGStreamContext *oggstream, int64_t granule)
133 {
134  return (oggstream->kfgshift && !(granule & ((1<<oggstream->kfgshift)-1))) ||
135  (oggstream->isvp8 && !((granule >> 3) & 0x07ffffff));
136 }
137 
138 static int64_t ogg_granule_to_timestamp(OGGStreamContext *oggstream, int64_t granule)
139 {
140  if (oggstream->kfgshift)
141  return (granule>>oggstream->kfgshift) +
142  (granule & ((1<<oggstream->kfgshift)-1));
143  else if (oggstream->isvp8)
144  return granule >> 32;
145  else
146  return granule;
147 }
148 
150 {
151  AVStream *st2 = s->streams[next->stream_index];
152  AVStream *st = s->streams[page->stream_index];
153  int64_t next_granule, cur_granule;
154 
155  if (next->granule == -1 || page->granule == -1)
156  return 0;
157 
158  next_granule = av_rescale_q(ogg_granule_to_timestamp(st2->priv_data, next->granule),
159  st2->time_base, AV_TIME_BASE_Q);
160  cur_granule = av_rescale_q(ogg_granule_to_timestamp(st->priv_data, page->granule),
161  st ->time_base, AV_TIME_BASE_Q);
162  return next_granule > cur_granule;
163 }
164 
165 static int ogg_reset_cur_page(OGGStreamContext *oggstream)
166 {
167  oggstream->page.granule = -1;
168  oggstream->page.flags = 0;
169  oggstream->page.segments_count = 0;
170  oggstream->page.size = 0;
171  return 0;
172 }
173 
175 {
176  OGGContext *ogg = s->priv_data;
177  OGGPageList **p = &ogg->page_list;
178  OGGPageList *l = av_mallocz(sizeof(*l));
179 
180  if (!l)
181  return AVERROR(ENOMEM);
182  l->page = oggstream->page;
183 
184  oggstream->page.start_granule = ogg_granule_to_timestamp(oggstream, oggstream->page.granule);
185  oggstream->page_count++;
186  ogg_reset_cur_page(oggstream);
187 
188  while (*p) {
189  if (ogg_compare_granule(s, &(*p)->page, &l->page))
190  break;
191  p = &(*p)->next;
192  }
193  l->next = *p;
194  *p = l;
195 
196  return 0;
197 }
198 
200  const uint8_t *data, unsigned size, int64_t granule,
201  int header)
202 {
203  OGGStreamContext *oggstream = st->priv_data;
204  OGGContext *ogg = s->priv_data;
205  int total_segments = size / 255 + 1;
206  const uint8_t *p = data;
207  int i, segments, len, flush = 0;
208 
209  // Handles VFR by flushing page because this frame needs to have a timestamp
210  // For theora and VP8, keyframes also need to have a timestamp to correctly mark
211  // them as such, otherwise seeking will not work correctly at the very
212  // least with old libogg versions.
213  // Do not try to flush header packets though, that will create broken files.
215  (ogg_granule_to_timestamp(oggstream, granule) >
216  ogg_granule_to_timestamp(oggstream, oggstream->last_granule) + 1 ||
217  ogg_key_granule(oggstream, granule))) {
218  if (oggstream->page.granule != -1)
219  ogg_buffer_page(s, oggstream);
220  flush = 1;
221  }
222 
223  // avoid a continued page
224  if (!header && oggstream->page.size > 0 &&
225  MAX_PAGE_SIZE - oggstream->page.size < size) {
226  ogg_buffer_page(s, oggstream);
227  }
228 
229  for (i = 0; i < total_segments; ) {
230  OGGPage *page = &oggstream->page;
231 
232  segments = FFMIN(total_segments - i, 255 - page->segments_count);
233 
234  if (i && !page->segments_count)
235  page->flags |= 1; // continued packet
236 
237  memset(page->segments+page->segments_count, 255, segments - 1);
238  page->segments_count += segments - 1;
239 
240  len = FFMIN(size, segments*255);
241  page->segments[page->segments_count++] = len - (segments-1)*255;
242  memcpy(page->data+page->size, p, len);
243  p += len;
244  size -= len;
245  i += segments;
246  page->size += len;
247 
248  if (i == total_segments)
249  page->granule = granule;
250 
251  {
252  AVStream *st = s->streams[page->stream_index];
253 
254  int64_t start = av_rescale_q(page->start_granule, st->time_base,
256  int64_t next = av_rescale_q(ogg_granule_to_timestamp(oggstream, page->granule),
258 
259  if (page->segments_count == 255) {
260  ogg_buffer_page(s, oggstream);
261  } else if (!header) {
262  if ((ogg->pref_size > 0 && page->size >= ogg->pref_size) ||
263  (ogg->pref_duration > 0 && next - start >= ogg->pref_duration)) {
264  ogg_buffer_page(s, oggstream);
265  }
266  }
267  }
268  }
269 
270  if (flush && oggstream->page.granule != -1)
271  ogg_buffer_page(s, oggstream);
272 
273  return 0;
274 }
275 
276 static uint8_t *ogg_write_vorbiscomment(int64_t offset, int bitexact,
277  int *header_len, AVDictionary **m, int framing_bit,
278  AVChapter **chapters, unsigned int nb_chapters)
279 {
280  const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
281  FFIOContext pb;
282  int64_t size;
283  uint8_t *p;
284 
286 
287  size = offset + ff_vorbiscomment_length(*m, vendor, chapters, nb_chapters) + framing_bit;
288  if (size > INT_MAX)
289  return NULL;
290  p = av_mallocz(size);
291  if (!p)
292  return NULL;
293 
294  ffio_init_context(&pb, p + offset, size - offset, 1, NULL, NULL, NULL, NULL);
295  ff_vorbiscomment_write(&pb.pub, *m, vendor, chapters, nb_chapters);
296  if (framing_bit)
297  avio_w8(&pb.pub, 1);
298 
299  *header_len = size;
300  return p;
301 }
302 
304  OGGStreamContext *oggstream, int bitexact,
305  AVDictionary **m)
306 {
307  uint8_t *p;
308 
310  return AVERROR(EINVAL);
311 
312  // first packet: STREAMINFO
313  oggstream->header_len[0] = 51;
314  oggstream->header[0] = av_mallocz(51); // per ogg flac specs
315  p = oggstream->header[0];
316  if (!p)
317  return AVERROR(ENOMEM);
318  bytestream_put_byte(&p, 0x7F);
319  bytestream_put_buffer(&p, "FLAC", 4);
320  bytestream_put_byte(&p, 1); // major version
321  bytestream_put_byte(&p, 0); // minor version
322  bytestream_put_be16(&p, 1); // headers packets without this one
323  bytestream_put_buffer(&p, "fLaC", 4);
324  bytestream_put_byte(&p, 0x00); // streaminfo
325  bytestream_put_be24(&p, 34);
327 
328  // second packet: VorbisComment
329  p = ogg_write_vorbiscomment(4, bitexact, &oggstream->header_len[1], m, 0, NULL, 0);
330  if (!p)
331  return AVERROR(ENOMEM);
332  oggstream->header[1] = p;
333  bytestream_put_byte(&p, 0x84); // last metadata block and vorbis comment
334  bytestream_put_be24(&p, oggstream->header_len[1] - 4);
335 
336  return 0;
337 }
338 
339 #define SPEEX_HEADER_SIZE 80
340 
342  OGGStreamContext *oggstream, int bitexact,
343  AVDictionary **m)
344 {
345  uint8_t *p;
346 
348  return AVERROR_INVALIDDATA;
349 
350  // first packet: Speex header
352  if (!p)
353  return AVERROR(ENOMEM);
354  oggstream->header[0] = p;
355  oggstream->header_len[0] = SPEEX_HEADER_SIZE;
357  AV_WL32(&oggstream->header[0][68], 0); // set extra_headers to 0
358 
359  // second packet: VorbisComment
360  p = ogg_write_vorbiscomment(0, bitexact, &oggstream->header_len[1], m, 0, NULL, 0);
361  if (!p)
362  return AVERROR(ENOMEM);
363  oggstream->header[1] = p;
364 
365  return 0;
366 }
367 
368 #define OPUS_HEADER_SIZE 19
369 
371  OGGStreamContext *oggstream, int bitexact,
372  AVDictionary **m, AVChapter **chapters,
373  unsigned int nb_chapters)
374 {
375  uint8_t *p;
376 
377  if (par->extradata_size < OPUS_HEADER_SIZE)
378  return AVERROR_INVALIDDATA;
379 
380  /* first packet: Opus header */
381  p = av_mallocz(par->extradata_size);
382  if (!p)
383  return AVERROR(ENOMEM);
384  oggstream->header[0] = p;
385  oggstream->header_len[0] = par->extradata_size;
387 
388  /* second packet: VorbisComment */
389  p = ogg_write_vorbiscomment(8, bitexact, &oggstream->header_len[1], m, 0, chapters, nb_chapters);
390  if (!p)
391  return AVERROR(ENOMEM);
392  oggstream->header[1] = p;
393  bytestream_put_buffer(&p, "OpusTags", 8);
394 
395  return 0;
396 }
397 
398 #define VP8_HEADER_SIZE 26
399 
401  OGGStreamContext *oggstream, int bitexact)
402 {
403  AVCodecParameters *par = st->codecpar;
404  uint8_t *p;
405 
406  /* first packet: VP8 header */
408  if (!p)
409  return AVERROR(ENOMEM);
410  oggstream->header[0] = p;
411  oggstream->header_len[0] = VP8_HEADER_SIZE;
412  bytestream_put_byte(&p, 0x4f); // HDRID
413  bytestream_put_buffer(&p, "VP80", 4); // Identifier
414  bytestream_put_byte(&p, 1); // HDRTYP
415  bytestream_put_byte(&p, 1); // VMAJ
416  bytestream_put_byte(&p, 0); // VMIN
417  bytestream_put_be16(&p, par->width);
418  bytestream_put_be16(&p, par->height);
419  bytestream_put_be24(&p, par->sample_aspect_ratio.num);
420  bytestream_put_be24(&p, par->sample_aspect_ratio.den);
421  if (st->r_frame_rate.num > 0 && st->r_frame_rate.den > 0) {
422  // OggVP8 requires pts to increase by 1 per visible frame, so use the least common
423  // multiple framerate if available.
424  av_log(s, AV_LOG_DEBUG, "Changing time base from %d/%d to %d/%d\n",
425  st->time_base.num, st->time_base.den,
426  st->r_frame_rate.den, st->r_frame_rate.num);
428  }
429  bytestream_put_be32(&p, st->time_base.den);
430  bytestream_put_be32(&p, st->time_base.num);
431 
432  /* optional second packet: VorbisComment */
434  p = ogg_write_vorbiscomment(7, bitexact, &oggstream->header_len[1], &st->metadata, 0, NULL, 0);
435  if (!p)
436  return AVERROR(ENOMEM);
437  oggstream->header[1] = p;
438  bytestream_put_byte(&p, 0x4f); // HDRID
439  bytestream_put_buffer(&p, "VP80", 4); // Identifier
440  bytestream_put_byte(&p, 2); // HDRTYP
441  bytestream_put_byte(&p, 0x20);
442  }
443 
444  oggstream->isvp8 = 1;
445 
446  return 0;
447 }
448 
450 {
451  OGGContext *ogg = s->priv_data;
452  OGGPageList *next, *p;
453 
454  if (!ogg->page_list)
455  return;
456 
457  for (p = ogg->page_list; p; ) {
458  OGGStreamContext *oggstream =
459  s->streams[p->page.stream_index]->priv_data;
460  if (oggstream->page_count < 2 && !flush)
461  break;
462  ogg_write_page(s, &p->page,
463  flush == 1 && oggstream->page_count == 1 ? 4 : 0); // eos
464  next = p->next;
465  av_freep(&p);
466  p = next;
467  }
468  ogg->page_list = p;
469 }
470 
472 {
473  OGGContext *ogg = s->priv_data;
474  OGGStreamContext *oggstream = NULL;
475  int i, j;
476 
477  if (ogg->pref_size)
478  av_log(s, AV_LOG_WARNING, "The pagesize option is deprecated\n");
479 
480  for (i = 0; i < s->nb_streams; i++) {
481  AVStream *st = s->streams[i];
482  unsigned serial_num = i + ogg->serial_offset;
483 
484  if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
485  if (st->codecpar->codec_id == AV_CODEC_ID_OPUS)
486  /* Opus requires a fixed 48kHz clock */
487  avpriv_set_pts_info(st, 64, 1, 48000);
488  else
489  avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
490  }
491 
492  if (st->codecpar->codec_id != AV_CODEC_ID_VORBIS &&
498  av_log(s, AV_LOG_ERROR, "Unsupported codec id in stream %d\n", i);
499  return AVERROR(EINVAL);
500  }
501 
502  if ((!st->codecpar->extradata || !st->codecpar->extradata_size) &&
504  av_log(s, AV_LOG_ERROR, "No extradata present\n");
505  return AVERROR_INVALIDDATA;
506  }
507  oggstream = av_mallocz(sizeof(*oggstream));
508  if (!oggstream)
509  return AVERROR(ENOMEM);
510 
511  oggstream->page.stream_index = i;
512 
513  if (!(s->flags & AVFMT_FLAG_BITEXACT))
514  do {
515  serial_num = av_get_random_seed();
516  for (j = 0; j < i; j++) {
517  OGGStreamContext *sc = s->streams[j]->priv_data;
518  if (serial_num == sc->serial_num)
519  break;
520  }
521  } while (j < i);
522  oggstream->serial_num = serial_num;
523 
524  av_dict_copy(&st->metadata, s->metadata, AV_DICT_DONT_OVERWRITE);
525 
526  st->priv_data = oggstream;
527  if (st->codecpar->codec_id == AV_CODEC_ID_FLAC) {
528  int err = ogg_build_flac_headers(st->codecpar, oggstream,
529  s->flags & AVFMT_FLAG_BITEXACT,
530  &st->metadata);
531  if (err) {
532  av_log(s, AV_LOG_ERROR, "Error writing FLAC headers\n");
533  return err;
534  }
535  } else if (st->codecpar->codec_id == AV_CODEC_ID_SPEEX) {
536  int err = ogg_build_speex_headers(st->codecpar, oggstream,
537  s->flags & AVFMT_FLAG_BITEXACT,
538  &st->metadata);
539  if (err) {
540  av_log(s, AV_LOG_ERROR, "Error writing Speex headers\n");
541  return err;
542  }
543  } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
544  int err = ogg_build_opus_headers(st->codecpar, oggstream,
545  s->flags & AVFMT_FLAG_BITEXACT,
546  &st->metadata, s->chapters, s->nb_chapters);
547  if (err) {
548  av_log(s, AV_LOG_ERROR, "Error writing Opus headers\n");
549  return err;
550  }
551  } else if (st->codecpar->codec_id == AV_CODEC_ID_VP8) {
552  int err = ogg_build_vp8_headers(s, st, oggstream,
553  s->flags & AVFMT_FLAG_BITEXACT);
554  if (err) {
555  av_log(s, AV_LOG_ERROR, "Error writing VP8 headers\n");
556  return err;
557  }
558  } else {
559  uint8_t *p;
560  const char *cstr = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? "vorbis" : "theora";
561  int header_type = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 3 : 0x81;
562  int framing_bit = st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 1 : 0;
563 
565  st->codecpar->codec_id == AV_CODEC_ID_VORBIS ? 30 : 42,
566  (const uint8_t**)oggstream->header, oggstream->header_len) < 0) {
567  av_log(s, AV_LOG_ERROR, "Extradata corrupted\n");
568  oggstream->header[1] = NULL;
569  return AVERROR_INVALIDDATA;
570  }
571 
573  &oggstream->header_len[1], &st->metadata,
574  framing_bit, NULL, 0);
575  oggstream->header[1] = p;
576  if (!p)
577  return AVERROR(ENOMEM);
578 
579  bytestream_put_byte(&p, header_type);
580  bytestream_put_buffer(&p, cstr, 6);
581 
582  if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
583  int den = AV_RB32(oggstream->header[0] + 22), num = AV_RB32(oggstream->header[0] + 26);
584  /* Make sure to use time base stored in the Theora stream header to write
585  correct timestamps */
586  if (st->time_base.num != num || st->time_base.den != den) {
587  av_log(s, AV_LOG_DEBUG, "Changing time base from %d/%d to %d/%d\n",
588  st->time_base.num, st->time_base.den, num, den);
589  avpriv_set_pts_info(st, 64, num, den);
590  }
591  /** KFGSHIFT is the width of the less significant section of the granule position
592  The less significant section is the frame count since the last keyframe */
593  oggstream->kfgshift = ((oggstream->header[0][40]&3)<<3)|(oggstream->header[0][41]>>5);
594  oggstream->vrev = oggstream->header[0][9];
595  av_log(s, AV_LOG_DEBUG, "theora kfgshift %d, vrev %d\n",
596  oggstream->kfgshift, oggstream->vrev);
597  }
598  }
599  }
600 
601  return 0;
602 }
603 
605 {
606  OGGStreamContext *oggstream = NULL;
607  int i, j;
608 
609  for (j = 0; j < s->nb_streams; j++) {
610  oggstream = s->streams[j]->priv_data;
611  ogg_buffer_data(s, s->streams[j], oggstream->header[0],
612  oggstream->header_len[0], 0, 1);
613  oggstream->page.flags |= 2; // bos
614  ogg_buffer_page(s, oggstream);
615  }
616  for (j = 0; j < s->nb_streams; j++) {
617  AVStream *st = s->streams[j];
618  oggstream = st->priv_data;
619  for (i = 1; i < 3; i++) {
620  if (oggstream->header_len[i])
621  ogg_buffer_data(s, st, oggstream->header[i],
622  oggstream->header_len[i], 0, 1);
623  }
624  ogg_buffer_page(s, oggstream);
625  }
626 
627  oggstream->page.start_granule = AV_NOPTS_VALUE;
628 
629  ogg_write_pages(s, 2);
630 
631  return 0;
632 }
633 
635 {
636  AVStream *st = s->streams[pkt->stream_index];
637  OGGStreamContext *oggstream = st->priv_data;
638  int ret;
639  int64_t granule;
640 
641  if (st->codecpar->codec_id == AV_CODEC_ID_THEORA) {
642  int64_t pts = oggstream->vrev < 1 ? pkt->pts : pkt->pts + pkt->duration;
643  int pframe_count;
644  if (pkt->flags & AV_PKT_FLAG_KEY)
645  oggstream->last_kf_pts = pts;
646  pframe_count = pts - oggstream->last_kf_pts;
647  // prevent frame count from overflow if key frame flag is not set
648  if (pframe_count >= (1<<oggstream->kfgshift)) {
649  oggstream->last_kf_pts += pframe_count;
650  pframe_count = 0;
651  }
652  granule = (oggstream->last_kf_pts<<oggstream->kfgshift) | pframe_count;
653  } else if (st->codecpar->codec_id == AV_CODEC_ID_OPUS)
654  granule = pkt->pts + pkt->duration +
656  (AVRational){ 1, st->codecpar->sample_rate },
657  st->time_base);
658  else if (st->codecpar->codec_id == AV_CODEC_ID_VP8) {
659  int64_t pts, invcnt, dist;
660  int visible;
661 
662  visible = (pkt->data[0] >> 4) & 1;
663  pts = pkt->pts + pkt->duration;
664  invcnt = (oggstream->last_granule >> 30) & 3;
665  invcnt = visible ? 3 : (invcnt == 3 ? 0 : invcnt + 1);
666  dist = (pkt->flags & AV_PKT_FLAG_KEY) ? 0 : ((oggstream->last_granule >> 3) & 0x07ffffff) + 1;
667 
668  granule = (pts << 32) | (invcnt << 30) | (dist << 3);
669  } else
670  granule = pkt->pts + pkt->duration;
671 
672  if (oggstream->page.start_granule == AV_NOPTS_VALUE)
673  oggstream->page.start_granule = pkt->pts;
674 
675  ret = ogg_buffer_data(s, st, pkt->data, pkt->size, granule, 0);
676  if (ret < 0)
677  return ret;
678 
679  ogg_write_pages(s, 0);
680 
681  oggstream->last_granule = granule;
682 
683  return 0;
684 }
685 
687 {
688  int i;
689 
690  if (pkt)
692 
693  for (i = 0; i < s->nb_streams; i++) {
694  OGGStreamContext *oggstream = s->streams[i]->priv_data;
695  if (oggstream->page.segments_count)
696  ogg_buffer_page(s, oggstream);
697  }
698 
699  ogg_write_pages(s, 2);
700  return 1;
701 }
702 
704 {
705  int i;
706 
707  /* flush current page if needed */
708  for (i = 0; i < s->nb_streams; i++) {
709  OGGStreamContext *oggstream = s->streams[i]->priv_data;
710 
711  if (oggstream->page.size > 0)
712  ogg_buffer_page(s, oggstream);
713  }
714 
715  ogg_write_pages(s, 1);
716 
717  return 0;
718 }
719 
721 {
722  OGGContext *ogg = s->priv_data;
723  OGGPageList *p = ogg->page_list;
724  int i;
725 
726  for (i = 0; i < s->nb_streams; i++) {
727  AVStream *st = s->streams[i];
728  OGGStreamContext *oggstream = st->priv_data;
729  if (!oggstream)
730  continue;
731  if (st->codecpar->codec_id == AV_CODEC_ID_FLAC ||
735  av_freep(&oggstream->header[0]);
736  }
737  av_freep(&oggstream->header[1]);
738  }
739 
740  while (p) {
741  OGGPageList *next = p->next;
742  av_free(p);
743  p = next;
744  }
745  ogg->page_list = NULL;
746 }
747 
748 #if CONFIG_OGG_MUXER
750  .name = "ogg",
751  .long_name = NULL_IF_CONFIG_SMALL("Ogg"),
752  .mime_type = "application/ogg",
753  .extensions = "ogg"
754 #if !CONFIG_OGV_MUXER
755  ",ogv"
756 #endif
757 #if !CONFIG_SPX_MUXER
758  ",spx"
759 #endif
760 #if !CONFIG_OPUS_MUXER
761  ",opus"
762 #endif
763  ,
764  .priv_data_size = sizeof(OGGContext),
765  .audio_codec = CONFIG_LIBVORBIS_ENCODER ?
767  .video_codec = AV_CODEC_ID_THEORA,
768  .init = ogg_init,
772  .deinit = ogg_free,
774  .priv_class = &ogg_muxer_class,
775 };
776 #endif
777 
778 #if CONFIG_OGA_MUXER
780  .name = "oga",
781  .long_name = NULL_IF_CONFIG_SMALL("Ogg Audio"),
782  .mime_type = "audio/ogg",
783  .extensions = "oga",
784  .priv_data_size = sizeof(OGGContext),
785  .audio_codec = AV_CODEC_ID_FLAC,
786  .init = ogg_init,
790  .deinit = ogg_free,
792  .priv_class = &ogg_muxer_class,
793 };
794 #endif
795 
796 #if CONFIG_OGV_MUXER
798  .name = "ogv",
799  .long_name = NULL_IF_CONFIG_SMALL("Ogg Video"),
800  .mime_type = "video/ogg",
801  .extensions = "ogv",
802  .priv_data_size = sizeof(OGGContext),
803  .audio_codec = CONFIG_LIBVORBIS_ENCODER ?
805  .video_codec = CONFIG_LIBTHEORA_ENCODER ?
807  .init = ogg_init,
811  .deinit = ogg_free,
813  .priv_class = &ogg_muxer_class,
814 };
815 #endif
816 
817 #if CONFIG_SPX_MUXER
819  .name = "spx",
820  .long_name = NULL_IF_CONFIG_SMALL("Ogg Speex"),
821  .mime_type = "audio/ogg",
822  .extensions = "spx",
823  .priv_data_size = sizeof(OGGContext),
824  .audio_codec = AV_CODEC_ID_SPEEX,
825  .init = ogg_init,
829  .deinit = ogg_free,
831  .priv_class = &ogg_muxer_class,
832 };
833 #endif
834 
835 #if CONFIG_OPUS_MUXER
837  .name = "opus",
838  .long_name = NULL_IF_CONFIG_SMALL("Ogg Opus"),
839  .mime_type = "audio/ogg",
840  .extensions = "opus",
841  .priv_data_size = sizeof(OGGContext),
842  .audio_codec = AV_CODEC_ID_OPUS,
843  .init = ogg_init,
847  .deinit = ogg_free,
849  .priv_class = &ogg_muxer_class,
850 };
851 #endif
VP8_HEADER_SIZE
#define VP8_HEADER_SIZE
Definition: oggenc.c:398
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
OGGContext::pref_duration
int64_t pref_duration
preferred page duration (0 => fill all segments)
Definition: oggenc.c:78
AVOutputFormat::name
const char * name
Definition: avformat.h:510
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
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:57
ff_ogg_muxer
const AVOutputFormat ff_ogg_muxer
AV_WL32
#define AV_WL32(p, v)
Definition: intreadwrite.h:426
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:53
AVCRC
uint32_t AVCRC
Definition: crc.h:46
AVStream::priv_data
void * priv_data
Definition: avformat.h:964
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:149
deinit
static void deinit(AVFormatContext *s)
Definition: chromaprint.c:49
AVPacket::data
uint8_t * data
Definition: packet.h:374
vorbiscomment.h
OGGPageList
Definition: oggenc.c:69
AVOption
AVOption.
Definition: opt.h:251
data
const char data[16]
Definition: mxf.c:143
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:276
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
OGGStreamContext::last_granule
int64_t last_granule
last packet granule
Definition: oggenc.c:66
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:392
mathematics.h
AVDictionary
Definition: dict.c:30
AV_CODEC_ID_FLAC
@ AV_CODEC_ID_FLAC
Definition: codec_id.h:439
ogg_muxer_class
static const AVClass ogg_muxer_class
Definition: oggenc.c:97
ogg
Definition: oggdec.h:101
FFIOContext
Definition: avio_internal.h:29
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:429
OGGPageList::next
struct OGGPageList * next
Definition: oggenc.c:71
OGGStreamContext::page_count
unsigned page_count
number of page buffered
Definition: oggenc.c:63
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
init
static int init
Definition: av_tx.c:47
OGGPageList::page
OGGPage page
Definition: oggenc.c:70
crc.h
avio_write_marker
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
Definition: aviobuf.c:490
OGGStreamContext::page
OGGPage page
current page
Definition: oggenc.c:64
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
AV_CODEC_ID_SPEEX
@ AV_CODEC_ID_SPEEX
Definition: codec_id.h:462
OFFSET
#define OFFSET(x)
Definition: oggenc.c:82
ff_vorbiscomment_write
int ff_vorbiscomment_write(AVIOContext *pb, const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters)
Write a VorbisComment into an AVIOContext.
Definition: vorbiscomment.c:65
AVChapter
Definition: avformat.h:1172
ogg_write_header
static int ogg_write_header(AVFormatContext *s)
Definition: oggenc.c:604
ff_oga_muxer
const AVOutputFormat ff_oga_muxer
pts
static int64_t pts
Definition: transcode_aac.c:654
AVRational::num
int num
Numerator.
Definition: rational.h:59
OGGStreamContext::eos
int eos
Definition: oggenc.c:62
OGGStreamContext::page_counter
unsigned page_counter
Definition: oggenc.c:53
ff_opus_muxer
const AVOutputFormat ff_opus_muxer
ogg_write_packet_internal
static int ogg_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
Definition: oggenc.c:634
ogg_write_pages
static void ogg_write_pages(AVFormatContext *s, int flush)
Definition: oggenc.c:449
SPEEX_HEADER_SIZE
#define SPEEX_HEADER_SIZE
Definition: oggenc.c:339
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
OGGStreamContext::isvp8
int isvp8
Definition: oggenc.c:61
ogg_init
static int ogg_init(AVFormatContext *s)
Definition: oggenc.c:471
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
ogg_build_vp8_headers
static int ogg_build_vp8_headers(AVFormatContext *s, AVStream *st, OGGStreamContext *oggstream, int bitexact)
Definition: oggenc.c:400
s
#define s(width, name)
Definition: cbs_vp9.c:256
AVCodecParameters::sample_aspect_ratio
AVRational sample_aspect_ratio
Video only.
Definition: codec_par.h:137
ogg_buffer_data
static int ogg_buffer_data(AVFormatContext *s, AVStream *st, const uint8_t *data, unsigned size, int64_t granule, int header)
Definition: oggenc.c:199
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
OGGStreamContext::last_kf_pts
int64_t last_kf_pts
Definition: oggenc.c:58
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:127
ff_spx_muxer
const AVOutputFormat ff_spx_muxer
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:226
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
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:43
ogg_free
static void ogg_free(AVFormatContext *s)
Definition: oggenc.c:720
ogg_buffer_page
static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
Definition: oggenc.c:174
OGGStreamContext
Definition: oggenc.c:52
AVFormatContext
Format I/O context.
Definition: avformat.h:1213
internal.h
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
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
OGGContext::serial_offset
int serial_offset
Definition: oggenc.c:79
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
flush
static void flush(AVCodecContext *avctx)
Definition: aacdec_template.c:606
NULL
#define NULL
Definition: coverity.c:32
write_trailer
static int write_trailer(AVFormatContext *s1)
Definition: v4l2enc.c:100
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:1019
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:74
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:210
options
static const AVOption options[]
Definition: oggenc.c:85
OGGStreamContext::header
uint8_t * header[3]
Definition: oggenc.c:54
ff_vorbiscomment_length
int64_t ff_vorbiscomment_length(const AVDictionary *m, const char *vendor_string, AVChapter **chapters, unsigned int nb_chapters)
Calculate the length in bytes of a VorbisComment.
Definition: vorbiscomment.c:41
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:177
OGGContext::pref_size
int pref_size
preferred page size (0 => fill all segments)
Definition: oggenc.c:77
MAX_PAGE_SIZE
#define MAX_PAGE_SIZE
Definition: oggenc.c:39
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:79
OGGPage::segments
uint8_t segments[255]
Definition: oggenc.c:47
AVPacket::size
int size
Definition: packet.h:375
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
FFIOContext::pub
AVIOContext pub
Definition: avio_internal.h:30
size
int size
Definition: twinvq_data.h:10344
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:96
AVFMT_ALLOW_FLUSH
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:490
PARAM
#define PARAM
Definition: oggenc.c:83
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition: codec_id.h:487
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:232
OGGPage::stream_index
int stream_index
Definition: oggenc.c:44
av_crc_get_table
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
Definition: crc.c:374
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: packet.h:380
OGGPage::data
uint8_t data[MAX_PAGE_SIZE]
Definition: oggenc.c:48
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:370
bytestream_put_buffer
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
Definition: bytestream.h:372
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
avio_internal.h
OGGPage::segments_count
uint8_t segments_count
Definition: oggenc.c:46
ogg_build_flac_headers
static int ogg_build_flac_headers(AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
Definition: oggenc.c:303
AV_CODEC_ID_THEORA
@ AV_CODEC_ID_THEORA
Definition: codec_id.h:80
AVCodecParameters::height
int height
Definition: codec_par.h:128
ffio_init_context
void ffio_init_context(FFIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Definition: aviobuf.c:81
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:42
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
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:264
ogg_write_trailer
static int ogg_write_trailer(AVFormatContext *s)
Definition: oggenc.c:703
len
int len
Definition: vorbis_enc_data.h:426
AV_CRC_32_IEEE
@ AV_CRC_32_IEEE
Definition: crc.h:52
AVFMT_TS_NEGATIVE
#define AVFMT_TS_NEGATIVE
Format allows muxing negative timestamps.
Definition: avformat.h:494
AVFMT_TS_NONSTRICT
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:491
version.h
ret
ret
Definition: filter_design.txt:187
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1348
AVStream
Stream structure.
Definition: avformat.h:948
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
OGGContext
Definition: oggenc.c:74
OGGPage
Definition: oggenc.c:41
ogg_write_page
static void ogg_write_page(AVFormatContext *s, OGGPage *page, int extra_flags)
Definition: oggenc.c:104
avformat.h
OGGStreamContext::serial_num
unsigned serial_num
serial number
Definition: oggenc.c:65
random_seed.h
ogg_granule_to_timestamp
static int64_t ogg_granule_to_timestamp(OGGStreamContext *oggstream, int64_t granule)
Definition: oggenc.c:138
av_crc
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
Definition: crc.c:392
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
ogg_build_speex_headers
static int ogg_build_speex_headers(AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
Definition: oggenc.c:341
AVStream::r_frame_rate
AVRational r_frame_rate
Real base framerate of the stream.
Definition: avformat.h:1097
OGGPage::size
uint16_t size
Definition: oggenc.c:49
OGGPage::flags
uint8_t flags
Definition: oggenc.c:45
OGGContext::page_list
OGGPageList * page_list
Definition: oggenc.c:76
OGGStreamContext::vrev
int vrev
Definition: oggenc.c:59
AVPacket::stream_index
int stream_index
Definition: packet.h:376
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:26
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:61
AVPacket
This structure stores compressed data.
Definition: packet.h:351
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
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:57
bytestream.h
AV_CODEC_ID_VP8
@ AV_CODEC_ID_VP8
Definition: codec_id.h:190
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
OGGStreamContext::header_len
int header_len[3]
Definition: oggenc.c:55
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
OPUS_HEADER_SIZE
#define OPUS_HEADER_SIZE
Definition: oggenc.c:368
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
MKTAG
#define MKTAG(a, b, c, d)
Definition: macros.h:55
AV_CODEC_ID_VORBIS
@ AV_CODEC_ID_VORBIS
Definition: codec_id.h:432
ogg_write_packet
static int ogg_write_packet(AVFormatContext *s, AVPacket *pkt)
Definition: oggenc.c:686
write_packet
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
Definition: v4l2enc.c:92
write_header
static void write_header(FFV1Context *f)
Definition: ffv1enc.c:346
flac.h
ff_ogv_muxer
const AVOutputFormat ff_ogv_muxer
AVCodecParameters::initial_padding
int initial_padding
Audio only.
Definition: codec_par.h:196
AVIO_DATA_MARKER_FLUSH_POINT
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...
Definition: avio.h:147
ogg_key_granule
static int ogg_key_granule(OGGStreamContext *oggstream, int64_t granule)
Definition: oggenc.c:132
ogg_reset_cur_page
static int ogg_reset_cur_page(OGGStreamContext *oggstream)
Definition: oggenc.c:165