[libcamera-devel,2/2] cam: sdl_texture: Renaming 'pitch' to 'stride'
diff mbox series

Message ID 20220808155605.7925-3-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • cam: Miscellaneous fixes for the SDL sink
Related show

Commit Message

Laurent Pinchart Aug. 8, 2022, 3:56 p.m. UTC
The libcamera public API uses 'stride' to refer to the line stride.
Rename the SDLTexture::pitch_ member variable for consistency.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/cam/sdl_texture.cpp      | 4 ++--
 src/cam/sdl_texture.h        | 4 ++--
 src/cam/sdl_texture_mjpg.cpp | 6 +++---
 src/cam/sdl_texture_yuv.cpp  | 6 +++---
 4 files changed, 10 insertions(+), 10 deletions(-)

Comments

Eric Curtin Aug. 8, 2022, 7:22 p.m. UTC | #1
On Mon, 8 Aug 2022 at 16:56, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>
> The libcamera public API uses 'stride' to refer to the line stride.
> Rename the SDLTexture::pitch_ member variable for consistency.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

LGTM

Reviewed-by: Eric Curtin <ecurtin@redhat.com>

> ---
>  src/cam/sdl_texture.cpp      | 4 ++--
>  src/cam/sdl_texture.h        | 4 ++--
>  src/cam/sdl_texture_mjpg.cpp | 6 +++---
>  src/cam/sdl_texture_yuv.cpp  | 6 +++---
>  4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/src/cam/sdl_texture.cpp b/src/cam/sdl_texture.cpp
> index 02a8ff28b669..e9040bc5f67e 100644
> --- a/src/cam/sdl_texture.cpp
> +++ b/src/cam/sdl_texture.cpp
> @@ -10,8 +10,8 @@
>  #include <iostream>
>
>  SDLTexture::SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat,
> -                      const int pitch)
> -       : ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), pitch_(pitch)
> +                      const int stride)
> +       : ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), stride_(stride)
>  {
>  }
>
> diff --git a/src/cam/sdl_texture.h b/src/cam/sdl_texture.h
> index e4d3fb2bcf39..6ccd85eab390 100644
> --- a/src/cam/sdl_texture.h
> +++ b/src/cam/sdl_texture.h
> @@ -16,7 +16,7 @@
>  class SDLTexture
>  {
>  public:
> -       SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int pitch);
> +       SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int stride);
>         virtual ~SDLTexture();
>         int create(SDL_Renderer *renderer);
>         virtual void update(const std::vector<libcamera::Span<const uint8_t>> &data) = 0;
> @@ -26,5 +26,5 @@ protected:
>         SDL_Texture *ptr_;
>         const SDL_Rect rect_;
>         const uint32_t pixelFormat_;
> -       const int pitch_;
> +       const int stride_;
>  };
> diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp
> index 8dd5ee3eb6bc..da958e0372af 100644
> --- a/src/cam/sdl_texture_mjpg.cpp
> +++ b/src/cam/sdl_texture_mjpg.cpp
> @@ -39,7 +39,7 @@ struct JpegErrorManager : public jpeg_error_mgr {
>
>  SDLTextureMJPG::SDLTextureMJPG(const SDL_Rect &rect)
>         : SDLTexture(rect, SDL_PIXELFORMAT_RGB24, rect.w * 3),
> -         rgb_(std::make_unique<unsigned char[]>(pitch_ * rect.h))
> +         rgb_(std::make_unique<unsigned char[]>(stride_ * rect.h))
>  {
>  }
>
> @@ -65,7 +65,7 @@ int SDLTextureMJPG::decompress(Span<const uint8_t> data)
>         jpeg_start_decompress(&cinfo);
>
>         for (int i = 0; cinfo.output_scanline < cinfo.output_height; ++i) {
> -               JSAMPROW rowptr = rgb_.get() + i * pitch_;
> +               JSAMPROW rowptr = rgb_.get() + i * stride_;
>                 jpeg_read_scanlines(&cinfo, &rowptr, 1);
>         }
>
> @@ -79,5 +79,5 @@ int SDLTextureMJPG::decompress(Span<const uint8_t> data)
>  void SDLTextureMJPG::update(const std::vector<libcamera::Span<const uint8_t>> &data)
>  {
>         decompress(data[0]);
> -       SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), pitch_);
> +       SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), stride_);
>  }
> diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp
> index aa424559abd7..b29c3b937265 100644
> --- a/src/cam/sdl_texture_yuv.cpp
> +++ b/src/cam/sdl_texture_yuv.cpp
> @@ -17,8 +17,8 @@ SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)
>
>  void SDLTextureNV12::update(const std::vector<libcamera::Span<const uint8_t>> &data)
>  {
> -       SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,
> -                           data[1].data(), pitch_);
> +       SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), stride_,
> +                           data[1].data(), stride_);
>  }
>  #endif
>
> @@ -29,5 +29,5 @@ SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)
>
>  void SDLTextureYUYV::update(const std::vector<libcamera::Span<const uint8_t>> &data)
>  {
> -       SDL_UpdateTexture(ptr_, &rect_, data[0].data(), pitch_);
> +       SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_);
>  }
> --
> Regards,
>
> Laurent Pinchart
>
Jacopo Mondi Aug. 9, 2022, 7:25 a.m. UTC | #2
Hi Laurent

On Mon, Aug 08, 2022 at 06:56:05PM +0300, Laurent Pinchart via libcamera-devel wrote:
> The libcamera public API uses 'stride' to refer to the line stride.
> Rename the SDLTexture::pitch_ member variable for consistency.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  src/cam/sdl_texture.cpp      | 4 ++--
>  src/cam/sdl_texture.h        | 4 ++--
>  src/cam/sdl_texture_mjpg.cpp | 6 +++---
>  src/cam/sdl_texture_yuv.cpp  | 6 +++---
>  4 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/src/cam/sdl_texture.cpp b/src/cam/sdl_texture.cpp
> index 02a8ff28b669..e9040bc5f67e 100644
> --- a/src/cam/sdl_texture.cpp
> +++ b/src/cam/sdl_texture.cpp
> @@ -10,8 +10,8 @@
>  #include <iostream>
>
>  SDLTexture::SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat,
> -		       const int pitch)
> -	: ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), pitch_(pitch)
> +		       const int stride)
> +	: ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), stride_(stride)
>  {
>  }
>
> diff --git a/src/cam/sdl_texture.h b/src/cam/sdl_texture.h
> index e4d3fb2bcf39..6ccd85eab390 100644
> --- a/src/cam/sdl_texture.h
> +++ b/src/cam/sdl_texture.h
> @@ -16,7 +16,7 @@
>  class SDLTexture
>  {
>  public:
> -	SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int pitch);
> +	SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int stride);
>  	virtual ~SDLTexture();
>  	int create(SDL_Renderer *renderer);
>  	virtual void update(const std::vector<libcamera::Span<const uint8_t>> &data) = 0;
> @@ -26,5 +26,5 @@ protected:
>  	SDL_Texture *ptr_;
>  	const SDL_Rect rect_;
>  	const uint32_t pixelFormat_;
> -	const int pitch_;
> +	const int stride_;
>  };
> diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp
> index 8dd5ee3eb6bc..da958e0372af 100644
> --- a/src/cam/sdl_texture_mjpg.cpp
> +++ b/src/cam/sdl_texture_mjpg.cpp
> @@ -39,7 +39,7 @@ struct JpegErrorManager : public jpeg_error_mgr {
>
>  SDLTextureMJPG::SDLTextureMJPG(const SDL_Rect &rect)
>  	: SDLTexture(rect, SDL_PIXELFORMAT_RGB24, rect.w * 3),
> -	  rgb_(std::make_unique<unsigned char[]>(pitch_ * rect.h))
> +	  rgb_(std::make_unique<unsigned char[]>(stride_ * rect.h))
>  {
>  }
>
> @@ -65,7 +65,7 @@ int SDLTextureMJPG::decompress(Span<const uint8_t> data)
>  	jpeg_start_decompress(&cinfo);
>
>  	for (int i = 0; cinfo.output_scanline < cinfo.output_height; ++i) {
> -		JSAMPROW rowptr = rgb_.get() + i * pitch_;
> +		JSAMPROW rowptr = rgb_.get() + i * stride_;
>  		jpeg_read_scanlines(&cinfo, &rowptr, 1);
>  	}
>
> @@ -79,5 +79,5 @@ int SDLTextureMJPG::decompress(Span<const uint8_t> data)
>  void SDLTextureMJPG::update(const std::vector<libcamera::Span<const uint8_t>> &data)
>  {
>  	decompress(data[0]);
> -	SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), pitch_);
> +	SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), stride_);
>  }
> diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp
> index aa424559abd7..b29c3b937265 100644
> --- a/src/cam/sdl_texture_yuv.cpp
> +++ b/src/cam/sdl_texture_yuv.cpp
> @@ -17,8 +17,8 @@ SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)
>
>  void SDLTextureNV12::update(const std::vector<libcamera::Span<const uint8_t>> &data)
>  {
> -	SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,
> -			    data[1].data(), pitch_);
> +	SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), stride_,
> +			    data[1].data(), stride_);
>  }
>  #endif
>
> @@ -29,5 +29,5 @@ SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)
>
>  void SDLTextureYUYV::update(const std::vector<libcamera::Span<const uint8_t>> &data)
>  {
> -	SDL_UpdateTexture(ptr_, &rect_, data[0].data(), pitch_);
> +	SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_);
>  }
> --
> Regards,
>
> Laurent Pinchart
>

Patch
diff mbox series

diff --git a/src/cam/sdl_texture.cpp b/src/cam/sdl_texture.cpp
index 02a8ff28b669..e9040bc5f67e 100644
--- a/src/cam/sdl_texture.cpp
+++ b/src/cam/sdl_texture.cpp
@@ -10,8 +10,8 @@ 
 #include <iostream>
 
 SDLTexture::SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat,
-		       const int pitch)
-	: ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), pitch_(pitch)
+		       const int stride)
+	: ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), stride_(stride)
 {
 }
 
diff --git a/src/cam/sdl_texture.h b/src/cam/sdl_texture.h
index e4d3fb2bcf39..6ccd85eab390 100644
--- a/src/cam/sdl_texture.h
+++ b/src/cam/sdl_texture.h
@@ -16,7 +16,7 @@ 
 class SDLTexture
 {
 public:
-	SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int pitch);
+	SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int stride);
 	virtual ~SDLTexture();
 	int create(SDL_Renderer *renderer);
 	virtual void update(const std::vector<libcamera::Span<const uint8_t>> &data) = 0;
@@ -26,5 +26,5 @@  protected:
 	SDL_Texture *ptr_;
 	const SDL_Rect rect_;
 	const uint32_t pixelFormat_;
-	const int pitch_;
+	const int stride_;
 };
diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp
index 8dd5ee3eb6bc..da958e0372af 100644
--- a/src/cam/sdl_texture_mjpg.cpp
+++ b/src/cam/sdl_texture_mjpg.cpp
@@ -39,7 +39,7 @@  struct JpegErrorManager : public jpeg_error_mgr {
 
 SDLTextureMJPG::SDLTextureMJPG(const SDL_Rect &rect)
 	: SDLTexture(rect, SDL_PIXELFORMAT_RGB24, rect.w * 3),
-	  rgb_(std::make_unique<unsigned char[]>(pitch_ * rect.h))
+	  rgb_(std::make_unique<unsigned char[]>(stride_ * rect.h))
 {
 }
 
@@ -65,7 +65,7 @@  int SDLTextureMJPG::decompress(Span<const uint8_t> data)
 	jpeg_start_decompress(&cinfo);
 
 	for (int i = 0; cinfo.output_scanline < cinfo.output_height; ++i) {
-		JSAMPROW rowptr = rgb_.get() + i * pitch_;
+		JSAMPROW rowptr = rgb_.get() + i * stride_;
 		jpeg_read_scanlines(&cinfo, &rowptr, 1);
 	}
 
@@ -79,5 +79,5 @@  int SDLTextureMJPG::decompress(Span<const uint8_t> data)
 void SDLTextureMJPG::update(const std::vector<libcamera::Span<const uint8_t>> &data)
 {
 	decompress(data[0]);
-	SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), pitch_);
+	SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), stride_);
 }
diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp
index aa424559abd7..b29c3b937265 100644
--- a/src/cam/sdl_texture_yuv.cpp
+++ b/src/cam/sdl_texture_yuv.cpp
@@ -17,8 +17,8 @@  SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)
 
 void SDLTextureNV12::update(const std::vector<libcamera::Span<const uint8_t>> &data)
 {
-	SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,
-			    data[1].data(), pitch_);
+	SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), stride_,
+			    data[1].data(), stride_);
 }
 #endif
 
@@ -29,5 +29,5 @@  SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)
 
 void SDLTextureYUYV::update(const std::vector<libcamera::Span<const uint8_t>> &data)
 {
-	SDL_UpdateTexture(ptr_, &rect_, data[0].data(), pitch_);
+	SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_);
 }