Commit Graph

36 Commits

Author SHA1 Message Date
Andreas Rheinhardt 82bf41f3ab avformat: Replace ffurl_close() by ffurl_closep() where appropriate
It avoids leaving dangling pointers behind in memory.

Also remove redundant checks for whether the URLContext to be closed is
already NULL.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-25 13:11:36 +02:00
Steven Liu 4110029e56 avformat/cache: rename the class name fro Cache to cache
liuqideMacBook-Pro:build liuqi$ ffmpeg --help full | grep cache
cannot find cache protocol options.

after patch:
bogon:dash liuqi$ ./ffmpeg --help full | grep cache
cache AVOptions:
can find the cache AVOptions after patch.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-12-11 15:22:24 +08:00
Gyan Doshi 50789e356d avformat/cache - delete cache file after closing handle
Verified that cache files get deleted on Windows.
2019-05-25 00:21:26 +05:30
Daniel Kucera 858db4b01f libavformat: not treat 0 as EOF
transfer_func variable passed to retry_transfer_wrapper
are h->prot->url_read and h->prot->url_write functions.
These need to return EOF or other error properly.
In case of returning >= 0, url_read/url_write is retried
until error is returned.

Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
2017-10-19 22:07:21 +02:00
Derek Buitenhuis f8e89d8a29 Merge commit 'fab8156b2f30666adabe227b3d7712fd193873b1'
* commit 'fab8156b2f30666adabe227b3d7712fd193873b1':
  avio: Copy URLContext generic options into child URLContexts

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-21 15:55:09 +01:00
Michael Niedermayer 9d4ab1380a Use avpriv_tempfile()
Should fix xvid/cache on windows with --enable-shared

May be related to Ticket 4780

Tested-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-12 02:08:45 +01:00
Derek Buitenhuis 93629735d7 avformat: Add a protocol blacklisting API
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-03-04 16:13:42 +00:00
Michael Niedermayer 554f6e930c avformat/cache: Fix memleak of tree entries
Found-by: jamrial

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-02 14:27:57 +01:00
Derek Buitenhuis 9c75148e6e Merge commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d'
This commit also disables the async fate test, because it
used internal APIs in a non-kosher way, which no longer
exists.

* commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d':
  lavf: reorganize URLProtocols

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 16:51:10 +00:00
Michael Niedermayer fe3fed0b14 Update demuxers and protocols for protocol whitelist support
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 04:16:50 +01:00
Bryan Huh 72f9a6349c avformat/cache: Avoid int-overflow in cache compare function
cache protocol indexes its cache using AVTreeNodes which require a cmp
function for inserting and searching new cache-entries. This cmp
function expects a 32-bit int return value (negative, zero, or positive)
but the cache cmp function returns an int64_t which can overflow the
int, giving negative numbers for when it should be positive, vice versa.
This manifests itself only for very large files (e.g. 4GB+)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-09 19:25:05 +01:00
Bryan Huh d917f25658 avformat/cache: Use int64_t to avoid int overflow in cache_read
Fixes an issue where an int64_t ffurl_seek return-value was being stored
in an int (32-bit) "r" variable, leading to integer overflow when seeking
into a large file (>2GB), and ultimately a "Failed to perform internal
seek" error mesage.

To test, try running `ffprobe 'cache:http://<something>'` on a file that
is ~3GB large, whose moov atom is at the end of the file

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-04 03:59:17 +01:00
Ganesh Ajjanagadde 7c8fcbbde3 avutil/tree: add additional const qualifier to the comparator
libc's qsort comparator has a const qualifier on both arguments. This
adds a missing const qualifier to exactly match the comparator API.

Existing usages of av_tree_find, av_tree_insert are appropriately
modified: type signature changes of the comparators, and removal of
unnecessary void * casts of function pointers.

Reviewed-by: Henrik Gramner <henrik@gramner.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
2015-10-24 20:38:07 -04:00
Andreas Cadhalpun 482c86f231 fix spelling errors
opttimizations -> optimizations
 grabing        -> grabbing
 many resource  -> many resources
 isnt           -> isn't
 silcense       -> silence

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-06 21:35:00 +01:00
Zhang Rui ca2e3e47fc avformat/cache: pass options to the underlying protocol via the url_open2
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-01-31 18:55:46 +01:00
Michael Niedermayer 0704c44d68 avformat/cache: remove ftruncate usage, its not always available
In case of errors the cache file will be slightly larger than needed,
this should have no practical relevance though

Should fix build on VS201*

Found-by: jamrial
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-26 12:41:15 +01:00
Michael Niedermayer 7c210c4424 avformat/cache: Extend cache entries if possible instead of creating new ones
This reduces the number of cache entries and should significantly
reduce memory requirements

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-26 02:21:51 +01:00
Michael Niedermayer 312151bb9a avformat/cache: avoid lseek() on reading from the cache if possible
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-26 01:24:27 +01:00
Michael Niedermayer ce3551896a avformat/cache: keep cache_pos updated
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-26 01:22:52 +01:00
Michael Niedermayer 954fc854f2 avformat/cache: cleanup cache file on cache write failure
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-26 01:13:49 +01:00
Michael Niedermayer 8706910c4c avformat/cache: Support user specified read-ahead for non seekable media
Fixes Ticket2406

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 22:09:24 +01:00
Michael Niedermayer 7018d3d351 avformat/cache: Use the correct io handle in seeking
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 22:07:32 +01:00
Michael Niedermayer dedd3c89ae avformat/cache: more informative error message
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 22:07:32 +01:00
Michael Niedermayer 681559d3ff avformat/cache: remember EOF point if hit and use it to handle SEEK_END
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 22:07:23 +01:00
Michael Niedermayer 0c0168a210 avformat/cache: support non continuous caching
This allows using the cache protocol on top of seekable but slow protocols to
speed them up

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 19:20:55 +01:00
Michael Niedermayer eb19d89d8e cache: check lseek() return
Fixes CID717496
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-10-18 00:55:03 +02:00
Derek Buitenhuis af2a17c09a cache: Only include unistd.h if it exists
This follows suite from f3be359707.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-09-07 19:29:58 +02:00
Michael Niedermayer e81e0b9991 cache: fix "warning: passing argument 2 of ‘av_tempfile’ from incompatible pointer type"
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-02-06 02:04:09 +01:00
Jean First 576ada791a cache: use av_freep instead of av_free in cache_open
Signed-off-by: Jean First <jeanfirst@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-31 02:27:10 +01:00
Jean First 3ceb4c907e cache: remove unused variable in cache_open
Signed-off-by: Jean First <jeanfirst@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-31 02:27:10 +01:00
Michael Niedermayer 7b0b10ce41 Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits)
  rtpenc: Add support for G726 audio
  rtpdec: Interpret the different G726 names as bits_per_coded_sample
  rtpenc: Change rtp_send_samples to handle sample sizes other than even bytes
  rtpenc: Cast a rescaling parameter to int64_t
  h264: cap max has_b_frames at MAX_DELAYED_PIC_COUNT - 1.
  ARM: fix indentation in ff_dsputil_init_neon()
  ARM: NEON put/avg_pixels8/16 cosmetics
  ARM: add remaining NEON avg_pixels8/16 functions
  ARM: clean up NEON put/avg_pixels macros
  fate: split acodec-pcm into individual tests
  swscale: #include "libavutil/mathematics.h"
  pmpdec: don't use deprecated av_set_pts_info.
  rv34: align temporary block of "dct" coefs
  Add PlayStation Portable PMP format demuxer
  proto: Realign struct initializers
  proto: Use .priv_data_size to allocate the private context
  mmsh: Properly clean up if the second ffurl_alloc failed
  rtmp: Clean up properly if the handshake failed
  md5proto: Remove the get_file_handle function
  applehttpproto: Use the close function if the open function fails
  ...

Conflicts:
	libavcodec/vble.c
	libavformat/mmsh.c
	libavformat/pmpdec.c
	libavformat/udp.c
	tests/ref/acodec/pcm

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-02 00:51:11 +01:00
Michael Niedermayer 5f268ca5c5 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  lavf: pass options from AVFormatContext to avio.
  avformat: Use avio_open2, pass the AVFormatContext interrupt_callback onwards
  avio: add avio_open2, taking an interrupt callback and options
  avio: add support for passing options to protocols.
  avio: add and use ffurl_protocol_next().
  avformat: Pass the interrupt callback on to chained muxers/demuxers
  avio: Add an AVIOInterruptCB parameter to ffurl_open/ffurl_alloc
  avformat: Use ff_check_interrupt
  avio: Add an internal utility function for checking the new interrupt callback
  avio: Add AVIOInterruptCB
  texi2html: remove stray \n
  doc: prettyfy the texi2html documentation
  swscale: handle unaligned buffers in yuv2plane1

Conflicts:
	libavformat/avformat.h
	libavformat/avio.c
	libavformat/mov.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-11-14 00:33:39 +01:00
Michael Niedermayer 74dbb5388e av_tempfile: Pass int log_offset, void *log_ctx
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-16 21:51:28 +02:00
Michael Niedermayer 9329d36a3a cache: add todo list
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-16 21:51:28 +02:00
Michael Niedermayer 02b651a7e3 cache: Fallback to using the cache size for AVSEEK_SIZE if the underlaying protocol has nothing better.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-16 17:12:37 +02:00
Michael Niedermayer e9f62a8b2b add cache protocol
This allows backward seeking on top of some non seekable streams.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2011-10-16 17:12:37 +02:00