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 void end_frame(AVFilterLink *inlink)\n{\n    AVFilterContext   *ctx        = inlink->dst;\n    FieldOrderContext *fieldorder = ctx->priv;\n    AVFilterLink      *outlink    = ctx->outputs[0];\n    AVFilterBufferRef *inpicref   = inlink->cur_buf;\n    AVFilterBufferRef *outpicref  = outlink->out_buf;\n    int               h, plane, line_step, line_size, line;\n    uint8_t           *cpy_src, *cpy_dst;\n    if (    inpicref->video->interlaced\n         && inpicref->video->top_field_first != fieldorder->dst_tff) {\n        av_dlog(ctx,\n                "picture will move %s one line\\n",\n                fieldorder->dst_tff ? "up" : "down");\n        h = inpicref->video->h;\n        for (plane = 0; plane < 4 && inpicref->data[plane]; plane++) {\n            line_step = inpicref->linesize[plane];\n            line_size = fieldorder->line_size[plane];\n            cpy_src = inpicref->data[plane];\n            cpy_dst = outpicref->data[plane];\n            if (fieldorder->dst_tff) {\n                for (line = 0; line < h; line++) {\n                    if (1 + line < outpicref->video->h) {\n                        memcpy(cpy_dst, cpy_src + line_step, line_size);\n                    } else {\n                        memcpy(cpy_dst, cpy_src - line_step - line_step, line_size);\n                    }\n                    cpy_src += line_step;\n                    cpy_dst += line_step;\n                }\n            } else {\n                cpy_src += (h - 1) * line_step;\n                cpy_dst += (h - 1) * line_step;\n                for (line = h - 1; line >= 0 ; line--) {\n                    if (line > 0) {\n                        memcpy(cpy_dst, cpy_src - line_step, line_size);\n                    } else {\n                        memcpy(cpy_dst, cpy_src + line_step + line_step, line_size);\n                    }\n                    cpy_src -= line_step;\n                    cpy_dst -= line_step;\n                }\n            }\n        }\n        outpicref->video->top_field_first = fieldorder->dst_tff;\n        ff_draw_slice(outlink, 0, h, 1);\n    } else {\n        av_dlog(ctx,\n                "not interlaced or field order already correct\\n");\n    }\n    ff_end_frame(outlink);\n    avfilter_unref_buffer(inpicref);\n    avfilter_unref_bufferp(&outlink->out_buf);\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}']