如何在 Android 上使用硬件加速视频解码? [英] How to use hardware accelerated video decoding on Android?

查看:45
本文介绍了如何在 Android 上使用硬件加速视频解码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个研究项目的硬件加速 H.264 解码,以测试自定义协议.

I need hardware-accelerated H.264 decoding for a research project, to test a self-defined protocol.

由于我在网络上进行了搜索,因此我找到了几种在 Android 上执行硬件加速视频解码的方法.

As I have Search on the web, I have found a few ways to perform hardware-accelerated video decoding on Android.

  1. 使用 ffmpeg libstagefright(概述libstagefright) 或直接在操作系统中使用 libstagefright,例如 这里.
  2. 在特定硬件平台上使用 OpenMax.像这里关于三星设备此处了解高通骁龙系列
  3. 有些人提到了PVplayer
  1. Use ffmpeg libstagefright (overview of libstagefright) or use libstagefright in the OS directly, like here.
  2. Use OpenMax on specific hardware platform. like here about samsung device and here about Qualcomm Snapdragon series
  3. Some people mentioned PVplayer,

有些人说" libstagefright 是唯一的方法高通公司的人显然取得了成功.

Some people "say" libstagefright is the only way while Qualcomm guys have made success obviously.

目前我不确定哪种方式可行.我现在有点困惑.如果一切都可行,我当然更喜欢与硬件无关的方法.

Currently I am not sure which way could work. I am a little confused now. If all could work, I would certainly prefer a hardware independent method.

因为我已经用 Galaxy Tab 7.7(3.2 & Enxyos)、VLC、Mobo、Rock、vplayer、rock 和 mobo 测试了一些他们的硬件加速的视频播放器,VLC 不起作用,vplayer 似乎有一个渲染错误,这会降低其性能.

As I have tested a few video players of their H/W acceleration with Galaxy Tab 7.7(3.2 & Enxyos), VLC, Mobo, Rock, vplayer, rock and mobo work fine, VLC doesn't work, vplayer seems to have a rendering bug which costs its performance.

无论如何,我对 Rockplayer 进行了操作"并删除了 datadatacom.redirecting ockplayer 中的所有 .so 库,并且软件解码崩溃,而硬件解码仍然正常!我想知道他们是怎么做到的.在我看来,硬件加速可以独立于硬件平台.

Anyway, I did an 'operation' on Rockplayer and deleted all its .so libs in datadatacom.redirecting ockplayer, and software decoding crashes while hw decoding works still fine! I wonder how they did that. It appears to me that hw acceleration could be independent of hardware platforms.

有人能解决这个问题吗?或者提供任何参考以提供更多信息或更详细的信息?

Can someone nail this problem? Or provide any reference with additional information or better details?

推荐答案

为了回答上面的问题,我先介绍几个Android相关的概念

To answer the above question, let me introduce few concepts related to Android

OpenMAXAndroid 使用 OpenMAX 作为编解码器接口.因此,所有本机编解码器(硬件加速或其他方式)都提供 OpenMAX 接口.StageFright(播放器框架)使用此接口使用编解码器解码媒体

OpenMAX Android uses OpenMAX for codec interface. Hence all native codecs (hardware accelerated or otherwise) provide OpenMAX interface. This interface is used by StageFright(Player framework) for decoding media using codec

NDKAndroid 允许 Java 应用程序使用 NDK 与底层 C/C++ 本机库进行交互.这需要使用 JNI(Java Native Interface).

NDK Android allows Java Applications to interact with underlying C/C++ native libraries using NDK. This requires using JNI (Java Native Interface).

现在来回答你的问题如何利用原生解码器来解码原始视频比特流?

在 Android 4.0 及以下版本中,Android 不提供对 Java 层底层视频解码器的访问.您需要编写本机代码才能直接与 OMX 解码器交互.尽管这是可能的,但它并非微不足道,因为它需要了解 OMX 的工作原理以及如何使用 NDK 将此 OMX 映射到应用程序.

In Android 4.0 version and below, Android did not provide access to underlying video decoders at Java layer. You would need to write native code to directly interact with OMX decoder. Though this is possible, it is not trivial as it would need knowledge of how OMX works and how to map this OMX to application using NDK.

在 4.1(Jelly Bean 版本)中,Android 似乎通过 JAVA API 在应用程序级别提供对硬件加速解码器的访问.有关新 API 的更多详细信息,请访问 http://developer.android.com/about/versions/android-4.1.html#Multimedia

In 4.1 (Jelly Bean version), Android seems to provide access to hardware accelerated decoders at application level through JAVA APIs. More details about new APIs at http://developer.android.com/about/versions/android-4.1.html#Multimedia

这篇关于如何在 Android 上使用硬件加速视频解码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆