[NUT-devel] [nut]: r193 - in trunk: libnut/muxer.c libnut/nut.h nututils/nutmerge.c

ods15 subversion at mplayerhq.hu
Tue Nov 7 19:28:25 CET 2006


Author: ods15
Date: Tue Nov  7 19:28:25 2006
New Revision: 193

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

Log:
add realtime_stream option for muxer.
Effect is allowed use of nut_write_info(), writing of each NUT packet 
individually, and writing the entire NUT headers only once, at init, in 
the first packet to write() function. No index writing.
Cost - memcpy for ALL frame data in order too prepend to it the frame 
headers.


Modified: trunk/libnut/muxer.c
==============================================================================
--- trunk/libnut/muxer.c	(original)
+++ trunk/libnut/muxer.c	Tue Nov  7 19:28:25 2006
@@ -12,7 +12,7 @@
 }
 
 static void flush_buf(output_buffer_t * bc) {
-	assert(!bc->is_mem);
+	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;
 }
@@ -457,6 +457,7 @@
 }
 
 static void check_header_repetition(nut_context_t * nut) {
+	if (nut->mopts.realtime_stream) return;
 	if (bctello(nut->o) >= (1 << 23)) {
 		int i; // ### magic value for header repetition
 		for (i = 24; bctello(nut->o) >= (1 << i); i++);
@@ -501,9 +502,13 @@
 	if ((fd->flags & NUT_FLAG_KEY) && !sc->last_key) sc->last_key = fd->pts + 1;
 	if (fd->flags & NUT_FLAG_EOR) sc->eor = fd->pts + 1;
 	else sc->eor = 0;
+
+	if (nut->mopts.realtime_stream) flush_buf(nut->o);
 }
 
 void nut_write_info(nut_context_t * nut, const nut_info_packet_t * info) {
+	if (!nut->mopts.realtime_stream) return;
+
 	nut->last_headers = bctello(nut->o); // to force syncpoint writing after the info header
 	put_info(nut, info);
 }
@@ -517,6 +522,7 @@
 	else nut = malloc(sizeof(nut_context_t));
 
 	nut->mopts = *mopts;
+	if (nut->mopts.realtime_stream) nut->mopts.write_index = 0;
 
 	nut->alloc = &nut->mopts.alloc;
 
@@ -531,6 +537,8 @@
 	nut->tmp_buffer2 = new_mem_buffer(nut->alloc); //  for packet_headers
 	nut->max_distance = mopts->max_distance;
 
+	if (nut->mopts.realtime_stream) nut->o->is_mem = 1;
+
 	if (nut->max_distance > 65536) nut->max_distance = 65536;
 
 	{
@@ -649,6 +657,8 @@
 
 	put_headers(nut);
 
+	if (nut->mopts.realtime_stream) flush_buf(nut->o);
+
 	return nut;
 }
 
@@ -657,8 +667,10 @@
 	int total = 0;
 	if (!nut) return;
 
-	while (nut->headers_written < 2) put_headers(nut); // force 3rd copy of main headers
-	put_headers(nut);
+	if (!nut->mopts.realtime_stream) {
+		while (nut->headers_written < 2) put_headers(nut); // force 3rd copy of main headers
+		put_headers(nut);
+	}
 	if (nut->mopts.write_index) put_index(nut);
 
 	for (i = 0; i < nut->stream_count; i++) {

Modified: trunk/libnut/nut.h
==============================================================================
--- trunk/libnut/nut.h	(original)
+++ trunk/libnut/nut.h	Tue Nov  7 19:28:25 2006
@@ -75,6 +75,7 @@
 	nut_output_stream_t output;
 	nut_alloc_t alloc;
 	int write_index;
+	int realtime_stream; // implies no write_index
 	int max_distance;
 	frame_table_input_t * fti;
 } nut_muxer_opts_t;

Modified: trunk/nututils/nutmerge.c
==============================================================================
--- trunk/nututils/nutmerge.c	(original)
+++ trunk/nututils/nutmerge.c	Tue Nov  7 19:28:25 2006
@@ -127,6 +127,7 @@
 
 	mopts.output = (nut_output_stream_t){ .priv = out, .write = NULL };
 	mopts.write_index = 1;
+	mopts.realtime_stream = 0;
 	mopts.fti = ft_default;
 	mopts.max_distance = 32768;
 	mopts.alloc.malloc = NULL;



More information about the NUT-devel mailing list