Skip to content

Commit

Permalink
Merge pull request #308 from bl-dpt/rf64-support
Browse files Browse the repository at this point in the history
WAVE: RF64, extended MIME type support, and bug fixes
  • Loading branch information
carlwilson authored Mar 29, 2018
2 parents d383b37 + e346e43 commit b46ffe7
Show file tree
Hide file tree
Showing 38 changed files with 809 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ public void setBitrateReduction (String codecName,
*/
public static interface TimeDesc {
/** Returns the hours component. */
public int getHours ();
public long getHours ();
/** Returns the minutes component. */
public int getMinutes ();
public long getMinutes ();
/** Returns the seconds component. */
public int getSeconds ();
public long getSeconds ();
/** Returns the frames component of the fraction of a second.
* We always consider frames to be thirtieths of a second. */
public int getFrames ();
public long getFrames ();
/** Returns the samples remaining after the frames part of
* the fractional second. */
public int getSamples ();
public long getSamples ();
/** Returns the sample rate on which the samples remainder
* is based. */
public double getSampleRate ();
Expand Down Expand Up @@ -361,13 +361,13 @@ public void setWordSize (int wordSize)
*/
class TimeDescImpl implements TimeDesc
{
private int _hours;
private int _minutes;
private int _seconds;
private int _frames;
private int _samples;
private long _hours;
private long _minutes;
private long _seconds;
private long _frames;
private long _samples;
private double _sampleRate;
private int _frameCount;
private long _frameCount;

/* Constructor rewritten to avoid rounding errors when converting to
* TCF. Now uses integer remainder math instead of floating point.
Expand Down Expand Up @@ -405,15 +405,15 @@ public TimeDescImpl (long samples)
_sample_count = (_sample_count % sample_in_1_day);
}

_hours = (int)(_sample_count / sample_in_1_hour);
_sample_count -= (_hours * sample_in_1_hour);
_minutes = (int)(_sample_count / sample_in_1_minute);
_sample_count -= (_minutes * sample_in_1_minute);
_seconds = (int)(_sample_count / sample_in_1_second);
_sample_count -= (_seconds * sample_in_1_second);
_frames = (int)(_sample_count / sample_in_1_frame);
_sample_count -= (_frames * sample_in_1_frame);
_samples = (int)_sample_count;
_hours = _sample_count / sample_in_1_hour;
_sample_count -= _hours * sample_in_1_hour;
_minutes = _sample_count / sample_in_1_minute;
_sample_count -= _minutes * sample_in_1_minute;
_seconds = _sample_count / sample_in_1_second;
_sample_count -= _seconds * sample_in_1_second;
_frames = _sample_count / sample_in_1_frame;
_sample_count -= _frames * sample_in_1_frame;
_samples = _sample_count;

/* At present TCF does not have the ability to handle time stamps
* > midnight. Industry practice is to roll the clock forward to
Expand All @@ -424,29 +424,29 @@ public TimeDescImpl (long samples)
}

/** Returns the hours component. */
public int getHours () {
public long getHours () {
return _hours;
}

/** Returns the minutes component. */
public int getMinutes () {
public long getMinutes () {
return _minutes;
}

/** Returns the seconds component. */
public int getSeconds () {
public long getSeconds () {
return _seconds;
}

/** Returns the frames component of the fraction of a second.
* We always consider frames to be thirtieths of a second. */
public int getFrames () {
public long getFrames () {
return _frames;
}

/** Returns the samples remaining after the frames part of
* the fractional second. */
public int getSamples () {
public long getSamples () {
return _samples;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public class JhoveBase {
* Instantiates a <code>JhoveBase</code> object.
*
* @throws JhoveException
* If invoked with JVM lower than 1.6
* if invoked with a JVM lower than 1.6
*/
public JhoveBase() throws JhoveException {

Expand Down
28 changes: 21 additions & 7 deletions jhove-core/src/main/java/edu/harvard/hul/ois/jhove/ModuleBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1099,9 +1099,7 @@ public static long readUnsignedInt (RandomAccessFile file,


/**
* Reads eight bytes as a signed 64-bit value from a
* DataInputStream. (There is no way in Java to have
* an unsigned long.)
* Reads eight bytes as a signed 64-bit value from a DataInputStream.
*
* @param stream The stream to read from.
* @param bigEndian If true, interpret the first byte as the high
Expand Down Expand Up @@ -1372,12 +1370,28 @@ public long skipBytes(DataInputStream stream, long bytesToSkip,
{
long totalBytesSkipped = 0;
while (bytesToSkip > 0) {
long bytesSkipped = stream.skip(bytesToSkip);
long bytesSkipped;
long availableBytes = stream.available();
if (availableBytes == 0) break;
// The count of skipped bytes returned by FileInputStream's 'skip'
// method is unreliable and may be greater than what was available
// to skip. So we need to monitor and correct any discrepancies
// ourselves. Luckily the 'available' method seems to accurately
// report the number of bytes available to be skipped, but because
// it returns an int, we're limited to skipping Integer.MAX_VALUE
// each call lest we skip more bytes than we can verify.
if (bytesToSkip > availableBytes) {
bytesSkipped = stream.skip(availableBytes);
} else {
bytesSkipped = stream.skip(bytesToSkip);
}
// If it reports skipping more bytes than were available,
// correct it to the most it could have skipped.
if (bytesSkipped > availableBytes) {
bytesSkipped = availableBytes;
}
totalBytesSkipped += bytesSkipped;
bytesToSkip -= bytesSkipped;
// Cease skipping if end of stream reached before
// requested number of bytes have been skipped.
if (stream.available() == 0) break;
}
if (counted != null) {
counted._nByte += totalBytesSkipped;
Expand Down
Loading

0 comments on commit b46ffe7

Please sign in to comment.