Commit Graph

44 Commits

Author SHA1 Message Date
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt b800327f4c avformat/avformat: Add FFInputFormat, hide internals of AVInputFormat
This commit does for AVInputFormat what commit
59c9dc82f4 did for AVOutputFormat:
It adds a new type FFInputFormat, moves all the internals
of AVInputFormat to it and adds a now reduced AVInputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for demuxers (it is still a mess due to lavd).

This is possible since 50f34172e0
(which removed the last usage of an internal field of AVInputFormat
in fftools).

(Hint: tools/probetest.c accesses the internals of FFInputFormat
as well, but given that it is a testing tool this is not considered
a problem.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
Vittorio Giovara 28fdd7c6cb mvdec: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-15 09:42:35 -03:00
John-Paul Stewart b24f0c82b3 avformat/mvdec: re-indent after last commit
Signed-off-by: John-Paul Stewart <jpstewart@personalprojects.net>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Reviewed-by: Peter Ross <pross@xvid.org>
2022-01-08 09:21:21 +11:00
John-Paul Stewart a8da115143 avformat/mvdec: make audio stream conditional
Only allocate an audio stream if there is one in the data.  Silicon
Graphics movie format will contain default values (16 bit samples, 2
audio channels, 22050 Hz sample rate) even when no audio is present in
the file.  This confuses FFmpeg into thinking such an audio stream is
present with 0 samples in it.

There is a flag value in the format to indicate whether or not audio is
present.  This patch checks that and behaves accordingly.

Signed-off-by: John-Paul Stewart <jpstewart@personalprojects.net>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Reviewed-by: Peter Ross <pross@xvid.org>
2022-01-08 09:21:21 +11:00
Michael Niedermayer f3a949dc4c avformat/mvdec: Check bytes_per_sample
Fixes: division by zero
Fixes: 42814/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-4787014237552640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Reviewed-by: John-Paul Stewart <jpstewart@personalprojects.net>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-25 11:59:47 +01:00
John-Paul Stewart 50bfd5e96e avformat/mvdec: explicitly set duration
Resolves a warning that duration is being innaccurately estimated based
on bitrate.

Signed-off-by: John-Paul Stewart <jpstewart@personalprojects.net>
Reviewed-by: Peter Ross <pross@xvid.org>
2021-12-21 12:01:22 +11:00
John-Paul Stewart 3c9ffbd009 avformat/mvdec: read frame rate from data stream
Prior to this patch, for version 2 of the file format the frame rate was
hard-coded at 15 fps.  This uses the 64-bit floating-point value from
the data stream, similar to what is already done for version 3 of the
file format (around line 206).

Signed-off-by: John-Paul Stewart <jpstewart@personalprojects.net>
Reviewed-by: Peter Ross <pross@xvid.org>
2021-12-21 12:01:17 +11:00
Michael Niedermayer 99b2700f5b avformat/mvdec: Use 64 bit in timestamp computation
Fixes: division by zero
Fixes: 42198/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5054366405492736.fuzz
Fixes: 42222/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-4561249331970048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 21:06:47 +01:00
John-Paul Stewart 6c76b63923 avformat/mvdec: handle audio sample size
Adds support for reading audio sample size from the data instead of
assuming all audio is 16 bits per sample.

Reviewed-by: Peter Ross <pross@xvid.org>
2021-12-03 19:53:56 +11:00
John-Paul Stewart 4a90c039e7 avformat/mvdec: fix reading number of audio channels
The number of audio channels is stored after the magic number
identifying the audio format.  Prior to this patch the code has been
reading it earlier, causing files with only one audio channel to be
handled incorrectly.

Reviewed-by: Peter Ross <pross@xvid.org>
2021-12-03 19:53:56 +11:00
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
James Almer 229e949c8e avformat/mvdec: Don't signal success on parse_audio_var() error
Propagate the error it returned instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-09-16 19:44:32 -03:00
Michael Niedermayer 737e6bf216 avformat/mvdec: Do not set invalid sample rate
Fixes: signed integer overflow: -682581959642593728 * 16 cannot be represented in type 'long'
Fixes: 37883/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5311691517198336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-09-16 18:41:10 +02:00
Michael Niedermayer 0ff60249a5 avformat/mvdec: Check sample rate in parse_audio_var()
Fixes: signed integer overflow: -635424002382840000 * 16 cannot be represented in type 'long'
Fixes: 33612/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5704741108711424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-04 17:55:24 +02:00
Andreas Rheinhardt bc70684e74 avformat: Constify all muxer/demuxers
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:06 -03:00
Michael Niedermayer c35e456f54 avformat/mvdec: Allocate extradata only once
Fixes: memleak
Fixes: 28686/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5822961932173312

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-09 21:16:56 +01:00
Michael Niedermayer 6c64351bb1 avformat/mvdec: Check for EOF in read_index()
Fixes: Timeout
Fixes: 29550/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5094307193290752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-02-10 12:28:29 +01:00
Michael Niedermayer ab82c10578 avformat/mvdec: Sanity check SAMPLE_WIDTH
Fixes: signed integer overflow: 999999999 * 8 cannot be represented in type 'int'
Fixes: 30048/clusterfuzz-testcase-minimized-ffmpeg_dem_MV_fuzzer-5864289917337600

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-02-04 17:20:31 +01:00
Anton Khirnov cea7c19cda lavf: move AVStream.*index_entries* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public
header. Since there are some (semi-)public fields located after these,
even though this section is supposed to be private, keep some dummy
padding there until the next major bump to preserve ABI compatibility.
2020-10-28 14:59:28 +01:00
Michael Niedermayer b6fbbe08c3 avformat/mvdec: Fix integer overflow with billions of channels
Fixes: signed integer overflow: 1394614304 * 2 cannot be represented in type 'int'
Fixes: 23491/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5697377020411904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-06-27 12:43:51 +02:00
Michael Niedermayer 618a9bea65 avformat/mvdec: Check stream numbers
Fixes: null pointer dereference
Fixes: 20768/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5638648978735104.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-25 19:57:16 +01:00
Steven Liu b1071b405d avformat/mvdec: check av_strdup() return value
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2019-10-19 06:56:02 +02:00
Carl Eugen Hoyos 4d8875ec23 lavf: Constify the probe function argument.
Reviewed-by: Lauri Kasanen
Reviewed-by: Tomas Härdin
2019-03-21 11:42:17 +01:00
Paul B Mahol 3f4fccf4d6 avformat/mvdec: check for EOF
Fixes #6805.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-11-05 10:42:07 +01:00
Michael Niedermayer 4f05e2e2dc avformat/mvdec: Fix DoS due to lack of eof check
Fixes: loop.mv

Found-by: Xiaohei and Wangchu from Alibaba Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-27 19:23:37 +02:00
James Almer 4de591e6fb Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'
* commit '83548fe894cdb455cc127f754d09905b6d23c173':
  lavf: fix usage of AVIOContext.seekable

Merged-by: James Almer <jamrial@gmail.com>
2017-03-21 17:02:30 -03:00
Andreas Cadhalpun 2c818c3821 mvdec: validate sample_rate
A negative sample rate doesn't make sense and triggers assertions in
av_rescale_rnd.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-07 00:51:49 +01:00
Anton Khirnov 83548fe894 lavf: fix usage of AVIOContext.seekable
It is supposed to be a flag. The only currently defined value is
AVIO_SEEKABLE_NORMAL, but other ones may be added in the future.
However all the current lavf code treats this field as a bool (mainly
for historical reasons).
Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
2016-09-30 16:54:33 +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
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
Michael Niedermayer 26c0cc154e avformat/mvdec: Use 64bit for ret to avoid overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-20 20:41:35 +01:00
Michael Niedermayer f1c21a200b avformat/mvdec: Check size in read_table() for validity
This check is redundant with the previous commit but it provides
better error messages and feedback while the previous commit
ensures that var_read_string() doesnt return uninitialized arrays
if it itself is feeded with an invalid size possibly through a
different future codepath.

Fixes: asan_heap-oob_49b1e5_12_011.movie
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-28 17:51:14 +01:00
Michael Niedermayer 86e5749285 avformat/mvdec: Check size for validity in var_read_string()
Fixes out of array read
Fixes: asan_heap-oob_49b1e5_12_011.movie
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-28 17:06:16 +01:00
Michael Niedermayer 01a39a978c Merge commit '55ddd700c67529ff2c6c4e976673f1341bba7a82'
* commit '55ddd700c67529ff2c6c4e976673f1341bba7a82':
  Silicon Graphics Movie demuxer

Conflicts:
	Changelog
	libavformat/mvdec.c
	libavformat/version.h

See: 6fb40779cd
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-19 20:17:33 +02:00
Peter Ross 55ddd700c6 Silicon Graphics Movie demuxer
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2014-04-19 16:24:27 +02:00
Paul B Mahol a9b424879f lavc & lavf: replace deprecated av_log* functions
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2013-03-15 18:10:28 +00:00
Michael Niedermayer 5de286ef88 mvdec: check var_read_string() return value
Prevent null pointer dereference

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-27 02:15:02 +01:00
Michael Niedermayer 362271d72f mvdec: Check the frame counter against the correct limit.
fixes out of array reads

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-27 02:11:19 +01:00
Michael Niedermayer b89815f519 mvdec: check channel count.
Fixes division by 0

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-22 23:06:49 +01:00
Michael Niedermayer e6cc3c869b mvdec: minor simplification, remove av_inv_q()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-22 22:52:23 +01:00
Michael Niedermayer 4c9f35bb7c mvdec: use avpriv_set_pts_info() instead of directly setting tb.
Fixes division by 0

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-01-22 22:41:09 +01:00
Michael Niedermayer 70d5cd103a mcdec: suppress "warning: a/vst may be used uninitialized in this function"
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-12-24 18:31:37 +01:00
Peter Ross 6fb40779cd Silicon Graphics Movie (.mv) demuxer
Signed-off-by: Peter Ross <pross@xvid.org>
2012-12-17 20:37:54 +11:00