mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-19 07:24:34 +08:00
[jpegd] decrease input buffer length and allocate new memory if input buffer length is too small.
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1136 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -1206,6 +1206,20 @@ MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pkt_length > JpegParserCtx->bufferSize) {
|
||||||
|
JPEGD_INFO_LOG("Huge Frame(%d Bytes)!", pkt_length);
|
||||||
|
mpp_free(JpegParserCtx->recv_buffer);
|
||||||
|
JpegParserCtx->recv_buffer = NULL;
|
||||||
|
|
||||||
|
JpegParserCtx->recv_buffer = mpp_calloc(RK_U8, pkt_length + 1024);
|
||||||
|
if (NULL == JpegParserCtx->recv_buffer) {
|
||||||
|
JPEGD_ERROR_LOG("no memory!");
|
||||||
|
return MPP_ERR_NOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
JpegParserCtx->bufferSize = pkt_length + 1024;
|
||||||
|
}
|
||||||
|
|
||||||
jpegd_parser_split_frame(pPacket, pkt_length, JpegParserCtx->recv_buffer, ©_length);
|
jpegd_parser_split_frame(pPacket, pkt_length, JpegParserCtx->recv_buffer, ©_length);
|
||||||
|
|
||||||
pPos += pkt_length;
|
pPos += pkt_length;
|
||||||
@@ -2699,50 +2713,50 @@ MPP_RET jpegd_decode_frame(JpegParserContext *ctx)
|
|||||||
|
|
||||||
void jpegd_free_huffman_tables(void *ctx)
|
void jpegd_free_huffman_tables(void *ctx)
|
||||||
{
|
{
|
||||||
FUN_TEST("Enter");
|
FUN_TEST("Enter");
|
||||||
JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx;
|
JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx;
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.acTable0.vals) {
|
if (JpegParserCtx->pSyntax->vlc.acTable0.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.acTable0.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.acTable0.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.acTable0.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.acTable0.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.acTable1.vals) {
|
if (JpegParserCtx->pSyntax->vlc.acTable1.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.acTable1.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.acTable1.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.acTable1.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.acTable1.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.acTable2.vals) {
|
if (JpegParserCtx->pSyntax->vlc.acTable2.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.acTable2.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.acTable2.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.acTable2.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.acTable2.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.acTable3.vals) {
|
if (JpegParserCtx->pSyntax->vlc.acTable3.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.acTable3.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.acTable3.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.acTable3.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.acTable3.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.dcTable0.vals) {
|
if (JpegParserCtx->pSyntax->vlc.dcTable0.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable0.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable0.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.dcTable0.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.dcTable0.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.dcTable1.vals) {
|
if (JpegParserCtx->pSyntax->vlc.dcTable1.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable1.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable1.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.dcTable1.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.dcTable1.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.dcTable2.vals) {
|
if (JpegParserCtx->pSyntax->vlc.dcTable2.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable2.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable2.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.dcTable2.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.dcTable2.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax->vlc.dcTable3.vals) {
|
if (JpegParserCtx->pSyntax->vlc.dcTable3.vals) {
|
||||||
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable3.vals);
|
mpp_free(JpegParserCtx->pSyntax->vlc.dcTable3.vals);
|
||||||
JpegParserCtx->pSyntax->vlc.dcTable3.vals = NULL;
|
JpegParserCtx->pSyntax->vlc.dcTable3.vals = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUN_TEST("Exit");
|
FUN_TEST("Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2753,7 +2767,7 @@ MPP_RET jpegd_parse(void *ctx, HalDecTask *task)
|
|||||||
JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx;
|
JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx;
|
||||||
task->valid = 0;
|
task->valid = 0;
|
||||||
|
|
||||||
jpegd_free_huffman_tables(JpegParserCtx);
|
jpegd_free_huffman_tables(JpegParserCtx);
|
||||||
memset(JpegParserCtx->pSyntax, 0, sizeof(JpegSyntaxParam));
|
memset(JpegParserCtx->pSyntax, 0, sizeof(JpegSyntaxParam));
|
||||||
jpegd_get_image_info(JpegParserCtx);
|
jpegd_get_image_info(JpegParserCtx);
|
||||||
ret = jpegd_decode_frame(JpegParserCtx);
|
ret = jpegd_decode_frame(JpegParserCtx);
|
||||||
@@ -2767,7 +2781,7 @@ MPP_RET jpegd_parse(void *ctx, HalDecTask *task)
|
|||||||
jpegd_update_frame(JpegParserCtx);
|
jpegd_update_frame(JpegParserCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
//mpp_show_mem_status();
|
//mpp_show_mem_status();
|
||||||
|
|
||||||
FUN_TEST("Exit");
|
FUN_TEST("Exit");
|
||||||
return ret;
|
return ret;
|
||||||
@@ -2783,7 +2797,7 @@ MPP_RET jpegd_deinit(void *ctx)
|
|||||||
JpegParserCtx->recv_buffer = NULL;
|
JpegParserCtx->recv_buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
jpegd_free_huffman_tables(JpegParserCtx);
|
jpegd_free_huffman_tables(JpegParserCtx);
|
||||||
|
|
||||||
if (JpegParserCtx->pSyntax) {
|
if (JpegParserCtx->pSyntax) {
|
||||||
mpp_free(JpegParserCtx->pSyntax);
|
mpp_free(JpegParserCtx->pSyntax);
|
||||||
@@ -2853,9 +2867,10 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg)
|
|||||||
|
|
||||||
JpegParserCtx->recv_buffer = mpp_calloc(RK_U8, JPEGD_STREAM_BUFF_SIZE);
|
JpegParserCtx->recv_buffer = mpp_calloc(RK_U8, JPEGD_STREAM_BUFF_SIZE);
|
||||||
if (NULL == JpegParserCtx->recv_buffer) {
|
if (NULL == JpegParserCtx->recv_buffer) {
|
||||||
JPEGD_ERROR_LOG("NULL pointer");
|
JPEGD_ERROR_LOG("no memory!");
|
||||||
return MPP_ERR_NULL_PTR;
|
return MPP_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
JpegParserCtx->bufferSize = JPEGD_STREAM_BUFF_SIZE;
|
||||||
mpp_packet_init(&JpegParserCtx->input_packet, JpegParserCtx->recv_buffer, JPEGD_STREAM_BUFF_SIZE);
|
mpp_packet_init(&JpegParserCtx->input_packet, JpegParserCtx->recv_buffer, JPEGD_STREAM_BUFF_SIZE);
|
||||||
|
|
||||||
mpp_frame_init(&JpegParserCtx->output_frame);
|
mpp_frame_init(&JpegParserCtx->output_frame);
|
||||||
@@ -2875,7 +2890,6 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg)
|
|||||||
JpegParserCtx->pSyntax->ppInstance = (void *)0; /* will be changed when need pp */
|
JpegParserCtx->pSyntax->ppInstance = (void *)0; /* will be changed when need pp */
|
||||||
|
|
||||||
memset(&(JpegParserCtx->imageInfo), 0, sizeof(JpegDecImageInfo));
|
memset(&(JpegParserCtx->imageInfo), 0, sizeof(JpegDecImageInfo));
|
||||||
JpegParserCtx->bufferSize = JPEGD_STREAM_BUFF_SIZE;
|
|
||||||
JpegParserCtx->decImageType = JPEGDEC_IMAGE; /* FULL MODEs */
|
JpegParserCtx->decImageType = JPEGDEC_IMAGE; /* FULL MODEs */
|
||||||
JpegParserCtx->sliceMbSet = 0; /* will be changed when over 16MB*/
|
JpegParserCtx->sliceMbSet = 0; /* will be changed when over 16MB*/
|
||||||
JpegParserCtx->color_conv = 1;
|
JpegParserCtx->color_conv = 1;
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
#define JPEGDEC_YUV440 5
|
#define JPEGDEC_YUV440 5
|
||||||
#define JPEGDEC_YUV411 6
|
#define JPEGDEC_YUV411 6
|
||||||
|
|
||||||
#define JPEGD_STREAM_BUFF_SIZE (10*1024*1024)
|
#define JPEGD_STREAM_BUFF_SIZE (512*1024)
|
||||||
#define JPEGDEC_BASELINE_TABLE_SIZE (544)
|
#define JPEGDEC_BASELINE_TABLE_SIZE (544)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@@ -2079,6 +2079,7 @@ MPP_RET hal_jpegd_control(void *hal, RK_S32 cmd_type, void *param)
|
|||||||
(void)hal;
|
(void)hal;
|
||||||
(void)cmd_type;
|
(void)cmd_type;
|
||||||
(void)param;
|
(void)param;
|
||||||
|
FUN_TEST("Exit");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
#define JPEGD_STREAM_BUFF_SIZE (10*1024*1024)
|
#define JPEGD_STREAM_BUFF_SIZE (512*1024)
|
||||||
|
|
||||||
typedef enum VPU_API_DEMO_RET {
|
typedef enum VPU_API_DEMO_RET {
|
||||||
PARSER_DEMO_OK = 0,
|
PARSER_DEMO_OK = 0,
|
||||||
|
Reference in New Issue
Block a user