summaryrefslogtreecommitdiff
path: root/libavcodec/dvdsubdec.c
Commit message (Collapse)AuthorAgeFilesLines
* avcodec/codec_internal: Add macro to set AVCodec.long_nameAndreas Rheinhardt2022-09-031-1/+1
| | | | | | | | 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>
* avutil/internal: Move avpriv-file API to a header of its ownAndreas Rheinhardt2022-09-031-0/+1
| | | | | | | It is not used by the large majority of files that include lavu/internal.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move ff_dvdsub_parse_palette() to new header dvdsub.hAndreas Rheinhardt2022-08-271-1/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/internal: Move ff_set_dimensions() to decode.hAndreas Rheinhardt2022-08-271-1/+1
| | | | | | | | | 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>
* avcodec: Make init-threadsafety the defaultAndreas Rheinhardt2022-07-181-1/+0
| | | | | | | | | | | 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>
* avcodec/dvdsubdec, dvbsubdec: remove bitmap dumping in DEBUG buildssoftworkz2022-06-081-48/+0
| | | | | | | | | It's been a regular annoyance and often undesired. There will be a subtitle filter which allows to dump individual subtitle bitmaps. Signed-off-by: softworkz <softworkz@hotmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avcodec/dvdsubdec: use avpriv_fopen_utf8() instead of plain fopen()softworkz2022-05-241-1/+1
| | | | | | | | Unify file access operations by replacing usages of direct calls to posix fopen() to prepare for long filename support on Windows. Signed-off-by: softworkz <softworkz@hotmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
* avcodec/dvdsubdec: fix incorrect yellow appearance of dvd subtitlessoftworkz2022-04-091-1/+1
| | | | | | | | | | | | The guess_palette() implementation is questionable in itself as its results don't match those from other DVD subtitle decoders. This commit starts cleanup by fixing an obvious bug which has made certain DVD subs appear yellow instead of white or grey for more than 10 years.. Signed-off-by: softworkz <softworkz@hotmail.com> Signed-off-by: rcombs <rcombs@rcombs.me>
* avcodec/codec_internal: Constify AVPacket in decode_sub cbAndreas Rheinhardt2022-04-051-1/+1
| | | | | | No subtitle decoder ever modifies the AVPacket given to it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Use union for FFCodec decode/encode callbacksAndreas Rheinhardt2022-04-051-1/+1
| | | | | | | | | | | 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>
* avcodec/codec_internal: Add FFCodec.decode_subAndreas Rheinhardt2022-04-051-5/+3
| | | | | | | | | This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVSubtitle *sub = data;" line for subtitle decoders. Its only downside is that it increases sizeof(FFCodec), yet this can be more than offset lateron. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/codec_internal: Add FFCodec, hide internal part of AVCodecAndreas Rheinhardt2022-03-211-6/+6
| | | | | | | | | | | | | | | | 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>
* avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.hAndreas Rheinhardt2022-03-211-0/+1
| | | | | | | | | | 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>
* avcodec/dvdsubdec: Mark decoder as init-threadsafeAndreas Rheinhardt2021-05-121-0/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/dvdsubdec: Remove unnecessary close functionAndreas Rheinhardt2021-05-121-7/+0
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec: Constify AVCodecsAndreas Rheinhardt2021-04-271-1/+1
| | | | | | | | | | 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>
* avcodec: Remove deprecated AVPicture APIAndreas Rheinhardt2021-04-271-18/+0
| | | | | | | Deprecated in a17a7661906ba295d67afd80ac0770422e1b02b3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* lavc/dvdsubdec: Move palette parsing to new functionMichael Kuron2020-02-041-16/+6
| | | | | Signed-off-by: Michael Kuron <michael.kuron@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: discard accumulated buffer on errorMichael Niedermayer2018-12-141-0/+1
| | | | | | | | Fixes: Timeout Fixes: 10992/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVDSUB_fuzzer-5657495410835456 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: Sanity check len in decode_rle()Michael Niedermayer2018-09-191-0/+2
| | | | | | | | Fixes: Timeout Fixes: 9778/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVDSUB_fuzzer-5186007132536832 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: Avoid branch in decode_run_8bit()Michael Niedermayer2018-09-151-4/+1
| | | | | | | Speed improvment 35.5 sec -> 34.7sec Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: Check for fully transparent rectangles earlierMichael Niedermayer2018-07-021-7/+14
| | | | | | | | | | Testcase with large transparent rectangles changes from 67 sec to 3 sec decode time Fixes: Timeout Fixes: 8728/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVDSUB_fuzzer-5190088756559872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: Fix runtime error: left shift of 242 by 24 places cannot ↵Michael Niedermayer2017-05-051-1/+1
| | | | | | | | | be represented in type 'int' Fixes: 1080/clusterfuzz-testcase-5353236754071552 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: Fixes 2 runtime error: left shift of 170 by 24 places ↵Michael Niedermayer2017-04-071-2/+2
| | | | | | | | | cannot be represented in type 'int' Fixes: 619/clusterfuzz-testcase-5803914534322176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Fix all -Wformat warnings raised by DJGPPClément Bœsch2017-03-291-1/+1
|
* avcodec/dvdsubdec: Fix off by 1 errorMichael Niedermayer2016-10-261-1/+1
| | | | | | | Fixes out of array read Found-by: Thomas Garnier using libFuzzer Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: Fix buf_size checkMichael Niedermayer2016-10-261-1/+2
| | | | | | | Fixes out of array access Found-by: Thomas Garnier using libFuzzer Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/dvdsubdec: ignore h <= 1 case, to properly decode subtitlePaul B Mahol2016-09-181-1/+1
| | | | | | | | Fixes #5825. If h == 1, second decode_rle() fails. Regression since: 3f0a3e9e127d067c5cf65640a44765c1ddd01622. Signed-off-by: Paul B Mahol <onemda@gmail.com>
* avcodec/dvdsubdec: fix typo in dlog messageGanesh Ajjanagadde2015-12-061-1/+1
| | | | | | | | | Likely accidental in 764900d6458a2f79166ff91df4f20ad39cd6acec. Fixes: CID 1341578. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* avcodec: use AV_OPT_TYPE_BOOL in a bunch of placesClément Bœsch2015-12-041-1/+1
|
* avcodec/dvdsubdec: Fix types for offset1/2 in ff_dlog()Michael Niedermayer2015-11-221-2/+2
| | | | Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* Merge commit '5c30ae1a09b66179e16694f6137658023ed1fef3'Derek Buitenhuis2015-11-221-1/+5
|\ | | | | | | | | | | | | | | | | | | * commit '5c30ae1a09b66179e16694f6137658023ed1fef3': dvdsubdec: Validate the RLE offsets Conflicts: libavcodec/dvdsubdec.c Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
| * dvdsubdec: Validate the RLE offsetsLuca Barbato2015-11-171-1/+5
| | | | | | | | CC: libav-stable@libav.org
* | dvdsubdec: validate offset2 similar to offset1Andreas Cadhalpun2015-11-111-1/+1
| | | | | | | | | | | | | | If it is negative, it causes segmentation faults in decode_rle. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* | Merge commit 'a17a7661906ba295d67afd80ac0770422e1b02b3'Hendrik Leppkes2015-10-221-20/+41
|\ \ | |/ | | | | | | | | | | * commit 'a17a7661906ba295d67afd80ac0770422e1b02b3': lavc: Add data and linesize to AVSubtitleRect Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
| * lavc: Add data and linesize to AVSubtitleRectVittorio Giovara2015-10-211-22/+36
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | avcodec/dvdsubdec: don't use a NULL log contextwm42015-09-221-1/+1
| |
* | avcodec/dvdsubdec: reject some broken packetswm42015-09-221-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | If cmd_pos is broken, this would just keep accumulating packets in the reassembly buffer, until it fails and flushes the buffer on overflow. Since packets are usually rather small, this will take a lot of subtitle packets. The perceived effect is that subtitles are not displayed anymore after the faulty packet was passed to the decoder. I'm not terribly sure about this, but on the other hand this code is active only when fragmented packets need to be reassembled. Fixes sample file in trac issue #4872.
* | avcodec/dvdsub: fix partial packet assemblywm42015-09-221-1/+3
| | | | | | | | | | | | | | | | | | | | Assuming the first and second packets are partial, this would append the reassembly buffer (ctx->buf) to itself with the second append_to_cached_buf() call, because buf is set to ctx->buf. I do not know a valid sample file which triggers this, and do not know if packets can be split into more than 2 sub-packets, but it triggered with a (differently) broken sample file in trac issue #4872.
* | avcodec/dvdsubdec: fix indentationwm42015-09-211-1/+1
| |
* | dvdsubdec: implement flushingwm42015-05-281-1/+7
| | | | | | | | | | | | This is needed for proper operation with seeking. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | dvdsubdec: reset buffer size on invalid over-large packetswm42015-05-281-0/+1
| | | | | | | | | | | | | | | | Otherwise it will never be reset, and remain "stuck" in this state forever. Can happen when seeking: the decoder will receive fragments from different file positions, which triggers the condition easily. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25'Michael Niedermayer2015-04-201-8/+8
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25': lavc: Replace av_dlog and tprintf with internal macros Conflicts: libavcodec/aacdec.c libavcodec/audio_frame_queue.c libavcodec/bitstream.c libavcodec/dcadec.c libavcodec/dnxhddec.c libavcodec/dvbsubdec.c libavcodec/dvdec.c libavcodec/dvdsubdec.c libavcodec/get_bits.h libavcodec/gifdec.c libavcodec/h264.h libavcodec/h264_cabac.c libavcodec/h264_cavlc.c libavcodec/h264_loopfilter.c libavcodec/h264_refs.c libavcodec/imc.c libavcodec/interplayvideo.c libavcodec/jpeglsdec.c libavcodec/libopencore-amr.c libavcodec/mjpegdec.c libavcodec/mpeg12dec.c libavcodec/mpegvideo_enc.c libavcodec/mpegvideo_parser.c libavcodec/pngdec.c libavcodec/ratecontrol.c libavcodec/rv10.c libavcodec/svq1dec.c libavcodec/vqavideo.c libavcodec/wmadec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * lavc: Replace av_dlog and tprintf with internal macrosVittorio Giovara2015-04-191-8/+8
| |
* | Merge commit 'ec17782e17de1e8501ca213e276dfe5412ff1d11'Michael Niedermayer2015-02-171-2/+9
|\ \ | |/ | | | | | | | | | | | | | | | | * commit 'ec17782e17de1e8501ca213e276dfe5412ff1d11': dvdsubdec: Check memory allocations Conflicts: libavcodec/dvdsubdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * dvdsubdec: Check memory allocationsVittorio Giovara2015-02-171-2/+9
| |
* | avcodec/dvdsubdec: fix accessing dangling pointerswm42015-01-081-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dvdsub_decode() can call append_to_cached_buf() 2 times, the second time with ctx->buf as argument. If the second append_to_cached_buf() reallocs ctx->buf, the argument will be a pointer to the previous, freed block. This can cause invalid reads at least with some fuzzed files - and possibly with valid files. Since packets can apparently not be larger than 64K (even if packets are combined), just use a fixed size buffer. It will be allocated as part of the DVDSubContext, and although some memory is "wasted", it's relatively minimal by modern standards and should be acceptable. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/dvdsubdec: error on bitmaps with size 0wm42015-01-081-0/+3
| | | | | | | | | | | | | | Attemtping to decode them could lead to invalid writes with some fuzzed samples. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/dvdsubdec: fix out of bounds accesseswm42015-01-051-4/+9
| | | | | | | | | | | | | | | | The code blindly trusted buffer offsets read from the file in the RLE decoder. Explicitly check the offset. Also error out on other RLE decoding errors. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/dvdsubdec: Avoid strerror() due to thread safteyMichael Niedermayer2014-12-131-1/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>