[NUT-devel] [nut]: r661 - in src/trunk: libnut/demuxer.c libnut/framecode.c libnut/libnut.h libnut/muxer.c libnut/priv.h libnut/reorder.c nututils/demux_avi.c nututils/demux_ogg.c nututils/framer_mp3.c nututils/framer_mpeg4.c nututils/framer_vorbis.c nututils/nutindex.c nututils/nutmerge.c nututils/nutmerge.h
ods15
subversion at mplayerhq.hu
Thu Dec 11 21:34:45 CET 2008
Author: ods15
Date: Thu Dec 11 21:34:43 2008
New Revision: 661
Log:
Rename all typedefs from _t to _tt for POSIX compatibility
Modified:
src/trunk/libnut/demuxer.c
src/trunk/libnut/framecode.c
src/trunk/libnut/libnut.h
src/trunk/libnut/muxer.c
src/trunk/libnut/priv.h
src/trunk/libnut/reorder.c
src/trunk/nututils/demux_avi.c
src/trunk/nututils/demux_ogg.c
src/trunk/nututils/framer_mp3.c
src/trunk/nututils/framer_mpeg4.c
src/trunk/nututils/framer_vorbis.c
src/trunk/nututils/nutindex.c
src/trunk/nututils/nutmerge.c
src/trunk/nututils/nutmerge.h
Modified: src/trunk/libnut/demuxer.c
==============================================================================
--- src/trunk/libnut/demuxer.c (original)
+++ src/trunk/libnut/demuxer.c Thu Dec 11 21:34:43 2008
@@ -16,7 +16,7 @@ static off_t stream_seek(void * priv, lo
return ftello(priv);
}
-static void flush_buf(input_buffer_t *bc) {
+static void flush_buf(input_buffer_tt *bc) {
assert(!bc->is_mem);
bc->file_pos += bc->buf_ptr - bc->buf;
bc->read_len -= bc->buf_ptr - bc->buf;
@@ -24,7 +24,7 @@ static void flush_buf(input_buffer_t *bc
bc->buf_ptr = bc->buf;
}
-static int ready_read_buf(input_buffer_t * bc, int amount) {
+static int ready_read_buf(input_buffer_tt * bc, int amount) {
int pos = (bc->buf_ptr - bc->buf);
if (bc->read_len - pos < amount && !bc->is_mem) {
amount += 10;
@@ -42,7 +42,7 @@ static int ready_read_buf(input_buffer_t
return bc->read_len - (bc->buf_ptr - bc->buf);
}
-static void seek_buf(input_buffer_t * bc, long long pos, int whence) {
+static void seek_buf(input_buffer_tt * bc, long long pos, int whence) {
assert(!bc->is_mem);
if (whence != SEEK_END) {
// don't do anything when already in seeked position. but still flush_buf
@@ -66,26 +66,26 @@ static void seek_buf(input_buffer_t * bc
if (whence == SEEK_END) bc->filesize = bc->file_pos - pos;
}
-static int buf_eof(input_buffer_t * bc) {
+static int buf_eof(input_buffer_tt * bc) {
if (bc->is_mem) return NUT_ERR_BAD_EOF;
if (!bc->alloc) return NUT_ERR_OUT_OF_MEM;
if (!bc->isc.eof || bc->isc.eof(bc->isc.priv)) return NUT_ERR_EOF;
return NUT_ERR_EAGAIN;
}
-static int skip_buffer(input_buffer_t * bc, int len) {
+static int skip_buffer(input_buffer_tt * bc, int len) {
if (ready_read_buf(bc, len) < len) return buf_eof(bc);
bc->buf_ptr += len;
return 0;
}
-static uint8_t * get_buf(input_buffer_t * bc, off_t start) {
+static uint8_t * get_buf(input_buffer_tt * bc, off_t start) {
start -= bc->file_pos;
assert((unsigned)start < bc->read_len);
return bc->buf + start;
}
-static input_buffer_t * new_mem_buffer(input_buffer_t * bc) {
+static input_buffer_tt * new_mem_buffer(input_buffer_tt * bc) {
if (!bc) return NULL;
bc->read_len = 0;
bc->write_len = 0;
@@ -97,8 +97,8 @@ static input_buffer_t * new_mem_buffer(i
return bc;
}
-static input_buffer_t * new_input_buffer(nut_alloc_t * alloc, nut_input_stream_t isc) {
- input_buffer_t * bc = new_mem_buffer(alloc->malloc(sizeof(input_buffer_t)));
+static input_buffer_tt * new_input_buffer(nut_alloc_tt * alloc, nut_input_stream_tt isc) {
+ input_buffer_tt * bc = new_mem_buffer(alloc->malloc(sizeof(input_buffer_tt)));
if (!bc) return NULL;
bc->alloc = alloc;
bc->is_mem = 0;
@@ -112,14 +112,14 @@ static input_buffer_t * new_input_buffer
return bc;
}
-static void free_buffer(input_buffer_t * bc) {
+static void free_buffer(input_buffer_tt * bc) {
if (!bc) return;
assert(!bc->is_mem);
bc->alloc->free(bc->buf);
bc->alloc->free(bc);
}
-static int get_bytes(input_buffer_t * bc, int count, uint64_t * val) {
+static int get_bytes(input_buffer_tt * bc, int count, uint64_t * val) {
int i;
if (ready_read_buf(bc, count) < count) return buf_eof(bc);
*val = 0;
@@ -129,7 +129,7 @@ static int get_bytes(input_buffer_t * bc
return 0;
}
-static int get_v(input_buffer_t * bc, uint64_t * val) {
+static int get_v(input_buffer_tt * bc, uint64_t * val) {
int i, len;
*val = 0;
@@ -145,7 +145,7 @@ static int get_v(input_buffer_t * bc, ui
return buf_eof(bc);
}
-static int get_s(input_buffer_t * bc, int64_t * val) {
+static int get_s(input_buffer_tt * bc, int64_t * val) {
uint64_t tmp;
int err;
if ((err = get_v(bc, &tmp))) return err;
@@ -156,13 +156,13 @@ static int get_s(input_buffer_t * bc, in
}
#ifdef TRACE
-static int get_v_trace(input_buffer_t * bc, uint64_t * val, char * var, char * file, int line, char * func) {
+static int get_v_trace(input_buffer_tt * bc, uint64_t * val, char * var, char * file, int line, char * func) {
int a = get_v(bc, val);
printf("GET_V %llu to var `%s' at %s:%d, %s() (ret: %d)\n", *val, var, file, line, func, a);
return a;
}
-static int get_s_trace(input_buffer_t * bc, int64_t * val, char * var, char * file, int line, char * func) {
+static int get_s_trace(input_buffer_tt * bc, int64_t * val, char * var, char * file, int line, char * func) {
int a = get_s(bc, val);
printf("GET_S %lld to var `%s' at %s:%d, %s() (ret: %d)\n", *val, var, file, line, func, a);
return a;
@@ -193,7 +193,7 @@ static int get_s_trace(input_buffer_t *
(var) = _tmp; \
} while(0)
-static int get_data(input_buffer_t * bc, int len, uint8_t * buf) {
+static int get_data(input_buffer_tt * bc, int len, uint8_t * buf) {
int tmp;
if (!len) return 0;
@@ -208,7 +208,7 @@ static int get_data(input_buffer_t * bc,
return len;
}
-static int get_vb(nut_alloc_t * alloc, input_buffer_t * in, int * len, uint8_t ** buf) {
+static int get_vb(nut_alloc_tt * alloc, input_buffer_tt * in, int * len, uint8_t ** buf) {
uint64_t tmp;
int err;
if ((err = get_v(in, &tmp))) return err;
@@ -221,7 +221,7 @@ static int get_vb(nut_alloc_t * alloc, i
return 0;
}
-static int get_header(input_buffer_t * in, input_buffer_t * out) {
+static int get_header(input_buffer_tt * in, input_buffer_tt * out) {
off_t start = bctello(in) - 8; // startcode
int forward_ptr;
int err = 0;
@@ -246,8 +246,8 @@ err_out:
return err;
}
-static int get_main_header(nut_context_t * nut) {
- input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
+static int get_main_header(nut_context_tt * nut) {
+ input_buffer_tt itmp, * tmp = new_mem_buffer(&itmp);
int i, j, err = 0;
int flag, fields, timestamp = 0, mul = 1, stream = 0, size, count, reserved;
@@ -261,8 +261,8 @@ static int get_main_header(nut_context_t
GET_V(tmp, nut->timebase_count);
nut->alloc->free(nut->tb); nut->tb = NULL;
- ERROR(SIZE_MAX/sizeof(nut_timebase_t) < nut->timebase_count, NUT_ERR_OUT_OF_MEM);
- nut->tb = nut->alloc->malloc(nut->timebase_count * sizeof(nut_timebase_t));
+ ERROR(SIZE_MAX/sizeof(nut_timebase_tt) < nut->timebase_count, NUT_ERR_OUT_OF_MEM);
+ nut->tb = nut->alloc->malloc(nut->timebase_count * sizeof(nut_timebase_tt));
ERROR(!nut->tb, NUT_ERR_OUT_OF_MEM);
for (i = 0; i < nut->timebase_count; i++) {
GET_V(tmp, nut->tb[i].num);
@@ -303,9 +303,9 @@ err_out:
return err;
}
-static int get_stream_header(nut_context_t * nut) {
- input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
- stream_context_t * sc;
+static int get_stream_header(nut_context_tt * nut) {
+ input_buffer_tt itmp, * tmp = new_mem_buffer(&itmp);
+ stream_context_tt * sc;
int i, err = 0;
CHECK(get_header(nut->i, tmp));
@@ -347,14 +347,14 @@ err_out:
return err;
}
-static void free_info_packet(nut_context_t * nut, nut_info_packet_t * info) {
+static void free_info_packet(nut_context_tt * nut, nut_info_packet_tt * info) {
int i;
for (i = 0; i < info->count; i++) nut->alloc->free(info->fields[i].data);
nut->alloc->free(info->fields);
}
-static int get_info_header(nut_context_t * nut, nut_info_packet_t * info) {
- input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
+static int get_info_header(nut_context_tt * nut, nut_info_packet_tt * info) {
+ input_buffer_tt itmp, * tmp = new_mem_buffer(&itmp);
int i, err = 0;
CHECK(get_header(nut->i, tmp));
@@ -366,11 +366,11 @@ static int get_info_header(nut_context_t
GET_V(tmp, info->chapter_len);
GET_V(tmp, info->count);
- SAFE_CALLOC(nut->alloc, info->fields, sizeof(nut_info_field_t), info->count);
+ SAFE_CALLOC(nut->alloc, info->fields, sizeof(nut_info_field_tt), info->count);
for (i = 0; i < info->count; i++) {
int len;
- nut_info_field_t * field = &info->fields[i];
+ nut_info_field_tt * field = &info->fields[i];
len = sizeof(field->name) - 1;
CHECK(get_vb(nut->alloc, tmp, &len, (uint8_t**)&field->name));
@@ -409,8 +409,8 @@ err_out:
return err;
}
-static void add_existing_syncpoint(nut_context_t * nut, syncpoint_t sp, uint64_t * pts, uint64_t * eor, int i) {
- syncpoint_list_t * sl = &nut->syncpoints;
+static void add_existing_syncpoint(nut_context_tt * nut, syncpoint_tt sp, uint64_t * pts, uint64_t * eor, int i) {
+ syncpoint_list_tt * sl = &nut->syncpoints;
int j;
int pts_cache = nut->dopts.cache_syncpoints & 1;
@@ -433,8 +433,8 @@ static void add_existing_syncpoint(nut_c
if (sp.pts_valid && i) sl->s[i-1].seen_next = 1;
}
-static int add_syncpoint(nut_context_t * nut, syncpoint_t sp, uint64_t * pts, uint64_t * eor, int * out) {
- syncpoint_list_t * sl = &nut->syncpoints;
+static int add_syncpoint(nut_context_tt * nut, syncpoint_tt sp, uint64_t * pts, uint64_t * eor, int * out) {
+ syncpoint_list_tt * sl = &nut->syncpoints;
int i, j, err = 0;
int pts_cache = nut->dopts.cache_syncpoints & 1;
@@ -452,13 +452,13 @@ static int add_syncpoint(nut_context_t *
i++;
if (sl->len + 1 > sl->alloc_len) {
sl->alloc_len += PREALLOC_SIZE/4;
- SAFE_REALLOC(nut->alloc, sl->s, sizeof(syncpoint_t), sl->alloc_len);
+ SAFE_REALLOC(nut->alloc, sl->s, sizeof(syncpoint_tt), sl->alloc_len);
if (pts_cache) {
SAFE_REALLOC(nut->alloc, sl->pts, nut->stream_count * sizeof(uint64_t), sl->alloc_len);
SAFE_REALLOC(nut->alloc, sl->eor, nut->stream_count * sizeof(uint64_t), sl->alloc_len);
}
}
- memmove(sl->s + i + 1, sl->s + i, (sl->len - i) * sizeof(syncpoint_t));
+ memmove(sl->s + i + 1, sl->s + i, (sl->len - i) * sizeof(syncpoint_tt));
sl->s[i] = sp;
if (sl->s[i].pts_valid) {
if (!pts_cache) sl->s[i].pts_valid = 0; // pts_valid is not really true, only used for seen_next
@@ -480,9 +480,9 @@ err_out:
return err;
}
-static int queue_add_syncpoint(nut_context_t * nut, syncpoint_t sp, uint64_t * pts, uint64_t * eor) {
- syncpoint_list_t * sl = &nut->syncpoints;
- syncpoint_linked_t * s;
+static int queue_add_syncpoint(nut_context_tt * nut, syncpoint_tt sp, uint64_t * pts, uint64_t * eor) {
+ syncpoint_list_tt * sl = &nut->syncpoints;
+ syncpoint_linked_tt * s;
size_t malloc_size;
int pts_cache = nut->dopts.cache_syncpoints & 1;
int err = 0;
@@ -500,7 +500,7 @@ static int queue_add_syncpoint(nut_conte
return 0;
}
- malloc_size = sizeof(syncpoint_linked_t) - sizeof(uint64_t);
+ malloc_size = sizeof(syncpoint_linked_tt) - sizeof(uint64_t);
if (pts_cache && sp.pts_valid) {
assert(pts && eor); // code sanity check
malloc_size += (nut->stream_count*2) * sizeof(uint64_t);
@@ -522,11 +522,11 @@ err_out:
return err;
}
-static int flush_syncpoint_queue(nut_context_t * nut) {
- syncpoint_list_t * sl = &nut->syncpoints;
+static int flush_syncpoint_queue(nut_context_tt * nut) {
+ syncpoint_list_tt * sl = &nut->syncpoints;
int err = 0;
while (sl->linked) {
- syncpoint_linked_t * s = sl->linked;
+ syncpoint_linked_tt * s = sl->linked;
CHECK(add_syncpoint(nut, s->s, s->pts_eor, s->pts_eor + nut->stream_count, NULL));
sl->linked = s->prev;
nut->alloc->free(s);
@@ -535,20 +535,20 @@ err_out:
return err;
}
-static void set_global_pts(nut_context_t * nut, uint64_t pts) {
+static void set_global_pts(nut_context_tt * nut, uint64_t pts) {
int i;
TO_PTS(timestamp, pts)
for (i = 0; i < nut->stream_count; i++) {
- nut->sc[i].last_pts = convert_ts(timestamp_p, nut->tb[timestamp_t], TO_TB(i));
+ nut->sc[i].last_pts = convert_ts(timestamp_p, nut->tb[timestamp_tb], TO_TB(i));
}
}
-static int get_syncpoint(nut_context_t * nut) {
+static int get_syncpoint(nut_context_tt * nut) {
int err = 0;
- syncpoint_t s;
+ syncpoint_tt s;
int after_seek = nut->last_syncpoint ? 0 : 1;
- input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
+ input_buffer_tt itmp, * tmp = new_mem_buffer(&itmp);
s.pos = bctello(nut->i) - 8;
@@ -584,23 +584,23 @@ err_out:
return err;
}
-static int get_index(nut_context_t * nut) {
- input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
+static int get_index(nut_context_tt * nut) {
+ input_buffer_tt itmp, * tmp = new_mem_buffer(&itmp);
int i, err = 0;
uint64_t max_pts;
- syncpoint_list_t * sl = &nut->syncpoints;
+ syncpoint_list_tt * sl = &nut->syncpoints;
CHECK(get_header(nut->i, tmp));
GET_V(tmp, max_pts);
for (i = 0; i < nut->stream_count; i++) {
TO_PTS(max, max_pts)
- nut->sc[i].sh.max_pts = convert_ts(max_p, nut->tb[max_t], TO_TB(i));
+ nut->sc[i].sh.max_pts = convert_ts(max_p, nut->tb[max_tb], TO_TB(i));
}
GET_V(tmp, sl->len);
sl->alloc_len = sl->len;
- SAFE_REALLOC(nut->alloc, sl->s, sizeof(syncpoint_t), sl->alloc_len);
+ SAFE_REALLOC(nut->alloc, sl->s, sizeof(syncpoint_tt), sl->alloc_len);
SAFE_REALLOC(nut->alloc, sl->pts, nut->stream_count * sizeof(uint64_t), sl->alloc_len);
SAFE_REALLOC(nut->alloc, sl->eor, nut->stream_count * sizeof(uint64_t), sl->alloc_len);
@@ -656,7 +656,7 @@ err_out:
return err;
}
-static void clear_dts_cache(nut_context_t * nut) {
+static void clear_dts_cache(nut_context_tt * nut) {
int i;
for (i = 0; i < nut->stream_count; i++) {
int j;
@@ -665,8 +665,8 @@ static void clear_dts_cache(nut_context_
}
}
-static int get_packet(nut_context_t * nut, nut_packet_t * pd, int * saw_syncpoint) {
- nut_info_packet_t info = { 0 };
+static int get_packet(nut_context_tt * nut, nut_packet_tt * pd, int * saw_syncpoint) {
+ nut_info_packet_tt info = { 0 };
uint64_t tmp;
int err = 0, after_sync = 0, checksum = 0, flags, i;
off_t start;
@@ -769,8 +769,8 @@ err_out:
return err;
}
-static void push_frame(nut_context_t * nut, nut_packet_t * pd) {
- stream_context_t * sc = &nut->sc[pd->stream];
+static void push_frame(nut_context_tt * nut, nut_packet_tt * pd) {
+ stream_context_tt * sc = &nut->sc[pd->stream];
sc->last_pts = pd->pts;
sc->last_dts = get_dts(sc->sh.decode_delay, sc->pts_cache, pd->pts);
if (pd->flags & NUT_FLAG_KEY && !sc->last_key) sc->last_key = pd->pts + 1;
@@ -778,7 +778,7 @@ static void push_frame(nut_context_t * n
else sc->eor = 0;
}
-static int find_main_headers(nut_context_t * nut) {
+static int find_main_headers(nut_context_tt * nut) {
int err = 0;
uint64_t tmp;
int len = PREALLOC_SIZE;
@@ -845,7 +845,7 @@ err_out:
return err;
}
-static int find_syncpoint(nut_context_t * nut, syncpoint_t * res, int backwards, off_t stop) {
+static int find_syncpoint(nut_context_tt * nut, syncpoint_tt * res, int backwards, off_t stop) {
int read;
int err = 0;
uint64_t tmp;
@@ -862,7 +862,7 @@ retry:
tmp = (tmp << 8) | *(nut->i->buf_ptr++);
if (tmp != SYNCPOINT_STARTCODE) continue;
if (res) {
- input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
+ input_buffer_tt itmp, * tmp = new_mem_buffer(&itmp);
res->pos = bctello(nut->i) - 8;
if ((err = get_header(nut->i, tmp)) == NUT_ERR_EAGAIN) goto err_out;
@@ -904,9 +904,9 @@ err_out:
return err;
}
-static int smart_find_syncpoint(nut_context_t * nut, syncpoint_t * sp, int backwards, off_t stop) {
+static int smart_find_syncpoint(nut_context_tt * nut, syncpoint_tt * sp, int backwards, off_t stop) {
struct find_syncpoint_state_s * fss = &nut->find_syncpoint_state;
- syncpoint_list_t * sl = &nut->syncpoints;
+ syncpoint_list_tt * sl = &nut->syncpoints;
int i = fss->i, err = 0;
off_t pos = fss->i ? fss->pos : bctello(nut->i);
@@ -960,7 +960,7 @@ static int smart_find_syncpoint(nut_cont
i = tmp + 1;
}
- memmove(sl->s + begin, sl->s + i, (sl->len - i) * sizeof(syncpoint_t));
+ memmove(sl->s + begin, sl->s + i, (sl->len - i) * sizeof(syncpoint_tt));
memmove(sl->pts + begin * nut->stream_count, sl->pts + i * nut->stream_count, (sl->len - i) * nut->stream_count * sizeof(uint64_t));
memmove(sl->eor + begin * nut->stream_count, sl->eor + i * nut->stream_count, (sl->len - i) * nut->stream_count * sizeof(uint64_t));
@@ -989,10 +989,10 @@ err_out:
return err;
}
-int nut_read_next_packet(nut_context_t * nut, nut_packet_t * pd) {
+int nut_read_next_packet(nut_context_tt * nut, nut_packet_tt * pd) {
int err = 0;
if (nut->seek_status) { // in error mode!
- syncpoint_t s;
+ syncpoint_tt s;
CHECK(smart_find_syncpoint(nut, &s, 0, 0));
nut->i->buf_ptr = get_buf(nut->i, s.pos); // go back to beginning of syncpoint
flush_buf(nut->i);
@@ -1019,7 +1019,7 @@ err_out:
return err;
}
-static int get_headers(nut_context_t * nut, int read_info) {
+static int get_headers(nut_context_tt * nut, int read_info) {
int i, err = 0;
uint64_t tmp;
@@ -1027,7 +1027,7 @@ static int get_headers(nut_context_t * n
assert(tmp == MAIN_STARTCODE); // sanity, get_headers should only be called in this situation
CHECK(get_main_header(nut));
- SAFE_CALLOC(nut->alloc, nut->sc, sizeof(stream_context_t), nut->stream_count);
+ SAFE_CALLOC(nut->alloc, nut->sc, sizeof(stream_context_tt), nut->stream_count);
for (i = 0; i < nut->stream_count; i++) nut->sc[i].sh.type = -1;
CHECK(get_bytes(nut->i, 8, &tmp));
@@ -1037,8 +1037,8 @@ static int get_headers(nut_context_t * n
if (tmp == STREAM_STARTCODE) {
CHECK(get_stream_header(nut));
} else if (tmp == INFO_STARTCODE && read_info) {
- SAFE_REALLOC(nut->alloc, nut->info, sizeof(nut_info_packet_t), ++nut->info_count + 1);
- memset(&nut->info[nut->info_count - 1], 0, sizeof(nut_info_packet_t));
+ SAFE_REALLOC(nut->alloc, nut->info, sizeof(nut_info_packet_tt), ++nut->info_count + 1);
+ memset(&nut->info[nut->info_count - 1], 0, sizeof(nut_info_packet_tt));
CHECK(get_info_header(nut, &nut->info[nut->info_count - 1]));
nut->info[nut->info_count].count = -1;
} else if (tmp == INDEX_STARTCODE && nut->dopts.read_index&1) {
@@ -1060,9 +1060,9 @@ err_out:
return err;
}
-int nut_read_headers(nut_context_t * nut, nut_stream_header_t * s [], nut_info_packet_t * info []) {
+int nut_read_headers(nut_context_tt * nut, nut_stream_header_tt * s [], nut_info_packet_tt * info []) {
int i, err = 0;
- syncpoint_t sp;
+ syncpoint_tt sp;
// step 1 - find headers and load to memory
if (!nut->last_headers) CHECK(find_main_headers(nut));
@@ -1113,7 +1113,7 @@ int nut_read_headers(nut_context_t * nut
nut->i->buf_ptr = get_buf(nut->i, sp.pos); // rewind to the syncpoint, this is where playback starts...
nut->seek_status = 0;
- SAFE_CALLOC(nut->alloc, *s, sizeof(nut_stream_header_t), nut->stream_count + 1);
+ SAFE_CALLOC(nut->alloc, *s, sizeof(nut_stream_header_tt), nut->stream_count + 1);
for (i = 0; i < nut->stream_count; i++) (*s)[i] = nut->sc[i].sh;
(*s)[i].type = -1;
nut->tmp_buffer = (void*)*s;
@@ -1124,7 +1124,7 @@ err_out:
return err;
}
-int nut_read_frame(nut_context_t * nut, int * len, uint8_t * buf) {
+int nut_read_frame(nut_context_tt * nut, int * len, uint8_t * buf) {
int tmp = MIN(*len, nut->i->read_len - (nut->i->buf_ptr - nut->i->buf));
if (tmp) {
memcpy(buf, nut->i->buf_ptr, tmp);
@@ -1155,12 +1155,12 @@ static off_t seek_interpolate(int max_di
return guess;
}
-static int binary_search_syncpoint(nut_context_t * nut, double time_pos, off_t * start, off_t * end, syncpoint_t * stopper) {
+static int binary_search_syncpoint(nut_context_tt * nut, double time_pos, off_t * start, off_t * end, syncpoint_tt * stopper) {
int i, err = 0;
- syncpoint_t s;
+ syncpoint_tt s;
off_t fake_hi, * guess = &nut->binary_guess;
uint64_t timebases[nut->timebase_count];
- syncpoint_list_t * sl = &nut->syncpoints;
+ syncpoint_list_tt * sl = &nut->syncpoints;
int a = 0;
for (i = 0; i < nut->timebase_count; i++) timebases[i] = (uint64_t)(time_pos / nut->tb[i].num * nut->tb[i].den);
assert(sl->len); // it is impossible for the first syncpoint to not have been read
@@ -1181,7 +1181,7 @@ static int binary_search_syncpoint(nut_c
for (i = 0; i < sl->len; i++) {
TO_PTS(tmp, sl->s[i].pts)
- if (timebases[tmp_t] <= tmp_p) break;
+ if (timebases[tmp_tb] <= tmp_p) break;
}
if (i == sl->len) { // there isn't any syncpoint bigger than requested
@@ -1256,15 +1256,15 @@ err_out:
return err;
}
-static int linear_search_seek(nut_context_t * nut, int backwards, off_t start, off_t end, syncpoint_t * stopper) {
- syncpoint_list_t * sl = &nut->syncpoints;
+static int linear_search_seek(nut_context_tt * nut, int backwards, off_t start, off_t end, syncpoint_tt * stopper) {
+ syncpoint_list_tt * sl = &nut->syncpoints;
int i, err = 0;
off_t min_pos = 0;
off_t buf_before = 0;
off_t stopper_syncpoint = 0;
if (nut->seek_status <= 1) {
- syncpoint_t s;
+ syncpoint_tt s;
if (!nut->seek_status) seek_buf(nut->i, start, SEEK_SET);
nut->seek_status = 1;
// find closest syncpoint by linear search, SHOULD be one pointed to by back_ptr...
@@ -1291,7 +1291,7 @@ static int linear_search_seek(nut_contex
#define CHECK_break(expr) { if ((err = (expr))) { if (end && err != NUT_ERR_EAGAIN) break; else goto err_out; } }
if (!(nut->seek_status & 1)) while (bctello(nut->i) < end || !end) {
int saw_syncpoint;
- nut_packet_t pd;
+ nut_packet_tt pd;
buf_before = bctello(nut->i);
err = get_packet(nut, &pd, &saw_syncpoint); // we're counting on syncpoint cache!! for the good_key later, and stopper_syncpoint
@@ -1335,7 +1335,7 @@ static int linear_search_seek(nut_contex
off_t back_ptr = stopper->pos - stopper->back_ptr;
TO_PTS(stopper, stopper->pts)
// only relevant if pts is smaller than stopper, and we passed stopper's back_ptr
- if (compare_ts(pd.pts, TO_TB(pd.stream), stopper_p, nut->tb[stopper_t]) < 0 && buf_before >= back_ptr) {
+ if (compare_ts(pd.pts, TO_TB(pd.stream), stopper_p, nut->tb[stopper_tb]) < 0 && buf_before >= back_ptr) {
if (!stopper_syncpoint) nut->sc[pd.stream].state.good_key = 1;
else if (nut->sc[pd.stream].state.good_key) {
int n = 1;
@@ -1378,7 +1378,7 @@ static int linear_search_seek(nut_contex
buf_before = bctello(nut->i);
while (bctello(nut->i) < min_pos) {
- nut_packet_t pd;
+ nut_packet_tt pd;
while ((err = get_packet(nut, &pd, NULL)) == -1);
CHECK(err);
push_frame(nut, &pd);
@@ -1405,11 +1405,11 @@ err_out:
return err;
}
-int nut_seek(nut_context_t * nut, double time_pos, int flags, const int * active_streams) {
+int nut_seek(nut_context_tt * nut, double time_pos, int flags, const int * active_streams) {
int err = 0;
off_t start = 0, end = 0;
int backwards = flags & 1 ? time_pos < 0 : 1;
- syncpoint_t stopper = { 0, 0, 0, 0, 0 };
+ syncpoint_tt stopper = { 0, 0, 0, 0, 0 };
if (!nut->i->isc.seek) return NUT_ERR_NOT_SEEKABLE;
@@ -1448,7 +1448,7 @@ int nut_seek(nut_context_t * nut, double
}
if (nut->syncpoints.s[nut->syncpoints.len-1].seen_next) {
- syncpoint_list_t * sl = &nut->syncpoints;
+ syncpoint_list_tt * sl = &nut->syncpoints;
int i;
int sync[nut->stream_count];
int good_sync = -2;
@@ -1502,7 +1502,7 @@ int nut_seek(nut_context_t * nut, double
debug_msg("DONE SEEK\n");
err_out:
if (err != NUT_ERR_EAGAIN) { // unless EAGAIN
- syncpoint_list_t * sl = &nut->syncpoints;
+ syncpoint_list_tt * sl = &nut->syncpoints;
flush_buf(nut->i);
nut->before_seek = 0;
nut->dopts.cache_syncpoints &= ~2;
@@ -1515,11 +1515,11 @@ err_out:
return err;
}
-nut_context_t * nut_demuxer_init(nut_demuxer_opts_t * dopts) {
- nut_context_t * nut;
+nut_context_tt * nut_demuxer_init(nut_demuxer_opts_tt * dopts) {
+ nut_context_tt * nut;
- if (dopts->alloc.malloc) nut = dopts->alloc.malloc(sizeof(nut_context_t));
- else nut = malloc(sizeof(nut_context_t));
+ if (dopts->alloc.malloc) nut = dopts->alloc.malloc(sizeof(nut_context_tt));
+ else nut = malloc(sizeof(nut_context_tt));
if (!nut) return NULL;
@@ -1572,7 +1572,7 @@ nut_context_t * nut_demuxer_init(nut_dem
return nut;
}
-void nut_demuxer_uninit(nut_context_t * nut) {
+void nut_demuxer_uninit(nut_context_tt * nut) {
int i;
if (!nut) return;
for (i = 0; i < nut->stream_count; i++) {
@@ -1586,7 +1586,7 @@ void nut_demuxer_uninit(nut_context_t *
nut->alloc->free(nut->syncpoints.pts);
nut->alloc->free(nut->syncpoints.eor);
while (nut->syncpoints.linked) {
- syncpoint_linked_t * s = nut->syncpoints.linked;
+ syncpoint_linked_tt * s = nut->syncpoints.linked;
nut->syncpoints.linked = s->prev;
nut->alloc->free(s);
}
Modified: src/trunk/libnut/framecode.c
==============================================================================
--- src/trunk/libnut/framecode.c (original)
+++ src/trunk/libnut/framecode.c Thu Dec 11 21:34:43 2008
@@ -7,15 +7,15 @@
#include "libnut.h"
#include "priv.h"
-typedef nut_frame_table_input_t fti_t; // just a shortcut
+typedef nut_frame_table_input_tt fti_tt; // just a shortcut
-static int count_streams(const nut_stream_header_t * s) {
+static int count_streams(const nut_stream_header_tt * s) {
int i;
for (i = 0; s[i].type != -1; i++);
return i;
}
-void nut_framecode_generate(const nut_stream_header_t s[], nut_frame_table_input_t fti[256]) {
+void nut_framecode_generate(const nut_stream_header_tt s[], nut_frame_table_input_tt fti[256]) {
int stream_count = count_streams(s);
int i, n = 0, m = 0, tot_con = 0;
enum {
@@ -29,21 +29,21 @@ void nut_framecode_generate(const nut_st
for (i = 0; i < stream_count; i++) consume[i] = e_consume_none;
// the basic framecodes. flag, pts, stream, mul, size, count
- fti[n++] = (fti_t){ /*invalid 0x00*/ FLAG_INVALID, 0, 0, 1, 0, 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_CODED_PTS|FLAG_STREAM_ID|FLAG_SIZE_MSB, 0, 0, 1, 0, 1 };
- fti[n++] = (fti_t){ FLAG_CODED_PTS|FLAG_STREAM_ID|FLAG_SIZE_MSB, 0, 0, 1, 0, 1 };
- fti[n++] = (fti_t){ /*extreme fallback*/ FLAG_CODED, 1, 0, 1, 0, 1 };
+ fti[n++] = (fti_tt){ /*invalid 0x00*/ FLAG_INVALID, 0, 0, 1, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_CODED_PTS|FLAG_STREAM_ID|FLAG_SIZE_MSB, 0, 0, 1, 0, 1 };
+ fti[n++] = (fti_tt){ FLAG_CODED_PTS|FLAG_STREAM_ID|FLAG_SIZE_MSB, 0, 0, 1, 0, 1 };
+ fti[n++] = (fti_tt){ /*extreme fallback*/ FLAG_CODED, 1, 0, 1, 0, 1 };
for (i = 0; i < stream_count; i++) {
if (n + m > 230) break; // that's enough! don't overflow
switch (s[i].type) {
case NUT_VIDEO_CLASS:
- fti[n++] = (fti_t){ NUT_FLAG_KEY| FLAG_SIZE_MSB, 1, i, 1, 0, 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_CHECKSUM|FLAG_SIZE_MSB, 1, i, 1, 0, 1 };
- fti[n++] = (fti_t){ FLAG_CODED_PTS|FLAG_SIZE_MSB, 0, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY| FLAG_SIZE_MSB, 1, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_CHECKSUM|FLAG_SIZE_MSB, 1, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ FLAG_CODED_PTS|FLAG_SIZE_MSB, 0, i, 1, 0, 1 };
if (s[i].fourcc_len == 4 && !strncmp((char*)s[i].fourcc, "mp4v", 4)) {
- fti[n++] = (fti_t){ 0, 1, i, 7, 6, 1 };
- fti[n++] = (fti_t){ 0, 2, i, 7, 6, 1 };
+ fti[n++] = (fti_tt){ 0, 1, i, 7, 6, 1 };
+ fti[n++] = (fti_tt){ 0, 2, i, 7, 6, 1 };
consume[i] = e_consume_mpeg4;
} else if (s[i].fourcc_len == 4 && !strncmp((char*)s[i].fourcc, "h264", 4)) {
consume[i] = e_consume_h264;
@@ -52,29 +52,29 @@ void nut_framecode_generate(const nut_st
}
break;
case NUT_AUDIO_CLASS:
- fti[n++] = (fti_t){NUT_FLAG_KEY| FLAG_SIZE_MSB, 1, i, 1, 0, 1 };
- fti[n++] = (fti_t){NUT_FLAG_KEY|FLAG_CODED_PTS|FLAG_SIZE_MSB, 0, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){NUT_FLAG_KEY| FLAG_SIZE_MSB, 1, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){NUT_FLAG_KEY|FLAG_CODED_PTS|FLAG_SIZE_MSB, 0, i, 1, 0, 1 };
if (s[i].fourcc_len == 4 && !strncmp((char*)s[i].fourcc, "mp3 ", 4)) {
int j, a[] = {288,336,384,480,576,672,768,960};
for (j = 0; j < sizeof a/sizeof*a; j++)
- fti[n++] = (fti_t){ NUT_FLAG_KEY, 1, i, a[j]+1, a[j], 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 1, i, 4, 0, 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 1, i, 4, 2, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY, 1, i, a[j]+1, a[j], 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 1, i, 4, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 1, i, 4, 2, 1 };
} else if (s[i].fourcc_len == 4 && !strncmp((char*)s[i].fourcc, "vrbs", 4)) {
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 2, i, 1, 0, 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 9, i, 1, 0, 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 23, i, 1, 0, 1 };
- fti[n++] = (fti_t){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 16, i, 6, 0, 6 }; m+=5;
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 2, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 9, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 23, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY|FLAG_SIZE_MSB, 16, i, 6, 0, 6 }; m+=5;
consume[i] = e_consume_vorbis;
}
break;
case NUT_SUBTITLE_CLASS:
- fti[n++] = (fti_t){NUT_FLAG_KEY|FLAG_SIZE_MSB|FLAG_CODED_PTS, 0, i, 5, 0, 5 }; m+=4;
- fti[n++] = (fti_t){NUT_FLAG_KEY|NUT_FLAG_EOR| FLAG_CODED_PTS, 0, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){NUT_FLAG_KEY|FLAG_SIZE_MSB|FLAG_CODED_PTS, 0, i, 5, 0, 5 }; m+=4;
+ fti[n++] = (fti_tt){NUT_FLAG_KEY|NUT_FLAG_EOR| FLAG_CODED_PTS, 0, i, 1, 0, 1 };
break;
case NUT_USERDATA_CLASS:
- fti[n++] = (fti_t){NUT_FLAG_KEY|FLAG_SIZE_MSB|FLAG_CODED_PTS, 0, i, 1, 0, 1 };
- fti[n++] = (fti_t){ FLAG_SIZE_MSB|FLAG_CODED_PTS, 0, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){NUT_FLAG_KEY|FLAG_SIZE_MSB|FLAG_CODED_PTS, 0, i, 1, 0, 1 };
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB|FLAG_CODED_PTS, 0, i, 1, 0, 1 };
break;
default:
assert(0);
@@ -93,9 +93,9 @@ void nut_framecode_generate(const nut_st
int al1 = al*35/100;
int al2 = al*45/100;
int al3 = al-al1-al2;
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, 1, i, al1, 0, al1 }; m+=al1-1;
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, 2, i, al2, 0, al2 }; m+=al2-1;
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, -1, i, al3, 0, al3 }; m+=al3-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, 1, i, al1, 0, al1 }; m+=al1-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, 2, i, al2, 0, al2 }; m+=al2-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, -1, i, al3, 0, al3 }; m+=al3-1;
break;
}
case e_consume_h264: {
@@ -103,27 +103,27 @@ void nut_framecode_generate(const nut_st
int al2 = al*35/100;
int al3 = al*20/100;
int al4 = al-al1-al2-al3;
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, 1, i, al1, 0, al1 }; m+=al1-1;
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, 2, i, al2, 0, al2 }; m+=al2-1;
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, -1, i, al3, 0, al3 }; m+=al3-1;
- fti[n++] = (fti_t){ FLAG_CODED_PTS|FLAG_SIZE_MSB, 0, i, al4, 0, al4 }; m+=al4-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, 1, i, al1, 0, al1 }; m+=al1-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, 2, i, al2, 0, al2 }; m+=al2-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, -1, i, al3, 0, al3 }; m+=al3-1;
+ fti[n++] = (fti_tt){ FLAG_CODED_PTS|FLAG_SIZE_MSB, 0, i, al4, 0, al4 }; m+=al4-1;
break;
}
case e_consume_video:
- fti[n++] = (fti_t){ FLAG_SIZE_MSB, 1, i, al, 0, al }; m+=al-1;
+ fti[n++] = (fti_tt){ FLAG_SIZE_MSB, 1, i, al, 0, al }; m+=al-1;
break;
case e_consume_vorbis: {
int al1 = al*70/100;
int al2 = al-al1;
al1 /= 2; al2 /= 2;
- fti[n++] = (fti_t){ NUT_FLAG_KEY, 16, i,240+al1,240-al1, al1*2 }; m+=al1*2-1;
- fti[n++] = (fti_t){ NUT_FLAG_KEY, 2, i, 65+al2, 65-al2, al2*2 }; m+=al2*2-1;
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY, 16, i,240+al1,240-al1, al1*2 }; m+=al1*2-1;
+ fti[n++] = (fti_tt){ NUT_FLAG_KEY, 2, i, 65+al2, 65-al2, al2*2 }; m+=al2*2-1;
break;
}
}
}
i = 255-n-m;
- fti[n++] = (fti_t){ /*invalid 0xFF*/ FLAG_INVALID, 0, 0, i, 0, i };
+ fti[n++] = (fti_tt){ /*invalid 0xFF*/ FLAG_INVALID, 0, 0, i, 0, i };
// the final framecode. flag, pts, stream, mul, size, count
- fti[n++] = (fti_t){ -1 };
+ fti[n++] = (fti_tt){ -1 };
}
Modified: src/trunk/libnut/libnut.h
==============================================================================
--- src/trunk/libnut/libnut.h (original)
+++ src/trunk/libnut/libnut.h Thu Dec 11 21:34:43 2008
@@ -17,7 +17,7 @@
#define NUT_VERSION 2 ///< Version of NUT specification this library implements.
/// Stream class values, only one can be set. Higher values are not legal.
-enum nut_stream_class_t {
+enum nut_stream_class_tt {
NUT_VIDEO_CLASS = 0, ///< = 0
NUT_AUDIO_CLASS = 1, ///< = 1
NUT_SUBTITLE_CLASS = 2, ///< = 2
@@ -25,33 +25,33 @@ enum nut_stream_class_t {
};
/// frame flags bitfield (several flags may be set at once)
-enum nut_frame_flags_t {
+enum nut_frame_flags_tt {
NUT_FLAG_KEY = 1, ///< Marks a frame as keyframe.
NUT_FLAG_EOR = 2, ///< Marks end of relevance for stream. #NUT_FLAG_KEY \b must be set together with this flag.
};
/// @}
-typedef struct nut_context_s nut_context_t;
+typedef struct nut_context_s nut_context_tt;
/// memory allocation function pointers \ingroup demuxer muxer
typedef struct {
void * (*malloc)(size_t size); ///< memory allocation malloc function pointer
void * (*realloc)(void *ptr, size_t size); ///< memory allocation realloc function pointer
void (*free)(void *ptr); ///< memory allocation free function pointer
-} nut_alloc_t;
+} nut_alloc_tt;
/// timebase struct \ingroup demuxer muxer
typedef struct {
int num; ///< Example: 1001
int den; ///< Example: 24000
-} nut_timebase_t;
+} nut_timebase_tt;
/// stream header struct \ingroup demuxer muxer
typedef struct {
int type; ///< Possible values are enum ::nut_stream_class_t. A value of -1 terminates a stream header array.
int fourcc_len; ///< fourcc length
uint8_t * fourcc; ///< fourcc in big-endian format
- nut_timebase_t time_base; ///< stream timebase
+ nut_timebase_tt time_base; ///< stream timebase
int fixed_fps; ///< denote stream as fixed or variable fps
int decode_delay; ///< decode delay of codec in this stream
int codec_specific_len; ///< length of codec-specific data
@@ -71,7 +71,7 @@ typedef struct {
int samplerate_num; ///< audio sample rate, example: 44100
int samplerate_denom; ///< audio sample rate denominator, example: 1
int channel_count; ///< number of audio channels
-} nut_stream_header_t;
+} nut_stream_header_tt;
/// single info field struct \ingroup demuxer muxer
typedef struct {
@@ -79,20 +79,20 @@ typedef struct {
char name[65]; ///< NULL-terminated string, name of info field
int64_t val; ///< meaning of value defined by #type
int den; ///< Used if #type is "r", #val is the numerator.
- nut_timebase_t tb; ///< Used if #type is "t".
+ nut_timebase_tt tb; ///< Used if #type is "t".
uint8_t * data; ///< Used if #type is non-numeric.
-} nut_info_field_t;
+} nut_info_field_tt;
/// single info packet struct \ingroup demuxer muxer
typedef struct {
int count; ///< number of info fields in #fields.
int stream_id_plus1; ///< Zero indicates non-stream-specific info packet.
int chapter_id; ///< subsection of the file this info packet applies to
- nut_timebase_t chapter_tb; ///< timebase of #chapter_start and #chapter_len
+ nut_timebase_tt chapter_tb; ///< timebase of #chapter_start and #chapter_len
uint64_t chapter_start; ///< start of chapter or complete file
uint64_t chapter_len; ///< length of chapter or complete file
- nut_info_field_t * fields; ///< Info fields, has #count elements.
-} nut_info_packet_t;
+ nut_info_field_tt * fields; ///< Info fields, has #count elements.
+} nut_info_packet_tt;
/// single frame packet struct \ingroup demuxer muxer
typedef struct {
@@ -101,7 +101,7 @@ typedef struct {
uint64_t pts; ///< presentation timestamp of frame
int flags; ///< frame flags from #nut_frame_flags_t
int64_t next_pts; ///< Only used in muxer. Only necessary if nut_write_frame_reorder() is used.
-} nut_packet_t;
+} nut_packet_tt;
@@ -115,8 +115,8 @@ typedef struct {
/// output stream struct
typedef struct {
void * priv; ///< opaque priv pointer to be passed to function calls
- int (*write)(void * priv, size_t len, const uint8_t * buf); ///< If NULL, nut_output_stream_t::priv is used as FILE*.
-} nut_output_stream_t;
+ int (*write)(void * priv, size_t len, const uint8_t * buf); ///< If NULL, nut_output_stream_tt::priv is used as FILE*.
+} nut_output_stream_tt;
/// NUT framecode table input
typedef struct {
@@ -126,38 +126,38 @@ typedef struct {
int mul; ///< multiplier for coded frame size
int size; ///< LSB for coded frame size
int count; ///< Explicit count of framecode entry, \b should be (mul-size) in almost all cases.
-} nut_frame_table_input_t;
+} nut_frame_table_input_tt;
/// muxer options struct
typedef struct {
- nut_output_stream_t output; ///< output stream function pointers
- nut_alloc_t alloc; ///< memory allocation function pointers
+ nut_output_stream_tt output; ///< output stream function pointers
+ nut_alloc_tt alloc; ///< memory allocation function pointers
int write_index; ///< whether or not to write an index
int realtime_stream; ///< Implies no write_index.
int max_distance; ///< Valid values are 32-65536, the recommended value is 32768. Lower values give better seekability and error detection and recovery but cause higher overhead.
- nut_frame_table_input_t * fti; ///< Framecode table, may be NULL.
-} nut_muxer_opts_t;
+ nut_frame_table_input_tt * fti; ///< Framecode table, may be NULL.
+} nut_muxer_opts_tt;
/// Allocates NUT muxer context and writes headers to file.
-nut_context_t * nut_muxer_init(const nut_muxer_opts_t * mopts, const nut_stream_header_t s[], const nut_info_packet_t info[]);
+nut_context_tt * nut_muxer_init(const nut_muxer_opts_tt * mopts, const nut_stream_header_tt s[], const nut_info_packet_tt info[]);
/// Deallocates NUT muxer context.
-void nut_muxer_uninit(nut_context_t * nut);
+void nut_muxer_uninit(nut_context_tt * nut);
/// Writes a single frame to a NUT file.
-void nut_write_frame(nut_context_t * nut, const nut_packet_t * p, const uint8_t * buf);
+void nut_write_frame(nut_context_tt * nut, const nut_packet_tt * p, const uint8_t * buf);
/// Writes a single info packet to a NUT file.
-void nut_write_info(nut_context_t * nut, const nut_info_packet_t * info);
+void nut_write_info(nut_context_tt * nut, const nut_info_packet_tt * info);
/// Buffers and sorts a single frame to be written to a NUT file.
-void nut_write_frame_reorder(nut_context_t * nut, const nut_packet_t * p, const uint8_t * buf);
+void nut_write_frame_reorder(nut_context_tt * nut, const nut_packet_tt * p, const uint8_t * buf);
/// Flushes reorder buffer and deallocates NUT muxer context.
-void nut_muxer_uninit_reorder(nut_context_t * nut);
+void nut_muxer_uninit_reorder(nut_context_tt * nut);
/// Creates an optimized framecode table for the NUT main header based on stream info.
-void nut_framecode_generate(const nut_stream_header_t s[], nut_frame_table_input_t fti[256]);
+void nut_framecode_generate(const nut_stream_header_tt s[], nut_frame_table_input_tt fti[256]);
/// @}
@@ -176,17 +176,17 @@ typedef struct {
off_t (*seek)(void * priv, long long pos, int whence); ///< Input stream seek function, must return position in file after seek.
int (*eof)(void * priv); ///< Returns if EOF has been met in stream in case of read error.
off_t file_pos; ///< file position at beginning of read
-} nut_input_stream_t;
+} nut_input_stream_tt;
/// demuxer options struct
typedef struct {
- nut_input_stream_t input; ///< input stream function pointers
- nut_alloc_t alloc; ///< memory allocation function pointers
+ nut_input_stream_tt input; ///< input stream function pointers
+ nut_alloc_tt alloc; ///< memory allocation function pointers
int read_index; ///< Seeks to end-of-file at beginning of playback to search for index. Implies cache_syncpoints.
int cache_syncpoints; ///< Improves seekability and error recovery greatly, but costs some memory (0.5MB for very large files).
void * info_priv; ///< opaque priv pointer to be passed to #new_info
- void (*new_info)(void * priv, nut_info_packet_t * info); ///< Function to be called when info is found mid-stream. May be NULL.
-} nut_demuxer_opts_t;
+ void (*new_info)(void * priv, nut_info_packet_tt * info); ///< Function to be called when info is found mid-stream. May be NULL.
+} nut_demuxer_opts_tt;
/// Possible errors given from demuxer functions. Only the first 4 errors should ever be returned, the rest are internal.
enum nut_errors {
@@ -211,25 +211,25 @@ enum nut_errors {
};
/// Creates a NUT demuxer context. Does not read any information from file.
-nut_context_t * nut_demuxer_init(nut_demuxer_opts_t * dopts);
+nut_context_tt * nut_demuxer_init(nut_demuxer_opts_tt * dopts);
/// Frees a NUT demuxer context. No other functions can be called after this.
-void nut_demuxer_uninit(nut_context_t * nut);
+void nut_demuxer_uninit(nut_context_tt * nut);
/// Reads headers and index, \b must be called at init.
-int nut_read_headers(nut_context_t * nut, nut_stream_header_t * s [], nut_info_packet_t * info []);
+int nut_read_headers(nut_context_tt * nut, nut_stream_header_tt * s [], nut_info_packet_tt * info []);
/// Gets frame header, must be called before each packet.
-int nut_read_next_packet(nut_context_t * nut, nut_packet_t * pd);
+int nut_read_next_packet(nut_context_tt * nut, nut_packet_tt * pd);
/// Reads just the frame \b data, not the header.
-int nut_read_frame(nut_context_t * nut, int * len, uint8_t * buf);
+int nut_read_frame(nut_context_tt * nut, int * len, uint8_t * buf);
/// Gives human readable description of the error return code of any demuxing function.
const char * nut_error(int error);
/// Seeks to the requested position in seconds.
-int nut_seek(nut_context_t * nut, double time_pos, int flags, const int * active_streams);
+int nut_seek(nut_context_tt * nut, double time_pos, int flags, const int * active_streams);
/// @}
@@ -272,14 +272,14 @@ int nut_seek(nut_context_t * nut, double
* \par Example:
* \code
* char * text = "The Foobar Adventure";
- * nut_info_field_t title = {
+ * nut_info_field_tt title = {
* .type = "UTF-8",
* .name = "Title",
* .val = strlen(text),
* .data = text,
* };
*
- * nut_info_field_t rational = {
+ * nut_info_field_tt rational = {
* .type = "r",
* .name = "X-Value close to Pi",
* .val = 355,
@@ -288,7 +288,7 @@ int nut_seek(nut_context_t * nut, double
* \endcode
*/
-/*! \var char nut_info_field_t::type[7]
+/*! \var char nut_info_field_tt::type[7]
* Type of field value
* - "v" - integer value
* - "s" - signed integer value
@@ -298,7 +298,7 @@ int nut_seek(nut_context_t * nut, double
* - Other - binary data
*/
-/*! \var int64_t nut_info_field_t::val
+/*! \var int64_t nut_info_field_tt::val
* - "v" - integer value
* - "s" - integer value
* - "r" - numerator of fraction
@@ -309,24 +309,24 @@ int nut_seek(nut_context_t * nut, double
* terminating NUL (U+0000).
*/
-/*! \var nut_timebase_t nut_info_field_t::tb
+/*! \var nut_timebase_tt nut_info_field_tt::tb
* In the muxer case, values of #tb \b must be identical to the
* timebase of one of the streams.
*/
-/*! \var uint8_t * nut_info_field_t::data
+/*! \var uint8_t * nut_info_field_tt::data
* Even in the case of an UTF-8 string, this data is \b not NULL terminated.
*
* For the muxer, this value \b must be NULL if info field carries no binary
* data.
*/
-/*! \var int nut_info_packet_t::count
+/*! \var int nut_info_packet_tt::count
* For arrays of #nut_info_packet_t, the packet with a #count of \a -1
* terminates the array.
*/
-/*! \var nut_info_packet_t::chapter_id
+/*! \var nut_info_packet_tt::chapter_id
* A value of 0 indicates that the info packet applies to the complete file.
*
* Positive values are real chapters. Real chapters must not overlap. The
@@ -339,13 +339,13 @@ int nut_seek(nut_context_t * nut, double
* of the entire file.
*/
-/*! \var nut_info_packet_t::chapter_tb
+/*! \var nut_info_packet_tt::chapter_tb
* When muxing, values #chapter_tb \b must be identical to the timebase of
* one of the streams.
*/
/*!
- * \var int nut_frame_table_input_t::flag
+ * \var int nut_frame_table_input_tt::flag
*
* This variable is a bitfield. Valid flags are:
* - 1 FLAG_KEYFRAME
@@ -358,40 +358,40 @@ int nut_seek(nut_context_t * nut, double
* - 4096 FLAG_CODED
* - 8192 FLAG_INVALID
*
- * The last entry of nut_frame_table_input_t \b must have flag == -1.
+ * The last entry of nut_frame_table_input_tt \b must have flag == -1.
*/
-/*! \fn nut_context_t * nut_muxer_init(const nut_muxer_opts_t * mopts, const nut_stream_header_t s[], const nut_info_packet_t info[])
+/*! \fn nut_context_tt * nut_muxer_init(const nut_muxer_opts_tt * mopts, const nut_stream_header_tt s[], const nut_info_packet_tt info[])
* \param mopts muxer options
* \param s Stream header data, terminated by \a type = -1.
* \param info Info packet data, terminated by \a count = -1. May be \a NULL.
* \return NUT muxer context
*
- * In case nut_muxer_opts_t::realtime_stream is set, the first packet passed
- * to the nut_output_stream_t::write() function will be all of the main
+ * In case nut_muxer_opts_tt::realtime_stream is set, the first packet passed
+ * to the nut_output_stream_tt::write() function will be all of the main
* headers. This packet must be passed along exactly once with the
* beginning of any stream forwarded out.
*/
-/*! \fn void nut_muxer_uninit(nut_context_t *nut)
+/*! \fn void nut_muxer_uninit(nut_context_tt *nut)
* \param nut NUT muxer context
*
- * Optionaly writes index if nut_muxer_opts_t::write_index is set and
- * nut_muxer_opts_t::realtime_stream is unset.
+ * Optionaly writes index if nut_muxer_opts_tt::write_index is set and
+ * nut_muxer_opts_tt::realtime_stream is unset.
*
* \warning Must \b not be used directly if nut_write_frame_reorder() was used.
* \see nut_muxer_uninit_reorder()
*/
-/*! \fn void nut_write_frame(nut_context_t * nut, const nut_packet_t * p, const uint8_t * buf)
+/*! \fn void nut_write_frame(nut_context_tt * nut, const nut_packet_tt * p, const uint8_t * buf)
* \param nut NUT muxer context
* \param p information about the frame
* \param buf actual frame data
*
- * If nut_muxer_opts_t::realtime_stream realtime_stream is unset, repeated
+ * If nut_muxer_opts_tt::realtime_stream realtime_stream is unset, repeated
* headers will be written at some positions. Syncpoints will be written in
- * accordance to the NUT spec. If nut_muxer_opts_t::realtime_stream is set,
- * calling this function will result in a single nut_output_stream_t::write()
+ * accordance to the NUT spec. If nut_muxer_opts_tt::realtime_stream is set,
+ * calling this function will result in a single nut_output_stream_tt::write()
* call, which will be the full frame NUT packet. If the packet starts with
* a syncpoint startcode, it may be used as a start point after giving the
* main headers to a new client.
@@ -403,16 +403,16 @@ int nut_seek(nut_context_t * nut, double
* \sa nut_write_frame_reorder()
*/
-/*! \fn void nut_write_info(nut_context_t * nut, const nut_info_packet_t * info)
+/*! \fn void nut_write_info(nut_context_tt * nut, const nut_info_packet_tt * info)
* \param nut NUT muxer context
* \param info a single info packet
*
* The use of this function is \b illegal in non-realtime streams, and will
- * do nothing if nut_muxer_opts_t::realtime_stream is not set. The result
- * is a single call to nut_output_stream_t::write() with the NUT info packet.
+ * do nothing if nut_muxer_opts_tt::realtime_stream is not set. The result
+ * is a single call to nut_output_stream_tt::write() with the NUT info packet.
*/
-/*! \fn void nut_write_frame_reorder(nut_context_t * nut, const nut_packet_t * p, const uint8_t * buf)
+/*! \fn void nut_write_frame_reorder(nut_context_tt * nut, const nut_packet_tt * p, const uint8_t * buf)
* \param nut NUT muxer context
* \param p information about the frame
* \param buf actual frame data
@@ -425,14 +425,14 @@ int nut_seek(nut_context_t * nut, double
* \sa nut_muxer_uninit_reorder()
*/
-/*! \fn void nut_muxer_uninit_reorder(nut_context_t * nut)
+/*! \fn void nut_muxer_uninit_reorder(nut_context_tt * nut)
* \param nut NUT muxer context
*
* Must be used if nut_write_frame_reorder() was used.
* \sa nut_muxer_uninit()
*/
-/*! \fn void nut_framecode_generate(const nut_stream_header_t s[], nut_frame_table_input_t fti[256])
+/*! \fn void nut_framecode_generate(const nut_stream_header_tt s[], nut_frame_table_input_tt fti[256])
* \param s Stream header data, terminated by \a type = -1.
* \param fti Output framecode table data, must be preallocated to 256 entries.
*
@@ -441,7 +441,7 @@ int nut_seek(nut_context_t * nut, double
* "mp3 ", and "vrbs".
*
* This function is used directly by nut_muxer_init() if
- * nut_muxer_opts_t::fti is \a NULL.
+ * nut_muxer_opts_tt::fti is \a NULL.
*/
/*! \addtogroup demuxer
@@ -458,7 +458,7 @@ int nut_seek(nut_context_t * nut, double
* error and only nut_demuxer_uninit() can be called.
*
* \par NUT_ERR_EAGAIN
- * Indicates that not enough data was returned by nut_input_stream_t::read(),
+ * Indicates that not enough data was returned by nut_input_stream_tt::read(),
* but EOF was not reached. Whichever function returned this should be called
* again with the exact same parameters when more data is available.
* The exception to this is nut_read_frame(), which should be called with
@@ -474,15 +474,15 @@ int nut_seek(nut_context_t * nut, double
* The only legal operation after a fatal error is nut_demuxer_uninit().
*/
-/*! \var size_t (*nut_input_stream_t::read)(void * priv, size_t len, uint8_t * buf)
- * If NULL, nut_input_stream_t::priv is used as FILE*, and
- * nut_input_stream_t::seek and nut_input_stream_t::eof are ignored.
+/*! \var size_t (*nut_input_stream_tt::read)(void * priv, size_t len, uint8_t * buf)
+ * If NULL, nut_input_stream_tt::priv is used as FILE*, and
+ * nut_input_stream_tt::seek and nut_input_stream_tt::eof are ignored.
*/
-/*! \var off_t (*nut_input_stream_t::seek)(void * priv, long long pos, int whence)
- * If NULL (and nut_input_stream_t::read is non-NULL), indicates stream is
- * unseekable. This implies nut_demuxer_opts_t::read_index and
- * nut_demuxer_opts_t::cache_syncpoints to be unset. Any call to
+/*! \var off_t (*nut_input_stream_tt::seek)(void * priv, long long pos, int whence)
+ * If NULL (and nut_input_stream_tt::read is non-NULL), indicates stream is
+ * unseekable. This implies nut_demuxer_opts_tt::read_index and
+ * nut_demuxer_opts_tt::cache_syncpoints to be unset. Any call to
* nut_seek() with an unseekable stream will yield #NUT_ERR_NOT_SEEKABLE
*
* Parameter whence must support the following libc defines:
@@ -491,11 +491,11 @@ int nut_seek(nut_context_t * nut, double
* - SEEK_END - pos is used as offset from end of file
*/
-/*! \var int (*nut_input_stream_t::eof)(void * priv)
+/*! \var int (*nut_input_stream_tt::eof)(void * priv)
* Only necessary if stream supports non-blocking mode.
* Returns non-zero if stream is at EOF, 0 otherwise.
*
- * This function is called if nut_input_stream_t::read returns less data
+ * This function is called if nut_input_stream_tt::read returns less data
* read than requested. If it returns zero, then the stream is assumed to
* be lacking data and #NUT_ERR_EAGAIN is raised. Otherwise, #NUT_ERR_EOF
* is raised.
@@ -503,12 +503,12 @@ int nut_seek(nut_context_t * nut, double
* If NULL, then any read error is assumed to be caused by EOF.
*/
-/*! \var off_t nut_input_stream_t::file_pos
+/*! \var off_t nut_input_stream_tt::file_pos
* Must contain the position in the file at which demuxing begins. Should
* usually be zero.
*/
-/*! \fn int nut_read_headers(nut_context_t * nut, nut_stream_header_t * s [], nut_info_packet_t * info [])
+/*! \fn int nut_read_headers(nut_context_tt * nut, nut_stream_header_tt * s [], nut_info_packet_tt * info [])
* \param nut NUT demuxer context
* \param s Pointer to stream header variable to be set to an array
* \param info Pointer to info header variable, may be NULL.
@@ -526,7 +526,7 @@ int nut_seek(nut_context_t * nut, double
* nut_read_headers() succeeds.
*/
-/*! \fn int nut_read_next_packet(nut_context_t * nut, nut_packet_t * pd)
+/*! \fn int nut_read_next_packet(nut_context_tt * nut, nut_packet_tt * pd)
* \param nut NUT demuxer context
* \param pd Pointer to frame header struct to be filled with next frame
* information.
@@ -534,7 +534,7 @@ int nut_seek(nut_context_t * nut, double
* After a successful call to nut_read_next_packet(), nut_read_frame()
* \b must be called.
*
- * If nut_demuxer_opts_t::new_info is non-NULL, a new info packet may be
+ * If nut_demuxer_opts_tt::new_info is non-NULL, a new info packet may be
* seen before decoding the frame header and this function pointer will be
* called (possibly even several times).
*
@@ -543,7 +543,7 @@ int nut_seek(nut_context_t * nut, double
* the next undamaged frame in the stream.
*/
-/*! \fn int nut_read_frame(nut_context_t * nut, int * len, uint8_t * buf)
+/*! \fn int nut_read_frame(nut_context_tt * nut, int * len, uint8_t * buf)
* \param nut NUT demuxer context
* \param len length of data left to be read
* \param buf buffer to write the frame data
@@ -559,14 +559,14 @@ int nut_seek(nut_context_t * nut, double
*
* \par Example:
* \code
- * nut_packet_t pd;
+ * nut_packet_tt pd;
* int len = pd.len;
* while((err = nut_read_frame(nut, &len, buf+pd.len-len)) == NUT_ERR_EAGAIN)
* sleep(1);
* \endcode
*/
-/*! \fn int nut_seek(nut_context_t * nut, double time_pos, int flags, const int * active_streams)
+/*! \fn int nut_seek(nut_context_tt * nut, double time_pos, int flags, const int * active_streams)
* \param nut NUT demuxer context
* \param time_pos position to seek to in seconds
* \param flags bitfield with seek options
Modified: src/trunk/libnut/muxer.c
==============================================================================
--- src/trunk/libnut/muxer.c (original)
+++ src/trunk/libnut/muxer.c Thu Dec 11 21:34:43 2008
@@ -11,13 +11,13 @@ static int stream_write(void * priv, siz
return fwrite(buf, 1, len, priv);
}
-static void flush_buf(output_buffer_t * bc) {
+static void flush_buf(output_buffer_tt * bc) {
assert(bc->osc.write);
bc->file_pos += bc->osc.write(bc->osc.priv, bc->buf_ptr - bc->buf, bc->buf);
bc->buf_ptr = bc->buf;
}
-static void ready_write_buf(output_buffer_t * bc, int amount) {
+static void ready_write_buf(output_buffer_tt * bc, int amount) {
if (bc->write_len - (bc->buf_ptr - bc->buf) > amount) return;
if (bc->is_mem) {
@@ -35,8 +35,8 @@ static void ready_write_buf(output_buffe
}
}
-static output_buffer_t * new_mem_buffer(nut_alloc_t * alloc) {
- output_buffer_t * bc = alloc->malloc(sizeof(output_buffer_t));
+static output_buffer_tt * new_mem_buffer(nut_alloc_tt * alloc) {
+ output_buffer_tt * bc = alloc->malloc(sizeof(output_buffer_tt));
bc->alloc = alloc;
bc->write_len = PREALLOC_SIZE;
bc->is_mem = 1;
@@ -46,28 +46,28 @@ static output_buffer_t * new_mem_buffer(
return bc;
}
-static output_buffer_t * new_output_buffer(nut_alloc_t * alloc, nut_output_stream_t osc) {
- output_buffer_t * bc = new_mem_buffer(alloc);
+static output_buffer_tt * new_output_buffer(nut_alloc_tt * alloc, nut_output_stream_tt osc) {
+ output_buffer_tt * bc = new_mem_buffer(alloc);
bc->is_mem = 0;
bc->osc = osc;
if (!bc->osc.write) bc->osc.write = stream_write;
return bc;
}
-static void free_buffer(output_buffer_t * bc) {
+static void free_buffer(output_buffer_tt * bc) {
if (!bc) return;
if (!bc->is_mem) flush_buf(bc);
bc->alloc->free(bc->buf);
bc->alloc->free(bc);
}
-static output_buffer_t * clear_buffer(output_buffer_t * bc) {
+static output_buffer_tt * clear_buffer(output_buffer_tt * bc) {
assert(bc->is_mem);
bc->buf_ptr = bc->buf;
return bc;
}
-static void put_bytes(output_buffer_t * bc, int count, uint64_t val) {
+static void put_bytes(output_buffer_tt * bc, int count, uint64_t val) {
ready_write_buf(bc, count);
for(count--; count >= 0; count--){
*(bc->buf_ptr++) = val >> (8 * count);
@@ -81,7 +81,7 @@ static int v_len(uint64_t val) {
return i;
}
-static void put_v(output_buffer_t * bc, uint64_t val) {
+static void put_v(output_buffer_tt * bc, uint64_t val) {
int i = v_len(val);
ready_write_buf(bc, i);
for(i = (i-1)*7; i; i-=7) {
@@ -90,12 +90,12 @@ static void put_v(output_buffer_t * bc,
*(bc->buf_ptr++)= val & 0x7F;
}
-static void put_s(output_buffer_t * bc, int64_t val) {
+static void put_s(output_buffer_tt * bc, int64_t val) {
if (val<=0) put_v(bc, -2*val );
else put_v(bc, 2*val-1);
}
-static void put_data(output_buffer_t * bc, int len, const void * data) {
+static void put_data(output_buffer_tt * bc, int len, const void * data) {
if (!len) return;
assert(data);
if (bc->write_len - (bc->buf_ptr - bc->buf) > len || bc->is_mem) {
@@ -108,12 +108,12 @@ static void put_data(output_buffer_t * b
}
}
-static void put_vb(output_buffer_t * bc, int len, const void * data) {
+static void put_vb(output_buffer_tt * bc, int len, const void * data) {
put_v(bc, len);
put_data(bc, len, data);
}
-static void put_header(output_buffer_t * bc, output_buffer_t * in, output_buffer_t * tmp, uint64_t startcode, int index_ptr) {
+static void put_header(output_buffer_tt * bc, output_buffer_tt * in, output_buffer_tt * tmp, uint64_t startcode, int index_ptr) {
int forward_ptr;
assert(in->is_mem);
assert(tmp->is_mem);
@@ -137,8 +137,8 @@ static void put_header(output_buffer_t *
if (startcode != SYNCPOINT_STARTCODE) debug_msg("header/index size: %d\n", (int)(bctello(tmp) + bctello(in)));
}
-static void put_main_header(nut_context_t * nut) {
- output_buffer_t * tmp = clear_buffer(nut->tmp_buffer);
+static void put_main_header(nut_context_tt * nut) {
+ output_buffer_tt * tmp = clear_buffer(nut->tmp_buffer);
int i;
int flag, fields, timestamp = 0, mul = 1, stream = 0, size, count;
@@ -187,9 +187,9 @@ static void put_main_header(nut_context_
put_header(nut->o, tmp, nut->tmp_buffer2, MAIN_STARTCODE, 0);
}
-static void put_stream_header(nut_context_t * nut, int id) {
- output_buffer_t * tmp = clear_buffer(nut->tmp_buffer);
- stream_context_t * sc = &nut->sc[id];
+static void put_stream_header(nut_context_tt * nut, int id) {
+ output_buffer_tt * tmp = clear_buffer(nut->tmp_buffer);
+ stream_context_tt * sc = &nut->sc[id];
put_v(tmp, id);
put_v(tmp, sc->sh.type);
@@ -219,8 +219,8 @@ static void put_stream_header(nut_contex
put_header(nut->o, tmp, nut->tmp_buffer2, STREAM_STARTCODE, 0);
}
-static void put_info(nut_context_t * nut, const nut_info_packet_t * info) {
- output_buffer_t * tmp = clear_buffer(nut->tmp_buffer);
+static void put_info(nut_context_tt * nut, const nut_info_packet_tt * info) {
+ output_buffer_tt * tmp = clear_buffer(nut->tmp_buffer);
int i;
put_v(tmp, info->stream_id_plus1);
@@ -231,7 +231,7 @@ static void put_info(nut_context_t * nut
put_v(tmp, info->count);
for(i = 0; i < info->count; i++){
- nut_info_field_t * field = &info->fields[i];
+ nut_info_field_tt * field = &info->fields[i];
put_vb(tmp, strlen(field->name), field->name);
if (!strcmp(field->type, "v")) {
put_s(tmp, field->val);
@@ -260,7 +260,7 @@ static void put_info(nut_context_t * nut
put_header(nut->o, tmp, nut->tmp_buffer2, INFO_STARTCODE, 0);
}
-static void put_headers(nut_context_t * nut) {
+static void put_headers(nut_context_tt * nut) {
int i;
nut->last_headers = bctello(nut->o);
nut->headers_written++;
@@ -270,14 +270,14 @@ static void put_headers(nut_context_t *
for (i = 0; i < nut->info_count; i++) put_info(nut, &nut->info[i]);
}
-static void put_syncpoint(nut_context_t * nut) {
- output_buffer_t * tmp = clear_buffer(nut->tmp_buffer);
+static void put_syncpoint(nut_context_tt * nut) {
+ output_buffer_tt * tmp = clear_buffer(nut->tmp_buffer);
int i;
uint64_t pts = 0;
int timebase = 0;
int back_ptr = 0;
int keys[nut->stream_count];
- syncpoint_list_t * s = &nut->syncpoints;
+ syncpoint_list_tt * s = &nut->syncpoints;
nut->last_syncpoint = bctello(nut->o);
@@ -290,7 +290,7 @@ static void put_syncpoint(nut_context_t
if (s->alloc_len <= s->len) {
s->alloc_len += PREALLOC_SIZE;
- s->s = nut->alloc->realloc(s->s, s->alloc_len * sizeof(syncpoint_t));
+ s->s = nut->alloc->realloc(s->s, s->alloc_len * sizeof(syncpoint_tt));
s->pts = nut->alloc->realloc(s->pts, s->alloc_len * nut->stream_count * sizeof(uint64_t));
s->eor = nut->alloc->realloc(s->eor, s->alloc_len * nut->stream_count * sizeof(uint64_t));
}
@@ -317,7 +317,7 @@ static void put_syncpoint(nut_context_t
back_ptr = (nut->last_syncpoint - s->s[i].pos) / 16;
if (!nut->mopts.write_index) { // clear some syncpoint cache if possible
s->len -= i;
- memmove(s->s, s->s + i, s->len * sizeof(syncpoint_t));
+ memmove(s->s, s->s + i, s->len * sizeof(syncpoint_tt));
memmove(s->pts, s->pts + i * nut->stream_count, s->len * nut->stream_count * sizeof(uint64_t));
memmove(s->eor, s->eor + i * nut->stream_count, s->len * nut->stream_count * sizeof(uint64_t));
}
@@ -336,9 +336,9 @@ static void put_syncpoint(nut_context_t
nut->sync_overhead += bctello(tmp) + bctello(nut->tmp_buffer2);
}
-static void put_index(nut_context_t * nut) {
- output_buffer_t * tmp = clear_buffer(nut->tmp_buffer);
- syncpoint_list_t * s = &nut->syncpoints;
+static void put_index(nut_context_tt * nut) {
+ output_buffer_tt * tmp = clear_buffer(nut->tmp_buffer);
+ syncpoint_list_tt * s = &nut->syncpoints;
int i;
uint64_t max_pts = 0;
int timebase = 0;
@@ -403,8 +403,8 @@ static void put_index(nut_context_t * nu
put_header(nut->o, tmp, nut->tmp_buffer2, INDEX_STARTCODE, 1);
}
-static int frame_header(nut_context_t * nut, output_buffer_t * tmp, const nut_packet_t * fd) {
- stream_context_t * sc = &nut->sc[fd->stream];
+static int frame_header(nut_context_tt * nut, output_buffer_tt * tmp, const nut_packet_tt * fd) {
+ stream_context_tt * sc = &nut->sc[fd->stream];
int i, ftnum = -1, size = 0, coded_pts, coded_flags = 0, msb_pts = (1 << sc->msb_pts_shift);
int checksum = 0, pts_delta = (int64_t)fd->pts - (int64_t)sc->last_pts;
@@ -455,17 +455,17 @@ static int frame_header(nut_context_t *
return size;
}
-static int add_timebase(nut_context_t * nut, nut_timebase_t tb) {
+static int add_timebase(nut_context_tt * nut, nut_timebase_tt tb) {
int i;
for (i = 0; i < nut->timebase_count; i++) if (compare_ts(1, nut->tb[i], 1, tb) == 0) break;
if (i == nut->timebase_count) {
- nut->tb = nut->alloc->realloc(nut->tb, sizeof(nut_timebase_t) * ++nut->timebase_count);
+ nut->tb = nut->alloc->realloc(nut->tb, sizeof(nut_timebase_tt) * ++nut->timebase_count);
nut->tb[i] = tb;
}
return i;
}
-static void check_header_repetition(nut_context_t * nut) {
+static void check_header_repetition(nut_context_tt * nut) {
if (nut->mopts.realtime_stream) return;
if (bctello(nut->o) >= (1 << 23)) {
int i; // ### magic value for header repetition
@@ -477,9 +477,9 @@ static void check_header_repetition(nut_
}
}
-void nut_write_frame(nut_context_t * nut, const nut_packet_t * fd, const uint8_t * buf) {
- stream_context_t * sc = &nut->sc[fd->stream];
- output_buffer_t * tmp;
+void nut_write_frame(nut_context_tt * nut, const nut_packet_tt * fd, const uint8_t * buf) {
+ stream_context_tt * sc = &nut->sc[fd->stream];
+ output_buffer_tt * tmp;
int i;
check_header_repetition(nut);
@@ -515,7 +515,7 @@ void nut_write_frame(nut_context_t * nut
if (nut->mopts.realtime_stream) flush_buf(nut->o);
}
-void nut_write_info(nut_context_t * nut, const nut_info_packet_t * info) {
+void nut_write_info(nut_context_tt * nut, const nut_info_packet_tt * info) {
if (!nut->mopts.realtime_stream) return;
nut->last_headers = bctello(nut->o); // to force syncpoint writing after the info header
@@ -523,14 +523,14 @@ void nut_write_info(nut_context_t * nut,
if (nut->mopts.realtime_stream) flush_buf(nut->o);
}
-nut_context_t * nut_muxer_init(const nut_muxer_opts_t * mopts, const nut_stream_header_t s[], const nut_info_packet_t info[]) {
- nut_context_t * nut;
- nut_frame_table_input_t * fti = mopts->fti, mfti[256];
+nut_context_tt * nut_muxer_init(const nut_muxer_opts_tt * mopts, const nut_stream_header_tt s[], const nut_info_packet_tt info[]) {
+ nut_context_tt * nut;
+ nut_frame_table_input_tt * fti = mopts->fti, mfti[256];
int i, n;
// TODO check that all input is valid
- if (mopts->alloc.malloc) nut = mopts->alloc.malloc(sizeof(nut_context_t));
- else nut = malloc(sizeof(nut_context_t));
+ if (mopts->alloc.malloc) nut = mopts->alloc.malloc(sizeof(nut_context_tt));
+ else nut = malloc(sizeof(nut_context_tt));
nut->mopts = *mopts;
if (nut->mopts.realtime_stream) nut->mopts.write_index = 0;
@@ -590,7 +590,7 @@ nut_context_t * nut_muxer_init(const nut
for (nut->stream_count = 0; s[nut->stream_count].type >= 0; nut->stream_count++);
- nut->sc = nut->alloc->malloc(sizeof(stream_context_t) * nut->stream_count);
+ nut->sc = nut->alloc->malloc(sizeof(stream_context_tt) * nut->stream_count);
nut->tb = NULL;
nut->timebase_count = 0;
@@ -631,12 +631,12 @@ nut_context_t * nut_muxer_init(const nut
if (info) {
for (nut->info_count = 0; info[nut->info_count].count >= 0; nut->info_count++);
- nut->info = nut->alloc->malloc(sizeof(nut_info_packet_t) * nut->info_count);
+ nut->info = nut->alloc->malloc(sizeof(nut_info_packet_tt) * nut->info_count);
for (i = 0; i < nut->info_count; i++) {
int j;
nut->info[i] = info[i];
- nut->info[i].fields = nut->alloc->malloc(sizeof(nut_info_field_t) * info[i].count);
+ nut->info[i].fields = nut->alloc->malloc(sizeof(nut_info_field_tt) * info[i].count);
add_timebase(nut, nut->info[i].chapter_tb);
for (j = 0; j < info[i].count; j++) {
nut->info[i].fields[j] = info[i].fields[j];
@@ -667,7 +667,7 @@ nut_context_t * nut_muxer_init(const nut
return nut;
}
-void nut_muxer_uninit(nut_context_t * nut) {
+void nut_muxer_uninit(nut_context_tt * nut) {
int i;
int total = 0;
if (!nut) return;
Modified: src/trunk/libnut/priv.h
==============================================================================
--- src/trunk/libnut/priv.h (original)
+++ src/trunk/libnut/priv.h Thu Dec 11 21:34:43 2008
@@ -45,7 +45,7 @@
#define ABS(a) ((a) > 0 ? (a) : -(a))
typedef struct {
- nut_input_stream_t isc;
+ nut_input_stream_tt isc;
int is_mem;
uint8_t * buf;
uint8_t * buf_ptr;
@@ -53,18 +53,18 @@ typedef struct {
int read_len; // data in memory
off_t file_pos;
off_t filesize;
- nut_alloc_t * alloc;
-} input_buffer_t;
+ nut_alloc_tt * alloc;
+} input_buffer_tt;
typedef struct {
- nut_output_stream_t osc;
+ nut_output_stream_tt osc;
int is_mem;
uint8_t * buf;
uint8_t * buf_ptr;
int write_len; // allocated memory
off_t file_pos;
- nut_alloc_t * alloc;
-} output_buffer_t;
+ nut_alloc_tt * alloc;
+} output_buffer_tt;
typedef struct {
uint16_t flags;
@@ -73,7 +73,7 @@ typedef struct {
int16_t pts_delta;
uint8_t reserved;
uint8_t stream;
-} frame_table_t;
+} frame_table_tt;
typedef struct {
off_t pos;
@@ -81,30 +81,30 @@ typedef struct {
int back_ptr:30;
unsigned int seen_next:1;
unsigned int pts_valid:1;
-} syncpoint_t;
+} syncpoint_tt;
-typedef struct syncpoint_linked_s syncpoint_linked_t;
+typedef struct syncpoint_linked_s syncpoint_linked_tt;
struct syncpoint_linked_s {
- syncpoint_linked_t * prev;
- syncpoint_t s;
+ syncpoint_linked_tt * prev;
+ syncpoint_tt s;
uint64_t pts_eor[1];
};
typedef struct {
int len;
int alloc_len;
- syncpoint_t * s;
+ syncpoint_tt * s;
uint64_t * pts; // each elem is stream_count items, +1 to real pts, 0 means there is no key
uint64_t * eor; // same as pts, is the pts of last eor in syncpoint region _IF_ eor is set by syncpoint.
int cached_pos;
- syncpoint_linked_t * linked; // entries are entered in reverse order for speed, points to END of list
-} syncpoint_list_t;
+ syncpoint_linked_tt * linked; // entries are entered in reverse order for speed, points to END of list
+} syncpoint_list_tt;
typedef struct {
- nut_packet_t p;
+ nut_packet_tt p;
uint8_t * buf;
int64_t dts;
-} reorder_packet_t;
+} reorder_packet_tt;
typedef struct {
int active;
@@ -112,7 +112,7 @@ typedef struct {
uint64_t old_last_pts;
off_t good_key;
int pts_higher; // for active streams
-} seek_state_t;
+} seek_state_tt;
typedef struct {
uint64_t last_key; // muxer.c, reset to 0 on every keyframe
@@ -121,41 +121,41 @@ typedef struct {
int msb_pts_shift;
int max_pts_distance;
int timebase_id;
- nut_stream_header_t sh;
+ nut_stream_header_tt sh;
int64_t * pts_cache;
int64_t eor;
- seek_state_t state;
+ seek_state_tt state;
// reorder.c
int64_t next_pts;
- reorder_packet_t * packets;
+ reorder_packet_tt * packets;
int num_packets;
int64_t * reorder_pts_cache;
// debug stuff
int overhead;
int tot_size;
int total_frames;
-} stream_context_t;
+} stream_context_tt;
struct nut_context_s {
- nut_muxer_opts_t mopts;
- nut_demuxer_opts_t dopts;
- nut_alloc_t * alloc;
- input_buffer_t * i;
- output_buffer_t * o;
- output_buffer_t * tmp_buffer;
- output_buffer_t * tmp_buffer2;
+ nut_muxer_opts_tt mopts;
+ nut_demuxer_opts_tt dopts;
+ nut_alloc_tt * alloc;
+ input_buffer_tt * i;
+ output_buffer_tt * o;
+ output_buffer_tt * tmp_buffer;
+ output_buffer_tt * tmp_buffer2;
int timebase_count;
- nut_timebase_t * tb;
+ nut_timebase_tt * tb;
int stream_count;
- stream_context_t * sc;
+ stream_context_tt * sc;
int info_count;
- nut_info_packet_t * info;
+ nut_info_packet_tt * info;
int max_distance;
- frame_table_t ft[256];
+ frame_table_tt ft[256];
off_t last_syncpoint; // for checking corruption and putting syncpoints, also for back_ptr
off_t last_headers; // for header repetition and state for demuxer
@@ -166,7 +166,7 @@ struct nut_context_s {
off_t binary_guess;
double seek_time_pos;
- syncpoint_list_t syncpoints;
+ syncpoint_list_tt syncpoints;
struct find_syncpoint_state_s {
int i, begin, seeked;
off_t pos;
@@ -192,7 +192,7 @@ static inline uint32_t crc32(uint8_t * b
return crc;
}
-static inline uint64_t convert_ts(uint64_t sn, nut_timebase_t from, nut_timebase_t to) {
+static inline uint64_t convert_ts(uint64_t sn, nut_timebase_tt from, nut_timebase_tt to) {
uint64_t ln, d1, d2;
ln = (uint64_t)from.num * to.den;
d1 = from.den;
@@ -200,7 +200,7 @@ static inline uint64_t convert_ts(uint64
return (ln / d1 * sn + (ln%d1) * sn / d1) / d2;
}
-static inline int compare_ts(uint64_t a, nut_timebase_t at, uint64_t b, nut_timebase_t bt) {
+static inline int compare_ts(uint64_t a, nut_timebase_tt at, uint64_t b, nut_timebase_tt bt) {
if (convert_ts(a, at, bt) < b) return -1;
if (convert_ts(b, bt, at) < a) return 1;
return 0;
@@ -234,7 +234,7 @@ static inline int gcd(int a, int b) {
#define bctello(bc) ((bc)->file_pos + ((bc)->buf_ptr - (bc)->buf))
#define TO_PTS(prefix, pts) \
- int prefix##_t = (pts) % nut->timebase_count; \
+ int prefix##_tb = (pts) % nut->timebase_count; \
uint64_t prefix##_p = (pts) / nut->timebase_count;
#define TO_DOUBLE(t, pts) ((double)(pts) / nut->tb[t].den * nut->tb[t].num)
Modified: src/trunk/libnut/reorder.c
==============================================================================
--- src/trunk/libnut/reorder.c (original)
+++ src/trunk/libnut/reorder.c Thu Dec 11 21:34:43 2008
@@ -7,7 +7,7 @@
#include "libnut.h"
#include "priv.h"
-static void shift_frames(nut_context_t * nut, stream_context_t * s, int amount) {
+static void shift_frames(nut_context_tt * nut, stream_context_tt * s, int amount) {
int i;
assert(amount <= s->num_packets);
for (i = 0; i < amount; i++) {
@@ -17,11 +17,11 @@ static void shift_frames(nut_context_t *
if (s->next_pts != -2) s->next_pts = s->packets[i - 1].p.next_pts;
s->num_packets -= amount;
- memmove(s->packets, s->packets + amount, s->num_packets * sizeof(reorder_packet_t));
- s->packets = nut->alloc->realloc(s->packets, s->num_packets * sizeof(reorder_packet_t));
+ memmove(s->packets, s->packets + amount, s->num_packets * sizeof(reorder_packet_tt));
+ s->packets = nut->alloc->realloc(s->packets, s->num_packets * sizeof(reorder_packet_tt));
}
-static void flushcheck_frames(nut_context_t * nut) {
+static void flushcheck_frames(nut_context_tt * nut) {
int change, i;
for (i = 0; i < nut->stream_count; i++) {
// check if any streams are missing essential info
@@ -58,7 +58,7 @@ static void flushcheck_frames(nut_contex
} while (change);
}
-void nut_muxer_uninit_reorder(nut_context_t * nut) {
+void nut_muxer_uninit_reorder(nut_context_tt * nut) {
int i;
if (!nut) return;
@@ -73,15 +73,15 @@ void nut_muxer_uninit_reorder(nut_contex
nut_muxer_uninit(nut);
}
-void nut_write_frame_reorder(nut_context_t * nut, const nut_packet_t * p, const uint8_t * buf) {
- stream_context_t * s = &nut->sc[p->stream];
+void nut_write_frame_reorder(nut_context_tt * nut, const nut_packet_tt * p, const uint8_t * buf) {
+ stream_context_tt * s = &nut->sc[p->stream];
if (nut->stream_count < 2) { // do nothing
nut_write_frame(nut, p, buf);
return;
}
s->num_packets++;
- s->packets = nut->alloc->realloc(s->packets, s->num_packets * sizeof(reorder_packet_t));
+ s->packets = nut->alloc->realloc(s->packets, s->num_packets * sizeof(reorder_packet_tt));
s->packets[s->num_packets - 1].p = *p;
s->packets[s->num_packets - 1].dts = get_dts(s->sh.decode_delay, s->reorder_pts_cache, p->pts);
Modified: src/trunk/nututils/demux_avi.c
==============================================================================
--- src/trunk/nututils/demux_avi.c (original)
+++ src/trunk/nututils/demux_avi.c Thu Dec 11 21:34:43 2008
@@ -18,12 +18,12 @@ typedef struct riff_tree_s {
struct riff_tree_s * tree; // this is an array (size is 'amount')
char * data;
int offset;
-} riff_tree_t;
+} riff_tree_tt;
typedef struct {
int amount;
- riff_tree_t * tree;
-} full_riff_tree_t;
+ riff_tree_tt * tree;
+} full_riff_tree_tt;
typedef struct {
uint8_t wFormatTag[2];
@@ -33,7 +33,7 @@ typedef struct {
uint16_t nBlockAlign;
uint16_t wBitsPerSample;
uint16_t cbSize;
-} audio_header_t;
+} audio_header_tt;
typedef struct {
uint32_t biSize;
@@ -47,7 +47,7 @@ typedef struct {
uint32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
-} video_header_t;
+} video_header_tt;
typedef struct {
uint32_t dwMicroSecPerFrame;
@@ -64,7 +64,7 @@ typedef struct {
uint32_t dwRate;
uint32_t dwStart;
uint32_t dwLength;
-} avi_header_t;
+} avi_header_tt;
typedef struct {
uint8_t fccType[4];
@@ -80,32 +80,32 @@ typedef struct {
uint32_t dwQuality;
uint32_t dwSampleSize;
uint16_t rcframe[4];
-} avi_stream_header_t;
+} avi_stream_header_tt;
typedef struct {
uint8_t ckid[4];
uint32_t dwFlags;
uint32_t dwChunkOffset;
uint32_t dwChunkLength;
-} avi_index_entry_t;
+} avi_index_entry_tt;
typedef struct {
int type; // 0 video, 1 audio
- avi_stream_header_t * strh;
- video_header_t * video;
- audio_header_t * audio;
+ avi_stream_header_tt * strh;
+ video_header_tt * video;
+ audio_header_tt * audio;
int extra_len;
int last_pts;
uint8_t * extra;
-} avi_stream_context_t;
+} avi_stream_context_tt;
struct demuxer_priv_s {
FILE * in;
- full_riff_tree_t * riff;
- stream_t * s;
- avi_header_t * avih;
- avi_stream_context_t * stream; // this is an array, free this
- avi_index_entry_t * index; // this is an array and data
+ full_riff_tree_tt * riff;
+ stream_tt * s;
+ avi_header_tt * avih;
+ avi_stream_context_tt * stream; // this is an array, free this
+ avi_index_entry_tt * index; // this is an array and data
int packets;
int cur;
};
@@ -114,7 +114,7 @@ struct demuxer_priv_s {
#define READ_16(out, ptr) do { out = ((uint8_t*)ptr)[0] | (((uint8_t*)ptr)[1] << 8); ptr += 2; } while (0)
#define READ_32(out, ptr) do { out = ((uint8_t*)ptr)[0] | (((uint8_t*)ptr)[1] << 8) | (((uint8_t*)ptr)[2] << 16) | (((uint8_t*)ptr)[3] << 24); ptr += 4; } while (0)
-static void data_to_audio_header(void * data, audio_header_t * out) {
+static void data_to_audio_header(void * data, audio_header_tt * out) {
uint8_t * p = data;
READ_B(out->wFormatTag, p, 2);
READ_16(out->nChannels, p);
@@ -125,7 +125,7 @@ static void data_to_audio_header(void *
READ_16(out->cbSize, p);
}
-static void data_to_video_header(void * data, video_header_t * out) {
+static void data_to_video_header(void * data, video_header_tt * out) {
uint8_t * p = data;
READ_32(out->biSize, p);
READ_32(out->biWidth, p);
@@ -140,7 +140,7 @@ static void data_to_video_header(void *
READ_32(out->biClrImportant, p);
}
-static void data_to_avi_header(void * data, avi_header_t * out) {
+static void data_to_avi_header(void * data, avi_header_tt * out) {
uint8_t * p = data;
READ_32(out->dwMicroSecPerFrame, p);
READ_32(out->dwMaxBytesPerSec, p);
@@ -158,7 +158,7 @@ static void data_to_avi_header(void * da
READ_32(out->dwLength, p);
}
-static void data_to_stream_header(void * data, avi_stream_header_t * out) {
+static void data_to_stream_header(void * data, avi_stream_header_tt * out) {
uint8_t * p = data;
READ_B(out->fccType, p, 4);
READ_B(out->fccHandler, p, 4);
@@ -178,7 +178,7 @@ static void data_to_stream_header(void *
READ_16(out->rcframe[3], p);
}
-static void data_to_index_entry(void * data, avi_index_entry_t * out) {
+static void data_to_index_entry(void * data, avi_index_entry_tt * out) {
uint8_t * p = data;
READ_B(out->ckid, p, 4);
READ_32(out->dwFlags, p);
@@ -186,7 +186,7 @@ static void data_to_index_entry(void * d
READ_32(out->dwChunkLength, p);
}
-static int mk_riff_tree(FILE * in, riff_tree_t * tree) {
+static int mk_riff_tree(FILE * in, riff_tree_tt * tree) {
char lenc[4], * p = lenc;
int left;
tree->tree = NULL;
@@ -210,7 +210,7 @@ static int mk_riff_tree(FILE * in, riff_
while (left > 0) {
int err;
tree->tree =
- realloc(tree->tree, sizeof(riff_tree_t) * (tree->amount+1));
+ realloc(tree->tree, sizeof(riff_tree_tt) * (tree->amount+1));
if ((err = mk_riff_tree(in, &tree->tree[tree->amount])))
return err;
left -= (tree->tree[tree->amount].len + 8);
@@ -227,7 +227,7 @@ static int mk_riff_tree(FILE * in, riff_
return 0;
}
-static void free_riff_tree(riff_tree_t * tree) {
+static void free_riff_tree(riff_tree_tt * tree) {
int i;
if (!tree) return;
@@ -238,27 +238,27 @@ static void free_riff_tree(riff_tree_t *
free(tree->data); tree->data = NULL;
}
-static full_riff_tree_t * init_riff() {
- full_riff_tree_t * full = malloc(sizeof(full_riff_tree_t));
+static full_riff_tree_tt * init_riff() {
+ full_riff_tree_tt * full = malloc(sizeof(full_riff_tree_tt));
full->amount = 0;
full->tree = NULL;
return full;
}
-static int get_full_riff_tree(FILE * in, full_riff_tree_t * full) {
+static int get_full_riff_tree(FILE * in, full_riff_tree_tt * full) {
int err = 0;
while (1) {
int c;
if ((c = fgetc(in)) == EOF) break; ungetc(c, in);
- full->tree = realloc(full->tree, sizeof(riff_tree_t) * ++full->amount);
+ full->tree = realloc(full->tree, sizeof(riff_tree_tt) * ++full->amount);
if ((err = mk_riff_tree(in, &full->tree[full->amount - 1]))) goto err_out;
}
err_out:
return err;
}
-static void uninit_riff(full_riff_tree_t * full) {
+static void uninit_riff(full_riff_tree_tt * full) {
int i;
if (!full) return;
for (i = 0; i < full->amount; i++) free_riff_tree(&full->tree[i]);
@@ -266,7 +266,7 @@ static void uninit_riff(full_riff_tree_t
free(full);
}
-static int avi_read_stream_header(avi_stream_context_t * stream, riff_tree_t * tree) {
+static int avi_read_stream_header(avi_stream_context_tt * stream, riff_tree_tt * tree) {
int i;
assert(tree->type == 0);
assert(strFOURCC(tree->listname) == mmioFOURCC('s','t','r','l'));
@@ -274,7 +274,7 @@ static int avi_read_stream_header(avi_st
for (i = 0; i < tree->amount; i++) {
if (tree->tree[i].type == 1 && !strncmp(tree->tree[i].name, "strh", 4)) {
if (tree->tree[i].len != 56) return err_avi_bad_strh_len;
- stream->strh = malloc(sizeof(avi_stream_header_t));
+ stream->strh = malloc(sizeof(avi_stream_header_tt));
data_to_stream_header(tree->tree[i].data, stream->strh);
break;
}
@@ -288,7 +288,7 @@ static int avi_read_stream_header(avi_st
case mmioFOURCC('v','i','d','s'):
if (len < 40) return err_avi_bad_vids_len;
stream->type = 0;
- stream->video = malloc(sizeof(video_header_t));
+ stream->video = malloc(sizeof(video_header_tt));
data_to_video_header(tree->tree[i].data, stream->video);
stream->extra_len = len - 40;
if (len > 40) stream->extra = (uint8_t*)tree->tree[i].data + 40;
@@ -296,7 +296,7 @@ static int avi_read_stream_header(avi_st
case mmioFOURCC('a','u','d','s'):
if (len < 18) return err_avi_bad_auds_len;
stream->type = 1;
- stream->audio = malloc(sizeof(audio_header_t));
+ stream->audio = malloc(sizeof(audio_header_tt));
data_to_audio_header(tree->tree[i].data, stream->audio);
stream->extra_len = len - 18;
if (len > 18) stream->extra = (uint8_t*)tree->tree[i].data + 18;
@@ -312,7 +312,7 @@ static int avi_read_stream_header(avi_st
return 0;
}
-static int avi_read_main_header(demuxer_priv_t * avi, const riff_tree_t * tree) {
+static int avi_read_main_header(demuxer_priv_tt * avi, const riff_tree_tt * tree) {
int i, tmp = 0, err;
assert(tree->type == 0);
assert(strFOURCC(tree->listname) == mmioFOURCC('h','d','r','l'));
@@ -320,7 +320,7 @@ static int avi_read_main_header(demuxer_
for (i = 0; i < tree->amount; i++) {
if (tree->tree[i].type == 1 && !strncmp(tree->tree[i].name, "avih", 4)) {
if (tree->tree[i].len != 56) return err_avi_bad_avih_len;
- avi->avih = malloc(sizeof(avi_header_t));
+ avi->avih = malloc(sizeof(avi_header_tt));
data_to_avi_header(tree->tree[i].data, avi->avih);
break;
}
@@ -328,7 +328,7 @@ static int avi_read_main_header(demuxer_
if (i == tree->amount) return err_avi_no_avih;
if (avi->avih->dwStreams > 200) return err_avi_stream_overflow;
- avi->stream = malloc(avi->avih->dwStreams * sizeof(avi_stream_context_t));
+ avi->stream = malloc(avi->avih->dwStreams * sizeof(avi_stream_context_tt));
for (i = 0; i < avi->avih->dwStreams; i++) {
avi->stream[i].video = NULL;
avi->stream[i].audio = NULL;
@@ -345,8 +345,8 @@ static int avi_read_main_header(demuxer_
return 0;
}
-static int avi_read_headers(demuxer_priv_t * avi) {
- const riff_tree_t * tree;
+static int avi_read_headers(demuxer_priv_tt * avi) {
+ const riff_tree_tt * tree;
int i, err;
if ((err = get_full_riff_tree(avi->in, avi->riff))) return err;
tree = &avi->riff->tree[0];
@@ -366,7 +366,7 @@ static int avi_read_headers(demuxer_priv
for (j = 0; j < tree->amount; j++) {
if (tree->tree[j].type == 1 && !strncmp(tree->tree[j].name, "idx1", 4)) {
avi->packets = tree->tree[j].len / 16;
- avi->index = calloc(avi->packets, sizeof(avi_index_entry_t));
+ avi->index = calloc(avi->packets, sizeof(avi_index_entry_tt));
for (ii = 0; ii < avi->packets; ii++) {
data_to_index_entry((char*)tree->tree[j].data + 16*ii, avi->index + ii);
}
@@ -386,7 +386,7 @@ static int avi_read_headers(demuxer_priv
return 0;
}
-static int read_headers(demuxer_priv_t * avi, stream_t ** streams) {
+static int read_headers(demuxer_priv_tt * avi, stream_tt ** streams) {
int i;
if ((i = avi_read_headers(avi))) return i;
for (i = 0; i < avi->avih->dwStreams; i++) {
@@ -408,9 +408,9 @@ static int read_headers(demuxer_priv_t *
}
}
- *streams = avi->s = malloc(sizeof(stream_t) * (avi->avih->dwStreams + 1));
+ *streams = avi->s = malloc(sizeof(stream_tt) * (avi->avih->dwStreams + 1));
for (i = 0; i < avi->avih->dwStreams; i++) {
- extern demuxer_t avi_demuxer;
+ extern demuxer_tt avi_demuxer;
avi->s[i].stream_id = i;
avi->s[i].demuxer = avi_demuxer;
avi->s[i].demuxer.priv = avi;
@@ -451,10 +451,10 @@ static int read_headers(demuxer_priv_t *
return 0;
}
-static int fill_buffer(demuxer_priv_t * avi) {
+static int fill_buffer(demuxer_priv_tt * avi) {
char fourcc[4], lenc[4], * plen = lenc;
int len;
- packet_t p;
+ packet_tt p;
if (ftell(avi->in) & 1) fgetc(avi->in);
if (avi->cur >= avi->packets) return -1;
@@ -487,8 +487,8 @@ static int fill_buffer(demuxer_priv_t *
return 0;
}
-static demuxer_priv_t * init(FILE * in) {
- demuxer_priv_t * avi = malloc(sizeof(demuxer_priv_t));
+static demuxer_priv_tt * init(FILE * in) {
+ demuxer_priv_tt * avi = malloc(sizeof(demuxer_priv_tt));
avi->avih = NULL;
avi->stream = NULL;
avi->index = NULL;
@@ -499,7 +499,7 @@ static demuxer_priv_t * init(FILE * in)
return avi;
}
-static void uninit(demuxer_priv_t * avi) {
+static void uninit(demuxer_priv_tt * avi) {
int i, streams = avi->avih ? avi->avih->dwStreams : 0;
uninit_riff(avi->riff);
if (avi->stream) for (i = 0; i < streams; i++) {
@@ -515,7 +515,7 @@ static void uninit(demuxer_priv_t * avi)
free(avi);
}
-demuxer_t avi_demuxer = {
+demuxer_tt avi_demuxer = {
"avi",
init,
read_headers,
Modified: src/trunk/nututils/demux_ogg.c
==============================================================================
--- src/trunk/nututils/demux_ogg.c (original)
+++ src/trunk/nututils/demux_ogg.c Thu Dec 11 21:34:43 2008
@@ -8,7 +8,7 @@
#include "nutmerge.h"
#define FREAD(file, len, var) do { if (fread((var), 1, (len), (file)) != (len)) return -1; }while(0)
-typedef struct ogg_stream_s ogg_stream_t;
+typedef struct ogg_stream_s ogg_stream_tt;
struct ogg_stream_s {
int serial;
@@ -18,8 +18,8 @@ struct ogg_stream_s {
struct demuxer_priv_s {
FILE * in;
- ogg_stream_t * os;
- stream_t * s;
+ ogg_stream_tt * os;
+ stream_tt * s;
int nstreams;
int stream_count; // when nutmerge_streams was handed to the API ...
};
@@ -29,14 +29,14 @@ static struct { enum nutmerge_codecs id;
{ 0, NULL, 0 }
};
-static int find_stream(demuxer_priv_t * ogg, int serial) {
- extern demuxer_t ogg_demuxer;
+static int find_stream(demuxer_priv_tt * ogg, int serial) {
+ extern demuxer_tt ogg_demuxer;
int i;
for (i = 0; i < ogg->nstreams; i++) {
if (ogg->os[i].serial == serial) return i;
}
- ogg->os = realloc(ogg->os, sizeof(ogg_stream_t) * ++ogg->nstreams);
- ogg->s = realloc(ogg->s, sizeof(stream_t) * (ogg->nstreams+1));
+ ogg->os = realloc(ogg->os, sizeof(ogg_stream_tt) * ++ogg->nstreams);
+ ogg->s = realloc(ogg->s, sizeof(stream_tt) * (ogg->nstreams+1));
ogg->os[i].serial = serial;
ogg->os[i].leftover_buf = NULL;
ogg->os[i].leftover = 0;
@@ -49,8 +49,8 @@ static int find_stream(demuxer_priv_t *
return i;
}
-static int read_page(demuxer_priv_t * ogg, int * stream) {
- ogg_stream_t * os;
+static int read_page(demuxer_priv_tt * ogg, int * stream) {
+ ogg_stream_tt * os;
int i, serial, segments;
char tmp_header[27];
uint8_t sizes[256];
@@ -73,7 +73,7 @@ static int read_page(demuxer_priv_t * og
for (i = 0; i < segments; i++) {
len += sizes[i];
if (sizes[i] != 255) {
- packet_t p;
+ packet_tt p;
p.buf = malloc(len);
p.p.len = len;
p.p.stream = *stream;
@@ -97,7 +97,7 @@ static int read_page(demuxer_priv_t * og
return 0;
}
-static int read_headers(demuxer_priv_t * ogg, stream_t ** streams) {
+static int read_headers(demuxer_priv_tt * ogg, stream_tt ** streams) {
int i;
int err;
@@ -120,7 +120,7 @@ static int read_headers(demuxer_priv_t *
return 0;
}
-static int fill_buffer(demuxer_priv_t * ogg) {
+static int fill_buffer(demuxer_priv_tt * ogg) {
int err, dummy;
if ((err = read_page(ogg, &dummy))) return err;
@@ -129,8 +129,8 @@ static int fill_buffer(demuxer_priv_t *
return 0;
}
-static demuxer_priv_t * init(FILE * in) {
- demuxer_priv_t * ogg = malloc(sizeof(demuxer_priv_t));
+static demuxer_priv_tt * init(FILE * in) {
+ demuxer_priv_tt * ogg = malloc(sizeof(demuxer_priv_tt));
ogg->in = in;
ogg->os = NULL;
ogg->s = NULL;
@@ -138,7 +138,7 @@ static demuxer_priv_t * init(FILE * in)
return ogg;
}
-static void uninit(demuxer_priv_t * ogg) {
+static void uninit(demuxer_priv_tt * ogg) {
int i;
for (i = 0; i < ogg->nstreams; i++) free(ogg->os[i].leftover_buf);
free(ogg->os);
@@ -147,7 +147,7 @@ static void uninit(demuxer_priv_t * ogg)
free(ogg);
}
-demuxer_t ogg_demuxer = {
+demuxer_tt ogg_demuxer = {
"ogg",
init,
read_headers,
Modified: src/trunk/nututils/framer_mp3.c
==============================================================================
--- src/trunk/nututils/framer_mp3.c (original)
+++ src/trunk/nututils/framer_mp3.c Thu Dec 11 21:34:43 2008
@@ -4,10 +4,10 @@
#include "nutmerge.h"
struct framer_priv_s {
- stream_t * stream;
+ stream_tt * stream;
};
-static int get_packet(framer_priv_t * mp, packet_t * p) {
+static int get_packet(framer_priv_tt * mp, packet_tt * p) {
static const int tabsel_123[2][3][16] = {
{ {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,0},
@@ -62,22 +62,22 @@ static int get_packet(framer_priv_t * mp
return 0;
}
-static int setup_headers(framer_priv_t * mp, nut_stream_header_t * s) {
+static int setup_headers(framer_priv_tt * mp, nut_stream_header_tt * s) {
*s = mp->stream->sh;
return 0; // nothing to do
}
-static framer_priv_t * init(stream_t * s) {
- framer_priv_t * mp = malloc(sizeof(framer_priv_t));
+static framer_priv_tt * init(stream_tt * s) {
+ framer_priv_tt * mp = malloc(sizeof(framer_priv_tt));
mp->stream = s;
return mp;
}
-static void uninit(framer_priv_t * mp) {
+static void uninit(framer_priv_tt * mp) {
free(mp);
}
-framer_t mp3_framer = {
+framer_tt mp3_framer = {
e_mp3,
init,
setup_headers,
Modified: src/trunk/nututils/framer_mpeg4.c
==============================================================================
--- src/trunk/nututils/framer_mpeg4.c (original)
+++ src/trunk/nututils/framer_mpeg4.c Thu Dec 11 21:34:43 2008
@@ -4,7 +4,7 @@
#include "nutmerge.h"
struct framer_priv_s {
- stream_t * stream;
+ stream_tt * stream;
int64_t cur_pts;
};
@@ -20,8 +20,8 @@ static int find_frame_type(int len, uint
#define CHECK(x) do{ if ((err = (x))) return err; }while(0)
-static int get_packet(framer_priv_t * mc, packet_t * p) {
- packet_t tmp_p;
+static int get_packet(framer_priv_tt * mc, packet_tt * p) {
+ packet_tt tmp_p;
int n = 0;
int type, err = 0;
@@ -52,23 +52,23 @@ static int get_packet(framer_priv_t * mc
return 0;
}
-static int setup_headers(framer_priv_t * mc, nut_stream_header_t * s) {
+static int setup_headers(framer_priv_tt * mc, nut_stream_header_tt * s) {
*s = mc->stream->sh;
return 0; // nothing to do
}
-static framer_priv_t * init(stream_t * s) {
- framer_priv_t * mc = malloc(sizeof(framer_priv_t));
+static framer_priv_tt * init(stream_tt * s) {
+ framer_priv_tt * mc = malloc(sizeof(framer_priv_tt));
mc->stream = s;
mc->cur_pts = 0;
return mc;
}
-static void uninit(framer_priv_t * mc) {
+static void uninit(framer_priv_tt * mc) {
free(mc);
}
-framer_t mpeg4_framer = {
+framer_tt mpeg4_framer = {
e_mpeg4,
init,
setup_headers,
Modified: src/trunk/nututils/framer_vorbis.c
==============================================================================
--- src/trunk/nututils/framer_vorbis.c (original)
+++ src/trunk/nututils/framer_vorbis.c Thu Dec 11 21:34:43 2008
@@ -6,7 +6,7 @@
struct framer_priv_s {
int blocksize[2];
- stream_t * stream;
+ stream_tt * stream;
int mode_count;
int * modes;
uint8_t * codec_specific;
@@ -31,9 +31,9 @@ typedef struct bit_packer_s {
int pos;
int left;
uint8_t * buf_ptr;
-} bit_packer_t;
+} bit_packer_tt;
-static int get_bits(bit_packer_t * bp, int bits, uint64_t * res) {
+static int get_bits(bit_packer_tt * bp, int bits, uint64_t * res) {
uint64_t val = 0;
int pos = 0;
bp->left -= bits;
@@ -65,13 +65,13 @@ static int get_bits(bit_packer_t * bp, i
#define CHECK(x) do{ if ((err = (x))) goto err_out; }while(0)
-static int setup_headers(framer_priv_t * vc, nut_stream_header_t * s) {
- bit_packer_t bp;
+static int setup_headers(framer_priv_tt * vc, nut_stream_header_tt * s) {
+ bit_packer_tt bp;
uint64_t num;
int i, err = 0, pd_read = 0;
int channels, sample_rate, codec_specific_len;
uint8_t * p;
- packet_t pd[3];
+ packet_tt pd[3];
// need first 3 packets - TODO - support working directly from good codec_specific instead of Ogg crap
CHECK(get_stream_packet(vc->stream, &pd[0])); pd_read++;
@@ -283,8 +283,8 @@ err_out:
return err;
}
-static int get_packet(framer_priv_t * vc, packet_t * p) {
- bit_packer_t bp;
+static int get_packet(framer_priv_tt * vc, packet_tt * p) {
+ bit_packer_tt bp;
uint64_t num;
int64_t last_pts = MAX(vc->pts, 0); // -1 is not valid
int mode, err = 0;
@@ -319,8 +319,8 @@ err_out:
return err == err_vorbis_header ? err_vorbis_packet : err;
}
-static framer_priv_t * init(stream_t * s) {
- framer_priv_t * vc = malloc(sizeof(framer_priv_t));
+static framer_priv_tt * init(stream_tt * s) {
+ framer_priv_tt * vc = malloc(sizeof(framer_priv_tt));
vc->stream = s;
vc->modes = NULL;
vc->codec_specific = NULL;
@@ -328,13 +328,13 @@ static framer_priv_t * init(stream_t * s
return vc;
}
-static void uninit(framer_priv_t * vc) {
+static void uninit(framer_priv_tt * vc) {
free(vc->modes);
free(vc->codec_specific);
free(vc);
}
-framer_t vorbis_framer = {
+framer_tt vorbis_framer = {
e_vorbis,
init,
setup_headers,
Modified: src/trunk/nututils/nutindex.c
==============================================================================
--- src/trunk/nututils/nutindex.c (original)
+++ src/trunk/nututils/nutindex.c Thu Dec 11 21:34:43 2008
@@ -43,15 +43,15 @@ typedef struct {
int write_len; // allocated memory
off_t file_pos;
FILE * out;
-} output_buffer_t;
+} output_buffer_tt;
-static void flush_out_buf(output_buffer_t * bc) {
+static void flush_out_buf(output_buffer_tt * bc) {
assert(!bc->is_mem);
bc->file_pos += fwrite(bc->buf, 1, bc->buf_ptr - bc->buf, bc->out);
bc->buf_ptr = bc->buf;
}
-static void ready_write_buf(output_buffer_t * bc, int amount) {
+static void ready_write_buf(output_buffer_tt * bc, int amount) {
if (bc->write_len - (bc->buf_ptr - bc->buf) > amount) return;
if (bc->is_mem) {
@@ -69,14 +69,14 @@ static void ready_write_buf(output_buffe
}
}
-static void put_bytes(output_buffer_t * bc, int count, uint64_t val) {
+static void put_bytes(output_buffer_tt * bc, int count, uint64_t val) {
ready_write_buf(bc, count);
for(count--; count >= 0; count--){
*(bc->buf_ptr++) = val >> (8 * count);
}
}
-static output_buffer_t * new_mem_buffer(output_buffer_t * bc) {
+static output_buffer_tt * new_mem_buffer(output_buffer_tt * bc) {
bc->write_len = 0;
bc->is_mem = 1;
bc->file_pos = 0;
@@ -84,7 +84,7 @@ static output_buffer_t * new_mem_buffer(
return bc;
}
-static output_buffer_t * new_output_buffer(output_buffer_t * bc, FILE * out) {
+static output_buffer_tt * new_output_buffer(output_buffer_tt * bc, FILE * out) {
new_mem_buffer(bc);
bc->is_mem = 0;
bc->out = out;
@@ -98,7 +98,7 @@ static int v_len(uint64_t val) {
return i;
}
-static void put_v(output_buffer_t * bc, uint64_t val) {
+static void put_v(output_buffer_tt * bc, uint64_t val) {
int i = v_len(val);
ready_write_buf(bc, i);
for(i = (i-1)*7; i; i-=7) {
@@ -107,7 +107,7 @@ static void put_v(output_buffer_t * bc,
*(bc->buf_ptr++)= val & 0x7F;
}
-static void put_data(output_buffer_t * bc, int len, const uint8_t * data) {
+static void put_data(output_buffer_tt * bc, int len, const uint8_t * data) {
if (len + (bc->buf_ptr - bc->buf) < bc->write_len || bc->is_mem) {
ready_write_buf(bc, len);
memcpy(bc->buf_ptr, data, len);
@@ -118,7 +118,7 @@ static void put_data(output_buffer_t * b
}
}
-static void free_out_buffer(output_buffer_t * bc) {
+static void free_out_buffer(output_buffer_tt * bc) {
if (!bc) return;
if (!bc->is_mem) flush_out_buf(bc);
free(bc->buf);
@@ -134,16 +134,16 @@ typedef struct {
int read_len; // data in memory
off_t file_pos;
off_t filesize;
-} input_buffer_t;
+} input_buffer_tt;
-static void flush_buf(input_buffer_t *bc) {
+static void flush_buf(input_buffer_tt *bc) {
bc->file_pos += bc->buf_ptr - bc->buf;
bc->read_len -= bc->buf_ptr - bc->buf;
memmove(bc->buf, bc->buf_ptr, bc->read_len);
bc->buf_ptr = bc->buf;
}
-static int ready_read_buf(input_buffer_t * bc, int amount) {
+static int ready_read_buf(input_buffer_tt * bc, int amount) {
int pos = (bc->buf_ptr - bc->buf);
if (bc->read_len - pos < amount) {
amount += 10;
@@ -157,7 +157,7 @@ static int ready_read_buf(input_buffer_t
return bc->read_len - (bc->buf_ptr - bc->buf);
}
-static void seek_buf(input_buffer_t * bc, long long pos, int whence) {
+static void seek_buf(input_buffer_tt * bc, long long pos, int whence) {
if (whence == SEEK_CUR) pos -= bc->read_len - (bc->buf_ptr - bc->buf);
fseek(bc->in, pos, whence);
bc->file_pos = ftell(bc->in);
@@ -166,7 +166,7 @@ static void seek_buf(input_buffer_t * bc
if (whence == SEEK_END) bc->filesize = bc->file_pos - pos;
}
-static input_buffer_t * new_input_buffer(input_buffer_t * bc, FILE * in) {
+static input_buffer_tt * new_input_buffer(input_buffer_tt * bc, FILE * in) {
bc->read_len = 0;
bc->write_len = 0;
bc->file_pos = 0;
@@ -176,18 +176,18 @@ static input_buffer_t * new_input_buffer
return bc;
}
-static int skip_buffer(input_buffer_t * bc, int len) {
+static int skip_buffer(input_buffer_tt * bc, int len) {
if (ready_read_buf(bc, len) < len) return 1;
bc->buf_ptr += len;
return 0;
}
-static void free_buffer(input_buffer_t * bc) {
+static void free_buffer(input_buffer_tt * bc) {
if (!bc) return;
free(bc->buf);
}
-static int get_bytes(input_buffer_t * bc, int count, uint64_t * val) {
+static int get_bytes(input_buffer_tt * bc, int count, uint64_t * val) {
int i;
if (ready_read_buf(bc, count) < count) return 1;
*val = 0;
@@ -197,7 +197,7 @@ static int get_bytes(input_buffer_t * bc
return 0;
}
-static int get_v(input_buffer_t * bc, uint64_t * val) {
+static int get_v(input_buffer_tt * bc, uint64_t * val) {
int i, len;
*val = 0;
do {
@@ -211,7 +211,7 @@ static int get_v(input_buffer_t * bc, ui
return 1;
}
-static int get_data(input_buffer_t * bc, int len, uint8_t * buf) {
+static int get_data(input_buffer_tt * bc, int len, uint8_t * buf) {
int tmp = MIN(len, bc->read_len - (bc->buf_ptr - bc->buf));
if (tmp) {
memcpy(buf, bc->buf_ptr, tmp);
@@ -230,7 +230,7 @@ static int get_data(input_buffer_t * bc,
#define CHECK(expr) do { int _a; if ((_a = (expr))) return _a; } while(0)
#define GET_V(bc, v) do { uint64_t _tmp; CHECK(get_v((bc), &_tmp)); (v) = _tmp; } while(0)
-static int get_header(input_buffer_t * in) {
+static int get_header(input_buffer_tt * in) {
off_t start = bctello(in) - 8; // startcode
int forward_ptr;
@@ -245,7 +245,7 @@ static int get_header(input_buffer_t * i
return 0;
}
-static int read_headers(input_buffer_t * in) {
+static int read_headers(input_buffer_tt * in) {
int len = strlen(ID_STRING) + 1;
uint64_t tmp;
assert(in->buf == in->buf_ptr);
@@ -262,7 +262,7 @@ static int read_headers(input_buffer_t *
return 0;
}
-static int find_copy_index(input_buffer_t * in, output_buffer_t * out, off_t * end) {
+static int find_copy_index(input_buffer_tt * in, output_buffer_tt * out, off_t * end) {
uint64_t tmp;
uint64_t idx_len;
uint64_t max_pts, syncpoints;
@@ -326,8 +326,8 @@ static int find_copy_index(input_buffer_
int main(int argc, char * argv[]) {
FILE * fin = argc>2 ? fopen(argv[1], "rb") : NULL;
FILE * fout = argc>2 ? fopen(argv[2], "wb") : NULL;
- input_buffer_t iin, * in;
- output_buffer_t oout, * out, omem, * mem = new_mem_buffer(&omem);
+ input_buffer_tt iin, * in;
+ output_buffer_tt oout, * out, omem, * mem = new_mem_buffer(&omem);
off_t end;
if (!fin || !fout) {
fprintf(stderr, "%s <input-nut-file> <output-nut-file>\n", argv[0]);
Modified: src/trunk/nututils/nutmerge.c
==============================================================================
--- src/trunk/nututils/nutmerge.c (original)
+++ src/trunk/nututils/nutmerge.c Thu Dec 11 21:34:43 2008
@@ -6,37 +6,37 @@
FILE * stats = NULL;
-extern demuxer_t avi_demuxer;
-extern demuxer_t nut_demuxer;
-extern demuxer_t ogg_demuxer;
+extern demuxer_tt avi_demuxer;
+extern demuxer_tt nut_demuxer;
+extern demuxer_tt ogg_demuxer;
-demuxer_t * ndemuxers[] = {
+demuxer_tt * ndemuxers[] = {
&avi_demuxer,
//&nut_demuxer,
&ogg_demuxer,
NULL
};
-extern framer_t vorbis_framer;
-extern framer_t mpeg4_framer;
-extern framer_t mp3_framer;
+extern framer_tt vorbis_framer;
+extern framer_tt mpeg4_framer;
+extern framer_tt mp3_framer;
-framer_t * nframers[] = {
+framer_tt * nframers[] = {
&vorbis_framer,
&mpeg4_framer,
&mp3_framer,
NULL
};
-void push_packet(stream_t * stream, packet_t * p) {
+void push_packet(stream_tt * stream, packet_tt * p) {
if (stream->npackets == stream->packets_alloc) {
stream->packets_alloc += 20;
- stream->packets = realloc(stream->packets, stream->packets_alloc * sizeof(packet_t));
+ stream->packets = realloc(stream->packets, stream->packets_alloc * sizeof(packet_tt));
}
stream->packets[stream->npackets++] = *p;
}
-int peek_stream_packet(stream_t * stream, packet_t * p, int n) {
+int peek_stream_packet(stream_tt * stream, packet_tt * p, int n) {
while (stream->npackets <= n) {
int err;
if ((err = stream->demuxer.fill_buffer(stream->demuxer.priv))) return err;
@@ -45,18 +45,18 @@ int peek_stream_packet(stream_t * stream
return 0;
}
-int get_stream_packet(stream_t * stream, packet_t * p) {
+int get_stream_packet(stream_tt * stream, packet_tt * p) {
while (!stream->npackets) {
int err;
if ((err = stream->demuxer.fill_buffer(stream->demuxer.priv))) return err;
}
*p = stream->packets[0];
stream->npackets--;
- memmove(&stream->packets[0], &stream->packets[1], stream->npackets * sizeof(packet_t));
+ memmove(&stream->packets[0], &stream->packets[1], stream->npackets * sizeof(packet_tt));
return 0;
}
-void free_streams(stream_t * streams) {
+void free_streams(stream_tt * streams) {
int i;
if (!streams) return;
for (i = 0; streams[i].stream_id >= 0; i++) {
@@ -66,7 +66,7 @@ void free_streams(stream_t * streams) {
}
}
-static int pick(stream_t * streams, int stream_count) {
+static int pick(stream_tt * streams, int stream_count) {
int i, n = 0;
for (i = 1; i < stream_count; i++) if (streams[i].npackets > streams[n].npackets) n = i;
return n;
@@ -74,13 +74,13 @@ static int pick(stream_t * streams, int
#define fget_packet(framer, p) (framer).get_packet((framer).priv, p)
-static int convert(FILE * out, demuxer_t * demuxer, stream_t * streams, int stream_count) {
- nut_context_t * nut = NULL;
- nut_stream_header_t nut_stream[stream_count+1];
- nut_muxer_opts_t mopts;
- framer_t framers[stream_count];
+static int convert(FILE * out, demuxer_tt * demuxer, stream_tt * streams, int stream_count) {
+ nut_context_tt * nut = NULL;
+ nut_stream_header_tt nut_stream[stream_count+1];
+ nut_muxer_opts_tt mopts;
+ framer_tt framers[stream_count];
int i, err = 0;
- packet_t p;
+ packet_tt p;
int pts[stream_count];
memset(framers, 0, sizeof framers);
@@ -96,7 +96,7 @@ static int convert(FILE * out, demuxer_t
}
nut_stream[i].type = -1;
- mopts.output = (nut_output_stream_t){ .priv = out, .write = NULL };
+ mopts.output = (nut_output_stream_tt){ .priv = out, .write = NULL };
mopts.write_index = 1;
mopts.realtime_stream = 0;
mopts.fti = NULL;
@@ -125,8 +125,8 @@ err_out:
int main(int argc, char * argv []) {
FILE * in = NULL, * out = NULL;
- demuxer_t demuxer = { .priv = NULL };
- stream_t * streams;
+ demuxer_tt demuxer = { .priv = NULL };
+ stream_tt * streams;
int i, err = 0;
const char * extension;
Modified: src/trunk/nututils/nutmerge.h
==============================================================================
--- src/trunk/nututils/nutmerge.h (original)
+++ src/trunk/nututils/nutmerge.h Thu Dec 11 21:34:43 2008
@@ -16,9 +16,9 @@
extern FILE * stats;
-typedef struct demuxer_priv_s demuxer_priv_t;
-typedef struct framer_priv_s framer_priv_t;
-typedef struct stream_s stream_t;
+typedef struct demuxer_priv_s demuxer_priv_tt;
+typedef struct framer_priv_s framer_priv_tt;
+typedef struct stream_s stream_tt;
enum nutmerge_codecs {
e_vorbis,
@@ -27,49 +27,49 @@ enum nutmerge_codecs {
};
typedef struct {
- nut_packet_t p;
+ nut_packet_tt p;
uint8_t * buf; // the demuxer mallocs this, nutmerge (or framer) eventually frees it
-} packet_t;
+} packet_tt;
typedef struct {
char * extension;
- demuxer_priv_t * (*init)(FILE * in);
+ demuxer_priv_tt * (*init)(FILE * in);
/// streams is -1 terminated, handled and freed by demuxer
- int (*read_headers)(demuxer_priv_t * priv, stream_t ** streams);
- int (*fill_buffer)(demuxer_priv_t * priv);
- void (*uninit)(demuxer_priv_t * priv);
- demuxer_priv_t * priv;
-} demuxer_t;
+ int (*read_headers)(demuxer_priv_tt * priv, stream_tt ** streams);
+ int (*fill_buffer)(demuxer_priv_tt * priv);
+ void (*uninit)(demuxer_priv_tt * priv);
+ demuxer_priv_tt * priv;
+} demuxer_tt;
typedef struct {
enum nutmerge_codecs codec_id;
- framer_priv_t * (*init)(stream_t * stream);
- int (*setup_headers)(framer_priv_t * priv, nut_stream_header_t * s); // fill 's'
- int (*get_packet)(framer_priv_t * priv, packet_t * p); // 'p->buf' is now controlled by caller
- void (*uninit)(framer_priv_t * priv);
- framer_priv_t * priv;
-} framer_t;
+ framer_priv_tt * (*init)(stream_tt * stream);
+ int (*setup_headers)(framer_priv_tt * priv, nut_stream_header_tt * s); // fill 's'
+ int (*get_packet)(framer_priv_tt * priv, packet_tt * p); // 'p->buf' is now controlled by caller
+ void (*uninit)(framer_priv_tt * priv);
+ framer_priv_tt * priv;
+} framer_tt;
struct stream_s {
int stream_id; // -1 terminated
- demuxer_t demuxer;
+ demuxer_tt demuxer;
enum nutmerge_codecs codec_id;
- nut_stream_header_t sh;
+ nut_stream_header_tt sh;
int npackets;
int packets_alloc;
- packet_t * packets;
+ packet_tt * packets;
};
-void ready_stream(stream_t * streams); // setup default stream info
+void ready_stream(stream_tt * streams); // setup default stream info
-void push_packet(stream_t * stream, packet_t * p);
+void push_packet(stream_tt * stream, packet_tt * p);
-int peek_stream_packet(stream_t * stream, packet_t * p, int n); // n = 0 means next packet, n = 1 means 1 after that
-int get_stream_packet(stream_t * stream, packet_t * p);
+int peek_stream_packet(stream_tt * stream, packet_tt * p, int n); // n = 0 means next packet, n = 1 means 1 after that
+int get_stream_packet(stream_tt * stream, packet_tt * p);
-void free_streams(stream_t * streams); // all the way to -1 terminated list, not the actual 'streams' though
+void free_streams(stream_tt * streams); // all the way to -1 terminated list, not the actual 'streams' though
enum nutmerge_errors {
err_unexpected_eof = 1,
More information about the NUT-devel
mailing list