Commit Graph

911 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
Michael Niedermayer e849eb2343
avformat/matroskadec: Check timescale
Fixes: 3.82046e+18 is outside the range of representable values of type 'unsigned int'
Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-6381436594421760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-03-26 23:25:42 +01:00
Andreas Rheinhardt 4a4dcde339 avformat/internal: Move FF_FMT_INIT_CLEANUP to demux.h
and rename it to FF_INFMT_INIT_CLEANUP. This flag is demuxer-only,
so this is the more appropriate place for it.
This does not preclude adding internal flags common to both
demuxer and muxer in the future.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
James Almer 53dd31497b avformat/matroska: use named constants for ITU-T T.35 metadata
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-19 10:49:20 -03:00
Anton Khirnov 384a207ea9 lavf/matroskadec: add missing linebreaks in error messages 2024-03-07 15:59:31 +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
asivery 7f4abe7c37 avformat/matroska: Add support for A_ATRAC/AT1
Signed-off-by: asivery <asivery@protonmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-02-13 15:27:29 +01:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Andreas Rheinhardt 37b5f4a1f6 avformat/matroskadec, mov: Fix declaration-after-statement warnings
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-10-09 00:21:43 +02:00
Michael Niedermayer 2d6df3719d
avformat/matroskadec: Check prebuffered_ns for overflow
Fixes: signed integer overflow: 9223372036630775808 + 1000000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-5406131992526848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-10-08 21:36:06 +02:00
James Almer 5432d2aaca avformat/avformat: use the side data from AVStream.codecpar
Deprecate AVStream.side_data and its helpers in favor of the AVStream's
codecpar.coded_side_data.

This will considerably simplify the propagation of global side data to decoders
and from encoders. Instead of having to do it inside packets, it will be
available during init().
Global and frame specific side data will therefore be distinct.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-10-06 10:03:57 -03:00
Andreas Rheinhardt 7001ff74ba avformat/aviobuf: Add ffio_init_(read|write)_context()
Most users of ffio_init_context() simply want to wrap
a buffer into an AVIOContext; they do not provide
function pointers at all.

Therefore this commit adds shortcuts for these two common
operations. This also allows to accept const data when reading
(i.e. the const is now cast away at a central place in
ffio_init_read_context() instead of at several callers).
This also allows to constify the data in ff_text_init_buf().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:41:45 +02:00
Andreas Rheinhardt 8238bc0b5e avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* defines
These defines are also used in other contexts than just AVCodecContext
ones, e.g. in libavformat. Furthermore, given that these defines are
public, the AV-prefix is the right one, so deprecate (and not just move)
the FF-macros.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:39:02 +02:00
Andreas Rheinhardt 4e633e51da avformat/matroskadec: Factor parsing content encodings out
Namely, out of matroska_parse_tracks().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt b105ad50c5 avformat/matroskadec: Move WEBVTT code to mkv_parse_subtitle_codec()
and also perform the remainder of the subtitle parsing directly
after mkv_parse_subtitle_codec().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt ee25dcd5fb avformat/matroskdec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt a20bd65934 avformat/matroskadec: Factor generic parsing of audio tracks out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt c2b8a694e1 avformat/matroskadec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt c8903755ae avformat/matroskadec: Factor generic parsing of video tracks out
Out of matroska_parse_tracks(), that is.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 7b5b6ebdac avformat/matroskadec: Factor parsing subtitle codecs out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt a64c2e0e0b avformat/matroskadec: Use av_dict_set_int() where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt d989785e47 avformat/matroskadec: Avoid clobbering CodecPrivate size
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 007c22ce09 avformat/matroskadec: Move reading color space to a better place
Namely to a place after the AVStream has already been created,
so that it can be directly attached to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 05ae0ccad9 avformat/matroskadec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 15f96bb074 avformat/matroskadec: Factor video parsing out of matroska_parse_tracks()
More exactly, factor codec-specific video parsing out of
matroska_parse_tracks(). This is intended to improve readability.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 8eaf23a160 avformat/matroskadec: Reindent after the previous commit
Also fix a variable shadowing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 9d3c4170c5 avformat/matroskadec: Remove redundant checks
If the size of the data of an EbmlBin is > 0, its data is always
present, as ebml_read_binary() always leaves the buffer
in a consistent state (even on error).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 8ecd1b80d1 avformat/matroskdec: Factor audio parsing out of matroska_parse_tracks()
More exactly, factor codec-specific audio parsing out of
matroska_parse_tracks(). This is intended to improve readability.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 758b3ba6e1 avformat/matroskadec: Set AVCodecParameters earlier
This is in preparation for future commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 7c95dbd94e avformat/matroskadec: Redo handling extradata allocation
Up until now, matroska_parse_tracks() has two main ways
to set AVCodecParameters.extradata: A generic way via CodecPrivate
(possibly with an offset) and by allocating a buffer manually;
the pointer to this buffer is stored in a stack pointer.

In particular, the latter method is problematic, as the buffer
needs to be freed manually in case of error (currently there
are no error conditions between the place where it is set
to AVCodecParameters.extradata).

Most of these buffers are very small (<= 22B), so replace
the pointer to an allocated buffer with a stack buffer
and set the extradata directly for the one place where
the buffer may not be small.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt e8af7d0acd avformat/matroskadec: Use dedicated pointer for access to codecpar
Shortens code and improves readability.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt 8507b9203c avformat/matroskadec: Set several stream parameters earlier
Don't do it in between parsing and setting extradata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:28:27 +02:00
Andreas Rheinhardt fc993e7a53 avformat/matroska(dec|enc): Rename macro to avoid clash with winbase.h
winbase.h defines IGNORE and is included via bzlib.h when compiling
for Windows. So rename this macro to NOTHING.
Also rename the muxer macro for consistency.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-02 10:36:20 +02:00
Andreas Rheinhardt 6a15b4d16c avformat/matroskadec: Use named constants instead of their value
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-30 19:43:49 +02:00
Andreas Rheinhardt b3825bd711 avformat/matroskadec: Replace switch with array
This simplification reduces codesize.
(It even reduces the size of .rodata here, because
the jump table used by the compiler is bigger than
the actual array.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-30 19:42:55 +02:00
Andreas Rheinhardt 9c46faaf77 avformat/matroska: Move ff_mkv_stereo3d_conv() to demuxer
It is now its only user; also make it static.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-30 19:34:47 +02:00
Andreas Rheinhardt 3fc9ed8497 avformat/matroska: Move ff_matroska_video_stereo_plane to demuxer
Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-30 19:26:10 +02:00
James Almer c558fcf41e avformat/matroskadec: also export non-HDR10+ ITU-T T.35 payloads as BlockAdditional side data
Partially reverts a change from 88de01d878, and
2133cadfcf.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-10 18:52:08 -03:00
James Almer 82a14f3602 avformat/matroskadec: also validate the mapping when BlockAddIDType is 0
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-08 15:24:44 -03:00
James Almer e1f691b2e8 avformat/matroskadec: remove itu_t_t35 flag from MatroskaTrack
It's no longer needed after 88de01d878.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-08 10:21:56 -03:00
James Almer 6d31619af2 avformat/matroskadec: validate MaxBlockAdditionID in the presence of BlockAdditions
The Matroska spec requires it to be equal to the highest BlockAddID value in a
BlockAdditions, but being purely an informative element, only abort if strict
compliance is requested, as demuxing is otherwise unaffected.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-07 14:13:03 -03:00
James Almer 2133cadfcf avformat/matroskadec: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-07 11:57:17 -03:00
James Almer 88de01d878 avformat/matroskadec: parse all BlockAdditionMapping elements and export the correct value as BlockAdditional side data
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-07 11:55:47 -03:00
James Almer 00fde8063a avformat/matroska: add a few more Block Addition ID Type enum values
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer c73cf41f1e avformat/matroskadec: export Dynamic HDR10+ packet side data
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer 6def862559 avformat/matroskadec: set the default value for BlockAddIDType
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
James Almer 44513156e3 avformat/matroskadec: support parsing more than one BlockMore element
Signed-off-by: James Almer <jamrial@gmail.com>
2023-04-05 09:47:12 -03:00
rcombs f758d4fcb9 lavf/matroska: add support for ARIB captions 2023-03-08 14:57:54 -06:00
Andreas Rheinhardt 832e6563df avformat/matroska*: Use av_chroma_location_(pos_to_enum|enum_to_pos)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-26 03:02:27 +02:00