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

Nicolas George nicolas.george at normalesup.org
Tue Mar 5 23:34:10 CET 2013


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].

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130305/4b29d888/attachment.asc>


More information about the ffmpeg-devel mailing list