public Size getSize() { return new Size(width, height); } }
/** * Calculates the component size based on the fullt size and color subsampling of the given component index. * @param size * @return Component size */ public Size compSize(Size size, int comp) { if (compWidth[comp] == 0 && compHeight[comp] == 0) return size; return new Size(size.getWidth() >> compWidth[comp], size.getHeight() >> compHeight[comp]); } }
@Override public LoanerPicture filter(Picture picture, PixelStore store) { Size pictureSize = picture.getSize(); if (resampler == null || currentColor != picture.getColor() || !pictureSize.equals(currentSize)) { currentColor = picture.getColor(); currentSize = picture.getSize(); targetSize = new Size(width & currentColor.getWidthMask(), height & currentColor.getHeightMask()); resampler = new LanczosResampler(currentSize, targetSize); } LoanerPicture dest = store.getPicture(targetSize.getWidth(), targetSize.getHeight(), currentColor); resampler.resample(picture, dest.getPicture()); return dest; }
@Override public MediaInfo getMediaInfo() { return new MediaInfo(new Size(0, 0)); }
public LanczosResampler(Size from, Size to) { super(from, to); scaleFactorX = (double) to.getWidth() / from.getWidth(); scaleFactorY = (double) to.getHeight() / from.getHeight(); tapsXs = new short[precision][nTaps]; tapsYs = new short[precision][nTaps]; buildTaps(nTaps, precision, scaleFactorX, tapsXs); buildTaps(nTaps, precision, scaleFactorY, tapsYs); }
@Override public DemuxerTrackMeta getMeta() { return new DemuxerTrackMeta(TrackType.VIDEO, Codec.RAW, totalDuration, null, totalFrames, null, org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(width, height), ColorSpace.YUV420), null); }
public static Size getPicSize(SeqParameterSet sps) { int w = (sps.picWidthInMbsMinus1 + 1) << 4; int h = SeqParameterSet.getPicHeightInMbs(sps) << 4; if (sps.frameCroppingFlag) { w -= (sps.frameCropLeftOffset + sps.frameCropRightOffset) << sps.chromaFormatIdc.compWidth[1]; h -= (sps.frameCropTopOffset + sps.frameCropBottomOffset) << sps.chromaFormatIdc.compHeight[1]; } return new Size(w, h); }
public SeqParameterSet initSPS(Size sz) { SeqParameterSet sps = new SeqParameterSet(); sps.picWidthInMbsMinus1 = ((sz.getWidth() + 15) >> 4) - 1; sps.picHeightInMapUnitsMinus1 = ((sz.getHeight() + 15) >> 4) - 1; sps.chromaFormatIdc = ColorSpace.YUV420J; sps.profileIdc = 66; sps.levelIdc = 40; sps.numRefFrames = 1; sps.frameMbsOnlyFlag = true; sps.log2MaxFrameNumMinus4 = Math.max(0, MathUtil.log2(keyInterval) - 3); int codedWidth = (sps.picWidthInMbsMinus1 + 1) << 4; int codedHeight = (sps.picHeightInMapUnitsMinus1 + 1) << 4; sps.frameCroppingFlag = codedWidth != sz.getWidth() || codedHeight != sz.getHeight(); sps.frameCropRightOffset = (codedWidth - sz.getWidth() + 1) >> 1; sps.frameCropBottomOffset = (codedHeight - sz.getHeight() + 1) >> 1; return sps; }
@Override public DemuxerTrackMeta getMeta() { return new DemuxerTrackMeta(org.jcodec.common.TrackType.VIDEO, codec, 0, null, 0, state, org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(demuxer.pictureWidth, demuxer.pictureHeight), ColorSpace.YUV420), null); }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { return org.jcodec.common.VideoCodecMeta.createSimpleVideoCodecMeta(new Size(width, height), ColorSpace.YUV420); } }
public static VideoSampleEntry videoSampleEntry(String fourcc, Size size, String encoderName) { return createVideoSampleEntry(new Header(fourcc), (short) 0, (short) 0, "jcod", 0, 768, (short) size.getWidth(), (short) size.getHeight(), 72, 72, (short) 1, encoderName != null ? encoderName : "jcodec", (short) 24, (short) 1, (short) -1); }
@Override public VideoCodecMeta getCodecMeta(ByteBuffer data) { try { BufferedImage rgb = ImageIO.read(new ByteArrayInputStream(NIOUtils.toArray(data))); return VideoCodecMeta.createSimpleVideoCodecMeta(new Size(rgb.getWidth(), rgb.getHeight()), ColorSpace.RGB); } catch (IOException e) { return null; } } }