public static YUVFormat specialize(YUVFormat yuvFormat, Class<?> dataType) Dimension size = yuvFormat.getSize(); int strideY = yuvFormat.getStrideY(); int strideUV = yuvFormat.getStrideUV(); strideUV = (strideY + 1) / 2; int offsetY = yuvFormat.getOffsetY(); int offsetU = yuvFormat.getOffsetU(); offsetU = offsetY + strideY * size.height; int offsetV = yuvFormat.getOffsetV(); new YUVFormat( size, maxDataLength, (dataType == null) ? yuvFormat.getDataType() : dataType, yuvFormat.getFrameRate(), YUVFormat.YUV_420, strideY, strideUV,
/** * Sets the <tt>Format</tt> of the media data to be input to this * <tt>Codec</tt>. * * @param format the <tt>Format</tt> of media data to set on this * <tt>Codec</tt> * @return the <tt>Format</tt> of media data set on this <tt>Codec</tt> or * <tt>null</tt> if the specified <tt>format</tt> is not supported by this * <tt>Codec</tt> */ @Override public Format setInputFormat(Format format) { // mismatch input format if (!(format instanceof VideoFormat) || (null == AbstractCodec2.matches(format, inputFormats))) return null; YUVFormat yuvFormat = (YUVFormat) format; if (yuvFormat.getOffsetU() > yuvFormat.getOffsetV()) return null; inputFormat = AbstractCodec2.specialize(yuvFormat, Format.byteArray); // Return the selected inputFormat return inputFormat; }
if (YUVFormat.YUV_420 == yuvFormat.getYuvType()) Dimension size = yuvFormat.getSize(); = new YUVFormat( new Dimension(width, height), yuvFormat.getDataType(), yuvFormat.getFrameRate(), yuvFormat.getYuvType(),
Dimension formatSize = format.getSize(); int width = formatSize.width; int height = formatSize.height; int strideY = format.getStrideY(); if (strideY == Format.NOT_SPECIFIED) strideY = width; int strideUV = format.getStrideUV(); if (strideUV == Format.NOT_SPECIFIED) strideUV = width/2; VPX.img_set_stride3(img, 0); int offsetY = format.getOffsetY(); if (offsetY == Format.NOT_SPECIFIED) offsetY = 0; int offsetU = format.getOffsetU(); if (offsetU == Format.NOT_SPECIFIED) offsetU = offsetY + width * height; int offsetV = format.getOffsetV(); if (offsetV == Format.NOT_SPECIFIED) offsetV = offsetU + (width * height) / 4;
CaptureDeviceManager.getDeviceList(new YUVFormat());
= new YUVFormat( size, yuvFormat.getYuvType(),
/** * Initializes a new <tt>JNIEncoder</tt> instance. */ public JNIEncoder() { inputFormats = new Format[] { new YUVFormat( /* size */ null, /* maxDataLength */ Format.NOT_SPECIFIED, Format.byteArray, /* frameRate */ Format.NOT_SPECIFIED, YUVFormat.YUV_420, /* strideY */ Format.NOT_SPECIFIED, /* strideUV */ Format.NOT_SPECIFIED, /* offsetY */ Format.NOT_SPECIFIED, /* offsetU */ Format.NOT_SPECIFIED, /* offsetV */ Format.NOT_SPECIFIED) }; inputFormat = null; outputFormat = null; }
/** * Sets the input format. * * @param format format to set * @return format */ @Override public Format setInputFormat(Format format) { if(!(format instanceof VideoFormat) || (matches(format, inputFormats) == null)) return null; YUVFormat yuvFormat = (YUVFormat) format; if (yuvFormat.getOffsetU() > yuvFormat.getOffsetV()) return null; inputFormat = specialize(yuvFormat, Format.byteArray); // Return the selected inputFormat return inputFormat; }
/** * Initializes a new <tt>JNIEncoder</tt> instance. */ public JNIEncoder() { inputFormats = new Format[] { new YUVFormat( /* size */ null, /* maxDataLength */ Format.NOT_SPECIFIED, Format.byteArray, /* frameRate */ Format.NOT_SPECIFIED, YUVFormat.YUV_420, /* strideY */ Format.NOT_SPECIFIED, /* strideUV */ Format.NOT_SPECIFIED, /* offsetY */ Format.NOT_SPECIFIED, /* offsetU */ Format.NOT_SPECIFIED, /* offsetV */ Format.NOT_SPECIFIED) }; inputFormat = null; outputFormat = null; }
/** * Sets the <tt>Format</tt> of the media data to be input to this * <tt>Codec</tt>. * * @param format the <tt>Format</tt> of media data to set on this * <tt>Codec</tt> * @return the <tt>Format</tt> of media data set on this <tt>Codec</tt> or * <tt>null</tt> if the specified <tt>format</tt> is not supported by this * <tt>Codec</tt> */ @Override public Format setInputFormat(Format format) { // mismatch input format if (!(format instanceof VideoFormat) || (null == AbstractCodec2.matches(format, inputFormats))) return null; YUVFormat yuvFormat = (YUVFormat) format; if (yuvFormat.getOffsetU() > yuvFormat.getOffsetV()) return null; inputFormat = AbstractCodec2.specialize(yuvFormat, Format.byteArray); // Return the selected inputFormat return inputFormat; }
/** * Initializes a new <tt>VPXEncoder</tt> instance. */ public VPXEncoder() { super("VP8 Encoder", VideoFormat.class, SUPPORTED_OUTPUT_FORMATS); inputFormats = new VideoFormat[] { new YUVFormat( /* size */ null, /* maxDataLength */ Format.NOT_SPECIFIED, Format.byteArray, /* frameRate */ Format.NOT_SPECIFIED, YUVFormat.YUV_420, /* strideY */ Format.NOT_SPECIFIED, /* strideUV */ Format.NOT_SPECIFIED, /* offsetY */ Format.NOT_SPECIFIED, /* offsetU */ Format.NOT_SPECIFIED, /* offsetV */ Format.NOT_SPECIFIED) }; inputFormat = null; outputFormat = null; }
/** * Initializes a new <tt>SwScale</tt> instance which can optionally attempt * to keep the width and height of YUV 420 output even and to preserve the * aspect ratio of the video frames provided to the instance as input to be * processed. * * @param fixOddYuv420Size <tt>true</tt> to have the new instance keep the * width and height of YUV 420 output even; otherwise, <tt>false</tt> * @param preserveAspectRatio <tt>true</tt> to have the new instance * preserve the aspect ratio of the video frames provided to it as input to * be processed; otherwise, <tt>false</tt> */ public SwScale(boolean fixOddYuv420Size, boolean preserveAspectRatio) { this.fixOddYuv420Size = fixOddYuv420Size; this.preserveAspectRatio = preserveAspectRatio; inputFormats = new Format[] { new AVFrameFormat(), new RGBFormat(), new YUVFormat(YUVFormat.YUV_420) }; addControl(frameProcessingControl); }
VideoFormat[] desiredFormats = new VideoFormat[] {new H263Format(), new JPEGFormat(), new RGBFormat(), new YUVFormat()}; for (VideoFormat checkFormat : desiredFormats) {