[NUT-devel] [nut]: r176 - in trunk/nututils: Makefile demux_avi.c framer_mp3.c nutmerge.c nutmerge.h

ods15 subversion at mplayerhq.hu
Sat Nov 4 13:05:16 CET 2006


Author: ods15
Date: Sat Nov  4 13:05:13 2006
New Revision: 176

Added:
   trunk/nututils/framer_mp3.c
Modified:
   trunk/nututils/Makefile
   trunk/nututils/demux_avi.c
   trunk/nututils/nutmerge.c
   trunk/nututils/nutmerge.h

Log:
make demux_avi more strict on what it accepts
add framer_mp3


Modified: trunk/nututils/Makefile
==============================================================================
--- trunk/nututils/Makefile	(original)
+++ trunk/nututils/Makefile	Sat Nov  4 13:05:13 2006
@@ -8,7 +8,7 @@
 	${CC} ${CFLAGS} -DAVI_PROG $^ -o $@
 oggreader: demux_ogg.c
 	${CC} ${CFLAGS} -DOGG_PROG $^ -o $@
-nutmerge: demux_ogg.c demux_avi.c framer_vorbis.c framer_mpeg4.c nutmerge.c ../libnut/libnut.a # demux_nut.c
+nutmerge: demux_ogg.c demux_avi.c framer_vorbis.c framer_mp3.c framer_mpeg4.c nutmerge.c ../libnut/libnut.a # demux_nut.c
 	${CC} ${CFLAGS} $^ -o $@
 nutindex: nutindex.c
 	${CC} ${CFLAGS} $^ -o $@

Modified: trunk/nututils/demux_avi.c
==============================================================================
--- trunk/nututils/demux_avi.c	(original)
+++ trunk/nututils/demux_avi.c	Sat Nov  4 13:05:13 2006
@@ -332,6 +332,25 @@
 static int read_headers(demuxer_priv_t * avi, stream_t ** streams) {
 	int i;
 	if ((i = avi_read_headers(avi))) return i;
+	for (i = 0; i < avi->avih->dwStreams; i++) {
+		if (avi->stream[i].type == 0) { // video
+			char * fourccs[] = {"FMP4","fmp4","DIVX","divx",
+			                    "DIV1","div1","MP4S","mp4s",
+			                    "xvid","XVID","XviD","XVIX",
+			                    "M4S2","m4s2","mp4v","MP4V"
+			                    "DX50","dx50","BLZ0",
+			};
+			int j;
+			for (j = sizeof(fourccs)/sizeof(fourccs[0]); j--; ) {
+				if (!strncmp(avi->stream[i].video->biCompression, fourccs[j], 4)) break;
+			}
+			if (j == -1) return 18;
+		} else {
+			if (avi->stream[i].audio->wFormatTag[0] != 0x55 ||
+			    avi->stream[i].audio->wFormatTag[1] != 0x00) return 19;
+		}
+	}
+
 	*streams = avi->s = malloc(sizeof(stream_t) * (avi->avih->dwStreams + 1));
 	for (i = 0; i < avi->avih->dwStreams; i++) {
 		extern demuxer_t avi_demuxer;
@@ -340,19 +359,18 @@
 		avi->s[i].demuxer.priv = avi;
 		avi->s[i].packets_alloc = avi->s[i].npackets = 0;
 		avi->s[i].packets = NULL;
-		if (i == 0) avi->s[i].codec_id = e_mpeg4;
-		else avi->s[i].codec_id = e_null;
 
 		avi->s[i].sh.type = avi->stream[i].type;
 		avi->s[i].sh.time_base.den = avi->stream[i].strh->dwRate;
 		avi->s[i].sh.time_base.nom = avi->stream[i].strh->dwScale;
 		avi->s[i].sh.fixed_fps = 1;
-		avi->s[i].sh.decode_delay = !i; // FIXME
 		avi->s[i].sh.codec_specific_len = avi->stream[i].extra_len;
 		avi->s[i].sh.codec_specific = avi->stream[i].extra;
 		if (avi->stream[i].type == 0) { // video
 			avi->s[i].sh.fourcc_len = 4;
 			avi->s[i].sh.fourcc = avi->stream[i].video->biCompression;
+			avi->s[i].codec_id = e_mpeg4;
+			avi->s[i].sh.decode_delay = 1;
 
 			avi->s[i].sh.width = avi->stream[i].video->biWidth;
 			avi->s[i].sh.height = avi->stream[i].video->biHeight;
@@ -360,8 +378,10 @@
 			avi->s[i].sh.sample_height = 0;
 			avi->s[i].sh.colorspace_type = 0;
 		} else { // audio
-			avi->s[i].sh.fourcc_len = 2;
-			avi->s[i].sh.fourcc = avi->stream[i].audio->wFormatTag;
+			avi->s[i].sh.fourcc_len = 4;
+			avi->s[i].sh.fourcc = "mp3 ";
+			avi->s[i].codec_id = e_mp3;
+			avi->s[i].sh.decode_delay = 0;
 
 			avi->s[i].sh.samplerate_nom = 1;
 			avi->s[i].sh.samplerate_denom = avi->stream[i].audio->nSamplesPerSec;
@@ -449,36 +469,6 @@
 	uninit
 };
 
-struct framer_priv_s { stream_t * stream; };
-
-static int n_get_packet(framer_priv_t * mc, packet_t * p) {
-	return get_stream_packet(mc->stream, p);
-}
-
-static int n_setup_headers(framer_priv_t * mc, nut_stream_header_t * s) {
-	*s = mc->stream->sh;
-	return 0; // nothing to do
-}
-
-static framer_priv_t * n_init(stream_t * s) {
-	framer_priv_t * mc = malloc(sizeof(framer_priv_t));
-	mc->stream = s;
-	return mc;
-}
-
-static void n_uninit(framer_priv_t * mc) {
-	free(mc);
-}
-
-framer_t null_framer = {
-	e_null,
-	n_init,
-	n_setup_headers,
-	n_get_packet,
-	n_uninit,
-	NULL
-};
-
 
 #ifdef AVI_PROG
 void ready_stream(stream_t * streams){}

Added: trunk/nututils/framer_mp3.c
==============================================================================
--- (empty file)
+++ trunk/nututils/framer_mp3.c	Sat Nov  4 13:05:13 2006
@@ -0,0 +1,36 @@
+// (C) 2005-2006 Oded Shimon
+// This file is available under the MIT/X license, see COPYING
+
+#include "nutmerge.h"
+
+struct framer_priv_s {
+	stream_t * stream;
+};
+
+static int get_packet(framer_priv_t * mp, packet_t * p) {
+	return get_stream_packet(mp->stream, p);
+}
+
+static int setup_headers(framer_priv_t * mp, nut_stream_header_t * 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));
+	mp->stream = s;
+	return mp;
+}
+
+static void uninit(framer_priv_t * mp) {
+	free(mp);
+}
+
+framer_t mp3_framer = {
+	e_mp3,
+	init,
+	setup_headers,
+	get_packet,
+	uninit,
+	NULL
+};

Modified: trunk/nututils/nutmerge.c
==============================================================================
--- trunk/nututils/nutmerge.c	(original)
+++ trunk/nututils/nutmerge.c	Sat Nov  4 13:05:13 2006
@@ -20,12 +20,12 @@
 
 extern framer_t vorbis_framer;
 extern framer_t mpeg4_framer;
-extern framer_t null_framer;
+extern framer_t mp3_framer;
 
 framer_t * nframers[] = {
 	&vorbis_framer,
 	&mpeg4_framer,
-	&null_framer,
+	&mp3_framer,
 	NULL
 };
 

Modified: trunk/nututils/nutmerge.h
==============================================================================
--- trunk/nututils/nutmerge.h	(original)
+++ trunk/nututils/nutmerge.h	Sat Nov  4 13:05:13 2006
@@ -20,7 +20,7 @@
 enum nutmerge_codecs {
 	e_vorbis,
 	e_mpeg4,
-	e_null,
+	e_mp3,
 };
 
 typedef struct {



More information about the NUT-devel mailing list