[Scummvm-cvs-logs] SF.net SVN: scummvm: [22142] tools/trunk/encode_dxa.cpp

kirben at users.sourceforge.net kirben at users.sourceforge.net
Mon Apr 24 16:03:04 CEST 2006


Revision: 22142
Author:   kirben
Date:     2006-04-24 16:02:30 -0700 (Mon, 24 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=22142&view=rev

Log Message:
-----------
Add NULL tag is audio doesn't exist, make adpcm compression optional and update help

Modified Paths:
--------------
    tools/trunk/encode_dxa.cpp
Modified: tools/trunk/encode_dxa.cpp
===================================================================
--- tools/trunk/encode_dxa.cpp	2006-04-24 22:00:41 UTC (rev 22141)
+++ tools/trunk/encode_dxa.cpp	2006-04-24 23:02:30 UTC (rev 22142)
@@ -37,14 +37,16 @@
 
 class DxaEncoder {
 private:
-	FILE *_dxa;
 	int _width, _height, _framerate, _framecount;
 	uint8 *_prevframe, *_prevpalette;
 
 public:
+	FILE *_dxa;
+
 	DxaEncoder(char *filename, int width, int height, int fps);
 	~DxaEncoder();
 	void writeHeader();
+	void writeNULL();
 	void addAudio(char *wavfilename);
 	void writeFrame(uint8 *frame, uint8 *palette);
 };
@@ -85,6 +87,11 @@
 	writeUint16BE(_dxa, _height);
 }
 
+void DxaEncoder::writeNULL() {
+	//NULL
+	fwrite(&typeNULL, 4, 1, _dxa);
+}
+
 void DxaEncoder::addAudio(char* wavfilename) {
 	//WAVE
 	const int BUFSIZE = 8192;
@@ -130,8 +137,7 @@
 
 		memcpy(_prevpalette, palette, 768);
 	} else {
-		//NULL
-		fwrite(&typeNULL, 4, 1, _dxa);
+		writeNULL();
 	}
 
 	if (_framecount == 0 || memcmp(_prevframe, frame, _width * _height)) {
@@ -188,8 +194,7 @@
 		memcpy(_prevframe, frame, _width * _height);
 
 	} else {
-		//NULL
-		fwrite(&typeNULL, 4, 1, _dxa);
+		writeNULL();
 	}
 
 	_framecount++;
@@ -365,21 +370,34 @@
 	fclose(smk);
 }
 
+void showhelp(char *exename) {
+	printf("\nUsage: %s <params> <inputfile> <inputdir>\n", exename);
+	printf("\nParams:\n");
+	printf(" --adpcm      encode audio to Microsoft ADPCM format\n");
+	printf("(If one of these is specified, it must be the first parameter.)\n");
+	exit(2);
+}
+
 int main(int argc, char *argv[]) {
 	printf("Dxa encoder (c) 2006 Benjamin Haisch\n");
         
-	if (argc < 3) {
-		printf("syntax: encodedxa prefix datapath\n");
-		return 1;
-	}
+	if (argc < 3)
+		showhelp(argv[0]);
 
-	int width, height, framerate, frames, useMsAdpcm = 0;
 	char strbuf[512];
+	int width, height, framerate, frames;
+	bool useMsAdpcm = false;
         
-	char *prefix = argv[1], *datapath = argv[2];
+	int i = 1;
+	if (strcmp(argv[1], "--adpcm") == 0) {
+		useMsAdpcm = true;
+		i++;
+	}
 
+	char *prefix = argv[i++];
+	char *datapath = argv[i++];
+
 	// read some data from the Smacker file.
-	// TODO: make the values cmdline parameters and this optional.
 	sprintf(strbuf, "%s%s.smk", datapath, prefix);
 	readSmackerInfo(strbuf, width, height, framerate, frames);
 
@@ -403,6 +421,8 @@
 			strcpy(strbuf, "dxatemp.wav");
 		}
 		dxe.addAudio(strbuf);
+	} else {
+		dxe.writeNULL();
 	}
 
 	uint8 *image, *palette;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Scummvm-git-logs mailing list