private long decode(boolean withPrefix) {
		int n = 0, i = 0, j = 0;
		long elapsed = 0, now = timestamp();
		int decInputIndex = 0, decOutputIndex = 0;
		ByteBuffer[] decInputBuffers = mDecoder.getInputBuffers();
		ByteBuffer[] decOutputBuffers = mDecoder.getOutputBuffers();
		BufferInfo info = new BufferInfo();

		while (elapsed<3000000) {

			// Feeds the decoder with a NAL unit
			if (i<NB_ENCODED) {
				decInputIndex = mDecoder.dequeueInputBuffer(1000000/FRAMERATE);
				if (decInputIndex>=0) {
					int l1 = decInputBuffers[decInputIndex].capacity();
					int l2 = mVideo[i].length;
					decInputBuffers[decInputIndex].clear();
					
					if ((withPrefix && hasPrefix(mVideo[i])) || (!withPrefix && !hasPrefix(mVideo[i]))) {
						check(l1>=l2, "The decoder input buffer is not big enough (nal="+l2+", capacity="+l1+").");
						decInputBuffers[decInputIndex].put(mVideo[i],0,mVideo[i].length);
					} else if (withPrefix && !hasPrefix(mVideo[i])) {
						check(l1>=l2+4, "The decoder input buffer is not big enough (nal="+(l2+4)+", capacity="+l1+").");
						decInputBuffers[decInputIndex].put(new byte[] {0,0,0,1});
						decInputBuffers[decInputIndex].put(mVideo[i],0,mVideo[i].length);
					} else if (!withPrefix && hasPrefix(mVideo[i])) {
						check(l1>=l2-4, "The decoder input buffer is not big enough (nal="+(l2-4)+", capacity="+l1+").");
						decInputBuffers[decInputIndex].put(mVideo[i],4,mVideo[i].length-4);
					}
					
					mDecoder.queueInputBuffer(decInputIndex, 0, l2, timestamp(), 0);
					i++;
				} else {
					if (VERBOSE) Log.d(TAG,"No buffer available !");
				}
			}

			// Tries to get a decoded image
			decOutputIndex = mDecoder.dequeueOutputBuffer(info, 1000000/FRAMERATE);
			if (decOutputIndex == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
				decOutputBuffers = mDecoder.getOutputBuffers();
			} else if (decOutputIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
				mDecOutputFormat = mDecoder.getOutputFormat();
			} else if (decOutputIndex>=0) {
				if (n>2) {
					// We have successfully encoded and decoded an image !
					int length = info.size;
					mDecodedVideo[j] = new byte[length];
					decOutputBuffers[decOutputIndex].clear();
					decOutputBuffers[decOutputIndex].get(mDecodedVideo[j], 0, length);
					// Converts the decoded frame to NV21
					convertToNV21(j);
					if (j>=NB_DECODED-1) {
						flushMediaCodec(mDecoder);
						if (VERBOSE) Log.v(TAG, "Decoding "+n+" frames took "+elapsed/1000+" ms");
						return elapsed;
					}
					j++;
				}
				mDecoder.releaseOutputBuffer(decOutputIndex, false);
				n++;
			}	
			elapsed = timestamp() - now;
		}

		throw new RuntimeException("The decoder did not decode anything.");

	}
@param withPrefix If set to true, the decoder will be fed with NALs preceeded with 0x00000001.
@return How long it took to decode all the NALs
src/net/majorkernelpanic/streaming/hw/EncoderDebugger.java