diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-04-02 01:48:36 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-04-02 02:17:02 +0400 |
commit | 49891784ce70456305f19847d4188f07bbc1b6e1 (patch) | |
tree | ea5bd40d34743197c8cd4329ba223a8ba49118b3 /libavfilter/vf_scale.c | |
parent | 178f75a5aeb3606bb7947e08f0b89826f5e31f85 (diff) | |
parent | 95587d29d73c5cdf39062fde3f21436f8abf3e79 (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
vsrc_buffer: allow buffering arbitrary number of frames.
vf_scale: avoid a pointless memcpy in no-op conversion.
avfiltergraph: try to reduce format conversions in filters.
avfiltergraph: add an AVClass to AVFilterGraph on next major bump.
id3v2: fix skipping extended header in id3v2.4
Conflicts:
libavfilter/vf_scale.c
libavfilter/vsrc_buffer.c
libavformat/id3v2.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_scale.c')
-rw-r--r-- | libavfilter/vf_scale.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 692e2c5a14..deb7009fa1 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -214,21 +214,26 @@ static int config_props(AVFilterLink *outlink) if (scale->sws) sws_freeContext(scale->sws); - scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format, - outlink->w, outlink->h, outfmt, - scale->flags, NULL, NULL, NULL); - if (scale->isws[0]) - sws_freeContext(scale->isws[0]); - scale->isws[0] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format, - outlink->w, outlink->h/2, outfmt, + if (inlink->w == outlink->w && inlink->h == outlink->h && + inlink->format == outlink->format) + scale->sws = NULL; + else { + scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format, + outlink->w, outlink->h, outfmt, scale->flags, NULL, NULL, NULL); - if (scale->isws[1]) - sws_freeContext(scale->isws[1]); - scale->isws[1] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format, - outlink->w, outlink->h/2, outfmt, - scale->flags, NULL, NULL, NULL); - if (!scale->sws || !scale->isws[0] || !scale->isws[1]) - return AVERROR(EINVAL); + if (scale->isws[0]) + sws_freeContext(scale->isws[0]); + scale->isws[0] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format, + outlink->w, outlink->h/2, outfmt, + scale->flags, NULL, NULL, NULL); + if (scale->isws[1]) + sws_freeContext(scale->isws[1]); + scale->isws[1] = sws_getContext(inlink ->w, inlink ->h/2, inlink ->format, + outlink->w, outlink->h/2, outfmt, + scale->flags, NULL, NULL, NULL); + if (!scale->sws || !scale->isws[0] || !scale->isws[1]) + return AVERROR(EINVAL); + } if (inlink->sample_aspect_ratio.num){ outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h * inlink->w, outlink->w * inlink->h}, inlink->sample_aspect_ratio); @@ -257,6 +262,11 @@ static void start_frame(AVFilterLink *link, AVFilterBufferRef *picref) AVFilterLink *outlink = link->dst->outputs[0]; AVFilterBufferRef *outpicref; + if (!scale->sws) { + avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); + return; + } + scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; @@ -307,6 +317,11 @@ static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir) ScaleContext *scale = link->dst->priv; int out_h; + if (!scale->sws) { + avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir); + return; + } + if (scale->slice_y == 0 && slice_dir == -1) scale->slice_y = link->dst->outputs[0]->h; |