Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • Thrillseekr/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
400 results
Show changes
Commits on Source (5)
......@@ -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
......
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 $@
......@@ -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
......
......@@ -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"
......
......@@ -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)'
......
/*****************************************************************************
* ARIB STD-B24 caption decoder/renderer using libaribcaption.
*****************************************************************************
* Copyright (C) 2022 magicxqq
*
* Authors: magicxqq <xqq@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 ()
......@@ -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") );
}
}
......