FileDocCategorySizeDatePackage
AviVideoFormat.javaAPI DocJMF 2.1.1e7401Mon May 12 12:20:58 BST 2003com.sun.media.format

AviVideoFormat

public class AviVideoFormat extends VideoFormat
An extended video format class that contains additional information from the video header of an AVI file. This includes codec specific information required by certain codecs.

Fields Summary
protected int
planes
protected int
bitsPerPixel
protected int
imageSize
protected int
xPelsPerMeter
protected int
yPelsPerMeter
protected int
clrUsed
protected int
clrImportant
protected byte[]
codecSpecificHeader
Constructors Summary
public AviVideoFormat(String encoding)


       
	super(encoding);
    
public AviVideoFormat(String encoding, Dimension size, int maxDataLength, Class dataType, float frameRate, int planes, int bitsPerPixel, int imageSize, int xPelsPerMeter, int yPelsPerMeter, int clrUsed, int clrImportant, byte[] codecHeader)


	super(encoding, size, maxDataLength, dataType, frameRate);
	
	this.planes = planes;
	this.bitsPerPixel = bitsPerPixel;
	this.imageSize = imageSize;
	this.xPelsPerMeter = xPelsPerMeter;
	this.yPelsPerMeter = yPelsPerMeter;
	this.clrUsed = clrUsed;
	this.clrImportant = clrImportant;
	this.codecSpecificHeader = codecHeader;
    
Methods Summary
public java.lang.Objectclone()
Return a clone of this format.

	AviVideoFormat f = new AviVideoFormat(encoding);
	f.copy(this);
	return f;
    
protected voidcopy(javax.media.Format f)
Copy the attributes from the given object.

	super.copy(f);
	if (f instanceof AviVideoFormat) {
	    AviVideoFormat other = (AviVideoFormat) f;
	    planes = other.planes;
	    bitsPerPixel = other.bitsPerPixel;
	    imageSize = other.imageSize;
	    xPelsPerMeter = other.xPelsPerMeter;
	    yPelsPerMeter = other.yPelsPerMeter;
	    clrUsed = other.clrUsed;
	    clrImportant = other.clrImportant;
	    codecSpecificHeader = other.codecSpecificHeader;
	}
    
public booleanequals(java.lang.Object format)

return
True if the given format is the same as this one.

	if (format instanceof AviVideoFormat) {
	    AviVideoFormat other = (AviVideoFormat) format;
	    
	    boolean result = super.equals(format) &&
		planes == other.planes &&
		bitsPerPixel == other.bitsPerPixel &&
		imageSize == other.imageSize &&
		xPelsPerMeter == other.xPelsPerMeter &&
		yPelsPerMeter == other.yPelsPerMeter &&
		clrUsed == other.clrUsed &&
		clrImportant == other.clrImportant;
	    if (result == false)
		return false;
	    else {
		if (codecSpecificHeader == other.codecSpecificHeader)
		    return true;
		if (codecSpecificHeader == null ||
		    other.codecSpecificHeader == null)
		    return false;
		if (codecSpecificHeader.length != other.codecSpecificHeader.length)
		    return false;
		for (int i = 0; i < codecSpecificHeader.length; i++)
		    if (codecSpecificHeader[i] != other.codecSpecificHeader[i])
			return false;
		return true;
	    }
	} else
	    return false;
    
public intgetBitsPerPixel()

	return bitsPerPixel;
    
public intgetClrImportant()

	return clrImportant;
    
public intgetClrUsed()

	return clrUsed;
    
public byte[]getCodecSpecificHeader()

	return codecSpecificHeader;
    
public intgetImageSize()

	return imageSize;
    
public intgetPlanes()

	return planes;
    
public intgetXPelsPerMeter()

	return xPelsPerMeter;
    
public intgetYPelsPerMeter()

	return yPelsPerMeter;
    
public javax.media.Formatintersects(javax.media.Format format)
Find the common attributes of two matching formats. If the given format does not match this one, the result is undefined. Otherwise, it returns a format object with its attributes set to the common attributes of the two.

return
a format object with its attributes set to the common attributes of the two.
see
matches

	Format fmt;
	if ((fmt = super.intersects(format)) == null)
	    return null;
	if (!(format instanceof AviVideoFormat))
	    return fmt;
	AviVideoFormat other = (AviVideoFormat)format;
	AviVideoFormat res = (AviVideoFormat)fmt;
	res.planes = (planes != NOT_SPECIFIED ?
		      planes : other.planes);
	res.bitsPerPixel = (bitsPerPixel != NOT_SPECIFIED ?
			    bitsPerPixel : other.bitsPerPixel);
	res.imageSize = (imageSize != NOT_SPECIFIED ?
			 imageSize : other.imageSize);
	res.xPelsPerMeter = (xPelsPerMeter != NOT_SPECIFIED ?
			     xPelsPerMeter : other.xPelsPerMeter);
	res.yPelsPerMeter = (yPelsPerMeter != NOT_SPECIFIED ?
			     yPelsPerMeter : other.yPelsPerMeter);
	res.clrUsed = (clrUsed != NOT_SPECIFIED ?
		       clrUsed : other.clrUsed);
	res.clrImportant = (clrImportant != NOT_SPECIFIED ?
			    clrImportant : other.clrImportant);
	res.codecSpecificHeader = (codecSpecificHeader != null ?
				   codecSpecificHeader : other.codecSpecificHeader);
	return res;
    
public booleanmatches(javax.media.Format format)
Test to see if the given format matches this format. Matches compares attributes that are defined and ignore attributes that are unspecified. Two formats do not have to be of the same class to be considered a match. Say "A" are "B" are the two classes. If "A" derives "B" or "B" derives "A", then a match is possible (after comparing individual attributes. Otherwise, matches fails. This is to prevent matching VideoFormat and AudioFormat, for example.

return
true if the given format matches this one.

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

	AviVideoFormat other = (AviVideoFormat) format;

	boolean returnVal = 
	    (planes == NOT_SPECIFIED || other.planes == NOT_SPECIFIED ||
	     planes == other.planes) &&
	    (bitsPerPixel == NOT_SPECIFIED || other.bitsPerPixel == NOT_SPECIFIED ||
	     bitsPerPixel == other.bitsPerPixel) &&
	    (imageSize == NOT_SPECIFIED || other.imageSize == NOT_SPECIFIED ||
	     imageSize == other.imageSize) &&
	    (xPelsPerMeter == NOT_SPECIFIED || other.xPelsPerMeter == NOT_SPECIFIED ||
	     xPelsPerMeter == other.xPelsPerMeter) &&
	    (yPelsPerMeter == NOT_SPECIFIED || other.yPelsPerMeter == NOT_SPECIFIED ||
	     yPelsPerMeter == other.yPelsPerMeter) &&
	    (clrUsed == NOT_SPECIFIED || other.clrUsed == NOT_SPECIFIED ||
	     clrUsed == other.clrUsed) &&
	    (clrImportant == NOT_SPECIFIED || other.clrImportant == NOT_SPECIFIED ||
	     clrImportant == other.clrImportant)
		&&
	    (codecSpecificHeader == null || other.codecSpecificHeader == null ||
	     codecSpecificHeader == other.codecSpecificHeader ||
	     codecSpecificHeader.equals(codecSpecificHeader));
	    
	return returnVal;
    
public javax.media.Formatrelax()

	AviVideoFormat fmt;
	if ((fmt = (AviVideoFormat)super.relax()) == null)
	    return null;

	fmt.imageSize = NOT_SPECIFIED;
	return fmt;
    
public java.lang.StringtoString()

	String s = super.toString() + " " + (codecSpecificHeader != null ? codecSpecificHeader.length : 0) + " extra bytes";
	return s;