Revision e7ddafd5 libavformat/matroskaenc.c

View differences:

libavformat/matroskaenc.c
80 80
    int64_t         duration_offset;
81 81
    int64_t         duration;
82 82
    mkv_seekhead    *main_seekhead;
83
    mkv_seekhead    *cluster_seekhead;
84 83
    mkv_cues        *cues;
85 84
    mkv_track       *tracks;
86 85

  
......
725 724
    // isn't more than 10 elements if we only write one of each other
726 725
    // currently defined level 1 element
727 726
    mkv->main_seekhead    = mkv_start_seekhead(pb, mkv->segment_offset, 10);
728
    mkv->cluster_seekhead = mkv_start_seekhead(pb, mkv->segment_offset, 0);
729
    if (mkv->main_seekhead == NULL || mkv->cluster_seekhead == NULL)
727
    if (!mkv->main_seekhead)
730 728
        return AVERROR(ENOMEM);
731 729

  
732 730
    ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_INFO, url_ftell(pb));
......
908 906
    }
909 907

  
910 908
    if (!mkv->cluster_pos) {
911
        ret = mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb));
912
        if (ret < 0) return ret;
913

  
914 909
        mkv->cluster_pos = url_ftell(s->pb);
915 910
        mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0);
916 911
        put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, FFMAX(0, ts));
......
997 992
{
998 993
    MatroskaMuxContext *mkv = s->priv_data;
999 994
    ByteIOContext *pb = s->pb;
1000
    int64_t currentpos, second_seekhead, cuespos;
995
    int64_t currentpos, cuespos;
1001 996
    int ret;
1002 997

  
1003 998
    // check if we have an audio packet cached
......
1019 1014

  
1020 1015
    if (!url_is_streamed(pb)) {
1021 1016
        cuespos = mkv_write_cues(pb, mkv->cues, s->nb_streams);
1022
        second_seekhead = mkv_write_seekhead(pb, mkv->cluster_seekhead);
1023 1017

  
1024 1018
        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CUES    , cuespos);
1025 1019
        if (ret < 0) return ret;
1026
        if (second_seekhead >= 0) {
1027
            ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_SEEKHEAD, second_seekhead);
1028
            if (ret < 0) return ret;
1029
        }
1030 1020
        mkv_write_seekhead(pb, mkv->main_seekhead);
1031 1021

  
1032 1022
        // update the duration

Also available in: Unified diff