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 7249549D75 for ; Mon, 11 Mar 2024 00:44:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3219068CE20; Mon, 11 Mar 2024 02:44:21 +0200 (EET) 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-Google-Smtp-Source: AGHT+IHnjboGPWcgU8bW1bhM7cKbN1p0b3IMbaVwm/h0q53vOt0npS//+90C5aQGeOC/zUr1Pu/zlw0xg8U5 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 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. 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); -- 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".