Revision dc05b6af

View differences:

libavformat/oggenc.c
20 20
 */
21 21

  
22 22
#include "libavutil/crc.h"
23
#include "libavutil/opt.h"
23 24
#include "libavutil/random_seed.h"
24 25
#include "libavcodec/xiph.h"
25 26
#include "libavcodec/bytestream.h"
......
62 63
} OGGPageList;
63 64

  
64 65
typedef struct {
66
    const AVClass *class;
65 67
    OGGPageList *page_list;
68
    int pref_size; ///< preferred page size (0 => fill all segments)
66 69
} OGGContext;
67 70

  
71

  
72
static const AVOption options[] = {
73
    { "oggpagesize", "Set preferred Ogg page size.",
74
      offsetof(OGGContext, pref_size), FF_OPT_TYPE_INT, 0, 0, MAX_PAGE_SIZE, AV_OPT_FLAG_ENCODING_PARAM},
75
    { NULL },
76
};
77

  
78
static const AVClass ogg_muxer_class = {
79
    "Ogg muxer",
80
    av_default_item_name,
81
    options,
82
    LIBAVUTIL_VERSION_INT,
83
};
84

  
85

  
68 86
static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
69 87
{
70 88
    int64_t pos = avio_tell(pb);
......
174 192
                           uint8_t *data, unsigned size, int64_t granule)
175 193
{
176 194
    OGGStreamContext *oggstream = st->priv_data;
195
    OGGContext *ogg = s->priv_data;
177 196
    int total_segments = size / 255 + 1;
178 197
    uint8_t *p = data;
179 198
    int i, segments, len, flush = 0;
......
209 228
        if (i == total_segments)
210 229
            page->granule = granule;
211 230

  
212
        if (page->segments_count == 255) {
213
            ogg_buffer_page(s, oggstream);
231
        if(page->segments_count == 255 ||
232
           (ogg->pref_size > 0 && page->size >= ogg->pref_size)) {
233
           ogg_buffer_page(s, oggstream);
214 234
        }
215 235
    }
216 236

  
......
514 534
    ogg_write_header,
515 535
    ogg_write_packet,
516 536
    ogg_write_trailer,
537
    .priv_class = &ogg_muxer_class,
517 538
};

Also available in: Unified diff