FFmpeg
Data Structures | Macros | Functions | Variables
oggenc.c File Reference
#include "config_components.h"
#include <stdint.h>
#include "libavutil/crc.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavcodec/xiph.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/flac.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "mux.h"
#include "version.h"
#include "vorbiscomment.h"

Go to the source code of this file.

Data Structures

struct  OGGPage
 
struct  OGGStreamContext
 
struct  OGGPageList
 
struct  OGGContext
 

Macros

#define MAX_PAGE_SIZE   65025
 
#define OFFSET(x)   offsetof(OGGContext, x)
 
#define PARAM   AV_OPT_FLAG_ENCODING_PARAM
 
#define SPEEX_HEADER_SIZE   80
 
#define OPUS_HEADER_SIZE   19
 
#define VP8_HEADER_SIZE   26
 

Functions

static int ogg_write_trailer (AVFormatContext *s)
 
static void ogg_cleanup_stream (AVStream *st)
 
static void ogg_write_page (AVFormatContext *s, OGGPage *page, int extra_flags)
 
static int ogg_key_granule (OGGStreamContext *oggstream, int64_t granule)
 
static int64_t ogg_granule_to_timestamp (OGGStreamContext *oggstream, int64_t granule)
 
static int ogg_compare_granule (AVFormatContext *s, OGGPage *next, OGGPage *page)
 
static int ogg_reset_cur_page (OGGStreamContext *oggstream)
 
static int ogg_buffer_page (AVFormatContext *s, OGGStreamContext *oggstream)
 
static int ogg_buffer_data (AVFormatContext *s, AVStream *st, const uint8_t *data, unsigned size, int64_t granule, int header)
 
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)
 
static int ogg_build_flac_headers (AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
 
static int ogg_build_speex_headers (AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m)
 
static int ogg_build_opus_headers (AVCodecParameters *par, OGGStreamContext *oggstream, int bitexact, AVDictionary **m, AVChapter **chapters, unsigned int nb_chapters)
 
static int ogg_build_vp8_headers (AVFormatContext *s, AVStream *st, OGGStreamContext *oggstream, int bitexact)
 
static void ogg_write_pages (AVFormatContext *s, int flush)
 
static int ogg_init (AVFormatContext *s)
 
static int ogg_write_header (AVFormatContext *s)
 
static int ogg_check_new_metadata (AVFormatContext *s, AVPacket *pkt)
 
static int ogg_write_packet_internal (AVFormatContext *s, AVPacket *pkt)
 
static int ogg_write_packet (AVFormatContext *s, AVPacket *pkt)
 
static void ogg_free (AVFormatContext *s)
 

Variables

static const AVOption options []
 
static const AVClass ogg_muxer_class
 

Macro Definition Documentation

◆ MAX_PAGE_SIZE

#define MAX_PAGE_SIZE   65025

Definition at line 41 of file oggenc.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(OGGContext, x)

Definition at line 85 of file oggenc.c.

◆ PARAM

#define PARAM   AV_OPT_FLAG_ENCODING_PARAM

Definition at line 86 of file oggenc.c.

◆ SPEEX_HEADER_SIZE

#define SPEEX_HEADER_SIZE   80

Definition at line 357 of file oggenc.c.

◆ OPUS_HEADER_SIZE

#define OPUS_HEADER_SIZE   19

Definition at line 386 of file oggenc.c.

◆ VP8_HEADER_SIZE

#define VP8_HEADER_SIZE   26

Definition at line 416 of file oggenc.c.

Function Documentation

◆ ogg_write_trailer()

static int ogg_write_trailer ( AVFormatContext s)
static

Definition at line 784 of file oggenc.c.

Referenced by ogg_check_new_metadata().

◆ ogg_cleanup_stream()

static void ogg_cleanup_stream ( AVStream st)
static

Definition at line 105 of file oggenc.c.

Referenced by ogg_free(), and ogg_init().

◆ ogg_write_page()

static void ogg_write_page ( AVFormatContext s,
OGGPage page,
int  extra_flags 
)
static

Definition at line 119 of file oggenc.c.

Referenced by ogg_write_pages().

◆ ogg_key_granule()

static int ogg_key_granule ( OGGStreamContext oggstream,
int64_t  granule 
)
static

Definition at line 147 of file oggenc.c.

Referenced by ogg_buffer_data().

◆ ogg_granule_to_timestamp()

static int64_t ogg_granule_to_timestamp ( OGGStreamContext oggstream,
int64_t  granule 
)
static

Definition at line 153 of file oggenc.c.

Referenced by ogg_buffer_data(), ogg_buffer_page(), and ogg_compare_granule().

◆ ogg_compare_granule()

static int ogg_compare_granule ( AVFormatContext s,
OGGPage next,
OGGPage page 
)
static

Definition at line 164 of file oggenc.c.

Referenced by ogg_buffer_page().

◆ ogg_reset_cur_page()

static int ogg_reset_cur_page ( OGGStreamContext oggstream)
static

Definition at line 180 of file oggenc.c.

Referenced by ogg_buffer_page().

◆ ogg_buffer_page()

static int ogg_buffer_page ( AVFormatContext s,
OGGStreamContext oggstream 
)
static

Definition at line 189 of file oggenc.c.

Referenced by ogg_buffer_data(), ogg_write_header(), ogg_write_packet(), and ogg_write_trailer().

◆ ogg_buffer_data()

static int ogg_buffer_data ( AVFormatContext s,
AVStream st,
const uint8_t *  data,
unsigned  size,
int64_t  granule,
int  header 
)
static

Definition at line 214 of file oggenc.c.

Referenced by ogg_write_header(), and ogg_write_packet_internal().

◆ 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 
)
static

◆ ogg_build_flac_headers()

static int ogg_build_flac_headers ( AVCodecParameters par,
OGGStreamContext oggstream,
int  bitexact,
AVDictionary **  m 
)
static

Definition at line 321 of file oggenc.c.

Referenced by ogg_init().

◆ ogg_build_speex_headers()

static int ogg_build_speex_headers ( AVCodecParameters par,
OGGStreamContext oggstream,
int  bitexact,
AVDictionary **  m 
)
static

Definition at line 359 of file oggenc.c.

Referenced by ogg_init().

◆ ogg_build_opus_headers()

static int ogg_build_opus_headers ( AVCodecParameters par,
OGGStreamContext oggstream,
int  bitexact,
AVDictionary **  m,
AVChapter **  chapters,
unsigned int  nb_chapters 
)
static

Definition at line 388 of file oggenc.c.

Referenced by ogg_init().

◆ ogg_build_vp8_headers()

static int ogg_build_vp8_headers ( AVFormatContext s,
AVStream st,
OGGStreamContext oggstream,
int  bitexact 
)
static

Definition at line 418 of file oggenc.c.

Referenced by ogg_init().

◆ ogg_write_pages()

static void ogg_write_pages ( AVFormatContext s,
int  flush 
)
static

◆ ogg_init()

static int ogg_init ( AVFormatContext s)
static

KFGSHIFT is the width of the less significant section of the granule position The less significant section is the frame count since the last keyframe

Definition at line 491 of file oggenc.c.

Referenced by ogg_check_new_metadata().

◆ ogg_write_header()

static int ogg_write_header ( AVFormatContext s)
static

Definition at line 628 of file oggenc.c.

Referenced by ogg_check_new_metadata().

◆ ogg_check_new_metadata()

static int ogg_check_new_metadata ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 658 of file oggenc.c.

Referenced by ogg_write_packet_internal().

◆ ogg_write_packet_internal()

static int ogg_write_packet_internal ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 706 of file oggenc.c.

Referenced by ogg_write_packet().

◆ ogg_write_packet()

static int ogg_write_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 767 of file oggenc.c.

◆ ogg_free()

static void ogg_free ( AVFormatContext s)
static

Definition at line 801 of file oggenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "serial_offset", "serial number offset",
OFFSET(serial_offset), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, PARAM },
{ "page_duration", "preferred page duration, in microseconds",
OFFSET(pref_duration), AV_OPT_TYPE_INT64, { .i64 = 1000000 }, 0, INT64_MAX, PARAM },
{ NULL },
}

Definition at line 90 of file oggenc.c.

◆ ogg_muxer_class

const AVClass ogg_muxer_class
static
Initial value:
= {
.class_name = "Ogg (audio/video/Speex/Opus) muxer",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 98 of file oggenc.c.

OFFSET
#define OFFSET(x)
Definition: oggenc.c:85
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition: opt.h:262
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:242
options
static const AVOption options[]
Definition: oggenc.c:90
PARAM
#define PARAM
Definition: oggenc.c:86
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:258