changeset 9:05c88622db6b default tip

- Adhoc transcoder now doesn't rely on Platinum - Moved the adhoc transcoder to the main source tree; it can be moved back into test once it's more stable
author fraserofthenight
date Tue, 14 Jul 2009 22:04:05 -0700
parents 71ebad05f542
children
files .classpath .settings/Hoofbaby - Debug.launch .settings/Hoofbaby - Release.launch src/build/frankenbuild.d src/impl/hoofbaby/app/libs.d src/impl/hoofbaby/app/main.d src/impl/hoofbaby/app/transcode.d src/impl/hoofbaby/codec/decoder.d src/test/hoofbaby/test/adhoc/transcode.d
diffstat 9 files changed, 164 insertions(+), 207 deletions(-) [+]
line wrap: on
line diff
--- a/.classpath	Sun Jul 12 03:49:39 2009 -0700
+++ b/.classpath	Tue Jul 14 22:04:05 2009 -0700
@@ -2,8 +2,6 @@
 <classpath>
 	<classpathentry kind="src" path="src/impl"/>
 	<classpathentry kind="src" path="src/build"/>
-	<classpathentry kind="src" path="src/test"/>
-	<classpathentry kind="src" path="src/tools"/>
 	<classpathentry kind="con" path="descent.USER_LIBRARY/Tango"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
--- a/.settings/Hoofbaby - Debug.launch	Sun Jul 12 03:49:39 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/hoofbaby/bin/build.bat}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="debug"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/hoofbaby/bin}"/>
-</launchConfiguration>
--- a/.settings/Hoofbaby - Release.launch	Sun Jul 12 03:49:39 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/hoofbaby/bin/build.bat}"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="release"/>
-<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/hoofbaby/bin}"/>
-</launchConfiguration>
--- a/src/build/frankenbuild.d	Sun Jul 12 03:49:39 2009 -0700
+++ b/src/build/frankenbuild.d	Tue Jul 14 22:04:05 2009 -0700
@@ -64,25 +64,24 @@
     if(cats.contains("transcode"))
     {
     	targetFound = true;
-    	 cats ~= "platif-debug";
 	    char[] cargs = cbase.dup;
 	    cargs ~= " -g";
 	    cargs ~= " -debug -debug=AVBuffer";
 	    cargs ~= " -ofhoofbaby-d/transcode.exe";
 	    cargs ~= " -I../src/test";
-	    cargs ~= " -oqobjs/debug";
-	    cargs ~= " ../src/test/hoofbaby/test/adhoc/transcode.d";
-	    commands ~= { return cpp("../src/platif/platif.h", "../src/impl/hoofbaby/platinum/platif.d"); };
+	    cargs ~= " -oqobjs/transcode";
+	    cargs ~= " ../src/impl/hoofbaby/app/transcode.d";
 	    commands ~= { return rebuild(cargs); };
     }
 	
-	if(cats.contains("debug"))
+	/+ if(cats.contains("debug"))
 	{
 	    targetFound = true;
 	    cats ~= "platif-debug";
 	    char[] cargs = cbase.dup;
 	    cargs ~= " -g";
 	    cargs ~= " -debug -debug=AVBuffer";
+    	cargs ~= " -version=UPnP";
 	    cargs ~= " -ofhoofbaby-d/hoofbaby.exe";
 	    cargs ~= " -oqobjs/debug";
 	    cargs ~= " ../src/impl/hoofbaby/app/main.d";
@@ -96,13 +95,14 @@
 	    cats ~= "platif-release";
 	    char[] cargs = cbase.dup;
 	    cargs ~= " -O -inline";
+    	cargs ~= " -version=UPnP";
 	    cargs ~= " -ofhoofbaby/hoofbaby.exe";
 	    cargs ~= " -oqobjs/release";
 	    cargs ~= " ../src/impl/hoofbaby/app/main.d";
 	    commands ~= { return cpp("../src/platif/platif.h", "../src/impl/hoofbaby/platinum/platif.d"); };
 	    commands ~= { return rebuild(cargs); };
 	    commands ~= { return upx("hoofbaby/hoofbaby.exe"); };// D executables are enormous
-    }
+    } +/
 	
 	if(cats.contains("platif-debug"))
 	{
--- a/src/impl/hoofbaby/app/libs.d	Sun Jul 12 03:49:39 2009 -0700
+++ b/src/impl/hoofbaby/app/libs.d	Tue Jul 14 22:04:05 2009 -0700
@@ -17,14 +17,14 @@
 
 import tango.io.Stdout;
 
-import platif = hoofbaby.platinum.platif;
+version(UPnP) import platif = hoofbaby.platinum.platif;
 import libav = hoofbaby.codec.libav.avformat;
 
 public bool initLibs()
 {
 	try
 	{
-		platif._loadLib();
+		version(UPnP) platif._loadLib();
 		libav.av_register_all();
 	}
 	catch(Exception e)
--- a/src/impl/hoofbaby/app/main.d	Sun Jul 12 03:49:39 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/**
- * Hoofbaby -- http://www.dsource.org/projects/hoofbaby
- * Copyright (C) 2009 Robert Fraser
- * 
- * This program is free software; you can redistribute it andor
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-module hoofbaby.app.main;
-
-// Imports for whole program (just link to them)
-import NONE_1       = tango.stdc.stdarg; // Must be linked in to prevent strange linker errors
-debug import NONE_2 = tango.core.stacktrace.TraceExceptions;
-import NONE_3       = hoofbaby.codec.libav.mingw;
-
-import hoofbaby.app.libs;
-
-public int main(char[][] args)
-{
-	initLibs();
-	return 0;
-}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/impl/hoofbaby/app/transcode.d	Tue Jul 14 22:04:05 2009 -0700
@@ -0,0 +1,153 @@
+/**
+ * Hoofbaby -- http://www.dsource.org/projects/hoofbaby
+ * Copyright (C) 2009 Robert Fraser
+ * 
+ * This program is free software; you can redistribute it andor
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+module hoofbaby.app.transcode;
+
+import NONE_1 = tango.stdc.stdarg; // Must be linked in to prevent strange linker errors
+debug import NONE_2 = tango.core.stacktrace.TraceExceptions;
+import NONE_3 = hoofbaby.codec.libav.mingw;
+
+import hoofbaby.app.libs;
+import hoofbaby.codec.decoder;
+import hoofbaby.codec.encoder;
+
+public int main(char[][] args)
+{
+	initLibs();
+	scope Decoder dec = new Decoder("../../ref/testv-h264-vorbis-ass.mkv");
+	scope Encoder enc = new Encoder("trans.wmv");
+	// WORKAREA check ffmpeg.c:1742
+	return 0;
+}
+
+/+ 
+
+import Math = tango.math.Math;
+import hoofbaby.codec.libav.avutil;
+import hoofbaby.codec.libav.avcodec;
+import hoofbaby.codec.libav.avformat;
+
+private const int STREAM_FRAME_RATE = 25;
+private const double STREAM_DURATION = 5.0;
+private const int STREAM_NB_FRAMES = (cast(int) (STREAM_DURATION * STREAM_FRAME_RATE));
+private const int WIDTH = 352;
+private const int HEIGHT = 288;
+private const int SAMPLE_RATE = 44100;
+private int AUDIO_FRAME_SIZE;
+
+private int frameCount = 0;
+private double audioCount = 0.0;
+private double audioIncr = 2 * Math.PI * 110.0 / SAMPLE_RATE;
+private double audioIncr2 = 2 * Math.PI * 110.0 / SAMPLE_RATE / SAMPLE_RATE;
+
+private AVFrame* generatePicture(AVFrame* pict, int width, int height)
+{
+	int x, y, i;
+	i = frameCount;
+
+	/* Y */
+	for(y = 0; y < height; y++)
+	{
+		for(x = 0; x < width; x++)
+		{
+			pict.data[0][y * pict.linesize[0] + x] = x + y + i * 3;
+		}
+	}
+
+	/* Cb and Cr */
+	for(y = 0; y < height / 2; y++)
+	{
+		for(x = 0; x < width / 2; x++)
+		{
+			pict.data[1][y * pict.linesize[1] + x] = 128 + y + i * 2;
+			pict.data[2][y * pict.linesize[2] + x] = 64 + x + i * 5;
+		}
+	}
+	
+	return pict;
+}
+
+private short* generateAudio(short* samples)
+{
+	int j, i, v;
+    short *q;
+
+    q = samples;
+    for(j = 0; j < AUDIO_FRAME_SIZE; j++)
+    {
+        v = cast(int)(Math.sin(audioCount) * 10000);
+        for(i = 0; i < 2; i++) // 2 is number of channels
+            *q++ = v;
+        audioCount += audioIncr;
+        audioIncr += audioIncr2;
+    }
+    
+    return samples;
+}
+
+public int main(char[][] args)
+{
+	initLibs();
+	scope Encoder enc = new Encoder("biff_happy.wmv");
+	AUDIO_FRAME_SIZE = enc.audioContext.frame_size;
+	
+	// Allocate a video frame and audio buffer to store stuff
+	AVFrame* frame = avpicture_alloc(PIX_FMT_YUV420P, WIDTH, HEIGHT);
+	assert(frame !is null, "Could not allocate frame");
+	scope(exit) if(frame) av_free(frame);
+	short* samples = cast(short*) av_malloc(AUDIO_FRAME_SIZE * 2 * 2); // AUDIO_FRAME_SIZE * 2 * number of channels
+	assert(frame !is null, "Could not allocate samples");
+	scope(exit) if(samples) av_free(samples);
+	
+	// Write header
+	enc.writeHeader();
+	
+	while(true)
+	{
+		double audio_pts = cast(double) enc.audioStream.pts.val * enc.audioStream.time_base.num / enc.audioStream.time_base.den;
+		double video_pts = cast(double) enc.videoStream.pts.val * enc.videoStream.time_base.num / enc.videoStream.time_base.den;
+	
+		if(audio_pts >= STREAM_DURATION && video_pts >= STREAM_DURATION)
+			break;
+	
+		// Write interleaved audio & video
+		if(audio_pts < video_pts)
+		{
+			enc.writeAudioFrame(generateAudio(samples));
+		}
+		else
+		{
+			if(frameCount >= STREAM_NB_FRAMES)
+			{
+				// no more frame to compress. The codec has a latency of a few
+				// frames if using B frames, so we get the last frames by
+				// passing the same picture again
+			}
+			else
+			{
+				generatePicture(frame, WIDTH, HEIGHT);
+			}
+			
+			enc.writeVideoFrame(frame);
+			frameCount++;
+		}
+	}
+	
+	// Write trailer
+	enc.writeTrailer();
+	
+	return 0;
+}
++/
\ No newline at end of file
--- a/src/impl/hoofbaby/codec/decoder.d	Sun Jul 12 03:49:39 2009 -0700
+++ b/src/impl/hoofbaby/codec/decoder.d	Tue Jul 14 22:04:05 2009 -0700
@@ -22,7 +22,7 @@
 import hoofbaby.codec.libav.avcodec;
 import hoofbaby.codec.libav.avformat;
 
-class Decoder
+public final class Decoder
 {
 	private char[] file;
 	
@@ -65,7 +65,7 @@
 		}
 		assert(videoStream !is null, "Could not find video stream");
 		videoContext = videoStream.codec;
-		assert(videoContext !is null, "Null codec context from non-null stream");
+		assert(videoContext !is null, "Null codec context from non-null video stream");
 		videoCodec = avcodec_find_decoder(videoContext.codec_id);
 		assert(videoCodec !is null, "Unsupported video format");
 		ret = avcodec_open(videoContext, videoCodec);
@@ -84,7 +84,7 @@
 		}
 		assert(audioStream !is null, "Could not find audio stream");
 		audioContext = audioStream.codec;
-		assert(audioContext !is null, "Null codec context from non-null stream");
+		assert(audioContext !is null, "Null codec context from non-null audio stream");
 		audioCodec = avcodec_find_decoder(audioContext.codec_id);
 		assert(audioCodec !is null, "Unsupported audio format");
 		ret = avcodec_open(audioContext, audioCodec);
--- a/src/test/hoofbaby/test/adhoc/transcode.d	Sun Jul 12 03:49:39 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/**
- * Hoofbaby -- http://www.dsource.org/projects/hoofbaby
- * Copyright (C) 2009 Robert Fraser
- * 
- * This program is free software; you can redistribute it andor
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-module hoofbaby.test.adhoc.transcode;
-
-import NONE_1 = tango.stdc.stdarg; // Must be linked in to prevent strange linker errors
-debug import NONE_2 = tango.core.stacktrace.TraceExceptions;
-import NONE_3 = hoofbaby.codec.libav.mingw;
-import hoofbaby.app.libs;
-
-import hoofbaby.codec.decoder;
-import hoofbaby.codec.encoder;
-
-
-public int main(char[][] args)
-{
-	initLibs();
-	scope Decoder dec = new Decoder("../../ref/testv-h264-vorbis-ass.mkv");
-	delete dec;
-	return 0;
-}
-
-/+ 
-
-import Math = tango.math.Math;
-import hoofbaby.codec.libav.avutil;
-import hoofbaby.codec.libav.avcodec;
-import hoofbaby.codec.libav.avformat;
-
-private const int STREAM_FRAME_RATE = 25;
-private const double STREAM_DURATION = 5.0;
-private const int STREAM_NB_FRAMES = (cast(int) (STREAM_DURATION * STREAM_FRAME_RATE));
-private const int WIDTH = 352;
-private const int HEIGHT = 288;
-private const int SAMPLE_RATE = 44100;
-private int AUDIO_FRAME_SIZE;
-
-private int frameCount = 0;
-private double audioCount = 0.0;
-private double audioIncr = 2 * Math.PI * 110.0 / SAMPLE_RATE;
-private double audioIncr2 = 2 * Math.PI * 110.0 / SAMPLE_RATE / SAMPLE_RATE;
-
-private AVFrame* generatePicture(AVFrame* pict, int width, int height)
-{
-	int x, y, i;
-	i = frameCount;
-
-	/* Y */
-	for(y = 0; y < height; y++)
-	{
-		for(x = 0; x < width; x++)
-		{
-			pict.data[0][y * pict.linesize[0] + x] = x + y + i * 3;
-		}
-	}
-
-	/* Cb and Cr */
-	for(y = 0; y < height / 2; y++)
-	{
-		for(x = 0; x < width / 2; x++)
-		{
-			pict.data[1][y * pict.linesize[1] + x] = 128 + y + i * 2;
-			pict.data[2][y * pict.linesize[2] + x] = 64 + x + i * 5;
-		}
-	}
-	
-	return pict;
-}
-
-private short* generateAudio(short* samples)
-{
-	int j, i, v;
-    short *q;
-
-    q = samples;
-    for(j = 0; j < AUDIO_FRAME_SIZE; j++)
-    {
-        v = cast(int)(Math.sin(audioCount) * 10000);
-        for(i = 0; i < 2; i++) // 2 is number of channels
-            *q++ = v;
-        audioCount += audioIncr;
-        audioIncr += audioIncr2;
-    }
-    
-    return samples;
-}
-
-public int main(char[][] args)
-{
-	initLibs();
-	scope Encoder enc = new Encoder("biff_happy.wmv");
-	AUDIO_FRAME_SIZE = enc.audioContext.frame_size;
-	
-	// Allocate a video frame and audio buffer to store stuff
-	AVFrame* frame = avpicture_alloc(PIX_FMT_YUV420P, WIDTH, HEIGHT);
-	assert(frame !is null, "Could not allocate frame");
-	scope(exit) if(frame) av_free(frame);
-	short* samples = cast(short*) av_malloc(AUDIO_FRAME_SIZE * 2 * 2); // AUDIO_FRAME_SIZE * 2 * number of channels
-	assert(frame !is null, "Could not allocate samples");
-	scope(exit) if(samples) av_free(samples);
-	
-	// Write header
-	enc.writeHeader();
-	
-	while(true)
-	{
-		double audio_pts = cast(double) enc.audioStream.pts.val * enc.audioStream.time_base.num / enc.audioStream.time_base.den;
-		double video_pts = cast(double) enc.videoStream.pts.val * enc.videoStream.time_base.num / enc.videoStream.time_base.den;
-	
-		if(audio_pts >= STREAM_DURATION && video_pts >= STREAM_DURATION)
-			break;
-	
-		// Write interleaved audio & video
-		if(audio_pts < video_pts)
-		{
-			enc.writeAudioFrame(generateAudio(samples));
-		}
-		else
-		{
-			if(frameCount >= STREAM_NB_FRAMES)
-			{
-				// no more frame to compress. The codec has a latency of a few
-				// frames if using B frames, so we get the last frames by
-				// passing the same picture again
-			}
-			else
-			{
-				generatePicture(frame, WIDTH, HEIGHT);
-			}
-			
-			enc.writeVideoFrame(frame);
-			frameCount++;
-		}
-	}
-	
-	// Write trailer
-	enc.writeTrailer();
-	
-	return 0;
-}
-+/
\ No newline at end of file