Skip to content

Commit

Permalink
AVIReader/AWriter does not inherit from AVIInputStream/OutputStream a…
Browse files Browse the repository at this point in the history
…nymore.

QuickTimeReader/Writer does not inherit from QuickTimeInputStream/OutputStream anymore.
  • Loading branch information
wrandelshofer committed Aug 9, 2024
1 parent 8584d5f commit 5d68072
Show file tree
Hide file tree
Showing 84 changed files with 619 additions and 381 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import org.monte.media.swing.BackgroundTask;
import org.monte.media.tree.TreeNode;

import javax.swing.*;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -63,7 +65,7 @@ public Main() {
IFFParser.stringToID("DLTA"),
IFFParser.stringToID("BODY"),};

private static Comparator<IFFChunkNode> nodeComparator = new Comparator<IFFChunkNode>() {
private static Comparator<IFFChunkNode> nodeComparator = new Comparator<>() {
/*
public int compare(Object o1, Object o2) {
return compare((IFFChunkNode) o1, (IFFChunkNode) o2);
Expand Down Expand Up @@ -114,7 +116,7 @@ public void mergeFrom(IFFChunkNode that) {
} else {

if (this.isSameAs(that)) {
final ArrayList<IFFChunkNode> mergedChildren = new ArrayList<IFFChunkNode>(Math.max(this.getChildCount(), that.getChildCount()));
final ArrayList<IFFChunkNode> mergedChildren = new ArrayList<>(Math.max(this.getChildCount(), that.getChildCount()));
this.sortChildren(nodeComparator);
that.sortChildren(nodeComparator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void main(String[] args) {

// Parse arguments
File outfile = null;
ArrayList<File> infiles = new ArrayList<File>();
ArrayList<File> infiles = new ArrayList<>();

try {
char arg = ' ';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
import org.monte.media.av.codec.video.VideoFormatKeys;
import org.monte.media.image.Images;

import javax.swing.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
Expand All @@ -35,7 +39,7 @@ public class ReadAVIDemo {
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
final ArrayList<BufferedImage> frames = new ArrayList<BufferedImage>();
final ArrayList<BufferedImage> frames = new ArrayList<>();
final File f = new File("/Users/Shared/Developer/Java/MonteMedia/current/trunk/MonteMedia/avidemo-tscc8.avi");
MovieReader in = Registry.getInstance().getReader(f);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import org.monte.media.image.Images;
import org.monte.media.math.Rational;

import java.awt.*;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.IndexColorModel;
import java.io.File;
Expand Down Expand Up @@ -52,7 +54,7 @@ public class ReadWriteDemoMain {
*/
public static void main(String[] args) {
try {
HashSet<String> usedFilenames = new HashSet<String>();
HashSet<String> usedFilenames = new HashSet<>();

// Test all available AVI video formats
for (Codec c : Registry.getInstance().getEncoders(new Format(MimeTypeKey, MIME_AVI, MediaTypeKey, MediaType.VIDEO))) {
Expand Down Expand Up @@ -160,7 +162,7 @@ FrameRateKey, new Rational(30, 1),//
}

private static BufferedImage[] readMovie(File file) throws IOException {
ArrayList<BufferedImage> frames = new ArrayList<BufferedImage>();
ArrayList<BufferedImage> frames = new ArrayList<>();

MovieReader in = Registry.getInstance().getReader(file);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void main(String[] args) {

// Parse arguments
File outfile = null;
ArrayList<File> infiles = new ArrayList<File>();
ArrayList<File> infiles = new ArrayList<>();
Rational start = null;
Rational end = null;
String startString = null, durationString = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.*;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.ProgressMonitor;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileSystemView;
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.io.File;
Expand Down Expand Up @@ -845,7 +851,7 @@ private void writeVideoAndAudio(File movieFile, File[] imgFiles, File audioFile,
}
}
if (longerTrack != -1) {
LinkedList<QuickTimeWriter.Edit> l = new LinkedList<QuickTimeWriter.Edit>();
LinkedList<QuickTimeWriter.Edit> l = new LinkedList<>();
l.add(new QuickTimeWriter.Edit(shorterDuration, 0, 1.0)); // sampleDuration, media time, media rate
qtOut.setEditList(longerTrack, l.toArray(new QuickTimeWriter.Edit[l.size()]));
}
Expand Down Expand Up @@ -874,7 +880,7 @@ private void writeVideoAndAudio(File movieFile, File[] imgFiles, File audioFile,
}
}
if (longerTrack != -1) {
LinkedList<QuickTimeWriter.Edit> l = new LinkedList<QuickTimeWriter.Edit>();
LinkedList<QuickTimeWriter.Edit> l = new LinkedList<>();
for (; longerDuration > 0; longerDuration -= shorterDuration) {
l.add(new QuickTimeWriter.Edit(min(shorterDuration, longerDuration), 0, 1.0)); // sampleDuration, media time, media rate
}
Expand All @@ -886,7 +892,7 @@ private void writeVideoAndAudio(File movieFile, File[] imgFiles, File audioFile,
long d0 = qtOut.getTrackDuration(at);
long d1 = qtOut.getTrackDuration(vt);
if (d0 != d1 && d0 != 0 && d1 != 0) {
LinkedList<QuickTimeWriter.Edit> l = new LinkedList<QuickTimeWriter.Edit>();
LinkedList<QuickTimeWriter.Edit> l = new LinkedList<>();
l.add(new QuickTimeWriter.Edit((int) d0, 0, d1 / (float) d0)); // sampleDuration, media time, media rate
qtOut.setEditList(1, l.toArray(new QuickTimeWriter.Edit[l.size()]));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
package org.monte.demo.moviereader;


import org.monte.media.av.*;

import javax.swing.*;
import org.monte.media.av.Buffer;
import org.monte.media.av.BufferFlag;
import org.monte.media.av.Codec;
import org.monte.media.av.Format;
import org.monte.media.av.FormatKeys;
import org.monte.media.av.MovieReader;
import org.monte.media.av.Registry;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
Expand Down Expand Up @@ -140,7 +152,7 @@ protected void done() {
}

private List<BufferedImage> readCaptions(File file) throws IOException {
List<BufferedImage> frames = new ArrayList<BufferedImage>();
List<BufferedImage> frames = new ArrayList<>();
MovieReader in = Registry.getInstance().getReader(file);
if (in == null)
throw new IOException("could not find a reader for file " + file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@
package org.monte.demo.moviereader;


import org.monte.media.av.*;
import org.monte.media.av.Buffer;
import org.monte.media.av.BufferFlag;
import org.monte.media.av.Codec;
import org.monte.media.av.Format;
import org.monte.media.av.FormatKeys;
import org.monte.media.av.MovieReader;
import org.monte.media.av.Registry;
import org.monte.media.image.Images;

import javax.swing.*;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
Expand All @@ -38,22 +50,24 @@ public class ReadImagesFromAMovieMain {
*
* @param args the command line arguments
*/
public static void main(String args[]) throws IOException {
public static void main(String args[]) throws Exception {
if (args.length != 1) {
System.err.println("""
Usage:
Main <inputfile>
Where arguments are:
inputfile
the path to a movie file (AVI)
""");
Usage:
Main <inputfile>
Where arguments are:
inputfile
the path to a movie file (AVI)
""");
}
File file = new File(args[0]);
ReadImagesFromAMovieMain main = new ReadImagesFromAMovieMain();
SwingUtilities.invokeLater(() -> {
SwingUtilities.invokeAndWait(() -> {
main.createFrame();
main.loadImages(file);
if (args.length == 1) {
File file = new File(args[0]);
main.loadImages(file);
}
});
}

Expand Down Expand Up @@ -139,7 +153,7 @@ protected void done() {
}

private List<BufferedImage> readImages(File file) throws IOException {
List<BufferedImage> frames = new ArrayList<BufferedImage>();
List<BufferedImage> frames = new ArrayList<>();
MovieReader in = Registry.getInstance().getReader(file);
if (in == null)
throw new IOException("could not find a reader for file " + file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.TargetDataLine;
import javax.swing.*;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
Expand Down Expand Up @@ -272,7 +288,7 @@ public void actionPerformed(ActionEvent e) {
mouseRateField.setModel(mouseRateModel);

// FIXME - 8-bit recording is currently broken
audioRateChoice.setModel(new DefaultComboBoxModel<AudioRateItem>(new AudioRateItem[]{
audioRateChoice.setModel(new DefaultComboBoxModel<>(new AudioRateItem[]{
//new AudioItem("No Audio", 0, 0),
//new AudioItem("8.000 Hz, 8-bit",8000,8),
new AudioRateItem("8.000 Hz", 8000, 16),
Expand All @@ -284,7 +300,7 @@ public void actionPerformed(ActionEvent e) {
new AudioRateItem("44.100 Hz", 44100, 16),}));
audioRate = prefs.getInt("ScreenRecording.audioRate", 0);
audioRateChoice.setSelectedIndex(audioRate);
audioSourceChoice.setModel(new DefaultComboBoxModel<AudioSourceItem>(getAudioSources()));
audioSourceChoice.setModel(new DefaultComboBoxModel<>(getAudioSources()));
audioSource = prefs.getInt("ScreenRecording.audioSource", 0);
audioSourceChoice.setSelectedIndex(audioSource);

Expand All @@ -293,7 +309,7 @@ public void actionPerformed(ActionEvent e) {
Point customLoc = new Point(
prefs.getInt("ScreenRecording.customAreaX", 100),
prefs.getInt("ScreenRecording.customAreaY", 100));
areaChoice.setModel(new DefaultComboBoxModel<AreaItem>(new AreaItem[]{
areaChoice.setModel(new DefaultComboBoxModel<>(new AreaItem[]{
new AreaItem("Entire Screen", null, SwingConstants.NORTH_WEST),
new AreaItem("Center 1280 x 720", new Dimension(1280, 720), SwingConstants.CENTER),
new AreaItem("Center 1024 x 768", new Dimension(1024, 768), SwingConstants.CENTER),
Expand Down Expand Up @@ -548,7 +564,7 @@ public void windowOpened(java.awt.event.WindowEvent evt) {
}// </editor-fold>//GEN-END:initComponents

private static Vector<AudioSourceItem> getAudioSources() {
Vector<AudioSourceItem> l = new Vector<AudioSourceItem>();
Vector<AudioSourceItem> l = new Vector<>();

l.add(new AudioSourceItem("None", null, false));
l.add(new AudioSourceItem("Default Input", null, true));
Expand Down Expand Up @@ -819,11 +835,11 @@ private void updateEncodingChoice() {
switch (formatChoice.getSelectedIndex()) {
case 0: // AVI
encodingChoice.setModel(
new javax.swing.DefaultComboBoxModel<String>(new String[]{"Screen Capture", "Run Length", "None", "PNG", "JPEG 100 %", "JPEG 50 %"}));
new javax.swing.DefaultComboBoxModel<>(new String[]{"Screen Capture", "Run Length", "None", "PNG", "JPEG 100 %", "JPEG 50 %"}));
break;
case 1: // QuickTime
encodingChoice.setModel(
new javax.swing.DefaultComboBoxModel<String>(new String[]{"Screen Capture", "Animation", "None", "PNG", "JPEG 100 %", "JPEG 50 %"}));
new javax.swing.DefaultComboBoxModel<>(new String[]{"Screen Capture", "Animation", "None", "PNG", "JPEG 100 %", "JPEG 50 %"}));
break;
}
encodingChoice.setSelectedIndex(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import org.monte.media.iff.MutableIFFChunk;
import org.monte.media.ilbm.ColorCyclingMemoryImageSource;

import java.awt.*;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
Expand Down Expand Up @@ -51,7 +53,7 @@ private AmigaBitmapImageFactory() {
*/
public static BufferedImage toBufferedImage(AmigaBitmapImage bm) {
BufferedImage image = null;
Hashtable<?, ?> properties = new Hashtable<Object, Object>();
Hashtable<?, ?> properties = new Hashtable<>();
//properties.put("comment","AmigaBitmapImage");

bm.convertToChunky();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
package org.monte.media.amigabitmap;

import java.awt.*;
import java.awt.Dimension;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
Expand Down Expand Up @@ -83,7 +83,7 @@ public boolean isInterlace() {

public static Map<Integer, AmigaDisplayInfo> getAllInfos() {
if (infos == null) {
infos = new TreeMap<Integer, AmigaDisplayInfo>();
infos = new TreeMap<>();
for (Object[] e : infoTable) {
int i = 0;
int camg = (Integer) e[i++];
Expand Down Expand Up @@ -223,7 +223,7 @@ public MonitorItem(String name, int fps) {
private final static TreeMap<Integer, MonitorItem> monitorToFPSMap;

static {
monitorToFPSMap = new TreeMap<Integer, MonitorItem>();
monitorToFPSMap = new TreeMap<>();
monitorToFPSMap.put(DEFAULT_MONITOR_ID, new MonitorItem("NTSC OCS", 60));
monitorToFPSMap.put(NTSC_MONITOR_ID, new MonitorItem("NTSC", 60));
monitorToFPSMap.put(PAL_MONITOR_ID, new MonitorItem("PAL", 50));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ANIMAudioCommand[] getAudioCommands() {
public void cleanUpAudioCommands() {
if (audioCommands != null && audioCommands.length > 1) {
int i, j;
ArrayList<ANIMAudioCommand> v = new ArrayList<ANIMAudioCommand>();
ArrayList<ANIMAudioCommand> v = new ArrayList<>();
v.add(audioCommands[0]);
for (i = 1; i < audioCommands.length; i++) {
for (j = 0; j < i; j++) {
Expand Down
Loading

0 comments on commit 5d68072

Please sign in to comment.