summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-17 11:28:15 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-17 11:29:22 +0200
commit71fcb6072ea6258b28e6267a3d7d5287569b2f26 (patch)
tree60e319e1c9bf07580a9a50194be7cf7758801154
parentc7078f4907dcff6877cf38f48526788c10644f07 (diff)
parent3fb29588a27a711132106b924e27b53789a58dcb (diff)
Merge commit '3fb29588a27a711132106b924e27b53789a58dcb'
* 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>
-rw-r--r--libavfilter/vf_aspect.c30
-rw-r--r--libavfilter/vf_crop.c3
-rw-r--r--libavfilter/vf_drawtext.c12
3 files changed, 28 insertions, 17 deletions
diff --git a/libavfilter/vf_aspect.c b/libavfilter/vf_aspect.c
index f8ed427aca..22d6c70e20 100644
--- a/libavfilter/vf_aspect.c
+++ b/libavfilter/vf_aspect.c
@@ -37,7 +37,8 @@
typedef struct {
const AVClass *class;
- AVRational aspect;
+ AVRational dar;
+ AVRational sar;
int max;
#if FF_API_OLD_FILTER_OPTS
float aspect_den;
@@ -61,16 +62,17 @@ static av_cold int init(AVFilterContext *ctx)
av_log(ctx, AV_LOG_ERROR, "Unable to parse ratio numerator \"%s\"\n", s->ratio_str);
return AVERROR(EINVAL);
}
- s->aspect = av_d2q(num / s->aspect_den, s->max);
+ s->sar = s->dar = av_d2q(num / s->aspect_den, s->max);
} else
#endif
if (s->ratio_str) {
- ret = av_parse_ratio(&s->aspect, s->ratio_str, s->max, 0, ctx);
- if (ret < 0 || s->aspect.num < 0 || s->aspect.den <= 0) {
+ ret = av_parse_ratio(&s->sar, s->ratio_str, s->max, 0, ctx);
+ if (ret < 0 || s->sar.num < 0 || s->sar.den <= 0) {
av_log(ctx, AV_LOG_ERROR,
"Invalid string '%s' for aspect ratio\n", s->ratio_str);
return AVERROR(EINVAL);
}
+ s->dar = s->sar;
}
return 0;
}
@@ -79,7 +81,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame)
{
AspectContext *s = link->dst->priv;
- frame->sample_aspect_ratio = s->aspect;
+ frame->sample_aspect_ratio = s->sar;
return ff_filter_frame(link->dst->outputs[0], frame);
}
@@ -100,14 +102,16 @@ static inline void compute_dar(AVRational *dar, AVRational sar, int w, int h)
static int setdar_config_props(AVFilterLink *inlink)
{
AspectContext *s = inlink->dst->priv;
- AVRational dar = s->aspect, old_dar;
+ AVRational dar;
+ AVRational old_dar;
AVRational old_sar = inlink->sample_aspect_ratio;
- if (s->aspect.num && s->aspect.den) {
- av_reduce(&s->aspect.num, &s->aspect.den,
- s->aspect.num * inlink->h,
- s->aspect.den * inlink->w, INT_MAX);
- inlink->sample_aspect_ratio = s->aspect;
+ if (s->dar.num && s->dar.den) {
+ av_reduce(&s->sar.num, &s->sar.den,
+ s->dar.num * inlink->h,
+ s->dar.den * inlink->w, INT_MAX);
+ inlink->sample_aspect_ratio = s->sar;
+ dar = s->dar;
} else {
inlink->sample_aspect_ratio = (AVRational){ 1, 1 };
dar = (AVRational){ inlink->w, inlink->h };
@@ -175,10 +179,10 @@ static int setsar_config_props(AVFilterLink *inlink)
AVRational old_sar = inlink->sample_aspect_ratio;
AVRational old_dar, dar;
- inlink->sample_aspect_ratio = s->aspect;
+ inlink->sample_aspect_ratio = s->sar;
compute_dar(&old_dar, old_sar, inlink->w, inlink->h);
- compute_dar(&dar, s->aspect, inlink->w, inlink->h);
+ compute_dar(&dar, s->sar, inlink->w, inlink->h);
av_log(inlink->dst, AV_LOG_VERBOSE, "w:%d h:%d sar:%d/%d dar:%d/%d -> sar:%d/%d dar:%d/%d\n",
inlink->w, inlink->h, old_sar.num, old_sar.den, old_dar.num, old_dar.den,
inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den, dar.num, dar.den);
diff --git a/libavfilter/vf_crop.c b/libavfilter/vf_crop.c
index 4edb7cfb05..7ba99d1d75 100644
--- a/libavfilter/vf_crop.c
+++ b/libavfilter/vf_crop.c
@@ -204,6 +204,9 @@ static int config_input(AVFilterLink *link)
s->w &= ~((1 << s->hsub) - 1);
s->h &= ~((1 << s->vsub) - 1);
+ av_expr_free(s->x_pexpr);
+ av_expr_free(s->y_pexpr);
+ s->x_pexpr = s->y_pexpr = NULL;
if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names,
NULL, NULL, NULL, NULL, 0, ctx)) < 0 ||
(ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names,
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index 63c436242d..303dcfe26e 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -534,10 +534,10 @@ static av_cold void uninit(AVFilterContext *ctx)
{
DrawTextContext *s = ctx->priv;
- av_expr_free(s->x_pexpr); s->x_pexpr = NULL;
- av_expr_free(s->y_pexpr); s->y_pexpr = NULL;
- av_expr_free(s->draw_pexpr); s->draw_pexpr = NULL;
-
+ av_expr_free(s->x_pexpr);
+ av_expr_free(s->y_pexpr);
+ av_expr_free(s->draw_pexpr);
+ s->x_pexpr = s->y_pexpr = s->draw_pexpr = NULL;
av_freep(&s->positions);
s->nb_positions = 0;
@@ -580,6 +580,10 @@ static int config_input(AVFilterLink *inlink)
av_lfg_init(&s->prng, av_get_random_seed());
+ av_expr_free(s->x_pexpr);
+ av_expr_free(s->y_pexpr);
+ av_expr_free(s->draw_pexpr);
+ s->x_pexpr = s->y_pexpr = s->draw_pexpr = NULL;
if ((ret = av_expr_parse(&s->x_pexpr, s->x_expr, var_names,
NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 ||
(ret = av_expr_parse(&s->y_pexpr, s->y_expr, var_names,