diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-06-06 13:24:30 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-06 13:24:30 +0200 |
commit | a083543da03e9270c1677eca592e96a298cccb1d (patch) | |
tree | 19db1ed1fb28381ab1ef99285716daa56d7d552e | |
parent | ec98f80af47d2f463c5c3c59aa36c5aaf74204c5 (diff) | |
parent | e7d6d0bf3c5cc1bc048b0ddbc169a91862568e0c (diff) | |
download | ffmpeg-a083543da03e9270c1677eca592e96a298cccb1d.tar.gz |
Merge commit 'e7d6d0bf3c5cc1bc048b0ddbc169a91862568e0c'
* commit 'e7d6d0bf3c5cc1bc048b0ddbc169a91862568e0c':
mov: Export geotag metadata fields
Conflicts:
libavformat/mov.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/mov.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index fe089cdc5c..cc1ed42397 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -222,6 +222,44 @@ static int mov_metadata_raw(MOVContext *c, AVIOContext *pb, return av_dict_set(&c->fc->metadata, key, value, AV_DICT_DONT_STRDUP_VAL); } +static int mov_metadata_loci(MOVContext *c, AVIOContext *pb, unsigned len) +{ + char language[4] = { 0 }; + char buf[100]; + uint16_t langcode = 0; + double longitude, latitude, altitude; + const char *key = "location"; + + if (len < 4 + 2 + 1 + 1 + 4 + 4 + 4) + return AVERROR_INVALIDDATA; + + avio_skip(pb, 4); // version+flags + langcode = avio_rb16(pb); + ff_mov_lang_to_iso639(langcode, language); + len -= 6; + + len -= avio_get_str(pb, len, buf, sizeof(buf)); // place name + if (len < 1) + return AVERROR_INVALIDDATA; + avio_skip(pb, 1); // role + len -= 1; + + if (len < 14) + return AVERROR_INVALIDDATA; + 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/", latitude, longitude); + if (*language && strcmp(language, "und")) { + char key2[16]; + snprintf(key2, sizeof(key2), "%s-%s", key, language); + av_dict_set(&c->fc->metadata, key2, buf, 0); + } + return av_dict_set(&c->fc->metadata, key, buf, 0); +} + static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) { #ifdef MOV_EXPORT_ALL_METADATA @@ -281,6 +319,8 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) return mov_metadata_raw(c, pb, atom.size, "premiere_version"); case MKTAG( '@','P','R','Q'): return mov_metadata_raw(c, pb, atom.size, "quicktime_version"); + case MKTAG( 'l','o','c','i'): + return mov_metadata_loci(c, pb, atom.size); } if (c->itunes_metadata && atom.size > 8) { |