Example #1
0
/*
 * read and verify the header of the recently opened file
 */
static int _mvefile_read_header(const MVEFILE *movie)
{
    unsigned char buffer[26];

    /* check the file is open */
    if (! movie->stream)
        return 0;

    /* check the file is long enough */
    if (! mve_read(movie->stream, buffer, 26))
        return 0;

    /* check the signature */
    if (memcmp(buffer, MVE_HEADER, 20))
        return 0;

    /* check the hard-coded constants */
    if (_mve_get_short(buffer+20) != MVE_HDRCONST1)
        return 0;
    if (_mve_get_short(buffer+22) != MVE_HDRCONST2)
        return 0;
    if (_mve_get_short(buffer+24) != MVE_HDRCONST3)
        return 0;

    return 1;
}
Example #2
0
static int _mvefile_fetch_next_chunk(MVEFILE *movie)
{
    unsigned char buffer[4];
    unsigned short length;

    /* fail if not open */
    if (! movie->stream)
        return 0;

    /* fail if we can't read the next segment descriptor */
    if (! mve_read(movie->stream, buffer, 4))
        return 0;

    /* pull out the next length */
    length = _mve_get_short(buffer);

    /* make sure we've got sufficient space */
    _mvefile_set_buffer_size(movie, length);

    /* read the chunk */
    if (! mve_read(movie->stream, &movie->cur_chunk[0], length))
        return 0;
    movie->cur_chunk.resize(length);
    movie->next_segment = 0;

    return 1;
}
Example #3
0
/*
 * get the size of the next segment
 */
int_fast32_t mvefile_get_next_segment_size(const MVEFILE *movie)
{
	if (!have_segment_header(movie))
        return -1;
    /* otherwise, get the data length */
    return _mve_get_short(&movie->cur_chunk[movie->next_segment]);
}
Example #4
0
int mvefile_get_next_segment_size (MVEFILE *movie)
{
// if nothing is cached, fail
    if (movie->cur_chunk == NULL  ||  movie->next_segment >= movie->cur_fill)
        return -1;
// if we don't have enough data to get a tSegment, fail
    if (movie->cur_fill - movie->next_segment < 4)
        return -1;
// otherwise, get the data length
    return _mve_get_short (movie->cur_chunk + movie->next_segment);
}
Example #5
0
static int _mvefile_fetch_next_chunk (MVEFILE *movie)
{
    unsigned char buffer[4];
    unsigned short length;

// fail if not open
    if (!movie->stream)
        return 0;
// fail if we can't read the next tSegment descriptor
    if (!mve_read (movie->stream, buffer, 4))
        return 0;
// pull out the next length
    length = _mve_get_short (buffer);
// make sure we've got sufficient space
    _mvefile_set_buffer_size (movie, length);
// read the chunk
    if (!mve_read (movie->stream, movie->cur_chunk, length))
        return 0;
    movie->cur_fill = length;
    movie->next_segment = 0;
    return 1;
}