Commit Graph

83 Commits

Author SHA1 Message Date
Andreas Rheinhardt
40bdd8cc05 avformat: Avoid allocation for AVStreamInternal
Do this by allocating AVStream together with the data that is
currently in AVStreamInternal; or rather: Put AVStream at the
beginning of a new structure called FFStream (which encompasses
more than just the internal fields and is a proper context in its own
right, hence the name) and remove AVStreamInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-17 13:22:25 +02:00
Andreas Rheinhardt
45bfe8b838 avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext.
This commit moves them into a new structure in avio_internal.h instead.
Said structure contains the public AVIOContext as its first element
in order to avoid having to allocate a separate AVIOContextInternal
which is costly for those use cases where one just wants to access
an already existing buffer via the AVIOContext-API.
For these cases ffio_init_context() can't fail and always returned zero,
which was typically not checked. Therefore it has been made to not
return anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
2934a4b9a5 Remove unnecessary avassert.h inclusions
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-22 15:02:30 +02:00
James Almer
b9c5fdf602 avformat: move AVStream.{parser,need_parsing} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-05-07 09:27:21 -03:00
Andreas Rheinhardt
56450a0ee4 avformat: Constify the API wrt AV(In|Out)putFormat
Also constify AVProbeData.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:08 -03:00
Carl Eugen Hoyos
3aa6208db9 lavf: Constify AVInputFormat pointer. 2019-03-20 18:52:38 +01:00
Carl Eugen Hoyos
dc77e64f2d lavf/rtpdec*: Constify all RTPDynamicProtocolHandler.
Reviewed-by: Muhammad Faiz
2018-02-14 01:14:35 +01:00
James Almer
f7c01ff24d avformat/rtpdec_asf: free the buffer pointed by the AVIOContext
Don't free the buffer allocated in ff_wms_parse_sdp_a_line() after
calling avformat_open_input(), as it may free it and replace it with
another one.

Should fix ticket #6808

Tested-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-11-06 16:25:32 -03:00
Kacper Michajłow
e947b75b1c libavformat/rtpdec_asf: zero initialize the AVIOContext struct
This fixes crash in avformat_open_input() when accessing
protocol_whitelist field.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-25 19:39:13 +02:00
Derek Buitenhuis
6f69f7a8bf Merge commit '9200514ad8717c63f82101dc394f4378854325bf'
* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-10 20:59:55 +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
Anton Khirnov
9200514ad8 lavf: replace AVStream.codec with AVStream.codecpar
Currently, AVStream contains an embedded AVCodecContext instance, which
is used by demuxers to export stream parameters to the caller and by
muxers to receive stream parameters from the caller. It is also used
internally as the codec context that is passed to parsers.

In addition, it is also widely used by the callers as the decoding (when
demuxer) or encoding (when muxing) context, though this has been
officially discouraged since Libav 11.

There are multiple important problems with this approach:
    - the fields in AVCodecContext are in general one of
        * stream parameters
        * codec options
        * codec state
      However, it's not clear which ones are which. It is consequently
      unclear which fields are a demuxer allowed to set or a muxer allowed to
      read. This leads to erratic behaviour depending on whether decoding or
      encoding is being performed or not (and whether it uses the AVStream
      embedded codec context).
    - various synchronization issues arising from the fact that the same
      context is used by several different APIs (muxers/demuxers,
      parsers, bitstream filters and encoders/decoders) simultaneously, with
      there being no clear rules for who can modify what and the different
      processes being typically delayed with respect to each other.
    - avformat_find_stream_info() making it necessary to support opening
      and closing a single codec context multiple times, thus
      complicating the semantics of freeing various allocated objects in the
      codec context.

Those problems are resolved by replacing the AVStream embedded codec
context with a newly added AVCodecParameters instance, which stores only
the stream parameters exported by the demuxers or read by the muxers.
2016-02-23 17:01:58 +01:00
Hendrik Leppkes
7f5af80ba4 Merge commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457'
* commit 'ce70f28a1732c74a9cd7fec2d56178750bd6e457':
  avpacket: Replace av_free_packet with av_packet_unref

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-27 14:28:56 +01:00
Luca Barbato
ce70f28a17 avpacket: Replace av_free_packet with av_packet_unref
`av_packet_unref` matches the AVFrame ref-counted API and can be used as
a drop in replacement.

Deprecate `av_free_packet`.
2015-10-26 18:00:55 +01:00
Michael Niedermayer
d5a645625d Merge commit '4733a12dd17a91d606e0079ff9bb48b9f419cbef'
* commit '4733a12dd17a91d606e0079ff9bb48b9f419cbef':
  rtpdec_asf: Check memory allocation and free memory on error

Conflicts:
	libavformat/rtpdec_asf.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-08 23:05:01 +02:00
Vittorio Giovara
4733a12dd1 rtpdec_asf: Check memory allocation and free memory on error
CC: libav-stable@libav.org
Bug-Id: CID 1257774
2015-06-08 13:04:29 +01:00
Michael Niedermayer
445a02b1ec avformat/rtpdec_asf: Fix potential pointer overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-12 17:41:23 +02:00
Michael Niedermayer
9575d8a652 Merge commit '15621cbbe4ed88409ef40257afaf239487964e98'
* commit '15621cbbe4ed88409ef40257afaf239487964e98':
  rtpdec_asf: Don't set RTP_FLAG_KEY

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-05 01:12:19 +01:00
Martin Storsjö
15621cbbe4 rtpdec_asf: Don't set RTP_FLAG_KEY
Nothing in the framework nor in the rest of the depacketizer actually
uses this flag - the chained demuxer sets the keyframe flag properly on
demuxed packets already.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-03-05 00:26:24 +02:00
Michael Niedermayer
634ce8ddad Merge commit '1dc19729e92a96620000e09eba8e58cb458c9486'
* commit '1dc19729e92a96620000e09eba8e58cb458c9486':
  rtpdec_asf: Don't free the payload context in the .close function

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-04 19:14:48 +01:00
Martin Storsjö
1dc19729e9 rtpdec_asf: Don't free the payload context in the .close function
This was missed in bb4a310bb. This fixes a double free on close.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-03-04 13:12:09 +02:00
Michael Niedermayer
3130e5be92 Merge commit 'd594dbecce5f3af7f80bbf5bb1b516d740b69ccd'
* commit 'd594dbecce5f3af7f80bbf5bb1b516d740b69ccd':
  rtpdec: Rename the free method to close

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-25 00:58:39 +01:00
Michael Niedermayer
7d9b06eb17 Merge commit '199fb40278146c5bb162990c66ad3cd561abc780'
* commit '199fb40278146c5bb162990c66ad3cd561abc780':
  rtpdec: Use ffio_free_dyn_buf

Conflicts:
	libavformat/rtpdec_latm.c
	libavformat/rtpdec_svq3.c
	libavformat/rtpdec_xiph.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-25 00:42:14 +01:00
Michael Niedermayer
3804d73e46 Merge commit '5d8cae45737bed6239bd6b6e0698802dbe1463c8'
* commit '5d8cae45737bed6239bd6b6e0698802dbe1463c8':
  rtpdec: Get rid of all trivial .alloc/.free functions

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-24 22:55:20 +01:00
Martin Storsjö
d594dbecce rtpdec: Rename the free method to close
Many of these functions were named foo_free_context, and since
the functions no longer should free the context itself, only
allocated elements within it, the previous naming was slightly
misleading.

Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:50 +02:00
Martin Storsjö
199fb40278 rtpdec: Use ffio_free_dyn_buf
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 23:07:44 +02:00
Martin Storsjö
5d8cae4573 rtpdec: Get rid of all trivial .alloc/.free functions
Signed-off-by: Martin Storsjö <martin@martin.st>
2015-02-24 16:24:19 +02:00
Michael Niedermayer
2ce1054257 avformat/rtpdec_asf: Use av_find_input_format() instead of directly linking to the demuxer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-25 16:28:03 +02:00
Michael Niedermayer
4641ae352e avformat: Add and use ff_copy_whitelists()
Fixes potential security issue in case of running out of memory

Found-by: ubitux
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-24 19:23:23 +02:00
Michael Niedermayer
feb9057b83 Forward whitelists to the asf demuxer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-23 18:19:37 +02:00
Michael Niedermayer
e6516944a3 avformat/rtpdec_asf: fix compiler warning about const qualifier being discarded
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-27 23:53:53 +02:00
Michael Niedermayer
c1333a762c Merge remote-tracking branch 'qatar/master'
* qatar/master:
  rtpdec_asf: Copy the need_parsing field from the chained demuxer

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-01-23 20:15:21 +01:00
Martin Storsjö
2aec9e228c rtpdec_asf: Copy the need_parsing field from the chained demuxer
This fixes playback of mp3 streams in rtp/asf. This used to work
until c6f1dc8, but mostly by coincidence.

Signed-off-by: Martin Storsjö <martin@martin.st>
2014-01-23 17:37:10 +02:00
Michael Niedermayer
20dfab33f5 Merge commit '5626f994f273af80fb100d4743b963304de9e05c'
* commit '5626f994f273af80fb100d4743b963304de9e05c':
  avformat: Use av_reallocp() where suitable

Conflicts:
	libavformat/avidec.c
	libavformat/avienc.c
	libavformat/aviobuf.c
	libavformat/oggparsevorbis.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-09-19 11:01:26 +02:00
Alexandra Khirnova
5626f994f2 avformat: Use av_reallocp() where suitable
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2013-09-18 18:28:38 +02:00
Michael Niedermayer
bb3420d88e Merge commit '90c784cc13f6bf21a8eb69f3b88b50c7a70f6c59'
* commit '90c784cc13f6bf21a8eb69f3b88b50c7a70f6c59':
  rtpdec: Pass the sequence number to depacketizers
  configure: Make avconv depend on null, anull and resample filters

Conflicts:
	configure

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-21 17:46:43 +01:00
Martin Storsjö
90c784cc13 rtpdec: Pass the sequence number to depacketizers
This allows depacketizers to figure out if packets have been lost.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-12-21 14:14:40 +02:00
Michael Niedermayer
7a72695c05 Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
* commit '36ef5369ee9b336febc2c270f8718cec4476cb85':
  Replace all CODEC_ID_* with AV_CODEC_ID_*
  lavc: add AV prefix to codec ids.

Conflicts:
	doc/APIchanges
	doc/examples/decoding_encoding.c
	doc/examples/muxing.c
	ffmpeg.c
	ffprobe.c
	ffserver.c
	libavcodec/8svx.c
	libavcodec/avcodec.h
	libavcodec/dnxhd_parser.c
	libavcodec/dvdsubdec.c
	libavcodec/error_resilience.c
	libavcodec/h263dec.c
	libavcodec/libvorbisenc.c
	libavcodec/mjpeg_parser.c
	libavcodec/mjpegenc.c
	libavcodec/mpeg12.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pcm.c
	libavcodec/r210dec.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/version.h
	libavdevice/alsa-audio-dec.c
	libavdevice/bktr.c
	libavdevice/v4l2.c
	libavformat/asfdec.c
	libavformat/asfenc.c
	libavformat/avformat.h
	libavformat/avidec.c
	libavformat/caf.c
	libavformat/electronicarts.c
	libavformat/flacdec.c
	libavformat/flvdec.c
	libavformat/flvenc.c
	libavformat/framecrcenc.c
	libavformat/img2.c
	libavformat/img2dec.c
	libavformat/img2enc.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/matroska.c
	libavformat/matroskadec.c
	libavformat/matroskaenc.c
	libavformat/mov.c
	libavformat/movenc.c
	libavformat/mp3dec.c
	libavformat/mpeg.c
	libavformat/mpegts.c
	libavformat/mxf.c
	libavformat/mxfdec.c
	libavformat/mxfenc.c
	libavformat/nsvdec.c
	libavformat/nut.c
	libavformat/oggenc.c
	libavformat/pmpdec.c
	libavformat/rawdec.c
	libavformat/rawenc.c
	libavformat/riff.c
	libavformat/sdp.c
	libavformat/utils.c
	libavformat/vocenc.c
	libavformat/wtv.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-07 22:45:46 +02:00
Anton Khirnov
36ef5369ee Replace all CODEC_ID_* with AV_CODEC_ID_* 2012-08-07 16:00:24 +02:00
Michael Niedermayer
5d6a40bc74 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  rtsp: Don't use av_malloc(0) if there are no streams
  rtsp: Don't use uninitialized data if there are no streams
  vaapi: mpeg2: fix slice_vertical_position calculation.
  hwaccel: mpeg2: decode first field, if requested.
  cosmetics: Fix indentation
  rtsp: Don't expose the MS-RTSP RTX data stream to the caller

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-08 20:55:11 +02:00
Martin Storsjö
456001486e rtsp: Don't expose the MS-RTSP RTX data stream to the caller
This avoids exposing a dummy AVStream which won't get any data
and which will make avformat_find_stream_info wait for info about
this stream.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-04-08 12:04:22 +03:00
Michael Niedermayer
6101e5322f Merge remote-tracking branch 'qatar/master'
* qatar/master:
  rtpdec_asf: Set the no_resync_search option for the chained asf demuxer
  asfdec: Add an option for not searching for the packet markers
  cosmetics: Clean up the tiffenc pix_fmts declaration to match the style of others
  cosmetics: Align codec declarations
  cosmetics: Convert mimic.c to utf-8
  avconv: remove an unused function parameter.
  avconv: remove now pointless variables.
  avconv: drop support for building without libavfilter.
  nellymoserenc: fix crash due to memsetting the wrong area.
  libavformat: Only require first packet to be known for audio/video streams
  avplay: Don't try to scale timestamps if the tb isn't set

Conflicts:
	Changelog
	configure
	ffmpeg.c
	libavcodec/aacenc.c
	libavcodec/bmpenc.c
	libavcodec/dnxhddec.c
	libavcodec/dnxhdenc.c
	libavcodec/ffv1.c
	libavcodec/flacenc.c
	libavcodec/fraps.c
	libavcodec/huffyuv.c
	libavcodec/libopenjpegdec.c
	libavcodec/mpeg12enc.c
	libavcodec/mpeg4videodec.c
	libavcodec/pamenc.c
	libavcodec/pgssubdec.c
	libavcodec/pngenc.c
	libavcodec/qtrleenc.c
	libavcodec/rawdec.c
	libavcodec/sgienc.c
	libavcodec/tiffenc.c
	libavcodec/v210dec.c
	libavcodec/wmv2dec.c
	libavformat/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-04-07 22:41:37 +02:00
Martin Storsjö
d293e3464d rtpdec_asf: Set the no_resync_search option for the chained asf demuxer
Searching for packet markers doesn't make sense for this use case,
where packets are fed one at a time to the demuxer.

This fixes playing back streams that have packets not starting
with the 0x82, 0x00, 0x00 marker.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-04-07 01:01:08 +03:00
Michael Niedermayer
0ebd83617f Merge remote-tracking branch 'qatar/master'
* qatar/master: (27 commits)
  avconv: free packet in write_frame() when discarding due to frame number limit
  FATE: use +/- flag option syntax for vp8 emu-edge tests
  lavf: make av_interleave_packet_per_dts() private.
  lavf: deprecate av_read_packet().
  oggdec: output correct timestamps for Vorbis
  avconv: pass input stream timestamps to audio encoders
  lavc: shrink encoded audio packet size after encoding.
  xa: set correct bit rate
  xa: do not set bit_rate, block_align, or bits_per_coded_sample
  xa: fix end-of-file handling
  xa: fix timestamp calculation
  bink: fix typo in FFALIGN() argument
  bink: align plane width to 8 when calculating bundle sizes
  doc: pass -Idoc texi2html and texi2pod
  doc: texi2pod: add -I flag
  movenc: Add a min_frag_duration option
  rtsp: Set the default delay to 0.1 s for the RTSP/SDP/RTP demuxers
  libavformat: Set the default for the max_delay option to -1
  Generate manpages for AV{Format,Codec}Context AVOptions.
  doc/avconv: remove entries for AVOptions.
  ...

Conflicts:
	doc/Makefile
	doc/ffmpeg.texi
	doc/muxers.texi
	ffmpeg.c
	libavcodec/Makefile
	libavcodec/options.c
	libavcodec/vp8.c
	libavformat/options.c
	tests/fate/demux.mak
	tests/ref/fate/truemotion1-15
	tests/ref/fate/truemotion1-24

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-03-21 01:33:53 +01:00
Anton Khirnov
3c90cc2ef2 lavf: deprecate av_read_packet().
The caller can achieve the same effect (i.e. getting raw unparsed/mangled
packets) with av_read_frame() and AVFMT_FLAG_NOPARSE |
AVFMT_FLAG_NOFILLIN
2012-03-20 20:12:16 +01:00
Michael Niedermayer
8bc7fe4daf Merge remote-tracking branch 'qatar/master'
* qatar/master:
  doxygen: misc consistency, spelling and wording fixes
  vcr1: drop unnecessary emms_c() calls without MMX code
  Replace all uses of av_close_input_file() with avformat_close_input().
  lavf: add avformat_close_input().
  lavf: deprecate av_close_input_stream().
  lavf doxy: add some basic demuxing documentation.
  lavf doxy: add some general lavf information.
  lavf doxy: add misc utility functions to a group.
  lavf doxy: add av_guess_codec/format to the encoding group.
  lavf doxy: add core functions to a doxy group.
  Add basic libavdevice documentation.
  lavc: convert error_recognition to err_recognition.
  avconv: update -map option help text
  x86: Require 7 registers for the cabac asm
  x86: bswap: remove test for bswap instruction
  bswap: make generic implementation more compiler-friendly
  h264: remove useless cast
  proresdec: fix decode_slice() prototype

Conflicts:
	configure
	doc/APIchanges
	ffprobe.c
	libavcodec/avcodec.h
	libavcodec/celp_math.h
	libavcodec/h264.c
	libavfilter/src_movie.c
	libavformat/anm.c
	libavformat/avformat.h
	libavformat/version.h
	libavutil/avstring.h
	libavutil/bswap.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-13 00:39:48 +01:00
Anton Khirnov
cd3716b9aa Replace all uses of av_close_input_file() with avformat_close_input(). 2011-12-12 20:34:38 +01:00
Michael Niedermayer
9d76cf0b18 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  rtpdec: Templatize the code for different g726 bitrate variants
  rv40: move loop filter to rv34dsp context
  lavf: make av_set_pts_info private.
  rtpdec: Add support for G726 audio
  rtpdec: Add an init function that can do custom codec context initialization
  avconv: make copy_tb on by default.
  matroskadec: don't set codec timebase.
  rmdec: don't set codec timebase.
  avconv: compute next_pts from input packet duration when possible.
  lavf: estimate frame duration from r_frame_rate.
  avconv: update InputStream.pts in the streamcopy case.

Conflicts:
	avconv.c
	libavdevice/alsa-audio-dec.c
	libavdevice/bktr.c
	libavdevice/fbdev.c
	libavdevice/libdc1394.c
	libavdevice/oss_audio.c
	libavdevice/v4l.c
	libavdevice/v4l2.c
	libavdevice/vfwcap.c
	libavdevice/x11grab.c
	libavformat/au.c
	libavformat/eacdata.c
	libavformat/flvdec.c
	libavformat/mpegts.c
	libavformat/mxfenc.c
	libavformat/rtpdec_g726.c
	libavformat/wtv.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-12-01 02:54:24 +01:00
Anton Khirnov
c3f9ebf743 lavf: make av_set_pts_info private.
It's supposed to be called only from (de)muxers.
2011-11-30 20:34:45 +01:00
Michael Niedermayer
78d7d8fe91 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Employ FF_ARRAY_ELEMS instead of manually calculating array length.
  Fixed invalid access in wavpack decoder on corrupted bitstream.
  Fixed invalid writes in wavpack decoder on corrupted bitstreams.
  Fixed invalid access in wavpack decoder on corrupted extra bits sub-blocks.
  rtpdec_asf: Fix integer underflow that could allow remote code execution

Conflicts:
	libavformat/rtpdec_asf.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2011-09-08 22:37:31 +02:00