From patchwork Fri May 29 11:03:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3880 Return-Path: Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2E72610DA for ; Fri, 29 May 2020 13:00:31 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 2A336E0005; Fri, 29 May 2020 11:00:30 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Fri, 29 May 2020 13:03:33 +0200 Message-Id: <20200529110335.620503-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200529110335.620503-1-jacopo@jmondi.org> References: <20200529110335.620503-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] libcamera: Rename ImageFormats X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 May 2020 11:00:32 -0000 The ImageFormats class is actually a map. Convey that in the class name. Signed-off-by: Jacopo Mondi --- include/libcamera/internal/camera_sensor.h | 2 +- include/libcamera/internal/formats.h | 2 +- include/libcamera/internal/v4l2_subdevice.h | 2 +- include/libcamera/internal/v4l2_videodevice.h | 2 +- src/libcamera/formats.cpp | 32 +++++++++---------- .../pipeline/raspberrypi/raspberrypi.cpp | 10 +++--- src/libcamera/pipeline/simple/simple.cpp | 2 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 2 +- src/libcamera/v4l2_subdevice.cpp | 4 +-- src/libcamera/v4l2_videodevice.cpp | 4 +-- test/v4l2_subdevice/list_formats.cpp | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 5c1d5789fe79..52eedb9ef880 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -75,7 +75,7 @@ private: std::string model_; - ImageFormats formats_; + ImageFormatsMap formats_; Size resolution_; std::vector mbusCodes_; std::vector sizes_; diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index e20c031e857f..cc56e256f54c 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -19,7 +19,7 @@ namespace libcamera { template -class ImageFormats +class ImageFormatsMap { public: using iterator = typename std::map>::iterator; diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h index 0ce6da48f58a..c9aa3428f93c 100644 --- a/include/libcamera/internal/v4l2_subdevice.h +++ b/include/libcamera/internal/v4l2_subdevice.h @@ -51,7 +51,7 @@ public: int setSelection(unsigned int pad, unsigned int target, Rectangle *rect); - ImageFormats formats(unsigned int pad); + ImageFormatsMap formats(unsigned int pad); int getFormat(unsigned int pad, V4L2SubdeviceFormat *format, Whence whence = ActiveFormat); diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h index de4745982e94..02d101db0b2b 100644 --- a/include/libcamera/internal/v4l2_videodevice.h +++ b/include/libcamera/internal/v4l2_videodevice.h @@ -187,7 +187,7 @@ public: int getFormat(V4L2DeviceFormat *format); int setFormat(V4L2DeviceFormat *format); - ImageFormats formats(uint32_t code = 0); + ImageFormatsMap formats(uint32_t code = 0); int setSelection(unsigned int target, Rectangle *rect); diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index a7922077d9c5..3acb6fe6284e 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -21,7 +21,7 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Formats) /** - * \class ImageFormats + * \class ImageFormatsMap * \brief Describe V4L2Device and V4L2SubDevice image formats and associated * image resolutions * @@ -36,62 +36,62 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \typedef ImageFormats::iterator + * \typedef ImageFormatsMap::iterator * \brief Iterator for the formats map */ /** - * \typedef ImageFormats::const_iterator + * \typedef ImageFormatsMap::const_iterator * \brief Const iterator for the formats map */ /** - * \typedef ImageFormats::value_type + * \typedef ImageFormatsMap::value_type * \brief Value type of the entries in the formats map */ /** - * \fn iterator ImageFormats::begin() + * \fn iterator ImageFormatsMap::begin() * \brief Retrieve an iterator to the first element in the formats map * \return An iterator to the first format map */ /** - * \fn const_iterator ImageFormats::begin() const + * \fn const_iterator ImageFormatsMap::begin() const * \brief Retrieve an const iterator to the first element in the formats map * \return A const iterator to the first format map */ /** - * \fn iterator ImageFormats::end() + * \fn iterator ImageFormatsMap::end() * \brief Retrieve an iterator pointing to the past-the-end element in the * formats map * \return An iterator to the element following the last format */ /** - * \fn const_iterator ImageFormats::end() const + * \fn const_iterator ImageFormatsMap::end() const * \brief Retrieve a const iterator pointing to the past-the-end element in the * formats map * \return A const iterator to the element following the last format */ /** - * \fn iterator ImageFormats::find(const T format) + * \fn iterator ImageFormatsMap::find(const T format) * \brief Find an element with key equal to \a format * \param[in] format The format to search for * \return An iterator to the vector of sizes associated with \a format */ /** - * \fn const_iterator ImageFormats::find(const T format) const + * \fn const_iterator ImageFormatsMap::find(const T format) const * \brief Find a const element with key equal to \a format * \param[in] format The format to search for * \return An const iterator to the vector of sizes associated with \a format */ /** - * \fn std::pair ImageFormats::emplace(Args&&... args) + * \fn std::pair ImageFormatsMap::emplace(Args&&... args) * \brief Insert a new element in the formats map constructed in place with the * given \a args * \param[in] args The argument pack used to construct the new entry in place @@ -100,7 +100,7 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \fn ImageFormats::addFormat(T format, const std::vector &sizes) + * \fn ImageFormatsMap::addFormat(T format, const std::vector &sizes) * \brief Add a format and corresponding sizes to the description * \param[in] format Pixel format or media bus code to describe * \param[in] sizes List of supported size ranges for the format @@ -110,19 +110,19 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \fn ImageFormats::isEmpty() const + * \fn ImageFormatsMap::isEmpty() const * \brief Check if the list of devices supported formats is empty * \return True if the list of supported formats is empty */ /** - * \fn ImageFormats::formats() const + * \fn ImageFormatsMap::formats() const * \brief Retrieve a list of all supported image formats * \return List of pixel formats or media bus codes */ /** - * \fn ImageFormats::sizes(T format) const + * \fn ImageFormatsMap::sizes(T format) const * \brief Retrieve all sizes for a specific format * \param[in] format The pixel format or mbus code * @@ -134,7 +134,7 @@ LOG_DEFINE_CATEGORY(Formats) */ /** - * \fn ImageFormats::data() const + * \fn ImageFormatsMap::data() const * \brief Retrieve the map that associates formats to image sizes * \return The map that associates formats to image sizes */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 64364afb3f7e..e0132113b072 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -65,7 +65,7 @@ double scoreFormat(double desired, double actual) return score; } -V4L2DeviceFormat findBestMode(ImageFormats &formatsMap, const Size &req) +V4L2DeviceFormat findBestMode(ImageFormatsMap &formatsMap, const Size &req) { double bestScore = 9e9, score; V4L2DeviceFormat bestMode = {}; @@ -424,7 +424,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * Calculate the best sensor mode we can use based on * the user request. */ - ImageFormats fmts = data_->unicam_[Unicam::Image].dev()->formats(); + ImageFormatsMap fmts = data_->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, cfg.size); PixelFormat sensorPixFormat = sensorFormat.fourcc.toPixelFormat(); if (cfg.size != sensorFormat.size || @@ -478,7 +478,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate() * */ PixelFormat &cfgPixFmt = config_.at(outSize[i].first).pixelFormat; - ImageFormats fmts; + ImageFormatsMap fmts; if (i == maxIndex) fmts = data_->isp_[Isp::Output0].dev()->formats(); @@ -515,7 +515,7 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera, RPiCameraData *data = cameraData(camera); CameraConfiguration *config = new RPiCameraConfiguration(data); V4L2DeviceFormat sensorFormat; - ImageFormats fmts; + ImageFormatsMap fmts; if (roles.empty()) return config; @@ -602,7 +602,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) } /* First calculate the best sensor mode we can use based on the user request. */ - ImageFormats fmts = data->unicam_[Unicam::Image].dev()->formats(); + ImageFormatsMap fmts = data->unicam_[Unicam::Image].dev()->formats(); V4L2DeviceFormat sensorFormat = findBestMode(fmts, rawStream ? sensorSize : maxSize); /* diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index f3e03ba60196..62906b560d6a 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -275,7 +275,7 @@ int SimpleCameraData::init() return ret; } - ImageFormats videoFormats = video_->formats(format.mbus_code); + ImageFormatsMap videoFormats = video_->formats(format.mbus_code); LOG(SimplePipeline, Debug) << "Adding configuration for " << format.size.toString() diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index dbd835f5c5ef..e1b1ae32b821 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -159,7 +159,7 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, if (roles.empty()) return config; - ImageFormats v4l2Formats = data->video_->formats(); + ImageFormatsMap v4l2Formats = data->video_->formats(); std::map> deviceFormats; std::transform(v4l2Formats.begin(), v4l2Formats.end(), std::inserter(deviceFormats, deviceFormats.begin()), diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp index 9fa20e84a904..80db4cda82bb 100644 --- a/src/libcamera/v4l2_subdevice.cpp +++ b/src/libcamera/v4l2_subdevice.cpp @@ -320,9 +320,9 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target, * * \return A list of the supported device formats */ -ImageFormats V4L2Subdevice::formats(unsigned int pad) +ImageFormatsMap V4L2Subdevice::formats(unsigned int pad) { - ImageFormats formats; + ImageFormatsMap formats; if (pad >= entity_->pads().size()) { LOG(V4L2, Error) << "Invalid pad: " << pad; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index ea952444e0ad..b264915cb73a 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -925,9 +925,9 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format) * * \return A list of the supported video device formats */ -ImageFormats V4L2VideoDevice::formats(uint32_t code) +ImageFormatsMap V4L2VideoDevice::formats(uint32_t code) { - ImageFormats formats; + ImageFormatsMap formats; for (V4L2PixelFormat pixelFormat : enumPixelformats(code)) { std::vector sizes = enumSizes(pixelFormat); diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index f66bb633fb00..adcf5606c961 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -48,7 +48,7 @@ void ListFormatsTest::printFormats(unsigned int pad, int ListFormatsTest::run() { /* List all formats available on existing "Scaler" pads. */ - ImageFormats formats; + ImageFormatsMap formats; formats = scaler_->formats(0); if (formats.isEmpty()) {