From 3a48d6c31e41b6969a39eb0c7acdb682d2c8184e Mon Sep 17 00:00:00 2001 From: Herman Chen Date: Fri, 24 Apr 2020 08:57:43 +0800 Subject: [PATCH] [mpp_enc]: Enlarge mjpeg encoder stream buffer Due to complex input image content mjpeg encoder required larger buffer to avoid overflow and hardware mmu fault. Signed-off-by: Herman Chen Change-Id: I4417ae5e62f16673a2ea06a5954463ce34b6bb8a --- mpp/codec/mpp_enc.cpp | 4 +++- mpp/codec/mpp_enc_v2.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) 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);