diff src/test/hoofbaby/test/adhoc/transcode.d @ 8:71ebad05f542

It seems to be successfully opening input files... Now to transcode!
author fraserofthenight
date Sun, 12 Jul 2009 03:49:39 -0700
parents 9fdfe4a64a13
children
line wrap: on
line diff
--- a/src/test/hoofbaby/test/adhoc/transcode.d	Sun Jul 12 03:04:27 2009 -0700
+++ b/src/test/hoofbaby/test/adhoc/transcode.d	Sun Jul 12 03:49:39 2009 -0700
@@ -20,9 +20,21 @@
 import NONE_3 = hoofbaby.codec.libav.mingw;
 import hoofbaby.app.libs;
 
-import Math = tango.math.Math;
 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;
@@ -40,26 +52,6 @@
 private double audioIncr = 2 * Math.PI * 110.0 / SAMPLE_RATE;
 private double audioIncr2 = 2 * Math.PI * 110.0 / SAMPLE_RATE / SAMPLE_RATE;
 
-private AVFrame* allocFrame(int pix_fmt, int width, int height)
-{
-	AVFrame* picture;
-	char* buf;
-	int size;
-
-	picture = avcodec_alloc_frame();
-	if(!picture)
-		return null;
-	size = avpicture_get_size(pix_fmt, width, height);
-	buf = cast(char*) av_malloc(size);
-	if(!buf)
-	{
-		av_free(picture);
-		return null;
-	}
-	avpicture_fill(cast(AVPicture*) picture, buf, pix_fmt, width, height);
-	return picture;
-}
-
 private AVFrame* generatePicture(AVFrame* pict, int width, int height)
 {
 	int x, y, i;
@@ -108,16 +100,11 @@
 public int main(char[][] args)
 {
 	initLibs();
-	scope Decoder dec = new Decoder("../../ref/testv-h264-vorbis-ass.mkv");
-	return 0;
-	
-	/+ 
-	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 = allocFrame(PIX_FMT_YUV420P, WIDTH, HEIGHT);
+	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
@@ -127,14 +114,14 @@
 	// Write header
 	enc.writeHeader();
 	
-    while(true)
+	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)
 		{
@@ -157,9 +144,10 @@
 			frameCount++;
 		}
 	}
-    
-    // Write trailer
+	
+	// Write trailer
 	enc.writeTrailer();
 	
-	return 0; +/
-}
\ No newline at end of file
+	return 0;
+}
++/
\ No newline at end of file