[vlc-devel] [PATCH] Support for rotated MP4 Movies (bug #2882)

Matthias Keiser matthias at tristan-inc.com
Sat Feb 8 00:19:18 CET 2014


From 5c88469141eb6f12c4bb34b46799921c24e6d139 Mon Sep 17 00:00:00 2001
From: Matthias Keiser <matthias at tristan-inc.com>
Date: Fri, 7 Feb 2014 23:46:12 +0100
Subject: [PATCH] Add function which applies the rotation to a video_format_t.

---
 include/vlc_es.h     |  6 ++++++
 src/misc/es_format.c | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/include/vlc_es.h b/include/vlc_es.h
index 3040c38..09b79ae 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -263,6 +263,12 @@ VLC_API void video_format_CopyCrop( video_format_t *, const video_format_t * );
 VLC_API void video_format_ScaleCropAr( video_format_t *, const video_format_t * );
 
 /**
+ * This function "normalizes" the formats orientation, by switching the a/r according to the orientation,
+ * producing a format whose orientation is ORIENT_NORMAL. It makes a shallow copy (pallette is not alloc'ed).
+ */
+void video_format_ApplyRotation(const video_format_t * restrict in, video_format_t * restrict out);
+
+/**
  * This function will check if the first video format is similar
  * to the second one.
  */
diff --git a/src/misc/es_format.c b/src/misc/es_format.c
index 87b6ada..d64f549 100644
--- a/src/misc/es_format.c
+++ b/src/misc/es_format.c
@@ -243,6 +243,27 @@ void video_format_ScaleCropAr( video_format_t *p_dst, const video_format_t *p_sr
                 p_dst->i_sar_num, p_dst->i_sar_den, 65536);
 }
 
+void video_format_ApplyRotation(const video_format_t * restrict in, video_format_t * restrict out) {
+
+    *out = *in;
+
+    if(in->orientation == ORIENT_ROTATED_90 || in->orientation == ORIENT_ROTATED_270 ||
+       in->orientation == ORIENT_LEFT_TOP || in->orientation == ORIENT_RIGHT_BOTTOM) {
+
+        out->i_visible_width = in->i_visible_height;
+        out->i_visible_height = in->i_visible_width;
+        out->i_height = in->i_width;
+        out->i_width = in->i_height;
+        out->i_sar_num = in->i_sar_den;
+        out->i_sar_den = in->i_sar_num;
+        out->orientation = ORIENT_NORMAL;
+    }
+    else {
+        out->orientation = ORIENT_NORMAL;
+    }
+}
+
+
 bool video_format_IsSimilar( const video_format_t *p_fmt1, const video_format_t *p_fmt2 )
 {
     video_format_t v1 = *p_fmt1;
@@ -259,6 +280,9 @@ bool video_format_IsSimilar( const video_format_t *p_fmt1, const video_format_t
     if( v1.i_sar_num * v2.i_sar_den != v2.i_sar_num * v1.i_sar_den )
         return false;
 
+    if( v1.orientation != v2.orientation)
+        return false;
+
     if( v1.i_chroma == VLC_CODEC_RGB15 ||
         v1.i_chroma == VLC_CODEC_RGB16 ||
         v1.i_chroma == VLC_CODEC_RGB24 ||
-- 
1.8.3.4 (Apple Git-47)





More information about the vlc-devel mailing list