[vlc-devel] [PATCH] Support for rotated MP4 Movies (bug #2882)
Matthias Keiser
matthias at tristan-inc.com
Fri Feb 7 22:30:02 CET 2014
From 5fe72164194ebfd38b6732813e5a030e408d79a6 Mon Sep 17 00:00:00 2001
From: Matthias Keiser <matthias at tristan-inc.com>
Date: Fri, 7 Feb 2014 22:27:45 +0100
Subject: [PATCH] Avformat: set video orientation according to the values
passed by libavformat (currently FFmpeg only).
---
modules/demux/avformat/demux.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index 6e8086e..e3ef925 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -323,6 +323,28 @@ int OpenDemux( vlc_object_t *p_this )
fmt.video.i_width = cc->width;
fmt.video.i_height = cc->height;
+
+ char const *kRotateKey = "rotate";
+ AVDictionaryEntry *rotation = av_dict_get(s->metadata, kRotateKey, NULL, 0);
+
+ if( rotation )
+ {
+
+ long angle = strtol(rotation->value, NULL, 10);
+
+ if (angle > 45 && angle < 135)
+ fmt.video.orientation = ORIENT_ROTATED_270;
+
+ else if (angle > 135 && angle < 225)
+ fmt.video.orientation = ORIENT_ROTATED_180;
+
+ else if (angle > 225 && angle < 315)
+ fmt.video.orientation = ORIENT_ROTATED_90;
+
+ else
+ fmt.video.orientation = ORIENT_NORMAL;
+ }
+
#if LIBAVCODEC_VERSION_MAJOR < 54
if( cc->palctrl )
{
--
1.8.3.4 (Apple Git-47)
Am 07.02.2014 um 09:11 schrieb Rémi Denis-Courmont <remi at remlab.net>:
> On Thu, 6 Feb 2014 23:18:15 +0100, Matthias Keiser
> <matthias at tristan-inc.com> wrote:
>> From f1ef96fc575693b7716f277012906758f0df83e4 Mon Sep 17 00:00:00 2001
>> From: Matthias Keiser <matthias at tristan-inc.com>
>> Date: Thu, 6 Feb 2014 16:06:14 +0100
>> Subject: [PATCH 05/13] Avformat: set video orientation according to the
>> values
>> passed by libavformat (currently FFmpeg only).
>>
>> ---
>> modules/demux/avformat/demux.c | 19 +++++++++++++++++++
>> 1 file changed, 19 insertions(+)
>>
>> diff --git a/modules/demux/avformat/demux.c
>> b/modules/demux/avformat/demux.c
>> index 6e8086e..a931572 100644
>> --- a/modules/demux/avformat/demux.c
>> +++ b/modules/demux/avformat/demux.c
>> @@ -323,6 +323,25 @@ int OpenDemux( vlc_object_t *p_this )
>>
>> fmt.video.i_width = cc->width;
>> fmt.video.i_height = cc->height;
>> +
>> + char const *kRotateKey = "rotate";
>> + AVDictionaryEntry *rotation = av_dict_get(s->metadata,
>> kRotateKey, NULL, 0);
>> +
>> + if( rotation )
>> + {
>> + if ( !strncmp(rotation->value, "90", 2 ))
>> + {
>> + fmt.video.orientation = ORIENT_ROTATED_270;
>> + }
>> + else if ( !strncmp(rotation->value, "180", 3 ))
>> + {
>> + fmt.video.orientation = ORIENT_ROTATED_180;
>> + }
>> + else if ( !strncmp(rotation->value, "270", 3 ))
>> + {
>> + fmt.video.orientation = ORIENT_ROTATED_90;
>> + }
>
> I would rather call atoi() and round to the nearest rectangular angle.
> Also mind the indentation...
>
>> + }
>> #if LIBAVCODEC_VERSION_MAJOR < 54
>> if( cc->palctrl )
>> {
>
> --
> Rémi Denis-Courmont
> Sent from my collocated server
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list