Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marth64 <marth64@proxyid.net>
To: ffmpeg-devel@ffmpeg.org
Cc: Marth64 <marth64@proxyid.net>
Subject: [FFmpeg-devel] [PATCH v3 3/6] avcodec/ccaption_dec: ignore leading non-breaking spaces
Date: Tue, 12 Mar 2024 01:00:02 -0500
Message-ID: <20240312060005.2111135-4-marth64@proxyid.net> (raw)
In-Reply-To: <20240312060005.2111135-1-marth64@proxyid.net>

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 <marth64@proxyid.net>
---
 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".

  parent reply	other threads:[~2024-03-12  6:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  5:59 [FFmpeg-devel] [PATCH v3 0/6] Closed Captions improvements (phase 1) Marth64
2024-03-12  6:00 ` [FFmpeg-devel] [PATCH v3 1/6] avcodec/mpeg12dec: extract only one type of CC substream Marth64
2024-03-12 11:00   ` Stefano Sabatini
2024-03-12 11:52     ` Andreas Rheinhardt
2024-03-28  9:29   ` Anton Khirnov
2024-03-28 15:41     ` Marth64
2024-03-12  6:00 ` [FFmpeg-devel] [PATCH v3 2/6] avcodec/ccaption_dec: don't print multiple \an and \pos tags Marth64
2024-03-12 13:49   ` Stefano Sabatini
2024-03-12  6:00 ` Marth64 [this message]
2024-03-12 13:50   ` [FFmpeg-devel] [PATCH v3 3/6] avcodec/ccaption_dec: ignore leading non-breaking spaces Stefano Sabatini
2024-03-17  4:27     ` Marth64
2024-03-12  6:00 ` [FFmpeg-devel] [PATCH v3 4/6] avcodec/rcwtenc: canonize name and refresh documentation Marth64
2024-03-12 13:52   ` Stefano Sabatini
2024-03-12  6:00 ` [FFmpeg-devel] [PATCH v3 5/6] avformat/rcwtdec: add RCWT Closed Captions demuxer Marth64
2024-03-12 11:44   ` Andreas Rheinhardt
2024-03-12 14:12     ` Marth64
2024-03-17  4:29     ` [FFmpeg-devel] [PATCH v4] " Marth64
2024-03-18 20:12       ` Marth64
2024-03-19 14:35       ` Stefano Sabatini
2024-03-19 15:55         ` Marth64
2024-03-19 17:39           ` [FFmpeg-devel] [PATCH v5 1/4] " Marth64
2024-03-19 17:39             ` [FFmpeg-devel] [PATCH v5 2/4] avformat/rcwtenc: remove repeated documentation Marth64
2024-03-19 17:39             ` [FFmpeg-devel] [PATCH v5 3/4] doc/muxers: refresh and simplify RCWT muxer documentation Marth64
2024-03-19 17:39             ` [FFmpeg-devel] [PATCH v5 4/4] doc/indevs: update CC extraction example to use RCWT muxer Marth64
2024-03-20 14:13               ` Stefano Sabatini
2024-03-19 21:41             ` [FFmpeg-devel] [PATCH v5 1/4] avformat/rcwtdec: add RCWT Closed Captions demuxer Michael Niedermayer
2024-03-19 22:07               ` Marth64
2024-03-20 14:11             ` Stefano Sabatini
2024-03-12  6:00 ` [FFmpeg-devel] [PATCH v3 6/6] avformat/sccdec: remove unused bprint.h include Marth64
2024-03-12 13:53   ` Stefano Sabatini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240312060005.2111135-4-marth64@proxyid.net \
    --to=marth64@proxyid.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git