Backed out changeset 571cef4dcf52 (bug 1074004) for m-oth test failure

--HG--
rename : media/libnestegg/README.md => media/libnestegg/README
This commit is contained in:
Carsten "Tomcat" Book 2014-09-30 08:16:55 +02:00
Родитель a20d7f582b
Коммит 1179dc5061
6 изменённых файлов: 86 добавлений и 187 удалений

Просмотреть файл

@ -1,5 +1,3 @@
[![Build Status](https://travis-ci.org/kinetiknz/nestegg.svg?branch=master)](https://travis-ci.org/kinetiknz/nestegg)
See INSTALL for build instructions.
Licensed under an ISC-style license. See LICENSE for details.

Просмотреть файл

@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
The nestegg git repository is: git://github.com/kinetiknz/nestegg.git
The git commit ID used was 2f596487949b192fb15866c6f8ecc6b04df92cb8.
The git commit ID used was 46ab96bcc8b099704cc8a15993f80fe0269a5284.

Просмотреть файл

@ -381,11 +381,8 @@ int nestegg_sniff(unsigned char const * buffer, size_t length);
* Set the underlying allocation function for library allocations.
*
* @param realloc_func The desired function.
* @retval 0 realloc_func(p, 0) does not act as free()
* @retval 1 realloc_func(p, 0) acts as free()
* @retval -1 malloc failed during realloc_func test
*/
int nestegg_set_halloc_func(void * (* realloc_func)(void *, size_t));
void nestegg_set_halloc_func(void * (* realloc_func)(void *, size_t));
#if defined(__cplusplus)
}

Просмотреть файл

@ -40,15 +40,13 @@ typedef struct hblock
*
*/
realloc_t halloc_allocator = NULL;
realloc_t halloc_wrapped_allocator = NULL;
#define allocator halloc_allocator
#define wrapped_allocator halloc_wrapped_allocator
/*
* static methods
*/
int halloc_set_allocator(realloc_t realloc_func);
static void _set_allocator(void);
static void * _realloc(void * ptr, size_t n);
static int _relate(hblock_t * b, hblock_t * p);
@ -64,7 +62,7 @@ void * halloc(void * ptr, size_t len)
/* set up default allocator */
if (! allocator)
{
halloc_set_allocator(realloc);
_set_allocator();
assert(allocator);
}
@ -174,7 +172,7 @@ char * h_strdup(const char * str)
/*
* static stuff
*/
int halloc_set_allocator(realloc_t realloc_func)
static void _set_allocator(void)
{
void * p;
assert(! allocator);
@ -189,20 +187,17 @@ int halloc_set_allocator(realloc_t realloc_func)
*
* Thanks to Stan Tobias for pointing this tricky part out.
*/
allocator = realloc_func;
allocator = realloc;
if (! (p = malloc(1)))
/* hmm */
return -1;
return;
if ((p = realloc_func(p, 0)))
if ((p = realloc(p, 0)))
{
/* realloc_func cannot be used as free() */
/* realloc cannot be used as free() */
allocator = _realloc;
wrapped_allocator = realloc_func;
free(p);
return 0;
}
return 1;
}
static void * _realloc(void * ptr, size_t n)
@ -211,7 +206,7 @@ static void * _realloc(void * ptr, size_t n)
* free'ing realloc()
*/
if (n)
return wrapped_allocator(ptr, n);
return realloc(ptr, n);
free(ptr);
return NULL;
}

Просмотреть файл

@ -321,18 +321,9 @@ struct block_additional {
struct block_additional * next;
};
#define NE_IO_BUFSZ 16384
struct nestegg_io_buf {
nestegg_io io;
unsigned char buffer[NE_IO_BUFSZ];
size_t bufsz;
int offset;
};
/* Public (opaque) Structures */
struct nestegg {
struct nestegg_io_buf * io;
nestegg_io * io;
nestegg_log log;
struct pool_ctx * alloc_pool;
uint64_t last_id;
@ -555,99 +546,19 @@ ne_alloc(size_t size)
}
static int
ne_io_read(struct nestegg_io_buf * io, void * buffer, size_t length)
ne_io_read(nestegg_io * io, void * buffer, size_t length)
{
int64_t off;
int r;
size_t avail;
assert(io->offset == -1 || (io->offset >= 0 && (unsigned int) io->offset < io->bufsz));
/* Too big to buffer, invalidate buffer and read through */
if (length > io->bufsz) {
if (io->offset != -1) {
r = io->io.seek(-(io->bufsz - io->offset), NESTEGG_SEEK_CUR, io->io.userdata);
if (r != 0) {
return -1;
}
}
io->offset = -1;
return io->io.read(buffer, length, io->io.userdata);
}
/* Buffer invalid */
if (io->offset == -1) {
off = io->io.tell(io->io.userdata);
if (off == -1) {
return -1;
}
/* Refill buffer */
r = io->io.read(io->buffer, io->bufsz, io->io.userdata);
if (r != 1) {
/* Read truncated due to being within io->bufsz of EOS, reset read
position and switch to read through mode */
io->offset = -1;
io->bufsz = 0;
if (r == 0) {
r = io->io.seek(off, NESTEGG_SEEK_SET, io->io.userdata);
}
if (r == 0) {
return io->io.read(buffer, length, io->io.userdata);
}
return -1;
}
if (r == 1) {
io->offset = 0;
}
}
/* Service request with what we have */
avail = length;
if (io->bufsz - io->offset < length) {
avail = io->bufsz - io->offset;
}
memcpy(buffer, io->buffer + io->offset, avail);
io->offset += avail;
if ((unsigned int) io->offset == io->bufsz) {
io->offset = -1;
}
/* Still more to read, invalidate buffer and read more */
if (length - avail > 0) {
return ne_io_read(io, (char *) buffer + avail, length - avail);
}
return 1;
return io->read(buffer, length, io->userdata);
}
static int
ne_io_seek(struct nestegg_io_buf * io, int64_t offset, int whence)
ne_io_seek(nestegg_io * io, int64_t offset, int whence)
{
/* Invalidate buffer */
io->offset = -1;
return io->io.seek(offset, whence, io->io.userdata);
}
static int64_t
ne_io_tell(struct nestegg_io_buf * io)
{
int64_t off;
off = io->io.tell(io->io.userdata);
if (off == -1) {
return -1;
}
if (io->offset == -1) {
return off;
}
assert(off >= (int64_t) io->bufsz - io->offset);
return off - io->bufsz + (unsigned int) io->offset;
return io->seek(offset, whence, io->userdata);
}
static int
ne_io_read_skip(struct nestegg_io_buf * io, size_t length)
ne_io_read_skip(nestegg_io * io, size_t length)
{
size_t get;
unsigned char buf[8192];
@ -664,8 +575,14 @@ ne_io_read_skip(struct nestegg_io_buf * io, size_t length)
return r;
}
static int64_t
ne_io_tell(nestegg_io * io)
{
return io->tell(io->userdata);
}
static int
ne_bare_read_vint(struct nestegg_io_buf * io, uint64_t * value, uint64_t * length, enum vint_mask maskflag)
ne_bare_read_vint(nestegg_io * io, uint64_t * value, uint64_t * length, enum vint_mask maskflag)
{
int r;
unsigned char b;
@ -702,19 +619,19 @@ ne_bare_read_vint(struct nestegg_io_buf * io, uint64_t * value, uint64_t * lengt
}
static int
ne_read_id(struct nestegg_io_buf * io, uint64_t * value, uint64_t * length)
ne_read_id(nestegg_io * io, uint64_t * value, uint64_t * length)
{
return ne_bare_read_vint(io, value, length, MASK_NONE);
}
static int
ne_read_vint(struct nestegg_io_buf * io, uint64_t * value, uint64_t * length)
ne_read_vint(nestegg_io * io, uint64_t * value, uint64_t * length)
{
return ne_bare_read_vint(io, value, length, MASK_FIRST_BIT);
}
static int
ne_read_svint(struct nestegg_io_buf * io, int64_t * value, uint64_t * length)
ne_read_svint(nestegg_io * io, int64_t * value, uint64_t * length)
{
int r;
uint64_t uvalue;
@ -736,7 +653,7 @@ ne_read_svint(struct nestegg_io_buf * io, int64_t * value, uint64_t * length)
}
static int
ne_read_uint(struct nestegg_io_buf * io, uint64_t * val, uint64_t length)
ne_read_uint(nestegg_io * io, uint64_t * val, uint64_t length)
{
unsigned char b;
int r;
@ -758,7 +675,7 @@ ne_read_uint(struct nestegg_io_buf * io, uint64_t * val, uint64_t length)
}
static int
ne_read_int(struct nestegg_io_buf * io, int64_t * val, uint64_t length)
ne_read_int(nestegg_io * io, int64_t * val, uint64_t length)
{
int r;
uint64_t uval, base;
@ -771,8 +688,8 @@ ne_read_int(struct nestegg_io_buf * io, int64_t * val, uint64_t length)
base = 1;
base <<= length * 8 - 1;
if (uval >= base) {
base = 1;
base <<= length * 8;
base = 1;
base <<= length * 8;
} else {
base = 0;
}
@ -785,7 +702,7 @@ ne_read_int(struct nestegg_io_buf * io, int64_t * val, uint64_t length)
}
static int
ne_read_float(struct nestegg_io_buf * io, double * val, uint64_t length)
ne_read_float(nestegg_io * io, double * val, uint64_t length)
{
union {
uint64_t u;
@ -819,9 +736,9 @@ ne_read_string(nestegg * ctx, char ** val, uint64_t length)
if (!str)
return -1;
if (length) {
r = ne_io_read(ctx->io, (unsigned char *) str, length);
if (r != 1)
return r;
r = ne_io_read(ctx->io, (unsigned char *) str, length);
if (r != 1)
return r;
}
str[length] = '\0';
*val = str;
@ -1101,9 +1018,8 @@ ne_read_simple(nestegg * ctx, struct ebml_element_desc * desc, size_t length)
break;
case TYPE_MASTER:
case TYPE_UNKNOWN:
default:
r = 0;
assert(0);
r = 0;
break;
}
@ -1220,7 +1136,7 @@ ne_xiph_lace_value(unsigned char ** np)
}
static int
ne_read_xiph_lace_value(struct nestegg_io_buf * io, uint64_t * value, size_t * consumed)
ne_read_xiph_lace_value(nestegg_io * io, uint64_t * value, size_t * consumed)
{
int r;
uint64_t lace;
@ -1243,7 +1159,7 @@ ne_read_xiph_lace_value(struct nestegg_io_buf * io, uint64_t * value, size_t * c
}
static int
ne_read_xiph_lacing(struct nestegg_io_buf * io, size_t block, size_t * read, uint64_t n, uint64_t * sizes)
ne_read_xiph_lacing(nestegg_io * io, size_t block, size_t * read, uint64_t n, uint64_t * sizes)
{
int r;
size_t i = 0;
@ -1266,7 +1182,7 @@ ne_read_xiph_lacing(struct nestegg_io_buf * io, size_t block, size_t * read, uin
}
static int
ne_read_ebml_lacing(struct nestegg_io_buf * io, size_t block, size_t * read, uint64_t n, uint64_t * sizes)
ne_read_ebml_lacing(nestegg_io * io, size_t block, size_t * read, uint64_t n, uint64_t * sizes)
{
int r;
uint64_t lace, sum, length;
@ -1876,9 +1792,9 @@ struct sniff_buffer {
};
static int
ne_buffer_read(void * buffer, size_t length, void * userdata)
ne_buffer_read(void * buffer, size_t length, void * user_data)
{
struct sniff_buffer * sb = userdata;
struct sniff_buffer * sb = user_data;
int rv = 1;
size_t available = sb->length - sb->offset;
@ -1893,21 +1809,21 @@ ne_buffer_read(void * buffer, size_t length, void * userdata)
}
static int
ne_buffer_seek(int64_t offset, int whence, void * userdata)
ne_buffer_seek(int64_t offset, int whence, void * user_data)
{
struct sniff_buffer * sb = userdata;
struct sniff_buffer * sb = user_data;
int64_t o = sb->offset;
switch(whence) {
case NESTEGG_SEEK_SET:
o = offset;
break;
case NESTEGG_SEEK_CUR:
o += offset;
break;
case NESTEGG_SEEK_END:
o = sb->length + offset;
break;
case NESTEGG_SEEK_SET:
o = offset;
break;
case NESTEGG_SEEK_CUR:
o += offset;
break;
case NESTEGG_SEEK_END:
o = sb->length + offset;
break;
}
if (o < 0 || o > (int64_t) sb->length)
@ -1918,9 +1834,9 @@ ne_buffer_seek(int64_t offset, int whence, void * userdata)
}
static int64_t
ne_buffer_tell(void * userdata)
ne_buffer_tell(void * user_data)
{
struct sniff_buffer * sb = userdata;
struct sniff_buffer * sb = user_data;
return sb->offset;
}
@ -1944,9 +1860,7 @@ ne_match_webm(nestegg_io io, int64_t max_offset)
nestegg_destroy(ctx);
return -1;
}
ctx->io->io = io;
ctx->io->bufsz = NE_IO_BUFSZ;
ctx->io->offset = -1;
*ctx->io = io;
ctx->alloc_pool = ne_pool_init();
if (!ctx->alloc_pool) {
nestegg_destroy(ctx);
@ -2004,9 +1918,7 @@ nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t ma
nestegg_destroy(ctx);
return -1;
}
ctx->io->io = io;
ctx->io->bufsz = NE_IO_BUFSZ;
ctx->io->offset = -1;
*ctx->io = io;
ctx->log = callback;
ctx->alloc_pool = ne_pool_init();
if (!ctx->alloc_pool) {
@ -2352,35 +2264,35 @@ nestegg_track_codec_data(nestegg * ctx, unsigned int track, unsigned int item,
return -1;
if (nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_VORBIS
&& nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS)
&& nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS)
return -1;
if (ne_get_binary(entry->codec_private, &codec_private) != 0)
return -1;
if (nestegg_track_codec_id(ctx, track) == NESTEGG_CODEC_VORBIS) {
p = codec_private.data;
count = *p++ + 1;
p = codec_private.data;
count = *p++ + 1;
if (count > 3)
return -1;
i = 0;
total = 0;
while (--count) {
sizes[i] = ne_xiph_lace_value(&p);
total += sizes[i];
i += 1;
}
sizes[i] = codec_private.length - total - (p - codec_private.data);
for (i = 0; i < item; ++i) {
if (sizes[i] > LIMIT_FRAME)
if (count > 3)
return -1;
p += sizes[i];
}
*data = p;
*length = sizes[item];
i = 0;
total = 0;
while (--count) {
sizes[i] = ne_xiph_lace_value(&p);
total += sizes[i];
i += 1;
}
sizes[i] = codec_private.length - total - (p - codec_private.data);
for (i = 0; i < item; ++i) {
if (sizes[i] > LIMIT_FRAME)
return -1;
p += sizes[i];
}
*data = p;
*length = sizes[item];
} else {
*data = codec_private.data;
*length = codec_private.length;
@ -2582,7 +2494,7 @@ nestegg_free_packet(nestegg_packet * pkt)
free(block_additional);
}
free(pkt);
free(pkt);
}
int
@ -2676,31 +2588,28 @@ int
nestegg_has_cues(nestegg * ctx)
{
return ctx->segment.cues.cue_point.head ||
ne_find_seek_for_id(ctx->segment.seek_head.head, ID_CUES);
ne_find_seek_for_id(ctx->segment.seek_head.head, ID_CUES);
}
int
nestegg_sniff(unsigned char const * buffer, size_t length)
{
nestegg_io io;
struct sniff_buffer userdata;
struct sniff_buffer user_data;
userdata.buffer = buffer;
userdata.length = length;
userdata.offset = 0;
user_data.buffer = buffer;
user_data.length = length;
user_data.offset = 0;
io.read = ne_buffer_read;
io.seek = ne_buffer_seek;
io.tell = ne_buffer_tell;
io.userdata = &userdata;
io.userdata = &user_data;
return ne_match_webm(io, length);
}
/* From halloc.c */
int halloc_set_allocator(realloc_t realloc_func);
int
void
nestegg_set_halloc_func(void * (* realloc_func)(void *, size_t))
{
return halloc_set_allocator(realloc_func);
halloc_allocator = realloc_func;
}

Просмотреть файл

@ -7,7 +7,7 @@ cp $1/halloc/src/halloc.c src
cp $1/halloc/src/hlist.h src
cp $1/halloc/src/macros.h src
cp $1/LICENSE .
cp $1/README.md .
cp $1/README .
cp $1/AUTHORS .
if [ -d $1/.git ]; then
rev=$(cd $1 && git rev-parse --verify HEAD)