Commit 70897dd6ab for ffmpeg

commit 70897dd6ab8439741c9f7f1e09674f0eeb585a42
Author: Ruk Doe <info@doany.io>
Date:   Sat Oct 10 16:18:22 2026 +0900

    avcodec/libaribcaption: merge the two ass clear paths

    A caption without regions and a caption whose regions were all skipped
    as ruby both end up with nothing to show, and were handled by two
    copies of the same clear-screen check. With no region the loop writes
    nothing, so the later check already covers it. Drop the early return.

    Also clean up through the fail path if adding the clear rect fails,
    like every other error in this function, instead of leaving the
    partially built subtitle to the caller.

    Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01DdDiDRusmi6eD7qSrKBjHb

diff --git a/libavcodec/libaribcaption.c b/libavcodec/libaribcaption.c
index 9232f0aaf0..5cc00619b6 100644
--- a/libavcodec/libaribcaption.c
+++ b/libavcodec/libaribcaption.c
@@ -604,17 +604,6 @@ static int aribcaption_trans_ass_subtitle(ARIBCaptionContext *ctx)
     if (ctx->avctx->profile == AV_PROFILE_ARIB_PROFILE_C)
         single_rect = true;

-    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 */
-        ret = ff_ass_add_rect(sub, "", ctx->readorder++, 0, NULL, NULL);
-        return ret < 0 ? ret : 1;
-    }
-
     sub->format = 1; /* text */

     av_bprint_init(&buf, ARIBC_BPRINT_SIZE_INIT, ARIBC_BPRINT_SIZE_MAX);
@@ -771,13 +760,19 @@ static int aribcaption_trans_ass_subtitle(ARIBCaptionContext *ctx)
         }
     }
     if (!emitted) {
-        /* Every region was skipped as ruby. Emit nothing, but a clear
-           screen (CS) must still erase the previous caption. */
-        av_bprint_finalize(&buf, NULL);
-        if (!(ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN))
+        /* Nothing to show: there is no region, or every region was skipped
+           as ruby. Only an explicit clear screen (CS) erases the previous
+           caption, for indefinite duration; a statement containing only
+           TIME also has no region. */
+        if (!(ctx->caption.flags & ARIBCC_CAPTIONFLAGS_CLEARSCREEN)) {
+            av_bprint_finalize(&buf, NULL);
             return 0;
+        }
         ret = ff_ass_add_rect(sub, "", ctx->readorder++, 0, NULL, NULL);
-        return ret < 0 ? ret : 1;
+        if (ret < 0)
+            goto fail;
+        av_bprint_finalize(&buf, NULL);
+        return 1;
     }
     if (single_rect) {
         if (!av_bprint_is_complete(&buf)) {