Commit Graph

188 Commits

Author SHA1 Message Date
Andreas Rheinhardt
cee04cbfe1 avcodec/decode: Fix leaks upon subtitle decoding errors
Up until now, various subtitle decoders have not cleaned up
the AVSubtitle on error; this task must not be left to the user
because the documentation explicitly states that the AVSubtitle
"must be freed with avsubtitle_free if *got_sub_ptr is set"
(which it isn't on error).
Leaks happen upon failure in ff_ass_add_rect() or in
ass_decode_frame(); freeing generically also allows to remove
now redundant freeing code in pgssubdec and dvbsubdec.
While just at it, also reset got_sub_ptr generically on error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-16 02:37:26 +01:00
Andreas Rheinhardt
a4798a5d51 all: Use av_memdup() where appropriate
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-12-03 16:07:02 +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
b3108b1cbc avcodec/dvbsubdec: Make decoder init-threadsafe
Note: This decoder uses a static variable in save_display_set() (which
is only enabled if DEBUG is defined); yet said function can't be reached
from the decoder's init function at all, so it is no problem for
setting the FF_CODEC_CAP_INIT_THREADSAFE flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-05-02 05:14:42 +02:00
Andreas Rheinhardt
834ef6f4a9 avcodec/dvbsubdec: Add const where appropriate
These pointers sometimes point to static storage (namely to
default_clut), so adding const to the pointed-to type is important to
ensure that one does not accidentally modify something that is not owned
by a single AVCodecContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-05-02 05:14:42 +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
Andreas Rheinhardt
d947464ad4 avcodec: Remove deprecated AVPicture API
Deprecated in a17a766190.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 10:43:04 -03:00
Michael Niedermayer
7b4510d2a8 avcodec/dvbsubdec: Support computing clut only once
This avoids crafted files from consuming excessive resources recomputing the clut after each pixel change

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-03-29 22:19:39 +02:00
Clément Bœsch
a469d29c08 avcodec/dvbsubdec: error out on unsupported coding methods 2020-08-22 19:02:01 +02:00
Clément Bœsch
b0f96f663c avcodec/dvbsubdec: request samples for missing coding methods 2020-08-22 19:02:01 +02:00
Limin Wang
9cfed6d84a avcodec/dvbsubdec: Cosmetics
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-08 23:09:29 +08:00
Limin Wang
c32114e0a5 avcodec/dvbsubdec: prefer to use variable instead of type for sizeof
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-08 23:09:29 +08:00
Limin Wang
e72e4b6967 avcodec/dvbsubdec: simplify code by using OFFSET() macro
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
2020-07-08 23:09:29 +08:00
Limin Wang
157873623f avcodec/dvbsubdec: replace data_size with got_sub_ptr for better readability
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-03-25 18:41:21 +01:00
Michael Niedermayer
5941b7f615 avcodec/dvbsubdec: Use ff_set_dimensions()
Fixes: signed integer overflow: 65313 * 65313 cannot be represented in type 'int'
Fixes: 15740/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVBSUB_fuzzer-5641749164195840

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-07-20 19:05:02 +02:00
Michael Niedermayer
a8c5ae4511 avcodec/dvbsubdec: Check object position
Reference: ETSI EN 300 743 V1.2.1  7.2.2 Region composition segment

Fixes: Timeout
Fixes: 13325/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVBSUB_fuzzer-5143979392237568

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-14 16:24:35 +01:00
Michael Niedermayer
71ba79702d avcodec/dvbsubdec: Compute scoretab without iterating over pixels multiple times in compute_default_clut()
Improves speed 102->2 sec
Testcase: 8655/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVBSUB_fuzzer-6277869285146624
Fixes: Timeout

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2018-06-27 13:43:39 +02:00
Michael Niedermayer
eec67f7b24 avcodec/dvbsubdec: Avoid re-computing clut
Fixes: Timeout
Fixes: 3218/clusterfuzz-testcase-5390672154591232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-11-15 17:31:09 +01:00
James Almer
7d1c79f533 Merge commit 'a594f17f83a1ffdc1eec18818208fe39487dd5d7'
* commit 'a594f17f83a1ffdc1eec18818208fe39487dd5d7':
  dvbsubdec: Free subrect memory on allocation error
  dvbsubdec: Fixed segfault when decoding subtitles

See
fbb59a3bf4
39dfe6801a

Merged-by: James Almer <jamrial@gmail.com>
2017-11-06 18:46:05 -03:00
Michael Niedermayer
963247b5f3 avcodec/dvbsubdec: Split best score computation out of loop in compute_default_clut()
3% faster

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-10-14 23:23:25 +02:00
Michael Niedermayer
cd2f69cdd6 avcodec/dvbsubdec: Factor a few expressions out of compute_default_clut()
32% faster loop

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-10-14 23:23:25 +02:00
Michael Niedermayer
7c10068da1 avcodec/dvbsubdec: Check for duplicate regions in dvbsub_parse_page_segment()
Fixes: OOM
Fixes: 3051/clusterfuzz-testcase-minimized-5745818336231424

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-25 23:38:24 +02:00
Vittorio Giovara
a594f17f83 dvbsubdec: Free subrect memory on allocation error
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-06-28 09:44:09 -04:00
Lorenz Brun
1cfd566324 dvbsubdec: Fixed segfault when decoding subtitles
This fixes a segfault (originally found in Movian, but traced to libav)
when decoding subtitles because only an array of rects is allocated,
but not the actual structs it contains. The issue was probably
introduced in commit 2383323 where the loop to allocate the rects in
the array was thrown away.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2017-06-28 09:44:09 -04:00
Michael Niedermayer
e1b0044c23 avcodec/dvbsubdec: Check pixel buffer size constraint from ETSI EN 300 743 V1.3.1
Fixes: OOM
Fixes: 2143/clusterfuzz-testcase-minimized-5482288060039168

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-10 00:48:07 +02:00
Michael Niedermayer
4bcde26172 avcodec/dvbsubdec: Use av_image_check_size2()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-06-10 00:48:07 +02:00
Michael Niedermayer
8a69f2602f avcodec/dvbsubdec: Check entry_id
Fixes: randomly writing over the array end
Fixes: 1473/clusterfuzz-testcase-minimized-5768907824562176

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-11 15:51:08 +02:00
Michael Niedermayer
0075d9eced avcodec/dvbsubdec: check region dimensions
Fixes: 1408/clusterfuzz-testcase-minimized-6529985844084736
Fixes: integer overflow

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-08 15:28:26 +02:00
Michael Niedermayer
b02027c79d avcodec/dvbsubdec: Replace fprintf(stderr) by av_log()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-04-05 23:57:08 +02:00
Clément Bœsch
7650bccdb1 Merge commit 'b34c6cd57a2e8aad5f773aea933f77883de320ec'
* commit 'b34c6cd57a2e8aad5f773aea933f77883de320ec':
  dvbsub: cosmetics: Group all debug code together

Merged-by: Clément Bœsch <u@pkh.me>
2017-04-03 21:02:54 +02:00
Clément Bœsch
9f7ba0ac9d Merge commit 'b8cd7a3c8df2c3aac8d7a0b5a02d83caf61bd769'
* commit 'b8cd7a3c8df2c3aac8d7a0b5a02d83caf61bd769':
  dvbsub: Check for errors from system()

printf(...) replaced with fprintf(stderr, ...) for logging errors.

Merged-by: Clément Bœsch <u@pkh.me>
2017-04-03 21:01:40 +02:00
Clément Bœsch
ff66ba6feb Merge commit '7effebde78977fafce935776153ea2f7c0981fa3'
* commit '7effebde78977fafce935776153ea2f7c0981fa3':
  dvbsubdec: Remove disabled, near-duplicate debug code

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-19 16:10:17 +01:00
Diego Biurrun
a25dac976a Use bitstream_init8() where appropriate 2017-02-07 18:27:21 +01:00
Alexandra Hájková
9aec009f65 dvbsubdec: Convert to the new bitstream reader 2017-01-09 15:21:47 +01:00
Diego Biurrun
b34c6cd57a dvbsub: cosmetics: Group all debug code together 2016-11-23 07:40:46 +01:00
Diego Biurrun
b8cd7a3c8d dvbsub: Check for errors from system()
libavcodec/dvbsubdec.c:145:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
libavcodec/dvbsubdec.c:148:5: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
2016-11-23 07:36:32 +01:00
Andreas Cadhalpun
c82b8ef0e4 dvbsubdec: fix division by zero in compute_default_clut
This problem was introduced in commit
4b90dcb849.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
2016-11-10 21:01:59 +01:00
Diego Biurrun
7effebde78 dvbsubdec: Remove disabled, near-duplicate debug code 2016-08-17 12:16:42 +02:00
Diego Biurrun
e723dce6f8 dvbsubdec: Use NULL instead of 0 as pointer value 2016-08-03 08:26:40 +02:00
Clément Bœsch
a4403e49b9 Merge commit 'b7e64fba7f37cc0399beae844f0a5dbef9219376'
* commit 'b7e64fba7f37cc0399beae844f0a5dbef9219376':
  Reduce the scope of some variables

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 22:40:56 +02:00
Diego Biurrun
b7e64fba7f Reduce the scope of some variables
This avoids unused variable warnings after the next version bump.
Also drop a trace level av_log() call that is in the way.
2016-05-11 12:21:25 +02:00
Clément Bœsch
fb99ef0bd3 avcodec: use AV_OPT_TYPE_BOOL in a bunch of places 2015-12-04 15:37:05 +01:00
Hendrik Leppkes
ee573b4d31 Merge commit 'a17a7661906ba295d67afd80ac0770422e1b02b3'
* commit 'a17a7661906ba295d67afd80ac0770422e1b02b3':
  lavc: Add data and linesize to AVSubtitleRect

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-22 21:41:53 +02:00
Vittorio Giovara
a17a766190 lavc: Add data and linesize to AVSubtitleRect
Use the new fields directly instead of the ones from AVPicture.
This removes a layer of indirection which serves no pratical purpose
whatsoever, and will help in removing AVPicture structure completely
later.

Every subtitle encoder/decoder seamlessly points to the new arrays,
so it is possible to deprecate AVSubtitleRect.pict.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2015-10-21 12:02:29 +02:00
Hendrik Leppkes
fbd71bba85 Merge commit '1da2a20763ae9ca579d5fd20763065871ddf6311'
* commit '1da2a20763ae9ca579d5fd20763065871ddf6311':
  dvbsubdec: Fix function return type

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-05 11:25:40 +02:00
Vittorio Giovara
1da2a20763 dvbsubdec: Fix function return type 2015-10-04 13:07:12 +02:00
Ronald S. Bultje
6471040f56 FF_OPT_TYPE_* -> AV_OPT_TYPE_*. 2015-08-18 11:48:49 -04:00
Michael Niedermayer
d21ab8e411 avcodec/dvbsubdec: Print field lens in case they are too lerge
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-13 01:50:08 +02:00
Carl Eugen Hoyos
daf2c35f52 lavc: Remove newline from avpriv_request_sample() calls. 2015-08-11 22:50:45 +02:00
Michael Niedermayer
e5774f28d1 avcodec/dvbsubdec: Do not stop decoding at a invalid depth
This corrects parsing the later elements

Fixes Ticket4754

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-08-05 00:16:43 +02:00