diff --git a/src/Encoder.cpp b/src/Encoder.cpp index ecade07..58fd12f 100644 --- a/src/Encoder.cpp +++ b/src/Encoder.cpp @@ -27,6 +27,7 @@ bool Encoder::init() { LOG_ERROR("IMP_Encoder_CreateGroup() == " << ret); return true; } + LOG_DEBUG("Encoder Group created"); ret = system_init(); if (ret < 0) { @@ -50,6 +51,7 @@ bool Encoder::init() { LOG_ERROR("IMP_System_Bind(FS, ENC) == " << ret); return true; } + LOG_DEBUG("IMP_System_Bind(FS, ENC)"); } else { // If OSD is enabled, initialize OSD and bind FrameSource to OSD, then OSD to Encoder @@ -70,12 +72,15 @@ bool Encoder::init() { LOG_ERROR("IMP_System_Bind(FS, OSD) == " << ret); return true; } + LOG_DEBUG("IMP_System_Bind(FS, OSD)"); + // OSD -> Encoder ret = IMP_System_Bind(&osd_cell, &enc); if (ret < 0) { LOG_ERROR("IMP_System_Bind(OSD, ENC) == " << ret); return true; } + LOG_DEBUG("IMP_System_Bind(OSD, ENC)"); } @@ -84,6 +89,7 @@ bool Encoder::init() { LOG_ERROR("IMP_FrameSource_EnableChn() == " << ret); return true; } + LOG_DEBUG("Frame Source Channel 0 enabled"); return false; } @@ -91,8 +97,6 @@ bool Encoder::init() { int Encoder::system_init() { int ret = 0; - IMP_ISP_Tuning_SetAntiFlickerAttr(IMPISP_ANTIFLICKER_60HZ); - return ret; } @@ -210,6 +214,7 @@ int Encoder::encoder_init() { if (ret < 0) { LOG_ERROR("IMP_Encoder_SetbufshareChn() == " << ret); } + LOG_ERROR("IMP_Encoder_SetbufshareChn(1, 0) enabled"); } #endif @@ -218,12 +223,14 @@ int Encoder::encoder_init() { LOG_ERROR("IMP_Encoder_CreateChn() == " << ret); return ret; } + LOG_DEBUG("Encoder Channel 0 created"); ret = IMP_Encoder_RegisterChn(0, 0); if (ret < 0) { LOG_ERROR("IMP_Encoder_RegisterChn() == " << ret); return ret; } + LOG_DEBUG("Encoder Channel 0 registered"); #if defined(PLATFORM_T10) || defined(PLATFORM_T20) || defined(PLATFORM_T21) || defined(PLATFORM_T23) || defined(PLATFORM_T30) /* @@ -335,11 +342,13 @@ void Encoder::jpeg_snap() { if (ret < 0) { LOG_ERROR("IMP_Encoder_CreateChn() == " << ret); } + LOG_DEBUG("Encoder JPEG Channel 1 created"); ret = IMP_Encoder_RegisterChn(0, 1); if (ret < 0) { LOG_ERROR("IMP_Encoder_RegisterChn() == " << ret); } + LOG_DEBUG("Encoder JPEG Channel 1 registered"); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // Wait for ISP to init before saving initial image @@ -399,7 +408,7 @@ void Encoder::jpeg_snap() { } void Encoder::run() { - LOG_DEBUG("Encoder Start."); + LOG_DEBUG("Encoder Start"); //The encoder thread is very important, but we //want sink threads to have higher priority. @@ -416,6 +425,8 @@ void Encoder::run() { IMP_System_RebaseTimeStamp(0); gettimeofday(&imp_time_base, NULL); IMP_Encoder_StartRecvPic(0); + LOG_DEBUG("Encoder StartRecvPic success"); + while (true) { IMPEncoderStream stream; diff --git a/src/IMP.cpp b/src/IMP.cpp index 6d6103b..b806e22 100644 --- a/src/IMP.cpp +++ b/src/IMP.cpp @@ -4,6 +4,8 @@ #include "Config.hpp" #include "Logger.hpp" +#define OSDPoolSize 131072 + bool IMP::init() { int ret; @@ -19,7 +21,6 @@ bool IMP::init() { return true; } - IMP_ISP_Tuning_SetISPBypass(IMPISP_TUNING_OPS_MODE_ENABLE); return false; } @@ -79,6 +80,7 @@ int IMP::framesource_init() { LOG_DEBUG("IMP_FrameSource_SetChnRotate() == " + std::to_string(ret)); return ret; } + LOG_DEBUG("IMP_FrameSource_SetChnRotate == " + std::to_string(rotation)); #endif #endif @@ -87,18 +89,39 @@ int IMP::framesource_init() { LOG_DEBUG("IMP_FrameSource_CreateChn() == " + std::to_string(ret)); return ret; } + LOG_DEBUG("IMP_FrameSource_CreateChn created"); ret = IMP_FrameSource_SetChnAttr(0, &fs_chn_attr); if (ret < 0) { - LOG_DEBUG("IMP_FrameSource_CreateChn() == " + std::to_string(ret)); + LOG_DEBUG("IMP_FrameSource_SetChnAttr() == " + std::to_string(ret)); return ret; } + LOG_DEBUG("IMP_FrameSource_SetChnAttr set"); IMPFSChnFifoAttr fifo; - IMP_FrameSource_GetChnFifoAttr(0, &fifo); + + ret = IMP_FrameSource_GetChnFifoAttr(0, &fifo); + if (ret < 0) { + LOG_DEBUG("IMP_FrameSource_GetChnFifoAttr() == " + std::to_string(ret)); + return ret; + } + LOG_DEBUG("IMP_FrameSource_GetChnFifoAttr set"); + fifo.maxdepth = 0; - IMP_FrameSource_SetChnFifoAttr(0, &fifo); - IMP_FrameSource_SetFrameDepth(0, 0); + ret = IMP_FrameSource_SetChnFifoAttr(0, &fifo); + if (ret < 0) { + LOG_DEBUG("IMP_FrameSource_SetChnFifoAttr() == " + std::to_string(ret)); + return ret; + } + LOG_DEBUG("IMP_FrameSource_SetChnFifoAttr set"); + + ret = IMP_FrameSource_SetFrameDepth(0, 0); + if (ret < 0) { + LOG_DEBUG("IMP_FrameSource_SetFrameDepth() == " + std::to_string(ret)); + return ret; + } + LOG_DEBUG("IMP_FrameSource_SetFrameDepth set"); + return ret; } @@ -120,12 +143,12 @@ int IMP::system_init() { const char* cpuInfo = IMP_System_GetCPUInfo(); LOG_INFO("CPU Information: " << cpuInfo); - ret = IMP_OSD_SetPoolSize(131072); + ret = IMP_OSD_SetPoolSize(OSDPoolSize); if (ret < 0) { - LOG_DEBUG("Error: IMP_OSD_SetPoolSize() == " + std::to_string(ret)); + LOG_DEBUG("Error: IMP_OSD_SetPoolSize == " + std::to_string(ret)); return ret; } - LOG_DEBUG("OSD Pool Size set"); + LOG_DEBUG("IMP_OSD_SetPoolSize == " + std::to_string(OSDPoolSize)); ret = IMP_ISP_Open(); if (ret < 0) { @@ -154,7 +177,7 @@ int IMP::system_init() { LOG_DEBUG("Error: IMP_System_Init() == " + std::to_string(ret)); return ret; } - LOG_DEBUG("System Initialized"); + LOG_DEBUG("IMP System Initialized"); //Enable tuning. //This is necessary to customize the sensor's image output. @@ -164,18 +187,23 @@ int IMP::system_init() { LOG_DEBUG("ERROR: IMP_ISP_EnableTuning() == " + std::to_string(ret)); return ret; } + LOG_DEBUG("IMP_ISP_EnableTuning enabled"); /* Set tuning defaults; on some SoC platforms, if we don't do this, the stream will be dark until manually set */ IMP_ISP_Tuning_SetContrast(128); IMP_ISP_Tuning_SetSharpness(128); IMP_ISP_Tuning_SetSaturation(128); IMP_ISP_Tuning_SetBrightness(128); + IMP_ISP_Tuning_SetISPBypass(IMPISP_TUNING_OPS_MODE_ENABLE); + IMP_ISP_Tuning_SetAntiFlickerAttr(IMPISP_ANTIFLICKER_60HZ); + LOG_DEBUG("ISP Tuning Defaults set"); ret = IMP_ISP_Tuning_SetSensorFPS(Config::singleton()->sensorFps, 1); if (ret < 0) { LOG_DEBUG("ERROR: IMP_ISP_Tuning_SetSensorFPS() == " + std::to_string(ret)); return ret; } + LOG_DEBUG("IMP_ISP_Tuning_SetSensorFPS == " + std::to_string(Config::singleton()->sensorFps)); // Set the ISP to DAY on launch ret = IMP_ISP_Tuning_SetISPRunningMode(IMPISP_RUNNING_MODE_DAY); @@ -183,6 +211,8 @@ int IMP::system_init() { LOG_DEBUG("ERROR: IMP_ISP_Tuning_SetISPRunningMode() == " + std::to_string(ret)); return ret; } + LOG_DEBUG("IMP_ISP_Tuning_SetISPRunningMode == " + std::to_string(IMPISP_RUNNING_MODE_DAY)); + return ret; } diff --git a/src/OSD.cpp b/src/OSD.cpp index f7567f7..37cbf3d 100644 --- a/src/OSD.cpp +++ b/src/OSD.cpp @@ -284,6 +284,7 @@ bool OSD::init() { LOG_DEBUG("IMP_OSD_CreateGroup() == " + std::to_string(ret)); return true; } + LOG_DEBUG("IMP_OSD_CreateGroup group 0 created"); memset(×tamp.imp_rgn, 0, sizeof(timestamp.imp_rgn)); timestamp.imp_rgn = IMP_OSD_CreateRgn(NULL); @@ -395,8 +396,9 @@ bool OSD::init() { LOG_DEBUG("IMP_OSD_Start() == " + std::to_string(ret)); return true; } + LOG_DEBUG("IMP_OSD_Start succeed"); - LOG_DEBUG("OSD init done"); + LOG_DEBUG("OSD init completed"); return false; } diff --git a/src/main.cpp b/src/main.cpp index a7760fa..9db2576 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,7 +77,7 @@ int main(int argc, const char *argv[]) { } if (Config::singleton()->stream1jpegEnable) { - LOG_DEBUG("JPEG Channel enabled"); + LOG_DEBUG("JPEG support enabled"); std::thread jpegThread(&Encoder::jpeg_snap, &jpg); jpegThread.detach(); }