0

i have followed below method to access YUV buffer. It works in few phones. But in S3 and Note 3 I'm getting problem. any reason ? Please help me.

sp<GraphicBuffer> mCurrGraphicBuffer;

void *vaddr;

mCurrGraphicBuffer = mVideoBuffer->graphicBuffer();

mCurrGraphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, &vaddr);

I tried to google, but nothing helped me.

Ganesh
  • 5,880
  • 2
  • 36
  • 54
  • This YUV comes from the camera and you want to change it before it gets into the HW encoder, is that right? – Alex Cohn Dec 14 '14 at 08:49
  • Hi Alex,I receive H264 Streams from network and after JB, i'll provide these streams to OMXCodec. Rendering is Fine. But i need to capture some Key frames to JPG. So i wrote this code to that. In most of the handsets its working fine. But in Note3 and S3 I'm facing this problem. – user3865065 Dec 16 '14 at 10:32
  • Aha, so you set up your stagefright to render the output on surface. On some Samsung devices, you will not have access to the YUV frame in this case. You can run a separate decoder to receive YUV. If you really need key frames only, you can run this decoder once in a while. – Alex Cohn Dec 16 '14 at 13:31
  • Ok. I will try to create decoder for this case. I'll update you. – user3865065 Dec 20 '14 at 11:57

1 Answers1

1

The implementation of lock to provide a mapped virtual address is dependent on the vendor's internal implementation in gralloc.

One potential cause for your issue could be that the GraphicBuffer may not have been created with usage flags indicating GRALLOC_USAGE_SW_READ_OFTEN.

If possible, please enable this flag in usage flags prior to the creation of GraphicBuffer and retry your experiment, which I feel should be successful.

Ganesh
  • 5,880
  • 2
  • 36
  • 54
  • You Mean, to enable flag kEnableGrallocUsageProtected ? – user3865065 Dec 16 '14 at 10:35
  • In the usage flags being passed to `gralloc`, you should include `GRALLOC_USAGE_SW_READ_OFTEN`. For example, in case of `kEnableGrallocUsageProtected`, there is an update to usage flags as in http://androidxref.com/5.0.0_r2/xref/frameworks/av/media/libstagefright/OMXCodec.cpp#1848 . One example can be found here: http://androidxref.com/5.0.0_r2/xref/frameworks/native/libs/gui/tests/SurfaceTextureGL_test.cpp#332 – Ganesh Dec 16 '14 at 14:01
  • Hi, I tried this method. No luck. any other suggestion please? – user3865065 Dec 20 '14 at 11:56