void avfilter_unref_buffer(AVFilterBufferRef *ref)
{
    if (!ref)
        return;
    if (!(--ref->buf->refcount))
        ref->buf->free(ref->buf);
    if (ref->extended_data != ref->data)
        av_freep(&ref->extended_data);
    av_free(ref->video);
    av_free(ref->audio);
    av_free(ref);
}
['static int request_frame(AVFilterLink *link)\n{\n    AVFilterContext *ctx = link->src;\n    ASyncContext      *s = ctx->priv;\n    int ret = 0;\n    int nb_samples;\n    s->got_output = 0;\n    while (ret >= 0 && !s->got_output)\n        ret = ff_request_frame(ctx->inputs[0]);\n    if (ret == AVERROR_EOF && (nb_samples = avresample_get_delay(s->avr))) {\n        AVFilterBufferRef *buf = ff_get_audio_buffer(link, AV_PERM_WRITE,\n                                                     nb_samples);\n        if (!buf)\n            return AVERROR(ENOMEM);\n        ret = avresample_convert(s->avr, (void**)buf->extended_data,\n                                 buf->linesize[0], nb_samples, NULL, 0, 0);\n        if (ret <= 0) {\n            avfilter_unref_bufferp(&buf);\n            return (ret < 0) ? ret : AVERROR_EOF;\n        }\n        buf->pts = s->pts;\n        return ff_filter_samples(link, buf);\n    }\n    return ret;\n}', 'int ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)\n{\n    int (*filter_samples)(AVFilterLink *, AVFilterBufferRef *);\n    AVFilterPad *dst = link->dstpad;\n    AVFilterBufferRef *buf_out;\n    FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1);\n    if (!(filter_samples = dst->filter_samples))\n        filter_samples = default_filter_samples;\n    if ((dst->min_perms & samplesref->perms) != dst->min_perms ||\n        dst->rej_perms & samplesref->perms) {\n        av_log(link->dst, AV_LOG_DEBUG,\n               "Copying audio data in avfilter (have perms %x, need %x, reject %x)\\n",\n               samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);\n        buf_out = ff_default_get_audio_buffer(link, dst->min_perms,\n                                              samplesref->audio->nb_samples);\n        if (!buf_out) {\n            avfilter_unref_buffer(samplesref);\n            return AVERROR(ENOMEM);\n        }\n        buf_out->pts                = samplesref->pts;\n        buf_out->audio->sample_rate = samplesref->audio->sample_rate;\n        av_samples_copy(buf_out->extended_data, samplesref->extended_data,\n                        0, 0, samplesref->audio->nb_samples,\n                        av_get_channel_layout_nb_channels(link->channel_layout),\n                        link->format);\n        avfilter_unref_buffer(samplesref);\n    } else\n        buf_out = samplesref;\n    return filter_samples(link, buf_out);\n}', 'void avfilter_unref_buffer(AVFilterBufferRef *ref)\n{\n    if (!ref)\n        return;\n    if (!(--ref->buf->refcount))\n        ref->buf->free(ref->buf);\n    if (ref->extended_data != ref->data)\n        av_freep(&ref->extended_data);\n    av_free(ref->video);\n    av_free(ref->audio);\n    av_free(ref);\n}']