android - MediaCodec decoding h264 wrong on one device -


i'm trying decode h.264 stream using android's mediacodec interface. working fine on test devices, on 1 customer device dont' have access (samsung tab s) there strange issues.

when decode stream don't send sps/pps nals or initial frame. start pushing data live stream, chopped blocks ending 0x09 nal , decoder synchronize nicely without problems quite quickly.

the issue @ least 1 device when bufferinfo decoder claim decoded 1413120 bytes of data, buffer size 1382400! of course if try data out of buffer crash.

the video 1280x720 , decoded nv12, buffer size fine. reported decoded output size isn't. if force size 1382400 , convert nv12 rgb correct picture. first 32 lines have strong green color , blue channel shifted quite lot. means uv block decoded partially wrong on device.

has run kind of issue before? have recorded raw h264 stream specific device , plays fine no green blocks or color shifts.

should set sps/pps , initial frame before starting streaming? stream seems contain needed since decoder realizes resolution correct, sets buffers , decodes on every other device i've tested except one. i'm wondering if samsung has special going on.

another application decoding same stream shows without issues, far know use ffmpeg internally, not mediacodec. rather use built-in system codecs if possible.

here example of result. don't have image of stream, note frame rotated. y component in green area fine , on white block on right can see blue shift.

enter image description here

edit: if start decoder sps/pps blocks in csd-0 color problems persist. isn't due that.

also managed test exact stream device. no green bar, no color shifts. it's problem codec in particular device/model.

i had similar issues in past (specifically on samsung devices) , if remember correctly due missing sps/pps data. must feed in sps/pps data if want consistent results.

not direct solution issue possible workaround use alternative decoder (if present) when running on particular device.

i'm not sure how instantiating decoder people use mime type so:

decoder = mediacodec.createdecoderbytype("video/avc"); 

the device choose preferred decoder (probably hardware).

you can alternatively instantiate specific decoder so:

decoder = mediacodec.createbycodecname("omx.google.h264.decoder");  // or  decoder = mediacodec.createbycodecname("omx.qcom.video.decoder.avc"); 

in experience, devices have @ least 2 different h264 decoders available , may find alternative decoder on device performs without faults.

you can list available codecs using following code:

static mediacodecinfo[] getcodecs() {      if (build.version.sdk_int >= build.version_codes.lollipop) {         mediacodeclist mediacodeclist = new mediacodeclist(mediacodeclist.all_codecs);         return mediacodeclist.getcodecinfos();     } else {         int numcodecs = mediacodeclist.getcodeccount();         mediacodecinfo[] mediacodecinfo = new mediacodecinfo[numcodecs];          (int = 0; < numcodecs; i++) {             mediacodecinfo codecinfo = mediacodeclist.getcodecinfoat(i);             mediacodecinfo[i] = codecinfo;         }          return mediacodecinfo;     }        } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -