* commit '3fb29588a27a711132106b924e27b53789a58dcb':
vf_drawtext: don't leak the expressions.
vf_crop: make config_props work properly when called multiple times.
vf_setdar: make config_props work properly when called multiple times.
Conflicts:
libavfilter/vf_aspect.c
libavfilter/vf_drawtext.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -37,7 +37,8 @@ |
37 | 37 |
|
38 | 38 |
typedef struct { |
39 | 39 |
const AVClass *class; |
40 |
- AVRational aspect; |
|
40 |
+ AVRational dar; |
|
41 |
+ AVRational sar; |
|
41 | 42 |
int max; |
42 | 43 |
#if FF_API_OLD_FILTER_OPTS |
43 | 44 |
float aspect_den; |
... | ... |
@@ -61,16 +62,17 @@ static av_cold int init(AVFilterContext *ctx) |
61 | 61 |
av_log(ctx, AV_LOG_ERROR, "Unable to parse ratio numerator \"%s\"\n", s->ratio_str); |
62 | 62 |
return AVERROR(EINVAL); |
63 | 63 |
} |
64 |
- s->aspect = av_d2q(num / s->aspect_den, s->max); |
|
64 |
+ s->sar = s->dar = av_d2q(num / s->aspect_den, s->max); |
|
65 | 65 |
} else |
66 | 66 |
#endif |
67 | 67 |
if (s->ratio_str) { |
68 |
- ret = av_parse_ratio(&s->aspect, s->ratio_str, s->max, 0, ctx); |
|
69 |
- if (ret < 0 || s->aspect.num < 0 || s->aspect.den <= 0) { |
|
68 |
+ ret = av_parse_ratio(&s->sar, s->ratio_str, s->max, 0, ctx); |
|
69 |
+ if (ret < 0 || s->sar.num < 0 || s->sar.den <= 0) { |
|
70 | 70 |
av_log(ctx, AV_LOG_ERROR, |
71 | 71 |
"Invalid string '%s' for aspect ratio\n", s->ratio_str); |
72 | 72 |
return AVERROR(EINVAL); |
73 | 73 |
} |
74 |
+ s->dar = s->sar; |
|
74 | 75 |
} |
75 | 76 |
return 0; |
76 | 77 |
} |
... | ... |
@@ -79,7 +81,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) |
79 | 79 |
{ |
80 | 80 |
AspectContext *s = link->dst->priv; |
81 | 81 |
|
82 |
- frame->sample_aspect_ratio = s->aspect; |
|
82 |
+ frame->sample_aspect_ratio = s->sar; |
|
83 | 83 |
return ff_filter_frame(link->dst->outputs[0], frame); |
84 | 84 |
} |
85 | 85 |
|
... | ... |
@@ -100,14 +102,16 @@ static inline void compute_dar(AVRational *dar, AVRational sar, int w, int h) |
100 | 100 |
static int setdar_config_props(AVFilterLink *inlink) |
101 | 101 |
{ |
102 | 102 |
AspectContext *s = inlink->dst->priv; |
103 |
- AVRational dar = s->aspect, old_dar; |
|
103 |
+ AVRational dar; |
|
104 |
+ AVRational old_dar; |
|
104 | 105 |
AVRational old_sar = inlink->sample_aspect_ratio; |
105 | 106 |
|
106 |
- if (s->aspect.num && s->aspect.den) { |
|
107 |
- av_reduce(&s->aspect.num, &s->aspect.den, |
|
108 |
- s->aspect.num * inlink->h, |
|
109 |
- s->aspect.den * inlink->w, INT_MAX); |
|
110 |
- inlink->sample_aspect_ratio = s->aspect; |
|
107 |
+ if (s->dar.num && s->dar.den) { |
|
108 |
+ av_reduce(&s->sar.num, &s->sar.den, |
|
109 |
+ s->dar.num * inlink->h, |
|
110 |
+ s->dar.den * inlink->w, INT_MAX); |
|
111 |
+ inlink->sample_aspect_ratio = s->sar; |
|
112 |
+ dar = s->dar; |
|
111 | 113 |
} else { |
112 | 114 |
inlink->sample_aspect_ratio = (AVRational){ 1, 1 }; |
113 | 115 |
dar = (AVRational){ inlink->w, inlink->h }; |
... | ... |
@@ -175,10 +179,10 @@ static int setsar_config_props(AVFilterLink *inlink) |
175 | 175 |
AVRational old_sar = inlink->sample_aspect_ratio; |
176 | 176 |
AVRational old_dar, dar; |
177 | 177 |
|
178 |
- inlink->sample_aspect_ratio = s->aspect; |
|
178 |
+ inlink->sample_aspect_ratio = s->sar; |
|
179 | 179 |
|
180 | 180 |
compute_dar(&old_dar, old_sar, inlink->w, inlink->h); |
181 |
- compute_dar(&dar, s->aspect, inlink->w, inlink->h); |
|
181 |
+ compute_dar(&dar, s->sar, inlink->w, inlink->h); |
|
182 | 182 |
av_log(inlink->dst, AV_LOG_VERBOSE, "w:%d h:%d sar:%d/%d dar:%d/%d -> sar:%d/%d dar:%d/%d\n", |
183 | 183 |
inlink->w, inlink->h, old_sar.num, old_sar.den, old_dar.num, old_dar.den, |
184 | 184 |
inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den, dar.num, dar.den); |
... | ... |
@@ -204,6 +204,9 @@ static int config_input(AVFilterLink *link) |
204 | 204 |
s->w &= ~((1 << s->hsub) - 1); |
205 | 205 |
s->h &= ~((1 << s->vsub) - 1); |
206 | 206 |
|
207 |
+ av_expr_free(s->x_pexpr); |
|
208 |
+ av_expr_free(s->y_pexpr); |
|
209 |
+ s->x_pexpr = s->y_pexpr = NULL; |
|
207 | 210 |
if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names, |
208 | 211 |
NULL, NULL, NULL, NULL, 0, ctx)) < 0 || |
209 | 212 |
(ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names, |
... | ... |
@@ -534,10 +534,10 @@ static av_cold void uninit(AVFilterContext *ctx) |
534 | 534 |
{ |
535 | 535 |
DrawTextContext *s = ctx->priv; |
536 | 536 |
|
537 |
- av_expr_free(s->x_pexpr); s->x_pexpr = NULL; |
|
538 |
- av_expr_free(s->y_pexpr); s->y_pexpr = NULL; |
|
539 |
- av_expr_free(s->draw_pexpr); s->draw_pexpr = NULL; |
|
540 |
- |
|
537 |
+ av_expr_free(s->x_pexpr); |
|
538 |
+ av_expr_free(s->y_pexpr); |
|
539 |
+ av_expr_free(s->draw_pexpr); |
|
540 |
+ s->x_pexpr = s->y_pexpr = s->draw_pexpr = NULL; |
|
541 | 541 |
av_freep(&s->positions); |
542 | 542 |
s->nb_positions = 0; |
543 | 543 |
|
... | ... |
@@ -580,6 +580,10 @@ static int config_input(AVFilterLink *inlink) |
580 | 580 |
|
581 | 581 |
av_lfg_init(&s->prng, av_get_random_seed()); |
582 | 582 |
|
583 |
+ av_expr_free(s->x_pexpr); |
|
584 |
+ av_expr_free(s->y_pexpr); |
|
585 |
+ av_expr_free(s->draw_pexpr); |
|
586 |
+ s->x_pexpr = s->y_pexpr = s->draw_pexpr = NULL; |
|
583 | 587 |
if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names, |
584 | 588 |
NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 || |
585 | 589 |
(ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names, |