[vlc-commits] androidsurface: ensure pitch % 16 == 0

Rafaël Carré git at videolan.org
Thu Jan 3 17:46:24 CET 2013


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Thu Jan  3 17:44:50 2013 +0100| [f7ef87e7efc846466cf3381a008c1a32f3bfc1e0] | committer: Rafaël Carré

androidsurface: ensure pitch % 16 == 0

Some devices (like Samsung Exynos) will not align pitch to 16 bytes.
Thus we need to align the hardware width ourselves.

Note that this needs to be accounted for in the JNI support code.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f7ef87e7efc846466cf3381a008c1a32f3bfc1e0
---

 modules/video_output/androidsurface.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/androidsurface.c b/modules/video_output/androidsurface.c
index 679b15c..d7c4331 100644
--- a/modules/video_output/androidsurface.c
+++ b/modules/video_output/androidsurface.c
@@ -337,9 +337,12 @@ static int  AndroidLockSurface(picture_t *picture) {
     else
         sys->s_lock2(surf, info, NULL);
 
-    // input size doesn't match the surface size,
-    // request a resize
-    if (info->w != sw || info->h != sh) {
+    // For RGB (32 or 16) we need to align on 8 or 4 pixels, 16 pixels for YUV
+    int align_pixels = (16 / picture->p[0].i_pixel_pitch) - 1;
+    uint32_t aligned_width = (sw + align_pixels) & ~align_pixels;
+
+    if (info->w != aligned_width || info->h != sh) {
+        // input size doesn't match the surface size -> request a resize
         jni_SetAndroidSurfaceSize(sw, sh, sys->i_sar_num, sys->i_sar_den);
         sys->s_unlockAndPost(surf);
         jni_UnlockAndroidSurface();



More information about the vlc-commits mailing list