uint32_t new_pal;
int size;
int i;
- tag = bytestream_get_le32(&buf);
- size = bytestream_get_be32(&buf);
+ tag = bytestream2_get_le32(&ctx);
+ size = bytestream2_get_be32(&ctx);
+ if(size < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid tag size %d\n", size);
+ return AVERROR_INVALIDDATA;
+ }
- size = FFMIN(size, buf_end - buf);
+ size = FFMIN(size, bytestream2_get_bytes_left(&ctx));
switch (tag) {
case PALT_TAG:
if (size < PALETTE_SIZE)
tmpptr += s->palettes_count * AVPALETTE_COUNT;
for (i = 0; i < PALETTE_COUNT; i++) {
#if RUNTIME_GAMMA
- int r = gamma_corr(*buf++);
- int g = gamma_corr(*buf++);
- int b = gamma_corr(*buf++);
+ int r = gamma_corr(bytestream2_get_byteu(&ctx));
+ int g = gamma_corr(bytestream2_get_byteu(&ctx));
+ int b = gamma_corr(bytestream2_get_byteu(&ctx));
#else
- int r = gamma_lookup[*buf++];
- int g = gamma_lookup[*buf++];
- int b = gamma_lookup[*buf++];
+ int r = gamma_lookup[bytestream2_get_byteu(&ctx)];
+ int g = gamma_lookup[bytestream2_get_byteu(&ctx)];
+ int b = gamma_lookup[bytestream2_get_byteu(&ctx)];
#endif
- *tmpptr++ = (r << 16) | (g << 8) | b;
+ *tmpptr++ = (0xFFU << 24) | (r << 16) | (g << 8) | b;
}
s->palettes_count++;
break;
#define PARAM AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "pagesize", "preferred page size in bytes",
+ { "oggpagesize", "Set preferred Ogg page size.",
+ offsetof(OGGContext, pref_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, MAX_PAGE_SIZE, AV_OPT_FLAG_ENCODING_PARAM},
+ { "pagesize", "preferred page size in bytes (deprecated)",
OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, PARAM },
+ { "page_duration", "preferred page duration, in microseconds",
+ OFFSET(pref_duration), AV_OPT_TYPE_INT, { .i64 = 1000000 }, 0, INT64_MAX, PARAM },
{ NULL },
};