Commit Graph

33 Commits

Author SHA1 Message Date
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01: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
Andreas Rheinhardt 66b691f99f avcodec/internal: Move ff_get_buffer() to decode.h
Only used by decoders (encoders have ff_encode_alloc_frame()).

Also clean up the other headers a bit while removing now redundant
internal.h inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-08-27 14:14:56 +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 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
Andreas Rheinhardt 7b10083933 avcodec: Factor updating palette out
Because the properties of frames returned from ff_get/reget_buffer
are not reset at all, lots of returned frames had palette_has_changed
wrongly set to 1. This has been changed, too.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-03-22 02:43:04 +01:00
James Almer d8a18c8fc2 avcodec: use the buffer_size_t typedef where required
Signed-off-by: James Almer <jamrial@gmail.com>
2021-03-10 20:26:36 -03:00
Andreas Rheinhardt 7e8306dd2d avcodec/gdv: Remove dead check
At the end of its decode function, the decoder sets *got_frame to 1 and
then checks whether ret is < 0; if so, it is returned, otherwise
avpkt->size is. But it is impossible for ret to be < 0 here and if it
were, it would be nonsense to set *got_frame to 1 before this. Therefore
just return avpkt->size unconditionally.

Fixes Coverity issue #1439730.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-11-10 02:14:29 +01:00
Michael Niedermayer a9fae76370 avcodec/gdv: Replace assert() checking bitstream by if()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-09-16 00:04:18 +02:00
Michael Niedermayer 5a6fc87443 avcodec/gdv: Check remaining output after decode 5/6/8/
Improves: Timeout (355sec -> 97sec)
Improves: 14709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5704215281795072

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2019-05-31 22:44:30 +02:00
Michael Niedermayer f857753f56 avcodec/gdv: Check input palette size before rescale()
Fixes: Timeout (22sec -> 11sec)
Fixes: 13576/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5681024577568768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-26 17:25:14 +02:00
Michael Niedermayer 5cf42f65b6 avcodec/gdv: Check for truncated tags in decompress_5()
Testcase: 13169/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5666354038833152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-03-03 13:17:02 +01:00
Michael Niedermayer 6e23736aef avcodec/gdv: Optimize and factorize scaling loops
Fixes: Timeout
Fixes: 11067/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5686623711264768

Before change: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5686623711264768 in 34386 ms
After  change: Executed clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5686623711264768 in 24327 ms

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-14 17:16:55 +01:00
Michael Niedermayer 2d580d727c avcodec/gdv: Optimize unscaled loop
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-01-05 22:36:12 +01:00
Michael Niedermayer 2076e11839 avcodec/gdv: Remove unused variable
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-30 22:23:02 +02:00
Michael Niedermayer 35517e3ca7 avcodec/gdv: Error out if we had insufficent input for the output frame in decompress_2()
Fixes: Timeout (with the previous commits to gdv.c)
Fixes: 9422/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5143490001371136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer 510bd61941 avcodec/gdv: Optimize 2x scaling loop a little in gdv_decode_frame()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer 6a4788e7b3 avcodec/gdv: Replace loop in gdv_decode_frame() by memcpy()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer 5f84fbce08 avcodec/gdv: Eliminate 50% of the reads in the first inner loop in rescale()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer d021729efc avcodec/gdv: Simplify first inner loop in rescale()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer 6228ce0a33 avcodec/gdv: Combine first and 3rd case in rescale()
Simplifies code

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer a423970511 avcodec/gdv: Factor terms out of inner loops in rescale()
This also replaces some loops by memcpy()

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer b90d8cc746 avcodec/gdv: Replace divisions by shifts in rescale()
Divisions tend to be slower than shifts unless the compiler optimizes them out.
And some of these are in inner loops.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-09-28 01:25:17 +02:00
Michael Niedermayer cf5a6c754a avcodec/gdv: Check compression before allocating frame
Fixes: 2926/clusterfuzz-testcase-4987110014582784

This reduces decoding time from 7 to 4 seconds

The timeout should have been fixed in 0561bd2fc2 but ossfuzz did not close this issue

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-11-03 00:56:30 +01:00
Michael Niedermayer 0561bd2fc2 avcodec/gdv: Check available space before reading palette
Fixes: Timeout
Fixes: 2926/clusterfuzz-testcase-498711001458278

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-08-11 19:27:52 +02:00
Paul B Mahol 4d681269e0 avcodec/gdv: add decompression for 2 and 5 method
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-29 15:54:20 +02:00
Michael Niedermayer 9b65dbf734 avcodec/gdv: Fix undefined shift
Fixes: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
Fixes: 2249/clusterfuzz-testcase-minimized-5388542379294720

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-16 23:32:28 +02:00
Paul B Mahol 9a949cdf8f avcodec/gdv: fix compiler warnings
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-11 10:26:18 +02:00
Paul B Mahol d1c08027d8 avcodec: add Gremlin Digital Video decoder
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-06-11 10:00:39 +02:00