¿Cómo podemos hacer que el método saveFrame () en ExtractMpegFramesTest sea más eficiente?
[editar] Reformateo en formato de preguntas y respuestas siguiendo la sugerencia de fadden @.
EnExtractMpegFramesTest_egl14.java.txt, método saveFrame (), hay un ciclo para reordenar RGBA en ARGB para la compresión PNG de mapa de bits (vea las citas de ese archivo a continuación), ¿cómo se puede optimizar esto?
// glReadPixels gives us a ByteBuffer filled with what is essentially big-endian RGBA
// data (i.e. a byte of red, followed by a byte of green...). We need an int[] filled
// with little-endian ARGB data to feed to Bitmap.
//
...
// So... we set the ByteBuffer to little-endian, which should turn the bulk IntBuffer
// get() into a straight memcpy on most Android devices. Our ints will hold ABGR data.
// Swapping B and R gives us ARGB. We need about 30ms for the bulk get(), and another
// 270ms for the color swap.
...
for (int i = 0; i < pixelCount; i++) {
int c = colors[i];
colors[i] = (c & 0xff00ff00) | ((c & 0x00ff0000) >> 16) | ((c & 0x000000ff) << 16);
}