Package com.avpkit.core.video
Class AConverter
- java.lang.Object
-
- com.avpkit.core.video.AConverter
-
- All Implemented Interfaces:
IConverter
- Direct Known Subclasses:
ArgbConverter,BgrConverter
public abstract class AConverter extends java.lang.Object implements IConverter
An abstract converter class from which specific converters can be derived to do the actual conversions. This class establishes if theIVideoPictureneeds to be re-sampled, and if so, creates appropriateIVideoResamplerobjects to do that.
-
-
Field Summary
Fields Modifier and Type Field Description protected intmImageHeightThe height of the images.protected intmImageWidthThe width of the images.protected intmPictureHeightThe height of the pictures.protected intmPictureWidthThe width of the pictures.protected IVideoResamplermToImageResamplerRe-sampler called when converting picture to image, may be null.protected IVideoResamplermToPictureResamplerRe-sampler called when converting image to picture, may be null.
-
Constructor Summary
Constructors Constructor Description AConverter(IPixelFormat.Type pictureType, IPixelFormat.Type requiredPictureType, int imageType, int pictureWidth, int pictureHeight, int imageWidth, int imageHeight)Construct an abstract Converter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.lang.StringgetDescription()Return a written description of the converter.intgetImageType()Get the image type, as defined byBufferedImage, which this converter recognizes.IPixelFormat.TypegetPictureType()Get the picture type, as defined byIPixelFormat.Type, which this converter recognizes.protected IPixelFormat.TypegetRequiredPictureType()Return the Type which matches theBufferedImagetype.protected static IVideoPictureresample(IVideoPicture picture1, IVideoResampler resampler)Re-sample a picture.java.lang.StringtoString()Get a string representation of this converter.protected voidvalidateImage(java.awt.image.BufferedImage image)Test that the passed image is valid and conforms to the converters specifications.protected voidvalidatePicture(IVideoPicture picture)Test that the passed picture is valid and conforms to the converters specifications.booleanwillResample()Test if this converter is going to re-sample during conversion.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.avpkit.core.video.IConverter
delete, toImage, toPicture
-
-
-
-
Field Detail
-
mToPictureResampler
protected IVideoResampler mToPictureResampler
Re-sampler called when converting image to picture, may be null.
-
mToImageResampler
protected IVideoResampler mToImageResampler
Re-sampler called when converting picture to image, may be null.
-
mPictureWidth
protected int mPictureWidth
The width of the pictures.
-
mPictureHeight
protected int mPictureHeight
The height of the pictures.
-
mImageWidth
protected int mImageWidth
The width of the images.
-
mImageHeight
protected int mImageHeight
The height of the images.
-
-
Constructor Detail
-
AConverter
public AConverter(IPixelFormat.Type pictureType, IPixelFormat.Type requiredPictureType, int imageType, int pictureWidth, int pictureHeight, int imageWidth, int imageHeight)
Construct an abstract Converter. This will create aIVideoResamplerto change color-space or resize the picture as needed for the conversions specified.- Parameters:
pictureType- the recognizedIVideoPicturetyperequiredPictureType- the picture type requred to translate to and from the BufferedImageimageType- the recognizedBufferedImagetypepictureWidth- the width of picturepictureHeight- the height of pictureimageWidth- the width of imageimageHeight- the height of image
-
-
Method Detail
-
getPictureType
public IPixelFormat.Type getPictureType()
Get the picture type, as defined byIPixelFormat.Type, which this converter recognizes.- Specified by:
getPictureTypein interfaceIConverter- Returns:
- the picture type of this converter.
- See Also:
IPixelFormat.Type
-
getRequiredPictureType
protected IPixelFormat.Type getRequiredPictureType()
Return the Type which matches theBufferedImagetype.- Returns:
- the picture type which allows for image translation.
-
getImageType
public int getImageType()
Get the image type, as defined byBufferedImage, which this converter recognizes.- Specified by:
getImageTypein interfaceIConverter- Returns:
- the image type of this converter.
- See Also:
BufferedImage
-
willResample
public boolean willResample()
Test if this converter is going to re-sample during conversion. For some conversions betweenBufferedImageandIVideoPicture, the IVideoPicture will need to be re-sampled into another pixel type, commonly between YUV and RGB types. This re-sample is time consuming, and may not be available for all installations of AVPKit.- Specified by:
willResamplein interfaceIConverter- Returns:
- true if this converter will re-sample during conversion.
- See Also:
IVideoResampler,IVideoResampler.isSupported(com.avpkit.core.IVideoResampler.Feature)
-
resample
protected static IVideoPicture resample(IVideoPicture picture1, IVideoResampler resampler)
Re-sample a picture.- Parameters:
picture1- the picture to re-sampleresampler- the picture re-samper to use- Throws:
java.lang.RuntimeException- if could not re-sample picture
-
validateImage
protected void validateImage(java.awt.image.BufferedImage image)
Test that the passed image is valid and conforms to the converters specifications.- Parameters:
image- the image to test- Throws:
java.lang.IllegalArgumentException- if the passedBufferedImageis NULL;java.lang.IllegalArgumentException- if the passedBufferedImageis not the correct type. SeegetImageType().
-
validatePicture
protected void validatePicture(IVideoPicture picture)
Test that the passed picture is valid and conforms to the converters specifications.- Parameters:
picture- the picture to test- Throws:
java.lang.IllegalArgumentException- if the passedIVideoPictureis NULL;java.lang.IllegalArgumentException- if the passedIVideoPictureis not complete.java.lang.IllegalArgumentException- if the passedIVideoPictureis not the correct type.
-
getDescription
public java.lang.String getDescription()
Return a written description of the converter.- Specified by:
getDescriptionin interfaceIConverter- Returns:
- a detailed description of what this converter does.
-
toString
public java.lang.String toString()
Get a string representation of this converter.- Overrides:
toStringin classjava.lang.Object
-
close
public void close()
-
-