Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
437 views
in Technique[技术] by (71.8m points)

android - How to dump YUV from OMXCodec decoding output

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

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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();

EDIT:

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...