mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-11-06 05:17:42 +00:00
avcodec/libaribcaption: only clear on CS in text and ass mode
The text and ass paths treated every caption without regions as a clear
and emitted an empty ("") subtitle. A statement containing only TIME
also decodes to zero regions, without the clear-screen flag, so it
erased the caption that was being displayed.
Test ARIBCC_CAPTIONFLAGS_CLEARSCREEN as the bitmap path already does,
and emit nothing for other regionless captions.
Add text and ass mode tests on the existing aribcaption_clear.ts sample
(visible caption, TIME-only statement, CS-only statement). Each
reference has two events; before this change there was a third, empty
one for the TIME-only statement.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DdDiDRusmi6eD7qSrKBjHb
This commit is contained in:
1 parent
7c06aea6f0
commit
84c71fb2e4
4 files changed
+53
-1
No files matched your search
@@ -618,13 +618,19 @@ static int aribcaption_trans_ass_subtitle(ARIBCaptionContext *ctx)
|
||||
if (ctx->avctx->profile == AV_PROFILE_ARIB_PROFILE_C)
|
||||
single_rect = true;
|
||||
|
||||
sub->format = 1; /* text */
|
||||
if (ctx->caption.region_count == 0) {
|
||||
/* Only an explicit clear screen (CS) erases the previous caption;
|
||||
a statement containing only TIME also has no region. */
|
||||
if (!(ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN))
|
||||
return 0;
|
||||
/* clear previous caption for indefinite duration */
|
||||
sub->format = 1; /* text */
|
||||
ff_ass_add_rect(sub, "", ctx->readorder++, 0, NULL, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub->format = 1; /* text */
|
||||
|
||||
av_bprint_init(&buf, ARIBC_BPRINT_SIZE_INIT, ARIBC_BPRINT_SIZE_MAX);
|
||||
|
||||
if (single_rect && ctx->avctx->profile != AV_PROFILE_ARIB_PROFILE_C) {
|
||||
@@ -814,6 +820,12 @@ static int aribcaption_trans_text_subtitle(ARIBCaptionContext *ctx)
|
||||
int ret = 0;
|
||||
const char *text;
|
||||
|
||||
/* Only an explicit clear screen (CS) erases the previous caption;
|
||||
a statement containing only TIME also has no region. */
|
||||
if (ctx->caption.region_count == 0 &&
|
||||
!(ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN))
|
||||
return 0;
|
||||
|
||||
sub->rects = av_calloc(1, sizeof(*sub->rects));
|
||||
if (!sub->rects) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
|
||||
@@ -172,6 +172,14 @@ FATE_SUBTITLES_PROBE-$(call DEMDEC, MPEGTS, LIBARIBCAPTION) += fate-sub-aribcapt
|
||||
fate-sub-aribcaption-clear: CMD = probeframes -sub_type bitmap $(TARGET_SAMPLES)/sub/aribcaption_clear.ts
|
||||
fate-sub-aribcaption-clear: CMP = diff
|
||||
|
||||
# same sample in text and ass mode: only CS must emit a clear event, which
|
||||
# the ass dialogue shows as an empty text
|
||||
FATE_SUBTITLES_PROBE-$(call DEMDEC, MPEGTS, LIBARIBCAPTION) += fate-sub-aribcaption-clear-text
|
||||
fate-sub-aribcaption-clear-text: CMD = probeframes -sub_type text $(TARGET_SAMPLES)/sub/aribcaption_clear.ts
|
||||
FATE_SUBTITLES_ASS-$(call DEMDEC, MPEGTS, LIBARIBCAPTION) += fate-sub-aribcaption-clear-ass
|
||||
fate-sub-aribcaption-clear-ass: CMD = fmtstdout ass -sub_type ass -font sans-serif -i $(TARGET_SAMPLES)/sub/aribcaption_clear.ts
|
||||
fate-sub-aribcaption-clear-text fate-sub-aribcaption-clear-ass: CMP = diff
|
||||
|
||||
FATE_SUBTITLES-$(call ENCMUX, ASS, ASS) += $(FATE_SUBTITLES_ASS-yes)
|
||||
FATE_SUBTITLES += $(FATE_SUBTITLES-yes)
|
||||
FATE_SUBTITLES := $(if $(CONFIG_PIPE_PROTOCOL), $(FATE_SUBTITLES))
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[Script Info]
|
||||
ScriptType: v4.00+
|
||||
PlayResX: 960
|
||||
PlayResY: 540
|
||||
WrapStyle: 2
|
||||
|
||||
[V4+ Styles]
|
||||
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
|
||||
Style: Default,sans-serif,36,&Hffffff,&Hffffff,&H0,&H0,0,0,0,0,100,100,0,0,4,0,4,2,10,10,10,0
|
||||
|
||||
[Events]
|
||||
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||
Dialogue: 0,0:00:01.00,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(200,300)}{\fsp4}{\3a&Hff&}{\4a&Hff&}〓
|
||||
Dialogue: 0,0:00:03.00,9:59:59.99,Default,,0,0,0,,
|
||||
@@ -0,0 +1,18 @@
|
||||
[SUBTITLE]
|
||||
media_type=subtitle
|
||||
pts=2000000
|
||||
pts_time=2.000000
|
||||
format=1
|
||||
start_display_time=0
|
||||
end_display_time=4294967295
|
||||
num_rects=1
|
||||
[/SUBTITLE]
|
||||
[SUBTITLE]
|
||||
media_type=subtitle
|
||||
pts=4000000
|
||||
pts_time=4.000000
|
||||
format=1
|
||||
start_display_time=0
|
||||
end_display_time=4294967295
|
||||
num_rects=1
|
||||
[/SUBTITLE]
|
||||
Reference in new issue
Block a user