@Override public int calculateMarshalSize(ReprocessFormatsMap value) { /* * // writing (static example, DNG+ZSL) * int32_t[] contents = { * RAW_OPAQUE, 3, RAW16, YUV_420_888, BLOB, * RAW16, 2, YUV_420_888, BLOB, * ..., * INPUT_FORMAT, OUTPUT_FORMAT_COUNT, [OUTPUT_0, OUTPUT_1, ..., OUTPUT_FORMAT_COUNT-1] * }; */ int length = 0; int[] inputs = value.getInputs(); for (int input : inputs) { length += 1; // INPUT_FORMAT length += 1; // OUTPUT_FORMAT_COUNT int[] outputs = value.getOutputs(input); length += outputs.length; // [OUTPUT_0, OUTPUT_1, ..., OUTPUT_FORMAT_COUNT-1] } return length * SIZEOF_INT32; }
@Override public void marshal(ReprocessFormatsMap value, ByteBuffer buffer) { /* * // writing (static example, DNG+ZSL) * int32_t[] contents = { * RAW_OPAQUE, 3, RAW16, YUV_420_888, BLOB, * RAW16, 2, YUV_420_888, BLOB, * ..., * INPUT_FORMAT, OUTPUT_FORMAT_COUNT, [OUTPUT_0, OUTPUT_1, ..., OUTPUT_FORMAT_COUNT-1] * }; */ int[] inputs = StreamConfigurationMap.imageFormatToInternal(value.getInputs()); for (int input : inputs) { // INPUT_FORMAT buffer.putInt(input); int[] outputs = StreamConfigurationMap.imageFormatToInternal(value.getOutputs(input)); // OUTPUT_FORMAT_COUNT buffer.putInt(outputs.length); // [OUTPUT_0, OUTPUT_1, ..., OUTPUT_FORMAT_COUNT-1] for (int output : outputs) { buffer.putInt(output); } } }