private boolean test(File coded, File ref) throws IOException {
BufferH264ES es = new BufferH264ES(NIOUtils.fetchFromFile(coded));
Picture buf = Picture.create(1920, 1088, ColorSpace.YUV420);
H264Decoder dec = new H264Decoder();
Packet nextFrame;
ByteBuffer _yuv = NIOUtils.fetchFromFile(ref);
while ((nextFrame = es.nextFrame()) != null) {
Picture out = dec.decodeFrame(nextFrame.getData(), buf.getData()).cropped();
Picture pic = out.createCompatible();
pic.copyFrom(out);
int lumaSize = pic.getWidth() * pic.getHeight();
int crSize = lumaSize >> 2;
int cbSize = lumaSize >> 2;
ByteBuffer yuv = NIOUtils.read(_yuv, lumaSize + crSize + cbSize);
if (!Platform.arrayEqualsByte(ArrayUtil.toByteArrayShifted(JCodecUtil2.getAsIntArray(yuv, lumaSize)), pic.getPlaneData(0)))
return false;
if (!Platform.arrayEqualsByte(ArrayUtil.toByteArrayShifted(JCodecUtil2.getAsIntArray(yuv, crSize)), pic.getPlaneData(1)))
return false;
if (!Platform.arrayEqualsByte(ArrayUtil.toByteArrayShifted(JCodecUtil2.getAsIntArray(yuv, cbSize)), pic.getPlaneData(2)))
return false;
}
return true;
}
}