1. 06 May, 2020 9 commits
    • Andreas Rheinhardt's avatar
      avformat/matroskaenc: Unify writing level 1 elements preliminarily · 851283a7
      Andreas Rheinhardt authored
      The Matroska muxer updates several header elements when the output is
      seekable; if unseekable, the buffer containing the contents of the element
      is immediately freed after writing. Before this commit, there were three
      places doing exactly the same: Checking whether the output is seekable
      and calling the function that writes and frees or the function that
      just writes the EBML master. This has been unified; adding SeekHead
      entries for these elements has been unified, too.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      851283a7
    • Andreas Rheinhardt's avatar
      avformat/matroskaenc: Move adding SeekEntry into end_ebml_master_crc32() · 4ed3c925
      Andreas Rheinhardt authored
      Up until now, SeekEntries were already added before
      start_ebml_master_crc32() was even called and before we were actually
      sure that we really write the element the SeekHead references: After
      all, we might also error out later; and given that the allocations
      implicit in dynamic buffers should be checked, end_ebml_master_crc32()
      will eventually have to return errors itself, so that it is the right
      place to add SeekHead entries.
      
      The earlier behaviour is of course a remnant of the time in which
      start_ebml_master_crc32() really did output something, so that the
      position before start_ebml_master_crc32() needed to be recorded.
      Erroring out later is also not as dangerous as it seems because in
      this case no SeekHead will be written (if it happened when writing
      the header, the whole muxing process would abort; if it happened
      when writing the trailer (when writing chapters not available initially),
      writing the trailer would be aborted and no SeekHead containing the
      bogus chapter entry would be written).
      
      This commit does not change the way the SeekEntries are added for those
      elements that are output preliminarily; this is so because the SeekHead
      is written before those elements are finally output and doing it
      otherwise would increase the amount of seeks.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      4ed3c925
    • Andreas Rheinhardt's avatar
      avformat/hlsenc: Improve checks for invalid stream mappings · c801ab43
      Andreas Rheinhardt authored
      The mapping of streams to the various variant streams to be created by
      the HLS muxer is roughly as follows: Space and tab separate variant
      stream group maps while the entries in each variant stream group map are
      separated by ','.
      
      The parsing process of each variant stream group proceeded as follows:
      At first the number of occurences of "a:", "v:" and "s:" in each variant
      stream group is calculated so that one can can allocate an array of
      streams with this number of entries. Then each entry is checked and the
      check for stream numbers was deficient: It did check that there is a
      number beginning after the ":", but it did not check that the number
      extends until the next "," (or until the end).
      
      This means that an invalid variant stream group like v:0_v:1 will not be
      rejected; the problem is that the variant stream in this example is
      supposed to have two streams associated with it (because it contains two
      "v:"), yet only one stream is actually associated with it (because there
      is no ',' to start a second stream specifier). This discrepancy led to
      segfaults (null pointer dereferencing) in the rest of the code (when the
      nonexistent second stream associated to the variant stream was inspected).
      
      Furthermore, this commit also removes an instance of using atoi() whose
      behaviour on a range error is undefined.
      
      Fixes ticket #8652.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      c801ab43
    • rcombs's avatar
      lavf/dashdec: support larger manifests · 29121188
      rcombs authored
      29121188
    • Steven Liu's avatar
      avformat/url: check url root node when rel include double dot and trim double dot · 648051f0
      Steven Liu authored
      fix ticket: 8625
      and add testcase into url for double dot corner case
      Signed-off-by: 's avatarSteven Liu <lq@chinaffmpeg.org>
      648051f0
    • Steven Liu's avatar
      avformat/hlsenc: resend full url of the init fragment mp4 · 666dbe7a
      Steven Liu authored
      fix ticket: 8651
      because the init fragment mp4 file name is without base url name,
      so just modify it use the full url which splice after init function.
      
      Tested-by: matclayton
      Signed-off-by: 's avatarSteven Liu <liuqi05@kuaishou.com>
      666dbe7a
    • Yaroslav Pogrebnyak's avatar
      libavformat/hlsenc: Allow usage of 'periodic-rekey' with multi-variant streams · 7f0200d0
      Yaroslav Pogrebnyak authored
      This patch adds possibility to use 'periodic-rekey' option with
      multi-variant streams to hlsenc muxer. All streams variants
      use parameters from the same key_info_file.
      
      There are 2 sets of encryption options that kind of overlaps and add
      complexity, so I tried to do the thing without changing too much code.
      
      There is a little duplication of the key_file, key_uri, iv_string, etc
      in the VariantStream since we copy it from hls to each variant stream,
      but generally all the code remains the same to minimise appearing
      of unexpected bugs. Refactoring could be done as a separate patch then as needed.
      Signed-off-by: 's avatarYaroslav Pogrebnyak <yyyaroslav@gmail.com>
      7f0200d0
    • Steven Liu's avatar
      avformat/hlsenc: compute segment duration use current pts minus last segment end pts · a7bab199
      Steven Liu authored
      segment duration is using vs duration which compute by frame per second,
      that can not fix problem of VFR video stream, so compute the duration
      when split the segment, set the segment target duration use
      current packet pts minus the prev segment end pts..
      Reported-by: 's avatarZhao Jun <barryjzhao@tencent.com>
      Reviewed-by: 's avatarZhao Jun <barryjzhao@tencent.com>
      Signed-off-by: 's avatarSteven Liu <liuqi05@kuaishou.com>
      a7bab199
    • Steven Liu's avatar
      tests/fate/hlsenc: rename fate macro define from FATE_AFILTER to FATE_HLSENC · 03b1b968
      Steven Liu authored
      and add fate-hlsenc for test all of the testcase
      Signed-off-by: 's avatarSteven Liu <lq@chinaffmpeg.org>
      03b1b968
  2. 05 May, 2020 17 commits
  3. 04 May, 2020 3 commits
    • Linjie Fu's avatar
      lavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encoders · 2b320689
      Linjie Fu authored
      ff_vaapi_encode_close() is not enough to free the resources like cbs
      if initialization failure happens after codec->configure (except for
      vp8/vp9).
      
      We need to call avctx->codec->close() to deallocate, otherwise memory
      leak happens.
      
      Add FF_CODEC_CAP_INIT_CLEANUP for vaapi encoders and deallocate the
      resources at free_and_end inside avcodec_open2().
      Reviewed-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
      Signed-off-by: 's avatarLinjie Fu <linjie.fu@intel.com>
      2b320689
    • Andreas Rheinhardt's avatar
      avformat/matroskadec: Free right buffer on error · 5767a2ed
      Andreas Rheinhardt authored
      Since commit 979b5b89, reverting the
      Matroska ContentCompression is no longer done inside
      matroska_parse_frame() (the function that creates AVPackets out of the
      parsed data (unless we are dealing with certain codecs that need special
      handling)), but instead in matroska_parse_block(). As a consequence,
      the data that matroska_parse_frame() receives is no longer always owned
      by an AVBuffer; it is owned by an AVBuffer iff no ContentCompression needed
      to be reversed; otherwise the data is independently allocated and needs
      to be freed on error.
      
      Whether the data is owned by an AVBuffer or not is indicated by a variable
      buf of type AVBufferRef *: If it is NULL, the data is independently
      allocated, if not it is owned by the underlying AVBuffer (and is used to
      avoid copying the data when creating the AVPackets).
      
      Because the allocation of the buffer holding the uncompressed data happens
      outside of matroska_parse_frame() (if a ContentCompression needs to be
      reversed), the data is passed as uint8_t ** in order to not leave any
      dangling pointers behind in matroska_parse_block() should the data need to
      be freed: In case of errors, said uint8_t ** would be av_freep()'ed in
      case buf indicated the data to be independently allocated.
      
      Yet there is a problem with this: Some codecs (namely WavPack and
      ProRes) need special handling: Their packets are only stored in
      Matroska in a stripped form to save space and the demuxer reconstructs
      full packets. This involved allocating a new, enlarged buffer. And if
      an error happens when trying to wrap this new buffer into an AVBuffer,
      this buffer needs to be freed; yet instead the given uint8_t ** (holding
      the uncompressed, yet still stripped form of the data) would be freed
      (av_freep()'ed) which certainly leads to a memleak of the new buffer;
      even worse, in case the track does not use ContentCompression the given
      uint8_t ** must not be freed as the actual data is owned by an AVBuffer
      and the data given to matroska_parse_frame() is not the start of the
      actual allocated buffer at all.
      
      Both of these issues are fixed by always freeing the current data in
      case it is independently allocated. Furthermore, while it would be
      possible to track whether the pointer from matroska_parse_block() needs
      to be reset or not, there is no gain in doing so, as the pointer is not
      used at all afterwards and the sematics are clear: If the data passed
      to matroska_parse_frame() is independently allocated, then ownership
      of the data passes to matroska_parse_frame(). So don't pass the data
      via uint8_t **.
      
      Fixes Coverity ID 1462661 (the issue as described by Coverity is btw
      a false positive: It thinks that this error can be triggered by ProRes
      with a size of zero after reconstructing the original packets, but the
      reconstructed packets can't have a size of zero).
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      5767a2ed
    • Steven Liu's avatar
      doc/muxers: remove hls_fmp4_init_resend parameter · 0b0a36b4
      Steven Liu authored
      the parameter should boolean
      0b0a36b4
  4. 03 May, 2020 11 commits