1
0
Fork 0
Commit Graph

54 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
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 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 59c9dc82f4 avformat/avformat: Move AVOutputFormat internals out of public header
This commit does for AVOutputFormat what commit
20f9727018 did for AVCodec:
It adds a new type FFOutputFormat, moves all the internals
of AVOutputFormat to it and adds a now reduced AVOutputFormat
as first member.

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

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 15:24:15 +01:00
James Almer 487b49d8f2 avformat/webmdashenc: fix on-demand profile string
Fixes ticket #9596

Signed-off-by: James Almer <jamrial@gmail.com>
2022-04-07 21:57:42 -03:00
Andreas Rheinhardt 636631d9db Remove unnecessary libavutil/(avutil|common|internal).h inclusions
Some of these were made possible by moving several common macros to
libavutil/macros.h.

While just at it, also improve the other headers a bit.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-24 12:56:49 +01:00
Matthieu Patou 52795d7f09 lavf/webmdashenc.c: Allow AV1 video in WebM
Suggested-By: ffmpeg@fb.com
2021-06-20 22:30:38 +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
Andreas Rheinhardt a42c47b77f avformat/webmdashenc: Don't pass NULL to memcmp
Affects the FATE-tests webm-dash-manifest-unaligned-video-streams,
webm-dash-manifest and webm-dash-manifest-representations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-28 17:50:17 +02:00
Andreas Rheinhardt 546e3964dd avformat/webmdashenc: Use av_strstart instead of strncmp
It makes the intent clearer and avoids calculating the length
separately.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-28 17:14:22 +01:00
Andreas Rheinhardt f38d01714a avformat/webmdashenc: Cosmetics
Mostly using intermediate pointers for accesses (i.e. storing s->pb in a
variable pb and then using pb for writing instead of s->pb) to improve
readability. Furthermore, the opening brace '{' of a function has been
moved into a line of its own in instances where it wasn't before.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:47:01 +02:00
Andreas Rheinhardt e45365d15d avformat/webmdashenc: Only check for existence of metadata if it is used
Also return proper error codes when it is absent: AVERROR(EINVAL)
instead of AVERROR_INVALIDDATA.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:44:07 +02:00
Andreas Rheinhardt f163b2eb27 avformat/webmdashenc: Avoid allocations, fix memleak
When using the WebM DASH Manifest muxer, every stream of each adaptation
set has to contain a metadata entry containing the filename of the
source file. In case of live stream manifests, said filename has to
conform to a pattern of
<file_description>_<representation_id>.<extension>. These pieces are
used to create the other strings that are actually output. Up until now,
these other strings would be allocated, used once and then freed
directly after usage. This commit changes this: The function that
allocated and assembled these strings now returns pointers to the '_'
and '.' delimiters and so that the caller can easily pick substrings
from it without needing to copy the string.

Avoiding allocations also fixes a memleak: One of the allocated strings
would leak upon a subsequent allocation failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:39:53 +02:00
Andreas Rheinhardt c1fab8637e avformat/webmdashenc: Fix segfault when no filename is given when live
by checking a bit earlier.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-07-26 16:22:24 +02:00
Andreas Rheinhardt b2c0b3774f avformat/webmdashenc: Simplify parsing strings
Don't use the functions for searching substrings when all one is
looking for is a char anyway. Given that there is already a standard
library function for "find last occurence of a char in a string" also
allows one to remove a custom loop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 06:41:50 +02:00
Andreas Rheinhardt 1e689518d5 avformat/webmdashenc: Don't segfault on invalid arguments
The current parsing process for adaptation_sets does not guarantee
every adaptation set to contain at least one stream, because the loop
exits immediately as soon as the end of the string has been reached,
without checking whether the currently active adaptation set group is
lacking a stream. This would lead to segfaults lateron as the rest of
the code presumed that every adaptation set contains a stream. This
commit fixes this by erroring out when the last adaptation set group
is incomplete.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 06:32:29 +02:00
Andreas Rheinhardt 9b61482627 avformat/webmdashenc: Remove possibility of infinite loop
The WebM DASH manifest muxer uses a loop to parse the adaptation_sets
string (which is given by the user and governs which AVStreams are
mapped to what adaptation set) and the very beginning of this loop is
"if (*p == ' ') continue;". This of course leads to an infinite loop if
the condition is true. It is true if e.g. the string begins with ' ' or
if there are more than one ' ' between different adaptation set groups.

To fix this, the parsing process has been modified to consume the space
if it is at a place where it can legitimately occur, i.e. when a new
adaptation set group is expected. The latter restriction implies that an
error is returned if a space exists where none is allowed to exist.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 06:29:53 +02:00
Andreas Rheinhardt 1030993db2 avformat/webmdashenc: Be more strict when parsing stream indices
The syntax of the adaptation_sets string by which the user determines
the mapping of AVStreams to adaptation sets is
"id=x,streams=a,b,c id=y,streams=d,e" (means: the streams with the
indices a, b and c belong to the adaptation set with id x). Yet there
was no check for whether these indices were actual numbers and if there
is a number whether it really extends to the next ',', ' ' or to the
end of the string or not. This commit adds a check for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 06:09:09 +02:00
Andreas Rheinhardt 325c901430 avformat/webmdashenc: Avoid allocation for parsing a number
In order to parse a number from a string, the WebM DASH manifest muxer
would duplicate (via heap-allocation) the part of the string that
contains the number, then read the number via atoi() and then free the
duplicate again. This has been replaced by simply using strtoll() (which
in contrast to atoi() has defined behaviour when the number is not
representable).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-05-23 06:05:16 +02:00
Andreas Rheinhardt 0c0a1d73c2 avformat/Makefile: Remove false dependencies of WebM and Matroska muxer
These muxers don't depend on the WebM Chunk or the WebM DASH Manifest
muxers.

Furthermore, remove some #if checks in webm_chunk.c and webmdashenc.c.
They are always true now that webm_chunk.c and webmdashenc.c are only
compiled when their corresponding muxers are enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:43:44 +02:00
Andreas Rheinhardt 8744f973ab avformat/webmdashenc: Remove unnecessary header
avio_internal.h has been included in this muxer since the beginning and
was never needed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-14 18:37:49 +02:00
Andreas Rheinhardt 1719c7f5db avformat/webmdashenc: Use AVCodecDescriptors for codec names
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-07 15:02:54 +02:00
Andreas Rheinhardt cbea58b2b3 avformat/webmdashenc: Check codec types
The WebM DASH Manifest muxer only supports VP8, VP9, Vorbis and Opus,
but there was no check for this. The codec type is used to get a pointer
to a string containing the codec name or NULL if it is not one of those
four codecs. Said pointer has then been used without further checks as
string for the %s conversion specifier in an avio_printf()) call which
is undefined behaviour.

This commit adds a check for the supported codec types.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-04-07 15:01:10 +02:00
Carl Eugen Hoyos 61dcaf5fb7 lavf, lavfi: Remove uses of sizeof(char).
The C standard requires sizeof(char) == 1.
2020-04-04 23:21:14 +02:00
Andreas Rheinhardt 418e468699 avformat/webmdashenc: Fix memleak upon realloc failure
The classical ptr = av_realloc(ptr, size).

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-26 21:33:51 +01:00
Andreas Rheinhardt 00d0934fce avformat/webmdashenc: Don't use custom option for bitexactness
The WebM DASH Manifest muxer can write manifests for live streams and
these contain an entry that depends on the time the manifest is written;
an AVOption to make the output reproducible has been added for tests.
But this is unnecessary, as there already is a method for reproducible
output: The AVFMT_FLAG_BITEXACT-flag of the AVFormatContext. Therefore
this commit removes the custom option.

Given that the description of said option contained "private option -
users should never set this" and that it was not documented in
muxers.texi, no deprecation period for this option seemed necessary.

The commands of the FATE-tests for this muxer have been changed to no
longer use this option.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-03-25 23:26:29 +01:00
Andreas Rheinhardt c467328f07 avformat/webmdashenc: Remove write_trailer
It doesn't do anything: All allocated blocks have already been freed in
write_header.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2020-03-15 12:15:24 -03:00
Michael Niedermayer b687b549aa avformat/webmdashenc: Check id in adaption_sets
Fixes: out of array access

Found-by: Wenxiang Qian
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-02-17 10:29:42 +01:00
Derek Buitenhuis a27c412795 webmdashenc: Fix memory leak
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2017-07-16 16:09:17 +01:00
Derek Buitenhuis ec07efa700 avformat/webmdashenc: Validate the 'streams' adaptation sets parameter
It should not be a value larger than the number of streams we have,
or it will cause invalid reads and/or SIGSEGV.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-20 18:07:32 +02:00
Derek Buitenhuis cbd3a68f3e avformat/webmdashenc: Require the 'adaptation_sets' option to be set
This seems to be non-optional, and if the muxer is run without it,
strlen() is run on NULL, causing a segfault.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-20 18:07:32 +02:00
Vignesh Venkatasubramanian 62c27fdba4 webm_dash_manifest: Add option to specify bandwidth
Add an option to webm_dash_manifest demuxer to specify a value for
"bandwidth" field in the DASH manifest. The value is then used by
the muxer. Fixes an existing FIXME in the code.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: James Zern <jzern@google.com>
2017-04-17 10:46:51 -07: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
Clément Bœsch 43ecec0f03 avformat: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:43:33 +01:00
AppChecker 8199908fdf fix: assigning instead of comparing
Signed-off-by: AppChecker <support.appc@cnpo.ru>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-10-27 12:11:38 +01:00
Ganesh Ajjanagadde b772847eb0 avformat/webmdashenc: fix uninitialized variable
Fixes -Wsometimes-uninitialized from
http://fate.ffmpeg.org/report.cgi?time=20150820031140&slot=arm64-darwin-clang-apple-5.1

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
Reviewed-by: "Ronald S. Bultje" <rsbultje@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-20 21:03:08 +02:00
Vignesh Venkatasubramanian b5508f74b9 lavf/webmdashenc: fix unchecked strftime
Fix unchecked strftime return value. This patch fixes Coverity
CID 1295086.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-15 00:56:43 +02:00
Vignesh Venkatasubramanian b410c69fb6 webmdashenc: Fix UTCTiming Element
Remove the direct profile from UTCTiming element. Per DASH spec,
direct profile value should be the time at which the request was
made to the server and not the time at which the manifest was
written. So ffmpeg cannot write this value. This patch removes
the direct profile and write the UTCTiming element with the http
profile only if a URL is passed as a parameter. Update the fate
test to reflect this change.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-28 03:39:07 +02:00
Vignesh Venkatasubramanian f82ce6aa88 webmdashenc: parameter'ize minimumUpdatePeriod
Some players do not support setting minimumUpdatePeriod to zero.
This patch adds a new parameter that will let the users set any
value to this field. Also updates the test and the documentation.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-22 11:41:03 +02:00
Vignesh Venkatasubramanian 4f287a3c50 webmdashenc: Add minimumUpdatePeriod
DASH spec requires the presence of either duration of the period
or the minimumUpdatePeriod element. This patch adds the
minimumUpdatePeriod element hardcoded with the value 0 as the
manifest will never be updated for WebM DASH Live streams. Also
updating the fate test reference file.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-22 01:43:37 +02:00
Vignesh Venkatasubramanian 30ba28fe8e webmdashenc: Fix potential memory leak
Fix potential memory leak in WebM DASH Muxer. This fixes coverity
scan CID 1295088.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-21 01:12:27 +02:00
Vignesh Venkatasubramanian 1c37848f90 webmdashenc: Add better error handling
Return appropriate error codes and propagate the error codes from
helper functions to the outer calls. Also fix a potential leak in
call to av_realloc.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-17 04:48:29 +02:00
Vignesh Venkatasubramanian 30e2f87d2e webdashenc: replace unchecked av_malloc with stack allocation
Replace an unchecked av_malloc call with stack allocation as the size
is always a constant.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-14 20:48:30 +02:00
Vignesh Venkatasubramanian d6bb82387c webmdashenc: Fix fate in MSVC
MSVC does not support the %F and %T format specifiers in strftime.
Replace that with the expanded version. This fixes the broken fate
tests in MSVC (webm-dash-manifest-*).

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-07 21:29:20 +02:00
Vignesh Venkatasubramanian 26f2e2f3f7 webmdashenc: Support for live stream manifests
This patch adds support for creating DASH manifests for WebM Live
Streams. It also updates the documentation and adds a fate test to
verify the behavior of the new muxer flag.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-05 02:08:55 +02:00
Michael Niedermayer 5b911f1d5b avformat/webmdashenc: use AVERROR(ENOMEM) for memory allocation failures
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-04-01 18:11:48 +02:00
Vignesh Venkatasubramanian 597d826123 lavf/webmdashenc: Representation IDs should be unique.
According to the DASH spec, Representation IDs should be unique
across all adaptation sets. Fixing that and updating the fate
reference file to reflect this change.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-11-12 00:21:37 +01:00
Vignesh Venkatasubramanian a9b10e1510 lavf/webm_dash: some fields should go into Representation
Width, Height and Sample Rate should be in the AdaptationSet tag
only if all the contained representations have the same width,
height and sampling rate. Otherwise they should go into the
Representation tag. This patch adds this functionality and a fate
test for the same.

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-02 19:20:05 +02:00
Carl Eugen Hoyos 7c3ba1b83a Add a closing LF to Webm-manifest files.
Fixes fate-webm-dash-manifest on AIX.

Reviewed-by: Nicolas George
2014-09-16 17:24:56 +02:00