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 JPEG_THUMBNAIL_QUALITY 60
29 #define EXIF_LIMIT_SIZE 64*1024
30 //#define JPEG_WA_FOR_PAGEFAULT
31 #define JPEG_WA_BUFFER_SIZE 64
33 class ExynosJpegEncoderForCamera
{
37 ERROR_ALREADY_CREATE
= -0x200,
38 ERROR_CANNOT_CREATE_EXYNOS_JPEG_ENC_HAL
,
39 ERROR_NOT_YET_CREATED
,
40 ERROR_ALREADY_DESTROY
,
41 ERROR_INPUT_DATA_SIZE_TOO_LARGE
,
42 ERROR_OUT_BUFFER_SIZE_TOO_SMALL
,
43 ERROR_EXIFOUT_ALLOC_FAIL
,
45 ERROR_INVALID_SCALING_WIDTH_HEIGHT
,
46 ERROR_CANNOT_CREATE_SEC_THUMB
,
47 ERROR_THUMB_JPEG_SIZE_TOO_SMALL
,
48 ERROR_IMPLEMENT_NOT_YET
,
49 ERROR_JPEG_DEVICE_ALREADY_CREATE
= -0x100,
50 ERROR_CANNOT_OPEN_JPEG_DEVICE
,
51 ERROR_JPEG_DEVICE_ALREADY_CLOSED
,
52 ERROR_JPEG_DEVICE_ALREADY_DESTROY
,
53 ERROR_JPEG_DEVICE_NOT_CREATE_YET
,
54 ERROR_INVALID_COLOR_FORMAT
,
55 ERROR_INVALID_JPEG_FORMAT
,
56 ERROR_JPEG_CONFIG_POINTER_NULL
,
57 ERROR_INVALID_JPEG_CONFIG
,
58 ERROR_IN_BUFFER_CREATE_FAIL
,
59 ERROR_OUT_BUFFER_CREATE_FAIL
,
61 ERROR_JPEG_SIZE_TOO_SMALL
,
62 ERROR_CANNOT_CHANGE_CACHE_SETTING
,
63 ERROR_SIZE_NOT_SET_YET
,
65 ERROR_BUFFER_TOO_SMALL
,
68 ERROR_INVALID_V4l2_BUF_TYPE
= -0x80,
74 ExynosJpegEncoderForCamera();
75 virtual ~ExynosJpegEncoderForCamera();
81 int setSize(int w
, int h
);
82 int setQuality(int quality
);
83 int setColorFormat(int colorFormat
);
84 int setJpegFormat(int jpegFormat
);
86 int updateConfig(void);
88 int setInBuf(char **buf
, int *size
);
89 int setOutBuf(char *buf
, int size
);
91 int encode(int *size
, exif_attribute_t
*exifInfo
);
93 int setThumbnailSize(int w
, int h
);
94 int setThumbnailQuality(int quality
);
96 int makeExif(unsigned char *exifOut
,
97 exif_attribute_t
*exifIn
,
99 bool useMainbufForThumb
= false);
102 inline void writeExifIfd(unsigned char **pCur
,
107 inline void writeExifIfd(unsigned char **pCur
,
111 unsigned char *pValue
);
112 inline void writeExifIfd(unsigned char **pCur
,
117 unsigned int *offset
,
118 unsigned char *start
);
119 inline void writeExifIfd(unsigned char **pCur
,
123 unsigned char *pValue
,
124 unsigned int *offset
,
125 unsigned char *start
);
126 int scaleDownYuv422(char **srcBuf
, unsigned int srcW
, unsigned int srcH
,
127 char **dstBuf
, unsigned int dstW
, unsigned int dstH
);
128 int scaleDownYuv422_2p(char **srcBuf
, unsigned int srcW
, unsigned int srcH
,
129 char **dstBuf
, unsigned int dstW
, unsigned int dstH
);
131 int encodeThumbnail(unsigned int *size
, bool useMain
= true);
133 int allocJpegIonMemory(ion_client ionClient
, ion_buffer
*ionBuffer
, char **buffer
, int size
);
134 void freeJpegIonMemory(ion_client ionClient
, ion_buffer
*ionBuffer
, char **buffer
, int size
);
138 ExynosJpegEncoder
*m_jpegMain
;
139 ExynosJpegEncoder
*m_jpegThumb
;
141 char *m_pThumbInputBuffer
;
142 char *m_pThumbOutputBuffer
;
143 #ifdef JPEG_WA_FOR_PAGEFAULT
145 char *m_pJpegInputBuffer
;
147 #endif // JPEG_WA_FOR_PAGEFAULT
148 ion_client m_ionJpegClient
;
149 ion_buffer m_ionThumbInBuffer
, m_ionThumbOutBuffer
;
150 #ifdef JPEG_WA_FOR_PAGEFAULT
151 ion_buffer m_ionJpegInBuffer
;
152 #endif // JPEG_WA_FOR_PAGEFAULT
156 int m_thumbnailQuality
;
159 #endif /* __SEC_JPG_ENC_H__ */