1/*-
2 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 45 unchanged lines hidden (view full) ---
54#endif
55#include <dev/sound/pcm/sound.h>
56#include <dev/sound/pcm/pcm.h>
57#include "feeder_if.h"
58
59#define SND_USE_FXDIV
60#include "snd_fxdiv_gen.h"
61
62SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/feeder_rate.c 195519 2009-07-09 22:21:18Z ariff $");
63#endif
64
65#include "feeder_rate_gen.h"
66
67#if !defined(_KERNEL) && defined(SND_DIAGNOSTIC)
68#undef Z_DIAGNOSTIC
69#define Z_DIAGNOSTIC 1
70#elif defined(_KERNEL)
--- 713 unchanged lines hidden (view full) ---
784 * Pick suitable polynomial interpolators based on filter oversampled ratio
785 * (2 ^ Z_DRIFT_SHIFT).
786 */
787#if !(defined(Z_COEFF_INTERP_ZOH) || defined(Z_COEFF_INTERP_LINEAR) || \
788 defined(Z_COEFF_INTERP_QUADRATIC) || defined(Z_COEFF_INTERP_HERMITE) || \
789 defined(Z_COEFF_INTER_BSPLINE) || defined(Z_COEFF_INTERP_OPT32X) || \
790 defined(Z_COEFF_INTERP_OPT16X) || defined(Z_COEFF_INTERP_OPT8X) || \
791 defined(Z_COEFF_INTERP_OPT4X) || defined(Z_COEFF_INTERP_OPT2X))
792#if Z_DRIFT_SHIFT >= 12
793#define Z_COEFF_INTERP_LINEAR 1
794#elif Z_DRIFT_SHIFT >= 8
795#define Z_COEFF_INTERP_QUADRATIC 1
796#elif Z_DRIFT_SHIFT >= 5
797#define Z_COEFF_INTERP_OPT32X 1
798#elif Z_DRIFT_SHIFT == 4
799#define Z_COEFF_INTERP_OPT16X 1
800#elif Z_DRIFT_SHIFT == 3
801#define Z_COEFF_INTERP_OPT8X 1
802#elif Z_DRIFT_SHIFT == 2
803#define Z_COEFF_INTERP_OPT4X 1
--- 26 unchanged lines hidden (view full) ---
830 coeff = z_coeff[0];
831#elif defined(Z_COEFF_INTERP_LINEAR)
832 int32_t zl0, zl1;
833
834 /* 2-point, 1st-order Linear */
835 zl0 = z_coeff[0];
836 zl1 = z_coeff[1] - z_coeff[0];
837
838 coeff = (((int64_t)zl1 * z) >> Z_SHIFT) + zl0;
839#elif defined(Z_COEFF_INTERP_QUADRATIC)
840 int32_t zq0, zq1, zq2;
841
842 /* 3-point, 2nd-order Quadratic */
843 zq0 = z_coeff[0];
844 zq1 = z_coeff[1] - z_coeff[-1];
845 zq2 = z_coeff[1] + z_coeff[-1] - (z_coeff[0] << 1);
846
847 coeff = ((((((int64_t)zq2 * z) >> Z_SHIFT) +
848 zq1) * z) >> (Z_SHIFT + 1)) + zq0;
849#elif defined(Z_COEFF_INTERP_HERMITE)
850 int32_t zh0, zh1, zh2, zh3;
851
852 /* 4-point, 3rd-order Hermite */
853 zh0 = z_coeff[0];
854 zh1 = z_coeff[1] - z_coeff[-1];
855 zh2 = (z_coeff[-1] << 1) - (z_coeff[0] * 5) + (z_coeff[1] << 2) -
856 z_coeff[2];
857 zh3 = z_coeff[2] - z_coeff[-1] + ((z_coeff[0] - z_coeff[1]) * 3);
858
859 coeff = (((((((((int64_t)zh3 * z) >> Z_SHIFT) +
860 zh2) * z) >> Z_SHIFT) + zh1) * z) >> (Z_SHIFT + 1)) + zh0;
861#elif defined(Z_COEFF_INTERP_BSPLINE)
862 int32_t zb0, zb1, zb2, zb3;
863
864 /* 4-point, 3rd-order B-Spline */
865 zb0 = (((int64_t)z_coeff[0] << 2) + z_coeff[-1] + z_coeff[1]) / 3;
866 zb1 = z_coeff[1] - z_coeff[-1];
867 zb2 = z_coeff[-1] + z_coeff[1] - (z_coeff[0] << 1);
868 zb3 = (((z_coeff[0] - z_coeff[1]) * 3) + z_coeff[2] - z_coeff[-1]) / 3;
869
870 coeff = ((((((((((int64_t)zb3 * z) >> Z_SHIFT) +
871 zb2) * z) >> Z_SHIFT) + zb1) * z) >> Z_SHIFT) + zb0) >> 1;
872#elif defined(Z_COEFF_INTERP_OPT32X)
873 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
874 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
875
876 /* 6-point, 5th-order Optimal 32x */
877 zoz = z - (Z_ONE >> 1);
878 zoe1 = z_coeff[1] + z_coeff[0];
879 zoe2 = z_coeff[2] + z_coeff[-1];
880 zoe3 = z_coeff[3] + z_coeff[-2];
881 zoo1 = z_coeff[1] - z_coeff[0];
882 zoo2 = z_coeff[2] - z_coeff[-1];
883 zoo3 = z_coeff[3] - z_coeff[-2];
884
885 zoc0 = ((0x1ac2260dLL * zoe1) + (0x0526cdcaLL * zoe2) +
886 (0x00170c29LL * zoe3)) >> 30;
887 zoc1 = ((0x14f8a49aLL * zoo1) + (0x0d6d1109LL * zoo2) +
888 (0x008cd4dcLL * zoo3)) >> 30;
889 zoc2 = ((-0x0d3e94a4LL * zoe1) + (0x0bddded4LL * zoe2) +
890 (0x0160b5d0LL * zoe3)) >> 30;
891 zoc3 = ((-0x0de10cc4LL * zoo1) + (0x019b2a7dLL * zoo2) +
892 (0x01cfe914LL * zoo3)) >> 30;
893 zoc4 = ((0x02aa12d7LL * zoe1) + (-0x03ff1bb3LL * zoe2) +
894 (0x015508ddLL * zoe3)) >> 30;
895 zoc5 = ((0x051d29e5LL * zoo1) + (-0x028e7647LL * zoo2) +
896 (0x0082d81aLL * zoo3)) >> 30;
897
898 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
899 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
900 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
901#elif defined(Z_COEFF_INTERP_OPT16X)
902 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
903 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
904
905 /* 6-point, 5th-order Optimal 16x */
906 zoz = z - (Z_ONE >> 1);
907 zoe1 = z_coeff[1] + z_coeff[0];
908 zoe2 = z_coeff[2] + z_coeff[-1];
909 zoe3 = z_coeff[3] + z_coeff[-2];
910 zoo1 = z_coeff[1] - z_coeff[0];
911 zoo2 = z_coeff[2] - z_coeff[-1];
912 zoo3 = z_coeff[3] - z_coeff[-2];
913
914 zoc0 = ((0x1ac2260dLL * zoe1) + (0x0526cdcaLL * zoe2) +
915 (0x00170c29LL * zoe3)) >> 30;
916 zoc1 = ((0x14f8a49aLL * zoo1) + (0x0d6d1109LL * zoo2) +
917 (0x008cd4dcLL * zoo3)) >> 30;
918 zoc2 = ((-0x0d3e94a4LL * zoe1) + (0x0bddded4LL * zoe2) +
919 (0x0160b5d0LL * zoe3)) >> 30;
920 zoc3 = ((-0x0de10cc4LL * zoo1) + (0x019b2a7dLL * zoo2) +
921 (0x01cfe914LL * zoo3)) >> 30;
922 zoc4 = ((0x02aa12d7LL * zoe1) + (-0x03ff1bb3LL * zoe2) +
923 (0x015508ddLL * zoe3)) >> 30;
924 zoc5 = ((0x051d29e5LL * zoo1) + (-0x028e7647LL * zoo2) +
925 (0x0082d81aLL * zoo3)) >> 30;
926
927 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
928 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
929 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
930#elif defined(Z_COEFF_INTERP_OPT8X)
931 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
932 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
933
934 /* 6-point, 5th-order Optimal 8x */
935 zoz = z - (Z_ONE >> 1);
936 zoe1 = z_coeff[1] + z_coeff[0];
937 zoe2 = z_coeff[2] + z_coeff[-1];
938 zoe3 = z_coeff[3] + z_coeff[-2];
939 zoo1 = z_coeff[1] - z_coeff[0];
940 zoo2 = z_coeff[2] - z_coeff[-1];
941 zoo3 = z_coeff[3] - z_coeff[-2];
942
943 zoc0 = ((0x1aa9b47dLL * zoe1) + (0x053d9944LL * zoe2) +
944 (0x0018b23fLL * zoe3)) >> 30;
945 zoc1 = ((0x14a104d1LL * zoo1) + (0x0d7d2504LL * zoo2) +
946 (0x0094b599LL * zoo3)) >> 30;
947 zoc2 = ((-0x0d22530bLL * zoe1) + (0x0bb37a2cLL * zoe2) +
948 (0x016ed8e0LL * zoe3)) >> 30;
949 zoc3 = ((-0x0d744b1cLL * zoo1) + (0x01649591LL * zoo2) +
950 (0x01dae93aLL * zoo3)) >> 30;
951 zoc4 = ((0x02a7ee1bLL * zoe1) + (-0x03fbdb24LL * zoe2) +
952 (0x0153ed07LL * zoe3)) >> 30;
953 zoc5 = ((0x04cf9b6cLL * zoo1) + (-0x0266b378LL * zoo2) +
954 (0x007a7c26LL * zoo3)) >> 30;
955
956 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
957 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
958 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
959#elif defined(Z_COEFF_INTERP_OPT4X)
960 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
961 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
962
963 /* 6-point, 5th-order Optimal 4x */
964 zoz = z - (Z_ONE >> 1);
965 zoe1 = z_coeff[1] + z_coeff[0];
966 zoe2 = z_coeff[2] + z_coeff[-1];
967 zoe3 = z_coeff[3] + z_coeff[-2];
968 zoo1 = z_coeff[1] - z_coeff[0];
969 zoo2 = z_coeff[2] - z_coeff[-1];
970 zoo3 = z_coeff[3] - z_coeff[-2];
971
972 zoc0 = ((0x1a8eda43LL * zoe1) + (0x0556ee38LL * zoe2) +
973 (0x001a3784LL * zoe3)) >> 30;
974 zoc1 = ((0x143d863eLL * zoo1) + (0x0d910e36LL * zoo2) +
975 (0x009ca889LL * zoo3)) >> 30;
976 zoc2 = ((-0x0d026821LL * zoe1) + (0x0b837773LL * zoe2) +
977 (0x017ef0c6LL * zoe3)) >> 30;
978 zoc3 = ((-0x0cef1502LL * zoo1) + (0x01207a8eLL * zoo2) +
979 (0x01e936dbLL * zoo3)) >> 30;
980 zoc4 = ((0x029fe643LL * zoe1) + (-0x03ef3fc8LL * zoe2) +
981 (0x014f5923LL * zoe3)) >> 30;
982 zoc5 = ((0x043a9d08LL * zoo1) + (-0x02154febLL * zoo2) +
983 (0x00670dbdLL * zoo3)) >> 30;
984
985 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
986 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
987 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
988#elif defined(Z_COEFF_INTERP_OPT2X)
989 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
990 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
991
992 /* 6-point, 5th-order Optimal 2x */
993 zoz = z - (Z_ONE >> 1);
994 zoe1 = z_coeff[1] + z_coeff[0];
995 zoe2 = z_coeff[2] + z_coeff[-1];
996 zoe3 = z_coeff[3] + z_coeff[-2];
997 zoo1 = z_coeff[1] - z_coeff[0];
998 zoo2 = z_coeff[2] - z_coeff[-1];
999 zoo3 = z_coeff[3] - z_coeff[-2];
1000
1001 zoc0 = ((0x19edb6fdLL * zoe1) + (0x05ebd062LL * zoe2) +
1002 (0x00267881LL * zoe3)) >> 30;
1003 zoc1 = ((0x1223af76LL * zoo1) + (0x0de3dd6bLL * zoo2) +
1004 (0x00d683cdLL * zoo3)) >> 30;
1005 zoc2 = ((-0x0c3ee068LL * zoe1) + (0x0a5c3769LL * zoe2) +
1006 (0x01e2aceaLL * zoe3)) >> 30;
1007 zoc3 = ((-0x0a8ab614LL * zoo1) + (-0x0019522eLL * zoo2) +
1008 (0x022cefc7LL * zoo3)) >> 30;
1009 zoc4 = ((0x0276187dLL * zoe1) + (-0x03a801e8LL * zoe2) +
1010 (0x0131d935LL * zoe3)) >> 30;
1011 zoc5 = ((0x02c373f5LL * zoo1) + (-0x01275f83LL * zoo2) +
1012 (0x0018ee79LL * zoo3)) >> 30;
1013
1014 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
1015 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
1016 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
1017#else
1018#error "Interpolation type screwed!"
1019#endif
1020
1021#if Z_POLYPHASE_COEFF_SHIFT > 0
1022 coeff = Z_RSHIFT(coeff, Z_POLYPHASE_COEFF_SHIFT);
1023#endif
1024 return (coeff);
--- 714 unchanged lines hidden ---
2 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 45 unchanged lines hidden (view full) ---
54#endif
55#include <dev/sound/pcm/sound.h>
56#include <dev/sound/pcm/pcm.h>
57#include "feeder_if.h"
58
59#define SND_USE_FXDIV
60#include "snd_fxdiv_gen.h"
61
62SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/feeder_rate.c 195519 2009-07-09 22:21:18Z ariff $");
63#endif
64
65#include "feeder_rate_gen.h"
66
67#if !defined(_KERNEL) && defined(SND_DIAGNOSTIC)
68#undef Z_DIAGNOSTIC
69#define Z_DIAGNOSTIC 1
70#elif defined(_KERNEL)
--- 713 unchanged lines hidden (view full) ---
784 * Pick suitable polynomial interpolators based on filter oversampled ratio
785 * (2 ^ Z_DRIFT_SHIFT).
786 */
787#if !(defined(Z_COEFF_INTERP_ZOH) || defined(Z_COEFF_INTERP_LINEAR) || \
788 defined(Z_COEFF_INTERP_QUADRATIC) || defined(Z_COEFF_INTERP_HERMITE) || \
789 defined(Z_COEFF_INTER_BSPLINE) || defined(Z_COEFF_INTERP_OPT32X) || \
790 defined(Z_COEFF_INTERP_OPT16X) || defined(Z_COEFF_INTERP_OPT8X) || \
791 defined(Z_COEFF_INTERP_OPT4X) || defined(Z_COEFF_INTERP_OPT2X))
792#if Z_DRIFT_SHIFT >= 12
793#define Z_COEFF_INTERP_LINEAR 1
794#elif Z_DRIFT_SHIFT >= 8
795#define Z_COEFF_INTERP_QUADRATIC 1
796#elif Z_DRIFT_SHIFT >= 5
797#define Z_COEFF_INTERP_OPT32X 1
798#elif Z_DRIFT_SHIFT == 4
799#define Z_COEFF_INTERP_OPT16X 1
800#elif Z_DRIFT_SHIFT == 3
801#define Z_COEFF_INTERP_OPT8X 1
802#elif Z_DRIFT_SHIFT == 2
803#define Z_COEFF_INTERP_OPT4X 1
--- 26 unchanged lines hidden (view full) ---
830 coeff = z_coeff[0];
831#elif defined(Z_COEFF_INTERP_LINEAR)
832 int32_t zl0, zl1;
833
834 /* 2-point, 1st-order Linear */
835 zl0 = z_coeff[0];
836 zl1 = z_coeff[1] - z_coeff[0];
837
838 coeff = (((int64_t)zl1 * z) >> Z_SHIFT) + zl0;
839#elif defined(Z_COEFF_INTERP_QUADRATIC)
840 int32_t zq0, zq1, zq2;
841
842 /* 3-point, 2nd-order Quadratic */
843 zq0 = z_coeff[0];
844 zq1 = z_coeff[1] - z_coeff[-1];
845 zq2 = z_coeff[1] + z_coeff[-1] - (z_coeff[0] << 1);
846
847 coeff = ((((((int64_t)zq2 * z) >> Z_SHIFT) +
848 zq1) * z) >> (Z_SHIFT + 1)) + zq0;
849#elif defined(Z_COEFF_INTERP_HERMITE)
850 int32_t zh0, zh1, zh2, zh3;
851
852 /* 4-point, 3rd-order Hermite */
853 zh0 = z_coeff[0];
854 zh1 = z_coeff[1] - z_coeff[-1];
855 zh2 = (z_coeff[-1] << 1) - (z_coeff[0] * 5) + (z_coeff[1] << 2) -
856 z_coeff[2];
857 zh3 = z_coeff[2] - z_coeff[-1] + ((z_coeff[0] - z_coeff[1]) * 3);
858
859 coeff = (((((((((int64_t)zh3 * z) >> Z_SHIFT) +
860 zh2) * z) >> Z_SHIFT) + zh1) * z) >> (Z_SHIFT + 1)) + zh0;
861#elif defined(Z_COEFF_INTERP_BSPLINE)
862 int32_t zb0, zb1, zb2, zb3;
863
864 /* 4-point, 3rd-order B-Spline */
865 zb0 = (((int64_t)z_coeff[0] << 2) + z_coeff[-1] + z_coeff[1]) / 3;
866 zb1 = z_coeff[1] - z_coeff[-1];
867 zb2 = z_coeff[-1] + z_coeff[1] - (z_coeff[0] << 1);
868 zb3 = (((z_coeff[0] - z_coeff[1]) * 3) + z_coeff[2] - z_coeff[-1]) / 3;
869
870 coeff = ((((((((((int64_t)zb3 * z) >> Z_SHIFT) +
871 zb2) * z) >> Z_SHIFT) + zb1) * z) >> Z_SHIFT) + zb0) >> 1;
872#elif defined(Z_COEFF_INTERP_OPT32X)
873 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
874 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
875
876 /* 6-point, 5th-order Optimal 32x */
877 zoz = z - (Z_ONE >> 1);
878 zoe1 = z_coeff[1] + z_coeff[0];
879 zoe2 = z_coeff[2] + z_coeff[-1];
880 zoe3 = z_coeff[3] + z_coeff[-2];
881 zoo1 = z_coeff[1] - z_coeff[0];
882 zoo2 = z_coeff[2] - z_coeff[-1];
883 zoo3 = z_coeff[3] - z_coeff[-2];
884
885 zoc0 = ((0x1ac2260dLL * zoe1) + (0x0526cdcaLL * zoe2) +
886 (0x00170c29LL * zoe3)) >> 30;
887 zoc1 = ((0x14f8a49aLL * zoo1) + (0x0d6d1109LL * zoo2) +
888 (0x008cd4dcLL * zoo3)) >> 30;
889 zoc2 = ((-0x0d3e94a4LL * zoe1) + (0x0bddded4LL * zoe2) +
890 (0x0160b5d0LL * zoe3)) >> 30;
891 zoc3 = ((-0x0de10cc4LL * zoo1) + (0x019b2a7dLL * zoo2) +
892 (0x01cfe914LL * zoo3)) >> 30;
893 zoc4 = ((0x02aa12d7LL * zoe1) + (-0x03ff1bb3LL * zoe2) +
894 (0x015508ddLL * zoe3)) >> 30;
895 zoc5 = ((0x051d29e5LL * zoo1) + (-0x028e7647LL * zoo2) +
896 (0x0082d81aLL * zoo3)) >> 30;
897
898 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
899 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
900 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
901#elif defined(Z_COEFF_INTERP_OPT16X)
902 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
903 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
904
905 /* 6-point, 5th-order Optimal 16x */
906 zoz = z - (Z_ONE >> 1);
907 zoe1 = z_coeff[1] + z_coeff[0];
908 zoe2 = z_coeff[2] + z_coeff[-1];
909 zoe3 = z_coeff[3] + z_coeff[-2];
910 zoo1 = z_coeff[1] - z_coeff[0];
911 zoo2 = z_coeff[2] - z_coeff[-1];
912 zoo3 = z_coeff[3] - z_coeff[-2];
913
914 zoc0 = ((0x1ac2260dLL * zoe1) + (0x0526cdcaLL * zoe2) +
915 (0x00170c29LL * zoe3)) >> 30;
916 zoc1 = ((0x14f8a49aLL * zoo1) + (0x0d6d1109LL * zoo2) +
917 (0x008cd4dcLL * zoo3)) >> 30;
918 zoc2 = ((-0x0d3e94a4LL * zoe1) + (0x0bddded4LL * zoe2) +
919 (0x0160b5d0LL * zoe3)) >> 30;
920 zoc3 = ((-0x0de10cc4LL * zoo1) + (0x019b2a7dLL * zoo2) +
921 (0x01cfe914LL * zoo3)) >> 30;
922 zoc4 = ((0x02aa12d7LL * zoe1) + (-0x03ff1bb3LL * zoe2) +
923 (0x015508ddLL * zoe3)) >> 30;
924 zoc5 = ((0x051d29e5LL * zoo1) + (-0x028e7647LL * zoo2) +
925 (0x0082d81aLL * zoo3)) >> 30;
926
927 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
928 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
929 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
930#elif defined(Z_COEFF_INTERP_OPT8X)
931 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
932 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
933
934 /* 6-point, 5th-order Optimal 8x */
935 zoz = z - (Z_ONE >> 1);
936 zoe1 = z_coeff[1] + z_coeff[0];
937 zoe2 = z_coeff[2] + z_coeff[-1];
938 zoe3 = z_coeff[3] + z_coeff[-2];
939 zoo1 = z_coeff[1] - z_coeff[0];
940 zoo2 = z_coeff[2] - z_coeff[-1];
941 zoo3 = z_coeff[3] - z_coeff[-2];
942
943 zoc0 = ((0x1aa9b47dLL * zoe1) + (0x053d9944LL * zoe2) +
944 (0x0018b23fLL * zoe3)) >> 30;
945 zoc1 = ((0x14a104d1LL * zoo1) + (0x0d7d2504LL * zoo2) +
946 (0x0094b599LL * zoo3)) >> 30;
947 zoc2 = ((-0x0d22530bLL * zoe1) + (0x0bb37a2cLL * zoe2) +
948 (0x016ed8e0LL * zoe3)) >> 30;
949 zoc3 = ((-0x0d744b1cLL * zoo1) + (0x01649591LL * zoo2) +
950 (0x01dae93aLL * zoo3)) >> 30;
951 zoc4 = ((0x02a7ee1bLL * zoe1) + (-0x03fbdb24LL * zoe2) +
952 (0x0153ed07LL * zoe3)) >> 30;
953 zoc5 = ((0x04cf9b6cLL * zoo1) + (-0x0266b378LL * zoo2) +
954 (0x007a7c26LL * zoo3)) >> 30;
955
956 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
957 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
958 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
959#elif defined(Z_COEFF_INTERP_OPT4X)
960 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
961 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
962
963 /* 6-point, 5th-order Optimal 4x */
964 zoz = z - (Z_ONE >> 1);
965 zoe1 = z_coeff[1] + z_coeff[0];
966 zoe2 = z_coeff[2] + z_coeff[-1];
967 zoe3 = z_coeff[3] + z_coeff[-2];
968 zoo1 = z_coeff[1] - z_coeff[0];
969 zoo2 = z_coeff[2] - z_coeff[-1];
970 zoo3 = z_coeff[3] - z_coeff[-2];
971
972 zoc0 = ((0x1a8eda43LL * zoe1) + (0x0556ee38LL * zoe2) +
973 (0x001a3784LL * zoe3)) >> 30;
974 zoc1 = ((0x143d863eLL * zoo1) + (0x0d910e36LL * zoo2) +
975 (0x009ca889LL * zoo3)) >> 30;
976 zoc2 = ((-0x0d026821LL * zoe1) + (0x0b837773LL * zoe2) +
977 (0x017ef0c6LL * zoe3)) >> 30;
978 zoc3 = ((-0x0cef1502LL * zoo1) + (0x01207a8eLL * zoo2) +
979 (0x01e936dbLL * zoo3)) >> 30;
980 zoc4 = ((0x029fe643LL * zoe1) + (-0x03ef3fc8LL * zoe2) +
981 (0x014f5923LL * zoe3)) >> 30;
982 zoc5 = ((0x043a9d08LL * zoo1) + (-0x02154febLL * zoo2) +
983 (0x00670dbdLL * zoo3)) >> 30;
984
985 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
986 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
987 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
988#elif defined(Z_COEFF_INTERP_OPT2X)
989 int32_t zoz, zoe1, zoe2, zoe3, zoo1, zoo2, zoo3;
990 int32_t zoc0, zoc1, zoc2, zoc3, zoc4, zoc5;
991
992 /* 6-point, 5th-order Optimal 2x */
993 zoz = z - (Z_ONE >> 1);
994 zoe1 = z_coeff[1] + z_coeff[0];
995 zoe2 = z_coeff[2] + z_coeff[-1];
996 zoe3 = z_coeff[3] + z_coeff[-2];
997 zoo1 = z_coeff[1] - z_coeff[0];
998 zoo2 = z_coeff[2] - z_coeff[-1];
999 zoo3 = z_coeff[3] - z_coeff[-2];
1000
1001 zoc0 = ((0x19edb6fdLL * zoe1) + (0x05ebd062LL * zoe2) +
1002 (0x00267881LL * zoe3)) >> 30;
1003 zoc1 = ((0x1223af76LL * zoo1) + (0x0de3dd6bLL * zoo2) +
1004 (0x00d683cdLL * zoo3)) >> 30;
1005 zoc2 = ((-0x0c3ee068LL * zoe1) + (0x0a5c3769LL * zoe2) +
1006 (0x01e2aceaLL * zoe3)) >> 30;
1007 zoc3 = ((-0x0a8ab614LL * zoo1) + (-0x0019522eLL * zoo2) +
1008 (0x022cefc7LL * zoo3)) >> 30;
1009 zoc4 = ((0x0276187dLL * zoe1) + (-0x03a801e8LL * zoe2) +
1010 (0x0131d935LL * zoe3)) >> 30;
1011 zoc5 = ((0x02c373f5LL * zoo1) + (-0x01275f83LL * zoo2) +
1012 (0x0018ee79LL * zoo3)) >> 30;
1013
1014 coeff = (((((((((((((((int64_t)zoc5 * zoz) >> Z_SHIFT) +
1015 zoc4) * zoz) >> Z_SHIFT) + zoc3) * zoz) >> Z_SHIFT) +
1016 zoc2) * zoz) >> Z_SHIFT) + zoc1) * zoz) >> Z_SHIFT) + zoc0;
1017#else
1018#error "Interpolation type screwed!"
1019#endif
1020
1021#if Z_POLYPHASE_COEFF_SHIFT > 0
1022 coeff = Z_RSHIFT(coeff, Z_POLYPHASE_COEFF_SHIFT);
1023#endif
1024 return (coeff);
--- 714 unchanged lines hidden ---