[NUT-devel] [nut]: r181 - in trunk/libnut: muxer.c nut.h

ods15 subversion at mplayerhq.hu
Sat Nov 4 14:35:40 CET 2006


Author: ods15
Date: Sat Nov  4 14:35:40 2006
New Revision: 181

Modified:
   trunk/libnut/muxer.c
   trunk/libnut/nut.h

Log:
change some timebase related stuff in info for muxer


Modified: trunk/libnut/muxer.c
==============================================================================
--- trunk/libnut/muxer.c	(original)
+++ trunk/libnut/muxer.c	Sat Nov  4 14:35:40 2006
@@ -66,6 +66,16 @@
 	return bc;
 }
 
+static int add_timebase(nut_context_t * nut, nut_timebase_t tb) {
+	int i;
+	for (i = 0; i < nut->timebase_count; i++) if (compare_ts(nut, 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[i] = tb;
+	}
+	return i;
+}
+
 static void put_bytes(output_buffer_t * bc, int count, uint64_t val) {
 	ready_write_buf(bc, count);
 	for(count--; count >= 0; count--){
@@ -222,7 +232,8 @@
 
 	put_v(tmp, info->stream_id_plus1);
 	put_v(tmp, info->chapter_id);
-	put_v(tmp, info->chapter_start);
+	for (i = 0; i < nut->timebase_count; i++) if (compare_ts(nut, 1, info->chapter_tb, 1, nut->tb[i]) == 0) break;
+	put_v(tmp, info->chapter_start * nut->timebase_count + i);
 	put_v(tmp, info->chapter_len);
 	put_v(tmp, info->count);
 
@@ -235,8 +246,10 @@
 			put_s(tmp, -3);
 			put_s(tmp, field->val);
 		} else if (!strcmp(field->type, "t")) {
+			int j;
+			for (j = 0; j < nut->timebase_count; j++) if (compare_ts(nut, 1, field->tb, 1, nut->tb[j]) == 0) break;
 			put_s(tmp, -4);
-			put_v(tmp, field->val);
+			put_v(tmp, field->val * nut->timebase_count + j);
 		} else if (!strcmp(field->type, "r")) {
 			put_s(tmp, -(field->den + 4));
 			put_s(tmp, field->val);
@@ -556,7 +569,7 @@
 	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->tb = nut->alloc->malloc(sizeof(nut_timebase_t) * nut->stream_count);
+	nut->tb = NULL;
 	nut->timebase_count = 0;
 
 	for (i = 0; i < nut->stream_count; i++) {
@@ -578,9 +591,7 @@
 
 		nut->sc[i].pts_cache = nut->alloc->malloc(nut->sc[i].sh.decode_delay * sizeof(int64_t));
 
-		for (j = 0; j < nut->timebase_count; j++) if (compare_ts(nut, 1, s[i].time_base, 1, nut->tb[j]) == 0) break;
-		if (j == nut->timebase_count) nut->tb[nut->timebase_count++] = s[i].time_base;
-		nut->sc[i].timebase_id = j;
+		nut->sc[i].timebase_id = add_timebase(nut, s[i].time_base);
 
 		// reorder.c
 		nut->sc[i].reorder_pts_cache = nut->alloc->malloc(nut->sc[i].sh.decode_delay * sizeof(int64_t));
@@ -604,12 +615,14 @@
 			int j;
 			nut->info[i] = info[i];
 			nut->info[i].fields = nut->alloc->malloc(sizeof(nut_info_field_t) * 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];
 				if (info[i].fields[j].data) {
 					nut->info[i].fields[j].data = nut->alloc->malloc(info[i].fields[j].val);
 					memcpy(nut->info[i].fields[j].data, info[i].fields[j].data, info[i].fields[j].val);
 				}
+				if (!strcmp(nut->info[i].fields[j].type, "t")) add_timebase(nut, nut->info[i].fields[j].tb);
 			}
 		}
 	} else {

Modified: trunk/libnut/nut.h
==============================================================================
--- trunk/libnut/nut.h	(original)
+++ trunk/libnut/nut.h	Sat Nov  4 14:35:40 2006
@@ -91,6 +91,7 @@
 	char name[65];
 	int64_t val;
 	int den;
+	nut_timebase_t tb;
 	uint8_t * data; // must be NULL if carries no data
 } nut_info_field_t;
 
@@ -98,6 +99,7 @@
 	int count; // count=-1 terminates the nut_info_packet_t array
 	int stream_id_plus1;
 	int chapter_id;
+	nut_timebase_t chapter_tb;
 	uint64_t chapter_start;
 	uint64_t chapter_len;
 	nut_info_field_t * fields;



More information about the NUT-devel mailing list