示例#1
0
// 8.7.3.2 Sample Size Box (p57)
int mov_read_stsz(struct mov_t* mov, const struct mov_box_t* box)
{
	uint32_t i = 0, sample_size, sample_count;
	struct mov_track_t* track = mov->track;

	mov_buffer_r8(&mov->io); /* version */
	mov_buffer_r24(&mov->io); /* flags */
	sample_size = mov_buffer_r32(&mov->io);
	sample_count = mov_buffer_r32(&mov->io);

	assert(0 == track->sample_count && NULL == track->samples); // duplicated STSZ atom
	if (track->sample_count < sample_count)
	{
		void* p = malloc(sizeof(struct mov_sample_t) * (sample_count + 1));
		if (NULL == p) return ENOMEM;
		track->samples = (struct mov_sample_t*)p;
	}
	track->sample_count = sample_count;

	if (0 == sample_size)
	{
		for (i = 0; i < sample_count; i++)
			track->samples[i].bytes = mov_buffer_r32(&mov->io); // uint32_t entry_size
	}
	else
	{
		for (i = 0; i < sample_count; i++)
			track->samples[i].bytes = sample_size;
	}

	(void)box;
	return mov_buffer_error(&mov->io);
}
示例#2
0
// 8.6.1.2 Decoding Time to Sample Box (p47)
int mov_read_stts(struct mov_t* mov, const struct mov_box_t* box)
{
	uint32_t i, entry_count;
	struct mov_stbl_t* stbl = &mov->track->stbl;

	mov_buffer_r8(&mov->io); /* version */
	mov_buffer_r24(&mov->io); /* flags */
	entry_count = mov_buffer_r32(&mov->io);

	assert(0 == stbl->stts_count && NULL == stbl->stts); // duplicated STTS atom
	if (stbl->stts_count < entry_count)
	{
		void* p = realloc(stbl->stts, sizeof(struct mov_stts_t) * entry_count);
		if (NULL == p) return ENOMEM;
		stbl->stts = (struct mov_stts_t*)p;
	}
	stbl->stts_count = entry_count;

	for (i = 0; i < entry_count; i++)
	{
		stbl->stts[i].sample_count = mov_buffer_r32(&mov->io);
		stbl->stts[i].sample_delta = mov_buffer_r32(&mov->io);
	}

	(void)box;
	return mov_buffer_error(&mov->io);
}
示例#3
0
// 8.6.1.4 Composition to Decode Box (p53)
int mov_read_cslg(struct mov_t* mov, const struct mov_box_t* box)
{
	uint8_t version;
//	struct mov_stbl_t* stbl = &mov->track->stbl;

	version = (uint8_t)mov_buffer_r8(&mov->io); /* version */
	mov_buffer_r24(&mov->io); /* flags */

	if (0 == version)
	{
		(int32_t)mov_buffer_r32(&mov->io); /* compositionToDTSShift */
		(int32_t)mov_buffer_r32(&mov->io); /* leastDecodeToDisplayDelta */
		(int32_t)mov_buffer_r32(&mov->io); /* greatestDecodeToDisplayDelta */
		(int32_t)mov_buffer_r32(&mov->io); /* compositionStartTime */
		(int32_t)mov_buffer_r32(&mov->io); /* compositionEndTime */
	}
	else
	{
		(int64_t)mov_buffer_r64(&mov->io);
		(int64_t)mov_buffer_r64(&mov->io);
		(int64_t)mov_buffer_r64(&mov->io);
		(int64_t)mov_buffer_r64(&mov->io);
		(int64_t)mov_buffer_r64(&mov->io);
	}

	(void)box;
	return mov_buffer_error(&mov->io);
}
示例#4
0
int mov_read_avcc(struct mov_t* mov, const struct mov_box_t* box)
{
	struct mov_track_t* track = mov->track;
	struct mov_sample_entry_t* entry = track->stsd.current;
	if (entry->extra_data_size < box->size)
	{
		void* p = realloc(entry->extra_data, (size_t)box->size);
		if (NULL == p) return ENOMEM;
		entry->extra_data = p;
	}

	mov_buffer_read(&mov->io, entry->extra_data, box->size);
	entry->extra_data_size = (size_t)box->size;
	return mov_buffer_error(&mov->io);
}
示例#5
0
// 8.8.2 Movie Extends Header Box (p68)
int mov_read_mehd(struct mov_t* mov, const struct mov_box_t* box)
{
    unsigned int version;
    uint64_t fragment_duration;
    version = mov_buffer_r8(&mov->io); /* version */
    mov_buffer_r24(&mov->io); /* flags */

    if (1 == version)
        fragment_duration = mov_buffer_r64(&mov->io); /* fragment_duration*/
    else
        fragment_duration = mov_buffer_r32(&mov->io); /* fragment_duration*/

    (void)box;
    assert(fragment_duration <= mov->mvhd.duration);
    return mov_buffer_error(&mov->io);
}