static int compat_read(AVFilterContext *ctx, AVFilterBufferRef **pbuf, int nb_samples)

{

    AVFilterBufferRef *buf;

    AVFrame *frame;

    int ret;



    if (!pbuf)

        return ff_poll_frame(ctx->inputs[0]);



    frame = av_frame_alloc();

    if (!frame)

        return AVERROR(ENOMEM);



    if (!nb_samples)

        ret = av_buffersink_get_frame(ctx, frame);

    else

        ret = av_buffersink_get_samples(ctx, frame, nb_samples);



    if (ret < 0)

        goto fail;



    if (ctx->inputs[0]->type == AVMEDIA_TYPE_VIDEO) {

        buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,

                                                        AV_PERM_READ,

                                                        frame->width, frame->height,

                                                        frame->format);

    } else {

        buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,

                                                        frame->linesize[0], AV_PERM_READ,

                                                        frame->nb_samples,

                                                        frame->format,

                                                        frame->channel_layout);

    }

    if (!buf) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    avfilter_copy_frame_props(buf, frame);



    buf->buf->priv = frame;

    buf->buf->free = compat_free_buffer;



    *pbuf = buf;



    return 0;

fail:

    av_frame_free(&frame);

    return ret;

}

static int compat_read(AVFilterContext *ctx, AVFilterBufferRef **pbuf, int nb_samples)

{

    AVFilterBufferRef *buf;

    AVFrame *frame;

    int ret;



    if (!pbuf)

        return ff_poll_frame(ctx->inputs[0]);



    frame = av_frame_alloc();

    if (!frame)

        return AVERROR(ENOMEM);



    if (!nb_samples)

        ret = av_buffersink_get_frame(ctx, frame);

    else

        ret = av_buffersink_get_samples(ctx, frame, nb_samples);



    if (ret < 0)

        goto fail;



    if (ctx->inputs[0]->type == AVMEDIA_TYPE_VIDEO) {

        buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,

                                                        AV_PERM_READ,

                                                        frame->width, frame->height,

                                                        frame->format);

    } else {

        buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,

                                                        frame->linesize[0], AV_PERM_READ,

                                                        frame->nb_samples,

                                                        frame->format,

                                                        frame->channel_layout);

    }

    if (!buf) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    avfilter_copy_frame_props(buf, frame);



    buf->buf->priv = frame;

    buf->buf->free = compat_free_buffer;



    *pbuf = buf;



    return 0;

fail:

    av_frame_free(&frame);

    return ret;

}

static int compat_read(AVFilterContext *ctx, AVFilterBufferRef **pbuf, int nb_samples)
static int FUNC_0(AVFilterContext *VAR_0, AVFilterBufferRef **VAR_1, int VAR_2)

{

    AVFilterBufferRef *buf;

    AVFrame *frame;

    int VAR_3;



    if (!VAR_1)

        return ff_poll_frame(VAR_0->inputs[0]);



    frame = av_frame_alloc();

    if (!frame)

        return AVERROR(ENOMEM);



    if (!VAR_2)

        VAR_3 = av_buffersink_get_frame(VAR_0, frame);

    else

        VAR_3 = av_buffersink_get_samples(VAR_0, frame, VAR_2);



    if (VAR_3 < 0)

        goto fail;



    if (VAR_0->inputs[0]->type == AVMEDIA_TYPE_VIDEO) {

        buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,

                                                        AV_PERM_READ,

                                                        frame->width, frame->height,

                                                        frame->format);

    } else {

        buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,

                                                        frame->linesize[0], AV_PERM_READ,

                                                        frame->VAR_2,

                                                        frame->format,

                                                        frame->channel_layout);

    }

    if (!buf) {

        VAR_3 = AVERROR(ENOMEM);

        goto fail;

    }



    avfilter_copy_frame_props(buf, frame);



    buf->buf->priv = frame;

    buf->buf->free = compat_free_buffer;



    *VAR_1 = buf;



    return 0;

fail:

    av_frame_free(&frame);

    return VAR_3;

}

static int FUNC_0(AVFilterContext *VAR_0, AVFilterBufferRef **VAR_1, int VAR_2)
{ AVFilterBufferRef *buf; AVFrame *frame; int VAR_3; if (!VAR_1)
return ff_poll_frame(VAR_0->inputs[0]); frame = av_frame_alloc(); if (!frame)
return AVERROR(ENOMEM); if (!VAR_2)
VAR_3 = av_buffersink_get_frame(VAR_0, frame); else
VAR_3 = av_buffersink_get_samples(VAR_0, frame, VAR_2); if (VAR_3 < 0)
goto fail; if (VAR_0->inputs[0]->type == AVMEDIA_TYPE_VIDEO) { buf = avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize,
AV_PERM_READ,
frame->width, frame->height,
frame->format); } else { buf = avfilter_get_audio_buffer_ref_from_arrays(frame->extended_data,
frame->linesize[0], AV_PERM_READ,
frame->VAR_2,
frame->format,
frame->channel_layout); } if (!buf) { VAR_3 = AVERROR(ENOMEM); goto fail; } avfilter_copy_frame_props(buf, frame); buf->buf->priv = frame; buf->buf->free = compat_free_buffer; *VAR_1 = buf; return 0; fail:
av_frame_free(&frame); return VAR_3; }