Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
faa94061
Commit
faa94061
authored
Dec 28, 2012
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SubViewer v1 subtitles demuxer and decoder.
parent
7b434027
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
160 additions
and
4 deletions
+160
-4
Changelog
Changelog
+1
-1
general.texi
doc/general.texi
+1
-0
Makefile
libavcodec/Makefile
+1
-0
allcodecs.c
libavcodec/allcodecs.c
+1
-0
avcodec.h
libavcodec/avcodec.h
+1
-0
codec_desc.c
libavcodec/codec_desc.c
+6
-0
textdec.c
libavcodec/textdec.c
+17
-1
version.h
libavcodec/version.h
+1
-1
Makefile
libavformat/Makefile
+1
-0
allformats.c
libavformat/allformats.c
+1
-0
subviewer1dec.c
libavformat/subviewer1dec.c
+124
-0
version.h
libavformat/version.h
+1
-1
subtitles.mak
tests/fate/subtitles.mak
+3
-0
sub-subviewer1
tests/ref/fate/sub-subviewer1
+1
-0
No files found.
Changelog
View file @
faa94061
...
@@ -51,7 +51,7 @@ version <next>:
...
@@ -51,7 +51,7 @@ version <next>:
- pp (postproc) filter ported from MPlayer
- pp (postproc) filter ported from MPlayer
- NIST Sphere demuxer
- NIST Sphere demuxer
- av_basename and av_dirname
- av_basename and av_dirname
- MPL2, VPlayer, MPlayer, AQTitle
and PJS
subtitles demuxers and decoders
- MPL2, VPlayer, MPlayer, AQTitle
, PJS and SubViewer v1
subtitles demuxers and decoders
version 1.0:
version 1.0:
...
...
doc/general.texi
View file @
faa94061
...
@@ -933,6 +933,7 @@ performance on systems without hardware floating point support).
...
@@ -933,6 +933,7 @@ performance on systems without hardware floating point support).
@item SAMI @tab @tab X @tab @tab X
@item SAMI @tab @tab X @tab @tab X
@item SSA/ASS @tab X @tab X @tab X @tab X
@item SSA/ASS @tab X @tab X @tab X @tab X
@item SubRip (SRT) @tab X @tab X @tab X @tab X
@item SubRip (SRT) @tab X @tab X @tab X @tab X
@item SubViewer v1 @tab @tab X @tab @tab X
@item SubViewer @tab @tab X @tab @tab X
@item SubViewer @tab @tab X @tab @tab X
@item TED Talks captions @tab @tab X @tab @tab X
@item TED Talks captions @tab @tab X @tab @tab X
@item VobSub (IDX+SUB) @tab @tab X @tab @tab X
@item VobSub (IDX+SUB) @tab @tab X @tab @tab X
...
...
libavcodec/Makefile
View file @
faa94061
...
@@ -402,6 +402,7 @@ OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o
...
@@ -402,6 +402,7 @@ OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o
OBJS-$(CONFIG_SRT_ENCODER)
+=
srtenc.o
ass_split.o
OBJS-$(CONFIG_SRT_ENCODER)
+=
srtenc.o
ass_split.o
OBJS-$(CONFIG_SUBRIP_DECODER)
+=
srtdec.o
ass.o
OBJS-$(CONFIG_SUBRIP_DECODER)
+=
srtdec.o
ass.o
OBJS-$(CONFIG_SUBRIP_ENCODER)
+=
srtenc.o
ass_split.o
OBJS-$(CONFIG_SUBRIP_ENCODER)
+=
srtenc.o
ass_split.o
OBJS-$(CONFIG_SUBVIEWER1_DECODER)
+=
textdec.o
ass.o
OBJS-$(CONFIG_SUBVIEWER_DECODER)
+=
subviewerdec.o
ass.o
OBJS-$(CONFIG_SUBVIEWER_DECODER)
+=
subviewerdec.o
ass.o
OBJS-$(CONFIG_SUNRAST_DECODER)
+=
sunrast.o
OBJS-$(CONFIG_SUNRAST_DECODER)
+=
sunrast.o
OBJS-$(CONFIG_SUNRAST_ENCODER)
+=
sunrastenc.o
OBJS-$(CONFIG_SUNRAST_ENCODER)
+=
sunrastenc.o
...
...
libavcodec/allcodecs.c
View file @
faa94061
...
@@ -456,6 +456,7 @@ void avcodec_register_all(void)
...
@@ -456,6 +456,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC
(
SRT
,
srt
);
REGISTER_ENCDEC
(
SRT
,
srt
);
REGISTER_ENCDEC
(
SUBRIP
,
subrip
);
REGISTER_ENCDEC
(
SUBRIP
,
subrip
);
REGISTER_DECODER
(
SUBVIEWER
,
subviewer
);
REGISTER_DECODER
(
SUBVIEWER
,
subviewer
);
REGISTER_DECODER
(
SUBVIEWER1
,
subviewer1
);
REGISTER_DECODER
(
TEXT
,
text
);
REGISTER_DECODER
(
TEXT
,
text
);
REGISTER_DECODER
(
VPLAYER
,
vplayer
);
REGISTER_DECODER
(
VPLAYER
,
vplayer
);
REGISTER_DECODER
(
WEBVTT
,
webvtt
);
REGISTER_DECODER
(
WEBVTT
,
webvtt
);
...
...
libavcodec/avcodec.h
View file @
faa94061
...
@@ -463,6 +463,7 @@ enum AVCodecID {
...
@@ -463,6 +463,7 @@ enum AVCodecID {
AV_CODEC_ID_JACOSUB
=
MKBETAG
(
'J'
,
'S'
,
'U'
,
'B'
),
AV_CODEC_ID_JACOSUB
=
MKBETAG
(
'J'
,
'S'
,
'U'
,
'B'
),
AV_CODEC_ID_SAMI
=
MKBETAG
(
'S'
,
'A'
,
'M'
,
'I'
),
AV_CODEC_ID_SAMI
=
MKBETAG
(
'S'
,
'A'
,
'M'
,
'I'
),
AV_CODEC_ID_REALTEXT
=
MKBETAG
(
'R'
,
'T'
,
'X'
,
'T'
),
AV_CODEC_ID_REALTEXT
=
MKBETAG
(
'R'
,
'T'
,
'X'
,
'T'
),
AV_CODEC_ID_SUBVIEWER1
=
MKBETAG
(
'S'
,
'b'
,
'V'
,
'1'
),
AV_CODEC_ID_SUBVIEWER
=
MKBETAG
(
'S'
,
'u'
,
'b'
,
'V'
),
AV_CODEC_ID_SUBVIEWER
=
MKBETAG
(
'S'
,
'u'
,
'b'
,
'V'
),
AV_CODEC_ID_SUBRIP
=
MKBETAG
(
'S'
,
'R'
,
'i'
,
'p'
),
AV_CODEC_ID_SUBRIP
=
MKBETAG
(
'S'
,
'R'
,
'i'
,
'p'
),
AV_CODEC_ID_WEBVTT
=
MKBETAG
(
'W'
,
'V'
,
'T'
,
'T'
),
AV_CODEC_ID_WEBVTT
=
MKBETAG
(
'W'
,
'V'
,
'T'
,
'T'
),
...
...
libavcodec/codec_desc.c
View file @
faa94061
...
@@ -2440,6 +2440,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
...
@@ -2440,6 +2440,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
.
name
=
"realtext"
,
.
name
=
"realtext"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"RealText subtitle"
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"RealText subtitle"
),
},
},
{
.
id
=
AV_CODEC_ID_SUBVIEWER1
,
.
type
=
AVMEDIA_TYPE_SUBTITLE
,
.
name
=
"subviewer1"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SubViewer v1 subtitle"
),
},
{
{
.
id
=
AV_CODEC_ID_SUBVIEWER
,
.
id
=
AV_CODEC_ID_SUBVIEWER
,
.
type
=
AVMEDIA_TYPE_SUBTITLE
,
.
type
=
AVMEDIA_TYPE_SUBTITLE
,
...
...
libavcodec/textdec.c
View file @
faa94061
...
@@ -128,7 +128,7 @@ AVCodec ff_text_decoder = {
...
@@ -128,7 +128,7 @@ AVCodec ff_text_decoder = {
};
};
#endif
#endif
#if CONFIG_VPLAYER_DECODER || CONFIG_PJS_DECODER
#if CONFIG_VPLAYER_DECODER || CONFIG_PJS_DECODER
|| CONFIG_TEXT_DECODER
static
int
linebreak_init
(
AVCodecContext
*
avctx
)
static
int
linebreak_init
(
AVCodecContext
*
avctx
)
{
{
...
@@ -169,4 +169,20 @@ AVCodec ff_pjs_decoder = {
...
@@ -169,4 +169,20 @@ AVCodec ff_pjs_decoder = {
};
};
#endif
#endif
#if CONFIG_SUBVIEWER1_DECODER
#define subviewer1_options options
DECLARE_CLASS
(
subviewer1
);
AVCodec
ff_subviewer1_decoder
=
{
.
name
=
"subviewer1"
,
.
priv_data_size
=
sizeof
(
TextContext
),
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SubViewer1 subtitle"
),
.
type
=
AVMEDIA_TYPE_SUBTITLE
,
.
id
=
AV_CODEC_ID_SUBVIEWER1
,
.
decode
=
text_decode_frame
,
.
init
=
linebreak_init
,
.
priv_class
=
&
subviewer1_decoder_class
,
};
#endif
#endif
/* text subtitles with '|' line break */
#endif
/* text subtitles with '|' line break */
libavcodec/version.h
View file @
faa94061
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "libavutil/avutil.h"
#include "libavutil/avutil.h"
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MAJOR 54
#define LIBAVCODEC_VERSION_MINOR 8
3
#define LIBAVCODEC_VERSION_MINOR 8
4
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
...
...
libavformat/Makefile
View file @
faa94061
...
@@ -348,6 +348,7 @@ OBJS-$(CONFIG_SPDIF_MUXER) += spdif.o spdifenc.o
...
@@ -348,6 +348,7 @@ OBJS-$(CONFIG_SPDIF_MUXER) += spdif.o spdifenc.o
OBJS-$(CONFIG_SRT_DEMUXER)
+=
srtdec.o
OBJS-$(CONFIG_SRT_DEMUXER)
+=
srtdec.o
OBJS-$(CONFIG_SRT_MUXER)
+=
srtenc.o
OBJS-$(CONFIG_SRT_MUXER)
+=
srtenc.o
OBJS-$(CONFIG_STR_DEMUXER)
+=
psxstr.o
OBJS-$(CONFIG_STR_DEMUXER)
+=
psxstr.o
OBJS-$(CONFIG_SUBVIEWER1_DEMUXER)
+=
subviewer1dec.o
OBJS-$(CONFIG_SUBVIEWER_DEMUXER)
+=
subviewerdec.o
OBJS-$(CONFIG_SUBVIEWER_DEMUXER)
+=
subviewerdec.o
OBJS-$(CONFIG_SWF_DEMUXER)
+=
swfdec.o
swf.o
OBJS-$(CONFIG_SWF_DEMUXER)
+=
swfdec.o
swf.o
OBJS-$(CONFIG_SWF_MUXER)
+=
swfenc.o
swf.o
OBJS-$(CONFIG_SWF_MUXER)
+=
swfenc.o
swf.o
...
...
libavformat/allformats.c
View file @
faa94061
...
@@ -259,6 +259,7 @@ void av_register_all(void)
...
@@ -259,6 +259,7 @@ void av_register_all(void)
REGISTER_MUXDEMUX
(
SPDIF
,
spdif
);
REGISTER_MUXDEMUX
(
SPDIF
,
spdif
);
REGISTER_MUXDEMUX
(
SRT
,
srt
);
REGISTER_MUXDEMUX
(
SRT
,
srt
);
REGISTER_DEMUXER
(
STR
,
str
);
REGISTER_DEMUXER
(
STR
,
str
);
REGISTER_DEMUXER
(
SUBVIEWER1
,
subviewer1
);
REGISTER_DEMUXER
(
SUBVIEWER
,
subviewer
);
REGISTER_DEMUXER
(
SUBVIEWER
,
subviewer
);
REGISTER_MUXDEMUX
(
SWF
,
swf
);
REGISTER_MUXDEMUX
(
SWF
,
swf
);
REGISTER_DEMUXER
(
TAK
,
tak
);
REGISTER_DEMUXER
(
TAK
,
tak
);
...
...
libavformat/subviewer1dec.c
0 → 100644
View file @
faa94061
/*
* Copyright (c) 2012 Clément Bœsch
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* SubViewer v1 subtitle demuxer
*/
#include "avformat.h"
#include "internal.h"
#include "subtitles.h"
typedef
struct
{
FFDemuxSubtitlesQueue
q
;
}
SubViewer1Context
;
static
int
subviewer1_probe
(
AVProbeData
*
p
)
{
const
unsigned
char
*
ptr
=
p
->
buf
;
if
(
strstr
(
ptr
,
"******** START SCRIPT ********"
))
return
AVPROBE_SCORE_MAX
/
2
;
return
0
;
}
static
int
subviewer1_read_header
(
AVFormatContext
*
s
)
{
int
delay
=
0
;
AVPacket
*
sub
=
NULL
;
SubViewer1Context
*
subviewer1
=
s
->
priv_data
;
AVStream
*
st
=
avformat_new_stream
(
s
,
NULL
);
if
(
!
st
)
return
AVERROR
(
ENOMEM
);
avpriv_set_pts_info
(
st
,
64
,
1
,
1
);
st
->
codec
->
codec_type
=
AVMEDIA_TYPE_SUBTITLE
;
st
->
codec
->
codec_id
=
AV_CODEC_ID_SUBVIEWER1
;
while
(
!
url_feof
(
s
->
pb
))
{
char
line
[
4096
];
int
len
=
ff_get_line
(
s
->
pb
,
line
,
sizeof
(
line
));
int
hh
,
mm
,
ss
;
if
(
!
len
)
break
;
if
(
!
strncmp
(
line
,
"[DELAY]"
,
7
))
{
ff_get_line
(
s
->
pb
,
line
,
sizeof
(
line
));
sscanf
(
line
,
"%d"
,
&
delay
);
}
if
(
sscanf
(
line
,
"[%d:%d:%d]"
,
&
hh
,
&
mm
,
&
ss
)
==
3
)
{
const
int64_t
pos
=
avio_tell
(
s
->
pb
);
int64_t
pts_start
=
hh
*
3600LL
+
mm
*
60LL
+
ss
+
delay
;
len
=
ff_get_line
(
s
->
pb
,
line
,
sizeof
(
line
));
line
[
strcspn
(
line
,
"
\r\n
"
)]
=
0
;
if
(
!*
line
)
{
if
(
sub
)
sub
->
duration
=
pts_start
-
sub
->
pts
;
}
else
{
sub
=
ff_subtitles_queue_insert
(
&
subviewer1
->
q
,
line
,
len
,
0
);
if
(
!
sub
)
return
AVERROR
(
ENOMEM
);
sub
->
pos
=
pos
;
sub
->
pts
=
pts_start
;
sub
->
duration
=
-
1
;
}
}
}
ff_subtitles_queue_finalize
(
&
subviewer1
->
q
);
return
0
;
}
static
int
subviewer1_read_packet
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
SubViewer1Context
*
subviewer1
=
s
->
priv_data
;
return
ff_subtitles_queue_read_packet
(
&
subviewer1
->
q
,
pkt
);
}
static
int
subviewer1_read_seek
(
AVFormatContext
*
s
,
int
stream_index
,
int64_t
min_ts
,
int64_t
ts
,
int64_t
max_ts
,
int
flags
)
{
SubViewer1Context
*
subviewer1
=
s
->
priv_data
;
return
ff_subtitles_queue_seek
(
&
subviewer1
->
q
,
s
,
stream_index
,
min_ts
,
ts
,
max_ts
,
flags
);
}
static
int
subviewer1_read_close
(
AVFormatContext
*
s
)
{
SubViewer1Context
*
subviewer1
=
s
->
priv_data
;
ff_subtitles_queue_clean
(
&
subviewer1
->
q
);
return
0
;
}
AVInputFormat
ff_subviewer1_demuxer
=
{
.
name
=
"subviewer1"
,
.
long_name
=
NULL_IF_CONFIG_SMALL
(
"SubViewer v1 subtitle format"
),
.
priv_data_size
=
sizeof
(
SubViewer1Context
),
.
read_probe
=
subviewer1_probe
,
.
read_header
=
subviewer1_read_header
,
.
read_packet
=
subviewer1_read_packet
,
.
read_seek2
=
subviewer1_read_seek
,
.
read_close
=
subviewer1_read_close
,
.
extensions
=
"sub"
,
};
libavformat/version.h
View file @
faa94061
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MAJOR 54
#define LIBAVFORMAT_VERSION_MINOR 5
5
#define LIBAVFORMAT_VERSION_MINOR 5
6
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
...
...
tests/fate/subtitles.mak
View file @
faa94061
...
@@ -37,6 +37,9 @@ fate-sub-srt: CMD = md5 -i $(SAMPLES)/sub/SubRip_capability_tester.srt -f ass
...
@@ -37,6 +37,9 @@ fate-sub-srt: CMD = md5 -i $(SAMPLES)/sub/SubRip_capability_tester.srt -f ass
FATE_SUBTITLES-$(call ALLYES, MOV_DEMUXER MOVTEXT_DECODER SUBRIP_ENCODER) += fate-sub-subripenc
FATE_SUBTITLES-$(call ALLYES, MOV_DEMUXER MOVTEXT_DECODER SUBRIP_ENCODER) += fate-sub-subripenc
fate-sub-subripenc: CMD = md5 -i $(SAMPLES)/sub/MovText_capability_tester.mp4 -scodec subrip -f srt
fate-sub-subripenc: CMD = md5 -i $(SAMPLES)/sub/MovText_capability_tester.mp4 -scodec subrip -f srt
FATE_SUBTITLES_ASS-$(call DEMDEC, SUBVIEWER1, SUBVIEWER1) += fate-sub-subviewer1
fate-sub-subviewer1: CMD = md5 -i $(SAMPLES)/sub/SubViewer1_capability_tester.sub -f ass
FATE_SUBTITLES_ASS-$(call DEMDEC, SUBVIEWER, SUBVIEWER) += fate-sub-subviewer
FATE_SUBTITLES_ASS-$(call DEMDEC, SUBVIEWER, SUBVIEWER) += fate-sub-subviewer
fate-sub-subviewer: CMD = md5 -i $(SAMPLES)/sub/SubViewer_capability_tester.sub -f ass
fate-sub-subviewer: CMD = md5 -i $(SAMPLES)/sub/SubViewer_capability_tester.sub -f ass
...
...
tests/ref/fate/sub-subviewer1
0 → 100644
View file @
faa94061
0c2096fedf7c971742b2e879bb303ce9
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