1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00
Commit Graph

100605 Commits

Author SHA1 Message Date
Marton Balint
2e2891383e avformat: remove some mpegts details from AVStream
These fields were added to support -merge_pmt_versions, but the mpegts demuxer
is also keeping track its programs internally, so that should be a better place
to handle it.

Also it is not a very good idea to keep fields like program_num or
pmt_stream_idx in an AVStream, because a single stream can be part of multiple
programs, multiple PMTs, so the stream attributes can refer to any program the
stream is part of.

Since they are not part of public API, lets simply remove them, or rather
replace them with placeholders for ABI compatibility with libavdevice.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 22:38:12 +01:00
Marton Balint
e57879ec18 avformat/mpegts: use stream index based lookup with merge_pmt_versions if stream identifier matches multiple streams
Also make sure we are checking the old state of the streams because otherwise
some streams might already have the newly parsed stream identifiers which
corrupts matching.

Fixes streams having the same identifier mixed up on pmt version change.

Fixes ticket #9006.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 22:38:12 +01:00
Marton Balint
f143a6c151 avformat/mpegts: only clear programs which no longer exist or have a new PMT
Otherwise there can be a small period when the programs only contain the PMT
pid.

Also make sure skip_clear only affects AVProgram clear, and that pmt_pid is
always kept as the first entry of the PID list of the programs. Also reject
PMTs for programs on the wrong PID.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 22:38:12 +01:00
Marton Balint
10c8e53294 avformat/mpegts: rework clearing and adding pid to program
And use better function names.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 22:38:12 +01:00
Marton Balint
5ea37923a8 avformat/mpegts: never discard PAT pid
PID 0 was removed from the pid list when then PMT was parsed, it is better
to explictly avoid it from being discarded instead of keeing it in the list of
every program.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 22:38:12 +01:00
Marton Balint
9298e8eb61 avformat/utils: do not overwrite already existing program with defaults in av_new_program
av_new_program returns the existing program if that already exists, in that
case it makes no sense to overwrite existing attributes.

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 22:38:12 +01:00
Lynne
91e1625db1
lavu/tx: clip when converting table values to fixed-point
INT32_MAX (2147483647) isn't exactly representable by a floating point
value, with the closest being 2147483648.0. So when rescaling a value
of 1.0, this could overflow when casting the 64-bit value returned from
lrintf() into 32 bits.
Unfortunately the properties of integer overflows don't match up well
with how a Fourier Transform operates. So clip the value before
casting to a 32-bit int.

Should be noted we don't have overflows with the table values we're
currently using. However, converting a Kaiser-Bessel window function
with a length of 256 and a parameter of 5.0 to fixed point did create
overflows. So this is more of insurance to save debugging time
in case something changes in the future.
The macro is only used during init, so it being a little slower is
not a problem.
2021-01-09 20:54:56 +01:00
Arnaud Vrac
29993b2947 sbc: do not set sample format in parser
Commit bdd31feec9 changed the SBC decoder to only set the output
sample format on init, instead of setting it explicitly on each frame,
which is correct. But the SBC parser overrides the sample format to S16,
which triggers a crash when combining the parser and the decoder.

Fix the issue by not setting the sample format anymore in the parser,
which is wrong.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-09 15:24:32 -03:00
Christopher Degawa
eacad3406e avdevice/decklink_dec: mark get_frame_timecode and get_bmd_timecode static
The function is not used anywhere else and is causing mingw-w64 clang
builds to fail with

ffmpeg-git/libavdevice/decklink_dec.cpp:792:5: error: no previous prototype for function 'get_bmd_timecode' [-Werror,-Wmissing-prototypes]
int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame *videoFrame)

Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 17:37:02 +01:00
Matthieu Bouron
2e17435480 avformat/mov: adjust skip_samples according to seek timestamp
Currently skip_samples is set to start_pad if sample_time is lesser or
equal to 0. This can cause issues if the stream starts with packets that
have negative pts. Calling avformat_seek_file() with ts set to 0 on such
streams makes the mov demuxer return the right corresponding packets
(near the 0 timestamp) but set skip_samples to start_pad which is
incorrect as the audio decoder will discard the returned samples
according to skip_samples from the first packet it receives (which has
its timestamp near 0).

For example, considering the following audio stream with start_pad=1344:

 [PKT pts=-1344] [PKT pts=-320] [PKT pts=704] [PKT pts=1728] [...]

Calling avformat_seek_file() with ts=0 makes the next call to
av_read_frame() return the packet with pts=-320 and a skip samples
side data set to 1344 (start_pad). This makes the audio decoder
incorrectly discard (1344 - 320) samples.

This commit makes the move demuxer adjust skip_samples according to the
stream start_pad, seek timestamp and first sample timestamp.

The above example will now result in av_read_frame() still returning the
packet with pts=-320 but with a skip samples side data set to 320
(src_pad - (seek_timestamp - first_timestamp)). This makes the audio
decoder only discard 320 samples (from pts=-320 to pts=0).

Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 17:08:27 +01:00
Lingjiang Fang
c4407a3e00 doc/protocols: explain tcp listen option description
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-01-09 17:08:27 +01:00
Timo Rothenpieler
7a2d94cf1a avcodec/nvenc: fix timestamp offset ticks logic 2021-01-09 16:34:59 +01:00
Andreas Rheinhardt
42ee3898c8 avcodec/ac3dec: Make decoders init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:32 +01:00
Andreas Rheinhardt
10663312de avcodec/ac3dec: Check operations that can fail
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:32 +01:00
Andreas Rheinhardt
277281ac8e avcodec/ac3enc: Factor common end of float/fixed encode_frame out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:32 +01:00
Andreas Rheinhardt
49a12ac4af avcodec/ac3enc_template: Perform compile-time checks at compile-time
Runtime checks for whether the encoder is fixed-point or not are
unnecessary here as this is a template; furthermore, there is no
fixed-point EAC-3 encoder, so some checks for whether one is in EAC-3
mode can be omitted when doing fixed-point encoding.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:31 +01:00
Andreas Rheinhardt
496ff9f2e5 avcodec/[e]ac3enc: Don't invade CONFIG_ namespace
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:31 +01:00
Andreas Rheinhardt
953924781e avcodec/ac3enc: Set function pointers earlier
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:31 +01:00
Andreas Rheinhardt
505d4de064 avcodec/[e]ac3enc: Make encoders init-threadsafe, fix race
ff_eac3_exponent_init() set values twice when initializing a static
table; ergo the initialization code must not run concurrently with
a running EAC-3 encoder. Yet this code is executed every time an EAC-3
encoder is initialized. So use ff_thread_once() for this and also for a
similar initialization performed for all AC-3 encoders to make them all
init-threadsafe.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-09 04:06:31 +01:00
Michael Niedermayer
69aeba8a19 avcodec/wmaprodec: Check packet size
Fixes: left shift of negative value -25824
Fixes: 27754/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-5760255962906624

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-08 18:08:57 +01:00
Michael Niedermayer
0a0b92b4b2 avformat/dhav: Check position for overflow
Fixes: signed integer overflow: 9223372036854775807 + 32768 cannot be represented in type 'long'
Fixes: 27744/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5179319491756032

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-08 18:08:57 +01:00
Michael Niedermayer
380a3a0adf avcodec/rasc: Check frame before clearing
Fixes: null pointer dereference
Fixes: 27737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5769028685266944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-08 18:08:56 +01:00
Michael Niedermayer
ac5a568e6d avformat/utils: Change compute_chapters_end() from O(n²) to O(n log n)
Fixes: Timeout (49sec -> 9sec)
Fixes: 27427/clusterfuzz-testcase-minimized-ffmpeg_dem_FFMETADATA_fuzzer-5140589838073856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-08 18:02:55 +01:00
Andreas Rheinhardt
a454a0c14f avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86
Also do it for FFT_FLOAT only, as this is the only combination for which
it can be set.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 06:52:51 +01:00
Andreas Rheinhardt
482aeda8bf avfilter/vsrc_testsrc: Deduplicate options
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 06:08:03 +01:00
Andreas Rheinhardt
6fed8a6cb0 avfilter/af_biquads: Don't redundantly set AVClass
It is already set generically in ff_filter_alloc().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Andreas Rheinhardt
2d48b69b3d avfilter/af_biquads: Deduplicate options
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Andreas Rheinhardt
a6fa1838e6 avfilter/vf_blend: Deduplicate options
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Andreas Rheinhardt
c51887c56a avfilter/af_asupercut: Deduplicate options
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Andreas Rheinhardt
d1de1d95a6 avfilter/vf_neighbor: Deduplicate options
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:12 +01:00
Andreas Rheinhardt
096cb41624 avfilter/vf_convolution: Deduplicate filter options
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:11 +01:00
Andreas Rheinhardt
cb4c3b6162 avformat/hashenc: Deduplicate (stream)hash options
Also saves relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:11 +01:00
Andreas Rheinhardt
5e11dcf52f avcodec/wavpack: Deduplicate exp and log tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:06:11 +01:00
Andreas Rheinhardt
ac0e75b647 avformat/mxf: Deduplicate random_index_pack_key
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:13 +01:00
Andreas Rheinhardt
a91b18f368 avfilter/vf_qp: Deduplicate variable names arrays
This also avoids relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:10 +01:00
Andreas Rheinhardt
241cb4a48c avcodec/vp3data: Deduplicate coeff_tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:10 +01:00
Andreas Rheinhardt
0a493ac0ca avcodec/twinvq, metasound_data: Deduplicate lsp tables
Saves about 24KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:10 +01:00
Andreas Rheinhardt
f25b1742f0 avcodec/metasound: Deduplicate data
Saves about 13KB; also reduces the amount of relocations.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:10 +01:00
Andreas Rheinhardt
9c318b30f3 avcodec/g723_1: Move tables to their only user
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:10 +01:00
Andreas Rheinhardt
3d284e35c2 avcodec/g723_1: Deduplicate arrays
Saves about 17KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-08 05:05:10 +01:00
Arthur Taylor
f4bdeddc3c avcodec/libopusenc: Fix for header pre-skip value
The Opus header initial padding preskip amount is always to be expressed
relative to 48kHz. However, the encoder delay returned from querying
libopus is relative to the encoding samplerate. Multiply by the
samplerate conversion factor to correct.

Signed-off-by: Arthur Taylor <art@ified.ca>
2021-01-07 22:42:15 +01:00
Michael Niedermayer
66deab3a26 avformat/vividas: Check number of audio channels
Fixes: division by 0
Fixes: 28597/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5752201490333696

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-05 02:00:05 +01:00
Michael Niedermayer
7ce40dde03 avcodec/alsdec: Fix integer overflow with quant_cof
Fixes: signed integer overflow: -210824 * 16384 cannot be represented in type 'int'
Fixes: 28670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5682310846480384

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-05 02:00:05 +01:00
Michael Niedermayer
58c7d4a3e3 tools/target_dem_fuzzer.c: Decrease maxblocks
Fixes: Timeout
Fixes: 28606/clusterfuzz-testcase-minimized-ffmpeg_dem_FRM_fuzzer-5123311424110592
Fixes: 28796/clusterfuzz-testcase-minimized-ffmpeg_dem_R3D_fuzzer-5945803411685376
Fixes: 28821/clusterfuzz-testcase-minimized-ffmpeg_dem_BRSTM_fuzzer-6044239834251264
Fixes: 28841/clusterfuzz-testcase-minimized-ffmpeg_dem_SIFF_fuzzer-5485368388485120
Fixes: 28862/clusterfuzz-testcase-minimized-ffmpeg_dem_AST_fuzzer-5081306790756352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-01-05 02:00:05 +01:00
James Almer
5f9632e491 avcodec/av1dec: add an option to select an operating point
Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-04 16:28:29 -03:00
James Almer
f951d47563 avcodec/cbs_av1: add an option to select an operating point
This implements the function drop_obu() as defined in Setion 6.2.1 from the
spec.
In a reading only scenario, units that belong to an operating point the
caller doesn't want should not be parsed.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-04 16:28:29 -03:00
James Almer
3b8400c221 avcodec/cbs: allow cbs_read_fragment_content() to skip decomposition of units
The caller may not need all units in a fragment in reading only scenarios.
They could in fact alter global state stored in the private CodedBitstreamType
fields in an undesirable way.
With this change, unit decomposition can be skipped based on parsed values
within the unit.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-04 16:28:29 -03:00
James Almer
9caf132462 avcodec/cbs: add an AVClass to CodedBitstreamType for option handling
So unit parsing may be configured with caller set options.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-01-04 16:28:29 -03:00
Joose Sainio
0cd8769207 avcodec/libkvazaar: Set default ratecontrol algorithm for libkvazaar
The standalone version of Kvazaar sets a default ratecontrol algorithm when
bitrate is set. Mirror this behaviour.

Signed-off-by: Joose Sainio <joose.sainio@tuni.fi>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-04 15:18:19 +00:00
Xu Guangxin
c8bc0f66a8 avcodec/hevcdec: fix stat_coeff save/load for persistent_rice_adaptation_enabled_flag
It's required by the 9.3.1 TableStatCoeff* section.

Following clips have this feature:
WPP_HIGH_TP_444_8BIT_RExt_Apple_2.bit
Bitdepth_A_RExt_Sony_1.bin
Bitdepth_B_RExt_Sony_1.bin
EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_10BIT_RExt_Sony_1.bit
EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_12BIT_RExt_Sony_1.bit
EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_8BIT_RExt_Sony_1.bit
EXTPREC_MAIN_444_16_INTRA_10BIT_RExt_Sony_1.bit
EXTPREC_MAIN_444_16_INTRA_12BIT_RExt_Sony_1.bit
EXTPREC_MAIN_444_16_INTRA_8BIT_RExt_Sony_1.bit
WPP_AND_TILE_10Bit422Test_HIGH_TP_444_10BIT_RExt_Apple_2.bit
WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_0_HIGH_TP_444_14BIT_RExt_Apple_2.bit
WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_1_HIGH_TP_444_14BIT_RExt_Apple_2.bit
WPP_AND_TILE_HIGH_TP_444_8BIT_RExt_Apple_2.bit

you can download them from:
https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/RExt/

Signed-off-by: Xu Guangxin <oddstone@gmail.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
2021-01-04 15:18:19 +00:00