3 ** Copyright 2008, The Android Open Source Project
4 ** Copyright 2012, Samsung Electronics Co. LTD
6 ** Licensed under the Apache License, Version 2.0 (the "License");
7 ** you may not use this file except in compliance with the License.
8 ** You may obtain a copy of the License at
10 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
20 * \file MetadataConverter.cpp
21 * \brief source file for Metadata converter ( for camera hal2 implementation )
22 * \author Sungjoong Kang(sj3.kang@samsung.com)
25 * <b>Revision History: </b>
26 * - 2012/05/31 : Sungjoong Kang(sj3.kang@samsung.com) \n
30 //#define LOG_NDEBUG 0
31 #define LOG_TAG "MetadataConverter"
32 #include <utils/Log.h>
34 #include "MetadataConverter.h"
35 #include "exynos_format.h"
40 MetadataConverter::MetadataConverter()
46 MetadataConverter::~MetadataConverter()
48 ALOGV("DEBUG(%s)destroy!!:", __FUNCTION__
);
52 status_t
MetadataConverter::CheckEntryTypeMismatch(camera_metadata_entry_t
* entry
,
55 if (!(entry
->type
==type
))
57 ALOGV("DEBUG(%s):Metadata Missmatch tag(%s) type (%d) count(%d)",
58 __FUNCTION__
, get_camera_metadata_tag_name(entry
->tag
), entry
->type
, entry
->count
);
64 status_t
MetadataConverter::CheckEntryTypeMismatch(camera_metadata_entry_t
* entry
,
65 uint8_t type
, size_t count
)
67 if (!((entry
->type
==type
)&&(entry
->count
==count
)))
69 ALOGV("DEBUG(%s):Metadata Missmatch tag(%s) type (%d) count(%d)",
70 __FUNCTION__
, get_camera_metadata_tag_name(entry
->tag
), entry
->type
, entry
->count
);
76 status_t
MetadataConverter::ToInternalShot(camera_metadata_t
* request
, struct camera2_shot_ext
* dst_ext
)
78 uint32_t num_entry
= 0;
82 camera_metadata_entry_t curr_entry
;
83 struct camera2_shot
* dst
= NULL
;
85 if (request
== NULL
|| dst_ext
== NULL
)
88 memset((void*)dst_ext
, 0, sizeof(struct camera2_shot_ext
));
91 dst
->magicNumber
= 0x23456789;
92 dst
->ctl
.aa
.aeTargetFpsRange
[0] = 15;
93 dst
->ctl
.aa
.aeTargetFpsRange
[1] = 30;
94 dst
->ctl
.aa
.aeExpCompensation
= 5;
96 num_entry
= (uint32_t)get_camera_metadata_entry_count(request
);
97 for (index
= 0 ; index
< num_entry
; index
++) {
99 if (get_camera_metadata_entry(request
, index
, &curr_entry
)==0) {
100 switch (curr_entry
.tag
) {
102 case ANDROID_LENS_FOCUS_DISTANCE
:
103 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_FLOAT
, 1))
105 dst
->ctl
.lens
.focusDistance
= curr_entry
.data
.f
[0];
108 case ANDROID_LENS_APERTURE
:
109 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_FLOAT
, 1))
111 dst
->ctl
.lens
.aperture
= curr_entry
.data
.f
[0];
114 case ANDROID_LENS_FOCAL_LENGTH
:
115 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_FLOAT
, 1))
117 dst
->ctl
.lens
.focalLength
= curr_entry
.data
.f
[0];
120 case ANDROID_LENS_FILTER_DENSITY
:
121 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_FLOAT
, 1))
123 dst
->ctl
.lens
.filterDensity
= curr_entry
.data
.f
[0];
126 case ANDROID_LENS_OPTICAL_STABILIZATION_MODE
:
127 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
129 dst
->ctl
.lens
.opticalStabilizationMode
=
130 (enum optical_stabilization_mode
)curr_entry
.data
.u8
[0];
134 case ANDROID_SENSOR_TIMESTAMP
:
135 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT64
, 1))
137 dst
->dm
.sensor
.timeStamp
= curr_entry
.data
.i64
[0];
141 case ANDROID_SENSOR_SENSITIVITY
:
142 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
144 dst
->dm
.aa
.isoValue
= curr_entry
.data
.i32
[0];
147 case ANDROID_SENSOR_EXPOSURE_TIME
:
148 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT64
, 1))
150 dst
->dm
.sensor
.exposureTime
= curr_entry
.data
.i64
[0];
154 case ANDROID_FLASH_MODE
:
155 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
157 dst
->ctl
.flash
.flashMode
= (enum flash_mode
)(curr_entry
.data
.u8
[0] + 1);
160 case ANDROID_FLASH_FIRING_POWER
:
161 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
163 dst
->ctl
.flash
.firingPower
= curr_entry
.data
.u8
[0];
166 case ANDROID_FLASH_FIRING_TIME
:
167 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT64
, 1))
169 dst
->ctl
.flash
.firingTime
= curr_entry
.data
.i64
[0];
174 case ANDROID_SCALER_CROP_REGION
:
175 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 4))
178 dst
->ctl
.scaler
.cropRegion
[i
] = ALIGN(curr_entry
.data
.i32
[i
], 2);
182 case ANDROID_JPEG_QUALITY
:
183 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
185 dst
->ctl
.jpeg
.quality
= curr_entry
.data
.i32
[0];
188 case ANDROID_JPEG_THUMBNAIL_SIZE
:
189 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 2))
191 for (i
=0 ; i
<curr_entry
.count
; i
++)
192 dst
->ctl
.jpeg
.thumbnailSize
[i
] = curr_entry
.data
.i32
[i
];
195 case ANDROID_JPEG_THUMBNAIL_QUALITY
:
196 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
198 dst
->ctl
.jpeg
.thumbnailQuality
= curr_entry
.data
.i32
[0];
201 case ANDROID_JPEG_GPS_COORDINATES
:
202 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_DOUBLE
, 3))
204 for (i
=0 ; i
<curr_entry
.count
; i
++)
205 dst
->ctl
.jpeg
.gpsCoordinates
[i
] = curr_entry
.data
.d
[i
];
208 case ANDROID_JPEG_GPS_PROCESSING_METHOD
:
209 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
))
211 if (curr_entry
.count
> 32)
214 cnt
= curr_entry
.count
;
215 for (i
= 0 ; i
< cnt
; i
++)
216 dst_ext
->gpsProcessingMethod
[i
] = curr_entry
.data
.u8
[i
];
219 case ANDROID_JPEG_GPS_TIMESTAMP
:
220 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT64
, 1))
222 dst
->ctl
.jpeg
.gpsTimestamp
= curr_entry
.data
.i64
[0];
225 case ANDROID_JPEG_ORIENTATION
:
226 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
228 dst
->ctl
.jpeg
.orientation
= curr_entry
.data
.i32
[0];
233 case ANDROID_STATISTICS_FACE_DETECT_MODE
:
234 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
236 dst
->ctl
.stats
.faceDetectMode
= (enum facedetect_mode
)(curr_entry
.data
.u8
[0] + 1);
239 case ANDROID_CONTROL_CAPTURE_INTENT
:
240 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
242 dst
->ctl
.aa
.captureIntent
= (enum aa_capture_intent
)curr_entry
.data
.u8
[0];
245 case ANDROID_CONTROL_MODE
:
246 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
248 dst
->ctl
.aa
.mode
= (enum aa_mode
)(curr_entry
.data
.u8
[0] + 1);
252 case ANDROID_CONTROL_VIDEO_STABILIZATION_MODE
:
253 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
255 dst
->ctl
.aa
.videoStabilizationMode
= curr_entry
.data
.u8
[0];
258 case ANDROID_CONTROL_AE_MODE
:
259 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
261 dst
->ctl
.aa
.aeMode
= (enum aa_aemode
)(curr_entry
.data
.u8
[0] + 2);
263 if (dst
->ctl
.aa
.aeMode
== AA_AEMODE_LOCKED
)
264 dst
->ctl
.aa
.aeMode
= AA_AEMODE_OFF
;
265 ALOGV("DEBUG(%s): ANDROID_CONTROL_AE_MODE (%d)", __FUNCTION__
, dst
->ctl
.aa
.aeMode
);
268 case ANDROID_CONTROL_AE_LOCK
:
269 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
271 dst_ext
->ae_lock
= (enum ae_lockmode
)(curr_entry
.data
.u8
[0]);
274 case ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION
:
275 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
277 dst
->ctl
.aa
.aeExpCompensation
= curr_entry
.data
.i32
[0] + 5;
280 case ANDROID_CONTROL_AWB_MODE
:
281 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
283 dst
->ctl
.aa
.awbMode
= (enum aa_awbmode
)(curr_entry
.data
.u8
[0] + 2);
285 if (dst
->ctl
.aa
.awbMode
== AA_AWBMODE_LOCKED
)
286 dst
->ctl
.aa
.awbMode
= AA_AWBMODE_OFF
;
287 dst_ext
->awb_mode_dm
= (enum aa_awbmode
)(curr_entry
.data
.u8
[0] + 2);
290 case ANDROID_CONTROL_AWB_LOCK
:
291 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
293 dst_ext
->awb_lock
= (enum awb_lockmode
)(curr_entry
.data
.u8
[0]);
296 case ANDROID_CONTROL_AF_MODE
:
297 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
299 dst
->ctl
.aa
.afMode
= (enum aa_afmode
)(curr_entry
.data
.u8
[0] + 1);
300 if (dst
->ctl
.aa
.afMode
== AA_AFMODE_OFF
)
301 dst
->ctl
.aa
.afMode
= AA_AFMODE_MANUAL
;
304 case ANDROID_CONTROL_AF_REGIONS
:
305 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 5))
307 for (i
=0 ; i
<curr_entry
.count
; i
++)
308 dst
->ctl
.aa
.afRegions
[i
] = curr_entry
.data
.i32
[i
];
311 case ANDROID_CONTROL_AE_REGIONS
:
312 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 5))
314 for (i
=0 ; i
<curr_entry
.count
; i
++)
315 dst
->ctl
.aa
.aeRegions
[i
] = curr_entry
.data
.i32
[i
];
319 case ANDROID_REQUEST_ID
:
320 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
322 dst
->ctl
.request
.id
= curr_entry
.data
.i32
[0];
323 ALOGV("DEBUG(%s): ANDROID_REQUEST_ID (%d)", __FUNCTION__
, dst
->ctl
.request
.id
);
326 case ANDROID_REQUEST_METADATA_MODE
:
327 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
329 dst
->ctl
.request
.metadataMode
= (enum metadata_mode
)curr_entry
.data
.u8
[0];
330 ALOGV("DEBUG(%s): ANDROID_REQUEST_METADATA_MODE (%d)", __FUNCTION__
, (int)( dst
->ctl
.request
.metadataMode
));
333 case ANDROID_REQUEST_OUTPUT_STREAMS
:
334 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
))
337 dst
->ctl
.request
.outputStreams
[0] = 0;
338 for (i
=0 ; i
<curr_entry
.count
; i
++) {
339 ALOGV("DEBUG(%s): OUTPUT_STREAM[%d] = %d ", __FUNCTION__
, i
, curr_entry
.data
.i32
[i
]);
340 dst
->ctl
.request
.outputStreams
[0] |= (1 << curr_entry
.data
.i32
[i
]);
344 case ANDROID_REQUEST_INPUT_STREAMS
:
345 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
))
348 for (i
=0 ; i
<curr_entry
.count
; i
++) {
349 dst_ext
->reprocessInput
= curr_entry
.data
.i32
[0];
350 ALOGV("DEBUG(%s): ANDROID_REQUEST_INPUT_STREAMS[%d] = %d ", __FUNCTION__
, i
, dst_ext
->reprocessInput
);
354 case ANDROID_REQUEST_TYPE
:
355 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
357 dst_ext
->isReprocessing
= curr_entry
.data
.u8
[0];
358 ALOGV("DEBUG(%s): ANDROID_REQUEST_TYPE (%d)", __FUNCTION__
, dst_ext
->isReprocessing
);
361 case ANDROID_REQUEST_FRAME_COUNT
:
362 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 1))
364 dst
->ctl
.request
.frameCount
= curr_entry
.data
.i32
[0];
365 ALOGV("DEBUG(%s): ANDROID_REQUEST_FRAME_COUNT (%d)", __FUNCTION__
, dst
->ctl
.request
.frameCount
);
368 case ANDROID_CONTROL_SCENE_MODE
:
369 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_BYTE
, 1))
371 dst
->ctl
.aa
.sceneMode
= (enum aa_scene_mode
)(curr_entry
.data
.u8
[0] + 1);
374 case ANDROID_CONTROL_AE_TARGET_FPS_RANGE
:
375 if (NO_ERROR
!= CheckEntryTypeMismatch(&curr_entry
, TYPE_INT32
, 2))
377 for (i
=0 ; i
<curr_entry
.count
; i
++)
378 dst
->ctl
.aa
.aeTargetFpsRange
[i
] = curr_entry
.data
.i32
[i
];
382 ALOGV("DEBUG(%s):Bad Metadata tag (%d)", __FUNCTION__
, curr_entry
.tag
);
387 if (dst
->ctl
.aa
.mode
!= AA_CONTROL_USE_SCENE_MODE
)
388 dst
->ctl
.aa
.sceneMode
= AA_SCENE_MODE_UNSUPPORTED
;
389 ApplySceneModeParameters(request
, dst_ext
);
393 status_t
MetadataConverter::ApplySceneModeParameters(camera_metadata_t
* request
, struct camera2_shot_ext
* dst_ext
)
395 camera_metadata_entry_t curr_entry
;
396 struct camera2_shot
* dst
= NULL
;
398 ALOGV("DEBUG(%s):", __FUNCTION__
);
400 dst
= &(dst_ext
->shot
);
402 switch (dst
->ctl
.aa
.sceneMode
) {
404 case AA_SCENE_MODE_ACTION
:
405 dst
->ctl
.aa
.mode
= AA_CONTROL_USE_SCENE_MODE
;
406 if (dst
->ctl
.aa
.aeMode
!= AA_AEMODE_LOCKED
)
407 dst
->ctl
.aa
.aeMode
= AA_AEMODE_ON
;
408 dst
->ctl
.aa
.awbMode
= AA_AWBMODE_WB_AUTO
;
409 dst_ext
->awb_mode_dm
= AA_AWBMODE_WB_AUTO
;
410 dst
->ctl
.aa
.isoMode
= AA_ISOMODE_AUTO
;
411 dst
->ctl
.aa
.isoValue
= 0;
412 dst
->ctl
.aa
.aeTargetFpsRange
[0] = 30;
413 dst
->ctl
.aa
.aeTargetFpsRange
[1] = 30;
415 dst
->ctl
.noise
.mode
= PROCESSING_MODE_FAST
;
416 dst
->ctl
.noise
.strength
= 0;
417 dst
->ctl
.edge
.mode
= PROCESSING_MODE_FAST
;
418 dst
->ctl
.edge
.strength
= 0;
420 dst
->ctl
.color
.saturation
= 3; // means '0'
423 case AA_SCENE_MODE_PARTY
:
424 dst
->ctl
.aa
.mode
= AA_CONTROL_USE_SCENE_MODE
;
425 if (dst
->ctl
.aa
.aeMode
!= AA_AEMODE_LOCKED
)
426 dst
->ctl
.aa
.aeMode
= AA_AEMODE_ON
;
427 dst
->ctl
.aa
.awbMode
= AA_AWBMODE_WB_AUTO
;
428 dst_ext
->awb_mode_dm
= AA_AWBMODE_WB_AUTO
;
429 dst
->ctl
.aa
.isoMode
= AA_ISOMODE_MANUAL
;
430 dst
->ctl
.aa
.isoValue
= 200;
431 dst
->ctl
.aa
.aeTargetFpsRange
[0] = 15;
432 dst
->ctl
.aa
.aeTargetFpsRange
[1] = 30;
434 dst
->ctl
.noise
.mode
= PROCESSING_MODE_FAST
;
435 dst
->ctl
.noise
.strength
= 0;
436 dst
->ctl
.edge
.mode
= PROCESSING_MODE_FAST
;
437 dst
->ctl
.edge
.strength
= 0;
439 dst
->ctl
.color
.saturation
= 4; // means '+1'
442 case AA_SCENE_MODE_SUNSET
:
443 dst
->ctl
.aa
.mode
= AA_CONTROL_USE_SCENE_MODE
;
444 if (dst
->ctl
.aa
.aeMode
!= AA_AEMODE_LOCKED
)
445 dst
->ctl
.aa
.aeMode
= AA_AEMODE_ON
;
446 dst
->ctl
.aa
.awbMode
= AA_AWBMODE_WB_DAYLIGHT
;
447 dst_ext
->awb_mode_dm
= AA_AWBMODE_WB_DAYLIGHT
;
448 dst
->ctl
.aa
.isoMode
= AA_ISOMODE_AUTO
;
449 dst
->ctl
.aa
.isoValue
= 0;
450 dst
->ctl
.aa
.aeTargetFpsRange
[0] = 15;
451 dst
->ctl
.aa
.aeTargetFpsRange
[1] = 30;
453 dst
->ctl
.noise
.mode
= PROCESSING_MODE_FAST
;
454 dst
->ctl
.noise
.strength
= 0;
455 dst
->ctl
.edge
.mode
= PROCESSING_MODE_FAST
;
456 dst
->ctl
.edge
.strength
= 0;
458 dst
->ctl
.color
.saturation
= 3; // means '0'
461 case AA_SCENE_MODE_NIGHT
:
462 dst
->ctl
.aa
.mode
= AA_CONTROL_USE_SCENE_MODE
;
463 dst
->ctl
.aa
.aeMode
= AA_AEMODE_ON
; // AE_LOCK is prohibited
464 dst
->ctl
.aa
.awbMode
= AA_AWBMODE_WB_AUTO
;
465 dst_ext
->awb_mode_dm
= AA_AWBMODE_WB_AUTO
;
466 dst
->ctl
.aa
.isoMode
= AA_ISOMODE_AUTO
;
467 dst
->ctl
.aa
.isoValue
= 0;
468 dst
->ctl
.aa
.aeTargetFpsRange
[0] = 8;
469 dst
->ctl
.aa
.aeTargetFpsRange
[1] = 30;
471 dst
->ctl
.noise
.mode
= PROCESSING_MODE_FAST
;
472 dst
->ctl
.noise
.strength
= 0;
473 dst
->ctl
.edge
.mode
= PROCESSING_MODE_FAST
;
474 dst
->ctl
.edge
.strength
= 0;
476 dst
->ctl
.color
.saturation
= 3; // means '0'
479 case AA_SCENE_MODE_FACE_PRIORITY
:
480 dst
->ctl
.aa
.mode
= AA_CONTROL_AUTO
;
481 if ((dst
->ctl
.aa
.aeMode
!= AA_AEMODE_LOCKED
) && (dst
->ctl
.aa
.aeMode
< AA_AEMODE_ON_AUTO_FLASH
))
482 dst
->ctl
.aa
.aeMode
= AA_AEMODE_ON
;
483 dst
->ctl
.aa
.sceneMode
= AA_SCENE_MODE_FACE_PRIORITY
;
484 dst
->ctl
.aa
.isoMode
= AA_ISOMODE_AUTO
;
485 dst
->ctl
.aa
.isoValue
= 0;
486 dst
->ctl
.noise
.mode
= PROCESSING_MODE_OFF
;
487 dst
->ctl
.noise
.strength
= 0;
488 dst
->ctl
.edge
.mode
= PROCESSING_MODE_OFF
;
489 dst
->ctl
.edge
.strength
= 0;
490 dst
->ctl
.color
.saturation
= 3; // means '0'
494 dst
->ctl
.aa
.mode
= AA_CONTROL_AUTO
;
495 if ((dst
->ctl
.aa
.aeMode
!= AA_AEMODE_LOCKED
) && (dst
->ctl
.aa
.aeMode
< AA_AEMODE_ON_AUTO_FLASH
))
496 dst
->ctl
.aa
.aeMode
= AA_AEMODE_ON
;
497 dst
->ctl
.aa
.sceneMode
= AA_SCENE_MODE_UNSUPPORTED
;
498 dst
->ctl
.aa
.isoMode
= AA_ISOMODE_AUTO
;
499 dst
->ctl
.aa
.isoValue
= 0;
500 dst
->ctl
.noise
.mode
= PROCESSING_MODE_OFF
;
501 dst
->ctl
.noise
.strength
= 0;
502 dst
->ctl
.edge
.mode
= PROCESSING_MODE_OFF
;
503 dst
->ctl
.edge
.strength
= 0;
504 dst
->ctl
.color
.saturation
= 3; // means '0'
512 status_t
MetadataConverter::ToDynamicMetadata(struct camera2_shot_ext
* metadata_ext
, camera_metadata_t
* dst
)
515 struct camera2_shot
* metadata
= &metadata_ext
->shot
;
519 if (0 != add_camera_metadata_entry(dst
, ANDROID_REQUEST_ID
,
520 &(metadata
->ctl
.request
.id
), 1))
523 if (0 != add_camera_metadata_entry(dst
, ANDROID_REQUEST_METADATA_MODE
,
524 &(metadata
->ctl
.request
.metadataMode
), 1))
527 if (0 != add_camera_metadata_entry(dst
, ANDROID_REQUEST_FRAME_COUNT
,
528 &(metadata
->ctl
.request
.frameCount
), 1))
531 if (0 != add_camera_metadata_entry(dst
, ANDROID_SENSOR_TIMESTAMP
,
532 &metadata
->dm
.sensor
.timeStamp
, 1))
535 if (0 != add_camera_metadata_entry(dst
, ANDROID_SENSOR_EXPOSURE_TIME
,
536 &metadata
->dm
.sensor
.exposureTime
, 1))
539 if (0 != add_camera_metadata_entry(dst
, ANDROID_LENS_APERTURE
,
540 &metadata
->dm
.lens
.aperture
, 1))
543 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AE_TARGET_FPS_RANGE
,
544 &(metadata
->ctl
.aa
.aeTargetFpsRange
), 2))
547 ALOGV("(%s): ID(%d) METAMODE(%d) FrameCnt(%d) Timestamp(%lld) exposure(%lld) aper(%f)", __FUNCTION__
,
548 metadata
->ctl
.request
.id
, metadata
->ctl
.request
.metadataMode
, metadata
->ctl
.request
.frameCount
,
549 metadata
->dm
.sensor
.timeStamp
, metadata
->dm
.sensor
.exposureTime
, metadata
->dm
.lens
.aperture
);
552 byteData
= metadata_ext
->awb_mode_dm
- 2;
553 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AWB_MODE
,
557 byteData
= metadata
->dm
.aa
.aeMode
- 1;
558 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AE_MODE
,
562 byteData
= metadata
->ctl
.aa
.afMode
- 1;
563 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AF_MODE
,
567 byteData
= metadata
->ctl
.aa
.sceneMode
- 1;
568 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_SCENE_MODE
,
572 intData
= metadata
->ctl
.aa
.aeExpCompensation
- 5;
573 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION
,
577 byteData
= metadata
->dm
.stats
.faceDetectMode
- 1;
578 if (0 != add_camera_metadata_entry(dst
, ANDROID_STATISTICS_FACE_DETECT_MODE
,
582 int maxFacecount
= CAMERA2_MAX_FACES
;
583 if (0 != add_camera_metadata_entry(dst
, ANDROID_STATISTICS_INFO_MAX_FACE_COUNT
,
587 int tempFaceCount
= 0;
588 for (int i
= 0; i
< CAMERA2_MAX_FACES
; i
++) {
589 if (metadata
->dm
.stats
.faceIds
[i
] > 0) {
590 mataFaceIds
[tempFaceCount
] = metadata
->dm
.stats
.faceIds
[i
];
591 // clipping fd score because the max face score of android is 100
592 if (metadata
->dm
.stats
.faceScores
[i
] > 100)
593 metaFaceScores
[tempFaceCount
] = 100;
595 metaFaceScores
[tempFaceCount
] = metadata
->dm
.stats
.faceScores
[i
];
597 memcpy(&mataFaceLandmarks
[tempFaceCount
][0], &metadata
->dm
.stats
.faceLandmarks
[i
][0], 6*sizeof(uint32_t));
598 memcpy(&metaFaceRectangles
[tempFaceCount
][0], &metadata
->dm
.stats
.faceRectangles
[i
][0], 4*sizeof(uint32_t));
603 if (tempFaceCount
> 0) {
604 if (0 != add_camera_metadata_entry(dst
, ANDROID_STATISTICS_FACE_RECTANGLES
,
605 &metaFaceRectangles
, 4 * tempFaceCount
))
608 if (0 != add_camera_metadata_entry(dst
, ANDROID_STATISTICS_FACE_LANDMARKS
,
609 &mataFaceLandmarks
, 6 * tempFaceCount
))
612 if (0 != add_camera_metadata_entry(dst
, ANDROID_STATISTICS_FACE_IDS
,
613 &mataFaceIds
, tempFaceCount
))
616 if (0 != add_camera_metadata_entry(dst
, ANDROID_STATISTICS_FACE_SCORES
,
617 &metaFaceScores
, tempFaceCount
))
620 if (0 != add_camera_metadata_entry(dst
, ANDROID_SENSOR_SENSITIVITY
,
621 &metadata
->dm
.aa
.isoValue
, 1))
624 // Need a four-entry crop region
625 uint32_t cropRegion
[4] = {
626 metadata
->ctl
.scaler
.cropRegion
[0],
627 metadata
->ctl
.scaler
.cropRegion
[1],
628 metadata
->ctl
.scaler
.cropRegion
[2],
631 if (0 != add_camera_metadata_entry(dst
, ANDROID_SCALER_CROP_REGION
,
635 byteData
= metadata
->dm
.aa
.aeState
- 1;
636 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AE_STATE
,
640 if (0 != add_camera_metadata_entry(dst
, ANDROID_CONTROL_AWB_STATE
,
641 &(metadata
->dm
.aa
.awbState
), 1))
645 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_ORIENTATION
,
646 &metadata
->ctl
.jpeg
.orientation
, 1))
649 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_QUALITY
,
650 &metadata
->ctl
.jpeg
.quality
, 1))
653 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_THUMBNAIL_SIZE
,
654 &metadata
->ctl
.jpeg
.thumbnailSize
, 2))
657 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_THUMBNAIL_QUALITY
,
658 &metadata
->ctl
.jpeg
.thumbnailQuality
, 1))
662 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_GPS_COORDINATES
,
663 &(metadata
->ctl
.jpeg
.gpsCoordinates
), 3))
666 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_GPS_PROCESSING_METHOD
,
667 &(metadata_ext
->gpsProcessingMethod
), 32))
670 if (0 != add_camera_metadata_entry(dst
, ANDROID_JPEG_GPS_TIMESTAMP
,
671 &(metadata
->ctl
.jpeg
.gpsTimestamp
), 1))
673 ALOGV("(%s): AWB(%d) AE(%d) SCENE(%d) AEComp(%d) AF(%d)", __FUNCTION__
,
674 metadata_ext
->awb_mode_dm
- 2, metadata
->dm
.aa
.aeMode
- 1, metadata
->ctl
.aa
.sceneMode
- 1,
675 metadata
->ctl
.aa
.aeExpCompensation
, metadata
->ctl
.aa
.afMode
- 1);
678 if (metadata
->ctl
.request
.metadataMode
== METADATA_MODE_NONE
) {
679 ALOGV("DEBUG(%s): METADATA_MODE_NONE", __FUNCTION__
);
687 }; // namespace android