summaryrefslogtreecommitdiff
path: root/libavcodec/pgssubdec.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>
* avcodec/internal: Move ff_set_dimensions() to decode.hAndreas Rheinhardt2022-08-271-2/+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/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-7/+6
| | | | | | | | | 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/decode: Fix leaks upon subtitle decoding errorsAndreas Rheinhardt2021-12-161-4/+1
| | | | | | | | | | | | | | 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>
* avcodec/pgssubdec: Use dedicated pointer for accessesAndreas Rheinhardt2021-12-161-34/+32
| | | | | | Improves readability and decreases codesize. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pgssubdec: Remove redundant freeing codeAndreas Rheinhardt2021-12-161-13/+4
| | | | | | | | The caller of display_end_segment() frees the AVSubtitle on error in case ENOMEM is returned or err_recognition is set to explode, so display_end_segment() doesn't have to. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pgssubdec: Always return error upon allocation errorAndreas Rheinhardt2021-12-161-1/+2
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Replace all occurences of av_mallocz_array() by av_calloc()Andreas Rheinhardt2021-09-201-1/+1
| | | | | | | They do the same. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avcodec/pgssubdec: Mark decoder as init-threadsafeAndreas Rheinhardt2021-05-021-0/+1
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.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-14/+0
| | | | | | | Deprecated in a17a7661906ba295d67afd80ac0770422e1b02b3. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/pgssubdec: replace data_size with got_sub_ptr for better readabilityLimin Wang2020-03-251-5/+5
| | | | | Signed-off-by: Limin Wang <lance.lmwang@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/pgssubdec: Free subtitle on errorMichael Niedermayer2020-01-051-1/+4
| | | | | | | | | Fixes: Assertion failure Fixes: 19753/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGSSUB_fuzzer-5688461843759104 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>
* avcodec/pgssubdec: Check for duplicate display segmentsMichael Niedermayer2019-02-031-0/+5
| | | | | | | | | | In such a duplication the previous gets overwritten and leaks Fixes: memleak Fixes: 12510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGSSUB_fuzzer-5694439226343424 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* pgssubdec: reset rle_data_len/rle_remaining_len on allocation errorAndreas Cadhalpun2017-02-011-1/+4
| | | | | | | | The code relies on their validity and otherwise can try to access a NULL object->rle pointer, causing segmentation faults. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* pgssubdec: only set w/h/linesize when allocating dataAndreas Cadhalpun2016-11-241-4/+5
| | | | | | | Rects with positive w/h/linesize but no data are invalid. Reviewed-by: Petri Hintukainen <phintuka@gmail.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
* Merge commit 'b7e64fba7f37cc0399beae844f0a5dbef9219376'Clément Bœsch2016-06-211-2/+4
|\ | | | | | | | | | | | | * commit 'b7e64fba7f37cc0399beae844f0a5dbef9219376': Reduce the scope of some variables Merged-by: Clément Bœsch <u@pkh.me>
| * Reduce the scope of some variablesDiego Biurrun2016-05-111-2/+4
| | | | | | | | | | This avoids unused variable warnings after the next version bump. Also drop a trace level av_log() call that is in the way.
* | Merge commit '885a9d6087315a85d98f7e89656ef01dc7104c4c'Clément Bœsch2016-06-211-1/+1
|\ \ | |/ | | | | | | | | | | | | | | * commit '885a9d6087315a85d98f7e89656ef01dc7104c4c': pgssub: Fix subpicture colorspace and range See 9779b6262471d553c1ed811ff7312564e39d8adf Merged-by: Clément Bœsch <u@pkh.me>
| * pgssub: Fix subpicture colorspace and rangeJan Ekström2016-05-101-2/+8
| | | | | | | | | | | | | | | | | | Widen the values from limited to full range and use BT.709 where it should be used according to the video resolution: SD is BT.601, HD is BT.709 Default to BT.709 due to most observed HDMV content being HD.
| * pgssubdec: fix API compability layerPetri Hintukainen2015-11-261-10/+10
| | | | | | | | | | | | | | Copy pointers to AVPicture after memory has been allocated. Fixes NULL pointers in AVPicture after a17a7661906ba295d67afd80ac0770422e1b02b3. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | pgssubdec: fix subpicture output colorspace and rangeJan Ekström2016-04-241-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Functionality used before didn't widen the values from limited to full range. Additionally, now the decoder uses BT.709 where it should be used according to the video resolution. Default for not yet set colorimetry is BT.709 due to most observed HDMV content being HD. BT.709 coefficients were gathered from the first two parts of BT.709 to BT.2020 conversion guide in ARIB STD-B62 (Pt. 1, Chapter 6.2.2). They were additionally confirmed by manually calculating values. Fixes #4637
* | avcodec/pgssubdec: Fix left shift of 255 by 24 places cannot be represented ↵Michael Niedermayer2015-12-041-1/+1
| | | | | | | | | | | | | | | | | | in type int Fixes: b293a6479bb4b5286cff24d356bfd955/asan_generic_225c3c9_7819_cc526b657450c6cdef1371b526499626.mkv Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | avcodec/pgssubdec: Check dimensions for 0Michael Niedermayer2015-11-141-2/+2
| | | | | | | | | | | | | | | | Fixes division by 0 Fixes: b293a6479bb4b5286cff24d356bfd955/asan_generic_225c3c9_7819_cc526b657450c6cdef1371b526499626.mkv Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* | Merge commit 'a17a7661906ba295d67afd80ac0770422e1b02b3'Hendrik Leppkes2015-10-221-8/+19
|\ \ | |/ | | | | | | | | | | * 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-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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/pgssubdec: use AV_OPT_TYPE_BOOL for forced_subs_only optionClément Bœsch2015-09-121-1/+1
| |
* | Merge commit '6a85dfc830f51f1f5c2d36d4182d265c1ea3ba25'Michael Niedermayer2015-04-201-9/+9
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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-9/+9
| |
* | avcodec/pgssubdec: Use av_malloc*_array()Michael Niedermayer2015-01-111-2/+2
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit 'd98e6c5d5d80c1dfe0c30f2e73d41a3aea0b920d'Michael Niedermayer2014-08-011-5/+7
|\ \ | |/ | | | | | | | | | | | | * commit 'd98e6c5d5d80c1dfe0c30f2e73d41a3aea0b920d': pgssubdec: Check RLE size before copying See: c0d68be555f5858703383040e04fcd6529777061 Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * pgssubdec: Check RLE size before copyingMichael Niedermayer2014-08-011-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Make sure the buffer size does not exceed the expected RLE size. Prevent an out of array bound write. Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at> Bug-Id: CVE-2013-0852 Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
* | avcodec/pgssubdec: Fix input ptsMichael Niedermayer2014-07-121-1/+1
| | | | | | | | | | | | Fixes part of Ticket2516 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: remove unused variablesMichael Niedermayer2014-06-301-3/+0
| | | | | | | | | | Found-by: ubitux Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: Check input buffer size in parse_presentation_segment()Michael Niedermayer2014-06-301-0/+8
| | | | | | | | | | | | Might fix overread, no testcase known though. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | Merge commit '253d0be6a1ecc343d29ff8e1df0ddf961ab9c772'Michael Niedermayer2014-06-301-120/+239
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | * commit '253d0be6a1ecc343d29ff8e1df0ddf961ab9c772': pgssubdec: handle more complex PGS scenarios Conflicts: libavcodec/pgssubdec.c Some of this has been split out and commited in cleanly split patches immedeately before this merge Merged-by: Michael Niedermayer <michaelni@gmx.at>
| * pgssubdec: handle more complex PGS scenariosJohn Stebbins2014-06-301-130/+294
| | | | | | | | | | | | | | | | | | Add ability to handle multiple palettes and objects simultaneously. Each simultaneous object is given its own AVSubtitleRect. Note that there can be up to 64 currently valid objects, but only 2 at any one time can be "presented". Signed-off-by: Anton Khirnov <anton@khirnov.net>
* | avcodec/pgssubdec: fix end display timeJohn Stebbins2014-06-301-1/+4
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: Bail out of decode_rle() if error and AV_EF_EXPLODE is setJohn Stebbins2014-06-301-1/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: better error codesJohn Stebbins2014-06-301-7/+7
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: Pass AVSubtitleRect to decode_rle()John Stebbins2014-06-301-11/+11
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: split out flush_cache()John Stebbins2014-06-301-10/+14
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: do not fail when part of the packet is faulty unless ↵John Stebbins2014-06-301-6/+11
| | | | | | | | | | | | AV_EF_EXPLODE is set Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: rename PICTURE_SEGMENTJohn Stebbins2014-06-301-2/+2
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* | avcodec/pgssubdec: Use av_malloc(z)_array()Michael Niedermayer2014-05-221-2/+2
| | | | | | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>