summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2013-12-03 07:08:51 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2013-12-03 07:08:51 -0800
commitb15073daf8948977f0397cc24affc7a3ee5cf7e0 (patch)
treef2b10789b1b973cec73f85e7eb42a195d3a6a726
parent3d8326b10a7578c5c9e4b06638d6bdeb6bddc679 (diff)
parent0c73bb5e0916c97bd0375c5713452dbd2a26772d (diff)
downloadandroid_hardware_qcom_media-b15073daf8948977f0397cc24affc7a3ee5cf7e0.tar.gz
android_hardware_qcom_media-b15073daf8948977f0397cc24affc7a3ee5cf7e0.tar.bz2
android_hardware_qcom_media-b15073daf8948977f0397cc24affc7a3ee5cf7e0.zip
Merge "mm-video: vdec: Set input buffer size dynamically"
-rw-r--r--mm-video/vidc/vdec/inc/h264_utils.h1
-rw-r--r--mm-video/vidc/vdec/inc/omx_vdec.h2
-rw-r--r--mm-video/vidc/vdec/src/h264_utils.cpp10
-rw-r--r--mm-video/vidc/vdec/src/omx_vdec.cpp108
4 files changed, 88 insertions, 33 deletions
diff --git a/mm-video/vidc/vdec/inc/h264_utils.h b/mm-video/vidc/vdec/inc/h264_utils.h
index 8006bb2a..df21ecc8 100644
--- a/mm-video/vidc/vdec/inc/h264_utils.h
+++ b/mm-video/vidc/vdec/inc/h264_utils.h
@@ -187,6 +187,7 @@ public:
~H264_Utils();
void initialize_frame_checking_environment();
void allocate_rbsp_buffer(uint32 inputBufferSize);
+ void deallocate_rbsp_buffer(void);
bool isNewFrame(OMX_BUFFERHEADERTYPE *p_buf_hdr,
OMX_IN OMX_U32 size_of_nal_length_field,
OMX_OUT OMX_BOOL &isNewFrame);
diff --git a/mm-video/vidc/vdec/inc/omx_vdec.h b/mm-video/vidc/vdec/inc/omx_vdec.h
index 4beeaf3c..4b7adbe7 100644
--- a/mm-video/vidc/vdec/inc/omx_vdec.h
+++ b/mm-video/vidc/vdec/inc/omx_vdec.h
@@ -906,6 +906,8 @@ private:
int secureDisplay(int mode);
int unsecureDisplay(int mode);
int set_turbo_mode(bool mode);
+ OMX_ERRORTYPE allocate_scratch_buffers(void);
+ void deallocate_scratch_buffers(void);
bool msg_thread_created;
bool async_thread_created;
bool m_turbo_mode;
diff --git a/mm-video/vidc/vdec/src/h264_utils.cpp b/mm-video/vidc/vdec/src/h264_utils.cpp
index b94f0236..dc9587fd 100644
--- a/mm-video/vidc/vdec/src/h264_utils.cpp
+++ b/mm-video/vidc/vdec/src/h264_utils.cpp
@@ -168,6 +168,16 @@ void H264_Utils::allocate_rbsp_buffer(uint32 inputBufferSize)
m_prv_nalu.nalu_type = NALU_TYPE_UNSPECIFIED;
}
+void H264_Utils::deallocate_rbsp_buffer()
+{
+ if (m_rbspBytes)
+ {
+ free(m_rbspBytes);
+ m_rbspBytes = NULL;
+ }
+}
+
+
H264_Utils::H264_Utils(): m_height(0),
m_width(0),
m_rbspBytes(NULL),
diff --git a/mm-video/vidc/vdec/src/omx_vdec.cpp b/mm-video/vidc/vdec/src/omx_vdec.cpp
index ba2023a7..55e6244f 100644
--- a/mm-video/vidc/vdec/src/omx_vdec.cpp
+++ b/mm-video/vidc/vdec/src/omx_vdec.cpp
@@ -94,6 +94,7 @@ char ouputextradatafilename [] = "/data/extradata";
#define MAX_NUM_PPS 256
#define MAX_INPUT_ERROR (MAX_NUM_SPS + MAX_NUM_PPS)
#define MAX_SUPPORTED_FPS 120
+#define MAX_INPUT_BUF_SIZE (4 * 1024 * 1024)
#define VC1_SP_MP_START_CODE 0xC5000000
#define VC1_SP_MP_START_CODE_MASK 0xFF000000
@@ -1713,40 +1714,8 @@ OMX_ERRORTYPE omx_vdec::component_init(OMX_STRING role)
}
if (drv_ctx.decoder_format == VDEC_CODECTYPE_H264)
{
- if (m_frame_parser.mutils == NULL)
- {
- m_frame_parser.mutils = new H264_Utils();
-
- if (m_frame_parser.mutils == NULL)
- {
- DEBUG_PRINT_ERROR("\n parser utils Allocation failed ");
- eRet = OMX_ErrorInsufficientResources;
- }
- else
- {
- h264_scratch.nAllocLen = drv_ctx.ip_buf.buffer_size - DEVICE_SCRATCH;
- h264_scratch.pBuffer = (OMX_U8 *)malloc (h264_scratch.nAllocLen);
- h264_scratch.nFilledLen = 0;
- h264_scratch.nOffset = 0;
-
- if (h264_scratch.pBuffer == NULL)
- {
- DEBUG_PRINT_ERROR("\n h264_scratch.pBuffer Allocation failed ");
- return OMX_ErrorInsufficientResources;
- }
- m_frame_parser.mutils->initialize_frame_checking_environment();
- m_frame_parser.mutils->allocate_rbsp_buffer (drv_ctx.ip_buf.buffer_size);
- }
- }
-
- h264_parser = new h264_stream_parser();
- if (!h264_parser)
- {
- DEBUG_PRINT_ERROR("ERROR: H264 parser allocation failed!");
- eRet = OMX_ErrorInsufficientResources;
- }
+ eRet = allocate_scratch_buffers();
}
-
if(pipe(fds))
{
DEBUG_PRINT_ERROR("\n pipe creation failed.");
@@ -3364,6 +3333,15 @@ OMX_ERRORTYPE omx_vdec::set_parameter(OMX_IN OMX_HANDLETYPE hComp,
eRet = get_buffer_req(&drv_ctx.op_buf);
}
}
+ else if (portDefn->nBufferSize > (drv_ctx.ip_buf.buffer_size - DEVICE_SCRATCH))
+ {
+ drv_ctx.ip_buf.buffer_size = MAX_INPUT_BUF_SIZE;
+ eRet = set_buffer_req(&drv_ctx.ip_buf);
+ if (eRet != OMX_ErrorNone)
+ return eRet;
+ deallocate_scratch_buffers();
+ eRet = allocate_scratch_buffers();
+ }
else if (portDefn->nBufferCountActual >= drv_ctx.ip_buf.mincount
&& portDefn->nBufferSize == (drv_ctx.ip_buf.buffer_size - DEVICE_SCRATCH))
{
@@ -10437,6 +10415,70 @@ bool omx_vdec::is_component_secure()
return secure_mode;
}
+OMX_ERRORTYPE omx_vdec::allocate_scratch_buffers()
+{
+ OMX_ERRORTYPE eRet = OMX_ErrorNone;
+ DEBUG_PRINT_LOW("H264 scratch buffers allocation");
+ if (drv_ctx.decoder_format == VDEC_CODECTYPE_H264)
+ {
+ if (m_frame_parser.mutils == NULL)
+ {
+ m_frame_parser.mutils = new H264_Utils();
+
+ if (m_frame_parser.mutils == NULL)
+ {
+ DEBUG_PRINT_ERROR("\n parser utils Allocation failed ");
+ eRet = OMX_ErrorInsufficientResources;
+ }
+ else
+ {
+ h264_scratch.nAllocLen = drv_ctx.ip_buf.buffer_size - DEVICE_SCRATCH;
+ h264_scratch.pBuffer = (OMX_U8 *)malloc (h264_scratch.nAllocLen);
+ h264_scratch.nFilledLen = 0;
+ h264_scratch.nOffset = 0;
+
+ if (h264_scratch.pBuffer == NULL)
+ {
+ DEBUG_PRINT_ERROR("\n h264_scratch.pBuffer Allocation failed ");
+ return OMX_ErrorInsufficientResources;
+ }
+ m_frame_parser.mutils->initialize_frame_checking_environment();
+ m_frame_parser.mutils->allocate_rbsp_buffer (drv_ctx.ip_buf.buffer_size);
+ }
+ }
+
+ h264_parser = new h264_stream_parser();
+ if (!h264_parser)
+ {
+ DEBUG_PRINT_ERROR("ERROR: H264 parser allocation failed!");
+ eRet = OMX_ErrorInsufficientResources;
+ }
+ }
+ return eRet;
+}
+
+void omx_vdec::deallocate_scratch_buffers()
+{
+ DEBUG_PRINT_LOW("H264 scratch buffers deallocation");
+ if (m_frame_parser.mutils)
+ {
+ m_frame_parser.mutils->deallocate_rbsp_buffer();
+ DEBUG_PRINT_LOW("\n Free utils parser");
+ delete (m_frame_parser.mutils);
+ m_frame_parser.mutils = NULL;
+ }
+ if(h264_scratch.pBuffer)
+ {
+ free(h264_scratch.pBuffer);
+ h264_scratch.pBuffer = NULL;
+ }
+ if (h264_parser)
+ {
+ delete h264_parser;
+ h264_parser = NULL;
+ }
+}
+
bool omx_vdec::allocate_color_convert_buf::get_color_format(OMX_COLOR_FORMATTYPE &dest_color_format)
{
bool status = true;