[FFmpeg-soc] expand filter (alternative to pad syntax)

Michael Niedermayer michaelni at gmx.at
Thu May 15 19:07:49 CEST 2008


On Thu, May 15, 2008 at 11:30:15AM +0900, Ryo Hirafuji wrote:
> Here is a newer source.
> 
> > i suggest you use a single sscanf()
> I would use "sscanf" for args,but it doen't work well...
> 
> sscanf(arg,"%d:%d:%d:%d:%s:%s:%d",&a,&b,&c,&d,e,f,&g);
> 
> and input:
> 640:480:10:10:false:16/9:10
> 
> Results are:
> a=640
> b=480
> c=10
> d=10
> e="false:16/9:10"
> f,g -> not inputed.

as victor already suggested %[] can be used here ...


> 
> so I used strok_r for args.
> 
> 2008/5/11 Michael Niedermayer <michaelni at gmx.at>:
> >> +    if (expand->w == -1){
> >> +        expand->w=width;
> >> +    } else if (expand->w < -1){
> >> +        expand->w=width - expand->w;
> >> +    } else if (expand->w < width){
> >> +        expand->w=width;
> >> +    }
> >> +
> >> +    if (expand->h == -1){
> >> +        expand->h=height;
> >> +    } else if (expand->h < -1){
> >> +        expand->h=height - expand->h;
> >> +    } else if (expand->h < height){
> >> +        expand->h=height;
> >> +    }
> >
> > duplicate
> >> +    if(expand->x < 0 || (expand->x+width) > expand->w){
> >> +        expand->x = (expand->w - width)>>1;
> >> +    }
> >> +    if(expand->y < 0 || (expand->y+height) > expand->h){
> >> +        expand->y = (expand->h - height)>>1;
> >> +    }
> >
> > duplicate
> 
> Yes, they're duplicate,but it is more simple than they are merged, I think.


for(i=0; i<2; i++){
    if (expand->dim[i] < 0){
        expand->dim[i]= dim[i] - expand->dim[i];
    } else if (expand->dim[i] < dim[i]){
        expand->dim[i]= dim[i];
    }

    if(expand->off[i] < 0 || (expand->off[i]+dim[i]) > expand->dim[i])
        expand->off[i] = (expand->dim[i] - dim[i])>>1;
}

is very much simpler



> 
> > Iam pretty sure theres a generic way to find the byte per pixel which
> > does not require a long switch-case. pix_fmt_info after all does contain
> > the information.
> Oh, really?
> I think there are no way to access "pix_fmt_info".

there is always a way :)


> It is because "pix_fmt_info" is visible in only "libavcodec/imgconvert.c".
> So, for example,"vf_crop" filter is also finding the bytes per pixel
> with switch-case.

Code duplication is not acceptable in ffmpeg and always means patch rejection
so if there is no way to access the information from pix_fmt_info then
solution would be to add a way ...


> 
> > as with vmrsss, unconditional copying is not ok
> Other filters are also drawing images in the same way, aren't they?
> (For example,vf_drawbox.)

there is no memcpy() in vf_drawbox

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20080515/9a1b42d7/attachment.pgp>


More information about the FFmpeg-soc mailing list