[FFmpeg-devel] [PATCH] lavfi/curves: do not automatically insert points at x=0 and x=1

Clément Bœsch u at pkh.me
Sun Jul 17 18:25:44 EEST 2016


On Sun, Jul 17, 2016 at 05:03:35PM +0200, Clément Bœsch wrote:
> There is actually a need for the origin and end point not to be defined.
> We can not automatically insert them with the y value of the first and
> last point as it will influence the curves in a wrong way.
> 
> Fixes #5397
> ---
>  Changelog               |  1 +
>  doc/filters.texi        | 10 ++----
>  libavfilter/version.h   |  2 +-
>  libavfilter/vf_curves.c | 85 ++++++++++++++++++++++++-------------------------
>  4 files changed, 47 insertions(+), 51 deletions(-)
[...]
> @@ -177,30 +177,6 @@ static int parse_points_str(AVFilterContext *ctx, struct keypoint **points, cons
>          last = point;
>      }
>  
> -    /* auto insert first key point if missing at x=0 */
> -    if (!*points) {
> -        last = make_point(0, 0, NULL);
> -        if (!last)
> -            return AVERROR(ENOMEM);
> -        last->x = last->y = 0;
> -        *points = last;
> -    } else if ((*points)->x != 0.) {
> -        struct keypoint *newfirst = make_point(0, 0, *points);
> -        if (!newfirst)
> -            return AVERROR(ENOMEM);
> -        *points = newfirst;
> -    }
> -
> -    av_assert0(last);
> -
> -    /* auto insert last key point if missing at x=1 */
> -    if (last->x != 1.) {
> -        struct keypoint *point = make_point(1, 1, NULL);
> -        if (!point)
> -            return AVERROR(ENOMEM);
> -        last->next = point;
> -    }
> -

Added the following warning locally:

    if (*points && !(*points)->next) {
        av_log(ctx, AV_LOG_WARNING, "Only one point (at (%f;%f)) is defined, "
               "this is unlikely to behave as you expect. You probably want"
               "at least 2 points.",
               (*points)->x, (*points)->y);
    }


>      return 0;
>  }
>  
> @@ -225,11 +201,25 @@ static int interpolate(AVFilterContext *ctx, uint8_t *y, const struct keypoint *
>      const struct keypoint *point;

changed locally to

       const struct keypoint *point = NULL;

to prevent a crash in case of only one point defined.

[...]

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160717/8e9b315d/attachment.sig>


More information about the ffmpeg-devel mailing list