Commit 97c02be6 authored by Naohiro KORIYAMA's avatar Naohiro KORIYAMA Committed by Francois Cartegnie

codecs: add support for ARIB subtitles

Fixed-by: default avatarFrancois Cartegnie <fcvlcdev@free.fr>
Signed-off-by: default avatarFrancois Cartegnie <fcvlcdev@free.fr>
parent b48567c9
......@@ -10,6 +10,7 @@ Access:
Decoder:
* OMX GPU-zerocopy support for decoding and display on Android using OpenMax IL
* Support 4:4:4 chroma sampling with VDPAU hw acceleration
* Support for ARIB B24 subtitles
Demuxers:
* Support HD-DVD .evo (H.264, VC-1, MPEG-2, PCM, AC-3, E-AC3, MLP, DTS)
......
......@@ -3032,6 +3032,24 @@ AS_IF( [test "${enable_libass}" != "no"], [
])
])
dnl
dnl ARIB subtitles rendering module
dnl
AC_ARG_ENABLE(aribsub,
[ --enable-aribsub ARIB Subtitles support (default enabled)])
AS_IF( [test "${enable_aribsub}" != "no" ],[
PKG_CHECK_MODULES(ARIBB24, [aribb24 >= 1.0.1], [
have_aribb24="yes"
VLC_ADD_PLUGIN([aribsub])
VLC_ADD_LIBS([aribsub],[-laribb24])
AC_DEFINE(HAVE_ARIBB24, 1, [Define if libaribb24 is available.])
],[
AC_MSG_WARN(Library [aribb24] needed for [aribsub] was not found)
have_aribb24="no"
])
AM_CONDITIONAL([HAVE_ARIBB24], [test "${have_aribb24}" = "yes"])
])
dnl
dnl kate decoder plugin
dnl
......
......@@ -452,6 +452,8 @@
#define VLC_CODEC_OGT VLC_FOURCC('o','g','t',' ')
#define VLC_CODEC_CVD VLC_FOURCC('c','v','d',' ')
#define VLC_CODEC_TX3G VLC_FOURCC('t','x','3','g')
#define VLC_CODEC_ARIB_A VLC_FOURCC('a','r','b','a')
#define VLC_CODEC_ARIB_C VLC_FOURCC('a','r','b','c')
/* Blu-ray Presentation Graphics */
#define VLC_CODEC_BD_PG VLC_FOURCC('b','d','p','g')
/* EBU STL (TECH. 3264-E) */
......
......@@ -37,6 +37,7 @@ $Id$
* android_surface: video output for Android, based on Surface
* antiflicker: anti-flicker video filter
* araw: Pseudo audio decoder for raw PCM
* aribsub: ARIB subtitles decoder
* asf: ASF demuxer
* atmo: Ambilight-like video-output
* attachment: Attachment access module
......
......@@ -152,6 +152,11 @@ codec_LTLIBRARIES += libcvdsub_plugin.la
libdvbsub_plugin_la_SOURCES = codec/dvbsub.c
codec_LTLIBRARIES += libdvbsub_plugin.la
libaribsub_plugin_la_SOURCES = codec/arib/aribsub.c codec/arib/substext.h
libaribsub_plugin_la_CFLAGS = $(ARIBB24_CFLAGS)
libaribsub_plugin_la_LIBADD = $(ARIBB24_LIBS)
codec_LTLIBRARIES += libaribsub_plugin.la
libscte27_plugin_la_SOURCES = codec/scte27.c
codec_LTLIBRARIES += libscte27_plugin.la
......
This diff is collapsed.
/*****************************************************************************
* substext.h : ARIB subtitles subpicture decoder
*****************************************************************************
* Copyright (C) 2012 Naohiro KORIYAMA
*
* Authors: Naohiro KORIYAMA <nkoriyama@gmail.com>
*
* 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.
*****************************************************************************/
typedef struct arib_text_region_s
{
char *psz_text;
char *psz_html;
char *psz_fontname;
int i_font_color;
int i_planewidth;
int i_planeheight;
int i_fontwidth;
int i_fontheight;
int i_verint;
int i_horint;
int i_charleft;
int i_charbottom;
int i_charleft_adj;
int i_charbottom_adj;
struct arib_text_region_s *p_next;
} arib_text_region_t;
struct subpicture_updater_sys_t
{
arib_text_region_t *p_region;
};
static int SubpictureTextValidate(subpicture_t *subpic,
bool has_src_changed, const video_format_t *fmt_src,
bool has_dst_changed, const video_format_t *fmt_dst,
mtime_t ts)
{
subpicture_updater_sys_t *sys = subpic->updater.p_sys;
VLC_UNUSED(fmt_src); VLC_UNUSED(fmt_dst); VLC_UNUSED(ts);
VLC_UNUSED(sys);
if (!has_src_changed && !has_dst_changed)
{
return VLC_SUCCESS;
}
return VLC_EGENERIC;
}
static void SubpictureTextUpdate(subpicture_t *subpic,
const video_format_t *fmt_src,
const video_format_t *fmt_dst,
mtime_t ts)
{
subpicture_updater_sys_t *sys = subpic->updater.p_sys;
VLC_UNUSED(fmt_src); VLC_UNUSED(ts);
if (fmt_dst->i_sar_num <= 0 || fmt_dst->i_sar_den <= 0)
{
return;
}
video_format_t fmt;
video_format_Init(&fmt, VLC_CODEC_TEXT);
fmt.i_sar_num = 1;
fmt.i_sar_den = 1;
subpicture_region_t *r = NULL;
arib_text_region_t *p_region;
for( p_region = sys->p_region; p_region; p_region = p_region->p_next )
{
if( !r )
{
subpic->p_region = r = subpicture_region_New(&fmt);
}
else
{
r->p_next = subpicture_region_New(&fmt);
r = r->p_next;
}
if( r == NULL )
{
return;
}
r->psz_text = p_region->psz_text ? strdup(p_region->psz_text) : NULL;
r->psz_html = p_region->psz_html ? strdup(p_region->psz_html) : NULL;
r->i_align = SUBPICTURE_ALIGN_LEFT | SUBPICTURE_ALIGN_TOP;
subpic->i_original_picture_width = p_region->i_planewidth;
subpic->i_original_picture_height = p_region->i_planeheight;
r->i_x = p_region->i_charleft - (p_region->i_fontwidth + p_region->i_horint / 2) + p_region->i_charleft_adj;
r->i_y = p_region->i_charbottom - (p_region->i_fontheight + p_region->i_verint / 2) + p_region->i_charbottom_adj;
r->p_style = text_style_New();
r->p_style->psz_fontname = p_region->psz_fontname ? strdup( p_region->psz_fontname ) : NULL;
r->p_style->i_font_size = p_region->i_fontheight;
r->p_style->i_font_color = p_region->i_font_color;
r->p_style->i_style_flags = 0;
if( p_region->i_fontwidth < p_region->i_fontheight )
{
r->p_style->i_style_flags |= STYLE_HALFWIDTH;
}
r->p_style->i_spacing = p_region->i_horint;
}
}
static void SubpictureTextDestroy(subpicture_t *subpic)
{
subpicture_updater_sys_t *sys = subpic->updater.p_sys;
arib_text_region_t *p_region, *p_region_next;
for( p_region = sys->p_region; p_region; p_region = p_region_next )
{
free( p_region->psz_text );
free( p_region->psz_html );
free( p_region->psz_fontname );
p_region_next = p_region->p_next;
free( p_region );
}
sys->p_region = NULL;
free( sys );
}
static inline subpicture_t *decoder_NewSubpictureText(decoder_t *decoder)
{
subpicture_updater_sys_t *sys = (subpicture_updater_sys_t*)
calloc( 1, sizeof(subpicture_updater_sys_t) );
subpicture_updater_t updater = {
.pf_validate = SubpictureTextValidate,
.pf_update = SubpictureTextUpdate,
.pf_destroy = SubpictureTextDestroy,
.p_sys = sys,
};
subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater);
if( subpic == NULL )
{
free( sys );
}
return subpic;
}
......@@ -345,6 +345,7 @@ modules/codec/a52.c
modules/codec/adpcm.c
modules/codec/aes3.c
modules/codec/araw.c
modules/codec/arib/aribsub.c
modules/codec/avcodec/audio.c
modules/codec/avcodec/avcodec.c
modules/codec/avcodec/avcodec.h
......
......@@ -1559,6 +1559,12 @@ static const staticentry_t p_list_spu[] = {
B(VLC_CODEC_CVD, "CVD subtitles"),
A("cvd "),
B(VLC_CODEC_ARIB_A, "ARIB subtitles (A-profile)"),
A("arba"),
B(VLC_CODEC_ARIB_C, "ARIB subtitles (C-profile)"),
A("arbc"),
B(VLC_CODEC_BD_PG, "BD subtitles"),
A("bdpg"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment