Browse code

avfilter/ass: add shaping option

The documentation is mostly based on ass.h public header.

Clément Bœsch authored on 2014/09/12 04:10:43
Showing 3 changed files
... ...
@@ -2552,6 +2552,26 @@ Same as the @ref{subtitles} filter, except that it doesn't require libavcodec
2552 2552
 and libavformat to work. On the other hand, it is limited to ASS (Advanced
2553 2553
 Substation Alpha) subtitles files.
2554 2554
 
2555
+This filter accepts the following option in addition to the common options from
2556
+the @ref{subtitles} filter:
2557
+
2558
+@table @option
2559
+@item shaping
2560
+Set the shaping engine
2561
+
2562
+Available values are:
2563
+@table @samp
2564
+@item auto
2565
+The default libass shaping engine, which is the best available.
2566
+@item simple
2567
+Fast, font-agnostic shaper that can do only substitutions
2568
+@item complex
2569
+Slower shaper using OpenType for substitutions and positioning
2570
+@end table
2571
+
2572
+The default is @code{auto}.
2573
+@end table
2574
+
2555 2575
 @section bbox
2556 2576
 
2557 2577
 Compute the bounding box for the non-black pixels in the input frame
... ...
@@ -31,7 +31,7 @@
31 31
 
32 32
 #define LIBAVFILTER_VERSION_MAJOR  5
33 33
 #define LIBAVFILTER_VERSION_MINOR  1
34
-#define LIBAVFILTER_VERSION_MICRO 100
34
+#define LIBAVFILTER_VERSION_MICRO 101
35 35
 
36 36
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
37 37
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -55,6 +55,7 @@ typedef struct {
55 55
     uint8_t rgba_map[4];
56 56
     int     pix_step[4];       ///< steps per pixel for each plane of the main output
57 57
     int original_w, original_h;
58
+    int shaping;
58 59
     FFDrawContext draw;
59 60
 } AssContext;
60 61
 
... ...
@@ -141,6 +142,8 @@ static int config_input(AVFilterLink *inlink)
141 141
     if (ass->original_w && ass->original_h)
142 142
         ass_set_aspect_ratio(ass->renderer, (double)inlink->w / inlink->h,
143 143
                              (double)ass->original_w / ass->original_h);
144
+    if (ass->shaping != -1)
145
+        ass_set_shaper(ass->renderer, ass->shaping);
144 146
 
145 147
     return 0;
146 148
 }
... ...
@@ -207,6 +210,10 @@ static const AVFilterPad ass_outputs[] = {
207 207
 
208 208
 static const AVOption ass_options[] = {
209 209
     COMMON_OPTIONS
210
+    {"shaping", "set shaping engine", OFFSET(shaping), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, "shaping_mode"},
211
+        {"auto", NULL,                 0, AV_OPT_TYPE_CONST, {.i64 = -1},                  INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
212
+        {"simple",  "simple shaping",  0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_SIMPLE},  INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
213
+        {"complex", "complex shaping", 0, AV_OPT_TYPE_CONST, {.i64 = ASS_SHAPING_COMPLEX}, INT_MIN, INT_MAX, FLAGS, "shaping_mode"},
210 214
     {NULL},
211 215
 };
212 216