1. 31 Jul, 2016 6 commits
  2. 30 Jul, 2016 6 commits
    • Alexey Tourbin's avatar
      avfilter/af_stereowiden: fix read/write past the end of buffer · 906ee411
      Alexey Tourbin authored
      The stereowiden filter uses a buffer, s->buffer[], and a pointer
      within the buffer, s->write, to implement inter-channel delays.
      The loop which applies the delayed samples turns out to be faulty.
      
         109      for (n = 0; n < in->nb_samples; n++, src += 2, dst += 2) {
         110          const float left = src[0], right = src[1];
         111          float *read = s->write + 2;
         112
         113          if (read > s->buffer + s->length)
         114              read = s->buffer;
         115
         116          dst[0] = drymix * left - crossfeed * right - feedback * read[1];
         117          dst[1] = drymix * right - crossfeed * left - feedback * read[0];
         118
         119          s->write[0] = left;
         120          s->write[1] = right;
         121
         122          if (s->write == s->buffer + s->length)
         123              s->write = s->buffer;
         124          else
         125              s->write += 2;
         126      }
      
      For one, the buffer gets written past its end in lines 119-120, before
      the bound check is done in lines 122-123.  This can be easily confirmed
      by valgrind.
      
      ==3544== Invalid read of size 4
      ==3544==    at 0x593B41: filter_frame (af_stereowiden.c:116)
      ==3544==  Address 0xb1b03c4 is 4 bytes after a block of size 7,680 alloc'd
      ==3544==
      ==3544== Invalid read of size 4
      ==3544==    at 0x593B66: filter_frame (af_stereowiden.c:117)
      ==3544==  Address 0xb1b03c0 is 0 bytes after a block of size 7,680 alloc'd
      ==3544==
      ==3544== Invalid write of size 4
      ==3544==    at 0x593B79: filter_frame (af_stereowiden.c:119)
      ==3544==  Address 0xb1b03c0 is 0 bytes after a block of size 7,680 alloc'd
      ==3544==
      ==3544== Invalid write of size 4
      ==3544==    at 0x593B7D: filter_frame (af_stereowiden.c:120)
      ==3544==  Address 0xb1b03c4 is 4 bytes after a block of size 7,680 alloc'd
      
      Also, using two separate pointers, s->write and read = s->write + 2,
      does not seem to be well thought out.  To apply the delay of s->buffer[],
      it is enough to read the delayed samples at the current position within
      the buffer, and then to store new samples at the same current position.
      Thus the application of delayed samples can probably be best described
      with a single pointer s->cur.
      
      I also introduce a minor change to ensure that the size of s->buffer[]
      is always a multiple of 2.  Since the delay parameter is a float, it is
      otherwise possible to trick the code into allocating off-by-one buffer.
      906ee411
    • Paul B Mahol's avatar
    • Timothy Gu's avatar
      doxygen: Set tab size to 4 · 7204a629
      Timothy Gu authored
      7204a629
    • Timothy Gu's avatar
      doxygen: Update Doxyfile for Doxygen 1.8.8 · 6253e567
      Timothy Gu authored
      6253e567
    • Timothy Gu's avatar
      doxygen: Fix PREDEFINED syntax · f198b8af
      Timothy Gu authored
      f198b8af
    • Timothy Gu's avatar
      22df70e9
  3. 29 Jul, 2016 12 commits
  4. 28 Jul, 2016 9 commits
    • Petru Rares Sincraian's avatar
    • Petru Rares Sincraian's avatar
    • Matthieu Bouron's avatar
      83b99093
    • Zhao Zhili's avatar
      avutil/mem: fix memleak · 65b2feb8
      Zhao Zhili authored
      The original code assumes av_realloc() will free ptr if size is zero.
      The assumes is incorrect now.
      Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
      65b2feb8
    • Paul B Mahol's avatar
      d7ae4f79
    • Clément Bœsch's avatar
      lavfi/hdcd: fix style · 37abc8cc
      Clément Bœsch authored
      37abc8cc
    • Clément Bœsch's avatar
      4791716c
    • Burt P's avatar
      af_hdcd: Report PE as being intermittent or permanent · fb91143e
      Burt P authored
      The Peak Extend feature could be enabled permanently or only
      when needed. This is now reported.
      Signed-off-by: 's avatarBurt P <pburt0@gmail.com>
      Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
      fb91143e
    • softworkz's avatar
      avformat/matroskaenc: Write duration early during mkv_write_header (Rev #3) · 70c1647a
      softworkz authored
      Rev #2: Fixes doubled header writing, checked FATE running without errors
      Rev #3: Fixed coding style
      
      This commit addresses the following scenario:
      
      we are using ffmpeg to transcode or remux mkv (or something else) to mkv. The result is being streamed on-the-fly to an HTML5 client (streaming starts while ffmpeg is still running). The problem here is that the client is unable to detect the duration because the duration is only written to the mkv at the end of the transcoding/remoxing process. In matroskaenc.c, the duration is only written during mkv_write_trailer but not during mkv_write_header.
      
      The approach:
      
      FFMPEG is currently putting quite some effort to estimate the durations of source streams, but in many cases the source stream durations are still left at 0 and these durations are nowhere mapped to or used for output streams. As much as I would have liked to deduct or estimate output durations based on input stream durations - I realized that this is a hard task (as Nicolas already mentioned in a previous conversation). It would involve changes to the duration calculation/estimation/deduction for input streams and propagating these durations to output streams or the output context in a correct way.
      So I looked for a simple and small solution with better chances to get accepted. In webmdashenc.c I found that a duration is written during write_header and this duration is taken from the streams' metadata, so I decided for a similar approach.
      
      And here's what it does:
      
      At first it is checking the duration of the AVFormatContext. In typical cases this value is not set, but: It is set in cases where the user has specified a recording_time or an end_time via the -t or -to parameters.
      Then it is looking for a DURATION metadata field in the metadata of the output context (AVFormatContext::metadata). This would only exist in case the user has explicitly specified a metadata DURATION value from the command line.
      Then it is iterating all streams looking for a "DURATION" metadata (this works unless the option "-map_metadata -1" has been specified) and determines the maximum value.
      The precendence is as follows: 1. Use duration of AVFormatContext - 2. Use explicitly specified metadata duration value - 3. Use maximum (mapped) metadata duration over all streams.
      
      To test this:
      
      1. With explicit recording time:
      ffmpeg -i file:"src.mkv" -loglevel debug -t 01:38:36.000 -y "dest.mkv"
      
      2. Take duration from metadata specified via command line parameters:
      ffmpeg -i file:"src.mkv" -loglevel debug -map_metadata -1 -metadata Duration="01:14:33.00" -y "dest.mkv"
      
      3. Take duration from mapped input metadata:
      ffmpeg -i file:"src.mkv" -loglevel debug -y "dest.mkv"
      
      Regression risk:
      
      Very low IMO because it only affects the header while ffmpeg is still running. When ffmpeg completes the process, the duration is rewritten to the header with the usual value (same like without this commit).
      Signed-off-by: 's avatarSoftWorkz <softworkz@hotmail.com>
      Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
      70c1647a
  5. 27 Jul, 2016 7 commits
    • Anssi Hannula's avatar
      avformat/hls: Fix missing streams in some cases with MPEG TS · 04964ac3
      Anssi Hannula authored
      HLS demuxer calls the subdemuxer avformat_find_stream_info() while
      overriding the subdemuxer AVFMTCTX_NOHEADER flag by clearing it.
      However, this prevents some streams in some MPEG TS streams from being
      detected properly.
      
      Simply removing the clearing of the flag would cause the inner
      avformat_find_stream_info() call to take longer in some cases, without
      a way to control it.
      
      To fix the issue, do not clear the flag but propagate it to HLS demuxer.
      To avoid the above-mentioned mandatory delay, the call to
      avformat_find_stream_info() is dropped except in the HLS ID3 timestamped
      case. The HLS demuxer user should be calling avformat_find_stream_info()
      on the HLS demuxer if it wants to find the stream info.
      
      The main streams are now created dynamically after read_header time if
      the subdemuxer uses AVFMTCTX_NOHEADER (mpegts).
      
      Subdemuxer avformat_find_stream_info() is still called for the HLS ID3
      timestamped case as the HLS demuxer needs to know the packet durations
      to properly interleave ID3 timestamped streams with MPEG TS streams on
      sub-segment level.
      
      Fixes ticket #4930.
      04964ac3
    • Anssi Hannula's avatar
      avformat/hls: Move stream propagation to a separate function · 83db3c84
      Anssi Hannula authored
      Creation of main demuxer streams from subdemuxer streams is moved to
      update_streams_from_subdemuxer() which can be called repeatedly.
      
      There should be no functional changes.
      83db3c84
    • Anssi Hannula's avatar
      avformat/hls: Use an array instead of stream offset for stream mapping · 9884f17e
      Anssi Hannula authored
      This will be useful when the amount of streams per subdemuxer is not
      known at hls_read_header time in a following commit.
      9884f17e
    • Anssi Hannula's avatar
      avformat/hls: Sync starting segment across variants on live streams · 4d85069e
      Anssi Hannula authored
      This will avoid a large time difference between variants in the most
      common case.
      4d85069e
    • Anssi Hannula's avatar
      avformat/hls: Fix regression with ranged media segments · 9cb30f7a
      Anssi Hannula authored
      Commit 81306fd4bdf ("hls: eliminate ffurl_* usage", merged in d0fc5de3)
      changed the hls demuxer to use AVIOContext instead of URLContext for its
      HTTP requests.
      
      HLS demuxer uses the "offset" option of the http demuxer, requesting
      the initial file offset for the I/O (http URLProtocol uses the "Range:"
      HTTP header to try to accommodate that).
      
      However, the code in libavformat/aviobuf.c seems to be doing its own
      accounting for the current file offset (AVIOContext.pos), with the
      assumption that the initial offset is always zero.
      
      HLS demuxer does an explicit seek after open_url to account for cases
      where the "offset" was not effective (due to the URL being a local file
      or the HTTP server not obeying it), which should be a no-op in case the
      file offset is already at that position.
      
      However, since aviobuf.c code thinks the starting offset is 0, this
      doesn't work properly.
      
      This breaks retrieval of ranged media segments.
      
      To fix the regression, just drop the seek call from the HLS demuxer when
      the HTTP(S) protocol is used.
      9cb30f7a
    • Anssi Hannula's avatar
      avformat/utils: Fix find_stream_info not considering the extradata it found · 60873bf9
      Anssi Hannula authored
      Commit 9200514a ("lavf: replace AVStream.codec with
      AVStream.codecpar") merged in commit 6f69f7a8 changed
      avformat_find_stream_info() to put the extradata it got from
      st->parser->parser->split() to st->internal->avctx instead of st->codec
      (extradata in st->internal->avctx will be later copied to st->codecpar).
      
      However, in the same function, the "is stream ready?" check was changed
      to check for extradata in st->codecpar instead of st->codec, even
      though st->codecpar is not yet updated at that point.
      
      Extradata retrieved from split() is therefore not considered anymore,
      and avformat_find_stream_info() will therefore needlessly continue
      probing in some cases.
      
      Fix that by checking for the extradata at st->internal->avctx where it
      is actually put.
      60873bf9
    • Burt P's avatar
      af_hdcd: Add counter for cdt expirations · c26305f6
      Burt P authored
      Adds a counter for when the "code detect timer" expired without
      finding a valid packet.
      Signed-off-by: 's avatarBurt P <pburt0@gmail.com>
      Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
      c26305f6