GeezerVison is showing github.com — Migrating further to 8 bit images · codice/jcodec@a420d79
File treeExpand file treeCollapse file tree Open diff view settings samples/main/java/org/jcodec/samples/transcode
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: samples/main/java/org/jcodec/samples/transcode/TranscodeMain.java +98-95Lines changed: 98 additions & 95 deletions Large diffs are not rendered by default. Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/h264/decode/BlockInterpolator.java -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | import static java.lang.System.arraycopy; | 4 | 4 | import static org.jcodec.common.tools.MathUtil.clip; | 5 | 5 |
| 6 | | -import org.jcodec.codecs.aac.blocks.Block; | 7 | 6 | import org.jcodec.common.model.Picture8Bit; | 8 | 7 |
| 9 | 8 | /** | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/h264/encode/MBEncoderP16x16.java +11-12Lines changed: 11 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | import static org.jcodec.codecs.h264.H264Const.MB_BLK_OFF_TOP; | 7 | 7 | import static org.jcodec.codecs.h264.io.model.MBType.P_16x16; | 8 | 8 |
| 9 | | -import java.util.Arrays; | 10 | | - | 11 | 9 | import org.jcodec.codecs.h264.H264Const; | 12 | 10 | import org.jcodec.codecs.h264.decode.BlockInterpolator; | 13 | 11 | import org.jcodec.codecs.h264.decode.CoeffTransformer; | | 16 | 14 | import org.jcodec.codecs.h264.io.model.SeqParameterSet; | 17 | 15 | import org.jcodec.codecs.h264.io.write.CAVLCWriter; | 18 | 16 | import org.jcodec.common.io.BitWriter; | 19 | | -import org.jcodec.common.model.Picture; | 20 | 17 | import org.jcodec.common.model.Picture8Bit; | 21 | 18 |
| | 19 | +import java.util.Arrays; | | 20 | + | 22 | 21 | /** | 23 | 22 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed | 24 | 23 | * under FreeBSD License | @@ -80,7 +79,7 @@ public void encodeMacroblock(Picture8Bit pic, int mbX, int mbY, BitWriter out, E | 80 | 79 | CAVLCWriter.writeSE(out, mv[1] - mvpy); // mvdy | 81 | 80 |
| 82 | 81 | Picture8Bit mbRef = Picture8Bit.create(16, 16, sps.chroma_format_idc); | 83 | | - Picture mb = Picture.create(16, 16, sps.chroma_format_idc); | | 82 | + int[][] mb = new int[][] {new int[256], new int[256 >> (cw + ch)], new int[256 >> (cw + ch)]}; | 84 | 83 |
| 85 | 84 | interpolator.getBlockLuma(ref, mbRef, 0, (mbX << 6) + mv[0], (mbY << 6) + mv[1], 16, 16); | 86 | 85 |
| @@ -90,25 +89,25 @@ public void encodeMacroblock(Picture8Bit pic, int mbX, int mbY, BitWriter out, E | 90 | 89 | mbRef.getPlaneData(2), 0, mbRef.getPlaneWidth(2), (mbX << 6) + mv[0], (mbY << 6) + mv[1], 8, 8); | 91 | 90 |
| 92 | 91 | MBEncoderHelper.takeSubtract(pic.getPlaneData(0), pic.getPlaneWidth(0), pic.getPlaneHeight(0), mbX << 4, | 93 | | - mbY << 4, mb.getPlaneData(0), mbRef.getPlaneData(0), 16, 16); | | 92 | + mbY << 4, mb[0], mbRef.getPlaneData(0), 16, 16); | 94 | 93 | MBEncoderHelper.takeSubtract(pic.getPlaneData(1), pic.getPlaneWidth(1), pic.getPlaneHeight(1), mbX << (4 - cw), | 95 | | - mbY << (4 - ch), mb.getPlaneData(1), mbRef.getPlaneData(1), 16 >> cw, 16 >> ch); | | 94 | + mbY << (4 - ch), mb[1], mbRef.getPlaneData(1), 16 >> cw, 16 >> ch); | 96 | 95 | MBEncoderHelper.takeSubtract(pic.getPlaneData(2), pic.getPlaneWidth(2), pic.getPlaneHeight(2), mbX << (4 - cw), | 97 | | - mbY << (4 - ch), mb.getPlaneData(2), mbRef.getPlaneData(2), 16 >> cw, 16 >> ch); | | 96 | + mbY << (4 - ch), mb[2], mbRef.getPlaneData(2), 16 >> cw, 16 >> ch); | 98 | 97 |
| 99 | 98 | int codedBlockPattern = getCodedBlockPattern(); | 100 | 99 | CAVLCWriter.writeUE(out, H264Const.CODED_BLOCK_PATTERN_INTER_COLOR_INV[codedBlockPattern]); | 101 | 100 |
| 102 | 101 | CAVLCWriter.writeSE(out, qpDelta); | 103 | 102 |
| 104 | | - luma(pic, mb.getPlaneData(0), mbX, mbY, out, qp, outMB.getNc()); | 105 | | - chroma(pic, mb.getPlaneData(1), mb.getPlaneData(2), mbX, mbY, out, qp); | | 103 | + luma(pic, mb[0], mbX, mbY, out, qp, outMB.getNc()); | | 104 | + chroma(pic, mb[1], mb[2], mbX, mbY, out, qp); | 106 | 105 |
| 107 | | - MBEncoderHelper.putBlk(outMB.getPixels().getPlaneData(0), mb.getPlaneData(0), mbRef.getPlaneData(0), 4, 0, 0, | | 106 | + MBEncoderHelper.putBlk(outMB.getPixels().getPlaneData(0), mb[0], mbRef.getPlaneData(0), 4, 0, 0, | 108 | 107 | 16, 16); | 109 | | - MBEncoderHelper.putBlk(outMB.getPixels().getPlaneData(1), mb.getPlaneData(1), mbRef.getPlaneData(1), 4 - cw, 0, | | 108 | + MBEncoderHelper.putBlk(outMB.getPixels().getPlaneData(1), mb[1], mbRef.getPlaneData(1), 4 - cw, 0, | 110 | 109 | 0, 16 >> cw, 16 >> ch); | 111 | | - MBEncoderHelper.putBlk(outMB.getPixels().getPlaneData(2), mb.getPlaneData(2), mbRef.getPlaneData(2), 4 - cw, 0, | | 110 | + MBEncoderHelper.putBlk(outMB.getPixels().getPlaneData(2), mb[2], mbRef.getPlaneData(2), 4 - cw, 0, | 112 | 111 | 0, 16 >> cw, 16 >> ch); | 113 | 112 |
| 114 | 113 | Arrays.fill(outMB.getMx(), mv[0]); | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/h264/io/model/Frame.java +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package org.jcodec.codecs.h264.io.model; | 2 | 2 |
| 3 | | -import java.util.Comparator; | 4 | | - | 5 | 3 | import org.jcodec.common.model.ColorSpace; | 6 | | -import org.jcodec.common.model.Picture; | 7 | 4 | import org.jcodec.common.model.Picture8Bit; | 8 | 5 | import org.jcodec.common.model.Rect; | 9 | 6 |
| | 7 | +import java.util.Comparator; | | 8 | + | 10 | 9 | /** | 11 | 10 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed | 12 | 11 | * under FreeBSD License | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/vp8/VP8Decoder.java +12-12Lines changed: 12 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 10 | 10 | import static org.jcodec.codecs.vp8.VP8Util.keyFrameYModeTree; | 11 | 11 | import static org.jcodec.codecs.vp8.VP8Util.vp8CoefUpdateProbs; | 12 | 12 |
| 13 | | -import java.io.IOException; | 14 | | -import java.nio.ByteBuffer; | 15 | | - | 16 | 13 | import org.jcodec.api.NotSupportedException; | 17 | 14 | import org.jcodec.codecs.vp8.Macroblock.Subblock; | 18 | 15 | import org.jcodec.codecs.vp8.VP8Util.QuantizationParams; | 19 | 16 | import org.jcodec.codecs.vp8.VP8Util.SubblockConstants; | 20 | 17 | import org.jcodec.common.Assert; | 21 | 18 | import org.jcodec.common.model.ColorSpace; | 22 | | -import org.jcodec.common.model.Picture; | | 19 | +import org.jcodec.common.model.Picture8Bit; | | 20 | + | | 21 | +import java.io.IOException; | | 22 | +import java.nio.ByteBuffer; | 23 | 23 |
| 24 | 24 | /** | 25 | 25 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed | @@ -211,14 +211,14 @@ public void decode(ByteBuffer frame) throws IOException { | 211 | 211 |
| 212 | 212 | } | 213 | 213 |
| 214 | | - public Picture getPicture() { | 215 | | - Picture p = Picture.create(width, height, ColorSpace.YUV420); | | 214 | + public Picture8Bit getPicture8Bit() { | | 215 | + Picture8Bit p = Picture8Bit.create(width, height, ColorSpace.YUV420); | 216 | 216 |
| 217 | | - int[] luma = p.getPlaneData(0); | | 217 | + byte[] luma = p.getPlaneData(0); | 218 | 218 | // int strideLuma = p.getPlaneWidth(0); | 219 | 219 |
| 220 | | - int[] cb = p.getPlaneData(1); | 221 | | - int[] cr = p.getPlaneData(2); | | 220 | + byte[] cb = p.getPlaneData(1); | | 221 | + byte[] cr = p.getPlaneData(2); | 222 | 222 | // int strideChroma = p.getPlaneWidth(1); | 223 | 223 | int mbWidth = getMacroblockCount(width); | 224 | 224 | int mbHeight = getMacroblockCount(height); | @@ -239,7 +239,7 @@ public Picture getPicture() { | 239 | 239 | continue; | 240 | 240 |
| 241 | 241 | int yy = mb.ySubblocks[lumaRow][lumaCol].val[lumaPRow * 4 + lumaPCol]; | 242 | | - luma[strideLuma * y + x] = yy; | | 242 | + luma[strideLuma * y + x] = (byte)(yy - 128); | 243 | 243 | } | 244 | 244 |
| 245 | 245 | for (int chromaRow = 0; chromaRow < 2; chromaRow++) | @@ -253,8 +253,8 @@ public Picture getPicture() { | 253 | 253 |
| 254 | 254 | int u = mb.uSubblocks[chromaRow][chromaCol].val[chromaPRow * 4 + chromaPCol]; | 255 | 255 | int v = mb.vSubblocks[chromaRow][chromaCol].val[chromaPRow * 4 + chromaPCol]; | 256 | | - cb[strideChroma * y + x] = u; | 257 | | - cr[strideChroma * y + x] = v; | | 256 | + cb[strideChroma * y + x] = (byte)(u - 128); | | 257 | + cr[strideChroma * y + x] = (byte)(v - 128); | 258 | 258 | } | 259 | 259 | } | 260 | 260 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/main/java/org/jcodec/codecs/vpx/VP8Encoder.java +43-48Lines changed: 43 additions & 48 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | import static java.lang.System.arraycopy; | 4 | 4 | import static org.jcodec.common.tools.MathUtil.clip; | 5 | 5 |
| 6 | | -import java.nio.ByteBuffer; | 7 | | -import java.nio.ByteOrder; | 8 | | -import java.util.Arrays; | 9 | | - | 10 | 6 | import org.jcodec.codecs.common.biari.VPxBooleanEncoder; | 11 | 7 | import org.jcodec.common.ArrayUtil; | 12 | 8 | import org.jcodec.common.VideoEncoder; | 13 | 9 | import org.jcodec.common.model.ColorSpace; | 14 | | -import org.jcodec.common.model.Picture; | 15 | 10 | import org.jcodec.common.model.Picture8Bit; | 16 | 11 | import org.jcodec.common.tools.MathUtil; | 17 | 12 |
| | 13 | +import java.nio.ByteBuffer; | | 14 | +import java.nio.ByteOrder; | | 15 | +import java.util.Arrays; | | 16 | + | 18 | 17 | /** | 19 | 18 | * This class is part of JCodec ( www.jcodec.org ) This software is distributed | 20 | 19 | * under FreeBSD License | | 25 | 24 | public class VP8Encoder extends VideoEncoder { | 26 | 25 |
| 27 | 26 | private VPXBitstream bitstream; | 28 | | - private int[][] leftRow; | 29 | | - private int[][] topLine; | | 27 | + private byte[][] leftRow; | | 28 | + private byte[][] topLine; | 30 | 29 | private VPXQuantizer quantizer; | 31 | 30 | private int[] tmp; | 32 | 31 | private RateControl rc; | @@ -43,22 +42,23 @@ public VP8Encoder(RateControl rc) { | 43 | 42 | this.tmp = new int[16]; | 44 | 43 | } | 45 | 44 |
| 46 | | - public ByteBuffer encodeFrame(Picture pic, ByteBuffer _buf) { | | 45 | + @Override | | 46 | + public ByteBuffer encodeFrame8Bit(Picture8Bit pic, ByteBuffer _buf) { | 47 | 47 | ByteBuffer out = _buf.duplicate(); | 48 | 48 | int mbWidth = ((pic.getWidth() + 15) >> 4); | 49 | 49 | int mbHeight = ((pic.getHeight() + 15) >> 4); | 50 | 50 |
| 51 | 51 | prepareBuffers(mbWidth, mbHeight); | 52 | 52 |
| 53 | 53 | bitstream = new VPXBitstream(VPXConst.tokenDefaultBinProbs, mbWidth); | 54 | | - leftRow = new int[][] { new int[16], new int[8], new int[8] }; | 55 | | - topLine = new int[][] { new int[mbWidth << 4], new int[mbWidth << 3], new int[mbWidth << 3] }; | 56 | | - initValue(leftRow, 129); | 57 | | - initValue(topLine, 127); | | 54 | + leftRow = new byte[][] { new byte[16], new byte[8], new byte[8] }; | | 55 | + topLine = new byte[][] { new byte[mbWidth << 4], new byte[mbWidth << 3], new byte[mbWidth << 3] }; | | 56 | + initValue(leftRow, (byte)1); | | 57 | + initValue(topLine, (byte)-1); | 58 | 58 |
| 59 | 59 | quantizer = new VPXQuantizer(); | 60 | 60 |
| 61 | | - Picture outMB = Picture.create(16, 16, ColorSpace.YUV420); | | 61 | + Picture8Bit outMB = Picture8Bit.create(16, 16, ColorSpace.YUV420); | 62 | 62 |
| 63 | 63 | int[] segmentQps = rc.getSegmentQps(); | 64 | 64 |
| @@ -68,7 +68,7 @@ public ByteBuffer encodeFrame(Picture pic, ByteBuffer _buf) { | 68 | 68 |
| 69 | 69 | // MB residuals | 70 | 70 | for (int mbY = 0, mbAddr = 0; mbY < mbHeight; mbY++) { | 71 | | - initValue(leftRow, 129); | | 71 | + initValue(leftRow, (byte)1); | 72 | 72 |
| 73 | 73 | for (int mbX = 0; mbX < mbWidth; mbX++, mbAddr++) { | 74 | 74 |
| @@ -161,7 +161,7 @@ private int[] calcSegmentProbs(int[] segmentMap) { | 161 | 161 | return result; | 162 | 162 | } | 163 | 163 |
| 164 | | - private void initValue(int[][] leftRow2, int val) { | | 164 | + private void initValue(byte[][] leftRow2, byte val) { | 165 | 165 | Arrays.fill(leftRow2[0], val); | 166 | 166 | Arrays.fill(leftRow2[1], val); | 167 | 167 | Arrays.fill(leftRow2[2], val); | @@ -244,7 +244,7 @@ private void writeHeader(ByteBuffer out, int width, int height, int firstPart) { | 244 | 244 | out.putShort((short) height); | 245 | 245 | } | 246 | 246 |
| 247 | | - private void collectPredictors(Picture outMB, int mbX) { | | 247 | + private void collectPredictors(Picture8Bit outMB, int mbX) { | 248 | 248 | arraycopy(outMB.getPlaneData(0), 240, topLine[0], mbX << 4, 16); | 249 | 249 | arraycopy(outMB.getPlaneData(1), 56, topLine[1], mbX << 3, 8); | 250 | 250 | arraycopy(outMB.getPlaneData(2), 56, topLine[2], mbX << 3, 8); | @@ -254,14 +254,14 @@ private void collectPredictors(Picture outMB, int mbX) { | 254 | 254 | copyCol(outMB.getPlaneData(2), 7, 8, leftRow[2]); | 255 | 255 | } | 256 | 256 |
| 257 | | - private void copyCol(int[] planeData, int off, int stride, int[] out) { | | 257 | + private void copyCol(byte[] planeData, int off, int stride, byte[] out) { | 258 | 258 | for (int i = 0; i < out.length; i++) { | 259 | 259 | out[i] = planeData[off]; | 260 | 260 | off += stride; | 261 | 261 | } | 262 | 262 | } | 263 | 263 |
| 264 | | - private void luma(Picture pic, int mbX, int mbY, VPxBooleanEncoder out, int qp, Picture outMB) { | | 264 | + private void luma(Picture8Bit pic, int mbX, int mbY, VPxBooleanEncoder out, int qp, Picture8Bit outMB) { | 265 | 265 | int x = mbX << 4; | 266 | 266 | int y = mbY << 4; | 267 | 267 | int[][] ac = transform(pic, 0, qp, x, y); | @@ -299,7 +299,7 @@ private int[] zigzag(int[] zz, int[] tmp2) { | 299 | 299 | return tmp2; | 300 | 300 | } | 301 | 301 |
| 302 | | - private void chroma(Picture pic, int mbX, int mbY, VPxBooleanEncoder boolEnc, int qp, Picture outMB) { | | 302 | + private void chroma(Picture8Bit pic, int mbX, int mbY, VPxBooleanEncoder boolEnc, int qp, Picture8Bit outMB) { | 303 | 303 | int x = mbX << 3; | 304 | 304 | int y = mbY << 3; | 305 | 305 | int chromaPred1 = chromaPredBlk(1, x, y); | @@ -317,7 +317,7 @@ private void chroma(Picture pic, int mbX, int mbY, VPxBooleanEncoder boolEnc, in | 317 | 317 | putChroma(outMB.getData()[2], 2, x, y, ac2, chromaPred2); | 318 | 318 | } | 319 | 319 |
| 320 | | - private int[][] transformChroma(Picture pic, int comp, int qp, int x, int y, Picture outMB, int chromaPred) { | | 320 | + private int[][] transformChroma(Picture8Bit pic, int comp, int qp, int x, int y, Picture8Bit outMB, int chromaPred) { | 321 | 321 | int[][] ac = new int[4][16]; | 322 | 322 |
| 323 | 323 | for (int blk = 0; blk < ac.length; blk++) { | @@ -332,22 +332,22 @@ private int[][] transformChroma(Picture pic, int comp, int qp, int x, int y, Pic | 332 | 332 | return ac; | 333 | 333 | } | 334 | 334 |
| 335 | | - private void putChroma(int[] mb, int comp, int x, int y, int[][] ac, int chromaPred) { | | 335 | + private void putChroma(byte[] mb, int comp, int x, int y, int[][] ac, int chromaPred) { | 336 | 336 | for (int blk = 0; blk < 4; blk++) | 337 | 337 | putBlk(mb, chromaPred, ac[blk], 3, (blk & 1) << 2, (blk >> 1) << 2); | 338 | 338 | } | 339 | 339 |
| 340 | | - private final int chromaPredOne(int[] pix, int x) { | 341 | | - return (pix[x] + pix[x + 1] + pix[x + 2] + pix[x + 3] + pix[x + 4] + pix[x + 5] + pix[x + 6] + pix[x + 7] + 4) >> 3; | | 340 | + private final byte chromaPredOne(byte[] pix, int x) { | | 341 | + return (byte)((pix[x] + pix[x + 1] + pix[x + 2] + pix[x + 3] + pix[x + 4] + pix[x + 5] + pix[x + 6] + pix[x + 7] + 4) >> 3); | 342 | 342 | } | 343 | 343 |
| 344 | | - private final int chromaPredTwo(int[] pix1, int[] pix2, int x, int y) { | 345 | | - return (pix1[x] + pix1[x + 1] + pix1[x + 2] + pix1[x + 3] + pix1[x + 4] + pix1[x + 5] + pix1[x + 6] | | 344 | + private final byte chromaPredTwo(byte[] pix1, byte[] pix2, int x, int y) { | | 345 | + return (byte)((pix1[x] + pix1[x + 1] + pix1[x + 2] + pix1[x + 3] + pix1[x + 4] + pix1[x + 5] + pix1[x + 6] | 346 | 346 | + pix1[x + 7] + pix2[y] + pix2[y + 1] + pix2[y + 2] + pix2[y + 3] + pix2[y + 4] + pix2[y + 5] | 347 | | - + pix2[y + 6] + pix2[y + 7] + 8) >> 4; | | 347 | + + pix2[y + 6] + pix2[y + 7] + 8) >> 4); | 348 | 348 | } | 349 | 349 |
| 350 | | - private int chromaPredBlk(int comp, int x, int y) { | | 350 | + private byte chromaPredBlk(int comp, int x, int y) { | 351 | 351 | int predY = y & 0x7; | 352 | 352 | if (x != 0 && y != 0) | 353 | 353 | return chromaPredTwo(leftRow[comp], topLine[comp], predY, x); | @@ -356,24 +356,24 @@ else if (x != 0) | 356 | 356 | else if (y != 0) | 357 | 357 | return chromaPredOne(topLine[comp], x); | 358 | 358 | else | 359 | | - return 128; | | 359 | + return 0; | 360 | 360 | } | 361 | 361 |
| 362 | | - private void putLuma(int[] planeData, int pred, int[][] ac, int log2stride) { | | 362 | + private void putLuma(byte[] planeData, int pred, int[][] ac, int log2stride) { | 363 | 363 | for (int blk = 0; blk < ac.length; blk++) { | 364 | 364 | int blkOffX = (blk & 3) << 2; | 365 | 365 | int blkOffY = blk & ~3; | 366 | 366 | putBlk(planeData, pred, ac[blk], log2stride, blkOffX, blkOffY); | 367 | 367 | } | 368 | 368 | } | 369 | 369 |
| 370 | | - private void putBlk(int[] planeData, int pred, int[] block, int log2stride, int blkX, int blkY) { | | 370 | + private void putBlk(byte[] planeData, int pred, int[] block, int log2stride, int blkX, int blkY) { | 371 | 371 | int stride = 1 << log2stride; | 372 | 372 | for (int line = 0, srcOff = 0, dstOff = (blkY << log2stride) + blkX; line < 4; line++) { | 373 | | - planeData[dstOff] = clip(block[srcOff] + pred, 0, 255); | 374 | | - planeData[dstOff + 1] = clip(block[srcOff + 1] + pred, 0, 255); | 375 | | - planeData[dstOff + 2] = clip(block[srcOff + 2] + pred, 0, 255); | 376 | | - planeData[dstOff + 3] = clip(block[srcOff + 3] + pred, 0, 255); | | 373 | + planeData[dstOff] = (byte)(clip(block[srcOff] + pred, -128, 127)); | | 374 | + planeData[dstOff + 1] = (byte)(clip(block[srcOff + 1] + pred, -128, 127)); | | 375 | + planeData[dstOff + 2] = (byte)(clip(block[srcOff + 2] + pred, -128, 127)); | | 376 | + planeData[dstOff + 3] = (byte)(clip(block[srcOff + 3] + pred, -128, 127)); | 377 | 377 | srcOff += 4; | 378 | 378 | dstOff += stride; | 379 | 379 | } | @@ -404,19 +404,19 @@ private int[] extractDC(int[][] ac) { | 404 | 404 | return dc; | 405 | 405 | } | 406 | 406 |
| 407 | | - private int lumaDCPred(int x, int y) { | | 407 | + private byte lumaDCPred(int x, int y) { | 408 | 408 | if (x == 0 && y == 0) | 409 | | - return 128; | | 409 | + return 0; | 410 | 410 |
| 411 | 411 | if (y == 0) | 412 | | - return (ArrayUtil.sumInt(leftRow[0]) + 8) >> 4; | | 412 | + return (byte)((ArrayUtil.sumByte(leftRow[0]) + 8) >> 4); | 413 | 413 | if (x == 0) | 414 | | - return (ArrayUtil.sumInt3(topLine[0], x, 16) + 8) >> 4; | | 414 | + return (byte)((ArrayUtil.sumByte3(topLine[0], x, 16) + 8) >> 4); | 415 | 415 |
| 416 | | - return (ArrayUtil.sumInt(leftRow[0]) + ArrayUtil.sumInt3(topLine[0], x, 16) + 16) >> 5; | | 416 | + return (byte)((ArrayUtil.sumByte(leftRow[0]) + ArrayUtil.sumByte3(topLine[0], x, 16) + 16) >> 5); | 417 | 417 | } | 418 | 418 |
| 419 | | - private int[][] transform(Picture pic, int comp, int qp, int x, int y) { | | 419 | + private int[][] transform(Picture8Bit pic, int comp, int qp, int x, int y) { | 420 | 420 | int dcc = lumaDCPred(x, y); | 421 | 421 |
| 422 | 422 | int[][] ac = new int[16][16]; | @@ -431,15 +431,15 @@ private int[][] transform(Picture pic, int comp, int qp, int x, int y) { | 431 | 431 | return ac; | 432 | 432 | } | 433 | 433 |
| 434 | | - private final void takeSubtract(int[] planeData, int planeWidth, int planeHeight, int x, int y, int[] coeff, int dc) { | | 434 | + private final void takeSubtract(byte[] planeData, int planeWidth, int planeHeight, int x, int y, int[] coeff, int dc) { | 435 | 435 | if (x + 4 < planeWidth && y + 4 < planeHeight) | 436 | 436 | takeSubtractSafe(planeData, planeWidth, planeHeight, x, y, coeff, dc); | 437 | 437 | else | 438 | 438 | takeSubtractUnsafe(planeData, planeWidth, planeHeight, x, y, coeff, dc); | 439 | 439 |
| 440 | 440 | } | 441 | 441 |
| 442 | | - private final void takeSubtractSafe(int[] planeData, int planeWidth, int planeHeight, int x, int y, int[] coeff, | | 442 | + private final void takeSubtractSafe(byte[] planeData, int planeWidth, int planeHeight, int x, int y, int[] coeff, | 443 | 443 | int dc) { | 444 | 444 | for (int i = 0, srcOff = y * planeWidth + x, dstOff = 0; i < 4; i++, srcOff += planeWidth, dstOff += 4) { | 445 | 445 | coeff[dstOff] = planeData[srcOff] - dc; | @@ -449,7 +449,7 @@ private final void takeSubtractSafe(int[] planeData, int planeWidth, int planeHe | 449 | 449 | } | 450 | 450 | } | 451 | 451 |
| 452 | | - private final void takeSubtractUnsafe(int[] planeData, int planeWidth, int planeHeight, int x, int y, int[] coeff, | | 452 | + private final void takeSubtractUnsafe(byte[] planeData, int planeWidth, int planeHeight, int x, int y, int[] coeff, | 453 | 453 | int dc) { | 454 | 454 | int outOff = 0; | 455 | 455 |
| @@ -478,9 +478,4 @@ private final void takeSubtractUnsafe(int[] planeData, int planeWidth, int plane | 478 | 478 | public ColorSpace[] getSupportedColorSpaces() { | 479 | 479 | return new ColorSpace[] { ColorSpace.YUV420J }; | 480 | 480 | } | 481 | | - | 482 | | - @Override | 483 | | - public ByteBuffer encodeFrame8Bit(Picture8Bit pic, ByteBuffer _out) { | 484 | | - throw new RuntimeException("Unsupported"); | 485 | | - } | 486 | 481 | } |
|