quirks |= kOutputBuffersAreUnreadable;
}
+ if (!strncmp(componentName, "OMX.SEC.", 8) && isEncoder) {
+ // These input buffers contain meta data (for instance,
+ // information helps locate the actual YUV data, or
+ // the physical address of the YUV data).
+ quirks |= kStoreMetaDataInInputVideoBuffers;
+ }
+
return quirks;
}
"an EMPTY_BUFFER_DONE.", buffer);
}
- buffers->editItemAt(i).mOwnedByComponent = false;
+ {
+ BufferInfo *info = &buffers->editItemAt(i);
+ info->mOwnedByComponent = false;
+ if (info->mMediaBuffer != NULL) {
+ // It is time to release the media buffers storing meta data
+ info->mMediaBuffer->release();
+ info->mMediaBuffer = NULL;
+ }
+ }
if (mPortStatus[kPortIndexInput] == DISABLING) {
CODEC_LOGV("Port is disabled, freeing buffer %p", buffer);
CHECK_EQ(info->mMediaBuffer->refcount(), 0);
info->mMediaBuffer->release();
+ info->mMediaBuffer = NULL;
}
buffers->removeAt(i);
break;
}
+ // Do not release the media buffer if it stores meta data
+ // instead of YUV data. The release is delayed until
+ // EMPTY_BUFFER_DONE callback is received.
+ bool releaseBuffer = true;
if (mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames)) {
CHECK(mOMXLivesLocally && offset == 0);
OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *) info->mBuffer;
header->pBuffer = (OMX_U8 *) srcBuffer->data() + srcBuffer->range_offset();
} else {
+ if (mQuirks & kStoreMetaDataInInputVideoBuffers) {
+ releaseBuffer = false;
+ info->mMediaBuffer = srcBuffer;
+ }
memcpy((uint8_t *)info->mData + offset,
(const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(),
srcBuffer->range_length());
offset += srcBuffer->range_length();
- srcBuffer->release();
- srcBuffer = NULL;
+ if (releaseBuffer) {
+ srcBuffer->release();
+ srcBuffer = NULL;
+ }
++n;