summaryrefslogtreecommitdiffstats
path: root/encoder
diff options
context:
space:
mode:
authorHarinarayanan K K <harinarayanan.kk@ittiam.com>2015-06-19 14:45:44 +0530
committerMarco Nelissen <marcone@google.com>2015-06-25 08:25:55 -0700
commit205e6fe11056f892b3449aac437ff14f159149d4 (patch)
tree799fd701988c40ee9900cdd1bd82bc729b67f90a /encoder
parent7dbacdf7651457dfc6244ed96b797e93a6944680 (diff)
downloadandroid_external_libavc-205e6fe11056f892b3449aac437ff14f159149d4.tar.gz
android_external_libavc-205e6fe11056f892b3449aac437ff14f159149d4.tar.bz2
android_external_libavc-205e6fe11056f892b3449aac437ff14f159149d4.zip
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
Diffstat (limited to 'encoder')
-rw-r--r--encoder/ih264e_api.c2
-rw-r--r--encoder/ih264e_bitstream.c2
-rw-r--r--encoder/ih264e_bitstream.h2
-rw-r--r--encoder/ih264e_encode.c10
-rw-r--r--encoder/ih264e_error.h5
5 files changed, 17 insertions, 4 deletions
diff --git a/encoder/ih264e_api.c b/encoder/ih264e_api.c
index 1cb2ff6..881ea53 100644
--- a/encoder/ih264e_api.c
+++ b/encoder/ih264e_api.c
@@ -4618,7 +4618,7 @@ static WORD32 ih264e_get_buf_info(iv_obj_t *ps_codec_obj,
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 @@ IH264E_ERROR_T ih264e_bitstrm_init(bitstrm_t *ps_bitstrm,
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 7651352..0760231 100644
--- a/encoder/ih264e_encode.c
+++ b/encoder/ih264e_encode.c
@@ -226,6 +226,16 @@ WORD32 ih264e_encode(iv_obj_t *ps_codec_obj, void *pv_api_ip, void *pv_api_op)
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 @@ typedef enum
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,