[FFmpeg-devel] Channel mapping integration in af pan

Clément Bœsch ubitux at gmail.com
Wed Jan 18 17:54:25 CET 2012


On Wed, Jan 18, 2012 at 02:31:39PM +0100, Nicolas George wrote:
> Le nonidi 29 nivôse, an CCXX, Clément Bœsch a écrit :
> > +    // gains are pures, init the channel mapping array
> > +    if (pan->pure_gains) {
> > +        for (i = 0; i < pan->nb_output_channels; i++) {
> > +            int ch_id = -1;
> > +            for (j = 0; j < pan->nb_input_channels; j++) {
> > +                if (pan->gain.d[i][j]) {
> > 
> > If I replace this with "if (pan->gain.i[i][j]) {", it doesn't work as expected:
> > since the int are 32 bits and the gains are stored in double (64),
> > pan->gain.i[0][3] will evaluate the first gain (low 32 bits of the second
> > double) instead of the 3rd. That's how I understand the issue.
> 
> Oh, yes, I see. At that point, the coefficients are still stored as double,
> so you _must_ use them as such. Unions are not, in general, an automatic
> conversion system.
> 
> Imagine it was written that way:
> 
> 	gain_d = malloc(n * n * sizeof(double));
> 	/* before */
> 
> 	gain_i = malloc(n * n * sizeof(int));
> 	for (i, j)
> 	    gain_i[i][j] = 256 * gain_d[i][j];
> 	free(gain_d);
> 
> 	/* after */
> 
> In the "before" code, you can and must only use gain_d, and in the "after"
> code, you can and must only use gain_i.
> 

As you pointed out, I misunderstood the point of the union.

> > Playing with the spacing doesn't seem to help.
> 
> Then I will try to search what is wrong when I have time.
> 

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/20120118/a1e899bf/attachment.asc>


More information about the ffmpeg-devel mailing list