Commit Graph

104 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
Andreas Rheinhardt 654e4b00e2 avformat/wtvdec: Avoid unnecessary allocations
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 23:35:26 +02:00
Andreas Rheinhardt ea0a41bcaf avformat/wtvdec: Use smaller upper bound for buffer
Every code point in the BMP is representable with at most three bytes
in UTF-8 and every code point not in the BMP takes four bytes.
For each of the latter, the encoding of UTF-16 takes as many
bytes; for each of the former, it takes at most 3/2 as many.
Therefore one can decrease the size of the buffer allocated
here.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 23:35:14 +02:00
Andreas Rheinhardt 78169f397d avformat/wtvdec: Fix signed integer overflow
Happens when length > INT_MAX / 2; use unsigned for the computation,
but restrict the value to INT_MAX, because avio_get_str16le()
accepts an int as buf_len argument. Notice that it can happen
that the string read by avio_get_str16le() is truncated in this case.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 23:35:01 +02:00
Andreas Rheinhardt 197f7e914b avformat/wtvdec: Skip too big tags
get_tag() is not designed with negative length in mind;
in this case, it will allocate a very small buffer
(LEN_PRETTY_GUID + 1) and might call avio_get_str16le()
with a negative maxlen (which relies on these parameters
to be signed).

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 23:34:54 +02:00
Andreas Rheinhardt c461ee39f9 avformat/wtvdec: Don't truncate GUIDs
Each of the 16 bytes of a GUID is written as a two-character
hex value and three hyphens, leading to a length of 35.
GCC 13 emits a -Wformat-truncation= warning because of this.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 23:34:40 +02:00
Andreas Rheinhardt 0c6e5f321b avformat/avformat: Avoid including codec.h, frame.h
AVCodec is only ever used as an incomplete type (i.e. via a pointer
to an AVCodec) in avformat.h and it is not really part of the core
of avformat.h or libavformat; almost none of our internal users
make use of it (and none make use of hwcontext.h, which is implicitly
included). So switch to use struct AVCodec, but continue to include
codec.h for external users for compatibility.

Also, do the same for AVFrame and frame.h, which is implicitly included
by codec.h (via lavu/hwcontext.h).

Also, remove an unnecessary inclusion of <time.h>.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:30:08 +02:00
Andreas Rheinhardt 35ec5c819b avformat/demux: Add new demux.h header
And move those stuff already in demuxer-only files to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-05-10 07:37:38 +02:00
Vittorio Giovara b0e5661194 wtv: 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:38 -03: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
Michael Niedermayer 89505d38de avformat/wtvdec: Check for EOF before seeking back in parse_media_type()
Fixes: Infinite loop
Fixes: 36311/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-4889181296918528

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-08-06 21:04:43 +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 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 f8ec1da8ac avformat/wtvdec: Improve size overflow checks in parse_chunks()
Fixes: signed integer overflow: 32 + 2147483647 cannot be represented in type 'int
Fixes: 32967/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5132856218222592

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-04-22 16:01:21 +02:00
Andreas Rheinhardt 39ecb63d0f avformat: Add and use helper function to add attachment streams
All instances of adding attached pictures to a stream or adding
a stream and an attached packet to said stream have several things
in common like setting the index and flags of the packet, setting
the stream disposition etc. This commit therefore factors this out.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-04-01 18:23:13 +02:00
Michael Niedermayer 1f74661543 avformat/wtvdec: Check size in SBE2_STREAM_DESC_EVENT / stream2_guid
Fixes: signed integer overflow: 539033600 - -1910497124 cannot be represented in type 'int'
Fixes: 30928/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5922630966312960

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-29 22:19:39 +02:00
Michael Niedermayer 5552ceaf56 avformat/wtvdec: Check len in parse_chunks() to avoid overflow
Fixes: signed integer overflow: 2147483647 + 7 cannot be represented in type 'int'
Fixes: 30084/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-6192261941559296

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-09 19:37:27 +01:00
Michael Niedermayer 69754e07f5 avformat/wtvdec: Check for EOF before potentially reseting the eof state
Fixes: infinite loop
Fixes: 28042/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-6311288967528448

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-09 19:37:27 +01:00
Michael Niedermayer 1868cb7316 avformat/wtvdec: Check dir_length
Fixes: Infinite loop
Fixes: 26445/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5125558331244544

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>
2020-10-21 17:21:41 +02:00
Andreas Rheinhardt acbd950ed2 avformat/wtvdec: Forward errors when reading packet
wtvfile_read_packet did not abide by the requirements of an
AVIOContext's read_packet-function: If it did not read anything,
it returned zero, which currently leads to a warning in read_packet_wrapper
in aviobuf.c. Said warning will be an av_assert2 as soon as
FF_API_OLD_AVIO_EOF_0 is zero (probably the next major version bump).
So instead forward the error code from the underlying protocol.

This error/assert is triggered in the wtv-demux FATE test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-02-19 22:37:30 +01:00
Andreas Rheinhardt 653ef8828a avformat/wtvdec: Cosmetics
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-07 22:35:52 -03:00
Andreas Rheinhardt 373c1c9b69 avformat/wtvdec: Fix memleak when reading header fails
Fixes #8314.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-01-07 22:35:27 -03:00
Michael Niedermayer dd357d76e5 avformat/wtvdec: Avoid (32bit signed) sectors
Fixes: left shift of negative value -14614752
Fixes: 15174/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5670543606415360

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>
2019-06-14 21:36:39 +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
Daniel Kucera feed201849 libavformat/wtvdec: return AVERROR_EOF on EOF
Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
Signed-off-by: wm4 <nfxjfg@googlemail.com>
2017-10-13 17:23:54 +02:00
Anton Khirnov 78a7af823b Use the new AVIOContext destructor.
(cherry picked from commit 6f554521af)
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-01 02:16:33 -03:00
Michael Niedermayer cc5e5548df avformat/wtvdec: Check pointer before use
Fixes out of array read
Fixes: 049fdf78565f1ce5665df236d90f8657/asan_heap-oob_10a5a97_1026_42f9d4855547329560f385768de2f3fb.wtv

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-08-21 21:31:46 +02:00
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +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
Michael Niedermayer 92dfeb5c31 avformat/wtvdec: Set AVFMTCTX_NOHEADER
Needed for noStreams.wtv unless something else forces continued parsing (like looking for more than 1
frame in attachments)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-19 22:58:34 +01:00
Derek Buitenhuis 1a12eb4a73 Merge commit '29c2d06d67724e994980045afa055c6c34611b30'
* commit '29c2d06d67724e994980045afa055c6c34611b30':
  cosmetics: Drop empty comment lines

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 17:31:44 +00:00
Timothy Gu e5a6dcac47 wtvdec: Removed unused variable 2016-01-31 15:52:23 -08:00
popcornmix def56677e5 wtv: Speed up wtv index creation
The index creation is O(N^2) with number of entries (typically thousands).
On a Pi this can take more than 60 seconds to execute for a recording of a few hours.

By replacing with an O(N) loop, this takes virtually zero time

Liked-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-01 00:40:47 +01:00
Michael Niedermayer ba77fb61f7 Merge commit 'd80811c94e068085aab797f9ba35790529126f85'
* commit 'd80811c94e068085aab797f9ba35790529126f85':
  riff: Use the correct logging context

Conflicts:
	libavformat/asfdec_o.c
	libavformat/avidec.c
	libavformat/dxa.c
	libavformat/matroskadec.c
	libavformat/mov.c
	libavformat/riff.h
	libavformat/riffdec.c
	libavformat/wavdec.c
	libavformat/wtvdec.c
	libavformat/xwma.c

Merged-by: Michael Niedermayer <michael@niedermayer.cc>
2015-07-12 15:22:37 +02:00
Michael Niedermayer d44e0d8b93 avformat/wtvdec: Use 64bit for ret to avoid overflow
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-20 20:57:31 +01:00
Rodger Combs 62e95757d5 wtvdec: fix integer overflow resulting in errors with large files
This fixes a regression in 9fbc613f0d

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-20 18:38:36 +01:00
Michael Niedermayer a0fe1a25fa Merge commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e'
* commit 'daf8cf358a098a903d59adb6c0d0cc3262a8c93e':
  avformat: Don't anonymously typedef structs

Conflicts:
	libavformat/adtsenc.c
	libavformat/aiffenc.c
	libavformat/avidec.c
	libavformat/gif.c
	libavformat/iff.c
	libavformat/img2dec.c
	libavformat/jvdec.c
	libavformat/matroskadec.c
	libavformat/udp.c
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-02-14 21:07:40 +01:00
Michael Niedermayer 443bd2715d avformat/wtvdec: Use av_freep() avoid leaving stale pointers in memory
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-25 12:51:48 +01:00
Thomas Volkert 00d7555f34 wavdec: RIFX file format support
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-12-18 00:10:35 +01:00
Michael Niedermayer 4a39d4c65a Merge commit '82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de'
* commit '82ee7d0dda0fec8cdb670f4e844bf5c2927ad9de':
  Use gmtime_r instead of gmtime and localtime_r instead of localtime

Conflicts:
	libavformat/mov.c
	libavformat/mxfenc.c
	libavformat/wtvdec.c
	libavutil/parseutils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-26 02:38:26 +01:00
Michael Niedermayer 3b709fd912 Merge commit '9dcf2397219ca796f0fafce2a703770d6fd09920'
* commit '9dcf2397219ca796f0fafce2a703770d6fd09920':
  lavf: Check the return value of strftime

Conflicts:
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-26 02:06:40 +01:00
Michael Niedermayer 50697ac5b2 Merge commit '851ace79a307bea54b44bd6f7ecd3b7861c28ec6'
* commit '851ace79a307bea54b44bd6f7ecd3b7861c28ec6':
  wtv: Avoid needlessly calling gmtime twice with the same argument

Conflicts:
	libavformat/wtvdec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-26 02:21:42 +02:00
Michael Niedermayer c04f125bb4 Merge commit '9fbc613f0df1628e7e78bca791fa8833846f8210'
* commit '9fbc613f0df1628e7e78bca791fa8833846f8210':
  wtv: check seek_by_sector return value

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-20 21:43:44 +02:00
Carl Eugen Hoyos 6efe4137ce Stop demuxing wtv on eof.
Fixes ticket #3991.
Fixes ticket #3995.
Fixes ticket #3997.

Reviewed-by: Peter Ross
Reviewed-by: Paul B Mahol
2014-10-02 09:41:57 +02:00
Peter Ross 9b8eedd736 avformat/wtvdec: seek over broken chunks
Fixes ticket #3898

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-29 14:00:58 +02:00
James Almer d34ec64a22 replace calls to url_feof() with avio_feof()
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-08-08 00:48:38 +02:00
Peter Ross be098f6237 avformat/wtvdec: ignore mpeg2 extradata
Files produced by windows media center contain meaningless mpeg1 sequence
header. The mpeg2 decoder detects the presence mpeg1 sequence header start
codes and attempts to decode the stream as mpeg1. (This problem introduced
in 73a2d16b.)

Fixes ticket #3601.

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-05-01 18:36:27 +02:00
Peter Ross 0cc685e3ad avformat/wtvdec: populate codec_tag from BITMAPINFOHEADER
Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-04 17:20:38 +02:00
Peter Ross 8348bd198f avformat/wtvdec: ignore MPEG2VIDEO extradata when count is invalid
Fixes ticket #3522.

Signed-off-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-04 17:11:47 +02:00