Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 144382 Details for
Bug 195561
openal-0.0.8-r2 has a problem with ut2004
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
media-libs/openal/files/0.0.8/006_all_convert.patch
006_all_convert.patch (text/plain), 17.95 KB, created by
Sergey Belyashov
on 2008-02-22 20:25:47 UTC
(
hide
)
Description:
media-libs/openal/files/0.0.8/006_all_convert.patch
Filename:
MIME Type:
Creator:
Sergey Belyashov
Created:
2008-02-22 20:25:47 UTC
Size:
17.95 KB
patch
obsolete
>Index: src/audioconvert/ac_channels.c >=================================================================== >--- src/audioconvert/ac_channels.c (revision 1451) >+++ src/audioconvert/ac_channels.c (revision 1452) >@@ -14,7 +14,8 @@ > #include "audioconvert/audioconvert.h" > > /* Duplicate a mono channel to both stereo channels */ >-void acConvertStereo(acAudioCVT *cvt, ALushort format) { >+void acConvertStereo(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > > if((format & 0xFF) == 16) { >@@ -44,15 +45,17 @@ > } > } > >+ channels *= 2; > cvt->len_cvt *= 2; > > if ( cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > > /* Effectively mix right and left channels into a single channel */ >-void acConvertMono(acAudioCVT *cvt, ALushort format) { >+void acConvertMono(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > ALint sample; > >@@ -194,9 +197,11 @@ > } > break; > } >+ >+ channels /= 2; > cvt->len_cvt /= 2; > > if ( cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } >Index: src/audioconvert/ac_freq.c >=================================================================== >--- src/audioconvert/ac_freq.c (revision 1451) >+++ src/audioconvert/ac_freq.c (revision 1452) >@@ -15,8 +15,9 @@ > #include "audioconvert/audioconvert.h" > > /* Convert rate up by multiple of 2 */ >-void acFreqMUL2(acAudioCVT *cvt, ALushort format) { >- int i; >+void acFreqMUL2(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ >+ int i, j; > ALubyte *src, *dst; > src = (ALubyte *) cvt->buf + cvt->len_cvt; > dst = (ALubyte *) cvt->buf + cvt->len_cvt * 2; >@@ -25,108 +26,144 @@ > case 8: > if (format == AUDIO_U8) { > ALubyte *src8 = (ALubyte*) src; >- ALubyte *dst8 = (ALubyte*) dst; >- src8 -= 1; >- dst8 -= 2; >+ ALubyte *dst8 = (ALubyte*) dst - channels; > /* For the first sample to be processed (last sample > in the buffer) there's no 'next' sample in the > buffer to interpolate against. So we use a value > extrapolated (then dampened) from the previous > sample in the buffer; this dampens (but doesn't > eliminate :() the 'click' of the first sample. */ >- if (cvt->len_cvt >= 2) { >- int ex; /* extrapolated sample, damped */ >- ex = src8[0] + (src8[0]-(int)src8[-1])/8; >- if ( ex > 255 ) >- ex = 255; >- else if ( ex < 0 ) >- ex = 0; >- dst8[0] = src8[0]; >- dst8[1] = ex; >- for ( i=cvt->len_cvt-1; i; --i ) { >+ if (cvt->len_cvt >= channels*2) { >+ for( i=channels; i; --i) { >+ int ex; /* extrapolated sample, damped */ > src8 -= 1; >- dst8 -= 2; >+ dst8 -= 1; >+ ex = src8[0] + (src8[0]-(int)src8[-channels])/8; >+ if ( ex > 255 ) >+ ex = 255; >+ else if ( ex < 0 ) >+ ex = 0; > dst8[0] = src8[0]; >- dst8[1] = (src8[0]+(int)src8[1])/2; >+ dst8[channels] = ex; > } >- } else if (cvt->len_cvt == 1) { >- dst8[0] = src8[0]; >- dst8[1] = src8[0]; >+ for ( i=cvt->len_cvt-channels; i; ) { >+ dst8 -= channels; >+ for( j=channels; j; --j,--i) { >+ src8 -= 1; >+ dst8 -= 1; >+ dst8[0] = src8[0]; >+ dst8[channels] = (src8[0]+(int)src8[channels])/2; >+ } >+ } >+ } else if (cvt->len_cvt >= channels*1) { >+ for( i=channels; i; --i) { >+ src8 -= 1; >+ dst8 -= 1; >+ dst8[0] = src8[0]; >+ dst8[channels] = src8[0]; >+ } > } > } else if (format == AUDIO_S8) { > ALbyte *src8 = (ALbyte*) src; >- ALbyte *dst8 = (ALbyte*) dst; >- src8 -= 1; >- dst8 -= 2; >- if (cvt->len_cvt >= 2) { >- int ex; /* extrapolated sample, damped */ >- ex = src8[0] + (src8[0]-(int)src8[-1])/8; >- if ( ex > 127 ) >- ex = 127; >- else if ( ex < -128 ) >- ex = -128; >- dst8[0] = src8[0]; >- dst8[1] = ex; >- for ( i=cvt->len_cvt-1; i; --i ) { >+ ALbyte *dst8 = (ALbyte*) dst - channels; >+ if (cvt->len_cvt >= channels*2) { >+ for( i=channels; i; --i) { >+ int ex; /* extrapolated sample, damped */ > src8 -= 1; >- dst8 -= 2; >+ dst8 -= 1; >+ ex = src8[0] + (src8[0]-(int)src8[-channels])/8; >+ if ( ex > 127 ) >+ ex = 127; >+ else if ( ex < -128 ) >+ ex = -128; > dst8[0] = src8[0]; >- dst8[1] = (src8[0]+(int)src8[1])/2; >+ dst8[channels] = ex; > } >- } else { >- dst8[0] = src8[0]; >- dst8[1] = src8[0]; >+ for ( i=cvt->len_cvt-channels; i; ) { >+ dst8 -= channels; >+ for( j=channels; j; --j,--i) { >+ src8 -= 1; >+ dst8 -= 1; >+ dst8[0] = src8[0]; >+ dst8[channels] = (src8[0]+(int)src8[channels])/2; >+ } >+ } >+ } else if (cvt->len_cvt >= channels*1) { >+ for( i=channels; i; --i) { >+ src8 -= 1; >+ dst8 -= 1; >+ dst8[0] = src8[0]; >+ dst8[channels] = src8[0]; >+ } > } > } > break; > case 16: > if (format == AUDIO_S16) { > ALshort *src16 = (ALshort*) src; >- ALshort *dst16 = (ALshort*) dst; >- src16 -= 1; >- dst16 -= 2; >- if (cvt->len_cvt >= 4) { >- int ex; /* extrapolated sample, damped */ >- ex = src16[0] + (src16[0]-(int)src16[-1])/8; >- if ( ex > 32767 ) >- ex = 32767; >- else if ( ex < -32768 ) >- ex = -32768; >- dst16[0] = src16[0]; >- dst16[1] = ex; >- for ( i=cvt->len_cvt/2-1; i; --i ) { >+ ALshort *dst16 = (ALshort*) dst - channels; >+ if (cvt->len_cvt >= channels*4) { >+ for ( i=channels; i; --i ) { >+ int ex; /* extrapolated sample, damped */ > src16 -= 1; >- dst16 -= 2; >+ dst16 -= 1; >+ ex = src16[0] + (src16[0]-(int)src16[-channels])/8; >+ if ( ex > 32767 ) >+ ex = 32767; >+ else if ( ex < -32768 ) >+ ex = -32768; > dst16[0] = src16[0]; >- dst16[1] = (src16[0]+(int)src16[1])/2; >+ dst16[channels] = ex; > } >- } else if (cvt->len_cvt == 2) { >- dst16[0] = src16[0]; >- dst16[1] = src16[0]; >+ for ( i=cvt->len_cvt/2-channels; i; ) { >+ dst16 -= channels; >+ for( j=channels; j; --j,--i) { >+ src16 -= 1; >+ dst16 -= 1; >+ dst16[0] = src16[0]; >+ dst16[channels] = (src16[0]+(int)src16[channels])/2; >+ } >+ } >+ } else if (cvt->len_cvt >= channels*2) { >+ for( i=channels; i; --i) { >+ src16 -= 1; >+ dst16 -= 1; >+ dst16[0] = src16[0]; >+ dst16[channels] = src16[0]; >+ } > } > } else if (format == AUDIO_U16) { > ALushort *src16 = (ALushort*) src; >- ALushort *dst16 = (ALushort*) dst; >- src16 -= 1; >- dst16 -= 2; >- if (cvt->len_cvt >= 4) { >- int ex; /* extrapolated sample, damped */ >- ex = src16[0] + (src16[0]-(int)src16[-1])/8; >- if ( ex > 65535 ) >- ex = 65535; >- else if ( ex < 0 ) >- ex = 0; >- dst16[0] = src16[0]; >- dst16[1] = ex; >- for ( i=cvt->len_cvt/2-1; i; --i ) { >+ ALushort *dst16 = (ALushort*) dst - channels; >+ if (cvt->len_cvt >= channels*4) { >+ for( i=channels; i; --i) { >+ int ex; /* extrapolated sample, damped */ >+ ex = src16[0] + (src16[0]-(int)src16[-channels])/8; > src16 -= 1; >- dst16 -= 2; >+ dst16 -= 1; >+ if ( ex > 65535 ) >+ ex = 65535; >+ else if ( ex < 0 ) >+ ex = 0; > dst16[0] = src16[0]; >- dst16[1] = (src16[0]+(int)src16[1])/2; >+ dst16[channels] = ex; > } >- } else if (cvt->len_cvt == 2) { >- dst16[0] = src16[0]; >- dst16[1] = src16[0]; >+ for ( i=cvt->len_cvt/2-channels; i; ) { >+ dst16 -= channels; >+ for( j=channels; j; --j,--i) { >+ src16 -= 1; >+ dst16 -= 1; >+ dst16[0] = src16[0]; >+ dst16[channels] = (src16[0]+(int)src16[channels])/2; >+ } >+ } >+ } else if (cvt->len_cvt >= channels*2) { >+ for( i=channels; i; --i) { >+ src16 -= 1; >+ dst16 -= 1; >+ dst16[0] = src16[0]; >+ dst16[channels] = src16[0]; >+ } > } > } else { > /* this is a 16-bit format that doesn't correspond >@@ -136,11 +173,14 @@ > future work. */ > ALushort *src16 = (ALushort*) src; > ALushort *dst16 = (ALushort*) dst; >- for ( i=cvt->len_cvt/2; i; --i ) { >- src16 -= 1; >- dst16 -= 2; >- dst16[0] = src16[0]; >- dst16[1] = src16[0]; >+ for ( i=cvt->len_cvt/2; i; ) { >+ dst16 -= channels; >+ for( j=channels; j; --j,--i) { >+ src16 -= 1; >+ dst16 -= 1; >+ dst16[0] = src16[0]; >+ dst16[channels] = src16[0]; >+ } > } > } > break; >@@ -148,31 +188,38 @@ > cvt->len_cvt *= 2; > > if (cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > > /* Convert rate down by multiple of 2 */ >-void acFreqDIV2(acAudioCVT *cvt, ALushort format) { >- int i; >+void acFreqDIV2(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ >+ int i, j; > ALubyte *src, *dst; > > src = cvt->buf; > dst = cvt->buf; > switch(format & 0xFF) { > case 8: >- for ( i=cvt->len_cvt/2; i; --i ) { >- dst[0] = src[0]; >- src += 2; >- dst += 1; >+ for ( i=cvt->len_cvt/2; i; ) { >+ for ( j=channels; j; --j,--i ) { >+ dst[0] = src[0]; >+ src += 1; >+ dst += 1; >+ } >+ src += channels; > } > break; > case 16: >- for ( i=cvt->len_cvt/4; i; --i ) { >- dst[0] = src[0]; >- dst[1] = src[1]; >- src += 4; >- dst += 2; >+ for ( i=cvt->len_cvt/4; i; ) { >+ for ( j=channels; j; --j,--i ) { >+ dst[0] = src[0]; >+ dst[1] = src[1]; >+ src += 2; >+ dst += 2; >+ } >+ src += channels*2; > } > break; > } >@@ -180,27 +227,30 @@ > cvt->len_cvt /= 2; > > if (cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > > /* Very slow rate conversion routine */ >-void acFreqSLOW(acAudioCVT *cvt, ALushort format) { >+void acFreqSLOW(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > double ipos; >- int i, clen; >+ int i, j, clen; > >- clen = (int) ((double)cvt->len_cvt / cvt->rate_incr); >+ clen = (int) ((double)((int)cvt->len_cvt / channels) / cvt->rate_incr); > if(cvt->rate_incr > 1.0) { > switch(format & 0xFF) { > case 8: { >- ALubyte *output; >+ ALubyte *output = cvt->buf; > >- output = cvt->buf; >+ clen *= channels; > ipos = 0.0; >- for ( i=clen; i; --i ) { >- *output = *((ALubyte *) cvt->buf + (int)ipos); >+ for ( i=clen; i; ) { >+ for ( j=0; j<channels; ++j,--i ) { >+ *output=((ALubyte *)cvt->buf)[(int)ipos * channels + j]; >+ output += 1; >+ } > ipos += cvt->rate_incr; >- output += 1; > } > } > break; >@@ -209,12 +259,15 @@ > ALushort *output; > > clen &= ~1; >+ clen *= channels; > output = (ALushort *) cvt->buf; > ipos = 0.0; >- for ( i=clen/2; i; --i ) { >- *output=((ALushort *)cvt->buf)[(int)ipos]; >+ for ( i=clen/2; i; ) { >+ for ( j=0; j<channels; ++j,--i ) { >+ *output=((ALushort *)cvt->buf)[(int)ipos * channels + j]; >+ output += 1; >+ } > ipos += cvt->rate_incr; >- output += 1; > } > } > break; >@@ -229,12 +282,15 @@ > case 8: { > ALubyte *output; > >+ clen *= channels; > output = (ALubyte *) cvt->buf + clen; >- ipos = (double)cvt->len_cvt; >- for ( i=clen; i; --i ) { >+ ipos = (double)(cvt->len_cvt / channels); >+ for ( i=clen; i; ) { >+ for ( j=0; j<channels; ++j,--i ) { >+ output -= 1; >+ *output=((ALubyte *)cvt->buf)[(int)ipos * channels - j - 1]; >+ } > ipos -= cvt->rate_incr; >- output -= 1; >- *output = *((ALubyte *) cvt->buf + (int)ipos); > } > } > break; >@@ -243,14 +299,17 @@ > ALushort *output; > > clen &= ~1; >+ clen *= channels; > output = (ALushort *) cvt->buf; > output += clen / sizeof *output; > >- ipos = (double)cvt->len_cvt/2; >- for ( i=clen/2; i; --i ) { >+ ipos = (double)(cvt->len_cvt/2/channels); >+ for ( i=clen/2; i; ) { >+ for ( j=0; j<channels; ++j,--i ) { >+ output -= 1; >+ *output=((ALushort *)cvt->buf)[(int)ipos * channels - j - 1]; >+ } > ipos -= cvt->rate_incr; >- output -= 1; >- *output=((ALushort *)cvt->buf)[(int)ipos]; > } > } > break; >@@ -264,6 +323,6 @@ > cvt->len_cvt = clen; > > if (cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } >Index: src/audioconvert/ac_helper.c >=================================================================== >--- src/audioconvert/ac_helper.c (revision 1451) >+++ src/audioconvert/ac_helper.c (revision 1452) >@@ -21,11 +21,12 @@ > > #include "audioconvert/audioconvert.h" > >-void acConvertSign(acAudioCVT *cvt, ALushort format); >-void acConvertEndian(acAudioCVT *cvt, ALushort format); >+void acConvertSign(acAudioCVT *cvt, ALushort format, ALushort channels); >+void acConvertEndian(acAudioCVT *cvt, ALushort format, ALushort channels); > > /* Toggle signed/unsigned */ >-void acConvertSign(acAudioCVT *cvt, ALushort format) { >+void acConvertSign(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > ALubyte *data; > >@@ -48,12 +49,13 @@ > format = (format ^ 0x8000); > > if (cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > > /* Toggle endianness */ >-void acConvertEndian(acAudioCVT *cvt, ALushort format) { >+void acConvertEndian(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > ALubyte *data, tmp; > >@@ -68,7 +70,7 @@ > format = (format ^ 0x1000); > > if (cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > >@@ -88,6 +90,10 @@ > cvt->filters[0] = NULL; > cvt->len_mult = 1; > cvt->len_ratio = 1.0; >+ cvt->src_format = src_format; >+ cvt->dst_format = dst_format; >+ cvt->src_channels = src_channels; >+ cvt->dst_channels = dst_channels; > > /* First filter: Endian conversion from src to dst */ > if((( src_format & 0x1000) != (dst_format & 0x1000)) && >@@ -159,7 +165,7 @@ > ALuint hi_rate, lo_rate; > int len_mult; > double len_ratio; >- void (*rate_cvt)(acAudioCVT *, ALushort ); >+ void (*rate_cvt)(acAudioCVT *, ALushort, ALushort); > > assert(src_rate != 0); > >@@ -210,11 +216,9 @@ > > /* Set up the filter information */ > if(cvt->filter_index != 0) { >- cvt->needed = 1; >- cvt->len = 0; >- cvt->buf = NULL; >- cvt->src_format = src_format; >- cvt->dst_format = dst_format; >+ cvt->needed = 1; >+ cvt->len = 0; >+ cvt->buf = NULL; > cvt->filters[cvt->filter_index] = NULL; > } > >@@ -241,7 +245,7 @@ > > /* Set up the conversion and go! */ > cvt->filter_index = 0; >- cvt->filters[0](cvt, cvt->src_format); >+ cvt->filters[0](cvt, cvt->src_format, cvt->src_channels); > > return 0; > } >Index: src/audioconvert/ac_bits.c >=================================================================== >--- src/audioconvert/ac_bits.c (revision 1451) >+++ src/audioconvert/ac_bits.c (revision 1452) >@@ -13,7 +13,8 @@ > #include "audioconvert/audioconvert.h" > > /* Convert 8-bit to 16-bit - LSB */ >-void acConvert16LSB( acAudioCVT *cvt, ALushort format ) { >+void acConvert16LSB(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > ALubyte *src, *dst; > >@@ -30,12 +31,13 @@ > cvt->len_cvt *= 2; > > if ( cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > > /* Convert 8-bit to 16-bit - MSB */ >-void acConvert16MSB(acAudioCVT *cvt, ALushort format) { >+void acConvert16MSB(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > ALubyte *src, *dst; > >@@ -52,12 +54,13 @@ > cvt->len_cvt *= 2; > > if ( cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } > > /* Convert 16-bit to 8-bit */ >-void acConvert8(acAudioCVT *cvt, ALushort format) { >+void acConvert8(acAudioCVT *cvt, ALushort format, ALushort channels) >+{ > int i; > ALubyte *src, *dst; > >@@ -78,6 +81,6 @@ > cvt->len_cvt /= 2; > > if ( cvt->filters[++cvt->filter_index] ) { >- cvt->filters[cvt->filter_index](cvt, format); >+ cvt->filters[cvt->filter_index](cvt, format, channels); > } > } >Index: src/audioconvert/audioconvert.h >=================================================================== >--- src/audioconvert/audioconvert.h (revision 1451) >+++ src/audioconvert/audioconvert.h (revision 1452) >@@ -16,13 +16,15 @@ > int needed; /* Set to 1 if conversion possible */ > ALushort src_format; /* Source audio format */ > ALushort dst_format; /* Target audio format */ >+ ALushort src_channels; /* Source channel count */ >+ ALushort dst_channels; /* Target channel count */ > double rate_incr; /* Rate conversion increment */ > void *buf; /* Buffer to hold entire audio data */ > int len; /* Length of original audio buffer */ > int len_cvt; /* Length of converted audio buffer */ > int len_mult; /* buffer must be len*len_mult big */ > double len_ratio; /* Given len, final size is len*len_ratio */ >- void (*filters[10])(struct _acAudioCVT *cvt, ALushort format); >+ void (*filters[10])(struct _acAudioCVT *cvt, ALushort format, ALushort channels); > int filter_index; /* Current audio conversion function */ > } acAudioCVT; > >@@ -47,18 +49,18 @@ > #define acFormatBits(fmt) (fmt & 0xff) > > /* bit changes */ >-void acConvert16MSB(acAudioCVT *cvt, ALushort format); >-void acConvert16LSB(acAudioCVT *cvt, ALushort format); >-void acConvert8(acAudioCVT *cvt, ALushort format); >+void acConvert16MSB(acAudioCVT *cvt, ALushort format, ALushort channels); >+void acConvert16LSB(acAudioCVT *cvt, ALushort format, ALushort channels); >+void acConvert8(acAudioCVT *cvt, ALushort format, ALushort channels); > > /* frequency changes */ >-void acFreqMUL2(acAudioCVT *cvt, ALushort format); >-void acFreqDIV2(acAudioCVT *cvt, ALushort format); >-void acFreqSLOW(acAudioCVT *cvt, ALushort format); >+void acFreqMUL2(acAudioCVT *cvt, ALushort format, ALushort channels); >+void acFreqDIV2(acAudioCVT *cvt, ALushort format, ALushort channels); >+void acFreqSLOW(acAudioCVT *cvt, ALushort format, ALushort channels); > > /* channel changes */ >-void acConvertStereo(acAudioCVT *cvt, ALushort format); >-void acConvertMono(acAudioCVT *cvt, ALushort format); >+void acConvertStereo(acAudioCVT *cvt, ALushort format, ALushort channels); >+void acConvertMono(acAudioCVT *cvt, ALushort format, ALushort channels); > > /* misc */ > int ac_is_wave(void *data);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 195561
: 144382