1
0
Fork 0
Commit Graph

95 Commits

Author SHA1 Message Date
Andreas Rheinhardt 2a0194bafa avcodec/ccaption_dec: Use static_assert instead of _Static_assert
The latter is not supported by MSVC 19.27.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-18 01:49:38 +01:00
Marth64 590b2d6517 avcodec/ccaption_dec: use consistent naming convention of Closed Captions
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-10 15:21:23 +01:00
Marth64 8991cedd6a avcodec/ccaption_dec: clarify log message when out-of-display columns are ignored
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-03-10 15:21:23 +01:00
Andreas Rheinhardt ec1b6e0cd4 avcodec/ccaption_dec: Avoid relocations for strings
The longest string here takes four bytes, so using an array
of pointers is wasteful even when ignoring the cost of relocations;
the lack of relocations also implies that this array
will now be put into .rodata and not into .data.rel.ro.

Static asserts are used to ensure that all strings are always
properly zero-terminated.

Tested-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-08 00:59:24 +01:00
Anton Khirnov 1e7d2007c3 all: use designated initializers for AVOption.unit
Makes it robust against adding fields before it, which will be useful in
following commits.

Majority of the patch generated by the following Coccinelle script:

@@
typedef AVOption;
identifier arr_name;
initializer list il;
initializer list[8] il1;
expression tail;
@@
AVOption arr_name[] = { il, { il1,
- tail
+ .unit = tail
}, ...  };

with some manual changes, as the script:
* has trouble with options defined inside macros
* sometimes does not handle options under an #else branch
* sometimes swallows whitespace
2024-02-14 14:53:41 +01:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Paul B Mahol 8980c1313b avcodec/ccaption_dec: simplify init function 2023-05-20 13:06:40 +02:00
Paul B Mahol c48eff209c avcodec/ccaptions_dec: correct flushing output on EOF
Prevents infinite flushing same last output.
2023-05-18 11:59:34 +02:00
wang-bin e16b874b6a avcodec/ccaption_dec: return the number of bytes decoded
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-20 17:48:11 +01:00
Andreas Rheinhardt 48286d4d98 avcodec/codec_internal: Add macro to set AVCodec.long_name
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>
2022-09-03 15:42:57 +02:00
Andreas Rheinhardt 21b23ceab3 avcodec: Make init-threadsafety the default
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>
2022-07-18 20:04:59 +02:00
Andreas Rheinhardt 6ed0d95fa2 avcodec/codec_internal: Constify AVPacket in decode_sub cb
No subtitle decoder ever modifies the AVPacket given to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-04-05 20:02:47 +02:00
Andreas Rheinhardt 4243da4ff4 avcodec/codec_internal: Use union for FFCodec decode/encode callbacks
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>
2022-04-05 20:02:37 +02:00
Andreas Rheinhardt fb59a42ef9 avcodec/codec_internal: Add FFCodec.decode_sub
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>
2022-04-05 19:53:27 +02:00
Andreas Rheinhardt 20f9727018 avcodec/codec_internal: Add FFCodec, hide internal part of AVCodec
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>
2022-03-21 01:33:09 +01:00
Andreas Rheinhardt a688f3c13c avcodec/internal: Move FF_CODEC_CAP_* to a new header codec_internal.h
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>
2022-03-21 01:33:09 +01:00
Michael Niedermayer 8701af40bc avcodec/ccaption_dec: Use ff_ass_add_rect2()
Fixes: Timeout
Fixes: 42258/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CCAPTION_fuzzer-5540144118104064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-03-18 19:56:50 +01:00
Pavel Koshevoy b51c2c48c1 avcodec/ccaption_dec: Make real-time latency configurable
Un-hardcode the 200ms minimum latency between emitting subtitle events
so that those that wish to receive a subtitle event for every screen
change could do so.

The problem with delaying realtime output by any amount is that it is
unknown when the next byte pair that would trigger output will happen.
It may be within 200ms, or it may be several seconds later -- that's
not realtime at all.
2021-06-18 19:20:03 -06:00
Andreas Rheinhardt 1c7e52f8ff avcodec: Mark ff_ass_subtitle_header based decoders as init-threadsafe
ff_ass_subtitle_header_full() just uses av_asprintf() and is therefore
thread-safe itself.

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
Paul B Mahol 001748b326 avcodec/ccaption_dec: add support for background colors 2020-06-23 21:55:40 +02:00
Paul B Mahol 00842b3a0d avcodec/ccaption_dec: use uint8_t type for prev_cmd array
Commands are unsigned so be consistent.
2020-06-20 15:07:26 +02:00
Paul B Mahol bd1b78e91a avcodec/ccaption_dec: do not modify packet data in case of parity error
To dissallow similar errors in future, make pointers const.
2020-06-20 15:07:26 +02:00
Paul B Mahol bbd0be04d0 avcodec/ccaption_dec: allow selection of second field captions 2020-06-20 15:07:26 +02:00
Paul B Mahol c6791a32b4 avcodec/ccaption_dec: rework non-real-time mode with pop-on captions by delaying
So it give similar output as visual output of real-time mode.
2020-06-20 15:07:26 +02:00
Paul B Mahol c0974355c7 avcodec/ccaption_dec: do not modify pkt data and stop removing parity bit twice 2020-06-17 00:38:08 +02:00
Paul B Mahol 9887bcc6c6 avcodec/ccaption_dec: remove usage of extra buffer 2020-06-16 17:11:38 +02:00
Paul B Mahol d5b1760665 avcodec/ccaption_dec: fix some small style issues 2020-06-16 17:11:38 +02:00
Paul B Mahol 3615b58693 avcodec/ccaption_dec: remove pts parameter from handle_char() 2020-06-16 17:11:38 +02:00
Paul B Mahol cb98483ea0 avcodec/ccaption_dec: add support for colors 2020-06-15 19:27:20 +02:00
Paul B Mahol 0c2623d3aa avcodec/ccaption_dec: switch active screen in end of caption early
Fixes dropping of last caption.
2020-06-13 12:02:44 +02:00
Paul B Mahol 847d0b99de avcodec/ccaption_dec: remove unused arguments from function 2020-06-13 12:02:44 +02:00
Paul B Mahol 6995ea3506 avcodec/ccaption_dec: check for error codes 2020-06-13 12:02:44 +02:00
Michael Niedermayer f17e8e90bb avcodec/ccaption_dec: Add a blank like at the end to avoid rollup reading from outside
Fixes: index 20 out of bounds for type 'const char *[4][128]'
Fixes: 14367/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CCAPTION_fuzzer-5718819672162304

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-04-21 23:29:04 +02:00
Paul B Mahol b4a13d442a avcodecc/ccaption_dec: remove extra word from long codec description
Signed-off-by: Paul B Mahol <onemda@gmail.com>
2017-01-25 12:00:02 +01:00
Michael Niedermayer 752e6dfa3e avcodec/ccaption_dec: Use simple array instead of AVBuffer
This is simpler and fixes an out of array read, fixing it with AVBuffers
would be more complex

Fixes: e00d9e6e50e5495cc93fea41147b97bb/asan_heap-oob_12dcdbb_8798_b32a97ea722dd37bb5066812cc674552.mov

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-09-09 11:01:24 +02:00
Aman Gupta a49ed9e32d avcodec/ccaption_dec: default rollup to row 10
This ensures that captions are written towards the bottom of the screen
when tuning into mid-stream. The row will be reset on the receipt of the
next PAC command. Row 10 was chosen as it corresponds to the value of
"0" in a PAC (see row_map in handle_pac()).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-18 01:34:56 +02:00
Aman Gupta 9ca9671458 avcodec/ccaption_dec: implement positioning for closed captions
Positioning math is based on the guidelines in https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-18 01:31:25 +02:00
Aman Gupta 309322ef65 avcodec/ccaption_dec: change write_char() to void as return value is unused
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-07-17 20:16:22 +02:00
Michael Niedermayer 6cc4c42226 avcodec/ccaption_dec: Fix mixed declaration and statement.
Found-by: ubitux
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-28 02:33:03 +02:00
Aman Gupta 4448f16ef5 avcodec/ccaption_dec: implement tab offset commands
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-06-28 01:52:31 +02:00
Clément Bœsch d8620158c7 lavc/ccaption_dec: remove usage of avctx->time_base
lavc/utils already rescales avpkt->pts to sub->pts in AV_TIME_BASE_Q
before calling the decode callback. This prevents from rescaling again
into the decoder, and avoid the use of avctx->time_base which will
disappear in the incoming codecpar merge.

This commit also replaces the use of "20 centisecond" (ass time base)
with "200 ms".
2016-04-02 19:03:06 +02:00
Clément Bœsch 30e7685360 lavc/options: add ass_ro_flush_noop to flags2 2016-02-26 21:53:32 +01:00
Clément Bœsch 2941282124 lavc: allow subtitle text format to be ASS without timing 2016-02-26 21:49:34 +01:00
Aman Gupta 5f5467e749 lavc/ccaption_dec: implement special and extended character sets
character sets implemented as defined in https://en.wikipedia.org/wiki/EIA-608#Characters
2016-02-17 21:32:18 +01:00
Aman Gupta 2f26b67d55 lavc/ccaption_dec: do not ignore repeated character commands
control codes in a cc stream can be repeated, and must be ignored.
however, repeated characters must not be ignored. the code attempted to
wipe prev_cmd in handle_char to allow repeated characters to be
processed, but prev_cmd would previously get reset _after_ handle_char()

i also moved the prev_cmd reset out from handle_char() so it can be
re-used for special character sets, which _must_ be ignored when
repeated.
2016-02-17 21:32:18 +01:00
Michael Niedermayer 22f64c2324 avcodec/ccaption_dec: Fix mixed declarations and code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-19 13:48:21 +01:00
Aman Gupta 3a0e5cfcee lavc/ccaption_dec: clear all unused rows during rollup
Sometimes rollup captions can move around the screen. This fixes "ghost"
captions from below the current rollup area from continuing to be
captured when a rollup moves higher up on the screen.
2016-01-14 23:13:15 +01:00
Aman Gupta 9027806e3c lavc/ccaption_dec: clean up whitespace 2016-01-14 23:13:09 +01:00