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 B9C41480BC for ; Sun, 10 Mar 2024 01:26:56 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0561568CC85; Sun, 10 Mar 2024 03:26:55 +0200 (EET) Received: from mail-ua1-f99.google.com (mail-ua1-f99.google.com [209.85.222.99]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D51A568C119 for ; Sun, 10 Mar 2024 03:26:48 +0200 (EET) Received: by mail-ua1-f99.google.com with SMTP id a1e0cc1a2514c-7dba73cab13so1094987241.3 for ; Sat, 09 Mar 2024 17:26:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1710034007; x=1710638807; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FXh8lJKsggq3F2XFBj51zGFqFTi4Spl3y95mzAEA854=; b=OlonFocrpP45AnzqgRkgdRH/323IWivWjqUkEZ6euvGB1yk4vO4+TxhgDurIpo2Lug h2s2udiqdq1WWL3xpYZeC471FuQo41/WP3Xl3O2F+QTAGnOhf1DYvc8wTqdHGq08L9vS h7mule4PBi/GSgSLSUQxjIu+UVlK8MdDUHr9fnrrIFNKHAGS2LqjkJeZztHP09D09/cr nkmTi9OOeS1AVFAPF5JPBkPznZ7QyqLOT5UX5RIDh3qEq9oXimcOg/3mj80tFOgy2cJ0 Tf/OcA+k1j4kjXeF4Q+uUH3BCN0saJ91D4jJHPhOzlcdpXA47BVr1RCIRbh7caRlNU7e thIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710034007; x=1710638807; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FXh8lJKsggq3F2XFBj51zGFqFTi4Spl3y95mzAEA854=; b=q/yYwraYzMYE+fFCGwjf3K+uMEV3MAjag+LNckOGZjKH5xWcpIqahixUAKW3OOGxHS g/1pJQPh2P/99aAS+mC9u1oA/ThCVtunhz7kIMPxu8mfEai1NlPJJZn1Jq8dnazxcfcG FoF9cNCeslRIGd0wAVSiFZE/abp9xfbucfyg5tUaGm8EQ0VD2rCaUuInEgZSn4cYaN7F 8V3ddV5JMOqOZcOP3ZTQ2vxsJcwISG+FABCks1uMc7Ky8SjNufKkvcy4gK9yF6pzUS/r pBqT73v7z05/3tkqThOTuOUvUdM+d9AbgFlCVvV3eWivGC6xbVC50wAQmX5bpQqvLuIH +MrA== X-Gm-Message-State: AOJu0YzIW6DKJlvCOspdsm7YBA/dxvWjIivpbruyF36i9PPve/E2MgS1 b3C95FgXKe2lBoiczhY1Fs7d3l3cF5lIlUjJQNCA3BxKtqwgMnQVlEdTZhKHWOdq2bYs+P2eI5I kcc+xHg9WXGzrOewK2V3bNb9ikwiJGC21uJal0TQy X-Google-Smtp-Source: AGHT+IHIlqCjfQmVSUDLl3QhWDdohL9HoA583bHNVjFIT2gcq4XLfKccsBX95q+x9k7pBq15tSiMWZgB9nYa X-Received: by 2002:a67:c911:0:b0:470:54fa:b37b with SMTP id w17-20020a67c911000000b0047054fab37bmr1173246vsk.35.1710034007180; Sat, 09 Mar 2024 17:26:47 -0800 (PST) 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 k1-20020a0561023f0100b004729b5aace3sm137489vsv.5.2024.03.09.17.26.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 17:26:47 -0800 (PST) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Mar 2024 19:26:43 -0600 Message-Id: <20240310012643.3231911-1-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avformat/ccaption_dec: honor transparency of leading non-breaking space 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 by using it 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 over 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 faf058ce97..591013d202 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".