cancel
Showing results for 
Search instead for 
Did you mean: 

Android MediaCodec

kumetick
Honored Guest
Hello everyone.
In our program, HLS 360video data is decoded using Android MediaCodec and rendered on the Unity.
It uses MediaCodec to decode the H264 stream, but it looks very slow in Oculus Quest.
And MediaCodec stops decoding after a short while.

The following log was displayed in logcat.


This content is output every time data is sent using MediaCodec's queueInputBuffer.
#gpuaddr changes every time.
2019-08-19 11:51:33.251 685-22216/? E/Adreno-C2D: <c2dgsl_unmap_user_mem:1124>: Invalid input (gpuaddr=0x2b1a000) error=0 
2019-08-19 11:51:33.251 685-22216/? E/C2DColorConvert: c2dUnMapAddr failed: status 3 gpuaddr 02b1a000
2019-08-19 11:51:33.251 685-22216/? E/C2DColorConvert: unmapping GPU address failed
2019-08-19 11:51:33.251 685-22216/? E/OMX-VDEC-1080P: Failed color conversion 0

After decoding for a few seconds, the log changes to the following.
2019-08-19 11:51:36.036 685-22223/? W/Adreno-GSL: <gsl_ldd_control:549>: ioctl fd 13 code 0xc0200948 (IOCTL_KGSL_GPUOBJ_IMPORT) failed: errno 12 Out of memory
2019-08-19 11:51:36.036 685-22223/? E/Adreno-C2D: <c2dgsl_map_user_mem:1095>: Error while gsl_memory_map_ext_fd(mem_fd=34, hostptr=0xe1f32000, len=1413120, offset=0, flags=3 ) error=-4
2019-08-19 11:51:36.036 685-22223/? E/C2DColorConvert: c2dMapAddr failed: status 3 fd 34 ptr 0xe1f32000 len 1413120 flags 3

It seems that GPU memory allocation and deallocation in the decoder does not work, but the cause is unknown.


 The source code of the part that uses MediaCodec is posted.

# Partially omitted.

Decoder initialization process.

I tried setting #SPS and PPS, and setting other keys to MediaFormat, but the operation did not change.
void initDecoder(final byte[] data) throws IOException {
MediaFormat mediaFormat;
mediaFormat = MediaFormat.createVideoFormat(mime, viewWidth, viewHeight);
mediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, viewWidth * viewHeight);

try {
codec.configure(mediaFormat, null, null, 0);
codec.start();
} catch (Exception e) {
}
}

 When receiving frame data by streaming, it passes the data to the decoder.
boolean decodeFrame(final int iTimestamp, byte[] data) {
if (doInit) {
try {
initDecoder(data);
} catch (IOException e) {
e.printStackTrace();
}
doInit = false;
//flgs = MediaCodec.BUFFER_FLAG_CODEC_CONFIG;
flgs = MediaCodec.BUFFER_FLAG_KEY_FRAME;
} else {
flgs = MediaCodec.BUFFER_FLAG_PARTIAL_FRAME; //Tried another flg. But result did not change.
}

try {
final int inputBufIndex = codec.dequeueInputBuffer(1000 * 100);

if (inputBufIndex >= 0) {
ByteBuffer[] inputBuffers = null;
ByteBuffer inputBuf;
inputBuf = codec.getInputBuffer(inputBufIndex);
inputBuf.put(data);
long presentationTimeUs = iTimestamp*1000;

codec.queueInputBuffer(
inputBufIndex,
0, // offset
data.length,
presentationTimeUs,
flgs
);
return true;
}
} catch (Exception e) {
return false;
}
return false;
}

This issue has not happened on other Android devices.

The same program works fine with Oculus Go, but only Oculus Quest has this problem.

Is this a bug specific to Oculus Quest?
3 REPLIES 3

Tomas-Jakobsson
Honored Guest
We have the same issue, and also only on the Quest, it works just fine on all other Android devices we've tested it on.

whatisor
Explorer
Is there someone working on it?
I believe Quest should have some specific setting...

robco5
Honored Guest

I have same issue on Quest.

Everything works fine on Quest 2...

 

Any suggestions on how to fix it on Quest?