summaryrefslogtreecommitdiff
path: root/libavformat/subtitles.c
Commit message (Collapse)AuthorAge
* avformat/subtitles: Honour ff_subtitles_read_line() documentationAndreas Rheinhardt2021-10-02
| | | | | | | | | It claims to always zero-terminate its buffer like snprintf(), yet it does it not on EOF. Because of this the mcc demuxer used uninitialized values when reading an empty input file. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avio: Move internal AVIOContext fields to avio_internal.hAndreas Rheinhardt2021-08-25
| | | | | | | | | | | | | | Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* Remove unnecessary avassert.h inclusionsAndreas Rheinhardt2021-07-22
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/subtitles: Deduplicate subtitles' read_(packet|seek|close)Andreas Rheinhardt2021-07-18
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/subtitles: Check pts difference before useMichael Niedermayer2021-06-18
| | | | | | | | Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_MPL2_fuzzer-6747053545881600 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/subtitles: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/subtitles: Don't increment packet counter prematurelyAndreas Rheinhardt2020-03-22
| | | | | | | | | Do it only if the packet has been successfully allocated in av_new_packet() -- otherwise on error a completely uninitialized packet would be unreferenced later. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat: Forward errors where possibleAndreas Rheinhardt2019-12-12
| | | | | | | | | | It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/subtitles: Check nb_subs in ff_subtitles_queue_finalize()Michael Niedermayer2019-10-06
| | | | | | | | | Fixes: null pointer dereference Fixes: 17828/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5645915116797952 Fixes: Ticket8147 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avformat/subtitles: ignore extra '\r' at line endingsPaul B Mahol2019-04-27
|
* avformat: replace all uses of av_copy_packet()James Almer2017-09-25
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/subtitles: treat negative duration like unknown durationwm42015-12-23
| | | | | | | | | Fixes a specific srt sample, which has an event with negative duration. libavcodec will convert an event with negative duration to an ASS event which will be displayed forever, which is not wanted here. Treat negative duration always as unknown duration instead, and show it until the next subtitle event.
* all: use FFDIFFSIGN to resolve possible undefined behavior in comparatorsGanesh Ajjanagadde2015-11-03
| | | | | | | | | | | | | | | | | | | FFDIFFSIGN was created explicitly for this purpose, since the common return a - b idiom is unsafe regarding overflow on signed integers. It optimizes to branchless code on common compilers. FFDIFFSIGN also has the subjective benefit of being easier to read due to lack of ternary operators. Tested with FATE. Things not covered by this are unsigned integers, for which overflows are well defined, and also places where overflow is clearly impossible, e.g an instance where the a - b was being done on 24 bit values. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde@gmail.com>
* Replace remaining occurances of av_free_packet with av_packet_unrefHendrik Leppkes2015-10-27
|
* avformat/subtitles: make dropping duplicate events optionalwm42015-09-21
|
* avformat/subtitles: forward log context in ff_subtitles_queue_finalize() for ↵Clément Bœsch2015-09-10
| | | | logging
* avformat/subtitles: make sure we don't drop "duplicated" events from ↵Clément Bœsch2015-09-10
| | | | different streams
* avformat/subtitles: drop duplicated eventsClément Bœsch2015-09-10
| | | | Fix Ticket #4843
* avformat/subtitles: Use size_t for lenMichael Niedermayer2015-05-11
| | | | | | | string length could theoretically be larger than int Reviewed-by: Clément Bœsch <u@pkh.me> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* avformat/subtitles: reduce log level of UTF-16 warningwm42014-10-29
| | | | Applications can use this to silence the message.
* Print a warning if a subtitle demuxer changes utf16 to utf8.Carl Eugen Hoyos2014-10-29
| | | | | | | This does not fix anything but gives users a chance to know that they must not pass -sub_charenc UTF-16 to ffmpeg. Fixes ticket #4059.
* avformat/realtextdec: UTF-16 supportwm42014-09-05
| | | | Also remove ff_smil_extract_next_chunk - this was the last user of it.
* avformat/samidec: UTF-16 supportwm42014-09-05
| | | | ff_smil_extract_next_chunk() is still used by RealText.
* avformat/srtdec: UTF-16 supportwm42014-09-05
|
* avformat/assdec: UTF-16 supportwm42014-09-05
| | | | | | | | | | Use the UTF-16 BOM to detect UTF-16 encoding. Convert the file contents to UTF-8 on the fly using FFTextReader, which acts as converting wrapper around AVIOContext. It also can work on a static buffer, needed for format probing. The FFTextReader wrapper now also takes care of skipping the UTF-8 BOM. Fix Ticket #3496.
* avformat/vobsub: fix several issues.Clément Bœsch2013-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here is an extract of fate-samples/sub/vobsub.idx, with an additional text at the end of each line to better identify each bitmap: timestamp: 00:04:55:445, filepos: 00001b000 Ace! timestamp: 00:05:00:049, filepos: 00001b800 Wake up, honey! timestamp: 00:05:02:018, filepos: 00001c800 I gotta go to work. timestamp: 00:05:02:035, filepos: 00001d000 <???> timestamp: 00:05:04:203, filepos: 00001d800 Look after Clayton, okay? timestamp: 00:05:05:947, filepos: 00001e800 I'll be back tonight. timestamp: 00:05:07:957, filepos: 00001f800 Bye! Love you. timestamp: 00:05:21:295, filepos: 000020800 Hey, Ace! What's up? timestamp: 00:05:23:356, filepos: 000021800 Hey, how's it going? timestamp: 00:05:24:640, filepos: 000022800 Remember what today is? The 3rd! timestamp: 00:05:27:193, filepos: 000023800 Look over there! timestamp: 00:05:28:369, filepos: 000024800 Where are they going? timestamp: 00:05:28:361, filepos: 000025000 <???> timestamp: 00:05:29:946, filepos: 000025800 Let's go see. timestamp: 00:05:31:230, filepos: 000026000 I can't, man. I got Clayton. Note the two "<???>": they are basically split subtitles (with the previous one), which the dvdsub decoder is now supposed to reconstruct with a previous commit. But also note that while the first chunk has increasing timestamps, timestamp: 00:05:02:018, filepos: 00001c800 timestamp: 00:05:02:035, filepos: 00001d000 ...it's not the case of the second one (and this is not an exception in the original file): timestamp: 00:05:28:369, filepos: 000024800 timestamp: 00:05:28:361, filepos: 000025000 For the dvdsub decoder, they need to be "filepos'ed" ordered, but the FFDemuxSubtitlesQueue is timestamps ordered, which is the reason of the introduction of a sub sort method in the context, to allow giving priority to the position, and then the timestamps. With that change, the dvdsub decoder get fed with ordered packets. Now the packet size estimation was also broken: the filepos differences in the vobsub index defines the full data read between two subtitles chunks, and it is necessary to take into account what is read by the mpegps_read_pes_header() function since the length returned by that function doesn't count the size of the data it reads. This is fixed with the introduction of total_read, and {old,new}_pos. By doing this change, we can drop the unreliable len16 heuristic and simplify the whole loop. Note that mpegps_read_pes_header() often read more than one PES packet (typically in one call it can read 0x1ba and 0x1be chunk along with the relevant 0x1bd packet), which triggers the "total_read + pkt_size > psize" check. This is an expected behaviour, which could be avoided by having a more chunked version of mpegps_read_pes_header(). The latest change is the extraction of each stream into its own subtitles queue. If we don't do this, the maximum size for a subtitle chunk is broken, and the previous changes can not work. Having each stream in a different queue requires some little adjustments in the seek code of the demuxer. This commit is only meaningful as a whole change and can not be easily split. The FATE test changes because it uses the vobsub demuxer.
* avformat/subtitles: support standalone CR (MacOS).Clément Bœsch2013-09-08
| | | | Recent .srt files with CR only were found in the wild.
* avformat/subtitles: binary search seeking.Clément Bœsch2013-09-08
|
* avformat/subtitles: check lower bound for duration overlap seeking.Clément Bœsch2013-09-08
|
* avformat/vobsub: fix seeking.Clément Bœsch2013-09-08
|
* vformat/subtitles: check av_copy_packets return codeMichael Niedermayer2013-08-30
| | | | Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* Merge commit '1afddbe59e96af75f1c07605afc95615569f388f'Michael Niedermayer2013-03-08
| | | | | | | | | | | | | | | | | | * commit '1afddbe59e96af75f1c07605afc95615569f388f': avpacket: use AVBuffer to allow refcounting the packets. Conflicts: libavcodec/avpacket.c libavcodec/utils.c libavdevice/v4l2.c libavformat/avidec.c libavformat/flacdec.c libavformat/id3v2.c libavformat/matroskaenc.c libavformat/mux.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
* Remove incorrect use of ctype.h functions.Reimar Döffinger2013-03-03
| | | | | | | As far as I can tell the code should not change behaviour depending on locale in any of these places. Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
* lavf: move stream==-1 handling from ff_subtitles_queue_seek() to ↵Michael Niedermayer2013-01-02
| | | | | | avformat_seek_file() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* lavf: move srtdec:read_chunk() to subtitles utils.Clément Bœsch2012-12-30
| | | | This function can be useful for various other subtitles formats.
* lavf/subtitles: seek a little more backward when necessary.Clément Bœsch2012-12-02
| | | | | If some previous subtitles are overlapping with the current time we make sure they are raised so the renderer can display them too.
* lavf/subtitles: add ff_subtitles_queue_seek().Clément Bœsch2012-12-02
| | | | | | | | | | | | This function is almost identical to lavf/assdec:read_seek2(). It performs a generic seek for text subtitles demuxers for the new seeking API. The only difference with assdec:read_seek2 is the ts_diff being unsigned to avoid overflows. The seek callback in the ASS demuxer will be removed when it is redesigned to use FFDemuxSubtitlesQueue.
* lavf/subtitles: add some SMIL helpers.Clément Bœsch2012-06-29
| | | | This is needed for SAMI and RealText demuxers.
* lavf: add internal demuxer helpers for subtitles.Clément Bœsch2012-06-29