diff mbox series

[FFmpeg-devel] Setting default G0 character set for teletext decoder

Message ID b427bbac-a2c5-739a-72e8-63f230220b3f@inventos.ru
State New
Headers show
Series [FFmpeg-devel] Setting default G0 character set for teletext decoder
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

k.savkov Feb. 18, 2020, 2:23 p.m. UTC
Some providers don't send info about character set, so default (latin) 
is used when decoding. I added option to force desired language with 
function vbi_teletext_set_default_region. You can see what character set 
code maps to what language in Table 32 ETS 300 706,  Section 15.

Comments

Marton Balint Feb. 18, 2020, 8:48 p.m. UTC | #1
On Tue, 18 Feb 2020, k.savkov wrote:

> Some providers don't send info about character set, so default (latin) is 
> used when decoding. I added option to force desired language with function 
> vbi_teletext_set_default_region. You can see what character set code maps to 
> what language in Table 32 ETS 300 706,  Section 15.

docs/decoders.texi update is missing.

Regards,
Marton
Carl Eugen Hoyos Feb. 19, 2020, 2:15 a.m. UTC | #2
> Am 18.02.2020 um 15:23 schrieb k.savkov <k.savkov@inventos.ru>:
> 
> Some providers don't send info about character set, so default (latin) is used when decoding. I added option to force desired language with function vbi_teletext_set_default_region.

Please remove the re-indentation from your patch (assuming there is, I cannot day for sure).

Carl Eugen
k.savkov Feb. 19, 2020, 7:06 a.m. UTC | #3
I can also provide sample files, for which this option is needed, where 
can I upload them?

On 18.02.2020 23:48, Marton Balint wrote:
>
>
> On Tue, 18 Feb 2020, k.savkov wrote:
>
>> Some providers don't send info about character set, so default 
>> (latin) is used when decoding. I added option to force desired 
>> language with function vbi_teletext_set_default_region. You can see 
>> what character set code maps to what language in Table 32 ETS 300 
>> 706,  Section 15.
>
> docs/decoders.texi update is missing.
>
> Regards,
> Marton
> _______________________________________________
> 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".
Marton Balint Feb. 23, 2020, 11:15 p.m. UTC | #4
On Wed, 19 Feb 2020, k.savkov wrote:

> I can also provide sample files, for which this option is needed, where can I 
> upload them?

No need, the why is more important, so I extended the help text and 
applied your patch.

Thanks,
Marton

>
> On 18.02.2020 23:48, Marton Balint wrote:
>> 
>> 
>> On Tue, 18 Feb 2020, k.savkov wrote:
>> 
>>> Some providers don't send info about character set, so default (latin) is 
>>> used when decoding. I added option to force desired language with function 
>>> vbi_teletext_set_default_region. You can see what character set code maps 
>>> to what language in Table 32 ETS 300 706,  Section 15.
>> 
>> docs/decoders.texi update is missing.
>> 
>> Regards,
>> Marton
>> _______________________________________________
>> 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".
>
diff mbox series

Patch

From 1c5c903d893c74025f2e8f62050755eb11b74be8 Mon Sep 17 00:00:00 2001
From: Kirill Savkov <k.savkov@inventos.ru>
Date: Tue, 18 Feb 2020 16:53:34 +0300
Subject: [PATCH] libavcodec/libzvbi-teletextdec.c: added option to set default
 G0 character set for decoding

Signed-off-by: Kirill Savkov <k.savkov@inventos.ru>
---
 libavcodec/libzvbi-teletextdec.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c
index 3515f33924..b243c69293 100644
--- a/libavcodec/libzvbi-teletextdec.c
+++ b/libavcodec/libzvbi-teletextdec.c
@@ -55,6 +55,7 @@  typedef struct TeletextContext
 {
     AVClass        *class;
     char           *pgno;
+    int             default_region;
     int             x_offset;
     int             y_offset;
     int             format_id; /* 0 = bitmap, 1 = text/ass, 2 = ass */
@@ -645,6 +646,10 @@  static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_si
     if (!ctx->vbi) {
         if (!(ctx->vbi = vbi_decoder_new()))
             return AVERROR(ENOMEM);
+        if (ctx->default_region != -1) {
+            av_log(avctx, AV_LOG_INFO, "Setting default zvbi region to %i\n", ctx->default_region);
+            vbi_teletext_set_default_region(ctx->vbi, ctx->default_region);
+        }
         if (!vbi_event_handler_register(ctx->vbi, VBI_EVENT_TTX_PAGE, handler, ctx)) {
             vbi_decoder_delete(ctx->vbi);
             ctx->vbi = NULL;
@@ -791,18 +796,19 @@  static void teletext_flush(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(TeletextContext, x)
 #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
 static const AVOption options[] = {
-    {"txt_page",        "page numbers to decode, subtitle for subtitles, * for all", OFFSET(pgno),   AV_OPT_TYPE_STRING, {.str = "*"},      0, 0,        SD},
-    {"txt_chop_top",    "discards the top teletext line",                    OFFSET(chop_top),       AV_OPT_TYPE_INT,    {.i64 = 1},        0, 1,        SD},
-    {"txt_format",      "format of the subtitles (bitmap or text or ass)",   OFFSET(format_id),      AV_OPT_TYPE_INT,    {.i64 = 0},        0, 2,        SD,  "txt_format"},
-    {"bitmap",          NULL,                                                0,                      AV_OPT_TYPE_CONST,  {.i64 = 0},        0, 0,        SD,  "txt_format"},
-    {"text",            NULL,                                                0,                      AV_OPT_TYPE_CONST,  {.i64 = 1},        0, 0,        SD,  "txt_format"},
-    {"ass",             NULL,                                                0,                      AV_OPT_TYPE_CONST,  {.i64 = 2},        0, 0,        SD,  "txt_format"},
-    {"txt_left",        "x offset of generated bitmaps",                     OFFSET(x_offset),       AV_OPT_TYPE_INT,    {.i64 = 0},        0, 65535,    SD},
-    {"txt_top",         "y offset of generated bitmaps",                     OFFSET(y_offset),       AV_OPT_TYPE_INT,    {.i64 = 0},        0, 65535,    SD},
-    {"txt_chop_spaces", "chops leading and trailing spaces from text",       OFFSET(chop_spaces),    AV_OPT_TYPE_INT,    {.i64 = 1},        0, 1,        SD},
-    {"txt_duration",    "display duration of teletext pages in msecs",       OFFSET(sub_duration),   AV_OPT_TYPE_INT,    {.i64 = -1},      -1, 86400000, SD},
-    {"txt_transparent", "force transparent background of the teletext",      OFFSET(transparent_bg), AV_OPT_TYPE_INT,    {.i64 = 0},        0, 1,        SD},
-    {"txt_opacity",     "set opacity of the transparent background",         OFFSET(opacity),        AV_OPT_TYPE_INT,    {.i64 = -1},      -1, 255,      SD},
+    {"txt_page",           "page numbers to decode, subtitle for subtitles, * for all", OFFSET(pgno),   AV_OPT_TYPE_STRING, {.str = "*"},      0, 0,        SD},
+    {"txt_default_region", "default G0 character set used for decoding",        OFFSET(default_region), AV_OPT_TYPE_INT,    {.i64 = -1},      -1, 80,       SD},
+    {"txt_chop_top",       "discards the top teletext line",                    OFFSET(chop_top),       AV_OPT_TYPE_INT,    {.i64 = 1},        0, 1,        SD},
+    {"txt_format",         "format of the subtitles (bitmap or text or ass)",   OFFSET(format_id),      AV_OPT_TYPE_INT,    {.i64 = 0},        0, 2,        SD,  "txt_format"},
+    {"bitmap",             NULL,                                                0,                      AV_OPT_TYPE_CONST,  {.i64 = 0},        0, 0,        SD,  "txt_format"},
+    {"text",               NULL,                                                0,                      AV_OPT_TYPE_CONST,  {.i64 = 1},        0, 0,        SD,  "txt_format"},
+    {"ass",                NULL,                                                0,                      AV_OPT_TYPE_CONST,  {.i64 = 2},        0, 0,        SD,  "txt_format"},
+    {"txt_left",           "x offset of generated bitmaps",                     OFFSET(x_offset),       AV_OPT_TYPE_INT,    {.i64 = 0},        0, 65535,    SD},
+    {"txt_top",            "y offset of generated bitmaps",                     OFFSET(y_offset),       AV_OPT_TYPE_INT,    {.i64 = 0},        0, 65535,    SD},
+    {"txt_chop_spaces",    "chops leading and trailing spaces from text",       OFFSET(chop_spaces),    AV_OPT_TYPE_INT,    {.i64 = 1},        0, 1,        SD},
+    {"txt_duration",       "display duration of teletext pages in msecs",       OFFSET(sub_duration),   AV_OPT_TYPE_INT,    {.i64 = -1},      -1, 86400000, SD},
+    {"txt_transparent",    "force transparent background of the teletext",      OFFSET(transparent_bg), AV_OPT_TYPE_INT,    {.i64 = 0},        0, 1,        SD},
+    {"txt_opacity",        "set opacity of the transparent background",         OFFSET(opacity),        AV_OPT_TYPE_INT,    {.i64 = -1},      -1, 255,      SD},
     { NULL },
 };
 
-- 
2.25.0