[soc]: r1932 - libavfilter/vf_scale.c
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932 Log: Slice support for vf_scale. Modified: libavfilter/vf_scale.c Modified: libavfilter/vf_scale.c ============================================================================== --- libavfilter/vf_scale.c (original) +++ libavfilter/vf_scale.c Thu Feb 28 00:18:58 2008 @@ -34,6 +34,8 @@ typedef struct * -1 = keep original aspect */ int w, h; + + int sliceY; ///< top of current output slice } ScaleContext; static int init(AVFilterContext *ctx, const char *args, void *opaque) @@ -110,6 +112,7 @@ static int config_props(AVFilterLink *li static void start_frame(AVFilterLink *link, AVFilterPicRef *picref) { + ScaleContext *scale = link->dst->priv; AVFilterLink *out = link->dst->outputs[0]; out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE); @@ -122,22 +125,20 @@ static void start_frame(AVFilterLink *li FFMAX(out->outpic->pixel_aspect.num, out->outpic->pixel_aspect.den)); avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); -} + scale->sliceY = 0; +} -/* TODO: figure out the swscale API well enough to scale slice at a time */ -static void end_frame(AVFilterLink *link) +static void draw_slice(AVFilterLink *link, int y, int h) { ScaleContext *scale = link->dst->priv; + int outH; - sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize, 0, - link->cur_pic->h, link->dst->outputs[0]->outpic->data, + outH = sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize, + y, h, link->dst->outputs[0]->outpic->data, link->dst->outputs[0]->outpic->linesize); - avfilter_draw_slice(link->dst->outputs[0], 0, link->dst->outputs[0]->h); - avfilter_end_frame(link->dst->outputs[0]); - - avfilter_unref_pic(link->cur_pic); - avfilter_unref_pic(link->dst->outputs[0]->outpic); + avfilter_draw_slice(link->dst->outputs[0], scale->sliceY, outH); + scale->sliceY += outH; } AVFilter avfilter_vf_scale = @@ -154,7 +155,7 @@ AVFilter avfilter_vf_scale = .inputs = (AVFilterPad[]) {{ .name = "default", .type = CODEC_TYPE_VIDEO, .start_frame = start_frame, - .end_frame = end_frame, + .draw_slice = draw_slice, .min_perms = AV_PERM_READ, }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default",
On Thu, 28 Feb 2008 00:18:59 +0100 (CET) koorogi <subversion@mplayerhq.hu> wrote:
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932
Log: Slice support for vf_scale.
Modified: libavfilter/vf_scale.c
Modified: libavfilter/vf_scale.c ============================================================================== --- libavfilter/vf_scale.c (original) +++ libavfilter/vf_scale.c Thu Feb 28 00:18:58 2008 @@ -34,6 +34,8 @@ typedef struct * -1 = keep original aspect */ int w, h; + + int sliceY; ///< top of current output slice } ScaleContext;
static int init(AVFilterContext *ctx, const char *args, void *opaque) @@ -110,6 +112,7 @@ static int config_props(AVFilterLink *li
static void start_frame(AVFilterLink *link, AVFilterPicRef *picref) { + ScaleContext *scale = link->dst->priv; AVFilterLink *out = link->dst->outputs[0];
out->outpic = avfilter_get_video_buffer(out, AV_PERM_WRITE); @@ -122,22 +125,20 @@ static void start_frame(AVFilterLink *li FFMAX(out->outpic->pixel_aspect.num, out->outpic->pixel_aspect.den)); avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0)); -}
+ scale->sliceY = 0; +}
-/* TODO: figure out the swscale API well enough to scale slice at a time */ -static void end_frame(AVFilterLink *link) +static void draw_slice(AVFilterLink *link, int y, int h) { ScaleContext *scale = link->dst->priv; + int outH;
- sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize, 0, - link->cur_pic->h, link->dst->outputs[0]->outpic->data, + outH = sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize, + y, h, link->dst->outputs[0]->outpic->data, link->dst->outputs[0]->outpic->linesize); - avfilter_draw_slice(link->dst->outputs[0], 0, link->dst->outputs[0]->h); - avfilter_end_frame(link->dst->outputs[0]); - - avfilter_unref_pic(link->cur_pic); - avfilter_unref_pic(link->dst->outputs[0]->outpic); + avfilter_draw_slice(link->dst->outputs[0], scale->sliceY, outH); + scale->sliceY += outH; }
AVFilter avfilter_vf_scale = @@ -154,7 +155,7 @@ AVFilter avfilter_vf_scale = .inputs = (AVFilterPad[]) {{ .name = "default", .type = CODEC_TYPE_VIDEO, .start_frame = start_frame, - .end_frame = end_frame, + .draw_slice = draw_slice, .min_perms = AV_PERM_READ, }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default",
After some more testing, it seems this doesn't work right with --enable-swscaler. I'll take a closer look at it later tonight. -- Bobby Bingham Never trust atoms. Or anything made of atoms. このメールは再利用されたバイトでできている。
Hi Bobby Bingham wrote:
On Thu, 28 Feb 2008 00:18:59 +0100 (CET) koorogi <subversion@mplayerhq.hu> wrote:
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932
Log: Slice support for vf_scale.
Modified: libavfilter/vf_scale.c
[...]
After some more testing, it seems this doesn't work right with --enable-swscaler. I'll take a closer look at it later tonight.
I was wondering one thing: imagine doing a 200x200 -> 400x400 linear interpolation resizing. The filter gets as input a (for ex.) 4x100 slice. It can then interpolate the line numbers (1,2,3,4,5,6,7) of the output. For the next slice, it would be able to output the lines (9,10,11,12,13,14,15). But to evaluate the output line 8, it'll need both the input line 4 and 5. So to do slice-based resizing, it would be necessary a complicated, resize algorithm dependent, caching. Also it would require some kind of memcpy. So my opinion is that implementing slices in resizing is hard and maybe not worth the effort. In the other hand, colospace conversion should be pretty simple. Or am I missing something? -Vitor
On Sun, 02 Mar 2008 15:00:34 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Hi
Bobby Bingham wrote:
On Thu, 28 Feb 2008 00:18:59 +0100 (CET) koorogi <subversion@mplayerhq.hu> wrote:
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932
Log: Slice support for vf_scale.
Modified: libavfilter/vf_scale.c
[...]
After some more testing, it seems this doesn't work right with --enable-swscaler. I'll take a closer look at it later tonight.
I was wondering one thing: imagine doing a 200x200 -> 400x400 linear interpolation resizing.
The filter gets as input a (for ex.) 4x100 slice. It can then interpolate the line numbers (1,2,3,4,5,6,7) of the output. For the next slice, it would be able to output the lines (9,10,11,12,13,14,15). But to evaluate the output line 8, it'll need both the input line 4 and 5. So to do slice-based resizing, it would be necessary a complicated, resize algorithm dependent, caching. Also it would require some kind of memcpy.
So my opinion is that implementing slices in resizing is hard and maybe not worth the effort. In the other hand, colospace conversion should be pretty simple. Or am I missing something?
I believe that this caching is already implemented by libswscale. -- Bobby Bingham Never trust atoms. Or anything made of atoms. このメールは再利用されたバイトでできている。
Hi Bobby Bingham wrote:
On Sun, 02 Mar 2008 15:00:34 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Bobby Bingham wrote:
On Thu, 28 Feb 2008 00:18:59 +0100 (CET) koorogi <subversion@mplayerhq.hu> wrote:
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932
Log: Slice support for vf_scale.
Modified: libavfilter/vf_scale.c
[...]
After some more testing, it seems this doesn't work right with --enable-swscaler. I'll take a closer look at it later tonight. I was wondering one thing: imagine doing a 200x200 -> 400x400 linear interpolation resizing.
The filter gets as input a (for ex.) 4x100 slice. It can then interpolate the line numbers (1,2,3,4,5,6,7) of the output. For the next slice, it would be able to output the lines (9,10,11,12,13,14,15). But to evaluate the output line 8, it'll need both the input line 4 and 5. So to do slice-based resizing, it would be necessary a complicated, resize algorithm dependent, caching. Also it would require some kind of memcpy.
So my opinion is that implementing slices in resizing is hard and maybe not worth the effort. In the other hand, colospace conversion should be pretty simple. Or am I missing something?
I believe that this caching is already implemented by libswscale.
Does imgresample.c also support this? -Vitor
On Sun, Mar 02, 2008 at 06:11:10PM +0100, Vitor Sessak wrote:
Hi
Bobby Bingham wrote:
On Sun, 02 Mar 2008 15:00:34 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Bobby Bingham wrote:
On Thu, 28 Feb 2008 00:18:59 +0100 (CET) koorogi <subversion@mplayerhq.hu> wrote:
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932
Log: Slice support for vf_scale.
Modified: libavfilter/vf_scale.c
[...]
After some more testing, it seems this doesn't work right with --enable-swscaler. I'll take a closer look at it later tonight. I was wondering one thing: imagine doing a 200x200 -> 400x400 linear interpolation resizing.
The filter gets as input a (for ex.) 4x100 slice. It can then interpolate the line numbers (1,2,3,4,5,6,7) of the output. For the next slice, it would be able to output the lines (9,10,11,12,13,14,15). But to evaluate the output line 8, it'll need both the input line 4 and 5. So to do slice-based resizing, it would be necessary a complicated, resize algorithm dependent, caching. Also it would require some kind of memcpy.
So my opinion is that implementing slices in resizing is hard and maybe not worth the effort. In the other hand, colospace conversion should be pretty simple. Or am I missing something?
I believe that this caching is already implemented by libswscale.
yes, swscale will do the horizontal scaling into a ring buffer of lines and then use that to do vertical scaling
Does imgresample.c also support this?
no, imgresample is trash [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates
On Sun, 02 Mar 2008 18:11:10 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Hi
Bobby Bingham wrote:
On Sun, 02 Mar 2008 15:00:34 +0100 Vitor Sessak <vitor1001@gmail.com> wrote:
Bobby Bingham wrote:
On Thu, 28 Feb 2008 00:18:59 +0100 (CET) koorogi <subversion@mplayerhq.hu> wrote:
Author: koorogi Date: Thu Feb 28 00:18:58 2008 New Revision: 1932
Log: Slice support for vf_scale.
Modified: libavfilter/vf_scale.c
[...]
After some more testing, it seems this doesn't work right with --enable-swscaler. I'll take a closer look at it later tonight. I was wondering one thing: imagine doing a 200x200 -> 400x400 linear interpolation resizing.
The filter gets as input a (for ex.) 4x100 slice. It can then interpolate the line numbers (1,2,3,4,5,6,7) of the output. For the next slice, it would be able to output the lines (9,10,11,12,13,14,15). But to evaluate the output line 8, it'll need both the input line 4 and 5. So to do slice-based resizing, it would be necessary a complicated, resize algorithm dependent, caching. Also it would require some kind of memcpy.
So my opinion is that implementing slices in resizing is hard and maybe not worth the effort. In the other hand, colospace conversion should be pretty simple. Or am I missing something?
I believe that this caching is already implemented by libswscale.
Does imgresample.c also support this?
It doesn't appear to. Hmmm... Maybe it's a good time to implement some flags to let filters tell the system that they require full-frame slices, and make vf_scale use that in the imgresample.c case. -- Bobby Bingham Never trust atoms. Or anything made of atoms. このメールは再利用されたバイトでできている。
participants (4)
-
Bobby Bingham -
koorogi -
Michael Niedermayer -
Vitor Sessak