From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id CF3BA49E07 for ; Tue, 12 Mar 2024 06:00:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EEB3C68D109; Tue, 12 Mar 2024 08:00:21 +0200 (EET) Received: from mail-yw1-f227.google.com (mail-yw1-f227.google.com [209.85.128.227]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7630968C2BD for ; Tue, 12 Mar 2024 08:00:12 +0200 (EET) Received: by mail-yw1-f227.google.com with SMTP id 00721157ae682-60a3c48e70fso17795697b3.1 for ; Mon, 11 Mar 2024 23:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1710223211; x=1710828011; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nDGz8EzYRx8cdiEl8bIvqBosnnrjAgszPSPAguKJN88=; b=LN5AO2hA+lvl3QZ6j1A1xoFFUKJ4Jo+m7t/HI7rP8l3cpoatpuVu9aKs1UIIzvw3Lr zqF0/BT3CTUwyYFxcAfjszvFRqop2KAGfGy6+mPfwQe8Hb7NNajOWu/j6u0brnGmchan W48oitm36tADO0D3k4fOkedbZ9ne7U0pi5WB7cBI1svrzG4GCvAFU/VE7C4VpRUFR9L+ q8j9irCNC/WHhhIXiyrkHcvIGQG6Y7cB/fUGfUNEcGCWa0vlf+kDbZ1sTSSa8UK8sEQF +liB2f97oDOXBKmOD/KE0h3rHeip0DFNEjoL2RP/iTH7h8Q5YbA0daV/hQJtY5s3vOYi 7djw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710223211; x=1710828011; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nDGz8EzYRx8cdiEl8bIvqBosnnrjAgszPSPAguKJN88=; b=Y9A9CssYg2gDn3Ow3RHUEGViuCWsH4t9avBoX/niOZdt+O5xta0Ju0NkPd2RHpU6t8 Qg712v5UDJMUqWDi/xvatDkVzOiWukNZv40NnN4TiBRlt6yEbOhfSD9QxVuHs5UMkWx0 /GUwxFpHdtRoEJXEXr6kHCtbkgHtD2QINnRmNS0sE1ykA7BHRPvU/4n8CK6YSWGefOmF yCCJBTXpMcfvogGi238bTRx/0UfmGx3XUBU7WIskUztxeJGTxNZONwLuF8+CUzCyGMWR mkhPGqNBBiIakPHgqBVtahvz9VidagSMBlhInmvZ8hUTP2E3TkmLuPLI922m4Db9IC+O 82nA== X-Gm-Message-State: AOJu0YxnU+rutLyaHKM+JB7ZulKs2gyRx7D1MH3A7nmq0OMwevVa3bre OQZalBFNQTU3vPtPCi0PmA3uw6ydWaDfwNdOojbSmwCg3uYCNS0zvomgNpG5oFP7GQ3GfhAORdy Ytvu7mjToT0WkijRD9zfr7BvD65h3b7LxnE2GTzIQ X-Google-Smtp-Source: AGHT+IEdRVXoKtZNxQO6vL4UF8p0RNEo+TaWvGfetEmBqUowBxnD1F6csXfgZHY+E2ElpX6tzn3/knbgZaql X-Received: by 2002:a25:ea05:0:b0:dcd:24b6:1ae7 with SMTP id p5-20020a25ea05000000b00dcd24b61ae7mr5169481ybd.63.1710223211164; Mon, 11 Mar 2024 23:00:11 -0700 (PDT) Received: from wsx-cc1-001.. (c-76-141-249-38.hsd1.il.comcast.net. [76.141.249.38]) by smtp-relay.gmail.com with ESMTPS id ds4-20020a056902248400b00dc6185d4494sm322329ybb.6.2024.03.11.23.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 23:00:11 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Mar 2024 01:00:02 -0500 Message-Id: <20240312060005.2111135-4-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312060005.2111135-1-marth64@proxyid.net> References: <20240312060005.2111135-1-marth64@proxyid.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 3/6] avcodec/ccaption_dec: ignore leading non-breaking spaces X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marth64 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: In Closed Captions (US), the non-breaking space (0xA0) can be used to align text horizontally from the left when used as a leading character. However, CC decoder does not ignore it as a leading character like it does an ordinary space, so a blank padding is rendered on the black CC box. This is not the intended viewing experience. Ignore the leading non-breaking spaces, thus creating the intended transparency which aligns the text. Since all characters are fixed-width in CC, it can be handled the same way as we currently treat leading ordinary spaces. Also, as a nit, lowercase the NBSP's hex code in the entry table to match casing of the other hex codes. Signed-off-by: Marth64 --- libavcodec/ccaption_dec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index 9d4a93647c..25b0f2e064 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -91,7 +91,7 @@ enum cc_charset { ENTRY(0x36, "\u00a3") \ ENTRY(0x37, "\u266a") \ ENTRY(0x38, "\u00e0") \ - ENTRY(0x39, "\u00A0") \ + ENTRY(0x39, "\u00a0") \ ENTRY(0x3a, "\u00e8") \ ENTRY(0x3b, "\u00e2") \ ENTRY(0x3c, "\u00ea") \ @@ -471,7 +471,8 @@ static int capture_screen(CCaptionSubContext *ctx) const char *row = screen->characters[i]; const char *charset = screen->charsets[i]; j = 0; - while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN) + while ((row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN) || + (row[j] == 0x39 && charset[j] == CCSET_SPECIAL_AMERICAN)) j++; if (!tab || j < tab) tab = j; @@ -491,7 +492,9 @@ static int capture_screen(CCaptionSubContext *ctx) j = 0; /* skip leading space */ - while (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN && j < tab) + while (j < tab && + (row[j] == ' ' && charset[j] == CCSET_BASIC_AMERICAN) || + (row[j] == 0x39 && charset[j] == CCSET_SPECIAL_AMERICAN)) j++; x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".