[vlc-commits] [Git][videolan/vlc][master] 5 commits: contrib: libaribcaption: Add libaribcaption rules.mak

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Thu Mar 10 21:54:01 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
065e168e by xqq at 2022-03-10T21:06:36+00:00
contrib: libaribcaption: Add libaribcaption rules.mak

- - - - -
d7082e8b by xqq at 2022-03-10T21:06:36+00:00
codec: arib: Add libaribcaption caption decoder/renderer

- - - - -
615eca1e by xqq at 2022-03-10T21:06:36+00:00
demux: ts: Remove jpn language tag for ARIB subtitles

Since ARIB subtitles used in South America are also being recognized,
they're not limited to Japanese. Remove the "jpn" tag for the moment.

- - - - -
4aa08571 by xqq at 2022-03-10T21:06:36+00:00
extras: wasm: Disable libaribcaption because not supported

- - - - -
5f74392d by xqq at 2022-03-10T21:06:36+00:00
extras: raspberry: Disable libaribcaption due to weird build error

- - - - -


7 changed files:

- configure.ac
- + contrib/src/libaribcaption/rules.mak
- extras/package/raspberry/build.sh
- extras/package/wasm-emscripten/build.sh
- modules/codec/Makefile.am
- + modules/codec/arib/libaribcaption.c
- modules/demux/mpeg/ts_psi.c


Changes:

=====================================
configure.ac
=====================================
@@ -3017,6 +3017,11 @@ AS_IF( [test "${enable_telx}" != "no" ],[
   ])
 AM_CONDITIONAL([HAVE_TELX], [test "x${have_telx}" = x"yes"])
 
+dnl
+dnl ARIB caption rendering module
+dnl
+PKG_ENABLE_MODULES_VLC([ARIBCAPTION], [], [libaribcaption], [ARIB caption decoder/renderer], [auto])
+
 dnl
 dnl ARIB subtitles rendering module
 dnl


=====================================
contrib/src/libaribcaption/rules.mak
=====================================
@@ -0,0 +1,83 @@
+LIBARIBCC_HASH := c84612b78181d9369075ec8712683c6b10d9da71
+LIBARIBCC_VERSION := git-$(LIBARIBCC_HASH)
+LIBARIBCC_GITURL := https://github.com/xqq/libaribcaption.git
+
+PKGS += libaribcaption
+ifeq ($(call need_pkg,"libaribcaption"),)
+PKGS_FOUND += libaribcaption
+endif
+
+LIBARIBCC_WITH_FREETYPE = 1
+
+ifdef HAVE_ANDROID
+LIBARIBCC_WITH_FONTCONFIG = 0
+LIBARIBCC_WITH_CORETEXT = 0
+LIBARIBCC_WITH_DIRECTWRITE = 0
+else
+ifdef HAVE_DARWIN_OS
+LIBARIBCC_WITH_FONTCONFIG = 0
+LIBARIBCC_WITH_CORETEXT = 1
+LIBARIBCC_WITH_DIRECTWRITE = 0
+else
+ifdef HAVE_WIN32
+LIBARIBCC_WITH_FONTCONFIG = 0
+LIBARIBCC_WITH_CORETEXT = 0
+LIBARIBCC_WITH_DIRECTWRITE = 1
+else
+LIBARIBCC_WITH_FONTCONFIG = 1
+LIBARIBCC_WITH_CORETEXT = 0
+LIBARIBCC_WITH_DIRECTWRITE = 0
+endif
+endif
+endif
+
+$(TARBALLS)/libaribcaption-$(LIBARIBCC_VERSION).tar.xz:
+	$(call download_git,$(LIBARIBCC_GITURL),,$(LIBARIBCC_HASH))
+
+.sum-libaribcaption: libaribcaption-$(LIBARIBCC_VERSION).tar.xz
+	$(call check_githash,$(LIBARIBCC_HASH))
+	touch $@
+
+libaribcaption: libaribcaption-$(LIBARIBCC_VERSION).tar.xz .sum-libaribcaption
+	$(UNPACK)
+	$(MOVE)
+
+LIBARIBCC_CONF := \
+	-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON \
+	-DARIBCC_NO_EXCEPTIONS:BOOL=ON \
+	-DARIBCC_NO_RTTI:BOOL=ON
+
+ifdef HAVE_ANDROID
+LIBARIBCC_CONF += -DARIBCC_IS_ANDROID:BOOL=ON
+endif
+
+ifeq ($(LIBARIBCC_WITH_FREETYPE), 1)
+DEPS_libaribcaption += freetype2 $(DEPS_freetype2)
+LIBARIBCC_CONF += -DARIBCC_USE_FREETYPE:BOOL=ON
+else
+LIBARIBCC_CONF += -DARIBCC_USE_FREETYPE:BOOL=OFF
+endif
+
+ifeq ($(LIBARIBCC_WITH_FONTCONFIG), 1)
+DEPS_libaribcaption += fontconfig $(DEPS_fontconfig)
+LIBARIBCC_CONF += -DARIBCC_USE_FONTCONFIG:BOOL=ON
+else
+LIBARIBCC_CONF += -DARIBCC_USE_FONTCONFIG:BOOL=OFF
+endif
+
+ifeq ($(LIBARIBCC_WITH_CORETEXT), 1)
+LIBARIBCC_CONF += -DARIBCC_USE_CORETEXT:BOOL=ON
+else
+LIBARIBCC_CONF += -DARIBCC_USE_CORETEXT:BOOL=OFF
+endif
+
+ifeq ($(LIBARIBCC_WITH_DIRECTWRITE), 1)
+LIBARIBCC_CONF += -DARIBCC_USE_DIRECTWRITE:BOOL=ON
+endif
+
+
+.libaribcaption: libaribcaption toolchain.cmake
+	cd $< && rm -f CMakeCache.txt
+	cd $< && $(HOSTVARS_PIC) $(CMAKE) $(LIBARIBCC_CONF)
+	cd $< && $(CMAKEBUILD) . --target install
+	touch $@


=====================================
extras/package/raspberry/build.sh
=====================================
@@ -110,7 +110,7 @@ info "Building contribs"
 mkdir -p contrib/contrib-$SHORTARCH && cd contrib/contrib-$SHORTARCH
 
 # issue with arm detection of the target (detects i686)
-CONTRIBFLAGS="$CONTRIBFLAGS --disable-x265 --disable-mpg123 --disable-xcb"
+CONTRIBFLAGS="$CONTRIBFLAGS --disable-x265 --disable-mpg123 --disable-xcb --disable-libaribcaption"
 
 ${SCRIPT_PATH}/../../../contrib/bootstrap --host=$TRIPLET $CONTRIBFLAGS
 


=====================================
extras/package/wasm-emscripten/build.sh
=====================================
@@ -125,7 +125,7 @@ diagnostic "vlc contribs: bootstrap"
             --disable-orc --disable-protobuf --disable-sidplay2 \
             --disable-soxr --disable-spatialaudio --disable-speex \
             --disable-speexdsp --disable-taglib --disable-zvbi \
-            --disable-rnnoise \
+            --disable-rnnoise --disable-libaribcaption \
             --host=wasm32-unknown-emscripten
 
 diagnostic "vlc contribs: make"


=====================================
modules/codec/Makefile.am
=====================================
@@ -182,6 +182,13 @@ codec_LTLIBRARIES += libcvdsub_plugin.la
 libdvbsub_plugin_la_SOURCES = codec/dvbsub.c
 codec_LTLIBRARIES += libdvbsub_plugin.la
 
+libaribcaption_plugin_la_SOURCES = codec/arib/libaribcaption.c
+libaribcaption_plugin_la_CFLAGS = $(AM_CFLAGS) $(ARIBCAPTION_CFLAGS)
+libaribcaption_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'
+libaribcaption_plugin_la_LIBADD = $(ARIBCAPTION_LIBS) $(LIBS_freetype) $(FREETYPE_LIBS)
+EXTRA_LTLIBRARIES += libaribcaption_plugin.la
+codec_LTLIBRARIES += $(LTLIBaribcaption)
+
 libaribsub_plugin_la_SOURCES = codec/arib/aribsub.c codec/arib/substext.h
 libaribsub_plugin_la_CFLAGS = $(AM_CFLAGS) $(ARIBB24_CFLAGS)
 libaribsub_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(codecdir)'


=====================================
modules/codec/arib/libaribcaption.c
=====================================
@@ -0,0 +1,531 @@
+/*****************************************************************************
+ * ARIB STD-B24 caption decoder/renderer using libaribcaption.
+ *****************************************************************************
+ * Copyright (C) 2022 magicxqq
+ *
+ * Authors:  magicxqq <xqq at xqq.im>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#   include "config.h"
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <limits.h>
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_atomic.h>
+#include <vlc_codec.h>
+
+#include <aribcaption/aribcaption.h>
+
+
+/*****************************************************************************
+ * Local prototypes
+ *****************************************************************************/
+typedef struct
+{
+    /* The following fields of decoder_sys_t are shared between decoder and spu units */
+    vlc_atomic_rc_t    rc;
+
+    int                i_cfg_rendering_backend;
+    char*              psz_cfg_font_name;
+    bool               b_cfg_replace_drcs;
+    bool               b_cfg_force_stroke_text;
+    bool               b_cfg_ignore_background;
+    bool               b_cfg_ignore_ruby;
+    bool               b_cfg_fadeout;
+    float              f_cfg_stroke_width;
+
+    aribcc_context_t  *p_context;
+    aribcc_decoder_t  *p_decoder;
+    aribcc_renderer_t *p_renderer;
+
+    vlc_mutex_t        dec_lock;    // protect p_dec pointer
+    decoder_t*         p_dec;       // pointer to decoder_t for logcat callback, NULL if decoder closed
+} decoder_sys_t;
+
+typedef struct
+{
+    decoder_sys_t         *p_dec_sys;
+    vlc_tick_t             i_pts;
+    aribcc_render_result_t render_result;
+} libaribcaption_spu_updater_sys_t;
+
+
+static void DecSysRetain(decoder_sys_t *p_sys)
+{
+    vlc_atomic_rc_inc(&p_sys->rc);
+}
+
+static void DecSysRelease(decoder_sys_t *p_sys)
+{
+    if (!vlc_atomic_rc_dec(&p_sys->rc))
+        return;
+
+    if (p_sys->p_renderer)
+        aribcc_renderer_free(p_sys->p_renderer);
+    if (p_sys->p_decoder)
+        aribcc_decoder_free(p_sys->p_decoder);
+    if (p_sys->p_context)
+        aribcc_context_free(p_sys->p_context);
+
+    free(p_sys);
+}
+
+
+/****************************************************************************
+ *
+ ****************************************************************************/
+static int SubpictureValidate(subpicture_t *p_subpic,
+                              bool b_src_changed, const video_format_t *p_src_format,
+                              bool b_dst_changed, const video_format_t *p_dst_format,
+                              vlc_tick_t i_ts)
+{
+    VLC_UNUSED(p_src_format);
+
+    libaribcaption_spu_updater_sys_t *p_spusys = p_subpic->updater.p_sys;
+    decoder_sys_t *p_sys = p_spusys->p_dec_sys;
+
+    if (b_src_changed || b_dst_changed) {
+        const video_format_t *fmt = p_dst_format;
+        aribcc_renderer_set_frame_size(p_sys->p_renderer, fmt->i_visible_width, fmt->i_visible_height);
+    }
+
+    const vlc_tick_t i_stream_date = p_spusys->i_pts + (i_ts - p_subpic->i_start);
+
+    aribcc_render_status_t status = aribcc_renderer_render(p_sys->p_renderer,
+                                                           MS_FROM_VLC_TICK(i_stream_date),
+                                                           &p_spusys->render_result);
+    if (status == ARIBCC_RENDER_STATUS_ERROR) {
+        return VLC_SUCCESS;
+    }
+
+    bool b_changed = (status != ARIBCC_RENDER_STATUS_GOT_IMAGE_UNCHANGED);
+
+    if (!b_changed && !b_src_changed && !b_dst_changed &&
+        (p_spusys->render_result.images != NULL) == (p_subpic->p_region != NULL)) {
+        aribcc_render_result_cleanup(&p_spusys->render_result);
+        return VLC_SUCCESS;
+    }
+
+    return VLC_EGENERIC;
+}
+
+static void CopyImageToRegion(subpicture_region_t *p_region, const aribcc_image_t *image)
+{
+    const plane_t *p = &p_region->p_picture->p[0];
+    const int i_height = p_region->fmt.i_height;
+    const uint32_t copy_line_size = __MIN(image->stride, p->i_pitch);
+
+    memset(p->p_pixels, 0, p->i_pitch * p->i_visible_lines);
+
+    for (int y = 0; y < i_height; y++) {
+        const uint8_t *src_line_begin = image->bitmap + y * image->stride;
+        uint8_t *dst_line_begin = p->p_pixels + y * p->i_pitch;
+        memcpy(dst_line_begin, src_line_begin, copy_line_size);
+    }
+}
+
+static void SubpictureUpdate(subpicture_t *p_subpic,
+                             const video_format_t *p_src_format,
+                             const video_format_t *p_dst_format,
+                             vlc_tick_t i_ts)
+{
+    VLC_UNUSED(p_src_format); VLC_UNUSED(p_dst_format); VLC_UNUSED(i_ts);
+
+    libaribcaption_spu_updater_sys_t *p_spusys = p_subpic->updater.p_sys;
+
+    video_format_t  fmt = *p_dst_format;
+    fmt.i_chroma         = VLC_CODEC_RGBA;
+    fmt.i_bits_per_pixel = 0;
+    fmt.i_x_offset       = 0;
+    fmt.i_y_offset       = 0;
+
+    aribcc_image_t *p_images = p_spusys->render_result.images;
+    uint32_t        i_image_count = p_spusys->render_result.image_count;
+
+    p_subpic->i_original_picture_width = fmt.i_visible_width;
+    p_subpic->i_original_picture_height = fmt.i_visible_height;
+
+    if (!p_images || i_image_count == 0) {
+        return;
+    }
+
+    /* Allocate the regions and draw them */
+    subpicture_region_t **pp_region_last = &p_subpic->p_region;
+
+    for (uint32_t i = 0; i < i_image_count; i++) {
+        aribcc_image_t *image = &p_images[i];
+        video_format_t  fmt_region = fmt;
+
+        fmt_region.i_width =
+        fmt_region.i_visible_width  = image->width;
+        fmt_region.i_height =
+        fmt_region.i_visible_height = image->height;
+
+        subpicture_region_t *region = subpicture_region_New(&fmt_region);
+        if (!region)
+            break;
+
+        region->i_x = image->dst_x;
+        region->i_y = image->dst_y;
+        region->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
+
+        CopyImageToRegion(region, image);
+
+        *pp_region_last = region;
+        pp_region_last = &region->p_next;
+    }
+
+    aribcc_render_result_cleanup(&p_spusys->render_result);
+}
+
+static void SubpictureDestroy(subpicture_t *p_subpic)
+{
+    libaribcaption_spu_updater_sys_t *p_spusys = p_subpic->updater.p_sys;
+    DecSysRelease(p_spusys->p_dec_sys);
+    free(p_spusys);
+}
+
+/****************************************************************************
+ * Decode:
+ ****************************************************************************/
+static int Decode(decoder_t *p_dec, block_t *p_block)
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+
+    if (p_block == NULL) /* No Drain */
+        return VLCDEC_SUCCESS;
+
+    if (p_block->i_flags & BLOCK_FLAG_CORRUPTED) {
+        block_Release(p_block);
+        return VLCDEC_SUCCESS;
+    }
+
+    aribcc_caption_t caption;
+    aribcc_decode_status_t status = aribcc_decoder_decode(p_sys->p_decoder,
+                                                          p_block->p_buffer,
+                                                          p_block->i_buffer,
+                                                          MS_FROM_VLC_TICK(p_block->i_pts),
+                                                          &caption);
+    if (status == ARIBCC_DECODE_STATUS_ERROR) {
+        msg_Err(p_dec, "aribcc_decoder_decode() returned with error");
+    }
+
+    if (status == ARIBCC_DECODE_STATUS_ERROR || status == ARIBCC_DECODE_STATUS_NO_CAPTION) {
+        block_Release(p_block);
+        return VLCDEC_SUCCESS;
+    }
+
+    aribcc_renderer_append_caption(p_sys->p_renderer, &caption);
+    aribcc_caption_cleanup(&caption);
+
+
+    libaribcaption_spu_updater_sys_t *p_spusys = malloc(sizeof(libaribcaption_spu_updater_sys_t));
+    if (!p_spusys) {
+        block_Release(p_block);
+        return VLCDEC_SUCCESS;
+    }
+    p_spusys->p_dec_sys = p_sys;
+    p_spusys->i_pts = p_block->i_pts;
+    memset(&p_spusys->render_result, 0, sizeof(p_spusys->render_result));
+
+    subpicture_updater_t updater = {
+        .pf_validate = SubpictureValidate,
+        .pf_update   = SubpictureUpdate,
+        .pf_destroy  = SubpictureDestroy,
+        .p_sys       = p_spusys,
+    };
+
+    subpicture_t *p_spu = decoder_NewSubpicture(p_dec, &updater);
+    if (!p_spu) {
+        msg_Warn(p_dec, "can't get spu buffer");
+        free(p_spusys);
+        block_Release(p_block);
+        return VLCDEC_SUCCESS;
+    }
+    p_spu->i_start = p_block->i_pts;
+    p_spu->i_stop = p_block->i_pts;
+    p_spu->b_absolute = true;
+    p_spu->b_fade = p_sys->b_cfg_fadeout;
+
+    if (caption.wait_duration == ARIBCC_DURATION_INDEFINITE) {
+        p_spu->b_ephemer = true;
+    } else {
+        p_spu->i_stop = p_block->i_pts + VLC_TICK_FROM_MS(caption.wait_duration);
+    }
+
+
+    DecSysRetain(p_sys); /* Keep a reference for the returned subpicture */
+
+    block_Release(p_block);
+
+    decoder_QueueSub(p_dec, p_spu);
+
+    return VLCDEC_SUCCESS;
+}
+
+/*****************************************************************************
+ * Flush:
+ *****************************************************************************/
+static void Flush(decoder_t *p_dec)
+{
+    decoder_sys_t *p_sys = p_dec->p_sys;
+    aribcc_decoder_flush(p_sys->p_decoder);
+    aribcc_renderer_flush(p_sys->p_renderer);
+}
+
+/*****************************************************************************
+ * libaribcaption logcat callback function
+ *****************************************************************************/
+static void LogcatCallback(aribcc_loglevel_t level, const char *message, void *userdata)
+{
+    decoder_sys_t *p_sys = userdata;
+
+    if (p_sys->p_dec != NULL) {
+        vlc_mutex_lock(&p_sys->dec_lock);
+
+        if (p_sys->p_dec != NULL) {
+            decoder_t* p_dec = p_sys->p_dec;
+
+            if (level == ARIBCC_LOGLEVEL_ERROR) {
+                msg_Err(p_dec, "%s", message);
+            } else if (level == ARIBCC_LOGLEVEL_WARNING) {
+                msg_Warn(p_dec, "%s", message);
+            } else {
+                msg_Dbg(p_dec, "%s", message);
+            }
+        }
+
+        vlc_mutex_unlock(&p_sys->dec_lock);
+    }
+}
+
+#define ARIBCAPTION_CFG_PREFIX "aribcaption-"
+
+/*****************************************************************************
+ * Open: Create libaribcaption context/decoder/renderer.
+ *****************************************************************************/
+static int Open(vlc_object_t *p_this)
+{
+    decoder_t     *p_dec = (decoder_t *)p_this;
+    decoder_sys_t *p_sys;
+
+    if (p_dec->fmt_in.i_codec != VLC_CODEC_ARIB_A &&
+        p_dec->fmt_in.i_codec != VLC_CODEC_ARIB_C) {
+        return VLC_ENOTSUP;
+    }
+
+    p_sys = malloc(sizeof(decoder_sys_t));
+    if (unlikely(p_sys == NULL))
+        return VLC_ENOMEM;
+
+    vlc_atomic_rc_init(&p_sys->rc);
+
+    p_sys->i_cfg_rendering_backend = var_InheritInteger(p_this, ARIBCAPTION_CFG_PREFIX "rendering-backend");
+    p_sys->psz_cfg_font_name = var_InheritString(p_this, ARIBCAPTION_CFG_PREFIX "font");
+    p_sys->b_cfg_replace_drcs = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "replace-drcs");
+    p_sys->b_cfg_force_stroke_text = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "force-stroke-text");
+    p_sys->b_cfg_ignore_background = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "ignore-background");
+    p_sys->b_cfg_ignore_ruby = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "ignore-ruby");
+    p_sys->b_cfg_fadeout = var_InheritBool(p_this, ARIBCAPTION_CFG_PREFIX "fadeout");
+    p_sys->f_cfg_stroke_width = var_InheritFloat(p_this, ARIBCAPTION_CFG_PREFIX "stroke-width");
+
+    vlc_mutex_init(&p_sys->dec_lock);
+    p_sys->p_dec = p_dec;
+
+    /* Create libaribcaption context */
+    aribcc_context_t *p_ctx = p_sys->p_context = aribcc_context_alloc();
+    if (!p_ctx) {
+        msg_Err(p_dec, "libaribcaption context allocation failed");
+        DecSysRelease(p_sys);
+        return VLC_EGENERIC;
+    }
+
+    aribcc_context_set_logcat_callback(p_ctx, LogcatCallback, p_sys);
+
+
+    /* Create the decoder */
+    aribcc_decoder_t* p_decoder = p_sys->p_decoder = aribcc_decoder_alloc(p_ctx);
+    if (!p_decoder) {
+        msg_Err(p_dec, "libaribcaption decoder creation failed");
+        DecSysRelease(p_sys);
+        return VLC_EGENERIC;
+    }
+
+    aribcc_profile_t i_profile = ARIBCC_PROFILE_A;
+    if (p_dec->fmt_in.i_codec == VLC_CODEC_ARIB_C) {
+        i_profile = ARIBCC_PROFILE_C;
+    }
+
+    bool b_succ = aribcc_decoder_initialize(p_decoder,
+                                            ARIBCC_ENCODING_SCHEME_AUTO,
+                                            ARIBCC_CAPTIONTYPE_CAPTION,
+                                            i_profile,
+                                            ARIBCC_LANGUAGEID_FIRST);
+    if (!b_succ) {
+        msg_Err(p_dec, "libaribcaption decoder initialization failed");
+        DecSysRelease(p_sys);
+        return VLC_EGENERIC;
+    }
+
+
+    /* Create the renderer */
+    aribcc_renderer_t* p_renderer = p_sys->p_renderer = aribcc_renderer_alloc(p_ctx);
+    if (!p_renderer) {
+        msg_Err(p_dec, "libaribcaption renderer creation failed");
+        DecSysRelease(p_sys);
+        return VLC_EGENERIC;
+    }
+
+    b_succ = aribcc_renderer_initialize(p_renderer,
+                                        ARIBCC_CAPTIONTYPE_CAPTION,
+                                        ARIBCC_FONTPROVIDER_TYPE_AUTO,
+                                        (aribcc_textrenderer_type_t)p_sys->i_cfg_rendering_backend);
+    if (!b_succ) {
+        msg_Err(p_dec, "libaribcaption renderer initialization failed");
+        DecSysRelease(p_sys);
+        return VLC_EGENERIC;
+    }
+    aribcc_renderer_set_storage_policy(p_renderer, ARIBCC_CAPTION_STORAGE_POLICY_MINIMUM, 0);
+    aribcc_renderer_set_replace_drcs(p_renderer, p_sys->b_cfg_replace_drcs);
+    aribcc_renderer_set_force_stroke_text(p_renderer, p_sys->b_cfg_force_stroke_text);
+    aribcc_renderer_set_force_no_background(p_renderer, p_sys->b_cfg_ignore_background);
+    aribcc_renderer_set_force_no_ruby(p_renderer, p_sys->b_cfg_ignore_ruby);
+    aribcc_renderer_set_stroke_width(p_renderer, p_sys->f_cfg_stroke_width);
+
+    if (p_sys->psz_cfg_font_name && strlen(p_sys->psz_cfg_font_name) > 0) {
+        const char* font_families[] = { p_sys->psz_cfg_font_name };
+        aribcc_renderer_set_default_font_family(p_renderer, font_families, 1, true);
+    }
+
+    p_dec->p_sys = p_sys;
+    p_dec->pf_decode = Decode;
+    p_dec->pf_flush  = Flush;
+    p_dec->fmt_out.i_codec = VLC_CODEC_RGBA;
+
+    return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * Close: finish
+ *****************************************************************************/
+static void Close(vlc_object_t *p_this)
+{
+    decoder_t *p_dec = (decoder_t *)p_this;
+    decoder_sys_t *p_sys = p_dec->p_sys;
+
+    vlc_mutex_lock(&p_sys->dec_lock);
+    p_sys->p_dec = NULL;
+    vlc_mutex_unlock(&p_sys->dec_lock);
+
+    DecSysRelease(p_sys);
+}
+
+
+#define CFG_TEXT_RENDERING_BACKEND N_("Text rendering backend")
+#define CFG_LONGTEXT_RENDERING_BACKEND N_("Select text rendering backend")
+
+#define CFG_TEXT_FONT N_("Font")
+#define CFG_LONGTEXT_FONT N_("Select font")
+
+#define CFG_TEXT_REPLACE_DRCS N_("Replace known DRCS")
+#define CFG_LONGTEXT_REPLACE_DRCS N_("Replace known DRCS in the caption")
+
+#define CFG_TEXT_FORCE_STROKE_TEXT N_("Force stroke text")
+#define CFG_LONGTEXT_FORCE_STROKE_TEXT N_("Always render characters with stroke")
+
+#define CFG_TEXT_IGNORE_BACKGROUND N_("Ignore background")
+#define CFG_LONGTEXT_IGNORE_BACKGROUND N_("Ignore rendering caption background")
+
+#define CFG_TEXT_IGNORE_RUBY N_("Ignore ruby (furigana)")
+#define CFG_LONGTEXT_IGNORE_RUBY N_("Ignore ruby-like characters, like furigana")
+
+#define CFG_TEXT_FADEOUT N_("Fadeout")
+#define CFG_LONGTEXT_FADEOUT N_("Enable Fadeout")
+
+#define CFG_TEXT_STROKE_WIDTH N_("Stroke width")
+#define CFG_LONGTEXT_STROKE_WIDTH N_("Indicate stroke width for stroke text")
+
+
+static const int rendering_backend_values[] = {
+    ARIBCC_TEXTRENDERER_TYPE_AUTO,
+
+#if defined(ARIBCC_USE_CORETEXT)
+    ARIBCC_TEXTRENDERER_TYPE_CORETEXT,
+#endif
+
+#if defined(ARIBCC_USE_DIRECTWRITE)
+    ARIBCC_TEXTRENDERER_TYPE_DIRECTWRITE,
+#endif
+
+#if defined(ARIBCC_USE_FREETYPE)
+    ARIBCC_TEXTRENDERER_TYPE_FREETYPE
+#endif
+};
+
+static const char* const ppsz_rendering_backend_descriptions[] = {
+    N_("Auto"),
+
+#if defined(ARIBCC_USE_CORETEXT)
+    N_("CoreText"),
+#endif
+
+#if defined(ARIBCC_USE_DIRECTWRITE)
+    N_("DirectWrite"),
+#endif
+
+#if defined(ARIBCC_USE_FREETYPE)
+    N_("FreeType")
+#endif
+};
+
+#ifdef __APPLE__
+# define DEFAULT_FAMILY "Hiragino Maru Gothic ProN"
+#elif defined(_WIN32)
+# define DEFAULT_FAMILY "MS Gothic"
+#else
+# define DEFAULT_FAMILY "sans-serif"
+#endif
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+vlc_module_begin ()
+    set_shortname(N_("ARIB caption"))
+    set_description(N_("ARIB caption renderer"))
+    set_capability("spu decoder", 60)
+    set_subcategory(SUBCAT_INPUT_SCODEC)
+    set_callbacks(Open, Close)
+
+    add_integer(ARIBCAPTION_CFG_PREFIX "rendering-backend", 0, CFG_TEXT_RENDERING_BACKEND, CFG_LONGTEXT_RENDERING_BACKEND)
+        change_integer_list(rendering_backend_values, ppsz_rendering_backend_descriptions)
+    add_font(ARIBCAPTION_CFG_PREFIX "font", DEFAULT_FAMILY, CFG_TEXT_FONT, CFG_LONGTEXT_FONT)
+    add_bool(ARIBCAPTION_CFG_PREFIX "replace-drcs", true, CFG_TEXT_REPLACE_DRCS, CFG_LONGTEXT_REPLACE_DRCS)
+    add_bool(ARIBCAPTION_CFG_PREFIX "force-stroke-text", false, CFG_TEXT_FORCE_STROKE_TEXT, CFG_LONGTEXT_FORCE_STROKE_TEXT)
+    add_bool(ARIBCAPTION_CFG_PREFIX "ignore-background", false, CFG_TEXT_IGNORE_BACKGROUND, CFG_LONGTEXT_IGNORE_BACKGROUND)
+    add_bool(ARIBCAPTION_CFG_PREFIX "ignore-ruby", false, CFG_TEXT_IGNORE_RUBY, CFG_LONGTEXT_IGNORE_RUBY)
+    add_bool(ARIBCAPTION_CFG_PREFIX "fadeout", false, CFG_TEXT_FADEOUT, CFG_LONGTEXT_FADEOUT)
+    add_float_with_range(ARIBCAPTION_CFG_PREFIX "stroke-width", 1.5f, 0.0f, 3.0f, CFG_TEXT_STROKE_WIDTH, CFG_LONGTEXT_STROKE_WIDTH)
+vlc_module_end ()


=====================================
modules/demux/mpeg/ts_psi.c
=====================================
@@ -1311,14 +1311,12 @@ static void PMTSetupEs0x06( demux_t *p_demux, ts_stream_t *p_pes,
                 PMTEsHasComponentTagBetween( p_dvbpsies, 0x30, 0x37 ) )
             {
                 es_format_Change( p_fmt, SPU_ES, VLC_CODEC_ARIB_A );
-                p_fmt->psz_language = strndup ( "jpn", 3 );
                 p_fmt->psz_description = strdup( _("ARIB subtitles") );
             }
             else if( i_data_component_id == 0x0012 &&
                      PMTEsHasComponentTagBetween( p_dvbpsies, 0x87, 0x88 ) )
             {
                 es_format_Change( p_fmt, SPU_ES, VLC_CODEC_ARIB_C );
-                p_fmt->psz_language = strndup ( "jpn", 3 );
                 p_fmt->psz_description = strdup( _("ARIB subtitles") );
             }
         }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/98374a84f40a31cace228e5f4331973365de89b9...5f74392dcbac45ab762adbae6c6e49cd02fa5029

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/98374a84f40a31cace228e5f4331973365de89b9...5f74392dcbac45ab762adbae6c6e49cd02fa5029
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list