如何从OMX codeC的解码输出转储YUVOMX、codeC、YUV

2023-09-04 13:35:06 作者:执青灯望长安

我想从 OMX codeC 解码输出转储 YUV 数据。 这是 MediaBuffer 键入。这是不可能的访问数据()指针。

I'd like to dump YUV data from OMXCodec decoding output. It's MediaBuffer type. It's impossible to access data() pointer.

如果我试图访问数据时,会发生死机由于下面的检查code。

If I try to access data, crash happens due to the check code below.

frameworks/av/media/libstagefright/MediaBuffer.cpp:119 CHECK(mGraphicBuffer == NULL) failed.

请让我知道解决这一提取物 YUV 数据 MediaBuffer

Please let me know the solution to extract YUV data from this MediaBuffer.

推荐答案

MediaBuffer ,我觉得下面的应该是功能。我还没有尝试过同样的但并与RG2的解决方案,即直接根据 gralloc 处理工作,但觉得以下也应该是功能性的。

From the MediaBuffer, I feel that the following should be functional. I haven't tried the same yet and have worked with rg2's solution i.e. directly based on gralloc handle, but feel that the following should also be functional.

 sp<GraphicBuffer> mCurrGraphicBuffer;
 void *vaddr;

 err = source->read(&buffer, &options); // Where buffer is of MediaBuffer type

 mCurrGraphicBuffer = buffer->graphicBuffer();
 width  = mCurrGraphicBuffer->getWidth();
 height = mCurrGraphicBuffer->getWidth();
 format = mCurrGraphicBuffer->getFormat();

 mCurrGraphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, &vaddr);
 //Dump the YUV file based on the vaddr, width, height, format
 mCurrGraphicBuffer->unlock();

编辑:

为了对上述解决方案的工作,实际 GraphicBuffer 应创建或分配相应的使用标志即缓冲区应该用一个暗示,CPU会被创建访问相同。否则, -EINVAL 将返回按照的在 gralloc 。文件

In order for the aforementioned solution to work, the actual GraphicBuffer should be created or allocated with appropriate usage flags i.e. the buffer should be created with a hint that CPU would be accessing the same. Else, -EINVAL would be returned as per the documentation in gralloc.