[vlc-commits] MP4: fill the orientation flag in video_format_t

Jean-Baptiste Kempf git at videolan.org
Tue Apr 10 18:00:03 CEST 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Apr 10 17:57:50 2012 +0200| [a5e1acf939f54ca0f95f54c33a72b192a90bb621] | committer: Jean-Baptiste Kempf

MP4: fill the orientation flag in video_format_t

Ref #2882

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

 modules/demux/mp4/libmp4.c |    2 ++
 modules/demux/mp4/libmp4.h |    1 +
 modules/demux/mp4/mp4.c    |   16 ++++++++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 82ff608..a50c525 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -736,6 +736,8 @@ static int MP4_ReadBox_tkhd(  stream_t *p_stream, MP4_Box_t *p_box )
     if (rotation < 0)
         rotation += 360.;
 
+    p_box->data.p_tkhd->f_rotation = rotation;
+
 #ifdef MP4_VERBOSE
     MP4_ConvertDate2Str( s_creation_time, p_box->data.p_mvhd->i_creation_time );
     MP4_ConvertDate2Str( s_modification_time, p_box->data.p_mvhd->i_modification_time );
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 25ac42c..b8490d5 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -341,6 +341,7 @@ typedef struct MP4_Box_data_tkhd_s
     int32_t  i_matrix[9];
     int32_t  i_width;
     int32_t  i_height;
+    float    f_rotation;
 
 } MP4_Box_data_tkhd_t;
 
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index d7ede74..b13bc5f 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -105,6 +105,7 @@ typedef struct
     /* display size only ! */
     int i_width;
     int i_height;
+    float f_rotation;
 
     /* more internal data */
     uint64_t        i_timescale;    /* time scale for this track only */
@@ -1568,6 +1569,20 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
                               p_track, i_sample_description_index, i_chunk );
         p_demux->p_sys->f_fps = (float)p_track->fmt.video.i_frame_rate /
                                 (float)p_track->fmt.video.i_frame_rate_base;
+
+        /* Rotation */
+        switch( (int)p_track->f_rotation ) {
+            case 90:
+                p_track->fmt.video.orientation = ORIENT_ROTATED_90;
+                break;
+            case 180:
+                p_track->fmt.video.orientation = ORIENT_ROTATED_180;
+                break;
+            case 270:
+                p_track->fmt.video.orientation = ORIENT_ROTATED_270;
+                break;
+        }
+
         break;
 
     case AUDIO_ES:
@@ -2325,6 +2340,7 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
     p_track->i_track_ID = p_tkhd->data.p_tkhd->i_track_ID;
     p_track->i_width = p_tkhd->data.p_tkhd->i_width / 65536;
     p_track->i_height = p_tkhd->data.p_tkhd->i_height / 65536;
+    p_track->f_rotation = p_tkhd->data.p_tkhd->f_rotation;
 
     if( p_tref )
     {



More information about the vlc-commits mailing list