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 poll_filters(void)\n{\n    AVFilterBufferRef *picref;\n    AVFrame *filtered_frame = NULL;\n    int i, frame_size;\n    for (i = 0; i < nb_output_streams; i++) {\n        OutputStream *ost = output_streams[i];\n        OutputFile    *of = output_files[ost->file_index];\n        int ret = 0;\n        if (!ost->filter || ost->is_past_recording_time)\n            continue;\n        if (!ost->filtered_frame && !(ost->filtered_frame = avcodec_alloc_frame())) {\n            return AVERROR(ENOMEM);\n        } else\n            avcodec_get_frame_defaults(ost->filtered_frame);\n        filtered_frame = ost->filtered_frame;\n        while (ret >= 0) {\n            if (ost->enc->type == AVMEDIA_TYPE_AUDIO &&\n                !(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE))\n                ret = av_buffersink_read_samples(ost->filter->filter, &picref,\n                                                 ost->st->codec->frame_size);\n            else\n                ret = av_buffersink_read(ost->filter->filter, &picref);\n            if (ret < 0)\n                break;\n            avfilter_copy_buf_props(filtered_frame, picref);\n            if (picref->pts != AV_NOPTS_VALUE)\n                filtered_frame->pts = av_rescale_q(picref->pts,\n                                                   ost->filter->filter->inputs[0]->time_base,\n                                                   ost->st->codec->time_base) -\n                                      av_rescale_q(of->start_time,\n                                                   AV_TIME_BASE_Q,\n                                                   ost->st->codec->time_base);\n            if (of->start_time && filtered_frame->pts < of->start_time) {\n                avfilter_unref_buffer(picref);\n                continue;\n            }\n            switch (ost->filter->filter->inputs[0]->type) {\n            case AVMEDIA_TYPE_VIDEO:\n                if (!ost->frame_aspect_ratio)\n                    ost->st->codec->sample_aspect_ratio = picref->video->pixel_aspect;\n                do_video_out(of->ctx, ost, filtered_frame, &frame_size,\n                             same_quant ? ost->last_quality :\n                                          ost->st->codec->global_quality);\n                if (vstats_filename && frame_size)\n                    do_video_stats(of->ctx, ost, frame_size);\n                break;\n            case AVMEDIA_TYPE_AUDIO:\n                do_audio_out(of->ctx, ost, filtered_frame);\n                break;\n            default:\n                av_assert0(0);\n            }\n            avfilter_unref_buffer(picref);\n        }\n    }\n    return 0;\n}', 'int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)\n{\n    int planes, nb_channels;\n    memcpy(dst->data, src->data, sizeof(dst->data));\n    memcpy(dst->linesize, src->linesize, sizeof(dst->linesize));\n    dst->pts     = src->pts;\n    dst->format  = src->format;\n    switch (src->type) {\n    case AVMEDIA_TYPE_VIDEO:\n        dst->width               = src->video->w;\n        dst->height              = src->video->h;\n        dst->sample_aspect_ratio = src->video->pixel_aspect;\n        dst->interlaced_frame    = src->video->interlaced;\n        dst->top_field_first     = src->video->top_field_first;\n        dst->key_frame           = src->video->key_frame;\n        dst->pict_type           = src->video->pict_type;\n        break;\n    case AVMEDIA_TYPE_AUDIO:\n        nb_channels = av_get_channel_layout_nb_channels(src->audio->channel_layout);\n        planes      = av_sample_fmt_is_planar(src->format) ? nb_channels : 1;\n        if (planes > FF_ARRAY_ELEMS(dst->data)) {\n            dst->extended_data = av_mallocz(planes * sizeof(*dst->extended_data));\n            if (!dst->extended_data)\n                return AVERROR(ENOMEM);\n            memcpy(dst->extended_data, src->extended_data,\n                   planes * sizeof(dst->extended_data));\n        } else\n            dst->extended_data = dst->data;\n        dst->sample_rate         = src->audio->sample_rate;\n        dst->channel_layout      = src->audio->channel_layout;\n        dst->nb_samples          = src->audio->nb_samples;\n        break;\n    default:\n        return AVERROR(EINVAL);\n    }\n    return 0;\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}']