public Picture decodeFrameHiBD(ByteBuffer data, byte[][] target, byte[][] lowBits) { FrameHeader fh = readFrameHeader(data); int codedWidth = ((fh.width + 15) & ~0xf) >> 3; int codedHeight = ((fh.height + 15) & ~0xf) >> 3; int lumaSize = codedWidth * codedHeight; int chromaSize = lumaSize >> 1; if (target == null || target[0].length < lumaSize || target[1].length < chromaSize || target[2].length < chromaSize) { throw new RuntimeException("Provided output picture won't fit into provided buffer"); } if (fh.frameType == 0) { decodePicture(data, target, lowBits, codedWidth, codedHeight, codedWidth >> 1, fh.qMatLuma, fh.qMatChroma, new int[] { 0 }, 0, fh.chromaType); } else { decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 1, fh.qMatLuma, fh.qMatChroma, new int[] { 0 }, fh.topFieldFirst ? 1 : 2, fh.chromaType); decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 1, fh.qMatLuma, fh.qMatChroma, new int[] { 0 }, fh.topFieldFirst ? 2 : 1, fh.chromaType); } ColorSpace color = fh.chromaType == 2 ? ColorSpace.YUV422 : ColorSpace.YUV444; return new Picture(codedWidth, codedHeight, target, lowBits, color, lowBits == null ? 0 : 2, new Rect(0, 0, (fh.width >> 3) & color.getWidthMask(), (fh.height >> 3) & color.getHeightMask())); }
public Picture decodeFrameHiBD(ByteBuffer data, byte[][] target, byte[][] lowBits) { FrameHeader fh = readFrameHeader(data); int codedWidth = (fh.width + 15) & ~0xf; int codedHeight = (fh.height + 15) & ~0xf; int lumaSize = codedWidth * codedHeight; int chromaSize = lumaSize >> (3 - fh.chromaType); if (target == null || target[0].length < lumaSize || target[1].length < chromaSize || target[2].length < chromaSize) { throw new RuntimeException("Provided output picture won't fit into provided buffer"); } if (fh.frameType == 0) { decodePicture(data, target, lowBits, codedWidth, codedHeight, codedWidth >> 4, fh.qMatLuma, fh.qMatChroma, fh.scan, 0, fh.chromaType); } else { decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 4, fh.qMatLuma, fh.qMatChroma, fh.scan, fh.topFieldFirst ? 1 : 2, fh.chromaType); decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 4, fh.qMatLuma, fh.qMatChroma, fh.scan, fh.topFieldFirst ? 2 : 1, fh.chromaType); } ColorSpace color = fh.chromaType == 2 ? ColorSpace.YUV422 : ColorSpace.YUV444; return new Picture(codedWidth, codedHeight, target, lowBits, color, lowBits == null ? 0 : 2, new Rect(0, 0, fh.width & color.getWidthMask(), fh.height & color.getHeightMask())); }
@Override public Picture decodeFrameHiBD(ByteBuffer data, byte[][] target, byte[][] lowBits) { FrameHeader fh = readFrameHeader(data); int codedWidth = ((fh.width + 15) & ~0xf) >> 1; int codedHeight = ((fh.height + 15) & ~0xf) >> 1; int lumaSize = codedWidth * codedHeight; int chromaSize = lumaSize >> 1; if (target == null || target[0].length < lumaSize || target[1].length < chromaSize || target[2].length < chromaSize) { throw new RuntimeException("Provided output picture won't fit into provided buffer"); } if (fh.frameType == 0) { decodePicture(data, target, lowBits, codedWidth, codedHeight, codedWidth >> 3, fh.qMatLuma, fh.qMatChroma, progressive_scan_4x4, 0, fh.chromaType); } else { decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 3, fh.qMatLuma, fh.qMatChroma, interlaced_scan_4x4, fh.topFieldFirst ? 1 : 2, fh.chromaType); decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 3, fh.qMatLuma, fh.qMatChroma, interlaced_scan_4x4, fh.topFieldFirst ? 2 : 1, fh.chromaType); } ColorSpace color = fh.chromaType == 2 ? ColorSpace.YUV422 : ColorSpace.YUV444; return new Picture(codedWidth, codedHeight, target, lowBits, color, lowBits == null ? 0 : 2, new Rect(0, 0, (fh.width >> 1) & color.getWidthMask(), (fh.height >> 1) & color.getHeightMask())); }
@Override public Picture decodeFrameHiBD(ByteBuffer data, byte[][] target, byte[][] lowBits) { FrameHeader fh = readFrameHeader(data); int codedWidth = ((fh.width + 15) & ~0xf) >> 2; int codedHeight = ((fh.height + 15) & ~0xf) >> 2; int lumaSize = codedWidth * codedHeight; int chromaSize = lumaSize >> 1; if (target == null || target[0].length < lumaSize || target[1].length < chromaSize || target[2].length < chromaSize) { throw new RuntimeException("Provided output picture won't fit into provided buffer"); } if (fh.frameType == 0) { decodePicture(data, target, lowBits, codedWidth, codedHeight, codedWidth >> 2, fh.qMatLuma, fh.qMatChroma, new int[] { 0, 1, 2, 3 }, 0, fh.chromaType); } else { decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 2, fh.qMatLuma, fh.qMatChroma, new int[] { 0, 2, 1, 3 }, fh.topFieldFirst ? 1 : 2, fh.chromaType); decodePicture(data, target, lowBits, codedWidth, codedHeight >> 1, codedWidth >> 2, fh.qMatLuma, fh.qMatChroma, new int[] { 0, 2, 1, 3 }, fh.topFieldFirst ? 2 : 1, fh.chromaType); } ColorSpace color = fh.chromaType == 2 ? ColorSpace.YUV422 : ColorSpace.YUV444; return new Picture(codedWidth, codedHeight, target, lowBits, color, lowBits == null ? 0 : 2, new Rect(0, 0, (fh.width >> 2) & color.getWidthMask(), (fh.height >> 2) & color.getHeightMask())); }
@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; }