Revision d9fc9ff3

View differences:

libavformat/movenc.c
1200 1200
}
1201 1201

  
1202 1202
/* helper function to write a data tag with the specified string as data */
1203
static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int long_style)
1203
static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lang, int long_style)
1204 1204
{
1205 1205
    if(long_style){
1206 1206
        int64_t pos = url_ftell(pb);
......
1212 1212
        return updateSize(pb, pos);
1213 1213
    }else{
1214 1214
        put_be16(pb, strlen(data)); /* string length */
1215
        put_be16(pb, 0);
1215
        put_be16(pb, lang);
1216 1216
        put_buffer(pb, data, strlen(data));
1217 1217
        return strlen(data) + 4;
1218 1218
    }
1219 1219
}
1220 1220

  
1221
static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int long_style){
1221
static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int lang, int long_style){
1222 1222
    int size = 0;
1223 1223
    if (value && value[0]) {
1224 1224
        int64_t pos = url_ftell(pb);
1225 1225
        put_be32(pb, 0); /* size */
1226 1226
        put_tag(pb, name);
1227
        mov_write_string_data_tag(pb, value, long_style);
1227
        mov_write_string_data_tag(pb, value, lang, long_style);
1228 1228
        size= updateSize(pb, pos);
1229 1229
    }
1230 1230
    return size;
......
1234 1234
                                     const char *name, const char *tag,
1235 1235
                                     int long_style)
1236 1236
{
1237
    AVMetadataTag *t;
1237
    int l, lang = 0, len, len2;
1238
    AVMetadataTag *t, *t2 = NULL;
1239
    char tag2[16];
1238 1240

  
1239 1241
    if (!(t = av_metadata_get(s->metadata, tag, NULL, 0)))
1240 1242
        return 0;
1241 1243

  
1242
    return mov_write_string_tag(pb, name, t->value, long_style);
1244
    len = strlen(t->key);
1245
    snprintf(tag2, sizeof(tag2), "%s-", tag);
1246
    while ((t2 = av_metadata_get(s->metadata, tag2, t2, AV_METADATA_IGNORE_SUFFIX))) {
1247
        len2 = strlen(t2->key);
1248
        if (len2 == len+4 && !strcmp(t->value, t2->value)
1249
            && (l=ff_mov_iso639_to_lang(&t2->key[len2-3], 0)) >= 0) {
1250
            lang = l;
1251
            break;
1252
        }
1253
    }
1254
    return mov_write_string_tag(pb, name, t->value, lang, long_style);
1243 1255
}
1244 1256

  
1245 1257
/* iTunes track number */
......
1281 1293
    mov_write_string_metadata(s, pb, "\251wrt", "author"   , 1);
1282 1294
    mov_write_string_metadata(s, pb, "\251alb", "album"    , 1);
1283 1295
    mov_write_string_metadata(s, pb, "\251day", "year"     , 1);
1284
    mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 1);
1296
    mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
1285 1297
    mov_write_string_metadata(s, pb, "\251cmt", "comment"  , 1);
1286 1298
    mov_write_string_metadata(s, pb, "\251gen", "genre"    , 1);
1287 1299
    mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1);
......
1382 1394
            mov_write_string_metadata(s, pb_buf, "\251aut", "author"     , 0);
1383 1395
            mov_write_string_metadata(s, pb_buf, "\251alb", "album"      , 0);
1384 1396
            mov_write_string_metadata(s, pb_buf, "\251day", "year"       , 0);
1385
            mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0);
1397
            mov_write_string_tag(pb_buf, "\251enc", LIBAVFORMAT_IDENT, 0, 0);
1386 1398
            mov_write_string_metadata(s, pb_buf, "\251des", "comment"    , 0);
1387 1399
            mov_write_string_metadata(s, pb_buf, "\251gen", "genre"      , 0);
1388 1400
            mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright"  , 0);

Also available in: Unified diff