You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.4KB

  1. /*
  2. * Copyright (c) 2012 Mans Rullgard <mans@mansr.com>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <stdint.h>
  21. #undef FUNC
  22. #undef sample
  23. #if SAMPLE_SIZE == 32
  24. # define FUNC(n) n ## _32
  25. # define sample int32_t
  26. #else
  27. # define FUNC(n) n ## _16
  28. # define sample int16_t
  29. #endif
  30. static void FUNC(flac_decorrelate_indep_c)(uint8_t **out, int32_t **in,
  31. int channels, int len, int shift)
  32. {
  33. sample *samples = (sample *) out[0];
  34. int i, j;
  35. for (j = 0; j < len; j++)
  36. for (i = 0; i < channels; i++)
  37. *samples++ = in[i][j] << shift;
  38. }
  39. static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in,
  40. int channels, int len, int shift)
  41. {
  42. sample *samples = (sample *) out[0];
  43. int i;
  44. for (i = 0; i < len; i++) {
  45. int a = in[0][i];
  46. int b = in[1][i];
  47. *samples++ = a << shift;
  48. *samples++ = (a - b) << shift;
  49. }
  50. }
  51. static void FUNC(flac_decorrelate_rs_c)(uint8_t **out, int32_t **in,
  52. int channels, int len, int shift)
  53. {
  54. sample *samples = (sample *) out[0];
  55. int i;
  56. for (i = 0; i < len; i++) {
  57. int a = in[0][i];
  58. int b = in[1][i];
  59. *samples++ = (a + b) << shift;
  60. *samples++ = b << shift;
  61. }
  62. }
  63. static void FUNC(flac_decorrelate_ms_c)(uint8_t **out, int32_t **in,
  64. int channels, int len, int shift)
  65. {
  66. sample *samples = (sample *) out[0];
  67. int i;
  68. for (i = 0; i < len; i++) {
  69. int a = in[0][i];
  70. int b = in[1][i];
  71. a -= b >> 1;
  72. *samples++ = (a + b) << shift;
  73. *samples++ = a << shift;
  74. }
  75. }