2 AHI - Hardware independent audio subsystem
3 Copyright (C) 1996-2005 Martin Blom <martin@blom.org>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,
23 #include "addroutines.h"
25 typedef long long LONGLONG
;
27 /******************************************************************************
28 ** Add-Routines ***************************************************************
29 ******************************************************************************/
35 ** LONG *StartPointLeft
36 ** LONG *StartPointRight
49 The fraction offset is divided by two in order to make sure that the
50 calculation of linearsample fits a LONG (0 =< offsetf <= 32767).
52 The routines could be faster, of course. One idea is to split the for loop
53 into two loops in order to eliminate the FirstOffsetI test in the second loop.
57 /*****************************************************************************/
59 /* Forward mixing code */
61 #define offseti ( (long) ( offset >> 32 ) )
63 #define offsetf ( offset & 0xffffffffULL )
66 AddLongMono( ADDARGS
)
70 Fixed64 offset
= *Offset
;
72 LONG startpoint
, endpoint
= 0; // Make compiler happy
75 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
77 for( i
= 0; i
< Samples
; i
++)
79 if( offseti
== FirstOffsetI
) {
80 startpoint
= *StartPointLeft
<< 16;
84 startpoint
= src
[ offseti
- 1 ];
87 endpoint
= src
[ offseti
];
89 startpoint
+= (LONG
) (((LONGLONG
) (endpoint
- startpoint
) * offsetf
) >> 32);
92 ( ( lastpoint
< 0 && startpoint
>= 0 ) ||
93 ( lastpoint
> 0 && startpoint
<= 0 ) ) )
98 lastpoint
= startpoint
;
100 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpoint
) >> 16 );
105 *StartPointLeft
= endpoint
>> 16;
115 AddLongStereo( ADDARGS
)
119 Fixed64 offset
= *Offset
;
121 LONG startpoint
, endpoint
= 0; // Make compiler happy
124 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
126 for( i
= 0; i
< Samples
; i
++)
128 if( offseti
== FirstOffsetI
) {
129 startpoint
= *StartPointLeft
<< 16;
133 startpoint
= src
[ offseti
- 1 ];
136 endpoint
= src
[ offseti
];
138 startpoint
+= (LONG
) (((LONGLONG
) (endpoint
- startpoint
) * offsetf
) >> 32);
141 ( ( lastpoint
< 0 && startpoint
>= 0 ) ||
142 ( lastpoint
> 0 && startpoint
<= 0 ) ) )
147 lastpoint
= startpoint
;
149 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpoint
) >> 16 );
150 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleRight
* startpoint
) >> 16 );
155 *StartPointLeft
= endpoint
>> 16;
164 AddLongsMono( ADDARGS
)
168 Fixed64 offset
= *Offset
;
170 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
171 LONG lastpointL
, lastpointR
;
173 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
175 for( i
= 0; i
< Samples
; i
++)
177 if( offseti
== FirstOffsetI
) {
178 startpointL
= *StartPointLeft
<< 16;
179 startpointR
= *StartPointRight
<< 16;
183 startpointL
= src
[ offseti
* 2 + 0 - 2 ];
184 startpointR
= src
[ offseti
* 2 + 1 - 2 ];
187 endpointL
= src
[ offseti
* 2 + 0 ];
188 endpointR
= src
[ offseti
* 2 + 1 ];
190 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
191 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
194 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
195 ( lastpointR
< 0 && startpointR
>= 0 ) ||
196 ( lastpointL
> 0 && startpointL
<= 0 ) ||
197 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
202 lastpointL
= startpointL
;
203 lastpointR
= startpointR
;
205 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 )
206 + (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
211 *StartPointLeft
= endpointL
>> 16;
212 *StartPointRight
= endpointR
>> 16;
222 AddLongsStereo( ADDARGS
)
226 Fixed64 offset
= *Offset
;
228 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
229 LONG lastpointL
, lastpointR
;
231 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
233 for( i
= 0; i
< Samples
; i
++)
235 if( offseti
== FirstOffsetI
) {
236 startpointL
= *StartPointLeft
<< 16;
237 startpointR
= *StartPointRight
<< 16;
241 startpointL
= src
[ offseti
* 2 + 0 - 2 ];
242 startpointR
= src
[ offseti
* 2 + 1 - 2 ];
245 endpointL
= src
[ offseti
* 2 + 0 ];
246 endpointR
= src
[ offseti
* 2 + 1 ];
248 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
249 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
252 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
253 ( lastpointR
< 0 && startpointR
>= 0 ) ||
254 ( lastpointL
> 0 && startpointL
<= 0 ) ||
255 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
260 lastpointL
= startpointL
;
261 lastpointR
= startpointR
;
263 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 );
264 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
269 *StartPointLeft
= endpointL
>> 16;
270 *StartPointRight
= endpointR
>> 16;
284 Fixed64 offset
= *Offset
;
286 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
287 LONG lastpointL
, lastpointR
;
289 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
291 for( i
= 0; i
< Samples
; i
++)
293 if( offseti
== FirstOffsetI
) {
294 startpointL
= *StartPointLeft
<< 16;
295 startpointR
= *StartPointRight
<< 16;
299 startpointL
= src
[ offseti
* 8 + 0 - 8 ];
300 startpointR
= src
[ offseti
* 8 + 1 - 8 ];
303 endpointL
= src
[ offseti
* 8 + 0 ];
304 endpointR
= src
[ offseti
* 8 + 1 ];
306 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
307 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
310 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
311 ( lastpointR
< 0 && startpointR
>= 0 ) ||
312 ( lastpointL
> 0 && startpointL
<= 0 ) ||
313 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
318 lastpointL
= startpointL
;
319 lastpointR
= startpointR
;
321 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 )
322 + (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
327 *StartPointLeft
= endpointL
>> 16;
328 *StartPointRight
= endpointR
>> 16;
338 Add71Stereo( ADDARGS
)
342 Fixed64 offset
= *Offset
;
344 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
345 LONG lastpointL
, lastpointR
;
347 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
349 for( i
= 0; i
< Samples
; i
++)
351 if( offseti
== FirstOffsetI
) {
352 startpointL
= *StartPointLeft
<< 16;
353 startpointR
= *StartPointRight
<< 16;
357 startpointL
= src
[ offseti
* 8 + 0 - 8 ];
358 startpointR
= src
[ offseti
* 8 + 1 - 8 ];
361 endpointL
= src
[ offseti
* 8 + 0 ];
362 endpointR
= src
[ offseti
* 8 + 1 ];
364 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
365 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
368 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
369 ( lastpointR
< 0 && startpointR
>= 0 ) ||
370 ( lastpointL
> 0 && startpointL
<= 0 ) ||
371 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
376 lastpointL
= startpointL
;
377 lastpointR
= startpointR
;
379 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 );
380 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
385 *StartPointLeft
= endpointL
>> 16;
386 *StartPointRight
= endpointR
>> 16;
394 /*****************************************************************************/
396 /* Lofi mixing code */
399 AddLofiLongMono( ADDARGS
)
403 Fixed64 offset
= *Offset
;
405 LONG lastpoint
, sample
;
407 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
409 for( i
= 0; i
< Samples
; i
++)
411 sample
= src
[ offseti
] >> 16;
414 ( ( lastpoint
< 0 && sample
>= 0 ) ||
415 ( lastpoint
> 0 && sample
<= 0 ) ) )
422 *dst
++ += ( ScaleLeft
* sample
) >> 16;
435 AddLofiLongStereo( ADDARGS
)
439 Fixed64 offset
= *Offset
;
441 LONG lastpoint
, sample
;
443 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
445 for( i
= 0; i
< Samples
; i
++)
447 sample
= src
[ offseti
] >> 16;;
450 ( ( lastpoint
< 0 && sample
>= 0 ) ||
451 ( lastpoint
> 0 && sample
<= 0 ) ) )
458 *dst
++ += ( ScaleLeft
* sample
) >> 16;
459 *dst
++ += ( ScaleRight
* sample
) >> 16;
471 AddLofiLongsMono( ADDARGS
)
475 Fixed64 offset
= *Offset
;
477 LONG lastpointL
, lastpointR
, sampleL
, sampleR
;
479 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
481 for( i
= 0; i
< Samples
; i
++)
483 sampleL
= src
[ offseti
* 2 + 0 ] >> 16;;
484 sampleR
= src
[ offseti
* 2 + 1 ] >> 16;;
487 ( ( lastpointL
< 0 && sampleL
>= 0 ) ||
488 ( lastpointR
< 0 && sampleR
>= 0 ) ||
489 ( lastpointL
> 0 && sampleL
<= 0 ) ||
490 ( lastpointR
> 0 && sampleR
<= 0 ) ) )
495 lastpointL
= sampleL
;
496 lastpointR
= sampleR
;
498 *dst
++ += ( ScaleLeft
* sampleL
+ ScaleRight
* sampleR
) >> 16;
511 AddLofiLongsStereo( ADDARGS
)
515 Fixed64 offset
= *Offset
;
517 LONG lastpointL
, lastpointR
, sampleL
, sampleR
;
519 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
521 for( i
= 0; i
< Samples
; i
++)
523 sampleL
= src
[ offseti
* 2 + 0 ] >> 16;;
524 sampleR
= src
[ offseti
* 2 + 1 ] >> 16;;
527 ( ( lastpointL
< 0 && sampleL
>= 0 ) ||
528 ( lastpointR
< 0 && sampleR
>= 0 ) ||
529 ( lastpointL
> 0 && sampleL
<= 0 ) ||
530 ( lastpointR
> 0 && sampleR
<= 0 ) ) )
535 lastpointL
= sampleL
;
536 lastpointR
= sampleR
;
538 *dst
++ += ( ScaleLeft
* sampleL
) >> 16;
539 *dst
++ += ( ScaleRight
* sampleR
) >> 16;
554 /*****************************************************************************/
556 /* Backward mixing code */
558 #define offsetf ( (long) ( 32768 - ( (unsigned long) ( offset & 0xffffffffULL ) >> 17 ) ) )
561 AddLongMonoB( ADDARGS
)
565 Fixed64 offset
= *Offset
;
567 LONG startpoint
, endpoint
= 0; // Make compiler happy
570 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
572 for( i
= 0; i
< Samples
; i
++)
574 if( offseti
== FirstOffsetI
) {
575 startpoint
= *StartPointLeft
<< 16;
579 startpoint
= src
[ offseti
+ 1 ];
582 endpoint
= src
[ offseti
];
584 startpoint
+= (LONG
) (((LONGLONG
) (endpoint
- startpoint
) * offsetf
) >> 32);
587 ( ( lastpoint
< 0 && startpoint
>= 0 ) ||
588 ( lastpoint
> 0 && startpoint
<= 0 ) ) )
593 lastpoint
= startpoint
;
595 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpoint
) >> 16 );
600 *StartPointLeft
= endpoint
>> 16;
610 AddLongStereoB( ADDARGS
)
614 Fixed64 offset
= *Offset
;
616 LONG startpoint
, endpoint
= 0; // Make compiler happy
619 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
621 for( i
= 0; i
< Samples
; i
++)
623 if( offseti
== FirstOffsetI
) {
624 startpoint
= *StartPointLeft
<< 16;
628 startpoint
= src
[ offseti
+ 1 ];
631 endpoint
= src
[ offseti
];
633 startpoint
+= (LONG
) (((LONGLONG
) (endpoint
- startpoint
) * offsetf
) >> 32);
636 ( ( lastpoint
< 0 && startpoint
>= 0 ) ||
637 ( lastpoint
> 0 && startpoint
<= 0 ) ) )
642 lastpoint
= startpoint
;
644 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpoint
) >> 16 );
645 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleRight
* startpoint
) >> 16 );
650 *StartPointLeft
= endpoint
>> 16;
660 AddLongsMonoB( ADDARGS
)
664 Fixed64 offset
= *Offset
;
666 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
667 LONG lastpointL
, lastpointR
;
669 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
671 for( i
= 0; i
< Samples
; i
++)
673 if( offseti
== FirstOffsetI
) {
674 startpointL
= *StartPointLeft
<< 16;
675 startpointR
= *StartPointRight
<< 16;
679 startpointL
= src
[ offseti
* 2 + 0 + 2 ];
680 startpointR
= src
[ offseti
* 2 + 1 + 2 ];
683 endpointL
= src
[ offseti
* 2 + 0 ];
684 endpointR
= src
[ offseti
* 2 + 1 ];
686 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
687 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
690 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
691 ( lastpointR
< 0 && startpointR
>= 0 ) ||
692 ( lastpointL
> 0 && startpointL
<= 0 ) ||
693 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
698 lastpointL
= startpointL
;
699 lastpointR
= startpointR
;
701 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 ) +
702 (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
707 *StartPointLeft
= endpointL
>> 16;
708 *StartPointRight
= endpointR
>> 16;
718 AddLongsStereoB( ADDARGS
)
722 Fixed64 offset
= *Offset
;
724 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
725 LONG lastpointL
, lastpointR
;
727 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
729 for( i
= 0; i
< Samples
; i
++)
731 if( offseti
== FirstOffsetI
) {
732 startpointL
= *StartPointLeft
<< 16;
733 startpointR
= *StartPointRight
<< 16;
737 startpointL
= src
[ offseti
* 2 + 0 + 2 ];
738 startpointR
= src
[ offseti
* 2 + 1 + 2 ];
741 endpointL
= src
[ offseti
* 2 + 0 ];
742 endpointR
= src
[ offseti
* 2 + 1 ];
744 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
745 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
748 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
749 ( lastpointR
< 0 && startpointR
>= 0 ) ||
750 ( lastpointL
> 0 && startpointL
<= 0 ) ||
751 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
756 lastpointL
= startpointL
;
757 lastpointR
= startpointR
;
759 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 );
760 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
765 *StartPointLeft
= endpointL
>> 16;
766 *StartPointRight
= endpointR
>> 16;
776 Add71MonoB( ADDARGS
)
780 Fixed64 offset
= *Offset
;
782 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
783 LONG lastpointL
, lastpointR
;
785 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
787 for( i
= 0; i
< Samples
; i
++)
789 if( offseti
== FirstOffsetI
) {
790 startpointL
= *StartPointLeft
<< 16;
791 startpointR
= *StartPointRight
<< 16;
795 startpointL
= src
[ offseti
* 8 + 0 + 8 ];
796 startpointR
= src
[ offseti
* 8 + 1 + 8 ];
799 endpointL
= src
[ offseti
* 8 + 0 ];
800 endpointR
= src
[ offseti
* 8 + 1 ];
802 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
803 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
806 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
807 ( lastpointR
< 0 && startpointR
>= 0 ) ||
808 ( lastpointL
> 0 && startpointL
<= 0 ) ||
809 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
814 lastpointL
= startpointL
;
815 lastpointR
= startpointR
;
817 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 ) +
818 (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
823 *StartPointLeft
= endpointL
>> 16;
824 *StartPointRight
= endpointR
>> 16;
834 Add71StereoB( ADDARGS
)
838 Fixed64 offset
= *Offset
;
840 LONG startpointL
, startpointR
, endpointL
= 0, endpointR
= 0; // Make compiler happy
841 LONG lastpointL
, lastpointR
;
843 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
845 for( i
= 0; i
< Samples
; i
++)
847 if( offseti
== FirstOffsetI
) {
848 startpointL
= *StartPointLeft
<< 16;
849 startpointR
= *StartPointRight
<< 16;
853 startpointL
= src
[ offseti
* 8 + 0 + 8 ];
854 startpointR
= src
[ offseti
* 8 + 1 + 8 ];
857 endpointL
= src
[ offseti
* 8 + 0 ];
858 endpointR
= src
[ offseti
* 8 + 1 ];
860 startpointL
+= (LONG
) (((LONGLONG
) (endpointL
- startpointL
) * offsetf
) >> 32);
861 startpointR
+= (LONG
) (((LONGLONG
) (endpointR
- startpointR
) * offsetf
) >> 32);
864 ( ( lastpointL
< 0 && startpointL
>= 0 ) ||
865 ( lastpointR
< 0 && startpointR
>= 0 ) ||
866 ( lastpointL
> 0 && startpointL
<= 0 ) ||
867 ( lastpointR
> 0 && startpointR
<= 0 ) ) )
872 lastpointL
= startpointL
;
873 lastpointR
= startpointR
;
875 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleLeft
* startpointL
) >> 16 );
876 *dst
++ += (LONG
) ( ( (LONGLONG
) ScaleRight
* startpointR
) >> 16 );
881 *StartPointLeft
= endpointL
>> 16;
882 *StartPointRight
= endpointR
>> 16;
891 /*****************************************************************************/
893 /* Lofi mixing code */
896 AddLofiLongMonoB( ADDARGS
)
900 Fixed64 offset
= *Offset
;
902 LONG lastpoint
, sample
;
904 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
906 for( i
= 0; i
< Samples
; i
++)
908 sample
= src
[ offseti
] >> 16;;
911 ( ( lastpoint
< 0 && sample
>= 0 ) ||
912 ( lastpoint
> 0 && sample
<= 0 ) ) )
919 *dst
++ += ( ScaleLeft
* sample
) >> 16;
932 AddLofiLongStereoB( ADDARGS
)
936 Fixed64 offset
= *Offset
;
938 LONG lastpoint
, sample
;
940 lastpoint
= 0; // 0 doesn't affect the StopAtZero code
942 for( i
= 0; i
< Samples
; i
++)
944 sample
= src
[ offseti
] >> 16;;
947 ( ( lastpoint
< 0 && sample
>= 0 ) ||
948 ( lastpoint
> 0 && sample
<= 0 ) ) )
955 *dst
++ += ( ScaleLeft
* sample
) >> 16;
956 *dst
++ += ( ScaleRight
* sample
) >> 16;
969 AddLofiLongsMonoB( ADDARGS
)
973 Fixed64 offset
= *Offset
;
975 LONG lastpointL
, lastpointR
, sampleL
, sampleR
;
977 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
979 for( i
= 0; i
< Samples
; i
++)
981 sampleL
= src
[ offseti
* 2 + 0 ] >> 16;;
982 sampleR
= src
[ offseti
* 2 + 1 ] >> 16;;
985 ( ( lastpointL
< 0 && sampleL
>= 0 ) ||
986 ( lastpointR
< 0 && sampleR
>= 0 ) ||
987 ( lastpointL
> 0 && sampleL
<= 0 ) ||
988 ( lastpointR
> 0 && sampleR
<= 0 ) ) )
993 lastpointL
= sampleL
;
994 lastpointR
= sampleR
;
996 *dst
++ += ( ScaleLeft
* sampleL
+ ScaleRight
* sampleR
) >> 16;
1009 AddLofiLongsStereoB( ADDARGS
)
1013 Fixed64 offset
= *Offset
;
1015 LONG lastpointL
, lastpointR
, sampleL
, sampleR
;
1017 lastpointL
= lastpointR
= 0; // 0 doesn't affect the StopAtZero code
1019 for( i
= 0; i
< Samples
; i
++)
1021 sampleL
= src
[ offseti
* 2 + 0 ] >> 16;;
1022 sampleR
= src
[ offseti
* 2 + 1 ] >> 16;;
1025 ( ( lastpointL
< 0 && sampleL
>= 0 ) ||
1026 ( lastpointR
< 0 && sampleR
>= 0 ) ||
1027 ( lastpointL
> 0 && sampleL
<= 0 ) ||
1028 ( lastpointR
> 0 && sampleR
<= 0 ) ) )
1033 lastpointL
= sampleL
;
1034 lastpointR
= sampleR
;
1036 *dst
++ += ( ScaleLeft
* sampleL
) >> 16;
1037 *dst
++ += ( ScaleRight
* sampleR
) >> 16;
1052 /*****************************************************************************/