Revision dc75e4e3 libavformat/movenc.c

View differences:

libavformat/movenc.c
1513 1513
    return updateSize(pb, pos);
1514 1514
}
1515 1515

  
1516
static int mov_write_chpl_tag(ByteIOContext *pb, AVFormatContext *s)
1517
{
1518
    int64_t pos = url_ftell(pb);
1519
    int i, nb_chapters = FFMIN(s->nb_chapters, 255);
1520

  
1521
    put_be32(pb, 0);            // size
1522
    put_tag (pb, "chpl");
1523
    put_be32(pb, 0x01000000);   // version + flags
1524
    put_be32(pb, 0);            // unknown
1525
    put_byte(pb, nb_chapters);
1526

  
1527
    for (i = 0; i < nb_chapters; i++) {
1528
        AVChapter *c = s->chapters[i];
1529
        AVMetadataTag *t;
1530
        put_be64(pb, av_rescale_q(c->start, c->time_base, (AVRational){1,10000000}));
1531

  
1532
        if ((t = av_metadata_get(c->metadata, "title", NULL, 0))) {
1533
            int len = FFMIN(strlen(t->value), 255);
1534
            put_byte(pb, len);
1535
            put_buffer(pb, t->value, len);
1536
        } else
1537
            put_byte(pb, 0);
1538
    }
1539
    return updateSize(pb, pos);
1540
}
1541

  
1516 1542
static int mov_write_udta_tag(ByteIOContext *pb, MOVMuxContext *mov,
1517 1543
                              AVFormatContext *s)
1518 1544
{
......
1551 1577
            mov_write_meta_tag(pb_buf, mov, s);
1552 1578
        }
1553 1579

  
1580
        if (s->nb_chapters)
1581
            mov_write_chpl_tag(pb_buf, s);
1582

  
1554 1583
    if ((size = url_close_dyn_buf(pb_buf, &buf)) > 0) {
1555 1584
        put_be32(pb, size+8);
1556 1585
        put_tag(pb, "udta");

Also available in: Unified diff