Developing H264 hardware decoder Android - Stagefright or OpenMax IL?

我们两清 提交于 2019-12-03 15:47:32

You really should go for MediaCodec. Calling java methods via JNI does have some overhead, but you should keep in mind what order of magnitude the overhead is. If you'd call a function per pixel, the overhead of JNI calls might be problematic. But for using MediaCodec, you only do a few function calls per frame, and the overhead there is negligible.

See e.g. http://git.videolan.org/?p=vlc.git;a=blob;f=modules/codec/omxil/mediacodec_jni.c;h=57df9889c97706436823a4960206e323565e221c;hb=b31df501269b56c65327be181cdca3df48946fb1 as an example on using MediaCodec from C code using JNI. As others also have gone this way, I can assure you that the JNI overhead is not a reason to consider other APIs than MediaCodec.

Using stagefright or OMX directly is problematic; the ABI differs between each platform version (so you can either only target one version, or compile multiple times targeting different versions, packaging it all up in one package), and you'd have to deal with a lot of device specific quirks, while MediaCodec should (and on modern versions does) work the same across all devices.

I found a great resource of using stagefright with FFmpeg, but I can not use FFmpeg as for its license, it is quite restrictive for distributed software. (Or possible to discard FFmpeg from this approach?)

That's not true. FFmpeg is LGPL, so you can just use it in your commercially redistributable application.

However, you might be using modules of FFmpeg which are GPL licensed, e.g. libx264. In that case, your program must be GPL-compliant.

But not even that is bad for distributing software -- it just means that you need to give your customers (who should be kings, anyway), access to the source code of the application they are paying for, and are not allowed to restrict their freedoms. Not a bad deal, IMHO.

Also, I came to know that Android H/W accelerated decoder is vendor specific and every vendors has their own OMX interfacing APIs. Is it true?

Obviously, yes. If you need hardware acceleration, someone has to write a program that makes your specific hardware accelerate something.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!