FileDocCategorySizeDatePackage
JPEGFormat.javaAPI DocJMF 2.1.1e6789Mon May 12 12:20:34 BST 2003javax.media.format

JPEGFormat

public class JPEGFormat extends VideoFormat
Describes JPEG compressed video data.
since
JMF 2.0

Fields Summary
public static final int
DEC_422
JPEG 422 decimation.
public static final int
DEC_420
JPEG 420 decimation.
public static final int
DEC_444
JPEG 444 decimation.
public static final int
DEC_402
JPEG 402 decimation.
public static final int
DEC_411
JPEG 411 decimation.
int
qFactor
JPEG encoding parameter quality factor.
int
decimation
Indicates whether or not JPEG decimation is used.
Constructors Summary
public JPEGFormat()
Constructs a default JPEGFormat object.



              
      
	super(VideoFormat.JPEG);
    
public JPEGFormat(Dimension size, int maxDataLength, Class dataType, float frameRate, int q, int dec)
Constructs a JPEGFormat with the specified parameters.

param
size A Dimension that specifies the frame size.
param
maxDataLength The maximum size of the compressed data array.
param
dataType The class type of the data.
param
frameRate The frame rate of the video.
param
q The JPEG quality factor. This is a value from 0 to 100, where 0 is the lowest quality and 100 is the highest.
param
dec The JPEG decimation used.

	super(VideoFormat.JPEG, size, maxDataLength, dataType, frameRate);
	this.qFactor = q;
	this.decimation = dec;
    
Methods Summary
public java.lang.Objectclone()
Creates a clone of this JPEGFormat by copying each format attribute to the clone.

return
A clone of this JPEGFormat.

	JPEGFormat f = new JPEGFormat(getSize(), getMaxDataLength(),
				getDataType(), getFrameRate(),
				qFactor, decimation);
	f.copy(this);
	return f;
    
protected voidcopy(javax.media.Format f)
Copies the attributes from the specified Format into this JPEGFormat.

param
f The Format to copy the attributes from.

	super.copy(f);
	JPEGFormat jf = (JPEGFormat)f;
	qFactor = jf.qFactor;
	decimation = jf.decimation;
    
public booleanequals(java.lang.Object format)
Compares the specified Format with this JPEGFormat. Returns true only if the specified Format is an JPEGFormat and all of its attributes are identical to this JPEGFormat.

param
format The Format to compare with this one.
return
true if the specified Format is the same, false if it is not.

	if (format instanceof JPEGFormat) {
	    JPEGFormat vf = (JPEGFormat)format;

	    return super.equals(format) &&
		qFactor == vf.qFactor &&
		decimation == vf.decimation;
	}
	return false;
    
public intgetDecimation()
Gets the decimation of the video.

return
An integer that indicates the decimation of this Format: DEC_422, DEC_420, DEC_444, DEC_402, or DEC_411.

	return decimation;
    
public intgetQFactor()
Gets the JPEG quality factor for this JPEGFormat.

return
An integer in the range 0 to 100, where 0 is the lowest quality and 100 is the highest.

	return qFactor;
    
public javax.media.Formatintersects(javax.media.Format format)
Finds the attributes shared by two matching Format objects. If the specified Format does not match this one, the result is undefined.

param
The matching Format to intersect with this JPEGFormat.
return
A Format object with its attributes set to those attributes common to both Format objects.
see
#matches

	Format fmt;
	if ((fmt = super.intersects(format)) == null)
	    return null;
	if (!(format instanceof JPEGFormat))
	    return fmt;
	JPEGFormat other = (JPEGFormat)format;
	JPEGFormat res = (JPEGFormat)fmt;
	res.qFactor = (qFactor != NOT_SPECIFIED ?
			 qFactor : other.qFactor);
	res.decimation = (decimation != NOT_SPECIFIED ?
			 decimation : other.decimation);
	return res;
    
public booleanmatches(javax.media.Format format)
Checks whether or not the specified Format matches this JPEGFormat. Matches only compares the attributes that are defined in the specified Format, unspecified attributes are ignored.

The two Format objects do not have to be of the same class to match. For example, if "A" are "B" are being compared, a match is possible if "A" is derived from "B" or "B" is derived from "A". (The compared attributes must still match, or matches fails.)

param
format The Format to compare with this one.
return
true if the specified Format matches this one, false if it does not.

	if (!super.matches(format))
	    return false;
	if (!(format instanceof JPEGFormat))
	    return true;

	JPEGFormat vf = (JPEGFormat)format;

	return 
	    (qFactor == NOT_SPECIFIED || vf.qFactor == NOT_SPECIFIED ||
	     qFactor == vf.qFactor) &&
	    (decimation == NOT_SPECIFIED || vf.decimation == NOT_SPECIFIED ||
	     decimation == vf.decimation);
    
public java.lang.StringtoString()
Gets a String representation of the attributes of this JPEGFormat. For example: "JPEG, 352x240, ...".

return
A String that describes the JPEGFormat attributes.

	String s = getEncoding() + " video format:";
	if (size != null)
	    s += " size = " + size.width + "x" + size.height;
	if (frameRate != NOT_SPECIFIED)
	    s += " FrameRate = " + frameRate;
	if (maxDataLength != NOT_SPECIFIED)
	    s += " maxDataLength = " + maxDataLength;
	if (dataType != null)
	    s += " dataType = " + dataType;
	if (qFactor != NOT_SPECIFIED)
	    s += " q factor = " + qFactor;
	if (decimation != NOT_SPECIFIED)
	    s += " decimation = " + decimation;
	return s;