Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
a1d39b55
Commit
a1d39b55
authored
Apr 26, 2011
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separated SRT and USF subtitles decoder.
parent
675a76e9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
182 deletions
+87
-182
modules/codec/Modules.am
modules/codec/Modules.am
+2
-2
modules/codec/subsdec.c
modules/codec/subsdec.c
+24
-66
modules/codec/subsdec.h
modules/codec/subsdec.h
+0
-94
modules/codec/subsusf.c
modules/codec/subsusf.c
+61
-20
No files found.
modules/codec/Modules.am
View file @
a1d39b55
...
@@ -33,8 +33,8 @@ SOURCES_kate = kate.c
...
@@ -33,8 +33,8 @@ SOURCES_kate = kate.c
SOURCES_schroedinger = schroedinger.c
SOURCES_schroedinger = schroedinger.c
SOURCES_libass = libass.c
SOURCES_libass = libass.c
SOURCES_aes3 = aes3.c
SOURCES_aes3 = aes3.c
SOURCES_subsdec = subsdec.c
subsdec.h
SOURCES_subsdec = subsdec.c
SOURCES_subsusf = subsusf.c
subsdec.h
SOURCES_subsusf = subsusf.c
SOURCES_t140 = t140.c
SOURCES_t140 = t140.c
SOURCES_crystalhd = crystalhd.c
SOURCES_crystalhd = crystalhd.c
...
...
modules/codec/subsdec.c
View file @
a1d39b55
...
@@ -31,20 +31,10 @@
...
@@ -31,20 +31,10 @@
# include "config.h"
# include "config.h"
#endif
#endif
#include
"subsdec.h"
#include
<vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
#include <vlc_codec.h>
/*****************************************************************************
#include <vlc_charset.h>
* Local prototypes
*****************************************************************************/
static
int
OpenDecoder
(
vlc_object_t
*
);
static
void
CloseDecoder
(
vlc_object_t
*
);
static
subpicture_t
*
DecodeBlock
(
decoder_t
*
,
block_t
**
);
static
subpicture_t
*
ParseText
(
decoder_t
*
,
block_t
*
);
static
char
*
StripTags
(
char
*
);
static
char
*
CreateHtmlSubtitle
(
int
*
pi_align
,
char
*
);
/*****************************************************************************
/*****************************************************************************
* Module descriptor.
* Module descriptor.
...
@@ -178,6 +168,8 @@ static const char *const ppsz_justification_text[] = {
...
@@ -178,6 +168,8 @@ static const char *const ppsz_justification_text[] = {
#define FORMAT_LONGTEXT N_("Some subtitle formats allow for text formatting. " \
#define FORMAT_LONGTEXT N_("Some subtitle formats allow for text formatting. " \
"VLC partly implements this, but you can choose to disable all formatting.")
"VLC partly implements this, but you can choose to disable all formatting.")
static
int
OpenDecoder
(
vlc_object_t
*
);
static
void
CloseDecoder
(
vlc_object_t
*
);
vlc_module_begin
()
vlc_module_begin
()
set_shortname
(
N_
(
"Subtitles"
))
set_shortname
(
N_
(
"Subtitles"
))
...
@@ -199,6 +191,25 @@ vlc_module_begin ()
...
@@ -199,6 +191,25 @@ vlc_module_begin ()
false
)
false
)
vlc_module_end
()
vlc_module_end
()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
#define NO_BREAKING_SPACE " "
struct
decoder_sys_t
{
int
i_align
;
/* Subtitles alignment on the vout */
vlc_iconv_t
iconv_handle
;
/* handle to iconv instance */
bool
b_autodetect_utf8
;
};
static
subpicture_t
*
DecodeBlock
(
decoder_t
*
,
block_t
**
);
static
subpicture_t
*
ParseText
(
decoder_t
*
,
block_t
*
);
static
char
*
StripTags
(
char
*
);
static
char
*
CreateHtmlSubtitle
(
int
*
pi_align
,
char
*
);
/*****************************************************************************
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
* OpenDecoder: probe the decoder and return score
*****************************************************************************
*****************************************************************************
...
@@ -232,10 +243,6 @@ static int OpenDecoder( vlc_object_t *p_this )
...
@@ -232,10 +243,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys
->
i_align
=
0
;
p_sys
->
i_align
=
0
;
p_sys
->
iconv_handle
=
(
vlc_iconv_t
)
-
1
;
p_sys
->
iconv_handle
=
(
vlc_iconv_t
)
-
1
;
p_sys
->
b_autodetect_utf8
=
false
;
p_sys
->
b_autodetect_utf8
=
false
;
p_sys
->
i_original_height
=
-
1
;
p_sys
->
i_original_width
=
-
1
;
TAB_INIT
(
p_sys
->
i_ssa_styles
,
p_sys
->
pp_ssa_styles
);
TAB_INIT
(
p_sys
->
i_images
,
p_sys
->
pp_images
);
char
*
psz_charset
=
NULL
;
char
*
psz_charset
=
NULL
;
...
@@ -352,37 +359,6 @@ static void CloseDecoder( vlc_object_t *p_this )
...
@@ -352,37 +359,6 @@ static void CloseDecoder( vlc_object_t *p_this )
if
(
p_sys
->
iconv_handle
!=
(
vlc_iconv_t
)
-
1
)
if
(
p_sys
->
iconv_handle
!=
(
vlc_iconv_t
)
-
1
)
vlc_iconv_close
(
p_sys
->
iconv_handle
);
vlc_iconv_close
(
p_sys
->
iconv_handle
);
if
(
p_sys
->
pp_ssa_styles
)
{
int
i
;
for
(
i
=
0
;
i
<
p_sys
->
i_ssa_styles
;
i
++
)
{
if
(
!
p_sys
->
pp_ssa_styles
[
i
]
)
continue
;
free
(
p_sys
->
pp_ssa_styles
[
i
]
->
psz_stylename
);
free
(
p_sys
->
pp_ssa_styles
[
i
]
->
font_style
.
psz_fontname
);
free
(
p_sys
->
pp_ssa_styles
[
i
]
);
}
TAB_CLEAN
(
p_sys
->
i_ssa_styles
,
p_sys
->
pp_ssa_styles
);
}
if
(
p_sys
->
pp_images
)
{
int
i
;
for
(
i
=
0
;
i
<
p_sys
->
i_images
;
i
++
)
{
if
(
!
p_sys
->
pp_images
[
i
]
)
continue
;
if
(
p_sys
->
pp_images
[
i
]
->
p_pic
)
picture_Release
(
p_sys
->
pp_images
[
i
]
->
p_pic
);
free
(
p_sys
->
pp_images
[
i
]
->
psz_filename
);
free
(
p_sys
->
pp_images
[
i
]
);
}
TAB_CLEAN
(
p_sys
->
i_images
,
p_sys
->
pp_images
);
}
free
(
p_sys
);
free
(
p_sys
);
}
}
...
@@ -517,24 +493,6 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
...
@@ -517,24 +493,6 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
return
p_spu
;
return
p_spu
;
}
}
char
*
GotoNextLine
(
char
*
psz_text
)
{
char
*
p_newline
=
psz_text
;
while
(
p_newline
[
0
]
!=
'\0'
)
{
if
(
p_newline
[
0
]
==
'\n'
||
p_newline
[
0
]
==
'\r'
)
{
p_newline
++
;
while
(
p_newline
[
0
]
==
'\n'
||
p_newline
[
0
]
==
'\r'
)
p_newline
++
;
break
;
}
else
p_newline
++
;
}
return
p_newline
;
}
/* Function now handles tags with attribute values, and tries
/* Function now handles tags with attribute values, and tries
* to deal with &' commands too. It no longer modifies the string
* to deal with &' commands too. It no longer modifies the string
* in place, so that the original text can be reused
* in place, so that the original text can be reused
...
...
modules/codec/subsdec.h
deleted
100644 → 0
View file @
675a76e9
/*****************************************************************************
* subsdec.h : text/ASS-SSA/USF subtitles headers
*****************************************************************************
* Copyright (C) 2000-2006 the VideoLAN team
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Samuel Hocevar <sam@zoy.org>
* Derk-Jan Hartman <hartman at videolan dot org>
* Bernie Purcell <bitmap@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU 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.
*****************************************************************************/
#ifndef SUBSDEC_HEADER_H
#define SUBSDEC_HEADER_H
#include <vlc_common.h>
#include <vlc_codec.h>
#include <vlc_input.h>
#include <vlc_filter.h>
#include <vlc_image.h>
#include <vlc_charset.h>
#include <vlc_stream.h>
#include <vlc_xml.h>
#include <string.h>
#define DEFAULT_NAME "Default"
#define MAX_LINE 8192
#define NO_BREAKING_SPACE " "
enum
{
ATTRIBUTE_ALIGNMENT
=
(
1
<<
0
),
ATTRIBUTE_X
=
(
1
<<
1
),
ATTRIBUTE_X_PERCENT
=
(
1
<<
2
),
ATTRIBUTE_Y
=
(
1
<<
3
),
ATTRIBUTE_Y_PERCENT
=
(
1
<<
4
),
};
typedef
struct
{
char
*
psz_filename
;
picture_t
*
p_pic
;
}
image_attach_t
;
typedef
struct
{
char
*
psz_stylename
;
/* The name of the style, no comma's allowed */
text_style_t
font_style
;
int
i_align
;
int
i_margin_h
;
int
i_margin_v
;
int
i_margin_percent_h
;
int
i_margin_percent_v
;
}
ssa_style_t
;
/*****************************************************************************
* decoder_sys_t : decoder descriptor
*****************************************************************************/
struct
decoder_sys_t
{
int
i_original_height
;
int
i_original_width
;
int
i_align
;
/* Subtitles alignment on the vout */
vlc_iconv_t
iconv_handle
;
/* handle to iconv instance */
bool
b_autodetect_utf8
;
ssa_style_t
**
pp_ssa_styles
;
int
i_ssa_styles
;
image_attach_t
**
pp_images
;
int
i_images
;
};
char
*
GotoNextLine
(
char
*
psz_text
);
#endif
modules/codec/subsusf.c
View file @
a1d39b55
...
@@ -23,31 +23,24 @@
...
@@ -23,31 +23,24 @@
#ifdef HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
# include "config.h"
# include "config.h"
#endif
#endif
#include <assert.h>
#include
"subsdec.h"
#include
<vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_plugin.h>
#include <vlc_modules.h>
#include <vlc_modules.h>
#include <assert.h>
#include <vlc_codec.h>
#include <vlc_input.h>
#include <vlc_charset.h>
#include <vlc_image.h>
#include <vlc_xml.h>
#include <vlc_stream.h>
/*****************************************************************************
/*****************************************************************************
*
Local prototypes
*
Module descriptor.
*****************************************************************************/
*****************************************************************************/
static
int
OpenDecoder
(
vlc_object_t
*
);
static
int
OpenDecoder
(
vlc_object_t
*
);
static
void
CloseDecoder
(
vlc_object_t
*
);
static
void
CloseDecoder
(
vlc_object_t
*
);
static
subpicture_t
*
DecodeBlock
(
decoder_t
*
,
block_t
**
);
static
char
*
CreatePlainText
(
char
*
);
static
int
ParseImageAttachments
(
decoder_t
*
p_dec
);
static
subpicture_t
*
ParseText
(
decoder_t
*
,
block_t
*
);
static
void
ParseUSFHeader
(
decoder_t
*
);
static
subpicture_region_t
*
ParseUSFString
(
decoder_t
*
,
char
*
);
static
subpicture_region_t
*
LoadEmbeddedImage
(
decoder_t
*
p_dec
,
const
char
*
psz_filename
,
int
i_transparent_color
);
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
vlc_module_begin
()
vlc_module_begin
()
set_capability
(
"decoder"
,
40
)
set_capability
(
"decoder"
,
40
)
set_shortname
(
N_
(
"USFSubs"
))
set_shortname
(
N_
(
"USFSubs"
))
...
@@ -58,6 +51,58 @@ vlc_module_begin ()
...
@@ -58,6 +51,58 @@ vlc_module_begin ()
/* We inherit subsdec-align and subsdec-formatted from subsdec.c */
/* We inherit subsdec-align and subsdec-formatted from subsdec.c */
vlc_module_end
()
vlc_module_end
()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
enum
{
ATTRIBUTE_ALIGNMENT
=
(
1
<<
0
),
ATTRIBUTE_X
=
(
1
<<
1
),
ATTRIBUTE_X_PERCENT
=
(
1
<<
2
),
ATTRIBUTE_Y
=
(
1
<<
3
),
ATTRIBUTE_Y_PERCENT
=
(
1
<<
4
),
};
typedef
struct
{
char
*
psz_filename
;
picture_t
*
p_pic
;
}
image_attach_t
;
typedef
struct
{
char
*
psz_stylename
;
/* The name of the style, no comma's allowed */
text_style_t
font_style
;
int
i_align
;
int
i_margin_h
;
int
i_margin_v
;
int
i_margin_percent_h
;
int
i_margin_percent_v
;
}
ssa_style_t
;
struct
decoder_sys_t
{
int
i_original_height
;
int
i_original_width
;
int
i_align
;
/* Subtitles alignment on the vout */
ssa_style_t
**
pp_ssa_styles
;
int
i_ssa_styles
;
image_attach_t
**
pp_images
;
int
i_images
;
};
static
subpicture_t
*
DecodeBlock
(
decoder_t
*
,
block_t
**
);
static
char
*
CreatePlainText
(
char
*
);
static
int
ParseImageAttachments
(
decoder_t
*
p_dec
);
static
subpicture_t
*
ParseText
(
decoder_t
*
,
block_t
*
);
static
void
ParseUSFHeader
(
decoder_t
*
);
static
subpicture_region_t
*
ParseUSFString
(
decoder_t
*
,
char
*
);
static
subpicture_region_t
*
LoadEmbeddedImage
(
decoder_t
*
p_dec
,
const
char
*
psz_filename
,
int
i_transparent_color
);
/*****************************************************************************
/*****************************************************************************
* OpenDecoder: probe the decoder and return score
* OpenDecoder: probe the decoder and return score
*****************************************************************************
*****************************************************************************
...
@@ -80,10 +125,6 @@ static int OpenDecoder( vlc_object_t *p_this )
...
@@ -80,10 +125,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_dec
->
fmt_out
.
i_cat
=
SPU_ES
;
p_dec
->
fmt_out
.
i_cat
=
SPU_ES
;
p_dec
->
fmt_out
.
i_codec
=
0
;
p_dec
->
fmt_out
.
i_codec
=
0
;
/* Unused fields of p_sys - not needed for USF decoding */
p_sys
->
iconv_handle
=
(
vlc_iconv_t
)
-
1
;
p_sys
->
b_autodetect_utf8
=
false
;
/* init of p_sys */
/* init of p_sys */
p_sys
->
i_align
=
0
;
p_sys
->
i_align
=
0
;
p_sys
->
i_original_height
=
0
;
p_sys
->
i_original_height
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment