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
.
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 ongralloc
handle, but feel that the following should also be functional.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 ingralloc
.On some platforms, the hardware decoder does not create user-space YUV by default. You may try
What platform are you using?
1) Usually the easiest way to get output buffer dump is to do it in vendor OMX IL (in every vendor impl which I worked there were ready functions/macros to do it)
2) If not you should try to dump buffer in ACodec
onFillBufferDone
(you need to differentiate between audio/video) oronOutputBufferDrained
, you must getmGraphicBuffer
and get from it raw buffer - encapsulation is platform dependent eg for qc it would beAssuming that info is (in ACodec::onOutputBufferDrained)
In OMXCodec case you can make the same at the end of OMXCodec::read Returned buf just save into the file, size to be written will be WxHxPixelRatio.