[RFC,v1,5/5] apps: cam: sdl_sink: Support `{RGB,BGR}888`
diff mbox series

Message ID 20250421155109.175930-6-barnabas.pocze@ideasonboard.com
State Superseded
Headers show
Series
  • apps: cam: Support {RGB,BGR}888 format
Related show

Commit Message

Barnabás Pőcze April 21, 2025, 3:51 p.m. UTC
These two formats map to `SDL_PIXELFORMAT_{RGB,BGR}24`, respectively;
use the generic `SDLTexture1Plane` to handle them.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/apps/cam/sdl_sink.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Barnabás Pőcze April 22, 2025, 9:38 a.m. UTC | #1
2025. 04. 21. 17:51 keltezéssel, Barnabás Pőcze írta:
> These two formats map to `SDL_PIXELFORMAT_{RGB,BGR}24`, respectively;
> use the generic `SDLTexture1Plane` to handle them.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>   src/apps/cam/sdl_sink.cpp | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp
> index b295675dc..51c8cfb52 100644
> --- a/src/apps/cam/sdl_sink.cpp
> +++ b/src/apps/cam/sdl_sink.cpp
> @@ -77,6 +77,12 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)
>   	case libcamera::formats::YUYV:
>   		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YUY2, cfg.stride);
>   		break;
> +	case libcamera::formats::RGB888:
> +		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_RGB24, cfg.stride);
> +		break;
> +	case libcamera::formats::BGR888:
> +		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_BGR24, cfg.stride);
> +		break;

Oops... the mapping to SDL formats should be the other way around.


Regards,
Barnabás Pőcze


>   	default:
>   		std::cerr << "Unsupported pixel format "
>   			  << cfg.pixelFormat.toString() << std::endl;
Laurent Pinchart April 22, 2025, 11:41 p.m. UTC | #2
On Tue, Apr 22, 2025 at 11:38:41AM +0200, Barnabás Pőcze wrote:
> 2025. 04. 21. 17:51 keltezéssel, Barnabás Pőcze írta:
> > These two formats map to `SDL_PIXELFORMAT_{RGB,BGR}24`, respectively;
> > use the generic `SDLTexture1Plane` to handle them.
> > 
> > Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> > ---
> >   src/apps/cam/sdl_sink.cpp | 6 ++++++
> >   1 file changed, 6 insertions(+)
> > 
> > diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp
> > index b295675dc..51c8cfb52 100644
> > --- a/src/apps/cam/sdl_sink.cpp
> > +++ b/src/apps/cam/sdl_sink.cpp
> > @@ -77,6 +77,12 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)
> >   	case libcamera::formats::YUYV:
> >   		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YUY2, cfg.stride);
> >   		break;
> > +	case libcamera::formats::RGB888:
> > +		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_RGB24, cfg.stride);
> > +		break;
> > +	case libcamera::formats::BGR888:
> > +		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_BGR24, cfg.stride);
> > +		break;
> 
> Oops... the mapping to SDL formats should be the other way around.

With the order fixed (in the code and in the commit message), this looks
good to me.

> >   	default:
> >   		std::cerr << "Unsupported pixel format "
> >   			  << cfg.pixelFormat.toString() << std::endl;

Patch
diff mbox series

diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp
index b295675dc..51c8cfb52 100644
--- a/src/apps/cam/sdl_sink.cpp
+++ b/src/apps/cam/sdl_sink.cpp
@@ -77,6 +77,12 @@  int SDLSink::configure(const libcamera::CameraConfiguration &config)
 	case libcamera::formats::YUYV:
 		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_YUY2, cfg.stride);
 		break;
+	case libcamera::formats::RGB888:
+		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_RGB24, cfg.stride);
+		break;
+	case libcamera::formats::BGR888:
+		texture_ = std::make_unique<SDLTexture1Plane>(rect_, SDL_PIXELFORMAT_BGR24, cfg.stride);
+		break;
 	default:
 		std::cerr << "Unsupported pixel format "
 			  << cfg.pixelFormat.toString() << std::endl;