OMX extension to support storing meta data in video input buffers during recording
bug - 3042125 Change-Id: I7543809fa4ff61d48da35eec6c2bd5eaa7e8cead
This commit is contained in:
@@ -79,6 +79,9 @@ public:
|
||||
node_id node, OMX_INDEXTYPE index,
|
||||
const void *params, size_t size) = 0;
|
||||
|
||||
virtual status_t storeMetaDataInBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
|
||||
|
||||
virtual status_t enableGraphicBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable) = 0;
|
||||
|
||||
|
||||
@@ -49,6 +49,32 @@ struct EnableAndroidNativeBuffersParams {
|
||||
OMX_BOOL enable;
|
||||
};
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
// Color formats in the range [OMX_COLOR_FormatAndroidPrivateStart,
|
||||
// OMX_COLOR_FormatAndroidPrivateEnd) will be converted to a gralloc pixel
|
||||
// format when used to allocate Android native buffers via gralloc. The
|
||||
|
||||
@@ -24,6 +24,7 @@ enum {
|
||||
ENABLE_GRAPHIC_BUFFERS,
|
||||
USE_BUFFER,
|
||||
USE_GRAPHIC_BUFFER,
|
||||
STORE_META_DATA_IN_BUFFERS,
|
||||
ALLOC_BUFFER,
|
||||
ALLOC_BUFFER_WITH_BACKUP,
|
||||
FREE_BUFFER,
|
||||
@@ -276,6 +277,19 @@ public:
|
||||
return err;
|
||||
}
|
||||
|
||||
virtual status_t storeMetaDataInBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable) {
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
|
||||
data.writeIntPtr((intptr_t)node);
|
||||
data.writeInt32(port_index);
|
||||
data.writeInt32((uint32_t)enable);
|
||||
remote()->transact(STORE_META_DATA_IN_BUFFERS, data, &reply);
|
||||
|
||||
status_t err = reply.readInt32();
|
||||
return err;
|
||||
}
|
||||
|
||||
virtual status_t allocateBuffer(
|
||||
node_id node, OMX_U32 port_index, size_t size,
|
||||
buffer_id *buffer, void **buffer_data) {
|
||||
@@ -634,6 +648,20 @@ status_t BnOMX::onTransact(
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
case STORE_META_DATA_IN_BUFFERS:
|
||||
{
|
||||
CHECK_INTERFACE(IOMX, data, reply);
|
||||
|
||||
node_id node = (void*)data.readIntPtr();
|
||||
OMX_U32 port_index = data.readInt32();
|
||||
OMX_BOOL enable = (OMX_BOOL)data.readInt32();
|
||||
|
||||
status_t err = storeMetaDataInBuffers(node, port_index, enable);
|
||||
reply->writeInt32(err);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
case ALLOC_BUFFER:
|
||||
{
|
||||
CHECK_INTERFACE(IOMX, data, reply);
|
||||
|
||||
@@ -62,6 +62,9 @@ public:
|
||||
virtual status_t enableGraphicBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable);
|
||||
|
||||
virtual status_t storeMetaDataInBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable);
|
||||
|
||||
virtual status_t useBuffer(
|
||||
node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms,
|
||||
buffer_id *buffer);
|
||||
|
||||
@@ -50,6 +50,7 @@ struct OMXNodeInstance {
|
||||
status_t setConfig(OMX_INDEXTYPE index, const void *params, size_t size);
|
||||
|
||||
status_t enableGraphicBuffers(OMX_U32 portIndex, OMX_BOOL enable);
|
||||
status_t storeMetaDataInBuffers(OMX_U32 portIndex, OMX_BOOL enable);
|
||||
|
||||
status_t useBuffer(
|
||||
OMX_U32 portIndex, const sp<IMemory> ¶ms,
|
||||
|
||||
@@ -294,6 +294,11 @@ status_t OMX::enableGraphicBuffers(
|
||||
return findInstance(node)->enableGraphicBuffers(port_index, enable);
|
||||
}
|
||||
|
||||
status_t OMX::storeMetaDataInBuffers(
|
||||
node_id node, OMX_U32 port_index, OMX_BOOL enable) {
|
||||
return findInstance(node)->storeMetaDataInBuffers(port_index, enable);
|
||||
}
|
||||
|
||||
status_t OMX::useBuffer(
|
||||
node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms,
|
||||
buffer_id *buffer) {
|
||||
|
||||
@@ -284,6 +284,37 @@ status_t OMXNodeInstance::enableGraphicBuffers(
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t OMXNodeInstance::storeMetaDataInBuffers(
|
||||
OMX_U32 portIndex,
|
||||
OMX_BOOL enable) {
|
||||
Mutex::Autolock autolock(mLock);
|
||||
|
||||
OMX_INDEXTYPE index;
|
||||
OMX_STRING name = const_cast<OMX_STRING>(
|
||||
"OMX.google.android.index.storeMetaDataInBuffers");
|
||||
|
||||
OMX_ERRORTYPE err = OMX_GetExtensionIndex(mHandle, name, &index);
|
||||
if (err != OMX_ErrorNone) {
|
||||
LOGE("OMX_GetExtensionIndex %s failed", name);
|
||||
return StatusFromOMXError(err);
|
||||
}
|
||||
|
||||
StoreMetaDataInBuffersParams params;
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.nSize = sizeof(params);
|
||||
|
||||
// Version: 1.0.0.0
|
||||
params.nVersion.s.nVersionMajor = 1;
|
||||
|
||||
params.nPortIndex = portIndex;
|
||||
params.bStoreMetaData = enable;
|
||||
if ((err = OMX_SetParameter(mHandle, index, ¶ms)) != OMX_ErrorNone) {
|
||||
LOGE("OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x%08x", err);
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
status_t OMXNodeInstance::useBuffer(
|
||||
OMX_U32 portIndex, const sp<IMemory> ¶ms,
|
||||
OMX::buffer_id *buffer) {
|
||||
|
||||
Reference in New Issue
Block a user