From patchwork Mon Mar 11 00:44:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 46944 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dc95:b0:1a1:738b:6bc0 with SMTP id ky21csp950913pzb; Sun, 10 Mar 2024 17:44:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU3Qwe0Chl7kIdtaaz+D8JU7hNSQSj+1iAmez2BFpjiZJ3yaVgzWHljPsbgoM+pb5jj/brtT0iTcjl7qyQwKa4FfVpteFske+PthQ== X-Google-Smtp-Source: AGHT+IGW0T4ELDHKyGvE7T1jn1U9VbIpsen90DsgBw2q5EXe2wom8ImLKRJdqeJ4r0B69LpJVZg3 X-Received: by 2002:a2e:7203:0:b0:2d3:9354:fe07 with SMTP id n3-20020a2e7203000000b002d39354fe07mr3141885ljc.5.1710117865858; Sun, 10 Mar 2024 17:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710117865; cv=none; d=google.com; s=arc-20160816; b=0OedhJm2yXxkR1VhRFS61N9jGBTrH2of2QNYXcGsnna4DvOkp1AD+WaqWqy8efqQV0 zxuVYyE8D8SRSnVt+yoF8rzkCRFBQLFYy3T1lvh0o4V9Yt4I5h5+ry7kBW2dDKt8mGZR 1Jq7kfNPOvHSNtEueztXyZCBxGEZ2JByhD+UWlRlAzEYHNst8YKk5VPBKjpYsWrXzjuN lRhvwfvFzfML8DSJuvSGn/bu652ycYRF544PaYla/OElMwMwG2bLO3dzKligFa+bfi5F l0OnNtP9I+S6+e1WPGX6lEAnipPzudPLVN5qbhUOocFITeUuNyjt7Mf9FlLR1mE1hZB5 3TAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=o+P+hkN3SOj2XceYHWASbP+aJZ8A875s9MALXCbROTU=; fh=PlWMzmI9LD2qGS7ipLrQl8z0iaQTLQLHzoGuXcBzpCg=; b=jpSFqkvPI7ZD2Vsx13MOA6YsCzJzSTNdUgeTInyFN9JaNueIbPOLqNH2iYPw/BvQtc QWJK2Lwym/5daFkyOzEfQhlzTXHM3wu/ZrEnbkTstWpn9VEj7q09ikDtflqvOuUGhDGG nl8kRiMulyHKPqSfl9qNz4Qx+nE4VDoNExStxmf/IoMyo4WdlwZBGJGtnoQWO6jLEyYn cO3SX3zxJ+PHdPQVV8Dp2R9ZSIvxCAxc0Wd6Wo5KmR33NYCYClfv5uLV05jk7k/CDlWb lyJ5smc04y12zGZRD6BP3PmLdslUqVK2dBxzT1BgpjjkPCqNveZKXu1y1JDrY4G4+UN/ vB+w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@proxyid.net header.s=google header.b=Z2R+XPRN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a12-20020aa7d90c000000b00567230f1004si2044358edr.556.2024.03.10.17.44.24; Sun, 10 Mar 2024 17:44:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@proxyid.net header.s=google header.b=Z2R+XPRN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 634BC68CE21; Mon, 11 Mar 2024 02:44:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f226.google.com (mail-il1-f226.google.com [209.85.166.226]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CB23368C719 for ; Mon, 11 Mar 2024 02:44:14 +0200 (EET) Received: by mail-il1-f226.google.com with SMTP id e9e14a558f8ab-3662feb90a8so16384635ab.3 for ; Sun, 10 Mar 2024 17:44:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxyid.net; s=google; t=1710117853; x=1710722653; 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=VtM2iRsbgAzWz+KVBRZVE24nu7KY+0XHytHuRgCGWZQ=; b=Z2R+XPRNhdfDvPFL2Y1/HCwMdmkrS9x1xWn4Fp52g53aeVHH+bMhalbkeV/JMssoOW y8fN8918+Eo4iysdiJmBHh5bI/rJazBHvJpyA3Y2o+P3VlAbm3/PE7ej6FQwzP302ff5 Tc+t/Ph21vIWBx5641RknxOWLhzN4P1xNrr+AJHeDWQO+GgHJEbAluB0+Q/ttv+tzw02 KZXfe27UKMaGb7T962GAhsAYS99QZsGOA+yd5YoyLPdML7hCLjlEAMaheGimNGuAQcq/ IAqc55hF0+nvp1DwESNZxwDZpkBPhZDVSKuclBMo5hKb4dwTZkejkK4hvRssKuI+kDBw uOuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710117853; x=1710722653; 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=VtM2iRsbgAzWz+KVBRZVE24nu7KY+0XHytHuRgCGWZQ=; b=Izdd4X5aS8z7Lpw3PxZV1XOxdZX0ZSMSOlvQ7u8GrqwOfKW7xxtbF7nAcNaziouCAQ cxODFMXEEsZ79htiAOdNmSMn4A3lJ8pd7oeRHh9TkVtREgckPqN9JrXgJ1wde4OLB4UQ F4eBz8ncJuiDbiGzI4ctHka9S98/sk27KSHwnh417czNd0xkoOSI3yvgDgfnFqoHJ+sc Icf/vQVokO1LQiJHSPDIy64UGiSLYwNB6UsnjZ4PIrsQG0vr51RafHI+z2Ef4pZpLBJA rMbKCs2Li49Hsrtg01fCxFV6Eiesoi1qyapGKPnwS8OdbwhDfhxzWxOeCDZdMGk6MnLD yJlQ== X-Gm-Message-State: AOJu0Yzyh9S8x030DUL8Aia4loFSc1CsUdFYMY9E+awV8OncLBAyS/mv VpXn0YBvZ4qpLFE16bQjaE9yan8diCxnk4xa2iX6GRfKwO+4plEPXDMkY+fw4zHKvB19yPY7QLP Hu6BRhe8ufFH9g0WLIdkEzUAyPMHckeaNNIBi4dF/ X-Received: by 2002:a5d:9617:0:b0:7c8:612c:42c2 with SMTP id w23-20020a5d9617000000b007c8612c42c2mr5222150iol.6.1710117853265; Sun, 10 Mar 2024 17:44:13 -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 gn32-20020a056602642000b007c8be8b097fsm13274iob.4.2024.03.10.17.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Mar 2024 17:44:13 -0700 (PDT) X-Relaying-Domain: proxyid.net From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Mar 2024 19:44:11 -0500 Message-Id: <20240311004411.140656-1-marth64@proxyid.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] avcodec/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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9aNRo48sU/iT 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. v2 only updates the commit message which mistakenly referenced avformat. 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);