summaryrefslogtreecommitdiff
path: root/src/qcam/viewfinder.h
AgeCommit message (Collapse)Author
2022-10-20Move test applications to src/apps/Laurent Pinchart
The cam and qcam test application share code, currently through a crude hack that references the cam source files directly from the qcam meson.build file. To prepare for the introduction of hosting that code in a static library, move all applications to src/apps/. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2022-09-01qcam: Pass color space to ViewFinder::setFormat()Laurent Pinchart
To prepare for color space support in the viewfinder, pass the color space to the setFormat() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
2021-11-24qcam: Convert to pragma onceKieran Bingham
Remove the verbose #ifndef/#define/#endif pattern for maintaining header idempotency, and replace it with a simple #pragma once. This simplifies the headers, and prevents redundant changes when header files get moved. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-09-22qcam: viewfinder: Pass stride value to viewfinderLaurent Pinchart
qcam currently assumes that no padding is used at end of lines, and uses the image width as the stride. This leads to rendering failures with some formats on some platforms. To prepare for stride support, add a stride parameter to the ViewFinder::setFormat() function to pass the stride from the stream configuration to the viewfinder. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
2021-09-07qcam: Use Image class to access pixel dataLaurent Pinchart
Replace the manual implementation of frame buffer mapping with the Image class to improve code sharing. The ViewFinder API is updated to take an Image pointer in the render() function to prepare for multi-planar buffer support. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-21qcam: Replace MappedBuffer with Span<uint8_t>Laurent Pinchart
The MappedBuffer structure is a custom container that binds a data pointer with a length. This is exactly what Span is. Use it instead. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-07-11libcamera: buffer: Rename buffer.h to framebuffer.hLaurent Pinchart
libcamera names header files based on the classes they define. The buffer.h file is an exception. Rename it to framebuffer.h. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-10-23libcamera: Declare empty virtual destructors as defaultedLaurent Pinchart
The base class of polymorphic classes is required to declare a destructor. Several of these are empty, and can thus be declared as defaulted. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-09-15qcam: New viewfinder hierarchyShow Liu
Create ViewFinder base class and rename the original ViewFinder as QPainter-based ViewFinder. Signed-off-by: Show Liu <show.liu@linaro.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-06libcamera: Rename pixelformats.{cpp,h} to pixel_format.{cpp,h}Laurent Pinchart
The libcamera source files are named after class names, using snake_case. pixelformats.h and pixelformats.cpp don't comply with that rule. Fix them. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2020-03-24qcam: viewfinder: Report the natively supported pixel formatsLaurent Pinchart
Expose the pixel formats natively supported by the viewfinder, to allow selection of stream formats that would minimize usage of software conversion. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-24qcam: viewfinder: Display icon when stopping captureLaurent Pinchart
When stopping capture, display an icon instead of the last frame. This is required to be able to release the last buffer when the viewfinder operators in zero-copy mode. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-24qcam: viewfinder: Avoid memory copy when conversion isn't neededLaurent Pinchart
If the frame buffer format is identical to the display format, the viewfinder still invokes the converter to perform what is essentially a slow memcpy(). Make it possible to skip that operation by creating a QImage referencing the buffer memory instead. A reference to the frame buffer is kept internally, and released when the next buffer is queued, pushing the current one out. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-24qcam: viewfinder: Embed QImage in ViewFinderLaurent Pinchart
The QImage class is a thin wrapper that uses implicit sharing. We can thus embed it in the ViewFinder class instead of allocating it dynamically, and assign it at runtime. This simplifies the code. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-24qcam: viewfinder: Make the viewfinder hold a reference to a bufferLaurent Pinchart
The viewfinder is currently expected to render frames to the screen synchronously in the display() function, or at least to copy data so that the buffer can be queued in a new request when the function returns. This prevents optimisations when the capture format is identical to the display format. Make the viewfinder take ownership of the buffer, and notify of its release through a signal. The release is currently still synchronous, this will be addressed in a subsequent patch. Rename the ViewFinder::display() function to render() to better describe its purpose, as it's meant to start the rendering and not display the frame synchronously. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-24qcam: viewfinder: Add MappedBuffer to store memory mapping informationLaurent Pinchart
The new MappedBuffer structure replaces the std::pair<> used in the mapped buffers map, and allows passing data to the ViewFinder::display() function in a more structured way. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-24qcam: Use QSize through the code baseLaurent Pinchart
Qt has a QSize class to store sizes. Use it to replace width and height where applicable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2020-03-18libcamera: PixelFormat: Mark all function arguments of type PixelFormat as ↵Niklas Söderlund
const reference PixelFormat was previously an alias for unsigned int but is now a class. Make all functions taking PixelFormat do so as a const reference. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-03-18libcamera: Use PixelFormat instead of unsigned int where appropriateNiklas Söderlund
Use the PixelFormat instead of unsigned int where a pixel format is to be used. PixelFormat is defined as an unsigned int but is about to be turned into a class to add functionality. There is no functional change in this patch. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-02-14qcam: Provide save image functionalityKieran Bingham
Implement a save image button on the toolbar which will take a current viewfinder image and present the user with a QFileDialog to allow them to choose where to save the image. Utilise the QImageWriter to perform the output task. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-01-20qcam: Support scaling of the viewfinderLaurent Pinchart
The viewfinder is drawn using a QLabel. This could support scaling through QLabel::setScaledContents(), but in a very inefficient way. To maintain reasonable efficiency, turn the viewfinder into a QWidget and draw the image directly using a QPainter. No performance change was noticed running on a fast x86 machine, and performance was 60% higher when scaling up to full screen compared to QLabel. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-09-24qcam: Fix ViewFinder memory leakKieran Bingham
When setting the format on the ViewFinder, a new image_ is allocated. Any change in format deletes the existing allocation, but it is not cleaned up on shutdown: Direct leak of 32 byte(s) in 1 object(s) allocated from: #0 0x7f0bf8a7e17f in operator new(unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x10e17f) #1 0x564c7205f7b0 in ViewFinder::setFormat(unsigned int, unsigned int, unsigned int) ../src/qcam/viewfinder.cpp:43 #2 0x564c71fec467 in MainWindow::startCapture() ../src/qcam/main_window.cpp:152 #3 0x564c71fe6c1a in MainWindow::MainWindow(libcamera::CameraManager*, OptionsParser::Options const&) ../src/qcam/main_window.cpp:40 #4 0x564c71fdf133 in main ../src/qcam/main.cpp:76 #5 0x7f0bf5944b6a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26b6a) Provide a ViewFinder destructor, and delete the allocation as appropriate. Fixes: 97e8b3a2eb32 ("qcam: Add Qt-based GUI application") Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-04-02qcam: Add JPEG format supportLaurent Pinchart
When the camera provides MJPEG, use the QImage JPEG decompression code to convert that to RGB. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-03-29qcam: Add Qt-based GUI applicationLaurent Pinchart
qcam is a sample camera GUI application based on Qt. It demonstrates integration of the Qt event loop with libcamera. The application lets the user select a camera through the GUI, and then captures a single stream from the camera and displays it in a window. Only streams in YUYV formats are supported for now. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>