[4/8] mov: Append place name instead of overwriting for loci

Message ID 1463569341-73691-4-git-send-email-martin@martin.st
State Committed
Commit 94d8141c8cd96c176f7d4bdb74a95331ec7db19b
Headers show

Commit Message

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

---
 libavformat/mov.c | 6 +++---
 1 file changed, 3 insertions(+), 3 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 | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 81803cf..3130c32 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -221,7 +221,7 @@ static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
>  static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
>  {
>      char language[4] = { 0 };
> -    char buf[100];
> +    char buf[200], place[100];
>      uint16_t langcode = 0;
>      double longitude, latitude;
>      const char *key = "location";
> @@ -236,7 +236,7 @@ static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
>      ff_mov_lang_to_iso639(langcode, language);
>      len -= 6;
>
> -    len -= avio_get_str(pb, len, buf, sizeof(buf)); // place name
> +    len -= avio_get_str(pb, len, place, sizeof(place));
>      if (len < 1) {
>          av_log(c->fc, AV_LOG_ERROR, "place name too long\n");
>          return AVERROR_INVALIDDATA;
> @@ -252,7 +252,7 @@ static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
>      latitude  = ((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/", latitude, longitude);
> +    snprintf(buf, sizeof(buf), "%+08.4f%+09.4f/%s", latitude, longitude, place);
>      if (*language && strcmp(language, "und")) {
>          char key2[16];
>          snprintf(key2, sizeof(key2), "%s-%s", key, language);
> --

should be fine

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 81803cf..3130c32 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -221,7 +221,7 @@  static int mov_read_covr(MOVContext *c, AVIOContext *pb, int type, int len)
 static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
 {
     char language[4] = { 0 };
-    char buf[100];
+    char buf[200], place[100];
     uint16_t langcode = 0;
     double longitude, latitude;
     const char *key = "location";
@@ -236,7 +236,7 @@  static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
     ff_mov_lang_to_iso639(langcode, language);
     len -= 6;
 
-    len -= avio_get_str(pb, len, buf, sizeof(buf)); // place name
+    len -= avio_get_str(pb, len, place, sizeof(place));
     if (len < 1) {
         av_log(c->fc, AV_LOG_ERROR, "place name too long\n");
         return AVERROR_INVALIDDATA;
@@ -252,7 +252,7 @@  static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len)
     latitude  = ((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/", latitude, longitude);
+    snprintf(buf, sizeof(buf), "%+08.4f%+09.4f/%s", latitude, longitude, place);
     if (*language && strcmp(language, "und")) {
         char key2[16];
         snprintf(key2, sizeof(key2), "%s-%s", key, language);