Commit a083543d authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'e7d6d0bf'

* commit 'e7d6d0bf':
  mov: Export geotag metadata fields

Conflicts:
	libavformat/mov.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents ec98f80a e7d6d0bf
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment