[FFmpeg-devel] [PATCH] avfilter: add panorama filter

Clément Bœsch u at pkh.me
Sat Dec 5 18:57:44 CET 2015


On Sat, Dec 05, 2015 at 06:38:47PM +0100, Paul B Mahol wrote:
[...]
> +    { "input",  "set input projection",   OFFSET(in), AV_OPT_TYPE_INT,   {.i64=SPHERE}, 0, NB_PROJECTIONS-1, FLAGS, "in" },
> +    {     "s", "spheric",                          0, AV_OPT_TYPE_CONST, {.i64=SPHERE}, 0,                0, FLAGS, "in" },
> +    {     "c", "cubic",                            0, AV_OPT_TYPE_CONST, {.i64=CUBE},   0,                0, FLAGS, "in" },
> +    { "output", "set output projection", OFFSET(out), AV_OPT_TYPE_INT,   {.i64=CUBE},   0, NB_PROJECTIONS-1, FLAGS, "out" },
> +    {     "s", "spheric",                          0, AV_OPT_TYPE_CONST, {.i64=SPHERE}, 0,                0, FLAGS, "out" },
> +    {     "c", "cubic",                            0, AV_OPT_TYPE_CONST, {.i64=CUBE},   0,                0, FLAGS, "out" },

i think you can use something like "projection" as unit, and define the
const list only once.

> +    { NULL }
> +};
> +
> +AVFILTER_DEFINE_CLASS(panorama);
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> +    static const enum AVPixelFormat pix_fmts[] = {
> +        AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA420P,
> +        AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUVJ422P,AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ411P,
> +        AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
> +        AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
> +    };
> +
> +    AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
> +    if (!fmts_list)
> +        return AVERROR(ENOMEM);
> +    return ff_set_common_formats(ctx, fmts_list);
> +}
> +
> +static int bilinear(PanoramaContext *s,
> +                    const uint8_t *src, uint8_t *dst,
> +                    int width, int height,
> +                    int in_linesize, int out_linesize,

> +                    struct XYRemap *remap)

remap doesn't seem altered here

> +{
> +    double A, B, C, D;
> +    int x, y;
> +
> +    for (y = 0; y < height; y++) {
> +        uint8_t *d = dst + y * out_linesize;
> +        for (x = 0; x < width; x++) {
> +            struct XYRemap *r = &remap[y * width + x];
> +
> +            A = src[r->vi * in_linesize + r->ui];
> +            B = src[r->vi * in_linesize + r->u2];
> +            C = src[r->v2 * in_linesize + r->ui];
> +            D = src[r->v2 * in_linesize + r->u2];

nit: you can declare A,B,C,D as local const double in this scope

> +            *d++ = round(A * r->a + B * r->b + C * r->c + D * r->d);
> +        }
> +    }
> +
> +    return 0;
> +}
> +

looks threadable btw

[...]

-- 
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/20151205/0a0ad165/attachment.sig>


More information about the ffmpeg-devel mailing list