00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdint.h>
00022 #include "libavutil/avutil.h"
00023
00024 #undef FUNC
00025 #undef FSUF
00026 #undef sample
00027 #undef sample_type
00028 #undef OUT
00029 #undef S
00030
00031 #if SAMPLE_SIZE == 32
00032 # define sample_type int32_t
00033 #else
00034 # define sample_type int16_t
00035 #endif
00036
00037 #if PLANAR
00038 # define FSUF AV_JOIN(SAMPLE_SIZE, p)
00039 # define sample sample_type *
00040 # define OUT(n) n
00041 # define S(s, c, i) (s[c][i])
00042 #else
00043 # define FSUF SAMPLE_SIZE
00044 # define sample sample_type
00045 # define OUT(n) n[0]
00046 # define S(s, c, i) (*s++)
00047 #endif
00048
00049 #define FUNC(n) AV_JOIN(n ## _, FSUF)
00050
00051 static void FUNC(flac_decorrelate_indep_c)(uint8_t **out, int32_t **in,
00052 int channels, int len, int shift)
00053 {
00054 sample *samples = (sample *) OUT(out);
00055 int i, j;
00056
00057 for (j = 0; j < len; j++)
00058 for (i = 0; i < channels; i++)
00059 S(samples, i, j) = in[i][j] << shift;
00060 }
00061
00062 static void FUNC(flac_decorrelate_ls_c)(uint8_t **out, int32_t **in,
00063 int channels, int len, int shift)
00064 {
00065 sample *samples = (sample *) OUT(out);
00066 int i;
00067
00068 for (i = 0; i < len; i++) {
00069 int a = in[0][i];
00070 int b = in[1][i];
00071 S(samples, 0, i) = a << shift;
00072 S(samples, 1, i) = (a - b) << shift;
00073 }
00074 }
00075
00076 static void FUNC(flac_decorrelate_rs_c)(uint8_t **out, int32_t **in,
00077 int channels, int len, int shift)
00078 {
00079 sample *samples = (sample *) OUT(out);
00080 int i;
00081
00082 for (i = 0; i < len; i++) {
00083 int a = in[0][i];
00084 int b = in[1][i];
00085 S(samples, 0, i) = (a + b) << shift;
00086 S(samples, 1, i) = b << shift;
00087 }
00088 }
00089
00090 static void FUNC(flac_decorrelate_ms_c)(uint8_t **out, int32_t **in,
00091 int channels, int len, int shift)
00092 {
00093 sample *samples = (sample *) OUT(out);
00094 int i;
00095
00096 for (i = 0; i < len; i++) {
00097 int a = in[0][i];
00098 int b = in[1][i];
00099 a -= b >> 1;
00100 S(samples, 0, i) = (a + b) << shift;
00101 S(samples, 1, i) = a << shift;
00102 }
00103 }