Using an H264Decoder I would like to obtain the decoded YUV420 data as a Java byte array. I have searched all over and I don't see any examples that fit.
ByteBuffer buf = ByteBuffer.wrap(h264EncodedByteArray); H264Decoder decoder = new H264Decoder(); // assume that sps and pps are set on the decoder Picture out = Picture.create(320, 240, ColorSpace.YUV420); Picture real = decoder.decodeFrame(buf, out.getData());
The "h264EncodedByteArray" would be an array of h264 encoded bytes from a stream or file.
As far as I can tell the buf and avcC box must be supplied when doing the decode. Before any decoding can commence, you must provide avcC data.
After the avcC is created, you can use the following line to get the Picture.
In the code above the buf may or may not contain multiple NAL elements.