*/
#include "libavutil/crc.h"
+#include "libavutil/opt.h"
#include "libavutil/random_seed.h"
#include "libavcodec/xiph.h"
#include "libavcodec/bytestream.h"
} OGGPageList;
typedef struct {
+ const AVClass *class;
OGGPageList *page_list;
+ int pref_size; ///< preferred page size (0 => fill all segments)
} OGGContext;
+
+static const AVOption options[] = {
+ { "oggpagesize", "Set preferred Ogg page size.",
+ offsetof(OGGContext, pref_size), FF_OPT_TYPE_INT, 0, 0, MAX_PAGE_SIZE, AV_OPT_FLAG_ENCODING_PARAM},
+ { NULL },
+};
+
+static const AVClass ogg_muxer_class = {
+ "Ogg muxer",
+ av_default_item_name,
+ options,
+ LIBAVUTIL_VERSION_INT,
+};
+
+
static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
{
int64_t pos = avio_tell(pb);
int ret, size;
uint8_t *buf;
- ret = url_open_dyn_buf(&pb);
+ ret = avio_open_dyn_buf(&pb);
if (ret < 0)
return ret;
ffio_init_checksum(pb, ff_crc04C11DB7_update, 0);
ogg_update_checksum(s, pb, crc_offset);
avio_flush(pb);
- size = url_close_dyn_buf(pb, &buf);
+ size = avio_close_dyn_buf(pb, &buf);
if (size < 0)
return size;
uint8_t *data, unsigned size, int64_t granule)
{
OGGStreamContext *oggstream = st->priv_data;
+ OGGContext *ogg = s->priv_data;
int total_segments = size / 255 + 1;
uint8_t *p = data;
int i, segments, len, flush = 0;
if (i == total_segments)
page->granule = granule;
- if (page->segments_count == 255) {
- ogg_buffer_page(s, oggstream);
+ if(page->segments_count == 255 ||
+ (ogg->pref_size > 0 && page->size >= ogg->pref_size)) {
+ ogg_buffer_page(s, oggstream);
}
}
}
static uint8_t *ogg_write_vorbiscomment(int offset, int bitexact,
- int *header_len, AVMetadata **m, int framing_bit)
+ int *header_len, AVDictionary **m, int framing_bit)
{
const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
int size;
static int ogg_build_flac_headers(AVCodecContext *avctx,
OGGStreamContext *oggstream, int bitexact,
- AVMetadata **m)
+ AVDictionary **m)
{
enum FLACExtradataFormat format;
uint8_t *streaminfo;
static int ogg_build_speex_headers(AVCodecContext *avctx,
OGGStreamContext *oggstream, int bitexact,
- AVMetadata **m)
+ AVDictionary **m)
{
uint8_t *p;
ogg_write_header,
ogg_write_packet,
ogg_write_trailer,
+ .priv_class = &ogg_muxer_class,
};