- AVFilterLink *outlink = link->dst->outputs[0];
- AVFilterBufferRef *outpicref, *for_next_filter;
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
- char buf[32];
- int ret = 0;
-
- if( picref->video->w != link->w
- || picref->video->h != link->h
- || picref->format != link->format) {
- int ret;
- snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
- av_opt_set(scale, "w", buf, 0);
- snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
- av_opt_set(scale, "h", buf, 0);
-
- link->dst->inputs[0]->format = picref->format;
- link->dst->inputs[0]->w = picref->video->w;
- link->dst->inputs[0]->h = picref->video->h;
-
- if ((ret = config_props(outlink)) < 0)
- return ret;
- }
-
- if (!scale->sws) {
- outpicref = avfilter_ref_buffer(picref, ~0);
- if (!outpicref)
- return AVERROR(ENOMEM);
- return ff_start_frame(outlink, outpicref);
- }
-
- scale->hsub = desc->log2_chroma_w;
- scale->vsub = desc->log2_chroma_h;
-
- outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h);
- if (!outpicref)
- return AVERROR(ENOMEM);
-
- avfilter_copy_buffer_ref_props(outpicref, picref);
- outpicref->video->w = outlink->w;
- outpicref->video->h = outlink->h;
-
- if(scale->output_is_pal)
- avpriv_set_systematic_pal2((uint32_t*)outpicref->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
-
- av_reduce(&outpicref->video->sample_aspect_ratio.num, &outpicref->video->sample_aspect_ratio.den,
- (int64_t)picref->video->sample_aspect_ratio.num * outlink->h * link->w,
- (int64_t)picref->video->sample_aspect_ratio.den * outlink->w * link->h,
- INT_MAX);
-
- scale->slice_y = 0;
- for_next_filter = avfilter_ref_buffer(outpicref, ~0);
- if (for_next_filter)
- ret = ff_start_frame(outlink, for_next_filter);
- else
- ret = AVERROR(ENOMEM);
-
- if (ret < 0) {
- avfilter_unref_bufferp(&outpicref);
- return ret;
- }
-
- outlink->out_buf = outpicref;
- return 0;
-}
-
-static int scale_slice(AVFilterLink *link, struct SwsContext *sws, int y, int h, int mul, int field)
-{
- ScaleContext *scale = link->dst->priv;
- AVFilterBufferRef *cur_pic = link->cur_buf;
- AVFilterBufferRef *out_buf = link->dst->outputs[0]->out_buf;