Skip to contentSkip to conversation

drm: fix pixel size of NV12 / NV16 pixel formats

PATCH In review Fabien Dessenne 2 participants 2 messages Apr 28, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: fix pixel size of NV12 / NV16 pixel formats

With NV12, NV21, NV16 and NV61 formats, the size of one pixel from the UV plane (plane #1) is one byte.

Indeed, these pixel formats use 4:2:x chroma subsampling: the chroma pixels are sampled at half the luma: for 2 pixels, there are 1 Cb + 1 Cr = 2 bytes.
So for plane #1, the correct size is actually 1 byte per pixel.

---
 drivers/gpu/drm/drm_crtc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc.c +4 -4
index 3313f7e..572c6fa 100644
@@ -5618,10 +5618,6 @@ int drm_format_plane_cpp(uint32_t format, int plane)
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
 		return 2;
-	case DRM_FORMAT_NV12:
-	case DRM_FORMAT_NV21:
-	case DRM_FORMAT_NV16:
-	case DRM_FORMAT_NV61:
 	case DRM_FORMAT_NV24:
 	case DRM_FORMAT_NV42:
 		return plane ? 2 : 1;
@@ -5635,6 +5631,10 @@ int drm_format_plane_cpp(uint32_t format, int plane)
 	case DRM_FORMAT_YVU422:
 	case DRM_FORMAT_YUV444:
 	case DRM_FORMAT_YVU444:
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV16:
+	case DRM_FORMAT_NV61:
 		return 1;
 	default:
 		drm_fb_get_bpp_depth(format, &depth, &bpp);
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 6 lines · Fabien Dessenne

With NV12, NV21, NV16 and NV61 formats, the size of one pixel from the UV plane (plane #1) is one byte.

Indeed, these pixel formats use 4:2:x chroma subsampling: the chroma pixels are sampled at half the luma: for 2 pixels, there are 1 Cb + 1 Cr = 2 bytes.

You just said it, it's 2 bytes. NAK

Quoted 40 lines

So for plane #1, the correct size is actually 1 byte per pixel.

---
 drivers/gpu/drm/drm_crtc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc.c +4 -4
index 3313f7e..572c6fa 100644
@@ -5618,10 +5618,6 @@ int drm_format_plane_cpp(uint32_t format, int plane)
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
 		return 2;
-	case DRM_FORMAT_NV12:
-	case DRM_FORMAT_NV21:
-	case DRM_FORMAT_NV16:
-	case DRM_FORMAT_NV61:
 	case DRM_FORMAT_NV24:
 	case DRM_FORMAT_NV42:
 		return plane ? 2 : 1;
@@ -5635,6 +5631,10 @@ int drm_format_plane_cpp(uint32_t format, int plane)
 	case DRM_FORMAT_YVU422:
 	case DRM_FORMAT_YUV444:
 	case DRM_FORMAT_YVU444:
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV16:
+	case DRM_FORMAT_NV61:
 		return 1;
 	default:
 		drm_fb_get_bpp_depth(format, &depth, &bpp);
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel