[jpegd]: add jpegd source code file and comment jpegd in support_list.

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@1099 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
HuangTingjin
2016-07-26 09:32:21 +00:00
parent 39ab4c7e75
commit a82bda1f00
17 changed files with 6950 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ target_link_libraries(mpp_codec
codec_mpg4d codec_mpg4d
codec_vp8d codec_vp8d
codec_vp9d codec_vp9d
codec_jpegd
codec_h264e codec_h264e
codec_dummy_enc codec_dummy_enc
codec_dummy_dec codec_dummy_dec

View File

@@ -23,3 +23,4 @@ add_subdirectory(vp8)
add_subdirectory(vp9) add_subdirectory(vp9)
add_subdirectory(jpeg)

View File

@@ -0,0 +1,17 @@
# vim: syntax=cmake
set(JPEGD_PARSER_HDR
jpegd_parser.h
)
set(JPEGD_PARSER_SRC
jpegd_parser.c
)
add_library(codec_jpegd STATIC
${JPEGD_PARSER_SRC} ${JPEGD_PARSER_HDR}
)
set_target_properties(codec_jpegd PROPERTIES FOLDER "mpp/codec")
target_link_libraries(codec_jpegd mpp_base)
#add_subdirectory(test)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,203 @@
/*
*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __JPEGD_PARSER_H__
#define __JPEGD_PARSER_H__
#include "mpp_bitread.h"
#include "mpp_common.h"
#include "mpp_frame.h"
#include "limits.h"
#include <string.h>
#include <mpp_mem.h>
#include "mpp_dec.h"
#include "mpp_buf_slot.h"
#include "mpp_packet.h"
#include "jpegd_syntax.h"
/* Max amount of stream */
#define DEC_RK70_MAX_STREAM ((1<<24)-1)
#define JPEGDEC_RK70_MIN_BUFFER 256//5120
#define JPEGDEC_RK70_MAX_BUFFER 16776960
#define JPEGDEC_MAX_SLICE_SIZE 4096
#define JPEGDEC_TABLE_SIZE 544
#define JPEGDEC_MIN_WIDTH 48
#define JPEGDEC_MIN_HEIGHT 48
#define JPEGDEC_MAX_WIDTH 4672
#define JPEGDEC_MAX_HEIGHT 4672
#define JPEGDEC_MAX_PIXEL_AMOUNT 16370688
#define JPEGDEC_MAX_WIDTH_8190 8176
#define JPEGDEC_MAX_HEIGHT_8190 8176
#define JPEGDEC_MAX_PIXEL_AMOUNT_8190 66846976
#define JPEGDEC_MAX_SLICE_SIZE_8190 8100
#define JPEGDEC_MAX_WIDTH_TN 256
#define JPEGDEC_MAX_HEIGHT_TN 256
//#define JPEGDEC_BASELINE_TABLE_SIZE 544
#define JPEGDEC_PROGRESSIVE_TABLE_SIZE 576
#define JPEGDEC_QP_BASE 32
#define JPEGDEC_AC1_BASE 48
#define JPEGDEC_AC2_BASE 88
#define JPEGDEC_DC1_BASE 129
#define JPEGDEC_DC2_BASE 132
#define JPEGDEC_DC3_BASE 135
#define PP_IN_FORMAT_YUV422INTERLAVE 0
#define PP_IN_FORMAT_YUV420SEMI 1
#define PP_IN_FORMAT_YUV420PLANAR 2
#define PP_IN_FORMAT_YUV400 3
#define PP_IN_FORMAT_YUV422SEMI 4
#define PP_IN_FORMAT_YUV420SEMITIELED 5
#define PP_IN_FORMAT_YUV440SEMI 6
#define PP_IN_FORMAT_YUV444_SEMI 7
#define PP_IN_FORMAT_YUV411_SEMI 8
#define PP_OUT_FORMAT_RGB565 0
#define PP_OUT_FORMAT_ARGB 1
#define PP_OUT_FORMAT_YUV422INTERLAVE 3
#define PP_OUT_FORMAT_YUV420INTERLAVE 5
/* progressive */
#define JPEGDEC_COEFF_SIZE 96
/* Timeout value for the VPUWaitHwReady() call. */
/* Set to -1 for an unspecified value */
#ifndef DEC_RK70_TIMEOUT_LENGTH
#define DEC_RK70_TIMEOUT_LENGTH (-1)
#endif
enum {
JPEGDEC_NO_UNITS = 0, /* No units, X and Y specify
* the pixel aspect ratio */
JPEGDEC_DOTS_PER_INCH = 1, /* X and Y are dots per inch */
JPEGDEC_DOTS_PER_CM = 2 /* X and Y are dots per cm */
};
enum {
JPEGDEC_THUMBNAIL_JPEG = 0x10,
JPEGDEC_THUMBNAIL_NOT_SUPPORTED_FORMAT = 0x11,
JPEGDEC_NO_THUMBNAIL = 0x12
};
enum {
JPEGDEC_IMAGE = 0,
JPEGDEC_THUMBNAIL = 1
};
enum{
SOF0 = 0xC0,
SOF1 = 0xC1,
SOF2 = 0xC2,
SOF3 = 0xC3,
SOF5 = 0xC5,
SOF6 = 0xC6,
SOF7 = 0xC7,
SOF9 = 0xC8,
SOF10 = 0xCA,
SOF11 = 0xCB,
SOF13 = 0xCD,
SOF14 = 0xCE,
SOF15 = 0xCF,
JPG = 0xC8,
DHT = 0xC4,
DAC = 0xCC,
SOI = 0xD8,
EOI = 0xD9,
SOS = 0xDA,
DQT = 0xDB,
DNL = 0xDC,
DRI = 0xDD,
DHP = 0xDE,
EXP = 0xDF,
APP0 = 0xE0,
APP1 = 0xE1,
APP2 = 0xE2,
APP3 = 0xE3,
APP4 = 0xE4,
APP5 = 0xE5,
APP6 = 0xE6,
APP7 = 0xE7,
APP8 = 0xE8,
APP9 = 0xE9,
APP10 = 0xEA,
APP11 = 0xEB,
APP12 = 0xEC,
APP13 = 0xED,
APP14 = 0xEE,
APP15 = 0xEF,
JPG0 = 0xF0,
JPG1 = 0xF1,
JPG2 = 0xF2,
JPG3 = 0xF3,
JPG4 = 0xF4,
JPG5 = 0xF5,
JPG6 = 0xF6,
JPG7 = 0xF7,
JPG8 = 0xF8,
JPG9 = 0xF9,
JPG10 = 0xFA,
JPG11 = 0xFB,
JPG12 = 0xFC,
JPG13 = 0xFD,
COM = 0xFE,
TEM = 0x01,
RST0 = 0xD0,
RST1 = 0xD1,
RST2 = 0xD2,
RST3 = 0xD3,
RST4 = 0xD4,
RST5 = 0xD5,
RST6 = 0xD6,
RST7 = 0xD7
};
typedef struct JpegParserContext {
MppBufSlots packet_slots;
MppBufSlots frame_slots;
RK_S32 frame_slot_index; /* slot index for output */
RK_U8 *recv_buffer;
JpegSyntaxParam *pSyntax;
JpegDecImageInfo imageInfo;
RK_U32 streamLength; /* input stream length or buffer size */
RK_U32 bufferSize; /* input stream buffer size */
RK_U32 decImageType; /* Full image or Thumbnail to be decoded */
RK_U32 sliceMbSet; /* slice mode: mcu rows to decode */
RK_U32 color_conv;
RK_U32 dri_en;
MppPacket input_packet;
MppFrame output_frame;
RK_U32 is8190;
RK_U32 fuseBurned;
RK_U32 minSupportedWidth;
RK_U32 minSupportedHeight;
RK_U32 maxSupportedWidth;
RK_U32 maxSupportedHeight;
RK_U32 maxSupportedPixelAmount;
RK_U32 maxSupportedSliceSize;
RK_U32 extensionsSupported;
RK_S64 pts;
RK_U32 parser_debug_enable;
RK_U32 input_jpeg_count;
}JpegParserContext;
#endif /* __JPEGD_PARSER_H__ */

104
mpp/codec/inc/jpegd_api.h Normal file
View File

@@ -0,0 +1,104 @@
/*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __JPEGD_API_H__
#define __JPEGD_API_H__
#include "parser_api.h"
#ifdef __cplusplus
extern "C" {
#endif
extern const ParserApi api_jpegd_parser;
extern RK_U32 jpegd_log;
#define JPEGD_VBE_LOG (0x01)
#define JPEGD_DBG_LOG (0x02)
#define JPEGD_INF_LOG (0x04)
#define JPEGD_ERR_LOG (0x08)
#define JPEGD_DBG_ASSERT (1)
#define FUN_TEST(tag) \
do {\
if (JPEGD_VBE_LOG & jpegd_log)\
{ mpp_log("[Verbose] %s: line(%d), func(%s)", tag, __LINE__, __FUNCTION__); }\
} while (0)
#define JPEGD_ASSERT(val)\
do {\
if (JPEGD_DBG_ASSERT)\
{ mpp_assert(val); }\
} while (0)
//check function return
#define CHECK_FUN(val) \
do{ \
if((val) < 0) { \
ret = (val); \
mpp_log("func return error(Line %d), ret:%d\n", __LINE__, ret); \
goto __FAILED; \
} \
} while (0)
//memory malloc check
#define CHECK_MEM(val, ...)\
do{ if(!(val)) {\
ret = MPP_ERR_MALLOC;\
mpp_log("malloc buffer error(Line %d), pointer:%p\n", __LINE__, val);\
goto __FAILED;\
} } while (0)
#define JPEGD_VERBOSE_LOG(fmt, ...) \
do {\
if (JPEGD_VBE_LOG & jpegd_log)\
{ mpp_log("[Verbose] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0)
#define JPEGD_DEBUG_LOG(fmt, ...) \
do {\
if (JPEGD_DBG_LOG & jpegd_log)\
{ mpp_log("[Debug] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0)
#define JPEGD_INFO_LOG(fmt, ...) \
do {\
if (JPEGD_INF_LOG & jpegd_log)\
{ mpp_log("[Info] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0)
#define JPEGD_ERROR_LOG(fmt, ...) \
do {\
if (JPEGD_ERR_LOG & jpegd_log)\
{ mpp_log("[Error] func(%s), line(%d), "fmt"", __FUNCTION__, __LINE__, ##__VA_ARGS__); }\
} while (0)
MPP_RET jpegd_prepare(void *ctx, MppPacket pkt, HalDecTask *task);
MPP_RET jpegd_init(void *ctx, ParserCfg *parser_cfg);
MPP_RET jpegd_parse(void *ctx, HalDecTask *task);
MPP_RET jpegd_deinit(void *ctx);
MPP_RET jpegd_flush(void *ctx);
MPP_RET jpegd_reset(void *ctx);
MPP_RET jpegd_control(void *ctx, RK_S32 cmd, void *param);
MPP_RET jpegd_callback(void *ctx, void *err_info);
#ifdef __cplusplus
}
#endif
#endif /*__JPEGD_API_H__*/

View File

@@ -32,6 +32,7 @@
#include "m2vd_api.h" #include "m2vd_api.h"
#include "mpg4d_api.h" #include "mpg4d_api.h"
#include "vp8d_api.h" #include "vp8d_api.h"
#include "jpegd_api.h"
// for test and demo // for test and demo
#include "dummy_dec_api.h" #include "dummy_dec_api.h"
@@ -49,6 +50,7 @@ static const ParserApi *parsers[] = {
&api_mpg4d_parser, &api_mpg4d_parser,
&api_vp8d_parser, &api_vp8d_parser,
&api_vp9d_parser, &api_vp9d_parser,
&api_jpegd_parser,
&dummy_dec_parser, &dummy_dec_parser,
}; };

376
mpp/common/jpegd_syntax.h Normal file
View File

@@ -0,0 +1,376 @@
/*
*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __JPEGD_SYNTAX__
#define __JPEGD_SYNTAX__
#include "vpu_api.h"
#define MIN_NUMBER_OF_COMPONENTS 1
#define MAX_NUMBER_OF_COMPONENTS 3
#define JPEGDEC_YCbCr400 0x080000U
#define JPEGDEC_YCbCr420_SEMIPLANAR 0x020001U
#define JPEGDEC_YCbCr422_SEMIPLANAR 0x010001U
#define JPEGDEC_YCbCr440 0x010004U
#define JPEGDEC_YCbCr411_SEMIPLANAR 0x100000U
#define JPEGDEC_YCbCr444_SEMIPLANAR 0x200000U
#define JPEGDEC_BASELINE 0x0
#define JPEGDEC_PROGRESSIVE 0x1
#define JPEGDEC_NONINTERLEAVED 0x2
#define JPEGDEC_YUV400 0
#define JPEGDEC_YUV420 2
#define JPEGDEC_YUV422 3
#define JPEGDEC_YUV444 4
#define JPEGDEC_YUV440 5
#define JPEGDEC_YUV411 6
#define JPEGD_STREAM_BUFF_SIZE (10*1024*1024)
#define JPEGDEC_BASELINE_TABLE_SIZE (544)
typedef enum {
JPEGDEC_SLICE_READY = 2,
JPEGDEC_FRAME_READY = 1,
JPEGDEC_STRM_PROCESSED = 3,
JPEGDEC_SCAN_PROCESSED = 4,
JPEGDEC_OK = 0,
JPEGDEC_ERROR = -1,
JPEGDEC_UNSUPPORTED = -2,
JPEGDEC_PARAM_ERROR = -3,
JPEGDEC_MEMFAIL = -4,
JPEGDEC_INITFAIL = -5,
JPEGDEC_INVALID_STREAM_LENGTH = -6,
JPEGDEC_STRM_ERROR = -7,
JPEGDEC_INVALID_INPUT_BUFFER_SIZE = -8,
JPEGDEC_HW_RESERVED = -9,
JPEGDEC_INCREASE_INPUT_BUFFER = -10,
JPEGDEC_SLICE_MODE_UNSUPPORTED = -11,
JPEGDEC_DWL_HW_TIMEOUT = -253,
JPEGDEC_DWL_ERROR = -254,
JPEGDEC_HW_BUS_ERROR = -255,
JPEGDEC_SYSTEM_ERROR = -256,
JPEGDEC_FORMAT_NOT_SUPPORTED = -1000
} JpegDecRet;
typedef struct {
RK_U32 C; /* Component id */
RK_U32 H; /* Horizontal sampling factor */
RK_U32 V; /* Vertical sampling factor */
RK_U32 Tq; /* Quantization table destination selector */
} Components;
typedef struct {
RK_U8 *pStartOfStream;
RK_U8 *pCurrPos;
RK_U32 streamBus; /* physical address */
RK_U32 bitPosInByte;
RK_U32 streamLength;
RK_U32 readBits;
RK_U32 appnFlag;
RK_U32 thumbnail;
RK_U32 returnSosMarker;
} StreamStorage;
typedef struct {
RK_U8 *pStartOfImage;
RK_U8 *pLum;
RK_U8 *pCr;
RK_U8 *pCb;
RK_U32 imageReady;
RK_U32 headerReady;
RK_U32 size;
RK_U32 sizeLuma;
RK_U32 sizeChroma;
RK_U32 ready;
RK_U32 columns[MAX_NUMBER_OF_COMPONENTS];
RK_U32 pixelsPerRow[MAX_NUMBER_OF_COMPONENTS];
} ImageData;
typedef struct {
RK_U32 Lf;
RK_U32 P;
RK_U32 Y;
RK_U32 hwY;
RK_U32 X;
RK_U32 hwX;
RK_U32 Nf; /* Number of components in frame */
RK_U32 codingType;
RK_U32 numMcuInFrame;
RK_U32 numMcuInRow;
RK_U32 mcuNumber;
RK_U32 nextRstNumber;
RK_U32 Ri;
RK_U32 driPeriod;
RK_U32 block;
RK_U32 row;
RK_U32 col;
RK_U32 cIndex;
RK_U32 *pBuffer;
RK_U32 bufferBus;
RK_S32 *pBufferCb;
RK_S32 *pBufferCr;
VPUMemLinear_t pTableBase;
RK_U32 numBlocks[MAX_NUMBER_OF_COMPONENTS];
RK_U32 blocksPerRow[MAX_NUMBER_OF_COMPONENTS];
RK_U32 useAcOffset[MAX_NUMBER_OF_COMPONENTS];
Components component[MAX_NUMBER_OF_COMPONENTS];
} FrameInfo;
typedef struct {
RK_U32 Ls;
RK_U32 Ns;
RK_U32 Cs[MAX_NUMBER_OF_COMPONENTS]; /* Scan component selector */
RK_U32 Td[MAX_NUMBER_OF_COMPONENTS]; /* Selects table for DC */
RK_U32 Ta[MAX_NUMBER_OF_COMPONENTS]; /* Selects table for AC */
RK_U32 Ss;
RK_U32 Se;
RK_U32 Ah;
RK_U32 Al;
RK_U32 index;
RK_S32 numIdctRows;
RK_S32 pred[MAX_NUMBER_OF_COMPONENTS];
} ScanInfo;
typedef struct {
RK_U32 sliceHeight;
RK_U32 amountOfQTables;
RK_U32 yCbCrMode;
RK_U32 yCbCr422;
RK_U32 column;
RK_U32 X; /* width */
RK_U32 Y; /* height */
RK_U32 memSize;
RK_U32 SliceCount;
RK_U32 SliceReadyForPause;
RK_U32 SliceMBCutValue;
RK_U32 pipeline;
RK_U32 userAllocMem;
RK_U32 sliceMbSetValue;
RK_U32 timeout;
RK_U32 rlcMode;
RK_U32 lumaPos;
RK_U32 chromaPos;
RK_U32 sliceStartCount;
RK_U32 amountOfSlices;
RK_U32 noSliceIrqForUser;
RK_U32 sliceLimitReached;
RK_U32 inputBufferEmpty;
RK_U32 fillRight;
RK_U32 fillBottom;
RK_U32 streamEnd;
RK_U32 streamEndFlag;
RK_U32 inputBufferLen;
RK_U32 inputStreaming;
RK_U32 decodedStreamLen;
RK_U32 init;
RK_U32 initThumb;
RK_U32 initBufferSize;
RK_S32 dcRes[MAX_NUMBER_OF_COMPONENTS];
VPUMemLinear_t outLuma;
VPUMemLinear_t outChroma;
VPUMemLinear_t outChroma2;
VPUMemLinear_t givenOutLuma;
VPUMemLinear_t givenOutChroma;
VPUMemLinear_t givenOutChroma2;
RK_S32 pred[MAX_NUMBER_OF_COMPONENTS];
/* progressive parameters */
RK_U32 nonInterleaved;
RK_U32 componentId;
RK_U32 operationType;
RK_U32 operationTypeThumb;
RK_U32 progressiveScanReady;
RK_U32 nonInterleavedScanReady;
RK_U32 allocated;
RK_U32 yCbCrModeOrig;
RK_U32 getInfoYCbCrMode;
RK_U32 components[MAX_NUMBER_OF_COMPONENTS];
VPUMemLinear_t pCoeffBase;
RK_U32 fillX;
RK_U32 fillY;
RK_U32 progressiveFinish;
RK_U32 pfCompId;
RK_U32 pfNeeded[MAX_NUMBER_OF_COMPONENTS];
VPUMemLinear_t tmpStrm;
} DecInfo;
// TODO: The way to malloc buffer has been changed in MPP
typedef struct {
VPUMemLinear_t outLumaBuffer;
VPUMemLinear_t outChromaBuffer;
VPUMemLinear_t outChromaBuffer2;
} JpegAsicBuffers;
typedef struct {
RK_U32 bits[16];
RK_U32 *vals;
RK_U32 tableLength;
RK_U32 start;
RK_U32 last;
} VlcTable;
typedef struct {
RK_U32 Lh;
VlcTable acTable0;
VlcTable acTable1;
VlcTable acTable2;
VlcTable acTable3;
VlcTable dcTable0;
VlcTable dcTable1;
VlcTable dcTable2;
VlcTable dcTable3;
VlcTable *table;
} HuffmanTables;
typedef struct {
RK_U32 Lq; /* Quantization table definition length */
RK_U32 table0[64];
RK_U32 table1[64];
RK_U32 table2[64];
RK_U32 table3[64];
RK_U32 *table;
} QuantTables;
/* Control interface between decoder and pp */
/* decoder writes, pp read-only */
typedef struct DecPpInterface_ {
enum {
DECPP_IDLE = 0,
DECPP_RUNNING, /* PP was started */
DECPP_PIC_READY, /* PP has finished a picture */
DECPP_PIC_NOT_FINISHED /* PP still processing a picture */
} ppStatus; /* Decoder keeps track of what it asked the pp to do */
enum {
MULTIBUFFER_UNINIT = 0, /* buffering mode not yet decided */
MULTIBUFFER_DISABLED, /* Single buffer legacy mode */
MULTIBUFFER_SEMIMODE, /* enabled but full pipel cannot be used */
MULTIBUFFER_FULLMODE /* enabled and full pipeline successful */
} multiBufStat;
RK_U32 inputBusLuma;
RK_U32 inputBusChroma;
RK_U32 bottomBusLuma;
RK_U32 bottomBusChroma;
RK_U32 picStruct; /* structure of input picture */
RK_U32 topField;
RK_U32 inwidth;
RK_U32 inheight;
RK_U32 usePipeline;
RK_U32 littleEndian;
RK_U32 wordSwap;
RK_U32 croppedW;
RK_U32 croppedH;
RK_U32 bufferIndex; /* multibuffer, where to put PP output */
RK_U32 displayIndex; /* multibuffer, next picture in display order */
RK_U32 prevAnchorDisplayIndex;
/* VC-1 */
RK_U32 rangeRed;
RK_U32 rangeMapYEnable;
RK_U32 rangeMapYCoeff;
RK_U32 rangeMapCEnable;
RK_U32 rangeMapCCoeff;
} DecPpInterface;
typedef struct {
int enable;
int outFomart; /* =0,RGB565;=1,ARGB 8888 */
//int destWidth;
//int destHeight;
int scale_denom;
int shouldDither;
int cropX;
int cropY;
int cropW;
int cropH;
} PostProcessInfo;
/* Image information */
typedef struct {
RK_U32 displayWidth;
RK_U32 displayHeight;
RK_U32 outputWidth; /* Number of pixels/line in the image */
RK_U32 outputHeight; /* Number of lines in in the image */
RK_U32 version;
RK_U32 units;
RK_U32 xDensity;
RK_U32 yDensity;
RK_U32 outputFormat; /* JPEGDEC_YCbCr400
* JPEGDEC_YCbCr420
* JPEGDEC_YCbCr422
*/
RK_U32 codingMode; /* JPEGDEC_BASELINE
* JPEGDEC_PROGRESSIVE
* JPEGDEC_NONINTERLEAVED
*/
RK_U32 thumbnailType; /* Thumbnail exist or not or not supported */
RK_U32 displayWidthThumb;
RK_U32 displayHeightThumb;
RK_U32 outputWidthThumb; /* Number of pixels/line in the image */
RK_U32 outputHeightThumb; /* Number of lines in in the image */
RK_U32 outputFormatThumb; /* JPEGDEC_YCbCr400
* JPEGDEC_YCbCr420
* JPEGDEC_YCbCr422
*/
RK_U32 codingModeThumb; /* JPEGDEC_BASELINE
* JPEGDEC_PROGRESSIVE
* JPEGDEC_NONINTERLEAVED
*/
} JpegDecImageInfo;
typedef struct JpegSyntaxParam{
StreamStorage stream;
FrameInfo frame;
ImageData image;
ScanInfo scan;
DecInfo info;
HuffmanTables vlc;
QuantTables quant;
JpegDecImageInfo imageInfo;
RK_U32 ppInputFomart;
PostProcessInfo ppInfo;
RK_U32 is8190;
RK_U32 fuseBurned;
RK_U32 ppScaleW;
RK_U32 ppScaleH;
RK_U32 minSupportedWidth;
RK_U32 minSupportedHeight;
RK_U32 maxSupportedWidth;
RK_U32 maxSupportedHeight;
RK_U32 maxSupportedPixelAmount;
RK_U32 maxSupportedSliceSize;
RK_U32 extensionsSupported;
JpegAsicBuffers asicBuff;
DecPpInterface ppControl;
RK_U32 ppStatus;
int socket; /* socket instance */
void* vpumem_ctx;
const void *ppInstance;
VPUMemLinear_t *pictureMem;
}JpegSyntaxParam;
#endif /*__JPEGD_SYNTAX__*/

View File

@@ -30,6 +30,8 @@ add_subdirectory(vpu/mpg4d)
add_subdirectory(vpu/vp8d) add_subdirectory(vpu/vp8d)
add_subdirectory(vpu/jpegd)
add_subdirectory(rkenc/h264e) add_subdirectory(rkenc/h264e)
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
@@ -52,6 +54,7 @@ target_link_libraries(mpp_hal
hal_mpg4d hal_mpg4d
hal_vp8d hal_vp8d
hal_vp9d hal_vp9d
hal_jpegd
hal_h264e hal_h264e
hal_dummy hal_dummy
${RKPLAT_VPU} ${RKPLAT_VPU}

View File

@@ -0,0 +1,47 @@
/*
*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HAL_JPEGD_API_H__
#define __HAL_JPEGD_API_H__
#include "rk_type.h"
#include "mpp_err.h"
#include "mpp_hal.h"
#ifdef __cplusplus
extern "C" {
#endif
extern const MppHalApi hal_api_jpegd;
RK_S32 hal_jpegd_init(void *hal, MppHalCfg *cfg);
RK_S32 hal_jpegd_gen_regs(void *hal, HalTaskInfo *syn);
RK_S32 hal_jpegd_deinit(void *hal);
MPP_RET hal_jpegd_start(void *hal, HalTaskInfo *task);
MPP_RET hal_jpegd_wait(void *hal, HalTaskInfo *task);
MPP_RET hal_jpegd_reset(void *hal);
MPP_RET hal_jpegd_flush(void *hal);
MPP_RET hal_jpegd_control(void *hal, RK_S32 cmd_type, void *param);
#ifdef __cplusplus
}
#endif
#endif /*__HAL_JPEGD_API_H__*/

View File

@@ -34,6 +34,7 @@
#include "hal_mpg4d_api.h" #include "hal_mpg4d_api.h"
#include "hal_vp8d_api.h" #include "hal_vp8d_api.h"
#include "hal_h264e_api.h" #include "hal_h264e_api.h"
#include "hal_jpegd_api.h"
// for test and demo // for test and demo
#include "hal_dummy_dec_api.h" #include "hal_dummy_dec_api.h"
@@ -51,6 +52,7 @@ static const MppHalApi *hw_apis[] = {
&hal_api_mpg4d, &hal_api_mpg4d,
&hal_api_vp8d, &hal_api_vp8d,
&hal_api_vp9d, &hal_api_vp9d,
&hal_api_jpegd,
&hal_api_h264e, &hal_api_h264e,
&hal_api_dummy_dec, &hal_api_dummy_dec,
&hal_api_dummy_enc, &hal_api_dummy_enc,

View File

@@ -0,0 +1,20 @@
# vim: syntax=cmake
# hal jpeg reg
set(HAL_JPEGD_HDR
hal_jpegd_reg.h
)
set(HAL_JPEGD_SRC
hal_jpegd_reg.c
)
add_library(hal_jpegd STATIC
${HAL_JPEGD_SRC} ${HAL_JPEGD_HDR}
)
set_target_properties(hal_jpegd PROPERTIES FOLDER "mpp/hal")
target_link_libraries(hal_jpegd mpp_base)
#add_subdirectory(test)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,723 @@
/*
*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __HAL_JPEGD_REG_H__
#define __HAL_JPEGD_REG_H__
#include "rk_type.h"
#include "mpp_log.h"
#include "mpp_buf_slot.h"
#include "jpegd_syntax.h"
#define JPEGD_REG_NUM 159
#define JPEG_RK70_MODE_JPEG (3)
#define DEC_RK70_LITTLE_ENDIAN 1
#define DEC_RK70_BIG_ENDIAN 0
#define DEC_RK70_BUS_BURST_LENGTH_UNDEFINED 0
#define DEC_RK70_BUS_BURST_LENGTH_4 4
#define DEC_RK70_BUS_BURST_LENGTH_8 8
#define DEC_RK70_BUS_BURST_LENGTH_16 16
#define DEC_RK70_ASIC_SERVICE_PRIORITY_DEFAULT 0
#define DEC_RK70_ASIC_SERVICE_PRIORITY_WR_1 1
#define DEC_RK70_ASIC_SERVICE_PRIORITY_WR_2 2
#define DEC_RK70_ASIC_SERVICE_PRIORITY_RD_1 3
#define DEC_RK70_ASIC_SERVICE_PRIORITY_RD_2 4
#define DEC_RK70_OUTPUT_FORMAT_RASTER_SCAN 0
#define DEC_RK70_OUTPUT_FORMAT_TILED 1
#define DEC_RK70_SCMD_DISABLE (0)
#define DEC_RK70_LATENCY_COMPENSATION 0
#define DEC_RK70_DATA_DISCARD_ENABLE 0
#define JPEGDEC_SLICE_START_VALUE 0
//modify following values in special product
#define BRIGHTNESS 4 // -128 ~ 127
#define CONTRAST 0 // -64 ~ 64
#define SATURATION 0 // -64 ~ 128
#define PP_IN_FORMAT_YUV422INTERLAVE 0
#define PP_IN_FORMAT_YUV420SEMI 1
#define PP_IN_FORMAT_YUV420PLANAR 2
#define PP_IN_FORMAT_YUV400 3
#define PP_IN_FORMAT_YUV422SEMI 4
#define PP_IN_FORMAT_YUV420SEMITIELED 5
#define PP_IN_FORMAT_YUV440SEMI 6
#define PP_IN_FORMAT_YUV444_SEMI 7
#define PP_IN_FORMAT_YUV411_SEMI 8
#define PP_OUT_FORMAT_RGB565 0
#define PP_OUT_FORMAT_ARGB 1
#define PP_OUT_FORMAT_YUV422INTERLAVE 3
#define PP_OUT_FORMAT_YUV420INTERLAVE 5
typedef struct JpegRegSet{
struct {
RK_U32 sw_pp_max_burst : 5;
RK_U32 sw_pp_scmd_dis : 1;
RK_U32 sw_reserved_1 : 2;
RK_U32 sw_pp_axi_rd_id : 8;
RK_U32 sw_pp_axi_wr_id : 8;
} 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 {
RK_U32 sw_pp_color_coefff : 8;
} 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 {
RK_U32 sw_crop_startx : 9;
RK_U32 sw_crop_starty_ext : 3;
RK_U32 sw_reserved_1 : 4;
RK_U32 sw_crop_starty : 8;
RK_U32 sw_crop_startx_ext : 3;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_pp_crop8_d_e : 1;
RK_U32 sw_pp_crop8_r_e : 1;
} reg14;
struct {
RK_U32 sw_rangemap_coef_y : 5;
RK_U32 sw_ycbcr_range : 1;
RK_U32 sw_reserved_1 : 2;
RK_U32 sw_rangemap_coef_c : 5;
} 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 {
RK_U32 sw_contrast_thr1 : 8;
RK_U32 sw_contrast_thr2 : 8;
} 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 {
RK_U32 sw_pp_in_width : 9;
RK_U32 sw_pp_in_w_ext : 3;
RK_U32 sw_ext_orig_width : 9;
RK_U32 sw_pp_in_height : 8;
RK_U32 sw_pp_in_h_ext : 3;
} reg34;
struct {
RK_U32 sw_pp_out_width : 11;
RK_U32 sw_reserved_1 : 5;
RK_U32 sw_pp_out_height : 11;
} reg35;
struct {
RK_U32 sw_dither_select_r : 2;
RK_U32 sw_dither_select_g : 2;
RK_U32 sw_dither_select_b : 2;
} reg36;
struct {
RK_U32 sw_pp_in_endian : 1;
RK_U32 sw_pp_in_a1_endian : 1;
RK_U32 sw_pp_in_a2_endsel : 1;
RK_U32 sw_pp_out_endian : 1;
RK_U32 sw_rgb_pix_in32 : 1;
RK_U32 sw_reserved_1 : 3;
RK_U32 sw_pp_in_swap32_e : 1;
RK_U32 sw_pp_in_a1_swap32 : 1;
RK_U32 sw_pp_out_swap16_e : 1;
RK_U32 sw_pp_out_swap32_e : 1;
RK_U32 sw_reserved_2 : 4;
RK_U32 sw_pp_in_start_ch : 1;
RK_U32 sw_pp_out_start_ch : 1;
RK_U32 sw_pp_in_cr_first : 1;
RK_U32 sw_pp_out_cr_first : 1;
RK_U32 sw_reserved_3 : 4;
RK_U32 sw_pp_in_struct : 3;
} reg37;
struct {
RK_U32 sw_rotation_mode : 3;
RK_U32 sw_reserved_1 : 5;
RK_U32 sw_pp_in_format : 3;
RK_U32 sw_pp_out_format : 3;
RK_U32 sw_reserved_2 : 2;
RK_U32 sw_pp_in_format_es : 3;
} reg38;
struct {
RK_U32 sw_display_width : 12;
} reg39;
RK_U32 reg40;
struct {
RK_U32 sw_pp_e : 1;
RK_U32 sw_deint_blend_e : 1;
RK_U32 sw_deint_e : 1;
RK_U32 sw_pp_clk_gate_e : 1;
RK_U32 sw_pp_pipeline_e : 1;
RK_U32 sw_reserved_1 : 3;
RK_U32 sw_rangemap_y_e : 1;
RK_U32 sw_rangemap_c_e : 1;
RK_U32 sw_reserved_2 : 6;
RK_U32 sw_pp_data_disc_e : 1;
RK_U32 sw_reserved_3 : 3;
RK_U32 sw_mask1_e : 1;
RK_U32 sw_mask2_e : 1;
RK_U32 sw_mask1_ablend_e : 1;
RK_U32 sw_mask2_ablend_e : 1;
RK_U32 sw_up_cross_e : 1;
RK_U32 sw_down_cross_e : 1;
RK_U32 sw_left_cross_e : 1;
RK_U32 sw_right_cross_e : 1;
RK_U32 sw_pp_ahb_hlock_e : 1;
} reg41;
RK_U32 ppReg2[8];
struct {
RK_U32 sw_dec_out_tiled_e : 1;
RK_U32 sw_dec_latency : 6;
RK_U32 sw_pic_fixed_quant : 1;
RK_U32 sw_filtering_dis : 1;
RK_U32 sw_skip_mode : 1;
RK_U32 sw_dec_scmd_dis : 1;
RK_U32 sw_dec_adv_pre_dis : 1;
RK_U32 sw_priority_mode : 1;
RK_U32 sw_refbu2_thr : 12;
RK_U32 sw_refbu2_picid : 5;
RK_U32 reserve1 : 2;
} reg50_dec_ctrl;
struct {
RK_U32 sw_stream_len : 24;
RK_U32 reserve1 : 1;
RK_U32 sw_init_qp : 6;
RK_U32 reserve2 : 1;
} reg51_stream_info;
struct {
RK_U32 sw_startmb_y : 8;
RK_U32 sw_startmb_x : 9;
RK_U32 sw_apf_threshold : 14;
RK_U32 sw_reserve : 1;
} reg52_error_concealment;
RK_U32 reg53_dec_mode;
struct {
RK_U32 sw_dec_in_endian : 1;
RK_U32 sw_dec_out_endian : 1;
RK_U32 sw_dec_inswap32_e : 1;
RK_U32 sw_dec_outswap32_e : 1;
RK_U32 sw_dec_strswap32_e : 1;
RK_U32 sw_dec_strendian_e : 1;
RK_U32 reserve3 : 26;
} reg54_endian;
struct {
RK_U32 sw_dec_irq : 1;
RK_U32 sw_dec_irq_dis : 1;
RK_U32 reserve0 : 2;
RK_U32 sw_dec_rdy_int : 1;
RK_U32 sw_dec_bus_int : 1;
RK_U32 sw_dec_buffer_int : 1;
RK_U32 reserve1 : 1;
RK_U32 sw_dec_aso_int : 1;
RK_U32 sw_dec_slice_int : 1;
RK_U32 sw_dec_pic_inf : 1;
RK_U32 reserve2 : 1;
RK_U32 sw_dec_error_int: 1;
RK_U32 sw_dec_timeout : 1;
RK_U32 reserve3 : 18;
} reg55_Interrupt;
struct {
RK_U32 sw_dec_axi_rn_id : 8;
RK_U32 sw_dec_axi_wr_id : 8;
RK_U32 sw_dec_max_burst : 5;
RK_U32 resever : 1;
RK_U32 sw_dec_data_disc_e : 1;
RK_U32 resever1 : 9;
} reg56_axi_ctrl;
struct {
RK_U32 sw_dec_e : 1;
RK_U32 sw_refbu2_buf_e : 1;
RK_U32 sw_dec_out_dis : 1;
RK_U32 resever : 1;
RK_U32 sw_dec_clk_gate_e : 1;
RK_U32 sw_dec_timeout_e : 1;
RK_U32 sw_picord_count_e : 1;
RK_U32 sw_seq_mbaff_e : 1;
RK_U32 sw_reftopfirst_e : 1;
RK_U32 sw_ref_topfield_e : 1;
RK_U32 sw_write_mvs_e : 1;
RK_U32 sw_sorenson_e : 1;
RK_U32 sw_fwd_interlace_e : 1;
RK_U32 sw_pic_topfield_e : 1 ;
RK_U32 sw_pic_inter_e : 1;
RK_U32 sw_pic_b_e : 1;
RK_U32 sw_pic_fieldmode_e : 1;
RK_U32 sw_pic_interlace_e : 1;
RK_U32 sw_pjpeg_e : 1;
RK_U32 sw_divx3_e : 1;
RK_U32 sw_rlc_mode_e : 1;
RK_U32 sw_ch_8pix_ileav_e : 1;
RK_U32 sw_start_code_e : 1;
RK_U32 resever1 : 8;
RK_U32 sw_dec_ahb_hlock_e : 1;
} reg57_enable_ctrl;
RK_U32 reg58_soft_rest;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_0_2 : 10;
RK_U32 sw_pred_bc_tap_0_1 : 10;
RK_U32 sw_pred_bc_tap_0_0 : 10;
} reg59;
RK_U32 reg60_addit_ch_st_base;
RK_U32 reg61_qtable_base;
RK_U32 reg62_directmv_base;
RK_U32 reg63_dec_out_base;
RK_U32 reg64_rlc_vlc_base;
struct {
RK_U32 sw_refbu_y_offset : 9;
RK_U32 sw_reserve : 3;
RK_U32 sw_refbu_fparmod_e : 1;
RK_U32 sw_refbu_eval_e : 1;
RK_U32 sw_refbu_picid : 5;
RK_U32 sw_refbu_thr : 12;
RK_U32 sw_refbu_e : 1;
} reg65_refpicbuf_ctrl;
struct {
RK_U32 build_version : 3;
RK_U32 product_IDen : 1;
RK_U32 minor_version : 8;
RK_U32 major_version : 4;
RK_U32 product_numer : 16;
} reg66_id;
struct {
RK_U32 sw_reserve : 25;
RK_U32 sw_dec_rtl_rom : 1;
RK_U32 sw_dec_rv_prof : 2;
RK_U32 sw_ref_buff2_exist : 1;
RK_U32 sw_dec_divx_prof : 1;
RK_U32 sw_dec_refbu_ilace : 1;
RK_U32 sw_dec_jpeg_exten : 1;
} reg67_synthesis_cfg;
struct {
RK_U32 sw_refbu_top_sum : 16;
RK_U32 sw_refbu_bot_sum : 16;
} reg68_sum_of_partitions;
struct {
RK_U32 sw_refbu_intra_sum : 16;
RK_U32 sw_refbu_hit_sum : 16;
} reg69_sum_inf;
struct {
RK_U32 sw_refbu_mv_sum : 22;
RK_U32 sw_reserve : 10;
} reg70_sum_mv;
RK_U32 reg71_119_reserve[49];
struct {
RK_U32 sw_pic_mb_h_ext : 3;
RK_U32 sw_pic_mb_w_ext : 3;
RK_U32 sw_alt_scan_e : 1;
RK_U32 sw_mb_height_off : 4;
RK_U32 sw_pic_mb_hight_p : 8;
RK_U32 sw_mb_width_off : 4;
RK_U32 sw_pic_mb_width : 9;
} reg120;
struct {
RK_U32 sw_pjpeg_se : 8;
RK_U32 sw_pjpeg_ss : 8;
RK_U32 sw_pjpeg_al : 4;
RK_U32 sw_pjpeg_ah : 4;
RK_U32 sw_pjpeg_hdiv8 : 1;
RK_U32 sw_pjpeg_wdiv8 : 1;
RK_U32 sw_pjpeg_fildown_e : 1;
} reg121;
struct {
RK_U32 sw_cb_dc_vlctable3 : 1;
RK_U32 sw_cr_dc_vlctable3 : 1;
RK_U32 sw_cb_dc_vlctable : 1;
RK_U32 sw_cr_dc_vlctable : 1;
RK_U32 sw_cb_ac_vlctable : 1;
RK_U32 sw_cr_ac_vlctable : 1;
RK_U32 sw_jpeg_stream_all : 1;
RK_U32 sw_jpeg_filright_e : 1;
RK_U32 sw_jpeg_mode : 3;
RK_U32 sw_jpeg_qtables : 2;
RK_U32 sw_reserved_1 : 12;
RK_U32 sw_sync_marker_e : 1;
RK_U32 sw_strm_start_bit : 6;
} reg122;
struct {
RK_U32 sw_pjpeg_rest_freq : 16;
} reg123;
struct {
RK_U32 sw_stream1_len : 24;
RK_U32 sw_coeffs_part_am : 4;
RK_U32 sw_resever : 4;
} reg124;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_5_3 : 10;
RK_U32 sw_pred_bc_tap_5_2 : 10;
RK_U32 sw_pred_bc_tap_5_1 : 10;
} reg125;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_6_2 : 10;
RK_U32 sw_pred_bc_tap_6_1 : 10;
RK_U32 sw_pred_bc_tap_6_0 : 10;
} reg126;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_7_1 : 10;
RK_U32 sw_pred_bc_tap_7_0 : 10;
RK_U32 sw_pred_bc_tap_6_3 : 10;
} reg127;
struct {
RK_U32 sw_pred_tap_6_4 : 2;
RK_U32 sw_pred_tap_6_M1 : 2;
RK_U32 sw_pred_tap_4_4 : 2;
RK_U32 sw_pred_tap_4_M1 : 2;
RK_U32 sw_pred_tap_2_4 : 2;
RK_U32 sw_pred_tap_2_M1 : 2;
RK_U32 sw_pred_bc_tap_7_3 : 10;
RK_U32 sw_pred_bc_tap_7_2 : 10;
} reg128;
struct {
RK_U32 sw_filt_level_3 : 6;
RK_U32 sw_filt_level_2 : 6;
RK_U32 sw_filt_level_1 : 6;
RK_U32 sw_filt_level_0 : 6;
RK_U32 resever : 8;
} reg129;
struct {
RK_U32 sw_quant_1 : 11;
RK_U32 sw_quant_0 : 11;
RK_U32 sw_quant_delta_1 : 5;
RK_U32 sw_quant_delta_0 : 5;
} reg130;
RK_U32 reg131_jpg_ch_out_base;
struct {
RK_U32 sw_filt_mb_adj_3 : 7;
RK_U32 sw_filt_mb_adj_2 : 7;
RK_U32 sw_filt_mb_adj_1 : 7;
RK_U32 sw_filt_mb_adj_0 : 7;
RK_U32 sw_filt_sharpness : 3;
RK_U32 sw_filt_type : 1;
} reg132;
struct {
RK_U32 sw_filt_ref_adj_3 : 7;
RK_U32 sw_filt_ref_adj_2 : 7;
RK_U32 sw_filt_ref_adj_1 : 7;
RK_U32 sw_filt_ref_adj_0 : 7;
RK_U32 sw_resver : 4;
} reg133;
struct {
RK_U32 sw_ac1_code1_cnt : 2;
RK_U32 sw_reserved_1 : 1;
RK_U32 sw_ac1_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_ac1_code3_cnt : 4;
RK_U32 sw_ac1_code4_cnt : 5;
RK_U32 sw_ac1_code5_cnt : 6;
RK_U32 sw_reserved_3 : 2;
RK_U32 sw_ac1_code6_cnt : 7;
}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 {
RK_U32 sw_ac1_code11_cnt : 8;
RK_U32 sw_ac1_code12_cnt : 8;
RK_U32 sw_ac1_code13_cnt : 8;
RK_U32 sw_ac1_code14_cnt : 8;
}reg136;
struct {
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;
struct {
RK_U32 sw_ac2_code5_cnt : 6;
RK_U32 sw_reserved_1 : 2;
RK_U32 sw_ac2_code6_cnt : 7;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_ac2_code7_cnt : 8;
RK_U32 sw_ac2_code8_cnt : 8;
} reg138;
struct {
RK_U32 sw_ac2_code9_cnt : 8;
RK_U32 sw_ac2_code10_cnt : 8;
RK_U32 sw_ac2_code11_cnt : 8;
RK_U32 sw_ac2_code12_cnt : 8;
}reg139;
struct {
RK_U32 sw_ac2_code13_cnt : 8;
RK_U32 sw_ac2_code14_cnt : 8;
RK_U32 sw_ac2_code15_cnt : 8;
RK_U32 sw_ac2_code16_cnt : 8;
}reg140;
struct {
RK_U32 sw_dc1_code1_cnt : 2;
RK_U32 sw_reserved_1 : 2;
RK_U32 sw_dc1_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_dc1_code3_cnt : 4;
RK_U32 sw_dc1_code4_cnt : 4;
RK_U32 sw_dc1_code5_cnt : 4;
RK_U32 sw_dc1_code6_cnt : 4;
RK_U32 sw_dc1_code7_cnt : 4;
RK_U32 sw_dc1_code8_cnt : 4;
}reg141;
struct {
RK_U32 sw_dc1_code9_cnt : 4;
RK_U32 sw_dc1_code10_cnt : 4;
RK_U32 sw_dc1_code11_cnt : 4;
RK_U32 sw_dc1_code12_cnt : 4;
RK_U32 sw_dc1_code13_cnt : 4;
RK_U32 sw_dc1_code14_cnt : 4;
RK_U32 sw_dc1_code15_cnt : 4;
RK_U32 sw_dc1_code16_cnt : 4;
}reg142;
struct {
RK_U32 sw_dc2_code1_cnt : 2;
RK_U32 sw_reserved_1 : 2;
RK_U32 sw_dc2_code2_cnt : 3;
RK_U32 sw_reserved_2 : 1;
RK_U32 sw_dc2_code3_cnt : 4;
RK_U32 sw_dc2_code4_cnt : 4;
RK_U32 sw_dc2_code5_cnt : 4;
RK_U32 sw_dc2_code6_cnt : 4;
RK_U32 sw_dc2_code7_cnt : 4;
RK_U32 sw_dc2_code8_cnt : 4;
}reg143;
struct {
RK_U32 sw_dc2_code9_cnt : 4;
RK_U32 sw_dc2_code10_cnt : 4;
RK_U32 sw_dc2_code11_cnt : 4;
RK_U32 sw_dc2_code12_cnt : 4;
RK_U32 sw_dc2_code13_cnt : 4;
RK_U32 sw_dc2_code14_cnt : 4;
RK_U32 sw_dc2_code15_cnt : 4;
RK_U32 sw_dc2_code16_cnt : 4;
}reg144;
RK_U32 reg145_bitpl_ctrl_base;
RK_U32 reg_dct_strm1_base[2];
struct {
RK_U32 sw_slice_h : 8;
RK_U32 sw_resver : 24;
} reg148;
RK_U32 reg149_segment_map_base;
struct {
RK_U32 sw_dct_start_bit_7 : 6;
RK_U32 sw_dct_start_bit_6 : 6;
RK_U32 sw_dct_start_bit_5 : 6;
RK_U32 sw_dct_start_bit_4 : 6;
RK_U32 sw_dct_start_bit_3 : 6;
RK_U32 sw_resver : 2;
} reg150;
struct {
RK_U32 sw_quant_3 : 11;
RK_U32 sw_quant_2 : 11;
RK_U32 sw_quant_delta_3 : 5;
RK_U32 sw_quant_delta_2 : 5;
} reg151;
struct {
RK_U32 sw_quant_5 : 11;
RK_U32 sw_quant_4 : 11;
RK_U32 sw_quant_delta_4 : 5;
RK_U32 sw_resver : 5;
} reg152;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_1_1 : 10;
RK_U32 sw_pred_bc_tap_1_0 : 10;
RK_U32 sw_pred_bc_tap_0_3 : 10;
} reg153;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_2_0 : 10;
RK_U32 sw_pred_bc_tap_1_3 : 10;
RK_U32 sw_pred_bc_tap_1_2 : 10;
} reg154;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_2_3 : 10;
RK_U32 sw_pred_bc_tap_2_2 : 10;
RK_U32 sw_pred_bc_tap_2_1 : 10;
} reg155;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_3_2 : 10;
RK_U32 sw_pred_bc_tap_3_1 : 10;
RK_U32 sw_pred_bc_tap_3_0 : 10;
} reg156;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_4_1 : 10;
RK_U32 sw_pred_bc_tap_4_0 : 10;
RK_U32 sw_pred_bc_tap_3_3 : 10;
} reg157;
struct {
RK_U32 resever : 2;
RK_U32 sw_pred_bc_tap_5_0 : 10;
RK_U32 sw_pred_bc_tap_4_3 : 10;
RK_U32 sw_pred_bc_tap_4_2 : 10;
} reg158;
} JpegRegSet;
typedef struct JpegHalContext {
MppBufSlots packet_slots;
MppBufSlots frame_slots;
RK_S32 vpu_socket;
JpegRegSet regs;
MppBufferGroup group;
MppBuffer frame_buf;
MppBuffer pTableBase;
RK_U32 hal_debug_enable;
RK_U32 frame_count;
RK_U32 output_yuv_count;
FILE *fp_reg_in;
FILE *fp_reg_out;
}JpegHalContext;
#endif /* __HAL_JPEGD_REG_H__ */

View File

@@ -43,6 +43,7 @@ static MppCodingTypeInfo support_list[] = {
{ MPP_CTX_DEC, MPP_VIDEO_CodingVP8, "dec", "vp8", }, { MPP_CTX_DEC, MPP_VIDEO_CodingVP8, "dec", "vp8", },
{ MPP_CTX_DEC, MPP_VIDEO_CodingVP9, "dec", "VP9", }, { MPP_CTX_DEC, MPP_VIDEO_CodingVP9, "dec", "VP9", },
{ MPP_CTX_DEC, MPP_VIDEO_CodingAVS, "dec", "avs+", }, { MPP_CTX_DEC, MPP_VIDEO_CodingAVS, "dec", "avs+", },
// { MPP_CTX_DEC, MPP_VIDEO_CodingMJPEG, "dec", "jpeg", },
{ MPP_CTX_ENC, MPP_VIDEO_CodingAVC, "enc", "h.264/AVC", }, { MPP_CTX_ENC, MPP_VIDEO_CodingAVC, "enc", "h.264/AVC", },
}; };

View File

@@ -36,3 +36,7 @@ if (${HAVE_AVSD})
include_directories(../codec/dec/avs) include_directories(../codec/dec/avs)
add_mpp_test(avsd) add_mpp_test(avsd)
endif() endif()
# jpeg decoder test
include_directories(../codec/dec/jpeg)
add_mpp_test(jpegd)

570
mpp/test/jpegd_test.c Normal file
View File

@@ -0,0 +1,570 @@
/*
* Copyright 2015 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define MODULE_TAG "JPEGD_TEST"
#include <string.h>
#include "mpp_env.h"
#include "mpp_err.h"
#include "mpp_log.h"
#include "mpp_mem.h"
#include "mpp_common.h"
#include "mpp_dec.h"
#include "mpp_frame.h"
#include "jpegd_api.h"
#include "jpegd_syntax.h"
#include "hal_jpegd_api.h"
#include "utils.h"
#define JPEGD_STREAM_BUFF_SIZE (10*1024*1024)
typedef enum VPU_API_DEMO_RET {
PARSER_DEMO_OK = 0,
PARSER_DEMO_PARSE_HELP_OK = 1,
PARSER_DEMO_ERROR_BASE = -100,
ERROR_INVALID_PARAM = PARSER_DEMO_ERROR_BASE - 1,
ERROR_INVALID_STREAM = PARSER_DEMO_ERROR_BASE - 2,
ERROR_IO = PARSER_DEMO_ERROR_BASE - 3,
ERROR_MEMORY = PARSER_DEMO_ERROR_BASE - 4,
ERROR_INIT_VPU = PARSER_DEMO_ERROR_BASE - 5,
ERROR_VPU_DECODE = PARSER_DEMO_ERROR_BASE - 90,
} PARSER_API_DEMO_RET;
typedef struct parserDemoCmdCtx {
char input_file[200];
char output_file[200];
RK_U32 width;
RK_U32 height;
RK_U8 have_input;
RK_U8 have_output;
RK_U8 disable_debug;
RK_U32 record_frames;
RK_S64 record_start_ms;
} parserDemoCmdCtx;
typedef struct jpegdDemoCtx {
parserDemoCmdCtx *cfg;
MppDec api;
HalDecTask task;
MppBuffer pkt_buf;
MppBuffer pic_buf;
MppBufferGroup frmbuf_grp;
MppBufferGroup strmbuf_grp;
MppPacket pkt;
FILE* pOutFile;
RK_U8 *strmbuf;
RK_U32 strmbytes;
RK_U32 dec_frm_num;
}jpegdDemoCtx;
static OptionInfo jpeg_parserCmd[] = {
{"i", "input_file", "input bitstream file"},
{"o", "output_file", "output bitstream file, "},
{"w", "width", "the width of input bitstream"},
{"h", "height", "the height of input bitstream"},
{"vframes", "number", "set the number of video frames to record"},
{"ss", "time_off", "set the start time offset, use Ms as the unit."},
{"d", "disable", "disable the debug output info."},
};
MPP_RET jpegd_readbytes_from_file(RK_U8* buf, RK_S32 aBytes, FILE* fp)
{
MPP_RET ret = MPP_OK;
if ((NULL == buf) || (NULL == fp) || (0 == aBytes)) {
return -1;
}
RK_S32 rd_bytes = fread(buf, 1, aBytes, fp);
if(rd_bytes != aBytes){
mpp_log("read %u bytes from file fail, actually only %#x bytes is read.", (RK_U32)aBytes, rd_bytes);
return -1;
}
mpp_log("read %d bytes from file sucessfully, the first 4 bytes: %08x", rd_bytes, *((RK_U32*)buf));
return ret;
}
static void jpeg_show_usage()
{
mpp_log("usage: parserDemo [options] input_file, \n\n");
mpp_log("Getting help:\n");
mpp_log("-help --print options of vpu api demo\n");
}
static void jpeg_show_options(int count, OptionInfo *options)
{
int i;
for (i = 0; i < count; i++) {
mpp_log("-%s %-16s\t%s\n",
options[i].name, options[i].argname, options[i].help);
}
}
static RK_S32 jpeg_show_help()
{
mpp_log("usage: parserDemo [options] input_file, \n\n");
jpeg_show_options(sizeof(jpeg_parserCmd)/sizeof(OptionInfo), jpeg_parserCmd);
return 0;
}
static RK_S32 jpeg_parse_options(int argc, char **argv, parserDemoCmdCtx* cmdCxt)
{
mpp_log("jpeg_parse_options enter\n");
const char *opt;
RK_S32 optindex, handleoptions = 1, ret = 0;
if ((argc < 2) || (cmdCxt == NULL)) {
mpp_log("parser demo, input parameter invalid\n");
jpeg_show_usage();
return MPP_ERR_STREAM;
}
/* parse options */
optindex = 1;
while (optindex < argc) {
opt = (const char*)argv[optindex++];
if (handleoptions && opt[0] == '-' && opt[1] != '\0') {
if (opt[1] == '-') {
if (opt[2] != '\0') {
opt++;
} else {
handleoptions = 0;
continue;
}
}
opt++;
switch (*opt) {
case 'i':
if (argv[optindex]) {
memcpy(cmdCxt->input_file, argv[optindex], strlen(argv[optindex]));
cmdCxt->input_file[strlen(argv[optindex])] = '\0';
cmdCxt->have_input = 1;
} else {
mpp_log("input file is invalid\n");
ret = -1;
goto PARSE_OPINIONS_OUT;
}
break;
case 'o':
if (argv[optindex]) {
memcpy(cmdCxt->output_file, argv[optindex], strlen(argv[optindex]));
cmdCxt->output_file[strlen(argv[optindex])] = '\0';
cmdCxt->have_output = 1;
break;
} else {
mpp_log("out file is invalid\n");
ret = -1;
goto PARSE_OPINIONS_OUT;
}
case 'd':
cmdCxt->disable_debug = 1;
break;
case 'w':
if (argv[optindex]) {
cmdCxt->width = atoi(argv[optindex]);
break;
} else {
mpp_log("input width is invalid\n");
ret = -1;
goto PARSE_OPINIONS_OUT;
}
case 'h':
if ((*(opt + 1) != '\0') && !strncmp(opt, "help", 4)) {
jpeg_show_help();
ret = PARSER_DEMO_PARSE_HELP_OK;
goto PARSE_OPINIONS_OUT;
} else if (argv[optindex]) {
cmdCxt->height = atoi(argv[optindex]);
} else {
mpp_log("input height is invalid\n");
ret = -1;
goto PARSE_OPINIONS_OUT;
}
break;
default:
if ((*(opt + 1) != '\0') && argv[optindex]) {
if (!strncmp(opt, "vframes", 7)) {
cmdCxt->record_frames = atoi(argv[optindex]);
} else if (!strncmp(opt, "ss", 2)) {
cmdCxt->record_start_ms = atoi(argv[optindex]);
} else {
ret = -1;
goto PARSE_OPINIONS_OUT;
}
} else {
ret = -1;
goto PARSE_OPINIONS_OUT;
}
break;
}
optindex += ret;
}
}
PARSE_OPINIONS_OUT:
if (ret < 0) {
mpp_log("vpu api demo, input parameter invalid\n");
jpeg_show_usage();
return MPP_ERR_STREAM;
}
mpp_log("jpeg_parse_options exit\n");
return ret;
}
MPP_RET jpegd_test_deinit(jpegdDemoCtx *ctx)
{
FUN_TEST("Enter");
MppDec *pApi = &(ctx->api);
if (pApi->parser) {
parser_deinit(pApi->parser);
pApi->parser = NULL;
}
if (pApi->hal) {
mpp_hal_deinit(pApi->hal);
pApi->hal = NULL;
}
if (pApi->frame_slots) {
mpp_buf_slot_deinit(pApi->frame_slots);
pApi->frame_slots = NULL;
}
if (pApi->packet_slots) {
mpp_buf_slot_deinit(pApi->packet_slots);
pApi->packet_slots = NULL;
}
if (ctx->pic_buf) {
mpp_buffer_put(ctx->pic_buf);
}
if (ctx->frmbuf_grp) {
mpp_err("frmbuf_grp deinit");
mpp_buffer_group_put(ctx->frmbuf_grp);
}
if (ctx->strmbuf_grp) {
mpp_err("strmbuf_grp deinit");
mpp_buffer_group_put(ctx->strmbuf_grp);
}
if(ctx->strmbuf) {
mpp_err("strmbuf free");
mpp_free(ctx->strmbuf);
}
if(ctx->pOutFile){
mpp_err("close output file");
fclose(ctx->pOutFile);
ctx->pOutFile = NULL;
}
FUN_TEST("Exit");
return MPP_OK;
}
MPP_RET jpegd_test_init(parserDemoCmdCtx *cmd, jpegdDemoCtx *ctx)
{
FUN_TEST("Enter");
MPP_RET ret = MPP_OK;
MppDec *pMppDec = NULL;
ParserCfg parser_cfg;
MppHalCfg hal_cfg;
memset(ctx, 0, sizeof(jpegdDemoCtx));
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
CHECK_MEM(ctx->strmbuf = mpp_malloc_size(RK_U8, JPEGD_STREAM_BUFF_SIZE));
//malloc buffers for hardware
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));
CHECK_MEM(pMppDec->frame_slots);
mpp_buf_slot_setup(pMppDec->frame_slots, 2);
CHECK_FUN(mpp_buf_slot_init(&pMppDec->packet_slots));
CHECK_MEM(pMppDec->packet_slots);
mpp_buf_slot_setup(pMppDec->packet_slots, 2);
//parser config
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:
FUN_TEST("Exit");
return ret;
}
MPP_RET jpegd_parser_test(parserDemoCmdCtx *cmd)
{
FUN_TEST("Enter");
MPP_RET ret = MPP_OK;
MppDec *pMppDec = NULL;
HalDecTask *curtask = NULL;
jpegdDemoCtx DemoCtx;
FILE* pInFile = NULL;
RK_S32 fileSize = 0;
// 1.jpegd_test_init
jpegd_test_init(cmd, &DemoCtx);
pMppDec = &DemoCtx.api;
curtask = &DemoCtx.task;
do {
RK_S32 slot_idx = 0;
if (cmd->have_input) {
mpp_log("input bitstream w: %d, h: %d, path: %s\n",
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);
fileSize = ftell(pInFile);
fseek(pInFile, 0L, SEEK_SET);
// 2.jpegd_readbytes_from_file
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);
// 3.parser_prepare
CHECK_FUN(parser_prepare(pMppDec->parser, DemoCtx.pkt, curtask)); // jpegd_parser_prepare
if (-1 == curtask->input) {
if (MPP_OK == mpp_buf_slot_get_unused(pMppDec->packet_slots, &slot_idx) ) {
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,
mpp_packet_get_data(curtask->input_packet),
mpp_packet_get_size(curtask->input_packet));
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_set_flag(pMppDec->packet_slots, curtask->input, SLOT_HAL_INPUT);
}
}
CHECK_FUN(parser_parse(pMppDec->parser, curtask)); // jpegd_parser_parse
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) {
fwrite(pOutYUV, 1, width * height * 3 / 2, 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);
mpp_buf_slot_clr_flag(pMppDec->frame_slots, curtask->output, SLOT_HAL_OUTPUT);
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));
__FAILED:
if(pInFile){
fclose(pInFile);
pInFile = NULL;
}
jpegd_test_deinit(&DemoCtx);
FUN_TEST("Exit");
return MPP_OK;
}
int main(int argc, char **argv)
{
FUN_TEST("Enter");
RK_S32 ret = 0;
parserDemoCmdCtx demoCmdCtx;
parserDemoCmdCtx* cmd = NULL;
if (argc == 1) {
jpeg_show_usage();
mpp_log("jpegd test demo complete directly\n");
return MPP_OK;
}
mpp_env_get_u32("mpp_debug", &mpp_debug, 0);
cmd = &demoCmdCtx;
memset((void*)cmd, 0, sizeof(parserDemoCmdCtx));
if ((ret = jpeg_parse_options(argc, argv, cmd)) != 0) {
if (ret == PARSER_DEMO_PARSE_HELP_OK) {
return MPP_OK;
}
mpp_log("parse_options fail\n\n");
jpeg_show_usage();
return MPP_OK;
}
jpegd_parser_test(cmd);
FUN_TEST("Exit");
return MPP_OK;
}