diff options
author | Lajos Molnar <lajos@google.com> | 2015-06-01 14:58:37 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2015-06-01 15:31:13 -0700 |
commit | cc7cc67349b7a3f498882087aa42ffc05a2daf11 (patch) | |
tree | 8eee8d499bf395c14750b900a82ecc59d47e6dbd /media/libstagefright/omx/OMXNodeInstance.cpp | |
parent | f9a3dce5d44b1ba598cc6f6a2e80da36e44618f7 (diff) | |
download | frameworks_av-cc7cc67349b7a3f498882087aa42ffc05a2daf11.zip frameworks_av-cc7cc67349b7a3f498882087aa42ffc05a2daf11.tar.gz frameworks_av-cc7cc67349b7a3f498882087aa42ffc05a2daf11.tar.bz2 |
stagefright: allow to overallocate OMX codec buffers
Specify allottedSize for useBuffer and allocateBufferWithBackup,
where OMX will see only the allottedSize, even though framework may
allocate and use a bigger buffer.
Bug: 13222807
Change-Id: Ibfa93f6c7b7c8ca0853ef17d4a0758e496eaf921
Diffstat (limited to 'media/libstagefright/omx/OMXNodeInstance.cpp')
-rw-r--r-- | media/libstagefright/omx/OMXNodeInstance.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp index 3dc1f7f..f5f0f4f 100644 --- a/media/libstagefright/omx/OMXNodeInstance.cpp +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -620,8 +620,11 @@ status_t OMXNodeInstance::configureVideoTunnelMode( status_t OMXNodeInstance::useBuffer( OMX_U32 portIndex, const sp<IMemory> ¶ms, - OMX::buffer_id *buffer) { + OMX::buffer_id *buffer, OMX_U32 allottedSize) { Mutex::Autolock autoLock(mLock); + if (allottedSize > params->size()) { + return BAD_VALUE; + } BufferMeta *buffer_meta = new BufferMeta(params); @@ -629,10 +632,11 @@ status_t OMXNodeInstance::useBuffer( OMX_ERRORTYPE err = OMX_UseBuffer( mHandle, &header, portIndex, buffer_meta, - params->size(), static_cast<OMX_U8 *>(params->pointer())); + allottedSize, static_cast<OMX_U8 *>(params->pointer())); if (err != OMX_ErrorNone) { - CLOG_ERROR(useBuffer, err, SIMPLE_BUFFER(portIndex, params->size(), params->pointer())); + CLOG_ERROR(useBuffer, err, SIMPLE_BUFFER( + portIndex, (size_t)allottedSize, params->pointer())); delete buffer_meta; buffer_meta = NULL; @@ -654,7 +658,7 @@ status_t OMXNodeInstance::useBuffer( } CLOG_BUFFER(useBuffer, NEW_BUFFER_FMT( - *buffer, portIndex, "%zu@%p", params->size(), params->pointer())); + *buffer, portIndex, "%u@%p", allottedSize, params->pointer())); return OK; } @@ -939,19 +943,21 @@ status_t OMXNodeInstance::allocateBuffer( status_t OMXNodeInstance::allocateBufferWithBackup( OMX_U32 portIndex, const sp<IMemory> ¶ms, - OMX::buffer_id *buffer) { + OMX::buffer_id *buffer, OMX_U32 allottedSize) { Mutex::Autolock autoLock(mLock); + if (allottedSize > params->size()) { + return BAD_VALUE; + } BufferMeta *buffer_meta = new BufferMeta(params, true); OMX_BUFFERHEADERTYPE *header; OMX_ERRORTYPE err = OMX_AllocateBuffer( - mHandle, &header, portIndex, buffer_meta, params->size()); - + mHandle, &header, portIndex, buffer_meta, allottedSize); if (err != OMX_ErrorNone) { CLOG_ERROR(allocateBufferWithBackup, err, - SIMPLE_BUFFER(portIndex, params->size(), params->pointer())); + SIMPLE_BUFFER(portIndex, (size_t)allottedSize, params->pointer())); delete buffer_meta; buffer_meta = NULL; @@ -971,8 +977,8 @@ status_t OMXNodeInstance::allocateBufferWithBackup( bufferSource->addCodecBuffer(header); } - CLOG_BUFFER(allocateBufferWithBackup, NEW_BUFFER_FMT(*buffer, portIndex, "%zu@%p :> %p", - params->size(), params->pointer(), header->pBuffer)); + CLOG_BUFFER(allocateBufferWithBackup, NEW_BUFFER_FMT(*buffer, portIndex, "%u@%p :> %p", + allottedSize, params->pointer(), header->pBuffer)); return OK; } |