1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-07 11:13:41 +02:00
Commit Graph

87 Commits

Author SHA1 Message Date
James Almer
2f561ba953 avcodec: use the new AVFrame interlace flags in all decoders and encoders
Signed-off-by: James Almer <jamrial@gmail.com>
2023-05-04 18:14:02 -03:00
Andreas Rheinhardt
9e9c99366a avcodec/cfhd, cfhddata: Free VLC as soon as it is not needed
The VLC is only used to initialize RL VLC.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 14:28:13 +02:00
Andreas Rheinhardt
6b1a7fc8bd avcodec/cfhd, cfhddata: Simplify check for escape
cfhd.c checked for level being equal to a certain codebook-
dependent constant and to run being two. The first check is
actually redundant, as all codebooks contain only one (real)
entry with run == 2 (as is usual with VLCs, this one real entry
has several corresponding entries in the table). But given
that no entry has a run of zero (except incomplete entries
which just signal that one needs to do another round of parsing),
one can actually use that as sentinel. This patch does so.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-05 14:22:30 +02:00
Andreas Rheinhardt
73fada029c avcodec/codec_internal: Add macros for update_thread_context(_for_user)
It reduces typing: Before this patch, there were 11 callbacks
that exceeded the 80 char line length limit; now there are zero.
It also allows to remove ONLY_IF_THREADS_ENABLED() in
libavutil/internal.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:57 +02:00
Andreas Rheinhardt
48286d4d98 avcodec/codec_internal: Add macro to set AVCodec.long_name
It reduces typing: Before this patch, there were 105 codecs
whose long_name-definition exceeded the 80 char line length
limit. Now there are only nine of them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-03 15:42:57 +02:00
Paul B Mahol
4beac58e90 avcodec/cfhd: fix escape handling for old codebook 2022-09-03 14:44:58 +02:00
Andreas Rheinhardt
b9eaf77ed1 avcodec/internal: Move ff_set_dimensions() to decode.h
Decoder-only, as the dimensions are set by the user when encoding.

Also fixup the other headers a bit while removing unnecessary internal.h
inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27 14:14:57 +02:00
Andreas Rheinhardt
21b23ceab3 avcodec: Make init-threadsafety the default
and remove FF_CODEC_CAP_INIT_THREADSAFE
All our native codecs are already init-threadsafe
(only wrappers for external libraries and hwaccels
are typically not marked as init-threadsafe yet),
so it is only natural for this to also be the default state.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-07-18 20:04:59 +02:00
Andreas Rheinhardt
4243da4ff4 avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
This is possible, because every given FFCodec has to implement
exactly one of these. Doing so decreases sizeof(FFCodec) and
therefore decreases the size of the binary.
Notice that in case of position-independent code the decrease
is in .data.rel.ro, so that this translates to decreased
memory consumption.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 20:02:37 +02:00
Andreas Rheinhardt
ce7dbd0481 avcodec/codec_internal: Make FFCodec.decode use AVFrame*
This increases type-safety by avoiding conversions from/through void*.
It also avoids the boilerplate "AVFrame *frame = data;" line
for non-subtitle decoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 19:54:09 +02:00
Andreas Rheinhardt
20f9727018 avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec
Up until now, codec.h contains both public and private parts
of AVCodec. This exposes the internals of AVCodec to users
and leads them into the temptation of actually using them
and forces us to forward-declare structures and types that
users can't use at all.

This commit changes this by adding a new structure FFCodec to
codec_internal.h that extends AVCodec, i.e. contains the public
AVCodec as first member; the private fields of AVCodec are moved
to this structure, leaving codec.h clean.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt
a688f3c13c avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.h
Also move FF_CODEC_TAGS_END as well as struct AVCodecDefault.
This reduces the amount of files that have to include internal.h
(which comes with quite a lot of indirect inclusions), as e.g.
most encoders don't need it. It is furthemore in preparation
for moving the private part of AVCodec out of the public codec.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt
02220b88fc avcodec/thread: Don't use ThreadFrame when unnecessary
The majority of frame-threaded decoders (mainly the intra-only)
need exactly one part of ThreadFrame: The AVFrame. They don't
need the owners nor the progress, yet they had to use it because
ff_thread_(get|release)_buffer() requires it.

This commit changes this and makes these functions work with ordinary
AVFrames; the decoders that need the extra fields for progress
use ff_thread_(get|release)_ext_buffer() which work exactly
as ff_thread_(get|release)_buffer() used to do.

This also avoids some unnecessary allocations of progress AVBuffers,
namely for H.264 and HEVC film grain frames: These frames are not
used for synchronization and therefore don't need a ThreadFrame.

Also move the ThreadFrame structure as well as ff_thread_ref_frame()
to threadframe.h, the header for frame-threaded decoders with
inter-frame dependencies.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-09 17:22:35 +01:00
Michael Niedermayer
cd6ac013a0 avcodec/cfhd: Avoid signed integer overflow in coeff
Fixes: signed integer overflow: 15244032 * 256 cannot be represented in type 'int'
Fixes: 43504/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4865014842916864

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-02-01 16:50:27 +01:00
Andreas Rheinhardt
1ea3650823 Replace all occurences of av_mallocz_array() by av_calloc()
They do the same.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-20 01:03:52 +02:00
Andreas Rheinhardt
a247ac640d avcodec: Constify AVCodecs
Given that the AVCodec.next pointer has now been removed, most of the
AVCodecs are not modified at all any more and can therefore be made
const (as this patch does); the only exceptions are the very few codecs
for external libraries that have a init_static_data callback.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:15 -03:00
Michael Niedermayer
da8c86dd8b avcodec/cfhd: Keep track of which subbands have been read
This avoids use of uninitialized data
also several checks are inside the band reading code
so it is important that it is run at least once

Fixes: out of array accesses
Fixes: 28209/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5684714694377472
Fixes: 32124/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5425980681355264
Fixes: 30519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4558757155700736

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-03 19:27:21 +02:00
Michael Niedermayer
3b88c88fa1 avcodec/cfhd: Require valid setup before Lowpass coefficients, BandHeader and BandSecondPass
Previously the code skipped all security checks when these where encountered but prior data was incorrect.
Also replace an always true condition by an assert

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-03 19:27:21 +02:00
Michael Niedermayer
20473a93d2 avcodec/cfhd: Check transform_type consistently
Fixes: out of array accesses
Fixes: 29754/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6333598414274560
Fixes: 30519/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6298424511168512
Fixes: 30739/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5011292836462592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-04-03 19:27:21 +02:00
Michael Niedermayer
cd3ab3a09b avcodec/cfhd: Fix negative shift in cfhd_decode()
Fixes: left shift of negative value -1
Fixes: 30714/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4867823371419648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-14 23:29:51 +01:00
Michael Niedermayer
386faeda5f avcodec/cfhd: check peak.offset
Fixes: signed integer overflow: -2147483648 - 4 cannot be represented in type 'int'
Fixes: 26907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5746202330267648

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-29 19:36:46 +01:00
Paul B Mahol
f975cf7cc0 avcodec/cfhd: only increase s->level if transform is supported 2021-01-17 13:40:15 +01:00
Paul B Mahol
676689cc7c avcodec/cfhd: properly handle midstream size changes for transform type 2 2020-12-25 13:28:39 +01:00
Paul B Mahol
aed8f40d45 avcodec/cfhd: check that lowpass_height is >= 3 when used in vertical filter
Also check for out of buffer access.
Also return early when encountering fatal error.
2020-09-23 23:04:36 +02:00
Michael Niedermayer
659658d08b avcodec/cfhd: Check transform type
Fixes: out of array access
Fixes: 24823/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4855119863349248

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Michael Niedermayer
2359656da2 avcodec/cfhd: Replace a few literal numbers by named constants
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-08-30 16:18:37 +02:00
Andreas Rheinhardt
5c923ce668 avcodec/cfhd: Remove unused-but-set variable
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-08-28 00:43:28 +02:00
Paul B Mahol
389cc142fb avcodec/cfhd: add x86 SIMD
Overall speed changes for 1920x1080, yuv422p10le, 60fps from: 0.19x to 0.343x
2020-08-26 21:13:38 +02:00
Paul B Mahol
9f702fc8f4 avcodec: extend CFHD description 2020-08-14 10:52:28 +02:00
Paul B Mahol
4ad77086b9 avcodec/cfhd: improve SampleIndex tag output
This tag is used for jumping to different channels in bitstream.
2020-08-09 18:47:30 +02:00
Paul B Mahol
17d1454a5f avcodec/cfhd: log version tags too 2020-08-09 18:47:29 +02:00
Paul B Mahol
fc3546bece avcodec/cfhd: read prescale table tag
Currently unused. Remove prescale shift tag as it
is not part of this codec.
2020-08-09 18:47:29 +02:00
Paul B Mahol
3ff7171a85 avcodec/cfhd: use init_get_bits8() 2020-08-09 18:47:29 +02:00
Paul B Mahol
25d07e1394 avcodec/cfhd: reindent 2020-08-09 18:47:28 +02:00
Paul B Mahol
8c7ea0c344 avcodec/cfhd: check if band encoding is valid
Also simplify lossless check as value of 5 for band encoding
always specify lossless mode.
2020-08-09 18:47:28 +02:00
Paul B Mahol
1006a21512 avcodec/cfhd: add 3d transform support
Based on Gagandeep Singh patch.
2020-08-08 12:03:43 +02:00
Paul B Mahol
1c6a010e3b avcodec/cfhd: remove some unused or only write items 2020-08-08 12:03:43 +02:00
Paul B Mahol
6ce4338943 avcodec/cfhd: fix overflow in multiplication in LUT calculation 2020-08-04 08:22:51 +02:00
Paul B Mahol
acaed62ad1 avcodec/cfhd: correct 71 tag usage
It stores input format and never codebook.
2020-08-03 22:45:17 +02:00
Paul B Mahol
05e58ce4e2 avcodec/cfhd: use LUT for 9 and 18 codebook decompanding
Also fix codebook 9 decompanding, fixing artifact with codebook 9
samples. Reused Gagandeep Singh patch.
2020-08-03 22:22:07 +02:00
Paul B Mahol
533d6030ca avcodec/cfhd: set correct bits_per_raw_sample 2020-08-02 09:33:24 +02:00
Paul B Mahol
e2b455f933 avcodec/cfhd: add more tag names 2020-08-02 09:33:24 +02:00
Paul B Mahol
4e27817629 avcodec: add CFHD encoder 2020-08-02 09:33:24 +02:00
Paul B Mahol
131d2a3e1c avcodec/cfhd: improve decompanding quality with reference implementation 2020-08-02 09:31:54 +02:00
Paul B Mahol
f7e35c8163 avcodec/cfhd: fix non-aligned to 8 height decoding 2020-08-02 09:31:54 +02:00
Paul B Mahol
fabbb680d4 avcodec/cfhd: move if/else out of loop in inverse transform 2020-08-02 09:31:54 +02:00
Kieran Kunhya
ec33f7793e cfhd: Add tag names 2020-07-04 16:27:24 +01:00
Anton Khirnov
1f4cf92cfb pthread_frame: merge the functionality for normal decoder init and init_thread_copy
The current design, where
- proper init is called for the first per-thread context
- first thread's private data is copied into private data for all the
  other threads
- a "fixup" function is called for all the other threads to e.g.
  allocate dynamically allocated data
is very fragile and hard to follow, so it is abandoned. Instead, the
same init function is used to init each per-thread context. Where
necessary, AVCodecInternal.is_copy can be used to differentiate between
the first thread and the other ones (e.g. for decoding the extradata
just once).
2020-04-10 15:24:54 +02:00
Michael Niedermayer
9fac243744 avcodec/cfhd: Check that cropped size is smaller than full
Fixes: signed integer overflow: 57342 * 120830 cannot be represented in type 'int'
Fixes: 16426/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5758744817827840

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2019-09-16 00:53:18 +02:00
Michael Niedermayer
58e084bd2c avcodec/cfhd: Check destination space for bayer before writing
Fixes: out of array write
Fixes: 16105/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5690817309573120
Fixes: 16119/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5099050675732480
Fixes: 16135/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5705501601431552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-08-05 17:54:24 +02:00