diff --git a/mpp/codec/mpp_enc.cpp b/mpp/codec/mpp_enc.cpp index d7137341..8879bdf7 100644 --- a/mpp/codec/mpp_enc.cpp +++ b/mpp/codec/mpp_enc.cpp @@ -21,6 +21,7 @@ #include "mpp_env.h" #include "mpp_log.h" #include "mpp_mem.h" +#include "mpp_common.h" #include "mpp_packet_impl.h" @@ -258,9 +259,10 @@ void *mpp_enc_control_thread(void *data) * if there is available buffer in the input frame do encoding */ if (NULL == packet) { + /* NOTE: set buffer w * h * 1.5 to avoid buffer overflow */ RK_U32 width = enc->cfg.prep.width; RK_U32 height = enc->cfg.prep.height; - RK_U32 size = width * height; + RK_U32 size = MPP_ALIGN(width, 16) * MPP_ALIGN(height, 16) * 3 / 2; MppBuffer buffer = NULL; mpp_assert(size); diff --git a/mpp/codec/mpp_enc_v2.cpp b/mpp/codec/mpp_enc_v2.cpp index 15eb325a..44b7aafb 100644 --- a/mpp/codec/mpp_enc_v2.cpp +++ b/mpp/codec/mpp_enc_v2.cpp @@ -629,9 +629,10 @@ void *mpp_enc_thread(void *data) * if there is available buffer in the input frame do encoding */ if (NULL == packet) { + /* NOTE: set buffer w * h * 1.5 to avoid buffer overflow */ RK_U32 width = enc->cfg.prep.width; RK_U32 height = enc->cfg.prep.height; - RK_U32 size = width * height; + RK_U32 size = MPP_ALIGN(width, 16) * MPP_ALIGN(height, 16) * 3 / 2; MppBuffer buffer = NULL; mpp_assert(size);