[jpegd]: move set_output_format function from jpegd_parser.c to hal_jpegd_reg.c.

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1184 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
HuangTingjin
2016-08-10 06:37:14 +00:00
parent ee5743f0e9
commit 592abf7851
3 changed files with 111 additions and 119 deletions

View File

@@ -812,12 +812,12 @@ JpegDecRet jpegd_decode_huffman_tables(JpegParserContext *ctx)
while (len < pSyntax->vlc.Lh) {
tmp = jpegd_get_byte(pStream);
len++;
Tc = tmp >> 4; /* Table class */
Tc = tmp >> 4; /* Table class: DC or AC */
if (Tc != 0 && Tc != 1) {
JPEGD_ERROR_LOG("Tc(%d) is unsupported", Tc);
return (JPEGDEC_UNSUPPORTED);
}
Th = tmp & 0xF; /* Huffman table identifier */
Th = tmp & 0xF; /* Huffman table identifier: 0 or 1 .(Baseline)*/
/* only two tables in baseline allowed */
if ((pSyntax->frame.codingType == SOF0) && (Th > 1)) {
JPEGD_ERROR_LOG("Th(%d) is unsupported", Th);
@@ -831,7 +831,7 @@ JpegDecRet jpegd_decode_huffman_tables(JpegParserContext *ctx)
/* set the table pointer */
if (Tc) {
/* Ac table */
/* AC table */
switch (Th) {
case 0:
JPEGD_VERBOSE_LOG("ac0\n");
@@ -854,7 +854,7 @@ JpegDecRet jpegd_decode_huffman_tables(JpegParserContext *ctx)
return (JPEGDEC_UNSUPPORTED);
}
} else {
/* Dc table */
/* DC table */
switch (Th) {
case 0:
JPEGD_VERBOSE_LOG("dc0\n");
@@ -1267,7 +1267,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr
}
JpegParserContext *pCtx = ctx;
JpegDecImageInfo *pImageInfo = (JpegDecImageInfo *) & (pCtx->imageInfo);
JpegDecImageInfo *pImageInfo = (JpegDecImageInfo *) & (pCtx->pSyntax->imageInfo);
JpegSyntaxParam *pSyntax = pCtx->pSyntax;
RK_U32 Nf = 0, Ns = 0, NsThumb = 0;
RK_U32 i, j = 0, init = 0, initThumb = 0;
@@ -1447,7 +1447,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr
JPEGD_VERBOSE_LOG("SOS, currentByte:0x%x", currentByte);
/* SOS length */
headerLength = jpegd_get_two_bytes(pStream);
JPEGD_VERBOSE_LOG("SOS, headerLength:%d", headerLength);
JPEGD_VERBOSE_LOG("Length of <Start of Scan> is %d", headerLength);
if (headerLength == STRM_ERROR ||
((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) {
JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength);
@@ -1481,7 +1481,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr
JPEGD_VERBOSE_LOG("DQT, currentByte:0x%x", currentByte);
/* DQT length */
headerLength = jpegd_get_two_bytes(pStream);
JPEGD_VERBOSE_LOG("headerLength:%d", headerLength);
JPEGD_VERBOSE_LOG("Length of Define Quantization Table is %d", headerLength);
if (headerLength == STRM_ERROR ||
((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) {
JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength);
@@ -1500,7 +1500,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr
JPEGD_VERBOSE_LOG("DHT, currentByte:0x%x", currentByte);
/* DHT length */
headerLength = jpegd_get_two_bytes(pStream);
JPEGD_VERBOSE_LOG("headerLength:%d", headerLength);
JPEGD_VERBOSE_LOG("Length of Define Huffman Table is %d", headerLength);
if (headerLength == STRM_ERROR ||
((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) {
JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength);
@@ -1518,24 +1518,19 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr
JPEGD_VERBOSE_LOG("DRI, currentByte:0x%x", currentByte);
/* DRI length */
headerLength = jpegd_get_two_bytes(pStream);
JPEGD_VERBOSE_LOG("headerLength:%d", headerLength);
JPEGD_VERBOSE_LOG("Length of Define Restart Interval(must be 4 Bytes) is %d", headerLength);
if (headerLength == STRM_ERROR ||
((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) {
JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength);
errorCode = 1;
break;
}
#if 0
/* jump over DRI header */
if (headerLength != 0) {
pStream->readBits += ((headerLength * 8) - 16);
pStream->pCurrPos += (((headerLength * 8) - 16) / 8);
}
#endif
headerLength = jpegd_get_two_bytes(pStream);
JPEGD_VERBOSE_LOG("headerLength:%d", headerLength);
JPEGD_VERBOSE_LOG("Restart Interval:%d", headerLength);
if (headerLength == STRM_ERROR ||
((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) {
/* may optimize one day */
JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength);
errorCode = 1;
break;
@@ -2096,18 +2091,14 @@ MPP_RET jpegd_get_image_info(JpegParserContext *ctx)
{
FUN_TEST("Enter");
JpegParserContext *pCtx = ctx;
MPP_RET ret = MPP_OK;
PostProcessInfo ppInfo;
RK_U32 ppInputFomart = 0;
RK_U32 ppScaleW = 640, ppScaleH = 480;
RK_U32 pic_size = 0;
StreamStorage stream;
if (NULL == pCtx) {
JPEGD_ERROR_LOG("NULL pointer");
return MPP_ERR_NULL_PTR;
}
MPP_RET ret = MPP_OK;
JpegSyntaxParam *pSyntax = pCtx->pSyntax;
StreamStorage stream;
if (pCtx->streamLength < 1) {
JPEGD_ERROR_LOG("streamLength:%d", pCtx->streamLength);
@@ -2126,8 +2117,7 @@ MPP_RET jpegd_get_image_info(JpegParserContext *ctx)
return MPP_ERR_VALUE;
}
memset(&(pCtx->imageInfo), 0, sizeof(JpegDecImageInfo));
pCtx->imageInfo.thumbnailType = JPEGDEC_NO_THUMBNAIL;
pSyntax->imageInfo.thumbnailType = JPEGDEC_NO_THUMBNAIL;
/* utils initialization */
stream.bitPosInByte = 0;
@@ -2143,94 +2133,6 @@ MPP_RET jpegd_get_image_info(JpegParserContext *ctx)
return ret;
}
if (pCtx->color_conv) {
/* Using pp to convert all format to yuv420sp */
switch (pCtx->imageInfo.outputFormat) {
case JPEGDEC_YCbCr400:
ppInputFomart = PP_IN_FORMAT_YUV400;
break;
case JPEGDEC_YCbCr420_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV420SEMI;
break;
case JPEGDEC_YCbCr422_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV422SEMI;
break;
case JPEGDEC_YCbCr440:
ppInputFomart = PP_IN_FORMAT_YUV440SEMI;
break;
case JPEGDEC_YCbCr411_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV411_SEMI;
break;
case JPEGDEC_YCbCr444_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV444_SEMI;
break;
}
// set pp info
memset(&ppInfo, 0, sizeof(ppInfo));
ppInfo.enable = 1;
ppInfo.outFomart = 5; //PP_OUT_FORMAT_YUV420INTERLAVE
ppScaleW = pCtx->imageInfo.outputWidth;
ppScaleH = pCtx->imageInfo.outputHeight;
if (ppScaleW > 1920) { // || ppScaleH > 1920) {
ppScaleW = (ppScaleW + 15) & (~15); //(ppScaleW + 15)/16*16;
ppScaleH = (ppScaleH + 15) & (~15);
} else {
ppScaleW = (ppScaleW + 7) & (~7); // pp dest width must be dividable by 8
ppScaleH = (ppScaleH + 1) & (~1); // must be dividable by 2.in pp downscaling ,the output lines always equal (desire lines - 1);
}
JPEGD_INFO_LOG("Post Process! ppScaleW:%d, ppScaleH:%d", ppScaleW, ppScaleH);
pic_size = ppScaleW * ppScaleH * 2;
pSyntax->ppInstance = (void *)1;
} else {
/* keep original output format */
memset(&ppInfo, 0, sizeof(ppInfo));
ppInfo.outFomart = 5; //PP_OUT_FORMAT_YUV420INTERLAVE
ppScaleW = pCtx->imageInfo.outputWidth;
ppScaleH = pCtx->imageInfo.outputHeight;
ppScaleW = (ppScaleW + 15) & (~15);
ppScaleH = (ppScaleH + 15) & (~15);
switch (pCtx->imageInfo.outputFormat) {
case JPEGDEC_YCbCr400:
ppInputFomart = PP_IN_FORMAT_YUV400;
pic_size = ppScaleW * ppScaleH;
break;
case JPEGDEC_YCbCr420_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV420SEMI;
pic_size = ppScaleW * ppScaleH * 3 / 2;
break;
case JPEGDEC_YCbCr422_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV422SEMI;
pic_size = ppScaleW * ppScaleH * 2;
break;
case JPEGDEC_YCbCr440:
ppInputFomart = PP_IN_FORMAT_YUV440SEMI;
pic_size = ppScaleW * ppScaleH * 2;
break;
case JPEGDEC_YCbCr411_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV411_SEMI;
pic_size = ppScaleW * ppScaleH * 2;
break;
case JPEGDEC_YCbCr444_SEMIPLANAR:
ppInputFomart = PP_IN_FORMAT_YUV444_SEMI;
pic_size = ppScaleW * ppScaleH * 3;
break;
}
pSyntax->ppInstance = (void *)0;
}
(void)pic_size;
memcpy(&(pSyntax->imageInfo), &(pCtx->imageInfo), sizeof(JpegDecImageInfo));
memcpy(&(pSyntax->ppInfo), &(ppInfo), sizeof(PostProcessInfo));
pSyntax->ppScaleW = ppScaleW;
pSyntax->ppScaleH = ppScaleH;
pSyntax->ppInputFomart = ppInputFomart;
FUN_TEST("Exit");
return ret;
}
@@ -2856,7 +2758,6 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg)
memset(JpegParserCtx->pSyntax, 0, sizeof(JpegSyntaxParam));
JpegParserCtx->pSyntax->ppInstance = (void *)0; /* will be changed when need pp */
memset(&(JpegParserCtx->imageInfo), 0, sizeof(JpegDecImageInfo));
JpegParserCtx->decImageType = JPEGDEC_IMAGE; /* FULL MODEs */
JpegParserCtx->sliceMbSet = 0; /* will be changed when over 16MB*/
JpegParserCtx->color_conv = 0;
@@ -2906,7 +2807,6 @@ MPP_RET jpegd_reset(void *ctx)
MPP_RET jpegd_control(void *ctx, RK_S32 cmd, void *param)
{
FUN_TEST("Enter");
MPP_RET ret = MPP_OK;
JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx;
if (NULL == JpegParserCtx) {
@@ -2922,7 +2822,6 @@ MPP_RET jpegd_control(void *ctx, RK_S32 cmd, void *param)
default :
ret = MPP_NOK;
}
FUN_TEST("Exit");
return ret;
}

View File

@@ -165,7 +165,6 @@ typedef struct JpegParserContext {
RK_S32 frame_slot_index; /* slot index for output */
RK_U8 *recv_buffer;
JpegSyntaxParam *pSyntax;
JpegDecImageInfo imageInfo;
RK_U32 streamLength; /* input stream length or buffer size */
RK_U32 bufferSize; /* input stream buffer size */