Commit Graph

103408 Commits

Author SHA1 Message Date
Andreas Rheinhardt
64020dfe08 avformat/vorbiscomment: Don't compute strlen twice
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-27 10:47:23 +02:00
Paul B Mahol
dc34bf45c5 avfilter/vf_colorcorrect: add median analyze mode 2021-08-27 10:04:04 +02:00
Paul B Mahol
0cacef58fa avfilter/vf_blend: use float for opacity calculations 2021-08-27 09:35:33 +02:00
Paul B Mahol
a6f00d4e82 avfilter/aeval: fix forgotten EOF case for activate
Bring fate test how it was previously.
2021-08-26 19:23:03 +02:00
maryam ebrahimzadeh
3e24e8108d avcodec/vc1dec: return value check for init_get_bits
As the second argument for init_get_bits(avctx and buf) can be crafted,
a return value check for this function call is necessary,
so replace init_get_bits with init_get_bits8 and add return value check.
2021-08-26 09:23:15 +02:00
Stéphane Cerveau
f9fbe2f9a9 avcodec/wmadec: handle run_level_decode error
Consider data as invalid if ff_wma_run_level_decode
gets out with an error.

It avoids an unpleasant sound distorsion.

See http://trac.ffmpeg.org/ticket/9358
2021-08-26 09:20:56 +02:00
Olivier Crête
521388edb7 avcodec/wma: Return specific error code
This way, the calling function can just forward it instead of
making it up.

Signed-off-by: Olivier Crête <olivier.crete@collabora.com>
2021-08-26 09:20:56 +02:00
Paul B Mahol
c1c7f2b61f avfilter/avf_showwaves: remove invalid multiplication by 2
Fixes output of average filter.
2021-08-26 09:16:35 +02:00
maryam ebrahimzadeh
ad88cce3f8 avcodec/vp6: return value check for init_get_bits
As the second argument for init_get_bits(buf) can be crafted,
a return value check for this function call is necessary.
Also replace init_get_bits with init_get_bits8.

Signed-off-by: Peter Ross <pross@xvid.org>
2021-08-26 17:06:57 +10:00
Andreas Rheinhardt
afeefb306e avcodec/bsf: Avoid allocation for AVBSFInternal
Do this by allocating AVBSFContext together with the data that is
currently in AVBSFInternal; or rather: Put AVBSFContext at the beginning
of a new structure called FFBSFContext (which encompasses more than just
the internal fields and is a proper context in its own right, hence the
name) and remove the AVBSFInternal altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
52bd399972 avformat/aviobuf: Use ffio_fill for padding
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
f5f984c9c3 avformat/aviobuf: Avoid allocation when using dynamic buffer
This can be achieved by allocating the AVIOContext and
the dynamic buffer's opaque and internal write buffer together.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
45bfe8b838 avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext.
This commit moves them into a new structure in avio_internal.h instead.
Said structure contains the public AVIOContext as its first element
in order to avoid having to allocate a separate AVIOContextInternal
which is costly for those use cases where one just wants to access
an already existing buffer via the AVIOContext-API.
For these cases ffio_init_context() can't fail and always returned zero,
which was typically not checked. Therefore it has been made to not
return anything.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
530ac6aa30 avformat/aviobuf: Make ffio_set_buf_size() static
Possible since 9c3adb7ce2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:54 +02:00
Andreas Rheinhardt
19093100fd avformat/utils: Move ffio_limit() to aviobuf
It is the more natural place for it given that it only deals with I/O;
in fact, the function already has the ffio prefix and its declaration
already is in avio_internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Andreas Rheinhardt
e75ab15fd4 avformat/matroskadec: Read RealAudio extradata directly
Don't use the avio-API to read a few bytes at fixed offsets.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Andreas Rheinhardt
7cfff1512c avformat/aviobuf: Avoid calling function twice due to FFMAX()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Andreas Rheinhardt
81b6186920 avutil/log: Reorder elements of AVClass to make it smaller
Putting child_next besides child_class_iterate is actually nicer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
Andreas Rheinhardt
417bd4f7dd avcodec/codec: Reorder elements to make AVCodec smaller
Reordering max_lowres is an ABI break.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-25 23:01:53 +02:00
James Almer
9677053884 avcodec/h264_slice: don't allocate film grain buffers when using hwaccel
Fixes regression since 66845cffc3

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-25 18:01:00 -03:00
Paul B Mahol
8cbed82b2a fftools/ffmpeg_filter: silence valgrind warning 2021-08-25 22:51:32 +02:00
Paul B Mahol
507fdcd1b0 avcodec/dnxhddec: ignore second flag for encoded field
And instead use previous field flag.

Fixes decoding files produced by non-compliant encoders.
2021-08-25 22:48:23 +02:00
Martin Storsjö
2589060b92 arm: hevc_qpel: Fix the assembly to work with non-multiple of 8 widths
This unbreaks the fate-checkasm-hevc_pel test on arm targets.

The assembly assumed that the width passed to the DSP functions is
a multiple of 8, while the checkasm test used other widths too.

This wasn't noticed before, because the hevc_pel checkasm tests
(that were added in 9c513edb79 in
January) weren't run as part of fate until in
b492cacffd in August.

As this hasn't been an issue in practice with actual full decoding
tests, it seems like the actual decoder doesn't call these functions
with such widths. Therefore, we could alternatively fix the test
to only test things that the real decoder does, and this modification
could be reverted.

Signed-off-by: Martin Storsjö <martin@martin.st>
2021-08-25 23:24:49 +03:00
Jan Ekström
d48232fb4c tests/fate: move TTML-in-MP4 tests from subtitles.mak to mov.mak
subtitles.mak's fate-sub tests utilize a more strict comparator
("rawdiff"), which causes the tests fail in case of white space
differences, such as CRLF vs LF. This in turn causes these
ffprobe-using TTML-in-MP4 tests to fail on non-LF systems such as
Windows or wine.
2021-08-25 23:17:53 +03:00
Paul B Mahol
02aa7dc423 avfilter: add hsvkey and hsvhold video filters 2021-08-25 20:43:18 +02:00
Shaun Simpson
16102cada5 avcodec/jpeg2000_parser: Fix skipping of JP2 info markers by correctly reading marker size
Signed-off-by: Shaun Simpson <shauns2029@gmail.com>
2021-08-25 15:12:09 +02:00
Shaun Simpson
01284c01c1 avcodec/jpeg2000_parser: Fix parsing of tile-part header
And frames where the end of frame marker is at the end of the buffer.

Signed-off-by: Shaun Simpson <shauns2029@gmail.com>
2021-08-25 14:47:03 +02:00
Jan Ekström
e41bd075dd avformat/movenc: add support for TTML muxing
Includes basic support for both the ISMV ('dfxp') and MP4 ('stpp')
methods. This initial version also foregoes fragmentation support
in case the built-in sample squashing is to be utilized, as this
eases the initial review.

Additionally, add basic tests for both muxing modes in MP4.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-08-25 09:26:46 +03:00
Jan Ekström
460beb948c avformat/ttml: split TTML paragraph based or not check into header
This way it can be re-utilized in movenc.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2021-08-25 09:26:46 +03:00
Niklas Haas
94653e0dee avcodec/h264dec: fix possible out-of-bounds array access
If slice_type is > 9, the access to ff_h264_golomb_to_pict_type is
out-of-bounds. Fix this by simply setting the slice_type to 0 in this
case.

This is completely inconsequential because the value is only being used
to being used as an offset in the calculation of the film grain seed
value, a corruption of which is practically invisible.

Fixes coverity ticket #1490802

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-25 00:56:35 -03:00
J. Dekker
b492cacffd checkasm: collapse hevc pel tests
Also add to `make fate-checkasm' target.

Signed-off-by: J. Dekker <jdek@itanimul.li>
2021-08-24 22:12:06 +02:00
James Almer
fbbca7b8fa fate: update some missing refs
Forgotten in 590a7e02f0

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 12:22:36 -03:00
James Almer
ab25874e32 avcodec/h264_slice: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
James Almer
9b05263ac1 avcodec/av1: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
James Almer
651fed3860 avcodec/libdav1d: signal the presence of Film Grain in the decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:20 -03:00
James Almer
590a7e02f0 avcodec: add a Film Grain codec property flag
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 10:00:06 -03:00
James Almer
6dd7149f4c avcodec/pthread_frame: also keep AVCodecContext.properties in sync between threads
Some frame threaded decoders set it, but this information never reached the
caller in frame threading scenarios.

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
Niklas Haas
66845cffc3 avcodec/h264dec: apply H.274 film grain
Because we need access to ref frames without film grain applied, we have
to add an extra AVFrame to H264Picture to avoid messing with the
original. This requires some amount of overhead to make the reference
moves work out, but it allows us to benefit from frame multithreading
for film grain application "for free".

Unfortunately, this approach requires twice as much RAM to be constantly
allocated for ref frames, due to the need for an extra buffer per
H264Picture. In theory, we could get away with freeing up this memory as
soon as it's no longer needed (since ref frames do not need film grain
buffers any longer), but trying to call ff_thread_release_buffer() from
output_frame() conflicts with possible later accesses to that same frame
and I'm not sure how to synchronize that well.

Tested on all three cases of (no fg), (fg present but exported) and (fg
present and not exported), with and without threading.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
Niklas Haas
6bc29a6b57 avcodec/h274: add film grain synthesis routine
This could arguably also be a vf, but I decided to put it here since
decoders are technically required to apply film grain during the output
step, and I would rather want to avoid requiring users insert the
correct film grain synthesis filter on their own.

The code, while in C, is written in a way that unrolls/vectorizes fairly
well under -O3, and is reasonably cache friendly. On my CPU, a single
thread pushes about 400 FPS at 1080p.

Apart from hand-written assembly, one possible avenue of improvement
would be to change the access order to compute the grain row-by-row
rather than in 8x8 blocks. This requires some redundant PRNG calls, but
would make the algorithm more cache-oblivious.

The implementation has been written to the wording of SMPTE RDD 5-2006
as faithfully as I can manage. However, apart from passing a visual
inspection, no guarantee of correctness can be made due to the lack of
any publicly available reference implementation against which to
compare it.

Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
Niklas Haas
cf37c3fb6c avcodec/h264_slice: compute and export film grain seed
From SMPTE RDD 5-2006, the grain seed is to be computed from the
following definition of `pic_offset`:

> When decoding H.264 | MPEG-4 AVC bitstreams, pic_offset is defined as
> follows:
>   - pic_offset = PicOrderCnt(CurrPic) + (PicOrderCnt_offset << 5)
> where:
>   - PicOrderCnt(CurrPic) is the picture order count of the current frame,
>     which shall be derived from [the video stream].
>
>   - PicOrderCnt_offset is set to idr_pic_id on IDR frames. idr_pic_id
>     shall be read from the slice header of [the video stream]. On non-IDR I
>     frames, PicOrderCnt_offset is set to 0. A frame shall be classified as I
>     frame when all its slices are I slices, which may be optionally
>     designated by setting primary_pic_type to 0 in the access delimiter NAL
>     unit. Otherwise, PicOrderCnt_offset it not changed. PicOrderCnt_offset is
>     updated in decoding order.

Co-authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:58:52 -03:00
James Almer
61b38f7aef avfilter/avfilter: add a return at the end of a non-void function
Fixes compilation with GCC 11 when configured with "--disable-optimizations --toolchain=gcc-tsan"

Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-24 09:36:21 -03:00
Andreas Rheinhardt
88b3e31562 avformat/matroskaenc: Only compile functions when needed
Fixes unused function warnings in case e.g. the WebM muxer is disabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-24 04:23:50 +02:00
Andreas Rheinhardt
201b8a4d67 avformat/matroskadec: Include webm_dash_manifest demuxer only if enabled
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-24 04:23:50 +02:00
Andreas Rheinhardt
750631b098 avformat/matroskaenc: Pass dispositions through unchanged by default
Up until now, the Matroska muxer did not use the dispositions it is
given as-is; instead it by default overrode the disposition of the first
track of a kind (audio, video, subtitles) if no track of this kind has
the default disposition set. And up until recently, it also enforced
by default that no more than one track of each kind be marked as
default.

The rationale for the former is that there are lots of containers which
lack the concept of default streams, so that it is not uncommon for no
stream to be marked as default at all; the rationale for the latter was
that up until recently, it was dubious whether the Matroska specification
allowed more than one default stream for track type (e.g. mkvmerge
disallowed it). It was this point which led to the implementation of
the above mentioned behaviour inspired by mkvmerge.

Yet the Matroska specifications have changed and now explicitly allow
to set more than one track of each type as default, so that the main
reason of not using the dispositions as-is was rendered moot. Therefore
this commit changes the default to pass the disposition through.

The matroska-mpegts-remux FATE-test has been updated to still use the
old "infer" mode so that it is still covered by FATE; the
matroska-zero-length-block test has also been updated to cover
the infer_no_subs mode. The references for lots of other FATE tests
needed to be updated because of a newly added FlagDefault element with
value zero (whereas a FlagDefault with value 1 needn't be coded at all,
as it coincided with the default value of said element).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-24 04:23:29 +02:00
Andreas Rheinhardt
beb60abab5 avformat/matroskaenc: Allow to set multiple streams as default
The Matroska specifications have evolved and now allow to mark
multiple tracks of the same kind as default (whether this was legal or
not before was dubious; e.g. mkvmerge disallowed it). Yet when the
Matroska muxer is set to infer default dispositions if absent, it also
enforced the now outdated restriction. So update this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-24 03:11:01 +02:00
Andreas Rheinhardt
ff02a42394 avformat/crcenc: Simplify writing trailer
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-24 03:05:27 +02:00
James Zern
cb23c1e553 avcodec/libaomenc: use ctx->usage to get default cfg
this prevents some mismatches in config values for realtime and all
intra modes, avoiding failures like:

[libaom-av1 @ ...] Failed to initialize encoder: Invalid parameter
[libaom-av1 @ ...]   Additional information: g_lag_in_frames out of
range [..0]

Signed-off-by: James Zern <jzern@google.com>
2021-08-23 15:33:51 -07:00
Paul B Mahol
7f194c7d96 avfilter/af_afreqshift: allow to change order of filters 2021-08-23 19:43:06 +02:00
Andreas Rheinhardt
0383ec88a5 avformat/av1dec: Disallow seeking by bytes
The low overhead OBU format provides no means to resync after performing
a byte-based seek; in other words: Byte based seeking is just not
supported.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-23 07:06:22 +02:00
Andreas Rheinhardt
3f938cd46a avformat/av1dec: Flush BSF upon seeking
The av1_merge_frame BSF outputs its cached data when it sees the
beginning of a new frame, i.e. when it sees a temporal delimiter OBU.
Therefore it typically has a temporal delimiter OBU cached after
outputting a packet.

This implies that the OBU demuxer must flush its BSF upon seeking
because otherwise the first frame returned after a seek consists
of an old temporal delimiter OBU only.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-23 07:05:56 +02:00