Revision 30f06a58

View differences:

libavformat/matroskaenc.c
725 725
    ret = mkv_write_chapters(s);
726 726
    if (ret < 0) return ret;
727 727

  
728
    ret = mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb));
729
    if (ret < 0) return ret;
730

  
731
    mkv->cluster_pos = url_ftell(pb);
732
    mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0);
733
    put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, 0);
734
    mkv->cluster_pts = 0;
735

  
736 728
    if (url_is_streamed(s->pb))
737 729
        mkv_write_seekhead(pb, mkv->main_seekhead);
738 730

  
......
849 841
    int duration = pkt->duration;
850 842
    int ret;
851 843

  
852
    // start a new cluster every 5 MB or 5 sec
853
    if (url_ftell(pb) > mkv->cluster_pos + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {
854
        av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64
855
               " bytes, pts %" PRIu64 "\n", url_ftell(pb), pkt->pts);
856
        end_ebml_master(pb, mkv->cluster);
857

  
844
    if (!mkv->cluster_pos) {
858 845
        ret = mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb));
859 846
        if (ret < 0) return ret;
860 847

  
......
882 869
        if (ret < 0) return ret;
883 870
    }
884 871

  
872
    // start a new cluster every 5 MB or 5 sec
873
    if (url_ftell(pb) > mkv->cluster_pos + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {
874
        av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %" PRIu64
875
               " bytes, pts %" PRIu64 "\n", url_ftell(pb), pkt->pts);
876
        end_ebml_master(pb, mkv->cluster);
877
        mkv->cluster_pos = 0;
878
    }
879

  
885 880
    mkv->duration = FFMAX(mkv->duration, pkt->pts + duration);
886 881
    return 0;
887 882
}
tests/ref/acodec/pcm
22 22
1058444 ./tests/data/acodec/pcm_s16le.wav
23 23
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav
24 24
stddev:    0.00 PSNR:999.99 bytes:  1058444/  1058444
25
2f3e0884e96b984436b1d01200d68871 *./tests/data/acodec/pcm_s16be.mkv
25
33c64392615a70aa1132b6f87215b8a9 *./tests/data/acodec/pcm_s16be.mkv
26 26
1060705 ./tests/data/acodec/pcm_s16be.mkv
27 27
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav
28 28
stddev:    0.00 PSNR:999.99 bytes:  1058444/  1058444
29
c98158732635effefffa006251b9a6c9 *./tests/data/acodec/pcm_s16le.mkv
29
ff09423d5ead01dee128b5875682de2a *./tests/data/acodec/pcm_s16le.mkv
30 30
1060705 ./tests/data/acodec/pcm_s16le.mkv
31 31
95e54b261530a1bcf6de6fe3b21dc5f6 *./tests/data/pcm.acodec.out.wav
32 32
stddev:    0.00 PSNR:999.99 bytes:  1058444/  1058444

Also available in: Unified diff