FFmpeg  2.6.3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vf_subtitles.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Baptiste Coudurier
3  * Copyright (c) 2011 Stefano Sabatini
4  * Copyright (c) 2012 Clément Bœsch
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * Libass subtitles burning filter.
26  *
27  * @see{http://www.matroska.org/technical/specs/subtitles/ssa.html}
28  */
29 
30 #include <ass/ass.h>
31 
32 #include "config.h"
33 #if CONFIG_SUBTITLES_FILTER
34 # include "libavcodec/avcodec.h"
35 # include "libavformat/avformat.h"
36 #endif
37 #include "libavutil/avstring.h"
38 #include "libavutil/imgutils.h"
39 #include "libavutil/opt.h"
40 #include "libavutil/parseutils.h"
41 #include "drawutils.h"
42 #include "avfilter.h"
43 #include "internal.h"
44 #include "formats.h"
45 #include "video.h"
46 
47 typedef struct {
48  const AVClass *class;
49  ASS_Library *library;
50  ASS_Renderer *renderer;
51  ASS_Track *track;
52  char *filename;
53  char *charenc;
54  char *force_style;
56  uint8_t rgba_map[4];
57  int pix_step[4]; ///< steps per pixel for each plane of the main output
58  int original_w, original_h;
59  int shaping;
61 } AssContext;
62 
63 #define OFFSET(x) offsetof(AssContext, x)
64 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
65 
66 #define COMMON_OPTIONS \
67  {"filename", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
68  {"f", "set the filename of file to read", OFFSET(filename), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
69  {"original_size", "set the size of the original video (used to scale fonts)", OFFSET(original_w), AV_OPT_TYPE_IMAGE_SIZE, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS }, \
70 
71 /* libass supports a log level ranging from 0 to 7 */
72 static const int ass_libavfilter_log_level_map[] = {
73  [0] = AV_LOG_FATAL, /* MSGL_FATAL */
74  [1] = AV_LOG_ERROR, /* MSGL_ERR */
75  [2] = AV_LOG_WARNING, /* MSGL_WARN */
76  [3] = AV_LOG_WARNING, /* <undefined> */
77  [4] = AV_LOG_INFO, /* MSGL_INFO */
78  [5] = AV_LOG_INFO, /* <undefined> */
79  [6] = AV_LOG_VERBOSE, /* MSGL_V */
80  [7] = AV_LOG_DEBUG, /* MSGL_DBG2 */
81 };
82 
83 static void ass_log(int ass_level, const char *fmt, va_list args, void *ctx)
84 {
85  const int ass_level_clip = av_clip(ass_level, 0,
87  const int level = ass_libavfilter_log_level_map[ass_level_clip];
88 
89  av_vlog(ctx, level, fmt, args);
90  av_log(ctx, level, "\n");
91 }
92 
93 static av_cold int init(AVFilterContext *ctx)
94 {
95  AssContext *ass = ctx->priv;
96 
97  if (!ass->filename) {
98  av_log(ctx, AV_LOG_ERROR, "No filename provided!\n");
99  return AVERROR(EINVAL);
100  }
101 
102  ass->library = ass_library_init();
103  if (!ass->library) {
104  av_log(ctx, AV_LOG_ERROR, "Could not initialize libass.\n");
105  return AVERROR(EINVAL);
106  }
107  ass_set_message_cb(ass->library, ass_log, ctx);
108 
109  ass->renderer = ass_renderer_init(ass->library);
110  if (!ass->renderer) {
111  av_log(ctx, AV_LOG_ERROR, "Could not initialize libass renderer.\n");
112  return AVERROR(EINVAL);
113  }
114 
115  return 0;
116 }
117 
118 static av_cold void uninit(AVFilterContext *ctx)
119 {
120  AssContext *ass = ctx->priv;
121 
122  if (ass->track)
123  ass_free_track(ass->track);
124  if (ass->renderer)
125  ass_renderer_done(ass->renderer);
126  if (ass->library)
127  ass_library_done(ass->library);
128 }
129 
131 {
133  return 0;
134 }
135 
136 static int config_input(AVFilterLink *inlink)
137 {
138  AssContext *ass = inlink->dst->priv;
139 
140  ff_draw_init(&ass->draw, inlink->format, 0);
141 
142  ass_set_frame_size (ass->renderer, inlink->w, inlink->h);
143  if (ass->original_w && ass->original_h)
144  ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h,
145  (double)ass->original_w / ass->original_h);
146  if (ass->shaping != -1)
147  ass_set_shaper(ass->renderer, ass->shaping);
148 
149  return 0;
150 }
151 
152 /* libass stores an RGBA color in the format RRGGBBTT, where TT is the transparency level */
153 #define AR(c) ( (c)>>24)
154 #define AG(c) (((c)>>16)&0xFF)
155 #define AB(c) (((c)>>8) &0xFF)
156 #define AA(c) ((0xFF-(c)) &0xFF)
157 
158 static void overlay_ass_image(AssContext *ass, AVFrame *picref,
159  const ASS_Image *image)
160 {
161  for (; image; image = image->next) {
162  uint8_t rgba_color[] = {AR(image->color), AG(image->color), AB(image->color), AA(image->color)};
164  ff_draw_color(&ass->draw, &color, rgba_color);
165  ff_blend_mask(&ass->draw, &color,
166  picref->data, picref->linesize,
167  picref->width, picref->height,
168  image->bitmap, image->stride, image->w, image->h,
169  3, 0, image->dst_x, image->dst_y);
170  }
171 }
172 
173 static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
174 {
175  AVFilterContext *ctx = inlink->dst;
176  AVFilterLink *outlink = ctx->outputs[0];
177  AssContext *ass = ctx->priv;
178  int detect_change = 0;
179  double time_ms = picref->pts * av_q2d(inlink->time_base) * 1000;
180  ASS_Image *image = ass_render_frame(ass->renderer, ass->track,
181  time_ms, &detect_change);
182 
183  if (detect_change)
184  av_log(ctx, AV_LOG_DEBUG, "Change happened at time ms:%f\n", time_ms);
185 
186  overlay_ass_image(ass, picref, image);
187 
188  return ff_filter_frame(outlink, picref);
189 }
190 
191 static const AVFilterPad ass_inputs[] = {
192  {
193  .name = "default",
194  .type = AVMEDIA_TYPE_VIDEO,
195  .filter_frame = filter_frame,
196  .config_props = config_input,
197  .needs_writable = 1,
198  },
199  { NULL }
200 };
201 
202 static const AVFilterPad ass_outputs[] = {
203  {
204  .name = "default",
205  .type = AVMEDIA_TYPE_VIDEO,
206  },
207  { NULL }
208 };
209 
210 #if CONFIG_ASS_FILTER
211 
212 static const AVOption ass_options[] = {
214  {"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, "shaping_mode"},
215  {"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
216  {"simple", "simple shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
217  {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
218  {NULL},
219 };
220 
222 
223 static av_cold int init_ass(AVFilterContext *ctx)
224 {
225  AssContext *ass = ctx->priv;
226  int ret = init(ctx);
227 
228  if (ret < 0)
229  return ret;
230 
231  /* Initialize fonts */
232  ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1);
233 
234  ass->track = ass_read_file(ass->library, ass->filename, NULL);
235  if (!ass->track) {
236  av_log(ctx, AV_LOG_ERROR,
237  "Could not create a libass track when reading file '%s'\n",
238  ass->filename);
239  return AVERROR(EINVAL);
240  }
241  return 0;
242 }
243 
244 AVFilter ff_vf_ass = {
245  .name = "ass",
246  .description = NULL_IF_CONFIG_SMALL("Render ASS subtitles onto input video using the libass library."),
247  .priv_size = sizeof(AssContext),
248  .init = init_ass,
249  .uninit = uninit,
251  .inputs = ass_inputs,
252  .outputs = ass_outputs,
253  .priv_class = &ass_class,
254 };
255 #endif
256 
257 #if CONFIG_SUBTITLES_FILTER
258 
259 static const AVOption subtitles_options[] = {
261  {"charenc", "set input character encoding", OFFSET(charenc), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
262  {"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS},
263  {"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS},
264  {"force_style", "force subtitle style", OFFSET(force_style), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, FLAGS},
265  {NULL},
266 };
267 
268 static const char * const font_mimetypes[] = {
269  "application/x-truetype-font",
270  "application/vnd.ms-opentype",
271  "application/x-font-ttf",
272  NULL
273 };
274 
275 static int attachment_is_font(AVStream * st)
276 {
277  const AVDictionaryEntry *tag = NULL;
278  int n;
279 
280  tag = av_dict_get(st->metadata, "mimetype", NULL, AV_DICT_MATCH_CASE);
281 
282  if (tag) {
283  for (n = 0; font_mimetypes[n]; n++) {
284  if (av_strcasecmp(font_mimetypes[n], tag->value) == 0)
285  return 1;
286  }
287  }
288  return 0;
289 }
290 
291 AVFILTER_DEFINE_CLASS(subtitles);
292 
293 static av_cold int init_subtitles(AVFilterContext *ctx)
294 {
295  int j, ret, sid;
296  int k = 0;
300  AVCodec *dec = NULL;
301  const AVCodecDescriptor *dec_desc;
302  AVStream *st;
303  AVPacket pkt;
304  AssContext *ass = ctx->priv;
305 
306  /* Init libass */
307  ret = init(ctx);
308  if (ret < 0)
309  return ret;
310  ass->track = ass_new_track(ass->library);
311  if (!ass->track) {
312  av_log(ctx, AV_LOG_ERROR, "Could not create a libass track\n");
313  return AVERROR(EINVAL);
314  }
315 
316  /* Open subtitles file */
317  ret = avformat_open_input(&fmt, ass->filename, NULL, NULL);
318  if (ret < 0) {
319  av_log(ctx, AV_LOG_ERROR, "Unable to open %s\n", ass->filename);
320  goto end;
321  }
322  ret = avformat_find_stream_info(fmt, NULL);
323  if (ret < 0)
324  goto end;
325 
326  /* Locate subtitles stream */
327  if (ass->stream_index < 0)
328  ret = av_find_best_stream(fmt, AVMEDIA_TYPE_SUBTITLE, -1, -1, NULL, 0);
329  else {
330  ret = -1;
331  if (ass->stream_index < fmt->nb_streams) {
332  for (j = 0; j < fmt->nb_streams; j++) {
333  if (fmt->streams[j]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
334  if (ass->stream_index == k) {
335  ret = j;
336  break;
337  }
338  k++;
339  }
340  }
341  }
342  }
343 
344  if (ret < 0) {
345  av_log(ctx, AV_LOG_ERROR, "Unable to locate subtitle stream in %s\n",
346  ass->filename);
347  goto end;
348  }
349  sid = ret;
350  st = fmt->streams[sid];
351 
352  /* Load attached fonts */
353  for (j = 0; j < fmt->nb_streams; j++) {
354  AVStream *st = fmt->streams[j];
356  attachment_is_font(st)) {
357  const AVDictionaryEntry *tag = NULL;
358  tag = av_dict_get(st->metadata, "filename", NULL,
360 
361  if (tag) {
362  av_log(ctx, AV_LOG_DEBUG, "Loading attached font: %s\n",
363  tag->value);
364  ass_add_font(ass->library, tag->value,
365  st->codec->extradata,
366  st->codec->extradata_size);
367  } else {
368  av_log(ctx, AV_LOG_WARNING,
369  "Font attachment has no filename, ignored.\n");
370  }
371  }
372  }
373 
374  /* Initialize fonts */
375  ass_set_fonts(ass->renderer, NULL, NULL, 1, NULL, 1);
376 
377  /* Open decoder */
378  dec_ctx = st->codec;
379  dec = avcodec_find_decoder(dec_ctx->codec_id);
380  if (!dec) {
381  av_log(ctx, AV_LOG_ERROR, "Failed to find subtitle codec %s\n",
382  avcodec_get_name(dec_ctx->codec_id));
383  return AVERROR(EINVAL);
384  }
385  dec_desc = avcodec_descriptor_get(dec_ctx->codec_id);
386  if (dec_desc && !(dec_desc->props & AV_CODEC_PROP_TEXT_SUB)) {
387  av_log(ctx, AV_LOG_ERROR,
388  "Only text based subtitles are currently supported\n");
389  return AVERROR_PATCHWELCOME;
390  }
391  if (ass->charenc)
392  av_dict_set(&codec_opts, "sub_charenc", ass->charenc, 0);
393  ret = avcodec_open2(dec_ctx, dec, &codec_opts);
394  if (ret < 0)
395  goto end;
396 
397  if (ass->force_style) {
398  char **list = NULL;
399  char *temp = NULL;
400  char *ptr = av_strtok(ass->force_style, ",", &temp);
401  int i = 0;
402  while (ptr) {
403  av_dynarray_add(&list, &i, ptr);
404  if (!list) {
405  ret = AVERROR(ENOMEM);
406  goto end;
407  }
408  ptr = av_strtok(NULL, ",", &temp);
409  }
410  av_dynarray_add(&list, &i, NULL);
411  if (!list) {
412  ret = AVERROR(ENOMEM);
413  goto end;
414  }
415  ass_set_style_overrides(ass->library, list);
416  av_free(list);
417  }
418  /* Decode subtitles and push them into the renderer (libass) */
419  if (dec_ctx->subtitle_header)
420  ass_process_codec_private(ass->track,
421  dec_ctx->subtitle_header,
422  dec_ctx->subtitle_header_size);
423  av_init_packet(&pkt);
424  pkt.data = NULL;
425  pkt.size = 0;
426  while (av_read_frame(fmt, &pkt) >= 0) {
427  int i, got_subtitle;
428  AVSubtitle sub = {0};
429 
430  if (pkt.stream_index == sid) {
431  ret = avcodec_decode_subtitle2(dec_ctx, &sub, &got_subtitle, &pkt);
432  if (ret < 0) {
433  av_log(ctx, AV_LOG_WARNING, "Error decoding: %s (ignored)\n",
434  av_err2str(ret));
435  } else if (got_subtitle) {
436  for (i = 0; i < sub.num_rects; i++) {
437  char *ass_line = sub.rects[i]->ass;
438  if (!ass_line)
439  break;
440  ass_process_data(ass->track, ass_line, strlen(ass_line));
441  }
442  }
443  }
444  av_free_packet(&pkt);
445  avsubtitle_free(&sub);
446  }
447 
448 end:
449  av_dict_free(&codec_opts);
450  if (dec_ctx)
451  avcodec_close(dec_ctx);
452  if (fmt)
453  avformat_close_input(&fmt);
454  return ret;
455 }
456 
457 AVFilter ff_vf_subtitles = {
458  .name = "subtitles",
459  .description = NULL_IF_CONFIG_SMALL("Render text subtitles onto input video using the libass library."),
460  .priv_size = sizeof(AssContext),
461  .init = init_subtitles,
462  .uninit = uninit,
464  .inputs = ass_inputs,
465  .outputs = ass_outputs,
466  .priv_class = &subtitles_class,
467 };
468 #endif
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
Definition: drawutils.c:453
static void overlay_ass_image(AssContext *ass, AVFrame *picref, const ASS_Image *image)
Definition: vf_subtitles.c:158
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
Definition: drawutils.c:525
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: vf_subtitles.c:136
void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:280
This structure describes decoded (raw) audio or video data.
Definition: frame.h:163
FFDrawContext draw
Definition: vf_subtitles.c:60
AVOption.
Definition: opt.h:255
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
Definition: vf_subtitles.c:173
const char * fmt
Definition: avisynth_c.h:670
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:181
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:246
Main libavfilter public API header.
ASS_Track * track
Definition: vf_subtitles.c:51
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:401
else temp
Definition: vf_mcdeint.c:257
static const AVClass ass_class
Definition: assenc.c:206
int size
Definition: avcodec.h:1161
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
Definition: avcodec.h:618
unsigned num_rects
Definition: avcodec.h:3498
#define FF_ARRAY_ELEMS(a)
static AVPacket pkt
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
Definition: utils.c:2713
AVCodec.
Definition: avcodec.h:3173
static void ass_log(int ass_level, const char *fmt, va_list args, void *ctx)
Definition: vf_subtitles.c:83
AVSubtitleRect ** rects
Definition: avcodec.h:3499
Format I/O context.
Definition: avformat.h:1214
const char * name
Pad name.
Definition: internal.h:67
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1145
static int query_formats(AVFilterContext *ctx)
Definition: vf_subtitles.c:130
uint8_t
#define av_cold
Definition: attributes.h:74
ASS_Library * library
Definition: vf_subtitles.c:49
AVOptions.
int subtitle_header_size
Definition: avcodec.h:2950
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition: log.c:86
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:67
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:249
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1353
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1282
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:80
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:39
uint8_t * data
Definition: avcodec.h:1160
uint32_t tag
Definition: movenc.c:1332
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:191
void ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:539
#define av_log(a,...)
A filter pad used for either input or output.
Definition: internal.h:61
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
Find the "best" stream in the file.
Definition: utils.c:3483
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
Definition: utils.c:2826
#define AA(c)
Definition: vf_subtitles.c:156
int width
width and height of the video frame
Definition: frame.h:212
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:175
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
Definition: dict.h:71
#define AVERROR(e)
Definition: error.h:43
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:180
void * priv
private data for use by the filter
Definition: avfilter.h:654
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:196
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
Definition: dict.c:194
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:198
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Definition: mem.c:322
Libavcodec external API header.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:2877
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:814
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
Definition: avcodec.h:574
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1270
int stream_index
Definition: vf_subtitles.c:55
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
Definition: avstring.c:213
ret
Definition: avfilter.c:974
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:119
int n
Definition: avisynth_c.h:589
AVDictionary * metadata
Definition: avformat.h:869
Opaque data information usually sparse.
Definition: avutil.h:198
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:2953
Stream structure.
Definition: avformat.h:795
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
#define AV_LOG_INFO
Standard information.
Definition: log.h:186
enum AVMediaType codec_type
Definition: avcodec.h:1247
misc drawing utilities
#define AG(c)
Definition: vf_subtitles.c:154
ASS_Renderer * renderer
Definition: vf_subtitles.c:50
enum AVCodecID codec_id
Definition: avcodec.h:1256
static const int ass_libavfilter_log_level_map[]
Definition: vf_subtitles.c:72
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:191
main external API structure.
Definition: avcodec.h:1239
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: utils.c:2934
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: utils.c:2807
int extradata_size
Definition: avcodec.h:1354
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
Describe the class of an AVClass context structure.
Definition: log.h:66
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:237
char * filename
Definition: vf_subtitles.c:52
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
Definition: log.c:356
const char * name
Filter name.
Definition: avfilter.h:474
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
Definition: drawutils.c:156
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
Definition: utils.c:1325
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: utils.c:1469
#define AB(c)
Definition: vf_subtitles.c:155
This struct describes the properties of a single codec described by an AVCodecID. ...
Definition: avcodec.h:558
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:174
uint8_t level
Definition: svq3.c:150
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok()...
Definition: avstring.c:184
static av_cold int init(AVFilterContext *ctx)
Definition: vf_subtitles.c:93
Main libavformat public API header.
AVDictionary * codec_opts
Definition: cmdutils.c:66
#define OFFSET(x)
Definition: vf_subtitles.c:63
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:3015
#define FLAGS
Definition: vf_subtitles.c:64
static AVCodecContext * dec_ctx
static const AVFilterPad ass_inputs[]
Definition: vf_subtitles.c:191
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:49
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:3631
#define COMMON_OPTIONS
Definition: vf_subtitles.c:66
#define av_free(p)
char * value
Definition: dict.h:88
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_subtitles.c:118
#define AVFILTER_DEFINE_CLASS(fname)
Definition: internal.h:313
char * force_style
Definition: vf_subtitles.c:54
char * ass
0 terminated ASS/SSA compatible event line.
Definition: avcodec.h:3489
An instance of a filter.
Definition: avfilter.h:633
int height
Definition: frame.h:212
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:169
char * charenc
Definition: vf_subtitles.c:53
int stream_index
Definition: avcodec.h:1162
internal API functions
This structure stores compressed data.
Definition: avcodec.h:1137
static const AVFilterPad ass_outputs[]
Definition: vf_subtitles.c:202
int original_w
Definition: vf_subtitles.c:58
#define AR(c)
Definition: vf_subtitles.c:153
uint8_t * subtitle_header
Header containing style information for text subtitles.
Definition: avcodec.h:2949
int original_h
Definition: vf_subtitles.c:58