[vlc-devel] [PATCH 3/3] omxil-dr: reorient video

Thomas Guillem thomas.guillem at gmail.com
Tue Sep 30 12:18:11 CEST 2014


---
 modules/codec/omxil/omxil.c | 37 +++++++++++++++++++++++++++++++------
 modules/codec/omxil/omxil.h |  1 +
 2 files changed, 32 insertions(+), 6 deletions(-)

diff --git a/modules/codec/omxil/omxil.c b/modules/codec/omxil/omxil.c
index e763f78..544d9ba 100644
--- a/modules/codec/omxil/omxil.c
+++ b/modules/codec/omxil/omxil.c
@@ -2173,6 +2173,31 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
         i_hw_usage = 0;
     }
 
+    if( p_port->p_fmt->video.orientation != ORIENT_NORMAL )
+    {
+        int i_angle;
+
+        switch( p_port->p_fmt->video.orientation )
+        {
+            case ORIENT_ROTATED_90:
+                i_angle = 90;
+                break;
+            case ORIENT_ROTATED_180:
+                i_angle = 180;
+                break;
+            case ORIENT_ROTATED_270:
+                i_angle = 270;
+                break;
+            default:
+                i_angle = 0;
+        }
+        p_port->p_hwbuf->anwpriv.setOrientation( p_port->p_hwbuf->window,
+                                                 i_angle );
+        video_format_ApplyRotation( &p_port->p_hwbuf->fmt_out,
+                                    &p_port->p_fmt->video );
+    } else
+        p_port->p_hwbuf->fmt_out = p_port->p_fmt->video;
+
     if( p_port->p_hwbuf->anwpriv.setup( p_port->p_hwbuf->window,
                                         def->format.video.nFrameWidth,
                                         def->format.video.nFrameHeight,
@@ -2212,12 +2237,12 @@ static int HwBuffer_AllocateBuffers( decoder_t *p_dec, OmxPort *p_port )
         goto error;
     }
 
-    jni_SetAndroidSurfaceSize( def->format.video.nFrameWidth,
-                               def->format.video.nFrameHeight,
-                               def->format.video.nFrameWidth,
-                               def->format.video.nFrameHeight,
-                               p_dec->fmt_out.video.i_sar_num,
-                               p_dec->fmt_out.video.i_sar_den );
+    jni_SetAndroidSurfaceSize( p_port->p_hwbuf->fmt_out.i_width,
+                               p_port->p_hwbuf->fmt_out.i_height,
+                               p_port->p_hwbuf->fmt_out.i_visible_width,
+                               p_port->p_hwbuf->fmt_out.i_visible_height,
+                               p_port->p_hwbuf->fmt_out.i_sar_num,
+                               p_port->p_hwbuf->fmt_out.i_sar_den );
 
     p_port->p_hwbuf->i_buffers = p_port->definition.nBufferCountActual;
     p_port->p_hwbuf->i_max_owned = p_port->p_hwbuf->i_buffers - min_undequeued;
diff --git a/modules/codec/omxil/omxil.h b/modules/codec/omxil/omxil.h
index 6dc7d17..651d708 100644
--- a/modules/codec/omxil/omxil.h
+++ b/modules/codec/omxil/omxil.h
@@ -76,6 +76,7 @@ typedef struct HwBuffer
 
     void            *p_library;
     void            *window;
+    video_format_t  fmt_out;
 #if defined(USE_IOMX)
     native_window_api_t native_window;
     native_window_priv_api_t anwpriv;
-- 
2.1.0




More information about the vlc-devel mailing list