トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

avi_tc_package on Linux

tritical氏のavi_tc_packageをLinuxで使いたくなったので、gcc(g++-4.3.2)でコンパイル通るようにいじくってみました。

ついでにVC2008 Express Editionだとafxres.hがないぞゴルァと言われるので、そこも。Warningは大目に見る方向で…(ぉ

cfr2tc.patch

diff -u org/cfr2tc.cpp ./cfr2tc.cpp
--- org/cfr2tc.cpp	2006-07-26 22:06:16.000000000 +0900
+++ ./cfr2tc.cpp	2010-05-14 20:47:55.787201000 +0900
@@ -22,10 +22,32 @@
 **   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include <windows.h>
 #include <stdio.h>
 #include <time.h>
-#include <malloc.h>
+#ifdef _MSC_VER
+	#include <windows.h>
+	#include <malloc.h>
+#else
+	#include <string.h>
+	#include <unistd.h>
+	#include <stdlib.h>
+
+	static inline void *_aligned_malloc(size_t size, size_t alignment)
+	{
+		void *p;
+		int ret = posix_memalign(&p, alignment, size);
+		return (ret == 0) ? p : 0;
+	}
+
+	static inline void _aligned_free(void *memblock)
+	{
+		return free(memblock);
+	}
+
+	typedef unsigned int DWORD;
+	typedef unsigned short WORD;
+
+#endif
 
 #define VERSION "v1.4"
 
@@ -45,8 +67,8 @@
 	DWORD ckSize;
 	DWORD ckDataSize;
 	void *ckData;
-	CHUNKHEADER::CHUNKHEADER() : ckID(0), ckSize(0), ckData(0), ckDataSize(0) {};
-	CHUNKHEADER::~CHUNKHEADER() { if (ckData) free(ckData); }
+	CHUNKHEADER() : ckID(0), ckSize(0), ckData(0), ckDataSize(0) {};
+	~CHUNKHEADER() { if (ckData) free(ckData); }
 };
 
 class LISTHEADER
@@ -56,9 +78,9 @@
 	DWORD lstSize;
 	FOURCC lstType;
 	CHUNKHEADER *chkHd;
-	LISTHEADER::LISTHEADER() : lstID(0), lstSize(0), lstType(0), chkHd(0) {};
-	LISTHEADER::~LISTHEADER() { if (chkHd) delete chkHd; }
-	LISTHEADER& LISTHEADER::operator=(LISTHEADER& ob2)
+	LISTHEADER() : lstID(0), lstSize(0), lstType(0), chkHd(0) {};
+	~LISTHEADER() { if (chkHd) delete chkHd; }
+	LISTHEADER& operator=(LISTHEADER& ob2)
 	{
 		lstID = ob2.lstID;
 		lstSize = ob2.lstSize;
@@ -80,8 +102,8 @@
 public:
 	DWORD size;
 	void *data;
-	TBUF::TBUF() : data(0), size(0) {};
-	TBUF::~TBUF() { if (data) free(data); }
+	TBUF() : data(0), size(0) {};
+	~TBUF() { if (data) free(data); }
 };
 
 typedef struct 
@@ -614,8 +636,8 @@
 		printf("Invalid mode value.\n");
 		return false;
 	}
-	fclose(tcf);
-	tcf = NULL;
+	//fclose(tcf);
+	//tcf = NULL;
 	printf("Timecode file created successfully.\n");
 	return true;
 }
@@ -723,6 +745,7 @@
 
 	/* Next grab the AVI2 "odml" LIST. */
 	LISTHEADER odml;
+	AVIEXTHEADER *aeh;
 	if (!scanForList(f, o, &odml, "odml", "movi", false, true, stop))
 	{
 		if (stop) { goto noodml; }
@@ -738,7 +761,7 @@
 		printf("Error reading dmlh CHUNK.\n");
 		return false;
 	}
-	AVIEXTHEADER *aeh = (AVIEXTHEADER*)odml.chkHd->ckData;
+	aeh = (AVIEXTHEADER*)odml.chkHd->ckData;
 	aeh->dwGrandFrames = newFrameCount;
 	if (!writeLHChunk(o, &odml)) return false;
 
@@ -864,7 +887,8 @@
 	DWORD sectionCount = 0;
 	DWORD frameSum = 0;
 	long last = -1;
-	for (DWORD i=0; i<newFrameCount-1; ++i)
+	DWORD i;
+	for (i=0; i<newFrameCount-1; ++i)
 	{
 		if (repCount[i] != repCount[i+1])
 		{
diff -u org/cfr2tc.rc ./cfr2tc.rc
--- org/cfr2tc.rc	2006-07-26 21:08:56.000000000 +0900
+++ ./cfr2tc.rc	2010-05-14 18:57:11.152302000 +0900
@@ -7,7 +7,9 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
-#include "afxres.h"
+// #include "afxres.h"
+#include <windows.h>
+#define IDC_STATIC -1

tc2cfr.patch

diff -u org/tc2cfr.cpp ./tc2cfr.cpp
--- org/tc2cfr.cpp	2006-08-02 22:59:44.000000000 +0900
+++ ./tc2cfr.cpp	2010-05-19 23:19:12.037989000 +0900
@@ -23,10 +23,32 @@
 **   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-#include <windows.h>
 #include <stdio.h>
 #include <time.h>
-#include <malloc.h>
+#ifdef _MSC_VER
+	#include <windows.h>
+	#include <malloc.h>
+#else
+	#include <string.h>
+	#include <unistd.h>
+	#include <stdlib.h>
+
+	static inline void *_aligned_malloc(size_t size, size_t alignment)
+	{
+		void *p;
+		int ret = posix_memalign(&p, alignment, size);
+		return (ret == 0) ? p : 0;
+	}
+
+	static inline void _aligned_free(void *memblock)
+	{
+		return free(memblock);
+	}
+
+	typedef unsigned int DWORD;
+	typedef unsigned short WORD;
+
+#endif
 
 #define VERSION "v1.5"
 
@@ -46,8 +68,8 @@
 	DWORD ckSize;
 	DWORD ckDataSize;
 	void *ckData;
-	CHUNKHEADER::CHUNKHEADER() : ckID(0), ckSize(0), ckData(0), ckDataSize(0) {};
-	CHUNKHEADER::~CHUNKHEADER() { if (ckData) free(ckData); }
+	CHUNKHEADER() : ckID(0), ckSize(0), ckData(0), ckDataSize(0) {};
+	~CHUNKHEADER() { if (ckData) free(ckData); }
 };
 
 class LISTHEADER
@@ -57,8 +79,8 @@
 	DWORD lstSize;
 	FOURCC lstType;
 	CHUNKHEADER *chkHd;
-	LISTHEADER::LISTHEADER() : lstID(0), lstSize(0), lstType(0), chkHd(0) {};
-	LISTHEADER::~LISTHEADER() { if (chkHd) delete chkHd; }
+	LISTHEADER() : lstID(0), lstSize(0), lstType(0), chkHd(0) {};
+	~LISTHEADER() { if (chkHd) delete chkHd; }
 };
 
 class TBUF
@@ -66,8 +88,8 @@
 public:
 	DWORD size;
 	void *data;
-	TBUF::TBUF() : data(0), size(0) {};
-	TBUF::~TBUF() { if (data) free(data); }
+	TBUF() : data(0), size(0) {};
+	~TBUF() { if (data) free(data); }
 };
 TBUF tbuf;
 
@@ -875,6 +897,7 @@
 
 	/* Next grab the AVI2 "odml" LIST. */
 	LISTHEADER odml;
+	AVIEXTHEADER *aeh;
 	if (!scanForNextList(f, o, &odml, "odml", false, 0, fmovi))
 	{
 		if (fmovi) { goto noodml; }
@@ -900,7 +923,7 @@
 	}
 
 	/* Modify needed fields of AVIEXTHEADER. */
-	AVIEXTHEADER *aeh = (AVIEXTHEADER*)odml.chkHd->ckData;
+	aeh = (AVIEXTHEADER*)odml.chkHd->ckData;
 	aeh->dwGrandFrames = newFrameCount;
 	if (!fwrite(aeh,sizeof(AVIEXTHEADER),1,o))
 	{
diff -u org/tc2cfr.rc ./tc2cfr.rc
--- org/tc2cfr.rc	2006-08-02 22:57:32.000000000 +0900
+++ ./tc2cfr.rc	2010-05-19 23:37:43.274982876 +0900
@@ -7,7 +7,9 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
-#include "afxres.h"
+// #include "afxres.h"
+#include <windows.h>
+#define IDC_STATIC -1