From 8a845ab078c3fe12ac4edd16c8cbac5b7ec03b98 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 format classes Now that format classes implement the stream formatting operator<<(), use it instead of the toString() function. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/android/camera_capabilities.cpp | 6 +++--- src/android/camera_device.cpp | 4 ++-- src/android/jpeg/encoder_libjpeg.cpp | 2 +- src/android/jpeg/thumbnailer.cpp | 2 +- src/android/mm/generic_camera_buffer.cpp | 3 +-- src/android/yuv/post_processor_yuv.cpp | 4 ++-- src/cam/camera_session.cpp | 2 +- src/cam/kms_sink.cpp | 2 +- src/libcamera/pipeline/ipu3/cio2.cpp | 2 +- src/libcamera/pipeline/ipu3/imgu.cpp | 6 +++--- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 20 ++++++++++---------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 10 +++++----- src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 6 +++--- src/libcamera/pipeline/simple/converter.cpp | 4 ++-- src/libcamera/pipeline/simple/simple.cpp | 9 ++++----- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 5 ++--- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 2 +- src/qcam/viewfinder_qt.cpp | 3 +-- src/v4l2/v4l2_camera_proxy.cpp | 2 +- 20 files changed, 46 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index e06a517d..6f197eb8 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -554,7 +554,7 @@ int CameraCapabilities::initializeStreamConfigurations() formatsMap_[androidFormat] = formats::MJPEG; LOG(HAL, Debug) << "Mapped Android format " << camera3Format.name << " to " - << formats::MJPEG.toString() + << formats::MJPEG << " (fixed mapping)"; continue; } @@ -566,7 +566,7 @@ int CameraCapabilities::initializeStreamConfigurations() PixelFormat mappedFormat; for (const PixelFormat &pixelFormat : libcameraFormats) { - LOG(HAL, Debug) << "Testing " << pixelFormat.toString(); + LOG(HAL, Debug) << "Testing " << pixelFormat; /* * The stream configuration size can be adjusted, @@ -605,7 +605,7 @@ int CameraCapabilities::initializeStreamConfigurations() formatsMap_[androidFormat] = mappedFormat; LOG(HAL, Debug) << "Mapped Android format " << camera3Format.name << " to " - << mappedFormat.toString(); + << mappedFormat; std::vector resolutions; const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f7ec95eb..8e804d4d 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -575,7 +575,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) << ", crop_rotate_scale_degrees: " << rotationToString(stream->crop_rotate_scale_degrees) #endif - << " (" << format.toString() << ")"; + << " (" << format << ")"; if (!format.isValid()) return -EINVAL; @@ -926,7 +926,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques << camera3Stream->height << ")" << "[" << utils::hex(camera3Stream->format) << "] -> " << "(" << cameraStream->configuration().size << ")[" - << cameraStream->configuration().pixelFormat.toString() << "]"; + << cameraStream->configuration().pixelFormat << "]"; /* * Inspect the camera stream type, create buffers opportunely diff --git a/src/android/jpeg/encoder_libjpeg.cpp b/src/android/jpeg/encoder_libjpeg.cpp index 21a3b33d..fd62bd9c 100644 --- a/src/android/jpeg/encoder_libjpeg.cpp +++ b/src/android/jpeg/encoder_libjpeg.cpp @@ -59,7 +59,7 @@ const struct JPEGPixelFormatInfo &findPixelInfo(const PixelFormat &format) const auto iter = pixelInfo.find(format); if (iter == pixelInfo.end()) { LOG(JPEG, Error) << "Unsupported pixel format for JPEG encoder: " - << format.toString(); + << format; return invalidPixelFormat; } diff --git a/src/android/jpeg/thumbnailer.cpp b/src/android/jpeg/thumbnailer.cpp index 1fab8072..41c71c76 100644 --- a/src/android/jpeg/thumbnailer.cpp +++ b/src/android/jpeg/thumbnailer.cpp @@ -30,7 +30,7 @@ void Thumbnailer::configure(const Size &sourceSize, PixelFormat pixelFormat) if (pixelFormat_ != formats::NV12) { LOG(Thumbnailer, Error) << "Failed to configure: Pixel Format " - << pixelFormat_.toString() << " unsupported."; + << pixelFormat_ << " unsupported."; return; } diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp index a4349f89..1bd7090d 100644 --- a/src/android/mm/generic_camera_buffer.cpp +++ b/src/android/mm/generic_camera_buffer.cpp @@ -66,8 +66,7 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer, const auto &info = PixelFormatInfo::info(pixelFormat); if (!info.isValid()) { error_ = -EINVAL; - LOG(HAL, Error) << "Invalid pixel format: " - << pixelFormat.toString(); + LOG(HAL, Error) << "Invalid pixel format: " << pixelFormat; return; } diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp index 513c6ef8..ed44e6fe 100644 --- a/src/android/yuv/post_processor_yuv.cpp +++ b/src/android/yuv/post_processor_yuv.cpp @@ -27,8 +27,8 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg, { if (inCfg.pixelFormat != outCfg.pixelFormat) { LOG(YUV, Error) << "Pixel format conversion is not supported" - << " (from " << inCfg.pixelFormat.toString() - << " to " << outCfg.pixelFormat.toString() << ")"; + << " (from " << inCfg.pixelFormat + << " to " << outCfg.pixelFormat << ")"; return -EINVAL; } diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index bacb4256..efffafbf 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -145,7 +145,7 @@ void CameraSession::infoConfiguration() const const StreamFormats &formats = cfg.formats(); for (PixelFormat pixelformat : formats.pixelformats()) { std::cout << " * Pixelformat: " - << pixelformat.toString() << " " + << pixelformat << " " << formats.range(pixelformat).toString() << std::endl; diff --git a/src/cam/kms_sink.cpp b/src/cam/kms_sink.cpp index 29be5623..7add81a6 100644 --- a/src/cam/kms_sink.cpp +++ b/src/cam/kms_sink.cpp @@ -194,7 +194,7 @@ int KMSSink::configurePipeline(const libcamera::PixelFormat &format) if (ret) { std::cerr << "Unable to find display pipeline for format " - << format.toString() << std::endl; + << format << std::endl; return ret; } diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index f4e8c663..a4e4d302 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -211,7 +211,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat) if (ret) return ret; - LOG(IPU3, Debug) << "CIO2 output format " << outputFormat->toString(); + LOG(IPU3, Debug) << "CIO2 output format " << outputFormat; return 0; } diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index 3ac997cc..34613feb 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -479,7 +479,7 @@ int ImgUDevice::configure(const PipeConfig &pipeConfig, V4L2DeviceFormat *inputF if (ret) return ret; - LOG(IPU3, Debug) << "ImgU input format = " << inputFormat->toString(); + LOG(IPU3, Debug) << "ImgU input format = " << inputFormat; /* * \todo The IPU3 driver implementation shall be changed to use the @@ -511,7 +511,7 @@ int ImgUDevice::configure(const PipeConfig &pipeConfig, V4L2DeviceFormat *inputF if (ret) return ret; - LOG(IPU3, Debug) << "ImgU GDC format = " << gdcFormat.toString(); + LOG(IPU3, Debug) << "ImgU GDC format = " << gdcFormat; StreamConfiguration paramCfg = {}; paramCfg.size = inputFormat->size; @@ -568,7 +568,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, const char *name = dev == output_.get() ? "output" : "viewfinder"; LOG(IPU3, Debug) << "ImgU " << name << " format = " - << outputFormat->toString(); + << outputFormat; return 0; } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d8c709b7..e2ee7f1a 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -167,7 +167,7 @@ V4L2SubdeviceFormat findBestFormat(const SensorFormats &formatsMap, const Size & } LOG(RPI, Debug) << "Format: " << size - << " fmt " << format.toString() + << " fmt " << format << " Score: " << score << " (best " << bestScore << ")"; } @@ -758,8 +758,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) return ret; LOG(RPI, Info) << "Sensor: " << camera->id() - << " - Selected sensor format: " << sensorFormat.toString() - << " - Selected unicam format: " << unicamFormat.toString(); + << " - Selected sensor format: " << sensorFormat + << " - Selected unicam format: " << unicamFormat; ret = data->isp_[Isp::Input].dev()->setFormat(&unicamFormat); if (ret) @@ -790,7 +790,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) format.colorSpace = cfg.colorSpace; LOG(RPI, Debug) << "Setting " << stream->name() << " to " - << format.toString(); + << format; ret = stream->dev()->setFormat(&format); if (ret) @@ -799,7 +799,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) if (format.size != cfg.size || format.fourcc != fourcc) { LOG(RPI, Error) << "Failed to set requested format on " << stream->name() - << ", returned " << format.toString(); + << ", returned " << format; return -EINVAL; } @@ -842,7 +842,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } LOG(RPI, Debug) << "Defaulting ISP Output0 format to " - << format.toString(); + << format; } /* @@ -866,7 +866,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) output1Format.fourcc = V4L2PixelFormat::fromPixelFormat(formats::YUV420); LOG(RPI, Debug) << "Setting ISP Output1 (internal) to " - << output1Format.toString(); + << output1Format; ret = data->isp_[Isp::Output1].dev()->setFormat(&output1Format); if (ret) { @@ -882,7 +882,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) ret = data->isp_[Isp::Stats].dev()->setFormat(&format); if (ret) { LOG(RPI, Error) << "Failed to set format on ISP stats stream: " - << format.toString(); + << format; return ret; } @@ -923,7 +923,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) ret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format); if (ret) { LOG(RPI, Error) << "Failed to set format on Unicam embedded: " - << format.toString(); + << format; return ret; } } @@ -965,7 +965,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) if (ret) { LOG(RPI, Error) << "Failed to set format on " << device->entity()->name() << " pad " << sinkPad->index() - << " with format " << format.toString() + << " with format " << format << ": " << ret; return ret; } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 1c53495c..7cf36524 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -573,13 +573,13 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) * the pipeline. */ V4L2SubdeviceFormat format = config->sensorFormat(); - LOG(RkISP1, Debug) << "Configuring sensor with " << format.toString(); + LOG(RkISP1, Debug) << "Configuring sensor with " << format; ret = sensor->setFormat(&format); if (ret < 0) return ret; - LOG(RkISP1, Debug) << "Sensor configured with " << format.toString(); + LOG(RkISP1, Debug) << "Sensor configured with " << format; ret = isp_->setFormat(0, &format); if (ret < 0) @@ -591,13 +591,13 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) return ret; LOG(RkISP1, Debug) - << "ISP input pad configured with " << format.toString() + << "ISP input pad configured with " << format << " 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() + << "Configuring ISP output pad with " << format << " crop " << rect; ret = isp_->setSelection(2, V4L2_SEL_TGT_CROP, &rect); @@ -609,7 +609,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) return ret; LOG(RkISP1, Debug) - << "ISP output pad configured with " << format.toString() + << "ISP output pad configured with " << format << " crop " << rect; std::map streamConfig; diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp index 490d09e4..6f175758 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp @@ -119,13 +119,13 @@ int RkISP1Path::configure(const StreamConfiguration &config, LOG(RkISP1, Debug) << "Configured " << name_ << " resizer input pad with " - << ispFormat.toString() << " crop " << rect; + << ispFormat << " crop " << rect; ispFormat.size = config.size; LOG(RkISP1, Debug) << "Configuring " << name_ << " resizer output pad with " - << ispFormat.toString(); + << ispFormat; switch (config.pixelFormat) { case formats::NV12: @@ -143,7 +143,7 @@ int RkISP1Path::configure(const StreamConfiguration &config, LOG(RkISP1, Debug) << "Configured " << name_ << " resizer output pad with " - << ispFormat.toString(); + << ispFormat; const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat); V4L2DeviceFormat outputFormat; diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp index ee8376de..77c44fc8 100644 --- a/src/libcamera/pipeline/simple/converter.cpp +++ b/src/libcamera/pipeline/simple/converter.cpp @@ -65,8 +65,8 @@ int SimpleConverter::Stream::configure(const StreamConfiguration &inputCfg, format.planes[0].bpl != inputCfg.stride) { LOG(SimplePipeline, Error) << "Input format not supported (requested " - << inputCfg.size << "-" << videoFormat.toString() - << ", got " << format.toString() << ")"; + << inputCfg.size << "-" << videoFormat + << ", got " << format << ")"; return -EINVAL; } diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e76bf012..76bd228b 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -607,10 +607,10 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, LOG(SimplePipeline, Debug) << "Source '" << source->entity()->name() << "':" << source->index() - << " produces " << sourceFormat.toString() + << " produces " << sourceFormat << ", sink '" << sink->entity()->name() << "':" << sink->index() - << " requires " << format->toString(); + << " requires " << format; return -EINVAL; } } @@ -620,7 +620,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, << "':" << source->index() << " -> '" << sink->entity()->name() << "':" << sink->index() - << " configured with format " << format->toString(); + << " configured with format " << format; } return 0; @@ -939,8 +939,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) captureFormat.size != pipeConfig->captureSize) { LOG(SimplePipeline, Error) << "Unable to configure capture in " - << pipeConfig->captureSize << "-" - << videoFormat.toString(); + << pipeConfig->captureSize << "-" << videoFormat; return -EINVAL; } diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index e5a79417..2ebf2788 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -126,9 +126,8 @@ CameraConfiguration::Status UVCCameraConfiguration::validate() if (iter == pixelFormats.end()) { cfg.pixelFormat = pixelFormats.front(); LOG(UVC, Debug) - << "Adjusting pixel format from " - << pixelFormat.toString() << " to " - << cfg.pixelFormat.toString(); + << "Adjusting pixel format from " << pixelFormat + << " to " << cfg.pixelFormat; status = Adjusted; } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 3db0ffe5..3379ac5c 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -209,7 +209,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera, if (pixelformat.first != formats::BGR888) { LOG(VIMC, Info) << "Skipping unsupported pixel format " - << pixelformat.first.toString(); + << pixelformat.first; continue; } } diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index b3d0ddad..ca6b43ce 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -206,7 +206,7 @@ uint8_t V4L2SubdeviceFormat::bitsPerPixel() const const auto it = formatInfoMap.find(mbus_code); if (it == formatInfoMap.end()) { LOG(V4L2, Error) << "No information available for format '" - << toString() << "'"; + << *this << "'"; return 0; } diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp index a05c75ed..6844f998 100644 --- a/src/qcam/viewfinder_qt.cpp +++ b/src/qcam/viewfinder_qt.cpp @@ -67,8 +67,7 @@ int ViewFinderQt::setFormat(const libcamera::PixelFormat &format, image_ = QImage(size, QImage::Format_RGB32); - qInfo() << "Using software format conversion from" - << format.toString().c_str(); + qInfo() << "Using software format conversion from" << format; } else { qInfo() << "Zero-copy enabled"; } diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 4913e44a..26a227da 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -327,7 +327,7 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg) if (ret < 0) { LOG(V4L2Compat, Error) << "Failed to negotiate a valid format: " - << format.toString(); + << format; return -EINVAL; } -- cgit v1.2.1