From 37958dfd713dd00d4a71a78a6a45f8016ad82e65 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 29 Apr 2022 03:59:45 +0300 Subject: libcamera: Replace toString with operator<<() for geometry classes Now that geometry classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/android/camera_capabilities.cpp | 6 +++--- src/android/camera_device.cpp | 2 +- src/android/yuv/post_processor_yuv.cpp | 4 ++-- src/cam/camera_session.cpp | 3 +-- src/cam/kms_sink.cpp | 4 +--- src/libcamera/camera_sensor.cpp | 4 ++-- src/libcamera/pipeline/ipu3/imgu.cpp | 19 +++++++++---------- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 6 +++--- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 2 +- src/libcamera/pipeline/simple/converter.cpp | 2 +- src/libcamera/pipeline/simple/simple.cpp | 8 ++++---- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 3 +-- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 2 +- src/libcamera/v4l2_videodevice.cpp | 2 +- test/camera-sensor.cpp | 3 +-- test/geometry.cpp | 4 +--- test/stream/stream_formats.cpp | 4 ++-- 19 files changed, 37 insertions(+), 45 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 55d651f3..e06a517d 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -487,7 +487,7 @@ int CameraCapabilities::initializeStreamConfigurations() * JPEG encoder requirements into account (alignment and aspect ratio). */ const Size maxRes = cfg.size; - LOG(HAL, Debug) << "Maximum supported resolution: " << maxRes.toString(); + LOG(HAL, Debug) << "Maximum supported resolution: " << maxRes; /* * Build the list of supported image resolutions. @@ -729,7 +729,7 @@ int CameraCapabilities::initializeStreamConfigurations() LOG(HAL, Debug) << "Collected stream configuration map: "; for (const auto &entry : streamConfigurations_) - LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - " + LOG(HAL, Debug) << "{ " << entry.resolution << " - " << utils::hex(entry.androidFormat) << " }"; return 0; @@ -1321,7 +1321,7 @@ int CameraCapabilities::initializeStaticMetadata() LOG(HAL, Debug) << "Output Stream: " << utils::hex(entry.androidFormat) - << " (" << entry.resolution.toString() << ")[" + << " (" << entry.resolution << ")[" << entry.minFrameDurationNsec << "]" << "@" << fps; } diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 00d48471..f7ec95eb 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -925,7 +925,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques ss << i << " - (" << camera3Stream->width << "x" << camera3Stream->height << ")" << "[" << utils::hex(camera3Stream->format) << "] -> " - << "(" << cameraStream->configuration().size.toString() << ")[" + << "(" << cameraStream->configuration().size << ")[" << cameraStream->configuration().pixelFormat.toString() << "]"; /* diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index 9f883924..513c6ef8 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -34,8 +34,8 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg, if (inCfg.size < outCfg.size) { LOG(YUV, Error) << "Up-scaling is not supported" - << " (from " << inCfg.size.toString() - << " to " << outCfg.size.toString() << ")"; + << " (from " << inCfg.size + << " to " << outCfg.size << ")"; return -EINVAL; } diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index 0428b538..bacb4256 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -150,8 +150,7 @@ void CameraSession::infoConfiguration() const << std::endl; for (const Size &size : formats.sizes(pixelformat)) - std::cout << " - " << size.toString() - << std::endl; + std::cout << " - " << size << std::endl; } index++; diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index da579846..29be5623 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -119,9 +119,7 @@ int KMSSink::configure(const libcamera::CameraConfiguration &config) mode.vdisplay == cfg.size.height; }); if (iter == modes.end()) { - std::cerr - << "No mode matching " << cfg.size.toString() - << std::endl; + std::cerr << "No mode matching " << cfg.size << std::endl; return -EINVAL; } diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index eaa2da6b..4bb2066f 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -238,7 +238,7 @@ int CameraSensor::validateSensorDriver() LOG(CameraSensor, Warning) << "The PixelArraySize property has been defaulted to " - << pixelArraySize_.toString(); + << pixelArraySize_; err = -EINVAL; } else { pixelArraySize_ = rect.size(); @@ -249,7 +249,7 @@ int CameraSensor::validateSensorDriver() activeArea_ = Rectangle(pixelArraySize_); LOG(CameraSensor, Warning) << "The PixelArrayActiveAreas property has been defaulted to " - << activeArea_.toString(); + << activeArea_; err = -EINVAL; } diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index e5bbc382..3ac997cc 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -386,9 +386,9 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) pipeConfigs.clear(); LOG(IPU3, Debug) << "Calculating pipe configuration for: "; - LOG(IPU3, Debug) << "input: " << pipe->input.toString(); - LOG(IPU3, Debug) << "main: " << pipe->main.toString(); - LOG(IPU3, Debug) << "vf: " << pipe->viewfinder.toString(); + LOG(IPU3, Debug) << "input: " << pipe->input; + LOG(IPU3, Debug) << "main: " << pipe->main; + LOG(IPU3, Debug) << "vf: " << pipe->viewfinder; const Size &in = pipe->input; @@ -397,8 +397,7 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) * See https://bugs.libcamera.org/show_bug.cgi?id=32 */ if (in.width < ImgUDevice::kIFMaxCropWidth || in.height < ImgUDevice::kIFMaxCropHeight) { - LOG(IPU3, Error) << "Input resolution " << in.toString() - << " not supported"; + LOG(IPU3, Error) << "Input resolution " << in << " not supported"; return {}; } @@ -460,9 +459,9 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) } LOG(IPU3, Debug) << "Computed pipe configuration: "; - LOG(IPU3, Debug) << "IF: " << pipeConfigs[bestIndex].iif.toString(); - LOG(IPU3, Debug) << "BDS: " << pipeConfigs[bestIndex].bds.toString(); - LOG(IPU3, Debug) << "GDC: " << pipeConfigs[bestIndex].gdc.toString(); + LOG(IPU3, Debug) << "IF: " << pipeConfigs[bestIndex].iif; + LOG(IPU3, Debug) << "BDS: " << pipeConfigs[bestIndex].bds; + LOG(IPU3, Debug) << "GDC: " << pipeConfigs[bestIndex].gdc; return pipeConfigs[bestIndex]; } @@ -496,13 +495,13 @@ int ImgUDevice::configure(const PipeConfig &pipeConfig, V4L2DeviceFormat *inputF ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &iif); if (ret) return ret; - LOG(IPU3, Debug) << "ImgU IF rectangle = " << iif.toString(); + LOG(IPU3, Debug) << "ImgU IF rectangle = " << iif; Rectangle bds{ 0, 0, pipeConfig.bds }; ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &bds); if (ret) return ret; - LOG(IPU3, Debug) << "ImgU BDS rectangle = " << bds.toString(); + LOG(IPU3, Debug) << "ImgU BDS rectangle = " << bds; V4L2SubdeviceFormat gdcFormat = {}; gdcFormat.mbus_code = MEDIA_BUS_FMT_FIXED; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index acc0beca..d8c709b7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -166,7 +166,7 @@ V4L2SubdeviceFormat findBestFormat(const SensorFormats &formatsMap, const Size & bestFormat.size = size; } - LOG(RPI, Debug) << "Format: " << size.toString() + LOG(RPI, Debug) << "Format: " << size << " fmt " << format.toString() << " Score: " << score << " (best " << bestScore << ")"; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 1624e2ec..1c53495c 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -592,13 +592,13 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "ISP input pad configured with " << format.toString() - << " crop " << rect.toString(); + << " crop " << rect; /* YUYV8_2X8 is required on the ISP source path pad for YUV output. */ format.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8; LOG(RkISP1, Debug) << "Configuring ISP output pad with " << format.toString() - << " crop " << rect.toString(); + << " crop " << rect; ret = isp_->setSelection(2, V4L2_SEL_TGT_CROP, &rect); if (ret < 0) @@ -610,7 +610,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) LOG(RkISP1, Debug) << "ISP output pad configured with " << format.toString() - << " crop " << rect.toString(); + << " crop " << rect; std::map streamConfig; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index f195f91e..490d09e4 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -119,7 +119,7 @@ int RkISP1Path::configure(const StreamConfiguration &config, LOG(RkISP1, Debug) << "Configured " << name_ << " resizer input pad with " - << ispFormat.toString() << " crop " << rect.toString(); + << ispFormat.toString() << " crop " << rect; ispFormat.size = config.size; diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index 9cbc6ee3..ee8376de 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -65,7 +65,7 @@ int SimpleConverter::Stream::configure(const StreamConfiguration &inputCfg, format.planes[0].bpl != inputCfg.stride) { LOG(SimplePipeline, Error) << "Input format not supported (requested " - << inputCfg.size.toString() << "-" << videoFormat.toString() + << inputCfg.size << "-" << videoFormat.toString() << ", got " << format.toString() << ")"; return -EINVAL; } diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index ece821bf..e76bf012 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -474,7 +474,7 @@ int SimpleCameraData::init() video_->formats(format.mbus_code); LOG(SimplePipeline, Debug) - << "Adding configuration for " << format.size.toString() + << "Adding configuration for " << format.size << " in pixel formats [ " << utils::join(videoFormats, ", ", [](const auto &f) { @@ -808,8 +808,8 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() if (!pipeConfig_->outputSizes.contains(cfg.size)) { LOG(SimplePipeline, Debug) - << "Adjusting size from " << cfg.size.toString() - << " to " << pipeConfig_->captureSize.toString(); + << "Adjusting size from " << cfg.size + << " to " << pipeConfig_->captureSize; cfg.size = pipeConfig_->captureSize; status = Adjusted; } @@ -939,7 +939,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) captureFormat.size != pipeConfig->captureSize) { LOG(SimplePipeline, Error) << "Unable to configure capture in " - << pipeConfig->captureSize.toString() << "-" + << pipeConfig->captureSize << "-" << videoFormat.toString(); return -EINVAL; } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 40654a0b..e5a79417 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -143,8 +143,7 @@ CameraConfiguration::Status UVCCameraConfiguration::validate() if (cfg.size != size) { LOG(UVC, Debug) - << "Adjusting size from " << size.toString() - << " to " << cfg.size.toString(); + << "Adjusting size from " << size << " to " << cfg.size; status = Adjusted; } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index c3e33ecf..3db0ffe5 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -164,7 +164,7 @@ CameraConfiguration::Status VimcCameraConfiguration::validate() if (cfg.size != size) { LOG(VIMC, Debug) - << "Adjusting size to " << cfg.size.toString(); + << "Adjusting size to " << cfg.size; status = Adjusted; } diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index fa216e85..d5ae4605 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -191,7 +191,7 @@ const std::map formatInfoMap = { const std::string V4L2SubdeviceFormat::toString() const { std::stringstream mbus; - mbus << size.toString() << "-"; + mbus << size << "-"; const auto it = formatInfoMap.find(mbus_code); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 05d3273e..5ba866ad 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -433,7 +433,7 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const const std::string V4L2DeviceFormat::toString() const { std::stringstream ss; - ss << size.toString() << "-" << fourcc.toString(); + ss << size << "-" << fourcc.toString(); return ss.str(); } diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 372ee4af..9b06a60e 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -86,8 +86,7 @@ protected: const Size &resolution = sensor_->resolution(); if (resolution != Size(4096, 2160)) { - cerr << "Incorrect sensor resolution " - << resolution.toString() << endl; + cerr << "Incorrect sensor resolution " << resolution << endl; return TestFail; } diff --git a/test/geometry.cpp b/test/geometry.cpp index 51256924..008d51ea 100644 --- a/test/geometry.cpp +++ b/test/geometry.cpp @@ -25,9 +25,7 @@ protected: bool result = op(lhs, rhs); if (result != expect) { - cout << lhs.toString() - << opName << " " - << rhs.toString() + cout << lhs << opName << " " << rhs << "test failed" << std::endl; return false; } diff --git a/test/stream/stream_formats.cpp b/test/stream/stream_formats.cpp index 9353d008..99fa0385 100644 --- a/test/stream/stream_formats.cpp +++ b/test/stream/stream_formats.cpp @@ -40,10 +40,10 @@ protected: cout << "Failed " << name << endl; cout << "Sizes to test:" << endl; for (Size &size : test) - cout << size.toString() << endl; + cout << size << endl; cout << "Valid sizes:" << endl; for (Size &size : valid) - cout << size.toString() << endl; + cout << size << endl; return TestFail; } -- cgit v1.2.1