1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-02 03:06:28 +02:00
Commit Graph

108936 Commits

Author SHA1 Message Date
Takeshi (Kesh) Ikuma
65f96a965a avfilter/vf_curves: add PCHIP interpolator and interp option
summary: This patch modifies the `curves` filter with new `interp` option
         to let user pick the existing natural cubic spline interpolation
         and the new PCHIP interapolation.

reason:  The natural cubic spline does not impose monotonicity between
         the keypoints. As such, the fitted curve may vary wildly against
         user's intension. The PCHIP interpolation is not as smooth as
         the natural spline but guarantees the monotonicity. Providing
         both options enhances users experience (e.g., reduces the number
         of keypoints to realize the desired curve). See the related bug
         report for the example of an ill-interpolated curve.

alternate solution:
         Both Photoshop and GIMP appear to use monotonic interpolation in
         their curve tools, which were the models for this filter. As
         such, an alternate solution is to drop the natural spline and
         go without the `interp` option.

related bug report: https://trac.ffmpeg.org/ticket/9947 (filed by myself)

Signed-off-by: Takeshi (Kesh) Ikuma <tikuma@hotmail.com>
2022-10-22 19:35:44 +02:00
Andreas Rheinhardt
993e3a6b54 avocdec/cbs_internal: Rename CBS_MAX_UNIT_TYPES->CBS_MAX_LIST_UNIT_TYPES
This makes it clearer that this limit does not apply to
CBS_UNIT_TYPE_RANGE units.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-22 17:35:56 +02:00
Andreas Rheinhardt
543ef831a8 avcodec/cbs: Remove CBS_CONTENT_TYPE_POD
It is equivalent to CBS_CONTENT_TYPE_INTERNAL_REFS
with nb_offsets equal to zero.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-22 17:28:01 +02:00
Paul B Mahol
ff3c708686 avfilter/vf_fftdnoiz: improve filtering at edges 2022-10-22 12:04:43 +02:00
Andreas Rheinhardt
ff3c4705f6 avcodec/speedhqdec: Remove write-only AVCodecContext*
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
7894d4c9fa avcodec/metasound: Remove unnecessary headers
They are used in twinvq.c, not in metasound.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
0d1028f63f avcodec/speedhq: Rename file to speedhqdec.c, move ff_rl_speedhq out
Renaming the decoder to speedhqdec.c makes sense since
we have an encoder in speedhqenc.c. Given that ff_rl_speedhq
is also used by the encoder, it is kept in speedhq.c
and a proper header for it is created to replace the ad-hoc
declaration in speedhqenc.c. This also allows to remove
the check for CONFIG_SPEEDHQ_DECODER, as it is always true
when speedhqdec.c is compiled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
1490ba6f41 avcodec/metasound: Remove always-false checks
The number of channels that is checked here is automatically
valid because it has just been set by us (based upon an entry
in codec_props).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
d94a445e3d avcodec/cyuv: Remove useless private context
It just contains duplicates of values from AVCodecContext
as well as an write-only pointer to said AVCodecContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
20a1296bb4 avcodec/nvdec_mjpeg: Remove always-true #if CONFIG_MJPEG_NVDEC_HWACCEL
This file is built iff said hwaccel is enabled.

Reviewed-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
f18f8a561c avcodec/speedhqenc: Remove always-true #if CONFIG_SPEEDHQ_ENCODER
This file is built iff the SpeedHQ encoder is enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Andreas Rheinhardt
1132007d3c avformat/mj2kdec: Remove always-true #if CONFIG_MJPEG_2000_DEMUXER
This file is built iff the MJPEG 2000 demuxer is enabled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-21 21:12:45 +02:00
Paul B Mahol
da4ff1d536 avfilter/vf_maskedthreshold: implement diff mode
To be useful for adaptive thresholding with threshold filter.
2022-10-21 20:11:14 +02:00
Chema Gonzalez
a1a87b7a24 avformat/yuv4mpegdec: increase header limit
Allows demuxing UHD F1000000000:33333333 fps yuvj420p files

ffmpeg (at HEAD as of now) is creating this:

```
$ ffmpeg -y -i source.265 /tmp/foo.y4m >& /dev/null
...
$ xxd /tmp/raw.y4m |less
00000000: 5955 5634 4d50 4547 3220 5731 3932 3020  YUV4MPEG2 W1920
00000010: 4831 3038 3020 4631 3030 3030 3030 3030  H1080 F100000000
00000020: 303a 3333 3333 3333 3333 2049 7020 4130  0:33333333 Ip A0
00000030: 3a30 2043 3432 306d 7065 6732 2058 5953  :0 C420mpeg2 XYS
00000040: 4353 533d 3432 304d 5045 4732 2058 434f  CSS=420MPEG2 XCO
00000050: 4c4f 5252 414e 4745 3d4c 494d 4954 4544  LORRANGE=LIMITED
00000060: 0a46 5241 4d45 0a82 8282 8282 8282 8282  .FRAME..........
...
```

Which cannot be parsed by the same ffmpeg decoder:
```
$ ffmpeg -i /tmp/foo.y4m /tmp/bar.y4m
...
[yuv4mpegpipe @ 0x2b69a40] Header too large.
/tmp/foo.y4m: Invalid argument
```

This is kicking the ball (per 0b1ff3265e),
but seems to work.
2022-10-21 20:11:14 +02:00
Anton Khirnov
4cfffdd551 fftools/ffmpeg: rename read_file() to avoid conflict with libass
libass defines a non-static read_file() symbol, which causes conflicts
with static linking.
2022-10-21 10:13:16 +02:00
Michael Niedermayer
9184d3d7b6
avcodec/speedhq: Check buf_size to be big enough for DC
Fixes: Timeout
Fixes: 51919/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SPEEDHQ_fuzzer-6023716480090112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-20 21:42:21 +02:00
Michael Niedermayer
148b98a429
tools/target_dec_fuzzer: Adjust threshold for FFV1
Fixes: Timeout
Fixes: 49446/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5085639783088128

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-20 21:42:21 +02:00
Michael Niedermayer
4df91e2215
avcodec/ffv1dec: Fail earlier if prior context is corrupted
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-20 21:42:20 +02:00
Michael Niedermayer
557aa7772e
avformat/asfdec_o: Check offset before adding index entry
Fixes: signed integer overflow: 9223372036854550860 + 530259564 cannot be represented in type 'long'
Fixes: 49093/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_O_fuzzer-4697179192688640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-10-20 21:42:20 +02:00
Tristan Matthews
eb9153b4a7 avformat/hls: fix spelling and grammar on wrap warning 2022-10-20 16:27:06 +05:30
Paul B Mahol
754d52cf42 avfilter/window_func: add kaiser window 2022-10-20 12:13:37 +02:00
Paul B Mahol
37efcb473f avcodec/mpegaudiodec_common: fix values for 24k sample rate 2022-10-20 10:06:50 +02:00
Andreas Rheinhardt
db42f70b3f avcodec/mpeg4videodec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
77f8d2da9d avcodec/mpeg4videodec: Remove always-true checks
codec_id is always AV_CODEC_ID_MPEG4 for mpeg4_decode_mb(),
as the MPEG-4 decoder is the only decoder for which
ff_mpeg4_decode_picture_header() as well as decode_init()
are ever called and these are the only places where
the decode_mb function pointer is ever set to mpeg4_decode_mb().
ff_mpeg4_workaround_bugs() is also only called for the MPEG-4
decoder (the caller checks the codec id).

(ff_mpeg4_decode_picture_header() is also called for the MPEG-4
parser, but it never uses the decode_mb function pointer.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
e19d10645c avcodec/mpeg4videodec: Sync sprite_warping_accuracy between threads
It is set in the vol header and is therefore a sequence and
not only a picture property.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
5d93c330f7 avcodec/mpegvideo: Move sprite-related fields to Mpeg4DecContext
Only used there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
4209216ee8 avcodec/mpegvideodsp: Make MpegVideoDSP MPEG-4 only
It is only used by gmc/gmc1 which is only used by the MPEG-4
decoder, so move it to Mpeg4DecContext and rename it
to Mpeg4VideoDSP. Also compile it iff the MPEG-4 decoder is compiled.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
ac8afdb9b5 avcodec/mpegvideo_motion: Move mspel/gmc motion to mpeg4videodec.c
It is the only codec for which mcsel is ever set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:56:17 +02:00
Andreas Rheinhardt
eb1ce6e3c7 avcodec/mpv_reconstruct_mb_template: Optimize dead code away
None of the MPEG-1/2 codecs support frame threading,
so one can optimize the check for it away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:32:28 +02:00
Andreas Rheinhardt
7d23b350c2 avcodec/mpeg12dec: Remove always-true check
mpeg12dec.c is a decoder-only file.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:29:05 +02:00
Andreas Rheinhardt
6fe4e8fab4 avcodec/mpegvideo: Split ff_mpv_reconstruct_mb() into de/encoder part
This has the advantage of not having to check for whether
a given MpegEncContext is actually a decoder or an encoder
context at runtime.

To do so, mpv_reconstruct_mb_internal() is moved into a new
template file that is included by both mpegvideo_enc.c
and mpegvideo_dec.c; the decoder-only code (mainly lowres)
are also moved to mpegvideo_dec.c. The is_encoder checks are
changed to #if IS_ENCODER in order to avoid having to include
headers for decoder-only functions in mpegvideo_enc.c.

This approach also has the advantage that it is easy to adapt
mpv_reconstruct_mb_internal() to using different structures
for decoders and encoders (e.g. the check for whether
a macroblock should be processed for the encoder or not
uses MpegEncContext elements that make no sense for decoders
and should not be part of their context).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:29:03 +02:00
Andreas Rheinhardt
9ca312d8ab avcodec/mpegvideo: Inline is_encoder in mpv_reconstruct_mb_internal()
Up until now, we inlined lowres_flag as well as is_mpeg12
independently (unless CONFIG_SMALL was true); this commit
changes this to instead inline mpv_reconstruct_mb_internal()
(at most) four times, namely once for encoders, once for decoders
using lowres and once for non-lowres mpeg-1/2 decoders and once
for non-lowres non-mpeg-1/2 decoders (mpeg-1/2 is not inlined
in case of CONFIG_SMALL). This is neutral performance-wise,
but proved beneficial size-wise: It saved 1776B of .text
for GCC 11 or 1344B for Clang 14 (both -O3 x64).

Notice that inlining is_mpeg12 for is_encoder would not really
be beneficial, as the encoder codepath does mostly not depend
on is_mpeg12 at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:21:33 +02:00
Andreas Rheinhardt
409c4723ec avcodec/mpegvideo: Make inlining is_mpeg12 more flexible
There are two types of checks for whether the current codec
is MPEG-1/2 in mpv_reconstruct_mb_internal(): Those that are
required for correctness and those that are not; an example
of the latter is "is_mpeg12 || (s->codec_id != AV_CODEC_ID_WMV2)".
The reason for the existence of such checks is that
mpv_reconstruct_mb_internal() has the av_always_inline attribute
and is_mpeg12 is usually inlined, so that in case we are dealing
with MPEG-1/2 the above check can be completely optimized away.

But is_mpeg12 is not always inlined: it is not in case
CONFIG_SMALL is true in which case is_mpeg12 is always zero,
so that the checks required for correctness need to check
out_format explicitly. This is currently done via a macro
in mpv_reconstruct_mb_internal(), so that the fact that
it is CONFIG_SMALL that determines this is encoded at two places.

This commit changes this by making is_mpeg12 a three-state:
DEFINITELY_MPEG12, MAY_BE_MPEG12 and NOT_MPEG12. In the second
case, one has to resort to check out_format, in the other cases
is_mpeg12 can be taken at face-value. This will allow to make
inlining is_mpeg12 more flexible in a future commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:09:11 +02:00
Andreas Rheinhardt
cab876f5f4 avcodec/mpegvideo: Ignore skip_idct for encoders
It is documented to be unused for encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 07:09:11 +02:00
Andreas Rheinhardt
a5e59fec07 avcodec/ffv1: Move ffv1_template.c inclusion to dec/enc templates
Both the FFV1 decoder and encoder use a template of their own
to generate code multiple times. They also use a common template,
used by both decoder and encoder templates which is currently
instantiated in ffv1.h (and therefore also in ffv1.c, which
doesn't need it at all).

All these templates have the prerequisite that two macros
are defined, namely RENAME() and TYPE. The codec-specific
templates call the functions generated via the common template
via the RENAME() macro and therefore the macros used for
the common template must coincide with the macros used for
the codec-specific templates. But then it is better to not
instantiate the common template in ffv1.h, but in the codec
specific templates.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
f63c6c81d4 avcodec/mpegutils: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
678f1b1cf4 avcodec/mpegutils: Return early in ff_draw_horiz_band()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
85f02c300f avcodec/mpegvideo: Move VIDEO_FORMAT_* defines to mpeg12enc.c
Forgotten in f899e3b51b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
9e32f2ebfd avcodec/h261: Use ptrdiff_t for stride
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
10dfbb0502 avcodec/mpegvideo: Reindent after the last commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
5ecf5b93dd avcodec/mpegvideo: Don't check for draw_horiz_band
Some parts of mpegvideo.c behave differently depending
upon whether AVCodecContext.draw_horiz_band is set or not.
This differing behaviour makes lots of FATE tests fail
and leads to garbage output, although setting this callback
is not supposed to change the output at all.

These checks have been added in commits
3994623df2 and
b68ab2609c. The commit messages
do not contain a real reason for adding the checks and it is
indeed a mystery to me. But removing these checks fixes
the FATE tests when one adds an (empty) draw_horiz_band
when using a codec that claims to support it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
5bcae5251f avcodec/vc1_block: Remove dead calls to ff_mpeg_draw_horiz_band()
The VC-1 decoders don't support draw_horiz_band at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
Andreas Rheinhardt
e0c01a62ad avcodec/(ffv1|h264|png|snow)dec: Remove comment out DRAW_HORIZ_BAND cap
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-20 06:57:30 +02:00
James Almer
1f63225f2b avcodec/librav1e: support AV_CODEC_CAP_ENCODER_RECON_FRAME
This bumps the minimum required version to 0.5.0

Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-19 11:15:38 -03:00
James Almer
f58f238936 avcodec/librav1e: export extradata on init()
librav1e provides a function to create extradata, so use it instead of
extracting the sequence header OBU from packets.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-19 10:13:37 -03:00
James Almer
d569958d29 avcodec/librav1e: support setting sample aspect ratio
Signed-off-by: James Almer <jamrial@gmail.com>
2022-10-19 10:13:37 -03:00
Andreas Rheinhardt
30e1f5ec77 avcodec/startcode: Avoid unaligned accesses
Up until now, ff_startcode_find_candidate_c() simply casts
an uint8_t* to uint64_t*/uint32_t* to read 64/32 bits at a time
in case HAVE_FAST_UNALIGNED is true. Yet this ignores the
alignment requirement of these types as well as effective type
rules of the C standard. This commit therefore replaces these
direct accesses with AV_RN64/32; this also improves
readability.

UBSan reported these unaligned accesses which happened in 233
FATE-tests involving H.264 and VC-1 (this has also been reported
in tickets #8138 and #8485); these tests are fixed by this commit.

The output of GCC with -O3 is unchanged for aarch64, loongarch,
ppc and x64 (as well as for arches like alpha for which
HAVE_FAST_UNALIGNED is never true in the first place).
There was only a slight difference for mips and arm.
I don't know about the speed impact of them.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-19 13:48:31 +02:00
Jan Ekström
b9058765d7 ffmpeg: Deprecate display rotation override with a metadata key
Now that we have proper options for defining display matrix
overrides, this should no longer be required.

fftools does not have its own versioning, so for now the define is
just set to 1 and disables the functionality if set to zero.
2022-10-19 11:53:52 +02:00
Jan Ekström
c889248647 ffmpeg: Add display_{rotation, hflip, vflip} options
This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on the input side.

Additionally, switch the singular test that was utilizing the rotation
metadata to instead override the input display rotation, thus leading
to the same result.
2022-10-19 11:53:52 +02:00
Andreas Rheinhardt
81bc4ef142 avcodec/msmpeg4data: Mark tables as hidden
This e.g. allows compilers to bake the "+ 256" offset
used to access ff_v2_dc_(lum|chroma)_table into
the general offset; for certain arches this is also necessary
in order to avoid building suboptimal code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-18 15:44:29 +02:00