From 2168884c177d844e82fd2c93fe9390e81549a5b9 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Wed, 24 Jul 2002 00:02:59 +0000 Subject: updated so it uses a dblptr matrix, and works Original commit message from CVS: updated so it uses a dblptr matrix, and works --- gst/mixmatrix/mixmatrix.c | 55 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 8 deletions(-) (limited to 'gst/mixmatrix/mixmatrix.c') diff --git a/gst/mixmatrix/mixmatrix.c b/gst/mixmatrix/mixmatrix.c index 92a95746..a8aaf330 100644 --- a/gst/mixmatrix/mixmatrix.c +++ b/gst/mixmatrix/mixmatrix.c @@ -33,7 +33,7 @@ struct _GstMixMatrix { GstPad **srcpads; gint srcpadalloc; - gfloat *matrix; + gfloat **matrix; }; struct _GstMixMatrixClass { @@ -169,6 +169,31 @@ gst_mixmatrix_class_init (GstMixMatrixClass *klass) gstelement_class->request_new_pad = gst_mixmatrix_request_new_pad; } +static gfloat ** +mixmatrix_alloc_matrix (int x,int y) +{ + gfloat **matrix; + int i; + fprintf(stderr,"allocating a %dx%d matrix of floats\n",x,y); + matrix = g_new(gfloat *,x); + fprintf(stderr,"%p: ",matrix); + for (i=0;isrcpads = g_new(GstPad *,mix->srcpadalloc); // allocate a similarly sized matrix - mix->matrix = g_new(gfloat, mix->sinkpadalloc * mix->srcpadalloc); + mix->matrix = mixmatrix_alloc_matrix(mix->sinkpadalloc,mix->srcpadalloc); // set the loop function that does all the work gst_element_set_loop_function(GST_ELEMENT(mix), gst_mixmatrix_loop); @@ -207,9 +232,11 @@ mixmatrix_resize(GstMixMatrix *mix, int sinkpads, int srcpads) int sinkresize = (sinkpads != mix->sinkpadalloc); int srcresize = (srcpads != mix->srcpadalloc); - gfloat *newmatrix; + gfloat **newmatrix; int i; + fprintf(stderr,"resizing matrix!!!!\n"); + // check the sinkpads list if (sinkresize) { mix->sinkpads = (GstPad **)grow_ptrlist((void **)mix->sinkpads,mix->sinkpadalloc,sinkpads); @@ -224,20 +251,20 @@ mixmatrix_resize(GstMixMatrix *mix, int sinkpads, int srcpads) // now resize the matrix if either has changed if (sinkresize || srcresize) { // allocate the new matrix - newmatrix = g_new(gfloat, sinkpads * srcpads); + newmatrix = mixmatrix_alloc_matrix(sinkpads,srcpads); // if only the srcpad count changed (y axis), we can just copy if (!sinkresize) { - memcpy(newmatrix,mix->matrix, sizeof(gfloat) * sinkpads * mix->srcpadalloc); + memcpy(newmatrix,mix->matrix,sizeof(gfloat *)*sinkpads); // otherwise we have to copy line by line } else { for (i=0;isrcpadalloc;i++) - memcpy(&newmatrix[i*sinkpads], &mix->matrix[i*mix->sinkpadalloc], mix->srcpadalloc); + memcpy(newmatrix[i], mix->matrix[i], sizeof(gfloat) * mix->srcpadalloc); } // would signal here! // free old matrix and replace it - g_free(mix->matrix); + mixmatrix_free_matrix(mix->matrix, mix->sinkpadalloc); mix->matrix = newmatrix; } @@ -385,7 +412,18 @@ gst_mixmatrix_loop (GstElement *element) // loop through each src pad for (j=0;jsrcpadalloc;j++) { if (mix->srcpads[j] != NULL) { - gain = mix->matrix[j + i*mix->srcpadalloc]; +/* +{ + int z; + fprintf(stderr,"matrix is %p: ",mix->matrix); + for (z=0;zsinkpadalloc;z++) + fprintf(stderr,"%p, ",mix->matrix[i]); + fprintf(stderr,"\n"); +} +fprintf(stderr,"attempting to get gain for %dx%d\n",i,j); +*/ + gain = mix->matrix[i][j]; +// fprintf(stderr,"%d->%d=%0.2f ",i,j,gain); for (k=0;koutsize;k++) { outfloats[j][k] += infloats[i][k] * gain; } @@ -393,6 +431,7 @@ gst_mixmatrix_loop (GstElement *element) } } } +// fprintf(stderr,"\n"); for (i=0;isrcpadalloc;i++) { if (mix->srcpads[i] != NULL) { -- cgit v1.2.1