所有电话都将在h.264编码器中支持YUV 420(半)平面彩色格式吗? [英] Will all phones support YUV 420 (Semi) Planar color format in h.264 encoder?

查看:111
本文介绍了所有电话都将在h.264编码器中支持YUV 420(半)平面彩色格式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Preambule:这听起来像是一个非常具体的问题,但这实际上是使用与大多数手机兼容的MediaCodec来构建API 16+ Android应用程序的一个可行的选择.

Preambule: This may sound like a very specific question, but this is actually a go / no go to build an API 16+ Android application using MediaCodec that is compatible with most phone.

我有一个带有h.264 MediaCodec的应用程序,该应用程序从缓冲区接收数据,而不是从表面接收数据,因为我在图像上进行了大量操作.创建Encoder时,我会遍历手机中可能的编码器列表,以确保我使用的是专有编码器(如果有).这部分没问题.

I have an application with a h.264 MediaCodec that receives data from a buffer - and not a surface since I'm doing a lot of manipulations on the image. When creating the Encoder, I iterate through the list of possible encoders from the phone to make sure I'm using a proprietary encoder if any. This part is not a problem.

问题是每个编码器都有其颜色格式首选项.这可能会导致在编码之前进行颜色格式转换.例如,在我的概念验证中,我包括了转换为NV12NV21YV12的方法,并遵循非常严格的规则,例如将某些平面/交错平面的起点放置在精确的偏移处只能使缓冲区中的视频看起来不错.

The problem is that each encoder has its color format preference. This may lead to color format conversion before encoding. In my proof-of-concept, for example, I included method to convert to NV12, NV21 and YV12, along with following very strict rules, like placing the start of some planes / interleaved plane at a precise offset in the buffer, etc. Just being able to make an encoded video look good may be a long story.

因此,如果我确定Android h.264 MediaCodec编码器所接受的标准,那么那将限制我为获得API 16 MediaCodec证明而必须进行的大量自定义操作-concept适用于所有设备.

So, if I was certain that there is a standard in what Android h.264 MediaCodec Encoders are accepting, then that would limit a lot the amount of customization I have to do to get my API 16 MediaCodec proof-of-concept working on all devices.

哦.我刚刚看到,在Android 18之前不可能创建输入界面.我将不得不依靠每种情况下检测专有编解码器和颜色格式,随机崩溃,缓慢的FPS等等.在2017年或2018年,将有足够的具有相关API功能的设备使用MediaCodec编写一个体面的应用程序.

Oh. I just saw that it's impossible to create an input surface before Android 18. I will have to rely on detecting proprietary codecs and color formats for each case, random crashes, slow FPS, etc. Bwe... With a bit of chance, in 2017 or 2018, there will be enough devices with relevant API features to write a decent app using MediaCodec.

推荐答案

真正的简短答案是:否.

The really short answer is: No.

从Android 4.3开始,有一项CTS测试,可以验证设备支持420个平面输入还是420个半平面输入-最重要的是,它以与其他输入相同的方式对其进行解释.

From Android 4.3 there is a CTS test that verifies that devices support either 420 planar or 420 semiplanar input - and, most importantly, that it interprets it in the same way as the others.

实际上,大多数Android 4.1设备确实以一种或另一种形式支持平面或半平面,但是您需要解决许多怪异的问题,这些怪异特定于不同的设备和芯片组.一些编码器(一堆Samsung Exynos设备)做广告为半平面广告,但与其他设备(和参考设备)相比,它通过交换色度分量来解释它.一些编码器(也包括Samsung Exynos)发布平面广告,但将其解释为专有的平铺格式(或崩溃).某些编码器(Qualcomm)假定亮度和色度平面之间存在额外的对齐方式.

In practice, most devices from Android 4.1 do support either planar or semiplanar in one form or another, but there's a lot of quirks you need to work around, which are specific to different devices and chipsets. Some encoders (a bunch of Samsung Exynos devices) advertise semiplanar but interpret it with chroma components swapped compared to other devices (and the reference). Some encoders (also Samsung Exynos) advertise planar but interpret it as a proprietary tiled format (or crash). Some encoders (Qualcomm) assume extra alignment between the luma and chroma planes.

请参见 https://code.google.com/p/android /issues/detail?id = 37769 了解有关您可能遇到的问题的更多详细信息.实际上,您可能可以使它在大量设备上运行,但是您需要或多或少地对每个设备进行验证,并为每个设备启用不同的怪异解决方法.

See https://code.google.com/p/android/issues/detail?id=37769 for more details on the issues you can encounter. In practice you can probably get it working on a large number of devices, but you'll need to more or less verify it per device and enable different quirk workarounds per device.

这篇关于所有电话都将在h.264编码器中支持YUV 420(半)平面彩色格式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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