[{"id":4045,"web_url":"https://patchwork.libcamera.org/comment/4045/","msgid":"<20200317110445.GE4864@pendragon.ideasonboard.com>","date":"2020-03-17T11:04:45","subject":"Re: [libcamera-devel] [PATCH v2 5/8] libcamera: v4l2_videodevice:\n\tRemove usage of ImageFormats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Tue, Mar 17, 2020 at 04:52:36AM +0100, Niklas Söderlund wrote:\n> The ImageFormats class is not very nice as it forces the pixel format to\n> be an unsigned integer. Replace it with a map of unsigned int to vector\n> of sizes.\n\ns/sizes/size ranges/\n\nThe commit message probably needs some improvement. I understand what\nyou're doing here, but replacing a class that forces usage of an integer\nwith a map that uses an integer key still forces usage of an integer :-)\nYou should explain the rationale behind this.\n\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/libcamera/include/v4l2_videodevice.h |  2 +-\n>  src/libcamera/pipeline/uvcvideo.cpp      |  3 +--\n>  src/libcamera/v4l2_videodevice.cpp       | 11 +++--------\n>  3 files changed, 5 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> index 2507daf23efac66f..62e6a657fc7eedb0 100644\n> --- a/src/libcamera/include/v4l2_videodevice.h\n> +++ b/src/libcamera/include/v4l2_videodevice.h\n> @@ -184,7 +184,7 @@ public:\n>  \n>  \tint getFormat(V4L2DeviceFormat *format);\n>  \tint setFormat(V4L2DeviceFormat *format);\n> -\tImageFormats formats();\n> +\tstd::map<unsigned int, std::vector<SizeRange>> formats();\n\nA shorter alias for the map would be nice, but I think it can go on top,\nonce we figure out what we need exactly.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \n>  \tint setCrop(Rectangle *rect);\n>  \tint setCompose(Rectangle *rect);\n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 14f7ddb18a765834..5ebd83f3c2099ffe 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -153,9 +153,8 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera,\n>  \tif (roles.empty())\n>  \t\treturn config;\n>  \n> -\tImageFormats v4l2formats = data->video_->formats();\n>  \tstd::map<PixelFormat, std::vector<SizeRange>> deviceformats;\n> -\tfor (const auto &it : v4l2formats.data()) {\n> +\tfor (const auto &it : data->video_->formats()) {\n>  \t\tPixelFormat pixelformat = V4L2VideoDevice::toPixelFormat(it.first);\n>  \t\tconst std::vector<SizeRange> &ranges = it.second;\n>  \t\tdeviceformats[pixelformat] = ranges;\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 858310c3b810350a..280cf1877c8936d7 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -901,21 +901,16 @@ int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format)\n>   *\n>   * \\return A list of the supported video device formats\n>   */\n> -ImageFormats V4L2VideoDevice::formats()\n> +std::map<unsigned int, std::vector<SizeRange>> V4L2VideoDevice::formats()\n>  {\n> -\tImageFormats formats;\n> +\tstd::map<unsigned int, std::vector<SizeRange>> formats;\n>  \n>  \tfor (unsigned int pixelformat : enumPixelformats()) {\n>  \t\tstd::vector<SizeRange> sizes = enumSizes(pixelformat);\n>  \t\tif (sizes.empty())\n>  \t\t\treturn {};\n>  \n> -\t\tif (formats.addFormat(pixelformat, sizes)) {\n> -\t\t\tLOG(V4L2, Error)\n> -\t\t\t\t<< \"Could not add sizes for pixel format \"\n> -\t\t\t\t<< pixelformat;\n> -\t\t\treturn {};\n> -\t\t}\n> +\t\tformats[pixelformat] = sizes;\n>  \t}\n>  \n>  \treturn formats;","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F15662923\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 Mar 2020 12:04:51 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E47BF9;\n\tTue, 17 Mar 2020 12:04:50 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584443091;\n\tbh=1AXpAf0eqh60PfOhSr+jGY5gs20YeQFpfFTxyPZzMCk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hGEIiqVYjEU4swFogwfzPwSSRwr/eNst2+XpR4i+PbLUXBJRaIqTwYI+aLGPaycQU\n\t4L41GS8sv+4dM0rsAac5hKynu5X4PWMFteDZjBgvzrcjwub7jNxRfuhW/ylrtvjNqG\n\tb23qoykFz1C0Zmf8YgUocGnyJife9uKYLjW95+k4=","Date":"Tue, 17 Mar 2020 13:04:45 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200317110445.GE4864@pendragon.ideasonboard.com>","References":"<20200317035239.2697679-1-niklas.soderlund@ragnatech.se>\n\t<20200317035239.2697679-6-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200317035239.2697679-6-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 5/8] libcamera: v4l2_videodevice:\n\tRemove usage of ImageFormats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 17 Mar 2020 11:04:51 -0000"}}]