[libcamera-devel,5/5] libcamera: Replace toString with operator<<() for format classes
diff mbox series

Message ID 20220429212348.18063-6-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: More operator<<() for stream output
Related show

Commit Message

Laurent Pinchart April 29, 2022, 9:23 p.m. UTC
Now that format classes implement the stream formatting operator<<(),
use it instead of the toString() function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 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 ++---
 .../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 +-
 test/bayer-format.cpp                         | 24 +++++++++----------
 test/camera-sensor.cpp                        |  2 +-
 22 files changed, 59 insertions(+), 63 deletions(-)

Comments

Kieran Bingham May 4, 2022, 9:08 a.m. UTC | #1
Quoting Laurent Pinchart via libcamera-devel (2022-04-29 22:23:48)
> Now that format classes implement the stream formatting operator<<(),
> use it instead of the toString() function.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  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 ++---
>  .../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 +-
>  test/bayer-format.cpp                         | 24 +++++++++----------
>  test/camera-sensor.cpp                        |  2 +-
>  22 files changed, 59 insertions(+), 63 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index e06a517d84b8..6f197eb80195 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<Size> resolutions;
>                 const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat);
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index f7ec95eb720e..8e804d4d5aed 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 21a3b33dd92c..fd62bd9c7c5b 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 1fab80724f3c..41c71c76e9ce 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 a4349f89cb13..1bd7090d634f 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 513c6ef86153..ed44e6fe02da 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 bacb42561560..efffafbf9e9a 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 29be5623cb17..7add81a64334 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 f4e8c6632c2f..a4e4d302f841 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 3ac997cc1acf..34613feb8130 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 d8c709b7a503..e2ee7f1ace21 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 1c53495c97cc..7cf36524ccc4 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<unsigned int, IPAStream> streamConfig;
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
> index f195f91ead1f..07a6566d308c 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.toString();
> +               << ispFormat << " crop " << rect.toString();
>  
>         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 ee8376dea1e0..77c44fc8714f 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 e76bf01261b0..76bd228b5aba 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 e5a79417f923..2ebf2788c3b4 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 3db0ffe58c39..3379ac5cd47d 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 b3d0ddad83db..ca6b43cea5f1 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 << "'";

This is probably the one time I'd prefer to see toString() rather than
*this, but I don't care too much.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>                 return 0;
>         }
>  
> diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp
> index a05c75ed9e12..6844f998bbe0 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;

I like the simplification here that we don't then need to call .c_str()
on this. Was that actually required for qInfo() before?


>         } else {
>                 qInfo() << "Zero-copy enabled";
>         }
> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp
> index 4913e44a6f5f..26a227da6db2 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;
>         }
>  
> diff --git a/test/bayer-format.cpp b/test/bayer-format.cpp
> index 135bcb5214c8..54f03487fa0e 100644
> --- a/test/bayer-format.cpp
> +++ b/test/bayer-format.cpp
> @@ -72,8 +72,8 @@ protected:
>                 bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtExpect);
>                 V4L2PixelFormat v4l2Fmt = bayerFmt.toV4L2PixelFormat();
>                 if (v4l2Fmt != v4l2FmtExpect) {
> -                       cerr << "Expected: '" << v4l2FmtExpect.toString()
> -                            << "' got: '" << v4l2Fmt.toString() << "'" << endl;
> +                       cerr << "Expected: '" << v4l2FmtExpect
> +                            << "' got: '" << v4l2Fmt << "'" << endl;
>                         return TestFail;
>                 }
>  
> @@ -86,7 +86,7 @@ protected:
>                 v4l2Fmt = bayerFmt.toV4L2PixelFormat();
>                 if (v4l2Fmt != v4l2FmtExpect) {
>                         cerr << "Expected: empty V4L2PixelFormat got: '"
> -                            << v4l2Fmt.toString() << "'" << endl;
> +                            << v4l2Fmt << "'" << endl;
>                         return TestFail;
>                 }
>  
> @@ -101,8 +101,8 @@ protected:
>                 bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt);
>                 if (bayerFmt != bayerFmtExpect) {
>                         cerr << "Expected BayerFormat '"
> -                            << bayerFmtExpect.toString() << "', got: '"
> -                            << bayerFmt.toString() << "'" << endl;
> +                            << bayerFmtExpect << "', got: '"
> +                            << bayerFmt << "'" << endl;
>                         return TestFail;
>                 }
>  
> @@ -115,7 +115,7 @@ protected:
>                 bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtUnknown);
>                 if (bayerFmt.isValid()) {
>                         cerr << "Expected empty BayerFormat got: '"
> -                            << bayerFmt.toString() << "'" << endl;
> +                            << bayerFmt << "'" << endl;
>                         return TestFail;
>                 }
>  
> @@ -151,8 +151,8 @@ protected:
>                 BayerFormat hFlipFmt = bayerFmt.transform(Transform::HFlip);
>                 if (hFlipFmt != bayerFmtExpect) {
>                         cerr << "Horizontal flip of 'BGGR-8' should result in '"
> -                            << bayerFmtExpect.toString() << "', got: '"
> -                            << hFlipFmt.toString() << "'" << endl;
> +                            << bayerFmtExpect << "', got: '"
> +                            << hFlipFmt << "'" << endl;
>                         return TestFail;
>                 }
>  
> @@ -166,8 +166,8 @@ protected:
>                 BayerFormat vFlipFmt = bayerFmt.transform(Transform::VFlip);
>                 if (vFlipFmt != bayerFmtExpect) {
>                         cerr << "Vertical flip of 'BGGR-8' should result in '"
> -                            << bayerFmtExpect.toString() << "', got: '"
> -                            << vFlipFmt.toString() << "'" << endl;
> +                            << bayerFmtExpect << "', got: '"
> +                            << vFlipFmt << "'" << endl;
>                         return TestFail;
>                 }
>  
> @@ -182,7 +182,7 @@ protected:
>                 if (transposeFmt != bayerFmt) {
>                         cerr << "Transpose with both green pixels on the "
>                              << "antidiagonal should not change the order "
> -                            << "(got '" << transposeFmt.toString() << "')"
> +                            << "(got '" << transposeFmt << "')"
>                              << endl;
>                         return TestFail;
>                 }
> @@ -199,7 +199,7 @@ protected:
>                 if (transposeFmt != bayerFmtExpect) {
>                         cerr << "Transpose with the red & blue pixels on the "
>                              << "antidiagonal should switch their position "
> -                            << "(got '" << transposeFmt.toString() << "')"
> +                            << "(got '" << transposeFmt << "')"
>                              << endl;
>                         return TestFail;
>                 }
> diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp
> index 9b06a60e7695..d3dcb51056f1 100644
> --- a/test/camera-sensor.cpp
> +++ b/test/camera-sensor.cpp
> @@ -99,7 +99,7 @@ protected:
>                     format.size != Size(4096, 2160)) {
>                         cerr << "Failed to get a suitable format, expected 4096x2160-0x"
>                              << utils::hex(MEDIA_BUS_FMT_SBGGR10_1X10)
> -                            << ", got " << format.toString() << endl;
> +                            << ", got " << format << endl;
>                         return TestFail;
>                 }
>  
> -- 
> Regards,
> 
> Laurent Pinchart
>
Laurent Pinchart May 4, 2022, 9:38 a.m. UTC | #2
Hi Kieran,

On Wed, May 04, 2022 at 10:08:16AM +0100, Kieran Bingham wrote:
> Quoting Laurent Pinchart via libcamera-devel (2022-04-29 22:23:48)
> > Now that format classes implement the stream formatting operator<<(),
> > use it instead of the toString() function.
> > 
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  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 ++---
> >  .../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 +-
> >  test/bayer-format.cpp                         | 24 +++++++++----------
> >  test/camera-sensor.cpp                        |  2 +-
> >  22 files changed, 59 insertions(+), 63 deletions(-)

[snip]

> > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> > index b3d0ddad83db..ca6b43cea5f1 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 << "'";
> 
> This is probably the one time I'd prefer to see toString() rather than
> *this, but I don't care too much.

'*this* always feels a bit weird, mostly because it's not often
encountered I suppose. I went for it to try and remove as many usages of
toString() as possible, to see what would remain.

> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> >                 return 0;
> >         }
> >  
> > diff --git a/src/qcam/viewfinder_qt.cpp b/src/qcam/viewfinder_qt.cpp
> > index a05c75ed9e12..6844f998bbe0 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;
> 
> I like the simplification here that we don't then need to call .c_str()
> on this. Was that actually required for qInfo() before?

Yes, qInfo() returns a QDebug object which has no operator<<(const
std::string &).

> >         } else {
> >                 qInfo() << "Zero-copy enabled";
> >         }

[snip]

Patch
diff mbox series

diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
index e06a517d84b8..6f197eb80195 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<Size> resolutions;
 		const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat);
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index f7ec95eb720e..8e804d4d5aed 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 21a3b33dd92c..fd62bd9c7c5b 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 1fab80724f3c..41c71c76e9ce 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 a4349f89cb13..1bd7090d634f 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 513c6ef86153..ed44e6fe02da 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 bacb42561560..efffafbf9e9a 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 29be5623cb17..7add81a64334 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 f4e8c6632c2f..a4e4d302f841 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 3ac997cc1acf..34613feb8130 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 d8c709b7a503..e2ee7f1ace21 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 1c53495c97cc..7cf36524ccc4 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<unsigned int, IPAStream> streamConfig;
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
index f195f91ead1f..07a6566d308c 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.toString();
+		<< ispFormat << " crop " << rect.toString();
 
 	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 ee8376dea1e0..77c44fc8714f 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 e76bf01261b0..76bd228b5aba 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 e5a79417f923..2ebf2788c3b4 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 3db0ffe58c39..3379ac5cd47d 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 b3d0ddad83db..ca6b43cea5f1 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 a05c75ed9e12..6844f998bbe0 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 4913e44a6f5f..26a227da6db2 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;
 	}
 
diff --git a/test/bayer-format.cpp b/test/bayer-format.cpp
index 135bcb5214c8..54f03487fa0e 100644
--- a/test/bayer-format.cpp
+++ b/test/bayer-format.cpp
@@ -72,8 +72,8 @@  protected:
 		bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtExpect);
 		V4L2PixelFormat v4l2Fmt = bayerFmt.toV4L2PixelFormat();
 		if (v4l2Fmt != v4l2FmtExpect) {
-			cerr << "Expected: '" << v4l2FmtExpect.toString()
-			     << "' got: '" << v4l2Fmt.toString() << "'" << endl;
+			cerr << "Expected: '" << v4l2FmtExpect
+			     << "' got: '" << v4l2Fmt << "'" << endl;
 			return TestFail;
 		}
 
@@ -86,7 +86,7 @@  protected:
 		v4l2Fmt = bayerFmt.toV4L2PixelFormat();
 		if (v4l2Fmt != v4l2FmtExpect) {
 			cerr << "Expected: empty V4L2PixelFormat got: '"
-			     << v4l2Fmt.toString() << "'" << endl;
+			     << v4l2Fmt << "'" << endl;
 			return TestFail;
 		}
 
@@ -101,8 +101,8 @@  protected:
 		bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt);
 		if (bayerFmt != bayerFmtExpect) {
 			cerr << "Expected BayerFormat '"
-			     << bayerFmtExpect.toString() << "', got: '"
-			     << bayerFmt.toString() << "'" << endl;
+			     << bayerFmtExpect << "', got: '"
+			     << bayerFmt << "'" << endl;
 			return TestFail;
 		}
 
@@ -115,7 +115,7 @@  protected:
 		bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtUnknown);
 		if (bayerFmt.isValid()) {
 			cerr << "Expected empty BayerFormat got: '"
-			     << bayerFmt.toString() << "'" << endl;
+			     << bayerFmt << "'" << endl;
 			return TestFail;
 		}
 
@@ -151,8 +151,8 @@  protected:
 		BayerFormat hFlipFmt = bayerFmt.transform(Transform::HFlip);
 		if (hFlipFmt != bayerFmtExpect) {
 			cerr << "Horizontal flip of 'BGGR-8' should result in '"
-			     << bayerFmtExpect.toString() << "', got: '"
-			     << hFlipFmt.toString() << "'" << endl;
+			     << bayerFmtExpect << "', got: '"
+			     << hFlipFmt << "'" << endl;
 			return TestFail;
 		}
 
@@ -166,8 +166,8 @@  protected:
 		BayerFormat vFlipFmt = bayerFmt.transform(Transform::VFlip);
 		if (vFlipFmt != bayerFmtExpect) {
 			cerr << "Vertical flip of 'BGGR-8' should result in '"
-			     << bayerFmtExpect.toString() << "', got: '"
-			     << vFlipFmt.toString() << "'" << endl;
+			     << bayerFmtExpect << "', got: '"
+			     << vFlipFmt << "'" << endl;
 			return TestFail;
 		}
 
@@ -182,7 +182,7 @@  protected:
 		if (transposeFmt != bayerFmt) {
 			cerr << "Transpose with both green pixels on the "
 			     << "antidiagonal should not change the order "
-			     << "(got '" << transposeFmt.toString() << "')"
+			     << "(got '" << transposeFmt << "')"
 			     << endl;
 			return TestFail;
 		}
@@ -199,7 +199,7 @@  protected:
 		if (transposeFmt != bayerFmtExpect) {
 			cerr << "Transpose with the red & blue pixels on the "
 			     << "antidiagonal should switch their position "
-			     << "(got '" << transposeFmt.toString() << "')"
+			     << "(got '" << transposeFmt << "')"
 			     << endl;
 			return TestFail;
 		}
diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp
index 9b06a60e7695..d3dcb51056f1 100644
--- a/test/camera-sensor.cpp
+++ b/test/camera-sensor.cpp
@@ -99,7 +99,7 @@  protected:
 		    format.size != Size(4096, 2160)) {
 			cerr << "Failed to get a suitable format, expected 4096x2160-0x"
 			     << utils::hex(MEDIA_BUS_FMT_SBGGR10_1X10)
-			     << ", got " << format.toString() << endl;
+			     << ", got " << format << endl;
 			return TestFail;
 		}