2 * Copyright Samsung Electronics Co.,LTD.
3 * Copyright (C) 2010 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef EXYNOS_JPEG_ENCODER_FOR_CAMERA_H_
19 #define EXYNOS_JPEG_ENCODER_FOR_CAMERA_H_
21 #include "ExynosExif.h"
23 #include "ExynosJpegApi.h"
28 #define MAX_IMAGE_PLANE_NUM (3)
30 class ExynosJpegEncoderForCamera
{
34 ERROR_ALREADY_CREATE
= -0x200,
35 ERROR_CANNOT_CREATE_EXYNOS_JPEG_ENC_HAL
,
36 ERROR_NOT_YET_CREATED
,
37 ERROR_ALREADY_DESTROY
,
38 ERROR_INPUT_DATA_SIZE_TOO_LARGE
,
39 ERROR_OUT_BUFFER_SIZE_TOO_SMALL
,
40 ERROR_EXIFOUT_ALLOC_FAIL
,
42 ERROR_INVALID_SCALING_WIDTH_HEIGHT
,
43 ERROR_CANNOT_CREATE_SEC_THUMB
,
44 ERROR_THUMB_JPEG_SIZE_TOO_SMALL
,
45 ERROR_IMPLEMENT_NOT_YET
,
47 ERROR_JPEG_DEVICE_ALREADY_CREATE
= -0x100,
48 ERROR_CANNOT_OPEN_JPEG_DEVICE
,
49 ERROR_JPEG_DEVICE_ALREADY_CLOSED
,
50 ERROR_JPEG_DEVICE_ALREADY_DESTROY
,
51 ERROR_JPEG_DEVICE_NOT_CREATE_YET
,
52 ERROR_INVALID_COLOR_FORMAT
,
53 ERROR_INVALID_JPEG_FORMAT
,
54 ERROR_JPEG_CONFIG_POINTER_NULL
,
55 ERROR_INVALID_JPEG_CONFIG
,
56 ERROR_IN_BUFFER_CREATE_FAIL
,
57 ERROR_OUT_BUFFER_CREATE_FAIL
,
59 ERROR_JPEG_SIZE_TOO_SMALL
,
60 ERROR_CANNOT_CHANGE_CACHE_SETTING
,
61 ERROR_SIZE_NOT_SET_YET
,
63 ERROR_BUFFER_TOO_SMALL
,
66 ERROR_INVALID_V4l2_BUF_TYPE
= -0x80,
72 ExynosJpegEncoderForCamera();
73 virtual ~ExynosJpegEncoderForCamera();
79 int setSize(int w
, int h
);
80 int setQuality(int quality
);
81 int setColorFormat(int colorFormat
);
82 int setJpegFormat(int jpegFormat
);
84 int updateConfig(void);
86 int setInBuf(int *buf
, char** vBuf
, int *size
);
87 int setOutBuf(int buf
, char* vBuf
, int size
);
89 int encode(int *size
, exif_attribute_t
*exifInfo
);
91 int setThumbnailSize(int w
, int h
);
92 int setThumbnailQuality(int quality
);
94 int makeExif(unsigned char *exifOut
,
95 exif_attribute_t
*exifIn
,
97 bool useMainbufForThumb
= false);
100 inline void writeExifIfd(unsigned char **pCur
,
105 inline void writeExifIfd(unsigned char **pCur
,
109 unsigned char *pValue
);
110 inline void writeExifIfd(unsigned char **pCur
,
115 unsigned int *offset
,
116 unsigned char *start
);
117 inline void writeExifIfd(unsigned char **pCur
,
121 unsigned char *pValue
,
122 unsigned int *offset
,
123 unsigned char *start
);
124 int scaleDownYuv422(char **srcBuf
, unsigned int srcW
, unsigned int srcH
,
125 char **dstBuf
, unsigned int dstW
, unsigned int dstH
);
126 int scaleDownYuv422_2p(char **srcBuf
, unsigned int srcW
, unsigned int srcH
,
127 char **dstBuf
, unsigned int dstW
, unsigned int dstH
);
129 int encodeThumbnail(unsigned int *size
, bool useMain
= true);
132 ion_client ionClient
;
133 ion_buffer ionBuffer
[MAX_IMAGE_PLANE_NUM
];
134 char *pcBuf
[MAX_IMAGE_PLANE_NUM
];
135 int iSize
[MAX_IMAGE_PLANE_NUM
];
138 int createIonClient(ion_client ionClient
);
139 int deleteIonClient(ion_client ionClient
);
140 int allocJpegMemory(struct stJpegMem
*pstMem
, int iMemoryNum
);
141 void freeJpegMemory(struct stJpegMem
*pstMem
, int iMemoryNum
);
142 void initJpegMemory(struct stJpegMem
*pstMem
, int iMemoryNum
);
146 ExynosJpegEncoder
*m_jpegMain
;
147 ExynosJpegEncoder
*m_jpegThumb
;
149 ion_client m_ionJpegClient
;
150 struct stJpegMem m_stThumbInBuf
;
151 struct stJpegMem m_stThumbOutBuf
;
152 struct stJpegMem m_stMainInBuf
;
153 struct stJpegMem m_stMainOutBuf
;
157 int m_thumbnailQuality
;
160 #endif /* __SEC_JPG_ENC_H__ */