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 { ...@@ -243,12 +243,14 @@ public class AudioVideoPlayer {
// set playback to new time // set playback to new time
public void setTime(int time) { public void setTime(int time) {
// linear sync of audio preplay // 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)); player.setMediaTime(new Time((long) ((time + replayOffset) / replayRatio) * 1000000l));
else }
else {
System.out.println("unscaled");
player.setMediaTime(new Time(time * 1000000l)); player.setMediaTime(new Time(time * 1000000l));
}
} }
......
...@@ -24,7 +24,7 @@ public class WavConcat { ...@@ -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[] 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 byte[] Offset = new byte[44]; //used to skip the .wav header of the files
FileInputStream fileIn; FileInputStream fileIn;
int Position = 44; //where to paste the new byte in the OutBuffer int Position = 44; //where to paste the new byte in the OutBuffer
...@@ -67,9 +67,7 @@ public class WavConcat { ...@@ -67,9 +67,7 @@ public class WavConcat {
private void saveDuration() { private void saveDuration() {
for(File i: InFiles) { for(File i: InFiles) {
try { try {
InBuffer = new byte[(int) (i.length() - Offset.length)];
fileIn = new FileInputStream(i); fileIn = new FileInputStream(i);
fileIn.read(Offset); fileIn.read(Offset);
//Duration = chunk/ bitrate (chunk = informationsize) //Duration = chunk/ bitrate (chunk = informationsize)
......
...@@ -35,6 +35,7 @@ import java.awt.Image; ...@@ -35,6 +35,7 @@ import java.awt.Image;
import java.awt.Insets; import java.awt.Insets;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ComponentAdapter; import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
...@@ -209,10 +210,10 @@ public class GraphicsContext extends JComponent implements GraphicInterface, Mes ...@@ -209,10 +210,10 @@ public class GraphicsContext extends JComponent implements GraphicInterface, Mes
// show blank page if whiteboard activated // show blank page if whiteboard activated
if (isWhiteboardEnabled()) { 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(); Graphics g = screenshot.getGraphics();
g.setColor(Color.white); 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.setColor(Color.black);
// g.setFont(g.getFont().deriveFont(100f)); // g.setFont(g.getFont().deriveFont(100f));
// g.drawString("WHITEBOARD", 200, 200); // g.drawString("WHITEBOARD", 200, 200);
...@@ -222,13 +223,13 @@ public class GraphicsContext extends JComponent implements GraphicInterface, Mes ...@@ -222,13 +223,13 @@ public class GraphicsContext extends JComponent implements GraphicInterface, Mes
// show desktop // show desktop
else { else {
// Create a buffered image using the default color model // 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 // 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 // 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(); g.dispose();
} }
return screenshot; return screenshot;
......
...@@ -784,12 +784,12 @@ public class Index { ...@@ -784,12 +784,12 @@ public class Index {
// set time of index // set time of index
IndexEntry indexEntry = index.get(i); IndexEntry indexEntry = index.get(i);
int timestamp = indexEntry.getTimestamp(); int timestamp = indexEntry.getTimestamp();
if ((mode & ScriptCreator.OCR_OPTIMIZED) == 0) if ((mode & ScriptCreator.OCR_OPTIMIZED) == 0)
if (i+1<index.size()){ if (i+1<index.size()){
timestamp += (index.get(i+1).getTimestamp()-timestamp)*.95; timestamp += (index.get(i+1).getTimestamp()-timestamp)*.95;
} }
recording.setTime(timestamp); recording.setTime(timestamp,false);
// create screenshot // create screenshot
Image screenshot = recording.graphicsContext.getScreenshotWithoutAnnotations(); Image screenshot = recording.graphicsContext.getScreenshotWithoutAnnotations();
...@@ -797,12 +797,12 @@ public class Index { ...@@ -797,12 +797,12 @@ public class Index {
// set thumbnail // set thumbnail
if ((mode & ScriptCreator.THUMBNAILS) != 0) { if ((mode & ScriptCreator.THUMBNAILS) != 0) {
// faster image scaling // 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); / thumbnail_scale_factor, recording.prefs.framebufferHeight / thumbnail_scale_factor);
indexEntry.setThumbnail(thumbnail); indexEntry.setThumbnail(thumbnail);
} }
// write input for Optical Character Recognition // write input for Optical Character Recognition
......
...@@ -456,7 +456,6 @@ public class ScriptCreator { ...@@ -456,7 +456,6 @@ public class ScriptCreator {
// // Image.getScaledInstance() is pretty lame // // Image.getScaledInstance() is pretty lame
// // NOTE: unscaled image resists in memory until drawn - draw to new image to free memory // // NOTE: unscaled image resists in memory until drawn - draw to new image to free memory
// return img.getScaledInstance(targetWidth, targetHeight, Image.SCALE_SMOOTH); // return img.getScaledInstance(targetWidth, targetHeight, Image.SCALE_SMOOTH);
// that is about 30% faster under Linux // that is about 30% faster under Linux
// TODO: Image.getScaledInstance() is suposed to be improved in Java 7 - check again // TODO: Image.getScaledInstance() is suposed to be improved in Java 7 - check again
return getScaledInstance(toBufferedImage(img), targetWidth, targetHeight, return getScaledInstance(toBufferedImage(img), targetWidth, targetHeight,
......
...@@ -675,6 +675,10 @@ public class Recording extends MessageProducerAdapter implements Runnable, ...@@ -675,6 +675,10 @@ public class Recording extends MessageProducerAdapter implements Runnable,
* @param time * @param time
*/ */
public void setTime(int time) { public void setTime(int time) {
setTime(time,true);
}
public void setTime(int time, boolean skipPlayer) {
time = sync(time); time = sync(time);
// System.out.println("set: " + Constants.getStringFromTime(time)); // System.out.println("set: " + Constants.getStringFromTime(time));
...@@ -698,8 +702,11 @@ public class Recording extends MessageProducerAdapter implements Runnable, ...@@ -698,8 +702,11 @@ public class Recording extends MessageProducerAdapter implements Runnable,
graphicsContext.refresh(); graphicsContext.refresh();
// synchronize audio/video // synchronize audio/video
// only if not adjusting, because synchronizing is slow // only if not adjusting, because synchronizing is slow
if (!adjusting && audioVideoPlayer != null){ if (skipPlayer && !adjusting && audioVideoPlayer != null){
setAudioVideoPlayerTime(time); setAudioVideoPlayerTime(time);
} }
// t = System.currentTimeMillis() - t; // t = System.currentTimeMillis() - t;
...@@ -709,9 +716,9 @@ public class Recording extends MessageProducerAdapter implements Runnable, ...@@ -709,9 +716,9 @@ public class Recording extends MessageProducerAdapter implements Runnable,
public void setAudioVideoPlayerTime(int time) { public void setAudioVideoPlayerTime(int time) {
// synchronize audio/video // synchronize audio/video
if (audioVideoPlayer != null) if (audioVideoPlayer != null)
audioVideoPlayer.setTime(time); audioVideoPlayer.setTime(time);
// notify playback loop // notify playback loop
interrupt(); interrupt();
} }
...@@ -789,6 +796,7 @@ public class Recording extends MessageProducerAdapter implements Runnable, ...@@ -789,6 +796,7 @@ public class Recording extends MessageProducerAdapter implements Runnable,
if (event instanceof MyChangeEvent) { if (event instanceof MyChangeEvent) {
adjusting = ((MyChangeEvent) event).adjusting; adjusting = ((MyChangeEvent) event).adjusting;
if (adjusting) { if (adjusting) {
System.out.println(" -> Set adjusting!");
// visible scrolling // visible scrolling
setTime(((MyChangeEvent) event).time); setTime(((MyChangeEvent) event).time);
} else { } 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