static int filter_frame(AVFilterLink *link, AVFrame *in)
{
    ScaleContext *scale = link->dst->priv;
    AVFilterLink *outlink = link->dst->outputs[0];
    AVFrame *out;
    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
    if (!scale->sws)
        return ff_filter_frame(outlink, in);
    scale->hsub = desc->log2_chroma_w;
    scale->vsub = desc->log2_chroma_h;
    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
    if (!out) {
        av_frame_free(&in);
        return AVERROR(ENOMEM);
    }
    av_frame_copy_props(out, in);
    out->width  = outlink->w;
    out->height = outlink->h;
    av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
              (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
              (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
              INT_MAX);
    sws_scale(scale->sws, in->data, in->linesize, 0, in->height,
              out->data, out->linesize);
    av_frame_free(&in);
    return ff_filter_frame(outlink, out);
}
['static int filter_frame(AVFilterLink *link, AVFrame *in)\n{\n    ScaleContext *scale = link->dst->priv;\n    AVFilterLink *outlink = link->dst->outputs[0];\n    AVFrame *out;\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);\n    if (!scale->sws)\n        return ff_filter_frame(outlink, in);\n    scale->hsub = desc->log2_chroma_w;\n    scale->vsub = desc->log2_chroma_h;\n    out = ff_get_video_buffer(outlink, outlink->w, outlink->h);\n    if (!out) {\n        av_frame_free(&in);\n        return AVERROR(ENOMEM);\n    }\n    av_frame_copy_props(out, in);\n    out->width  = outlink->w;\n    out->height = outlink->h;\n    av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,\n              (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,\n              (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,\n              INT_MAX);\n    sws_scale(scale->sws, in->data, in->linesize, 0, in->height,\n              out->data, out->linesize);\n    av_frame_free(&in);\n    return ff_filter_frame(outlink, out);\n}', 'const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)\n{\n    if (pix_fmt < 0 || pix_fmt >= AV_PIX_FMT_NB)\n        return NULL;\n    return &av_pix_fmt_descriptors[pix_fmt];\n}']