forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-08-21 fc437ccf3419c424092701f3d883215fa4552a8b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*------------------------------------------------------------------------------
--                                                                            --
--       This software is confidential and proprietary and may be used        --
--        only as expressly authorized by a licensing agreement from          --
--                                                                            --
--                            Rockchip Products .                             --
--                                                                            --
--                   (C) COPYRIGHT 2014 ROCKCHIP PRODUCTS                     --
--                            ALL RIGHTS RESERVED                             --
--                                                                            --
--                 The entire notice above must be reproduced                 --
--                  on all copies and should not be removed.                  --
--                                                                            --
--------------------------------------------------------------------------------
--
--  Description : JPEG decoder header file
--
------------------------------------------------------------------------------
--
--
--
------------------------------------------------------------------------------*/
#ifndef __JPEGDECAPI_H__
#define __JPEGDECAPI_H__
 
#ifdef __cplusplus
extern "C"
{
#endif
 
/*------------------------------------------------------------------------------
 
    Table of contents
 
    1. Include headers
    2. External compiler flags
    3. Module defines
    4. Local function prototypes
    5. Functions
 
------------------------------------------------------------------------------*/
 
/*------------------------------------------------------------------------------
    1. Include headers
------------------------------------------------------------------------------*/
#include "vpu_type.h"
#include "decapicommon.h"
#include "allocator_drm.h"
#ifndef DRM_LINUX
#include "vpu.h"
#include "vpu_api.h"
#endif
 
/*------------------------------------------------------------------------------
    2. Module defines
------------------------------------------------------------------------------*/
#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
 
/*------------------------------------------------------------------------------
    3. Data types
------------------------------------------------------------------------------*/
 
typedef void *JpegDecInst;
 
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;
 
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
};
 
typedef struct {
    RK_U32 *pVirtualAddress;
    RK_U32 busAddress;
} JpegDecLinearMem;
 
/* 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;
 
/* Decoder input JFIF information */
typedef struct {
    JpegDecLinearMem streamBuffer;  /* input stream buffer */
    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 */
    JpegDecLinearMem pictureBufferY;    /* luma output address ==> if user allocated */
    JpegDecLinearMem pictureBufferCbCr; /* chroma output address ==> if user allocated */
    JpegDecLinearMem pictureBufferCr; /* chroma output address ==> if user allocated */
#ifdef DRM_LINUX
    MppBufferInfo *pstreamMem;
#else
   VPUMemLinear_t *pstreamMem;
#endif
} JpegDecInput;
 
/* Decoder output */
typedef struct {
    JpegDecLinearMem outputPictureY;    /* Pointer to the Luma output image */
    JpegDecLinearMem outputPictureCbCr; /* Pointer to the Chroma output image */
    JpegDecLinearMem outputPictureCr; /* Pointer to the Chroma output image */
 
} JpegDecOutput;
 
typedef struct {
    RK_U32 major;  /* API major version */
    RK_U32 minor;  /* API minor version */
 
} JpegDecApiVersion;
 
typedef struct {
    RK_U32 swBuild;    /* Software build ID */
    RK_U32 hwBuild;    /* Hardware build ID */
    DecHwConfig hwConfig;   /* hardware supported configuration */
 
} JpegDecBuild;
 
/*------------------------------------------------------------------------------
    4. Function prototypes
------------------------------------------------------------------------------*/
 
/* Version information */
JpegDecApiVersion JpegGetAPIVersion(void);
 
/* Build information */
JpegDecBuild JpegDecGetBuild(void);
 
/* Initialization */
JpegDecRet JpegDecInit(JpegDecInst * pDecInst, RK_U32 color_conv);
 
/* Release */
void JpegDecRelease(JpegDecInst decInst);
 
/* Get image information of the JFIF */
JpegDecRet JpegDecGetImageInfo(JpegDecInst decInst,
                               JpegDecInput * pDecIn,
                               JpegDecImageInfo * pImageInfo);
 
/* Decode JFIF */
JpegDecRet JpegDecDecode(JpegDecInst decInst,
                         JpegDecInput * pDecIn, JpegDecOutput * pDecOut);
 
/*------------------------------------------------------------------------------
    Prototype of the API trace funtion. Traces all API entries and returns.
    This must be implemented by the application using the decoder API!
    Argument:
        string - trace message, a null terminated string
------------------------------------------------------------------------------*/
void JpegDecTrace(const char *string);
 
#ifdef __cplusplus
}
#endif
 
#endif