This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Native Camera app buffer details and omx_h264enc StoreMetaDataInBuffersParams

Hi,all!

    I have the ics 4.0.3  and omap4430. I want to use gstreamer and gst-openmax.The command is "gst-launch omx_camera mode=1 device=secondary name=cam cam.src ! queue ! surfaceflingersink cam.vidsrc ! queue ! omx_h264enc profile=8 bitrate=1024000 ! filesink location=/mnt/sdcard/ttt  --gst-debug=omx:5".  I have read the stagefright code in the ics and the stagefright use the  OMX_AllocateBuffer  and  copy the data from srcBuffer  by memcpy(OMXCodec::drainInputBuffer(BufferInfo *info)).I find that the it only copy a little of data from srcBuffer to omx buffer header  (memcpy((uint8_t *)info->mData + offset,(const uint8_t *)srcBuffer->data()+ srcBuffer->range_offset(),srcBuffer->range_length());),the most is 136 bytes. the camera and encoder  function are ok and the camera preview is ok too.

    I find the OMXNodeInstance::storeMetaDataInBuffers  and  struct StoreMetaDataInBuffersParams .this means  explain that :

// A pointer to this struct is passed to OMX_SetParameter() when the extension
// index "OMX.google.android.index.storeMetaDataInBuffers"
// is given.
//
// When meta data is stored in the video buffers passed between OMX clients
// and OMX components, interpretation of the buffer data is up to the
// buffer receiver, and the data may or may not be the actual video data, but
// some information helpful for the receiver to locate the actual data.
// The buffer receiver thus needs to know how to interpret what is stored
// in these buffers, with mechanisms pre-determined externally. How to
// interpret the meta data is outside of the scope of this method.
//
// Currently, this is specifically used to pass meta data from video source
// (camera component, for instance) to video encoder to avoid memcpying of
// input video frame data. To do this, bStoreMetaDta is set to OMX_TRUE.
// If bStoreMetaData is set to false, real YUV frame data will be stored
// in the buffers. In addition, if no OMX_SetParameter() call is made
// with the corresponding extension index, real YUV data is stored
// in the buffers.

struct StoreMetaDataInBuffersParams {
    OMX_U32 nSize;
    OMX_VERSIONTYPE nVersion;
    OMX_U32 nPortIndex;
    OMX_BOOL bStoreMetaData;
};

I  set the parameter   in the gst-openmax   omx_setup()   in  gstomx_h264enc.c  by storeMetaDataInBuffers function and it return OMX_ErrorNone.So i think it set success.so  i have some questions. 

1 ) Dose it affect camera that i set this parameter and the data from camera app have the address about the yuv ? 

2) what data produceed by camera  after set this parameter  and  what is the differences in data  before set and after? 

3) If the data is same before  and after  set paramter ,how the omx codec get the address about data only copy a few of bytes?  

4) The camera produce data and transfer data to omx_h264enc plugin  in the gstreamer and i want to use it as the same as stagefright .so i use the OMX_AllocateBuffer function in the g_omx_port_allocate_buffers (gstomx_port.c)  after set the StoreMetaDataInBuffersParams ,but i can not get the same data as stagefright.so what should i do ? 

5) In the gst-openmax ,the OMX_AllocateBuffer will allocate buffer and OMX_UseBuffer use the buffer pass by other component.Dose the two functions have other differences?

Thank you very much!

BR

Aaron 

  • 1 ) Dose it affect camera that i set this parameter and the data from camera app have the address about the yuv ? 

    2) what data produceed by camera  after set this parameter  and  what is the differences in data  before set and after? 

    - What Parameter are you setting with OMX_SetParemeter()?

    It is the Buffer headers that are being copied. The frame data (i.e image) is not copied.

    4) The camera produce data and transfer data to omx_h264enc plugin  in the gstreamer and i want to use it as the same as stagefright .so i use the OMX_AllocateBuffer function in the g_omx_port_allocate_buffers (gstomx_port.c)  after set the StoreMetaDataInBuffersParams ,but i can not get the same data as stagefright.so what should i do ? 

    Which TI release of OMAP4 Android S/W are you using ? Where is the GStreamer component in this TI release?

     

    5) In the gst-openmax ,the OMX_AllocateBuffer will allocate buffer and OMX_UseBuffer use the buffer pass by other component.Dose the two functions have other differences?

    No.

  •  

    3) If the data is same before  and after  set paramter ,how the omx codec get the address about data only copy a few of bytes? 

     

    It is the Buffer headers that are copied. The frame data (i.e image) is not copied.

  • Hi  Paul:

        I want to set the

    struct StoreMetaDataInBuffersParams {
        OMX_U32 nSize;
        OMX_VERSIONTYPE nVersion;
        OMX_U32 nPortIndex;
        OMX_BOOL bStoreMetaData;
    };

    with the OMX_SetParameter, and  What is the effect after setting   this  parameter ? I find that the stagefright  only  copy more than a dozen  bytes  and  the omx  component is ok ,so what means about the bytes ? which function will copy the header of omx to the buffer which alloc by OMX_AllocateBuffer?

    The android  is 4.0.3  and the gst-openmax  gets from the android 2.3. The gst-openmax and omx_h264enc are ok when i use the  file .But the encoder will suspend when i use the camera as src  in  the OMX_EmptyThisBuffer in  the release_buffer function.

    I find that the omx_buffer  nAllocLen is 4096  and the nFillLen is 3686400,i think this is wrong,is it?

    I want to modify the gst-openmax like openmx in stagefright,what  parameters should i set?

    I  know there is an  environment variable : OMX_ALLOCATE_ON, if set the OMX_ALLOCATE_ON = 1,the omx  component will call the OMX_AllocateBuffer to alloc buffer by itself.Does the OMX_ALLOCATE_ON only influence  the gst-openmax or will influence gst-openmax  and domx ?

    Thank you very much!

    BR

    Aaron

  • Aaron,

    OMX_SetParameter on StoreMetaDataInBuffersParams will result in MetData information being returned to the client. i.e not the actual frame buffer but pointer to the frame buffer.

    The memcopy function in the Client/StageFright  copies this meta data (which is only a dozen bytes or so).

    The OMAP Android releases do not have gstreamer integrated.

    Linux releases will have gstreamer integrated, so it may be easier to work with these releases instead (e.g Ubuntu 12.04 for Pandaboard). Contact your TI Sales representative for more details of the Linux releases.