FileDocCategorySizeDatePackage
YUVFormat.javaAPI DocJMF 2.1.1e12284Mon May 12 12:20:34 BST 2003javax.media.format

YUVFormat

public class YUVFormat extends VideoFormat
Describes YUV image data.
since
JMF 2.0

Fields Summary
public static final int
YUV_411
YUV Planar 4:1:1 type.
public static final int
YUV_420
YUV Planar 4:2:0 type.
public static final int
YUV_422
YUV Planar 4:2:2 type.
public static final int
YUV_111
YUV Planar 1:1:1 type.
public static final int
YUV_YVU9
YUV Planar YVU9 type. Contains a Y value for every pixel and U and V values for every 4x4 block of pixels.
public static final int
YUV_YUYV
YUV 4:2:2 interleaved format. The components are ordered as specified by the offsetY, offsetU and offsetV attributes. For example, if the ordering is Y, V, Y and U, the offsets would be offsetY=0;offsetU=3;offsetV=1. The position of the second Y is implied. Y pixel stride is assumed to be 2 and the U and V pixel strides are assumed to be 4.
public static final int
YUV_SIGNED
When added to the yuvType, specifies that the chrominance values are signed.
protected int
yuvType
The YUV format type
protected int
strideY
Length of a row of Y values. Would be >= width of the frame.
protected int
strideUV
Length of a row of U or V values.
protected int
offsetY
When the YUV data is in planar format, specifies the offset into the data for the Y plane. This value is ignored in the interleaved formats.
protected int
offsetU
When the YUV data is in planar format, specifies the offset into the data for the U plane. This value is ignored in the interleaved formats.
protected int
offsetV
When the YUV data is in planar format, specifies the offset into the data for the V plane. This value is ignored in the interleaved formats.
private static String
ENCODING
Constructors Summary
public YUVFormat()
Constructs a YUVFormat object that represents all YUV formats.


                  
      
	super(ENCODING);
    
public YUVFormat(int yuvType)
Constructs a YUVFormat object for a specific yuvType.

param
yuvType The YUV type for this YUVFormat: YUV_411, YUV_420, YUV_422, YUV_111, YUV_YVU9, or YUV_YUYV.

 	super(ENCODING);
 	this.yuvType = yuvType;
     
public YUVFormat(Dimension size, int maxDataLength, Class dataType, float frameRate, int yuvType, int strideY, int strideUV, int offsetY, int offsetU, int offsetV)
Constructs a YUVFormat with the specified properties. Use this constructor for planar YUV formats. (YUV_411, YUV_420, YUV_422, YUV_111, or YUV_YVU9.)

param
size A Dimension that specifies the frame size.
param
maxDataLength The maximum size of the data array.
param
dataType The type of the data.
param
yuvType The YUV ordering type.
param
strideY The number of data elements between the first Y component in a row and the first Y component in the next row.
param
strideUV The number of data elements between the first U component in a row and the first U component in the next row. The same value is expected for the V component.
param
offsetY The offset into the data array where the Y plane begins.
param
offsetU The offset into the data array where the U plane begins.
param
offsetV The offset into the data array where the V plane begins.

	// Call VideoFormat constructor
	super(ENCODING, size, maxDataLength, dataType, frameRate);
	// Set YUV properties.
	this.yuvType = yuvType;
	this.strideY = strideY;
	this.strideUV = strideUV;
	this.offsetY = offsetY;
	this.offsetU = offsetU;
	this.offsetV = offsetV;
    
Methods Summary
public java.lang.Objectclone()
Creates a clone of this YUVFormat.

return
A clone of this YUVFormat.

	YUVFormat f = new YUVFormat(size,
				    maxDataLength,
				    dataType,
				    frameRate,
				    yuvType,
				    strideY,
				    strideUV,
				    offsetY,
				    offsetU,
				    offsetV);
	f.copy(this);
	return f;
    
protected voidcopy(javax.media.Format f)
Copies the attributes from the specified Format into this YUVFormat.

param
f The Format to copy the attributes from.

	super.copy(f);
	if (f instanceof YUVFormat) {
	    YUVFormat other = (YUVFormat) f;
	    yuvType = other.yuvType;
	    strideY = other.strideY;
	    strideUV = other.strideUV;
	    offsetY = other.offsetY;
	    offsetU = other.offsetU;
	    offsetV = other.offsetV;
	}
    
public booleanequals(java.lang.Object format)
Compares the specified Format with this YUVFormat. Returns true only if the specified Format is a YUVFormat object and all of its attributes are identical to the attributes in this YUVFormat.

param
format The Format to compare.
return
true if the specified Format is the same as this one.

	if (format instanceof YUVFormat) {
	    YUVFormat other = (YUVFormat) format;
	    
	    return super.equals(format) &&
		yuvType == other.yuvType &&
		strideY == other.strideY &&
		strideUV == other.strideUV &&
		offsetY == other.offsetY &&
		offsetU == other.offsetU &&
		offsetV == other.offsetV;
	} else
	    return false;
    
public intgetOffsetU()
Gets the U offset--the position in the data where the U values begin.

return
An integer representing the U offset.

	return offsetU;
    
public intgetOffsetV()
Gets the V offset--the position in the data where the V values begin.

return
An integer representing the V offset.

	return offsetV;
    
public intgetOffsetY()
Gets the Y offset--the position in the data where the Y values begin.

return
An integer representing the Y offset.

	return offsetY;
    
public intgetStrideUV()
Gets the UV stride--the length of a row of U or V values.

return
An integer representing the UV stride.

	return strideUV;
    
public intgetStrideY()
Gets the Y stride--the length of a row of Y values.

return
An integer representing the Y stride.

	return strideY;
    
public intgetYuvType()
Gets the YUV data format.

return
The YUV type: YUV_411, YUV_420, YUV_422, YUV_111, YUV_YVU9, or YUV_YUYV.

	return yuvType;
    
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 YUVFormat.
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 YUVFormat))
	    return fmt;
	YUVFormat other = (YUVFormat)format;
	YUVFormat res = (YUVFormat)fmt;
	res.yuvType = (yuvType != NOT_SPECIFIED ?
					yuvType : other.yuvType);
	res.strideY = (strideY != NOT_SPECIFIED ?
		       strideY : other.strideY);
	res.strideUV = (strideUV != NOT_SPECIFIED ?
			strideUV : other.strideUV);

	res.offsetY = (offsetY != NOT_SPECIFIED ?
		       offsetY : other.offsetY);
	res.offsetU = (offsetU != NOT_SPECIFIED ?
		       offsetU : other.offsetU);
	res.offsetV = (offsetV != NOT_SPECIFIED ?
		       offsetV : other.offsetV);
	
	return res;
    
public booleanmatches(javax.media.Format format)
Checks whether or not the specified Format matches this YUVFormat. 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 YUVFormat))
	    return true;

	YUVFormat other = (YUVFormat) format;
	
	return
	    (yuvType == NOT_SPECIFIED || other.yuvType == NOT_SPECIFIED ||
	     yuvType == other.yuvType) &&

	    (strideY == NOT_SPECIFIED || other.strideY == NOT_SPECIFIED ||
	     strideY == other.strideY) &&
	    (strideUV == NOT_SPECIFIED || other.strideUV == NOT_SPECIFIED ||
	     strideUV == other.strideUV) &&

	    (offsetY == NOT_SPECIFIED || other.offsetY == NOT_SPECIFIED ||
	     offsetY == other.offsetY) &&
	    (offsetU == NOT_SPECIFIED || other.offsetU == NOT_SPECIFIED ||
	     offsetU == other.offsetU) &&
	    (offsetV == NOT_SPECIFIED || other.offsetV == NOT_SPECIFIED ||
	     offsetV == other.offsetV);
	    
    
public javax.media.Formatrelax()
Generate a format that's less restrictive than this format but contains the basic attributes that will make this resulting format useful for format matching.

return
A Format that's less restrictive than the this format.

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

	fmt.strideY = NOT_SPECIFIED;
	fmt.strideUV = NOT_SPECIFIED;
	fmt.offsetY = NOT_SPECIFIED;
	fmt.offsetU = NOT_SPECIFIED;
	fmt.offsetV = NOT_SPECIFIED;

	return fmt;
    
public java.lang.StringtoString()
Gets a String representation of the attributes of this YUVFormat. For example: "YUV Video Format, 352x240, ...".

return
A String that describes the format attributes.

	return "YUV Video Format: Size = " + size +
	    " MaxDataLength = " + maxDataLength + " DataType = " + dataType +
	    " yuvType = " + yuvType + " StrideY = " + strideY +
	    " StrideUV = " + strideUV +
	    " OffsetY = " + offsetY +
	    " OffsetU = " + offsetU + " OffsetV = " + offsetV + "\n";