mirror of
				https://github.com/nyanmisaka/mpp.git
				synced 2025-10-30 20:16:45 +08:00 
			
		
		
		
	[jpegd]: handle special stream and eos in parser_prepare and format source code with mpp_astyle.sh in Linux Server.
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1102 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
		| @@ -246,9 +246,9 @@ JpegDecRet jpegd_set_yuv_mode(JpegSyntaxParam *pSyntax) | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         /* JPEG_YCBCR422 */ |         /* JPEG_YCBCR422 */ | ||||||
| 		else if(pSyntax->frame.component[0].H == 2 && pSyntax->frame.component[0].V == 1 && |         else if (pSyntax->frame.component[0].H == 2 && pSyntax->frame.component[0].V == 1 && | ||||||
|                  pSyntax->frame.component[1].H == 1 && pSyntax->frame.component[1].V == 1 && |                  pSyntax->frame.component[1].H == 1 && pSyntax->frame.component[1].V == 1 && | ||||||
| 				pSyntax->frame.component[2].H == 1 && pSyntax->frame.component[2].V == 1){ |                  pSyntax->frame.component[2].H == 1 && pSyntax->frame.component[2].V == 1) { | ||||||
|             JPEGD_INFO_LOG("YCbCr Format: YUV422(%d*%d:%d*%d:%d*%d)", |             JPEGD_INFO_LOG("YCbCr Format: YUV422(%d*%d:%d*%d:%d*%d)", | ||||||
|                            pSyntax->frame.component[0].H, pSyntax->frame.component[0].V, |                            pSyntax->frame.component[0].H, pSyntax->frame.component[0].V, | ||||||
|                            pSyntax->frame.component[1].H, pSyntax->frame.component[1].V, |                            pSyntax->frame.component[1].H, pSyntax->frame.component[1].V, | ||||||
| @@ -348,7 +348,7 @@ JpegDecRet jpegd_set_yuv_mode(JpegSyntaxParam *pSyntax) | |||||||
|                 pSyntax->image.sizeChroma = pSyntax->image.sizeLuma / 2; |                 pSyntax->image.sizeChroma = pSyntax->image.sizeLuma / 2; | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
| 			JPEGD_ERROR_LOG("Unsupported YCbCr Format: (%d*%d:%d*%d:%d*%d)",pSyntax->frame.component[0].H, pSyntax->frame.component[0].V, |             JPEGD_ERROR_LOG("Unsupported YCbCr Format: (%d*%d:%d*%d:%d*%d)", pSyntax->frame.component[0].H, pSyntax->frame.component[0].V, | ||||||
|                             pSyntax->frame.component[1].H, pSyntax->frame.component[1].V, |                             pSyntax->frame.component[1].H, pSyntax->frame.component[1].V, | ||||||
|                             pSyntax->frame.component[2].H, pSyntax->frame.component[2].V); |                             pSyntax->frame.component[2].H, pSyntax->frame.component[2].V); | ||||||
|             return (JPEGDEC_UNSUPPORTED); |             return (JPEGDEC_UNSUPPORTED); | ||||||
| @@ -396,7 +396,7 @@ JpegDecRet jpegd_decode_frame_header(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -577,7 +577,7 @@ JpegDecRet jpegd_decode_scan_header(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -591,7 +591,7 @@ JpegDecRet jpegd_decode_scan_header(JpegParserContext *ctx) | |||||||
|     pSyntax->scan.Ls = jpegd_get_two_bytes(pStream); |     pSyntax->scan.Ls = jpegd_get_two_bytes(pStream); | ||||||
|  |  | ||||||
|     /* check if there is enough data */ |     /* check if there is enough data */ | ||||||
| 	if (((pStream->readBits / 8) + pSyntax->scan.Ls) > pStream->streamLength){ |     if (((pStream->readBits / 8) + pSyntax->scan.Ls) > pStream->streamLength) { | ||||||
|         JPEGD_ERROR_LOG("no enough data"); |         JPEGD_ERROR_LOG("no enough data"); | ||||||
|         return (JPEGDEC_STRM_ERROR); |         return (JPEGDEC_STRM_ERROR); | ||||||
|     } |     } | ||||||
| @@ -764,7 +764,7 @@ JpegDecRet jpegd_decode_scan(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -788,7 +788,7 @@ JpegDecRet jpegd_decode_huffman_tables(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -801,7 +801,7 @@ JpegDecRet jpegd_decode_huffman_tables(JpegParserContext *ctx) | |||||||
|     pSyntax->vlc.Lh = jpegd_get_two_bytes(pStream); |     pSyntax->vlc.Lh = jpegd_get_two_bytes(pStream); | ||||||
|  |  | ||||||
|     /* check if there is enough data for tables */ |     /* check if there is enough data for tables */ | ||||||
| 	if (((pStream->readBits / 8) + pSyntax->vlc.Lh) > pStream->streamLength){ |     if (((pStream->readBits / 8) + pSyntax->vlc.Lh) > pStream->streamLength) { | ||||||
|         JPEGD_ERROR_LOG("no enough data for tables"); |         JPEGD_ERROR_LOG("no enough data for tables"); | ||||||
|         return (JPEGDEC_STRM_ERROR); |         return (JPEGDEC_STRM_ERROR); | ||||||
|     } |     } | ||||||
| @@ -922,7 +922,7 @@ JpegDecRet jpegd_decode_quant_tables(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -934,7 +934,7 @@ JpegDecRet jpegd_decode_quant_tables(JpegParserContext *ctx) | |||||||
|     pSyntax->quant.Lq = jpegd_get_two_bytes(pStream); |     pSyntax->quant.Lq = jpegd_get_two_bytes(pStream); | ||||||
|  |  | ||||||
|     /* check if there is enough data for tables */ |     /* check if there is enough data for tables */ | ||||||
|     if (((pStream->readBits / 8) + pSyntax->quant.Lq) > pStream->streamLength){ |     if (((pStream->readBits / 8) + pSyntax->quant.Lq) > pStream->streamLength) { | ||||||
|         JPEGD_ERROR_LOG("no enough data for tables"); |         JPEGD_ERROR_LOG("no enough data for tables"); | ||||||
|         return (JPEGDEC_STRM_ERROR); |         return (JPEGDEC_STRM_ERROR); | ||||||
|     } |     } | ||||||
| @@ -991,6 +991,72 @@ JpegDecRet jpegd_default_huffman_tables(JpegParserContext *ctx) | |||||||
|     return MPP_OK; |     return MPP_OK; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | MPP_RET jpegd_parser_split_frame(RK_U8 *src, RK_U32 src_size, RK_U8 *dst, RK_U32 *dst_size) | ||||||
|  | { | ||||||
|  |     FUN_TEST("Enter"); | ||||||
|  |     MPP_RET ret = MPP_OK; | ||||||
|  |     if (NULL == src || NULL == dst || src_size <= 0) { | ||||||
|  |         JPEGD_ERROR_LOG("NULL pointer or wrong src_size(%d)", src_size); | ||||||
|  |         return MPP_ERR_NULL_PTR; | ||||||
|  |     } | ||||||
|  |     RK_U8 *end; | ||||||
|  |     RK_U8 *tmp; | ||||||
|  |     RK_U32 str_size = (src_size + 255) & (~255); | ||||||
|  |     end = dst + src_size; | ||||||
|  |  | ||||||
|  |     if (src[6] == 0x41 && src[7] == 0x56 && src[8] == 0x49 && src[9] == 0x31) { | ||||||
|  |         //distinguish 310 from 210 camera | ||||||
|  |         RK_U32     i; | ||||||
|  |         RK_U32 copy_len = 0; | ||||||
|  |         tmp = src; | ||||||
|  |         JPEGD_INFO_LOG("distinguish 310 from 210 camera"); | ||||||
|  |  | ||||||
|  |         for (i = 0; i < src_size - 4; i++) { | ||||||
|  |             if (tmp[i] == 0xff) { | ||||||
|  |                 if (tmp[i + 1] == 0x00 && tmp[i + 2] == 0xff && ((tmp[i + 3] & 0xf0) == 0xd0)) | ||||||
|  |                     i += 2; | ||||||
|  |             } | ||||||
|  |             *dst++ = tmp[i]; | ||||||
|  |             copy_len++; | ||||||
|  |         } | ||||||
|  |         for (; i < src_size; i++) { | ||||||
|  |             *dst++ = tmp[i]; | ||||||
|  |             copy_len++; | ||||||
|  |         } | ||||||
|  |         if (copy_len < src_size) | ||||||
|  |             memset(dst, 0, src_size - copy_len); | ||||||
|  |         *dst_size = copy_len; | ||||||
|  |     } else { | ||||||
|  |         memcpy(dst, src, src_size); | ||||||
|  |         memset(dst + src_size, 0, str_size - src_size); | ||||||
|  |         *dst_size = src_size; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /* NOTE: hardware bug, need to remove tailing FF 00 before FF D9 end flag */ | ||||||
|  |     if (end[-1] == 0xD9 && end[-2] == 0xFF) { | ||||||
|  |         end -= 2; | ||||||
|  |  | ||||||
|  |         do { | ||||||
|  |             if (end[-1] == 0xFF) { | ||||||
|  |                 end--; | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |             if (end[-1] == 0x00 && end [-2] == 0xFF) { | ||||||
|  |                 end -= 2; | ||||||
|  |                 continue; | ||||||
|  |             } | ||||||
|  |             break; | ||||||
|  |         } while (1); | ||||||
|  |  | ||||||
|  |         JPEGD_INFO_LOG("remove tailing FF 00 before FF D9 end flag."); | ||||||
|  |         end[0] = 0xff; | ||||||
|  |         end[1] = 0xD9; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     FUN_TEST("Exit"); | ||||||
|  |     return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
| MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task) | MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task) | ||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
| @@ -998,21 +1064,34 @@ MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task) | |||||||
|     JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx; |     JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx; | ||||||
|     MppPacket input_packet = JpegParserCtx->input_packet; |     MppPacket input_packet = JpegParserCtx->input_packet; | ||||||
|     RK_U32 pkt_length = 0; |     RK_U32 pkt_length = 0; | ||||||
|  |     RK_U32 copy_length = 0; | ||||||
|     void *pPacket = NULL; |     void *pPacket = NULL; | ||||||
|     void *pPos = NULL; |     void *pPos = NULL; | ||||||
|  |  | ||||||
|     task->valid = 0; |     task->valid = 0; | ||||||
|  |  | ||||||
|     JpegParserCtx->pts = mpp_packet_get_pts(pkt); |     JpegParserCtx->pts = mpp_packet_get_pts(pkt); | ||||||
|  |     JpegParserCtx->eos = mpp_packet_get_eos(pkt); | ||||||
|     pkt_length = mpp_packet_get_length(pkt); |     pkt_length = mpp_packet_get_length(pkt); | ||||||
|     pPacket = pPos = mpp_packet_get_pos(pkt); |     pPacket = pPos = mpp_packet_get_pos(pkt); | ||||||
| 	memcpy(JpegParserCtx->recv_buffer, pPacket, pkt_length); |  | ||||||
|  |     if (JpegParserCtx->eos) { | ||||||
|  |  | ||||||
|  |         JPEGD_INFO_LOG("it is end of stream."); | ||||||
|  |         task->flags.eos = 1; | ||||||
|  |         return ret; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     jpegd_parser_split_frame(pPacket, pkt_length, JpegParserCtx->recv_buffer, ©_length); | ||||||
|  |  | ||||||
|     pPos += pkt_length; |     pPos += pkt_length; | ||||||
|     mpp_packet_set_pos(pkt, pPos); |     mpp_packet_set_pos(pkt, pPos); | ||||||
|  |     if (copy_length != pkt_length) { | ||||||
|  |         JPEGD_INFO_LOG("there seems to be something wrong with split_frame. pkt_length:%d, copy_length:%d", pkt_length, copy_length); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /* debug information */ |     /* debug information */ | ||||||
| 	if(JpegParserCtx->parser_debug_enable && JpegParserCtx->input_jpeg_count < 3) |     if (JpegParserCtx->parser_debug_enable && JpegParserCtx->input_jpeg_count < 3) { | ||||||
| 	{ |  | ||||||
|         static FILE *jpg_file; |         static FILE *jpg_file; | ||||||
|         static char name[32]; |         static char name[32]; | ||||||
|  |  | ||||||
| @@ -1044,13 +1123,13 @@ MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task) | |||||||
| MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStream) | MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStream) | ||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
| 	if(NULL == ctx || NULL == pStream){ |     if (NULL == ctx || NULL == pStream) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	JpegDecImageInfo *pImageInfo = (JpegDecImageInfo *) &(pCtx->imageInfo); |     JpegDecImageInfo *pImageInfo = (JpegDecImageInfo *) & (pCtx->imageInfo); | ||||||
|     JpegSyntaxParam *pSyntax = pCtx->pSyntax; |     JpegSyntaxParam *pSyntax = pCtx->pSyntax; | ||||||
|     RK_U32 Nf = 0, Ns = 0, NsThumb = 0; |     RK_U32 Nf = 0, Ns = 0, NsThumb = 0; | ||||||
|     RK_U32 i, j = 0, init = 0, initThumb = 0; |     RK_U32 i, j = 0, init = 0, initThumb = 0; | ||||||
| @@ -1072,20 +1151,18 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* Read decoding parameters */ |     /* Read decoding parameters */ | ||||||
|     for (pStream->readBits = 0; (pStream->readBits / 8) < pStream->streamLength; pStream->readBits++)  |     for (pStream->readBits = 0; (pStream->readBits / 8) < pStream->streamLength; pStream->readBits++) { | ||||||
| 	{ |  | ||||||
|         /* Look for marker prefix byte from stream */ |         /* Look for marker prefix byte from stream */ | ||||||
|         if ((currentByte == 0xFF) || jpegd_get_byte(pStream) == 0xFF) { |         if ((currentByte == 0xFF) || jpegd_get_byte(pStream) == 0xFF) { | ||||||
|             currentByte = jpegd_get_byte(pStream); |             currentByte = jpegd_get_byte(pStream); | ||||||
|  |  | ||||||
|             switch (currentByte) { /* switch to certain header decoding */ |             switch (currentByte) { /* switch to certain header decoding */ | ||||||
|             case SOF0: /* baseline marker */ |             case SOF0: /* baseline marker */ | ||||||
| 	        case SOF2: /* progresive marker */ |             case SOF2: { /* progresive marker */ | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("SOF, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("SOF, currentByte:0x%x",currentByte); |                 if (currentByte == SOF0) { | ||||||
| 	            if (currentByte == SOF0){ |  | ||||||
|                     pImageInfo->codingMode = pSyntax->info.operationType = JPEGDEC_BASELINE; |                     pImageInfo->codingMode = pSyntax->info.operationType = JPEGDEC_BASELINE; | ||||||
| 	            }else{ |                 } else { | ||||||
|                     pImageInfo->codingMode = pSyntax->info.operationType = JPEGDEC_PROGRESSIVE; |                     pImageInfo->codingMode = pSyntax->info.operationType = JPEGDEC_PROGRESSIVE; | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -1139,7 +1216,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                     pImageInfo->outputWidth > pCtx->maxSupportedWidth || |                     pImageInfo->outputWidth > pCtx->maxSupportedWidth || | ||||||
|                     pImageInfo->outputHeight > pCtx->maxSupportedHeight || |                     pImageInfo->outputHeight > pCtx->maxSupportedHeight || | ||||||
|                     (pImageInfo->outputWidth * pImageInfo->outputHeight) > pCtx->maxSupportedPixelAmount) { |                     (pImageInfo->outputWidth * pImageInfo->outputHeight) > pCtx->maxSupportedPixelAmount) { | ||||||
| 	                JPEGD_ERROR_LOG("Unsupported size(%d*%d)",pImageInfo->outputWidth,pImageInfo->outputHeight); |                     JPEGD_ERROR_LOG("Unsupported size(%d*%d)", pImageInfo->outputWidth, pImageInfo->outputHeight); | ||||||
|                     return (JPEGDEC_UNSUPPORTED); |                     return (JPEGDEC_UNSUPPORTED); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
| @@ -1180,7 +1257,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                     pImageInfo->outputFormat = JPEGDEC_YCbCr420_SEMIPLANAR; |                     pImageInfo->outputFormat = JPEGDEC_YCbCr420_SEMIPLANAR; | ||||||
|                     pSyntax->frame.numMcuInRow = (pSyntax->frame.hwX / 16); |                     pSyntax->frame.numMcuInRow = (pSyntax->frame.hwX / 16); | ||||||
|                     pSyntax->frame.numMcuInFrame = ((pSyntax->frame.hwX * pSyntax->frame.hwY) / 256); |                     pSyntax->frame.numMcuInFrame = ((pSyntax->frame.hwX * pSyntax->frame.hwY) / 256); | ||||||
| 	            } else if(H[0] == 2 && V[0] == 1 && H[1] == 1 && V[1] == 1 && H[2] == 1 && V[2] == 1){ |                 } else if (H[0] == 2 && V[0] == 1 && H[1] == 1 && V[1] == 1 && H[2] == 1 && V[2] == 1) { | ||||||
|                     pImageInfo->outputFormat = JPEGDEC_YCbCr422_SEMIPLANAR; |                     pImageInfo->outputFormat = JPEGDEC_YCbCr422_SEMIPLANAR; | ||||||
|                     pSyntax->frame.numMcuInRow = (pSyntax->frame.hwX / 16); |                     pSyntax->frame.numMcuInRow = (pSyntax->frame.hwX / 16); | ||||||
|                     pSyntax->frame.numMcuInFrame = ((pSyntax->frame.hwX * pSyntax->frame.hwY) / 128); |                     pSyntax->frame.numMcuInFrame = ((pSyntax->frame.hwX * pSyntax->frame.hwY) / 128); | ||||||
| @@ -1228,12 +1305,11 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 pSyntax->info.yCbCrMode = pSyntax->info.getInfoYCbCrMode = pImageInfo->outputFormat; |                 pSyntax->info.yCbCrMode = pSyntax->info.getInfoYCbCrMode = pImageInfo->outputFormat; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case SOS: |             case SOS: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("SOS, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("SOS, currentByte:0x%x",currentByte); |  | ||||||
|                 /* SOS length */ |                 /* SOS length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("SOS, headerLength:%d",headerLength); |                 JPEGD_VERBOSE_LOG("SOS, headerLength:%d", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
|                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { |                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { | ||||||
|                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); |                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); | ||||||
| @@ -1263,12 +1339,11 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case DQT: |             case DQT: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("DQT, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("DQT, currentByte:0x%x",currentByte); |  | ||||||
|                 /* DQT length */ |                 /* DQT length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("headerLength:%d",headerLength); |                 JPEGD_VERBOSE_LOG("headerLength:%d", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
|                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { |                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { | ||||||
|                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); |                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); | ||||||
| @@ -1283,12 +1358,11 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case DHT: |             case DHT: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("DHT, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("DHT, currentByte:0x%x",currentByte); |  | ||||||
|                 /* DHT length */ |                 /* DHT length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("headerLength:%d",headerLength); |                 JPEGD_VERBOSE_LOG("headerLength:%d", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
|                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { |                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { | ||||||
|                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); |                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); | ||||||
| @@ -1302,12 +1376,11 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case DRI: |             case DRI: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("DRI, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("DRI, currentByte:0x%x",currentByte); |  | ||||||
|                 /* DRI length */ |                 /* DRI length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("headerLength:%d",headerLength); |                 JPEGD_VERBOSE_LOG("headerLength:%d", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
|                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { |                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { | ||||||
|                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); |                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); | ||||||
| @@ -1322,7 +1395,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
| #endif | #endif | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("headerLength:%d",headerLength); |                 JPEGD_VERBOSE_LOG("headerLength:%d", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
|                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { |                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { | ||||||
|                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); |                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); | ||||||
| @@ -1332,9 +1405,8 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 pSyntax->frame.Ri = headerLength; |                 pSyntax->frame.Ri = headerLength; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case APP0: /* application segments */ |             case APP0: { /* application segments */ | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("APP0, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("APP0, currentByte:0x%x",currentByte); |  | ||||||
|                 /* reset */ |                 /* reset */ | ||||||
|                 appBits = 0; |                 appBits = 0; | ||||||
|                 appLength = 0; |                 appLength = 0; | ||||||
| @@ -1342,7 +1414,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|  |  | ||||||
|                 /* APP0 length */ |                 /* APP0 length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("headerLength:%d",headerLength); |                 JPEGD_VERBOSE_LOG("headerLength:%d", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
|                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { |                     ((pStream->readBits + ((headerLength * 8) - 16)) > (8 * pStream->streamLength))) { | ||||||
|                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); |                     JPEGD_ERROR_LOG("readBits:%d, headerLength:%d, streamLength:%d", pStream->readBits, headerLength, pStream->streamLength); | ||||||
| @@ -1364,7 +1436,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|  |  | ||||||
|                 /* check identifier: 0x4A 0x46 0x49 0x46 0x00 */ |                 /* check identifier: 0x4A 0x46 0x49 0x46 0x00 */ | ||||||
|                 currentBytes = jpegd_get_two_bytes(pStream); |                 currentBytes = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("currentBytes:%x",currentBytes); |                 JPEGD_VERBOSE_LOG("currentBytes:%x", currentBytes); | ||||||
|                 appBits += 16; |                 appBits += 16; | ||||||
|                 if (currentBytes != 0x4A46) { |                 if (currentBytes != 0x4A46) { | ||||||
|                     pStream->appnFlag = 1; |                     pStream->appnFlag = 1; | ||||||
| @@ -1377,7 +1449,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 currentBytes = jpegd_get_two_bytes(pStream); |                 currentBytes = jpegd_get_two_bytes(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("currentBytes:%x",currentBytes); |                 JPEGD_VERBOSE_LOG("currentBytes:%x", currentBytes); | ||||||
|                 appBits += 16; |                 appBits += 16; | ||||||
|                 if (currentBytes != 0x4946 && currentBytes != 0x5858) { |                 if (currentBytes != 0x4946 && currentBytes != 0x5858) { | ||||||
|                     pStream->appnFlag = 1; |                     pStream->appnFlag = 1; | ||||||
| @@ -1395,7 +1467,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                     thumbnail = 1; |                     thumbnail = 1; | ||||||
|                 } |                 } | ||||||
|                 currentByte = jpegd_get_byte(pStream); |                 currentByte = jpegd_get_byte(pStream); | ||||||
| 				JPEGD_VERBOSE_LOG("currentBytes:%x",currentBytes); |                 JPEGD_VERBOSE_LOG("currentBytes:%x", currentBytes); | ||||||
|                 appBits += 8; |                 appBits += 8; | ||||||
|                 if (currentByte != 0x00) { |                 if (currentByte != 0x00) { | ||||||
|                     pStream->appnFlag = 1; |                     pStream->appnFlag = 1; | ||||||
| @@ -1412,7 +1484,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 if (thumbnail) { |                 if (thumbnail) { | ||||||
|                     /* extension code */ |                     /* extension code */ | ||||||
|                     currentByte = jpegd_get_byte(pStream); |                     currentByte = jpegd_get_byte(pStream); | ||||||
| 					JPEGD_VERBOSE_LOG("APP0 Extended thumb type, currentBytes:%x",currentBytes); |                     JPEGD_VERBOSE_LOG("APP0 Extended thumb type, currentBytes:%x", currentBytes); | ||||||
|                     if (currentByte == JPEGDEC_THUMBNAIL_JPEG) { |                     if (currentByte == JPEGDEC_THUMBNAIL_JPEG) { | ||||||
|                         pImageInfo->thumbnailType = JPEGDEC_THUMBNAIL_JPEG; |                         pImageInfo->thumbnailType = JPEGDEC_THUMBNAIL_JPEG; | ||||||
|                         appBits += 8; |                         appBits += 8; | ||||||
| @@ -1431,8 +1503,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                 currentByte = jpegd_get_byte(pStream); |                                 currentByte = jpegd_get_byte(pStream); | ||||||
|                                 switch (currentByte) { /* switch to certain header decoding */ |                                 switch (currentByte) { /* switch to certain header decoding */ | ||||||
|                                 case SOF0: /* baseline marker */ |                                 case SOF0: /* baseline marker */ | ||||||
| 	                            case SOF2: /* progresive marker */ |                                 case SOF2: { /* progresive marker */ | ||||||
| 								{ |  | ||||||
|                                     if (currentByte == SOF0) |                                     if (currentByte == SOF0) | ||||||
|                                         pImageInfo->codingModeThumb = pSyntax->info.operationTypeThumb = JPEGDEC_BASELINE; |                                         pImageInfo->codingModeThumb = pSyntax->info.operationTypeThumb = JPEGDEC_BASELINE; | ||||||
|                                     else |                                     else | ||||||
| @@ -1551,8 +1622,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                     initThumb = 1; |                                     initThumb = 1; | ||||||
|                                     break; |                                     break; | ||||||
|                                 } |                                 } | ||||||
| 	                            case SOS: |                                 case SOS: { | ||||||
| 								{ |  | ||||||
|                                     /* SOS length */ |                                     /* SOS length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR || |                                     if (headerLength == STRM_ERROR || | ||||||
| @@ -1584,8 +1654,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                     } |                                     } | ||||||
|                                     break; |                                     break; | ||||||
|                                 } |                                 } | ||||||
| 	                            case DQT: |                                 case DQT: { | ||||||
| 								{ |  | ||||||
|                                     /* DQT length */ |                                     /* DQT length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR) { |                                     if (headerLength == STRM_ERROR) { | ||||||
| @@ -1600,8 +1669,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                     appBits += (headerLength * 8); |                                     appBits += (headerLength * 8); | ||||||
|                                     break; |                                     break; | ||||||
|                                 } |                                 } | ||||||
| 	                            case DHT: |                                 case DHT: { | ||||||
| 								{ |  | ||||||
|                                     /* DHT length */ |                                     /* DHT length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR) { |                                     if (headerLength == STRM_ERROR) { | ||||||
| @@ -1616,8 +1684,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                     appBits += (headerLength * 8); |                                     appBits += (headerLength * 8); | ||||||
|                                     break; |                                     break; | ||||||
|                                 } |                                 } | ||||||
| 	                            case DRI: |                                 case DRI: { | ||||||
| 								{ |  | ||||||
|                                     /* DRI length */ |                                     /* DRI length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR) { |                                     if (headerLength == STRM_ERROR) { | ||||||
| @@ -1647,8 +1714,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                 case APP12: |                                 case APP12: | ||||||
|                                 case APP13: |                                 case APP13: | ||||||
|                                 case APP14: |                                 case APP14: | ||||||
| 	                            case APP15: |                                 case APP15: { | ||||||
| 								{ |  | ||||||
|                                     /* APPn length */ |                                     /* APPn length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR) { |                                     if (headerLength == STRM_ERROR) { | ||||||
| @@ -1663,8 +1729,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                     appBits += (headerLength * 8); |                                     appBits += (headerLength * 8); | ||||||
|                                     break; |                                     break; | ||||||
|                                 } |                                 } | ||||||
| 	                            case DNL: |                                 case DNL: { | ||||||
| 								{ |  | ||||||
|                                     /* DNL length */ |                                     /* DNL length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR) { |                                     if (headerLength == STRM_ERROR) { | ||||||
| @@ -1679,8 +1744,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                     appBits += (headerLength * 8); |                                     appBits += (headerLength * 8); | ||||||
|                                     break; |                                     break; | ||||||
|                                 } |                                 } | ||||||
| 	                            case COM: |                                 case COM: { | ||||||
| 								{ |  | ||||||
|                                     /* COM length */ |                                     /* COM length */ | ||||||
|                                     headerLength = jpegd_get_two_bytes(pStream); |                                     headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                                     if (headerLength == STRM_ERROR) { |                                     if (headerLength == STRM_ERROR) { | ||||||
| @@ -1707,8 +1771,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                                 case SOF14: |                                 case SOF14: | ||||||
|                                 case SOF15: |                                 case SOF15: | ||||||
|                                 case DAC: |                                 case DAC: | ||||||
| 	                            case DHP: |                                 case DHP: { | ||||||
| 								{ |  | ||||||
|                                     JPEGD_ERROR_LOG("Unsupported coding styles"); |                                     JPEGD_ERROR_LOG("Unsupported coding styles"); | ||||||
|                                     return (JPEGDEC_UNSUPPORTED); |                                     return (JPEGDEC_UNSUPPORTED); | ||||||
|                                 } |                                 } | ||||||
| @@ -1718,7 +1781,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|  |  | ||||||
|                                 if (pSyntax->info.initThumb && initThumb) { |                                 if (pSyntax->info.initThumb && initThumb) { | ||||||
|                                     /* flush the rest of thumbnail data */ |                                     /* flush the rest of thumbnail data */ | ||||||
| 	                                if (jpegd_flush_bits(pStream,((appLength * 8) - appBits)) == STRM_ERROR) { |                                     if (jpegd_flush_bits(pStream, ((appLength * 8) - appBits)) == STRM_ERROR) { | ||||||
|                                         errorCode = 1; |                                         errorCode = 1; | ||||||
|                                         break; |                                         break; | ||||||
|                                     } |                                     } | ||||||
| @@ -1737,7 +1800,7 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                         appBits += 8; |                         appBits += 8; | ||||||
|                         pImageInfo->thumbnailType = JPEGDEC_THUMBNAIL_NOT_SUPPORTED_FORMAT; |                         pImageInfo->thumbnailType = JPEGDEC_THUMBNAIL_NOT_SUPPORTED_FORMAT; | ||||||
|                         pStream->appnFlag = 1; |                         pStream->appnFlag = 1; | ||||||
| 	                    if (jpegd_flush_bits(pStream,((appLength * 8) - appBits)) == STRM_ERROR) { |                         if (jpegd_flush_bits(pStream, ((appLength * 8) - appBits)) == STRM_ERROR) { | ||||||
|                             errorCode = 1; |                             errorCode = 1; | ||||||
|                             break; |                             break; | ||||||
|                         } |                         } | ||||||
| @@ -1793,9 +1856,8 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|             case APP12: |             case APP12: | ||||||
|             case APP13: |             case APP13: | ||||||
|             case APP14: |             case APP14: | ||||||
| 	        case APP15: |             case APP15: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("APPn, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("APPn, currentByte:0x%x",currentByte); |  | ||||||
|                 /* APPn length */ |                 /* APPn length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                 JPEGD_VERBOSE_LOG("APPn length, headerLength:%x", headerLength); |                 JPEGD_VERBOSE_LOG("APPn length, headerLength:%x", headerLength); | ||||||
| @@ -1812,9 +1874,8 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case DNL: |             case DNL: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("DNL, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("DNL, currentByte:0x%x",currentByte); |  | ||||||
|                 /* DNL length */ |                 /* DNL length */ | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                 JPEGD_VERBOSE_LOG("DNL, headerLength:%x", headerLength); |                 JPEGD_VERBOSE_LOG("DNL, headerLength:%x", headerLength); | ||||||
| @@ -1831,9 +1892,8 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 	        case COM: |             case COM: { | ||||||
| 			{ |                 JPEGD_VERBOSE_LOG("COM, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_VERBOSE_LOG("COM, currentByte:0x%x",currentByte); |  | ||||||
|                 headerLength = jpegd_get_two_bytes(pStream); |                 headerLength = jpegd_get_two_bytes(pStream); | ||||||
|                 JPEGD_VERBOSE_LOG("COM, headerLength:%x", headerLength); |                 JPEGD_VERBOSE_LOG("COM, headerLength:%x", headerLength); | ||||||
|                 if (headerLength == STRM_ERROR || |                 if (headerLength == STRM_ERROR || | ||||||
| @@ -1861,9 +1921,8 @@ MPP_RET jpegd_read_decode_parameters(JpegParserContext *ctx, StreamStorage *pStr | |||||||
|             case SOF14: |             case SOF14: | ||||||
|             case SOF15: |             case SOF15: | ||||||
|             case DAC: |             case DAC: | ||||||
| 	        case DHP: |             case DHP: { | ||||||
| 			{ |                 JPEGD_ERROR_LOG("SOF, currentByte:0x%x", currentByte); | ||||||
| 				JPEGD_ERROR_LOG("SOF, currentByte:0x%x",currentByte); |  | ||||||
|                 JPEGD_ERROR_LOG("Unsupported coding styles"); |                 JPEGD_ERROR_LOG("Unsupported coding styles"); | ||||||
|                 return (JPEGDEC_UNSUPPORTED); |                 return (JPEGDEC_UNSUPPORTED); | ||||||
|             } |             } | ||||||
| @@ -1906,20 +1965,20 @@ MPP_RET jpegd_get_image_info(JpegParserContext *ctx) | |||||||
|     RK_U32 pic_size = 0; |     RK_U32 pic_size = 0; | ||||||
|     StreamStorage stream; |     StreamStorage stream; | ||||||
|  |  | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
|     JpegSyntaxParam *pSyntax = pCtx->pSyntax; |     JpegSyntaxParam *pSyntax = pCtx->pSyntax; | ||||||
|  |  | ||||||
| 	if(pCtx->streamLength < 1){ |     if (pCtx->streamLength < 1) { | ||||||
|         JPEGD_ERROR_LOG("streamLength:%d", pCtx->streamLength); |         JPEGD_ERROR_LOG("streamLength:%d", pCtx->streamLength); | ||||||
|         return MPP_ERR_VALUE; |         return MPP_ERR_VALUE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if ((pCtx->streamLength > DEC_RK70_MAX_STREAM) && |     if ((pCtx->streamLength > DEC_RK70_MAX_STREAM) && | ||||||
|         (pCtx->bufferSize < JPEGDEC_RK70_MIN_BUFFER || pCtx->bufferSize > JPEGDEC_RK70_MAX_BUFFER)) { |         (pCtx->bufferSize < JPEGDEC_RK70_MIN_BUFFER || pCtx->bufferSize > JPEGDEC_RK70_MAX_BUFFER)) { | ||||||
|         JPEGD_ERROR_LOG("bufferSize = %d,streamLength = %d\n",pCtx->bufferSize, pCtx->streamLength); |         JPEGD_ERROR_LOG("bufferSize = %d,streamLength = %d\n", pCtx->bufferSize, pCtx->streamLength); | ||||||
|         return MPP_ERR_VALUE; |         return MPP_ERR_VALUE; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -1941,12 +2000,12 @@ MPP_RET jpegd_get_image_info(JpegParserContext *ctx) | |||||||
|     stream.appnFlag = 0; |     stream.appnFlag = 0; | ||||||
|  |  | ||||||
|     ret = jpegd_read_decode_parameters(pCtx, &stream); |     ret = jpegd_read_decode_parameters(pCtx, &stream); | ||||||
| 	if(ret != MPP_OK){ |     if (ret != MPP_OK) { | ||||||
|         JPEGD_ERROR_LOG("read decode parameters failed, ret:%d", ret); |         JPEGD_ERROR_LOG("read decode parameters failed, ret:%d", ret); | ||||||
|         return ret; |         return ret; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	if(pCtx->color_conv){	 |     if (pCtx->color_conv) { | ||||||
|         /* Using pp to convert all format to yuv420sp */ |         /* Using pp to convert all format to yuv420sp */ | ||||||
|         switch (pCtx->imageInfo.outputFormat) { |         switch (pCtx->imageInfo.outputFormat) { | ||||||
|         case JPEGDEC_YCbCr400: |         case JPEGDEC_YCbCr400: | ||||||
| @@ -1987,7 +2046,7 @@ MPP_RET jpegd_get_image_info(JpegParserContext *ctx) | |||||||
|  |  | ||||||
|         pic_size = ppScaleW * ppScaleH * 2; |         pic_size = ppScaleW * ppScaleH * 2; | ||||||
|         pSyntax->ppInstance = (void *)1; |         pSyntax->ppInstance = (void *)1; | ||||||
|     }else{ |     } else { | ||||||
|         /* keep original output format */ |         /* keep original output format */ | ||||||
|         memset(&ppInfo, 0, sizeof(ppInfo)); |         memset(&ppInfo, 0, sizeof(ppInfo)); | ||||||
|         ppInfo.outFomart = 5;   //PP_OUT_FORMAT_YUV420INTERLAVE |         ppInfo.outFomart = 5;   //PP_OUT_FORMAT_YUV420INTERLAVE | ||||||
| @@ -2042,7 +2101,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2056,7 +2115,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|     RK_U32 findhufftable = 0; |     RK_U32 findhufftable = 0; | ||||||
|  |  | ||||||
|     JpegSyntaxParam *pSyntax = pCtx->pSyntax; |     JpegSyntaxParam *pSyntax = pCtx->pSyntax; | ||||||
|     StreamStorage *pStream = (StreamStorage *) &(pSyntax->stream); |     StreamStorage *pStream = (StreamStorage *) & (pSyntax->stream); | ||||||
|  |  | ||||||
|     do { |     do { | ||||||
|         /* if slice mode/slice done return to hw handling */ |         /* if slice mode/slice done return to hw handling */ | ||||||
| @@ -2069,14 +2128,12 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|  |  | ||||||
|             /* switch to certain header decoding */ |             /* switch to certain header decoding */ | ||||||
|             switch (currentByte) { |             switch (currentByte) { | ||||||
| 		    case 0x00: |             case 0x00: { | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("currentByte:0x00"); |                 JPEGD_VERBOSE_LOG("currentByte:0x00"); | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             case SOF0: |             case SOF0: | ||||||
| 		    case SOF2: |             case SOF2: { | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("SOF, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("SOF, currentByte:0x%x", currentByte); | ||||||
|                 /* Baseline/Progressive */ |                 /* Baseline/Progressive */ | ||||||
|                 pSyntax->frame.codingType = currentByte; |                 pSyntax->frame.codingType = currentByte; | ||||||
| @@ -2098,8 +2155,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 		    case SOS: /* Start of Scan */ |             case SOS: { /* Start of Scan */ | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("SOS, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("SOS, currentByte:0x%x", currentByte); | ||||||
|                 /* reset image ready */ |                 /* reset image ready */ | ||||||
|                 pSyntax->image.imageReady = 0; |                 pSyntax->image.imageReady = 0; | ||||||
| @@ -2141,8 +2197,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 		    case DHT: /* Start of Huffman tables */ |             case DHT: { /* Start of Huffman tables */ | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("DHT, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("DHT, currentByte:0x%x", currentByte); | ||||||
|                 retCode = jpegd_decode_huffman_tables(pCtx); |                 retCode = jpegd_decode_huffman_tables(pCtx); | ||||||
|                 if (retCode != JPEGDEC_OK) { |                 if (retCode != JPEGDEC_OK) { | ||||||
| @@ -2157,8 +2212,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                 findhufftable = 1; |                 findhufftable = 1; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 		    case DQT: /* start of Quantisation Tables */ |             case DQT: { /* start of Quantisation Tables */ | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("DQT, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("DQT, currentByte:0x%x", currentByte); | ||||||
|                 retCode = jpegd_decode_quant_tables(pCtx); |                 retCode = jpegd_decode_quant_tables(pCtx); | ||||||
|                 if (retCode != JPEGDEC_OK) { |                 if (retCode != JPEGDEC_OK) { | ||||||
| @@ -2172,13 +2226,11 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                 } |                 } | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 		    case SOI:  /* Start of Image */ |             case SOI: { /* Start of Image */ | ||||||
| 			{ |  | ||||||
|                 /* no actions needed, continue */ |                 /* no actions needed, continue */ | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
| 		    case EOI: /* End of Image */ |             case EOI: { /* End of Image */ | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("EOI, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("EOI, currentByte:0x%x", currentByte); | ||||||
|                 if (pSyntax->image.imageReady) { |                 if (pSyntax->image.imageReady) { | ||||||
|                     JPEGD_ERROR_LOG("EOI: OK\n"); |                     JPEGD_ERROR_LOG("EOI: OK\n"); | ||||||
| @@ -2188,8 +2240,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                     return (JPEGDEC_ERROR); |                     return (JPEGDEC_ERROR); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 		    case DRI:  /* Define Restart Interval */ |             case DRI: { /* Define Restart Interval */ | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("DRI, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("DRI, currentByte:0x%x", currentByte); | ||||||
|                 currentBytes = jpegd_get_two_bytes(pStream); |                 currentBytes = jpegd_get_two_bytes(pStream); | ||||||
|                 if (currentBytes == STRM_ERROR) { |                 if (currentBytes == STRM_ERROR) { | ||||||
| @@ -2207,8 +2258,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|             case RST4: |             case RST4: | ||||||
|             case RST5: |             case RST5: | ||||||
|             case RST6: |             case RST6: | ||||||
| 		    case RST7: |             case RST7: { | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("RST, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("RST, currentByte:0x%x", currentByte); | ||||||
|                 /* initialisation of DC predictors to zero value !!! */ |                 /* initialisation of DC predictors to zero value !!! */ | ||||||
|                 for (i = 0; i < MAX_NUMBER_OF_COMPONENTS; i++) { |                 for (i = 0; i < MAX_NUMBER_OF_COMPONENTS; i++) { | ||||||
| @@ -2230,13 +2280,11 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|             case SOF15: |             case SOF15: | ||||||
|             case DAC: |             case DAC: | ||||||
|             case DHP: |             case DHP: | ||||||
| 		    case TEM: |             case TEM: { | ||||||
| 			{ |  | ||||||
|                 JPEGD_ERROR_LOG("Unsupported Features, currentByte:0x%x", currentByte); |                 JPEGD_ERROR_LOG("Unsupported Features, currentByte:0x%x", currentByte); | ||||||
|                 return (JPEGDEC_UNSUPPORTED); |                 return (JPEGDEC_UNSUPPORTED); | ||||||
|             } |             } | ||||||
| 		    case APP0: /* application data & comments */ |             case APP0: { /* application data & comments */ | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("APP0, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("APP0, currentByte:0x%x", currentByte); | ||||||
|                 /* APP0 Extended Thumbnail */ |                 /* APP0 Extended Thumbnail */ | ||||||
|                 if (pCtx->decImageType == JPEGDEC_THUMBNAIL) { |                 if (pCtx->decImageType == JPEGDEC_THUMBNAIL) { | ||||||
| @@ -2265,7 +2313,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                     appBits += 16; |                     appBits += 16; | ||||||
|                     if (currentBytes != 0x5858) { |                     if (currentBytes != 0x5858) { | ||||||
|                         pSyntax->stream.appnFlag = 1; |                         pSyntax->stream.appnFlag = 1; | ||||||
| 		                if (jpegd_flush_bits(pStream,((appLength * 8) - appBits)) == STRM_ERROR) { |                         if (jpegd_flush_bits(pStream, ((appLength * 8) - appBits)) == STRM_ERROR) { | ||||||
|                             JPEGD_ERROR_LOG("Stream Error"); |                             JPEGD_ERROR_LOG("Stream Error"); | ||||||
|                             return (JPEGDEC_STRM_ERROR); |                             return (JPEGDEC_STRM_ERROR); | ||||||
|                         } |                         } | ||||||
| @@ -2277,7 +2325,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|                     appBits += 8; |                     appBits += 8; | ||||||
|                     if (currentByte != 0x00) { |                     if (currentByte != 0x00) { | ||||||
|                         pSyntax->stream.appnFlag = 1; |                         pSyntax->stream.appnFlag = 1; | ||||||
| 		                if (jpegd_flush_bits(pStream,((appLength * 8) - appBits)) == STRM_ERROR) { |                         if (jpegd_flush_bits(pStream, ((appLength * 8) - appBits)) == STRM_ERROR) { | ||||||
|                             JPEGD_ERROR_LOG("Stream Error"); |                             JPEGD_ERROR_LOG("Stream Error"); | ||||||
|                             return (JPEGDEC_STRM_ERROR); |                             return (JPEGDEC_STRM_ERROR); | ||||||
|                         } |                         } | ||||||
| @@ -2324,8 +2372,7 @@ MPP_RET jpegd_decode_frame_impl(JpegParserContext *ctx) | |||||||
|             case APP13: |             case APP13: | ||||||
|             case APP14: |             case APP14: | ||||||
|             case APP15: |             case APP15: | ||||||
| 		    case COM: |             case COM: { | ||||||
| 			{ |  | ||||||
|                 JPEGD_VERBOSE_LOG("APPn, currentByte:0x%x", currentByte); |                 JPEGD_VERBOSE_LOG("APPn, currentByte:0x%x", currentByte); | ||||||
|                 currentBytes = jpegd_get_two_bytes(pStream); |                 currentBytes = jpegd_get_two_bytes(pStream); | ||||||
|                 if (currentBytes == STRM_ERROR) { |                 if (currentBytes == STRM_ERROR) { | ||||||
| @@ -2365,7 +2412,7 @@ MPP_RET jpegd_allocate_frame(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2393,7 +2440,7 @@ MPP_RET jpegd_update_frame(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2412,7 +2459,7 @@ MPP_RET jpegd_decode_frame(JpegParserContext *ctx) | |||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     MPP_RET ret = MPP_OK; |     MPP_RET ret = MPP_OK; | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){ |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2443,9 +2490,9 @@ MPP_RET jpegd_decode_frame(JpegParserContext *ctx) | |||||||
|     pSyntax->info.sliceMbSetValue = pCtx->sliceMbSet; |     pSyntax->info.sliceMbSetValue = pCtx->sliceMbSet; | ||||||
|  |  | ||||||
|     /* check HW supported features */ |     /* check HW supported features */ | ||||||
| 	if (!pCtx->is8190){ |     if (!pCtx->is8190) { | ||||||
|         // TODO: |         // TODO: | ||||||
| 	}else{ |     } else { | ||||||
|         /* check if fuse was burned */ |         /* check if fuse was burned */ | ||||||
|         if (pCtx->fuseBurned) { |         if (pCtx->fuseBurned) { | ||||||
|             /* return if not valid HW and unsupported operation type */ |             /* return if not valid HW and unsupported operation type */ | ||||||
| @@ -2479,7 +2526,7 @@ MPP_RET jpegd_decode_frame(JpegParserContext *ctx) | |||||||
|             mcuSizeDivider = 1; |             mcuSizeDivider = 1; | ||||||
|  |  | ||||||
|         /* check slice config */ |         /* check slice config */ | ||||||
|         if ((pCtx->sliceMbSet * (pSyntax->frame.numMcuInRow / mcuSizeDivider)) > pCtx->maxSupportedSliceSize){           |         if ((pCtx->sliceMbSet * (pSyntax->frame.numMcuInRow / mcuSizeDivider)) > pCtx->maxSupportedSliceSize) { | ||||||
|             JPEGD_ERROR_LOG("sliceMbSet  > JPEGDEC_MAX_SLICE_SIZE"); |             JPEGD_ERROR_LOG("sliceMbSet  > JPEGDEC_MAX_SLICE_SIZE"); | ||||||
|             return (JPEGDEC_PARAM_ERROR); |             return (JPEGDEC_PARAM_ERROR); | ||||||
|         } |         } | ||||||
| @@ -2537,7 +2584,7 @@ MPP_RET jpegd_parse(void *ctx, HalDecTask *task) | |||||||
|     jpegd_get_image_info(JpegParserCtx); |     jpegd_get_image_info(JpegParserCtx); | ||||||
|     ret = jpegd_decode_frame(JpegParserCtx); |     ret = jpegd_decode_frame(JpegParserCtx); | ||||||
|  |  | ||||||
| 	if(MPP_OK == ret){ |     if (MPP_OK == ret) { | ||||||
|         jpegd_allocate_frame(JpegParserCtx); |         jpegd_allocate_frame(JpegParserCtx); | ||||||
|         task->syntax.data = (void *)JpegParserCtx->pSyntax; |         task->syntax.data = (void *)JpegParserCtx->pSyntax; | ||||||
|         task->syntax.number = sizeof(JpegSyntaxParam); |         task->syntax.number = sizeof(JpegSyntaxParam); | ||||||
| @@ -2555,65 +2602,66 @@ MPP_RET jpegd_deinit(void *ctx) | |||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx; |     JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx; | ||||||
|  |  | ||||||
| 	if(JpegParserCtx->recv_buffer){ |     if (JpegParserCtx->recv_buffer) { | ||||||
|         mpp_free(JpegParserCtx->recv_buffer); |         mpp_free(JpegParserCtx->recv_buffer); | ||||||
|         JpegParserCtx->recv_buffer = NULL; |         JpegParserCtx->recv_buffer = NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	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; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	if(JpegParserCtx->pSyntax){ |     if (JpegParserCtx->pSyntax) { | ||||||
|         mpp_free(JpegParserCtx->pSyntax); |         mpp_free(JpegParserCtx->pSyntax); | ||||||
|         JpegParserCtx->pSyntax = NULL; |         JpegParserCtx->pSyntax = NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	if(JpegParserCtx->output_frame){ |     if (JpegParserCtx->output_frame) { | ||||||
|         mpp_free(JpegParserCtx->output_frame); |         mpp_free(JpegParserCtx->output_frame); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	if(JpegParserCtx->input_packet){ |     if (JpegParserCtx->input_packet) { | ||||||
|         mpp_packet_deinit(&JpegParserCtx->input_packet); |         mpp_packet_deinit(&JpegParserCtx->input_packet); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     JpegParserCtx->pts = 0; |     JpegParserCtx->pts = 0; | ||||||
|  |     JpegParserCtx->eos = 0; | ||||||
|     JpegParserCtx->parser_debug_enable = 0; |     JpegParserCtx->parser_debug_enable = 0; | ||||||
|     JpegParserCtx->input_jpeg_count = 0; |     JpegParserCtx->input_jpeg_count = 0; | ||||||
|  |  | ||||||
| @@ -2625,7 +2673,7 @@ MPP_RET reset_jpeg_parser_context(JpegParserContext *ctx) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *pCtx = ctx; |     JpegParserContext *pCtx = ctx; | ||||||
| 	if(NULL == pCtx){		 |     if (NULL == pCtx) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2650,9 +2698,9 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg) | |||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
|     JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx; |     JpegParserContext *JpegParserCtx = (JpegParserContext *)ctx; | ||||||
| 	if(NULL == JpegParserCtx){ |     if (NULL == JpegParserCtx) { | ||||||
|         JpegParserCtx = (JpegParserContext *)mpp_calloc(JpegParserContext, 1); |         JpegParserCtx = (JpegParserContext *)mpp_calloc(JpegParserContext, 1); | ||||||
| 		if(NULL == JpegParserCtx){ |         if (NULL == JpegParserCtx) { | ||||||
|             JPEGD_ERROR_LOG("NULL pointer"); |             JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|             return MPP_ERR_NULL_PTR; |             return MPP_ERR_NULL_PTR; | ||||||
|         } |         } | ||||||
| @@ -2666,7 +2714,7 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg) | |||||||
|     mpp_buf_slot_setup(JpegParserCtx->frame_slots, 16); |     mpp_buf_slot_setup(JpegParserCtx->frame_slots, 16); | ||||||
|  |  | ||||||
|     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("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2680,7 +2728,7 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg) | |||||||
|     JpegParserCtx->fuseBurned = 1; /* changed by application*/ |     JpegParserCtx->fuseBurned = 1; /* changed by application*/ | ||||||
|  |  | ||||||
|     JpegParserCtx->pSyntax = mpp_calloc(JpegSyntaxParam, 1); |     JpegParserCtx->pSyntax = mpp_calloc(JpegSyntaxParam, 1); | ||||||
| 	if(NULL == JpegParserCtx->pSyntax){			 |     if (NULL == JpegParserCtx->pSyntax) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -2708,7 +2756,8 @@ MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg) | |||||||
|     JpegParserCtx->extensionsSupported = 1; |     JpegParserCtx->extensionsSupported = 1; | ||||||
|  |  | ||||||
|     JpegParserCtx->pts = 0; |     JpegParserCtx->pts = 0; | ||||||
| 	JpegParserCtx->parser_debug_enable = 1; |     JpegParserCtx->eos = 0; | ||||||
|  |     JpegParserCtx->parser_debug_enable = 0; | ||||||
|     JpegParserCtx->input_jpeg_count = 0; |     JpegParserCtx->input_jpeg_count = 0; | ||||||
|  |  | ||||||
|     FUN_TEST("Exit"); |     FUN_TEST("Exit"); | ||||||
|   | |||||||
| @@ -100,7 +100,7 @@ enum { | |||||||
|     JPEGDEC_THUMBNAIL = 1 |     JPEGDEC_THUMBNAIL = 1 | ||||||
| }; | }; | ||||||
|  |  | ||||||
| enum{ | enum { | ||||||
|     SOF0 = 0xC0, |     SOF0 = 0xC0, | ||||||
|     SOF1 = 0xC1, |     SOF1 = 0xC1, | ||||||
|     SOF2 = 0xC2, |     SOF2 = 0xC2, | ||||||
| @@ -195,9 +195,9 @@ typedef struct JpegParserContext { | |||||||
|     RK_U32 extensionsSupported; |     RK_U32 extensionsSupported; | ||||||
|  |  | ||||||
|     RK_S64 pts; |     RK_S64 pts; | ||||||
|  |     RK_U32 eos; | ||||||
|     RK_U32 parser_debug_enable; |     RK_U32 parser_debug_enable; | ||||||
|     RK_U32 input_jpeg_count; |     RK_U32 input_jpeg_count; | ||||||
| }JpegParserContext; | } JpegParserContext; | ||||||
|  |  | ||||||
| #endif /* __JPEGD_PARSER_H__ */ | #endif /* __JPEGD_PARSER_H__ */ | ||||||
|   | |||||||
| @@ -340,7 +340,7 @@ typedef struct { | |||||||
|                                  */ |                                  */ | ||||||
| } JpegDecImageInfo; | } JpegDecImageInfo; | ||||||
|  |  | ||||||
| typedef struct JpegSyntaxParam{ | typedef struct JpegSyntaxParam { | ||||||
|     StreamStorage stream; |     StreamStorage stream; | ||||||
|     FrameInfo frame; |     FrameInfo frame; | ||||||
|     ImageData image; |     ImageData image; | ||||||
| @@ -370,7 +370,7 @@ typedef struct JpegSyntaxParam{ | |||||||
|  |  | ||||||
|     const void *ppInstance; |     const void *ppInstance; | ||||||
|     VPUMemLinear_t *pictureMem; |     VPUMemLinear_t *pictureMem; | ||||||
| }JpegSyntaxParam; | } JpegSyntaxParam; | ||||||
|  |  | ||||||
|  |  | ||||||
| #endif /*__JPEGD_SYNTAX__*/ | #endif /*__JPEGD_SYNTAX__*/ | ||||||
|   | |||||||
| @@ -1175,12 +1175,12 @@ static void jpegd_write_tables(JpegSyntaxParam *pSyntax, JpegHalContext *pCtx) | |||||||
| MPP_RET jpegd_allocate_chroma_out_buffer(JpegSyntaxParam *pSyntax) | MPP_RET jpegd_allocate_chroma_out_buffer(JpegSyntaxParam *pSyntax) | ||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
| 	if(NULL == pSyntax){ |     if (NULL == pSyntax) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	if (pSyntax->ppInstance == NULL || (pSyntax->ppInstance != NULL && !pSyntax->ppControl.usePipeline)){ |     if (pSyntax->ppInstance == NULL || (pSyntax->ppInstance != NULL && !pSyntax->ppControl.usePipeline)) { | ||||||
|         if (pSyntax->info.givenOutLuma.vir_addr == NULL) { |         if (pSyntax->info.givenOutLuma.vir_addr == NULL) { | ||||||
|             JPEGD_INFO_LOG("givenOutLuma is NULL"); |             JPEGD_INFO_LOG("givenOutLuma is NULL"); | ||||||
|  |  | ||||||
| @@ -1238,7 +1238,7 @@ MPP_RET jpegd_allocate_chroma_out_buffer(JpegSyntaxParam *pSyntax) | |||||||
| MPP_RET jpegd_set_post_processor(JpegHalContext *pCtx, JpegSyntaxParam *pSyntax) | MPP_RET jpegd_set_post_processor(JpegHalContext *pCtx, JpegSyntaxParam *pSyntax) | ||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
| 	if(NULL == pCtx || NULL == pSyntax){ |     if (NULL == pCtx || NULL == pSyntax) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -1540,7 +1540,7 @@ MPP_RET jpegd_set_post_processor(JpegHalContext *pCtx, JpegSyntaxParam *pSyntax) | |||||||
|         break; |         break; | ||||||
|     case    PP_OUT_FORMAT_YUV420INTERLAVE: { |     case    PP_OUT_FORMAT_YUV420INTERLAVE: { | ||||||
|         RK_U32 phy_addr = pSyntax->asicBuff.outLumaBuffer.phy_addr; |         RK_U32 phy_addr = pSyntax->asicBuff.outLumaBuffer.phy_addr; | ||||||
| 		if(VPUClientGetIOMMUStatus() <= 0) { |         if (VPUClientGetIOMMUStatus() <= 0) { | ||||||
|             reg->reg22_pp_out_ch_base = (phy_addr + outWidth * outHeight); |             reg->reg22_pp_out_ch_base = (phy_addr + outWidth * outHeight); | ||||||
|         } else { |         } else { | ||||||
|             if (outWidth * outHeight > 0x400000) { |             if (outWidth * outHeight > 0x400000) { | ||||||
| @@ -1663,7 +1663,7 @@ JpegDecRet jpegd_configure_regs(JpegSyntaxParam *pSyntax, JpegHalContext *pCtx) | |||||||
|     if (pSyntax->frame.Ri) { |     if (pSyntax->frame.Ri) { | ||||||
|         reg->reg122.sw_sync_marker_e = 1; |         reg->reg122.sw_sync_marker_e = 1; | ||||||
|         reg->reg123.sw_pjpeg_rest_freq = pSyntax->frame.Ri; |         reg->reg123.sw_pjpeg_rest_freq = pSyntax->frame.Ri; | ||||||
| 	} else{ |     } else { | ||||||
|         reg->reg122.sw_sync_marker_e = 0; |         reg->reg122.sw_sync_marker_e = 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -1752,7 +1752,7 @@ static MPP_RET jpegd_regs_init(JpegRegSet *reg) | |||||||
| MPP_RET jpegd_gen_regs(JpegHalContext *ctx, JpegSyntaxParam *syntax) | MPP_RET jpegd_gen_regs(JpegHalContext *ctx, JpegSyntaxParam *syntax) | ||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
| 	if(NULL == ctx || NULL == syntax){ |     if (NULL == ctx || NULL == syntax) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -1773,7 +1773,7 @@ MPP_RET jpegd_gen_regs(JpegHalContext *ctx, JpegSyntaxParam *syntax) | |||||||
|                 /* if slice mode ==> set slice height */ |                 /* if slice mode ==> set slice height */ | ||||||
|                 if (pSyntax->info.sliceMbSetValue && pSyntax->ppControl.usePipeline == 0) { |                 if (pSyntax->info.sliceMbSetValue && pSyntax->ppControl.usePipeline == 0) { | ||||||
|                     jpegd_calculate_slice_size(pSyntax); |                     jpegd_calculate_slice_size(pSyntax); | ||||||
| 					JPEGD_INFO_LOG("sliceHeight is %d, sliceMbSetValue is %d",pSyntax->info.sliceHeight,pSyntax->info.sliceMbSetValue);		 |                     JPEGD_INFO_LOG("sliceHeight is %d, sliceMbSetValue is %d", pSyntax->info.sliceHeight, pSyntax->info.sliceMbSetValue); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 /* Start HW or continue after pause */ |                 /* Start HW or continue after pause */ | ||||||
| @@ -1818,7 +1818,7 @@ MPP_RET hal_jpegd_init(void *hal, MppHalCfg *cfg) | |||||||
|     JpegHalContext *JpegHalCtx = (JpegHalContext *)hal; |     JpegHalContext *JpegHalCtx = (JpegHalContext *)hal; | ||||||
|     if (NULL == JpegHalCtx) { |     if (NULL == JpegHalCtx) { | ||||||
|         JpegHalCtx = (JpegHalContext *)mpp_calloc(JpegHalContext, 1); |         JpegHalCtx = (JpegHalContext *)mpp_calloc(JpegHalContext, 1); | ||||||
| 		if(NULL == JpegHalCtx){ |         if (NULL == JpegHalCtx) { | ||||||
|             JPEGD_ERROR_LOG("NULL pointer"); |             JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|             return MPP_ERR_NULL_PTR; |             return MPP_ERR_NULL_PTR; | ||||||
|         } |         } | ||||||
| @@ -1830,7 +1830,7 @@ MPP_RET hal_jpegd_init(void *hal, MppHalCfg *cfg) | |||||||
|  |  | ||||||
|     //get vpu socket |     //get vpu socket | ||||||
| #ifdef RKPLATFORM | #ifdef RKPLATFORM | ||||||
| 	if(JpegHalCtx->vpu_socket <= 0) { |     if (JpegHalCtx->vpu_socket <= 0) { | ||||||
|         JpegHalCtx->vpu_socket = VPUClientInit(VPU_DEC_PP/*VPU_DEC*/); |         JpegHalCtx->vpu_socket = VPUClientInit(VPU_DEC_PP/*VPU_DEC*/); | ||||||
|         if (JpegHalCtx->vpu_socket <= 0) { |         if (JpegHalCtx->vpu_socket <= 0) { | ||||||
|             JPEGD_ERROR_LOG("get vpu_socket(%d) <= 0, failed. \n", JpegHalCtx->vpu_socket); |             JPEGD_ERROR_LOG("get vpu_socket(%d) <= 0, failed. \n", JpegHalCtx->vpu_socket); | ||||||
| @@ -1873,7 +1873,7 @@ MPP_RET hal_jpegd_init(void *hal, MppHalCfg *cfg) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     //init dbg stuff |     //init dbg stuff | ||||||
|     JpegHalCtx->hal_debug_enable = 1; |     JpegHalCtx->hal_debug_enable = 0; | ||||||
|     JpegHalCtx->frame_count = 0; |     JpegHalCtx->frame_count = 0; | ||||||
|     JpegHalCtx->output_yuv_count = 0; |     JpegHalCtx->output_yuv_count = 0; | ||||||
|  |  | ||||||
| @@ -1928,7 +1928,7 @@ MPP_RET hal_jpegd_deinit(void *hal) | |||||||
| MPP_RET hal_jpegd_gen_regs(void *hal,  HalTaskInfo *syn) | MPP_RET hal_jpegd_gen_regs(void *hal,  HalTaskInfo *syn) | ||||||
| { | { | ||||||
|     FUN_TEST("Enter"); |     FUN_TEST("Enter"); | ||||||
| 	if(NULL == hal || NULL == syn){ |     if (NULL == hal || NULL == syn) { | ||||||
|         JPEGD_ERROR_LOG("NULL pointer"); |         JPEGD_ERROR_LOG("NULL pointer"); | ||||||
|         return MPP_ERR_NULL_PTR; |         return MPP_ERR_NULL_PTR; | ||||||
|     } |     } | ||||||
| @@ -1941,7 +1941,7 @@ MPP_RET hal_jpegd_gen_regs(void *hal,  HalTaskInfo *syn) | |||||||
|     MppBuffer outputBuf = NULL; |     MppBuffer outputBuf = NULL; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| 	if(syn->dec.valid){	 |     if (syn->dec.valid) { | ||||||
|         syn->dec.valid = 0; |         syn->dec.valid = 0; | ||||||
|  |  | ||||||
| #ifdef RKPLATFORM | #ifdef RKPLATFORM | ||||||
| @@ -1958,13 +1958,13 @@ MPP_RET hal_jpegd_gen_regs(void *hal,  HalTaskInfo *syn) | |||||||
|  |  | ||||||
|         ret = jpegd_gen_regs(JpegHalCtx, pSyntax); |         ret = jpegd_gen_regs(JpegHalCtx, pSyntax); | ||||||
|  |  | ||||||
| 		if(JpegHalCtx->hal_debug_enable && JpegHalCtx->frame_count < 3){ |         if (JpegHalCtx->hal_debug_enable && JpegHalCtx->frame_count < 3) { | ||||||
|             RK_U32 idx = 0; |             RK_U32 idx = 0; | ||||||
| 			RK_U32 *pRegs = (RK_U32 *) &(JpegHalCtx->regs); |             RK_U32 *pRegs = (RK_U32 *) & (JpegHalCtx->regs); | ||||||
|             JPEGD_INFO_LOG("sizeof(JpegRegSet)=%d, sizeof(pRegs[0])=%d", sizeof(JpegRegSet), sizeof(pRegs[0])); |             JPEGD_INFO_LOG("sizeof(JpegRegSet)=%d, sizeof(pRegs[0])=%d", sizeof(JpegRegSet), sizeof(pRegs[0])); | ||||||
|  |  | ||||||
|             JpegHalCtx->frame_count++; |             JpegHalCtx->frame_count++; | ||||||
| 			for(idx = 0; idx < sizeof(JpegRegSet)/sizeof(pRegs[0]); idx++){ |             for (idx = 0; idx < sizeof(JpegRegSet) / sizeof(pRegs[0]); idx++) { | ||||||
|                 JPEGD_INFO_LOG("frame_%d_reg[%d]=0x%08x", JpegHalCtx->frame_count, idx, pRegs[idx]); |                 JPEGD_INFO_LOG("frame_%d_reg[%d]=0x%08x", JpegHalCtx->frame_count, idx, pRegs[idx]); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -2011,21 +2011,20 @@ MPP_RET hal_jpegd_wait(void *hal, HalTaskInfo *task) | |||||||
|     memset(®_out, 0, sizeof(JpegRegSet)); |     memset(®_out, 0, sizeof(JpegRegSet)); | ||||||
|  |  | ||||||
|     ret = VPUClientWaitResult(JpegHalCtx->vpu_socket, (RK_U32 *)®_out, JPEGD_REG_NUM, &cmd, &length); |     ret = VPUClientWaitResult(JpegHalCtx->vpu_socket, (RK_U32 *)®_out, JPEGD_REG_NUM, &cmd, &length); | ||||||
| 	if(reg_out.reg55_Interrupt.sw_dec_bus_int){ |     if (reg_out.reg55_Interrupt.sw_dec_bus_int) { | ||||||
|         JPEGD_ERROR_LOG("IRQ BUS ERROR!"); |         JPEGD_ERROR_LOG("IRQ BUS ERROR!"); | ||||||
| 	}else if(reg_out.reg55_Interrupt.sw_dec_error_int){ |     } else if (reg_out.reg55_Interrupt.sw_dec_error_int) { | ||||||
|         JPEGD_ERROR_LOG("IRQ STREAM ERROR!"); |         JPEGD_ERROR_LOG("IRQ STREAM ERROR!"); | ||||||
| 	}else if(reg_out.reg55_Interrupt.sw_dec_timeout){ |     } else if (reg_out.reg55_Interrupt.sw_dec_timeout) { | ||||||
|         JPEGD_ERROR_LOG("IRQ TIMEOUT!"); |         JPEGD_ERROR_LOG("IRQ TIMEOUT!"); | ||||||
| 	}else if(reg_out.reg55_Interrupt.sw_dec_buffer_int){ |     } else if (reg_out.reg55_Interrupt.sw_dec_buffer_int) { | ||||||
|         JPEGD_ERROR_LOG("IRQ BUFFER EMPTY!"); |         JPEGD_ERROR_LOG("IRQ BUFFER EMPTY!"); | ||||||
| 	}else if(reg_out.reg55_Interrupt.sw_dec_irq){ |     } else if (reg_out.reg55_Interrupt.sw_dec_irq) { | ||||||
|         JPEGD_INFO_LOG("DECODE SUCCESS!"); |         JPEGD_INFO_LOG("DECODE SUCCESS!"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* debug information */ |     /* debug information */ | ||||||
|     if(JpegHalCtx->hal_debug_enable && JpegHalCtx->output_yuv_count < 3) |     if (JpegHalCtx->hal_debug_enable && JpegHalCtx->output_yuv_count < 3) { | ||||||
|     { |  | ||||||
|         static FILE *jpg_file; |         static FILE *jpg_file; | ||||||
|         static char name[32]; |         static char name[32]; | ||||||
|         MppBuffer outputBuf = NULL; |         MppBuffer outputBuf = NULL; | ||||||
| @@ -2042,7 +2041,7 @@ MPP_RET hal_jpegd_wait(void *hal, HalTaskInfo *task) | |||||||
|  |  | ||||||
|             JPEGD_INFO_LOG("output YUV(%d*%d) saving to %s\n", width, height, name); |             JPEGD_INFO_LOG("output YUV(%d*%d) saving to %s\n", width, height, name); | ||||||
|             JPEGD_INFO_LOG("pOutYUV:%p", pOutYUV); |             JPEGD_INFO_LOG("pOutYUV:%p", pOutYUV); | ||||||
|             fwrite(pOutYUV, width*height*3/2, 1, jpg_file); |             fwrite(pOutYUV, width * height * 3 / 2, 1, jpg_file); | ||||||
|             fclose(jpg_file); |             fclose(jpg_file); | ||||||
|             JpegHalCtx->output_yuv_count++; |             JpegHalCtx->output_yuv_count++; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -70,7 +70,7 @@ | |||||||
| #define PP_OUT_FORMAT_YUV420INTERLAVE    5 | #define PP_OUT_FORMAT_YUV420INTERLAVE    5 | ||||||
|  |  | ||||||
|  |  | ||||||
| typedef struct JpegRegSet{ | typedef struct JpegRegSet { | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_pp_max_burst     : 5; |         RK_U32  sw_pp_max_burst     : 5; | ||||||
|         RK_U32  sw_pp_scmd_dis      : 1; |         RK_U32  sw_pp_scmd_dis      : 1; | ||||||
| @@ -529,21 +529,21 @@ typedef struct JpegRegSet{ | |||||||
|         RK_U32  sw_ac1_code5_cnt   : 6; |         RK_U32  sw_ac1_code5_cnt   : 6; | ||||||
|         RK_U32  sw_reserved_3      : 2; |         RK_U32  sw_reserved_3      : 2; | ||||||
|         RK_U32  sw_ac1_code6_cnt   : 7; |         RK_U32  sw_ac1_code6_cnt   : 7; | ||||||
| 	}reg134; |     } reg134; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_ac1_code7_cnt   : 8; |         RK_U32  sw_ac1_code7_cnt   : 8; | ||||||
|         RK_U32  sw_ac1_code8_cnt   : 8; |         RK_U32  sw_ac1_code8_cnt   : 8; | ||||||
|         RK_U32  sw_ac1_code9_cnt   : 8; |         RK_U32  sw_ac1_code9_cnt   : 8; | ||||||
|         RK_U32  sw_ac1_code10_cnt  : 8; |         RK_U32  sw_ac1_code10_cnt  : 8; | ||||||
| 	}reg135; |     } reg135; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_ac1_code11_cnt   : 8; |         RK_U32  sw_ac1_code11_cnt   : 8; | ||||||
|         RK_U32  sw_ac1_code12_cnt   : 8; |         RK_U32  sw_ac1_code12_cnt   : 8; | ||||||
|         RK_U32  sw_ac1_code13_cnt   : 8; |         RK_U32  sw_ac1_code13_cnt   : 8; | ||||||
|         RK_U32  sw_ac1_code14_cnt   : 8; |         RK_U32  sw_ac1_code14_cnt   : 8; | ||||||
| 	}reg136; |     } reg136; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_ac1_code15_cnt   : 8; |         RK_U32  sw_ac1_code15_cnt   : 8; | ||||||
| @@ -570,14 +570,14 @@ typedef struct JpegRegSet{ | |||||||
|         RK_U32  sw_ac2_code10_cnt   : 8; |         RK_U32  sw_ac2_code10_cnt   : 8; | ||||||
|         RK_U32  sw_ac2_code11_cnt   : 8; |         RK_U32  sw_ac2_code11_cnt   : 8; | ||||||
|         RK_U32  sw_ac2_code12_cnt   : 8; |         RK_U32  sw_ac2_code12_cnt   : 8; | ||||||
| 	}reg139; |     } reg139; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_ac2_code13_cnt   : 8; |         RK_U32  sw_ac2_code13_cnt   : 8; | ||||||
|         RK_U32  sw_ac2_code14_cnt   : 8; |         RK_U32  sw_ac2_code14_cnt   : 8; | ||||||
|         RK_U32  sw_ac2_code15_cnt   : 8; |         RK_U32  sw_ac2_code15_cnt   : 8; | ||||||
|         RK_U32  sw_ac2_code16_cnt   : 8; |         RK_U32  sw_ac2_code16_cnt   : 8; | ||||||
| 	}reg140; |     } reg140; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_dc1_code1_cnt    : 2; |         RK_U32  sw_dc1_code1_cnt    : 2; | ||||||
| @@ -590,7 +590,7 @@ typedef struct JpegRegSet{ | |||||||
|         RK_U32  sw_dc1_code6_cnt    : 4; |         RK_U32  sw_dc1_code6_cnt    : 4; | ||||||
|         RK_U32  sw_dc1_code7_cnt    : 4; |         RK_U32  sw_dc1_code7_cnt    : 4; | ||||||
|         RK_U32  sw_dc1_code8_cnt    : 4; |         RK_U32  sw_dc1_code8_cnt    : 4; | ||||||
| 	}reg141; |     } reg141; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_dc1_code9_cnt     : 4; |         RK_U32  sw_dc1_code9_cnt     : 4; | ||||||
| @@ -601,7 +601,7 @@ typedef struct JpegRegSet{ | |||||||
|         RK_U32  sw_dc1_code14_cnt    : 4; |         RK_U32  sw_dc1_code14_cnt    : 4; | ||||||
|         RK_U32  sw_dc1_code15_cnt    : 4; |         RK_U32  sw_dc1_code15_cnt    : 4; | ||||||
|         RK_U32  sw_dc1_code16_cnt    : 4; |         RK_U32  sw_dc1_code16_cnt    : 4; | ||||||
| 	}reg142; |     } reg142; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_dc2_code1_cnt    : 2; |         RK_U32  sw_dc2_code1_cnt    : 2; | ||||||
| @@ -614,7 +614,7 @@ typedef struct JpegRegSet{ | |||||||
|         RK_U32  sw_dc2_code6_cnt    : 4; |         RK_U32  sw_dc2_code6_cnt    : 4; | ||||||
|         RK_U32  sw_dc2_code7_cnt    : 4; |         RK_U32  sw_dc2_code7_cnt    : 4; | ||||||
|         RK_U32  sw_dc2_code8_cnt    : 4; |         RK_U32  sw_dc2_code8_cnt    : 4; | ||||||
| 	}reg143; |     } reg143; | ||||||
|  |  | ||||||
|     struct { |     struct { | ||||||
|         RK_U32  sw_dc2_code9_cnt     : 4; |         RK_U32  sw_dc2_code9_cnt     : 4; | ||||||
| @@ -625,7 +625,7 @@ typedef struct JpegRegSet{ | |||||||
|         RK_U32  sw_dc2_code14_cnt    : 4; |         RK_U32  sw_dc2_code14_cnt    : 4; | ||||||
|         RK_U32  sw_dc2_code15_cnt    : 4; |         RK_U32  sw_dc2_code15_cnt    : 4; | ||||||
|         RK_U32  sw_dc2_code16_cnt    : 4; |         RK_U32  sw_dc2_code16_cnt    : 4; | ||||||
| 	}reg144; |     } reg144; | ||||||
|  |  | ||||||
|     RK_U32 reg145_bitpl_ctrl_base; |     RK_U32 reg145_bitpl_ctrl_base; | ||||||
|     RK_U32 reg_dct_strm1_base[2]; |     RK_U32 reg_dct_strm1_base[2]; | ||||||
| @@ -718,6 +718,6 @@ typedef struct JpegHalContext { | |||||||
|  |  | ||||||
|     FILE *fp_reg_in; |     FILE *fp_reg_in; | ||||||
|     FILE *fp_reg_out; |     FILE *fp_reg_out; | ||||||
| }JpegHalContext; | } JpegHalContext; | ||||||
|  |  | ||||||
| #endif /* __HAL_JPEGD_REG_H__ */ | #endif /* __HAL_JPEGD_REG_H__ */ | ||||||
|   | |||||||
| @@ -77,7 +77,7 @@ typedef struct jpegdDemoCtx { | |||||||
|     RK_U8          *strmbuf; |     RK_U8          *strmbuf; | ||||||
|     RK_U32         strmbytes; |     RK_U32         strmbytes; | ||||||
|     RK_U32         dec_frm_num; |     RK_U32         dec_frm_num; | ||||||
| }jpegdDemoCtx; | } jpegdDemoCtx; | ||||||
|  |  | ||||||
| static OptionInfo jpeg_parserCmd[] = { | static OptionInfo jpeg_parserCmd[] = { | ||||||
|     {"i",               "input_file",           "input bitstream file"}, |     {"i",               "input_file",           "input bitstream file"}, | ||||||
| @@ -97,7 +97,7 @@ MPP_RET jpegd_readbytes_from_file(RK_U8* buf, RK_S32 aBytes, FILE* fp) | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     RK_S32 rd_bytes = fread(buf, 1, aBytes, fp); |     RK_S32 rd_bytes = fread(buf, 1, aBytes, fp); | ||||||
| 	if(rd_bytes != aBytes){ |     if (rd_bytes != aBytes) { | ||||||
|         mpp_log("read %u bytes from file fail, actually only %#x bytes is read.", (RK_U32)aBytes, rd_bytes); |         mpp_log("read %u bytes from file fail, actually only %#x bytes is read.", (RK_U32)aBytes, rd_bytes); | ||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
| @@ -126,7 +126,7 @@ static void jpeg_show_options(int count, OptionInfo *options) | |||||||
| static RK_S32 jpeg_show_help() | static RK_S32 jpeg_show_help() | ||||||
| { | { | ||||||
|     mpp_log("usage: parserDemo [options] input_file, \n\n"); |     mpp_log("usage: parserDemo [options] input_file, \n\n"); | ||||||
| 	jpeg_show_options(sizeof(jpeg_parserCmd)/sizeof(OptionInfo), jpeg_parserCmd); |     jpeg_show_options(sizeof(jpeg_parserCmd) / sizeof(OptionInfo), jpeg_parserCmd); | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -271,11 +271,11 @@ MPP_RET jpegd_test_deinit(jpegdDemoCtx *ctx) | |||||||
|         mpp_err("strmbuf_grp deinit"); |         mpp_err("strmbuf_grp deinit"); | ||||||
|         mpp_buffer_group_put(ctx->strmbuf_grp); |         mpp_buffer_group_put(ctx->strmbuf_grp); | ||||||
|     } |     } | ||||||
|     if(ctx->strmbuf) { |     if (ctx->strmbuf) { | ||||||
|         mpp_err("strmbuf free"); |         mpp_err("strmbuf free"); | ||||||
|         mpp_free(ctx->strmbuf); |         mpp_free(ctx->strmbuf); | ||||||
|     } |     } | ||||||
| 	if(ctx->pOutFile){ |     if (ctx->pOutFile) { | ||||||
|         mpp_err("close output file"); |         mpp_err("close output file"); | ||||||
|         fclose(ctx->pOutFile); |         fclose(ctx->pOutFile); | ||||||
|         ctx->pOutFile = NULL; |         ctx->pOutFile = NULL; | ||||||
| @@ -298,7 +298,7 @@ MPP_RET jpegd_test_init(parserDemoCmdCtx *cmd, jpegdDemoCtx *ctx) | |||||||
|  |  | ||||||
|     //demo configure |     //demo configure | ||||||
|     ctx->pOutFile = fopen("/data/spurs.yuv", "wb+"); |     ctx->pOutFile = fopen("/data/spurs.yuv", "wb+"); | ||||||
| 	if(NULL == ctx->pOutFile){ |     if (NULL == ctx->pOutFile) { | ||||||
|         JPEGD_ERROR_LOG("create spurs.yuv failed"); |         JPEGD_ERROR_LOG("create spurs.yuv failed"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -413,7 +413,7 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) | |||||||
|  |  | ||||||
|         // 2.jpegd_readbytes_from_file |         // 2.jpegd_readbytes_from_file | ||||||
|         ret = jpegd_readbytes_from_file(DemoCtx.strmbuf, fileSize, pInFile); |         ret = jpegd_readbytes_from_file(DemoCtx.strmbuf, fileSize, pInFile); | ||||||
| 		if(ret != MPP_OK){ |         if (ret != MPP_OK) { | ||||||
|             mpp_log("read bytes from file failed\n"); |             mpp_log("read bytes from file failed\n"); | ||||||
|             goto __FAILED; |             goto __FAILED; | ||||||
|         } |         } | ||||||
| @@ -435,7 +435,7 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) | |||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                     mpp_buffer_get(DemoCtx.strmbuf_grp, &buffer, size); |                     mpp_buffer_get(DemoCtx.strmbuf_grp, &buffer, size); | ||||||
| 					if (buffer != NULL){ |                     if (buffer != NULL) { | ||||||
|                         mpp_err("mpp_buf_slot_get_prop, buffer:%p, size:%d", buffer, size); |                         mpp_err("mpp_buf_slot_get_prop, buffer:%p, size:%d", buffer, size); | ||||||
|                         mpp_buf_slot_set_prop(pMppDec->packet_slots, slot_idx, SLOT_BUFFER, buffer); |                         mpp_buf_slot_set_prop(pMppDec->packet_slots, slot_idx, SLOT_BUFFER, buffer); | ||||||
|                     } |                     } | ||||||
| @@ -445,7 +445,7 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) | |||||||
|                                  mpp_packet_get_data(curtask->input_packet), |                                  mpp_packet_get_data(curtask->input_packet), | ||||||
|                                  mpp_packet_get_size(curtask->input_packet)); |                                  mpp_packet_get_size(curtask->input_packet)); | ||||||
|  |  | ||||||
| 				mpp_err("%s Line %d, (*input_packet):%p, length:%d", __func__,__LINE__, |                 mpp_err("%s Line %d, (*input_packet):%p, length:%d", __func__, __LINE__, | ||||||
|                         mpp_packet_get_data(curtask->input_packet), |                         mpp_packet_get_data(curtask->input_packet), | ||||||
|                         mpp_packet_get_size(curtask->input_packet)); |                         mpp_packet_get_size(curtask->input_packet)); | ||||||
|                 DemoCtx.pkt_buf = buffer; |                 DemoCtx.pkt_buf = buffer; | ||||||
| @@ -475,7 +475,7 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) | |||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 mpp_buffer_get(DemoCtx.frmbuf_grp, &buffer, size); |                 mpp_buffer_get(DemoCtx.frmbuf_grp, &buffer, size); | ||||||
| 				if (buffer){ |                 if (buffer) { | ||||||
|                     mpp_buf_slot_set_prop(pMppDec->frame_slots, index, SLOT_BUFFER, buffer); |                     mpp_buf_slot_set_prop(pMppDec->frame_slots, index, SLOT_BUFFER, buffer); | ||||||
|                     mpp_err("frame_slots, buffer:%p, size:%d", buffer, size); |                     mpp_err("frame_slots, buffer:%p, size:%d", buffer, size); | ||||||
|                 } |                 } | ||||||
| @@ -506,10 +506,10 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         /*** parser packet deinit ***/ |         /*** parser packet deinit ***/ | ||||||
| 		if(DemoCtx.pkt_buf) { |         if (DemoCtx.pkt_buf) { | ||||||
|             mpp_buffer_put(DemoCtx.pkt_buf); |             mpp_buffer_put(DemoCtx.pkt_buf); | ||||||
|         } |         } | ||||||
| 		if(DemoCtx.pic_buf) { |         if (DemoCtx.pic_buf) { | ||||||
|             mpp_buffer_put(DemoCtx.pic_buf); |             mpp_buffer_put(DemoCtx.pic_buf); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -521,12 +521,12 @@ MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) | |||||||
|         curtask->input = -1; |         curtask->input = -1; | ||||||
|  |  | ||||||
|         DemoCtx.dec_frm_num ++; |         DemoCtx.dec_frm_num ++; | ||||||
| 	}while(0); |     } while (0); | ||||||
|  |  | ||||||
|     CHECK_FUN(mpp_dec_flush(pMppDec)); |     CHECK_FUN(mpp_dec_flush(pMppDec)); | ||||||
|  |  | ||||||
| __FAILED: | __FAILED: | ||||||
| 	if(pInFile){ |     if (pInFile) { | ||||||
|         fclose(pInFile); |         fclose(pInFile); | ||||||
|         pInFile = NULL; |         pInFile = NULL; | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 HuangTingjin
					HuangTingjin