[5/8] mov: Also export loci altitude

Message ID 1463569341-73691-5-git-send-email-martin@martin.st
State Committed
Commit bc43131997a456ecdff160eab288395f5adb8d72
Headers show

Commit Message

Martin Storsjö May 18, 2016, 11:02 a.m.
From: Michael Niedermayer <michaelni@gmx.at>

---
 libavformat/mov.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Vittorio Giovara May 18, 2016, 4:06 p.m. | #1
On Wed, May 18, 2016 at 7:02 AM, Martin Storsjö <martin@martin.st> wrote:
> From: Michael Niedermayer <michaelni@gmx.at>
>
> ---
>  libavformat/mov.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 3130c32..0c1354b 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -223,7 +223,7 @@ static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
>      char language[4] = { 0 };
>      char buf[200], place[100];
>      uint16_t langcode = 0;
> -    double longitude, latitude;
> +    double longitude, latitude, altitude;
>      const char *key = "location";
>
>      if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
> @@ -250,9 +250,14 @@ static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
>      }
>      longitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
>      latitude  = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
> +    altitude  = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
>
>      // Try to output in the same format as the ?xyz field
> -    snprintf(buf, sizeof(buf), "%+08.4f%+09.4f/%s", latitude, longitude, place);
> +    snprintf(buf, sizeof(buf), "%+08.4f%+09.4f",  latitude, longitude);
> +    if (altitude)
> +        av_strlcatf(buf, sizeof(buf), "%+f", altitude);
> +    av_strlcatf(buf, sizeof(buf), "/%s", place);
> +
>      if (*language && strcmp(language, "und")) {
>          char key2[16];
>          snprintf(key2, sizeof(key2), "%s-%s", key, language);
> --
> 2.7.4 (Apple Git-66)

probably ok

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3130c32..0c1354b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -223,7 +223,7 @@  static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
     char language[4] = { 0 };
     char buf[200], place[100];
     uint16_t langcode = 0;
-    double longitude, latitude;
+    double longitude, latitude, altitude;
     const char *key = "location";
 
     if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) {
@@ -250,9 +250,14 @@  static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
     }
     longitude = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
     latitude  = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
+    altitude  = ((int32_t) avio_rb32(pb)) / (float) (1 << 16);
 
     // Try to output in the same format as the ?xyz field
-    snprintf(buf, sizeof(buf), "%+08.4f%+09.4f/%s", latitude, longitude, place);
+    snprintf(buf, sizeof(buf), "%+08.4f%+09.4f",  latitude, longitude);
+    if (altitude)
+        av_strlcatf(buf, sizeof(buf), "%+f", altitude);
+    av_strlcatf(buf, sizeof(buf), "/%s", place);
+
     if (*language && strcmp(language, "und")) {
         char key2[16];
         snprintf(key2, sizeof(key2), "%s-%s", key, language);