Commit Graph

105902 Commits

Author SHA1 Message Date
Paul B Mahol e7caa18b4a avfilter/af_afftdn: remove special handling for first and last bin 2022-03-11 23:57:33 +01:00
Paul B Mahol ea777333de avfilter/af_afftdn: remove code that have marginal impact to denoising 2022-03-11 23:57:33 +01:00
Andreas Rheinhardt 707ad03096 avformat/movenc: Simplify creating chapter track extradata
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-11 18:08:31 +01:00
Andreas Rheinhardt a909666d7c fate/mov: Add test for muxing chapters
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-11 17:58:40 +01:00
Adrian Ratiu bc5ccea3b9 configure: move ranlib -D test after setting defaults
In Gentoo and ChromeOS we want to allow pure LLVM builds without
using GNU tools, so we block any unwanted mixed GNU/LLVM usages
(GNU tools are still kept around in our chroots for projects
like glibc which cannot yet be built otherwise).

The default ${cross_prefix}${ranlib_default} points to GNU and
fails, so move the test a bit later - after the defaults are
set and the proper values get overriden - such that ffmpeg
configure calls the llvm-ranlib we desire. [1]

[1] https://gitweb.gentoo.org/repo/gentoo.git/tree/media-video/ffmpeg/ffmpeg-4.4.1-r1.ebuild?id=7a34377e3277a6a0e2eedd40e90452a44c55f1e6#n477

Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-11 14:20:14 +02:00
Paul B Mahol a0724328a8 avfilter/vf_zscale: do not attempt to continue filtering if there is no graph 2022-03-11 09:34:04 +01:00
Paul B Mahol 4ac85ae448 avfilter/vf_zscale: also check formats 2022-03-11 01:54:03 +01:00
Wu Jianhua f629ea2e18 avutil/cpu: add AVX512 Icelake flag
Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
Reviewed-by: Henrik Gramner <henrik@gramner.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-03-10 16:45:48 -03:00
Jack Bruienne e6e3aae294 avformat: add DFPWM WAV container support
This commit adds support for storing DFPWM audio in a WAV container.
It uses the WAVEFORMATEXTENSIBLE structure, following these conventions:
https://gist.github.com/MCJack123/90c24b64c8e626c7f130b57e9800962c
The implementation is very simple: it just adds the GUID to the list of
WAV GUIDs, and modifies the WAV muxer to always use WAVEFORMATEXTENSIBLE
format with that GUID.

This creates a standard container format for DFPWM besides raw data.
It will allow users to transfer DFPWM audio in a standard container
format, with the sample rate and channel count contained in the file
as opposed to being an external parameter as in the raw format.

This format is already supported in my AUKit library, which is the CC
analog to libav (albeit much smaller). Support in other applications is TBD.

Signed-off-by: Jack Bruienne <jackbruienne@gmail.com>
2022-03-10 14:11:12 +01:00
Jack Bruienne 70fef2371c avformat: add DFPWM raw format
This patch builds on my previous DFPWM codec patch, adding a raw
audio format to be able to read/write the raw files that are most commonly
used (as no other container format supports it yet).

The muxers are mostly copied from the PCM demuxer and the raw muxers, as
DFPWM is typically stored as raw data.

Please see the previous patch for more information on DFPWM.

Signed-off-by: Jack Bruienne <jackbruienne@gmail.com>
2022-03-10 14:11:12 +01:00
Jack Bruienne 39a33038ce avcodec: add DFPWM1a codec
From the wiki page (https://wiki.vexatos.com/dfpwm):
> DFPWM (Dynamic Filter Pulse Width Modulation) is an audio codec
> created by Ben “GreaseMonkey” Russell in 2012, originally to be used
> as a voice codec for asiekierka's pixmess, a C remake of 64pixels.
> It is a 1-bit-per-sample codec which uses a dynamic-strength one-pole
> low-pass filter as a predictor. Due to the fact that a raw DPFWM decoding
> creates a high-pitched whine, it is often followed by some post-processing
> filters to make the stream more listenable.

It has recently gained popularity through the ComputerCraft mod for
Minecraft, which added support for audio through this codec, as well as
the Computronics expansion which preceeded the official support. These
both implement the slightly adjusted 1a version of the codec, which is
the version I have chosen for this patch.

This patch adds a new codec (with encoding and decoding) for DFPWM1a.
The codec sources are pretty simple: they use the reference codec with
a basic wrapper to connect it to the FFmpeg AVCodec system.

To clarify, the codec does not have a specific sample rate - it is
provided by the container (or user), which is typically 48000, but has
also been known to be 32768. The codec does not specify channel info
either, and it's pretty much always used with one mono channel.
However, since it appears that libavcodec expects both sample rate and
channel count to be handled by either the codec or container, I have
made the decision to allow multiple channels interleaved, which as far
as I know has never been used, but it works fine here nevertheless. The
accompanying raw format has a channels option to set this. (I expect
most users of this will not use multiple channels, but it remains an
option just in case.)

This patch will be highly useful to ComputerCraft developers who are
working with audio, as it is the standard format for audio, and there
are few user-friendly encoders out there, and even fewer decoders. It
will streamline the process for importing and listening to audio,
replacing the need to write code or use tools that require very
specific input formats.

You may use the CraftOS-PC program (https://www.craftos-pc.cc) to test
out DFPWM playback. To use it, run the program and type this command:
"attach left speaker" Then run "speaker play <file.dfpwm>" for each file.
The app runs in a sandbox, so files have to be transferred in first;
the easiest way to do this is to simply drag the file on the window.
(Or copy files to the folder at https://www.craftos-pc.cc/docs/saves.)

Sample DFPWM files can be generated with an online tool at
https://music.madefor.cc. This is the current best way to encode DFPWM
files. Simply drag an audio file onto the page, and it will encode it,
giving a download link on the page.

I've made sure to update all of the docs as per Developer§7, and I've
tested it as per section 8. Test files encoded to DFPWM play correctly
in ComputerCraft, and other files that work in CC are correctly decoded.
I have also verified that corrupt files do not crash the decoder - this
should theoretically not be an issue as the result size is constant with
respect to the input size.

Signed-off-by: Jack Bruienne <jackbruienne@gmail.com>
2022-03-10 14:05:25 +01:00
Paul B Mahol 5cd8eb2aef avfilter/af_lv2: add commands support 2022-03-10 12:08:47 +01:00
Paul B Mahol 34715fe4a2 avfilter/af_anlmdn: add support for using writable frames 2022-03-10 12:08:47 +01:00
Limin Wang 0a005b1207 fate: add a test for HDR Vivid metadata in HEVC
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2022-03-10 07:05:57 +08:00
Paul B Mahol c71b76e141 avfilter/af_anlmdn: stop using fifo and rewriting pts 2022-03-09 22:08:36 +01:00
Paul B Mahol 41cae501b7 avfilter/af_anlmdn: fix possible array overflow and increase options limits 2022-03-09 22:08:36 +01:00
Andre Kempe 248986a0db arm64: Add Armv8.3-A PAC support to assembly files
This patch adds optional support for Arm Pointer Authentication Codes.

PAC support is turned on or off at compile time using additional
compiler flags. Unless any of these is enabled explicitly, no additional
code will be emitted at all.

Signed-off-by: André Kempe <andre.kempe@arm.com>
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-09 15:04:25 +02:00
Thilo Borgmann 74117abf0c lavfi/drawtext: Add %N for drawing fractions of a second
Suggested-By: ffmpeg@fb.com
2022-03-08 13:28:02 +01:00
Paul B Mahol 3706fb8f16 avfilter/f_segment: fix sending frames with zero samples out
Fix max_samples variable type, and check for out of range values.
2022-03-08 10:26:46 +01:00
Paul B Mahol a0fc6c4a8e avcodec/pngdec: support alpha blending for palette apng
Update clock test, as PAL8 apngs are now decoded as RGBA.
2022-03-08 10:26:46 +01:00
Michael Niedermayer 1bed27acef avcodec/argo: Check packet size
Fixes: Timeout
Fixes: 45052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-6033489206575104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-08 00:47:21 +01:00
Michael Niedermayer 757da974b2 avcodec/g729_parser: Check channels
Fixes: signed integer overflow: 10 * 808464428 cannot be represented in type 'int'
Fixes: assertion failure
Fixes: ticket9651

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-08 00:47:21 +01:00
Michael Niedermayer ec8ff659f5 avformat/avidec: Check height
Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself
Fixes: Ticket8486

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-08 00:47:21 +01:00
Michael Niedermayer 1c60ad469e tools/target_dec_fuzzer: Adjust threshold for targa
Fixes: Timeout
Fixes: 44877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TARGA_fuzzer-4870505251864576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-08 00:47:21 +01:00
Michael Niedermayer 15a646e501 avformat/rmdec: Better duplicate tags check
Fixes: memleaks
Fixes: 44810/clusterfuzz-testcase-minimized-ffmpeg_dem_IVR_fuzzer-5619494647627776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-08 00:47:21 +01:00
Paul B Mahol 13a153d801 avfilter/f_sendcmd: export width and height too 2022-03-07 17:00:12 +01:00
Paul B Mahol 328247076c avfilter/af_channelsplit: switch to activate() 2022-03-07 15:29:40 +01:00
Paul B Mahol a1f2e42ebf avfilter/af_acrossover: switch to activate() 2022-03-07 15:29:39 +01:00
Paul B Mahol 7238541d39 avfilter/vf_extractplanes: switch to activate()
Fixes hang at end of input with this command:

ffmpeg -f lavfi -i testsrc2=d=50,format=yuv444p -lavfi \
"extractplanes=y+u+v[y][u][v];[y]tpad=start=0[y];[u]tpad=start=0[u];[v]negate[v];[y][u][v]vstack=3" -f null -
2022-03-07 15:29:39 +01:00
Paul B Mahol 0f5c964c57 avfilter/split: switch to activate() 2022-03-07 15:29:39 +01:00
Martin Storsjö e645a1ddb9 libavfilter: vf_scale: Properly take in->color_range into account
While swscale can be reconfigured with sws_setColorspaceDetails,
the in/out ranges also need to be set before calling
sws_init_context, otherwise the initialization might choose
fastpaths that don't take the ranges into account.

Therefore, look at in->color_range too, when deciding on whether
the scaler needs to be reconfigured.

Add a new member variable for keeping track of this, for being
able to differentiate between whether the scale filter parameter
"in_range" has been set (which should override whatever the input
frame has set) or whether it has been configured based on the
latest frame (which should trigger reconfiguring the scaler if
the input frame ranges change).

Fixes: Ticket #9576

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-03-07 00:15:23 +02:00
Michael Niedermayer b9973b72c0 avfilter/vf_colorlevels: Fix build failure on ARM
This fixes building for arm after 10c2ef1ca4.
The argument to av_clip_uintp2 must be an assembly time immediate
constant.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Reviewed-by and commit message details-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-06 20:16:39 +01:00
Paul B Mahol 6f231664ab avfilter/vsrc_gradients: add radial gradients 2022-03-06 15:54:10 +01:00
Paul B Mahol 7c23c9dfc7 avfilter/vsrc_gradients: add gbrapf32 format support 2022-03-06 15:54:09 +01:00
Paul B Mahol 10c2ef1ca4 avfilter/vf_colorlevels: add planar rgb formats support 2022-03-06 14:00:26 +01:00
Paul B Mahol 47c3b34506 avcodec: add pcm-bluray encoder 2022-03-06 12:45:59 +01:00
Paul B Mahol 93dfb6afdd avformat/mpegtsenc: fix muxing pcm-bluray 2022-03-06 12:45:59 +01:00
Paul B Mahol c444d7fafa tests: update hash as output have changed again for fate-lavf-mxf_opatom 2022-03-06 12:31:43 +01:00
Paul B Mahol 88a58b90fe avfilter/avf_ahistogram: use av_clip_uint8() instead 2022-03-06 12:27:48 +01:00
Paul B Mahol 14c9b7b194 avcodec/dnxhdenc: fill unused bytes from put bits buffer with zeros 2022-03-05 23:03:45 +01:00
Paul B Mahol fb5e871937 avfilter/avf_ahistogram: add new histogram mode option 2022-03-05 22:11:38 +01:00
Paul B Mahol 044c09c0a0 avcodec/dnxhdenc: retry increasing qscale to not overflow max_bits
Increase mb_bits type from uint16_t to uint32_t to fix possible overflows
in bit size calculations.

Update fate test that needs change.
2022-03-05 22:11:38 +01:00
Paul B Mahol 37480b1b85 avcodec/dnxhdenc: fix possible out of bound writes for big w/h
It was caused by integer overflows.
2022-03-04 23:44:01 +01:00
Andreas Rheinhardt f497731260 fftools/ffmpeg_opt: Apply copyinkf for all stream types
The earlier code has ignored it for all stream types except
video and subtitles, probably because audio was presumed
to only consist of keyframes. Yet this assumption is not true
for e.g. TrueHD.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-04 21:39:42 +01:00
Paul B Mahol c72b5be9e3 avfilter/vf_pad: use already available outlink variable 2022-03-04 18:30:10 +01:00
Clément Bœsch 1a502b99e8 avformat/mov: reindent after previous commit 2022-03-04 15:50:51 +01:00
Clément Bœsch ab77b878f1 avformat/mov: fix seeking with HEVC open GOP files
This was tested with medias recorded from an iPhone XR and an iPhone 13.

Here is how a typical stream looks like in coding order:

    ┌────────┬─────┬─────┬──────────┐
    │ sample | PTS | DTS | keyframe |
    ├────────┼─────┼─────┼──────────┤
    ┊        ┊     ┊     ┊          ┊
    │   53   │ 560 │ 510 │    No    │
    │   54   │ 540 │ 520 │    No    │
    │   55   │ 530 │ 530 │    No    │
    │   56   │ 550 │ 540 │    No    │
    │   57   │ 600 │ 550 │    Yes   │
    │ * 58   │ 580 │ 560 │    No    │
    │ * 59   │ 570 │ 570 │    No    │
    │ * 60   │ 590 │ 580 │    No    │
    │   61   │ 640 │ 590 │    No    │
    │   62   │ 620 │ 600 │    No    │
    ┊        ┊     ┊     ┊          ┊

In composition/display order:

    ┌────────┬─────┬─────┬──────────┐
    │ sample | PTS | DTS | keyframe |
    ├────────┼─────┼─────┼──────────┤
    ┊        ┊     ┊     ┊          ┊
    │   55   │ 530 │ 530 │    No    │
    │   54   │ 540 │ 520 │    No    │
    │   56   │ 550 │ 540 │    No    │
    │   53   │ 560 │ 510 │    No    │
    │ * 59   │ 570 │ 570 │    No    │
    │ * 58   │ 580 │ 560 │    No    │
    │ * 60   │ 590 │ 580 │    No    │
    │   57   │ 600 │ 550 │    Yes   │
    │   63   │ 610 │ 610 │    No    │
    │   62   │ 620 │ 600 │    No    │
    ┊        ┊     ┊     ┊          ┊

Sample/frame 58, 59 and 60 are B-frames which actually depends on the
key frame (57). Here the key frame is not an IDR but a "CRA" (Clean
Random Access).

Initially, I thought I could rely on the sdtp box (independent and
disposable samples), but unfortunately:

    sdtp[54] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[55] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[56] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[57] is_leading:0 sample_depends_on:2 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[58] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[59] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[60] is_leading:0 sample_depends_on:1 sample_is_depended_on:2 sample_has_redundancy:0
    sdtp[61] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0
    sdtp[62] is_leading:0 sample_depends_on:1 sample_is_depended_on:0 sample_has_redundancy:0

The information that might have been useful here would have been
is_leading, but all the samples are set to 0 so this was unusable.

Instead, we need to rely on sgpd/sbgp tables. In my case the video track
contained 3 sgpd tables with the following grouping types: tscl, sync
and tsas. In the sync table we have the following 2 entries (only):

    sgpd.sync[1]: sync nal_unit_type:0x14
    sgpd.sync[2]: sync nal_unit_type:0x15

(The count starts at 1 because 0 carries the undefined semantic, we'll
see that later in the reference table).

The NAL unit types presented here correspond to:

    libavcodec/hevc.h:    HEVC_NAL_IDR_N_LP       = 20,
    libavcodec/hevc.h:    HEVC_NAL_CRA_NUT        = 21,

In parallel, the sbgp sync table contains the following:

    ┌────┬───────┬─────┐
    │ id │ count │ gdi │
    ├────┼───────┼─────┤
    │  0 │   1   │  1  │
    │  1 │   56  │  0  │
    │  2 │   1   │  2  │
    │  3 │   59  │  0  │
    │  4 │   1   │  2  │
    │  5 │   59  │  0  │
    │  6 │   1   │  2  │
    │  7 │   59  │  0  │
    │  8 │   1   │  2  │
    │  9 │   59  │  0  │
    │ 10 │   1   │  2  │
    │ 11 │   11  │  0  │
    └────┴───────┴─────┘

The gdi column (group description index) directly refers to the index in
the sgpd.sync table. This means the first frame is an IDR, then we have
batches of undefined frames interlaced with CRA frames. No IDR ever
appears again (tried on a 30+ seconds sample).

With that information, we can build an heuristic using the presentation
order.

A few things needed to be introduced in this commit:

1. min_sample_duration is extracted from the stts: we need the minimal
   step between sample in order to PTS-step backward to a valid point
2. In order to avoid a loop over the ctts table systematically during a
   seek, we build an expanded list of sample offsets which will be used
   to translate from DTS to PTS
3. An open_key_samples index to keep track of all the non-IDR key
   frames; for now it only supports HEVC CRA frames. We should probably
   add BLA frames as well, but I don't have any sample so I prefered to
   leave that for later

It is entirely possible I missed something obvious in my approach, but I
couldn't come up with a better solution. Also, as mentioned in the diff,
we could optimize is_open_key_sample(), but the linear scaling overhead
should be fine for now since it only happens in seek events.

Fixing this issue prevents sending broken packets to the decoder. With
FFmpeg hevc decoder the frames are skipped, with VideoToolbox the frames
are glitching.
2022-03-04 15:50:51 +01:00
Clément Bœsch e05e4398c3 avformat/mov: add parsing for the sgpd sync box
sgpd means Sample Group Description Box.

For now, only the sync grouping type is parsed, but the function can
easily be adjusted to support other flavours.

The sbgp (Sample to Group Box) sync_group table built in previous commit
contains references to this table through the group_description_index
field.
2022-03-04 15:50:51 +01:00
Clément Bœsch eb947471b2 avformat/mov: add support for sync group in sbgp box 2022-03-04 15:50:51 +01:00
Clément Bœsch 954f488ea3 avformat/mov: prepare sbgp parsing for other grouping types 2022-03-04 15:50:51 +01:00