FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavcodec
assdec.c
Go to the documentation of this file.
1
/*
2
* SSA/ASS decoder
3
* Copyright (c) 2010 Aurelien Jacobs <aurel@gnuage.org>
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
#include <string.h>
23
24
#include "
avcodec.h
"
25
#include "
ass.h
"
26
#include "
libavutil/internal.h
"
27
#include "
libavutil/mem.h
"
28
29
static
av_cold
int
ass_decode_init
(
AVCodecContext
*avctx)
30
{
31
avctx->
subtitle_header
=
av_malloc
(avctx->
extradata_size
+ 1);
32
if
(!avctx->
subtitle_header
)
33
return
AVERROR
(ENOMEM);
34
memcpy(avctx->
subtitle_header
, avctx->
extradata
, avctx->
extradata_size
);
35
avctx->
subtitle_header
[avctx->
extradata_size
] = 0;
36
avctx->
subtitle_header_size
= avctx->
extradata_size
;
37
return
0;
38
}
39
40
static
int
ass_decode_frame
(
AVCodecContext
*avctx,
void
*
data
,
int
*got_sub_ptr,
41
AVPacket
*avpkt)
42
{
43
AVSubtitle
*sub =
data
;
44
45
if
(avpkt->
size
<= 0)
46
return
avpkt->
size
;
47
48
sub->
rects
=
av_malloc
(
sizeof
(*sub->
rects
));
49
if
(!sub->
rects
)
50
return
AVERROR
(ENOMEM);
51
sub->
rects
[0] =
av_mallocz
(
sizeof
(*sub->
rects
[0]));
52
if
(!sub->
rects
[0])
53
return
AVERROR
(ENOMEM);
54
sub->
num_rects
= 1;
55
sub->
rects
[0]->
type
=
SUBTITLE_ASS
;
56
sub->
rects
[0]->
ass
=
av_strdup
(avpkt->
data
);
57
if
(!sub->
rects
[0]->
ass
)
58
return
AVERROR
(ENOMEM);
59
*got_sub_ptr = 1;
60
return
avpkt->
size
;
61
}
62
63
#if CONFIG_SSA_DECODER
64
AVCodec
ff_ssa_decoder = {
65
.
name
=
"ssa"
,
66
.long_name =
NULL_IF_CONFIG_SMALL
(
"ASS (Advanced SubStation Alpha) subtitle"
),
67
.type =
AVMEDIA_TYPE_SUBTITLE
,
68
.id =
AV_CODEC_ID_ASS
,
69
.init =
ass_decode_init
,
70
.decode =
ass_decode_frame
,
71
};
72
#endif
73
74
#if CONFIG_ASS_DECODER
75
AVCodec
ff_ass_decoder = {
76
.
name
=
"ass"
,
77
.long_name =
NULL_IF_CONFIG_SMALL
(
"ASS (Advanced SubStation Alpha) subtitle"
),
78
.type =
AVMEDIA_TYPE_SUBTITLE
,
79
.id =
AV_CODEC_ID_ASS
,
80
.init =
ass_decode_init
,
81
.decode =
ass_decode_frame
,
82
};
83
#endif
data
ptrdiff_t const GLvoid * data
Definition:
opengl_enc.c:101
mem.h
memory handling functions
AVPacket::size
int size
Definition:
avcodec.h:1581
AVSubtitle::num_rects
unsigned num_rects
Definition:
avcodec.h:3902
AVCodec
AVCodec.
Definition:
avcodec.h:3542
AVSubtitle::rects
AVSubtitleRect ** rects
Definition:
avcodec.h:3903
ass_decode_init
static av_cold int ass_decode_init(AVCodecContext *avctx)
Definition:
assdec.c:29
av_cold
#define av_cold
Definition:
attributes.h:82
av_malloc
#define av_malloc(s)
Definition:
tableprint_vlc.h:31
AVCodecContext::subtitle_header_size
int subtitle_header_size
Definition:
avcodec.h:3275
AVCodecContext::extradata
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition:
avcodec.h:1764
AVPacket::data
uint8_t * data
Definition:
avcodec.h:1580
AVSubtitle
Definition:
avcodec.h:3898
ass.h
AVERROR
#define AVERROR(e)
Definition:
error.h:43
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition:
internal.h:176
AVCodec::name
const char * name
Name of the codec implementation.
Definition:
avcodec.h:3549
internal.h
common internal API header
ass_decode_frame
static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
Definition:
assdec.c:40
avcodec.h
Libavcodec external API header.
av_strdup
char * av_strdup(const char *s)
Duplicate the string s.
Definition:
mem.c:267
AVCodecContext
main external API structure.
Definition:
avcodec.h:1649
AVCodecContext::extradata_size
int extradata_size
Definition:
avcodec.h:1765
AV_CODEC_ID_ASS
Definition:
avcodec.h:625
SUBTITLE_ASS
Formatted text, the ass field must be set by the decoder and is authoritative.
Definition:
avcodec.h:3858
AVSubtitleRect::ass
char * ass
0 terminated ASS/SSA compatible event line.
Definition:
avcodec.h:3893
AVSubtitleRect::type
enum AVSubtitleType type
Definition:
avcodec.h:3884
AVMEDIA_TYPE_SUBTITLE
Definition:
avutil.h:196
AVPacket
This structure stores compressed data.
Definition:
avcodec.h:1557
av_mallocz
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition:
mem.c:252
AVCodecContext::subtitle_header
uint8_t * subtitle_header
Header containing style information for text subtitles.
Definition:
avcodec.h:3274
Generated on Mon Jun 27 2016 02:34:34 for FFmpeg by
1.8.6