Commit 69bac921 authored by petter's avatar petter

Speeded Thumbnail generation up massively

git-svn-id: https://www2.in.tum.de/repos/ttt/trunk@169 0463f305-d864-43cb-8a47-61cf597d4139
parent e600a44b
......@@ -243,12 +243,14 @@ public class AudioVideoPlayer {
// set playback to new time
public void setTime(int time) {
// linear sync of audio preplay
if (recording.desktop_replay_factor_sync)
if (recording.desktop_replay_factor_sync) {
player.setMediaTime(new Time((long) ((time + replayOffset) / replayRatio) * 1000000l));
else
}
else {
System.out.println("unscaled");
player.setMediaTime(new Time(time * 1000000l));
}
}
......
......@@ -24,7 +24,7 @@ public class WavConcat {
byte[] header = new byte[44]; // stores the header for the wav. (wav header size is are 44 byte)
byte[] InBuffer; //reads each file and writes them then into the OutBuffer
//byte[] InBuffer; //reads each file and writes them then into the OutBuffer
byte[] Offset = new byte[44]; //used to skip the .wav header of the files
FileInputStream fileIn;
int Position = 44; //where to paste the new byte in the OutBuffer
......@@ -67,9 +67,7 @@ public class WavConcat {
private void saveDuration() {
for(File i: InFiles) {
try {
InBuffer = new byte[(int) (i.length() - Offset.length)];
fileIn = new FileInputStream(i);
fileIn.read(Offset);
//Duration = chunk/ bitrate (chunk = informationsize)
......
......@@ -35,6 +35,7 @@ import java.awt.Image;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent;
......@@ -209,10 +210,10 @@ public class GraphicsContext extends JComponent implements GraphicInterface, Mes
// show blank page if whiteboard activated
if (isWhiteboardEnabled()) {
screenshot = new BufferedImage(prefs.framebufferWidth, prefs.framebufferHeight, BufferedImage.TYPE_INT_RGB);
screenshot = new BufferedImage(prefs.framebufferWidth/ thumbnail_scale_factor, prefs.framebufferHeight/ thumbnail_scale_factor, BufferedImage.TYPE_INT_RGB);
Graphics g = screenshot.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, prefs.framebufferWidth, prefs.framebufferHeight);
g.fillRect(0, 0, prefs.framebufferWidth/ thumbnail_scale_factor, prefs.framebufferHeight/ thumbnail_scale_factor);
// g.setColor(Color.black);
// g.setFont(g.getFont().deriveFont(100f));
// g.drawString("WHITEBOARD", 200, 200);
......@@ -222,13 +223,13 @@ public class GraphicsContext extends JComponent implements GraphicInterface, Mes
// show desktop
else {
// Create a buffered image using the default color model
screenshot = new BufferedImage(prefs.framebufferWidth, prefs.framebufferHeight, BufferedImage.TYPE_INT_RGB);
screenshot = new BufferedImage(prefs.framebufferWidth/ thumbnail_scale_factor, prefs.framebufferHeight/ thumbnail_scale_factor, BufferedImage.TYPE_INT_RGB);
// Copy image to buffered image
Graphics g = ((BufferedImage) screenshot).createGraphics();
Graphics2D g = ((BufferedImage) screenshot).createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
// Paint the image onto the buffered image
g.drawImage(memImage, 0, 0, null);
g.drawImage(memImage, 0, 0,prefs.framebufferWidth/ thumbnail_scale_factor, prefs.framebufferHeight / thumbnail_scale_factor ,null);
g.dispose();
}
return screenshot;
......
......@@ -784,12 +784,12 @@ public class Index {
// set time of index
IndexEntry indexEntry = index.get(i);
int timestamp = indexEntry.getTimestamp();
if ((mode & ScriptCreator.OCR_OPTIMIZED) == 0)
if ((mode & ScriptCreator.OCR_OPTIMIZED) == 0)
if (i+1<index.size()){
timestamp += (index.get(i+1).getTimestamp()-timestamp)*.95;
}
recording.setTime(timestamp);
recording.setTime(timestamp,false);
// create screenshot
Image screenshot = recording.graphicsContext.getScreenshotWithoutAnnotations();
......@@ -797,12 +797,12 @@ public class Index {
// set thumbnail
if ((mode & ScriptCreator.THUMBNAILS) != 0) {
// faster image scaling
Image thumbnail = ScriptCreator.getScaledInstance(screenshot, recording.prefs.framebufferWidth
//Image thumbnail = recording.graphicsContext.getThumbnailWithoutAnnotations(thumbnail_scale_factor);
Image thumbnail = ScriptCreator.getScaledInstance(screenshot, recording.prefs.framebufferWidth
/ thumbnail_scale_factor, recording.prefs.framebufferHeight / thumbnail_scale_factor);
indexEntry.setThumbnail(thumbnail);
}
// write input for Optical Character Recognition
......
......@@ -456,7 +456,6 @@ public class ScriptCreator {
// // Image.getScaledInstance() is pretty lame
// // NOTE: unscaled image resists in memory until drawn - draw to new image to free memory
// return img.getScaledInstance(targetWidth, targetHeight, Image.SCALE_SMOOTH);
// that is about 30% faster under Linux
// TODO: Image.getScaledInstance() is suposed to be improved in Java 7 - check again
return getScaledInstance(toBufferedImage(img), targetWidth, targetHeight,
......
......@@ -675,6 +675,10 @@ public class Recording extends MessageProducerAdapter implements Runnable,
* @param time
*/
public void setTime(int time) {
setTime(time,true);
}
public void setTime(int time, boolean skipPlayer) {
time = sync(time);
// System.out.println("set: " + Constants.getStringFromTime(time));
......@@ -698,8 +702,11 @@ public class Recording extends MessageProducerAdapter implements Runnable,
graphicsContext.refresh();
// synchronize audio/video
// only if not adjusting, because synchronizing is slow
if (!adjusting && audioVideoPlayer != null){
if (skipPlayer && !adjusting && audioVideoPlayer != null){
setAudioVideoPlayerTime(time);
}
// t = System.currentTimeMillis() - t;
......@@ -709,9 +716,9 @@ public class Recording extends MessageProducerAdapter implements Runnable,
public void setAudioVideoPlayerTime(int time) {
// synchronize audio/video
if (audioVideoPlayer != null)
audioVideoPlayer.setTime(time);
// notify playback loop
interrupt();
}
......@@ -789,6 +796,7 @@ public class Recording extends MessageProducerAdapter implements Runnable,
if (event instanceof MyChangeEvent) {
adjusting = ((MyChangeEvent) event).adjusting;
if (adjusting) {
System.out.println(" -> Set adjusting!");
// visible scrolling
setTime(((MyChangeEvent) event).time);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment