diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 533e86ed..04b20adc 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -21,7 +21,7 @@ if(ANDROID_ABI STREQUAL "armeabi-v7a") add_definitions(-DUSING_N938) elseif(ANDROID_ABI STREQUAL "arm64-v8a") # add_definitions(-DUSING_N938) - add_definitions(-DUSING_PTZ) + # add_definitions(-DUSING_PTZ) endif() # OUTPUT_DBG_INFO: 输出调试相关信息 diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index c367c15a..d2000f5c 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -2483,6 +2483,7 @@ void NdkCamera::EnumCameraResult(ACameraMetadata* result, CAPTURE_RESULT& captur status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AE_EXPOSURE_COMPENSATION, &val); captureResult.compensation = (status == ACAMERA_OK) ? *(val.data.i32) : 0; + val = {0}; status = ACameraMetadata_getConstEntry(result, MTK_HDR_FEATURE_HDR_DETECTION_RESULT, &val); ALOGI("HDR Detection Result: %d", val.data.i32[0]); @@ -2743,7 +2744,7 @@ void NdkCamera::SetupHDR(ACameraMetadata* characteristics, ACaptureRequest* requ } - int32_t hdrMode = MTK_HDR_FEATURE_HDR_MODE_ON; // 1 Enable HDR + int32_t hdrMode = MTK_HDR_FEATURE_HDR_MODE_AUTO; // 1 Enable HDR ALOGI("Try to set MTK_HDR_FEATURE_HDR_MODE = %d", hdrMode); status = ACaptureRequest_setEntry_i32(request, MTK_HDR_FEATURE_HDR_MODE, 1, &hdrMode); if (status != ACAMERA_OK) @@ -2758,8 +2759,7 @@ void NdkCamera::SetupHDR(ACameraMetadata* characteristics, ACaptureRequest* requ ALOGE("Failed to set MTK_HDR_FEATURE_HDR_HAL_MODE, status: %d", status); } - - // int32_t ispTuning = (mfbMode != 0) ? MTK_CONTROL_CAPTURE_HINT_FOR_ISP_TUNING_MFNR : MTK_CONTROL_CAPTURE_HINT_FOR_ISP_TUNING_DEFAULT_NONE; + // int32_t ispTuning = MTK_CONTROL_CAPTURE_HINT_FOR_ISP_TUNING_AIHDR; // status = ACaptureRequest_setEntry_i32(request, MTK_CONTROL_CAPTURE_HINT_FOR_ISP_TUNING, 1, &ispTuning); uint8_t reqRemosaicEnable = 1; @@ -2769,24 +2769,50 @@ void NdkCamera::SetupHDR(ACameraMetadata* characteristics, ACaptureRequest* requ ALOGE("Failed to set MTK_HAL_REQUEST_REMOSAIC_ENABLE, status: %d", status); } - if (m_params.compensation != 0) - { - int32_t compensation = m_params.compensation; - status = ACaptureRequest_setEntry_i32(request, MTK_CONTROL_AE_EXPOSURE_COMPENSATION, 1, &compensation); - if (status != ACAMERA_OK) - { - ALOGE("Failed to set MTK_CONTROL_AE_EXPOSURE_COMPENSATION, status: %d", status); - } - } - // 设置HDR的AE目标模式 int32_t aeTargetMode = MTK_3A_FEATURE_AE_TARGET_MODE_NORMAL; status = ACaptureRequest_setEntry_i32(request, MTK_3A_FEATURE_AE_TARGET_MODE, 1, &aeTargetMode); -// 设置更高的曝光等级 + // 设置更高的曝光等级 int32_t exposureLevel = MTK_3A_FEATURE_AE_EXPOSURE_LEVEL_LONG; // 选择长曝光模式 status = ACaptureRequest_setEntry_i32(request, MTK_3A_FEATURE_AE_EXPOSURE_LEVEL, 1, &exposureLevel); + int32_t hdrModeParam = 1; // 偏向于亮部 + status = ACaptureRequest_setEntry_i32(request, MTK_3A_HDR_MODE, 1, &hdrModeParam); + + if ((aeCompensationRange.min_ != 0 || aeCompensationRange.max_ != 0) && m_params.compensation != 0) + { + int32_t compensation = m_params.compensation; + if (compensation < aeCompensationRange.min_) + { + compensation = aeCompensationRange.min_; + } + if (compensation > aeCompensationRange.max_) + { + compensation = aeCompensationRange.max_; + } + ACaptureRequest_setEntry_i32(request, MTK_CONTROL_AE_EXPOSURE_COMPENSATION, 1, &compensation); + + if (compensation > 0) + { + // 调整HDR混合ISO模式,优化暗部 + int32_t hdrMixedIso = 1; // 启用混合ISO + status = ACaptureRequest_setEntry_i32(request, MTK_3A_AE_HDR_MIXED_ISO, 1, &hdrMixedIso); + + // 降低高光恢复强度,允许更多过曝 - 这个设置没有问题 + float hlrRatio = 0.3f; + status = ACaptureRequest_setEntry_float(request, MTK_ISP_HLR_RATIO, 1, &hlrRatio); + + int32_t aeTargetMode = MTK_3A_FEATURE_AE_TARGET_MODE_MSTREAM_VHDR; // 多帧HDR模式 + status = ACaptureRequest_setEntry_i32(request, MTK_3A_FEATURE_AE_TARGET_MODE, 1, &aeTargetMode); + + int32_t ispBrightness = MTK_CONTROL_ISP_BRIGHTNESS_HIGH; // 范围通常是0-10,值越大越亮 + status = ACaptureRequest_setEntry_i32(request, MTK_CONTROL_ISP_BRIGHTNESS, 1, &ispBrightness); + + } + } + + int aa = 0; }