[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:
HuangTingjin
2016-07-27 02:57:06 +00:00
parent 16b22667c6
commit 448771db51
7 changed files with 4466 additions and 4418 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -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,
@@ -168,22 +168,22 @@ enum{
}; };
typedef struct JpegParserContext { typedef struct JpegParserContext {
MppBufSlots packet_slots; MppBufSlots packet_slots;
MppBufSlots frame_slots; MppBufSlots frame_slots;
RK_S32 frame_slot_index; /* slot index for output */ RK_S32 frame_slot_index; /* slot index for output */
RK_U8 *recv_buffer; RK_U8 *recv_buffer;
JpegSyntaxParam *pSyntax; JpegSyntaxParam *pSyntax;
JpegDecImageInfo imageInfo; JpegDecImageInfo imageInfo;
RK_U32 streamLength; /* input stream length or buffer size */ RK_U32 streamLength; /* input stream length or buffer size */
RK_U32 bufferSize; /* input stream buffer size */ RK_U32 bufferSize; /* input stream buffer size */
RK_U32 decImageType; /* Full image or Thumbnail to be decoded */ RK_U32 decImageType; /* Full image or Thumbnail to be decoded */
RK_U32 sliceMbSet; /* slice mode: mcu rows to decode */ RK_U32 sliceMbSet; /* slice mode: mcu rows to decode */
RK_U32 color_conv; RK_U32 color_conv;
RK_U32 dri_en; RK_U32 dri_en;
MppPacket input_packet; MppPacket input_packet;
MppFrame output_frame; MppFrame output_frame;
RK_U32 is8190; RK_U32 is8190;
RK_U32 fuseBurned; RK_U32 fuseBurned;
RK_U32 minSupportedWidth; RK_U32 minSupportedWidth;
@@ -194,10 +194,10 @@ typedef struct JpegParserContext {
RK_U32 maxSupportedSliceSize; RK_U32 maxSupportedSliceSize;
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__ */

View File

@@ -39,53 +39,53 @@ extern RK_U32 jpegd_log;
#define JPEGD_ASSERT(val)\ #define JPEGD_ASSERT(val)\
do {\ do {\
if (JPEGD_DBG_ASSERT)\ if (JPEGD_DBG_ASSERT)\
{ mpp_assert(val); }\ { mpp_assert(val); }\
} while (0) } while (0)
//check function return //check function return
#define CHECK_FUN(val) \ #define CHECK_FUN(val) \
do{ \ do{ \
if((val) < 0) { \ if((val) < 0) { \
ret = (val); \ ret = (val); \
mpp_log("func return error(Line %d), ret:%d\n", __LINE__, ret); \ mpp_log("func return error(Line %d), ret:%d\n", __LINE__, ret); \
goto __FAILED; \ goto __FAILED; \
} \ } \
} while (0) } while (0)
//memory malloc check //memory malloc check
#define CHECK_MEM(val, ...)\ #define CHECK_MEM(val, ...)\
do{ if(!(val)) {\ do{ if(!(val)) {\
ret = MPP_ERR_MALLOC;\ ret = MPP_ERR_MALLOC;\
mpp_log("malloc buffer error(Line %d), pointer:%p\n", __LINE__, val);\ mpp_log("malloc buffer error(Line %d), pointer:%p\n", __LINE__, val);\
goto __FAILED;\ goto __FAILED;\
} } while (0) } } while (0)
#define JPEGD_VERBOSE_LOG(fmt, ...) \ #define JPEGD_VERBOSE_LOG(fmt, ...) \
do {\ do {\
if (JPEGD_VBE_LOG & jpegd_log)\ if (JPEGD_VBE_LOG & jpegd_log)\
{ mpp_log("[Verbose] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\ { mpp_log("[Verbose] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0) } while (0)
#define JPEGD_DEBUG_LOG(fmt, ...) \ #define JPEGD_DEBUG_LOG(fmt, ...) \
do {\ do {\
if (JPEGD_DBG_LOG & jpegd_log)\ if (JPEGD_DBG_LOG & jpegd_log)\
{ mpp_log("[Debug] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\ { mpp_log("[Debug] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0) } while (0)
#define JPEGD_INFO_LOG(fmt, ...) \ #define JPEGD_INFO_LOG(fmt, ...) \
do {\ do {\
if (JPEGD_INF_LOG & jpegd_log)\ if (JPEGD_INF_LOG & jpegd_log)\
{ mpp_log("[Info] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\ { mpp_log("[Info] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0) } while (0)
#define JPEGD_ERROR_LOG(fmt, ...) \ #define JPEGD_ERROR_LOG(fmt, ...) \
do {\ do {\
if (JPEGD_ERR_LOG & jpegd_log)\ if (JPEGD_ERR_LOG & jpegd_log)\
{ mpp_log("[Error] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\ { mpp_log("[Error] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0) } while (0)
MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task); MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task);

View File

@@ -1,73 +1,73 @@
/* /*
* *
* Copyright 2015 Rockchip Electronics Co. LTD * Copyright 2015 Rockchip Electronics Co. LTD
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef __JPEGD_SYNTAX__ #ifndef __JPEGD_SYNTAX__
#define __JPEGD_SYNTAX__ #define __JPEGD_SYNTAX__
#include "vpu_api.h" #include "vpu_api.h"
#define MIN_NUMBER_OF_COMPONENTS 1 #define MIN_NUMBER_OF_COMPONENTS 1
#define MAX_NUMBER_OF_COMPONENTS 3 #define MAX_NUMBER_OF_COMPONENTS 3
#define JPEGDEC_YCbCr400 0x080000U #define JPEGDEC_YCbCr400 0x080000U
#define JPEGDEC_YCbCr420_SEMIPLANAR 0x020001U #define JPEGDEC_YCbCr420_SEMIPLANAR 0x020001U
#define JPEGDEC_YCbCr422_SEMIPLANAR 0x010001U #define JPEGDEC_YCbCr422_SEMIPLANAR 0x010001U
#define JPEGDEC_YCbCr440 0x010004U #define JPEGDEC_YCbCr440 0x010004U
#define JPEGDEC_YCbCr411_SEMIPLANAR 0x100000U #define JPEGDEC_YCbCr411_SEMIPLANAR 0x100000U
#define JPEGDEC_YCbCr444_SEMIPLANAR 0x200000U #define JPEGDEC_YCbCr444_SEMIPLANAR 0x200000U
#define JPEGDEC_BASELINE 0x0 #define JPEGDEC_BASELINE 0x0
#define JPEGDEC_PROGRESSIVE 0x1 #define JPEGDEC_PROGRESSIVE 0x1
#define JPEGDEC_NONINTERLEAVED 0x2 #define JPEGDEC_NONINTERLEAVED 0x2
#define JPEGDEC_YUV400 0 #define JPEGDEC_YUV400 0
#define JPEGDEC_YUV420 2 #define JPEGDEC_YUV420 2
#define JPEGDEC_YUV422 3 #define JPEGDEC_YUV422 3
#define JPEGDEC_YUV444 4 #define JPEGDEC_YUV444 4
#define JPEGDEC_YUV440 5 #define JPEGDEC_YUV440 5
#define JPEGDEC_YUV411 6 #define JPEGDEC_YUV411 6
#define JPEGD_STREAM_BUFF_SIZE (10*1024*1024) #define JPEGD_STREAM_BUFF_SIZE (10*1024*1024)
#define JPEGDEC_BASELINE_TABLE_SIZE (544) #define JPEGDEC_BASELINE_TABLE_SIZE (544)
typedef enum { typedef enum {
JPEGDEC_SLICE_READY = 2, JPEGDEC_SLICE_READY = 2,
JPEGDEC_FRAME_READY = 1, JPEGDEC_FRAME_READY = 1,
JPEGDEC_STRM_PROCESSED = 3, JPEGDEC_STRM_PROCESSED = 3,
JPEGDEC_SCAN_PROCESSED = 4, JPEGDEC_SCAN_PROCESSED = 4,
JPEGDEC_OK = 0, JPEGDEC_OK = 0,
JPEGDEC_ERROR = -1, JPEGDEC_ERROR = -1,
JPEGDEC_UNSUPPORTED = -2, JPEGDEC_UNSUPPORTED = -2,
JPEGDEC_PARAM_ERROR = -3, JPEGDEC_PARAM_ERROR = -3,
JPEGDEC_MEMFAIL = -4, JPEGDEC_MEMFAIL = -4,
JPEGDEC_INITFAIL = -5, JPEGDEC_INITFAIL = -5,
JPEGDEC_INVALID_STREAM_LENGTH = -6, JPEGDEC_INVALID_STREAM_LENGTH = -6,
JPEGDEC_STRM_ERROR = -7, JPEGDEC_STRM_ERROR = -7,
JPEGDEC_INVALID_INPUT_BUFFER_SIZE = -8, JPEGDEC_INVALID_INPUT_BUFFER_SIZE = -8,
JPEGDEC_HW_RESERVED = -9, JPEGDEC_HW_RESERVED = -9,
JPEGDEC_INCREASE_INPUT_BUFFER = -10, JPEGDEC_INCREASE_INPUT_BUFFER = -10,
JPEGDEC_SLICE_MODE_UNSUPPORTED = -11, JPEGDEC_SLICE_MODE_UNSUPPORTED = -11,
JPEGDEC_DWL_HW_TIMEOUT = -253, JPEGDEC_DWL_HW_TIMEOUT = -253,
JPEGDEC_DWL_ERROR = -254, JPEGDEC_DWL_ERROR = -254,
JPEGDEC_HW_BUS_ERROR = -255, JPEGDEC_HW_BUS_ERROR = -255,
JPEGDEC_SYSTEM_ERROR = -256, JPEGDEC_SYSTEM_ERROR = -256,
JPEGDEC_FORMAT_NOT_SUPPORTED = -1000 JPEGDEC_FORMAT_NOT_SUPPORTED = -1000
} JpegDecRet; } JpegDecRet;
typedef struct { typedef struct {
RK_U32 C; /* Component id */ RK_U32 C; /* Component id */
RK_U32 H; /* Horizontal sampling factor */ RK_U32 H; /* Horizontal sampling factor */
@@ -78,15 +78,15 @@ typedef struct {
typedef struct { typedef struct {
RK_U8 *pStartOfStream; RK_U8 *pStartOfStream;
RK_U8 *pCurrPos; RK_U8 *pCurrPos;
RK_U32 streamBus; /* physical address */ RK_U32 streamBus; /* physical address */
RK_U32 bitPosInByte; RK_U32 bitPosInByte;
RK_U32 streamLength; RK_U32 streamLength;
RK_U32 readBits; RK_U32 readBits;
RK_U32 appnFlag; RK_U32 appnFlag;
RK_U32 thumbnail; RK_U32 thumbnail;
RK_U32 returnSosMarker; RK_U32 returnSosMarker;
} StreamStorage; } StreamStorage;
typedef struct { typedef struct {
RK_U8 *pStartOfImage; RK_U8 *pStartOfImage;
RK_U8 *pLum; RK_U8 *pLum;
@@ -100,8 +100,8 @@ typedef struct {
RK_U32 ready; RK_U32 ready;
RK_U32 columns[MAX_NUMBER_OF_COMPONENTS]; RK_U32 columns[MAX_NUMBER_OF_COMPONENTS];
RK_U32 pixelsPerRow[MAX_NUMBER_OF_COMPONENTS]; RK_U32 pixelsPerRow[MAX_NUMBER_OF_COMPONENTS];
} ImageData; } ImageData;
typedef struct { typedef struct {
RK_U32 Lf; RK_U32 Lf;
RK_U32 P; RK_U32 P;
@@ -130,8 +130,8 @@ typedef struct {
RK_U32 blocksPerRow[MAX_NUMBER_OF_COMPONENTS]; RK_U32 blocksPerRow[MAX_NUMBER_OF_COMPONENTS];
RK_U32 useAcOffset[MAX_NUMBER_OF_COMPONENTS]; RK_U32 useAcOffset[MAX_NUMBER_OF_COMPONENTS];
Components component[MAX_NUMBER_OF_COMPONENTS]; Components component[MAX_NUMBER_OF_COMPONENTS];
} FrameInfo; } FrameInfo;
typedef struct { typedef struct {
RK_U32 Ls; RK_U32 Ls;
RK_U32 Ns; RK_U32 Ns;
@@ -145,16 +145,16 @@ typedef struct {
RK_U32 index; RK_U32 index;
RK_S32 numIdctRows; RK_S32 numIdctRows;
RK_S32 pred[MAX_NUMBER_OF_COMPONENTS]; RK_S32 pred[MAX_NUMBER_OF_COMPONENTS];
} ScanInfo; } ScanInfo;
typedef struct { typedef struct {
RK_U32 sliceHeight; RK_U32 sliceHeight;
RK_U32 amountOfQTables; RK_U32 amountOfQTables;
RK_U32 yCbCrMode; RK_U32 yCbCrMode;
RK_U32 yCbCr422; RK_U32 yCbCr422;
RK_U32 column; RK_U32 column;
RK_U32 X; /* width */ RK_U32 X; /* width */
RK_U32 Y; /* height */ RK_U32 Y; /* height */
RK_U32 memSize; RK_U32 memSize;
RK_U32 SliceCount; RK_U32 SliceCount;
RK_U32 SliceReadyForPause; RK_U32 SliceReadyForPause;
@@ -210,8 +210,8 @@ typedef struct {
RK_U32 pfNeeded[MAX_NUMBER_OF_COMPONENTS]; RK_U32 pfNeeded[MAX_NUMBER_OF_COMPONENTS];
VPUMemLinear_t tmpStrm; VPUMemLinear_t tmpStrm;
} DecInfo; } DecInfo;
// TODO: The way to malloc buffer has been changed in MPP // TODO: The way to malloc buffer has been changed in MPP
typedef struct { typedef struct {
VPUMemLinear_t outLumaBuffer; VPUMemLinear_t outLumaBuffer;
@@ -226,8 +226,8 @@ typedef struct {
RK_U32 tableLength; RK_U32 tableLength;
RK_U32 start; RK_U32 start;
RK_U32 last; RK_U32 last;
} VlcTable; } VlcTable;
typedef struct { typedef struct {
RK_U32 Lh; RK_U32 Lh;
VlcTable acTable0; VlcTable acTable0;
@@ -248,8 +248,8 @@ typedef struct {
RK_U32 table2[64]; RK_U32 table2[64];
RK_U32 table3[64]; RK_U32 table3[64];
RK_U32 *table; RK_U32 *table;
} QuantTables; } QuantTables;
/* Control interface between decoder and pp */ /* Control interface between decoder and pp */
/* decoder writes, pp read-only */ /* decoder writes, pp read-only */
typedef struct DecPpInterface_ { typedef struct DecPpInterface_ {
@@ -291,70 +291,70 @@ typedef struct DecPpInterface_ {
RK_U32 rangeMapYCoeff; RK_U32 rangeMapYCoeff;
RK_U32 rangeMapCEnable; RK_U32 rangeMapCEnable;
RK_U32 rangeMapCCoeff; RK_U32 rangeMapCCoeff;
} DecPpInterface; } DecPpInterface;
typedef struct { typedef struct {
int enable; int enable;
int outFomart; /* =0,RGB565;=1,ARGB 8888 */ int outFomart; /* =0,RGB565;=1,ARGB 8888 */
//int destWidth; //int destWidth;
//int destHeight; //int destHeight;
int scale_denom; int scale_denom;
int shouldDither; int shouldDither;
int cropX; int cropX;
int cropY; int cropY;
int cropW; int cropW;
int cropH; int cropH;
} PostProcessInfo; } PostProcessInfo;
/* Image information */ /* Image information */
typedef struct { typedef struct {
RK_U32 displayWidth; RK_U32 displayWidth;
RK_U32 displayHeight; RK_U32 displayHeight;
RK_U32 outputWidth; /* Number of pixels/line in the image */ RK_U32 outputWidth; /* Number of pixels/line in the image */
RK_U32 outputHeight; /* Number of lines in in the image */ RK_U32 outputHeight; /* Number of lines in in the image */
RK_U32 version; RK_U32 version;
RK_U32 units; RK_U32 units;
RK_U32 xDensity; RK_U32 xDensity;
RK_U32 yDensity; RK_U32 yDensity;
RK_U32 outputFormat; /* JPEGDEC_YCbCr400 RK_U32 outputFormat; /* JPEGDEC_YCbCr400
* JPEGDEC_YCbCr420 * JPEGDEC_YCbCr420
* JPEGDEC_YCbCr422 * JPEGDEC_YCbCr422
*/ */
RK_U32 codingMode; /* JPEGDEC_BASELINE RK_U32 codingMode; /* JPEGDEC_BASELINE
* JPEGDEC_PROGRESSIVE * JPEGDEC_PROGRESSIVE
* JPEGDEC_NONINTERLEAVED * JPEGDEC_NONINTERLEAVED
*/ */
RK_U32 thumbnailType; /* Thumbnail exist or not or not supported */ RK_U32 thumbnailType; /* Thumbnail exist or not or not supported */
RK_U32 displayWidthThumb; RK_U32 displayWidthThumb;
RK_U32 displayHeightThumb; RK_U32 displayHeightThumb;
RK_U32 outputWidthThumb; /* Number of pixels/line in the image */ RK_U32 outputWidthThumb; /* Number of pixels/line in the image */
RK_U32 outputHeightThumb; /* Number of lines in in the image */ RK_U32 outputHeightThumb; /* Number of lines in in the image */
RK_U32 outputFormatThumb; /* JPEGDEC_YCbCr400 RK_U32 outputFormatThumb; /* JPEGDEC_YCbCr400
* JPEGDEC_YCbCr420 * JPEGDEC_YCbCr420
* JPEGDEC_YCbCr422 * JPEGDEC_YCbCr422
*/ */
RK_U32 codingModeThumb; /* JPEGDEC_BASELINE RK_U32 codingModeThumb; /* JPEGDEC_BASELINE
* JPEGDEC_PROGRESSIVE * JPEGDEC_PROGRESSIVE
* JPEGDEC_NONINTERLEAVED * JPEGDEC_NONINTERLEAVED
*/ */
} JpegDecImageInfo; } JpegDecImageInfo;
typedef struct JpegSyntaxParam{ typedef struct JpegSyntaxParam {
StreamStorage stream; StreamStorage stream;
FrameInfo frame; FrameInfo frame;
ImageData image; ImageData image;
ScanInfo scan; ScanInfo scan;
DecInfo info; DecInfo info;
HuffmanTables vlc; HuffmanTables vlc;
QuantTables quant; QuantTables quant;
JpegDecImageInfo imageInfo; JpegDecImageInfo imageInfo;
RK_U32 ppInputFomart; RK_U32 ppInputFomart;
PostProcessInfo ppInfo; PostProcessInfo ppInfo;
RK_U32 is8190; RK_U32 is8190;
RK_U32 fuseBurned; RK_U32 fuseBurned;
RK_U32 ppScaleW; RK_U32 ppScaleW;
RK_U32 ppScaleH; RK_U32 ppScaleH;
RK_U32 minSupportedWidth; RK_U32 minSupportedWidth;
RK_U32 minSupportedHeight; RK_U32 minSupportedHeight;
RK_U32 maxSupportedWidth; RK_U32 maxSupportedWidth;
@@ -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__*/

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef __HAL_JPEGD_REG_H__ #ifndef __HAL_JPEGD_REG_H__
#define __HAL_JPEGD_REG_H__ #define __HAL_JPEGD_REG_H__
@@ -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;
@@ -78,179 +78,179 @@ typedef struct JpegRegSet{
RK_U32 sw_pp_axi_rd_id : 8; RK_U32 sw_pp_axi_rd_id : 8;
RK_U32 sw_pp_axi_wr_id : 8; RK_U32 sw_pp_axi_wr_id : 8;
} reg0; } reg0;
struct {
RK_U32 sw_color_coeffa1 : 10;
RK_U32 sw_color_coeffa2 : 10;
RK_U32 sw_color_coeffb : 10;
} reg1;
struct {
RK_U32 sw_color_coeffc : 10;
RK_U32 sw_color_coeffd : 10;
RK_U32 sw_color_coeffe : 10;
} reg2;
struct { struct {
RK_U32 sw_color_coeffa1 : 10;
RK_U32 sw_color_coeffa2 : 10;
RK_U32 sw_color_coeffb : 10;
} reg1;
struct {
RK_U32 sw_color_coeffc : 10;
RK_U32 sw_color_coeffd : 10;
RK_U32 sw_color_coeffe : 10;
} reg2;
struct {
RK_U32 sw_pp_color_coefff : 8; RK_U32 sw_pp_color_coefff : 8;
} reg3; } reg3;
struct {
RK_U32 sw_scale_wratio : 18;
RK_U32 sw_hor_scale_mode : 2;
RK_U32 sw_ver_scale_mode : 2;
} reg4;
struct {
RK_U32 sw_scale_hratio : 18;
} reg5;
struct {
RK_U32 sw_wscale_invra : 16;
RK_U32 sw_hscale_invra : 16;
} reg6;
RK_U32 reg7;
RK_U32 reg8;
RK_U32 reg9_r_mask;
RK_U32 reg10_g_mask;
RK_U32 reg11_b_mask;
RK_U32 reg12_pp_bot_yin_base;
RK_U32 reg13_pp_bot_cin_base;
struct { struct {
RK_U32 sw_scale_wratio : 18;
RK_U32 sw_hor_scale_mode : 2;
RK_U32 sw_ver_scale_mode : 2;
} reg4;
struct {
RK_U32 sw_scale_hratio : 18;
} reg5;
struct {
RK_U32 sw_wscale_invra : 16;
RK_U32 sw_hscale_invra : 16;
} reg6;
RK_U32 reg7;
RK_U32 reg8;
RK_U32 reg9_r_mask;
RK_U32 reg10_g_mask;
RK_U32 reg11_b_mask;
RK_U32 reg12_pp_bot_yin_base;
RK_U32 reg13_pp_bot_cin_base;
struct {
RK_U32 sw_crop_startx : 9; RK_U32 sw_crop_startx : 9;
RK_U32 sw_crop_starty_ext : 3; RK_U32 sw_crop_starty_ext : 3;
RK_U32 sw_reserved_1 : 4; RK_U32 sw_reserved_1 : 4;
RK_U32 sw_crop_starty : 8; RK_U32 sw_crop_starty : 8;
RK_U32 sw_crop_startx_ext : 3; RK_U32 sw_crop_startx_ext : 3;
RK_U32 sw_reserved_2 : 1; RK_U32 sw_reserved_2 : 1;
RK_U32 sw_pp_crop8_d_e : 1; RK_U32 sw_pp_crop8_d_e : 1;
RK_U32 sw_pp_crop8_r_e : 1; RK_U32 sw_pp_crop8_r_e : 1;
} reg14; } reg14;
struct { struct {
RK_U32 sw_rangemap_coef_y : 5; RK_U32 sw_rangemap_coef_y : 5;
RK_U32 sw_ycbcr_range : 1; RK_U32 sw_ycbcr_range : 1;
RK_U32 sw_reserved_1 : 2; RK_U32 sw_reserved_1 : 2;
RK_U32 sw_rangemap_coef_c : 5; RK_U32 sw_rangemap_coef_c : 5;
} reg15; } reg15;
struct {
RK_U32 sw_rgb_r_padd : 5;
RK_U32 sw_reserved_1 : 3;
RK_U32 sw_rgb_g_padd : 5;
RK_U32 sw_reserved_2 : 3;
RK_U32 sw_rgb_b_padd : 5;
} reg16;
RK_U32 reg17;
RK_U32 reg18_pp_in_lu_base;
RK_U32 reg19;
RK_U32 reg20;
RK_U32 reg21_pp_out_lu_base;
RK_U32 reg22_pp_out_ch_base;
RK_U32 reg23;
RK_U32 reg24;
RK_U32 reg25;
RK_U32 reg26;
RK_U32 reg27;
RK_U32 reg28;
RK_U32 reg29;
RK_U32 reg30;
struct { struct {
RK_U32 sw_rgb_r_padd : 5;
RK_U32 sw_reserved_1 : 3;
RK_U32 sw_rgb_g_padd : 5;
RK_U32 sw_reserved_2 : 3;
RK_U32 sw_rgb_b_padd : 5;
} reg16;
RK_U32 reg17;
RK_U32 reg18_pp_in_lu_base;
RK_U32 reg19;
RK_U32 reg20;
RK_U32 reg21_pp_out_lu_base;
RK_U32 reg22_pp_out_ch_base;
RK_U32 reg23;
RK_U32 reg24;
RK_U32 reg25;
RK_U32 reg26;
RK_U32 reg27;
RK_U32 reg28;
RK_U32 reg29;
RK_U32 reg30;
struct {
RK_U32 sw_contrast_thr1 : 8; RK_U32 sw_contrast_thr1 : 8;
RK_U32 sw_contrast_thr2 : 8; RK_U32 sw_contrast_thr2 : 8;
} reg31; } reg31;
struct {
RK_U32 sw_contrast_off1 : 10;
RK_U32 sw_reserved_1 : 6;
RK_U32 sw_contrast_off2 : 10;
} reg32;
RK_U32 reg33;
struct { struct {
RK_U32 sw_contrast_off1 : 10;
RK_U32 sw_reserved_1 : 6;
RK_U32 sw_contrast_off2 : 10;
} reg32;
RK_U32 reg33;
struct {
RK_U32 sw_pp_in_width : 9; RK_U32 sw_pp_in_width : 9;
RK_U32 sw_pp_in_w_ext : 3; RK_U32 sw_pp_in_w_ext : 3;
RK_U32 sw_ext_orig_width : 9; RK_U32 sw_ext_orig_width : 9;
RK_U32 sw_pp_in_height : 8; RK_U32 sw_pp_in_height : 8;
RK_U32 sw_pp_in_h_ext : 3; RK_U32 sw_pp_in_h_ext : 3;
} reg34; } reg34;
struct { struct {
RK_U32 sw_pp_out_width : 11; RK_U32 sw_pp_out_width : 11;
RK_U32 sw_reserved_1 : 5; RK_U32 sw_reserved_1 : 5;
RK_U32 sw_pp_out_height : 11; RK_U32 sw_pp_out_height : 11;
} reg35; } reg35;
struct { struct {
RK_U32 sw_dither_select_r : 2; RK_U32 sw_dither_select_r : 2;
RK_U32 sw_dither_select_g : 2; RK_U32 sw_dither_select_g : 2;
RK_U32 sw_dither_select_b : 2; RK_U32 sw_dither_select_b : 2;
} reg36; } reg36;
struct { struct {
RK_U32 sw_pp_in_endian : 1; RK_U32 sw_pp_in_endian : 1;
RK_U32 sw_pp_in_a1_endian : 1; RK_U32 sw_pp_in_a1_endian : 1;
RK_U32 sw_pp_in_a2_endsel : 1; RK_U32 sw_pp_in_a2_endsel : 1;
RK_U32 sw_pp_out_endian : 1; RK_U32 sw_pp_out_endian : 1;
RK_U32 sw_rgb_pix_in32 : 1; RK_U32 sw_rgb_pix_in32 : 1;
RK_U32 sw_reserved_1 : 3; RK_U32 sw_reserved_1 : 3;
RK_U32 sw_pp_in_swap32_e : 1; RK_U32 sw_pp_in_swap32_e : 1;
RK_U32 sw_pp_in_a1_swap32 : 1; RK_U32 sw_pp_in_a1_swap32 : 1;
RK_U32 sw_pp_out_swap16_e : 1; RK_U32 sw_pp_out_swap16_e : 1;
RK_U32 sw_pp_out_swap32_e : 1; RK_U32 sw_pp_out_swap32_e : 1;
RK_U32 sw_reserved_2 : 4; RK_U32 sw_reserved_2 : 4;
RK_U32 sw_pp_in_start_ch : 1; RK_U32 sw_pp_in_start_ch : 1;
RK_U32 sw_pp_out_start_ch : 1; RK_U32 sw_pp_out_start_ch : 1;
RK_U32 sw_pp_in_cr_first : 1; RK_U32 sw_pp_in_cr_first : 1;
RK_U32 sw_pp_out_cr_first : 1; RK_U32 sw_pp_out_cr_first : 1;
RK_U32 sw_reserved_3 : 4; RK_U32 sw_reserved_3 : 4;
RK_U32 sw_pp_in_struct : 3; RK_U32 sw_pp_in_struct : 3;
} reg37; } reg37;
struct { struct {
RK_U32 sw_rotation_mode : 3; RK_U32 sw_rotation_mode : 3;
RK_U32 sw_reserved_1 : 5; RK_U32 sw_reserved_1 : 5;
RK_U32 sw_pp_in_format : 3; RK_U32 sw_pp_in_format : 3;
RK_U32 sw_pp_out_format : 3; RK_U32 sw_pp_out_format : 3;
RK_U32 sw_reserved_2 : 2; RK_U32 sw_reserved_2 : 2;
RK_U32 sw_pp_in_format_es : 3; RK_U32 sw_pp_in_format_es : 3;
} reg38; } reg38;
struct { struct {
RK_U32 sw_display_width : 12; RK_U32 sw_display_width : 12;
} reg39; } reg39;
RK_U32 reg40; RK_U32 reg40;
struct { struct {
RK_U32 sw_pp_e : 1; RK_U32 sw_pp_e : 1;
RK_U32 sw_deint_blend_e : 1; RK_U32 sw_deint_blend_e : 1;
RK_U32 sw_deint_e : 1; RK_U32 sw_deint_e : 1;
RK_U32 sw_pp_clk_gate_e : 1; RK_U32 sw_pp_clk_gate_e : 1;
RK_U32 sw_pp_pipeline_e : 1; RK_U32 sw_pp_pipeline_e : 1;
RK_U32 sw_reserved_1 : 3; RK_U32 sw_reserved_1 : 3;
RK_U32 sw_rangemap_y_e : 1; RK_U32 sw_rangemap_y_e : 1;
RK_U32 sw_rangemap_c_e : 1; RK_U32 sw_rangemap_c_e : 1;
RK_U32 sw_reserved_2 : 6; RK_U32 sw_reserved_2 : 6;
RK_U32 sw_pp_data_disc_e : 1; RK_U32 sw_pp_data_disc_e : 1;
RK_U32 sw_reserved_3 : 3; RK_U32 sw_reserved_3 : 3;
RK_U32 sw_mask1_e : 1; RK_U32 sw_mask1_e : 1;
RK_U32 sw_mask2_e : 1; RK_U32 sw_mask2_e : 1;
RK_U32 sw_mask1_ablend_e : 1; RK_U32 sw_mask1_ablend_e : 1;
RK_U32 sw_mask2_ablend_e : 1; RK_U32 sw_mask2_ablend_e : 1;
RK_U32 sw_up_cross_e : 1; RK_U32 sw_up_cross_e : 1;
RK_U32 sw_down_cross_e : 1; RK_U32 sw_down_cross_e : 1;
RK_U32 sw_left_cross_e : 1; RK_U32 sw_left_cross_e : 1;
RK_U32 sw_right_cross_e : 1; RK_U32 sw_right_cross_e : 1;
RK_U32 sw_pp_ahb_hlock_e : 1; RK_U32 sw_pp_ahb_hlock_e : 1;
} reg41; } reg41;
RK_U32 ppReg2[8]; RK_U32 ppReg2[8];
struct { struct {
RK_U32 sw_dec_out_tiled_e : 1; RK_U32 sw_dec_out_tiled_e : 1;
RK_U32 sw_dec_latency : 6; RK_U32 sw_dec_latency : 6;
@@ -433,12 +433,12 @@ typedef struct JpegRegSet{
RK_U32 sw_cb_ac_vlctable : 1; RK_U32 sw_cb_ac_vlctable : 1;
RK_U32 sw_cr_ac_vlctable : 1; RK_U32 sw_cr_ac_vlctable : 1;
RK_U32 sw_jpeg_stream_all : 1; RK_U32 sw_jpeg_stream_all : 1;
RK_U32 sw_jpeg_filright_e : 1; RK_U32 sw_jpeg_filright_e : 1;
RK_U32 sw_jpeg_mode : 3; RK_U32 sw_jpeg_mode : 3;
RK_U32 sw_jpeg_qtables : 2; RK_U32 sw_jpeg_qtables : 2;
RK_U32 sw_reserved_1 : 12; RK_U32 sw_reserved_1 : 12;
RK_U32 sw_sync_marker_e : 1; RK_U32 sw_sync_marker_e : 1;
RK_U32 sw_strm_start_bit : 6; RK_U32 sw_strm_start_bit : 6;
} reg122; } reg122;
struct { struct {
@@ -520,112 +520,112 @@ typedef struct JpegRegSet{
} reg133; } reg133;
struct { struct {
RK_U32 sw_ac1_code1_cnt : 2; RK_U32 sw_ac1_code1_cnt : 2;
RK_U32 sw_reserved_1 : 1; RK_U32 sw_reserved_1 : 1;
RK_U32 sw_ac1_code2_cnt : 3; RK_U32 sw_ac1_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1; RK_U32 sw_reserved_2 : 1;
RK_U32 sw_ac1_code3_cnt : 4; RK_U32 sw_ac1_code3_cnt : 4;
RK_U32 sw_ac1_code4_cnt : 5; RK_U32 sw_ac1_code4_cnt : 5;
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 {
RK_U32 sw_ac1_code7_cnt : 8;
RK_U32 sw_ac1_code8_cnt : 8;
RK_U32 sw_ac1_code9_cnt : 8;
RK_U32 sw_ac1_code10_cnt : 8;
}reg135;
struct { struct {
RK_U32 sw_ac1_code11_cnt : 8; RK_U32 sw_ac1_code7_cnt : 8;
RK_U32 sw_ac1_code12_cnt : 8; RK_U32 sw_ac1_code8_cnt : 8;
RK_U32 sw_ac1_code13_cnt : 8; RK_U32 sw_ac1_code9_cnt : 8;
RK_U32 sw_ac1_code14_cnt : 8; RK_U32 sw_ac1_code10_cnt : 8;
}reg136; } reg135;
struct { struct {
RK_U32 sw_ac1_code15_cnt : 8; RK_U32 sw_ac1_code11_cnt : 8;
RK_U32 sw_ac1_code16_cnt : 8; RK_U32 sw_ac1_code12_cnt : 8;
RK_U32 sw_ac2_code1_cnt : 2; RK_U32 sw_ac1_code13_cnt : 8;
RK_U32 sw_reserved_1 : 1; RK_U32 sw_ac1_code14_cnt : 8;
RK_U32 sw_ac2_code2_cnt : 3; } reg136;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_ac2_code3_cnt : 4; struct {
RK_U32 sw_ac2_code4_cnt : 5; RK_U32 sw_ac1_code15_cnt : 8;
RK_U32 sw_ac1_code16_cnt : 8;
RK_U32 sw_ac2_code1_cnt : 2;
RK_U32 sw_reserved_1 : 1;
RK_U32 sw_ac2_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_ac2_code3_cnt : 4;
RK_U32 sw_ac2_code4_cnt : 5;
} reg137; } reg137;
struct { struct {
RK_U32 sw_ac2_code5_cnt : 6; RK_U32 sw_ac2_code5_cnt : 6;
RK_U32 sw_reserved_1 : 2; RK_U32 sw_reserved_1 : 2;
RK_U32 sw_ac2_code6_cnt : 7; RK_U32 sw_ac2_code6_cnt : 7;
RK_U32 sw_reserved_2 : 1; RK_U32 sw_reserved_2 : 1;
RK_U32 sw_ac2_code7_cnt : 8; RK_U32 sw_ac2_code7_cnt : 8;
RK_U32 sw_ac2_code8_cnt : 8; RK_U32 sw_ac2_code8_cnt : 8;
} reg138; } reg138;
struct { struct {
RK_U32 sw_ac2_code9_cnt : 8; RK_U32 sw_ac2_code9_cnt : 8;
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;
RK_U32 sw_reserved_1 : 2; RK_U32 sw_reserved_1 : 2;
RK_U32 sw_dc1_code2_cnt : 3; RK_U32 sw_dc1_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1; RK_U32 sw_reserved_2 : 1;
RK_U32 sw_dc1_code3_cnt : 4; RK_U32 sw_dc1_code3_cnt : 4;
RK_U32 sw_dc1_code4_cnt : 4; RK_U32 sw_dc1_code4_cnt : 4;
RK_U32 sw_dc1_code5_cnt : 4; RK_U32 sw_dc1_code5_cnt : 4;
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;
RK_U32 sw_dc1_code10_cnt : 4; RK_U32 sw_dc1_code10_cnt : 4;
RK_U32 sw_dc1_code11_cnt : 4; RK_U32 sw_dc1_code11_cnt : 4;
RK_U32 sw_dc1_code12_cnt : 4; RK_U32 sw_dc1_code12_cnt : 4;
RK_U32 sw_dc1_code13_cnt : 4; RK_U32 sw_dc1_code13_cnt : 4;
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;
RK_U32 sw_reserved_1 : 2; RK_U32 sw_reserved_1 : 2;
RK_U32 sw_dc2_code2_cnt : 3; RK_U32 sw_dc2_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1; RK_U32 sw_reserved_2 : 1;
RK_U32 sw_dc2_code3_cnt : 4; RK_U32 sw_dc2_code3_cnt : 4;
RK_U32 sw_dc2_code4_cnt : 4; RK_U32 sw_dc2_code4_cnt : 4;
RK_U32 sw_dc2_code5_cnt : 4; RK_U32 sw_dc2_code5_cnt : 4;
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;
RK_U32 sw_dc2_code10_cnt : 4; RK_U32 sw_dc2_code10_cnt : 4;
RK_U32 sw_dc2_code11_cnt : 4; RK_U32 sw_dc2_code11_cnt : 4;
RK_U32 sw_dc2_code12_cnt : 4; RK_U32 sw_dc2_code12_cnt : 4;
RK_U32 sw_dc2_code13_cnt : 4; RK_U32 sw_dc2_code13_cnt : 4;
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];
@@ -710,14 +710,14 @@ typedef struct JpegHalContext {
JpegRegSet regs; JpegRegSet regs;
MppBufferGroup group; MppBufferGroup group;
MppBuffer frame_buf; MppBuffer frame_buf;
MppBuffer pTableBase; MppBuffer pTableBase;
RK_U32 hal_debug_enable;
RK_U32 frame_count;
RK_U32 output_yuv_count;
RK_U32 hal_debug_enable;
RK_U32 frame_count;
RK_U32 output_yuv_count;
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__ */

View File

@@ -67,17 +67,17 @@ typedef struct jpegdDemoCtx {
MppDec api; MppDec api;
HalDecTask task; HalDecTask task;
MppBuffer pkt_buf; MppBuffer pkt_buf;
MppBuffer pic_buf; MppBuffer pic_buf;
MppBufferGroup frmbuf_grp; MppBufferGroup frmbuf_grp;
MppBufferGroup strmbuf_grp; MppBufferGroup strmbuf_grp;
MppPacket pkt; MppPacket pkt;
FILE* pOutFile; FILE* pOutFile;
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"},
@@ -95,14 +95,14 @@ MPP_RET jpegd_readbytes_from_file(RK_U8* buf, RK_S32 aBytes, FILE* fp)
if ((NULL == buf) || (NULL == fp) || (0 == aBytes)) { if ((NULL == buf) || (NULL == fp) || (0 == aBytes)) {
return -1; return -1;
} }
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;
} }
mpp_log("read %d bytes from file sucessfully, the first 4 bytes: %08x", rd_bytes, *((RK_U32*)buf)); mpp_log("read %d bytes from file sucessfully, the first 4 bytes: %08x", rd_bytes, *((RK_U32*)buf));
return ret; return ret;
} }
@@ -126,13 +126,13 @@ 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;
} }
static RK_S32 jpeg_parse_options(int argc, char **argv, parserDemoCmdCtx* cmdCxt) static RK_S32 jpeg_parse_options(int argc, char **argv, parserDemoCmdCtx* cmdCxt)
{ {
mpp_log("jpeg_parse_options enter\n"); mpp_log("jpeg_parse_options enter\n");
const char *opt; const char *opt;
RK_S32 optindex, handleoptions = 1, ret = 0; RK_S32 optindex, handleoptions = 1, ret = 0;
@@ -235,13 +235,13 @@ PARSE_OPINIONS_OUT:
jpeg_show_usage(); jpeg_show_usage();
return MPP_ERR_STREAM; return MPP_ERR_STREAM;
} }
mpp_log("jpeg_parse_options exit\n"); mpp_log("jpeg_parse_options exit\n");
return ret; return ret;
} }
MPP_RET jpegd_test_deinit(jpegdDemoCtx *ctx) MPP_RET jpegd_test_deinit(jpegdDemoCtx *ctx)
{ {
FUN_TEST("Enter"); FUN_TEST("Enter");
MppDec *pApi = &(ctx->api); MppDec *pApi = &(ctx->api);
if (pApi->parser) { if (pApi->parser) {
parser_deinit(pApi->parser); parser_deinit(pApi->parser);
@@ -271,275 +271,275 @@ 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;
} }
FUN_TEST("Exit"); FUN_TEST("Exit");
return MPP_OK; return MPP_OK;
} }
MPP_RET jpegd_test_init(parserDemoCmdCtx *cmd, jpegdDemoCtx *ctx) MPP_RET jpegd_test_init(parserDemoCmdCtx *cmd, jpegdDemoCtx *ctx)
{ {
FUN_TEST("Enter"); FUN_TEST("Enter");
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
MppDec *pMppDec = NULL; MppDec *pMppDec = NULL;
ParserCfg parser_cfg; ParserCfg parser_cfg;
MppHalCfg hal_cfg; MppHalCfg hal_cfg;
memset(ctx, 0, sizeof(jpegdDemoCtx)); memset(ctx, 0, sizeof(jpegdDemoCtx));
ctx->cfg = cmd; ctx->cfg = cmd;
//demo configure
ctx->pOutFile = fopen("/data/spurs.yuv", "wb+");
if(NULL == ctx->pOutFile){
JPEGD_ERROR_LOG("create spurs.yuv failed");
}
//malloc buffers for software //demo configure
CHECK_MEM(ctx->strmbuf = mpp_malloc_size(RK_U8, JPEGD_STREAM_BUFF_SIZE)); ctx->pOutFile = fopen("/data/spurs.yuv", "wb+");
if (NULL == ctx->pOutFile) {
//malloc buffers for hardware JPEGD_ERROR_LOG("create spurs.yuv failed");
if (ctx->frmbuf_grp == NULL) { }
ret = mpp_buffer_group_get_internal(&ctx->frmbuf_grp, MPP_BUFFER_TYPE_ION);
if (MPP_OK != ret) {
mpp_err("frmbuf_grp: jpegd mpp_buffer_group_get_internal failed\n");
goto __FAILED;
}
}
if (ctx->strmbuf_grp == NULL) {
ret = mpp_buffer_group_get_internal(&ctx->strmbuf_grp, MPP_BUFFER_TYPE_ION);
if (MPP_OK != ret) {
mpp_err("strmbuf_grp: jpegd mpp_buffer_group_get_internal failed\n");
goto __FAILED;
}
}
//api config
pMppDec = &ctx->api;
pMppDec->coding = MPP_VIDEO_CodingMJPEG;
CHECK_FUN(mpp_buf_slot_init(&pMppDec->frame_slots)); //malloc buffers for software
CHECK_MEM(pMppDec->frame_slots); CHECK_MEM(ctx->strmbuf = mpp_malloc_size(RK_U8, JPEGD_STREAM_BUFF_SIZE));
mpp_buf_slot_setup(pMppDec->frame_slots, 2);
CHECK_FUN(mpp_buf_slot_init(&pMppDec->packet_slots)); //malloc buffers for hardware
CHECK_MEM(pMppDec->packet_slots); if (ctx->frmbuf_grp == NULL) {
mpp_buf_slot_setup(pMppDec->packet_slots, 2); ret = mpp_buffer_group_get_internal(&ctx->frmbuf_grp, MPP_BUFFER_TYPE_ION);
if (MPP_OK != ret) {
mpp_err("frmbuf_grp: jpegd mpp_buffer_group_get_internal failed\n");
goto __FAILED;
}
}
if (ctx->strmbuf_grp == NULL) {
ret = mpp_buffer_group_get_internal(&ctx->strmbuf_grp, MPP_BUFFER_TYPE_ION);
if (MPP_OK != ret) {
mpp_err("strmbuf_grp: jpegd mpp_buffer_group_get_internal failed\n");
goto __FAILED;
}
}
//parser config //api config
memset(&parser_cfg, 0, sizeof(parser_cfg)); pMppDec = &ctx->api;
parser_cfg.coding = pMppDec->coding; pMppDec->coding = MPP_VIDEO_CodingMJPEG;
parser_cfg.frame_slots = pMppDec->frame_slots;
parser_cfg.packet_slots = pMppDec->packet_slots;
parser_cfg.task_count = 2;
parser_cfg.need_split = 0;
CHECK_FUN(parser_init(&pMppDec->parser, &parser_cfg));
//hal config CHECK_FUN(mpp_buf_slot_init(&pMppDec->frame_slots));
memset(&hal_cfg, 0, sizeof(hal_cfg)); CHECK_MEM(pMppDec->frame_slots);
hal_cfg.type = MPP_CTX_DEC; mpp_buf_slot_setup(pMppDec->frame_slots, 2);
hal_cfg.coding = pMppDec->coding;
hal_cfg.work_mode = HAL_MODE_LIBVPU;
{
RK_U32 hal_device_id = 0;
//mpp_env_get_u32("h264d_chg_org", &hal_device_id, 1);
hal_device_id = 0;
if (hal_device_id == 1) {
hal_cfg.device_id = HAL_RKVDEC;
} else {
hal_cfg.device_id = HAL_VDPU;
}
}
hal_cfg.frame_slots = pMppDec->frame_slots;
hal_cfg.packet_slots = pMppDec->packet_slots;
hal_cfg.task_count = parser_cfg.task_count;
CHECK_FUN(mpp_hal_init(&pMppDec->hal, &hal_cfg));
pMppDec->tasks = hal_cfg.tasks;
memset(&ctx->task, 0, sizeof(ctx->task)); CHECK_FUN(mpp_buf_slot_init(&pMppDec->packet_slots));
memset(ctx->task.refer, -1, sizeof(ctx->task.refer)); CHECK_MEM(pMppDec->packet_slots);
ctx->task.input = -1; mpp_buf_slot_setup(pMppDec->packet_slots, 2);
FUN_TEST("Exit"); //parser config
return MPP_OK; memset(&parser_cfg, 0, sizeof(parser_cfg));
parser_cfg.coding = pMppDec->coding;
parser_cfg.frame_slots = pMppDec->frame_slots;
parser_cfg.packet_slots = pMppDec->packet_slots;
parser_cfg.task_count = 2;
parser_cfg.need_split = 0;
CHECK_FUN(parser_init(&pMppDec->parser, &parser_cfg));
//hal config
memset(&hal_cfg, 0, sizeof(hal_cfg));
hal_cfg.type = MPP_CTX_DEC;
hal_cfg.coding = pMppDec->coding;
hal_cfg.work_mode = HAL_MODE_LIBVPU;
{
RK_U32 hal_device_id = 0;
//mpp_env_get_u32("h264d_chg_org", &hal_device_id, 1);
hal_device_id = 0;
if (hal_device_id == 1) {
hal_cfg.device_id = HAL_RKVDEC;
} else {
hal_cfg.device_id = HAL_VDPU;
}
}
hal_cfg.frame_slots = pMppDec->frame_slots;
hal_cfg.packet_slots = pMppDec->packet_slots;
hal_cfg.task_count = parser_cfg.task_count;
CHECK_FUN(mpp_hal_init(&pMppDec->hal, &hal_cfg));
pMppDec->tasks = hal_cfg.tasks;
memset(&ctx->task, 0, sizeof(ctx->task));
memset(ctx->task.refer, -1, sizeof(ctx->task.refer));
ctx->task.input = -1;
FUN_TEST("Exit");
return MPP_OK;
__FAILED: __FAILED:
FUN_TEST("Exit"); FUN_TEST("Exit");
return ret; return ret;
} }
MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd) MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd)
{ {
FUN_TEST("Enter"); FUN_TEST("Enter");
MPP_RET ret = MPP_OK; MPP_RET ret = MPP_OK;
MppDec *pMppDec = NULL; MppDec *pMppDec = NULL;
HalDecTask *curtask = NULL; HalDecTask *curtask = NULL;
jpegdDemoCtx DemoCtx; jpegdDemoCtx DemoCtx;
FILE* pInFile = NULL; FILE* pInFile = NULL;
RK_S32 fileSize = 0; RK_S32 fileSize = 0;
// 1.jpegd_test_init // 1.jpegd_test_init
jpegd_test_init(cmd, &DemoCtx); jpegd_test_init(cmd, &DemoCtx);
pMppDec = &DemoCtx.api; pMppDec = &DemoCtx.api;
curtask = &DemoCtx.task; curtask = &DemoCtx.task;
do { do {
RK_S32 slot_idx = 0; RK_S32 slot_idx = 0;
if (cmd->have_input) { if (cmd->have_input) {
mpp_log("input bitstream w: %d, h: %d, path: %s\n", mpp_log("input bitstream w: %d, h: %d, path: %s\n",
cmd->width, cmd->height, cmd->input_file); cmd->width, cmd->height, cmd->input_file);
pInFile = fopen(cmd->input_file, "rb");
if (pInFile == NULL) {
mpp_log("input file not exsist\n");
goto __FAILED;
}
} else {
mpp_log("please set input bitstream file\n");
goto __FAILED;
}
fseek(pInFile, 0L, SEEK_END); pInFile = fopen(cmd->input_file, "rb");
fileSize = ftell(pInFile); if (pInFile == NULL) {
fseek(pInFile, 0L, SEEK_SET); mpp_log("input file not exsist\n");
goto __FAILED;
}
} else {
mpp_log("please set input bitstream file\n");
goto __FAILED;
}
// 2.jpegd_readbytes_from_file fseek(pInFile, 0L, SEEK_END);
ret = jpegd_readbytes_from_file(DemoCtx.strmbuf, fileSize, pInFile); fileSize = ftell(pInFile);
if(ret != MPP_OK){ fseek(pInFile, 0L, SEEK_SET);
mpp_log("read bytes from file failed\n");
goto __FAILED;
}
mpp_packet_init(&DemoCtx.pkt, DemoCtx.strmbuf, fileSize);
// 3.parser_prepare // 2.jpegd_readbytes_from_file
CHECK_FUN(parser_prepare(pMppDec->parser, DemoCtx.pkt, curtask)); // jpegd_parser_prepare ret = jpegd_readbytes_from_file(DemoCtx.strmbuf, fileSize, pInFile);
if (ret != MPP_OK) {
mpp_log("read bytes from file failed\n");
goto __FAILED;
}
mpp_packet_init(&DemoCtx.pkt, DemoCtx.strmbuf, fileSize);
if (-1 == curtask->input) { // 3.parser_prepare
if (MPP_OK == mpp_buf_slot_get_unused(pMppDec->packet_slots, &slot_idx) ) { CHECK_FUN(parser_prepare(pMppDec->parser, DemoCtx.pkt, curtask)); // jpegd_parser_prepare
MppBuffer buffer = NULL;
curtask->input = slot_idx;
mpp_buf_slot_get_prop(pMppDec->packet_slots, slot_idx, SLOT_BUFFER, &buffer);
if (NULL == buffer) {
RK_U32 size = (RK_U32)mpp_buf_slot_get_size(pMppDec->packet_slots);
if (size == 0) {
size = (1024 * 1024);
}
mpp_buffer_get(DemoCtx.strmbuf_grp, &buffer, size);
if (buffer != NULL){
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_buffer_write(buffer, 0, if (-1 == curtask->input) {
mpp_packet_get_data(curtask->input_packet), if (MPP_OK == mpp_buf_slot_get_unused(pMppDec->packet_slots, &slot_idx) ) {
mpp_packet_get_size(curtask->input_packet)); MppBuffer buffer = NULL;
curtask->input = slot_idx;
mpp_err("%s Line %d, (*input_packet):%p, length:%d", __func__,__LINE__,
mpp_packet_get_data(curtask->input_packet),
mpp_packet_get_size(curtask->input_packet));
DemoCtx.pkt_buf = buffer;
mpp_buf_slot_set_flag(pMppDec->packet_slots, curtask->input, SLOT_CODEC_READY); mpp_buf_slot_get_prop(pMppDec->packet_slots, slot_idx, SLOT_BUFFER, &buffer);
mpp_buf_slot_set_flag(pMppDec->packet_slots, curtask->input, SLOT_HAL_INPUT); if (NULL == buffer) {
} RK_U32 size = (RK_U32)mpp_buf_slot_get_size(pMppDec->packet_slots);
} if (size == 0) {
size = (1024 * 1024);
}
CHECK_FUN(parser_parse(pMppDec->parser, curtask)); // jpegd_parser_parse mpp_buffer_get(DemoCtx.strmbuf_grp, &buffer, size);
if (buffer != NULL) {
if (curtask->valid) { mpp_err("mpp_buf_slot_get_prop, buffer:%p, size:%d", buffer, size);
HalTaskInfo task_info; mpp_buf_slot_set_prop(pMppDec->packet_slots, slot_idx, SLOT_BUFFER, buffer);
MppBuffer buffer = NULL; }
task_info.dec = *curtask; }
RK_S32 index = curtask->output;
if (mpp_buf_slot_is_changed(pMppDec->frame_slots)) { mpp_buffer_write(buffer, 0,
mpp_buf_slot_ready(pMppDec->frame_slots); mpp_packet_get_data(curtask->input_packet),
} mpp_packet_get_size(curtask->input_packet));
mpp_buf_slot_get_prop(pMppDec->frame_slots, index, SLOT_BUFFER, &buffer);
if (NULL == buffer) {
RK_U32 size = (RK_U32)mpp_buf_slot_get_size(pMppDec->frame_slots);
if (size == 0) {
size = 1920 * 1080 * 5;
}
mpp_buffer_get(DemoCtx.frmbuf_grp, &buffer, size); mpp_err("%s Line %d, (*input_packet):%p, length:%d", __func__, __LINE__,
if (buffer){ mpp_packet_get_data(curtask->input_packet),
mpp_buf_slot_set_prop(pMppDec->frame_slots, index, SLOT_BUFFER, buffer); mpp_packet_get_size(curtask->input_packet));
mpp_err("frame_slots, buffer:%p, size:%d", buffer, size); DemoCtx.pkt_buf = buffer;
}
DemoCtx.pic_buf = buffer;
}
mpp_hal_reg_gen(pMppDec->hal, &task_info); // jpegd_hal_gen_regs mpp_buf_slot_set_flag(pMppDec->packet_slots, curtask->input, SLOT_CODEC_READY);
mpp_hal_hw_start(pMppDec->hal, &task_info); // jpegd_hal_start mpp_buf_slot_set_flag(pMppDec->packet_slots, curtask->input, SLOT_HAL_INPUT);
mpp_hal_hw_wait(pMppDec->hal, &task_info); // jpegd_hal_wait }
}
parser_reset(pMppDec->parser); //[TEMP] jpegd_parser_reset
void* pOutYUV = NULL; CHECK_FUN(parser_parse(pMppDec->parser, curtask)); // jpegd_parser_parse
pOutYUV = mpp_buffer_get_ptr(DemoCtx.pic_buf);
if (pOutYUV) {
JPEGD_INFO_LOG("pOutYUV:%p", pOutYUV);
JpegSyntaxParam *pTmpSyn = (JpegSyntaxParam *)curtask->syntax.data;
RK_U32 width = pTmpSyn->frame.hwX;
RK_U32 height = pTmpSyn->frame.hwY;
JPEGD_INFO_LOG("Output Image: %d*%d", width, height); if (curtask->valid) {
HalTaskInfo task_info;
MppBuffer buffer = NULL;
task_info.dec = *curtask;
RK_S32 index = curtask->output;
if (mpp_buf_slot_is_changed(pMppDec->frame_slots)) {
mpp_buf_slot_ready(pMppDec->frame_slots);
}
mpp_buf_slot_get_prop(pMppDec->frame_slots, index, SLOT_BUFFER, &buffer);
if (NULL == buffer) {
RK_U32 size = (RK_U32)mpp_buf_slot_get_size(pMppDec->frame_slots);
if (size == 0) {
size = 1920 * 1080 * 5;
}
mpp_buffer_get(DemoCtx.frmbuf_grp, &buffer, size);
if (buffer) {
mpp_buf_slot_set_prop(pMppDec->frame_slots, index, SLOT_BUFFER, buffer);
mpp_err("frame_slots, buffer:%p, size:%d", buffer, size);
}
DemoCtx.pic_buf = buffer;
}
mpp_hal_reg_gen(pMppDec->hal, &task_info); // jpegd_hal_gen_regs
mpp_hal_hw_start(pMppDec->hal, &task_info); // jpegd_hal_start
mpp_hal_hw_wait(pMppDec->hal, &task_info); // jpegd_hal_wait
parser_reset(pMppDec->parser); //[TEMP] jpegd_parser_reset
void* pOutYUV = NULL;
pOutYUV = mpp_buffer_get_ptr(DemoCtx.pic_buf);
if (pOutYUV) {
JPEGD_INFO_LOG("pOutYUV:%p", pOutYUV);
JpegSyntaxParam *pTmpSyn = (JpegSyntaxParam *)curtask->syntax.data;
RK_U32 width = pTmpSyn->frame.hwX;
RK_U32 height = pTmpSyn->frame.hwY;
JPEGD_INFO_LOG("Output Image: %d*%d", width, height);
if (DemoCtx.pOutFile) { if (DemoCtx.pOutFile) {
fwrite(pOutYUV, 1, width * height * 3 / 2, DemoCtx.pOutFile); fwrite(pOutYUV, 1, width * height * 3 / 2, DemoCtx.pOutFile);
fflush(DemoCtx.pOutFile); fflush(DemoCtx.pOutFile);
} }
} }
} }
/*** parser packet deinit ***/
if(DemoCtx.pkt_buf) {
mpp_buffer_put(DemoCtx.pkt_buf);
}
if(DemoCtx.pic_buf) {
mpp_buffer_put(DemoCtx.pic_buf);
}
mpp_buf_slot_clr_flag(pMppDec->packet_slots, curtask->input, SLOT_HAL_INPUT); /*** parser packet deinit ***/
mpp_buf_slot_clr_flag(pMppDec->frame_slots, curtask->output, SLOT_HAL_OUTPUT); if (DemoCtx.pkt_buf) {
mpp_buffer_put(DemoCtx.pkt_buf);
}
if (DemoCtx.pic_buf) {
mpp_buffer_put(DemoCtx.pic_buf);
}
memset(curtask, 0, sizeof(HalDecTask)); mpp_buf_slot_clr_flag(pMppDec->packet_slots, curtask->input, SLOT_HAL_INPUT);
memset(&curtask->refer, -1, sizeof(curtask->refer)); mpp_buf_slot_clr_flag(pMppDec->frame_slots, curtask->output, SLOT_HAL_OUTPUT);
curtask->input = -1;
memset(curtask, 0, sizeof(HalDecTask));
memset(&curtask->refer, -1, sizeof(curtask->refer));
curtask->input = -1;
DemoCtx.dec_frm_num ++;
} while (0);
CHECK_FUN(mpp_dec_flush(pMppDec));
DemoCtx.dec_frm_num ++;
}while(0);
CHECK_FUN(mpp_dec_flush(pMppDec));
__FAILED: __FAILED:
if(pInFile){ if (pInFile) {
fclose(pInFile); fclose(pInFile);
pInFile = NULL; pInFile = NULL;
} }
jpegd_test_deinit(&DemoCtx); jpegd_test_deinit(&DemoCtx);
FUN_TEST("Exit"); FUN_TEST("Exit");
return MPP_OK; return MPP_OK;
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FUN_TEST("Enter"); FUN_TEST("Enter");
RK_S32 ret = 0; RK_S32 ret = 0;
parserDemoCmdCtx demoCmdCtx; parserDemoCmdCtx demoCmdCtx;
parserDemoCmdCtx* cmd = NULL; parserDemoCmdCtx* cmd = NULL;
@@ -565,6 +565,6 @@ int main(int argc, char **argv)
} }
jpegd_parser_test(cmd); jpegd_parser_test(cmd);
FUN_TEST("Exit"); FUN_TEST("Exit");
return MPP_OK; return MPP_OK;
} }