[FFmpeg-devel] [PATCH 2/2] lavfi/lut: simplify nested lut plane stepping.

Clément Bœsch ubitux at gmail.com
Thu Apr 18 04:04:56 CEST 2013


On Thu, Apr 18, 2013 at 10:00:33AM +0800, Wang Bin wrote:
> 2013/4/17 Clément Bœsch <ubitux at gmail.com>
> 
> > ---
> >  libavfilter/vf_lut.c | 14 +++++---------
> >  1 file changed, 5 insertions(+), 9 deletions(-)
> >
> > diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c
> > index be497ac..21309a5 100644
> > --- a/libavfilter/vf_lut.c
> > +++ b/libavfilter/vf_lut.c
> > @@ -286,15 +286,11 @@ static int filter_frame(AVFilterLink *inlink,
> > AVFrame *in)
> >              inrow  = inrow0;
> >              outrow = outrow0;
> >              for (j = 0; j < w; j++) {
> > -                outrow[0] = tab[0][inrow[0]];
> > -                if (lut->step>1) {
> > -                    outrow[1] = tab[1][inrow[1]];
> > -                    if (lut->step>2) {
> > -                        outrow[2] = tab[2][inrow[2]];
> > -                        if (lut->step>3) {
> > -                            outrow[3] = tab[3][inrow[3]];
> > -                        }
> > -                    }
> > +                switch (lut->step) {
> > +                case 3:  outrow[3] = tab[3][inrow[3]]; // Fall-through
> > +                case 2:  outrow[2] = tab[2][inrow[2]]; // Fall-through
> > +                case 1:  outrow[1] = tab[1][inrow[1]]; // Fall-through
> > +                default: outrow[0] = tab[0][inrow[0]];
> >                  }
> >                  outrow += lut->step;
> >                  inrow  += lut->step;
> >
> >
> I think this patch does not equals to the original code. For example, if
> lut->step == 3, the original code will run
> outrow[0] = tab[0][inrow[0]];
> outrow[1] = tab[1][inrow[1]];
> outrow[2] = tab[2][inrow[2]];
> but the patch code will only run
> outrow[3] = tab[3][inrow[3]];
> outrow[0] = tab[0][inrow[0]];
> I don't know which code is right, but i'm sure the result is different.

Yes, I messed up, but it was fortunately fixed by a benevolent spirit.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130418/68661fd0/attachment.asc>


More information about the ffmpeg-devel mailing list