Search
SailfishOS Open Build Service
>
Projects
>
nemo
:
devel:hw
:
native-common
>
gst-plugins-good
> _service:tar_git:0002-qtmux-write-rotation-information-into-the-TKHD-matri.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File _service:tar_git:0002-qtmux-write-rotation-information-into-the-TKHD-matri.patch of Package gst-plugins-good
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Mohammed Hassan <mohammed.hassan@jolla.com> Date: Thu, 5 Mar 2015 17:12:13 +0200 Subject: [PATCH] qtmux: write rotation information into the TKHD matrix This patch handles the simple cases of 0, 90, 180 and 270 We simply catch the image orientation event and translate that into the corresponding transformation matrix. Based on the work of Andrew den Exter <andrew.den.exter@jollamobile.com> --- .../gst-plugins-good/gst/isomp4/atoms.c | 31 +++++++++++++++++++ .../gst-plugins-good/gst/isomp4/atoms.h | 2 ++ .../gst-plugins-good/gst/isomp4/gstqtmux.c | 23 ++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/subprojects/gst-plugins-good/gst/isomp4/atoms.c b/subprojects/gst-plugins-good/gst/isomp4/atoms.c index 290d1fdf6257c681ff89e61aa31f90729caa7f48..7e34ced88e7de41846331f818359bb6e25824f28 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/atoms.c +++ b/subprojects/gst-plugins-good/gst/isomp4/atoms.c @@ -4450,6 +4450,37 @@ atom_trak_set_subtitle_type (AtomTRAK * trak, AtomsContext * context, return tx3g; } +void +atom_trak_set_video_transform (AtomTRAK * trak, gint rotation) +{ + switch (rotation) { + case 0: + trak->tkhd.matrix[0] = 1 << 16; + trak->tkhd.matrix[1] = 0; + trak->tkhd.matrix[3] = 0; + trak->tkhd.matrix[4] = 1 << 16; + break; + case 90: + trak->tkhd.matrix[0] = 0; + trak->tkhd.matrix[1] = 1 << 16; + trak->tkhd.matrix[3] = G_MAXUINT16 << 16; + trak->tkhd.matrix[4] = 0; + break; + case 180: + trak->tkhd.matrix[0] = G_MAXUINT16 << 16; + trak->tkhd.matrix[1] = 0; + trak->tkhd.matrix[3] = 0; + trak->tkhd.matrix[4] = G_MAXUINT16 << 16; + break; + case 270: + trak->tkhd.matrix[0] = 0; + trak->tkhd.matrix[1] = G_MAXUINT16 << 16; + trak->tkhd.matrix[3] = 1 << 16; + trak->tkhd.matrix[4] = 0; + break; + } +} + static void atom_mfhd_init (AtomMFHD * mfhd, guint32 sequence_number) { diff --git a/subprojects/gst-plugins-good/gst/isomp4/atoms.h b/subprojects/gst-plugins-good/gst/isomp4/atoms.h index 33d1525d4011ef5f00d1f6820bd7ef26110b42a7..406935ec3670419c5ab2063bb9b7c0f4968609d6 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/atoms.h +++ b/subprojects/gst-plugins-good/gst/isomp4/atoms.h @@ -1069,6 +1069,8 @@ SampleTableEntryMP4V * atom_trak_set_video_type (AtomTRAK * trak, AtomsContext * SampleTableEntryTX3G * atom_trak_set_subtitle_type (AtomTRAK * trak, AtomsContext * context, SubtitleSampleEntry * entry); +void atom_trak_set_video_transform (AtomTRAK * trak, gint rotation); + SampleTableEntryTMCD * atom_trak_set_timecode_type (AtomTRAK * trak, AtomsContext * context, guint trak_timescale, GstVideoTimeCode * tc); diff --git a/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c b/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c index f947a6aaa6938892b42f788e527154f8b87d6816..8f1207cbe4e3d1f0d5f7a47d84b587becc3c6a08 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c +++ b/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c @@ -6919,6 +6919,7 @@ gst_qt_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad, GstTagSetter *setter = GST_TAG_SETTER (qtmux); GstTagMergeMode mode; gchar *code; + gchar *orientation; GST_OBJECT_LOCK (qtmux); mode = gst_tag_setter_get_tag_merge_mode (setter); @@ -6957,6 +6958,28 @@ gst_qt_mux_sink_event (GstAggregator * agg, GstAggregatorPad * agg_pad, g_free (code); } + if (gst_tag_list_get_string (list, GST_TAG_IMAGE_ORIENTATION, &orientation)) { + + if (qtmux_pad->trak) { + gint rotation = -1; + if (strcmp(orientation, "rotate-0") == 0) + rotation = 0; + else if (strcmp(orientation, "rotate-90") == 0) + rotation = 90; + else if (strcmp(orientation, "rotate-180") == 0) + rotation = 180; + else if (strcmp(orientation, "rotate-270") == 0) + rotation = 270; + + if (rotation != -1) { + GST_DEBUG_OBJECT (qtmux, "setting rotation to %d", rotation); + atom_trak_set_video_transform (qtmux_pad->trak, rotation); + } + } + + g_free (orientation); + } + gst_event_unref (event); event = NULL; ret = TRUE;