1. 05 Apr, 2020 9 commits
  2. 04 Apr, 2020 23 commits
  3. 03 Apr, 2020 8 commits
    • Steve Lhomme's avatar
      avformat/matroska: clean the structure formatting · a6e56d12
      Steve Lhomme authored
      Always use a comma at the end, order elements by value.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      a6e56d12
    • Andreas Rheinhardt's avatar
      avformat/dss: Remove unnecessary allocation · aebf314a
      Andreas Rheinhardt authored
      Put a buffer with a known fixed size into the demuxer's context instead
      of allocating it separately. This also allows to remove the demuxer's
      read_close()-function.
      Reviewed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      aebf314a
    • Andreas Rheinhardt's avatar
    • Paul B Mahol's avatar
    • Andreas Rheinhardt's avatar
      avformat/matroskaenc: Improve BlockAdditions · 52523b69
      Andreas Rheinhardt authored
      8ffcc826 added support for muxing BlockAdditions with BlockAddID equal
      to one. The restriction to BlockAddID == 1 probably resulted from
      a limitation to what was needed; yet over time this led to three
      occurences of "(side_data_size && additional_id == 1)". This commit
      changes this by setting side_data_size to 0 if additional_id != 1.
      
      It also stops hardcoding 1 for the value of BlockAddID to write;
      but it still upholds the requirement that it is 1. See below.
      
      Despite BlockAddId actually having a default value of 1, it is still
      written, because until very recently (namely dbc50f8a) our demuxer
      used a wrong default value of 0.
      
      Furthermore, use put_ebml_binary() to write the BlockAdditional element.
      
      (The Matroska specifications have evolved and now the BlockAddID 1 is
      reserved for the codec (as described in the codec's codec mapping),
      BlockMore elements with BlockAddID > 1 are now of a more
      codec-independent nature and require a BlockAdditionalMapping in the
      track's TrackEntry. Given that this muxer does not support writing said
      BlockAdditionalMapping yet (actually, none have been defined yet), we
      have to uphold the requirement that BlockAddID == 1.)
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      52523b69
    • Andreas Rheinhardt's avatar
      avformat/matroskaenc: Improve checks for updating Tags · af97a3a4
      Andreas Rheinhardt authored
      When updating the Tags at the end, the Matroska muxer would twice check
      for whether (!mkv->is_live) is true, despite this code being only executed
      if it is. Furthermore, a loop iterates over all the streams even when
      there is no Tags element to update at all, because the check for whether
      there are Tags is only performed later. This commit fixes this.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      af97a3a4
    • Andreas Rheinhardt's avatar
      avformat/matroskaenc: Remove unnecessary avio_tell(), avio_seek() · 0fc150f0
      Andreas Rheinhardt authored
      avio_close_dyn_buf() has a bug: When the write pointer does not point to
      the end of the written data when calling it (i.e. when one has performed
      a seek back to update already written data), it would not add padding to
      the end of the buffer, but to the current position, overwriting other
      data; furthermore the reported size would be wrong (off by the amount of
      data it has overwritten with padding).
      
      In order not to run into this when updating already written elements or
      elements for which size has only been reserved, the Matroska muxer would
      first record the current position of the dynamic buffer, then seek to
      the desired position, perform the update and seek back to the earlier
      position.
      
      But now that end_ebml_master_crc32() does not make use of
      avio_close_dyn_buf() any more, this is no longer necessary.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      0fc150f0
    • Andreas Rheinhardt's avatar
      avformat/matroskaenc: Stop reallocating of Cluster buffer · 4aa0665f
      Andreas Rheinhardt authored
      The Matroska muxer uses a dynamic buffer to buffer the content of
      Clusters before eventually writing them. Up until now, each time a
      Cluster was written, the dynamic buffer was closed, i.e. freed; now it
      is only reset, saving allocations of the AVIOContext itself, its opaque
      as well as most of the reallocations of the buffer.
      
      This is advantageous performance-wise, in particular on systems where
      reallocations are slow (namely Windows). The following table shows the
      decicyles for writing a frame on Linux (Ubuntu 19.10) and Windows (7)
      on an x64 Haswell (to /dev/null on Linux, to stdout which is discarded
      on Windows (the default values of the size and duration of clusters for
      seekable output have been explicitly set in this case); in all tests,
      writing CRC-32 values has been disabled in all tests; calls to the muxer's
      write_packet function in write_packet() in libavformat/mux.c have been
      timed; each of the following tests has been repeated 50 times):
      
          | Windows before | Windows after | Linux before | Linux after
      _________________________________________________________________
       A  |     979437     |    192304     |    259500    |   183320
       B  |     715936     |    155648     |    152786    |   130879
       C  |     265115     |     56034     |     78496    |    53243
       D  |     386224     |     80307     |    128894    |    75354
       E  |      21732     |     10695     |     11320    |     9801
      
      (A is a 10.2 mb/s file with a GOP length of 2s, amounting to an average
      Cluster size of about 2.5 MiB; the average Cluster size of B is 1.1 MiB;
      for C it is 2.35 MiB, for D it is 0.46 MiB; for E - a file with just a
      single audio track of 158kb/s resulting in a Cluster size of about 100
      kB, the relative gains were the smallest, probably because of the small
      Cluster size.)
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      4aa0665f