static int load_apply_palette(FFFrameSync *fs)

{

    AVFilterContext *ctx = fs->parent;

    AVFilterLink *inlink = ctx->inputs[0];

    PaletteUseContext *s = ctx->priv;

    AVFrame *master, *second, *out;

    int ret;



    // writable for error diffusal dithering

    ret = ff_framesync_dualinput_get_writable(fs, &master, &second);

    if (ret < 0)

        return ret;

    if (!master || !second) {

        ret = AVERROR_BUG;

        goto error;

    }

    if (!s->palette_loaded) {

        load_palette(s, second);

    }

    out = apply_palette(inlink, master);

    return ff_filter_frame(ctx->outputs[0], out);



error:

    av_frame_free(&master);

    av_frame_free(&second);

    return ret;

}

static int load_apply_palette(FFFrameSync *fs)

{

    AVFilterContext *ctx = fs->parent;

    AVFilterLink *inlink = ctx->inputs[0];

    PaletteUseContext *s = ctx->priv;

    AVFrame *master, *second, *out;

    int ret;



    

    ret = ff_framesync_dualinput_get_writable(fs, &master, &second);

    if (ret < 0)

        return ret;

    if (!master || !second) {

        ret = AVERROR_BUG;

        goto error;

    }

    if (!s->palette_loaded) {

        load_palette(s, second);

    }

    out = apply_palette(inlink, master);

    return ff_filter_frame(ctx->outputs[0], out);



error:

    av_frame_free(&master);

    av_frame_free(&second);

    return ret;

}

static int FUNC_0(FFFrameSync *VAR_0)

{

    AVFilterContext *ctx = VAR_0->parent;

    AVFilterLink *inlink = ctx->inputs[0];

    PaletteUseContext *s = ctx->priv;

    AVFrame *master, *second, *out;

    int VAR_1;



    

    VAR_1 = ff_framesync_dualinput_get_writable(VAR_0, &master, &second);

    if (VAR_1 < 0)

        return VAR_1;

    if (!master || !second) {

        VAR_1 = AVERROR_BUG;

        goto error;

    }

    if (!s->palette_loaded) {

        load_palette(s, second);

    }

    out = apply_palette(inlink, master);

    return ff_filter_frame(ctx->outputs[0], out);



error:

    av_frame_free(&master);

    av_frame_free(&second);

    return VAR_1;

}

static int FUNC_0(FFFrameSync *VAR_0)
{ AVFilterContext *ctx = VAR_0->parent; AVFilterLink *inlink = ctx->inputs[0]; PaletteUseContext *s = ctx->priv; AVFrame *master, *second, *out; int VAR_1; VAR_1 = ff_framesync_dualinput_get_writable(VAR_0, &master, &second); if (VAR_1 < 0)
return VAR_1; if (!master || !second) { VAR_1 = AVERROR_BUG; goto error; } if (!s->palette_loaded) { load_palette(s, second); } out = apply_palette(inlink, master); return ff_filter_frame(ctx->outputs[0], out); error:
av_frame_free(&master); av_frame_free(&second); return VAR_1; }