[FFmpeg-devel] [PATCH] lavfi: add curves filter.

Clément Bœsch ubitux at gmail.com
Wed Mar 6 02:41:23 CET 2013


On Tue, Mar 05, 2013 at 11:34:10PM +0100, Nicolas George wrote:
> Le quintidi 15 ventôse, an CCXXI, Clement Boesch a écrit :
> > On Tue, Mar 05, 2013 at 08:01:42PM +0100, Nicolas George wrote:
> > > Le quintidi 15 ventôse, an CCXXI, Clement Boesch a écrit :
> > > > +    double *matrix = av_calloc(3 * n, sizeof(*matrix));
> > > > +    double *h = av_malloc((n - 1) * sizeof(*h));
> > > > +    double *r = av_calloc(n, sizeof(*r));
> > > 
> > > You could maybe make the code a little more readable by declaring the matrix
> > > as a bidimensional array: matrix[n][3] (since only the first dimension is
> > > variable, it can work).
> > > 
> > 
> > I didn't wanted to resurrect some VLA, nor replace 1 heap alloc with 3.
> 
> You need neither of these, you just need enough skill in
> C-pointer-declarationfu:
> 
> double (*matrix)[3] = av_malloc(n, sizeof(matrix));
> 
> This is exactly equivalent to your code except the compiler translates
> automatically matrix[i][j] into matrix[3 * i + j].
> 

Never used that trick, neat. Changed. I also used some more explicit
naming for the diagonals to prevent some confusions. Will send an updated
patch later. Thanks.

-- 
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/20130306/a1b1cb29/attachment.asc>


More information about the ffmpeg-devel mailing list