简体   繁体   English

使用Stagefright库在Android中进行H264 HW加速解码

[英]H264 HW accelerated decoding in Android using stagefright library

I`m trying to decode h264 video using HW with Stagefright library. 我正在尝试使用带有Stagefright库的硬件对h264视频进行解码。

i have used an example in here . 我在这里用了一个例子。 Im getting decoded data in MedaBuffer . 我在MedaBuffer获取解码数据。 For rendering MediaBuffer->data() i tried AwesomeLocalRenderer in AwesomePlayer.cpp. 用于渲染MediaBuffer->data()我试图AwesomeLocalRenderer在AwesomePlayer.cpp。

but picture in screen are distorted 但是屏幕上的图像失真

Here is The Link of original and crashed picture. 这是原始图片和崩溃图片的链接

And also tried this in example` 并在示例中也尝试过`

sp<MetaData> metaData = mVideoBuffer->meta_data();
int64_t timeUs = 0;
metaData->findInt64(kKeyTime, &timeUs);
native_window_set_buffers_timestamp(mNativeWindow.get(), timeUs * 1000);
err = mNativeWindow->queueBuffer(mNativeWindow.get(), 
mVideoBuffer->graphicBuffer().get(), -1);`

But my native code crashes. 但是我的本机代码崩溃了。 I can`t get real picture its or corrupted or it black screen. 我无法获得真实的照片或它损坏或黑屏。

Thanks in Advance. 提前致谢。

If you are using a HW accelerated decoder, then the allocation on the output port of your component would have been based on a Native Window . 如果您使用的是HW加速解码器,则组件输出端口上的分配将基于本Native Window In other words, the output buffer is basically a gralloc handle which has been passed by the Stagefright framework. 换句话说,输出缓冲区基本上是由Stagefright框架传递的gralloc句柄。 (Ref: OMXCodec::allocateOutputBuffersFromNativeWindow ). (参考: OMXCodec::allocateOutputBuffersFromNativeWindow )。 Hence, the MediaBuffer being returned shouldn't be interpreted as a plain YUV buffer. 因此, MediaBuffer将返回的MediaBuffer解释为普通的YUV缓冲区。

In case of AwesomeLocalRenderer , the framework performs a software color conversion when mTarget->render is invoked as shown here. 如果是AwesomeLocalRenderer ,则在调用mTarget->render时,框架将执行软件颜色转换,如下所示。 If you trace the code flow, you will find that the MediaBuffer content is directly interpreted as YUV buffer. 如果跟踪代码流,您会发现MediaBuffer内容直接解释为YUV缓冲区。

For HW accelerated codecs, you should be employing AwesomeNativeWindowRenderer . 对于HW加速编解码器,您应该使用AwesomeNativeWindowRenderer If you have any special conditions for employing AwesomeLocalRenderer , please do highlight the same. 如果您有使用AwesomeLocalRenderer特殊条件,请突出显示相同的内容。 I can refine this response appropriately. 我可以适当地优化此响应。

PS: For debug purposes, you could also refer to this question which captured the methods to dump the YUV data and analyze the same. PS:出于调试目的,您还可以参考此问题该问题捕获了转储YUV数据并进行分析的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM