1. 01 Oct, 2019 12 commits
  2. 30 Sep, 2019 17 commits
  3. 29 Sep, 2019 6 commits
  4. 28 Sep, 2019 5 commits
    • Andreas Rheinhardt's avatar
      avformat/utils: Remove unnecessary initializations · 9fdc2c7b
      Andreas Rheinhardt authored
      Up until now, read_frame_internal always initialized the packet it
      received. But since the recent changes to ff_read_packet, this is no
      longer needed: If the parsing queue is initially empty upon entering
      read_frame_internal, the packet will now either contain content upon
      success or be blank upon failure of ff_read_packet. If the parsing
      queue is initially not empty, the packet will be overwritten with the
      oldest one from the parsing queue.
      
      Similarly, it is unnecessary to initialize ret in read_frame_internal.
      
      In parse_packet, it is easily possible to only initialize the packet
      used as temporary storage for the output if said packet is used at all;
      furthermore, this packet doesn't need to be zero-initialized, because
      av_init_packet will initialize every field except size and data and
      those fields will be set by av_parser_parse2.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      9fdc2c7b
    • Andreas Rheinhardt's avatar
      avformat/utils: Improve parsing packets · 5c95af6b
      Andreas Rheinhardt authored
      Up until now, parse_packet() used a stack packet in case the stream is
      flushed. But using such a packet is unnecessary as there is an AVPacket
      readily available, it just needs to be used. Whether flushing is intended
      or not will now be signalled by an explicit parameter rather than by
      whether the packet parameter is NULL. This removes a few checks in
      parse_packet(), gets rid of the initialization of the stack packet and
      also reduces usage of sizeof(AVPacket) in libavformat.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      5c95af6b
    • Andreas Rheinhardt's avatar
      avformat/utils: Avoid copying packets unnecessarily · cdba00ae
      Andreas Rheinhardt authored
      Up until now, read_frame_internal in avformat/utils.c uses a spare
      packet on the stack that serves no real purpose: At no point in this
      function is there a need for another packet besides the packet destined
      for output:
      1. If the packet doesn't need a parser, but is output as is, the content
      of the spare packet (that at this point contains a freshly read packet)
      is simply copied into the output packet (via simple assignment, not
      av_packet_move_ref, thereby confusing ownership).
      2. If the packet needs parsing, the spare packet will be reset after
      parsing and any packets resulting from the packet read will be put into
      a packet list; the output packet is not used here at all.
      3. If the stream should be discarded, the spare packet will be
      unreferenced; the output packet is not used here at all either.
      
      Therefore the spare packet and the copies can be removed in principle.
      In practice, one more thing needs to be taken care of: If ff_read_packet
      failed, the output packet was not affected, now it is. But given that
      ff_read_packet returns a blank (as if reset via av_packet_unref) packet
      on failure, there is no problem from this side either.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      cdba00ae
    • Andreas Rheinhardt's avatar
      avformat/utils: Don't create unnecessary references · ada02cf8
      Andreas Rheinhardt authored
      When AVFMT_FLAG_GENPTS is set, av_read_frame would put a reference to a
      packet in the packet list (via av_packet_ref) and then immediately
      thereafter unreference the original packet. This has been changed to
      move the reference instead.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      ada02cf8
    • Andreas Rheinhardt's avatar
      avformat/utils: Fix memleaks II · bf79e442
      Andreas Rheinhardt authored
      Up until now, avformat_find_stream_info had a potential for memleaks:
      When everything was fine, it read packets and (depending upon whether
      AVFMT_FLAG_NOBUFFER was set) put them in a packet list or unreferenced
      them when they were no longer needed. But upon failure, said packets
      would leak if they were not already on the packet list. This patch fixes
      this.
      Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
      bf79e442