Commit Graph

30 Commits

Author SHA1 Message Date
Andreas Rheinhardt 4a4dcde339 avformat/internal: Move FF_FMT_INIT_CLEANUP to demux.h
and rename it to FF_INFMT_INIT_CLEANUP. This flag is demuxer-only,
so this is the more appropriate place for it.
This does not preclude adding internal flags common to both
demuxer and muxer in the future.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-26 06:36:43 +01:00
Marth64 b3d87fb0c4 avformat/sccdec: remove unused bprint.h include
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-12 14:54:54 +01:00
Andreas Rheinhardt b800327f4c avformat/avformat: Add FFInputFormat, hide internals of AVInputFormat
This commit does for AVInputFormat what commit
59c9dc82f4 did for AVOutputFormat:
It adds a new type FFInputFormat, moves all the internals
of AVInputFormat to it and adds a now reduced AVInputFormat
as first member.

This does not affect/improve extensibility of both public
or private fields for demuxers (it is still a mess due to lavd).

This is possible since 50f34172e0
(which removed the last usage of an internal field of AVInputFormat
in fftools).

(Hint: tools/probetest.c accesses the internals of FFInputFormat
as well, but given that it is a testing tool this is not considered
a problem.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-07 08:53:31 -03:00
Andreas Rheinhardt 07bf8f8332 avformat/sccdec: Remove nonsense cast
In most contexts, arrays are automatically converted to a pointer
to their first element; taking the address of the array just yields
a pointer to an array of fixed-size arrays, which is not intended here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-07 11:52:10 +02:00
Andreas Rheinhardt 2004d8d36d avformat/sccdec: Avoid zero-terminating unnecessarily
ff_subtitles_queue_insert() does not require its events to be
zero-terminated as it has a parameter for the length.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 17:16:21 +02:00
Andreas Rheinhardt ac42b60441 avformat/sccdec: Make constants more intelligible
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 17:16:02 +02:00
Andreas Rheinhardt 6795ebb2ea avformat/sccdec: Fix position of returned subtitle packets
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 17:15:43 +02:00
Andreas Rheinhardt e1d2a208a9 avformat/sccdec: Remove redundant check
The av_sscanf() will filter lines like "Scenarist_SCC V1.0" out.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 17:14:34 +02:00
Andreas Rheinhardt 60e12318bb avformat/sccdec: Don't use uninitialized data, fix crash, simplify logic
Up until now, the scc demuxer not only read the line that it intends
to process, but also the next line, in order to be able to calculate
the duration of the current line. This approach leads to unnecessary
complexity and also to bugs: For the last line, the timing of the
next subtitle is not only logically indeterminate, but also
uninitialized and the same applies to the duration of the last packet
derived from it.* Worse yet, in case of e.g. an empty file, it is not
only the duration that is uninitialized, but the whole timing as well
as the line buffer itself.** The latter is used in av_strtok(), which
could lead to crashes. Furthermore, the current code always outputs
at least one packet, even for empty files.

This commit fixes all of this: It stops using two lines at a time;
instead only the current line is dealt with and in case there is
a packet after that, the duration of the last packet is fixed up
after having already parsed it; consequently the duration of the
last packet is left in its default state (meaning "unknown/up until
the next subtitle"). If no further line could be read, processing
is stopped; in particular, no packet is output for an empty file.

*: Due to stack reuse it seems to be zero quite often; for the same
reason Valgrind does not report any errors for a normal input file.
**: While ff_subtitles_read_line() claims to always zero-terminate
the buffer like snprintf(), it doesn't do so if it didn't read anything.
And even if it did, it would not necessarily help here: The current
code jumps over 12 bytes that it deems to have read even when it
hasn't.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-10-02 17:14:20 +02:00
Andreas Rheinhardt ea5bdc8893 avformat/subtitles: Deduplicate subtitles' read_(packet|seek|close)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-18 04:26:35 +02:00
Andreas Rheinhardt 9ef7582446 avformat/sccdec: Simplify cleanup after read_header failure
by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-07-08 13:50:28 +02:00
Andreas Rheinhardt bc70684e74 avformat: Constify all muxer/demuxers
This is possible now that the next-API is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:06 -03:00
Michael Niedermayer 92b1949191 avformat/sccdec: Use larger intermediate for ts/next_ts computation
Fixes: signed integer overflow: 92237203 * 33 cannot be represented in type 'int'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_SCC_fuzzer-6603769487949824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-02-02 13:12:12 +01:00
Andreas Rheinhardt 05475ad26b avformat/sccdec: Avoid variable that is always zero
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-22 13:17:02 +02:00
Paul B Mahol b52ca2cec2 avformat/sccdec: make splitting more robust 2020-06-18 21:28:09 +02:00
Paul B Mahol 5422a4a7c5 avformat/sccdec: simplify demuxer a little 2020-06-17 00:38:08 +02:00
Paul B Mahol 6c84f8afae avformat/sccdec: unbreak previous commits to this file 2020-06-15 19:27:20 +02:00
Andreas Rheinhardt f3c63e67bb avformat/sccdec: Fix memleak upon read header failure
The already parsed subtitles (contained in an FFDemuxSubtitlesQueue)
would leak if an error happened upon reading a subsequent subtitle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-06-15 16:54:06 +02:00
Paul B Mahol 416dc133b9 avformat/sccdec: move pos variables outside of loop
Ensures that sub->pos is always correct.
2020-06-13 12:26:00 +02:00
Paul B Mahol 49d07642f3 avformat/sccdec: split line with multiple subs 2020-06-13 00:20:55 +02:00
Paul B Mahol a15618d2c3 avformat/sccdec: use av_sscanf() instead 2020-02-04 20:39:46 +01:00
Paul B Mahol a13af9aee1 avformat/sccdec: only change duration for last subtitle 2019-12-23 22:47:27 +01:00
Paul B Mahol 13bffa7969 avformat/sccdec: fix sub->pos values 2019-12-23 22:39:46 +01:00
Paul B Mahol 9da7536ce2 avformat/sccdec: fix timestamp of last subtitle
Fixes -c:s copy case.
2019-12-23 22:16:25 +01:00
Paul B Mahol de125a0942 avformat/sccdec: remove not needed code 2019-09-13 19:47:03 +02:00
Paul B Mahol 2b15d436db avformat/sccdec: display last caption even when there is no empty last line 2019-06-27 20:20:16 +02:00
Carl Eugen Hoyos 4d8875ec23 lavf: Constify the probe function argument.
Reviewed-by: Lauri Kasanen
Reviewed-by: Tomas Härdin
2019-03-21 11:42:17 +01:00
Paul B Mahol 76331361a5 avformat/sccdec: simplify 2 sscanf calls
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-30 11:00:58 +01:00
Paul B Mahol 4cfa1f80a9 avformat/sccdec: attempt to fix valgrind issue
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-28 17:23:31 +01:00
Paul B Mahol 45ff6ef50e avformat: add Scenarist Closed Captions demuxer
Fixes #4767.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-25 12:00:02 +01:00