diff mbox

[FFmpeg-devel] avfilter/vf_subtitles: enable processing of alpha channel

Message ID 20170830190459.4505-1-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol Aug. 30, 2017, 7:04 p.m. UTC
Fixes #6605.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/vf_subtitles.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Clément Bœsch Aug. 31, 2017, 6:21 p.m. UTC | #1
On Wed, Aug 30, 2017 at 09:04:59PM +0200, Paul B Mahol wrote:
> Fixes #6605.
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavfilter/vf_subtitles.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
> index 805ee2d..b7ba628 100644
> --- a/libavfilter/vf_subtitles.c
> +++ b/libavfilter/vf_subtitles.c
> @@ -54,6 +54,7 @@ typedef struct AssContext {
>      char *charenc;
>      char *force_style;
>      int stream_index;
> +    int alpha;
>      uint8_t rgba_map[4];
>      int     pix_step[4];       ///< steps per pixel for each plane of the main output
>      int original_w, original_h;
> @@ -69,6 +70,7 @@ typedef struct AssContext {
>      {"f",              "set the filename of file to read",                         OFFSET(filename),   AV_OPT_TYPE_STRING,     {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
>      {"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 }, \
>      {"fontsdir",       "set the directory containing the fonts to read",           OFFSET(fontsdir),   AV_OPT_TYPE_STRING,     {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
> +    {"alpha",          "enable processing of alpha channel",                       OFFSET(alpha),      AV_OPT_TYPE_BOOL,       {.i64 = 0   },         0,        1, FLAGS }, \
>  
>  /* libass supports a log level ranging from 0 to 7 */
>  static const int ass_libavfilter_log_level_map[] = {
> @@ -140,7 +142,7 @@ static int config_input(AVFilterLink *inlink)
>  {
>      AssContext *ass = inlink->dst->priv;
>  
> -    ff_draw_init(&ass->draw, inlink->format, 0);
> +    ff_draw_init(&ass->draw, inlink->format, ass->alpha);
>  

please use ass->alpha ? FF_DRAW_PROCESS_ALPHA : 0

and update doc/filters.texi

otherwise LGTM
diff mbox

Patch

diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c
index 805ee2d..b7ba628 100644
--- a/libavfilter/vf_subtitles.c
+++ b/libavfilter/vf_subtitles.c
@@ -54,6 +54,7 @@  typedef struct AssContext {
     char *charenc;
     char *force_style;
     int stream_index;
+    int alpha;
     uint8_t rgba_map[4];
     int     pix_step[4];       ///< steps per pixel for each plane of the main output
     int original_w, original_h;
@@ -69,6 +70,7 @@  typedef struct AssContext {
     {"f",              "set the filename of file to read",                         OFFSET(filename),   AV_OPT_TYPE_STRING,     {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
     {"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 }, \
     {"fontsdir",       "set the directory containing the fonts to read",           OFFSET(fontsdir),   AV_OPT_TYPE_STRING,     {.str = NULL},  CHAR_MIN, CHAR_MAX, FLAGS }, \
+    {"alpha",          "enable processing of alpha channel",                       OFFSET(alpha),      AV_OPT_TYPE_BOOL,       {.i64 = 0   },         0,        1, FLAGS }, \
 
 /* libass supports a log level ranging from 0 to 7 */
 static const int ass_libavfilter_log_level_map[] = {
@@ -140,7 +142,7 @@  static int config_input(AVFilterLink *inlink)
 {
     AssContext *ass = inlink->dst->priv;
 
-    ff_draw_init(&ass->draw, inlink->format, 0);
+    ff_draw_init(&ass->draw, inlink->format, ass->alpha);
 
     ass_set_frame_size  (ass->renderer, inlink->w, inlink->h);
     if (ass->original_w && ass->original_h)