}
@Test
public void testGetBlankFrame()
{
IVideoPicture frame = null;
byte y = 62;
byte u = 15;
byte v = 33;
int w = 100;
int h = 200;
long pts = 102832;
frame = Utils.getBlankFrame(w, h, y, u, v, pts);
assertTrue("got a frame", frame != null);
assertTrue("is complete", frame.isComplete());
assertTrue("correct pts", frame.getPts() == pts);
// now, loop through the array and ensure it is set
// correctly.
IBuffer data = frame.getData();
java.nio.ByteBuffer buffer = data.getByteBuffer(0, data.getBufferSize());
assertNotNull(buffer);
// we have the raw data; now we set it to the specified YUV value.
int lineLength = 0;
int offset = 0;
// first let's check the L
offset = 0;
lineLength = frame.getDataLineSize(0);
assertTrue("incorrect format", lineLength == w);
for(int i = offset ; i < offset + lineLength * h; i++)
{
byte val = buffer.get(i);
assertTrue("color not set correctly: " + i, val == y);
}
// now, check the U value
offset = (frame.getDataLineSize(0)*h);
lineLength = frame.getDataLineSize(1);
assertTrue("incorrect format", lineLength == w / 2);
for(int i = offset ; i < offset + lineLength * h / 2; i++)
{
byte val = buffer.get(i);
assertTrue("color not set correctly: " + i, val == u);
}
// and finally the V
offset = (frame.getDataLineSize(0)*h) + (frame.getDataLineSize(1)*h/2);
lineLength = frame.getDataLineSize(2);
assertTrue("incorrect format", lineLength == w / 2);
for(int i = offset; i < offset + lineLength * h / 2; i++)
{
byte val = buffer.get(i);
assertTrue("color not set correctly: " + i, val == v);