Commit Graph

24495 Commits

Author SHA1 Message Date
Andreas Rheinhardt
33e6d57f01 avcodec/mpegaudiodata: Unavpriv mpa_bitrate and mpa_frequency tabs
These arrays have a size of 180 resp. six bytes. This does not
make it worthwhile to export them due to the overhead this occurs;
for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn,
8B .got, 4B hash + twice the size of the name (here 20+23B).
Therefore these symbols are unavprived and duplicated for shared
builds.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:50 +01:00
Andreas Rheinhardt
49bf94536f avcodec/mpeg4audio: Unavpriv and deduplicate mpeg4audio_sample_rates
avpriv_mpeg4audio_sample_rates has a size of 64B and it is currently
avpriv; a clone of it exists in aacenctab.h and from there it is inlined
in aacenc.c (which also uses the avpriv version) and in the FLV muxer.
This means that despite it being avpriv both libavformat as well as
libavcodec have copies already.

This situation is clearly suboptimal. Given the overhead of exporting
symbols (for x64 Elf/Linux/GNU: 2x2B version, 2x24B .dynsym, 24B .rela.dyn,
8B .got, 4B hash + twice the size of the name (here 31B)) the object is
unavprived, i.e. duplicated into libavformat when creating a shared
build; but the duplicates in the AAC encoder and FLV muxer are removed.

This involves splitting of the sample rate table into a file of its own;
this allowed to break some spurious dependencies (e.g. both the AAC
encoder as well as the Matroska demuxer actually don't need the
mpeg4audio_get_config stuff).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:50 +01:00
Andreas Rheinhardt
1d333c1547 avcodec/jpegtables: Unavpriv MJPEG-tables
There are seven MJPEG-tables, five small (1x12, 4x17) and two
not small (2x162). These are all avpriv, despite this not being
worthwhile due to the overhead of exporting a symbol: The total
overhead for each symbol consists of two entries in .dynsym (24B each),
one entry in the importing library's .rela.dyn (24B) and one in .got
(8B) as well as 2x2B for symbol versions and 4B for symbol hashes
in the exporting library; in addition to that, the name of the symbol
is included in both exporting and importing libraries, using 2x210 bytes
in this case.
(The above numbers are for a x64 Elf/Linux/GNU system. Other platforms
will give different numbers.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:50 +01:00
Andreas Rheinhardt
3afb41655e avcodec/dca: Unavpriv dca_sample_rates
Said table is 64 bytes long and exported so that it can be used both
in libavcodec and libavformat. This commit stops doing so and instead
duplicates it for shared builds, because the overhead of exporting the
symbol is bigger than 64 bytes. It consists of the length of the name of
the symbol (2x24 bytes), two entries in .dynsym (2x24 bytes), two
entries for symbol version (2x2 bytes), one hash value in the exporting
library (4 bytes) in addition to one entry in the importing library's
.got and .rela.dyn (8 + 24 bytes).
(The above numbers are for a Linux/GNU/Elf system; the numbers for other
platforms may be different.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:49 +01:00
Andreas Rheinhardt
d7a75d2163 avcodec/ac3tab: Unavpriv ac3_channel_layout_tab
It is small (16 B) and therefore the overhead of exporting it more
than outweighs the size savings from not having duplicated symbols:
When the symbol is no longer avpriv, one saves twice the size of
the string containing the symbols name (2x30 byte), two entries
in .dynsym (24 bytes each on x64), one entry in the importing libraries
.got and .rela.dyn (8 + 24 bytes on x64) and two entries for the
symbol version (2 bytes each) and one hash value in the exporting
library (4 bytes).
(The exact numbers are of course different for other platforms
(e.g. when using dlls), but given that the strings saved alone
more than outweigh the array size it can be presumed that this
is beneficial for all platforms.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:49 +01:00
Andreas Rheinhardt
3d53cefb49 avcodec/raw: Reduce number of avpriv symbols
libavcodec currently exports four avpriv symbols that deal with
PixelFormatTags: avpriv_get_raw_pix_fmt_tags, avpriv_find_pix_fmt,
avpriv_pix_fmt_bps_avi and avpriv_pix_fmt_bps_mov. The latter two are
lists of PixelFormatTags, the former returns such a list and the second
searches a list for a pixel format that matches a given fourcc; only
one of the aforementioned three lists is ever searched.

Yet for avpriv_pix_fmt_bps_avi, avpriv_pix_fmt_bps_mov and
avpriv_find_pix_fmt the overhead of exporting these functions actually
exceeds the size of said objects (at least for ELF; the following numbers
are for x64 Ubuntu 20.10):
The code size of avpriv_find_pix_fmt is small (GCC 10.2 37B, Clang 11 41B),
yet exporting it adds a 20B string for the name alone to the exporting
as well as to each importing library; there is more: Four bytes in the
exporting libraries .gnu.hash; two bytes each for the exporting as well
as each importing libraries .gnu.version; 24B in the exporting as well
as each importing libraries .dynsym; 16B+24B for an entry in .plt as
well as the accompanying relocation entry in .rela.plt for each
importing library.

The overhead for the lists is similar: The strings are 23B and the
.plt+.rela.plt pair is replaced by 8B+24B for an entry in .got and
a relocation entry in .rela.dyn. These lists have a size of 80 resp.
72 bytes.

Yet for ff_raw_pix_fmt_tags, exporting it is advantageous compared to
duplicating it into libavformat and potentially libavdevice. Therefore
this commit replaces all library uses of the four symbols with a single
function that is exported for shared builds. It has an enum parameter
to choose the desired list besides the parameter for the fourcc. New
lists can be supported with new enum values.

Unfortunately, avpriv_get_raw_pix_fmt_tags could not be removed, as the
fourcc2pixfmt tool uses the table of raw pix fmts. No other user of this
function remains.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 13:16:49 +01:00
Andreas Rheinhardt
20b0b2be6c avformat/tests/imf: Don't use uninitialized value
Reviewed-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 10:35:19 +01:00
Pierre-Anthony Lemieux
4c03928f4d
avformat/imf: Fix error handling in set_context_streams_from_tracks()
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2022-01-04 19:07:32 +10:00
Andreas Rheinhardt
029598bd4a avformat/movenc: Use dedicated pointer for access to MOVTrack
Improves readability and slightly decreases codesize.
While just at it, also remove a check whether the packet list is
nonempty before freeing it, as freeing an empty list is fine
and basically a no-op.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 05:13:54 +01:00
Andreas Rheinhardt
41457e536c avformat/mux, mxfenc: Don't use sizeof(AVPacket)
This removes one of the last usages of sizeof(AVPacket)
in the generic muxing code.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 05:09:33 +01:00
Andreas Rheinhardt
20b0d24c2f Makefile: Redo duplicating object files in shared builds
In case of shared builds, some object files containing tables
are currently duplicated into other libraries: log2_tab.c,
golomb.c, reverse.c. The check for whether this is duplicated
is simply whether CONFIG_SHARED is true. Yet this is crude:
E.g. libavdevice includes reverse.c for shared builds, but only
needs it for the decklink input device, which given that decklink
is not enabled by default will be unused in most libavdevice.so.

This commit changes this by making it more explicit about what
to duplicate from other libraries. To do this, two new Makefile
variables were added: SHLIBOBJS and STLIBOBJS. SHLIBOBJS contains
the objects that are duplicated from other libraries in case of
shared builds; STLIBOBJS contains stuff that a library has to
provide for other libraries in case of static builds. These new
variables provide a way to enable/disable with a finer granularity
than just whether shared builds are enabled or not. E.g. lavd's
Makefile now contains: SHLIBOBJS-$(CONFIG_DECKLINK_INDEV) += reverse.o

Another example is provided by the golomb tables. These are provided
by lavc for static builds, even if one uses a build configuration
that makes only lavf use them. Therefore lavc's Makefile contains
STLIBOBJS-$(CONFIG_MXF_MUXER) += golomb.o, whereas lavf's Makefile
has a corresponding SHLIBOBJS-$(CONFIG_MXF_MUXER) += golomb_tab.o.
E.g. in case the MXF muxer is the only component needing these tables
only libavformat.so will contain them for shared builds; currently
libavcodec.so does so, too.
(There is currently a CONFIG_EXTRA group for golomb. But actually
one would need two groups (golomb_avcodec and golomb_avformat) in
order to know when and where to include these tables. Therefore
this commit uses a Makefile-based approach for this and stops
using these groups for the users in libavformat.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 05:01:04 +01:00
Andreas Rheinhardt
3485e79f07 avformat/(aiff|flac|mov|mp3|tta)enc: Don't create unnecessary references
The packet given to muxers is not used afterwards; it is always
unreferenced by libavformat. Ergo muxers are allowed to keep
the references in the packets and e.g. move the ownership to
a packet list. This is what this commit does.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 04:58:57 +01:00
quietvoid
f0fb005f59 avformat/movenc: Refactor mov_write_dvcc_dvvc_tag to use ff_isom_put_dvcc_dvvc
Improves code legibility by not using bit shifts.
Also avoids duplicating the dvcC/dvvC ISOM box writing code.

Signed-off-by: quietvoid <tcChlisop0@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 04:29:36 +01:00
quietvoid
9906f9ae3b avformat/mov: Refactor mov_read_dvcc_dvvc to use ff_isom_parse_dvcc_dvvc
To avoid duplicating code. The implementation in dovi_isom is identical.

Signed-off-by: quietvoid <tcChlisop0@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 04:29:36 +01:00
quietvoid
05c07943b0 avformat/matroska{dec, enc}: Parse BlockAdditionMapping elements
Adds handling of dvcC/dvvC block addition mappings.

The parsing creates AVDOVIDecoderConfigurationRecord side data.
The configuration block is written when muxing into Matroska,
if DOVI side data is present for the track.

Most of the Matroska element parsing is based on Plex's FFmpeg source code.

Signed-off-by: quietvoid <tcChlisop0@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 04:29:36 +01:00
quietvoid
5c16e46374 avformat/dovi_isom: Implement Dolby Vision configuration parsing/writing
Both parse/write implementations are based on mov/movenc.

This only adds support for the "Dolby Vision configuration box".
Other configuration boxes, such as
"Dolby Vision enhancement layer configuration box" are not supported.

The new functions will be used to implement parsing/writing the DOVI config
for Matroska, as well as to refactor both mov/movenc to use dovi_isom functions.

Signed-off-by: quietvoid <tcChlisop0@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-01-04 04:29:36 +01:00
Marton Balint
573b6b8a60 avformat/utils: propagate return value of ff_format_io_close in ff_format_shift_data
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-01-03 22:54:12 +01:00
Marton Balint
26d6c81dc6 avformat/segafilmenc: use ff_format_shift_data for shifting
Signed-off-by: Marton Balint <cus@passwd.hu>
2022-01-03 22:54:12 +01:00
Marton Balint
10a0a8ca83 avformat/flvenc: use ff_format_shift_data for data shifting
add_keyframe_index seems to generate a corrupted index even before this change.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-01-03 22:54:12 +01:00
Marton Balint
76e062322c avformat/movenc: factorize data shifting
And move data shift function from movenc to utils.

Signed-off-by: Marton Balint <cus@passwd.hu>
2022-01-03 22:54:12 +01:00
Michael Niedermayer
4be85c9331 lib*/version.h: Bump Versions after release/5.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-03 22:10:46 +01:00
Michael Niedermayer
f3964a59e1 lib*/version.h: Bump Versions before release/5.0 branch
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-01-03 22:08:31 +01:00
Anton Khirnov
70f318e6b6 lavf/imfdec: mark as experimental
People have expressed concerns about its safety, so prevent it from
being auto-selected without explicit user indication.
2022-01-03 20:38:35 +01:00
Anton Khirnov
be97d2a825 lavf: add a flag for experimental (de)muxers 2022-01-03 20:38:35 +01:00
James Almer
0154f142f3 avformat/Makefile: add imf.h to SKIPHEADERS
Should fix "make checkheaders".

Signed-off-by: James Almer <jamrial@gmail.com>
2021-12-31 19:22:47 -03:00
erankor
6348be83e8 http: make caching of redirect url optional
added "cache_redirect" option to http.
when enabled, requests issued after seek will use the latest redirected
url.
when disabled, each call to seek will revert to the original url that
was sent to http_open.

currently, the default remains 'enabled', until the next major
libavformat bump, where it will change to 'disabled'.
2021-12-31 14:27:00 -05:00
Gyan Doshi
9cfc7a2440 avformat/mov: add option max_stts_delta
Very high stts sample deltas may occasionally be intended but usually
they are written in error or used to store a negative value for dts correction
when treated as signed 32-bit integers.

This option lets the user set an upper limit, beyond which the delta is clamped to 1.
Values greater than the limit if negative when cast to int32 are used to adjust onward dts.

Unit is the track time scale. Default is UINT_MAX - 48000*10 which
allows upto a 10 second dts correction for 48 kHz audio streams while
accommodating 99.9% of uint32 range.

Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-31 14:44:20 +05:30
Pierre-Anthony Lemieux
6b7e4de0db
avformat/imf: Tests
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-12-31 17:26:01 +10:00
Pierre-Anthony Lemieux
73f6cce936
avformat/imf: Demuxer
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-12-31 17:26:01 +10:00
Limin Wang
d590e211a2 avformat: add bitpacked demuxer
Allows user can playback bitpacked pixel format directly:
ffplay -video_size 1280x720 -pixel_format yuv422p10 test.bitpacked
ffplay -f bitpacked -video_size 1280x720 -pixel_format uyvy422 test.yuv

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-31 07:08:43 +08:00
Michael Niedermayer
c217ca7718 avformat/flvdec: timestamps cannot use the full int64 range
We do not support this as we multiply by 1000
Fixes: signed integer overflow: -45318575073853696 * 1000 cannot be represented in type 'long'
Fixes: 42804/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-4630325425209344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-30 22:20:14 +01:00
sfan5
65197e9c98 lavf/tls_mbedtls: fix handling of tls_verify=0
If ca_file was set, setting tls_verify=0 would not actually disable
verification.
2021-12-30 19:32:34 +02:00
Nicolas Gaullier
dd7c0bc4f9 avformat/mxfenc: fix DNxHD GC element_type
The values for the essence element type were updated in the spec
from 0x05/0x06 (ST2019-4 2008) to 0x0C/0x0D (ST2019-4 2009).

Fixes ticket #6380.

Thanks-to: Philip de Nier <philip.denier@bbc.co.uk>
Thanks-to: Matthieu Bouron <matthieu.bouron@gmail.com>

Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-27 00:39:35 +01:00
Nicolas Gaullier
1cbeac0c2f avformat/mxfenc: fix DNxHD GC container_ul
Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Reviewed-by: Matthieu Bouron <matthieu.bouron@gmail.com>
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-27 00:38:52 +01: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
Gerard Sole
18ad360648 libavformat: add side_data copy in concat demuxer
Adds support for concat demuxer to copy the side data information
from the input file to the resulting file. It will behave like the
metadata copy, where the metadata of the first file is kept in the
the output file.

Extract the current code that already performs the stream side_data
copy into a separate method and reuse the method in the concat demuxer.

Signed-off-by: Gerard Sole <g.sole.ca@gmail.com>
2021-12-22 12:05:41 +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
Andreas Rheinhardt
16b1df7541 avformat/wvenc: Make init function out of write_header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-20 14:29:01 +01:00
Andreas Rheinhardt
ba27e248cf avformat/crcenc: Make init function out of write_header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-20 14:29:01 +01:00
Andreas Rheinhardt
631e31773b avformat/sdp: Fix use of uninitialised value
Fixes Coverity ticket #1495831.
Regression since fe31708eaa.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-20 02:37:08 +01:00
Andreas Rheinhardt
bb69b734c7 avformat/mxfenc: Avoid allocation for timecode track
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-19 01:01:47 +01:00
Andreas Rheinhardt
25ddf888d8 avformat/mxfenc: Use smaller types to make struct smaller
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-19 00:49:33 +01:00
Andreas Rheinhardt
69a45b8a49 avcodec/Makefile: Remove superfluous avformat->DNXHD dependencies
There is no mxfenc dependency any more since commit
b9a26b9d55.
Also remove a dnxhddata.h inclusion in mxfenc that was forgotten
in the very same commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-19 00:46:16 +01:00
Pierre-Anthony Lemieux
c8b5f2848d
avformat/aviobuf: ffio_copy_url_options
Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-12-19 00:35:24 +10:00
Anton Khirnov
fe31708eaa lavf/sdp: add more thorough error handling
Return error codes when constructing a stream config fails, rather than
just disregarding the failure and continuing.
Propagate the error codes from av_sdp_create().
2021-12-17 10:23:07 +01:00
Anton Khirnov
b0518f9977 lavf/sdp: reindent switch() according to our conventions 2021-12-17 10:22:46 +01:00
Anton Khirnov
230646751d lavf/sdp: add const qualifiers where appropriate
Declares that these structs are read-only for this code.
2021-12-17 10:22:41 +01:00
Michael Niedermayer
dd94912479 avformat/4xm: Check for duplicate track ids
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 22:31:13 +01:00
Michael Niedermayer
0dcd95ef8a avformat/4xm: Consider max_streams on reallocating tracks array
Fixes: OOM
Fixes: 41595/clusterfuzz-testcase-minimized-ffmpeg_dem_FOURXM_fuzzer-6355979363549184

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 22:31:13 +01:00
Michael Niedermayer
e22ec484aa avformat/cinedec: Avoid repeatedly allocating packets beyond the input
Fixes: Timeout
Fixes: 41025/clusterfuzz-testcase-minimized-ffmpeg_dem_CINE_fuzzer-5540848285122560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 22:31:13 +01:00
Michael Niedermayer
562021e2fd avformat/mov: Check next offset in mov_read_dref()
Fixes: signed integer overflow: 9223372036200463215 + 1109914409 cannot be represented in type 'long'
Fixes: 41480/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6553086177443840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 22:31:13 +01:00
Michael Niedermayer
bf1e93bdc9 avformat/vivo: Favor setting fps from explicit fractions
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 22:31:13 +01:00
Michael Niedermayer
7b24615565 avformat/vivo: Do not use the general expression evaluator for parsing a floating point value
Fixes: Timeout
Fixes: 41564/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVO_fuzzer-6309014024093696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-16 22:31:13 +01: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
Steven Liu
3f46ffe956 avformat/aviobuf: fix double free by return early on error
Because the s->buffer has been freed by av_freep in avio_closep.
It should not av_freep the buffer in label fail after avio_closep.
Then just move the av_freep before avio_closep and remove the label fail.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Reviewed-by: Zhao Zhili <zhilizhao@tencent.com>
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2021-12-16 11:02:57 +08:00
Andreas Rheinhardt
38e5ca9310 avformat/moflex: Don't use uninitialized timebase for data stream
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-16 03:08:10 +01:00
Andreas Rheinhardt
0a25abdacd avformat/moflex: Free AVPackets via av_packet_free() on error
(This is not a leak as long as av_free() completely frees blank
packets.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-16 03:06:52 +01:00
Andreas Rheinhardt
97e26937b4 avformat/demux: Remove redundant prevention against infinite loop
This piece of code has been added as FFmpeg's answer to
infinite loops in try_decode_frame() in commit
6072a19b4f. There is no loop
around try_decode_frame() any more, so this code can be removed.

This code is only triggered in case a) the codec parameter could
not be determined, b) the decode delay could not be guessed or
c) no packet was ever encountered and the encoder has the
AV_CODEC_CAP_CHANNEL_CONF. In these cases the new code will
no longer emit a "decoding for stream %d failed" message, which is
prima facie false. In case a) an additional "Could not find codec
parameters" message is (and will be) emitted. No warning will be
emitted any more in case b) (this happens e.g. with some
h264-conformance FATE-files).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-16 02:37:26 +01:00
Andreas Rheinhardt
52a4d44044 avformat/demux: Remove fake-loop
When flushing, try_decode_frame() itself loops until the desired
properties have been found or the decoder is drained.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-16 02:37:25 +01:00
Limin Wang
2f28f6c4b9 avformat/rtpdec_rfc4175: cosmetic changes
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-14 22:36:40 +08:00
Steven Liu
6cf55b9da2 avformat/hlsenc: deprecate hls_ts_options option
Because the hls_ts_options will be misunderstand by user,
and then user can use hls_segment_options instead of hls_ts_options.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2021-12-13 18:45:37 +08:00
Steven Liu
38fbe6a34c avformat/hlsenc: add hls_segment_options correct the segment options name
Because the hls_ts_options will be misunderstand by user that only can
be used in mpegts segments option. So add this option for segments.

Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
2021-12-13 18:45:33 +08:00
Marton Balint
466441a0d2 avformat/img2enc: do not ignore IO errors
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-12 00:32:20 +01:00
Marton Balint
64834bb86a avformat: introduce AVFormatContext io_close2 which returns an int
Otherwise there is no way to detect an error returned by avio_close() because
ff_format_io_close cannot get the return value.

Checking the return value of the close function is important in order to check
if all data was successfully written and the underlying close() operation was
successful.

It can also be useful even for read mode because it can return any pending
AVIOContext error, so the user don't have to manually check AVIOContext->error.

In order to still support if the user overrides io_close, the generic code only
uses io_close2 if io_close is either NULL or the default io_close callback.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-12 00:32:20 +01:00
Marton Balint
8a40cfa4da avformat/aviobuf: return stored AVIO context error on avio_close
Otherwise IO errors at avio_flush() before closing may be lost.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-12 00:32:20 +01:00
Marton Balint
722d28db12 avformat/file: use proper return value in file_close
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-12-12 00:32:20 +01:00
Michael Niedermayer
4f44a218e5 avformat/mxfdec: Check for duplicate mxf_read_index_entry_array()
Fixes: memleak
Fixes: 41596/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-6439060204290048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-09 13:40:54 +01:00
Michael Niedermayer
a4af92d7cb avformat/mxfdec: Check component_depth in mxf_get_color_range()
Fixes: shift exponent 4294967163 is too large for 32-bit type 'int'
Fixes: 41449/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6183636217495552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-09 13:12:45 +01:00
Andreas Rheinhardt
408b974796 avformat/utils: Add const where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-09 11:32:13 +01:00
Andreas Rheinhardt
a33e0ed11e avformat/utils: Fix wrong indentation
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-09 11:32:13 +01:00
Andreas Rheinhardt
17a93fd377 avformat/mov: Simplify data->hex conversion
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 14:17:39 +01:00
Andreas Rheinhardt
d203f6b4b3 avformat/md5proto: Simplify data->hex conversion
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 14:15:53 +01:00
Andreas Rheinhardt
72745beb44 avformat/aadec: Use smaller scope for variables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 14:12:42 +01:00
Andreas Rheinhardt
e5ba554edf avformat/aadec: Simplify data->hex conversion
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 14:11:14 +01:00
Andreas Rheinhardt
d27b97b043 avformat/aadec: Simplify deriving file key
Don't use different src and dst in av_tea_crypt(); use in-place
modifications instead. Also let av_tea_crypt() encrypt all three
blocks in one call.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 13:55:07 +01:00
Andreas Rheinhardt
c9b3099210 avformat/aadec: Don't unnecessarily reinitialize AVTEA context
We use ECB, not CBC mode here, so one does not need to reinitialize
the context; for the same reason, one can also just let av_tea_crypt()
loop over the blocks, avoiding a loop here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 13:47:04 +01:00
Andreas Rheinhardt
a0900a318a avformat/aadec: Avoid copying data around
Up until now, the packets have been read in blocks of at most
eight bytes at a time; then these blocks have been decrypted
and copied into a buffer on the stack (that was double the size
needed...). From there they have been copied to the dst packet.

This commit changes this: The data is read in one go; and
the decryption avoids temporary buffers, too, by making
use of the fact that src and dst of av_tea_crypt() can coincide.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 13:45:08 +01:00
Andreas Rheinhardt
0a76f8217e avformat/aadec: Don't use the same loop counter in inner and outer loop
Due to this bush.aa (from the FATE suite) exported garbage metadata
with key "_040930".

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 13:30:18 +01:00
Andreas Rheinhardt
e38eaf4749 avformat/utils: Make ff_data_to_hex() zero-terminate the string
Most callers want it that way anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-08 00:42:48 +01:00
Limin Wang
f1c8c25832 avformat/rtsp: fix the error code from ffurl_read_complete()
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:48:07 +08:00
Limin Wang
6d42af02f5 avformat/rtsp: add error code handling for ff_rtsp_skip_packet()
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:33:17 +08:00
Limin Wang
f210766a55 avformat/rtsp: free the alloc memory if failed
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:33:17 +08:00
Limin Wang
130e4c6f4c avformat/rtsp: remove redundant assignment
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-07 20:33:17 +08:00
Gyan Doshi
a454dfacd5 avformat/concatf: ignore trailing whitespaces
The concatf protocol returns an opaque error on open if
concatf list file contains trailing newlines.

Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro>
Reviewed-by: James Almer <jamrial@gmail.com>
2021-12-07 17:50:55 +05:30
Anton Khirnov
6ebaccf327 lavf/protocols: avoid discarding const in avio_enum_protocols()
Instead of storing the protocol pointer in the opaque iteration state,
store just the index of the next protocol, similarly to how
ff_urlcontext_child_class_iterate() works.
2021-12-07 11:16:14 +01:00
Anton Khirnov
c0e46ad9a9 lavf/img2enc: avoid a useless copy of the url
img2enc keeps a private (and possibly truncated) copy of the url that is
never modified. Just use AVFormatContext.url instead.
2021-12-07 11:16:14 +01:00
Anton Khirnov
7e29e0278f lavf/ftp: check for truncation in snprintf
Silences e.g. the following warning in gcc 10:
src/libavformat/ftp.c: In function ‘ftp_move’:
src/libavformat/ftp.c:1122:46: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 4091 [-Wformat-truncation=]
 1122 |     snprintf(command, sizeof(command), "RNTO %s\r\n", path);
      |                                              ^~       ~~~~
src/libavformat/ftp.c:1122:5: note: ‘snprintf’ output between 8 and 4103 bytes into a destination of size 4096
 1122 |     snprintf(command, sizeof(command), "RNTO %s\r\n", path);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-12-07 11:16:14 +01:00
Michael Niedermayer
b5ba74053c avformat/mov: Disallow duplicate smdm
Fixes: memleak
Fixes: 39879/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5327819907923968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-06 14:25:55 +01:00
Michael Niedermayer
59b4e7cbd8 avformat/mov: Check for EOF in mov_read_glbl()
Fixes: Infinite loop
Fixes: 41351/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5433895854669824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-12-06 14:25:55 +01:00
Andreas Rheinhardt
228b25ad9b avformat/smoothstreamingenc: Move buffers to the end of structs
This reduces codesize because the offsets of commonly used elements
are now smaller and thus need less bytes to encode in ptr+offset
addressing modes (with GCC 11.2 on x64: 0x1b8b -> 0x1a7b).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Andreas Rheinhardt
847d199138 avformat/takdec: Simplify data->hex conversion
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-05 13:27:38 +01:00
Marvin Scholz
c6f4e10111 avformat: do not use AVIO_FLAG_* with avio_alloc_context
The documentation states that here 0 should be used for read-only and
1 for a writable buffer. AVIO_FLAG_WRITE however is 2, while it works
due to the way the flag is handled internally, it is still wrong
according to the documentation.

Additionally it makes it seem as if the AVIO_FLAG_* values could be used
here, which is actually not true, as when AVIO_FLAG_READ would be used
here it would create a writable buffer as AVIO_FLAG_READ is defined as 1.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2021-12-04 14:06:30 +01:00
Limin Wang
d782c746a0 avformat/rtspdec: get rid of the hardcoded max size for sdp
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-04 08:26:30 +08:00
Limin Wang
98054e4f01 avformat/rtsp: load the sdp file with avio_read_to_bprint()
this allows getting rid of the hardcoded max size of SDP.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-04 08:26:30 +08:00
Limin Wang
3c74ffb01a avformat/aviobuf: check if read_packet() exist before read_packet_wrapper()
without it, read_packet_wrapper() will return AVERROR(EINVAL) and avio_read
will be failed.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-12-04 08:26:30 +08:00
Andreas Rheinhardt
a4798a5d51 all: Use av_memdup() where appropriate
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:07:02 +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
Zane van Iperen
12f8293c02
avformat/scd: add demuxer
Adds demuxer for Square Enux SCD files.

Based off [1] and personal investigation.

This has only been tested against Drakengard 3 (PS3) *_SCD.XXX files
(big-endian). As it is highly likely that FFXIV (PC) files are little-endian,
this demuxer is marked as experimental until this can be confirmed.

[1]: http://ffxivexplorer.fragmenterworks.com/research/scd%20files.txt

Reviewed-by: Peter Ross <pross@xvid.org>
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-12-02 01:41:55 +10:00
Andreas Rheinhardt
8a18db3ec6 avformat/matroskaenc: Sort cues entries by pts
Currently they are ordered as-written (i.e. by increasing position);
in case av_interleaved_write_frame() is used, this is (mostly)
the same as ordered by increasing dts.
Yet the Matroska specification strongly recommends (SHOULD) that
the CuePoints be sorted by CueTime. mkvalidator warns when they are
not. Therefore this commit sorts them accordingly.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:42:18 +01:00
Ryoji Gyoda
d9f07a506d avformat/fifo: avoid repeated scaling of timestamps on failure and recovery
If fifo_thread_recover() succeeds immediately after
fifo_thread_dispatch_message() fails, the dts of the packet is scaled
twice, causing cur_dts to be abnormally large and "Application provided
invalid, non monotonically increasing dts to muxer in stream" to occur
repeatedly.

Steps to reproduce:
1. ffmpeg -f lavfi -i testsrc -c:v libx264 -map 0:v -flags +global_header -f fifo -fifo_format flv -attempt_recovery 1 -recover_any_error 1 rtmp://example.com/livekey
2. set a breakpoint on fifo_thread_recover
3. force disconnect from the rtmp server
4. wait for break
5. reconnect to the rtmp server
6. resume execution of ffmpeg

Signed-off-by: Ryoji Gyoda <gy.cft4@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 22:20:20 +01:00
asilvestre
1c2dae153c avformat/flvenc: avoid 24bit timestamp truncation for FLV metadata
FLV AMF tags have a 24bit field for timestamps plus an 8bit for extended
timestamps.

All FLV AMF tags except when we write metadata handle this correctly
using the put_timestamp function.

Until now when writing metadata we were only using the first
24 bits and thus the timestamp value was wraping around 4 hours 40
minutes (16,800,000 ms, max 24 bit value 16,777,216) of playback.

This commit fixes this applying this same function put_timestamp
for the metadata FLV tag.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-29 21:30:09 +01:00
Michael Niedermayer
3a64a4c582 avformat/mov: Check channels for mov_parse_stsd_audio()
Fixes: signed integer overflow: -776522110086937600 * 16 cannot be represented in type 'long'
Fixes: 40563/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6644829447127040

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-29 17:15:07 +01:00
Alex Xu (Hello71)
6fdd7fe0b8 avformat/img2dec: probe JFIF/Exif header
Due to reasons, mpv doesn't pass filename when probing. mpv also sets
default probescore threshold to 26. Since the current jpeg_probe
implementation returns 25 until EOI, it means that the whole image needs
to be probed to succeed. Worse, the whole image is not passed at once;
increasingly large buffers are tried before that. Adding it up together,
if many demuxers are enabled, moderately large JPEG files (few MB) can
take several seconds to open, despite taking less than 1 second to
actually decode.

Therefore, adjust the heuristic to be more optimistic if proper JFIF or
Exif segments are found. While not strictly required, the vast majority
of JPEG-ish files have one or the other or both.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-27 18:24:49 +01:00
Andreas Rheinhardt
2cddb2f7a8 avformat/mpegtsenc: Avoid allocation of AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt
a81e0ee21f avformat/movenc: Avoid allocation of AVPacket
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt
5e01fc8318 avformat/dashenc: Don't use stack packet
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Andreas Rheinhardt
a5ee166327 avformat/avformat: Add AVStream parameter to check_bitstream() sig
For most check_bitstream() functions this just avoids having
to dereference s->streams[pkt->stream_index] themselves; but for
meta-muxers it will allow to forward the packet to stream with
a different stream_index (belonging to a different AVFormatContext)
without using a spare packet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-27 12:55:41 +01:00
Limin Wang
7bf4c06809 avformat/rtp: add localaddr for network interface selection
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-27 11:21:17 +08:00
Michael Niedermayer
57adb26d05 avformat/avidec: Check read_odml_index() for failure
Fixes: Timeout
Fixes: 40950/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-6478873068437504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-26 21:31:06 +01:00
Andreas Rheinhardt
7c2b9067d0 avformat/cafdec: Avoid unnecessary avio_tell() calls
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-26 18:55:58 +01:00
Limin Wang
27c9300027 avformat/udp: remove local localaddr array
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-26 17:43:48 +08:00
Marton Balint
0b9dbfab48 avformat/mpegts: fix stream index in verbose log message
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-25 19:11:24 +01:00
Marton Balint
6f10f4a479 avformat/libsrt: add missing version check for snddropdelay
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-25 19:11:24 +01:00
James Almer
b46817d9c3 avformat/http: prevent truncation of sanitized_path
path1 and sanitized_path are both MAX_URL_SIZE bytes long, yet the latter is
copied from the former with the addition of one extra character.

Should fix a -Wformat-truncation warning.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-11-25 12:06:15 -03:00
Limin Wang
522f577d7e avformat/rtp: support RGB/BGR for rfc4175
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:07:19 +08:00
Limin Wang
7b55f95f71 avformat: suppport YUV 4:2:2 10-bit for rfc4175
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:07:15 +08:00
Limin Wang
4f5352d5fe avformat/rtpenc: adds partial support for the RFC 4175
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:04:35 +08:00
Limin Wang
05b0c66313 avformat/rtpdec_rfc4175: support for yuv420p format
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:04:35 +08:00
Limin Wang
3399bbab4d avformat/rtpdec_rfc4175: use rawvideo for uyvy422
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-25 15:04:35 +08:00
Gyan Doshi
203b0e3561 avformat/mov: make STTS duration unsigned int
As per 8.6.1.2.2 of ISO/IEC 14496-12:2015(E), STTS sample offsets
are to be always stored as uint32_t. So far, they have been signed ints
which led to desync in files with very large offsets.

The MOVStts struct was used to store CTTS offsets as well. These can be
negative in version 1. So a new struct MOVCtts was created and all
declarations for CTTS usage changed to MOVCtts.
2021-11-22 15:18:42 +05:30
Andreas Rheinhardt
53c8b16c19 avformat/utils: Remove duplicated AV_DISPOSITION_FOO <-> "foo" table
Instead reuse stream_options.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 20:35:07 +01:00
Andreas Rheinhardt
b9a26b9d55 avformat/mxfenc: Remove redundant DNXHD frame size checks
The actual frame_size is no longer used since commit
3d38e45eb85c7a2420cb48a9cd45625c28644b2e; and the check for
"< 0" is equivalent to the CID being valid. But this is already
checked by avpriv_dnxhd_get_interlaced() (and is actually already
ensured by mxf_dnxhd_codec_uls containing this CID).

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 20:32:19 +01:00
Andreas Rheinhardt
4586de94a7 avformat/mxfenc: Store locally whether DNXHD profile is interlaced
It is just a flag per supported CID. So there is no reason to use
an avpriv function for this purpose.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 20:26:27 +01:00
Andreas Rheinhardt
ce8f77a903 avformat/nullenc: Use ff_interleave_packet_passthrough()
It avoids the overhead of the packet list; furthermore, using
ff_interleave_packet_per_dts() is wrong for the null muxer anyway,
because said muxer accepts packets without timestamps, which
ff_interleave_packet_per_dts() can't handle.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 18:11:46 +01:00
Andreas Rheinhardt
52d13d54e1 avformat/mux: Avoid overhead of packet list in case of single streams
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 17:56:12 +01:00
Andreas Rheinhardt
c03e53aea7 avformat/mux: Store pointer to interleavement func in FFFormatContext
It avoids branches lateron and will allow to easily avoid the overhead
of the linked list currently in use in case there is only one stream.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-19 17:47:04 +01:00
Gijs Peskens
9b15f43cf8 avformat/librist: correctly initialize logging_settings
Correct solution as suggested by Marton Balint on ffmpeg-devel

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-18 20:40:24 +01:00
Andreas Rheinhardt
419d93c379 avformat/utils: Remove unused shorthand feature for auto-inserted BSF
Besides being unused it should not be used at all:
The order of options of bitstream filters is not guaranteed
to be stable at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 06:01:59 +01:00
Andreas Rheinhardt
5f4b0ace4b avformat/mxfenc: Make init function out of write_header
The MXF muxers only write the header after they have received
a packet; the actual write_header function does not write anything.
So make an init function out of it.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 06:01:33 +01:00
Andreas Rheinhardt
ea81c23c94 avformat/mxfenc: Remove redundant check
None of the muxers here has the AVFMT_NOSTREAMS flag set,
so it is checked generically that there are streams.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 05:59:32 +01:00
Andreas Rheinhardt
96fe44e2e8 avformat/hlsenc: Only write something if there is something to write
This is especially important in case avio_write() would be switched
to an unsigned type like size_t, then a potential error from avio_read()
(with negative return value) would no longer be handled gracefully by
avio_write().

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 04:53:07 +01:00
Andreas Rheinhardt
7596b6530d avformat/hlsenc: Remove nonsense memset
The memset here is both unnecessary (avio_read() ignores the previous
content of the destination buffer) as well as nonsense (for a char
buf[BUFSIZE] sizeof(buf) and sizeof(BUFSIZE) are not the same; the
latter is sizeof(int)).
Fixes Coverity issue #1465863.

Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-18 04:51:24 +01:00
Derek Buitenhuis
a35101aae3 avformat/http: Add short_seek_size option
In 45bfe8b838, short_seek_threshold was removed
from the public AVIO struct. Although this option was private and not intended
to be used by public API users, it was nonetheless, because it provided functionality
that could otherwise not be gained via public API.

This was especially important for networked I/O like HTTP, where the internal
size for lavf could be way to small depending on the specifics of a user's
usecase, such as reading interlavd media files from cloud storage.

Add an AVOption to make this functionality accessible to the HTTP client.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-11-17 14:32:17 +00:00
Anton Khirnov
a4c5d241ec lavf: add "disposition" AVOption to AVStream AVClass
Use it to remove custom disposition parsing code from ffmpeg.c
2021-11-16 10:51:32 +01:00
Anton Khirnov
b731fb5104 lavf: add public functions converting dispositions to/from strings 2021-11-16 10:51:32 +01:00
Anton Khirnov
ed75a08d36 lavf: add an AVClass to AVStream on next major bump
Also add a function to retrieve that class, analogously to
avformat_get_class().

This will be useful for adding an AVOption for dispositions.
2021-11-16 10:51:32 +01:00
Anton Khirnov
85433fb937 lavf: improve AV_DISPOSITION_* doxy
Also switch the values definition to the (1 << N) style, which is easier
to read.
2021-11-16 10:51:32 +01:00
Anton Khirnov
db932241ee */version.h: define FF_API macros unconditionally
There is no reason to wrap them in #ifndef guards, they should only be
defined here and nowhere else. The define guards just add the
possibility to accidentally use the same FF_API name in different
libraries.
2021-11-15 16:24:58 +01:00
Googleplex
23a1f11d02 avformat/concatdec: fix NEEDS_UNSAFE flag value
NEEDS_UNSAFE has the same value as NEEDS_FILE,
causing "duration not allowed if safe" error
while duration directive doesn't require unsafe mode.

Signed-off-by: Googleplex <yyoung2001@gmail.com>
2021-11-14 19:25:11 +01:00
Marton Balint
406ffd9b9b avformat/demux: allow total size of packets in raw_packet_buffer to reach probesize
Previously this was hardcoded to 2500000 bytes, so probing of the stream codecs
was always limited by this, and not probesize.

Also keep track of the actual size of packets in raw_packet_buffer and not the
remaining size for simplicity.

Fixes ticket #5860.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-14 18:30:57 +01:00
Michael Niedermayer
97c3053d59 avformat/dhav: Limit get_duration() iterations
Fixes: Timeout
Fixes: 39971/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5756969890217984
Fixes: 39977/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5327123053674496

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-14 17:51:35 +01:00
Andreas Rheinhardt
945b2dcc63 avformat/hls_sample_encryption: Fix precedence
Fixes Coverity ticket #1492869.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-09 15:44:17 +01:00
Andreas Rheinhardt
e5199eebb4 avformat/apngenc: Use UINT16_MAX instead of USHRT_MAX
The latter needn't be 16 bits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-09 15:40:36 +01:00
Andreas Rheinhardt
9139dc6140 avformat/matroskadec: Don't unnecessarily reduce aspect ratio
Fixes ticket #9497.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-07 15:38:03 +01:00
Alex Shumsky
1728127e8c avformat/mpegtsenc: do not include adaptation field in teletext TS packets
From ETSI EN 300 472 V1.3.1 (2003-05) Specification for conveying ITU-R System
B Teletext in DVB bitstreams:

4.1 Transport Stream (TS) packet format
The standard TS packet syntax and semantics are followed, noting the following
constraint:
- adaptation_field_control only the values "01" and "10" are permitted.

Some set top boxes (Motorola, Arris, Zyxel) refuse non-conforming packets.

Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-06 20:35:39 +01:00
Maksym Veremeyenko
a085418303 avformat/mpegtsenc: fix first_pcr initial update
Commit 6f36eb0da7 claim it fixes endless loop on
package generation if muxrate specified and copyts used. But actually it does
not work properly if -mpegts_copyts 1 is specified:

ffmpeg -y -copyts -i loewe.ts -c:v libx264 -x264opts nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 1000k  -c:a mp2 -f mpegts -mpegts_copyts 1 -muxrate 4500k -vframes 1000 test.ts

ffmpeg generate huge file until it reach zero-based pcr value equal to first dts.

Attached patch fixes it.

Reviewed-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-11-06 20:35:19 +01:00
Zhao Zhili
a0f9650046 avformat/dashenc: enabling streaming and hls_playlist for lhls
Try to make the feature easier to use, especially since the user
have enabled -strict experimental manually. The user shouldn't
be surprised that hls_playlist is enabled for lhls automatically,
so change the log level from warning to info for that.
2021-11-05 15:32:11 -03:00
Zhao Zhili
f6b90d5fef avformat/dashenc: enabling streaming automatically for ldash
There is a little chance that user specified contradicted options
like -streaming 0 -ldash 1, however, it's more likely that user
didn't know or forgot to enable streaming for ldash. So enabling
streaming automatically to make the feature easier to use, similar
like enable FF_MOV_FLAG_FRAGMENT/EMPTY_MOOV/DEFAULT_BASE_MOOF and
so on for FF_MOV_FLAG_CMAF.
2021-11-05 15:30:43 -03:00
Thilo Borgmann
c42d513ede lavf/mov: Change default to prefer TFDT time and allow for fallback to SIDX or TFDT 2021-11-05 16:22:04 +01:00
Zhao Zhili
82e3251dd2 avformat/isom_tags: fix 'ipcm' with samplesize equal to 16
Use PCM_S16 so the codec_id will be updated later according to
bits_per_coded_sample.
2021-11-03 17:45:02 +01:00
Limin Wang
f05559554c avformat/dashenc: Fix comparing double with 0
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-11-03 21:38:37 +08:00
Michael Niedermayer
2171f97cc8 avformat/aiffdec: "-1" -> AVERROR_INVALIDDATA
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-01 20:37:20 +01:00
Michael Niedermayer
905588df97 avformat/aiffdec: Use av_rescale() for bitrate
Fixes: integer overflow
Fixes: 40313/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-4814761406103552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-01 20:37:20 +01:00
Michael Niedermayer
93f7776921 avformat/aiffdec: sanity check block_align
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-01 20:37:20 +01:00
Michael Niedermayer
1b04836dff avformat/aiffdec: Check sample_rate
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-11-01 20:37:20 +01:00
Alex Shumsky
3925b826df avformat/demux: preserve AV_PKT_FLAG_CORRUPT in parse_packet
If original packet is corrupted, then parsed packet is probably corrupted too.
Let the application decide what to do.

Signed-off-by: Alex Shumsky <alexthreed@gmail.com>
2021-10-29 13:37:20 -03:00
Pekka Väänänen
947d0ce0ea avcodec/vqavideo: Decode 15-bit VQA3 files
Adds support for 15-bit VQA3 videos used in Westwood Studios' games.

Signed-off-by: Pekka Väänänen <pekka.vaananen@iki.fi>
2021-10-28 22:24:54 +02:00
Limin Wang
08c688e64d avformat/mpegts: Fix for the DOVI video stream descriptor
By <<Dolby Vision Streams Within the MPEG-2 Transport Stream Format v1.2>>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-28 09:25:31 +08:00
Limin Wang
c0edfb514b avformat/movenc: support dvwC box for Dolby Vision
By <<Dolby Vision Streams Within the ISO Base Media File Format Version 2.2>>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-28 09:25:31 +08:00
Limin Wang
3c3ef41593 avformat/mov: support dvwC box for Dolby Vision
By <<Dolby Vision Streams Within the ISO Base Media File Format Version 2.2>>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-28 09:25:31 +08:00
Jan Ekström
682bafdb12 avformat/avio{,buf}: introduce public AVIOContext::bytes_{read,written}
Such fields can be seen as generally useful in cases where the
API user is not implementing custom AVIO callbacks, but still would
like to know if data is being read or written out, such as in case
data is being read from input but no AVPacket has been received yet.
2021-10-24 13:04:39 +03:00
Jan Ekström
a5622ed16f avformat/avio{,buf}: deprecate AVIOContext::written
Originally added as a private entry in commit
3f75e5116b, but its grouping with
the comment noting its private state was missed during merging of
the field from Libav (most likely due to an already existing field
in between).
2021-10-24 13:04:39 +03:00
Jan Ekström
d39b58dc32 avformat/avio: privatize source of truth for AVIOContext::written
Looking at 3f75e5116b, the field
was supposed to be private, but during merging the field and the
group that had the comment about it got separated.

Thus, move the actual privately utilized state of this variable
into the private FFIOContext. Additionally, name the private field
somewhat better, so that it does not get confused with the amount
of bytes written out.
2021-10-24 13:04:26 +03:00
Derek Buitenhuis
7216458c96 avformat/mov: Do not hard fail if bit rate calculation overflows unless in explode mode
bit_rate is not a critical field, and we shouln't hard fail if we
can't caluclate it due to a large timebase - it needlessly breaks
valid files.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-10-21 14:34:36 +01:00
Derek Buitenhuis
a987b5c9ee avformat/mov: Use av_rescale when calculating bit rate
It is less susceptible to overflows.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2021-10-21 14:34:36 +01:00
Limin Wang
44fe572371 avformat/mpegtsenc: add AVSV format_identifier for AVS standard
Listing of Registered Identifiers:
https://smpte-ra.org/registered-mpeg-ts-ids

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-20 22:47:17 +08:00
Limin Wang
5779bd5b2a avformat/mpegts: add support for stream_type 0xd4, which is AVS3
GB/T 17975.1
Information technology-Generic coding of moving pictures and associated audio
information-Part 1:Systems

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-20 22:40:13 +08:00
Limin Wang
a59f8ea2a9 avformat/mpegts: add support for stream_type 0xd2, which is AVS2
GB/T 17975.1
Information technology-Generic coding of moving pictures and associated audio
information-Part 1:Systems

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-19 20:15:48 +08:00
Limin Wang
38052757f5 avformat: add raw avs3 muxer
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-19 20:15:47 +08:00
Martin Storsjö
ab79263419 seek: Fix crashes in ff_seek_frame_binary if built with latest Clang 14
Passing an uninitialized variable as argument to a function is
undefined behaviour (UB). The compiler can assume that UB does not
happen.

Hence, the compiler can assume that the variables are never
uninitialized when passed as argument, which means that the codepaths
that initializes them must be taken.

In ff_seek_frame_binary, this means that the compiler can assume
that the codepaths that initialize pos_min and pos_max are taken,
which means that the conditions "if (sti->index_entries)" and
"if (index >= 0)" can be optimized out.

Current Clang git versions (upcoming Clang 14) enabled an optimization
that does this, which broke the current version of this function
(which intentionally left the variables uninitialized, but silencing
warnings about being uninitialized). See [1] for discussion on
the matter.

[1] https://reviews.llvm.org/D105169#3069555

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-10-18 14:34:30 +03:00
Limin Wang
fb4f9a2043 avformat/rtpdec_rfc4175: add support for RANGE
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:54:03 +08:00
Limin Wang
bad48dfe9a avformat/rtpdec_rfc4175: add support for colorimetry
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:54:03 +08:00
Limin Wang
ca56fedab5 avformat/rtpdec_rfc4175: add support for TCS
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:54:03 +08:00
Limin Wang
b07437f956 avformat/rtpdec_rfc4175: add support for exactframerate
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-17 16:54:03 +08:00
Zane van Iperen
5d16660598
avformat/argo_asf: use title metadata when muxing
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-10-15 23:40:15 +10:00
Zane van Iperen
9a2b9aafba
avformat/argo_asf: pass name through as metadata
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-10-15 23:40:15 +10:00
Zane van Iperen
20fa838da5
avformat/argo_asf: cleanup and NULL-terminate name field in header
Preparation for metadata changes in the following patches. Saves
having to create an extra buffer.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2021-10-15 23:39:47 +10:00
Pekka Väänänen
4d52e36bd0 avformat/westwood_vqa: Store VQFL codebook chunks
High color 15-bit VQA3 video streams contain high level chunks with
only codebook updates that shouldn't be considered new frames. Now
the demuxer stores a reference to such VQFL chunks and returns them
later along with a VQFR chunk with full frame data.
2021-10-14 09:59:52 +02:00
Paul B Mahol
13141339c1 avformat/dhav: make duration extraction more robust 2021-10-13 12:14:39 +02:00
Paul B Mahol
6384175d8c avformat/dhav: check if timestamp matches when seeking 2021-10-13 12:14:39 +02:00
Nachiket Tarate
f14adb0516 libavformat/hls: correct indentation
Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2021-10-13 11:24:02 +08:00
Nachiket Tarate
ff958b3846 libavformat/hls: add support for decryption of HLS media segments encrypted using SAMPLE-AES encryption method
Apple HTTP Live Streaming Sample Encryption:

https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2021-10-13 11:23:53 +08:00
Nachiket Tarate
ef0f5d1be6 libavformat/mov: add support for 'cens', 'cbc1' and 'cbcs' encryption schemes specified in Common Encryption (CENC) standard
correct implementation of 'cenc' encryption scheme to support
decryption of partial cipher blocks at the end of subsamples

https://www.iso.org/standard/68042.html

Signed-off-by: Nachiket Tarate <nachiket.programmer@gmail.com>
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2021-10-13 11:23:44 +08:00
Limin Wang
78c30857b7 avformat/rtpdec_rfc4175: return the proper value
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-11 23:27:27 +08:00
Limin Wang
5724e8a664 avformat/rtpdec_rfc4175: Remove redundant initialization
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-11 23:27:21 +08:00
Limin Wang
f7823c9a3a avformat/rtpdec_rfc4175: use av_get_bits_per_pixel()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-11 23:27:15 +08:00
Limin Wang
6260c611c5 avformat/libsrt: add snddropdelay parameter for srt
Reviewed-by: "zhilizhao(赵志立)" <quinkblack@foxmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-11 18:43:47 +08:00
Gijs Peskens
5274f2f7f8 avformat/librist: replace deprecated functions
This gets rid of of rist_receiver_data_read, rist_receiver_data_block_free and rist_parse_address
these functions have been deprecated since librist release v0.2.1 and are replaced with functions
suffixed with 2.
I added a version macro check at the top of the file to ensure ffmpeg can still be compiled against
older versions.

Signed-off-by: Gijs Peskens <gijs@peskens.net>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-10-10 17:25:23 +02:00
Marton Balint
9420f7e095 avformat/mpegts: fix max_packet_size in mpegts payload parsing
The maximum allowed useful PES payload data was set to PES_packet_length, but
it is in fact smaller by the length of the PES header.

This changes how corrupt streams are packetized:
- If PES header length is bigger than PES_packet_length then the PES packet
  payload will be handled as an unbound packet
- PES packets with payload across multiple MPEGTS packets will always be
  splitted if with the next chunk of data the payload should exceed
  PES_packet_length, previously a PES_header_length amount of excess was
  allowed.

Fixes ticket #9355.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-10-10 16:54:15 +02:00
Marton Balint
aeea2ad0e4 avformat/mpegts: rename PES total_size to PES_packet_length
This renames PESContext->total_size to PESContext->PES_packet_length and keeps
it 0 for unbound packets, so its name and semantics will match the standard.

There should be no change in functionality.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-10-10 16:54:15 +02:00
Marton Balint
65cd43cff3 avformat/mpegts: delay allocation of PES buffer
This allows us to allocate the buffer in a single code path.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-10-10 16:54:15 +02:00
Marton Balint
ce8db0c253 avformat/mpegts: use named constants for stream_id types
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-10-10 16:54:15 +02:00
Limin Wang
b4d665bf69 avformat/libsrt: specify base of maxbw string to 10 instead of auto-detect
Make all options string conversion consistent.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-10 11:00:59 +08:00
Limin Wang
1161d8b4b3 avformat/libsrt: use strtoll/strtol for int64_t/int
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2021-10-10 11:00:59 +08:00
Michael Niedermayer
d115eec979 avformat/matroskadec: Reset state also on failure in matroska_reset_status()
The calling code does not handle failures and will fail with assertion failures later.
Seeking can always fail even when the position was previously read.

Fixes: Assertion failure
Fixes: 35253/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-4693059982983168

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-09 17:01:49 +02:00
Andreas Rheinhardt
5a261cfa32 avformat/allformats: Fix data race when accessing devices lists
Up until now setting the input and output devices lists is guarded
by a mutex. This prevents data races emanating from multiple concurrent
calls to avpriv_register_devices() (triggered by multiple concurrent
calls to avdevice_register_all()). Yet reading the lists pointers was
done without any lock and with nonatomic variables. This means that
there are data races in case of concurrent calls to
av_(de)muxer_iterate() and avdevice_register_all() (but only if the
iteration in av_(de)muxer_iterate exhausts the non-device (de)muxers).

This commit fixes this by putting said pointers into atomic objects.
Due to the unavailability of _Atomic the object is an atomic_uintptr,
leading to ugly casts. Switching to atomics also allowed to remove
the mutex currently used in avpriv_register_devices().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-09 13:20:39 +02:00
Michael Niedermayer
849138f476 avformat/wavdec: Check smv_block_size
Fixes: Timeout
Fixes: 39554/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-4915221701984256

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-09 11:42:16 +02:00
Michael Niedermayer
8fe3566b8f avformat/rmdec: Check for multiple audio_stream_info
Fixes: memleak
Fixes: 39166/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5153276690038784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-10-09 11:42:16 +02:00