Revision 49674dd0 libavformat/mov.c

View differences:

libavformat/mov.c
24 24
//#define DEBUG
25 25

  
26 26
#include "libavutil/intreadwrite.h"
27
#include "libavutil/avstring.h"
27 28
#include "avformat.h"
28 29
#include "riff.h"
29 30
#include "isom.h"
......
494 495
    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
495 496
    MOVStreamContext *sc = st->priv_data;
496 497
    int version = get_byte(pb);
498
    char language[4] = {0};
497 499
    unsigned lang;
498 500

  
499 501
    if (version > 1)
......
512 514
    st->duration = (version == 1) ? get_be64(pb) : get_be32(pb); /* duration */
513 515

  
514 516
    lang = get_be16(pb); /* language */
515
    ff_mov_lang_to_iso639(lang, st->language);
517
    if (ff_mov_lang_to_iso639(lang, language))
518
        av_metadata_set(&st->metadata, "language", language);
516 519
    get_be16(pb); /* quality */
517 520

  
518 521
    return 0;
......
1438 1441

  
1439 1442
static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
1440 1443
{
1441
    char *str = NULL;
1442
    int size;
1444
    char str[1024], key2[16], language[4] = {0};
1445
    const char *key = NULL;
1443 1446
    uint16_t str_size;
1444 1447

  
1445 1448
    if (c->itunes_metadata) {
......
1453 1456
        } else return 0;
1454 1457
    } else {
1455 1458
        str_size = get_be16(pb); // string length
1456
        get_be16(pb); // language
1459
        ff_mov_lang_to_iso639(get_be16(pb), language);
1457 1460
        atom.size -= 4;
1458 1461
    }
1459 1462
    switch (atom.type) {
1460
    case MKTAG(0xa9,'n','a','m'):
1461
        str = c->fc->title; size = sizeof(c->fc->title); break;
1463
    case MKTAG(0xa9,'n','a','m'): key = "title";     break;
1462 1464
    case MKTAG(0xa9,'A','R','T'):
1463
    case MKTAG(0xa9,'w','r','t'):
1464
        str = c->fc->author; size = sizeof(c->fc->author); break;
1465
    case MKTAG(0xa9,'c','p','y'):
1466
        str = c->fc->copyright; size = sizeof(c->fc->copyright); break;
1465
    case MKTAG(0xa9,'w','r','t'): key = "author";    break;
1466
    case MKTAG(0xa9,'c','p','y'): key = "copyright"; break;
1467 1467
    case MKTAG(0xa9,'c','m','t'):
1468
    case MKTAG(0xa9,'i','n','f'):
1469
        str = c->fc->comment; size = sizeof(c->fc->comment); break;
1470
    case MKTAG(0xa9,'a','l','b'):
1471
        str = c->fc->album; size = sizeof(c->fc->album); break;
1468
    case MKTAG(0xa9,'i','n','f'): key = "comment";   break;
1469
    case MKTAG(0xa9,'a','l','b'): key = "album";     break;
1472 1470
    }
1473
    if (!str)
1471
    if (!key)
1474 1472
        return 0;
1475 1473
    if (atom.size < 0)
1476 1474
        return -1;
1477 1475

  
1478
    get_buffer(pb, str, FFMIN3(size, str_size, atom.size));
1476
    str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
1477
    get_buffer(pb, str, str_size);
1478
    str[str_size] = 0;
1479
    av_metadata_set(&c->fc->metadata, key, str);
1480
    if (*language && strcmp(language, "und")) {
1481
        snprintf(key2, sizeof(key2), "%s-%s", key, language);
1482
        av_metadata_set(&c->fc->metadata, key2, str);
1483
    }
1479 1484
    dprintf(c->fc, "%.4s %s %d %lld\n", (char*)&atom.type, str, str_size, atom.size);
1480 1485
    return 0;
1481 1486
}

Also available in: Unified diff