Added check for minimum output buffer size.
Changed macro specifying the minimum size required for output buffer.
Added an error check on the size allocated for output buffer.
Change-Id: I98e4f46e62ffc974df760f2633689de079ca3e5e
diff --git a/encoder/ih264e_api.c b/encoder/ih264e_api.c
index 7ff3305..d28fc44 100644
--- a/encoder/ih264e_api.c
+++ b/encoder/ih264e_api.c
@@ -4618,7 +4618,7 @@
for (i = 0; i < (WORD32) ps_op->s_ive_op.u4_out_comp_cnt; i++)
{
- ps_op->s_ive_op.au4_min_out_buf_size[i] = (wd * ht * 3) >> 1;
+ ps_op->s_ive_op.au4_min_out_buf_size[i] = MAX(((wd * ht * 3) >> 1), MIN_STREAM_SIZE);
}
ps_op->s_ive_op.u4_min_inp_bufs = MIN_INP_BUFS;
diff --git a/encoder/ih264e_bitstream.c b/encoder/ih264e_bitstream.c
index bfe8f9e..d79f637 100644
--- a/encoder/ih264e_bitstream.c
+++ b/encoder/ih264e_bitstream.c
@@ -97,7 +97,7 @@
UWORD32 u4_max_bitstrm_size)
{
ps_bitstrm->pu1_strm_buffer = pu1_bitstrm_buf;
- ps_bitstrm->u4_max_strm_size = MAX(u4_max_bitstrm_size, MIN_STREAM_SIZE);
+ ps_bitstrm->u4_max_strm_size = u4_max_bitstrm_size;
/* Default init values for other members of bitstream context */
ps_bitstrm->u4_strm_buf_offset = 0;
diff --git a/encoder/ih264e_bitstream.h b/encoder/ih264e_bitstream.h
index d5c8d89..9cd2b81 100644
--- a/encoder/ih264e_bitstream.h
+++ b/encoder/ih264e_bitstream.h
@@ -70,7 +70,7 @@
* @brief Stream buffer allocated per frame should be atleast MIN_STREAM_SIZE
******************************************************************************
*/
-#define MIN_STREAM_SIZE 0x20000
+#define MIN_STREAM_SIZE 0x800
/*****************************************************************************/
diff --git a/encoder/ih264e_encode.c b/encoder/ih264e_encode.c
index 5349f1a..041148b 100644
--- a/encoder/ih264e_encode.c
+++ b/encoder/ih264e_encode.c
@@ -226,6 +226,16 @@
ps_video_encode_op->s_ive_op.dump_recon = 0;
ps_video_encode_op->s_ive_op.u4_encoded_frame_type = IV_NA_FRAME;
+ /* Check for output memory allocation size */
+ if (ps_video_encode_ip->s_ive_ip.s_out_buf.u4_bufsize < MIN_STREAM_SIZE)
+ {
+ error_status |= IH264E_INSUFFICIENT_OUTPUT_BUFFER;
+ SET_ERROR_ON_RETURN(error_status,
+ IVE_UNSUPPORTEDPARAM,
+ ps_video_encode_op->s_ive_op.u4_error_code,
+ IV_FAIL);
+ }
+
/* copy output info. to internal structure */
s_out_buf.s_bits_buf = ps_video_encode_ip->s_ive_ip.s_out_buf;
s_out_buf.u4_is_last = 0;
diff --git a/encoder/ih264e_error.h b/encoder/ih264e_error.h
index 8fe9dac..1eba46c 100644
--- a/encoder/ih264e_error.h
+++ b/encoder/ih264e_error.h
@@ -218,7 +218,10 @@
IH264E_INVALID_ALT_REF_OPTION = IH264E_CODEC_ERROR_START + 0x2E,
/**No free picture buffer available to store recon pic */
- IH264E_NO_FREE_RECONBUF = IH264E_CODEC_ERROR_START + 0x2F,
+ IH264E_NO_FREE_RECONBUF = IH264E_CODEC_ERROR_START + 0x2F,
+
+ /**Not enough memory allocated as output buffer */
+ IH264E_INSUFFICIENT_OUTPUT_BUFFER = IH264E_CODEC_ERROR_START + 0x30,
/**max failure error code to ensure enum is 32 bits wide */
IH264E_FAIL = -1,